AG UUID

Go UUID

How to generate a standard UUID (typically v4) in Go, using the standard library or a widely used package.

Code

main.go
import "github.com/google/uuid"

id := uuid.New()          // v4
id, _ := uuid.NewV7()     // v7
Most languages provide v4 (random) out of the box, while v7 or ULID may require a separate library.

View version reference →