Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the "file version" field in PE header of EXE files?

I use go build to build a exe file.Then i view the property of the file(Right click the file -> property),In detail tab,the file's version is empty.

How i to set the version of the exe file.

enter image description here

like image 803
Dev Zhou Avatar asked Feb 01 '16 08:02

Dev Zhou


2 Answers

The EXE file version and other info are embedded as resources, which are specific to Windows and thus not supported by the Go compiler. You can use the package GoVersionInfo to accomplish this (it also supports embedding an icon). I haven't tried it myself, but it looks promising and well documented.

like image 113
rob74 Avatar answered Oct 16 '22 01:10

rob74


There is go-winres which lets you do this, either before or after go build.

Run go install github.com/tc-hib/go-winres@latest to install it. Then, inside your project folder, run go-winres init. This creates a subfolder named winres.

Modify winres/winres.json, and replace the icon.

Run go-winres make. This creates a .syso file. Run go build and see the result.

If you want to add a language, there's an example in the readme file. I didn't manage to do it with goversioninfo, while it works with go-winres.

like image 3
John N Avatar answered Oct 16 '22 01:10

John N