On Fri, Mar 8, 2019 at 4:42 PM <smudun...@heroku.com> wrote: > > I am an engineer working on Heroku's Go buildpack. > > Our buildpack needed a way for users to select the version of Go that they > wanted to build their code, so a “hacky” solution of using build tag like > constructs was implemented: > https://github.com/heroku/heroku-buildpack-go#go-module-specifics. TL;DR: > Users can specify their version in go.mod via: > // +heroku goVersion <a go Version> > > As of Go 1.12 there is a new go directive in the go.mod file that seems to > duplicate our hack. We've already had one issue opened where a user was > confused as to why they got Go 1.11 instead of Go 1.12: > https://github.com/heroku/heroku-buildpack-go/issues/301 (TL;DR: We don't > support the go directive and our default Go version is still go1.11.5) > > I am trying to implement go version selection per the go directive. I have > some questions related to how this directive will be used and how it's value > will change over time that aren't documented in the wiki.
For more background on the directive see https://golang.org/issue/28221 and https://github.com/golang/proposal/blob/master/design/28221-go2-transitions.md . > When go 1.12.1 is released and used by a user, will the directive be > automatically updated to go 1.12.1 the next time a go mod command is run? No. > Or will only major versions be represented in the file? If so, will the > directive be automatically updated when Go 1.13 comes out? Yes, only major versions. The directive will not be updated automatically. > Or will the user need to manually edit the file? No, but the user can choose to use "go mod edit -go" to change the version. > Or should we not use this directive to indicate the version of Go to use to > build the code? I'm not sure how that makes sense, exactly. You can't build one package with Go 1.11 and another package with Go 1.12. You have to build all of them together. What the go.mod go directive does is let you build all the packages with Go 1.12 while using language version 1.11 for some of them. They are still built with 1.12, but with the language features of 1.11. That doesn't matter for 1.11 and 1.12, but it will matter if and when we ever remove a language feature. The directive will permit modules that use the old language feature to still be built with new Go releases. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.