Update dependencies

This commit is contained in:
Ingo Oppermann
2024-07-17 16:58:45 +02:00
parent 15e1cd7b6f
commit 8a28e2cf96
259 changed files with 3976 additions and 2668 deletions

43
go.mod
View File

@@ -5,17 +5,17 @@ go 1.21.0
toolchain go1.22.1 toolchain go1.22.1
require ( require (
github.com/99designs/gqlgen v0.17.47 github.com/99designs/gqlgen v0.17.49
github.com/Masterminds/semver/v3 v3.2.1 github.com/Masterminds/semver/v3 v3.2.1
github.com/adhocore/gronx v1.8.1 github.com/adhocore/gronx v1.8.1
github.com/andybalholm/brotli v1.1.0 github.com/andybalholm/brotli v1.1.0
github.com/atrox/haikunatorgo/v2 v2.0.1 github.com/atrox/haikunatorgo/v2 v2.0.1
github.com/caddyserver/certmagic v0.21.3 github.com/caddyserver/certmagic v0.21.3
github.com/casbin/casbin/v2 v2.90.0 github.com/casbin/casbin/v2 v2.97.0
github.com/datarhei/gosrt v0.6.0 github.com/datarhei/gosrt v0.6.0
github.com/datarhei/joy4 v0.0.0-20240603190808-b1407345907e github.com/datarhei/joy4 v0.0.0-20240603190808-b1407345907e
github.com/fujiwara/shapeio v1.0.0 github.com/fujiwara/shapeio v1.0.0
github.com/go-playground/validator/v10 v10.21.0 github.com/go-playground/validator/v10 v10.22.0
github.com/gobwas/glob v0.2.3 github.com/gobwas/glob v0.2.3
github.com/goccy/go-json v0.10.3 github.com/goccy/go-json v0.10.3
github.com/golang-jwt/jwt/v4 v4.5.0 github.com/golang-jwt/jwt/v4 v4.5.0
@@ -23,31 +23,31 @@ require (
github.com/google/gops v0.3.28 github.com/google/gops v0.3.28
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
github.com/hashicorp/go-hclog v1.6.3 github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/raft v1.6.1 github.com/hashicorp/raft v1.7.0
github.com/hashicorp/raft-boltdb/v2 v2.3.0 github.com/hashicorp/raft-boltdb/v2 v2.3.0
github.com/invopop/jsonschema v0.4.0 github.com/invopop/jsonschema v0.4.0
github.com/joho/godotenv v1.5.1 github.com/joho/godotenv v1.5.1
github.com/klauspost/compress v1.17.8 github.com/klauspost/compress v1.17.9
github.com/klauspost/cpuid/v2 v2.2.7 github.com/klauspost/cpuid/v2 v2.2.8
github.com/labstack/echo/v4 v4.12.0 github.com/labstack/echo/v4 v4.12.0
github.com/lestrrat-go/strftime v1.0.6 github.com/lestrrat-go/strftime v1.0.6
github.com/lithammer/shortuuid/v4 v4.0.0 github.com/lithammer/shortuuid/v4 v4.0.0
github.com/mattn/go-isatty v0.0.20 github.com/mattn/go-isatty v0.0.20
github.com/minio/minio-go/v7 v7.0.70 github.com/minio/minio-go/v7 v7.0.74
github.com/prep/average v0.0.0-20200506183628-d26c465f48c3 github.com/prep/average v0.0.0-20200506183628-d26c465f48c3
github.com/prometheus/client_golang v1.19.1 github.com/prometheus/client_golang v1.19.1
github.com/puzpuzpuz/xsync/v3 v3.1.0 github.com/puzpuzpuz/xsync/v3 v3.4.0
github.com/shirou/gopsutil/v3 v3.24.5 github.com/shirou/gopsutil/v3 v3.24.5
github.com/stretchr/testify v1.9.0 github.com/stretchr/testify v1.9.0
github.com/swaggo/echo-swagger v1.4.1 github.com/swaggo/echo-swagger v1.4.1
github.com/swaggo/swag v1.16.3 github.com/swaggo/swag v1.16.3
github.com/vektah/gqlparser/v2 v2.5.12 github.com/vektah/gqlparser/v2 v2.5.16
github.com/xeipuuv/gojsonschema v1.2.0 github.com/xeipuuv/gojsonschema v1.2.0
go.etcd.io/bbolt v1.3.10 go.etcd.io/bbolt v1.3.10
go.uber.org/automaxprocs v1.5.3 go.uber.org/automaxprocs v1.5.3
go.uber.org/zap v1.27.0 go.uber.org/zap v1.27.0
golang.org/x/crypto v0.24.0 golang.org/x/crypto v0.25.0
golang.org/x/mod v0.18.0 golang.org/x/mod v0.19.0
) )
//replace github.com/datarhei/core-client-go/v16 => ../core-client-go //replace github.com/datarhei/core-client-go/v16 => ../core-client-go
@@ -60,7 +60,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect
github.com/boltdb/bolt v1.3.1 // indirect github.com/boltdb/bolt v1.3.1 // indirect
github.com/caddyserver/zerossl v0.1.3 // indirect github.com/caddyserver/zerossl v0.1.3 // indirect
github.com/casbin/govaluate v1.1.1 // indirect github.com/casbin/govaluate v1.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
@@ -68,6 +68,7 @@ require (
github.com/fatih/color v1.17.0 // indirect github.com/fatih/color v1.17.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.4 // indirect github.com/gabriel-vasile/mimetype v1.4.4 // indirect
github.com/ghodss/yaml v1.0.0 // indirect github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect github.com/go-openapi/jsonreference v0.21.0 // indirect
@@ -76,7 +77,7 @@ require (
github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/gorilla/websocket v1.5.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-msgpack/v2 v2.1.2 // indirect github.com/hashicorp/go-msgpack/v2 v2.1.2 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect
@@ -90,20 +91,21 @@ require (
github.com/mailru/easyjson v0.7.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mholt/acmez/v2 v2.0.1 // indirect github.com/mholt/acmez/v2 v2.0.1 // indirect
github.com/miekg/dns v1.1.59 // indirect github.com/miekg/dns v1.1.61 // indirect
github.com/minio/md5-simd v1.1.2 // indirect github.com/minio/md5-simd v1.1.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.54.0 // indirect github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect github.com/prometheus/procfs v0.15.1 // indirect
github.com/rs/xid v1.5.0 // indirect github.com/rs/xid v1.5.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sosodev/duration v1.3.1 // indirect github.com/sosodev/duration v1.3.1 // indirect
github.com/swaggo/files/v2 v2.0.0 // indirect github.com/swaggo/files/v2 v2.0.1 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.8.0 // indirect github.com/tklauser/numcpus v0.8.0 // indirect
github.com/urfave/cli/v2 v2.27.2 // indirect github.com/urfave/cli/v2 v2.27.2 // indirect
@@ -115,14 +117,13 @@ require (
github.com/yusufpapurcu/wmi v1.2.4 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect
github.com/zeebo/blake3 v0.2.3 // indirect github.com/zeebo/blake3 v0.2.3 // indirect
go.uber.org/multierr v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.26.0 // indirect golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.22.0 // indirect golang.org/x/tools v0.23.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

86
go.sum
View File

@@ -1,5 +1,5 @@
github.com/99designs/gqlgen v0.17.47 h1:M9DTK8X3+3ATNBfZlHBwMwNngn4hhZWDxNmTiuQU5tQ= github.com/99designs/gqlgen v0.17.49 h1:b3hNGexHd33fBSAd4NDT/c3NCcQzcAVkknhN9ym36YQ=
github.com/99designs/gqlgen v0.17.47/go.mod h1:ejVkldSdtmuudqmtfaiqjwlGXWAhIv0DKXGXFY25F04= github.com/99designs/gqlgen v0.17.49/go.mod h1:tC8YFVZMed81x7UJ7ORUwXF4Kn6SXuucFqQBhN8+BU0=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
@@ -39,11 +39,11 @@ github.com/caddyserver/certmagic v0.21.3 h1:pqRRry3yuB4CWBVq9+cUqu+Y6E2z8TswbhNx
github.com/caddyserver/certmagic v0.21.3/go.mod h1:Zq6pklO9nVRl3DIFUw9gVUfXKdpc/0qwTUAQMBlfgtI= github.com/caddyserver/certmagic v0.21.3/go.mod h1:Zq6pklO9nVRl3DIFUw9gVUfXKdpc/0qwTUAQMBlfgtI=
github.com/caddyserver/zerossl v0.1.3 h1:onS+pxp3M8HnHpN5MMbOMyNjmTheJyWRaZYwn+YTAyA= github.com/caddyserver/zerossl v0.1.3 h1:onS+pxp3M8HnHpN5MMbOMyNjmTheJyWRaZYwn+YTAyA=
github.com/caddyserver/zerossl v0.1.3/go.mod h1:CxA0acn7oEGO6//4rtrRjYgEoa4MFw/XofZnrYwGqG4= github.com/caddyserver/zerossl v0.1.3/go.mod h1:CxA0acn7oEGO6//4rtrRjYgEoa4MFw/XofZnrYwGqG4=
github.com/casbin/casbin/v2 v2.90.0 h1:65jvnocLmG8FfrfKcuqRd+Tp5B7R/OBxOVu1IhUMT5A= github.com/casbin/casbin/v2 v2.97.0 h1:FFHIzY+6fLIcoAB/DKcG5xvscUo9XqRpBniRYhlPWkg=
github.com/casbin/casbin/v2 v2.90.0/go.mod h1:jX8uoN4veP85O/n2674r2qtfSXI6myvxW85f6TH50fw= github.com/casbin/casbin/v2 v2.97.0/go.mod h1:jX8uoN4veP85O/n2674r2qtfSXI6myvxW85f6TH50fw=
github.com/casbin/govaluate v1.1.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= github.com/casbin/govaluate v1.1.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A=
github.com/casbin/govaluate v1.1.1 h1:J1rFKIBhiC5xr0APd5HP6rDL+xt+BRoyq1pa4o2i/5c= github.com/casbin/govaluate v1.2.0 h1:wXCXFmqyY+1RwiKfYo3jMKyrtZmOL3kHwaqDyCPOYak=
github.com/casbin/govaluate v1.1.1/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= github.com/casbin/govaluate v1.2.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
@@ -72,6 +72,8 @@ github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy
github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s= github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
@@ -93,8 +95,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.21.0 h1:4fZA11ovvtkdgaeev9RGWPgc1uj3H8W+rNYyH/ySBb0= github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
github.com/go-playground/validator/v10 v10.21.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
@@ -122,8 +124,8 @@ github.com/google/gops v0.3.28/go.mod h1:6f6+Nl8LcHrzJwi8+p0ii+vmBFSlB4f8cOOkTJ7
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
@@ -142,8 +144,8 @@ github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iP
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/raft v1.6.1 h1:v/jm5fcYHvVkL0akByAp+IDdDSzCNCGhdO6VdB56HIM= github.com/hashicorp/raft v1.7.0 h1:4u24Qn6lQ6uwziM++UgsyiT64Q8GyRn43CV41qPiz1o=
github.com/hashicorp/raft v1.6.1/go.mod h1:N1sKh6Vn47mrWvEArQgILTyng8GoDRNYlgKyK7PMjs0= github.com/hashicorp/raft v1.7.0/go.mod h1:N1sKh6Vn47mrWvEArQgILTyng8GoDRNYlgKyK7PMjs0=
github.com/hashicorp/raft-boltdb v0.0.0-20230125174641-2a8082862702 h1:RLKEcCuKcZ+qp2VlaaZsYZfLOmIiuJNpEi48Rl8u9cQ= github.com/hashicorp/raft-boltdb v0.0.0-20230125174641-2a8082862702 h1:RLKEcCuKcZ+qp2VlaaZsYZfLOmIiuJNpEi48Rl8u9cQ=
github.com/hashicorp/raft-boltdb v0.0.0-20230125174641-2a8082862702/go.mod h1:nTakvJ4XYq45UXtn0DbwR4aU9ZdjlnIenpbs6Cd+FM0= github.com/hashicorp/raft-boltdb v0.0.0-20230125174641-2a8082862702/go.mod h1:nTakvJ4XYq45UXtn0DbwR4aU9ZdjlnIenpbs6Cd+FM0=
github.com/hashicorp/raft-boltdb/v2 v2.3.0 h1:fPpQR1iGEVYjZ2OELvUHX600VAK5qmdnDEv3eXOwZUA= github.com/hashicorp/raft-boltdb/v2 v2.3.0 h1:fPpQR1iGEVYjZ2OELvUHX600VAK5qmdnDEv3eXOwZUA=
@@ -160,12 +162,12 @@ github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFF
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
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.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@@ -205,18 +207,20 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mholt/acmez/v2 v2.0.1 h1:3/3N0u1pLjMK4sNEAFSI+bcvzbPhRpY383sy1kLHJ6k= github.com/mholt/acmez/v2 v2.0.1 h1:3/3N0u1pLjMK4sNEAFSI+bcvzbPhRpY383sy1kLHJ6k=
github.com/mholt/acmez/v2 v2.0.1/go.mod h1:fX4c9r5jYwMyMsC+7tkYRxHibkOTgta5DIFGoe67e1U= github.com/mholt/acmez/v2 v2.0.1/go.mod h1:fX4c9r5jYwMyMsC+7tkYRxHibkOTgta5DIFGoe67e1U=
github.com/miekg/dns v1.1.59 h1:C9EXc/UToRwKLhK5wKU/I4QVsBUc8kE6MkHBkeypWZs= github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs=
github.com/miekg/dns v1.1.59/go.mod h1:nZpewl5p6IvctfgrckopVx2OlSEHPRO/U4SYkRklrEk= github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.70 h1:1u9NtMgfK1U42kUxcsl5v0yj6TEOPR497OAQxpJnn2g= github.com/minio/minio-go/v7 v7.0.74 h1:fTo/XlPBTSpo3BAMshlwKL5RspXRv9us5UeHEGYCFe0=
github.com/minio/minio-go/v7 v7.0.70/go.mod h1:4yBA8v80xGA30cfM3fz0DKYMXunWl/AV/6tWEs9ryzo= github.com/minio/minio-go/v7 v7.0.74/go.mod h1:qydcVzV8Hqtj1VtEocfxbmVFa2siu6HGa+LDEPogjD8=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
@@ -245,15 +249,15 @@ github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
github.com/prometheus/common v0.54.0 h1:ZlZy0BgJhTwVZUn7dLOkwCZHUkrAqd3WYtcFCWnM1D8= github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
github.com/prometheus/common v0.54.0/go.mod h1:/TQgMJP5CuVYveyT7n/0Ix8yLNNXy9yRSkhnLTHPDIQ= github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/puzpuzpuz/xsync/v3 v3.1.0 h1:EewKT7/LNac5SLiEblJeUu8z5eERHrmRLnMQL2d7qX4= github.com/puzpuzpuz/xsync/v3 v3.4.0 h1:DuVBAdXuGFHv8adVXjWWZ63pJq+NRXOWVXlKDBZ+mJ4=
github.com/puzpuzpuz/xsync/v3 v3.1.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= github.com/puzpuzpuz/xsync/v3 v3.4.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
@@ -283,8 +287,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/swaggo/echo-swagger v1.4.1 h1:Yf0uPaJWp1uRtDloZALyLnvdBeoEL5Kc7DtnjzO/TUk= github.com/swaggo/echo-swagger v1.4.1 h1:Yf0uPaJWp1uRtDloZALyLnvdBeoEL5Kc7DtnjzO/TUk=
github.com/swaggo/echo-swagger v1.4.1/go.mod h1:C8bSi+9yH2FLZsnhqMZLIZddpUxZdBYuNHbtaS1Hljc= github.com/swaggo/echo-swagger v1.4.1/go.mod h1:C8bSi+9yH2FLZsnhqMZLIZddpUxZdBYuNHbtaS1Hljc=
github.com/swaggo/files/v2 v2.0.0 h1:hmAt8Dkynw7Ssz46F6pn8ok6YmGZqHSVLZ+HQM7i0kw= github.com/swaggo/files/v2 v2.0.1 h1:XCVJO/i/VosCDsJu1YLpdejGsGnBE9deRMpjN4pJLHk=
github.com/swaggo/files/v2 v2.0.0/go.mod h1:24kk2Y9NYEJ5lHuCra6iVwkMjIekMCaFq/0JQj66kyM= github.com/swaggo/files/v2 v2.0.1/go.mod h1:24kk2Y9NYEJ5lHuCra6iVwkMjIekMCaFq/0JQj66kyM=
github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg= github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg=
github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk= github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk=
github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU=
@@ -298,8 +302,8 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/vektah/gqlparser/v2 v2.5.12 h1:COMhVVnql6RoaF7+aTBWiTADdpLGyZWU3K/NwW0ph98= github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0vy5p8=
github.com/vektah/gqlparser/v2 v2.5.12/go.mod h1:WQQjFc+I1YIzoPvZBhUQX7waZgg3pMLi0r8KymvAE2w= github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
@@ -329,15 +333,15 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 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-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/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-20190311183353-d8887717615a/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-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/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-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -360,8 +364,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
@@ -369,18 +373,16 @@ golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxb
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 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.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.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@@ -1,25 +1,74 @@
run: run:
tests: true tests: true
timeout: 5m
linters-settings: linters-settings:
gocritic:
enabled-checks:
- emptyStringTest
- equalFold
- httpNoBody
- nilValReturn
- paramTypeCombine
- preferFprint
- yodaStyleExpr
errcheck: errcheck:
exclude-functions: exclude-functions:
- (io.Writer).Write - (io.Writer).Write
- io.Copy - io.Copy
- io.WriteString - io.WriteString
perfsprint:
int-conversion: false
err-error: false
errorf: true
sprintf1: false
strconcat: false
revive: revive:
enable-all-rules: false enable-all-rules: false
rules: rules:
- name: empty-lines - name: empty-lines
- name: use-any
- name: struct-tag
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: error-return
- name: error-naming
- name: exported
disabled: true
- name: if-return
- name: increment-decrement
- name: var-declaration
- name: package-comments
disabled: true
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: superfluous-else
- name: unused-parameter
disabled: true
- name: unreachable-code
- name: redefines-builtin-id
testifylint: testifylint:
disable-all: true disable-all: true
enable: enable:
- blank-import
- bool-compare - bool-compare
- compares - compares
- empty
- error-is-as - error-is-as
- error-nil - error-nil
- expected-actual - expected-actual
- float-compare
- go-require
- len
- negative-positive
- nil-compare - nil-compare
- require-error
- useless-assert
linters: linters:
disable-all: true disable-all: true
@@ -35,6 +84,7 @@ linters:
- ineffassign - ineffassign
- misspell - misspell
- nakedret - nakedret
- perfsprint
- prealloc - prealloc
- revive - revive
- staticcheck - staticcheck
@@ -52,3 +102,14 @@ issues:
linters: linters:
- dupl - dupl
- errcheck - errcheck
# It's autogenerated code.
- path: codegen/testserver/.*/resolver\.go
linters:
- gocritic
# Disable revive.use-any for backwards compatibility
- path: graphql/map.go
text: "use-any: since GO 1.18 'interface{}' can be replaced by 'any'"
- path: codegen/testserver/followschema/resolver.go
text: "use-any: since GO 1.18 'interface{}' can be replaced by 'any'"
- path: codegen/testserver/singlefile/resolver.go
text: "use-any: since GO 1.18 'interface{}' can be replaced by 'any'"

View File

@@ -90,11 +90,11 @@ func Generate(cfg *config.Config, option ...Option) error {
} }
} }
// Merge again now that the generated models have been injected into the typemap // Merge again now that the generated models have been injected into the typemap
data_plugins := make([]interface{}, len(plugins)) dataPlugins := make([]any, len(plugins))
for index := range plugins { for index := range plugins {
data_plugins[index] = plugins[index] dataPlugins[index] = plugins[index]
} }
data, err := codegen.BuildData(cfg, data_plugins...) data, err := codegen.BuildData(cfg, dataPlugins...)
if err != nil { if err != nil {
return fmt.Errorf("merging type systems failed: %w", err) return fmt.Errorf("merging type systems failed: %w", err)
} }

View File

@@ -19,11 +19,11 @@ type ArgSet struct {
type FieldArgument struct { type FieldArgument struct {
*ast.ArgumentDefinition *ast.ArgumentDefinition
TypeReference *config.TypeReference TypeReference *config.TypeReference
VarName string // The name of the var in go VarName string // The name of the var in go
Object *Object // A link back to the parent object Object *Object // A link back to the parent object
Default interface{} // The default value Default any // The default value
Directives []*Directive Directives []*Directive
Value interface{} // value set in Data Value any // value set in Data
} }
// ImplDirectives get not Builtin and location ARGUMENT_DEFINITION directive // ImplDirectives get not Builtin and location ARGUMENT_DEFINITION directive

View File

@@ -61,7 +61,7 @@ func (b *Binder) FindTypeFromName(name string) (types.Type, error) {
return b.FindType(pkgName, typeName) return b.FindType(pkgName, typeName)
} }
func (b *Binder) FindType(pkgName string, typeName string) (types.Type, error) { func (b *Binder) FindType(pkgName, typeName string) (types.Type, error) {
if pkgName == "" { if pkgName == "" {
if typeName == "map[string]interface{}" { if typeName == "map[string]interface{}" {
return MapType, nil return MapType, nil
@@ -99,7 +99,7 @@ var (
func (b *Binder) DefaultUserObject(name string) (types.Type, error) { func (b *Binder) DefaultUserObject(name string) (types.Type, error) {
models := b.cfg.Models[name].Model models := b.cfg.Models[name].Model
if len(models) == 0 { if len(models) == 0 {
return nil, fmt.Errorf(name + " not found in typemap") return nil, fmt.Errorf("%s not found in typemap", name)
} }
if models[0] == "map[string]interface{}" { if models[0] == "map[string]interface{}" {
@@ -123,9 +123,9 @@ func (b *Binder) DefaultUserObject(name string) (types.Type, error) {
return obj.Type(), nil return obj.Type(), nil
} }
func (b *Binder) FindObject(pkgName string, typeName string) (types.Object, error) { func (b *Binder) FindObject(pkgName, typeName string) (types.Object, error) {
if pkgName == "" { if pkgName == "" {
return nil, fmt.Errorf("package cannot be nil") return nil, errors.New("package cannot be nil")
} }
pkg := b.pkgs.LoadWithTypes(pkgName) pkg := b.pkgs.LoadWithTypes(pkgName)
@@ -349,7 +349,7 @@ func isIntf(t types.Type) bool {
func unwrapOmittable(t types.Type) (types.Type, bool) { func unwrapOmittable(t types.Type) (types.Type, bool) {
if t == nil { if t == nil {
return t, false return nil, false
} }
named, ok := t.(*types.Named) named, ok := t.(*types.Named)
if !ok { if !ok {

View File

@@ -2,6 +2,7 @@ package config
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
"go/types" "go/types"
"io" "io"
@@ -40,6 +41,7 @@ type Config struct {
OmitGQLGenVersionInFileNotice bool `yaml:"omit_gqlgen_version_in_file_notice,omitempty"` OmitGQLGenVersionInFileNotice bool `yaml:"omit_gqlgen_version_in_file_notice,omitempty"`
OmitRootModels bool `yaml:"omit_root_models,omitempty"` OmitRootModels bool `yaml:"omit_root_models,omitempty"`
OmitResolverFields bool `yaml:"omit_resolver_fields,omitempty"` OmitResolverFields bool `yaml:"omit_resolver_fields,omitempty"`
OmitPanicHandler bool `yaml:"omit_panic_handler,omitempty"`
StructFieldsAlwaysPointers bool `yaml:"struct_fields_always_pointers,omitempty"` StructFieldsAlwaysPointers bool `yaml:"struct_fields_always_pointers,omitempty"`
ReturnPointersInUmarshalInput bool `yaml:"return_pointers_in_unmarshalinput,omitempty"` ReturnPointersInUmarshalInput bool `yaml:"return_pointers_in_unmarshalinput,omitempty"`
ResolversAlwaysReturnPointers bool `yaml:"resolvers_always_return_pointers,omitempty"` ResolversAlwaysReturnPointers bool `yaml:"resolvers_always_return_pointers,omitempty"`
@@ -305,7 +307,7 @@ func (c *Config) injectTypesFromSchema() error {
if ma := bd.Arguments.ForName("models"); ma != nil { if ma := bd.Arguments.ForName("models"); ma != nil {
if mvs, err := ma.Value.Value(nil); err == nil { if mvs, err := ma.Value.Value(nil); err == nil {
for _, mv := range mvs.([]interface{}) { for _, mv := range mvs.([]any) {
c.Models.Add(schemaType.Name, mv.(string)) c.Models.Add(schemaType.Name, mv.(string))
} }
} }
@@ -353,25 +355,11 @@ func (c *Config) injectTypesFromSchema() error {
if efds := schemaType.Directives.ForNames("goExtraField"); len(efds) != 0 { if efds := schemaType.Directives.ForNames("goExtraField"); len(efds) != 0 {
for _, efd := range efds { for _, efd := range efds {
if fn := efd.Arguments.ForName("name"); fn != nil { if t := efd.Arguments.ForName("type"); t != nil {
extraFieldName := ""
if fnv, err := fn.Value.Value(nil); err == nil {
extraFieldName = fnv.(string)
}
if extraFieldName == "" {
return fmt.Errorf(
"argument 'name' for directive @goExtraField (src: %s, line: %d) cannot by empty",
efd.Position.Src.Name,
efd.Position.Line,
)
}
extraField := ModelExtraField{} extraField := ModelExtraField{}
if t := efd.Arguments.ForName("type"); t != nil {
if tv, err := t.Value.Value(nil); err == nil { if tv, err := t.Value.Value(nil); err == nil {
extraField.Type = tv.(string) extraField.Type = tv.(string)
}
} }
if extraField.Type == "" { if extraField.Type == "" {
@@ -394,13 +382,28 @@ func (c *Config) injectTypesFromSchema() error {
} }
} }
typeMapEntry := c.Models[schemaType.Name] extraFieldName := ""
if typeMapEntry.ExtraFields == nil { if fn := efd.Arguments.ForName("name"); fn != nil {
typeMapEntry.ExtraFields = make(map[string]ModelExtraField) if fnv, err := fn.Value.Value(nil); err == nil {
extraFieldName = fnv.(string)
}
} }
c.Models[schemaType.Name] = typeMapEntry if extraFieldName == "" {
c.Models[schemaType.Name].ExtraFields[extraFieldName] = extraField // Embeddable fields
typeMapEntry := c.Models[schemaType.Name]
typeMapEntry.EmbedExtraFields = append(typeMapEntry.EmbedExtraFields, extraField)
c.Models[schemaType.Name] = typeMapEntry
} else {
// Regular fields
typeMapEntry := c.Models[schemaType.Name]
if typeMapEntry.ExtraFields == nil {
typeMapEntry.ExtraFields = make(map[string]ModelExtraField)
}
c.Models[schemaType.Name] = typeMapEntry
c.Models[schemaType.Name].ExtraFields[extraFieldName] = extraField
}
} }
} }
} }
@@ -439,7 +442,8 @@ type TypeMapEntry struct {
EnumValues map[string]EnumValue `yaml:"enum_values,omitempty"` EnumValues map[string]EnumValue `yaml:"enum_values,omitempty"`
// Key is the Go name of the field. // Key is the Go name of the field.
ExtraFields map[string]ModelExtraField `yaml:"extraFields,omitempty"` ExtraFields map[string]ModelExtraField `yaml:"extraFields,omitempty"`
EmbedExtraFields []ModelExtraField `yaml:"embedExtraFields,omitempty"`
} }
type TypeMapField struct { type TypeMapField struct {
@@ -480,7 +484,7 @@ type ModelExtraField struct {
type StringList []string type StringList []string
func (a *StringList) UnmarshalYAML(unmarshal func(interface{}) error) error { func (a *StringList) UnmarshalYAML(unmarshal func(any) error) error {
var single string var single string
err := unmarshal(&single) err := unmarshal(&single)
if err == nil { if err == nil {
@@ -562,11 +566,11 @@ func (c *Config) check() error {
Declaree: "federation", Declaree: "federation",
}) })
if c.Federation.ImportPath() != c.Exec.ImportPath() { if c.Federation.ImportPath() != c.Exec.ImportPath() {
return fmt.Errorf("federation and exec must be in the same package") return errors.New("federation and exec must be in the same package")
} }
} }
if c.Federated { if c.Federated {
return fmt.Errorf("federated has been removed, instead use\nfederation:\n filename: path/to/federated.go") return errors.New("federated has been removed, instead use\nfederation:\n filename: path/to/federated.go")
} }
for importPath, pkg := range fileList { for importPath, pkg := range fileList {
@@ -641,7 +645,7 @@ func (tm TypeMap) ReferencedPackages() []string {
return pkgs return pkgs
} }
func (tm TypeMap) Add(name string, goType string) { func (tm TypeMap) Add(name, goType string) {
modelCfg := tm[name] modelCfg := tm[name]
modelCfg.Model = append(modelCfg.Model, goType) modelCfg.Model = append(modelCfg.Model, goType)
tm[name] = modelCfg tm[name] = modelCfg

View File

@@ -1,6 +1,7 @@
package config package config
import ( import (
"errors"
"fmt" "fmt"
"go/types" "go/types"
"path/filepath" "path/filepath"
@@ -38,15 +39,15 @@ func (r *ExecConfig) Check() error {
switch r.Layout { switch r.Layout {
case ExecLayoutSingleFile: case ExecLayoutSingleFile:
if r.Filename == "" { if r.Filename == "" {
return fmt.Errorf("filename must be specified when using single-file layout") return errors.New("filename must be specified when using single-file layout")
} }
if !strings.HasSuffix(r.Filename, ".go") { if !strings.HasSuffix(r.Filename, ".go") {
return fmt.Errorf("filename should be path to a go source file when using single-file layout") return errors.New("filename should be path to a go source file when using single-file layout")
} }
r.Filename = abs(r.Filename) r.Filename = abs(r.Filename)
case ExecLayoutFollowSchema: case ExecLayoutFollowSchema:
if r.DirName == "" { if r.DirName == "" {
return fmt.Errorf("dir must be specified when using follow-schema layout") return errors.New("dir must be specified when using follow-schema layout")
} }
r.DirName = abs(r.DirName) r.DirName = abs(r.DirName)
default: default:
@@ -54,7 +55,7 @@ func (r *ExecConfig) Check() error {
} }
if strings.ContainsAny(r.Package, "./\\") { if strings.ContainsAny(r.Package, "./\\") {
return fmt.Errorf("package should be the output package name only, do not include the output filename") return errors.New("package should be the output package name only, do not include the output filename")
} }
if r.Package == "" && r.Dir() != "" { if r.Package == "" && r.Dir() != "" {

View File

@@ -1,7 +1,7 @@
package config package config
import ( import (
"fmt" "errors"
"go/types" "go/types"
"path/filepath" "path/filepath"
"strings" "strings"
@@ -44,13 +44,13 @@ func (c *PackageConfig) IsDefined() bool {
func (c *PackageConfig) Check() error { func (c *PackageConfig) Check() error {
if strings.ContainsAny(c.Package, "./\\") { if strings.ContainsAny(c.Package, "./\\") {
return fmt.Errorf("package should be the output package name only, do not include the output filename") return errors.New("package should be the output package name only, do not include the output filename")
} }
if c.Filename == "" { if c.Filename == "" {
return fmt.Errorf("filename must be specified") return errors.New("filename must be specified")
} }
if !strings.HasSuffix(c.Filename, ".go") { if !strings.HasSuffix(c.Filename, ".go") {
return fmt.Errorf("filename should be path to a go source file") return errors.New("filename should be path to a go source file")
} }
c.Filename = abs(c.Filename) c.Filename = abs(c.Filename)

View File

@@ -1,6 +1,7 @@
package config package config
import ( import (
"errors"
"fmt" "fmt"
"go/types" "go/types"
"path/filepath" "path/filepath"
@@ -59,7 +60,7 @@ func (r *ResolverConfig) Check() error {
} }
if strings.ContainsAny(r.Package, "./\\") { if strings.ContainsAny(r.Package, "./\\") {
return fmt.Errorf("package should be the output package name only, do not include the output filename") return errors.New("package should be the output package name only, do not include the output filename")
} }
if r.Package == "" && r.Dir() != "" { if r.Package == "" && r.Dir() != "" {

View File

@@ -1,6 +1,7 @@
package codegen package codegen
import ( import (
"errors"
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
@@ -34,7 +35,7 @@ type Data struct {
MutationRoot *Object MutationRoot *Object
SubscriptionRoot *Object SubscriptionRoot *Object
AugmentedSources []AugmentedSource AugmentedSources []AugmentedSource
Plugins []interface{} Plugins []any
} }
func (d *Data) HasEmbeddableSources() bool { func (d *Data) HasEmbeddableSources() bool {
@@ -77,7 +78,7 @@ func (d *Data) Directives() DirectiveList {
return res return res
} }
func BuildData(cfg *config.Config, plugins ...interface{}) (*Data, error) { func BuildData(cfg *config.Config, plugins ...any) (*Data, error) {
// We reload all packages to allow packages to be compared correctly. // We reload all packages to allow packages to be compared correctly.
cfg.ReloadAllPackages() cfg.ReloadAllPackages()
@@ -137,7 +138,7 @@ func BuildData(cfg *config.Config, plugins ...interface{}) (*Data, error) {
if s.Schema.Query != nil { if s.Schema.Query != nil {
s.QueryRoot = s.Objects.ByName(s.Schema.Query.Name) s.QueryRoot = s.Objects.ByName(s.Schema.Query.Name)
} else { } else {
return nil, fmt.Errorf("query entry point missing") return nil, errors.New("query entry point missing")
} }
if s.Schema.Mutation != nil { if s.Schema.Mutation != nil {
@@ -170,7 +171,7 @@ func BuildData(cfg *config.Config, plugins ...interface{}) (*Data, error) {
} }
// otherwise show a generic error message // otherwise show a generic error message
return nil, fmt.Errorf("invalid types were encountered while traversing the go source code, this probably means the invalid code generated isnt correct. add try adding -v to debug") return nil, errors.New("invalid types were encountered while traversing the go source code, this probably means the invalid code generated isnt correct. add try adding -v to debug")
} }
aSources := []AugmentedSource{} aSources := []AugmentedSource{}
for _, s := range cfg.Sources { for _, s := range cfg.Sources {
@@ -204,7 +205,7 @@ func BuildData(cfg *config.Config, plugins ...interface{}) (*Data, error) {
func (b *builder) injectIntrospectionRoots(s *Data) error { func (b *builder) injectIntrospectionRoots(s *Data) error {
obj := s.Objects.ByName(b.Schema.Query.Name) obj := s.Objects.ByName(b.Schema.Query.Name)
if obj == nil { if obj == nil {
return fmt.Errorf("root query type must be defined") return errors.New("root query type must be defined")
} }
__type, err := b.buildField(obj, &ast.FieldDefinition{ __type, err := b.buildField(obj, &ast.FieldDefinition{

View File

@@ -92,7 +92,7 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) {
func (b *builder) getDirectives(list ast.DirectiveList) ([]*Directive, error) { func (b *builder) getDirectives(list ast.DirectiveList) ([]*Directive, error) {
dirs := make([]*Directive, len(list)) dirs := make([]*Directive, len(list))
for i, d := range list { for i, d := range list {
argValues := make(map[string]interface{}, len(d.Arguments)) argValues := make(map[string]any, len(d.Arguments))
for _, da := range d.Arguments { for _, da := range d.Arguments {
val, err := da.Value.Value(nil) val, err := da.Value.Value(nil)
if err != nil { if err != nil {

View File

@@ -31,7 +31,7 @@ type Field struct {
NoErr bool // If this is bound to a go method, does that method have an error as the second argument NoErr bool // If this is bound to a go method, does that method have an error as the second argument
VOkFunc bool // If this is bound to a go method, is it of shape (interface{}, bool) VOkFunc bool // If this is bound to a go method, is it of shape (interface{}, bool)
Object *Object // A link back to the parent object Object *Object // A link back to the parent object
Default interface{} // The default value Default any // The default value
Stream bool // does this field return a channel? Stream bool // does this field return a channel?
Directives []*Directive Directives []*Directive
} }
@@ -174,7 +174,7 @@ func (b *builder) bindField(obj *Object, f *Field) (errret error) {
} else if s := sig.Results(); s.Len() == 2 && s.At(1).Type().String() == "bool" { } else if s := sig.Results(); s.Len() == 2 && s.At(1).Type().String() == "bool" {
f.VOkFunc = true f.VOkFunc = true
} else if sig.Results().Len() != 2 { } else if sig.Results().Len() != 2 {
return fmt.Errorf("method has wrong number of args") return errors.New("method has wrong number of args")
} }
params := sig.Params() params := sig.Params()
// If the first argument is the context, remove it from the comparison and set // If the first argument is the context, remove it from the comparison and set

View File

@@ -10,12 +10,14 @@ func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Contex
return {{ $null }} return {{ $null }}
} }
ctx = graphql.WithFieldContext(ctx, fc) ctx = graphql.WithFieldContext(ctx, fc)
{{- if not $.Config.OmitPanicHandler }}
defer func () { defer func () {
if r := recover(); r != nil { if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r)) ec.Error(ctx, ec.Recover(ctx, r))
ret = {{ $null }} ret = {{ $null }}
} }
}() }()
{{- end }}
{{- if $field.TypeReference.IsRoot }} {{- if $field.TypeReference.IsRoot }}
{{- if $field.TypeReference.IsPtr }} {{- if $field.TypeReference.IsPtr }}
res := &{{ $field.TypeReference.Elem.GO | ref }}{} res := &{{ $field.TypeReference.Elem.GO | ref }}{}
@@ -95,12 +97,14 @@ func (ec *executionContext) {{ $field.FieldContextFunc }}({{ if not $field.Args
}, },
} }
{{- if $field.Args }} {{- if $field.Args }}
{{- if not $.Config.OmitPanicHandler }}
defer func () { defer func () {
if r := recover(); r != nil { if r := recover(); r != nil {
err = ec.Recover(ctx, r) err = ec.Recover(ctx, r)
ec.Error(ctx, err) ec.Error(ctx, err)
} }
}() }()
{{- end }}
ctx = graphql.WithFieldContext(ctx, fc) ctx = graphql.WithFieldContext(ctx, fc)
if fc.Args, err = ec.{{ $field.ArgsFunc }}(ctx, field.ArgumentMap(ec.Variables)); err != nil { if fc.Args, err = ec.{{ $field.ArgsFunc }}(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err) ec.Error(ctx, err)

View File

@@ -20,7 +20,7 @@ var codegenTemplates embed.FS
func GenerateCode(data *Data) error { func GenerateCode(data *Data) error {
if !data.Config.Exec.IsDefined() { if !data.Config.Exec.IsDefined() {
return fmt.Errorf("missing exec config") return errors.New("missing exec config")
} }
switch data.Config.Exec.Layout { switch data.Config.Exec.Layout {

View File

@@ -49,11 +49,13 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec
field := field field := field
innerFunc := func(ctx context.Context, {{ if $field.TypeReference.GQL.NonNull }}fs{{ else }}_{{ end }} *graphql.FieldSet) (res graphql.Marshaler) { innerFunc := func(ctx context.Context, {{ if $field.TypeReference.GQL.NonNull }}fs{{ else }}_{{ end }} *graphql.FieldSet) (res graphql.Marshaler) {
{{- if not $.Config.OmitPanicHandler }}
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r)) ec.Error(ctx, ec.Recover(ctx, r))
} }
}() }()
{{- end }}
res = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}}) res = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}})
{{- if $field.TypeReference.GQL.NonNull }} {{- if $field.TypeReference.GQL.NonNull }}
if res == graphql.Null { if res == graphql.Null {

View File

@@ -1,6 +1,7 @@
package templates package templates
import ( import (
"errors"
"fmt" "fmt"
"go/types" "go/types"
"strconv" "strconv"
@@ -62,11 +63,11 @@ func (s *Imports) Reserve(path string, aliases ...string) (string, error) {
if existing.Alias == alias { if existing.Alias == alias {
return "", nil return "", nil
} }
return "", fmt.Errorf("ambient import already exists") return "", errors.New("ambient import already exists")
} }
if alias := s.findByAlias(alias); alias != nil { if alias := s.findByAlias(alias); alias != nil {
return "", fmt.Errorf("ambient import collides on an alias") return "", errors.New("ambient import collides on an alias")
} }
s.imports = append(s.imports, &Import{ s.imports = append(s.imports, &Import{

View File

@@ -2,6 +2,7 @@ package templates
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
"go/types" "go/types"
"io/fs" "io/fs"
@@ -52,7 +53,7 @@ type Options struct {
// FileNotice is notice written below the package line // FileNotice is notice written below the package line
FileNotice string FileNotice string
// Data will be passed to the template execution. // Data will be passed to the template execution.
Data interface{} Data any
Funcs template.FuncMap Funcs template.FuncMap
// Packages cache, you can find me on config.Config // Packages cache, you can find me on config.Config
@@ -71,7 +72,7 @@ var (
// files inside the directory where you wrote the plugin. // files inside the directory where you wrote the plugin.
func Render(cfg Options) error { func Render(cfg Options) error {
if CurrentImports != nil { if CurrentImports != nil {
panic(fmt.Errorf("recursive or concurrent call to RenderToFile detected")) panic(errors.New("recursive or concurrent call to RenderToFile detected"))
} }
CurrentImports = &Imports{packages: cfg.Packages, destDir: filepath.Dir(cfg.Filename)} CurrentImports = &Imports{packages: cfg.Packages, destDir: filepath.Dir(cfg.Filename)}
@@ -184,7 +185,7 @@ func parseTemplates(cfg Options, t *template.Template) (*template.Template, erro
return t, nil return t, nil
} }
func center(width int, pad string, s string) string { func center(width int, pad, s string) string {
if len(s)+2 > width { if len(s)+2 > width {
return s return s
} }
@@ -206,6 +207,7 @@ func Funcs() template.FuncMap {
"call": Call, "call": Call,
"prefixLines": prefixLines, "prefixLines": prefixLines,
"notNil": notNil, "notNil": notNil,
"strSplit": StrSplit,
"reserveImport": CurrentImports.Reserve, "reserveImport": CurrentImports.Reserve,
"lookupImport": CurrentImports.Lookup, "lookupImport": CurrentImports.Lookup,
"go": ToGo, "go": ToGo,
@@ -215,7 +217,7 @@ func Funcs() template.FuncMap {
"add": func(a, b int) int { "add": func(a, b int) int {
return a + b return a + b
}, },
"render": func(filename string, tpldata interface{}) (*bytes.Buffer, error) { "render": func(filename string, tpldata any) (*bytes.Buffer, error) {
return render(resolveName(filename, 0), tpldata) return render(resolveName(filename, 0), tpldata)
}, },
} }
@@ -567,7 +569,7 @@ func rawQuote(s string) string {
return "`" + strings.ReplaceAll(s, "`", "`+\"`\"+`") + "`" return "`" + strings.ReplaceAll(s, "`", "`+\"`\"+`") + "`"
} }
func notNil(field string, data interface{}) bool { func notNil(field string, data any) bool {
v := reflect.ValueOf(data) v := reflect.ValueOf(data)
if v.Kind() == reflect.Ptr { if v.Kind() == reflect.Ptr {
@@ -581,12 +583,16 @@ func notNil(field string, data interface{}) bool {
return val.IsValid() && !val.IsNil() return val.IsValid() && !val.IsNil()
} }
func Dump(val interface{}) string { func StrSplit(s, sep string) []string {
return strings.Split(s, sep)
}
func Dump(val any) string {
switch val := val.(type) { switch val := val.(type) {
case int: case int:
return strconv.Itoa(val) return strconv.Itoa(val)
case int64: case int64:
return fmt.Sprintf("%d", val) return strconv.FormatInt(val, 10)
case float64: case float64:
return fmt.Sprintf("%f", val) return fmt.Sprintf("%f", val)
case string: case string:
@@ -595,13 +601,13 @@ func Dump(val interface{}) string {
return strconv.FormatBool(val) return strconv.FormatBool(val)
case nil: case nil:
return "nil" return "nil"
case []interface{}: case []any:
var parts []string var parts []string
for _, part := range val { for _, part := range val {
parts = append(parts, Dump(part)) parts = append(parts, Dump(part))
} }
return "[]interface{}{" + strings.Join(parts, ",") + "}" return "[]interface{}{" + strings.Join(parts, ",") + "}"
case map[string]interface{}: case map[string]any:
buf := bytes.Buffer{} buf := bytes.Buffer{}
buf.WriteString("map[string]interface{}{") buf.WriteString("map[string]interface{}{")
var keys []string var keys []string
@@ -641,7 +647,7 @@ func resolveName(name string, skip int) string {
return filepath.Join(filepath.Dir(callerFile), name) return filepath.Join(filepath.Dir(callerFile), name)
} }
func render(filename string, tpldata interface{}) (*bytes.Buffer, error) { func render(filename string, tpldata any) (*bytes.Buffer, error) {
t := template.New("").Funcs(Funcs()) t := template.New("").Funcs(Funcs())
b, err := os.ReadFile(filename) b, err := os.ReadFile(filename)

View File

@@ -115,12 +115,14 @@
} }
ctx := graphql.WithFieldContext(ctx, fc) ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) { f := func(i int) {
{{- if not $.Config.OmitPanicHandler }}
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r)) ec.Error(ctx, ec.Recover(ctx, r))
ret = nil ret = nil
} }
}() }()
{{- end }}
if !isLen1 { if !isLen1 {
defer wg.Done() defer wg.Done()
} }

View File

@@ -6,7 +6,7 @@ import (
"github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql"
) )
func Calculate(es graphql.ExecutableSchema, op *ast.OperationDefinition, vars map[string]interface{}) int { func Calculate(es graphql.ExecutableSchema, op *ast.OperationDefinition, vars map[string]any) int {
walker := complexityWalker{ walker := complexityWalker{
es: es, es: es,
schema: es.Schema(), schema: es.Schema(),
@@ -18,7 +18,7 @@ func Calculate(es graphql.ExecutableSchema, op *ast.OperationDefinition, vars ma
type complexityWalker struct { type complexityWalker struct {
es graphql.ExecutableSchema es graphql.ExecutableSchema
schema *ast.Schema schema *ast.Schema
vars map[string]interface{} vars map[string]any
} }
func (cw complexityWalker) selectionSetComplexity(selectionSet ast.SelectionSet) int { func (cw complexityWalker) selectionSetComplexity(selectionSet ast.SelectionSet) int {
@@ -57,7 +57,7 @@ func (cw complexityWalker) selectionSetComplexity(selectionSet ast.SelectionSet)
return complexity return complexity
} }
func (cw complexityWalker) interfaceFieldComplexity(def *ast.Definition, field string, childComplexity int, args map[string]interface{}) int { func (cw complexityWalker) interfaceFieldComplexity(def *ast.Definition, field string, childComplexity int, args map[string]any) int {
// Interfaces don't have their own separate field costs, so they have to assume the worst case. // Interfaces don't have their own separate field costs, so they have to assume the worst case.
// We iterate over all implementors and choose the most expensive one. // We iterate over all implementors and choose the most expensive one.
maxComplexity := 0 maxComplexity := 0
@@ -71,7 +71,7 @@ func (cw complexityWalker) interfaceFieldComplexity(def *ast.Definition, field s
return maxComplexity return maxComplexity
} }
func (cw complexityWalker) fieldComplexity(object, field string, childComplexity int, args map[string]interface{}) int { func (cw complexityWalker) fieldComplexity(object, field string, childComplexity int, args map[string]any) int {
if customComplexity, ok := cw.es.Complexity(object, field, childComplexity, args); ok && customComplexity >= childComplexity { if customComplexity, ok := cw.es.Complexity(object, field, childComplexity, args); ok && customComplexity >= childComplexity {
return customComplexity return customComplexity
} }

View File

@@ -5,7 +5,7 @@ import (
"io" "io"
) )
func MarshalAny(v interface{}) Marshaler { func MarshalAny(v any) Marshaler {
return WriterFunc(func(w io.Writer) { return WriterFunc(func(w io.Writer) {
err := json.NewEncoder(w).Encode(v) err := json.NewEncoder(w).Encode(v)
if err != nil { if err != nil {
@@ -14,6 +14,6 @@ func MarshalAny(v interface{}) Marshaler {
}) })
} }
func UnmarshalAny(v interface{}) (interface{}, error) { func UnmarshalAny(v any) (any, error) {
return v, nil return v, nil
} }

View File

@@ -3,20 +3,19 @@ package graphql
import ( import (
"fmt" "fmt"
"io" "io"
"strconv"
"strings" "strings"
) )
func MarshalBoolean(b bool) Marshaler { func MarshalBoolean(b bool) Marshaler {
if b { str := strconv.FormatBool(b)
return WriterFunc(func(w io.Writer) { w.Write(trueLit) }) return WriterFunc(func(w io.Writer) { w.Write([]byte(str)) })
}
return WriterFunc(func(w io.Writer) { w.Write(falseLit) })
} }
func UnmarshalBoolean(v interface{}) (bool, error) { func UnmarshalBoolean(v any) (bool, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
return strings.ToLower(v) == "true", nil return strings.EqualFold(v, "true"), nil
case int: case int:
return v != 0, nil return v != 0, nil
case bool: case bool:

View File

@@ -5,25 +5,25 @@ import "context"
// Cache is a shared store for APQ and query AST caching // Cache is a shared store for APQ and query AST caching
type Cache interface { type Cache interface {
// Get looks up a key's value from the cache. // Get looks up a key's value from the cache.
Get(ctx context.Context, key string) (value interface{}, ok bool) Get(ctx context.Context, key string) (value any, ok bool)
// Add adds a value to the cache. // Add adds a value to the cache.
Add(ctx context.Context, key string, value interface{}) Add(ctx context.Context, key string, value any)
} }
// MapCache is the simplest implementation of a cache, because it can not evict it should only be used in tests // MapCache is the simplest implementation of a cache, because it can not evict it should only be used in tests
type MapCache map[string]interface{} type MapCache map[string]any
// Get looks up a key's value from the cache. // Get looks up a key's value from the cache.
func (m MapCache) Get(_ context.Context, key string) (value interface{}, ok bool) { func (m MapCache) Get(_ context.Context, key string) (value any, ok bool) {
v, ok := m[key] v, ok := m[key]
return v, ok return v, ok
} }
// Add adds a value to the cache. // Add adds a value to the cache.
func (m MapCache) Add(_ context.Context, key string, value interface{}) { m[key] = value } func (m MapCache) Add(_ context.Context, key string, value any) { m[key] = value }
type NoCache struct{} type NoCache struct{}
func (n NoCache) Get(_ context.Context, _ string) (value interface{}, ok bool) { return nil, false } func (n NoCache) Get(_ context.Context, _ string) (value any, ok bool) { return nil, false }
func (n NoCache) Add(_ context.Context, _ string, _ interface{}) {} func (n NoCache) Add(_ context.Context, _ string, _ any) {}

View File

@@ -5,51 +5,51 @@ import (
) )
// CoerceList applies coercion from a single value to a list. // CoerceList applies coercion from a single value to a list.
func CoerceList(v interface{}) []interface{} { func CoerceList(v any) []any {
var vSlice []interface{} var vSlice []any
if v != nil { if v != nil {
switch v := v.(type) { switch v := v.(type) {
case []interface{}: case []any:
// already a slice no coercion required // already a slice no coercion required
vSlice = v vSlice = v
case []string: case []string:
if len(v) > 0 { if len(v) > 0 {
vSlice = []interface{}{v[0]} vSlice = []any{v[0]}
} }
case []json.Number: case []json.Number:
if len(v) > 0 { if len(v) > 0 {
vSlice = []interface{}{v[0]} vSlice = []any{v[0]}
} }
case []bool: case []bool:
if len(v) > 0 { if len(v) > 0 {
vSlice = []interface{}{v[0]} vSlice = []any{v[0]}
} }
case []map[string]interface{}: case []map[string]any:
if len(v) > 0 { if len(v) > 0 {
vSlice = []interface{}{v[0]} vSlice = []any{v[0]}
} }
case []float64: case []float64:
if len(v) > 0 { if len(v) > 0 {
vSlice = []interface{}{v[0]} vSlice = []any{v[0]}
} }
case []float32: case []float32:
if len(v) > 0 { if len(v) > 0 {
vSlice = []interface{}{v[0]} vSlice = []any{v[0]}
} }
case []int: case []int:
if len(v) > 0 { if len(v) > 0 {
vSlice = []interface{}{v[0]} vSlice = []any{v[0]}
} }
case []int32: case []int32:
if len(v) > 0 { if len(v) > 0 {
vSlice = []interface{}{v[0]} vSlice = []any{v[0]}
} }
case []int64: case []int64:
if len(v) > 0 { if len(v) > 0 {
vSlice = []interface{}{v[0]} vSlice = []any{v[0]}
} }
default: default:
vSlice = []interface{}{v} vSlice = []any{v}
} }
} }
return vSlice return vSlice

View File

@@ -19,13 +19,13 @@ type FieldContext struct {
// The name of the type this field belongs to // The name of the type this field belongs to
Object string Object string
// These are the args after processing, they can be mutated in middleware to change what the resolver will get. // These are the args after processing, they can be mutated in middleware to change what the resolver will get.
Args map[string]interface{} Args map[string]any
// The raw field // The raw field
Field CollectedField Field CollectedField
// The index of array in path. // The index of array in path.
Index *int Index *int
// The result object of resolver // The result object of resolver
Result interface{} Result any
// IsMethod indicates if the resolver is a method // IsMethod indicates if the resolver is a method
IsMethod bool IsMethod bool
// IsResolver indicates if the field has a user-specified resolver // IsResolver indicates if the field has a user-specified resolver
@@ -98,7 +98,7 @@ func WithFieldContext(ctx context.Context, rc *FieldContext) context.Context {
return context.WithValue(ctx, resolverCtx, rc) return context.WithValue(ctx, resolverCtx, rc)
} }
func equalPath(a ast.Path, b ast.Path) bool { func equalPath(a, b ast.Path) bool {
if len(a) != len(b) { if len(a) != len(b) {
return false return false
} }

View File

@@ -14,7 +14,7 @@ type RequestContext = OperationContext
type OperationContext struct { type OperationContext struct {
RawQuery string RawQuery string
Variables map[string]interface{} Variables map[string]any
OperationName string OperationName string
Doc *ast.QueryDocument Doc *ast.QueryDocument
Headers http.Header Headers http.Header
@@ -36,7 +36,7 @@ func (c *OperationContext) Validate(ctx context.Context) error {
return errors.New("field 'RawQuery' is required") return errors.New("field 'RawQuery' is required")
} }
if c.Variables == nil { if c.Variables == nil {
c.Variables = make(map[string]interface{}) c.Variables = make(map[string]any)
} }
if c.ResolverMiddleware == nil { if c.ResolverMiddleware == nil {
return errors.New("field 'ResolverMiddleware' is required") return errors.New("field 'ResolverMiddleware' is required")
@@ -103,7 +103,7 @@ Next:
// Errorf sends an error string to the client, passing it through the formatter. // Errorf sends an error string to the client, passing it through the formatter.
// Deprecated: use graphql.AddErrorf(ctx, err) instead // Deprecated: use graphql.AddErrorf(ctx, err) instead
func (c *OperationContext) Errorf(ctx context.Context, format string, args ...interface{}) { func (c *OperationContext) Errorf(ctx context.Context, format string, args ...any) {
AddErrorf(ctx, format, args...) AddErrorf(ctx, format, args...)
} }
@@ -120,6 +120,6 @@ func (c *OperationContext) Error(ctx context.Context, err error) {
AddError(ctx, err) AddError(ctx, err)
} }
func (c *OperationContext) Recover(ctx context.Context, err interface{}) error { func (c *OperationContext) Recover(ctx context.Context, err any) error {
return ErrorOnPath(ctx, c.RecoverFunc(ctx, err)) return ErrorOnPath(ctx, c.RecoverFunc(ctx, err))
} }

View File

@@ -15,7 +15,7 @@ type responseContext struct {
errors gqlerror.List errors gqlerror.List
errorsMu sync.Mutex errorsMu sync.Mutex
extensions map[string]interface{} extensions map[string]any
extensionsMu sync.Mutex extensionsMu sync.Mutex
} }
@@ -45,7 +45,7 @@ func WithFreshResponseContext(ctx context.Context) context.Context {
} }
// AddErrorf writes a formatted error to the client, first passing it through the error presenter. // AddErrorf writes a formatted error to the client, first passing it through the error presenter.
func AddErrorf(ctx context.Context, format string, args ...interface{}) { func AddErrorf(ctx context.Context, format string, args ...any) {
AddError(ctx, fmt.Errorf(format, args...)) AddError(ctx, fmt.Errorf(format, args...))
} }
@@ -60,7 +60,7 @@ func AddError(ctx context.Context, err error) {
c.errors = append(c.errors, presentedError) c.errors = append(c.errors, presentedError)
} }
func Recover(ctx context.Context, err interface{}) (userMessage error) { func Recover(ctx context.Context, err any) (userMessage error) {
c := getResponseContext(ctx) c := getResponseContext(ctx)
return ErrorOnPath(ctx, c.recover(ctx, err)) return ErrorOnPath(ctx, c.recover(ctx, err))
} }
@@ -125,13 +125,13 @@ func GetErrors(ctx context.Context) gqlerror.List {
} }
// RegisterExtension allows you to add a new extension into the graphql response // RegisterExtension allows you to add a new extension into the graphql response
func RegisterExtension(ctx context.Context, key string, value interface{}) { func RegisterExtension(ctx context.Context, key string, value any) {
c := getResponseContext(ctx) c := getResponseContext(ctx)
c.extensionsMu.Lock() c.extensionsMu.Lock()
defer c.extensionsMu.Unlock() defer c.extensionsMu.Unlock()
if c.extensions == nil { if c.extensions == nil {
c.extensions = make(map[string]interface{}) c.extensions = make(map[string]any)
} }
if _, ok := c.extensions[key]; ok { if _, ok := c.extensions[key]; ok {
@@ -142,16 +142,16 @@ func RegisterExtension(ctx context.Context, key string, value interface{}) {
} }
// GetExtensions returns any extensions registered in the current result context // GetExtensions returns any extensions registered in the current result context
func GetExtensions(ctx context.Context) map[string]interface{} { func GetExtensions(ctx context.Context) map[string]any {
ext := getResponseContext(ctx).extensions ext := getResponseContext(ctx).extensions
if ext == nil { if ext == nil {
return map[string]interface{}{} return map[string]any{}
} }
return ext return ext
} }
func GetExtension(ctx context.Context, name string) interface{} { func GetExtension(ctx context.Context, name string) any {
ext := getResponseContext(ctx).extensions ext := getResponseContext(ctx).extensions
if ext == nil { if ext == nil {
return nil return nil

View File

@@ -1,17 +1,17 @@
package graphql package graphql
import ( import (
"fmt" "errors"
"time" "time"
dur "github.com/sosodev/duration" dur "github.com/sosodev/duration"
) )
// UnmarshalDuration returns the duration from a string in ISO8601 format // UnmarshalDuration returns the duration from a string in ISO8601 format
func UnmarshalDuration(v interface{}) (time.Duration, error) { func UnmarshalDuration(v any) (time.Duration, error) {
input, ok := v.(string) input, ok := v.(string)
if !ok { if !ok {
return 0, fmt.Errorf("input must be a string") return 0, errors.New("input must be a string")
} }
d2, err := dur.Parse(input) d2, err := dur.Parse(input)

View File

@@ -40,7 +40,7 @@ func Set(err error, value string) {
} }
if gqlErr.Extensions == nil { if gqlErr.Extensions == nil {
gqlErr.Extensions = map[string]interface{}{} gqlErr.Extensions = map[string]any{}
} }
gqlErr.Extensions["code"] = value gqlErr.Extensions["code"] = value

View File

@@ -12,7 +12,7 @@ import (
type ExecutableSchema interface { type ExecutableSchema interface {
Schema() *ast.Schema Schema() *ast.Schema
Complexity(typeName, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) Complexity(typeName, fieldName string, childComplexity int, args map[string]any) (int, bool)
Exec(ctx context.Context) ResponseHandler Exec(ctx context.Context) ResponseHandler
} }
@@ -116,7 +116,7 @@ func instanceOf(val string, satisfies []string) bool {
return false return false
} }
func getOrCreateAndAppendField(c *[]CollectedField, name string, alias string, objectDefinition *ast.Definition, creator func() CollectedField) *CollectedField { func getOrCreateAndAppendField(c *[]CollectedField, name, alias string, objectDefinition *ast.Definition, creator func() CollectedField) *CollectedField {
for i, cf := range *c { for i, cf := range *c {
if cf.Name == name && cf.Alias == alias { if cf.Name == name && cf.Alias == alias {
if cf.ObjectDefinition == objectDefinition { if cf.ObjectDefinition == objectDefinition {
@@ -150,7 +150,7 @@ func getOrCreateAndAppendField(c *[]CollectedField, name string, alias string, o
return &(*c)[len(*c)-1] return &(*c)[len(*c)-1]
} }
func shouldIncludeNode(directives ast.DirectiveList, variables map[string]interface{}) bool { func shouldIncludeNode(directives ast.DirectiveList, variables map[string]any) bool {
if len(directives) == 0 { if len(directives) == 0 {
return true return true
} }
@@ -168,7 +168,7 @@ func shouldIncludeNode(directives ast.DirectiveList, variables map[string]interf
return !skip && include return !skip && include
} }
func deferrable(directives ast.DirectiveList, variables map[string]interface{}) (shouldDefer bool, label string) { func deferrable(directives ast.DirectiveList, variables map[string]any) (shouldDefer bool, label string) {
d := directives.ForName("defer") d := directives.ForName("defer")
if d == nil { if d == nil {
return false, "" return false, ""
@@ -194,7 +194,7 @@ func deferrable(directives ast.DirectiveList, variables map[string]interface{})
return shouldDefer, label return shouldDefer, label
} }
func resolveIfArgument(d *ast.Directive, variables map[string]interface{}) bool { func resolveIfArgument(d *ast.Directive, variables map[string]any) bool {
arg := d.Arguments.ForName("if") arg := d.Arguments.ForName("if")
if arg == nil { if arg == nil {
panic(fmt.Sprintf("%s: argument 'if' not defined", d.Name)) panic(fmt.Sprintf("%s: argument 'if' not defined", d.Name))

View File

@@ -19,7 +19,7 @@ var _ ExecutableSchema = &ExecutableSchemaMock{}
// //
// // make and configure a mocked ExecutableSchema // // make and configure a mocked ExecutableSchema
// mockedExecutableSchema := &ExecutableSchemaMock{ // mockedExecutableSchema := &ExecutableSchemaMock{
// ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) { // ComplexityFunc: func(typeName string, fieldName string, childComplexity int, args map[string]any) (int, bool) {
// panic("mock out the Complexity method") // panic("mock out the Complexity method")
// }, // },
// ExecFunc: func(ctx context.Context) ResponseHandler { // ExecFunc: func(ctx context.Context) ResponseHandler {
@@ -36,7 +36,7 @@ var _ ExecutableSchema = &ExecutableSchemaMock{}
// } // }
type ExecutableSchemaMock struct { type ExecutableSchemaMock struct {
// ComplexityFunc mocks the Complexity method. // ComplexityFunc mocks the Complexity method.
ComplexityFunc func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) ComplexityFunc func(typeName string, fieldName string, childComplexity int, args map[string]any) (int, bool)
// ExecFunc mocks the Exec method. // ExecFunc mocks the Exec method.
ExecFunc func(ctx context.Context) ResponseHandler ExecFunc func(ctx context.Context) ResponseHandler
@@ -55,7 +55,7 @@ type ExecutableSchemaMock struct {
// ChildComplexity is the childComplexity argument value. // ChildComplexity is the childComplexity argument value.
ChildComplexity int ChildComplexity int
// Args is the args argument value. // Args is the args argument value.
Args map[string]interface{} Args map[string]any
} }
// Exec holds details about calls to the Exec method. // Exec holds details about calls to the Exec method.
Exec []struct { Exec []struct {
@@ -72,7 +72,7 @@ type ExecutableSchemaMock struct {
} }
// Complexity calls ComplexityFunc. // Complexity calls ComplexityFunc.
func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) { func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string, childComplexity int, args map[string]any) (int, bool) {
if mock.ComplexityFunc == nil { if mock.ComplexityFunc == nil {
panic("ExecutableSchemaMock.ComplexityFunc: method is nil but ExecutableSchema.Complexity was just called") panic("ExecutableSchemaMock.ComplexityFunc: method is nil but ExecutableSchema.Complexity was just called")
} }
@@ -80,7 +80,7 @@ func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string,
TypeName string TypeName string
FieldName string FieldName string
ChildComplexity int ChildComplexity int
Args map[string]interface{} Args map[string]any
}{ }{
TypeName: typeName, TypeName: typeName,
FieldName: fieldName, FieldName: fieldName,
@@ -101,13 +101,13 @@ func (mock *ExecutableSchemaMock) ComplexityCalls() []struct {
TypeName string TypeName string
FieldName string FieldName string
ChildComplexity int ChildComplexity int
Args map[string]interface{} Args map[string]any
} { } {
var calls []struct { var calls []struct {
TypeName string TypeName string
FieldName string FieldName string
ChildComplexity int ChildComplexity int
Args map[string]interface{} Args map[string]any
} }
mock.lockComplexity.RLock() mock.lockComplexity.RLock()
calls = mock.calls.Complexity calls = mock.calls.Complexity

View File

@@ -12,6 +12,8 @@ import (
"github.com/99designs/gqlgen/graphql/errcode" "github.com/99designs/gqlgen/graphql/errcode"
) )
const parserTokenNoLimit = 0
// Executor executes graphql queries against a schema. // Executor executes graphql queries against a schema.
type Executor struct { type Executor struct {
es graphql.ExecutableSchema es graphql.ExecutableSchema
@@ -21,6 +23,8 @@ type Executor struct {
errorPresenter graphql.ErrorPresenterFunc errorPresenter graphql.ErrorPresenterFunc
recoverFunc graphql.RecoverFunc recoverFunc graphql.RecoverFunc
queryCache graphql.Cache queryCache graphql.Cache
parserTokenLimit int
} }
var _ graphql.GraphExecutor = &Executor{} var _ graphql.GraphExecutor = &Executor{}
@@ -29,11 +33,12 @@ var _ graphql.GraphExecutor = &Executor{}
// recovery callbacks, and no query cache or extensions. // recovery callbacks, and no query cache or extensions.
func New(es graphql.ExecutableSchema) *Executor { func New(es graphql.ExecutableSchema) *Executor {
e := &Executor{ e := &Executor{
es: es, es: es,
errorPresenter: graphql.DefaultErrorPresenter, errorPresenter: graphql.DefaultErrorPresenter,
recoverFunc: graphql.DefaultRecover, recoverFunc: graphql.DefaultRecover,
queryCache: graphql.NoCache{}, queryCache: graphql.NoCache{},
ext: processExtensions(nil), ext: processExtensions(nil),
parserTokenLimit: parserTokenNoLimit,
} }
return e return e
} }
@@ -153,7 +158,7 @@ func (e *Executor) DispatchError(ctx context.Context, list gqlerror.List) *graph
return resp return resp
} }
func (e *Executor) PresentRecoveredError(ctx context.Context, err interface{}) error { func (e *Executor) PresentRecoveredError(ctx context.Context, err any) error {
return e.errorPresenter(ctx, e.recoverFunc(ctx, err)) return e.errorPresenter(ctx, e.recoverFunc(ctx, err))
} }
@@ -169,6 +174,10 @@ func (e *Executor) SetRecoverFunc(f graphql.RecoverFunc) {
e.recoverFunc = f e.recoverFunc = f
} }
func (e *Executor) SetParserTokenLimit(limit int) {
e.parserTokenLimit = limit
}
// parseQuery decodes the incoming query and validates it, pulling from cache if present. // parseQuery decodes the incoming query and validates it, pulling from cache if present.
// //
// NOTE: This should NOT look at variables, they will change per request. It should only parse and // NOTE: This should NOT look at variables, they will change per request. It should only parse and
@@ -189,7 +198,7 @@ func (e *Executor) parseQuery(
return doc.(*ast.QueryDocument), nil return doc.(*ast.QueryDocument), nil
} }
doc, err := parser.ParseQuery(&ast.Source{Input: query}) doc, err := parser.ParseQueryWithTokenLimit(&ast.Source{Input: query}, e.parserTokenLimit)
if err != nil { if err != nil {
gqlErr, ok := err.(*gqlerror.Error) gqlErr, ok := err.(*gqlerror.Error)
if ok { if ok {

View File

@@ -2,6 +2,7 @@ package executor
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql"
@@ -68,7 +69,7 @@ func processExtensions(exts []graphql.HandlerExtension) extensions {
rootFieldMiddleware: func(ctx context.Context, next graphql.RootResolver) graphql.Marshaler { rootFieldMiddleware: func(ctx context.Context, next graphql.RootResolver) graphql.Marshaler {
return next(ctx) return next(ctx)
}, },
fieldMiddleware: func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { fieldMiddleware: func(ctx context.Context, next graphql.Resolver) (res any, err error) {
return next(ctx) return next(ctx)
}, },
} }
@@ -105,8 +106,8 @@ func processExtensions(exts []graphql.HandlerExtension) extensions {
if p, ok := p.(graphql.FieldInterceptor); ok { if p, ok := p.(graphql.FieldInterceptor); ok {
previous := e.fieldMiddleware previous := e.fieldMiddleware
e.fieldMiddleware = func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { e.fieldMiddleware = func(ctx context.Context, next graphql.Resolver) (res any, err error) {
return p.InterceptField(ctx, func(ctx context.Context) (res interface{}, err error) { return p.InterceptField(ctx, func(ctx context.Context) (res any, err error) {
return previous(ctx, next) return previous(ctx, next)
}) })
} }
@@ -134,7 +135,7 @@ func (r aroundOpFunc) ExtensionName() string {
func (r aroundOpFunc) Validate(schema graphql.ExecutableSchema) error { func (r aroundOpFunc) Validate(schema graphql.ExecutableSchema) error {
if r == nil { if r == nil {
return fmt.Errorf("OperationFunc can not be nil") return errors.New("OperationFunc can not be nil")
} }
return nil return nil
} }
@@ -151,7 +152,7 @@ func (r aroundRespFunc) ExtensionName() string {
func (r aroundRespFunc) Validate(schema graphql.ExecutableSchema) error { func (r aroundRespFunc) Validate(schema graphql.ExecutableSchema) error {
if r == nil { if r == nil {
return fmt.Errorf("ResponseFunc can not be nil") return errors.New("ResponseFunc can not be nil")
} }
return nil return nil
} }
@@ -160,7 +161,7 @@ func (r aroundRespFunc) InterceptResponse(ctx context.Context, next graphql.Resp
return r(ctx, next) return r(ctx, next)
} }
type aroundFieldFunc func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) type aroundFieldFunc func(ctx context.Context, next graphql.Resolver) (res any, err error)
func (f aroundFieldFunc) ExtensionName() string { func (f aroundFieldFunc) ExtensionName() string {
return "InlineFieldFunc" return "InlineFieldFunc"
@@ -168,12 +169,12 @@ func (f aroundFieldFunc) ExtensionName() string {
func (f aroundFieldFunc) Validate(schema graphql.ExecutableSchema) error { func (f aroundFieldFunc) Validate(schema graphql.ExecutableSchema) error {
if f == nil { if f == nil {
return fmt.Errorf("FieldFunc can not be nil") return errors.New("FieldFunc can not be nil")
} }
return nil return nil
} }
func (f aroundFieldFunc) InterceptField(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { func (f aroundFieldFunc) InterceptField(ctx context.Context, next graphql.Resolver) (res any, err error) {
return f(ctx, next) return f(ctx, next)
} }
@@ -185,7 +186,7 @@ func (f aroundRootFieldFunc) ExtensionName() string {
func (f aroundRootFieldFunc) Validate(schema graphql.ExecutableSchema) error { func (f aroundRootFieldFunc) Validate(schema graphql.ExecutableSchema) error {
if f == nil { if f == nil {
return fmt.Errorf("RootFieldFunc can not be nil") return errors.New("RootFieldFunc can not be nil")
} }
return nil return nil
} }

View File

@@ -3,6 +3,7 @@ package graphql
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"math" "math"
@@ -11,11 +12,11 @@ import (
func MarshalFloat(f float64) Marshaler { func MarshalFloat(f float64) Marshaler {
return WriterFunc(func(w io.Writer) { return WriterFunc(func(w io.Writer) {
io.WriteString(w, fmt.Sprintf("%g", f)) fmt.Fprintf(w, "%g", f)
}) })
} }
func UnmarshalFloat(v interface{}) (float64, error) { func UnmarshalFloat(v any) (float64, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
return strconv.ParseFloat(v, 64) return strconv.ParseFloat(v, 64)
@@ -35,13 +36,13 @@ func UnmarshalFloat(v interface{}) (float64, error) {
func MarshalFloatContext(f float64) ContextMarshaler { func MarshalFloatContext(f float64) ContextMarshaler {
return ContextWriterFunc(func(ctx context.Context, w io.Writer) error { return ContextWriterFunc(func(ctx context.Context, w io.Writer) error {
if math.IsInf(f, 0) || math.IsNaN(f) { if math.IsInf(f, 0) || math.IsNaN(f) {
return fmt.Errorf("cannot marshal infinite no NaN float values") return errors.New("cannot marshal infinite no NaN float values")
} }
io.WriteString(w, fmt.Sprintf("%g", f)) fmt.Fprintf(w, "%g", f)
return nil return nil
}) })
} }
func UnmarshalFloatContext(ctx context.Context, v interface{}) (float64, error) { func UnmarshalFloatContext(ctx context.Context, v any) (float64, error) {
return UnmarshalFloat(v) return UnmarshalFloat(v)
} }

View File

@@ -16,18 +16,18 @@ type (
ResponseHandler func(ctx context.Context) *Response ResponseHandler func(ctx context.Context) *Response
ResponseMiddleware func(ctx context.Context, next ResponseHandler) *Response ResponseMiddleware func(ctx context.Context, next ResponseHandler) *Response
Resolver func(ctx context.Context) (res interface{}, err error) Resolver func(ctx context.Context) (res any, err error)
FieldMiddleware func(ctx context.Context, next Resolver) (res interface{}, err error) FieldMiddleware func(ctx context.Context, next Resolver) (res any, err error)
RootResolver func(ctx context.Context) Marshaler RootResolver func(ctx context.Context) Marshaler
RootFieldMiddleware func(ctx context.Context, next RootResolver) Marshaler RootFieldMiddleware func(ctx context.Context, next RootResolver) Marshaler
RawParams struct { RawParams struct {
Query string `json:"query"` Query string `json:"query"`
OperationName string `json:"operationName"` OperationName string `json:"operationName"`
Variables map[string]interface{} `json:"variables"` Variables map[string]any `json:"variables"`
Extensions map[string]interface{} `json:"extensions"` Extensions map[string]any `json:"extensions"`
Headers http.Header `json:"headers"` Headers http.Header `json:"headers"`
ReadTime TraceTiming `json:"-"` ReadTime TraceTiming `json:"-"`
} }
@@ -86,7 +86,7 @@ type (
// FieldInterceptor called around each field // FieldInterceptor called around each field
FieldInterceptor interface { FieldInterceptor interface {
InterceptField(ctx context.Context, next Resolver) (res interface{}, err error) InterceptField(ctx context.Context, next Resolver) (res any, err error)
} }
// Transport provides support for different wire level encodings of graphql requests, eg Form, Get, Post, Websocket // Transport provides support for different wire level encodings of graphql requests, eg Form, Get, Post, Websocket
@@ -103,7 +103,7 @@ func (p *RawParams) AddUpload(upload Upload, key, path string) *gqlerror.Error {
return gqlerror.Errorf("invalid operations paths for key %s", key) return gqlerror.Errorf("invalid operations paths for key %s", key)
} }
var ptr interface{} = p.Variables var ptr any = p.Variables
parts := strings.Split(path, ".") parts := strings.Split(path, ".")
// skip the first part (variables) because we started there // skip the first part (variables) because we started there
@@ -114,15 +114,15 @@ func (p *RawParams) AddUpload(upload Upload, key, path string) *gqlerror.Error {
} }
if index, parseNbrErr := strconv.Atoi(p); parseNbrErr == nil { if index, parseNbrErr := strconv.Atoi(p); parseNbrErr == nil {
if last { if last {
ptr.([]interface{})[index] = upload ptr.([]any)[index] = upload
} else { } else {
ptr = ptr.([]interface{})[index] ptr = ptr.([]any)[index]
} }
} else { } else {
if last { if last {
ptr.(map[string]interface{})[p] = upload ptr.(map[string]any)[p] = upload
} else { } else {
ptr = ptr.(map[string]interface{})[p] ptr = ptr.(map[string]any)[p]
} }
} }
} }

View File

@@ -4,7 +4,7 @@ import (
"context" "context"
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"fmt" "errors"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"github.com/vektah/gqlparser/v2/gqlerror" "github.com/vektah/gqlparser/v2/gqlerror"
@@ -47,7 +47,7 @@ func (a AutomaticPersistedQuery) ExtensionName() string {
func (a AutomaticPersistedQuery) Validate(schema graphql.ExecutableSchema) error { func (a AutomaticPersistedQuery) Validate(schema graphql.ExecutableSchema) error {
if a.Cache == nil { if a.Cache == nil {
return fmt.Errorf("AutomaticPersistedQuery.Cache can not be nil") return errors.New("AutomaticPersistedQuery.Cache can not be nil")
} }
return nil return nil
} }

View File

@@ -2,7 +2,7 @@ package extension
import ( import (
"context" "context"
"fmt" "errors"
"github.com/vektah/gqlparser/v2/gqlerror" "github.com/vektah/gqlparser/v2/gqlerror"
@@ -52,7 +52,7 @@ func (c ComplexityLimit) ExtensionName() string {
func (c *ComplexityLimit) Validate(schema graphql.ExecutableSchema) error { func (c *ComplexityLimit) Validate(schema graphql.ExecutableSchema) error {
if c.Func == nil { if c.Func == nil {
return fmt.Errorf("ComplexityLimit func can not be nil") return errors.New("ComplexityLimit func can not be nil")
} }
c.es = schema c.es = schema
return nil return nil

View File

@@ -24,10 +24,10 @@ func New(size int) *LRU {
return &LRU{cache} return &LRU{cache}
} }
func (l LRU) Get(ctx context.Context, key string) (value interface{}, ok bool) { func (l LRU) Get(ctx context.Context, key string) (value any, ok bool) {
return l.lru.Get(key) return l.lru.Get(key)
} }
func (l LRU) Add(ctx context.Context, key string, value interface{}) { func (l LRU) Add(ctx context.Context, key string, value any) {
l.lru.Add(key, value) l.lru.Add(key, value)
} }

View File

@@ -3,6 +3,7 @@ package handler
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"net/http" "net/http"
"time" "time"
@@ -66,6 +67,10 @@ func (s *Server) SetQueryCache(cache graphql.Cache) {
s.exec.SetQueryCache(cache) s.exec.SetQueryCache(cache)
} }
func (s *Server) SetParserTokenLimit(limit int) {
s.exec.SetParserTokenLimit(limit)
}
func (s *Server) Use(extension graphql.HandlerExtension) { func (s *Server) Use(extension graphql.HandlerExtension) {
s.exec.Use(extension) s.exec.Use(extension)
} }
@@ -131,7 +136,7 @@ func sendError(w http.ResponseWriter, code int, errors ...*gqlerror.Error) {
_, _ = w.Write(b) _, _ = w.Write(b)
} }
func sendErrorf(w http.ResponseWriter, code int, format string, args ...interface{}) { func sendErrorf(w http.ResponseWriter, code int, format string, args ...any) {
sendError(w, code, &gqlerror.Error{Message: fmt.Sprintf(format, args...)}) sendError(w, code, &gqlerror.Error{Message: fmt.Sprintf(format, args...)})
} }
@@ -143,7 +148,7 @@ func (r OperationFunc) ExtensionName() string {
func (r OperationFunc) Validate(schema graphql.ExecutableSchema) error { func (r OperationFunc) Validate(schema graphql.ExecutableSchema) error {
if r == nil { if r == nil {
return fmt.Errorf("OperationFunc can not be nil") return errors.New("OperationFunc can not be nil")
} }
return nil return nil
} }
@@ -160,7 +165,7 @@ func (r ResponseFunc) ExtensionName() string {
func (r ResponseFunc) Validate(schema graphql.ExecutableSchema) error { func (r ResponseFunc) Validate(schema graphql.ExecutableSchema) error {
if r == nil { if r == nil {
return fmt.Errorf("ResponseFunc can not be nil") return errors.New("ResponseFunc can not be nil")
} }
return nil return nil
} }
@@ -169,7 +174,7 @@ func (r ResponseFunc) InterceptResponse(ctx context.Context, next graphql.Respon
return r(ctx, next) return r(ctx, next)
} }
type FieldFunc func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) type FieldFunc func(ctx context.Context, next graphql.Resolver) (res any, err error)
func (f FieldFunc) ExtensionName() string { func (f FieldFunc) ExtensionName() string {
return "InlineFieldFunc" return "InlineFieldFunc"
@@ -177,11 +182,11 @@ func (f FieldFunc) ExtensionName() string {
func (f FieldFunc) Validate(schema graphql.ExecutableSchema) error { func (f FieldFunc) Validate(schema graphql.ExecutableSchema) error {
if f == nil { if f == nil {
return fmt.Errorf("FieldFunc can not be nil") return errors.New("FieldFunc can not be nil")
} }
return nil return nil
} }
func (f FieldFunc) InterceptField(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { func (f FieldFunc) InterceptField(ctx context.Context, next graphql.Resolver) (res any, err error) {
return f(ctx, next) return f(ctx, next)
} }

View File

@@ -22,6 +22,6 @@ func SendError(w http.ResponseWriter, code int, errors ...*gqlerror.Error) {
} }
// SendErrorf wraps SendError to add formatted messages // SendErrorf wraps SendError to add formatted messages
func SendErrorf(w http.ResponseWriter, code int, format string, args ...interface{}) { func SendErrorf(w http.ResponseWriter, code int, format string, args ...any) {
SendError(w, code, &gqlerror.Error{Message: fmt.Sprintf(format, args...)}) SendError(w, code, &gqlerror.Error{Message: fmt.Sprintf(format, args...)})
} }

View File

@@ -63,10 +63,10 @@ func (h UrlEncodedForm) Do(w http.ResponseWriter, r *http.Request, exec graphql.
return return
} }
rc, OpErr := exec.CreateOperationContext(ctx, params) rc, opErr := exec.CreateOperationContext(ctx, params)
if OpErr != nil { if opErr != nil {
w.WriteHeader(statusFor(OpErr)) w.WriteHeader(statusFor(opErr))
resp := exec.DispatchError(graphql.WithOperationContext(ctx, rc), OpErr) resp := exec.DispatchError(graphql.WithOperationContext(ctx, rc), opErr)
writeJson(w, resp) writeJson(w, resp)
return return
} }

View File

@@ -84,7 +84,7 @@ func (h GET) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecut
writeJson(w, responses(ctx)) writeJson(w, responses(ctx))
} }
func jsonDecode(r io.Reader, val interface{}) error { func jsonDecode(r io.Reader, val any) error {
dec := json.NewDecoder(r) dec := json.NewDecoder(r)
dec.UseNumber() dec.UseNumber()
return dec.Decode(val) return dec.Decode(val)

View File

@@ -64,10 +64,10 @@ func (h GRAPHQL) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphEx
return return
} }
rc, OpErr := exec.CreateOperationContext(ctx, params) rc, opErr := exec.CreateOperationContext(ctx, params)
if OpErr != nil { if opErr != nil {
w.WriteHeader(statusFor(OpErr)) w.WriteHeader(statusFor(opErr))
resp := exec.DispatchError(graphql.WithOperationContext(ctx, rc), OpErr) resp := exec.DispatchError(graphql.WithOperationContext(ctx, rc), opErr)
writeJson(w, resp) writeJson(w, resp)
return return
} }

View File

@@ -78,10 +78,10 @@ func (h POST) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecu
return return
} }
rc, OpErr := exec.CreateOperationContext(ctx, params) rc, opErr := exec.CreateOperationContext(ctx, params)
if OpErr != nil { if opErr != nil {
w.WriteHeader(statusFor(OpErr)) w.WriteHeader(statusFor(opErr))
resp := exec.DispatchError(graphql.WithOperationContext(ctx, rc), OpErr) resp := exec.DispatchError(graphql.WithOperationContext(ctx, rc), opErr)
writeJson(w, resp) writeJson(w, resp)
return return
} }

View File

@@ -22,7 +22,7 @@ func writeJsonError(w io.Writer, msg string) {
writeJson(w, &graphql.Response{Errors: gqlerror.List{{Message: msg}}}) writeJson(w, &graphql.Response{Errors: gqlerror.List{{Message: msg}}})
} }
func writeJsonErrorf(w io.Writer, format string, args ...interface{}) { func writeJsonErrorf(w io.Writer, format string, args ...any) {
writeJson(w, &graphql.Response{Errors: gqlerror.List{{Message: fmt.Sprintf(format, args...)}}}) writeJson(w, &graphql.Response{Errors: gqlerror.List{{Message: fmt.Sprintf(format, args...)}}})
} }

View File

@@ -193,7 +193,7 @@ func (c *wsConnection) init() bool {
} }
} }
var initAckPayload *InitPayload = nil var initAckPayload *InitPayload
if c.InitFunc != nil { if c.InitFunc != nil {
var ctx context.Context var ctx context.Context
ctx, initAckPayload, err = c.InitFunc(c.ctx, c.initPayload) ctx, initAckPayload, err = c.InitFunc(c.ctx, c.initPayload)
@@ -480,7 +480,7 @@ func (c *wsConnection) sendError(id string, errors ...*gqlerror.Error) {
c.write(&message{t: errorMessageType, id: id, payload: b}) c.write(&message{t: errorMessageType, id: id, payload: b})
} }
func (c *wsConnection) sendConnectionError(format string, args ...interface{}) { func (c *wsConnection) sendConnectionError(format string, args ...any) {
b, err := json.Marshal(&gqlerror.Error{Message: fmt.Sprintf(format, args...)}) b, err := json.Marshal(&gqlerror.Error{Message: fmt.Sprintf(format, args...)})
if err != nil { if err != nil {
panic(err) panic(err)

View File

@@ -10,7 +10,7 @@ const (
// InitPayload is a structure that is parsed from the websocket init message payload. TO use // InitPayload is a structure that is parsed from the websocket init message payload. TO use
// request headers for non-websocket, instead wrap the graphql handler in a middleware. // request headers for non-websocket, instead wrap the graphql handler in a middleware.
type InitPayload map[string]interface{} type InitPayload map[string]any
// GetString safely gets a string value from the payload. It returns an empty string if the // GetString safely gets a string value from the payload. It returns an empty string if the
// payload is nil or the value isn't set. // payload is nil or the value isn't set.

View File

@@ -11,7 +11,7 @@ func MarshalID(s string) Marshaler {
return MarshalString(s) return MarshalString(s)
} }
func UnmarshalID(v interface{}) (string, error) { func UnmarshalID(v any) (string, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
return v, nil return v, nil
@@ -22,13 +22,9 @@ func UnmarshalID(v interface{}) (string, error) {
case int64: case int64:
return strconv.FormatInt(v, 10), nil return strconv.FormatInt(v, 10), nil
case float64: case float64:
return fmt.Sprintf("%f", v), nil return strconv.FormatFloat(v, 'f', 6, 64), nil
case bool: case bool:
if v { return strconv.FormatBool(v), nil
return "true", nil
} else {
return "false", nil
}
case nil: case nil:
return "null", nil return "null", nil
default: default:
@@ -42,7 +38,7 @@ func MarshalIntID(i int) Marshaler {
}) })
} }
func UnmarshalIntID(v interface{}) (int, error) { func UnmarshalIntID(v any) (int, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
return strconv.Atoi(v) return strconv.Atoi(v)
@@ -63,7 +59,7 @@ func MarshalUintID(i uint) Marshaler {
}) })
} }
func UnmarshalUintID(v interface{}) (uint, error) { func UnmarshalUintID(v any) (uint, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
result, err := strconv.ParseUint(v, 10, 64) result, err := strconv.ParseUint(v, 10, 64)

View File

@@ -10,7 +10,7 @@ const unmarshalInputCtx key = "unmarshal_input_context"
// BuildUnmarshalerMap returns a map of unmarshal functions of the ExecutableContext // BuildUnmarshalerMap returns a map of unmarshal functions of the ExecutableContext
// to use with the WithUnmarshalerMap function. // to use with the WithUnmarshalerMap function.
func BuildUnmarshalerMap(unmarshaler ...interface{}) map[reflect.Type]reflect.Value { func BuildUnmarshalerMap(unmarshaler ...any) map[reflect.Type]reflect.Value {
maps := make(map[reflect.Type]reflect.Value) maps := make(map[reflect.Type]reflect.Value)
for _, v := range unmarshaler { for _, v := range unmarshaler {
ft := reflect.TypeOf(v) ft := reflect.TypeOf(v)
@@ -28,7 +28,7 @@ func WithUnmarshalerMap(ctx context.Context, maps map[reflect.Type]reflect.Value
} }
// UnmarshalInputFromContext allows unmarshaling input object from a context. // UnmarshalInputFromContext allows unmarshaling input object from a context.
func UnmarshalInputFromContext(ctx context.Context, raw, v interface{}) error { func UnmarshalInputFromContext(ctx context.Context, raw, v any) error {
m, ok := ctx.Value(unmarshalInputCtx).(map[reflect.Type]reflect.Value) m, ok := ctx.Value(unmarshalInputCtx).(map[reflect.Type]reflect.Value)
if m == nil || !ok { if m == nil || !ok {
return errors.New("graphql: the input context is empty") return errors.New("graphql: the input context is empty")

View File

@@ -13,7 +13,7 @@ func MarshalInt(i int) Marshaler {
}) })
} }
func UnmarshalInt(v interface{}) (int, error) { func UnmarshalInt(v any) (int, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
return strconv.Atoi(v) return strconv.Atoi(v)
@@ -34,7 +34,7 @@ func MarshalInt64(i int64) Marshaler {
}) })
} }
func UnmarshalInt64(v interface{}) (int64, error) { func UnmarshalInt64(v any) (int64, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
return strconv.ParseInt(v, 10, 64) return strconv.ParseInt(v, 10, 64)
@@ -55,7 +55,7 @@ func MarshalInt32(i int32) Marshaler {
}) })
} }
func UnmarshalInt32(v interface{}) (int32, error) { func UnmarshalInt32(v any) (int32, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
iv, err := strconv.ParseInt(v, 10, 32) iv, err := strconv.ParseInt(v, 10, 32)

View File

@@ -28,7 +28,7 @@ type Marshaler interface {
} }
type Unmarshaler interface { type Unmarshaler interface {
UnmarshalGQL(v interface{}) error UnmarshalGQL(v any) error
} }
type ContextMarshaler interface { type ContextMarshaler interface {
@@ -36,7 +36,7 @@ type ContextMarshaler interface {
} }
type ContextUnmarshaler interface { type ContextUnmarshaler interface {
UnmarshalGQLContext(ctx context.Context, v interface{}) error UnmarshalGQLContext(ctx context.Context, v any) error
} }
type contextMarshalerAdapter struct { type contextMarshalerAdapter struct {

View File

@@ -66,7 +66,7 @@ var altairPage = template.Must(template.New("altair").Parse(`<!doctype html>
// AltairHandler responsible for setting up the altair playground // AltairHandler responsible for setting up the altair playground
func AltairHandler(title, endpoint string) http.HandlerFunc { func AltairHandler(title, endpoint string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
err := altairPage.Execute(w, map[string]interface{}{ err := altairPage.Execute(w, map[string]any{
"title": title, "title": title,
"endpoint": endpoint, "endpoint": endpoint,
"endpointIsAbsolute": endpointHasScheme(endpoint), "endpointIsAbsolute": endpointHasScheme(endpoint),

View File

@@ -64,7 +64,7 @@ func ApolloSandboxHandler(title, endpoint string, opts ...ApolloSandboxOption) h
} }
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
err := apolloSandboxPage.Execute(w, map[string]interface{}{ err := apolloSandboxPage.Execute(w, map[string]any{
"title": title, "title": title,
"endpoint": endpoint, "endpoint": endpoint,
"endpointIsAbsolute": endpointHasScheme(endpoint), "endpointIsAbsolute": endpointHasScheme(endpoint),

View File

@@ -85,17 +85,17 @@ var page = template.Must(template.New("graphiql").Parse(`<!DOCTYPE html>
`)) `))
// Handler responsible for setting up the playground // Handler responsible for setting up the playground
func Handler(title string, endpoint string) http.HandlerFunc { func Handler(title, endpoint string) http.HandlerFunc {
return HandlerWithHeaders(title, endpoint, nil, nil) return HandlerWithHeaders(title, endpoint, nil, nil)
} }
// HandlerWithHeaders sets up the playground. // HandlerWithHeaders sets up the playground.
// fetcherHeaders are used by the playground's fetcher instance and will not be visible in the UI. // fetcherHeaders are used by the playground's fetcher instance and will not be visible in the UI.
// uiHeaders are default headers that will show up in the UI headers editor. // uiHeaders are default headers that will show up in the UI headers editor.
func HandlerWithHeaders(title string, endpoint string, fetcherHeaders map[string]string, uiHeaders map[string]string) http.HandlerFunc { func HandlerWithHeaders(title, endpoint string, fetcherHeaders, uiHeaders map[string]string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/html; charset=UTF-8") w.Header().Add("Content-Type", "text/html; charset=UTF-8")
err := page.Execute(w, map[string]interface{}{ err := page.Execute(w, map[string]any{
"title": title, "title": title,
"endpoint": endpoint, "endpoint": endpoint,
"fetcherHeaders": fetcherHeaders, "fetcherHeaders": fetcherHeaders,

View File

@@ -9,9 +9,9 @@ import (
"github.com/vektah/gqlparser/v2/gqlerror" "github.com/vektah/gqlparser/v2/gqlerror"
) )
type RecoverFunc func(ctx context.Context, err interface{}) (userMessage error) type RecoverFunc func(ctx context.Context, err any) (userMessage error)
func DefaultRecover(ctx context.Context, err interface{}) error { func DefaultRecover(ctx context.Context, err any) error {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
fmt.Fprintln(os.Stderr) fmt.Fprintln(os.Stderr)
debug.PrintStack() debug.PrintStack()

View File

@@ -13,15 +13,15 @@ import (
// https://github.com/facebook/graphql/commit/7b40390d48680b15cb93e02d46ac5eb249689876#diff-757cea6edf0288677a9eea4cfc801d87R107 // https://github.com/facebook/graphql/commit/7b40390d48680b15cb93e02d46ac5eb249689876#diff-757cea6edf0288677a9eea4cfc801d87R107
// and https://github.com/facebook/graphql/pull/384 // and https://github.com/facebook/graphql/pull/384
type Response struct { type Response struct {
Errors gqlerror.List `json:"errors,omitempty"` Errors gqlerror.List `json:"errors,omitempty"`
Data json.RawMessage `json:"data"` Data json.RawMessage `json:"data"`
Label string `json:"label,omitempty"` Label string `json:"label,omitempty"`
Path ast.Path `json:"path,omitempty"` Path ast.Path `json:"path,omitempty"`
HasNext *bool `json:"hasNext,omitempty"` HasNext *bool `json:"hasNext,omitempty"`
Extensions map[string]interface{} `json:"extensions,omitempty"` Extensions map[string]any `json:"extensions,omitempty"`
} }
func ErrorResponse(ctx context.Context, messagef string, args ...interface{}) *Response { func ErrorResponse(ctx context.Context, messagef string, args ...any) *Response {
return &Response{ return &Response{
Errors: gqlerror.List{{Message: fmt.Sprintf(messagef, args...)}}, Errors: gqlerror.List{{Message: fmt.Sprintf(messagef, args...)}},
} }

View File

@@ -14,7 +14,7 @@ type Stats struct {
// Stats collected by handler extensions. Don't use directly, the extension should provide a type safe way to // Stats collected by handler extensions. Don't use directly, the extension should provide a type safe way to
// access this. // access this.
extension map[string]interface{} extension map[string]any
} }
type TraceTiming struct { type TraceTiming struct {
@@ -42,14 +42,14 @@ func GetStartTime(ctx context.Context) time.Time {
return t return t
} }
func (c *Stats) SetExtension(name string, data interface{}) { func (c *Stats) SetExtension(name string, data any) {
if c.extension == nil { if c.extension == nil {
c.extension = map[string]interface{}{} c.extension = map[string]any{}
} }
c.extension[name] = data c.extension[name] = data
} }
func (c *Stats) GetExtension(name string) interface{} { func (c *Stats) GetExtension(name string) any {
if c.extension == nil { if c.extension == nil {
return nil return nil
} }

View File

@@ -47,7 +47,7 @@ func writeQuotedString(w io.Writer, s string) {
io.WriteString(w, `"`) io.WriteString(w, `"`)
} }
func UnmarshalString(v interface{}) (string, error) { func UnmarshalString(v any) (string, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
return v, nil return v, nil
@@ -60,11 +60,7 @@ func UnmarshalString(v interface{}) (string, error) {
case json.Number: case json.Number:
return string(v), nil return string(v), nil
case bool: case bool:
if v { return strconv.FormatBool(v), nil
return "true", nil
} else {
return "false", nil
}
case nil: case nil:
return "null", nil return "null", nil
default: default:

View File

@@ -17,7 +17,7 @@ func MarshalTime(t time.Time) Marshaler {
}) })
} }
func UnmarshalTime(v interface{}) (time.Time, error) { func UnmarshalTime(v any) (time.Time, error) {
if tmpStr, ok := v.(string); ok { if tmpStr, ok := v.(string); ok {
return time.Parse(time.RFC3339Nano, tmpStr) return time.Parse(time.RFC3339Nano, tmpStr)
} }

View File

@@ -14,7 +14,7 @@ func MarshalUint(i uint) Marshaler {
}) })
} }
func UnmarshalUint(v interface{}) (uint, error) { func UnmarshalUint(v any) (uint, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
u64, err := strconv.ParseUint(v, 10, 64) u64, err := strconv.ParseUint(v, 10, 64)
@@ -45,7 +45,7 @@ func MarshalUint64(i uint64) Marshaler {
}) })
} }
func UnmarshalUint64(v interface{}) (uint64, error) { func UnmarshalUint64(v any) (uint64, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
return strconv.ParseUint(v, 10, 64) return strconv.ParseUint(v, 10, 64)
@@ -74,7 +74,7 @@ func MarshalUint32(i uint32) Marshaler {
}) })
} }
func UnmarshalUint32(v interface{}) (uint32, error) { func UnmarshalUint32(v any) (uint32, error) {
switch v := v.(type) { switch v := v.(type) {
case string: case string:
iv, err := strconv.ParseUint(v, 10, 32) iv, err := strconv.ParseUint(v, 10, 32)

View File

@@ -18,7 +18,7 @@ func MarshalUpload(f Upload) Marshaler {
}) })
} }
func UnmarshalUpload(v interface{}) (Upload, error) { func UnmarshalUpload(v any) (Upload, error) {
upload, ok := v.(Upload) upload, ok := v.(Upload)
if !ok { if !ok {
return Upload{}, fmt.Errorf("%T is not an Upload", v) return Upload{}, fmt.Errorf("%T is not an Upload", v)

View File

@@ -1,3 +1,3 @@
package graphql package graphql
const Version = "v0.17.47" const Version = "v0.17.49"

View File

@@ -1,6 +1,7 @@
package code package code
import ( import (
"errors"
"fmt" "fmt"
"go/types" "go/types"
) )
@@ -32,7 +33,7 @@ func CompatibleTypes(expected, actual types.Type) error {
case *types.Array: case *types.Array:
if actual, ok := actual.(*types.Array); ok { if actual, ok := actual.(*types.Array); ok {
if expected.Len() != actual.Len() { if expected.Len() != actual.Len() {
return fmt.Errorf("array length differs") return errors.New("array length differs")
} }
return CompatibleTypes(expected.Elem(), actual.Elem()) return CompatibleTypes(expected.Elem(), actual.Elem())
@@ -50,7 +51,7 @@ func CompatibleTypes(expected, actual types.Type) error {
case *types.Struct: case *types.Struct:
if actual, ok := actual.(*types.Struct); ok { if actual, ok := actual.(*types.Struct); ok {
if expected.NumFields() != actual.NumFields() { if expected.NumFields() != actual.NumFields() {
return fmt.Errorf("number of struct fields differ") return errors.New("number of struct fields differ")
} }
for i := 0; i < expected.NumFields(); i++ { for i := 0; i < expected.NumFields(); i++ {

View File

@@ -102,21 +102,21 @@ func goModuleRoot(dir string) (string, bool) {
// go.mod is not found in the tree, so the same sentinel value fits all the directories in a tree // go.mod is not found in the tree, so the same sentinel value fits all the directories in a tree
goModuleRootCache[d] = result goModuleRootCache[d] = result
} else { } else {
if relPath, err := filepath.Rel(result.goModPath, d); err != nil { relPath, err := filepath.Rel(result.goModPath, d)
if err != nil {
panic(err) panic(err)
} else { }
path := result.moduleName path := result.moduleName
relPath := filepath.ToSlash(relPath) relPath = filepath.ToSlash(relPath)
if !strings.HasSuffix(relPath, "/") { if !strings.HasSuffix(relPath, "/") {
path += "/" path += "/"
} }
path += relPath path += relPath
goModuleRootCache[d] = goModuleSearchResult{ goModuleRootCache[d] = goModuleSearchResult{
path: path, path: path,
goModPath: result.goModPath, goModPath: result.goModPath,
moduleName: result.moduleName, moduleName: result.moduleName,
}
} }
} }
} }

View File

@@ -100,17 +100,17 @@ var initCmd = &cli.Command{
cwd, err := os.Getwd() cwd, err := os.Getwd()
if err != nil { if err != nil {
log.Println(err) log.Println(err)
return fmt.Errorf("unable to determine current directory:%w", err) return fmt.Errorf("unable to determine current directory: %w", err)
} }
pkgName := code.ImportPathForDir(cwd) pkgName := code.ImportPathForDir(cwd)
if pkgName == "" { if pkgName == "" {
return fmt.Errorf( return errors.New(
"unable to determine import path for current directory, you probably need to run 'go mod init' first", "unable to determine import path for current directory, you probably need to run 'go mod init' first",
) )
} }
modRoot := findModuleRoot(cwd) modRoot := findModuleRoot(cwd)
if modRoot == "" { if modRoot == "" {
return fmt.Errorf("go.mod is missing. Please, do 'go mod init' first\n") return errors.New("go.mod is missing. Please, do 'go mod init' first\n")
} }
// check schema and config don't already exist // check schema and config don't already exist
@@ -121,7 +121,7 @@ var initCmd = &cli.Command{
} }
_, err = config.LoadConfigFromDefaultLocations() _, err = config.LoadConfigFromDefaultLocations()
if err == nil { if err == nil {
return fmt.Errorf("gqlgen.yml already exists in a parent directory\n") return errors.New("gqlgen.yml already exists in a parent directory\n")
} }
// create config // create config
@@ -187,10 +187,7 @@ var generateCmd = &cli.Command{
} }
} }
if err = api.Generate(cfg); err != nil { return api.Generate(cfg)
return err
}
return nil
}, },
} }

View File

@@ -292,18 +292,17 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error {
getter += "\treturn interfaceSlice\n" getter += "\treturn interfaceSlice\n"
getter += "}" getter += "}"
return getter return getter
} else {
getter := fmt.Sprintf("func (this %s) Get%s() %s { return ", templates.ToGo(model.Name), field.GoName, goType)
if interfaceFieldTypeIsPointer && !structFieldTypeIsPointer {
getter += "&"
} else if !interfaceFieldTypeIsPointer && structFieldTypeIsPointer {
getter += "*"
}
getter += fmt.Sprintf("this.%s }", field.GoName)
return getter
} }
getter := fmt.Sprintf("func (this %s) Get%s() %s { return ", templates.ToGo(model.Name), field.GoName, goType)
if interfaceFieldTypeIsPointer && !structFieldTypeIsPointer {
getter += "&"
} else if !interfaceFieldTypeIsPointer && structFieldTypeIsPointer {
getter += "*"
}
getter += fmt.Sprintf("this.%s }", field.GoName)
return getter
} }
funcMap := template.FuncMap{ funcMap := template.FuncMap{
"getInterfaceByName": getInterfaceByName, "getInterfaceByName": getInterfaceByName,
@@ -446,38 +445,69 @@ func (m *Plugin) generateFields(cfg *config.Config, schemaType *ast.Definition)
fields = append(fields, f) fields = append(fields, f)
} }
// appending extra fields at the end of the fields list. fields = append(fields, getExtraFields(cfg, schemaType.Name)...)
modelcfg := cfg.Models[schemaType.Name]
if len(modelcfg.ExtraFields) > 0 {
ff := make([]*Field, 0, len(modelcfg.ExtraFields))
for fname, fspec := range modelcfg.ExtraFields {
ftype := buildType(fspec.Type)
tag := `json:"-"`
if fspec.OverrideTags != "" {
tag = fspec.OverrideTags
}
ff = append(ff,
&Field{
Name: fname,
GoName: fname,
Type: ftype,
Description: fspec.Description,
Tag: tag,
})
}
sort.Slice(ff, func(i, j int) bool {
return ff[i].Name < ff[j].Name
})
fields = append(fields, ff...)
}
return fields, nil return fields, nil
} }
func getExtraFields(cfg *config.Config, modelName string) []*Field {
modelcfg := cfg.Models[modelName]
extraFieldsCount := len(modelcfg.ExtraFields) + len(modelcfg.EmbedExtraFields)
if extraFieldsCount == 0 {
return nil
}
extraFields := make([]*Field, 0, extraFieldsCount)
makeExtraField := func(fname string, fspec config.ModelExtraField) *Field {
ftype := buildType(fspec.Type)
tag := `json:"-"`
if fspec.OverrideTags != "" {
tag = fspec.OverrideTags
}
return &Field{
Name: fname,
GoName: fname,
Type: ftype,
Description: fspec.Description,
Tag: tag,
}
}
if len(modelcfg.ExtraFields) > 0 {
for fname, fspec := range modelcfg.ExtraFields {
extraFields = append(extraFields, makeExtraField(fname, fspec))
}
}
if len(modelcfg.EmbedExtraFields) > 0 {
for _, fspec := range modelcfg.EmbedExtraFields {
extraFields = append(extraFields, makeExtraField("", fspec))
}
}
sort.Slice(extraFields, func(i, j int) bool {
if extraFields[i].Name == "" && extraFields[j].Name == "" {
return extraFields[i].Type.String() < extraFields[j].Type.String()
}
if extraFields[i].Name == "" {
return false
}
if extraFields[j].Name == "" {
return true
}
return extraFields[i].Name < extraFields[j].Name
})
return extraFields
}
func getStructTagFromField(cfg *config.Config, field *ast.FieldDefinition) string { func getStructTagFromField(cfg *config.Config, field *ast.FieldDefinition) string {
if !field.Type.NonNull && (cfg.EnableModelJsonOmitemptyTag == nil || *cfg.EnableModelJsonOmitemptyTag) { if !field.Type.NonNull && (cfg.EnableModelJsonOmitemptyTag == nil || *cfg.EnableModelJsonOmitemptyTag) {
return `json:"` + field.Name + `,omitempty"` return `json:"` + field.Name + `,omitempty"`
@@ -591,7 +621,7 @@ func removeDuplicateTags(t string) string {
key := kv[0] key := kv[0]
value := strings.Join(kv[1:], ":") value := strings.Join(kv[1:], ":")
processed[key] = true processed[key] = true
if len(returnTags) > 0 { if returnTags != "" {
returnTags = " " + returnTags returnTags = " " + returnTags
} }

View File

@@ -138,7 +138,7 @@ func (m *Plugin) generatePerSchema(data *codegen.Data) error {
continue continue
} }
if implExists { if implExists {
return fmt.Errorf("multiple plugins implement ResolverImplementer") return errors.New("multiple plugins implement ResolverImplementer")
} }
implExists = true implExists = true
resolver.ImplementationRender = rImpl.Implement resolver.ImplementationRender = rImpl.Implement
@@ -269,7 +269,7 @@ func (r *Resolver) Implementation() string {
return r.ImplementationStr return r.ImplementationStr
} }
func gqlToResolverName(base string, gqlname, filenameTmpl string) string { func gqlToResolverName(base, gqlname, filenameTmpl string) string {
gqlname = filepath.Base(gqlname) gqlname = filepath.Base(gqlname)
ext := filepath.Ext(gqlname) ext := filepath.Ext(gqlname)
if filenameTmpl == "" { if filenameTmpl == "" {

View File

@@ -15,6 +15,7 @@
package constant package constant
const ( const (
ActionIndex = "act"
DomainIndex = "dom" DomainIndex = "dom"
SubjectIndex = "sub" SubjectIndex = "sub"
ObjectIndex = "obj" ObjectIndex = "obj"

View File

@@ -323,11 +323,39 @@ func (e *Enforcer) ClearPolicy() {
// LoadPolicy reloads the policy from file/database. // LoadPolicy reloads the policy from file/database.
func (e *Enforcer) LoadPolicy() error { func (e *Enforcer) LoadPolicy() error {
needToRebuild := false newModel, err := e.loadPolicyFromAdapter(e.model)
newModel := e.model.Copy() if err != nil {
return err
}
err = e.applyModifiedModel(newModel)
if err != nil {
return err
}
return nil
}
func (e *Enforcer) loadPolicyFromAdapter(baseModel model.Model) (model.Model, error) {
newModel := baseModel.Copy()
newModel.ClearPolicy() newModel.ClearPolicy()
if err := e.adapter.LoadPolicy(newModel); err != nil && err.Error() != "invalid file path, file path cannot be empty" {
return nil, err
}
if err := newModel.SortPoliciesBySubjectHierarchy(); err != nil {
return nil, err
}
if err := newModel.SortPoliciesByPriority(); err != nil {
return nil, err
}
return newModel, nil
}
func (e *Enforcer) applyModifiedModel(newModel model.Model) error {
var err error var err error
needToRebuild := false
defer func() { defer func() {
if err != nil { if err != nil {
if e.autoBuildRoleLinks && needToRebuild { if e.autoBuildRoleLinks && needToRebuild {
@@ -336,20 +364,9 @@ func (e *Enforcer) LoadPolicy() error {
} }
}() }()
if err = e.adapter.LoadPolicy(newModel); err != nil && err.Error() != "invalid file path, file path cannot be empty" {
return err
}
if err = newModel.SortPoliciesBySubjectHierarchy(); err != nil {
return err
}
if err = newModel.SortPoliciesByPriority(); err != nil {
return err
}
if e.autoBuildRoleLinks { if e.autoBuildRoleLinks {
needToRebuild = true needToRebuild = true
if err := e.rebuildRoleLinks(newModel); err != nil { if err := e.rebuildRoleLinks(newModel); err != nil {
return err return err
} }
@@ -358,6 +375,7 @@ func (e *Enforcer) LoadPolicy() error {
return err return err
} }
} }
e.model = newModel e.model = newModel
e.invalidateMatcherMap() e.invalidateMatcherMap()
return nil return nil

View File

@@ -172,3 +172,14 @@ func GetCacheKey(params ...interface{}) (string, bool) {
} }
return key.String(), true return key.String(), true
} }
// ClearPolicy clears all policy.
func (e *CachedEnforcer) ClearPolicy() {
if atomic.LoadInt32(&e.enableCache) != 0 {
if err := e.cache.Clear(); err != nil {
e.logger.LogError(err, "clear cache failed")
return
}
}
e.Enforcer.ClearPolicy()
}

View File

@@ -22,8 +22,6 @@ import (
"github.com/casbin/govaluate" "github.com/casbin/govaluate"
"github.com/casbin/casbin/v2/persist" "github.com/casbin/casbin/v2/persist"
"github.com/casbin/casbin/v2/rbac"
defaultrolemanager "github.com/casbin/casbin/v2/rbac/default-role-manager"
) )
// SyncedEnforcer wraps Enforcer and provides synchronized access. // SyncedEnforcer wraps Enforcer and provides synchronized access.
@@ -117,48 +115,18 @@ func (e *SyncedEnforcer) ClearPolicy() {
// LoadPolicy reloads the policy from file/database. // LoadPolicy reloads the policy from file/database.
func (e *SyncedEnforcer) LoadPolicy() error { func (e *SyncedEnforcer) LoadPolicy() error {
e.m.Lock()
defer e.m.Unlock()
return e.Enforcer.LoadPolicy()
}
// LoadPolicyFast is not blocked when adapter calls LoadPolicy.
func (e *SyncedEnforcer) LoadPolicyFast() error {
e.m.RLock() e.m.RLock()
newModel := e.model.Copy() newModel, err := e.loadPolicyFromAdapter(e.model)
e.m.RUnlock() e.m.RUnlock()
if err != nil {
newModel.ClearPolicy()
newRmMap := map[string]rbac.RoleManager{}
var err error
if err = e.adapter.LoadPolicy(newModel); err != nil && err.Error() != "invalid file path, file path cannot be empty" {
return err return err
} }
if err = newModel.SortPoliciesBySubjectHierarchy(); err != nil {
return err
}
if err = newModel.SortPoliciesByPriority(); err != nil {
return err
}
if e.autoBuildRoleLinks {
for ptype := range newModel["g"] {
newRmMap[ptype] = defaultrolemanager.NewRoleManager(10)
}
err = newModel.BuildRoleLinks(newRmMap)
if err != nil {
return err
}
}
// reduce the lock range
e.m.Lock() e.m.Lock()
defer e.m.Unlock() err = e.applyModifiedModel(newModel)
e.model = newModel e.m.Unlock()
e.rmMap = newRmMap if err != nil {
return err
}
return nil return nil
} }

View File

@@ -19,38 +19,51 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/casbin/casbin/v2/constant"
"github.com/casbin/casbin/v2/util" "github.com/casbin/casbin/v2/util"
"github.com/casbin/govaluate" "github.com/casbin/govaluate"
) )
// GetAllSubjects gets the list of subjects that show up in the current policy. // GetAllSubjects gets the list of subjects that show up in the current policy.
func (e *Enforcer) GetAllSubjects() ([]string, error) { func (e *Enforcer) GetAllSubjects() ([]string, error) {
return e.model.GetValuesForFieldInPolicyAllTypes("p", 0) return e.model.GetValuesForFieldInPolicyAllTypesByName("p", constant.SubjectIndex)
} }
// GetAllNamedSubjects gets the list of subjects that show up in the current named policy. // GetAllNamedSubjects gets the list of subjects that show up in the current named policy.
func (e *Enforcer) GetAllNamedSubjects(ptype string) ([]string, error) { func (e *Enforcer) GetAllNamedSubjects(ptype string) ([]string, error) {
return e.model.GetValuesForFieldInPolicy("p", ptype, 0) fieldIndex, err := e.model.GetFieldIndex(ptype, constant.SubjectIndex)
if err != nil {
return nil, err
}
return e.model.GetValuesForFieldInPolicy("p", ptype, fieldIndex)
} }
// GetAllObjects gets the list of objects that show up in the current policy. // GetAllObjects gets the list of objects that show up in the current policy.
func (e *Enforcer) GetAllObjects() ([]string, error) { func (e *Enforcer) GetAllObjects() ([]string, error) {
return e.model.GetValuesForFieldInPolicyAllTypes("p", 1) return e.model.GetValuesForFieldInPolicyAllTypesByName("p", constant.ObjectIndex)
} }
// GetAllNamedObjects gets the list of objects that show up in the current named policy. // GetAllNamedObjects gets the list of objects that show up in the current named policy.
func (e *Enforcer) GetAllNamedObjects(ptype string) ([]string, error) { func (e *Enforcer) GetAllNamedObjects(ptype string) ([]string, error) {
return e.model.GetValuesForFieldInPolicy("p", ptype, 1) fieldIndex, err := e.model.GetFieldIndex(ptype, constant.ObjectIndex)
if err != nil {
return nil, err
}
return e.model.GetValuesForFieldInPolicy("p", ptype, fieldIndex)
} }
// GetAllActions gets the list of actions that show up in the current policy. // GetAllActions gets the list of actions that show up in the current policy.
func (e *Enforcer) GetAllActions() ([]string, error) { func (e *Enforcer) GetAllActions() ([]string, error) {
return e.model.GetValuesForFieldInPolicyAllTypes("p", 2) return e.model.GetValuesForFieldInPolicyAllTypesByName("p", constant.ActionIndex)
} }
// GetAllNamedActions gets the list of actions that show up in the current named policy. // GetAllNamedActions gets the list of actions that show up in the current named policy.
func (e *Enforcer) GetAllNamedActions(ptype string) ([]string, error) { func (e *Enforcer) GetAllNamedActions(ptype string) ([]string, error) {
return e.model.GetValuesForFieldInPolicy("p", ptype, 2) fieldIndex, err := e.model.GetFieldIndex(ptype, constant.ActionIndex)
if err != nil {
return nil, err
}
return e.model.GetValuesForFieldInPolicy("p", ptype, fieldIndex)
} }
// GetAllRoles gets the list of roles that show up in the current policy. // GetAllRoles gets the list of roles that show up in the current policy.

View File

@@ -458,3 +458,25 @@ func (model Model) GetValuesForFieldInPolicyAllTypes(sec string, fieldIndex int)
return values, nil return values, nil
} }
// GetValuesForFieldInPolicyAllTypesByName gets all values for a field for all rules in a policy of all ptypes, duplicated values are removed.
func (model Model) GetValuesForFieldInPolicyAllTypesByName(sec string, field string) ([]string, error) {
values := []string{}
for ptype := range model[sec] {
// GetFieldIndex will return (-1, err) if field is not found, ignore it
index, err := model.GetFieldIndex(ptype, field)
if err != nil {
continue
}
v, err := model.GetValuesForFieldInPolicy(sec, ptype, index)
if err != nil {
return nil, err
}
values = append(values, v...)
}
util.ArrayRemoveDuplicates(&values)
return values, nil
}

View File

@@ -229,28 +229,53 @@ func (e *Enforcer) HasPermissionForUser(user string, permission ...string) (bool
// GetRolesForUser("alice") can only get: ["role:admin"]. // GetRolesForUser("alice") can only get: ["role:admin"].
// But GetImplicitRolesForUser("alice") will get: ["role:admin", "role:user"]. // But GetImplicitRolesForUser("alice") will get: ["role:admin", "role:user"].
func (e *Enforcer) GetImplicitRolesForUser(name string, domain ...string) ([]string, error) { func (e *Enforcer) GetImplicitRolesForUser(name string, domain ...string) ([]string, error) {
res := []string{} var res []string
for _, rm := range e.rmMap { for v := range e.rmMap {
roleSet := make(map[string]bool) roles, err := e.GetNamedImplicitRolesForUser(v, name, domain...)
roleSet[name] = true if err != nil {
q := make([]string, 0) return nil, err
q = append(q, name) }
res = append(res, roles...)
}
for len(q) > 0 { return res, nil
name := q[0] }
q = q[1:]
roles, err := rm.GetRoles(name, domain...) // GetNamedImplicitRolesForUser gets implicit roles that a user has by named role definition.
if err != nil { // Compared to GetImplicitRolesForUser(), this function retrieves indirect roles besides direct roles.
return nil, err // For example:
} // g, alice, role:admin
for _, r := range roles { // g, role:admin, role:user
if _, ok := roleSet[r]; !ok { // g2, alice, role:admin2
res = append(res, r) //
q = append(q, r) // GetImplicitRolesForUser("alice") can only get: ["role:admin", "role:user"].
roleSet[r] = true // But GetNamedImplicitRolesForUser("g2", "alice") will get: ["role:admin2"].
} func (e *Enforcer) GetNamedImplicitRolesForUser(ptype string, name string, domain ...string) ([]string, error) {
var res []string
rm := e.GetNamedRoleManager(ptype)
if rm == nil {
return nil, fmt.Errorf("role manager %s is not initialized", ptype)
}
roleSet := make(map[string]bool)
roleSet[name] = true
q := make([]string, 0)
q = append(q, name)
for len(q) > 0 {
name := q[0]
q = q[1:]
roles, err := rm.GetRoles(name, domain...)
if err != nil {
return nil, err
}
for _, r := range roles {
if _, ok := roleSet[r]; !ok {
res = append(res, r)
q = append(q, r)
roleSet[r] = true
} }
} }
} }
@@ -299,7 +324,7 @@ func (e *Enforcer) GetImplicitUsersForRole(name string, domain ...string) ([]str
// GetPermissionsForUser("alice") can only get: [["alice", "data2", "read"]]. // GetPermissionsForUser("alice") can only get: [["alice", "data2", "read"]].
// But GetImplicitPermissionsForUser("alice") will get: [["admin", "data1", "read"], ["alice", "data2", "read"]]. // But GetImplicitPermissionsForUser("alice") will get: [["admin", "data1", "read"], ["alice", "data2", "read"]].
func (e *Enforcer) GetImplicitPermissionsForUser(user string, domain ...string) ([][]string, error) { func (e *Enforcer) GetImplicitPermissionsForUser(user string, domain ...string) ([][]string, error) {
return e.GetNamedImplicitPermissionsForUser("p", user, domain...) return e.GetNamedImplicitPermissionsForUser("p", "g", user, domain...)
} }
// GetNamedImplicitPermissionsForUser gets implicit permissions for a user or role by named policy. // GetNamedImplicitPermissionsForUser gets implicit permissions for a user or role by named policy.
@@ -311,17 +336,27 @@ func (e *Enforcer) GetImplicitPermissionsForUser(user string, domain ...string)
// //
// GetImplicitPermissionsForUser("alice") can only get: [["admin", "data1", "read"]], whose policy is default policy "p" // GetImplicitPermissionsForUser("alice") can only get: [["admin", "data1", "read"]], whose policy is default policy "p"
// But you can specify the named policy "p2" to get: [["admin", "create"]] by GetNamedImplicitPermissionsForUser("p2","alice"). // But you can specify the named policy "p2" to get: [["admin", "create"]] by GetNamedImplicitPermissionsForUser("p2","alice").
func (e *Enforcer) GetNamedImplicitPermissionsForUser(ptype string, user string, domain ...string) ([][]string, error) { func (e *Enforcer) GetNamedImplicitPermissionsForUser(ptype string, gtype string, user string, domain ...string) ([][]string, error) {
permission := make([][]string, 0) permission := make([][]string, 0)
rm := e.GetRoleManager() rm := e.GetNamedRoleManager(gtype)
if rm == nil { if rm == nil {
return nil, fmt.Errorf("role manager is not initialized") return nil, fmt.Errorf("role manager %s is not initialized", gtype)
} }
domainIndex, _ := e.GetFieldIndex(ptype, constant.DomainIndex)
roles, err := e.GetNamedImplicitRolesForUser(gtype, user, domain...)
if err != nil {
return nil, err
}
policyRoles := make(map[string]struct{}, len(roles)+1)
policyRoles[user] = struct{}{}
for _, r := range roles {
policyRoles[r] = struct{}{}
}
domainIndex, err := e.GetFieldIndex(ptype, constant.DomainIndex)
for _, rule := range e.model["p"][ptype].Policy { for _, rule := range e.model["p"][ptype].Policy {
if len(domain) == 0 { if len(domain) == 0 {
matched, _ := rm.HasLink(user, rule[0]) if _, ok := policyRoles[rule[0]]; ok {
if matched {
permission = append(permission, deepCopyPolicy(rule)) permission = append(permission, deepCopyPolicy(rule))
} }
continue continue
@@ -329,13 +364,15 @@ func (e *Enforcer) GetNamedImplicitPermissionsForUser(ptype string, user string,
if len(domain) > 1 { if len(domain) > 1 {
return nil, errors.ErrDomainParameter return nil, errors.ErrDomainParameter
} }
if err != nil {
return nil, err
}
d := domain[0] d := domain[0]
matched := rm.Match(d, rule[domainIndex]) matched := rm.Match(d, rule[domainIndex])
if !matched { if !matched {
continue continue
} }
matched, _ = rm.HasLink(user, rule[0], d) if _, ok := policyRoles[rule[0]]; ok {
if matched {
newRule := deepCopyPolicy(rule) newRule := deepCopyPolicy(rule)
newRule[domainIndex] = d newRule[domainIndex] = d
permission = append(permission, newRule) permission = append(permission, newRule)

View File

@@ -182,10 +182,10 @@ func (e *SyncedEnforcer) GetImplicitPermissionsForUser(user string, domain ...st
// //
// GetImplicitPermissionsForUser("alice") can only get: [["admin", "data1", "read"]], whose policy is default policy "p" // GetImplicitPermissionsForUser("alice") can only get: [["admin", "data1", "read"]], whose policy is default policy "p"
// But you can specify the named policy "p2" to get: [["admin", "create"]] by GetNamedImplicitPermissionsForUser("p2","alice"). // But you can specify the named policy "p2" to get: [["admin", "create"]] by GetNamedImplicitPermissionsForUser("p2","alice").
func (e *SyncedEnforcer) GetNamedImplicitPermissionsForUser(ptype string, user string, domain ...string) ([][]string, error) { func (e *SyncedEnforcer) GetNamedImplicitPermissionsForUser(ptype string, gtype string, user string, domain ...string) ([][]string, error) {
e.m.RLock() e.m.RLock()
defer e.m.RUnlock() defer e.m.RUnlock()
return e.Enforcer.GetNamedImplicitPermissionsForUser(ptype, user, domain...) return e.Enforcer.GetNamedImplicitPermissionsForUser(ptype, gtype, user, domain...)
} }
// GetImplicitUsersForPermission gets implicit users for a permission. // GetImplicitUsersForPermission gets implicit users for a permission.

View File

@@ -355,7 +355,7 @@ func makeAccessorStage(pair []string) evaluationOperator {
field = coreValue.MapIndex(reflect.ValueOf(pair[i])) field = coreValue.MapIndex(reflect.ValueOf(pair[i]))
if field != (reflect.Value{}) { if field != (reflect.Value{}) {
inter := field.Interface() inter := field.Interface()
if reflect.TypeOf(inter).Kind() == reflect.Func { if inter != nil && reflect.TypeOf(inter).Kind() == reflect.Func {
method = reflect.ValueOf(inter) method = reflect.ValueOf(inter)
} else { } else {
value = inter value = inter

View File

@@ -1,7 +1,7 @@
Package validator Package validator
================= =================
<img align="right" src="logo.png">[![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) <img align="right" src="logo.png">[![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Project status](https://img.shields.io/badge/version-10.21.0-green.svg) ![Project status](https://img.shields.io/badge/version-10.22.0-green.svg)
[![Build Status](https://travis-ci.org/go-playground/validator.svg?branch=master)](https://travis-ci.org/go-playground/validator) [![Build Status](https://travis-ci.org/go-playground/validator.svg?branch=master)](https://travis-ci.org/go-playground/validator)
[![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/validator?branch=master) [![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/validator?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator) [![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator)

View File

@@ -253,7 +253,7 @@ func parseOneOfParam2(s string) []string {
oneofValsCacheRWLock.RUnlock() oneofValsCacheRWLock.RUnlock()
if !ok { if !ok {
oneofValsCacheRWLock.Lock() oneofValsCacheRWLock.Lock()
vals = splitParamsRegex.FindAllString(s, -1) vals = splitParamsRegex().FindAllString(s, -1)
for i := 0; i < len(vals); i++ { for i := 0; i < len(vals); i++ {
vals[i] = strings.Replace(vals[i], "'", "", -1) vals[i] = strings.Replace(vals[i], "'", "", -1)
} }
@@ -264,15 +264,15 @@ func parseOneOfParam2(s string) []string {
} }
func isURLEncoded(fl FieldLevel) bool { func isURLEncoded(fl FieldLevel) bool {
return uRLEncodedRegex.MatchString(fl.Field().String()) return uRLEncodedRegex().MatchString(fl.Field().String())
} }
func isHTMLEncoded(fl FieldLevel) bool { func isHTMLEncoded(fl FieldLevel) bool {
return hTMLEncodedRegex.MatchString(fl.Field().String()) return hTMLEncodedRegex().MatchString(fl.Field().String())
} }
func isHTML(fl FieldLevel) bool { func isHTML(fl FieldLevel) bool {
return hTMLRegex.MatchString(fl.Field().String()) return hTMLRegex().MatchString(fl.Field().String())
} }
func isOneOf(fl FieldLevel) bool { func isOneOf(fl FieldLevel) bool {
@@ -429,7 +429,7 @@ func isSSN(fl FieldLevel) bool {
return false return false
} }
return sSNRegex.MatchString(field.String()) return sSNRegex().MatchString(field.String())
} }
// isLongitude is the validation function for validating if the field's value is a valid longitude coordinate. // isLongitude is the validation function for validating if the field's value is a valid longitude coordinate.
@@ -452,7 +452,7 @@ func isLongitude(fl FieldLevel) bool {
panic(fmt.Sprintf("Bad field type %T", field.Interface())) panic(fmt.Sprintf("Bad field type %T", field.Interface()))
} }
return longitudeRegex.MatchString(v) return longitudeRegex().MatchString(v)
} }
// isLatitude is the validation function for validating if the field's value is a valid latitude coordinate. // isLatitude is the validation function for validating if the field's value is a valid latitude coordinate.
@@ -475,7 +475,7 @@ func isLatitude(fl FieldLevel) bool {
panic(fmt.Sprintf("Bad field type %T", field.Interface())) panic(fmt.Sprintf("Bad field type %T", field.Interface()))
} }
return latitudeRegex.MatchString(v) return latitudeRegex().MatchString(v)
} }
// isDataURI is the validation function for validating if the field's value is a valid data URI. // isDataURI is the validation function for validating if the field's value is a valid data URI.
@@ -486,11 +486,11 @@ func isDataURI(fl FieldLevel) bool {
return false return false
} }
if !dataURIRegex.MatchString(uri[0]) { if !dataURIRegex().MatchString(uri[0]) {
return false return false
} }
return base64Regex.MatchString(uri[1]) return base64Regex().MatchString(uri[1])
} }
// hasMultiByteCharacter is the validation function for validating if the field's value has a multi byte character. // hasMultiByteCharacter is the validation function for validating if the field's value has a multi byte character.
@@ -501,17 +501,17 @@ func hasMultiByteCharacter(fl FieldLevel) bool {
return true return true
} }
return multibyteRegex.MatchString(field.String()) return multibyteRegex().MatchString(field.String())
} }
// isPrintableASCII is the validation function for validating if the field's value is a valid printable ASCII character. // isPrintableASCII is the validation function for validating if the field's value is a valid printable ASCII character.
func isPrintableASCII(fl FieldLevel) bool { func isPrintableASCII(fl FieldLevel) bool {
return printableASCIIRegex.MatchString(fl.Field().String()) return printableASCIIRegex().MatchString(fl.Field().String())
} }
// isASCII is the validation function for validating if the field's value is a valid ASCII character. // isASCII is the validation function for validating if the field's value is a valid ASCII character.
func isASCII(fl FieldLevel) bool { func isASCII(fl FieldLevel) bool {
return aSCIIRegex.MatchString(fl.Field().String()) return aSCIIRegex().MatchString(fl.Field().String())
} }
// isUUID5 is the validation function for validating if the field's value is a valid v5 UUID. // isUUID5 is the validation function for validating if the field's value is a valid v5 UUID.
@@ -561,52 +561,52 @@ func isULID(fl FieldLevel) bool {
// isMD4 is the validation function for validating if the field's value is a valid MD4. // isMD4 is the validation function for validating if the field's value is a valid MD4.
func isMD4(fl FieldLevel) bool { func isMD4(fl FieldLevel) bool {
return md4Regex.MatchString(fl.Field().String()) return md4Regex().MatchString(fl.Field().String())
} }
// isMD5 is the validation function for validating if the field's value is a valid MD5. // isMD5 is the validation function for validating if the field's value is a valid MD5.
func isMD5(fl FieldLevel) bool { func isMD5(fl FieldLevel) bool {
return md5Regex.MatchString(fl.Field().String()) return md5Regex().MatchString(fl.Field().String())
} }
// isSHA256 is the validation function for validating if the field's value is a valid SHA256. // isSHA256 is the validation function for validating if the field's value is a valid SHA256.
func isSHA256(fl FieldLevel) bool { func isSHA256(fl FieldLevel) bool {
return sha256Regex.MatchString(fl.Field().String()) return sha256Regex().MatchString(fl.Field().String())
} }
// isSHA384 is the validation function for validating if the field's value is a valid SHA384. // isSHA384 is the validation function for validating if the field's value is a valid SHA384.
func isSHA384(fl FieldLevel) bool { func isSHA384(fl FieldLevel) bool {
return sha384Regex.MatchString(fl.Field().String()) return sha384Regex().MatchString(fl.Field().String())
} }
// isSHA512 is the validation function for validating if the field's value is a valid SHA512. // isSHA512 is the validation function for validating if the field's value is a valid SHA512.
func isSHA512(fl FieldLevel) bool { func isSHA512(fl FieldLevel) bool {
return sha512Regex.MatchString(fl.Field().String()) return sha512Regex().MatchString(fl.Field().String())
} }
// isRIPEMD128 is the validation function for validating if the field's value is a valid PIPEMD128. // isRIPEMD128 is the validation function for validating if the field's value is a valid PIPEMD128.
func isRIPEMD128(fl FieldLevel) bool { func isRIPEMD128(fl FieldLevel) bool {
return ripemd128Regex.MatchString(fl.Field().String()) return ripemd128Regex().MatchString(fl.Field().String())
} }
// isRIPEMD160 is the validation function for validating if the field's value is a valid PIPEMD160. // isRIPEMD160 is the validation function for validating if the field's value is a valid PIPEMD160.
func isRIPEMD160(fl FieldLevel) bool { func isRIPEMD160(fl FieldLevel) bool {
return ripemd160Regex.MatchString(fl.Field().String()) return ripemd160Regex().MatchString(fl.Field().String())
} }
// isTIGER128 is the validation function for validating if the field's value is a valid TIGER128. // isTIGER128 is the validation function for validating if the field's value is a valid TIGER128.
func isTIGER128(fl FieldLevel) bool { func isTIGER128(fl FieldLevel) bool {
return tiger128Regex.MatchString(fl.Field().String()) return tiger128Regex().MatchString(fl.Field().String())
} }
// isTIGER160 is the validation function for validating if the field's value is a valid TIGER160. // isTIGER160 is the validation function for validating if the field's value is a valid TIGER160.
func isTIGER160(fl FieldLevel) bool { func isTIGER160(fl FieldLevel) bool {
return tiger160Regex.MatchString(fl.Field().String()) return tiger160Regex().MatchString(fl.Field().String())
} }
// isTIGER192 is the validation function for validating if the field's value is a valid isTIGER192. // isTIGER192 is the validation function for validating if the field's value is a valid isTIGER192.
func isTIGER192(fl FieldLevel) bool { func isTIGER192(fl FieldLevel) bool {
return tiger192Regex.MatchString(fl.Field().String()) return tiger192Regex().MatchString(fl.Field().String())
} }
// isISBN is the validation function for validating if the field's value is a valid v10 or v13 ISBN. // isISBN is the validation function for validating if the field's value is a valid v10 or v13 ISBN.
@@ -618,7 +618,7 @@ func isISBN(fl FieldLevel) bool {
func isISBN13(fl FieldLevel) bool { func isISBN13(fl FieldLevel) bool {
s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 4), " ", "", 4) s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 4), " ", "", 4)
if !iSBN13Regex.MatchString(s) { if !iSBN13Regex().MatchString(s) {
return false return false
} }
@@ -638,7 +638,7 @@ func isISBN13(fl FieldLevel) bool {
func isISBN10(fl FieldLevel) bool { func isISBN10(fl FieldLevel) bool {
s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 3), " ", "", 3) s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 3), " ", "", 3)
if !iSBN10Regex.MatchString(s) { if !iSBN10Regex().MatchString(s) {
return false return false
} }
@@ -662,7 +662,7 @@ func isISBN10(fl FieldLevel) bool {
func isISSN(fl FieldLevel) bool { func isISSN(fl FieldLevel) bool {
s := fl.Field().String() s := fl.Field().String()
if !iSSNRegex.MatchString(s) { if !iSSNRegex().MatchString(s) {
return false return false
} }
s = strings.ReplaceAll(s, "-", "") s = strings.ReplaceAll(s, "-", "")
@@ -688,14 +688,14 @@ func isISSN(fl FieldLevel) bool {
func isEthereumAddress(fl FieldLevel) bool { func isEthereumAddress(fl FieldLevel) bool {
address := fl.Field().String() address := fl.Field().String()
return ethAddressRegex.MatchString(address) return ethAddressRegex().MatchString(address)
} }
// isEthereumAddressChecksum is the validation function for validating if the field's value is a valid checksummed Ethereum address. // isEthereumAddressChecksum is the validation function for validating if the field's value is a valid checksummed Ethereum address.
func isEthereumAddressChecksum(fl FieldLevel) bool { func isEthereumAddressChecksum(fl FieldLevel) bool {
address := fl.Field().String() address := fl.Field().String()
if !ethAddressRegex.MatchString(address) { if !ethAddressRegex().MatchString(address) {
return false return false
} }
// Checksum validation. Reference: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md // Checksum validation. Reference: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
@@ -721,7 +721,7 @@ func isEthereumAddressChecksum(fl FieldLevel) bool {
func isBitcoinAddress(fl FieldLevel) bool { func isBitcoinAddress(fl FieldLevel) bool {
address := fl.Field().String() address := fl.Field().String()
if !btcAddressRegex.MatchString(address) { if !btcAddressRegex().MatchString(address) {
return false return false
} }
@@ -758,7 +758,7 @@ func isBitcoinAddress(fl FieldLevel) bool {
func isBitcoinBech32Address(fl FieldLevel) bool { func isBitcoinBech32Address(fl FieldLevel) bool {
address := fl.Field().String() address := fl.Field().String()
if !btcLowerAddressRegexBech32.MatchString(address) && !btcUpperAddressRegexBech32.MatchString(address) { if !btcLowerAddressRegexBech32().MatchString(address) && !btcUpperAddressRegexBech32().MatchString(address) {
return false return false
} }
@@ -1370,6 +1370,7 @@ func isPostcodeByIso3166Alpha2(fl FieldLevel) bool {
field := fl.Field() field := fl.Field()
param := fl.Param() param := fl.Param()
postcodeRegexInit.Do(initPostcodes)
reg, found := postCodeRegexDict[param] reg, found := postCodeRegexDict[param]
if !found { if !found {
return false return false
@@ -1407,22 +1408,22 @@ func isPostcodeByIso3166Alpha2Field(fl FieldLevel) bool {
// isBase32 is the validation function for validating if the current field's value is a valid base 32. // isBase32 is the validation function for validating if the current field's value is a valid base 32.
func isBase32(fl FieldLevel) bool { func isBase32(fl FieldLevel) bool {
return base32Regex.MatchString(fl.Field().String()) return base32Regex().MatchString(fl.Field().String())
} }
// isBase64 is the validation function for validating if the current field's value is a valid base 64. // isBase64 is the validation function for validating if the current field's value is a valid base 64.
func isBase64(fl FieldLevel) bool { func isBase64(fl FieldLevel) bool {
return base64Regex.MatchString(fl.Field().String()) return base64Regex().MatchString(fl.Field().String())
} }
// isBase64URL is the validation function for validating if the current field's value is a valid base64 URL safe string. // isBase64URL is the validation function for validating if the current field's value is a valid base64 URL safe string.
func isBase64URL(fl FieldLevel) bool { func isBase64URL(fl FieldLevel) bool {
return base64URLRegex.MatchString(fl.Field().String()) return base64URLRegex().MatchString(fl.Field().String())
} }
// isBase64RawURL is the validation function for validating if the current field's value is a valid base64 URL safe string without '=' padding. // isBase64RawURL is the validation function for validating if the current field's value is a valid base64 URL safe string without '=' padding.
func isBase64RawURL(fl FieldLevel) bool { func isBase64RawURL(fl FieldLevel) bool {
return base64RawURLRegex.MatchString(fl.Field().String()) return base64RawURLRegex().MatchString(fl.Field().String())
} }
// isURI is the validation function for validating if the current field's value is a valid URI. // isURI is the validation function for validating if the current field's value is a valid URI.
@@ -1668,42 +1669,42 @@ func isFilePath(fl FieldLevel) bool {
// isE164 is the validation function for validating if the current field's value is a valid e.164 formatted phone number. // isE164 is the validation function for validating if the current field's value is a valid e.164 formatted phone number.
func isE164(fl FieldLevel) bool { func isE164(fl FieldLevel) bool {
return e164Regex.MatchString(fl.Field().String()) return e164Regex().MatchString(fl.Field().String())
} }
// isEmail is the validation function for validating if the current field's value is a valid email address. // isEmail is the validation function for validating if the current field's value is a valid email address.
func isEmail(fl FieldLevel) bool { func isEmail(fl FieldLevel) bool {
return emailRegex.MatchString(fl.Field().String()) return emailRegex().MatchString(fl.Field().String())
} }
// isHSLA is the validation function for validating if the current field's value is a valid HSLA color. // isHSLA is the validation function for validating if the current field's value is a valid HSLA color.
func isHSLA(fl FieldLevel) bool { func isHSLA(fl FieldLevel) bool {
return hslaRegex.MatchString(fl.Field().String()) return hslaRegex().MatchString(fl.Field().String())
} }
// isHSL is the validation function for validating if the current field's value is a valid HSL color. // isHSL is the validation function for validating if the current field's value is a valid HSL color.
func isHSL(fl FieldLevel) bool { func isHSL(fl FieldLevel) bool {
return hslRegex.MatchString(fl.Field().String()) return hslRegex().MatchString(fl.Field().String())
} }
// isRGBA is the validation function for validating if the current field's value is a valid RGBA color. // isRGBA is the validation function for validating if the current field's value is a valid RGBA color.
func isRGBA(fl FieldLevel) bool { func isRGBA(fl FieldLevel) bool {
return rgbaRegex.MatchString(fl.Field().String()) return rgbaRegex().MatchString(fl.Field().String())
} }
// isRGB is the validation function for validating if the current field's value is a valid RGB color. // isRGB is the validation function for validating if the current field's value is a valid RGB color.
func isRGB(fl FieldLevel) bool { func isRGB(fl FieldLevel) bool {
return rgbRegex.MatchString(fl.Field().String()) return rgbRegex().MatchString(fl.Field().String())
} }
// isHEXColor is the validation function for validating if the current field's value is a valid HEX color. // isHEXColor is the validation function for validating if the current field's value is a valid HEX color.
func isHEXColor(fl FieldLevel) bool { func isHEXColor(fl FieldLevel) bool {
return hexColorRegex.MatchString(fl.Field().String()) return hexColorRegex().MatchString(fl.Field().String())
} }
// isHexadecimal is the validation function for validating if the current field's value is a valid hexadecimal. // isHexadecimal is the validation function for validating if the current field's value is a valid hexadecimal.
func isHexadecimal(fl FieldLevel) bool { func isHexadecimal(fl FieldLevel) bool {
return hexadecimalRegex.MatchString(fl.Field().String()) return hexadecimalRegex().MatchString(fl.Field().String())
} }
// isNumber is the validation function for validating if the current field's value is a valid number. // isNumber is the validation function for validating if the current field's value is a valid number.
@@ -1712,7 +1713,7 @@ func isNumber(fl FieldLevel) bool {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64: case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64:
return true return true
default: default:
return numberRegex.MatchString(fl.Field().String()) return numberRegex().MatchString(fl.Field().String())
} }
} }
@@ -1722,28 +1723,28 @@ func isNumeric(fl FieldLevel) bool {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64: case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64:
return true return true
default: default:
return numericRegex.MatchString(fl.Field().String()) return numericRegex().MatchString(fl.Field().String())
} }
} }
// isAlphanum is the validation function for validating if the current field's value is a valid alphanumeric value. // isAlphanum is the validation function for validating if the current field's value is a valid alphanumeric value.
func isAlphanum(fl FieldLevel) bool { func isAlphanum(fl FieldLevel) bool {
return alphaNumericRegex.MatchString(fl.Field().String()) return alphaNumericRegex().MatchString(fl.Field().String())
} }
// isAlpha is the validation function for validating if the current field's value is a valid alpha value. // isAlpha is the validation function for validating if the current field's value is a valid alpha value.
func isAlpha(fl FieldLevel) bool { func isAlpha(fl FieldLevel) bool {
return alphaRegex.MatchString(fl.Field().String()) return alphaRegex().MatchString(fl.Field().String())
} }
// isAlphanumUnicode is the validation function for validating if the current field's value is a valid alphanumeric unicode value. // isAlphanumUnicode is the validation function for validating if the current field's value is a valid alphanumeric unicode value.
func isAlphanumUnicode(fl FieldLevel) bool { func isAlphanumUnicode(fl FieldLevel) bool {
return alphaUnicodeNumericRegex.MatchString(fl.Field().String()) return alphaUnicodeNumericRegex().MatchString(fl.Field().String())
} }
// isAlphaUnicode is the validation function for validating if the current field's value is a valid alpha unicode value. // isAlphaUnicode is the validation function for validating if the current field's value is a valid alpha unicode value.
func isAlphaUnicode(fl FieldLevel) bool { func isAlphaUnicode(fl FieldLevel) bool {
return alphaUnicodeRegex.MatchString(fl.Field().String()) return alphaUnicodeRegex().MatchString(fl.Field().String())
} }
// isBoolean is the validation function for validating if the current field's value is a valid boolean value or can be safely converted to a boolean value. // isBoolean is the validation function for validating if the current field's value is a valid boolean value or can be safely converted to a boolean value.
@@ -2566,11 +2567,11 @@ func isIP6Addr(fl FieldLevel) bool {
} }
func isHostnameRFC952(fl FieldLevel) bool { func isHostnameRFC952(fl FieldLevel) bool {
return hostnameRegexRFC952.MatchString(fl.Field().String()) return hostnameRegexRFC952().MatchString(fl.Field().String())
} }
func isHostnameRFC1123(fl FieldLevel) bool { func isHostnameRFC1123(fl FieldLevel) bool {
return hostnameRegexRFC1123.MatchString(fl.Field().String()) return hostnameRegexRFC1123().MatchString(fl.Field().String())
} }
func isFQDN(fl FieldLevel) bool { func isFQDN(fl FieldLevel) bool {
@@ -2580,7 +2581,7 @@ func isFQDN(fl FieldLevel) bool {
return false return false
} }
return fqdnRegexRFC1123.MatchString(val) return fqdnRegexRFC1123().MatchString(val)
} }
// isDir is the validation function for validating if the current field's value is a valid existing directory. // isDir is the validation function for validating if the current field's value is a valid existing directory.
@@ -2679,7 +2680,7 @@ func isJSON(fl FieldLevel) bool {
// isJWT is the validation function for validating if the current field's value is a valid JWT string. // isJWT is the validation function for validating if the current field's value is a valid JWT string.
func isJWT(fl FieldLevel) bool { func isJWT(fl FieldLevel) bool {
return jWTRegex.MatchString(fl.Field().String()) return jWTRegex().MatchString(fl.Field().String())
} }
// isHostnamePort validates a <dns>:<port> combination for fields typically used for socket address. // isHostnamePort validates a <dns>:<port> combination for fields typically used for socket address.
@@ -2698,7 +2699,7 @@ func isHostnamePort(fl FieldLevel) bool {
// If host is specified, it should match a DNS name // If host is specified, it should match a DNS name
if host != "" { if host != "" {
return hostnameRegexRFC1123.MatchString(host) return hostnameRegexRFC1123().MatchString(host)
} }
return true return true
} }
@@ -2885,21 +2886,21 @@ func isBCP47LanguageTag(fl FieldLevel) bool {
func isIsoBicFormat(fl FieldLevel) bool { func isIsoBicFormat(fl FieldLevel) bool {
bicString := fl.Field().String() bicString := fl.Field().String()
return bicRegex.MatchString(bicString) return bicRegex().MatchString(bicString)
} }
// isSemverFormat is the validation function for validating if the current field's value is a valid semver version, defined in Semantic Versioning 2.0.0 // isSemverFormat is the validation function for validating if the current field's value is a valid semver version, defined in Semantic Versioning 2.0.0
func isSemverFormat(fl FieldLevel) bool { func isSemverFormat(fl FieldLevel) bool {
semverString := fl.Field().String() semverString := fl.Field().String()
return semverRegex.MatchString(semverString) return semverRegex().MatchString(semverString)
} }
// isCveFormat is the validation function for validating if the current field's value is a valid cve id, defined in CVE mitre org // isCveFormat is the validation function for validating if the current field's value is a valid cve id, defined in CVE mitre org
func isCveFormat(fl FieldLevel) bool { func isCveFormat(fl FieldLevel) bool {
cveString := fl.Field().String() cveString := fl.Field().String()
return cveRegex.MatchString(cveString) return cveRegex().MatchString(cveString)
} }
// isDnsRFC1035LabelFormat is the validation function // isDnsRFC1035LabelFormat is the validation function
@@ -2907,7 +2908,7 @@ func isCveFormat(fl FieldLevel) bool {
// a valid dns RFC 1035 label, defined in RFC 1035. // a valid dns RFC 1035 label, defined in RFC 1035.
func isDnsRFC1035LabelFormat(fl FieldLevel) bool { func isDnsRFC1035LabelFormat(fl FieldLevel) bool {
val := fl.Field().String() val := fl.Field().String()
return dnsRegexRFC1035Label.MatchString(val) return dnsRegexRFC1035Label().MatchString(val)
} }
// digitsHaveLuhnChecksum returns true if and only if the last element of the given digits slice is the Luhn checksum of the previous elements // digitsHaveLuhnChecksum returns true if and only if the last element of the given digits slice is the Luhn checksum of the previous elements
@@ -2936,13 +2937,13 @@ func digitsHaveLuhnChecksum(digits []string) bool {
// isMongoDBObjectId is the validation function for validating if the current field's value is valid MongoDB ObjectID // isMongoDBObjectId is the validation function for validating if the current field's value is valid MongoDB ObjectID
func isMongoDBObjectId(fl FieldLevel) bool { func isMongoDBObjectId(fl FieldLevel) bool {
val := fl.Field().String() val := fl.Field().String()
return mongodbIdRegex.MatchString(val) return mongodbIdRegex().MatchString(val)
} }
// isMongoDBConnectionString is the validation function for validating if the current field's value is valid MongoDB Connection String // isMongoDBConnectionString is the validation function for validating if the current field's value is valid MongoDB Connection String
func isMongoDBConnectionString(fl FieldLevel) bool { func isMongoDBConnectionString(fl FieldLevel) bool {
val := fl.Field().String() val := fl.Field().String()
return mongodbConnectionRegex.MatchString(val) return mongodbConnectionRegex().MatchString(val)
} }
// isSpiceDB is the validation function for validating if the current field's value is valid for use with Authzed SpiceDB in the indicated way // isSpiceDB is the validation function for validating if the current field's value is valid for use with Authzed SpiceDB in the indicated way
@@ -2952,11 +2953,11 @@ func isSpiceDB(fl FieldLevel) bool {
switch param { switch param {
case "permission": case "permission":
return spicedbPermissionRegex.MatchString(val) return spicedbPermissionRegex().MatchString(val)
case "type": case "type":
return spicedbTypeRegex.MatchString(val) return spicedbTypeRegex().MatchString(val)
case "id", "": case "id", "":
return spicedbIDRegex.MatchString(val) return spicedbIDRegex().MatchString(val)
} }
panic("Unrecognized parameter: " + param) panic("Unrecognized parameter: " + param)
@@ -3008,5 +3009,5 @@ func hasLuhnChecksum(fl FieldLevel) bool {
// isCron is the validation function for validating if the current field's value is a valid cron expression // isCron is the validation function for validating if the current field's value is a valid cron expression
func isCron(fl FieldLevel) bool { func isCron(fl FieldLevel) bool {
cronString := fl.Field().String() cronString := fl.Field().String()
return cronRegex.MatchString(cronString) return cronRegex().MatchString(cronString)
} }

View File

@@ -1,6 +1,9 @@
package validator package validator
import "regexp" import (
"regexp"
"sync"
)
var postCodePatternDict = map[string]string{ var postCodePatternDict = map[string]string{
"GB": `^GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}$`, "GB": `^GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}$`,
@@ -164,9 +167,12 @@ var postCodePatternDict = map[string]string{
"YT": `^976\d{2}$`, "YT": `^976\d{2}$`,
} }
var postCodeRegexDict = map[string]*regexp.Regexp{} var (
postcodeRegexInit sync.Once
postCodeRegexDict = map[string]*regexp.Regexp{}
)
func init() { func initPostcodes() {
for countryCode, pattern := range postCodePatternDict { for countryCode, pattern := range postCodePatternDict {
postCodeRegexDict[countryCode] = regexp.MustCompile(pattern) postCodeRegexDict[countryCode] = regexp.MustCompile(pattern)
} }

View File

@@ -1,6 +1,9 @@
package validator package validator
import "regexp" import (
"regexp"
"sync"
)
const ( const (
alphaRegexString = "^[a-zA-Z]+$" alphaRegexString = "^[a-zA-Z]+$"
@@ -76,74 +79,85 @@ const (
spicedbTypeRegexString = "^([a-z][a-z0-9_]{1,61}[a-z0-9]/)?[a-z][a-z0-9_]{1,62}[a-z0-9]$" spicedbTypeRegexString = "^([a-z][a-z0-9_]{1,61}[a-z0-9]/)?[a-z][a-z0-9_]{1,62}[a-z0-9]$"
) )
func lazyRegexCompile(str string) func() *regexp.Regexp {
var regex *regexp.Regexp
var once sync.Once
return func() *regexp.Regexp {
once.Do(func() {
regex = regexp.MustCompile(str)
})
return regex
}
}
var ( var (
alphaRegex = regexp.MustCompile(alphaRegexString) alphaRegex = lazyRegexCompile(alphaRegexString)
alphaNumericRegex = regexp.MustCompile(alphaNumericRegexString) alphaNumericRegex = lazyRegexCompile(alphaNumericRegexString)
alphaUnicodeRegex = regexp.MustCompile(alphaUnicodeRegexString) alphaUnicodeRegex = lazyRegexCompile(alphaUnicodeRegexString)
alphaUnicodeNumericRegex = regexp.MustCompile(alphaUnicodeNumericRegexString) alphaUnicodeNumericRegex = lazyRegexCompile(alphaUnicodeNumericRegexString)
numericRegex = regexp.MustCompile(numericRegexString) numericRegex = lazyRegexCompile(numericRegexString)
numberRegex = regexp.MustCompile(numberRegexString) numberRegex = lazyRegexCompile(numberRegexString)
hexadecimalRegex = regexp.MustCompile(hexadecimalRegexString) hexadecimalRegex = lazyRegexCompile(hexadecimalRegexString)
hexColorRegex = regexp.MustCompile(hexColorRegexString) hexColorRegex = lazyRegexCompile(hexColorRegexString)
rgbRegex = regexp.MustCompile(rgbRegexString) rgbRegex = lazyRegexCompile(rgbRegexString)
rgbaRegex = regexp.MustCompile(rgbaRegexString) rgbaRegex = lazyRegexCompile(rgbaRegexString)
hslRegex = regexp.MustCompile(hslRegexString) hslRegex = lazyRegexCompile(hslRegexString)
hslaRegex = regexp.MustCompile(hslaRegexString) hslaRegex = lazyRegexCompile(hslaRegexString)
e164Regex = regexp.MustCompile(e164RegexString) e164Regex = lazyRegexCompile(e164RegexString)
emailRegex = regexp.MustCompile(emailRegexString) emailRegex = lazyRegexCompile(emailRegexString)
base32Regex = regexp.MustCompile(base32RegexString) base32Regex = lazyRegexCompile(base32RegexString)
base64Regex = regexp.MustCompile(base64RegexString) base64Regex = lazyRegexCompile(base64RegexString)
base64URLRegex = regexp.MustCompile(base64URLRegexString) base64URLRegex = lazyRegexCompile(base64URLRegexString)
base64RawURLRegex = regexp.MustCompile(base64RawURLRegexString) base64RawURLRegex = lazyRegexCompile(base64RawURLRegexString)
iSBN10Regex = regexp.MustCompile(iSBN10RegexString) iSBN10Regex = lazyRegexCompile(iSBN10RegexString)
iSBN13Regex = regexp.MustCompile(iSBN13RegexString) iSBN13Regex = lazyRegexCompile(iSBN13RegexString)
iSSNRegex = regexp.MustCompile(iSSNRegexString) iSSNRegex = lazyRegexCompile(iSSNRegexString)
uUID3Regex = regexp.MustCompile(uUID3RegexString) uUID3Regex = lazyRegexCompile(uUID3RegexString)
uUID4Regex = regexp.MustCompile(uUID4RegexString) uUID4Regex = lazyRegexCompile(uUID4RegexString)
uUID5Regex = regexp.MustCompile(uUID5RegexString) uUID5Regex = lazyRegexCompile(uUID5RegexString)
uUIDRegex = regexp.MustCompile(uUIDRegexString) uUIDRegex = lazyRegexCompile(uUIDRegexString)
uUID3RFC4122Regex = regexp.MustCompile(uUID3RFC4122RegexString) uUID3RFC4122Regex = lazyRegexCompile(uUID3RFC4122RegexString)
uUID4RFC4122Regex = regexp.MustCompile(uUID4RFC4122RegexString) uUID4RFC4122Regex = lazyRegexCompile(uUID4RFC4122RegexString)
uUID5RFC4122Regex = regexp.MustCompile(uUID5RFC4122RegexString) uUID5RFC4122Regex = lazyRegexCompile(uUID5RFC4122RegexString)
uUIDRFC4122Regex = regexp.MustCompile(uUIDRFC4122RegexString) uUIDRFC4122Regex = lazyRegexCompile(uUIDRFC4122RegexString)
uLIDRegex = regexp.MustCompile(uLIDRegexString) uLIDRegex = lazyRegexCompile(uLIDRegexString)
md4Regex = regexp.MustCompile(md4RegexString) md4Regex = lazyRegexCompile(md4RegexString)
md5Regex = regexp.MustCompile(md5RegexString) md5Regex = lazyRegexCompile(md5RegexString)
sha256Regex = regexp.MustCompile(sha256RegexString) sha256Regex = lazyRegexCompile(sha256RegexString)
sha384Regex = regexp.MustCompile(sha384RegexString) sha384Regex = lazyRegexCompile(sha384RegexString)
sha512Regex = regexp.MustCompile(sha512RegexString) sha512Regex = lazyRegexCompile(sha512RegexString)
ripemd128Regex = regexp.MustCompile(ripemd128RegexString) ripemd128Regex = lazyRegexCompile(ripemd128RegexString)
ripemd160Regex = regexp.MustCompile(ripemd160RegexString) ripemd160Regex = lazyRegexCompile(ripemd160RegexString)
tiger128Regex = regexp.MustCompile(tiger128RegexString) tiger128Regex = lazyRegexCompile(tiger128RegexString)
tiger160Regex = regexp.MustCompile(tiger160RegexString) tiger160Regex = lazyRegexCompile(tiger160RegexString)
tiger192Regex = regexp.MustCompile(tiger192RegexString) tiger192Regex = lazyRegexCompile(tiger192RegexString)
aSCIIRegex = regexp.MustCompile(aSCIIRegexString) aSCIIRegex = lazyRegexCompile(aSCIIRegexString)
printableASCIIRegex = regexp.MustCompile(printableASCIIRegexString) printableASCIIRegex = lazyRegexCompile(printableASCIIRegexString)
multibyteRegex = regexp.MustCompile(multibyteRegexString) multibyteRegex = lazyRegexCompile(multibyteRegexString)
dataURIRegex = regexp.MustCompile(dataURIRegexString) dataURIRegex = lazyRegexCompile(dataURIRegexString)
latitudeRegex = regexp.MustCompile(latitudeRegexString) latitudeRegex = lazyRegexCompile(latitudeRegexString)
longitudeRegex = regexp.MustCompile(longitudeRegexString) longitudeRegex = lazyRegexCompile(longitudeRegexString)
sSNRegex = regexp.MustCompile(sSNRegexString) sSNRegex = lazyRegexCompile(sSNRegexString)
hostnameRegexRFC952 = regexp.MustCompile(hostnameRegexStringRFC952) hostnameRegexRFC952 = lazyRegexCompile(hostnameRegexStringRFC952)
hostnameRegexRFC1123 = regexp.MustCompile(hostnameRegexStringRFC1123) hostnameRegexRFC1123 = lazyRegexCompile(hostnameRegexStringRFC1123)
fqdnRegexRFC1123 = regexp.MustCompile(fqdnRegexStringRFC1123) fqdnRegexRFC1123 = lazyRegexCompile(fqdnRegexStringRFC1123)
btcAddressRegex = regexp.MustCompile(btcAddressRegexString) btcAddressRegex = lazyRegexCompile(btcAddressRegexString)
btcUpperAddressRegexBech32 = regexp.MustCompile(btcAddressUpperRegexStringBech32) btcUpperAddressRegexBech32 = lazyRegexCompile(btcAddressUpperRegexStringBech32)
btcLowerAddressRegexBech32 = regexp.MustCompile(btcAddressLowerRegexStringBech32) btcLowerAddressRegexBech32 = lazyRegexCompile(btcAddressLowerRegexStringBech32)
ethAddressRegex = regexp.MustCompile(ethAddressRegexString) ethAddressRegex = lazyRegexCompile(ethAddressRegexString)
uRLEncodedRegex = regexp.MustCompile(uRLEncodedRegexString) uRLEncodedRegex = lazyRegexCompile(uRLEncodedRegexString)
hTMLEncodedRegex = regexp.MustCompile(hTMLEncodedRegexString) hTMLEncodedRegex = lazyRegexCompile(hTMLEncodedRegexString)
hTMLRegex = regexp.MustCompile(hTMLRegexString) hTMLRegex = lazyRegexCompile(hTMLRegexString)
jWTRegex = regexp.MustCompile(jWTRegexString) jWTRegex = lazyRegexCompile(jWTRegexString)
splitParamsRegex = regexp.MustCompile(splitParamsRegexString) splitParamsRegex = lazyRegexCompile(splitParamsRegexString)
bicRegex = regexp.MustCompile(bicRegexString) bicRegex = lazyRegexCompile(bicRegexString)
semverRegex = regexp.MustCompile(semverRegexString) semverRegex = lazyRegexCompile(semverRegexString)
dnsRegexRFC1035Label = regexp.MustCompile(dnsRegexStringRFC1035Label) dnsRegexRFC1035Label = lazyRegexCompile(dnsRegexStringRFC1035Label)
cveRegex = regexp.MustCompile(cveRegexString) cveRegex = lazyRegexCompile(cveRegexString)
mongodbIdRegex = regexp.MustCompile(mongodbIdRegexString) mongodbIdRegex = lazyRegexCompile(mongodbIdRegexString)
mongodbConnectionRegex = regexp.MustCompile(mongodbConnStringRegexString) mongodbConnectionRegex = lazyRegexCompile(mongodbConnStringRegexString)
cronRegex = regexp.MustCompile(cronRegexString) cronRegex = lazyRegexCompile(cronRegexString)
spicedbIDRegex = regexp.MustCompile(spicedbIDRegexString) spicedbIDRegex = lazyRegexCompile(spicedbIDRegexString)
spicedbPermissionRegex = regexp.MustCompile(spicedbPermissionRegexString) spicedbPermissionRegex = lazyRegexCompile(spicedbPermissionRegexString)
spicedbTypeRegex = regexp.MustCompile(spicedbTypeRegexString) spicedbTypeRegex = lazyRegexCompile(spicedbTypeRegexString)
) )

View File

@@ -297,7 +297,8 @@ func panicIf(err error) {
// Checks if field value matches regex. If fl.Field can be cast to Stringer, it uses the Stringer interfaces // Checks if field value matches regex. If fl.Field can be cast to Stringer, it uses the Stringer interfaces
// String() return value. Otherwise, it uses fl.Field's String() value. // String() return value. Otherwise, it uses fl.Field's String() value.
func fieldMatchesRegexByStringerValOrString(regex *regexp.Regexp, fl FieldLevel) bool { func fieldMatchesRegexByStringerValOrString(regexFn func() *regexp.Regexp, fl FieldLevel) bool {
regex := regexFn()
switch fl.Field().Kind() { switch fl.Field().Kind() {
case reflect.String: case reflect.String:
return regex.MatchString(fl.Field().String()) return regex.MatchString(fl.Field().String())

View File

@@ -1,20 +0,0 @@
; https://editorconfig.org/
root = true
[*]
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
[{Makefile,go.mod,go.sum,*.go,.gitmodules}]
indent_style = tab
indent_size = 4
[*.md]
indent_size = 4
trim_trailing_whitespace = false
eclint_indent_style = unset

View File

@@ -1 +1,25 @@
coverage.coverprofile # Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
.idea/
*.iml

Some files were not shown because too many files have changed in this diff Show More