golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.38k stars 17.71k forks source link

x/pkgsite: x/pkgsite@latest doesn't compile, requires Go 1.18 #51185

Closed chmike closed 2 years ago

chmike commented 2 years ago

What version of Go are you using (go version)?

$ go version
go version go1.17.7 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/meessen/.cache/go-build"
GOENV="/home/meessen/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/meessen/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/meessen/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.7"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1089687875=/tmp/go-build -gno-record-gcc-switches"
m

What did you do?

$ cd ~/go/src
$ go install golang.org/x/pkgsite/cmd/pkgsite@latest
go: downloading github.com/google/safehtml v0.0.3-0.20211026203422-d6f0e11a5516
go: downloading github.com/hashicorp/golang-lru v0.5.1
go: downloading cloud.google.com/go/logging v1.4.2
go: downloading go.opencensus.io v0.23.0
go: downloading golang.org/x/net v0.0.0-20211013171255-e13a2654a71e
go: downloading github.com/go-git/go-billy/v5 v5.3.1
go: downloading github.com/go-git/go-git/v5 v5.4.2
go: downloading cloud.google.com/go/errorreporting v0.1.0
go: downloading cloud.google.com/go v0.99.0
go: downloading github.com/go-redis/redis/v8 v8.11.4
go: downloading github.com/go-redis/redis_rate/v9 v9.1.2
go: downloading google.golang.org/api v0.63.0
go: downloading github.com/microcosm-cc/bluemonday v1.0.5
go: downloading github.com/russross/blackfriday/v2 v2.1.0
go: downloading github.com/yuin/goldmark v1.4.0
go: downloading github.com/yuin/goldmark-emoji v1.0.1
go: downloading golang.org/x/vuln v0.0.0-20211104165457-3710d685f6c2
go: downloading github.com/google/licensecheck v0.3.1
go: downloading github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
go: downloading golang.org/x/sys v0.0.0-20211210111614-af8b64212486
go: downloading github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7
go: downloading github.com/imdario/mergo v0.3.12
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/emirpasic/gods v1.12.0
go: downloading github.com/cespare/xxhash/v2 v2.1.2
go: downloading github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/googleapis/gax-go/v2 v2.1.1
go: downloading google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa
go: downloading contrib.go.opencensus.io/exporter/prometheus v0.1.0
go: downloading contrib.go.opencensus.io/exporter/stackdriver v0.13.4
go: downloading github.com/ghodss/yaml v1.0.0
go: downloading cloud.google.com/go/storage v1.18.2
go: downloading github.com/Masterminds/squirrel v1.5.2
go: downloading github.com/golang-migrate/migrate/v4 v4.15.1
go: downloading github.com/lib/pq v1.10.2
go: downloading cloud.google.com/go/cloudtasks v1.0.0
go: downloading google.golang.org/grpc v1.43.0
go: downloading google.golang.org/protobuf v1.27.1
go: downloading github.com/evanw/esbuild v0.14.10
go: downloading github.com/chris-ramon/douceur v0.2.0
go: downloading golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
go: downloading github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
go: downloading github.com/go-git/gcfg v1.5.0
go: downloading golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
go: downloading cloud.google.com/go/secretmanager v1.0.0
go: downloading cloud.google.com/go/monitoring v1.1.0
go: downloading cloud.google.com/go/trace v1.0.0
go: downloading github.com/census-instrumentation/opencensus-proto v0.3.0
go: downloading github.com/lann/builder v0.0.0-20180802200727-47ae307949d0
go: downloading github.com/prometheus/client_golang v1.7.1
go: downloading contrib.go.opencensus.io/integrations/ocsql v0.1.4
go: downloading github.com/jackc/pgconn v1.10.1
go: downloading github.com/jackc/pgx/v4 v4.14.1
go: downloading github.com/hashicorp/go-multierror v1.1.0
go: downloading go.uber.org/atomic v1.6.0
go: downloading github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351
go: downloading github.com/xanzy/ssh-agent v0.3.0
go: downloading gopkg.in/warnings.v0 v0.1.2
go: downloading cloud.google.com/go/container v1.0.0
go: downloading github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/common v0.10.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/prometheus/procfs v0.6.0
go: downloading github.com/hashicorp/errwrap v1.0.0
go: downloading github.com/jackc/pgproto3/v2 v2.2.0
go: downloading github.com/jackc/pgtype v1.9.1
go: downloading github.com/aws/aws-sdk-go v1.34.29
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369
go: downloading github.com/jmespath/go-jmespath v0.4.0
# golang.org/x/pkgsite/internal/godoc/internal/doc
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/comment.go:241:17: undefined: strings.Cut
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/comment.go:252:17: undefined: strings.Cut
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/doc.go:160:86: undefined: any
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/exports.go:184:14: undefined: token.TILDE
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/exports.go:199:22: t.TypeParams undefined (type *ast.FuncType has no field or method TypeParams)
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/reader.go:40:8: undefined: ast.IndexListExpr
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/reader.go:133:8: undefined: ast.IndexListExpr
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/reader.go:455:35: fun.Type.TypeParams undefined (type *ast.FuncType has no field or method TypeParams)
note: module requires Go 1.18

What did you expect to see?

I expected pkgsite to compile and be usable.

I also expected that such a tool would not depend on an unreleased version of Go. Code depending on an unreleased version of Go should be in a branch that is merged when Go 1.18 is released.

What did you see instead?

Reported compilation errors:

# golang.org/x/pkgsite/internal/godoc/internal/doc
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/comment.go:241:17: undefined: strings.Cut
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/comment.go:252:17: undefined: strings.Cut
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/doc.go:160:86: undefined: any
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/exports.go:184:14: undefined: token.TILDE
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/exports.go:199:22: t.TypeParams undefined (type *ast.FuncType has no field or method TypeParams)
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/reader.go:40:8: undefined: ast.IndexListExpr
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/reader.go:133:8: undefined: ast.IndexListExpr
../pkg/mod/golang.org/x/pkgsite@v0.0.0-20220213193454-9a991af47a09/internal/godoc/internal/doc/reader.go:455:35: fun.Type.TypeParams undefined (type *ast.FuncType has no field or method TypeParams)
note: module requires Go 1.18
jamalc commented 2 years ago

Pkgsite requires Go 1.18 to run. The last commit that works with older versions of Go is 4d836c6a652cde92f433967680dfd6171a91ec12.

jba commented 2 years ago

We did add what Jamal wrote above to the README, but I also understand that not everyone reads the README on every go get.

We wanted to support generics as early as possible, since people are already writing generic code. We chose to upgrade master to using to 1.18 beta2 rather than creating a new branch.

I'm sorry the experience isn't great, but 1.18 is coming soon.

mvdan commented 2 years ago

Wouldn't @findleyr's typeparams package from https://github.com/golang/go/issues/50447 be enough to add support for generics without breaking Go 1.17 right away?

jba commented 2 years ago

The main problem is ast.IndexListExpr: https://go.googlesource.com/pkgsite/+/a70a3c2b473c9294b83bc93a6068c8ebcc9c4ecb%5E%21/#F1.