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 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题