-
Notifications
You must be signed in to change notification settings - Fork 385
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
Multiple go_binary rules are not fixed/updated #1041
Comments
Too late I realized the convention of 1 binary per directory. It makes sense Gazelle enforces this. Is https://github.com/golang-standards/project-layout the source of truth for the canonical project layout Gazelle supports, as much as there is one? If so, would it be ok to explicitly state that in the docs? I think it would save time for newcomers. |
Funny you should mention that project. See golang-standards/project-layout#117 with the knowledge that rsc (intentionally not tagged) is in charge of go. As a reference I would look to https://eli.thegreenplace.net/2019/simple-go-project-layout-with-modules/ Eli Bendersky. He is a Google employee, but I don't think he works on go proper. This is the repo layout that I use for everything. |
Not merely a convention, but a requirement of the language. A directory may contain only a single package; |
@achew22 - Thanks for the pointer! I feel like the README should explicitly call out the conventions it supports(?) This is obvious to devs familiar with Go, but probably a gotcha for new comers? Explicitly stating the requirement could save some folks time. @peterbourgon - Unpopular opinion: I kinda like how Bazel lets you break this convention if you really want to. Not saying Gazelle should officially support doing so. |
@tldr-darren, I'm sorry you had a bad time with gazelle in go mode. That's obviously not ideal for the repo. That said, this tool has been in a usable state since 2017 and this is the first time I've heard this complaint. My rule of thumb is that I like to see things three times before I take action. That said, if you are really convinced this is a problem, we love documentation PRs and I'd be happy to work through that with you. Just as a data point, are you a current/former user of |
Again, it is not a convention, it is a requirement of the (I suppose there could be |
No worries at all! Its all a learning process. I hope I didn't come off like I was knocking Gazelle, it is awesome. I was just trying to make it easier on the next person who comes along. I am quiet new to Golang/Bazel/Gazelle outside of Google's ecosystem. Maybe this is just a me problem :)
Assuming you are referring to Google's internal tool that is analogous to Gazelle? Yeah, long time user :) But the only references I could find to Perhaps that prior expectation is what tripped me up, and why this problem might be limited to me. I don't mind closing this issue for that reason.
Hypothesis: I believe what it is doing under the hood is treating each I agree this is not a coherent go package. I believe it is just made possible by the Bazel ecosystem. Going to close the issue because I have the answers I was looking for, thank you! |
To chime in an "well actually" a bit about rules and conventions: the language spec says that:
That leaves it ambiguous whether it's really necessary. That said, I'd encourage developers not to put multiple packages in the same directory, whether they are main package or not. The closer everyone stays to conventions, the easier life is for users, other developers, tools, and IDEs. Gazelle translates |
What version of gazelle are you using?
v0.23.0
What version of rules_go are you using?
v0.27.0
What version of Bazel are you using?
4.0.0
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
Ubuntu 20.04
What did you do?
Start with the following minimal directory structure and files:
base_dir
├── foo
│ ├── BUILD
│ └── foo.go
├── BUILD
├── bar.go
├── baz.go
└── WORKSPACE
foo/BUILD
foo/foo.go
BUILD
bar.go
&baz.go
WORKSPACE
Reproduction steps:
bazel build ...
, all builds finedeps = ["//foo"],
from rules//bar_lib
andbaz_lib
inBUILD
bazel run //:gazelle
What did you expect to see?
The 2
deps = ["//foo"],
lines reinserted into rules//bar_lib
andbaz_lib
.What did you see instead?
Nothing, no file change. Although Gazelle will fix formatting errors, so it is running. It just doesn't do any meaningful changes.
Proof of homework
I see Jay's comment in #826 referencing "Go already had a strong set of conventions", but if this is the case it is unclear what convention I am running afoul of. Gazelle is not printing a warning or error of any kind. The output is:
Questions
deps = ["//foo"]
attributes appropriately?The text was updated successfully, but these errors were encountered: