国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【Golang】排查 Build constraints exclude all the go files 的幾個思路

這篇具有很好參考價值的文章主要介紹了【Golang】排查 Build constraints exclude all the go files 的幾個思路。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

輸出該問題時說明在 Go 語言的啟動編譯(Build)階段,出現(xiàn)了編譯問題,往往是編譯配置的問題??梢酝ㄟ^以下思路去排查對應的錯誤。

一、查看 go env ??????

(1)首先可以查看被排除的 Go 文件是否啟用了條件編譯,通常的形式為在文件的首行添加(以 Linux 為例):

// +build linux
// 或
//go:build linux

// +build 會逐漸取代 //go:build,但 go 1.16 之前的版本只支持 //go:build。加上上述條件編譯后,該 Go 文件將只在 Linux 操作系統(tǒng)環(huán)境下才會被編譯,若是 MacOS 和 Windows 環(huán)境下將無法被編譯。解決方案是在 go env 和代碼編輯器中都配置好 GOOS 參數(shù)(VSCode 在左下角的 GO/env 中設置;GoLand 在左上角的 settings 中配置)。

go env -w GOOS=linux

(2)若非操作系統(tǒng)環(huán)境的問題,接著考慮是否有交叉編譯,即在 Go 語言編譯時調(diào)用了其他語言的情況,一般是 C 語言。此時需要在 go env 中開啟 CGO_ENABLED 特性。這樣在進行 go build 時,就會在編譯和鏈接階段啟動 gcc 編譯器。(經(jīng)評論指出,開啟 CGO_ENABLED 需要下載對應操作系統(tǒng)的 gcc 庫)

go env -w CGO_ENABLED=1

二、依賴包的依賴是否未導入 ??

在 go 的舊版本中基于 GOPATH 來尋找依賴,但可能依賴包的依賴未導入,可以考慮打開 GO111MODULE,實現(xiàn)模塊支持。go 命令行會使用modules,而完全不去 GOPATH 目錄下查找模塊。

go env -w GO111MODULE=on

三、是否存在重復依賴的情況 ??

這是我最終排查出的錯誤,因為在 GoLand 的 settings 中可以存在三個 GOPATH,分別是 Global、Project 和 Module 的 GOPATH。
Global 在 go env 中配置,Project 是項目的 GOPATH。若配置了多個 GOPATH,在導入二方或三方包時,可能在多個 GOPATH 下都有對應的緩存模塊,即重復依賴。此時需要刪除多余的 GOPATH。文章來源地址http://www.zghlxwxcb.cn/news/detail-608502.html

【Golang】排查 Build constraints exclude all the go files 的幾個思路,Go,golang,開發(fā)語言,后端

到了這里,關(guān)于【Golang】排查 Build constraints exclude all the go files 的幾個思路的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務器費用

相關(guān)文章

  • liunx nginx配置ssl 配置https 及訪問失敗問題排查(fopen:No such file or )([emerg] the “ssl“ parameter requires)

    liunx nginx配置ssl 配置https 及訪問失敗問題排查(fopen:No such file or )([emerg] the “ssl“ parameter requires)

    1.ssl證書下載 比如騰訊云下載目錄: 首先在網(wǎng)址(阿里云、騰訊云等)找到域名ssl下載,下載后解壓里面有xxx.yey、xxx.pem、xxx.crt等文件 在服務器nginx配置里新建個文件夾,如我的nginx 在 /usr/local/nginx這個目錄 2.將ssl證書文件拷貝至服務器 如: 3.檢查有沒有ssl插件(nginx -V 中V大寫

    2024年02月13日
    瀏覽(20)
  • Unity Error: In order to build a player go to ‘Player Settings...‘ to resolve the incompatibility be

    在Unity中切換安卓平臺時,出現(xiàn)這個問題,修改Player Setting–OtherSettings–Color Space* -- Gamma 比心~

    2024年02月12日
    瀏覽(24)
  • 解決go build 構(gòu)建問題 go:build comment without // +build comment

    記錄一個go build 構(gòu)建的問題 main.go 文件 腳本功能是監(jiān)聽8081端口訪問,打印訪問的頭信息日志 執(zhí)行g(shù)o build 構(gòu)建 報錯 排查了代碼應該是沒有問題,必應網(wǎng)站查詢問題原因,可能是go 的版本 是低于1.17版本 導致出現(xiàn)的問題,go 引入的依賴庫包中 1.17版本后 引入了新的構(gòu)建標記語

    2024年02月16日
    瀏覽(55)
  • Could not resolve all files for configuration ‘:app:androidJdkImage‘.

    在使用 ./gradlew build 編譯項目時候遇到了該問題,整體錯誤如下: 可以看出使用的sdk版本為34,java版本為21. 解決辦法為,修改java版本為17。本地重新下載Java17的jdk,這樣本地就會有21、17兩個版本,然后在項目中指定依賴的java版本17并配置路徑(也可以配置環(huán)境變量) gradle.prope

    2024年02月01日
    瀏覽(38)
  • Could not resolve all files for configuration ‘:app:androidApis‘

    Could not resolve all files for configuration ‘:app:androidApis‘

    ?我在第一次使用AndroidStudio時,編譯項目遇到了此問題 Could?not?resolve?all?files?for?configuration?\\\':app:androidApis\\\'. Failed?to?transform?file?\\\'android.jar\\\'?to?match?attributes?{artifactType=android-mockable-jar,?returnDefaultValues=false}?using?transform?MockableJarTransform Cannot?create?mockable?android.jar inval

    2024年02月04日
    瀏覽(24)
  • All the stories begin at installation

    All the stories begin at installation

    Before installation, there are some key points about Conan: “Conan is a dependency and package manager for C and C++ languages.” “With full binary management, Conan can create and reuse any number of different binaries (for different configurations like architectures, compiler versions, etc.) for any number of different versions of a package, using exa

    2024年02月20日
    瀏覽(20)
  • Build input file cannot be found: .pch

    Build input file cannot be found: .pch

    xcode真機運行時,報錯: Build input file cannot be found: /Users/mac/Desktop/projects/xxx/xxx.pch 實際查看發(fā)現(xiàn),項目中的.pch文件存在,但運行時報錯。修改配置里的.pch文件路徑后,正常。

    2024年02月13日
    瀏覽(23)
  • Android Could not resolve all files for configuration ‘:app:debugRuntimeClasspath‘

    Android Could not resolve all files for configuration ‘:app:debugRuntimeClasspath‘

    Could not resolve all files for configuration ‘:app:debugRuntimeClasspath’. Could not find com.just.agentweb:agentweb-androidx:4.1.4. Searched in the following locations: 打開settings.gradle文件,加入代碼 maven { url ‘https://maven.google.com’ } 如下所示: 重新編譯看問題是否解決,如果沒有再接著往下看. 點擊File-Sett

    2024年02月12日
    瀏覽(25)
  • Build File Explorer Applications in RAD Studio 12

    Build File Explorer Applications in RAD Studio 12

    December 13, 2023 ShellBrowser Delphi Components v12.1 now support RAD Studio 12 Athens, enabling developers to easily embed File Explorer functionality into their Delphi apps. ShellBrowser Delphi Components let you harness the familiar Windows Explorer experience within your Delphi or C++Builder applications. These components seamlessly replicate the functi

    2024年02月04日
    瀏覽(52)
  • go build

    作用:將Go語言程序和相關(guān)依賴編譯成可執(zhí)行文件 生成 當前目錄名 的可執(zhí)行文件并放置于當前目錄下,如: go build 編譯同目錄的多個源碼文件時,可以在 go build 的后面提供多個文件名,go build 會編譯這些源碼,輸出可執(zhí)行文件,“go build+文件列表”的格式如下: go build f

    2024年02月21日
    瀏覽(8)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包