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

Use gofmt/goimports #203

Closed
TheBestPessimist opened this issue Sep 19, 2017 · 14 comments
Closed

Use gofmt/goimports #203

TheBestPessimist opened this issue Sep 19, 2017 · 14 comments

Comments

@TheBestPessimist
Copy link
Contributor

Hello,

Firstly i hope i won't sound rude, this is more of a question/enhancement than a bug.

I have finally started working on #123 and #124 and i am using intellij idea as my ide.
I see that in your code you are not using gofmt and goimports, and because of this my file(s) look rather different compared to yours.

For example, one particular change is that gofmt uses tabs (i think that's horrible and whoever thought of this should feel really bad) instead of spaces.

My question is: would you like to use gofmt and goimports on your code, and then push a new version, just with these changes, or should we just figure out and stick to your indentation rules?

@gilbertchen
Copy link
Owner

I was mostly a C++ developer before building Duplicacy so you may find many c++ styles in the code.

I would like to hear other people's opinions.

@tbain98
Copy link

tbain98 commented Sep 20, 2017

I'm primarily a Java developer who uses Eclipse, which has the ability to customize how your code is formatted. That both helps standardize coding conventions on a project (which is a very good thing) and allows every project to set its own crazy standard that you then have to retrain your brain to when you switch to a new project.

Tabs vs. spaces is a religious war that no one will win (though everyone will agree that you shouldn't mix them for indentation purposes), and the fact that Go uses them instead of spaces means that you have to switch your brain when you switch between languages. BUT having all Go programs do things the same would mean that at least you don't have to retrain your brain when you switch from one Go-based project to another, and it should theoretically mean that tools that mechanically change the code should work more reliably. So since that seems to be the community-accepted standard way to do things, I'm in favor of making that the standard.

If it's fast enough (and the codebase is small enough), I'd propose linting the code on each push to the GitHub repo (can that be done?) to reject any PR merge that doesn't conform. If that's a bridge too far, then at least have a CI server such as Jenkins lint the codebase asynchronously after every commit and treat lint failures as a test failure.

@TheBestPessimist
Copy link
Contributor Author

Yeah @tbain98, this is what i was thinking as well: even though i don't like it (im a spaces guy), i think that we (this project) should use the official go formatting standard.

@gilbertchen
Copy link
Owner

Just checked in 923cd0a.

@TheBestPessimist
Copy link
Contributor Author

Goimports should do a little bit more than gofmt, hence i think it should be all right.
I can't check this now, maybe tonight, but most likely next week.

@TheBestPessimist
Copy link
Contributor Author

Just checked now and i see that something still isn't all right.

The only problem is line endings: i see that in some files clrf is used (windows) but at least in my case, goimports changes that to lf (linux).

i am using go 1.9, with all the libraries new.

I am raising this problem since it is possible that files will be modified in git, and actually nothing will be shown in the diff. (both in source tree and in intellij files are shown as modified, but the diff shows no differences)

@tbain98
Copy link

tbain98 commented Sep 21, 2017 via email

@leftytennis
Copy link
Contributor

Now I need to figure out how to configure vi so that I use tabs instead of spaces for go files... :)

@tbain98
Copy link

tbain98 commented Sep 22, 2017 via email

@leftytennis
Copy link
Contributor

A commit hook would be better for that I would think.

@gilbertchen
Copy link
Owner

$file duplicacy/duplicacy_main.go  src/*.go
duplicacy/duplicacy_main.go:           ASCII text
src/duplicacy_acdclient.go:            ASCII text
src/duplicacy_acdclient_test.go:       ASCII text
src/duplicacy_acdstorage.go:           ASCII text
src/duplicacy_azurestorage.go:         ASCII text
src/duplicacy_b2client.go:             ASCII text
src/duplicacy_b2client_test.go:        ASCII text
src/duplicacy_b2storage.go:            BSD makefile script text, ASCII text
src/duplicacy_backupmanager.go:        ASCII text
src/duplicacy_backupmanager_test.go:   ASCII text
src/duplicacy_chunk.go:                ASCII text
src/duplicacy_chunk_test.go:           ASCII text
src/duplicacy_chunkdownloader.go:      ASCII text
src/duplicacy_chunkmaker.go:           ASCII text
src/duplicacy_chunkmaker_test.go:      ASCII text
src/duplicacy_chunkuploader.go:        ASCII text
src/duplicacy_chunkuploader_test.go:   ASCII text
src/duplicacy_config.go:               ASCII text
src/duplicacy_dropboxstorage.go:       ASCII text
src/duplicacy_entry.go:                ASCII text
src/duplicacy_entry_test.go:           ASCII text
src/duplicacy_filereader.go:           ASCII text
src/duplicacy_filestorage.go:          ASCII text
src/duplicacy_gcdstorage.go:           ASCII text
src/duplicacy_gcsstorage.go:           ASCII text
src/duplicacy_hubicclient.go:          ASCII text
src/duplicacy_hubicclient_test.go:     ASCII text
src/duplicacy_hubicstorage.go:         ASCII text
src/duplicacy_keyring.go:              ASCII text
src/duplicacy_keyring_windows.go:      ASCII text
src/duplicacy_log.go:                  ASCII text
src/duplicacy_oneclient.go:            ASCII text
src/duplicacy_oneclient_test.go:       ASCII text
src/duplicacy_onestorage.go:           ASCII text
src/duplicacy_preference.go:           ASCII text
src/duplicacy_s3cstorage.go:           ASCII text
src/duplicacy_s3storage.go:            ASCII text
src/duplicacy_sftpstorage.go:          ASCII text
src/duplicacy_shadowcopy.go:           ASCII text
src/duplicacy_shadowcopy_windows.go:   ASCII text
src/duplicacy_snapshot.go:             ASCII text
src/duplicacy_snapshotmanager.go:      ASCII text
src/duplicacy_snapshotmanager_test.go: ASCII text
src/duplicacy_storage.go:              ASCII text
src/duplicacy_storage_test.go:         ASCII text
src/duplicacy_utils.go:                ASCII text
src/duplicacy_utils_others.go:         ASCII text
src/duplicacy_utils_test.go:           ASCII text
src/duplicacy_utils_windows.go:        ASCII text

I don't see any Windows newlines. I mainly edit source files on maxOS with Visual Studio Code.

@TheBestPessimist
Copy link
Contributor Author

In that case it may be something wrong in my git/go/intellij/i don't even know config?

@tbain98
Copy link

tbain98 commented Sep 26, 2017

@TheBestPessimist Can you provide the names of a couple files where you're seeing inconsistent line terminators?

@TheBestPessimist
Copy link
Contributor Author

@tbain98 i am unsure what happened last time. maybe i changed my settings in my ide, or something else. right now, with a new download of the repository the line endings look ok.

With this said, i think that @gilbertchen can close this issue whenever you find fit.

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

No branches or pull requests

4 participants