I am trying to install package from github. https://github.com/adnanh/webhook
Version
$ go version
go version go1.17.5 linux/amd64
.profile:
export PATH=$PATH:/usr/local/go/bin
Try:
$ 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'
Settings
$ 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"
where is a problem?
And I don't have go folder in /root/ with pkg and bin subfolders
CodePudding user response:
Only go install can work outside of any project (without a local .go.mod$
Since Go 1.16, if the arguments have version suffixes (like
@latestor@v1.0.0),go installbuilds packages in module-aware mode, ignoring thego.modfile 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, a package.
