mirror of
https://github.com/emojisum/emojisum.git
synced 2025-02-02 15:43:32 +00:00
emoji: more of a draft of a convention
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
2332d1260c
commit
3efa665df0
8 changed files with 637 additions and 536 deletions
|
@ -6,6 +6,10 @@ I attempted a curated list of 256 emojis that are not entirely similar. Using ht
|
||||||
|
|
||||||
So 1 emoji is 2 hex positions.
|
So 1 emoji is 2 hex positions.
|
||||||
|
|
||||||
|
## draft practice
|
||||||
|
|
||||||
|
For information on the draft for broader practice, see [the draft](./emoji/README.md).
|
||||||
|
|
||||||
## build
|
## build
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -1,5 +1,64 @@
|
||||||
# emojisum mapping
|
Emoji Working Group
|
||||||
|
|
||||||
The JSON is the authority of ordering. While this package is importable by
|
Category: Informational
|
||||||
golang projects, other languages can fetch the ordered list of the JSON
|
|
||||||
document and do their own emojisum comparison or rendering.
|
|
||||||
|
# emoji checksum mapping
|
||||||
|
|
||||||
|
## Status of This Document
|
||||||
|
|
||||||
|
This document provides information for the community. This document does not
|
||||||
|
specify a standard of any kind. It is open to suggestions and discussion for
|
||||||
|
improvements. This document is presently a draft and will apply versioning of
|
||||||
|
the documents as needed. Distribution of this document is unlimited.
|
||||||
|
|
||||||
|
|
||||||
|
## Notices
|
||||||
|
|
||||||
|
Permission is granted to copy and distribute this document for any purpose and
|
||||||
|
without charge, including translations into other languages and incorporation
|
||||||
|
into compilations, provided that the copyright notice and this notice are
|
||||||
|
preserved, and that any substantive changes or deletions from the original are
|
||||||
|
clearly marked.
|
||||||
|
|
||||||
|
A pointer to the latest version of this and related documentation in HTML
|
||||||
|
format can be found at the URL
|
||||||
|
[http://emoji.thisco.de/draft/emojimap.json](http://emoji.thisco.de/draft/emojimap.json)
|
||||||
|
|
||||||
|
## Abstract
|
||||||
|
|
||||||
|
This document specifies a practice of mapping an 8bit byte to one of a
|
||||||
|
corresponding list of 256 emoji strings.
|
||||||
|
|
||||||
|
The [`emojimap.json`](./emojimap.json) JSON is the authority of ordering.
|
||||||
|
While this directory contains golang source that is is importable by golang
|
||||||
|
projects, other languages can fetch the ordered list of the JSON document and
|
||||||
|
do their own emojisum comparison or rendering.
|
||||||
|
|
||||||
|
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
|
||||||
|
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
|
||||||
|
interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
|
||||||
|
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
### Purpose
|
||||||
|
|
||||||
|
The purpose of this practice is provide simplified way to convey [checksums](https://en.wikipedia.org/wiki/Checksum) for visual comparison.
|
||||||
|
|
||||||
|
|
||||||
|
### Intended Audience
|
||||||
|
|
||||||
|
This is intended for use by implementors of software to convey checksums or validate conveyed checksums.
|
||||||
|
|
||||||
|
|
||||||
|
## Details
|
||||||
|
|
||||||
|
By operating on an 8bit byte, this provides the oportunity for 256 permutations.
|
||||||
|
Most checksums convey in a hexadecimal notation, there showing a par of case-insensitive hexadecimal characters per byte (`16*16 = 256`).
|
||||||
|
Having a mapping of 256 emojis this thereby reduces the number of characters (or emojis) needed to convey the checksum.
|
||||||
|
In example, a [SHA1](https://en.wikipedia.org/wiki/SHA-1) checksum is 40 hexadecimal characters long, whereas an SHA1-emojisum is only 20 emojis.
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
* http://www.webpagefx.com/tools/emoji-cheat-sheet/
|
||||||
|
|
262
emoji/emojimap.json
Normal file
262
emoji/emojimap.json
Normal file
|
@ -0,0 +1,262 @@
|
||||||
|
{
|
||||||
|
"version": "draft",
|
||||||
|
"description": "This ordered list of emojiwords is the conventional order for the practice of conveying checksums with emoji",
|
||||||
|
"emojiwords": [
|
||||||
|
":+1:",
|
||||||
|
":8ball:",
|
||||||
|
":airplane:",
|
||||||
|
":alien:",
|
||||||
|
":anchor:",
|
||||||
|
":angel:",
|
||||||
|
":angry:",
|
||||||
|
":ant:",
|
||||||
|
":apple:",
|
||||||
|
":art:",
|
||||||
|
":baby:",
|
||||||
|
":baby_bottle:",
|
||||||
|
":back:",
|
||||||
|
":bamboo:",
|
||||||
|
":banana:",
|
||||||
|
":barber:",
|
||||||
|
":bathtub:",
|
||||||
|
":beer:",
|
||||||
|
":bell:",
|
||||||
|
":bicyclist:",
|
||||||
|
":bird:",
|
||||||
|
":birthday:",
|
||||||
|
":blossom:",
|
||||||
|
":blue_car:",
|
||||||
|
":boar:",
|
||||||
|
":bomb:",
|
||||||
|
":boom:",
|
||||||
|
":bow:",
|
||||||
|
":boy:",
|
||||||
|
":broken_heart:",
|
||||||
|
":bulb:",
|
||||||
|
":bus:",
|
||||||
|
":cactus:",
|
||||||
|
":calendar:",
|
||||||
|
":camera:",
|
||||||
|
":candy:",
|
||||||
|
":cat:",
|
||||||
|
":cherries:",
|
||||||
|
":children_crossing:",
|
||||||
|
":chocolate_bar:",
|
||||||
|
":clap:",
|
||||||
|
":cloud:",
|
||||||
|
":clubs:",
|
||||||
|
":cn:",
|
||||||
|
":coffee:",
|
||||||
|
":construction:",
|
||||||
|
":cookie:",
|
||||||
|
":copyright:",
|
||||||
|
":corn:",
|
||||||
|
":cow:",
|
||||||
|
":crescent_moon:",
|
||||||
|
":crown:",
|
||||||
|
":cry:",
|
||||||
|
":crystal_ball:",
|
||||||
|
":curly_loop:",
|
||||||
|
":dancers:",
|
||||||
|
":dash:",
|
||||||
|
":de:",
|
||||||
|
":diamonds:",
|
||||||
|
":dog:",
|
||||||
|
":doughnut:",
|
||||||
|
":dragon:",
|
||||||
|
":dvd:",
|
||||||
|
":ear:",
|
||||||
|
":eggplant:",
|
||||||
|
":elephant:",
|
||||||
|
":end:",
|
||||||
|
":envelope:",
|
||||||
|
":es:",
|
||||||
|
":eyes:",
|
||||||
|
":facepunch:",
|
||||||
|
":family:",
|
||||||
|
":ferris_wheel:",
|
||||||
|
":finnadie:",
|
||||||
|
":fire:",
|
||||||
|
":fireworks:",
|
||||||
|
":floppy_disk:",
|
||||||
|
":football:",
|
||||||
|
":fork_and_knife:",
|
||||||
|
":four_leaf_clover:",
|
||||||
|
":fr:",
|
||||||
|
":fries:",
|
||||||
|
":frog:",
|
||||||
|
":fu:",
|
||||||
|
":full_moon:",
|
||||||
|
":game_die:",
|
||||||
|
":eu:",
|
||||||
|
":gem:",
|
||||||
|
":girl:",
|
||||||
|
":goat:",
|
||||||
|
":grimacing:",
|
||||||
|
":grin:",
|
||||||
|
":guardsman:",
|
||||||
|
":guitar:",
|
||||||
|
":gun:",
|
||||||
|
":hamburger:",
|
||||||
|
":hammer:",
|
||||||
|
":hamster:",
|
||||||
|
":hear_no_evil:",
|
||||||
|
":heart:",
|
||||||
|
":heart_eyes_cat:",
|
||||||
|
":hearts:",
|
||||||
|
":heavy_check_mark:",
|
||||||
|
":moyai:",
|
||||||
|
":izakaya_lantern:",
|
||||||
|
":helicopter:",
|
||||||
|
":hocho:",
|
||||||
|
":honeybee:",
|
||||||
|
":horse:",
|
||||||
|
":horse_racing:",
|
||||||
|
":hourglass:",
|
||||||
|
":house:",
|
||||||
|
":hurtrealbad:",
|
||||||
|
":icecream:",
|
||||||
|
":imp:",
|
||||||
|
":it:",
|
||||||
|
":jack_o_lantern:",
|
||||||
|
":japanese_goblin:",
|
||||||
|
":jp:",
|
||||||
|
":key:",
|
||||||
|
":kiss:",
|
||||||
|
":kissing_cat:",
|
||||||
|
":koala:",
|
||||||
|
":kr:",
|
||||||
|
":lemon:",
|
||||||
|
":lipstick:",
|
||||||
|
":lock:",
|
||||||
|
":lollipop:",
|
||||||
|
":man:",
|
||||||
|
":maple_leaf:",
|
||||||
|
":mask:",
|
||||||
|
":metal:",
|
||||||
|
":microscope:",
|
||||||
|
":moneybag:",
|
||||||
|
":monkey:",
|
||||||
|
":mount_fuji:",
|
||||||
|
":muscle:",
|
||||||
|
":mushroom:",
|
||||||
|
":musical_keyboard:",
|
||||||
|
":musical_score:",
|
||||||
|
":nail_care:",
|
||||||
|
":new_moon:",
|
||||||
|
":no_entry:",
|
||||||
|
":nose:",
|
||||||
|
":notes:",
|
||||||
|
":nut_and_bolt:",
|
||||||
|
":o:",
|
||||||
|
":ocean:",
|
||||||
|
":ok_hand:",
|
||||||
|
":on:",
|
||||||
|
":package:",
|
||||||
|
":palm_tree:",
|
||||||
|
":panda_face:",
|
||||||
|
":paperclip:",
|
||||||
|
":partly_sunny:",
|
||||||
|
":passport_control:",
|
||||||
|
":paw_prints:",
|
||||||
|
":peach:",
|
||||||
|
":penguin:",
|
||||||
|
":phone:",
|
||||||
|
":pig:",
|
||||||
|
":pill:",
|
||||||
|
":pineapple:",
|
||||||
|
":pizza:",
|
||||||
|
":point_left:",
|
||||||
|
":point_right:",
|
||||||
|
":poop:",
|
||||||
|
":poultry_leg:",
|
||||||
|
":pray:",
|
||||||
|
":princess:",
|
||||||
|
":purse:",
|
||||||
|
":pushpin:",
|
||||||
|
":rabbit:",
|
||||||
|
":rainbow:",
|
||||||
|
":raised_hand:",
|
||||||
|
":recycle:",
|
||||||
|
":red_car:",
|
||||||
|
":registered:",
|
||||||
|
":ribbon:",
|
||||||
|
":rice:",
|
||||||
|
":rocket:",
|
||||||
|
":roller_coaster:",
|
||||||
|
":rooster:",
|
||||||
|
":ru:",
|
||||||
|
":sailboat:",
|
||||||
|
":santa:",
|
||||||
|
":satellite:",
|
||||||
|
":satisfied:",
|
||||||
|
":saxophone:",
|
||||||
|
":scissors:",
|
||||||
|
":see_no_evil:",
|
||||||
|
":sheep:",
|
||||||
|
":shell:",
|
||||||
|
":shoe:",
|
||||||
|
":ski:",
|
||||||
|
":skull:",
|
||||||
|
":sleepy:",
|
||||||
|
":smile:",
|
||||||
|
":smiley_cat:",
|
||||||
|
":smirk:",
|
||||||
|
":smoking:",
|
||||||
|
":snail:",
|
||||||
|
":snake:",
|
||||||
|
":snowflake:",
|
||||||
|
":soccer:",
|
||||||
|
":soon:",
|
||||||
|
":space_invader:",
|
||||||
|
":spades:",
|
||||||
|
":speak_no_evil:",
|
||||||
|
":star:",
|
||||||
|
":stars:",
|
||||||
|
":statue_of_liberty:",
|
||||||
|
":steam_locomotive:",
|
||||||
|
":sunflower:",
|
||||||
|
":sunglasses:",
|
||||||
|
":sunny:",
|
||||||
|
":sunrise:",
|
||||||
|
":surfer:",
|
||||||
|
":swimmer:",
|
||||||
|
":syringe:",
|
||||||
|
":tada:",
|
||||||
|
":tangerine:",
|
||||||
|
":taxi:",
|
||||||
|
":tennis:",
|
||||||
|
":tent:",
|
||||||
|
":thought_balloon:",
|
||||||
|
":tm:",
|
||||||
|
":toilet:",
|
||||||
|
":tongue:",
|
||||||
|
":tophat:",
|
||||||
|
":tractor:",
|
||||||
|
":trolleybus:",
|
||||||
|
":trollface:",
|
||||||
|
":trophy:",
|
||||||
|
":trumpet:",
|
||||||
|
":turtle:",
|
||||||
|
":two_men_holding_hands:",
|
||||||
|
":two_women_holding_hands:",
|
||||||
|
":uk:",
|
||||||
|
":umbrella:",
|
||||||
|
":unlock:",
|
||||||
|
":us:",
|
||||||
|
":v:",
|
||||||
|
":vhs:",
|
||||||
|
":violin:",
|
||||||
|
":warning:",
|
||||||
|
":watermelon:",
|
||||||
|
":wave:",
|
||||||
|
":wavy_dash:",
|
||||||
|
":wc:",
|
||||||
|
":wheelchair:",
|
||||||
|
":woman:",
|
||||||
|
":x:",
|
||||||
|
":yum:",
|
||||||
|
":zap:",
|
||||||
|
":zzz:"
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,258 +0,0 @@
|
||||||
[
|
|
||||||
":+1:",
|
|
||||||
":8ball:",
|
|
||||||
":airplane:",
|
|
||||||
":alien:",
|
|
||||||
":anchor:",
|
|
||||||
":angel:",
|
|
||||||
":angry:",
|
|
||||||
":ant:",
|
|
||||||
":apple:",
|
|
||||||
":art:",
|
|
||||||
":baby:",
|
|
||||||
":baby_bottle:",
|
|
||||||
":back:",
|
|
||||||
":bamboo:",
|
|
||||||
":banana:",
|
|
||||||
":barber:",
|
|
||||||
":bathtub:",
|
|
||||||
":beer:",
|
|
||||||
":bell:",
|
|
||||||
":bicyclist:",
|
|
||||||
":bird:",
|
|
||||||
":birthday:",
|
|
||||||
":blossom:",
|
|
||||||
":blue_car:",
|
|
||||||
":boar:",
|
|
||||||
":bomb:",
|
|
||||||
":boom:",
|
|
||||||
":bow:",
|
|
||||||
":boy:",
|
|
||||||
":broken_heart:",
|
|
||||||
":bulb:",
|
|
||||||
":bus:",
|
|
||||||
":cactus:",
|
|
||||||
":calendar:",
|
|
||||||
":camera:",
|
|
||||||
":candy:",
|
|
||||||
":cat:",
|
|
||||||
":cherries:",
|
|
||||||
":children_crossing:",
|
|
||||||
":chocolate_bar:",
|
|
||||||
":clap:",
|
|
||||||
":cloud:",
|
|
||||||
":clubs:",
|
|
||||||
":cn:",
|
|
||||||
":coffee:",
|
|
||||||
":construction:",
|
|
||||||
":cookie:",
|
|
||||||
":copyright:",
|
|
||||||
":corn:",
|
|
||||||
":cow:",
|
|
||||||
":crescent_moon:",
|
|
||||||
":crown:",
|
|
||||||
":cry:",
|
|
||||||
":crystal_ball:",
|
|
||||||
":curly_loop:",
|
|
||||||
":dancers:",
|
|
||||||
":dash:",
|
|
||||||
":de:",
|
|
||||||
":diamonds:",
|
|
||||||
":dog:",
|
|
||||||
":doughnut:",
|
|
||||||
":dragon:",
|
|
||||||
":dvd:",
|
|
||||||
":ear:",
|
|
||||||
":eggplant:",
|
|
||||||
":elephant:",
|
|
||||||
":end:",
|
|
||||||
":envelope:",
|
|
||||||
":es:",
|
|
||||||
":eyes:",
|
|
||||||
":facepunch:",
|
|
||||||
":family:",
|
|
||||||
":ferris_wheel:",
|
|
||||||
":finnadie:",
|
|
||||||
":fire:",
|
|
||||||
":fireworks:",
|
|
||||||
":floppy_disk:",
|
|
||||||
":football:",
|
|
||||||
":fork_and_knife:",
|
|
||||||
":four_leaf_clover:",
|
|
||||||
":fr:",
|
|
||||||
":fries:",
|
|
||||||
":frog:",
|
|
||||||
":fu:",
|
|
||||||
":full_moon:",
|
|
||||||
":game_die:",
|
|
||||||
":eu:",
|
|
||||||
":gem:",
|
|
||||||
":girl:",
|
|
||||||
":goat:",
|
|
||||||
":grimacing:",
|
|
||||||
":grin:",
|
|
||||||
":guardsman:",
|
|
||||||
":guitar:",
|
|
||||||
":gun:",
|
|
||||||
":hamburger:",
|
|
||||||
":hammer:",
|
|
||||||
":hamster:",
|
|
||||||
":hear_no_evil:",
|
|
||||||
":heart:",
|
|
||||||
":heart_eyes_cat:",
|
|
||||||
":hearts:",
|
|
||||||
":heavy_check_mark:",
|
|
||||||
":moyai:",
|
|
||||||
":izakaya_lantern:",
|
|
||||||
":helicopter:",
|
|
||||||
":hocho:",
|
|
||||||
":honeybee:",
|
|
||||||
":horse:",
|
|
||||||
":horse_racing:",
|
|
||||||
":hourglass:",
|
|
||||||
":house:",
|
|
||||||
":hurtrealbad:",
|
|
||||||
":icecream:",
|
|
||||||
":imp:",
|
|
||||||
":it:",
|
|
||||||
":jack_o_lantern:",
|
|
||||||
":japanese_goblin:",
|
|
||||||
":jp:",
|
|
||||||
":key:",
|
|
||||||
":kiss:",
|
|
||||||
":kissing_cat:",
|
|
||||||
":koala:",
|
|
||||||
":kr:",
|
|
||||||
":lemon:",
|
|
||||||
":lipstick:",
|
|
||||||
":lock:",
|
|
||||||
":lollipop:",
|
|
||||||
":man:",
|
|
||||||
":maple_leaf:",
|
|
||||||
":mask:",
|
|
||||||
":metal:",
|
|
||||||
":microscope:",
|
|
||||||
":moneybag:",
|
|
||||||
":monkey:",
|
|
||||||
":mount_fuji:",
|
|
||||||
":muscle:",
|
|
||||||
":mushroom:",
|
|
||||||
":musical_keyboard:",
|
|
||||||
":musical_score:",
|
|
||||||
":nail_care:",
|
|
||||||
":new_moon:",
|
|
||||||
":no_entry:",
|
|
||||||
":nose:",
|
|
||||||
":notes:",
|
|
||||||
":nut_and_bolt:",
|
|
||||||
":o:",
|
|
||||||
":ocean:",
|
|
||||||
":ok_hand:",
|
|
||||||
":on:",
|
|
||||||
":package:",
|
|
||||||
":palm_tree:",
|
|
||||||
":panda_face:",
|
|
||||||
":paperclip:",
|
|
||||||
":partly_sunny:",
|
|
||||||
":passport_control:",
|
|
||||||
":paw_prints:",
|
|
||||||
":peach:",
|
|
||||||
":penguin:",
|
|
||||||
":phone:",
|
|
||||||
":pig:",
|
|
||||||
":pill:",
|
|
||||||
":pineapple:",
|
|
||||||
":pizza:",
|
|
||||||
":point_left:",
|
|
||||||
":point_right:",
|
|
||||||
":poop:",
|
|
||||||
":poultry_leg:",
|
|
||||||
":pray:",
|
|
||||||
":princess:",
|
|
||||||
":purse:",
|
|
||||||
":pushpin:",
|
|
||||||
":rabbit:",
|
|
||||||
":rainbow:",
|
|
||||||
":raised_hand:",
|
|
||||||
":recycle:",
|
|
||||||
":red_car:",
|
|
||||||
":registered:",
|
|
||||||
":ribbon:",
|
|
||||||
":rice:",
|
|
||||||
":rocket:",
|
|
||||||
":roller_coaster:",
|
|
||||||
":rooster:",
|
|
||||||
":ru:",
|
|
||||||
":sailboat:",
|
|
||||||
":santa:",
|
|
||||||
":satellite:",
|
|
||||||
":satisfied:",
|
|
||||||
":saxophone:",
|
|
||||||
":scissors:",
|
|
||||||
":see_no_evil:",
|
|
||||||
":sheep:",
|
|
||||||
":shell:",
|
|
||||||
":shoe:",
|
|
||||||
":ski:",
|
|
||||||
":skull:",
|
|
||||||
":sleepy:",
|
|
||||||
":smile:",
|
|
||||||
":smiley_cat:",
|
|
||||||
":smirk:",
|
|
||||||
":smoking:",
|
|
||||||
":snail:",
|
|
||||||
":snake:",
|
|
||||||
":snowflake:",
|
|
||||||
":soccer:",
|
|
||||||
":soon:",
|
|
||||||
":space_invader:",
|
|
||||||
":spades:",
|
|
||||||
":speak_no_evil:",
|
|
||||||
":star:",
|
|
||||||
":stars:",
|
|
||||||
":statue_of_liberty:",
|
|
||||||
":steam_locomotive:",
|
|
||||||
":sunflower:",
|
|
||||||
":sunglasses:",
|
|
||||||
":sunny:",
|
|
||||||
":sunrise:",
|
|
||||||
":surfer:",
|
|
||||||
":swimmer:",
|
|
||||||
":syringe:",
|
|
||||||
":tada:",
|
|
||||||
":tangerine:",
|
|
||||||
":taxi:",
|
|
||||||
":tennis:",
|
|
||||||
":tent:",
|
|
||||||
":thought_balloon:",
|
|
||||||
":tm:",
|
|
||||||
":toilet:",
|
|
||||||
":tongue:",
|
|
||||||
":tophat:",
|
|
||||||
":tractor:",
|
|
||||||
":trolleybus:",
|
|
||||||
":trollface:",
|
|
||||||
":trophy:",
|
|
||||||
":trumpet:",
|
|
||||||
":turtle:",
|
|
||||||
":two_men_holding_hands:",
|
|
||||||
":two_women_holding_hands:",
|
|
||||||
":uk:",
|
|
||||||
":umbrella:",
|
|
||||||
":unlock:",
|
|
||||||
":us:",
|
|
||||||
":v:",
|
|
||||||
":vhs:",
|
|
||||||
":violin:",
|
|
||||||
":warning:",
|
|
||||||
":watermelon:",
|
|
||||||
":wave:",
|
|
||||||
":wavy_dash:",
|
|
||||||
":wc:",
|
|
||||||
":wheelchair:",
|
|
||||||
":woman:",
|
|
||||||
":x:",
|
|
||||||
":yum:",
|
|
||||||
":zap:",
|
|
||||||
":zzz:"
|
|
||||||
]
|
|
20
emoji/map.go
20
emoji/map.go
|
@ -1,9 +1,25 @@
|
||||||
//go:generate go run map_json.go
|
//go:generate go run map_json.go -in ./emojimap.json -out ./map_gen.go
|
||||||
|
|
||||||
package emoji
|
package emoji
|
||||||
|
|
||||||
// Map returns the emoji at the provided position.
|
// Map returns the emoji at the provided position.
|
||||||
// This list is from 0-255
|
// This list is from 0-255
|
||||||
func Map(b byte) string {
|
func Map(b byte) string {
|
||||||
return sumList[int(b)]
|
return mapGen.EmojiWords[int(b)]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version returns the version of the emojisum document currently compiled
|
||||||
|
// against
|
||||||
|
func Version() string {
|
||||||
|
return mapGen.Version
|
||||||
|
}
|
||||||
|
|
||||||
|
var mapGen VersionedMap
|
||||||
|
|
||||||
|
// VersionedMap is the structure used for the `emojimap.json` document
|
||||||
|
type VersionedMap struct {
|
||||||
|
Description string `json:"description"`
|
||||||
|
Version string `json:"version"`
|
||||||
|
// these are an ordered list, referened by a byte (each byte of a checksum digest)
|
||||||
|
EmojiWords []string `json:"emojiwords"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,11 @@
|
||||||
|
|
||||||
package emoji
|
package emoji
|
||||||
|
|
||||||
var sumList = []string{
|
func init() {
|
||||||
|
mapGen = VersionedMap{
|
||||||
|
Description: "",
|
||||||
|
Version: "draft",
|
||||||
|
EmojiWords: []string{
|
||||||
":+1:",
|
":+1:",
|
||||||
":8ball:",
|
":8ball:",
|
||||||
":airplane:",
|
":airplane:",
|
||||||
|
@ -259,4 +263,6 @@ var sumList = []string{
|
||||||
":yum:",
|
":yum:",
|
||||||
":zap:",
|
":zap:",
|
||||||
":zzz:",
|
":zzz:",
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
13
emoji/map_gen.tmpl
Normal file
13
emoji/map_gen.tmpl
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// THIS FILE IS GENERATED. DO NOT EDIT.
|
||||||
|
|
||||||
|
package emoji
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
mapGen = VersionedMap{
|
||||||
|
Description: "{{.Description}}",
|
||||||
|
Version: "{{.Version}}",
|
||||||
|
EmojiWords: []string{ {{- range .EmojiWords }}
|
||||||
|
"{{.}}",{{- end }}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,44 +4,43 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/vbatts/emojisum/emoji"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
input, err := os.Open("map-draft.json")
|
flag.Parse()
|
||||||
|
input, err := os.Open(*flInput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer input.Close()
|
defer input.Close()
|
||||||
|
|
||||||
// these are an ordered list, referened by a byte (each byte of a checksum digest)
|
vm := emoji.VersionedMap{}
|
||||||
Map := []string{}
|
|
||||||
|
|
||||||
dec := json.NewDecoder(input)
|
dec := json.NewDecoder(input)
|
||||||
if err := dec.Decode(&Map); err != nil {
|
if err := dec.Decode(&vm); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
output, err := os.Create("map_gen.go")
|
output, err := os.Create(*flOutput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer output.Close()
|
defer output.Close()
|
||||||
if err := mapGoTemp.Execute(output, Map); err != nil {
|
|
||||||
|
mapGoTemp := template.Must(template.ParseFiles(*flTemplate))
|
||||||
|
if err := mapGoTemp.Execute(output, vm); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mapGoText = `// THIS FILE IS GENERATED. DO NOT EDIT.
|
flInput = flag.String("in", "emojimap.json", "json input")
|
||||||
|
flOutput = flag.String("out", "map_gen.go", "golang output")
|
||||||
package emoji
|
flTemplate = flag.String("template", "map_gen.tmpl", "template of golang source to use")
|
||||||
|
|
||||||
var sumList = []string{ {{- range . }}
|
|
||||||
"{{.}}",{{- end }}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
mapGoTemp = template.Must(template.New("map.go").Parse(mapGoText))
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue