1、获取rsrc
go install github.com/akavel/rsrc@latest
在项目根目录中创建*.manifest文件(文件名没有过多局限,不过按照要求来也没错)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
2、编译 *.syso
rsrc -manifest .\test.manifest -o test.syso
文件名无要求
3、go编译打包
go build .
4、优化
如果需要做到windows全系列兼容,可以在<assembly>
标签下面增加以下内容:
<!-- OSVersion -->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedos id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"></supportedos>
<!-- Windows 8.1/Windows Blue/Server 2012 R2 -->
<supportedos id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"></supportedos>
<!-- Windows Vista/Server 2008 -->
<supportedos id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedos>
<!-- Windows 7/Server 2008 R2 -->
<supportedos id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"></supportedos>
<!-- Windows 8/Server 2012 -->
<supportedos id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedos>
</application>
</compatibility>
Copy
支持Windows 6.0界面库、支持管理员权限、兼容WIN8/WIN10下取系统版本、兼容DPI Aware,完整manifest可以参考https://blog.csdn.net/cometnet/article/details/52995192