embed.go (411B)
1 package main 2 3 import ( 4 "io/ioutil" 5 "os" 6 "fmt" 7 ) 8 9 func main() { 10 assets, _ := ioutil.ReadDir("assets") 11 out, _ := os.Create("assets.go") 12 out.Write([]byte("package main\n\nvar Assets = map[string][]byte{\n")) 13 for _, asset := range assets { 14 assetFile, _ := ioutil.ReadFile("assets/" + asset.Name()) 15 fmt.Fprintf(out, "\t\"%s\": []byte(%q),", asset.Name(), string(assetFile)) 16 } 17 out.Write([]byte("}\n")) 18 }