A small, dependency-free Go library for mapping emoji shortcodes (:smile:, :heart:, ...) to Unicode emoji characters. It is designed for text editors and TUI composers that want live shortcode preview and suggestion support.
Extracted from matcha so it can be reused by other Go projects.
go get github.com/floatpane/go-emoji-shortcodeRequires Go 1.26+.
package main
import (
"fmt"
"github.com/floatpane/go-emoji-shortcode"
)
func main() {
e, ok := shortcode.Lookup("smile")
if ok {
fmt.Println(e) // 😄
}
matches := shortcode.Suggest("sm")
for _, m := range matches {
fmt.Printf("%s -> %s\n", m.Code, m.Emoji)
}
}Lookup(shortcode string) (emoji string, ok bool)— exact shortcode to emoji.Suggest(prefix string) []Match— fuzzy-matched suggestions for a prefix (e.g."sm"matches:smile:,:smirk:, ...). Results are sorted by relevance.All() []Match— every known shortcode/emoji pair.
Full API reference: pkg.go.dev/github.com/floatpane/go-emoji-shortcode
PRs welcome. See CONTRIBUTING.md.
MIT. See LICENSE.