英文:
Go module installation error "undefined: any"
问题
我遇到了以下错误。有人可以尝试相同的命令吗?我想知道这是软件包中的一个错误,还是与我使用的go版本或我的设置有关。
$ go get github.com/gonejack/webarchive-to-html
# github.com/alecthomas/kong
../../../go/src/github.com/alecthomas/kong/callbacks.go:105:65: undefined: any
../../../go/src/github.com/alecthomas/kong/callbacks.go:124:15: undefined: any
../../../go/src/github.com/alecthomas/kong/context.go:723:27: undefined: any
../../../go/src/github.com/alecthomas/kong/options.go:59:8: undefined: any
../../../go/src/github.com/alecthomas/kong/options.go:66:18: undefined: any
$ echo $?
2
$ go version
go version go1.16 darwin/amd64
英文:
I got the following error. Could anybody try the same command? I want to know whether it is a bug in the package or it is related to the version of go that I use or my setup.
$ go get github.com/gonejack/webarchive-to-html
# github.com/alecthomas/kong
../../../go/src/github.com/alecthomas/kong/callbacks.go:105:65: undefined: any
../../../go/src/github.com/alecthomas/kong/callbacks.go:124:15: undefined: any
../../../go/src/github.com/alecthomas/kong/context.go:723:27: undefined: any
../../../go/src/github.com/alecthomas/kong/options.go:59:8: undefined: any
../../../go/src/github.com/alecthomas/kong/options.go:66:18: undefined: any
$ echo $?
2
$ go version
go version go1.16 darwin/amd64
答案1
得分: 3
让我们来看一下你想获取的包的 go.mod 文件。该包是基于 Go 1.18 版本编写的,所以你至少需要 1.18 版本。
module github.com/gonejack/webarchive-to-html
go 1.18
...
在 Go 1.18 中引入了内置类型 any
。any
是 interface{}
的简单别名。
// builtin.go
type any = interface{}
英文:
Let's see go.mod file of the package you trying to get. The package is written down based on 1.18 version of golang. So you need at least 1.18 version.
module github.com/gonejack/webarchive-to-html
go 1.18
...
Built-in type any
is introduced in go 1.18. any
is a simple alias for interface{}.
// builtin.go
type any = interface{}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论