diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.go | 7 | ||||
-rw-r--r-- | src/uuid.go | 16 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/main.go b/src/main.go new file mode 100644 index 0000000..d3c7f21 --- /dev/null +++ b/src/main.go @@ -0,0 +1,7 @@ +package main + +import "uuid" + +func main() { + uuid.Main() +} diff --git a/src/uuid.go b/src/uuid.go index 8b953f8..6c4b8f6 100644 --- a/src/uuid.go +++ b/src/uuid.go @@ -4,7 +4,9 @@ import ( "crypto/rand" "encoding/hex" "errors" + "fmt" "io" + "os" "strings" ) @@ -100,3 +102,17 @@ func FromString(str string) (UUID, error) { return [ByteCount]byte(data), nil } + + + +func Main() { + if len(os.Args) < 2 { + fmt.Println(New().String()) + } else { + _, err := FromString(strings.TrimSpace(os.Args[1])) + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(3) + } + } +} |