duanbiaoshu2021 2016-03-31 18:59
浏览 201
已采纳

godep:exec:“执行”:在$ PATH中找不到可执行文件

I trying to deploy my server on heroku and I stuck on step where I should use godep, I spent little time with GO, last two days I had looking how to solve this issue, actually it's a popular issue, but I can't figure out, maybe I did something fundamentally wrong.

I have OS X 10.11.2
My GOPATH - Users/denis/Programming/Golang
My PATH - $GOPATH/bin
I trying to use godep to my project which is placed in $GOPATH/src/backend

in my PATH I have an executable godep file(not .go).

Whole structure of my workplace.

/Golang/
     .bin/
        godep //executable file
     .pkg/
        .darwin-amd64/
             .//other folders/
     .src/
         .github.com/
         .backend/
         .//other folders// 
  • 写回答

1条回答 默认 最新

  • dongzhisang5342 2016-03-31 20:03
    关注

    First, what is the output of this:

    $ echo $PATH
    

    It should, at a minimal to run Go projects, have TWO directories in it for:

    • /path/to/go/installation/bin (e.g. /usr/local/go/bin)
    • /path/to/your/GOPATH/bin (e.g. /Users/denis/Programming/Golang/bin)

    Your go's installation should be in your PATH already if you followed the Go installation setup.

    https://golang.org/doc/install

    Since you posted /Users/denis/Programming/Golang, with the capital U, I am going to assume that you are on OS X going forward...

    In OS X, and if you used the default install, you can test for Go in your PATH with a simple command:

    $ echo $PATH | grep --color=auto "/usr/local/go/bin"
    

    It should print our your entire $PATH and highlight that you have things setup properly. This is because the OS X GoLang installer in the URL above should have modified your PATH to include:

    • /usr/local/go/bin
    • or more specifically, it may be export PATH="$PATH:/usr/local/go/bin"

    If you have some custom .bashrc and/or .profile files, then most likely your PATH isn't being setup correctly. You can test this by doing this:

    $ PATH="$PATH:/usr/local/go/bin"
    $ PATH="$PATH:/Users/denis/Programming/Golang/bin"
    $ godep go build
    

    If it works now, then your PATH isn't setup properly in your .bashrc/.profile files. That's a different kind of question and can be setup a 1000 different ways and you may need to figure it out (or another SO question).

    If that resolves your issue, then you need to follow the godep directions to run godep from your project's root:

    $ cd $GOPATH/src/backend/
    $ godep save
    $ git add Godeps/
    

    godep creates a Godeps directory in the root of the Go project. If you have multiple Go projects/multiple executables, then you need to run godep save on each root of the runtime.

    IOW, for each executable you run go build for, you need to run godep save in each directory.

    Also, once you move to godep, you want to use it for your build and testing as well:

    $ godep go build
    $ godep go test
    ...etc
    

    If that's not the problem (you are running it as stated above), then please update your question with more specifics such as what godep command you are running, where, and what that directorys structure looks like for the root of that project (including the filename with package main and your func main() function).

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

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大