windows 上的 Golang 依赖管理不起作用(GOPATH 错误)
Golang dependency management on windows does not work (GOPATH error)
我尝试使用不同的依赖管理工具:godep and dep。
两者都因类似错误而失败。我应该如何设置环境以及我应该在哪里放置资源?
部门
PS D:\Work\Golang\src\ChrBack> dep init
root project import: D:\Work\Golang\src\ChrBack is not within any GOPATH/src
godep
PS D:\Work\Golang\src\ChrBack> godep save
godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
godep: [WARNING]: Current Directory: D:\Work\Golang\src\ChrBack
godep: [WARNING]: $GOPATH: D:\Work\Golang\src
godep: Unable to find SrcRoot for package .
去环境
$ D:\Work\Golang\Go\bin\go.exe version
go version go1.9.1 windows/amd64
$ D:\Work\Golang\Go\bin\go.exe env
set GOARCH=amd64
set GOBIN=D:\Work\Golang\src\bin
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Work\Golang\src
set GORACE=
set GOROOT=D:\Work\Golang\Go
set GOTOOLDIR=D:\Work\Golang\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
尝试设置
GOPATH=D:\Work\Golang
然后创建 src\github.com\user\repo
之类的文件夹并将您保存在其中。
我尝试使用不同的依赖管理工具:godep and dep。 两者都因类似错误而失败。我应该如何设置环境以及我应该在哪里放置资源?
部门
PS D:\Work\Golang\src\ChrBack> dep init
root project import: D:\Work\Golang\src\ChrBack is not within any GOPATH/src
godep
PS D:\Work\Golang\src\ChrBack> godep save
godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
godep: [WARNING]: Current Directory: D:\Work\Golang\src\ChrBack
godep: [WARNING]: $GOPATH: D:\Work\Golang\src
godep: Unable to find SrcRoot for package .
去环境
$ D:\Work\Golang\Go\bin\go.exe version
go version go1.9.1 windows/amd64
$ D:\Work\Golang\Go\bin\go.exe env
set GOARCH=amd64
set GOBIN=D:\Work\Golang\src\bin
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Work\Golang\src
set GORACE=
set GOROOT=D:\Work\Golang\Go
set GOTOOLDIR=D:\Work\Golang\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
尝试设置
GOPATH=D:\Work\Golang
然后创建 src\github.com\user\repo
之类的文件夹并将您保存在其中。