JakubOboza / uuid

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

uuid build status

The uuid package generates and inspects UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.

This package is based on the github.com/pborman/uuid package (previously named code.google.com/p/go-uuid). It differs from these earlier packages in that a UUID is a 16 byte array rather than a byte slice. One loss due to this change is the ability to represent an invalid UUID (vs a NIL UUID).

Install

go get github.com/google/uuid

Example usage
package main

import (
  "fmt"

  "github.com/google/uuid"
)

func main() {

  // uuid in uuid.UUID form
  uid := uuid.New()
  fmt.Println(uid)

  // uuid v4 in a string form
  uidStr := uuid.NewString()
  fmt.Println(uidStr)

  // urn version urn:uuid:xxx...
  urnUuidStr := uuid.New().URN()
  fmt.Println(urnUuidStr)

  // Parse uuid
  parsedUuid, err := uuid.Parse("138e62c7-1f88-42cb-8185-8d9e07918e84")

  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println(parsedUuid)
  }

}

Documentation

GoDoc

Full go doc style documentation for the package can be viewed online without installing this package by using the GoDoc site here: http://pkg.go.dev/github.com/google/uuid

About

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 100.0%