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条)

报告相同问题?

悬赏问题

  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决