1
0
Fork 0
mirror of https://github.com/emojisum/emojisum.git synced 2024-11-24 00:15:39 +00:00
emojisum/emoji/map_json.go
Vincent Batts 3efa665df0
emoji: more of a draft of a convention
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-12-13 14:19:18 -05:00

46 lines
840 B
Go

// +build ignore
package main
import (
"encoding/json"
"flag"
"log"
"os"
"text/template"
"github.com/vbatts/emojisum/emoji"
)
func main() {
flag.Parse()
input, err := os.Open(*flInput)
if err != nil {
log.Fatal(err)
}
defer input.Close()
vm := emoji.VersionedMap{}
dec := json.NewDecoder(input)
if err := dec.Decode(&vm); err != nil {
log.Fatal(err)
}
output, err := os.Create(*flOutput)
if err != nil {
log.Fatal(err)
}
defer output.Close()
mapGoTemp := template.Must(template.ParseFiles(*flTemplate))
if err := mapGoTemp.Execute(output, vm); err != nil {
log.Fatal(err)
}
}
var (
flInput = flag.String("in", "emojimap.json", "json input")
flOutput = flag.String("out", "map_gen.go", "golang output")
flTemplate = flag.String("template", "map_gen.tmpl", "template of golang source to use")
)