Closed
Description
Go version
go version go1.21.7 linux/amd64
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.7'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/go/src/repro/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build936666295=/tmp/go-build -gno-record-gcc-switches'
What did you do?
https://go.dev/play/p/-yiceeveEDz?v=goprev
Details
//go:build go1.21
package main
import "slices"
func main() {
_ = slices.Clone([]string{})
}
-- go.mod --
module play.ground
go 1.16
What did you see happen?
Go 1.21:
embedding interface element ~[]string requires go1.18 or later (-lang was set to go1.16; check go.mod)
Go build failed.
Go 1.22:
Program exited.
What did you expect to see?
I expect the program to type-check successfully on Go 1.21, same as it does with Go 1.22.
This issue is making it impossible to use packages in non-module repositories which use the slices
or maps
packages with Go modules as the synthesized go.mod file has an implied language version of go1.16.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done