」工欲善其事,必先利其器。「—孔子《論語.錄靈公》
首頁 > 程式設計 > 包在構建時找不到原因及解決方法

包在構建時找不到原因及解決方法

發佈於2025-04-16
瀏覽:320

Why Can't Go Find My Package During Build, and How Do I Fix It?
fixing fixing“無法在go build

Understanding the Package Directory Structure

Go expects packages to reside in directories with the same name as their package names.導入軟件包時,“導入”語句指定軟件包名稱,而不是源文件名。因此,在您的示例中,應將foobar.go放在$ gopath/src/foobar/。

配置路徑(建議):

Organize Your Code:

Place main.go in a subfolder under $GOPATH/src to better organize your projects.

Use "go install": Execute "go install test" (assuming your project is now in $GOPATH/src/test/) to install $ gopath/bin中的可執行文件,允許您直接從終端運行。

最新教學 更多>

免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。

Copyright© 2022 湘ICP备2022001581号-3