walk icon indicating copy to clipboard operation
walk copied to clipboard

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

Open GodGavin opened this issue 5 years ago • 2 comments

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

GodGavin avatar Dec 16 '20 09:12 GodGavin

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

alkanna avatar Jan 11 '21 11:01 alkanna

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

tc-hib avatar Mar 08 '21 09:03 tc-hib