尝试使用 go 从 github 构建包时出错

Error when trying to build package from github with go

我正在尝试从 github 安装软件包。 https://github.com/adnanh/webhook

版本

$ go version
go version go1.17.5 linux/amd64

.个人资料:

export PATH=$PATH:/usr/local/go/bin

尝试:

$ go build github.com/adnanh/webhook
no required module provides package github.com/adnanh/webhook: go.mod file not found 
in current directory or any parent directory; see 'go help modules'

设置

$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build586084061=/tmp/go-build -gno-record-gcc-switches"

哪里有问题?

而且我在 /root/ 中没有带有 pkg​​ 和 bin 子文件夹的 go 文件夹

只有 go install 可以在任何项目之外工作(没有本地 .go.mod$

Since Go 1.16, if the arguments have version suffixes (like @latest or @v1.0.0), go install builds packages in module-aware mode, ignoring the go.mod file in the current directory or any parent directory if there is one.

This is useful for installing executables without affecting the dependencies of the main module.

go build is meant to be used within a local project, with its go.mod dependencies list. It compiles, but does not install,一个包.