-
Notifications
You must be signed in to change notification settings - Fork 114
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
Package templates into the binary #9
Comments
I think the way to do this may be to conditional-compile it for 1.16+, and use the current system for older versions. That is, we support a standalone binary on 1.16+, and 1.13+ as long as we can find the templates (e.g. |
Update: apparently that doesn't work because @StevenACoffman do you know if there's a way around this? I think we're sadly at least 6 months, maybe more, from it being reasonable to require 1.16+. |
This is an attempt to fix #9, but doesn't actually work; see the issue for details.
I forgot I never circled back on this because I wasn't sure what your question was. Please forgive me if you know all this and none of it is what you wanted to work around. As you have already figured out, if a module declares go
Note: This guard actually didn't work for a few versions of Go, so for instance in Go 1.15, you need Go 1.15.12 or it would complain anyway. I forget what version of Go 1.14 ignoring build tag guarded embed directives was backported to. However, you probably want to build this file with Go 1.17 as well. Multiple build tags on the same line in a .go file causes go build to interpret them using OR logic. If we put them on separate lines, then go build will interpret those tags using AND logic, instead, so I think you want to change it to:
And then I think the build tags for the prior to Go 1.16 versions should be:
Since Also, for the Go 1.15 file, you would need to have an alternative implementation like go-bindata or pkger or do the box thing. |
Unless I messed something up, the issue was none of those! You can see what I did here: e3e3e8e, and I believe it includes everything you said (except that we don't need a go1.17 tag because the go1.16 tag actually means 1.16+). The problem is that |
You can use Assuming you have ASDF installed to manage Go versions (and you have ASDF_GOLANG_VERSION=1.15.13 and ASDF_GOLANG_VERSION=1.16.6) installed, you can demonstrate for yourself this works:
I ran it fine on different various different Go versions, but it does break on Go 1.15.10 and lower. See golang/go#43980 (comment) where in Go 1.15.11:
|
Ah interesting. Let's just wait until we're ready to drop 1.15, I think that will be simpler than trying to make sure everyone has the right version and this doesn't seem to have caused much trouble in practice. |
Now that we're on Go 1.16+ we can do this easily! The main advantage is it means users can build a genqlient binary and use that portably (or we could distribute one, or whatever). Plus the code is marginally simpler; the `embed` API is really quite nice. Fixes #9. Test plan: ``` make check go build . rm -rf generate # pretend we have no checkout ./genqlient ./internal/integration/genqlient.yaml ./genqlient --init # fails after generating a default config ```
Now that we're on Go 1.16+ we can do this easily! The main advantage is it means users can build a genqlient binary and use that portably (or we could distribute one, or whatever). Plus the code is marginally simpler; the `embed` API is really quite nice. Fixes #9. Test plan: ``` make check go build . rm -rf generate # pretend we have no checkout ./genqlient ./internal/integration/genqlient.yaml ./genqlient --init # fails after generating a default config ```
I'm trying to use It looks like you've already fixed this on |
Just released v0.5.0, which includes this. Thanks for the poke! |
Thanks! I'm not seeing it though:
I did patch the current |
Whoops, forgot to actually push the tag. Try again now! |
If we can put this off until we're okay with a minimum version of 1.16, we can use stdlib embed.
The text was updated successfully, but these errors were encountered: