{"id":16714228,"url":"https://github.com/flier/atom","last_synced_at":"2026-04-25T18:32:01.330Z","repository":{"id":57604877,"uuid":"65522416","full_name":"flier/atom","owner":"flier","description":"Unique integer codes (also known as atoms) for a fixed set of frequently occurring strings","archived":false,"fork":false,"pushed_at":"2016-08-12T04:40:43.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-01T21:51:44.310Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flier.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":null,"support":null}},"created_at":"2016-08-12T04:08:54.000Z","updated_at":"2017-12-05T22:04:47.000Z","dependencies_parsed_at":"2022-09-12T23:23:18.168Z","dependency_job_id":null,"html_url":"https://github.com/flier/atom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/flier/atom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Fatom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Fatom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Fatom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Fatom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flier","download_url":"https://codeload.github.com/flier/atom/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Fatom/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32273213,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-10-12T20:49:56.586Z","updated_at":"2026-04-25T18:32:01.296Z","avatar_url":"https://github.com/flier.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview ![Travis Build](https://travis-ci.org/flier/atom.svg?branch=master)\n\nPackage atom provides integer codes (also known as atoms) for a fixed set of frequently occurring strings\n\nAn atom is an unique ID of a frequently occurring name, it could be more effective in store and compare in O(1).\n``` go\nhello := atom.New(\"hello\")\n```\nThe atom value will be unique in the same process base on the creating order.\n``` go\nhello.Value()\n```\nThe atom name/value mapping could be saved as a snapshot and serialized to the disk / database.\n``` go\ndata, cache := atom.Save()\n```\nWhen new process start next time or on the remote, load those will restore the atom name/value mapping.\n``` go\natom.Load(data, cache)\n```\n\n# Install\n\nGet and build package source.\n```\ngo get -u github.com/flier/atom\n```\nGet and install generate atom command.\n```\ngo install github.com/flier/atom/cmd/genatoms\n```\n\n# Internal\n\nAn atom is a 4 bytes uint32, which contains the offset and length of the atom name in a global buffer, or the embedded short name (less than 4 bytes) in the value.\n\nThe highest bit set to 0 means the atom contains a long string in the global buffer.\n```\n+--------+--------------------------+\n|0| len  |          offset          |\n+--------+--------------------------+\n|01234567|01234567|01234567|01234567|\n+--------+--------------------------+\n```\nThe hightest bit set to 1 means the atom embedded a short string in the value. The first byte must less than 0x80.\n```\n+--------+--------------------------+\n|1|str[0]| str[1] | str[2] | str[3] |\n+--------+--------------------------+\n|1|  3   | str[0] | str[1] | str[2] |\n+--------+--------------------------+\n|1|  2   |        | str[0] | str[1] |\n+--------+--------------------------+\n|1|  1   |        |        | str[0] |\n+--------+--------------------------+\n|01234567|01234567|01234567|01234567|\n+--------+--------------------------+\n```\nIt means the maximum length of atom name is 127 bytes.\n\n`Atom.IsEmbedded` will reports whether the atom embedded the name\n\n# Pregenerated Atoms\n\nA build-in atoms buffer and cache could be generated with command:\n```\n$ genatoms -i atoms.txt -o atom.go -p atom -test\n```\nIt will scan and extract all the Golang identifier from input file `atoms.txt`, the atom data and cache will be save to the output file `atom.go` with package name `atom`.\n```\n-case-insensitive\n      case-insensitive atom (default true)\n-format\n      format the generated code (default true)\n-i string\n      read atom from the input file (default STDIN)\n-o string\n      write atom table to the output file (default STDOUT)\n-p string\n      generated package name (default \"atom\")\n-test\n      generate test table for the atom data\n```\nThe extracted atom will be case insensitive by default.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflier%2Fatom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflier%2Fatom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflier%2Fatom/lists"}