Open fengshunli opened 2 months ago
Which version of go are you using?
v2.2.3 and go version 1.22
Can you confirm the go 1.22 being used? The mention of GOROOT and the message note: imported by a module that requires go 1.21
makes me believe a different version of go may be used here.
Alternatively, do you have a way to reproduce the error?
go-toml only supports the last two versions of go (1.23, 1.22 currently). It fails with a similar message on go 1.20, because, slices
were introduce in 1.21:
~$ docker run golang:1.23 bash -c "mkdir -p /example && cd /example && go mod init example.com/m && go get github.com/pelletier/go-toml/v2"
go: creating new go.mod: module example.com/m
go: downloading github.com/pelletier/go-toml/v2 v2.2.3
go: downloading github.com/pelletier/go-toml v1.9.5
go: added github.com/pelletier/go-toml/v2 v2.2.3
~$ docker run golang:1.22 bash -c "mkdir -p /example && cd /example && go mod init example.com/m && go get github.com/pelletier/go-toml/v2"
go: creating new go.mod: module example.com/m
go: downloading github.com/pelletier/go-toml/v2 v2.2.3
go: downloading github.com/pelletier/go-toml v1.9.5
go: added github.com/pelletier/go-toml/v2 v2.2.3
~$ docker run golang:1.21 bash -c "mkdir -p /example && cd /example && go mod init example.com/m && go get github.com/pelletier/go-toml/v2"
go: creating new go.mod: module example.com/m
go: downloading github.com/pelletier/go-toml v1.9.5
go: downloading github.com/pelletier/go-toml/v2 v2.2.3
go: added github.com/pelletier/go-toml/v2 v2.2.3
~$ docker run golang:1.20 bash -c "mkdir -p /example && cd /example && go mod init example.com/m && go get github.com/pelletier/go-toml/v2"
go: creating new go.mod: module example.com/m
go: downloading github.com/pelletier/go-toml v1.9.5
go: downloading github.com/pelletier/go-toml/v2 v2.2.3
github.com/pelletier/go-toml/v2 imports
slices: package slices is not in GOROOT (/usr/local/go/src/slices)
note: imported by a module that requires go 1.21
~$
I'm not sure what's going on. I would need a reproducible example to investigate further.
github.com/pelletier/go-toml/v2@v2.2.3/marshaler.go:11:2: package slices is not in GOROOT (/usr/local/go/src/slices) note: imported by a module that requires go 1.21