Home > Backend Development > Golang > Go module installation error 'undefined: any'

Go module installation error 'undefined: any'

王林
Release: 2024-02-08 22:09:25
forward
845 people have browsed it

Go module installation error undefined: any

In the process of using Go language development, we often encounter various problems. Among them, a common problem is encountering the error message "undefined: any" when installing Go modules. This error message can be confusing and you don’t know how to resolve it. PHP editor Youzi will provide you with methods and techniques to solve this problem, help you successfully install Go modules and improve development efficiency.

Question content

I receive the following error. Can anyone try the same command? I'm wondering if this is a bug in the package or something to do with the version of go I'm using 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
Copy after login

Solution

Let's take a look at the go.mod file for the package you want to get. This package is written based on golang version 1.18. So you need at least version 1.18.

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

go 1.18

...
Copy after login

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

// builtin.go
type any = interface{}
Copy after login

The above is the detailed content of Go module installation error 'undefined: any'. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template