mirror of https://github.com/status-im/gomoji.git
|
||
---|---|---|
cmd/openemojigen | ||
examples/openemoji | ||
.gitignore | ||
.golangci.yml | ||
LICENSE | ||
Makefile | ||
README.md | ||
data.go | ||
go.mod | ||
go.sum | ||
gomoji.go | ||
gomoji_test.go | ||
openemoji.go | ||
service.go |
README.md
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.