Skip to content

floatpane/go-emoji-shortcode

Repository files navigation

go-emoji-shortcode

Go Version Go Reference CI License: MIT

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.

About

Shortcode Unicode emoji library for Go

Resources

License

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages