首页  >  文章  >  后端开发  >  Go模块安装错误“undefined:any”

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

王林
王林转载
2024-02-08 22:09:25771浏览

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

在使用Go语言开发过程中,我们经常会遇到各种各样的问题。其中,一个常见的问题是在安装Go模块时遇到错误提示"undefined:any"。这个错误提示可能让人困惑,不知道该如何解决。php小编柚子将为大家提供解决这个问题的方法和技巧,帮助大家顺利安装Go模块,提高开发效率。

问题内容

我收到以下错误。有人可以尝试相同的命令吗?我想知道这是包中的错误还是与我使用的 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

解决方法

让我们看看 go.mod 文件您想要获取的包裹。该包是基于golang 1.18版本编写的。所以你至少需要1.18版本。

module github.com/gonejack/webarchive-to-html

go 1.18

...

go 1.18 中引入了内置类型 anyany 是 interface{} 的简单别名。

// builtin.go
type any = interface{}

以上是Go模块安装错误“undefined:any”的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:stackoverflow.com。如有侵权,请联系admin@php.cn删除