this function is in the main project now

This commit is contained in:
Vincent Batts 2018-10-22 19:01:35 +01:00
parent 1ea1a5749e
commit 94c9d40eee

View file

@ -1,7 +1,6 @@
package main package main
import ( import (
"encoding/hex"
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
@ -10,7 +9,7 @@ import (
"os/exec" "os/exec"
"strings" "strings"
esum "github.com/emojisum/emojisum/emoji" "github.com/emojisum/emojisum/emoji"
) )
var ( var (
@ -58,7 +57,7 @@ func main() {
if strings.Contains(it.Digest, ":") { if strings.Contains(it.Digest, ":") {
chunks := strings.SplitN(it.Digest, ":", 2) chunks := strings.SplitN(it.Digest, ":", 2)
h = chunks[0] h = chunks[0]
d, err = emojiFromHexString(chunks[1]) d, err = emoji.FromHexString(chunks[1])
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
os.Exit(1) os.Exit(1)
@ -80,25 +79,6 @@ func main() {
cmd.Run() cmd.Run()
} }
func emojiFromHexString(s string) (string, error) {
d, err := hex.DecodeString(s)
if err != nil {
return "", err
}
var ret string
for _, b := range d {
for _, e := range esum.Map(b) {
// use the first colon notation word and continue
if esum.IsCodepoint(e) {
ret = ret + esum.CodepointToUnicode(e)
break
}
}
}
return ret, nil
}
type ImageThing struct { type ImageThing struct {
Repo string Repo string
ID string ID string