pelletier / go-toml

Go library for the TOML file format
https://github.com/pelletier/go-toml
Other
1.75k stars 211 forks source link

go-toml update 2.2.3 linux deployment error #965

Open fengshunli opened 2 months ago

fengshunli commented 2 months ago

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

QQ_1725539153659

pelletier commented 2 months ago

Which version of go are you using?

fengshunli commented 2 months ago

v2.2.3 and go version 1.22

pelletier commented 2 months ago

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
~$
fengshunli commented 2 months ago

QQ_1726285236614

pelletier commented 1 month ago

I'm not sure what's going on. I would need a reproducible example to investigate further.