Go Build delete information

王林
Release: 2024-02-10 15:00:11
forward
1186 people have browsed it

Go Build删除信息

php editor Baicao Go Build is a powerful information deletion tool that can help users delete all kinds of information quickly and efficiently. Whether it is deleting useless information, cleaning spam, erasing personal privacy, or clearing browsing history, Go Build can handle it easily. With its intelligent algorithm, users can complete the information deletion task in just a few simple steps. Go Build is not only simple to operate, but also safe and reliable, protecting users' privacy from infringement. Whether it is an individual user or a corporate user, Go Build is an indispensable tool that makes information deletion more convenient and efficient.

Question content

I can already use Go Build to delete the current directory information of the project, and I can also delete the Gopath information, as shown below. Now I can only delete one of them individually

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

But I don't know how to delete them simultaneously, I don't know how to combine it

On Windows I try this

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

Not working

Final Results

@ZekeLu, the answer is correct.

I want to explain what happened, I originally wanted to remove the GOROOT information, but I wrote GOPATH, so I thought @ZekeLu's second answer was wrong, now I modified it and tested it, no problem, both The answers are all correct p>

Solution

Try this command:

go build -trimpath
Copy after login

This is the documentation for the -trimpath flag of the go command:

-Trim path

Remove all file system paths from the generated executable. Logged filename instead of absolute filesystem path will start module path@version (when using modules), Or a normal import path (when using the standard library or gopath).

If you just want to remove some prefixes, you can do this:

go build -gcflags "all=-trimpath=%cd%;%gopath%" -asmflags "all=-trimpath=%cd%;%gopath%"
Copy after login

Compile commands and asm commands call objabi.applyrewrites to prune paths. According to objabi's implementation of .applyrewrites, the rewrites argument is a ;-separated list of 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
}
Copy after login

The above is the detailed content of Go Build delete information. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!