How to embed files into Go binaries

===== Edit Jan 2021 ===== Starting with Go 1.16, released in Feb 2021, you can use the go:embed directive: import “embed” //go:embed hello.txt var s string print(s) //go:embed hello.txt var b []byte print(string(b)) //go:embed hello.txt var f embed.FS data, _ := f.ReadFile(“hello.txt”) print(string(data)) ===== Original answer ====== Since Go 1.4, you can use go generate … Read more