{"id":17204746,"url":"https://github.com/tmdvs/go-emoji-utils","last_synced_at":"2025-04-09T13:11:04.790Z","repository":{"id":57481535,"uuid":"147192820","full_name":"tmdvs/Go-Emoji-Utils","owner":"tmdvs","description":"A collection of useful functions for working with emoji. Look up the definition of an emoji, or search for all emojis in a string.","archived":false,"fork":false,"pushed_at":"2024-05-23T08:52:50.000Z","size":228,"stargazers_count":90,"open_issues_count":6,"forks_count":37,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-16T02:23:05.673Z","etag":null,"topics":["emoji","golang","strings"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmdvs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-03T11:06:24.000Z","updated_at":"2024-06-19T11:10:03.000Z","dependencies_parsed_at":"2024-10-25T11:49:53.125Z","dependency_job_id":null,"html_url":"https://github.com/tmdvs/Go-Emoji-Utils","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmdvs%2FGo-Emoji-Utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmdvs%2FGo-Emoji-Utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmdvs%2FGo-Emoji-Utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmdvs%2FGo-Emoji-Utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmdvs","download_url":"https://codeload.github.com/tmdvs/Go-Emoji-Utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045245,"owners_count":21038554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emoji","golang","strings"],"created_at":"2024-10-15T02:23:02.113Z","updated_at":"2025-04-09T13:11:04.761Z","avatar_url":"https://github.com/tmdvs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Go-Emoji-Utils](https://share.zight.com/52074bebc945/d)\n\n# Go Emoji Utils\nA collection of useful functions for working with emoji. For example: look up the definition of a specific emoji, or search for all occurrences of emojis in a string.\n\n## Features\n - [x] Find all occurrences of emoji in a string\n - [x] Search a string for the presence specific emoji\n - [x] Look up the definition of a single emoji\n - [x] Look up the definitions for a list of emojis\n - [x] Remove all emoji from a string\n - [x] Import tool to update Emoji data with [Emojipedia](http://emojipedia.org/) specs\n - [x] Find the location of and occurrences of a specific emoji in a string\n\n## Examples\n### Find all occurrences of emoji in a string\nYou can search a string for all occurrences of emoji. You will be returned an array of results specifying which emojis were found, and how many times each occurred. The `Locations` property comprises of an array containing the start and end locations of each occurance of the emoji within the string you're searching.\n\n```go\ninput := \"This is a string 😄 🐷 with some 👍🏻 🙈 emoji! 🐷 🏃🏿‍♂️\"\nresult := emoji.FindAll(input)\n\n// result: SearchResults{ SearchResult{ Match: Emoji{…}, Occurrences: 1, Locations: […] }, …}\n```\n\n### Search a string for the presence specific emoji\nYou can search a string for the presence of a specific emoji. You will be returned a `SearchResult` struct with the definition of the matching emoji, how many times it occurred in the string, and its location within the string. \n\n```go\ninput := \"This is a string 😄 🐷 with some 👍🏻 🙈 emoji! 🐷 🏃🏿‍♂️\"\nresult := emoji.Find(\"🐷\", input)\n\n// result: SearchResult{ Match: Emoji{ Key:\"1F437\", Value:\"🐷\", Descriptor: \"pig\" }, Occurrences: 2, Locations: [[19 19] [42 42]  } }\n```\n\n### Checking search results for the occurrence of a specific emoji\nThe `SearchResults` struct has an `IndexOf` method for conveniently checking whether or not a specific emoji appears within the results set. If the emoji is not found a position of `-1` is returned.\n\n```go\ninput := \"This is a string 😄 🐷\"\nresults := emoji.FindAll(input)\n\npigEmoji := emoji.Emojis[\"1F437\"]\npigIndex := results.IndexOf(pigEmoji)\n// pigIndex: 1\n```\n\n### Look up the definition of a single emoji\nYou can lookup the definition of a single emoji character using the `LookupEmoji` function. If a matching emoji can't be found an error will be returned.\n\n```go\nresult, err := emoji.LookupEmoji(\"🐷\")\n\n// result: Emoji{ Key:\"1F437\", Value:\"🐷\", Descriptor: \"pig\" }\n```\n\n### Look up the definitions for a list of emojis\nYou can lookup the definition of a for each emoji character in an array of emojis using the `LookupEmojis` function. This function is a convenience function that loops through the input slice and passes each emoji to the `LookupEmoji` function.\n\nResults are returned in the same order that the input strings were provided in. If a matching emoji can't be found an error will be appear in for that position in the result slice.\n\n```go\nresult := emoji.LookupEmojis([]string{\"🐷\", \"🙈\"})\n\n// result: []interface{}{ Emoji{ Key:\"1F437\", Value:\"🐷\", Descriptor: \"pig\" }, …}\n```\n\n### Remove all emoji from a string\nYou can remove all the emoji characters from a string. This function finds all occurences of emoji using the `FindAll` function, and uses the `Location` field to remove runes at those indexes.\n\n```go\ninput := \"This is a string 😄 🐷 with some 👍🏻 🙈 emoji! 🐷 🏃🏿‍♂️ 🥰\"\noutput := emoji.RemoveAll(input)\n\n// output: \"This is a string with some emoji!\"\n```\n\n### Updating the Emoji definitions data file\nDefinitions of each emoji can be found in the `data/emoji.json` file. This JSON file is unmarshalled into a map at runtime with the emoji's hex representation as it's key. You can update the definitions file using definitions from [Emojipedia](http://emojipedia.org/) with the `import` program bundled with this package. You can find it at `import/main.go`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmdvs%2Fgo-emoji-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmdvs%2Fgo-emoji-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmdvs%2Fgo-emoji-utils/lists"}