当前位置:网站首页>Go exe generates icon version information
Go exe generates icon version information
2022-07-28 18:40:00 【Compose】
Why add icons and details
As a desktop program , There is an icon , Be more formal . The detailed information has a version number to facilitate version identification . Forget it , I can't make it up . No matter how much , Anyway, others have these , You should have these functions ( but ).golang As a back-end language , Yes windows Interface programming support is not so friendly , It is difficult to add icons and details directly . Fortunately, there is a third-party library –GoVersionInfo, It can help us solve this problem .
GoVersionInfo Is used for Go Linguistic Microsoft Windows File attribute / Version information and icon resource generator
The package will create a syso file , It includes Microsoft Windows Version information and an optional icon . When you run “ go build” when ,Go Version information as well as optional icons and optional lists will be embedded in the executable . If it's with main() Functions are located in the same directory , be Go Will be used automatically syso file .
install GoVersionInfo
go get github.com/josephspurrier/goversioninfo/cmd/goversioninfo Download the just downloaded GoVersionInfo The catalog of github.com\josephspurrier\goversioninfo\testdata\resource Copy to our project directory (main.go In the directory ). And put versioninfo.json Copy to and main.go Same as catalog .
Modify file
stay main.go Add... To the first line of :
main.go Add notes
//go:generate goversioninfo -icon=jiuwei.ico -manifest=main.exe.manifestThen modify and main.go Under the same level of directory versioninfo.json file . Put the fields inside “ProductVersion” Change to the version number you want .( You can also modify other information, such as : Copyright , The product name , Document description, etc )
{
"FixedFileInfo": {
"FileVersion": {
"Major": 1,
"Minor": 0,
"Patch": 0,
"Build": 0
},
"ProductVersion": {
"Major": 1,
"Minor": 0,
"Patch": 0,
"Build": 0
},
"FileFlagsMask": "3f",
"FileFlags ": "00",
"FileOS": "040004",
"FileType": "01",
"FileSubType": "00"
},
"StringFileInfo": {
"Comments": "Test file.",
"CompanyName": "Test",
"FileDescription": "Test",
"FileVersion": "v1.0.0.0",
"InternalName": "Test.exe",
"LegalCopyright": " copyright ",
"LegalTrademarks": "",
"OriginalFilename": "Test.exe",
"PrivateBuild": "",
"ProductName": "Test",
"ProductVersion": "v1.0.0.0",
"SpecialBuild": ""
},
"VarFileInfo": {
"Translation": {
"LangID": "0409",
"CharsetID": "04B0"
}
},
"IconPath": "",
"ManifestPath": ""
}First use ,go generate Command to generate resource.syso Resource file
Reuse ,go build Command to generate EXE file . You need to use Directory The way to compile , Out-of-service File The way to compile .( That is to say, it can't be used go build main.go This way, ). The reason is through Directory The way to compile , The compiler will automatically find the resource files in the same directory and package them into EXE.
During the compilation process , You may encounter errors
C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `C:\Users\hjd\AppData\Local\Temp\go-link-681106599\000000.o' is incompatible with i386:x86-64 output
collect2.exe: error: ld returned 1 exit status
The above solution is , Compile with parameters
-ldflags="-linkmode internal"
go build -o myapp.exe -ldflags="-linkmode internal" -ldflags="-H windowsgui"
go build -o ./myapp.exe -ldflags="-linkmode internal" -ldflags="-H windowsgui"
The reason why I have -ldflags="-H windowsgui" Is to cancel the black window the reason being that GUI Interface
边栏推荐
- Go语言系列之日志库zap
- Six countries in Europe and the United States launched an express line product to optimize the "end-to-end" performance service on the 5th
- Is the training institution of software testing reliable
- Meta Q2财报:营收首次下滑,Metaverse将与苹果竞争
- Record your interview experience in Xiamen for two years -- Conclusion
- Mqtt over quic: the next generation Internet of things standard protocol injects new impetus into the message transmission scenario
- 连线:谁拥有未来的艺术?OpenAI允许Dall-E用户将作品商用化,目前而言
- 记录自己在厦门两年来的面试经历--完结篇
- There is a special cryptology language called asn.1
- Error 2003 (HY000) can't connect to MySQL server on 'localhost3306' (10061) solution
猜你喜欢

insight! Baidu pushed redis ceiling notes, which was originally understood by the database

1.2、队列

Random talk on GIS data (VI) - projection coordinate system

DC-DC switching power supply

Tcp/ip detailed diagram

Brief introduction: basic principle of srv6

Detailed explanation of oscilloscope parameters

Experimental building - PHP Dafa

Docker搭建Mysql主从复制

高德地图实现自定义小蓝点 自定义点标记 绘制多边形/圆形区域 根据地图的移动显示或者隐藏自定义点标记的相关实现
随机推荐
Seven steps, in-depth interpretation of data meaning
iptables 配置
当Golang遇到高并发秒杀
Novice record: some small knowledge of mechanical keyboard
数字化转型中的DevOps——弹性合作
Ue5 gas learning notes 1.2 game Tags
mysql 索引使用与优化
Mongodb create index
Shenzhen offline registration starrocks on AWS: how to conduct rapid unified analysis of real-time data warehouses
Meta Q2财报:营收首次下滑,Metaverse将与苹果竞争
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法
数字化洪流 :企业转型中的资源重组与战略冲突
Go的sleep
solidity转账函数的实现(基于transfer)
不理解模块化、组件化、插件化的区别怎么行?
Examples of AC simulation and S-parameter simulation of ADS simulation
顿悟!百度强推的Redis天花板笔记,原来数据库是这样理解的
NPM cannot recognize the "NPM" item as the name of a cmdlet, function, script file, or runnable program. Please check the spelling of the name. If the path is included, make sure the path is correct,
LeetCode_96_不同的二叉搜索树
Go's walk library reports an error