github.com/aminjam/goflat@v0.4.1-0.20160331105230-ec639fc0d5b3/scripts/embed_runtime.go (about) 1 package main 2 3 import ( 4 "io" 5 "io/ioutil" 6 "os" 7 "path/filepath" 8 "strings" 9 ) 10 11 func main() { 12 fs, _ := ioutil.ReadDir("runtime") 13 runtime_files := []string{"main.gotempl", "pipes.go"} 14 15 out, _ := os.Create("runtime.go") 16 out.Write([]byte("package goflat\n\nconst (\n")) 17 for _, f := range fs { 18 for _, runtime_file := range runtime_files { 19 if runtime_file == f.Name() { 20 varName := strings.Replace(strings.Title(f.Name()), ".", "", -1) 21 fPath := filepath.Join("runtime", f.Name()) 22 out.Write([]byte(varName + " = `")) 23 f, _ := os.Open(fPath) 24 io.Copy(out, f) 25 out.Write([]byte("`\n")) 26 } 27 } 28 } 29 out.Write([]byte(")\n")) 30 }