You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
616 B
Go
32 lines
616 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
args := flag.Args()
|
|
b, err := ioutil.ReadFile(args[0])
|
|
if err != nil {
|
|
fmt.Printf("Couldn't read '%s': %v\n", args[0], err)
|
|
os.Exit(1)
|
|
}
|
|
out, _ := os.Create(args[1])
|
|
defer out.Close()
|
|
|
|
out.Write([]byte("package main \n\n//THIS FILE IS AUTOMATICALLY GENERATED BY `go generate` DO NOT EDIT!\n\nvar " + args[2] + " = []byte{\n"))
|
|
for i, c := range b {
|
|
out.Write([]byte(strconv.Itoa(int(c))))
|
|
out.Write([]byte(","))
|
|
if i%32 == 0 && i != 0 {
|
|
out.Write([]byte("\n"))
|
|
}
|
|
}
|
|
out.Write([]byte("}\n"))
|
|
}
|