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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀