# README
guid
The guid package implements a 16-byte guid/uuid type. It supports parsing of guid strings, validation of guids, and random generation of guids according to RFC-4122.
See http://godoc.org/github.com/beevik/guid for the godoc-formatted API documentation.
Example: Parsing a guid
g, err := guid.ParseString("67a23ff3-20be-4420-9274-d16f2833d595")
Example: Generating a random guid
g := guid.New()
Example: Validating a guid string
s0 := "67a23ff3-20be-4420-9274-d16f2833d595"
s1 := "67a23ff3-20be-4420-9274"
fmt.Println("s0 a guid? ", guid.IsGuid(s0))
fmt.Println("s0 a guid? ", guid.IsGuid(s1))
Output:
s0 a guid? true
s1 a guid? false
Example: Converting a guid to a string
for i := 0; i < 4; i++ {
g := guid.New()
fmt.Println("guid: %s GUID: %s\n", g.String(), g.StringUpper())
}
Output:
guid: 9a5bb29c-cdcd-4b1b-a039-b88d1271ab4c GUID: 9A5BB29C-CDCD-4B1B-A039-B88D1271AB4C
guid: efeeee74-aea6-4fa9-8037-8d3a3f883d3f GUID: EFEEEE74-AEA6-4FA9-8037-8D3A3F883D3F
guid: 773730b7-7b5d-4ef0-80ed-f52617d5b688 GUID: 773730B7-7B5D-4EF0-80ED-F52617D5B688
guid: 256f523f-e65e-4451-9381-1d561abbc645 GUID: 256F523F-E65E-4451-9381-1D561ABBC645
# Functions
IsGuid returns true if the string contains a properly formatted Guid.
New generates a random RFC 4122-conformant version 4 Guid.
NewString is a helper function that returns a random RFC 4122-comformant version 4 Guid as a string.
ParseString returns the Guid represented by the string s.
# Variables
ErrInvalid is returned when parsing a string that is not formatted as a valid guid.
# Type aliases
Guid is a globally unique 16 byte identifier.