Go build: “Cannot find package” (even though GOPATH is set)

前端 未结 9 1512
庸人自扰
庸人自扰 2020-12-04 07:35

Even though I have GOPATH properly set, I still can\'t get \"go build\" or \"go run\" to find my own packages. What am I doing wrong?

$ echo $GO         


        
9条回答
  •  遥遥无期
    2020-12-04 08:02

    In the recent go versions from 1.14 onwards, we have to do go mod vendor before building or running, since by default go appends -mod=vendor to the go commands. So after doing go mod vendor, if we try to build, we won't face this issue.

提交回复
热议问题