首先准备ico文件,如favicon.ico
新建.rc文件,内容为:
IDI_ICON1 ICON "favicon.ico"
创建manifest文件
- 文件名:go文件名.exe.manifest
- 文件内容
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="x86"
name="controls"
type="win32"
></assemblyIdentity>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>
生成syso文件
$ rsrc -manifest go文件名.exe.manifest -ico favicon.ico -o go文件名.syso
编译
$ go build