-
Notifications
You must be signed in to change notification settings - Fork 145
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
Render templates from embed.FS
#89
Conversation
Hello and thanks for the PR! I love the idea of adding the I haven't tested this, but could we use build tags to get this in without bumping the go.mod version? If we added |
Thanks @unrolled for the quick review. I agree that bumping the go version might not be the best idea. I tried the approach you suggested, i.e. add build tag and keep the original version in Unfortunately, the go 1.16 compiler is not happy with the
This has been discussed in golang/go#43980
Originally posted by @rsc in golang/go#43980 (comment) The In the recent commit, I have pushed a possible solution with the following changes:
At a first glance these changes do not seem to look the cleanest approach, but they are a compromise which comply with these objectives:
I would be happy with a more simple, straightforward solution. |
This is looking awesome, the idea of a separate module for tests is smart! 👍 Couple of notes:
#!/bin/bash
set -o errexit
# Copy fixtures from one level up.
rm -rf ./fixtures
cp -r ../fixtures ./fixtures
# Run tests.
go test -v -race -tags=integration
|
Bumping the go version in go.mod does not require all users to have that Go version. The go mod tidy comment does still apply, though. |
Actually, I have been corrected. Go 1.15.10 and Go 1.16.3 understand to ignore missing standard library packages in |
@rsc Would bumping the version in go.mod to Go 1.16, and adding the build tag to our new |
Yes, to adopt embed for Go 1.16 you need to both bump the go.mod go version. To keep Go 1.15 and earlier builds happy you also need a build tag to not use The part about "go mod tidy" not liking this setup is fixed as of Go 1.15.10, |
@rcs Thanks for your insights, this makes a lot more sense now. @dominik-lekse Your first set of changes was pretty much perfect, sorry for the confusion! We just need the build tag at the top of the
|
3c39309
to
ec9f385
Compare
Thanks @rsc for joining the issue and clarifying role of the version in To summarize my understanding from the discussion: The version provided in @unrolled The PR now includes the initial proposal + build tag constraints in To confirm, I also have run tests with previous go versions: $ docker run --rm -v "$(pwd):/src" -e CGO_ENABLED=0 -w /src golang:1.16.4-alpine3.13 go test -tags=integration
PASS
ok github.com/unrolled/render 0.115s
$ docker run --rm -v "$(pwd):/src" -e CGO_ENABLED=0 -w /src golang:1.15.12-alpine3.13 go test -tags=integration
PASS
ok github.com/unrolled/render 0.190s
$ docker run --rm -v "$(pwd):/src" -e CGO_ENABLED=0 -w /src golang:1.14.15-alpine3.13 go test -tags=integration
PASS
ok github.com/unrolled/render 0.166s
$ docker run --rm -v "$(pwd):/src" -e CGO_ENABLED=0 -w /src golang:1.13.15-alpine3.12 go test -tags=integration
PASS
ok github.com/unrolled/render 0.170s |
@dominik-lekse Thanks for all the time you put into this! |
Implements #88