2 回答

MMTTMM
TA貢獻(xiàn)1869條經(jīng)驗 獲得超4個贊
If the name of a package does not start with . or /, like “fmt” or “container/list”, Go looks for it inthe global Go tree. If it starts with ./ the package is searched in the actual directory; starting with /(even on Windows) it is searched for in the (absolute) path indicated.
出自 The Way To Go
按照我自己理解解釋下:
$GOROOT 系統(tǒng)中Go的根目錄
$GOPATH 用來安裝第三方包的目錄,自己隨便指定
例如,使用 go get xxx 安裝的包會被放到 $GOPATH/src 下面
對于自己寫的模塊,最簡單的方式就是用相對或絕對路徑導(dǎo)入
如果想方便地在全局使用,像 "import "fmt"
一樣
推薦在$GOPATH/src下建立相應(yīng)的package,當(dāng)然放$GOROOT也是可以的
- 2 回答
- 0 關(guān)注
- 1841 瀏覽
添加回答
舉報
0/150
提交
取消