How do you set the application icon in golang?

前端 未结 5 976
抹茶落季
抹茶落季 2021-01-30 09:14

I\'ve just created my first go application on Windows.

How do I give it an icon?

There doesn\'t seem to be any build flags to do this, and I know golang doesn\'t

5条回答
  •  你的背包
    2021-01-30 09:51

    The topic is long time, in fact mingw is only requirement, we don't need 3rd party dependency. In addition, resource file *.rc is mandatory for win32 executable application. At last, you can find the demo in rc-demo

    1) Install mingw using Chocolatey: choco install mingw

    2) Create main.exe.manifest file

    
    
    
    
        
            
        
    
    
    

    3) Create main.rc file

    100 ICON    "main.ico"
    100 24      "main.exe.manifest"
    101 RCDATA  "content.zip"
    

    4) Build

    In git-bash windows perform the following command: windres -o main-res.syso main.rc && go build -i

提交回复
热议问题