douyi1963 2016-04-04 12:50 采纳率: 0%
浏览 110
已采纳

“去编译。/…”找不到软件包

I know internet full of similar issues and I tried all of suggested solutions, but can't figure out it at least 2 days.

I trying to deploy little Go server I using IntelliJ IDEA and it works great, it can build/run my code, but if I use terminal as example:

go build ./...

I see something like that:

OS-X-Dennis:backend denis$ go build ./...
out/production/mypocket_backend/server.go:4:2: cannot find package "api.jwt.auth/routers" in any of:
        /usr/local/go/src/api.jwt.auth/routers (from $GOROOT)
        /Users/denis/Programming/Golang/src/api.jwt.auth/routers (from $GOPATH)

OS X 10.11.2, IntelliJ IDEA 2016.1
$GOPATH = "Users/denis/Programming/Golang"
$GOROOT = "/usr/local/go"
$PATH = "$PATH:$GOPATH/bin"
These paths are correct?

Here is my work structure:

/Golang/
 .bin/
 .pkg/
    .darwin-amd64/
         .//other folders/
 .src/
     .github.com/
     .backend/ //project's source
           /src
              /api.jwt.auth/
                //source code
           .server.go - file with main func
          //other files as example .gitignore
     .//other folders// 

Here is my screen of main file and whole project-structure: enter image description here

I see that logs show me wrong path to my project.

 now
 /Users/denis/Programming/Golang/src/api.jwt.auth/routers
should
 /Users/denis/Programming/Golang/src/backend/src/api.jwt.auth/routers

I don't know where I should correct this path.

  • 写回答

1条回答 默认 最新

  • doumei1203 2016-04-04 14:59
    关注

    Your GOPATH can have multiple directories in it.

    If you truly want your backend directory to be a path of some of your Go libraries, in addition to your existing path of /Users/denis/Programming/Golang you can set your GOPATH to: /Users/denis/Programming/Golang:/Users/denis/Programming/Golang/src/backend

    This will cause import statements to search for source files in both the /Users/denis/Programming/Golang/src directory and the /Users/denis/Programming/Golang/src/backend/src directory.

    I would personally recommend moving your api.jwt.auth folder to /Users/denis/Programming/Golang/src/api.jwt.auth to keep your source all in one area, but having two different directories in your GOPATH as suggested above will work too.

    To understand GOPATH better, you can simply type go help gopath. Also a quickstart is here

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

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看