Repository: goadesign/goa (go)

Issue:
Missing UUID format example
This function doesn't provide an example for an uuid: https://github.com/goadesign/goa/blob/v3/expr/example.go#L172

Is that by choice?

Pull request:
UUID example
Fix #2233 

Patch:
diff --git a/dsl/description.go b/dsl/description.go
index 99ea9093..1587e9e0 100644
--- a/dsl/description.go
+++ b/dsl/description.go
@@ -1,7 +1,9 @@
 package dsl
 
-import "goa.design/goa/v3/expr"
-import "goa.design/goa/v3/eval"
+import (
+	"goa.design/goa/v3/eval"
+	"goa.design/goa/v3/expr"
+)
 
 // Description sets the expression description.
 //
diff --git a/dsl/value.go b/dsl/value.go
index a6cb15c6..229cd8f2 100644
--- a/dsl/value.go
+++ b/dsl/value.go
@@ -1,7 +1,9 @@
 package dsl
 
-import "goa.design/goa/v3/expr"
-import "goa.design/goa/v3/eval"
+import (
+	"goa.design/goa/v3/eval"
+	"goa.design/goa/v3/expr"
+)
 
 // Value sets the example value.
 //
diff --git a/expr/example.go b/expr/example.go
index 544e927e..2b156494 100644
--- a/expr/example.go
+++ b/expr/example.go
@@ -193,6 +193,13 @@ func byFormat(a *AttributeExpr, r *Random) interface{} {
 		FormatCIDR:    "192.168.100.14/24",
 		FormatRegexp:  r.faker.Characters(3) + ".*",
 		FormatRFC1123: time.Unix(int64(r.Int())%1454957045, 0).UTC().Format(time.RFC1123), // to obtain a "fixed" rand
+		FormatUUID: func() string {
+			res, err := regen.Generate(`[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}`)
+			if err != nil {
+				return "12345678-1234-1234-12324-123456789ABC"
+			}
+			return res
+		}(),
 	}[format]; ok {
 		return res
 	}
diff --git a/grpc/pb/error.pb.go b/grpc/pb/error.pb.go
index 7eb49739..520a7a91 100644
--- a/grpc/pb/error.pb.go
+++ b/grpc/pb/error.pb.go
@@ -3,9 +3,13 @@
 
 package goapb
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+
+	proto "github.com/golang/protobuf/proto"
+
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal


Test patch:
diff --git a/dsl/_spec/dsl_spec_test.go b/dsl/_spec/dsl_spec_test.go
index 64c25705..105e4d71 100644
--- a/dsl/_spec/dsl_spec_test.go
+++ b/dsl/_spec/dsl_spec_test.go
@@ -1,8 +1,10 @@
 // This test demonstrates all the DSL functions defined in the dsl package.
 package dsl_test
 
-import . "goa.design/goa/v3/expr"
-import . "goa.design/goa/v3/dsl"
+import (
+	. "goa.design/goa/v3/dsl"
+	. "goa.design/goa/v3/expr"
+)
 
 // The API expression defines the global API properties of the design. There can
 // only be one such declaration in a given design package.
diff --git a/dsl/_spec/type_spec_test.go b/dsl/_spec/type_spec_test.go
index cb655e11..acd517cd 100644
--- a/dsl/_spec/type_spec_test.go
+++ b/dsl/_spec/type_spec_test.go
@@ -1,8 +1,10 @@
 // This test demonstrates all the possible usage of Type.
 package dsl_test
 
-import . "goa.design/goa/v3/expr"
-import . "goa.design/goa/v3/dsl"
+import (
+	. "goa.design/goa/v3/dsl"
+	. "goa.design/goa/v3/expr"
+)
 
 // BasicType shows the basic usage for Type.
 //
diff --git a/expr/example_test.go b/expr/example_test.go
index 10df5055..5735e71a 100644
--- a/expr/example_test.go
+++ b/expr/example_test.go
@@ -39,6 +39,16 @@ func TestByPattern(t *testing.T) {
 	}
 }
 
+func TestByFormatUUID(t *testing.T) {
+	val := &expr.ValidationExpr{Format: expr.FormatUUID}
+	att := expr.AttributeExpr{Validation: val}
+	r := expr.NewRandom("test")
+	example := att.Example(r).(string)
+	if !regexp.MustCompile(`[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}`).MatchString(example) {
+		t.Errorf("got %s, expected a match with `[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}`", example)
+	}
+}
+
 func TestExample(t *testing.T) {
 	cases := []struct {
 		Name     string