Is there a compiler directive to use the Go version set in go.mod instead of the current toolchain version?

193 views
Skip to first unread message

tapi...@gmail.com

unread,
May 9, 2022, 1:18:22 PM5/9/22
to golang-nuts
I have a project using go1.16 embedding feature.
The project supports Go toolchain 1.15, by using "//go:build !go1.16" directive.

Now I have upgraded the toolchain to v1.18.1,
And I want to debug the non-embedding flow of the project.
Changing the go version in go.mod doesn't help.

Do I have to install back Go toolchain 1.15?

Ian Lance Taylor

unread,
May 9, 2022, 1:46:35 PM5/9/22
to tapi...@gmail.com, golang-nuts
I don't think that what you want to do is supported. I recommend that
you install 1.15 somewhere.

That said, you could try "go build -gcflags=-lang=go1.15".

Ian

tapi...@gmail.com

unread,
May 9, 2022, 8:24:12 PM5/9/22
to golang-nuts
 "go build -gcflags=-lang=go1.15" doesn't work too.
OK, I will try to install 1.15 alongside.

Amnon

unread,
May 10, 2022, 12:19:57 AM5/10/22
to golang-nuts
OT, but why do you want to support the Go 1.15 toolchain?
1.15 and 1.16 are no longer supported upstream, so will not get essential security fixes.
Why not just ask your users to upgrade to 1.18.1?

tapi...@gmail.com

unread,
May 10, 2022, 10:12:04 PM5/10/22
to golang-nuts
On Tuesday, May 10, 2022 at 12:19:57 PM UTC+8 Amnon wrote:
OT, but why do you want to support the Go 1.15 toolchain?
1.15 and 1.16 are no longer supported upstream, so will not get essential security fixes.
Why not just ask your users to upgrade to 1.18.1?

I can recommend but not force them to use a recent version.
And this is not a 1.15/1.16 specific problem.
Reply all
Reply to author
Forward
0 new messages