Skip to content

AkinAD/emoji

 
 

Repository files navigation

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.

This work has been modified by Akin from the original creator enescakir/emoji and includes updates from WinnerSoftLab/emoji and liemle3893/emoji with inspiration from forPelevin/gomoji as well.

Install 💾

go get github.com/AkinAD/emoji

Usage 🏄

package main

import (
    "fmt"

    "github.com/AkinAD/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 v14.0.

emoji.CallMeHand // 🤙
emoji.CallMeHand.Tone(emoji.Dark) // 🤙🏿
emoji.HasTone("💏🏽") // True
emoji.GetAllTones("👩🏿‍🤝‍👨🏽") // [emoji.Dark, emoji.Medium]

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

emoji.Parse(":+1:") // 👍
emoji.Parse(":100:") // 💯

The package also supports backwards naming of emojis.

emoji.Deparse("I ❤️ apples") // I :read_heart: apples
emoji.Deparse("te\U0001FAB7st") // te:lotus:st
emoji.Deparse("👩🏾‍❤️‍👨🏿") // :couple_with_heart_woman_man:

You can detect emojis in a given string.

emoji.ContainsEmoji("I won 🎊") // true
emoji.FindAllEmojis("👩🏽‍❤️‍💋‍👨🏿👨🏿‍🦰👩🏿‍🤝‍👨🏽f4mily!👨‍👨‍👧*️⃣🧑🏿‍🤝‍🧑🏻") // ["👩🏽‍❤️‍💋‍👨🏿", "👨🏿‍🦰", "👩🏿‍🤝‍👨🏽", "👨‍👨‍👧", "*️⃣" ,"🧑🏿‍🤝‍🧑🏻" ]
emoji.RemoveAllEmojis("te\U0001FAB7st") // test
emoji.RemoveAllEmojis("🧖 hello 🦋world") // hello world

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. Genereate new emojis with

go run ./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.

About

All your emoji needs for Go in one place

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.9%
  • Makefile 0.1%