dongsutao8921 2015-08-05 01:52
浏览 11
已采纳

在Fedora中设置并导出了GOPATH和GOBIN,但仍未安装程序

I have GO installed on a Fedora 21 laptop and I setup GOPATH and GOBIN, but it for some reason is not letting me install my go Programs.

pred@computer01 [20:03:02] ~  
$ echo $GOPATH
/home/pred/Documents/GO
pred@computer01 [20:03:11] ~  
$ echo $GOBIN
/home/pred/Documents/GO/bin
pred@computer01 [20:03:15] ~  
$ cd $GOPATH
pred@computer01 [20:03:21] ~/Documents/GO  
$ go install src/github.com/pred3/go_helloworld/helloworld/helloworld.go 
go install: no install location for .go files listed on command line (GOBIN not set)
pred@computer01 [20:03:32] ~/Documents/GO  
$ go env
GOARCH="amd64"
GOBIN="/home/pred/Documents/GO/bin"
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/pred/Documents/GO"
GORACE=""
GOROOT="/usr/lib/golang"
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

What else should I be doing to get this to work?

--EDIT--

Issuing the following command as stated below also gave errors.

pred@computer1 [21:22:51] ~/Documents/GO  
$ go install src/github.com/pred3/go_helloworld/helloworld
can't load package: package src/github.com/predatorian3/go_helloworld/helloworld: cannot find package "src/github.com/pred3/go_helloworld/helloworld" in any of:
    /usr/lib/golang/src/src/github.com/pred3/go_helloworld/helloworld (from $GOROOT)
    /home/pred/Documents/GO/src/src/github.com/pred3/go_helloworld/helloworld (from $GOPATH)

However, I did not have package main at the beginning of the go file I was trying to install. Once I changed it to package main it worked. I'm not sure why I couldn't use a different package name though.

  • 写回答

1条回答 默认 最新

  • draxu26480 2015-08-05 02:58
    关注

    go install expects a package as argument (see Description of package lists for more detailed explanation). In your case it probably should be

    go install github.com/pred3/go_helloworld/helloworld
    

    assuming that $GOPATH/src/github.com/pred3/go_helloworld/helloworld directory exists and $GOPATH/src/github.com/pred3/go_helloworld/helloworld/helloworld.go starts with package main

    The following commands will do the same:

    cd $GOPATH/src/github.com/pred3/go_helloworld/helloworld
    go intsall
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 平板录音机录音问题解决
  • ¥15 请问维特智能的安卓APP在手机上存储传感器数据后,如何找到它的存储路径?
  • ¥15 (SQL语句|查询结果翻了4倍)
  • ¥15 Odoo17操作下面代码的模块时出现没有'读取'来访问
  • ¥50 .net core 并发调用接口问题
  • ¥15 网上各种方法试过了,pip还是无法使用
  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 Hadoop集群部署启动Hadoop时碰到问题
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启