From 2a53159e4c6670f1b989ca8c45bba44659fcac31 Mon Sep 17 00:00:00 2001 From: Mario Ranftl Date: Tue, 23 Feb 2021 13:19:31 +0100 Subject: [PATCH 1/6] test upgrade to go-openapi/strfmt@v0.20.0 --- docker-helper.sh | 0 go.mod | 4 +--- go.sum | 15 +++++++++++++-- scripts/modulename/modulename.go | 32 -------------------------------- 4 files changed, 14 insertions(+), 37 deletions(-) mode change 100644 => 100755 docker-helper.sh delete mode 100644 scripts/modulename/modulename.go diff --git a/docker-helper.sh b/docker-helper.sh old mode 100644 new mode 100755 diff --git a/go.mod b/go.mod index 327c446..89075e4 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,4 @@ module github.com/allaboutapps/nullable go 1.14 -require ( - github.com/go-openapi/strfmt v0.19.11 -) +require github.com/go-openapi/strfmt v0.20.0 diff --git a/go.sum b/go.sum index ac7e43d..8341dbe 100644 --- a/go.sum +++ b/go.sum @@ -4,11 +4,12 @@ github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:W github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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-openapi/errors v0.19.8 h1:doM+tQdZbUm9gydV9yR+iQNmztbjj7I3sW4sIcAwIzc= github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/strfmt v0.19.11 h1:0+YvbNh05rmBkgztd6zHp4OCFn7Mtu30bn46NQo2ZRw= -github.com/go-openapi/strfmt v0.19.11/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= +github.com/go-openapi/strfmt v0.20.0 h1:l2omNtmNbMc39IGptl9BuXBEKcZfS8zjrTsPKTiJiDM= +github.com/go-openapi/strfmt v0.20.0/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -37,7 +38,9 @@ github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGt github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -51,17 +54,20 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxv github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +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/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -75,7 +81,9 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= @@ -106,11 +114,14 @@ golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo= gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/scripts/modulename/modulename.go b/scripts/modulename/modulename.go deleted file mode 100644 index c4838a6..0000000 --- a/scripts/modulename/modulename.go +++ /dev/null @@ -1,32 +0,0 @@ -// +build scripts - -// This program prints the current project's module name -// It can be invoked by running go run scripts/modulename/modulename.go -package main - -import ( - "fmt" - "log" - - "allaboutapps.dev/tpa/portal-backend/internal/util" - "allaboutapps.dev/tpa/portal-backend/scripts" -) - -// https://blog.carlmjohnson.net/post/2016-11-27-how-to-use-go-generate/ - -var ( - PROJECT_ROOT = util.GetProjectRootDir() - PATH_MOD_FILE = PROJECT_ROOT + "/go.mod" -) - -// get all functions in above handler packages -// that match Get*, Put*, Post*, Patch*, Delete* -func main() { - baseModuleName, err := scripts.GetModuleName(PATH_MOD_FILE) - - if err != nil { - log.Fatal(err) - } - - fmt.Println(baseModuleName) -} From 2734f63364cead7ce45e643aeb53aa12209de752 Mon Sep 17 00:00:00 2001 From: Mario Ranftl Date: Fri, 26 Feb 2021 17:13:38 +0100 Subject: [PATCH 2/6] support openapi.runtime ContextValidate, implement support for slice types, add tests for interfaces compability --- bool.go | 28 ++++++- float32.go | 28 ++++++- float64.go | 28 ++++++- go.mod | 5 +- go.sum | 112 +++++++++++++++++++++++++ int.go | 28 ++++++- int16.go | 28 ++++++- int32.go | 28 ++++++- int64.go | 28 ++++++- runtime_test.go | 47 +++++++++++ scripts/nullable/nullable_types.gotmpl | 28 ++++++- string.go | 28 ++++++- 12 files changed, 406 insertions(+), 10 deletions(-) create mode 100644 runtime_test.go diff --git a/bool.go b/bool.go index 01214ce..0010369 100644 --- a/bool.go +++ b/bool.go @@ -4,6 +4,7 @@ package nullable import ( "bytes" + "context" "encoding/json" "github.com/go-openapi/strfmt" ) @@ -42,11 +43,16 @@ func (b *Bool) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (b *Bool) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (b *Bool) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // BoolSlice represents a []bool that may be null or not // present in json at all. type BoolSlice struct { @@ -70,3 +76,23 @@ func (b *BoolSlice) UnmarshalJSON(data []byte) error { b.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (b *BoolSlice) Ptr() *[]bool { + if b.Present && b.Valid { + return &b.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (b *BoolSlice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (b *BoolSlice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/float32.go b/float32.go index 054dddd..1667bdd 100644 --- a/float32.go +++ b/float32.go @@ -4,6 +4,7 @@ package nullable import ( "bytes" + "context" "encoding/json" "github.com/go-openapi/strfmt" ) @@ -42,11 +43,16 @@ func (f *Float32) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (f *Float32) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (f *Float32) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // Float32Slice represents a []float32 that may be null or not // present in json at all. type Float32Slice struct { @@ -70,3 +76,23 @@ func (f *Float32Slice) UnmarshalJSON(data []byte) error { f.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (f *Float32Slice) Ptr() *[]float32 { + if f.Present && f.Valid { + return &f.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (f *Float32Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (f *Float32Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/float64.go b/float64.go index c671896..2fca2a5 100644 --- a/float64.go +++ b/float64.go @@ -4,6 +4,7 @@ package nullable import ( "bytes" + "context" "encoding/json" "github.com/go-openapi/strfmt" ) @@ -42,11 +43,16 @@ func (f *Float64) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (f *Float64) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (f *Float64) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // Float64Slice represents a []float64 that may be null or not // present in json at all. type Float64Slice struct { @@ -70,3 +76,23 @@ func (f *Float64Slice) UnmarshalJSON(data []byte) error { f.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (f *Float64Slice) Ptr() *[]float64 { + if f.Present && f.Valid { + return &f.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (f *Float64Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (f *Float64Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/go.mod b/go.mod index 89075e4..8e57bc4 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module github.com/allaboutapps/nullable go 1.14 -require github.com/go-openapi/strfmt v0.20.0 +require ( + github.com/go-openapi/runtime v0.19.26 + github.com/go-openapi/strfmt v0.20.0 +) diff --git a/go.sum b/go.sum index 8341dbe..2a682e8 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,11 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= +github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= @@ -6,10 +13,70 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= +github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= +github.com/go-openapi/analysis v0.19.4/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= +github.com/go-openapi/analysis v0.19.5/go.mod h1:hkEAkxagaIvIP7VTn8ygJNkd4kAYON2rCu0v0ObL0AU= +github.com/go-openapi/analysis v0.19.10/go.mod h1:qmhS3VNFxBlquFJ0RGoDtylO9y4pgTAUNE9AEEMdlJQ= +github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= +github.com/go-openapi/errors v0.19.3/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= +github.com/go-openapi/errors v0.19.6/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= github.com/go-openapi/errors v0.19.8 h1:doM+tQdZbUm9gydV9yR+iQNmztbjj7I3sW4sIcAwIzc= github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= +github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= +github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs= +github.com/go-openapi/loads v0.19.3/go.mod h1:YVfqhUCdahYwR3f3iiwQLhicVRvLlU/WO5WPaZvcvSI= +github.com/go-openapi/loads v0.19.5/go.mod h1:dswLCAdonkRufe/gSUC3gN8nTSaB9uaS2es0x5/IbjY= +github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= +github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= +github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4= +github.com/go-openapi/runtime v0.19.15/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo= +github.com/go-openapi/runtime v0.19.26 h1:K/6PoVNj5WJXUnMk+VEbELeXjtBkCS1UxTDa04tdXE0= +github.com/go-openapi/runtime v0.19.26/go.mod h1:BvrQtn6iVb2QmiVXRsFAm6ZCAZBpbVKFfN6QWCp582M= +github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= +github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= +github.com/go-openapi/spec v0.19.6/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/spec v0.19.8/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= +github.com/go-openapi/strfmt v0.19.2/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= +github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= +github.com/go-openapi/strfmt v0.19.4/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= +github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= github.com/go-openapi/strfmt v0.20.0 h1:l2omNtmNbMc39IGptl9BuXBEKcZfS8zjrTsPKTiJiDM= github.com/go-openapi/strfmt v0.20.0/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= +github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.7/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= +github.com/go-openapi/swag v0.19.9 h1:1IxuqvBUU3S2Bi4YC7tlP9SJF1gVpCvqN0T2Qof4azE= +github.com/go-openapi/swag v0.19.9/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= +github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= +github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= +github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo= +github.com/go-openapi/validate v0.19.10/go.mod h1:RKEZTUWDkxKQxN2jDT7ZnZi2bhZlbNMAuKvKB+IaGx8= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -38,8 +105,11 @@ github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGt github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -48,21 +118,34 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8= +github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -79,41 +162,63 @@ github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3 github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.3.0/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= +go.mongodb.org/mongo-driver v1.3.4/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= go.mongodb.org/mongo-driver v1.4.3 h1:moga+uhicpVshTyaqY9L23E6QqwcHRUv1sqyOsoyOO8= go.mongodb.org/mongo-driver v1.4.3/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -121,7 +226,14 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo= gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/int.go b/int.go index 4e729cb..773de57 100644 --- a/int.go +++ b/int.go @@ -4,6 +4,7 @@ package nullable import ( "bytes" + "context" "encoding/json" "github.com/go-openapi/strfmt" ) @@ -42,11 +43,16 @@ func (i *Int) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (i *Int) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // IntSlice represents a []int that may be null or not // present in json at all. type IntSlice struct { @@ -70,3 +76,23 @@ func (i *IntSlice) UnmarshalJSON(data []byte) error { i.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (i *IntSlice) Ptr() *[]int { + if i.Present && i.Valid { + return &i.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (i *IntSlice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *IntSlice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/int16.go b/int16.go index 3ea3a36..f699088 100644 --- a/int16.go +++ b/int16.go @@ -4,6 +4,7 @@ package nullable import ( "bytes" + "context" "encoding/json" "github.com/go-openapi/strfmt" ) @@ -42,11 +43,16 @@ func (i *Int16) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (i *Int16) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int16) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // Int16Slice represents a []int16 that may be null or not // present in json at all. type Int16Slice struct { @@ -70,3 +76,23 @@ func (i *Int16Slice) UnmarshalJSON(data []byte) error { i.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (i *Int16Slice) Ptr() *[]int16 { + if i.Present && i.Valid { + return &i.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (i *Int16Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int16Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/int32.go b/int32.go index b4e42a5..711f5f6 100644 --- a/int32.go +++ b/int32.go @@ -4,6 +4,7 @@ package nullable import ( "bytes" + "context" "encoding/json" "github.com/go-openapi/strfmt" ) @@ -42,11 +43,16 @@ func (i *Int32) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (i *Int32) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int32) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // Int32Slice represents a []int32 that may be null or not // present in json at all. type Int32Slice struct { @@ -70,3 +76,23 @@ func (i *Int32Slice) UnmarshalJSON(data []byte) error { i.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (i *Int32Slice) Ptr() *[]int32 { + if i.Present && i.Valid { + return &i.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (i *Int32Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int32Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/int64.go b/int64.go index 4eefdd1..72798fb 100644 --- a/int64.go +++ b/int64.go @@ -4,6 +4,7 @@ package nullable import ( "bytes" + "context" "encoding/json" "github.com/go-openapi/strfmt" ) @@ -42,11 +43,16 @@ func (i *Int64) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (i *Int64) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int64) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // Int64Slice represents a []int64 that may be null or not // present in json at all. type Int64Slice struct { @@ -70,3 +76,23 @@ func (i *Int64Slice) UnmarshalJSON(data []byte) error { i.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (i *Int64Slice) Ptr() *[]int64 { + if i.Present && i.Valid { + return &i.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (i *Int64Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (i *Int64Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/runtime_test.go b/runtime_test.go new file mode 100644 index 0000000..be73bfd --- /dev/null +++ b/runtime_test.go @@ -0,0 +1,47 @@ +package nullable + +import ( + "fmt" + "testing" + + "github.com/go-openapi/runtime" +) + +func TestInt16ImplementsRuntimeValidatable(t *testing.T) { + + tests := []interface{}{ + &Bool{}, + &BoolSlice{}, + &String{}, + &StringSlice{}, + &Int{}, + &IntSlice{}, + &Int16{}, + &Int16Slice{}, + &Int32{}, + &Int32Slice{}, + &Int64{}, + &Int64Slice{}, + &Float32{}, + &Float32Slice{}, + &Float64{}, + &Float64Slice{}, + } + + for _, tt := range tests { + t.Run(fmt.Sprintf("%T", tt), func(t *testing.T) { + + _, ok := interface{}(tt).(runtime.Validatable) + + if !ok { + t.Errorf("expected %T to implement github.com/go-openapi/runtime runtime.Validatable", tt) + } + + _, ok = interface{}(tt).(runtime.ContextValidatable) + + if !ok { + t.Errorf("expected %T to implement github.com/go-openapi/runtime runtime.ContextValidatable", tt) + } + }) + } +} diff --git a/scripts/nullable/nullable_types.gotmpl b/scripts/nullable/nullable_types.gotmpl index 81030ea..294c3b6 100644 --- a/scripts/nullable/nullable_types.gotmpl +++ b/scripts/nullable/nullable_types.gotmpl @@ -4,6 +4,7 @@ package nullable import ( "bytes" + "context" "encoding/json" "github.com/go-openapi/strfmt" ) @@ -42,11 +43,16 @@ func ({{ .Short }} *{{ .NullableType }}) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func ({{ .Short }} *{{ .NullableType }}) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func ({{ .Short }} *{{ .NullableType }}) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // {{ .NullableType }}Slice represents a []{{ .Type }} that may be null or not // present in json at all. type {{ .NullableType }}Slice struct { @@ -70,3 +76,23 @@ func ({{ .Short }} *{{ .NullableType }}Slice) UnmarshalJSON(data []byte) error { {{ .Short }}.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func ({{ .Short }} *{{ .NullableType }}Slice) Ptr() *[]{{ .Type }} { + if {{ .Short }}.Present && {{ .Short }}.Valid { + return &{{ .Short }}.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func ({{ .Short }} *{{ .NullableType }}Slice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func ({{ .Short }} *{{ .NullableType }}Slice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} diff --git a/string.go b/string.go index f4261e7..187bb2e 100644 --- a/string.go +++ b/string.go @@ -4,6 +4,7 @@ package nullable import ( "bytes" + "context" "encoding/json" "github.com/go-openapi/strfmt" ) @@ -42,11 +43,16 @@ func (s *String) UnmarshalJSON(data []byte) error { return nil } -// Validate implements runtime.Validateable interface for go-swagger generation. +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime func (s *String) Validate(formats strfmt.Registry) error { return nil } +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (s *String) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + // StringSlice represents a []string that may be null or not // present in json at all. type StringSlice struct { @@ -70,3 +76,23 @@ func (s *StringSlice) UnmarshalJSON(data []byte) error { s.Valid = true return nil } + +// Returns nil if not present or valid. Otherwise it will +// return a pointer to the value. +func (s *StringSlice) Ptr() *[]string { + if s.Present && s.Valid { + return &s.Value + } + + return nil +} + +// Validate implements runtime.Validateable interface from github.com/go-openapi/runtime +func (s *StringSlice) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate implements runtime.ContextValidatable from github.com/go-openapi/runtime +func (s *StringSlice) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} From 4b66323427c1fd2fc820f28ab3e063832f885464 Mon Sep 17 00:00:00 2001 From: Mario Ranftl Date: Fri, 26 Feb 2021 17:24:31 +0100 Subject: [PATCH 3/6] tmp expose module as github.com/majodev/nullable for testing --- README.md | 20 ++++++++++---------- examples/main.go | 2 +- go.mod | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3a6c20a..e2af74a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Build Status](https://travis-ci.com/kernle32dll/nullable.svg?branch=master)](https://travis-ci.com/kernle32dll/nullable) -[![GoDoc](https://godoc.org/github.com/allaboutapps/nullable?status.svg)](http://godoc.org/github.com/allaboutapps/nullable) -[![Go Report Card](https://goreportcard.com/badge/github.com/allaboutapps/nullable)](https://goreportcard.com/report/github.com/allaboutapps/nullable) +[![GoDoc](https://godoc.org/github.com/majodev/nullable?status.svg)](http://godoc.org/github.com/majodev/nullable) +[![Go Report Card](https://goreportcard.com/badge/github.com/majodev/nullable)](https://goreportcard.com/report/github.com/majodev/nullable) [![codecov](https://codecov.io/gh/kernle32dll/nullable/branch/master/graph/badge.svg)](https://codecov.io/gh/kernle32dll/nullable) # nullable @@ -13,13 +13,13 @@ Inspired by [How to determine if a JSON key has been set to null or not provided To get the package, execute: ```bash -go get github.com/allaboutapps/nullable +go get github.com/majodev/nullable ``` To import this package, add the following line to your code: ```bash -import "github.com/allaboutapps/nullable" +import "github.com/majodev/nullable" ``` Refer to it as `nullable`. @@ -29,7 +29,7 @@ For more details, see the API documentation. # Example ```go -import "github.com/allaboutapps/nullable" +import "github.com/majodev/nullable" func main() { usr := struct { @@ -74,14 +74,14 @@ definitions: example: 1234 x-go-type: import: - package: github.com/allaboutapps/nullable + package: github.com/majodev/nullable type: Int NullableInt16: type: integer example: 1234 x-go-type: import: - package: github.com/allaboutapps/nullable + package: github.com/majodev/nullable type: Int16 NullableFloat: type: number @@ -89,7 +89,7 @@ definitions: example: 1.5 x-go-type: import: - package: github.com/allaboutapps/nullable + package: github.com/majodev/nullable type: Float32 NullableFloat64: type: number @@ -97,14 +97,14 @@ definitions: example: 1.5 x-go-type: import: - package: github.com/allaboutapps/nullable + package: github.com/majodev/nullable type: Float64 NullableString: type: string example: example x-go-type: import: - package: github.com/allaboutapps/nullable + package: github.com/majodev/nullable type: String ``` diff --git a/examples/main.go b/examples/main.go index d8ef333..ac98f19 100644 --- a/examples/main.go +++ b/examples/main.go @@ -5,7 +5,7 @@ import ( "fmt" "log" - "github.com/allaboutapps/nullable" + "github.com/majodev/nullable" ) const ( diff --git a/go.mod b/go.mod index 8e57bc4..374891b 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/allaboutapps/nullable +module github.com/majodev/nullable go 1.14 From a75e45083fb12fad48ec15433ce80c5f6228a241 Mon Sep 17 00:00:00 2001 From: Mario Ranftl Date: Mon, 8 Mar 2021 17:56:11 +0100 Subject: [PATCH 4/6] compiletime check for runtime.Validatable and runtime.ContextValidatable impl. --- Dockerfile | 2 +- bool.go | 9 +++++++++ float32.go | 9 +++++++++ float64.go | 9 +++++++++ go.mod | 2 +- go.sum | 2 -- int.go | 9 +++++++++ int16.go | 9 +++++++++ int32.go | 9 +++++++++ int64.go | 9 +++++++++ scripts/nullable/nullable_types.gotmpl | 9 +++++++++ string.go | 9 +++++++++ 12 files changed, 83 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 581bce0..21db691 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # --- https://hub.docker.com/_/golang # --- https://github.com/microsoft/vscode-remote-try-go/blob/master/.devcontainer/Dockerfile ### ----------------------- -FROM golang:1.14.2 AS development +FROM golang:1.16.0 AS development # Avoid warnings by switching to noninteractive ENV DEBIAN_FRONTEND=noninteractive diff --git a/bool.go b/bool.go index 0010369..61f549e 100644 --- a/bool.go +++ b/bool.go @@ -6,9 +6,18 @@ import ( "bytes" "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Bool{} + _ runtime.ContextValidatable = &Bool{} + _ runtime.Validatable = &BoolSlice{} + _ runtime.ContextValidatable = &BoolSlice{} +) + // Bool represents a bool that may be null or not // present in json at all. type Bool struct { diff --git a/float32.go b/float32.go index 1667bdd..00becda 100644 --- a/float32.go +++ b/float32.go @@ -6,9 +6,18 @@ import ( "bytes" "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Float32{} + _ runtime.ContextValidatable = &Float32{} + _ runtime.Validatable = &Float32Slice{} + _ runtime.ContextValidatable = &Float32Slice{} +) + // Float32 represents a float32 that may be null or not // present in json at all. type Float32 struct { diff --git a/float64.go b/float64.go index 2fca2a5..455c23a 100644 --- a/float64.go +++ b/float64.go @@ -6,9 +6,18 @@ import ( "bytes" "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Float64{} + _ runtime.ContextValidatable = &Float64{} + _ runtime.Validatable = &Float64Slice{} + _ runtime.ContextValidatable = &Float64Slice{} +) + // Float64 represents a float64 that may be null or not // present in json at all. type Float64 struct { diff --git a/go.mod b/go.mod index 374891b..7ebda3e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/majodev/nullable -go 1.14 +go 1.16 require ( github.com/go-openapi/runtime v0.19.26 diff --git a/go.sum b/go.sum index 2a682e8..aef3231 100644 --- a/go.sum +++ b/go.sum @@ -219,7 +219,6 @@ golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -233,7 +232,6 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo= gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/int.go b/int.go index 773de57..053b93b 100644 --- a/int.go +++ b/int.go @@ -6,9 +6,18 @@ import ( "bytes" "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Int{} + _ runtime.ContextValidatable = &Int{} + _ runtime.Validatable = &IntSlice{} + _ runtime.ContextValidatable = &IntSlice{} +) + // Int represents a int that may be null or not // present in json at all. type Int struct { diff --git a/int16.go b/int16.go index f699088..d75bb83 100644 --- a/int16.go +++ b/int16.go @@ -6,9 +6,18 @@ import ( "bytes" "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Int16{} + _ runtime.ContextValidatable = &Int16{} + _ runtime.Validatable = &Int16Slice{} + _ runtime.ContextValidatable = &Int16Slice{} +) + // Int16 represents a int16 that may be null or not // present in json at all. type Int16 struct { diff --git a/int32.go b/int32.go index 711f5f6..9df4bb3 100644 --- a/int32.go +++ b/int32.go @@ -6,9 +6,18 @@ import ( "bytes" "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Int32{} + _ runtime.ContextValidatable = &Int32{} + _ runtime.Validatable = &Int32Slice{} + _ runtime.ContextValidatable = &Int32Slice{} +) + // Int32 represents a int32 that may be null or not // present in json at all. type Int32 struct { diff --git a/int64.go b/int64.go index 72798fb..2125fd0 100644 --- a/int64.go +++ b/int64.go @@ -6,9 +6,18 @@ import ( "bytes" "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &Int64{} + _ runtime.ContextValidatable = &Int64{} + _ runtime.Validatable = &Int64Slice{} + _ runtime.ContextValidatable = &Int64Slice{} +) + // Int64 represents a int64 that may be null or not // present in json at all. type Int64 struct { diff --git a/scripts/nullable/nullable_types.gotmpl b/scripts/nullable/nullable_types.gotmpl index 294c3b6..5055a62 100644 --- a/scripts/nullable/nullable_types.gotmpl +++ b/scripts/nullable/nullable_types.gotmpl @@ -6,9 +6,18 @@ import ( "bytes" "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &{{ .NullableType }}{} + _ runtime.ContextValidatable = &{{ .NullableType }}{} + _ runtime.Validatable = &{{ .NullableType }}Slice{} + _ runtime.ContextValidatable = &{{ .NullableType }}Slice{} +) + // {{ .NullableType }} represents a {{ .Type }} that may be null or not // present in json at all. type {{ .NullableType }} struct { diff --git a/string.go b/string.go index 187bb2e..76d176f 100644 --- a/string.go +++ b/string.go @@ -6,9 +6,18 @@ import ( "bytes" "context" "encoding/json" + "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" ) +// Compile time validation that our types implement the expected interfaces +var ( + _ runtime.Validatable = &String{} + _ runtime.ContextValidatable = &String{} + _ runtime.Validatable = &StringSlice{} + _ runtime.ContextValidatable = &StringSlice{} +) + // String represents a string that may be null or not // present in json at all. type String struct { From 865fddac3c2daf7edcd0cf68b9bf2a8ad7a7fc18 Mon Sep 17 00:00:00 2001 From: Mario Ranftl Date: Mon, 8 Mar 2021 17:58:25 +0100 Subject: [PATCH 5/6] del runtime test for interface impl (as we have that now automatically during compile time) --- runtime_test.go | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 runtime_test.go diff --git a/runtime_test.go b/runtime_test.go deleted file mode 100644 index be73bfd..0000000 --- a/runtime_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package nullable - -import ( - "fmt" - "testing" - - "github.com/go-openapi/runtime" -) - -func TestInt16ImplementsRuntimeValidatable(t *testing.T) { - - tests := []interface{}{ - &Bool{}, - &BoolSlice{}, - &String{}, - &StringSlice{}, - &Int{}, - &IntSlice{}, - &Int16{}, - &Int16Slice{}, - &Int32{}, - &Int32Slice{}, - &Int64{}, - &Int64Slice{}, - &Float32{}, - &Float32Slice{}, - &Float64{}, - &Float64Slice{}, - } - - for _, tt := range tests { - t.Run(fmt.Sprintf("%T", tt), func(t *testing.T) { - - _, ok := interface{}(tt).(runtime.Validatable) - - if !ok { - t.Errorf("expected %T to implement github.com/go-openapi/runtime runtime.Validatable", tt) - } - - _, ok = interface{}(tt).(runtime.ContextValidatable) - - if !ok { - t.Errorf("expected %T to implement github.com/go-openapi/runtime runtime.ContextValidatable", tt) - } - }) - } -} From df3394c11b9414436869675ec95f75103e2b1bd6 Mon Sep 17 00:00:00 2001 From: Mario Ranftl Date: Mon, 8 Mar 2021 18:00:10 +0100 Subject: [PATCH 6/6] change modname back to github.com/allaboutapps/nullable --- README.md | 20 ++++++++++---------- examples/main.go | 2 +- go.mod | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e2af74a..3a6c20a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Build Status](https://travis-ci.com/kernle32dll/nullable.svg?branch=master)](https://travis-ci.com/kernle32dll/nullable) -[![GoDoc](https://godoc.org/github.com/majodev/nullable?status.svg)](http://godoc.org/github.com/majodev/nullable) -[![Go Report Card](https://goreportcard.com/badge/github.com/majodev/nullable)](https://goreportcard.com/report/github.com/majodev/nullable) +[![GoDoc](https://godoc.org/github.com/allaboutapps/nullable?status.svg)](http://godoc.org/github.com/allaboutapps/nullable) +[![Go Report Card](https://goreportcard.com/badge/github.com/allaboutapps/nullable)](https://goreportcard.com/report/github.com/allaboutapps/nullable) [![codecov](https://codecov.io/gh/kernle32dll/nullable/branch/master/graph/badge.svg)](https://codecov.io/gh/kernle32dll/nullable) # nullable @@ -13,13 +13,13 @@ Inspired by [How to determine if a JSON key has been set to null or not provided To get the package, execute: ```bash -go get github.com/majodev/nullable +go get github.com/allaboutapps/nullable ``` To import this package, add the following line to your code: ```bash -import "github.com/majodev/nullable" +import "github.com/allaboutapps/nullable" ``` Refer to it as `nullable`. @@ -29,7 +29,7 @@ For more details, see the API documentation. # Example ```go -import "github.com/majodev/nullable" +import "github.com/allaboutapps/nullable" func main() { usr := struct { @@ -74,14 +74,14 @@ definitions: example: 1234 x-go-type: import: - package: github.com/majodev/nullable + package: github.com/allaboutapps/nullable type: Int NullableInt16: type: integer example: 1234 x-go-type: import: - package: github.com/majodev/nullable + package: github.com/allaboutapps/nullable type: Int16 NullableFloat: type: number @@ -89,7 +89,7 @@ definitions: example: 1.5 x-go-type: import: - package: github.com/majodev/nullable + package: github.com/allaboutapps/nullable type: Float32 NullableFloat64: type: number @@ -97,14 +97,14 @@ definitions: example: 1.5 x-go-type: import: - package: github.com/majodev/nullable + package: github.com/allaboutapps/nullable type: Float64 NullableString: type: string example: example x-go-type: import: - package: github.com/majodev/nullable + package: github.com/allaboutapps/nullable type: String ``` diff --git a/examples/main.go b/examples/main.go index ac98f19..d8ef333 100644 --- a/examples/main.go +++ b/examples/main.go @@ -5,7 +5,7 @@ import ( "fmt" "log" - "github.com/majodev/nullable" + "github.com/allaboutapps/nullable" ) const ( diff --git a/go.mod b/go.mod index 7ebda3e..24e5f00 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/majodev/nullable +module github.com/allaboutapps/nullable go 1.16