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 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化