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
4 years ago
|
package main
|
||
|
|
||
|
import (
|
||
3 years ago
|
"flag"
|
||
4 years ago
|
"fmt"
|
||
|
"io/ioutil"
|
||
|
"os"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
3 years ago
|
flag.Parse()
|
||
|
args := flag.Args()
|
||
|
b, err := ioutil.ReadFile(args[0])
|
||
4 years ago
|
if err != nil {
|
||
3 years ago
|
fmt.Printf("Couldn't read '%s': %v\n", args[0], err)
|
||
4 years ago
|
os.Exit(1)
|
||
|
}
|
||
3 years ago
|
out, _ := os.Create(args[1])
|
||
4 years ago
|
defer out.Close()
|
||
|
|
||
3 years ago
|
out.Write([]byte("package main \n\n//THIS FILE IS AUTOMATICALLY GENERATED BY `go generate` DO NOT EDIT!\n\nvar " + args[2] + " = []byte{\n"))
|
||
4 years ago
|
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"))
|
||
|
}
|