summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-05-04 09:12:26 -0300
committerEuAndreh <eu@euandre.org>2025-05-04 09:12:26 -0300
commitf5187787c58670e80884078bd8eca5335e5b37e7 (patch)
treecdc6afc123e95c4537fadd436879b5929801bd85 /src
parentre s/guuid/uuid/g (diff)
downloaduuid-f5187787c58670e80884078bd8eca5335e5b37e7.tar.gz
uuid-f5187787c58670e80884078bd8eca5335e5b37e7.tar.xz
Add standalone uuid(1) utility
Diffstat (limited to 'src')
-rw-r--r--src/main.go7
-rw-r--r--src/uuid.go16
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)
+ }
+ }
+}