gocuelang.org/go/pkg/uuid Index | Files

package uuid

import "cuelang.org/go/pkg/uuid"

Package uuid defines functionality for creating UUIDs as defined in RFC 4122.

Currently only Version 5 (SHA1) and Version 3 (MD5) are supported.

Index

Functions

func FromInt

func FromInt(i *big.Int) (string, error)

FromInt creates a UUID from an integer.

DNS:  uuid.FromInt(0x6ba7b810_9dad_11d1_80b4_00c04fd430c8)

func MD5

func MD5(space string, data []byte) (string, error)

MD5 generates a version 3 UUID based on the supplied name space and data. Use SHA1 instead if you can.

func Parse

func Parse(s string) (string, error)

Parse decodes s into a UUID or returns an error. Both the standard UUID forms of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded as well as the Microsoft encoding {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} and the raw hex encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.

func SHA1

func SHA1(space string, data []byte) (string, error)

SHA1 generates a version 5 UUID based on the supplied name space and data.

func ToInt

func ToInt(x string) *big.Int

ToInt represents a UUID string as a 128-bit value.

func ToString

func ToString(x string) string

String represents a 128-bit UUID value as a string.

func URN

func URN(x string) (string, error)

URN reports the canonical URN of a UUID.

func Valid

func Valid(s string) error

Valid ensures that s is a valid UUID which would be accepted by Parse.

func Variant

func Variant(x string) (int, error)

Variant reports the UUID variant.

func Version

func Version(x string) (int, error)

Version reports the UUID version.

Source Files

pkg.go uuid.go

Version
v0.12.0 (latest)
Published
Jan 30, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
8 hours ago

Tools for package owners.