Go模块安装错误 “undefined: any”

huangapple go评论169阅读模式
英文:

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 中引入了内置类型 anyanyinterface{} 的简单别名。

// 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{}

huangapple
  • 本文由 发表于 2022年12月13日 08:39:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/74778813.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定