How to convert binary code to go line syntax in main.go

124 Views Asked by At

Few days back code was showing like proper Go syntax. Not sure which command I ran but now main.go code is showing like this. May be this go build -gcflags='all=-N -l' -o main.go command converted code to binaries compile code. enter image description here

Any idea how to recover back actual code ?

1

There are 1 best solutions below

2
Zac Anger On

The -o flag says "compile out to this file," so you overwrote your source with the compiled binary.

There are efforts to reverse engineer a binary, like the things mentioned here, but they're not going to get you back your exact code, or probably something even all that readable or complete, depending on how large your program was.

Use Git to track your code, and use a Makefile or some other build system (even a little batch script) so you don't have to type out the command every time.