dsa1234569 2017-10-25 07:25
浏览 105

src / golang.org目录丢失

I'm a newcomer to Go and I think I've messed up the setup somewhere. When trying to install the Buffalo framework, I got the following error:

$ buffalo new todo-api --api
Buffalo version v0.9.5

--> go get -u golang.org/x/tools/cmd/goimports
package golang.org/x/tools/cmd/goimports: cannot find package "golang.org/x/tools/cmd/goimports" in any of:
    /usr/local/go/src/golang.org/x/tools/cmd/goimports (from $GOROOT)
    /home/ankush/go/src/golang.org/x/tools/cmd/goimports (from $GOPATH)

I remember emptying the $HOME/go directory because I had just upgraded from 1.8 to 1.9, and thought that Go would somehow automatically re-download and populate it. But it didn't, it seems.

So, is the src/golang.org directory supposed to be in $GOPATH? Because I didn't find it in $GOROOT and I had followed the standard setup instructions.

Any suggestions?

== Update 1 ==

The GOPATH is correctly set in my case. Here's the output of go env:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ankush/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build630744714=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

=== Update2 ===

Here's my output of go get for goimports:

go$ go get -u -v golang.org/x/tools/cmd/goimports
Fetching https://golang.org/x/tools/cmd/goimports?go-get=1
Parsing meta tags from https://golang.org/x/tools/cmd/goimports?go-get=1 (status code 200)
get "golang.org/x/tools/cmd/goimports": found meta tag get.metaImport{Prefix:"golang.org/x/tools", VCS:"git", RepoRoot:"https://go.googlesource.com/tools"} at https://golang.org/x/tools/cmd/goimports?go-get=1
get "golang.org/x/tools/cmd/goimports": verifying non-authoritative meta tag
Fetching https://golang.org/x/tools?go-get=1
Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200)
golang.org/x/tools (download)
package golang.org/x/tools/cmd/goimports: cannot find package "golang.org/x/tools/cmd/goimports" in any of:
    /usr/local/go/src/golang.org/x/tools/cmd/goimports (from $GOROOT)
    /home/ankush/go/src/golang.org/x/tools/cmd/goimports (from $GOPATH)
  • 写回答

1条回答 默认 最新

  • 普通网友 2017-10-26 07:59
    关注

    I was finally able to solve it. For someone else who gets bitten by this in future, in my case it helped to remove the concerned directory and then install again. Here's what helped:

    $ rm -rf /home/ankush/go/src/golang.org/x/tools
    $ go get -u -v golang.org/x/tools/cmd/goimports
    

    I'm not sure why this works, but maybe the the git pull had somehow failed earlier (sloppy connection?) as soon as the directory was created.

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP