github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/twinj/uuid/README.md (about) 1 Go UUID implementation 2 ======================== 3 4 [](https://travis-ci.org/twinj/uuid) 5 [](http://godoc.org/github.com/twinj/uuid) 6 7 This package provides RFC 4122 compliant UUIDs. 8 It will generate the following: 9 10 * Version 1: based on timestamp and MAC address 11 * Version 3: based on MD5 hash 12 * Version 4: based on cryptographically secure random numbers 13 * Version 5: based on SHA-1 hash 14 15 Functions NewV1, NewV3, NewV4, NewV5, New, NewHex and Parse() for generating versions 3, 4 16 and 5 UUIDs are as specified in [RFC 4122](http://www.ietf.org/rfc/rfc4122.txt). 17 18 # Requirements 19 20 Go 1.4, 1.3, 1.2 and tip supported. 21 22 # Recent Changes 23 24 * Removed use of OS Thread locking and runtime package requirement 25 * Changed String() output to CleanHyphen to match the canonical standard 26 * Plenty of minor change and housekeeping 27 * Removed default saver and replaced with interface 28 * API changes to simplify use. 29 * Added formatting support for user defined formats 30 * Added support for Google App Engine 31 * Variant type bits are now set correctly 32 * Variant type can now be retrieved more efficiently 33 * New tests for variant setting to confirm correctness 34 * New tests added to confirm proper version setting 35 * Type UUID change to UUIDArray for V3-5 UUIDs and UUIDStruct added for V1 UUIDs 36 ** These implement the BinaryMarshaller and BinaryUnmarshaller interfaces 37 * New was added to create a base UUID from a []byte slice - this uses UUIDArray 38 * ParseHex was renamed to ParseUUID 39 * NewHex now performs unsafe creation of UUID from a hex string 40 * NewV3 and NewV5 now take anything that implements the Stringer interface 41 * V1 UUIDs can now be created 42 * The printing format can be changed 43 44 ## Installation 45 46 Use the `go` tool: 47 48 $ go get github.com/twinj/uuid 49 50 ## Usage 51 52 See [documentation and examples](http://godoc.org/github.com/twinj/uuid) 53 for more information. 54 55 var config = uuid.StateSaverConfig{SaveReport: true, SaveSchedule: 30 * time.Minute} 56 uuid.SetupFileSystemStateSaver(config) 57 58 u1 := uuid.NewV1() 59 uP, _ := uuid.Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8") 60 u3 := uuid.NewV3(uP, uuid.Name("test")) 61 u4 := uuid.NewV4() 62 fmt.Printf(print, u4.Version(), u4.Variant(), u4) 63 64 u5 := uuid.NewV5(uuid.NamespaceURL, uuid.Name("test")) 65 66 if uuid.Equal(u1, u3) { 67 fmt.Printf("Will never happen") 68 } 69 fmt.Printf(uuid.Formatter(u5, uuid.CurlyHyphen)) 70 71 uuid.SwitchFormat(uuid.BracketHyphen) 72 73 ## Copyright 74 75 This is a derivative work 76 77 Orginal version from 78 Copyright (C) 2011 by Krzysztof Kowalik <chris@nu7hat.ch>. 79 See [COPYING](https://github.com/nu7hatch/gouuid/tree/master/COPYING) 80 file for details. 81 82 Also see: Algorithm details in [RFC 4122](http://www.ietf.org/rfc/rfc4122.txt). 83 84 Copyright (C) 2014 twinj@github.com 85 See [LICENSE](https://github.com/twinj/uuid/tree/master/LICENSE) 86 file for details.