Leave a Comment
Embedding assets to go binary in go 1.16
That’s how you can use it:
package server
import "embed"
// content holds our static web server content.
//go:embed image/* template/*
//go:embed html/index.html
var content embed.FS
data, _ := f.ReadFile("html/index.html")
print(string(data))
Or embedding one file directly into a variable:
import _ "embed" //go:embed hello.txt var s string print(s)
More details — https://golang.org/pkg/embed/
LEAVE A COMMENT
Для отправки комментария вам необходимо авторизоваться.