{"id":16906546,"url":"https://github.com/rsms/go-uuid","last_synced_at":"2025-03-22T10:31:13.288Z","repository":{"id":57550111,"uuid":"307804585","full_name":"rsms/go-uuid","owner":"rsms","description":"Binary sortable universally unique identifier","archived":false,"fork":false,"pushed_at":"2020-10-30T19:12:25.000Z","size":21,"stargazers_count":38,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-15T21:17:04.968Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rsms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-27T19:19:31.000Z","updated_at":"2023-08-09T20:46:08.000Z","dependencies_parsed_at":"2022-09-10T06:10:36.968Z","dependency_job_id":null,"html_url":"https://github.com/rsms/go-uuid","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fgo-uuid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fgo-uuid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fgo-uuid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsms%2Fgo-uuid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsms","download_url":"https://codeload.github.com/rsms/go-uuid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244943732,"owners_count":20536290,"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":[],"created_at":"2024-10-13T18:43:11.897Z","updated_at":"2025-03-22T10:31:12.956Z","avatar_url":"https://github.com/rsms.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# uuid\n\n[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/rsms/go-uuid.svg)][godoc]\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/rsms/go-uuid)][godoc]\n[![Go Report Card](https://goreportcard.com/badge/github.com/rsms/go-uuid)](https://goreportcard.com/report/github.com/rsms/go-uuid)\n\n[godoc]: https://pkg.go.dev/github.com/rsms/go-uuid\n\n- Binary sortable universally unique identifier\n- 16 bytes long, 6 bytes millisecond timestamp + 10 random bytes\n- Efficient base-62 string encoding that is URL safe\n\n\n## go doc\n\n[View as HTML on go.dev →][godoc]\n\n```\nCONSTANTS\n\nconst StringMaxLen = 22\n    StringMaxLen is the maximum length of a string representation of a UUID,\n    i.e. as returned by UUID.String()\n\n\nVARIABLES\n\nvar Max = UUID{\n    255, 255, 255, 255, 255, 255, 255, 255,\n    255, 255, 255, 255, 255, 255, 255, 255,\n}\n    Max is the largest possible UUID (must not be modified)\n\n\nTYPES\n\ntype UUID [16]byte\n    UUID is a universally unique identifier\n\n    UUIDs are binary sortable. The first 6 bytes constitutes a\n    millisecond-precision timestamp in big-endian byte order.\n\n    Data layout:\n\n        Byte 0-3  timestamp second, big endian\n        Byte 4-5  timestamp millisecond, big endian\n        Byte 6-15 random\n\n    Data layout example:\n\n        00 31 04 39 02 c9 39 ce 14 6c 0b db a1 40 77 78\n        ~~~~~~~~~~~ ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n         |            |           Random bytes\n         |            |\n         |           713 milliseconds\n         |\n        3212345 seconds since 2020-09-13 12:26:40\n                            = 2020-10-20 16:45:45.713 UTC\n\n    Note that while it seems like we could use nanosecond for the timestamp to\n    reduce the random data needed, environments like JavaScript doesn't\n    necessarily provide high-precision clocks. Doing things this way means that\n    we can generate and parse the embedded timestamp in a wide variety of\n    programming languages.\n\nvar Min UUID\n    Min is the zero UUID (must not be modified)\n\nfunc FromBytes(verbatim []byte) UUID\n    FromBytes copies verbatim bytes into an UUID and returns that UUID. verbatim\n    must be at least 16 bytes long or this will panic.\n\nfunc FromString(encoded string) UUID\n    FromString decodes a string representation of an UUID (i.e. from String())\n\nfunc Gen() (UUID, error)\n    Gen generates a universally unique UUID suitable to be used for sorted\n    identity. An error is returned only in the case that the host system's\n    random source fails.\n\nfunc MustGen() UUID\n    MustGen calls Gen and panics if Gen fails\n\nfunc New(sec int64, nsec int, random []byte) UUID\n    New creates a new UUID with specific Unix timestamp and random bytes.\n\n    nsec is the nanosecond part of the timestamp and should be in the range [0,\n    999999999]. It's valid to pass values outside this range for nsec. Only the\n    millisecond part of nsec is actually used.\n\n    To create an UUID with a time.Time object, do this:\n\n        New(t.Unix(), t.Nanosecond(), random)\n\n    Up to 10 bytes is used from random. If len(random) \u003c 10, the remaining\n    \"random\" bytes of UUID are zero.\n\nfunc (id UUID) Bytes() []byte\n    Bytes returns the IDs natural 16 byte long value. The returned slice's bytes\n    must not be modified.\n\nfunc (id *UUID) DecodeString(src []byte)\n    DecodeString sets the receiving UUID to the decoded value of src, which is\n    expected to be a string previously encoded using EncodeString (base62\n    0-9A-Za-z)\n\nfunc (id UUID) EncodeString(dst []byte) int\n    EncodeString writes the receiver to dst which must be at least StringMaxLen\n    (22) bytes. Returns the start offset (this function starts writing at the\n    end of dst.)\n\nfunc (id UUID) String() string\n    String returns a string representation of the UUID. The returned string is\n    sortable with the same order as the \"raw\" UUID bytes and is URL safe.\n\nfunc (id UUID) Time() time.Time\n    Time returns the time portion of the UUID\n\nfunc (id UUID) Timestamp() (sec uint32, millisec uint16)\n    Timestamp returns the timestamp portion of the UUID\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsms%2Fgo-uuid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsms%2Fgo-uuid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsms%2Fgo-uuid/lists"}