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

如何在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条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!