所以我有以下代码,
package main
import (
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter()
}
当我运行时,它给出了以下错误 binapi.go:4:2: no required module provides package github.com/gorilla/mux; to add it: go get github.com/gorilla/mux,我该如何解决这个错误?我已经以各种可能的方式运行了 go get github.com/gorilla/mux 命令,并且我确定它已安装。不久前我发现了一个帖子,但它给出的命令不起作用。该命令是 go env -w GO111MODULE=auto 但它没有解决问题。
这是 go 环境
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ProfMonkey07/Library/Caches/go-build"
GOENV="/Users/ProfMonkey07/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/ProfMonkey07/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/ProfMonkey07/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/ProfMonkey07/binapi/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8g/ssbpssj956ncjflh7w2k4w5m0000gn/T/go-build2892181555=/tmp/go-build -gno-record-gcc-switches -fno-common"