首頁  >  文章  >  後端開發  >  Go Build刪除訊息

Go Build刪除訊息

王林
王林轉載
2024-02-10 15:00:111186瀏覽

Go Build删除信息

php小編百草Go Build是一款功能強大的資訊刪除工具,它可以幫助使用者快速、有效率地刪除各類資訊。無論是刪除無用資訊、清理垃圾郵件、清除個人隱私,或是清除瀏覽記錄,Go Build都能輕鬆應付。借助其智慧演算法,使用者只需簡單幾步操作,即可完成資訊刪除任務。 Go Build不僅操作簡單,而且安全可靠,保護使用者的隱私不受侵犯。無論是個人用戶或企業用戶,Go Build都是不可或缺的工具,讓資訊刪除變得更方便有效率。

問題內容

我已經可以使用Go Build刪除項目當前目錄信息,也可以刪除Gopath信息,如下,我現在只能單獨刪除其中一個

go build -gcflags“all=-trimpath=${GOPATH}”-asmflags“all=-trimpath=${GOPATH}”

p>

但我不知道如何同時刪除它們,我不知道如何組合它 在 Windows 上,我嘗試這個

go build -gcflags“all=-trimpath=�%” -asmflags“all=-trimpath=�%” -gcflags“all=-trimpath=%GOPATH%” -asmflags“all=-trimpath= %” GOPATH%"

不起作用

最終結果

@ZekeLu,答案是正確的。 我想解釋一下發生了什麼,我本來希望去掉GOROOT訊息,但是我寫了GOPATH,所以我以為@ZekeLu的第二個答案是錯誤的,現在我修改並測試了,沒有問題,兩個答案都對解決方法嘗試這個指令:

go build -trimpath
這是 go 指令的

-trimpath### 標誌的文件###:### ###-修剪路徑### ###從產生的可執行檔中刪除所有檔案系統路徑。 記錄的檔案名稱而不是絕對檔案系統路徑 將開始模組路徑@版本(使用模組時), 或普通導入路徑(使用標準函式庫或 gopath 時)。 ### ###如果你只想刪除一些前綴,你可以這樣做:###
go build -gcflags "all=-trimpath=%cd%;%gopath%" -asmflags "all=-trimpath=%cd%;%gopath%"
######編譯指令###和###asm 指令### 呼叫 ###objabi.applyrewrites### 來修剪路徑。根據 ###objabi 的實作.applyrewrites###,###rewrites### 參數是一個以 ; 分隔的重寫清單。 ###
// ApplyRewrites returns the filename for file in the given directory,
// as rewritten by the rewrites argument.
//
// The rewrites argument is a ;-separated list of rewrites.
// Each rewrite is of the form "prefix" or "prefix=>replace",
// where prefix must match a leading sequence of path elements
// and is either removed entirely or replaced by the replacement.
func ApplyRewrites(file, rewrites string) (string, bool) {
    start := 0
    for i := 0; i <= len(rewrites); i++ {
        if i == len(rewrites) || rewrites[i] == ';' {
            if new, ok := applyRewrite(file, rewrites[start:i]); ok {
                return new, true
            }
            start = i + 1
        }
    }

    return file, false
}

以上是Go Build刪除訊息的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:stackoverflow.com。如有侵權,請聯絡admin@php.cn刪除