drfb52000 2016-09-02 23:42
浏览 22
已采纳

去忽略供应商目录

Everything I read about the vendor directory gives me the understanding that if I have a directory:

$GOPATH/src/vendor

And put my dependencies in there (I am using godeps), when doing go run, go should check in that directory first.

If I run my code in a Docker image I have, this works fine. However now that I try to run the same code on my Windows machine, go simply ignores the vendor/ directory, and fails to find the dependencies.

What am I doing wrong?

main.go:7:2: cannot find package "gopkg.in/alecthomas/kingpin.v2" in any of:
        C:\Go\src\gopkg.in\alecthomas\kingpin.v2 (from $GOROOT)
        C:\Users\js\dev\my_projectest\src\gopkg.in\alecthomas\kingpin.v2 (from $GOPATH)
        C:\Users\js\dev\go\src\gopkg.in\alecthomas\kingpin.v2

Is the output when I try to do:

go run main.go

A directory vendor/ exists in this directory.

go version go1.7 windows/amd64

The exact commands I run (in windows cmd.exe)

> cd C:\Users\js\dev\my_projectest\
> set GOPATH=C:\Users\js\dev\my_projectest\;c:\Users\js\dev\go

> cd src
> dir
...
2016-09-01  23:20             2 923 main.go
...
2016-09-03  01:27    <DIR>          vendor

> go run main.go
  • 写回答

3条回答 默认 最新

  • dqd54099 2016-09-07 21:23
    关注

    The reason this did not work is because you are not supposed to put any code directly into the $GOPATH/src/ directory.

    The solution is to put your project into a sub-directory like so:

    $GOPATH/src/app/*.go

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图