A minimalistic emoji package for Go (golang)

emoji πŸš€ πŸŽ’ πŸŽ‰

Build Status godoc Go Report Card Codecov MIT License

emoji is a minimalistic emoji library for Go. It lets you use emoji characters in strings.

Inspired by spatie/emoji

Install πŸ’Ύ

go get github.com/enescakir/emoji

Usage πŸ„

package main

import (
    "fmt"

    "github.com/enescakir/emoji"
)

func main() {
	fmt.Printf("Hello %v\n", emoji.WavingHand)
	fmt.Printf("I am %v from %v\n",
		emoji.ManTechnologist,
		emoji.FlagForTurkey,
	)
	fmt.Printf("Different skin tones.\n  default: %v light: %v dark: %v\n",
		emoji.ThumbsUp,
		emoji.OkHand.Tone(emoji.Light),
		emoji.CallMeHand.Tone(emoji.Dark),
	)
	fmt.Printf("Emojis with multiple skin tones.\n  both medium: %v light and dark: %v\n",
		emoji.PeopleHoldingHands.Tone(emoji.Medium),
		emoji.PeopleHoldingHands.Tone(emoji.Light, emoji.Dark),
	)
	fmt.Println(emoji.Parse("Emoji aliases are :sunglasses:"))
	emoji.Println("Use fmt wrappers :+1: with emoji support :tada:")
}

/* OUTPUT

    Hello πŸ‘‹
    I am πŸ‘¨β€πŸ’» from πŸ‡ΉπŸ‡·
    Different skin tones.
      default: πŸ‘ light: πŸ‘ŒπŸ» dark: πŸ€™πŸΏ
    Emojis with multiple skin tones.
      both medium: πŸ§‘πŸ½β€πŸ€β€πŸ§‘πŸ½ light and dark: πŸ§‘πŸ»β€πŸ€β€πŸ§‘πŸΏ
    Emoji aliases are 😎
    Use fmt wrappers πŸ‘ with emoji support πŸŽ‰
*/

This package contains emojis constants based on Full Emoji List v13.0.

emoji.CallMeHand // πŸ€™
emoji.CallMeHand.Tone(emoji.Dark) // πŸ€™πŸΏ

Also, it has additional emoji aliases from github/gemoji.

emoji.Parse(":+1:") // πŸ‘
emoji.Parse(":100:") // πŸ’―

You can generate country flag emoji with ISO 3166 Alpha2 codes:

emoji.CountryFlag("tr") // πŸ‡ΉπŸ‡·
emoji.CountryFlag("US") // πŸ‡ΊπŸ‡Έ
emoji.Parse("country flag alias :flag-gb:") // country flag alias πŸ‡¬πŸ‡§

All constants are generated by internal/generator.

Testing πŸ”¨

go test

Todo πŸ“Œ

  • Add examples to godoc

Contributing πŸ‘¨β€πŸ’»

I am accepting PRs that add aliases to the package. You have to add it to customEmojis list at internal/generator/main.

If you think an emoji constant is not correct, open an issue. Please use this list to look up the correct unicode value and the name of the character.

Credits ⭐

License πŸ“œ

The MIT License (MIT). Please see License File for more information.

Owner
Comments
  • String Parser

    String Parser

    Not sure if this is project goal or not. But I think a string parser that takes a string (for example I am cool :sunglasses: ) and returns a string that has :sunglasses: replaced with the actual emoji character would be really useful.

    Most uses cases I can think of would not involve manipulating specific emojis in code. Even if it did, defining specific emoji characters required by the project as constants in the project instead of introducing a dependency would be simpler and easier. In that sense, above feature can add great value to this project I think .

    If you think this would be useful, I can send a PR.

  • i cant see the result

    i cant see the result

    i write the code:

    package 
    
    import (
        "fmt"
    
        "github.com/enescakir/emoji"
    )
    
    func main() {
    	fmt.Printf("Hello %v\n", emoji.WavingHand)
    	fmt.Printf("I am %v from %v\n",
    		emoji.ManTechnologist,
    		emoji.FlagForTurkey,
    	)
    	fmt.Printf("Different skin tones.\n  default: %v light: %v dark: %v\n",
    		emoji.ThumbsUp,
    		emoji.OkHand.Tone(emoji.Light),
    		emoji.CallMeHand.Tone(emoji.Dark),
    	)
    	fmt.Printf("Emojis with multiple skin tones.\n  both medium: %v light and dark: %v\n",
    		emoji.PeopleHoldingHands.Tone(emoji.Medium),
    		emoji.PeopleHoldingHands.Tone(emoji.Light, emoji.Dark),
    	)
    	fmt.Println(emoji.Parse("Emoji aliases are :sunglasses:"))
    	emoji.Println("Use fmt wrappers :+1: with emoji support :tada:")
    }
    

    but the result is bad and i cant see the emoji's:

    Hello 
    I am  from 
    Different skin tones.
     default:  light:  dark: 
    Emojis with multiple skin tones.
     both medium:  light and dark: 
    Emoji aliases are 
    Use fmt wrappers  with emoji support
    

    What should I do ?

    I have Arch Linux Distro and i use zsh shell

  • add string parser

    add string parser

    • [x] add parser
    • [x] generate emoji map with generator
    • [x] add fmt methods
    • [x] add unit tests to parser
    • [x] add unit tests to fmt
    • [x] add new feature to README
  • Allocations optimisations

    Allocations optimisations

    A set of optimisations related to allocations

    Original
    BenchmarkParse
    BenchmarkParse-12    	 1446430	       799.4 ns/op	     288 B/op	      14 allocs/op
    
    Remove redundant allocation
    BenchmarkParse
    BenchmarkParse-12    	 1482784	       719.3 ns/op	     256 B/op	      12 allocs/op
    
    Use bytes.Buffer for matched
    BenchmarkParse
    BenchmarkParse-12    	 1745038	       638.7 ns/op	     184 B/op	       5 allocs/op
    
    Preallocate required space
    BenchmarkParse/static
    BenchmarkParse/static-12         	 2146411	       536.6 ns/op	     144 B/op	       2 allocs/op
    
    Reusable parser
    BenchmarkParse/reusable
    BenchmarkParse/reusable-12       	 2438487	       494.8 ns/op	      80 B/op	       1 allocs/op
    
  • Add ability to check (or retrieve) aliases in an input

    Add ability to check (or retrieve) aliases in an input

    Awesome package, thanks.

    What do you think about adding a func Contains(input string) bool or func FindAll(input string) []string functions? Exposing how Parse finds aliases.

    This would allow the caller to check for existence, or find all the aliases in a given input string.

  • Support alias back-and-forth

    Support alias back-and-forth

    Hi there, I found this module is quite interesting and easy to catch up.

    Currently, I got into situation where I need to implement some kind of searching, but the search engine is not fully support utf8. So, it's may good for user to be able to convert ❀️ => :heart: and back, :heart: => ❀️

    I'm also done a prototype for these implementation. My repo: https://github.com/liemle3893/emoji/commit/985fe954b73baf6614a2fd99d03779e49e07212d

    It's cool if we can add this feature.

    Regards.

  • ❀️‍πŸ”₯ Unicode Emoji 13.1 support

    ❀️‍πŸ”₯ Unicode Emoji 13.1 support

    image

    I love this library but.... Unicode emoji 13.1 is released which made this library kinda out of date. Full list of newly added emojis can be found at https://www.unicode.org/emoji/charts-13.1/emoji-released.html or the new full list at here https://unicode.org/Public/emoji/13.1/emoji-test.txt

:sushi: emoji terminal output for golang

Emoji Emoji is a simple golang package. Get it: go get github.com/kyokomi/emoji/v2 Import it: import ( "github.com/kyokomi/emoji/v2" ) Usage packag

Jan 8, 2023
A golang package to work with Decentralized Identifiers (DIDs)

did did is a Go package that provides tools to work with Decentralized Identifiers (DIDs). Install go get github.com/ockam-network/did Example packag

Nov 25, 2022
Go (Golang) GNU gettext utilities package

Gotext GNU gettext utilities for Go. Features Implements GNU gettext support in native Go. Complete support for PO files including: Support for multil

Dec 18, 2022
htmlquery is golang XPath package for HTML query.

htmlquery Overview htmlquery is an XPath query package for HTML, lets you extract data or evaluate from HTML documents by an XPath expression. htmlque

Jan 4, 2023
Package sanitize provides functions for sanitizing text in golang strings.

sanitize Package sanitize provides functions to sanitize html and paths with go (golang). FUNCTIONS sanitize.Accents(s string) string Accents replaces

Dec 5, 2022
xmlquery is Golang XPath package for XML query.

xmlquery Overview xmlquery is an XPath query package for XML documents, allowing you to extract data or evaluate from XML documents with an XPath expr

Jan 1, 2023
Frongo is a Golang package to create HTML/CSS components using only the Go language.

Frongo Frongo is a Go tool to make HTML/CSS document out of Golang code. It was designed with readability and usability in mind, so HTML objects are c

Jul 29, 2021
This package provides Go (golang) types and helper functions to do some basic but useful things with mxGraph diagrams in XML, which is most famously used by app.diagrams.net, the new name of draw.io.

Go Draw - Golang MX This package provides types and helper functions to do some basic but useful things with mxGraph diagrams in XML, which is most fa

Aug 30, 2022
Genex package for Go

genex Genex package for Go Easy and efficient package to expand any given regex into all the possible strings that it can match. This is the code that

Nov 2, 2022
A declarative struct-tag-based HTML unmarshaling or scraping package for Go built on top of the goquery library

goq Example import ( "log" "net/http" "astuart.co/goq" ) // Structured representation for github file name table type example struct { Title str

Dec 12, 2022
csvplus extends the standard Go encoding/csv package with fluent interface, lazy stream operations, indices and joins.

csvplus Package csvplus extends the standard Go encoding/csv package with fluent interface, lazy stream processing operations, indices and joins. The

Apr 9, 2022
[Go] Package of validators and sanitizers for strings, numerics, slices and structs

govalidator A package of validators and sanitizers for strings, structs and collections. Based on validator.js. Installation Make sure that Go is inst

Dec 28, 2022
Package strit introduces a new type of string iterator, along with a number of iterator constructors, wrappers and combinators.

strit Package strit (STRing ITerator) assists in development of string processing pipelines by providing a simple iteration model that allows for easy

Jun 21, 2022
A markdown renderer package for the terminal
A markdown renderer package for the terminal

go-term-markdown go-term-markdown is a go package implementing a Markdown renderer for the terminal. Note: Markdown being originally designed to rende

Nov 25, 2022
Go package for syntax highlighting of code

syntaxhighlight Package syntaxhighlight provides syntax highlighting for code. It currently uses a language-independent lexer and performs decently on

Nov 18, 2022
ByNom is a Go package for parsing byte sequences, suitable for parsing text and binary data

ByNom is a Go package for parsing byte sequences. Its goal is to provide tools to build safe byte parsers without compromising the speed or memo

May 5, 2021
Package i18n is a middleware that provides internationalization and localization for Flamego
Package i18n is a middleware that provides internationalization and localization for Flamego

i18n Package i18n is a middleware that provides internationalization and localization for Flamego. Installation The minimum requirement of Go is 1.16.

Dec 14, 2022
A dead simple parser package for Go
A dead simple parser package for Go

A dead simple parser package for Go V2 Introduction Tutorial Tag syntax Overview Grammar syntax Capturing Capturing boolean value Streaming Lexing Sta

Dec 30, 2022
A Package Searching and Installation tool for Go Projects.

Gosearch A Package Searching and Installation tool for Go Projects. Installation go install github.com/kinensake/[email protected] Usage gosearch <pack

Dec 19, 2022