From da9ff3f18abecce55f8d6972f31b40d23c4a63f8 Mon Sep 17 00:00:00 2001 From: Vojtech Vitek Date: Tue, 18 Jul 2023 20:28:19 +0200 Subject: [PATCH] Example: Add uuid.UUID type and regenerate --- _examples/golang-basics/example.gen.go | 13 ++++++++----- _examples/golang-basics/example.ridl | 7 +++++-- _examples/golang-basics/go.mod | 1 + _examples/golang-basics/go.sum | 2 ++ _examples/golang-basics/main.go | 1 + 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/_examples/golang-basics/example.gen.go b/_examples/golang-basics/example.gen.go index 4012696..e0f8878 100644 --- a/_examples/golang-basics/example.gen.go +++ b/_examples/golang-basics/example.gen.go @@ -1,6 +1,6 @@ -// example v0.0.1 ba4284d492b66debf310e943b82638d6885c0a64 +// example v0.0.1 87cdac57aac886a37b5caffc5962c93859970b68 // -- -// Code generated by webrpc-gen@v0.11.x-dev with custom generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.12.x-dev with custom generator. DO NOT EDIT. // // webrpc-gen -schema=example.ridl -target=../../../gen-golang -pkg=main -server -client -out=./example.gen.go -fmt=false -legacyErrors=true package main @@ -8,15 +8,17 @@ package main import ( "bytes" "context" - "errors" "encoding/json" + "errors" "fmt" - "io" + "io" "io/ioutil" "net/http" "net/url" "strings" "time" + + "github.com/google/uuid" ) // WebRPC description and code-gen version @@ -31,7 +33,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "ba4284d492b66debf310e943b82638d6885c0a64" + return "87cdac57aac886a37b5caffc5962c93859970b68" } // @@ -78,6 +80,7 @@ func (x *Kind) UnmarshalJSON(b []byte) error { type User struct { ID uint64 `json:"id" db:"id"` + Uuid uuid.UUID `json:"uuid" db:"id"` Username string `json:"USERNAME" db:"username"` Role string `json:"role" db:"-"` Nicknames []Nickname `json:"nicknames" db:"-"` diff --git a/_examples/golang-basics/example.ridl b/_examples/golang-basics/example.ridl index c450a72..bba44de 100644 --- a/_examples/golang-basics/example.ridl +++ b/_examples/golang-basics/example.ridl @@ -10,11 +10,14 @@ enum Kind: uint32 struct User - id: uint64 - + json = id + go.field.name = ID - #+ go.field.type = int64 + go.tag.db = id + - uuid: string + + go.tag.db = id + + go.field.type = uuid.UUID + + go.type.import = github.com/google/uuid + - username: string + json = USERNAME + go.tag.db = username diff --git a/_examples/golang-basics/go.mod b/_examples/golang-basics/go.mod index 468e1b0..0210692 100644 --- a/_examples/golang-basics/go.mod +++ b/_examples/golang-basics/go.mod @@ -9,6 +9,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/_examples/golang-basics/go.sum b/_examples/golang-basics/go.sum index 8ca3ac9..ceb89f7 100644 --- a/_examples/golang-basics/go.sum +++ b/_examples/golang-basics/go.sum @@ -3,6 +3,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8= github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/_examples/golang-basics/main.go b/_examples/golang-basics/main.go index 28c8743..a7f293b 100644 --- a/_examples/golang-basics/main.go +++ b/_examples/golang-basics/main.go @@ -1,3 +1,4 @@ +//go:generate webrpc-gen -schema=example.ridl -test //go:generate webrpc-gen -schema=example.ridl -target=../../../gen-golang -pkg=main -server -client -out=./example.gen.go -fmt=false -legacyErrors=true package main