2018-06-29 22:31
浏览 199


The error message is:

app.go:9:3: cannot find package "" in any of:
    /usr/local/Cellar/go/1.10.3/libexec/src/ (from 
    /Users/myname/go/src/ (from $GOPATH)

I understand GOROOT is for compiler tools that come with installation, so I am not sure why it looks for mux there. But I do see mux in the second location in my directory I created for go code.

I know this question was asked once before and I tried to debug following the advice from that question.

I used homebrew and installed go version go1.10.3 darwin/amd64.

Here is what I believe to be the relevant portion of my go env:


I also set my bash profile, excluding GOROOT because that is no longer required:

export GOPATH="/Users/myname/go/src/"
export PATH="/Users/myname/go/src/$PATH"

And did source ~/.bash_profile.

This setup was enough that I can run basic go programs like hello world. So I then tried to run code using the mux library.

I first installed mux within the directory of my program (cd'd into /Users/myname/go/src/

Then I ran:

go get -u

I can see the folder exists in my finder. I also looked in terminal:

ls -l /Users/myname/go/src/ | grep gorilla
=> drwxr-xr-x  3 myname  staff  102 Jun 29 14:35 gorilla


cd $GOPATH (/Users/myname/go)
go list ... | grep gorilla 
=> can't load package: package ../..: no Go files in /Users

So I saw gorilla in the first command but not the second. However, I do see the gorilla directory further within my go directory, so I'm not sure what the issue is.

Running go build returns the package of concern:

app.go:9:3: cannot find package "" in any of:
(from $GOROOT)
  /Users/myname/go/src/ (from $GOPATH)

I am not sure why it is looking for mux within the usr directory. Is there an issue with any of my paths? I keep checking that last path to see that the mux directory is there.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题