Documentation ¶
Overview ¶
Package emoji provides a convenient interface for working with emojis in go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var All = []Info{}/* 1903 elements not displayed */
Functions ¶
This section is empty.
Types ¶
type ImageData ¶
type ImageData struct { // A hyphen separated sequence of hex-encoded codepoints. // Includes zero-width-joiner character for multi code sequences. Unified string `json:"unified"` // Character is the actual emoji character consisting of one or more codepoints. Character string `json:"character"` // SheetX is the X index of the image in the sprite sheet. SheetX int `json:"sheet_x"` // SheetY is the Y index of the image in the sprite sheet. SheetY int `json:"sheet_y"` // AddedIn is the unicode revision that the emoji was added in AddedIn string `json:"added_in,omitempty"` // PlatformSupport defines the supported platforms. PlatformSupport map[Platform]bool `json:"platform_support,omitempty"` // Obsoletes is set if the emoji replaces another emoji from an older Unicode revision. Obsoletes string `json:"obsoletes,omitempty"` // ObsoletedBy is set if the emoji is replaced by another emoji from a newer Unicode revision. ObsoletedBy string `json:"obsoleted_by,omitempty"` }
ImageData contains the details pertinent to displaying an emoji.
type Info ¶
type Info struct { // Name is the canonical short name. Name string `json:"name"` // Category is the category of emoji. Category string `json:"category"` // PlainText is defined if the character has a canonical plaintext representation. PlainText string `json:"plain_text,omitempty"` // AlternateNames is a list of alternative string names or keywords AlternateNames []string `json:"alternate_names,omitempty"` // ImageData is an embedded struct with details about the actual image. ImageData // SkinVariations is the map of alternative emojis for different skin tones. SkinVariations map[Modifier]ImageData `json:"skin_variations,omitempty"` }
Info contains metadata about an emoji.
func (Info) ImageForModifier ¶
ImageForModifier returns the ImageData for the given emoji modifier sequence. Currently only skin tone modifications are supported.
type Modifier ¶
type Modifier int
Modifier is a string representation of an emoji modifier sequence.
const ( // SkinToneNone means no modifier was set. SkinToneNone Modifier = iota // SkinToneLight represents a light skin tone 👋🏻. SkinToneLight // SkinToneMediumLight represents a medium light skin tone 👋🏼. SkinToneMediumLight // SkinToneMedium represents a medium skin tone 👋🏽. SkinToneMedium // SkinToneMediumDark represents a medium dark skin tone 👋🏾. SkinToneMediumDark // SkinToneDark represents a dark skin tone 👋🏿. SkinToneDark )
func NewModifier ¶
NewModifier creates a modifier from a string. An empty string is interpreted as `SkinToneNone`.
func (Modifier) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface. This function also determines how a modifier is marshaled to JSON.
func (Modifier) String ¶
String implements fmt.Stringer and returns a string representation of the modifier.
func (Modifier) Unicode ¶
Unicode returns the sequence of unicode runes that represent the modifier.
func (*Modifier) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. This function also determines how a modifier is unmarshaled from JSON.
type Platform ¶
type Platform int
Platform defines constants that represent different emoji platforms.
const ( // PlatformNone represents no specific platform. PlatformNone Platform = iota // PlatformApple is the Apple Platform. PlatformApple // PlatformGoogle is the Google and Android platform. PlatformGoogle // PlatformTwitter is the Twitter platform. PlatformTwitter // PlatformFacebook is the Facebook platform. PlatformFacebook )
func (Platform) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface. This function also determines how a modifier is marshaled to JSON.
func (Platform) String ¶
String implements fmt.Stringer and returns a string representation of the platform.
func (*Platform) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. This function also determines how a modifier is unmarshaled from JSON.
type SearchIndex ¶
type SearchIndex struct {
// contains filtered or unexported fields
}
SearchIndex is allows a keyword-based search of the emoji dataset.
func NewSearchIndex ¶
func NewSearchIndex(opts ...SearchOption) *SearchIndex
NewSearchIndex creates a keyword fuzzy search index.
func (*SearchIndex) Search ¶
func (si *SearchIndex) Search(query string, opts ...SearchOption) []Info
Search performs a fuzzy search on the emoji keywords to find a matching symbol. The response array will contain up to the configured limit number of terms that are less than the maximum distance from the search term.
Options provided directly to the search term override the defaults passed to NewSearchIndex.
type SearchOption ¶
type SearchOption func(option *searchOptionSet)
SearchOption represents an option that is used to search the dataset.
func WithLimit ¶
func WithLimit(limit int) SearchOption
WithLimit sets the maximum number of results that will be returned. A 0 value means no limit.
func WithMaxDistance ¶
func WithMaxDistance(maxDistance int) SearchOption
WithMaxDistance configures the maximum Levenshtein distance for keyword matches. A 0 value means no maximum distance and the result will always contain the maximum limit of results.