3 ms·
The go:embed directive and embed.FS interface are great, as expected. If you're developing an AGPL or similarily licensed application it's incredibly easy to di
by minieggs 6y ago
The go:embed directive and embed.FS interface are great, as expected. If you're developing an AGPL or similarily licensed application it's incredibly easy to distribute source code with the application.
//go:embed main.go go.mod go.sum LICENSE README makefile static/*
var sourceCode embed.FS
// ...
func main() {
// ...
http.Handle("/source/", http.StripPrefix("/source/", http.FileServer(http.FS(sourceCode))))
// ...
}
- mseepgood 6y agoAlso quines become incredibly easy: package main import ( _ "embed" "fmt" ) //go:embed quine.go var src string func main() { fmt.Print(src) }