File tree Expand file tree Collapse file tree 8 files changed +413
-2
lines changed Expand file tree Collapse file tree 8 files changed +413
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ require (
5
5
github.com/cockroachdb/apd/v2 v2.0.1
6
6
github.com/emicklei/proto v1.6.15
7
7
github.com/google/go-cmp v0.4.0
8
+ github.com/google/uuid v1.2.0
8
9
github.com/kr/pretty v0.1.0
9
10
github.com/kylelemons/godebug v1.1.0
10
11
github.com/lib/pq v1.0.0 // indirect
Original file line number Diff line number Diff line change @@ -45,8 +45,8 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ
45
45
github.com/google/go-cmp v0.2.0 /go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M =
46
46
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4 =
47
47
github.com/google/go-cmp v0.4.0 /go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE =
48
- github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU =
49
- github.com/google/go-cmp v0.5.5 /go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE =
48
+ github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs =
49
+ github.com/google/uuid v1.2.0 /go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo =
50
50
github.com/gorilla/websocket v1.4.0 /go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ =
51
51
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 /go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs =
52
52
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 /go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk =
Original file line number Diff line number Diff line change @@ -45,4 +45,5 @@ import (
45
45
_ "cuelang.org/go/pkg/tool/file"
46
46
_ "cuelang.org/go/pkg/tool/http"
47
47
_ "cuelang.org/go/pkg/tool/os"
48
+ _ "cuelang.org/go/pkg/uuid"
48
49
)
Original file line number Diff line number Diff line change
1
+ -- in.cue --
2
+ import "uuid"
3
+
4
+ sha1: a: uuid.SHA1(uuid.ns.DNS, "cuelang.org")
5
+
6
+ md5: a: uuid.MD5(uuid.ns.URL, "https://cuelang.org")
7
+
8
+ valid: {
9
+ a: uuid.Valid
10
+ a: "052ef62d-7223-58b6-a551-c1deee46d401"
11
+ }
12
+
13
+ invalid: {
14
+ a: uuid.Valid
15
+ a: "052EF62D-7223-58B6-A551-C1DEEE46D401"
16
+
17
+ b: uuid.Valid
18
+ b: "052ef62d_7223_58b6_a551_c1deee46d401"
19
+ }
20
+
21
+ parse: a: uuid.Parse("052ef62d722358b6a551c1deee46d401")
22
+
23
+ fromInt: a: uuid.FromInt(0x052ef62d_7223_58b6_a551_c1deee46d401)
24
+
25
+ variant: a: uuid.Variant(sha1.a)
26
+ version: a: uuid.Version(sha1.a)
27
+ urn: a: uuid.URN(sha1.a)
28
+ toInt: a: uuid.ToInt(sha1.a)
29
+
30
+ -- out/uuid --
31
+ Errors:
32
+ invalid.a: invalid value "052EF62D-7223-58B6-A551-C1DEEE46D401" (does not satisfy uuid.Valid): invalid UUID "052EF62D-7223-58B6-A551-C1DEEE46D401":
33
+ ./in.cue:14:8
34
+ invalid.b: invalid value "052ef62d_7223_58b6_a551_c1deee46d401" (does not satisfy uuid.Valid): invalid UUID "052ef62d_7223_58b6_a551_c1deee46d401":
35
+ ./in.cue:17:8
36
+
37
+ Result:
38
+ sha1: {
39
+ a: "052ef62d-7223-58b6-a551-c1deee46d401"
40
+ }
41
+ md5: {
42
+ a: "d891d69e-ae5c-39e0-9ead-164abd207f1f"
43
+ }
44
+ valid: {
45
+ a: "052ef62d-7223-58b6-a551-c1deee46d401"
46
+ }
47
+ invalid: {
48
+ a: _|_ // invalid.a: invalid value "052EF62D-7223-58B6-A551-C1DEEE46D401" (does not satisfy uuid.Valid): invalid.a: invalid UUID "052EF62D-7223-58B6-A551-C1DEEE46D401"
49
+ b: _|_ // invalid.b: invalid value "052ef62d_7223_58b6_a551_c1deee46d401" (does not satisfy uuid.Valid): invalid.b: invalid UUID "052ef62d_7223_58b6_a551_c1deee46d401"
50
+ }
51
+ parse: {
52
+ a: "052ef62d-7223-58b6-a551-c1deee46d401"
53
+ }
54
+ fromInt: {
55
+ a: "052ef62d-7223-58b6-a551-c1deee46d401"
56
+ }
57
+ variant: {
58
+ a: 1
59
+ }
60
+ version: {
61
+ a: 5
62
+ }
63
+ urn: {
64
+ a: "urn:uuid:052ef62d-7223-58b6-a551-c1deee46d401"
65
+ }
66
+ toInt: {
67
+ a: 93651793875903522077150095950593860979557386807737776869062002310283964632724204171313
68
+ }
69
+
Original file line number Diff line number Diff line change
1
+ // Copyright 2021 CUE Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ package uuid
16
+
17
+ // Predefined namespaces
18
+ ns : {
19
+ DNS : " 6ba7b810-9dad-11d1-80b4-00c04fd430c8 "
20
+ URL : " 6ba7b811-9dad-11d1-80b4-00c04fd430c8 "
21
+ OID : " 6ba7b812-9dad-11d1-80b4-00c04fd430c8 "
22
+ X500 : " 6ba7b814-9dad-11d1-80b4-00c04fd430c8 "
23
+ Nil : " 00000000-0000-0000-0000-000000000000 "
24
+ }
25
+
26
+ // Invalid UUID
27
+ variants : Invalid : 0
28
+ // The variant specified in RFC4122
29
+ variants : RFC4122 : 1
30
+ // Reserved, NCS backward compatibility.
31
+ variants : Reserved : 2
32
+ // Reserved, Microsoft Corporation backward compatibility.
33
+ variants : Microsoft : 3
34
+ // Reserved for future definition.
35
+ variants : Future : 4
You can’t perform that action at this time.
0 commit comments