A minimalistic emoji package for Go (golang)

Overview

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.

Issues
  • 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.

    feature 
    opened by spy16 4
  • 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

    opened by sami2020pro 3
  • 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
    feature 
    opened by enescakir 1
  • 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
    
    opened by ascheglovclick 0
  • 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.

    opened by mfridman 2
  • 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.

    opened by liemle3893 3
  • ❤️‍🔥 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

    enhancement 
    opened by bayneri 1
Releases(v1.0.0)
Owner
Enes Çakır
Enes Çakır
: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

kyokomi 706 Aug 7, 2022
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

Ockam 64 Aug 3, 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

Leonel Quinteros 348 Aug 4, 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

null 507 Aug 17, 2022
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

Kenny Grant 319 Jul 17, 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

null 301 Aug 1, 2022
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

Rewan_ 21 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

null 1 Nov 30, 2021
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

Alix Axel 66 Aug 8, 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

Andrew Stuart 217 May 30, 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

Maxim 67 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

Alex Saskevich 5.4k Aug 17, 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

Maxim 84 Jun 21, 2022
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

Michael Muré 243 Aug 2, 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

Sourcegraph 255 Aug 11, 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

Andrew Bashkatov 4 May 5, 2021
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.

Flamego 5 Dec 15, 2021
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

Alec Thomas 2.5k Aug 11, 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

Quan Quan 5 Feb 5, 2022