dtt3399 2017-10-18 03:51
浏览 316
已采纳

Windows上的Golang依赖项管理不起作用(GOPATH错误)

I try to use to different dependency management tools: godep and dep. And both fail with similar error. How should i set enviroument and where should I put sources?

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 .

Go env

$ 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
  • 写回答

1条回答 默认 最新

  • douluan4644 2017-10-18 04:11
    关注

    Try to set

    GOPATH=D:\Work\Golang
    

    Then create folders like src\github.com\userepo and keep you in them.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 浮动div的高度控制问题。
  • ¥66 换电脑后应用程序报错
  • ¥50 array数据同步问题
  • ¥15 pic16F877a单片机的外部触发中断程序仿真失效
  • ¥15 Matlab插值拟合差分微分规划图论
  • ¥15 keil5 target not created
  • ¥15 C/C++数据与算法请教
  • ¥15 怎么找志同道合的伙伴
  • ¥20 如何让程序ab.eXe自已删除干净硬盘里的本文件自己的ab.eXe文件
  • ¥20 关于#Mathcad符号引擎无响应#的问题,如何解决?