Documentation
ยถ
Overview ยถ
Package turtle is a library for working with emojis. The API ca be used to retrieve emoji for a specific name, a category or a keyword. You can also search emojis if you do not know the name of an emoji.
Index ยถ
Examples ยถ
Constants ยถ
const Version = "v0.2.0"
Version of the turtle library
Variables ยถ
var Emojis = make(map[string]*Emoji)
Emojis maps a name to an Emoji
var EmojisByChar = make(map[string]*Emoji)
EmojisByChar maps a character to an Emoji
Functions ยถ
This section is empty.
Types ยถ
type Emoji ยถ
type Emoji struct { Name string `json:"name" toml:"name"` Category string `json:"category" toml:"category"` Char string `json:"char" toml:"char"` Keywords []string `json:"keywords" toml:"keywords"` }
Emoji holds info about an emoji character
func Category ยถ
Category filters the emojis by a category
Example ยถ
Example for using the Category function to find all emojis of the specified category.
c := "travel_and_places" emojis := Category(c) if emojis == nil { fmt.Fprintf(os.Stderr, "no emojis found for category: %v\n", c) os.Exit(1) } fmt.Printf("%s: %s\n", c, emojis[:3])
Output: travel_and_places: [๐ก โ๏ธ ๐]
func Filter ยถ added in v0.2.0
Filter the emojis based on the given comparison function
Example ยถ
Example for using the Filter function to find all emojis in a category with a specific keyword
emojis := Filter(func(e *Emoji) bool { if e.Category == "animals_and_nature" { for _, keyword := range e.Keywords { if keyword == "world" { return true } } } return false }) if emojis == nil { fmt.Fprintf(os.Stderr, "no emojis found in animals_and_nature with keyword world\n") os.Exit(1) } fmt.Printf("emojis: %s", emojis)
Output: emojis: [๐ ๐ ๐]
func Keyword ยถ
Keyword filters the emojis by a keyword
Example ยถ
Example for using the Keyword function to find all emojis with the specified keyword.
k := "happy" emojis := Keyword(k) if emojis == nil { fmt.Fprintf(os.Stderr, "no emoji found for keyword: %v\n", k) os.Exit(1) } fmt.Printf("%s: %s", k, emojis[:4])
Output: happy: [๐ ๐ ๐ ๐]
func Search ยถ
Search emojis by a name
Example ยถ
Example for using the Search function to find all emojis with a name that contains the search string.
s := "computer" emojis := Search(s) if emojis == nil { fmt.Fprintf(os.Stderr, "no emojis found for search: %v\n", s) os.Exit(1) } fmt.Printf("%s: %s", s, emojis)
Output: computer: [๐ป ๐ฑ ๐ฅ]