Giter Site home page Giter Site logo

gomoji's Introduction

GoMoji

work with emoji in the most convenient way

GoMoji is a Go package that provides a fast and simple way to work with emojis in strings. It has features such as:

Getting Started

Installing

To start using GoMoji, install Go and run go get:

$ go get -u github.com/forPelevin/gomoji

This will retrieve the package.

Check string contains emoji

package main

import (
    "github.com/forPelevin/gomoji"
)

func main() {
    res := gomoji.ContainsEmoji("hello world")
    println(res) // false
    
    res = gomoji.ContainsEmoji("hello world ๐Ÿค—")
    println(res) // true
}

Find all

The function searches for all emoji occurrences in a string. It returns a nil slice if there are no emojis.

package main

import (
    "github.com/forPelevin/gomoji"
)

func main() {
    res := gomoji.FindAll("๐Ÿง– hello ๐Ÿฆ‹ world")
    println(res)
}

Get all

The function returns all existed emojis. You can do whatever you need with the list.

package main

import (
    "github.com/forPelevin/gomoji"
)

func main() {
    emojis := gomoji.AllEmojis()
    println(emojis)
}

Emoji entity

All searching methods return the Emoji entity which contains comprehensive info about emoji.

type Emoji struct {
    Slug        string `json:"slug"`
    Character   string `json:"character"`
    UnicodeName string `json:"unicode_name"`
    CodePoint   string `json:"code_point"`
    Group       string `json:"group"`
    SubGroup    string `json:"sub_group"`
}

Example:

[]gomoji.Emoji{
    {
        Slug:        "e3-0-butterfly",
        Character:   "๐Ÿฆ‹",
        UnicodeName: "E3.0 butterfly",
        CodePoint:   "1F98B",
        Group:       "animals-nature",
        SubGroup:    "animal-bug",
    },
    {
        Slug:        "roll-of-paper",
        Character:   "๐Ÿงป",
        UnicodeName: "roll of paper",
        CodePoint:   "1F9FB",
        Group:       "objects",
        SubGroup:    "household",
    },
}

Performance

Benchmarks of GoMoji

BenchmarkContainsEmojiParallel-8   	94079461	        13.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkContainsEmoji-8           	23728635	        49.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkFindAllParallel-8         	10220854	       115 ns/op	     288 B/op	       2 allocs/op
BenchmarkFindAll-8                 	 4023626	       294 ns/op	     288 B/op	       2 allocs/op

Contact

Vlad Gukasov @vgukasov

License

GoMoji source code is available under the MIT License.

gomoji's People

Contributors

forpelevin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.