Fairly new to using go modules. I’m working through a class and they are talking about package constraints. I found the code and the valid go.mod file
module golang.org/x/exp
go 1.23.0
require (
github.com/google/go-cmp v0.6.0
golang.org/x/mod v0.24.0
golang.org/x/tools v0.33.0
)
require golang.org/x/sync v0.14.0 // indirect
And I can do go mod download for for the required packages but when I try to execute:
go get golang.org/x/exp/contstraints
which should work but I get an error:
go: golang.org/x/exp/contstraints: no matching versions for query "upgrade"
I also tried downloading different commits:
go get golang.org/x/exp/contstraints@2b6e20a6d8b6a7fa47ce7f245c422b7abb361048
but I get a variety of different errors from:
golang.org/x/exp/contstraints@v0.0.0-20250506013429-2b6e20a6d8b6: invalid version: missing golang.org/x/exp/contstraints/go.mod at revision 2b6e20a6d8b6
to
go: module golang.org/x/exp@2b6e20a6d8b6a7fa47ce7f245c422b7abb361048 found (v0.0.0-20250506013429-2b6e20a6d8b6), but does not contain package golang.org/x/exp/contstraints
I realize this is experimental code and does not have any compatibility guarantee I’m more curious if I’m doing something wrong and whether or not I should be able to do this. I’m running go 1.24.2:
dan@workstation-DBDGVD3:~/Class/002-Learning_Go-Take2/023-Generics/186-Package_constraints$ go env
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/dan/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/dan/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/home/dan/tmp/go-build3918362781=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/dan/Class/002-Learning_Go-Take2/023-Generics/186-Package_constraints/go.mod'
GOMODCACHE='/home/dan/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/dan/go'
GOPRIVATE=''
GOPROXY='direct'
GOROOT='/usr/lib/golang'
GOSUMDB='off'
GOTELEMETRY='local'
Thanks in advance,
Dan