-
Notifications
You must be signed in to change notification settings - Fork 229
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
go-vet does not work if Go code is not in the root folder #30
Comments
I'm experiencing a similar issue with both the At least the vet script tries to get a list. The build script currently does not. What would you think to :
? I could create a separate issue for the BTW: I currently get around this issue by having a |
Is there a reason running |
Hi @treuherz , I discovered the issue overall to be more nuanced, what with gopath vs modules and single-package-repos vs multi-package repos. Inspired by @dnephin 's work, I ended up developing a new set of hooks that tries to offer more support for various project setups: If you had some time to try it, I'd love to hear if it worked any better for your project's setup? |
That's excellent, @davidpfarrell, it solves the problem perfectly. The hooks that only run against the modules of staged files are great to see as well, a very helpful improvement. |
@davidpfarrell what is your suggestion for doc.go? How to make go build work? What do you write inside doc.go? Is it a blank file? i raised another issue for go build not working #50 |
@davidpfarrell your new repo is very useful, i am also moving to this one https://github.com/TekWizely/pre-commit-golang/blob/master/sample-config.yaml |
Hi @rupamkhaitan , Here's the I think at the time it just contained the
Good luck! |
@davidpfarrell yes i am using your repo and running my build by passing custom tags.. and everything works.. I dont really understand the diff between go-build-mod & go-build-repo-mod (and -pkg ones is for old strcuture??)
|
Some packages don't have any go files in the root directory, for example, those following https://github.com/golang-standards/project-layout In the case of a GO111MODULE package with go.mod in place, we can just use "go list -m" and this will return the package name even without any go files in the project root. I've also updated the script to report all files that fail "go vet" in a single run instead of exiting after finding the first error. This is a fix for issue dnephin#30.
Some packages don't have any go files in the root directory, for example, those following https://github.com/golang-standards/project-layout In the case of a GO111MODULE package with go.mod in place, we can just use "go list -m" and this will return the package name even without any go files in the project root. I've also updated the script to report all files that fail "go vet" in a single run instead of exiting after finding the first error. This is a fix for issue dnephin#30.
go-vet script, first runs
go list
in the root directory. It fails if it does not find go files.In my case, I have multiple related projects in the same repo. Something like this
I need
go-vet
to only run the backend folder. But the way script works, it is not possible.One way is to infer the directory from the staged files. Or add option to pass dir in the argument to the hook.
The text was updated successfully, but these errors were encountered: