duanliang1898 2014-09-01 09:20
浏览 725
已采纳

如何在golang中设置应用程序图标?

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 support resources.

  • 写回答

3条回答 默认 最新

  • douyuai8994 2014-09-01 11:29
    关注

    You can use a tool like akavel/rsrc in order to generate a .syso file with specified resources embedded in .rsrc section, aimed for consumption by Go linker when building Win32 excecutables.

    See as an example the lxn/walk application, which embeds other metadata in its executable.

    rsrc [-manifest FILE.exe.manifest] [-ico FILE.ico[,FILE2.ico...]] -o FILE.syso
    

    -ico="": comma-separated list of paths to .ico files to embed


    This differs from embedding binary data into a go program.
    For that, use jteeuwen/go-bindata.

    To access asset data, we use the Asset(string) []byte function which is included in the generated output.

    data := Asset("pub/style/foo.css")
    if len(data) == 0 {
        // Asset was not found.
    }
    
    // use asset data
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?