Search code examples
gogo-build

Why open the go build's binary file with vim, I can see some source repositories info?


In windows, new go file: test.go

package main

import (
    "fmt"
)

func main() {
    fmt.Println("Hello World!")
}

Then run go build test.go and then vim test.exe.

Search test.go, I can see many dir infos.

Why it happens and how to hide the info?


Solution

  • Why it happens ?

    The golang is a compiled language - that's mean it uses compiler (translators that generate machine code from source code). The test.exe file is a source code compiled into machine code.

    How to hide the info?

    The binary file (compiled program) contains all data(the source code, the .data section, strings and so on), you can't hide that info from binary, there is no way to do that, all that you can do is obfuscate somehow your source code.