首頁  >  文章  >  後端開發  >  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刪除