Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for interacting with remote file servers #1061

Closed
wants to merge 25 commits into from

Conversation

RahulMohanK
Copy link
Contributor

Pull Request Template

Description:

Additional Information:

  • This PR includes the usage of AddFileStore function to configure a remote file server in gofr and uses the api's available to interact with the remote directory.

Checklist:

  • I have formatted my code using goimport and golangci-lint.
  • All new code is covered by unit tests.
  • This PR does not decrease the overall code coverage.
  • I have reviewed the code comments and documentation for clarity.

Thank you for your contribution!

Copy link
Contributor

@srijan-27 srijan-27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are failing, please check. Also while fixing please update the branch as well.

examples/using-add-filestore/configs/.env Outdated Show resolved Hide resolved
examples/using-add-filestore/README.md Outdated Show resolved Hide resolved
examples/using-add-filestore/main.go Outdated Show resolved Hide resolved
@Umang01-hash
Copy link
Contributor

@RahulMohanK please resolve the review comments given by @srijan-27.

Thankyou

@RahulMohanK
Copy link
Contributor Author

@srijan-27 @Umang01-hash Resolved the issue with the unit tests.
Test coverage of current branch :
total: (statements) 88.6%
Previously ftp module dependencies for running the example were added into gofr.dev module which was not the right approach. So created a separate module for using-add-filestore to isolate the dependencies.

@RahulMohanK RahulMohanK requested a review from srijan-27 October 6, 2024 17:36
Copy link
Contributor

@Umang01-hash Umang01-hash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RahulMohanK the PR looks good but i would suggest to add some spacing in the file main_test.go to improve the readability of code.
(Variable declaratrion, catching logs and assertions, you can separate them using proper spacing).

Also i saw the we have used var logger logging.Logger as a global variable in the file main.go. We should be avoiding this and instead pass logger in the function/method wherever required.

@RahulMohanK
Copy link
Contributor Author

@Umang01-hash Refactored test file to increase the readability of the code. Passing logger into function instead of declaring a global variable.
Thanks for the comments!!

examples/using-add-filestore/main.go Outdated Show resolved Hide resolved
examples/using-add-filestore/main.go Outdated Show resolved Hide resolved
@Umang01-hash
Copy link
Contributor

@RahulMohanK there are a few review comments left by @aryanmehrotra. Please address them

examples/using-add-filestore/main.go Outdated Show resolved Hide resolved
examples/using-add-filestore/main.go Show resolved Hide resolved
@vipul-rawat
Copy link
Member

@RahulMohanK could you please resolve the review comments left by @aryanmehrotra and @shashank-zopsmart? I think they raised some key code and quality issues with the PR.
Thanks for your contribution.

Comment on lines +47 to +53
if err != nil {
fmt.Println(err)
} else {
printFiles(files)
}

return "", err

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err != nil {
fmt.Println(err)
} else {
printFiles(files)
}
return "", err
if err != nil {
return fmt.Sprintf("failed to read directory: %s", path), err
}
printFiles(files)
return "", nil

Comment on lines +62 to +69
if err != nil {
fmt.Println(err)
} else {
grepFiles(files, keyword)

}

return "", err

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to previous comment

Comment on lines +77 to +81
if err == nil {
return fmt.Sprintln("Successfully created file:", fileName), nil
}

return fmt.Sprintln("File Creation error"), err

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err == nil {
return fmt.Sprintln("Successfully created file:", fileName), nil
}
return fmt.Sprintln("File Creation error"), err
if err != nil {
return fmt.Sprintln("File Creation error"), err
}
return fmt.Sprintln("Successfully created file:", fileName), nil

Comment on lines +89 to +93
if err == nil {
return fmt.Sprintln("Successfully removed file:", fileName), nil
}

return fmt.Sprintln("File removal error"), err

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to previous comment

@vipul-rawat
Copy link
Member

@RahulMohanK can you address the review changes

@Umang01-hash
Copy link
Contributor

The work of this PR has been addressed in PR #1177.
Closing here due to inactivity.

Thankyou for your valuable contribution @RahulMohanK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Example for using interacting with files
6 participants