go-emoji-shortcode

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.
Install
go get github.com/floatpane/go-emoji-shortcode
Requires Go 1.26+.
Usage
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)
}
}
API
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.
Documentation
Full API reference: pkg.go.dev/github.com/floatpane/go-emoji-shortcode
Contributing
PRs welcome. See CONTRIBUTING.md.
License
MIT. See LICENSE.