Created
October 29, 2014 17:49
-
-
Save cmdrkeene/6abefe35ad7f1fd3d2a2 to your computer and use it in GitHub Desktop.
uuid v4 and func to swap in test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var uuidFunc = uuidV4 // for swapping in test | |
func uuidV4() string { | |
b := make([]byte, 16) | |
_, err := io.ReadFull(rand.Reader, b) | |
if err != nil { | |
panic(err) | |
} | |
b[6] = (b[6] & 0x0F) | 0x40 | |
b[8] = (b[8] &^ 0x40) | 0x80 | |
return fmt.Sprintf("%x%x%x%x%x", b[:4], b[4:6], b[6:8], b[8:10], b[10:]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment