lxn / walk

A Windows GUI toolkit for the Go Programming Language
Other
6.78k stars 885 forks source link

in the incoming go-1.16 , we can use the ‘’embed‘’ lib to embed static resources,so how can i use this way to embed the manifest file to build the exe instead of using the "github.com/akavel/rsrc" lib ;thanks #748

Open GodGavin opened 3 years ago

GodGavin commented 3 years ago

in the incoming go-1.16 , we can use the ‘’embed‘’ lib to embed static resources,so how can i use this way to embed the manifest file to build the exe instead of using the "github.com/akavel/rsrc" lib ;thanks

alkanna commented 3 years ago

It works with compiler instructions. The imported type should be string, []byte or FS. Short example, don't forget to import embed :

//go:embed hello.txt
var f embed.FS
data, _ := f.ReadFile("hello.txt")
print(string(data))

For more information, you can check this issue : https://github.com/golang/go/issues/41191

Another example, as string :

package main

import _"embed"

func main() {
    //go:embed "hello.txt"
    var s string
    print(s)
}
tc-hib commented 3 years ago

You can't. The manifest has to be in a specific section of the exe file. This is different from the embed package.

You may use go-winres, if you wish. It builds the manifest for you:

go install github.com/tc-hib/go-winres@latest
go-winres simply --manifest gui

Or in the code, for go generate:

//go:generate go-winres simply --manifest gui