如何在Fyne和Golang上编译一个带有图片的项目?

huangapple go评论88阅读模式
英文:

how to compile a project on fyne and golang with images?

问题

我有一个项目,其中我使用函数"file.Load Resource From Path("resources/img/planets/mercury.png")"上传图像,但是当我尝试使用命令"fyne-cross windows -arch=*"编译项目并从当前目录传输EXE文件时,我的程序中的图片无法显示。

我执行了"go build main.go"和"fyne-cross windows -arch=386",但我不知道我可以做什么。

如何在Fyne和Golang上编译一个带有图片的项目?
如何在Fyne和Golang上编译一个带有图片的项目?
如何在Fyne和Golang上编译一个带有图片的项目?

英文:

I have a project where I upload images with the function: "file.Load Resource From Path("resources/img/planets/mercury.png")", but when I try to compile the project with the command: "fyne-cross windows -arch=*" and transfer the EXE FILE where from the current directory, the pictures in my program are not displayed

go build main.go, fyne-cross windows -arch=386
I don't know what I can doing
如何在Fyne和Golang上编译一个带有图片的项目?
如何在Fyne和Golang上编译一个带有图片的项目?
如何在Fyne和Golang上编译一个带有图片的项目?

答案1

得分: 1

“resources”文件夹只是你的源代码的一部分。Fyne(就像Go一样)应用程序是单个二进制文件,不会与资源一起分发。如果你想包含这样的项目,你应该将它们捆绑在一起 - 使用“fyne bundle”或“go embed”可以为你解决这个问题。

英文:

The “resources” folder is just part of your source code. Fyne (like Go) apps are single binaries and not distributed with assets. If you want to include items like that you should bundle them - “fyne bundle” or “go embed” will sort this for you.

huangapple
  • 本文由 发表于 2023年3月6日 02:56:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/75644622.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定