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

refactor: The main function and some writes what I think is a better practice #68

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

uptutu
Copy link

@uptutu uptutu commented Oct 9, 2022

Thanks for this repo. I have learnt a lot from it.

I have also tried to modify some of the code to my current knowledge to try to make the whole repository more like a Go project as I know it.

I look forward to discussing some of the relevant changes with you under this PR.

ref: uber-go style guide

@Ajilagi
Copy link

Ajilagi commented Oct 9, 2022

to bring the project closer to the Go project

What&which "Go project" do you mean? I think there is no standard project layout that initially came from Go / Go authors.

@uptutu
Copy link
Author

uptutu commented Oct 9, 2022

What&which "Go project" do you mean? I think there is no standard project layout that initially came from Go / Go authors.

This is a good question, it is true that there is no official standard, and what I have is simply a style that I think is better, I guess.

Like what this repo is showing, or trying to express, I'm just relying on some of the knowledge that I have and doing what I think is a better practice.

I am very sorry for my title. This is very careless.

@uptutu uptutu changed the title refactor: The main functions and some writes have been refactored to bring the project closer to the Go project refactor: The main function and some writes what I think is a better practice Oct 9, 2022
@bxcodec
Copy link
Owner

bxcodec commented Dec 9, 2022

What do you think about applying the GolangCI linter?
Would it be help?

Comment on lines +49 to +53
defer func() {
if err := dbConn.Close(); err != nil {
log.Fatal(err)
}
}()
Copy link
Owner

@bxcodec bxcodec Dec 9, 2022

Choose a reason for hiding this comment

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

I think this is not correct, it will close the DB connection immediately when this function is called.

What you can do instead is pass the DBconn as a parameter.
And the DB close function can be called in after the server exit.

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.

3 participants