Does not make sense that I have to have files before import

后端 未结 3 1692
無奈伤痛
無奈伤痛 2021-01-14 07:55

How do I import an external package from scratch?

I\'ve written a library package in Go and testing to distribute through github. I am following http://golang.org/do

3条回答
  •  醉话见心
    2021-01-14 08:43

    From the help output for go get, it says:

    By default, get uses the network to check out missing packages but does not use it to look for updates to existing packages.

    When you created the $GOPATH/src/github.com/user/project directory prior to running go get, it assumed that the package had already been downloaded so skipped to the step of trying to build and install the package. That failed because the directory contained no Go source files.

    So the simple fix is to not create the folder associated with the package you are trying to download: go get will do that for you.

提交回复
热议问题