Pretty new to utilizing go modules. I’m working by way of a category and they’re speaking about package deal constraints. I discovered the code and the legitimate 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/instruments v0.33.0
)
require golang.org/x/sync v0.14.0 // oblique
And I can do go mod obtain for for the required packages however when I attempt to execute:
go get golang.org/x/exp/contstraints
which ought to work however I get an error:
go: golang.org/x/exp/contstraints: no matching variations for question "improve"
I additionally tried downloading totally different commits:
go get golang.org/x/exp/contstraints@2b6e20a6d8b6a7fa47ce7f245c422b7abb361048
however I get a wide range of totally different errors from:
golang.org/x/exp/contstraints@v0.0.0-20250506013429-2b6e20a6d8b6: invalid model: lacking golang.org/x/exp/contstraints/go.mod at revision 2b6e20a6d8b6
to
go: module golang.org/x/exp@2b6e20a6d8b6a7fa47ce7f245c422b7abb361048 discovered (v0.0.0-20250506013429-2b6e20a6d8b6), however doesn't comprise package deal golang.org/x/exp/contstraints
I notice that is experimental code and doesn’t have any compatibility assure I’m extra curious if I’m doing one thing unsuitable and whether or not or not I ought to be capable to do that. I’m working 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='/dwelling/dan/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/dwelling/dan/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/dwelling/dan/tmp/go-build3918362781=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dwelling/dan/Class/002-Learning_Go-Take2/023-Generics/186-Package_constraints/go.mod'
GOMODCACHE='/dwelling/dan/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/dwelling/dan/go'
GOPRIVATE=''
GOPROXY='direct'
GOROOT='/usr/lib/golang'
GOSUMDB='off'
GOTELEMETRY='native'
Thanks upfront,
Dan
go get golang.org/x/exp/contstraints
Assuming that you just’re after golang.org/x/exp/constraints, you’ve bought an additional ‘t’ in there. I feel that you just most likely supposed to do that.
go get golang.org/x/exp/constraints
Yeah it was only a mistype, however I nonetheless get
go: golang.org/x/exp/constraints: no matching variations for question "improve"
or after I add the tag I get:
go: golang.org/x/constraints@newest: unrecognized import path "golang.org/x/constraints": studying https://golang.org/x/constraints?go-get=1: 404 Not Discovered
server response: 404 web page not discovered
regardless that I’m wanting proper on the information.
I even tried the model method and get the identical reply
dan@workstation-DBDGVD3:~/Class/002-Learning_Go-Take2/023-Generics/186-Package_constraints$ go get golang.org/x/constraints@v0.0.0-20250506013437-ce4c2cf36ca6
go: golang.org/x/constraints@v0.0.0-20250506013437-ce4c2cf36ca6: unrecognized import path "golang.org/x/constraints": studying https://golang.org/x/constraints?go-get=1: 404 Not Discovered
server response: 404 web page not discovered
regardless that once more I’m wanting proper on the information,
Are you certain that’s not one other typo? You seem to have dropped the exp
a part of the module path.
Including again exp
works effective for me.
$ mkdir constraints-question
$ cd constraints-question
$ go mod init constraints-question
go: creating new go.mod: module constraints-question
$ go get golang.org/x/exp/constraints@v0.0.0-20250506013437-ce4c2cf36ca6
go: added golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6
$ cat go.mod
module constraints-question
go 1.24.0
require golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // oblique
$
And with out an specific model.
$ mkdir constraints-question
$ cd constraints-question
$ go mod init constraints-question
go: creating new go.mod: module constraints-question
$ go get golang.org/x/exp/constraints
go: added golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6
$ cat go.mod
module constraints-question
go 1.24.0
require golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // oblique
$
You’ve not bought any configuration that is perhaps related to getting modules, resembling GOPROXY
, GOPRIVATE
, or GONOPROXY
surroundings variables?
That did the trick, thanks a lot, @pekim ++