刚入门一天的goer安装iris
原来看教程上都是用 go get 获取软件包。提示如下,意思是go get要被废弃了。
我的版本是,go version go1.20.4 windows/amd64
go get -u github.com/kataras/iris
go: go.mod file not found in current directory or any parent directory.
'go get' is no longer supported outside a module.
To build and install a command, use 'go install' with a version,
like 'go install example.com/cmd@latest'
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
https://go.dev/doc/go-get-install-deprecation
对这个问题的解释。
Starting in Go 1.17, installing executables with
go get
is deprecated.go install
may be used instead.
Why this is happening
Since modules were introduced, the
go get
command has been used both to update dependencies ingo.mod
and to install commands. This combination is frequently confusing and inconvenient: in most cases, developers want to update a dependency or install a command but not both at the same time.Since Go 1.16,
go install
can install a command at a version specified on the command line while ignoring thego.mod
file in the current directory (if one exists).go install
should now be used to install commands in most cases.
go get
’s ability to build and install commands is now deprecated, since that functionality is redundant withgo install
. Removing this functionality will makego get
faster, since it won’t compile or link packages by default.go get
also won’t report an error when updating a package that can’t be built for the current platform.See proposal #40276 for the full discussion.
换命令。iris官网教程。https://www.iris-go.com/docs/#/
$ go get github.com/kataras/iris/v12@latest 抛弃go get 换 go install 执行。
go install github.com/kataras/iris/v12@latest
go install github.com/kataras/iris@latest
go: github.com/kataras/iris@latest: module github.com/kataras/iris: Get "https://proxy.golang.org/github.com/kataras/iris/@v/list": dial tcp 142.251.43.17:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
无法访问。
更换国内源
go get更换国内镜像源
https://www.cnblogs.com/nanahome/p/17731680.html
翻越千山万水。终于快到达目的地了。