-
Notifications
You must be signed in to change notification settings - Fork 43
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
Build setup and Cosmetics #58
Conversation
6ae6dc5
to
1a282e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending a pull request!
I think it's too soon for a Makefile. Most of what's in there I don't want, and we are a ways from the pieces I do want in there (building .deb, snaps, rpms, etc). There is one really nice thing in there, which is gofmt, please see the comment below about the precommit hook.
.gitignore
Outdated
@@ -0,0 +1 @@ | |||
ng |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use go install neugram.io/ng
for building the binary, so I'm never left with one floating around the tree. I'd rather not encourage a build process that does.
Makefile
Outdated
vet: | ||
go vet | ||
|
||
fmtcheck: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better as a precommit hook. Here's one you can use as a model:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a pre-commit hook will not guarantee that the code is well formatted: Some tools by-pass the hooks, committing from GoLand for example.
Having such a check performed in Travis for every pull request will, imho, be a surefire guarantee that the proposed changes are well formatted.
Makefile
Outdated
golint -set_exit_status . | ||
|
||
vet: | ||
go vet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend developing at tip until Go 1.10 is out, for a number of plugin bug fixes that are in the tree. A side effect of that is that go vet is now run every time go test is run, so there's no need for extra steps any more.
Makefile
Outdated
ineffassign . | ||
|
||
setup: | ||
go get github.com/Masterminds/glide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather avoid these external dependencies for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was a mistake for my part, sorry: glide is not needed (This is a leftover from copy/pasting).
If I get rid of ineffassign, this will just leave go-getting golint. Still unacceptable ? FYI this will only be called in travis and users of ng
won't be impacted by this.
eval/shell/job.go
Outdated
@@ -313,13 +313,13 @@ func (j *Job) setupSimpleCmd(cmd *expr.ShellSimpleCmd, sio stdio) (*proc, error) | |||
} | |||
switch argv[0] { | |||
case "cd": | |||
dir := "" | |||
var dir string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is generating these changes? Is it ineffassign
? If so, sorry, I disagree with the tool. These two statements are equivalent, and an automated tool shouldn't be choosing one over the other when there's no reason for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can get rid of ineffassign
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from that one class of false positive (variables assigned the zero value) everything else ineffassign complains about is a valid bug. If ineffassign isn't run via Travis, it should be run by hand frequently.
@crawshaw awaiting your feedback on whether you want to keep the go lint and gofmt checks (in which case I'll update the PR) or not (in which case I'll close it 😄 ) |
No golint please. (For now, I need to spend more time getting to know it. The last integrated version I used was too noisy, but it may be a configuration detail.) A gofmt check in travis is fine, though could we do it without the makefile? Something like: https://gist.github.com/ngdinhtoan/8c43fd92c379c4760735ec7186f215cf |
@crawshaw Done ! |
FYI, I have been using this pattern a lot in my projects: A go test Test that runs gofmt or goimports and checks that everything is as it should. |
Also reformat the existing files.
@crawshaw @sbinet Your feedback has been taken into account, with one change: The
|
Thanks! |
In case it's helpful (for future consideration), here is an IMO good way to run a https://github.com/shurcooL/home/blob/99ba63ab813bd15192b0aae77ef21c9b4332c580/.travis.yml#L14 |
This is not much, but here goes:
This PR proposes the following (1 commit per proposal):
.gitignore
file to ignore theng
binaryMakefile
with the following targets:ng
binarygo vet
,golint
,gofmt
orineffasign
detects any error. This one will be called by travis so that any future PR is checked for these.gofmt -s
so that the travis build passesineffassign
happy