1# UUID package for Go language 2 3[![Build Status](https://travis-ci.org/satori/go.uuid.svg?branch=master)](https://travis-ci.org/satori/go.uuid) 4[![Coverage Status](https://coveralls.io/repos/github/satori/go.uuid/badge.svg?branch=master)](https://coveralls.io/github/satori/go.uuid) 5[![GoDoc](http://godoc.org/github.com/satori/go.uuid?status.svg)](http://godoc.org/github.com/satori/go.uuid) 6 7This package provides pure Go implementation of Universally Unique Identifier (UUID). Supported both creation and parsing of UUIDs. 8 9With 100% test coverage and benchmarks out of box. 10 11Supported versions: 12* Version 1, based on timestamp and MAC address (RFC 4122) 13* Version 2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1) 14* Version 3, based on MD5 hashing (RFC 4122) 15* Version 4, based on random numbers (RFC 4122) 16* Version 5, based on SHA-1 hashing (RFC 4122) 17 18## Installation 19 20Use the `go` command: 21 22 $ go get github.com/satori/go.uuid 23 24## Requirements 25 26UUID package requires Go >= 1.2. 27 28## Example 29 30```go 31package main 32 33import ( 34 "fmt" 35 "github.com/satori/go.uuid" 36) 37 38func main() { 39 // Creating UUID Version 4 40 // panic on error 41 u1 := uuid.Must(uuid.NewV4()) 42 fmt.Printf("UUIDv4: %s\n", u1) 43 44 // or error handling 45 u2, err := uuid.NewV4() 46 if err != nil { 47 fmt.Printf("Something went wrong: %s", err) 48 return 49 } 50 fmt.Printf("UUIDv4: %s\n", u2) 51 52 // Parsing UUID from string input 53 u2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") 54 if err != nil { 55 fmt.Printf("Something went wrong: %s", err) 56 } 57 fmt.Printf("Successfully parsed: %s", u2) 58} 59``` 60 61## Documentation 62 63[Documentation](http://godoc.org/github.com/satori/go.uuid) is hosted at GoDoc project. 64 65## Links 66* [RFC 4122](http://tools.ietf.org/html/rfc4122) 67* [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01) 68 69## Copyright 70 71Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>. 72 73UUID package released under MIT License. 74See [LICENSE](https://github.com/satori/go.uuid/blob/master/LICENSE) for details. 75