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

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

Go module installation error "undefined: any"

问题

我遇到了以下错误。有人可以尝试相同的命令吗?我想知道这是软件包中的一个错误,还是与我使用的go版本或我的设置有关。

  1. $ go get github.com/gonejack/webarchive-to-html
  2. # github.com/alecthomas/kong
  3. ../../../go/src/github.com/alecthomas/kong/callbacks.go:105:65: undefined: any
  4. ../../../go/src/github.com/alecthomas/kong/callbacks.go:124:15: undefined: any
  5. ../../../go/src/github.com/alecthomas/kong/context.go:723:27: undefined: any
  6. ../../../go/src/github.com/alecthomas/kong/options.go:59:8: undefined: any
  7. ../../../go/src/github.com/alecthomas/kong/options.go:66:18: undefined: any
  8. $ echo $?
  9. 2
  10. $ go version
  11. 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.

  1. $ go get github.com/gonejack/webarchive-to-html
  2. # github.com/alecthomas/kong
  3. ../../../go/src/github.com/alecthomas/kong/callbacks.go:105:65: undefined: any
  4. ../../../go/src/github.com/alecthomas/kong/callbacks.go:124:15: undefined: any
  5. ../../../go/src/github.com/alecthomas/kong/context.go:723:27: undefined: any
  6. ../../../go/src/github.com/alecthomas/kong/options.go:59:8: undefined: any
  7. ../../../go/src/github.com/alecthomas/kong/options.go:66:18: undefined: any
  8. $ echo $?
  9. 2
  10. $ go version
  11. go version go1.16 darwin/amd64

答案1

得分: 3

让我们来看一下你想获取的包的 go.mod 文件。该包是基于 Go 1.18 版本编写的,所以你至少需要 1.18 版本。

  1. module github.com/gonejack/webarchive-to-html
  2. go 1.18
  3. ...

在 Go 1.18 中引入了内置类型 anyanyinterface{} 的简单别名。

  1. // builtin.go
  2. 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.

  1. module github.com/gonejack/webarchive-to-html
  2. go 1.18
  3. ...

Built-in type any is introduced in go 1.18. any is a simple alias for interface{}.

  1. // builtin.go
  2. 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:

确定