mirror of
https://github.com/emojisum/emojisum.git
synced 2025-07-16 13:50:27 +00:00
emoji: make the list an independent doc
during this draft phase, the authoritative document for the ordering of the emoji needs to be consumable by other languages and as a library. Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
a2456feb8f
commit
2332d1260c
6 changed files with 583 additions and 266 deletions
47
emoji/map_json.go
Normal file
47
emoji/map_json.go
Normal file
|
@ -0,0 +1,47 @@
|
|||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
func main() {
|
||||
input, err := os.Open("map-draft.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer input.Close()
|
||||
|
||||
// these are an ordered list, referened by a byte (each byte of a checksum digest)
|
||||
Map := []string{}
|
||||
|
||||
dec := json.NewDecoder(input)
|
||||
if err := dec.Decode(&Map); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
output, err := os.Create("map_gen.go")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer output.Close()
|
||||
if err := mapGoTemp.Execute(output, Map); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
mapGoText = `// THIS FILE IS GENERATED. DO NOT EDIT.
|
||||
|
||||
package emoji
|
||||
|
||||
var sumList = []string{ {{- range . }}
|
||||
"{{.}}",{{- end }}
|
||||
}
|
||||
`
|
||||
mapGoTemp = template.Must(template.New("map.go").Parse(mapGoText))
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue