Created
March 13, 2017 20:54
-
-
Save Adron/c7225ebc07058f443482925a4565afee to your computer and use it in GitHub Desktop.
Go UUID Creation
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
package main | |
import ( | |
"fmt" | |
"github.com/satori/go.uuid" | |
) | |
func main() { | |
// Creating UUID Version 4 | |
u1 := uuid.NewV4() | |
fmt.Printf("UUIDv4: %s\n", u1) | |
// Parsing UUID from string input | |
u2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") | |
if err != nil { | |
fmt.Printf("Something gone wrong: %s", err) | |
} | |
fmt.Printf("Successfully parsed: %s", u2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment