-
Notifications
You must be signed in to change notification settings - Fork 89
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
buildtags: support //go:build constraints #183
Comments
👋 hi! Do you think you'll have time for this before the end of the month? If you'd like, I can look into contributing the change! |
Hey! Sorry, yes I'll look at it this weekend :) |
FWIW, in Go 1.17 the Edit: Hmm, I realize now that |
@dmitshur I’m not sure whether go/format will continue to rewrite //+build to //go:build forever. Anyway, the nicer //go:build format will likely end up simplifying this code anyway once it can assume 1.17. |
@dmitshur should go/format touch .s files, if only the build header lines? Honestly, I wouldn’t mind if it also normalized the rest of the files either. Worth filing an issue (or two?)? |
My personal preference would be to keep the scope of |
Sorry for the really slow response on this, I've been struggling to keep up with my open-source work these days. Thank you for your input and for working around this issue in the meantime. There seem to be two issues here, firstly how to fix the immediate problem of Now: Update the printing of build constraints to go via Note the code to be updated is: Lines 46 to 49 in b935256
Lines 21 to 24 in b935256
The constraints formatter would just be something like: https://play.golang.org/p/UlV0ZypCbCL. Go 1.18+: The question here is what to do with the Lines 62 to 72 in b935256
In practice almost everyone has used the Therefore I think the best approach is that when Go 1.18 lands
The alternative is to attempt to maintain the
Thanks again! |
Implements formatting of constraints according to the current Go version supported syntax. This is achieved by delegating to go/format and extracting out the resulting comments. Also provides functions to query for constraint syntax support, which are mainly intended for writing version-dependent tests. Updates #183
Uses `buildtag.Format` to format constraints in the assembly and stub file printers. This will ensure `// + build` and `//go:build` syntax are used consistent with the current Go version. Updates #183
Bump CI Go versions to 1.16 and 1.17. Update build tags with `go:build` equivalents. Upgrade asmfmt tool for new `go:build` support. Updates #183
``` $ ./tmp/testgo161718.sh ./buildtags/ ./printer/ + go1.16.8 test ./buildtags/ ./printer/ ok github.com/mmcloughlin/avo/buildtags 0.001s ok github.com/mmcloughlin/avo/printer 0.002s + go1.17.2 test ./buildtags/ ./printer/ ok github.com/mmcloughlin/avo/buildtags 0.001s ok github.com/mmcloughlin/avo/printer 0.002s + gotip test ./buildtags/ ./printer/ ok github.com/mmcloughlin/avo/buildtags 0.001s ok github.com/mmcloughlin/avo/printer 0.002s ``` Updates #183
Okay landed #211 so it should do the right thing for Go 1.18. So, the current behavior is that This should be enough to unblock people, but I'm going to keep this open because |
Presence of this tag depends on the Go version on which `go generate` was run, see mmcloughlin/avo#183.
It would be great if we can force old tag creation. We already hit that problem in For me, it would be great if we have setters like |
Yes, I set the code generation jobs in I know it's not ideal, but how annoying is it to use Go 1.17 for your code generation? |
TBH, this would not be convenient. But I realized I can tweak an
Maybe that's not the nicest approach, but works perfectly on a local machine. |
I'm considering adding a Would this work for you @WojciechMula? Or do you want explicit control over the build tag syntax independent of specifying a target Go version? |
@mmcloughlin That would be perfect. However, I'm thinking now if it's really needed. So far I'm the only person who asked about that, and there's a workaround. Additionally, Go 1.16 is already not supported, EOL was in February this year. |
@WojciechMula Yeah, it's common for library authors to match the Go support policy and only support the last two minor versions. I'm curious why I'm considering the |
New
go:build
constraints will be preferred in Go 1.17. Thereforeavo
must support them.https://golang.org/design/draft-gobuild
golang/go#25348
golang/go#41184
The text was updated successfully, but these errors were encountered: