From 92803d4f70006721675381bdd788920ee0952ddc Mon Sep 17 00:00:00 2001 From: sliveryou Date: Wed, 6 Mar 2024 12:32:32 +0800 Subject: [PATCH] chore: upgrade dep --- .gitignore | 33 +++++++++++++++++---------------- Makefile | 2 +- go.mod | 4 ++-- go.sum | 8 ++++---- validator/validator_test.go | 14 ++++++++++++++ 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 104bb2d..98b8550 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ # Edit at https://www.toptal.com/developers/gitignore?templates=go,jetbrains+all,macos,windows ### Go ### +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# # Binaries for programs and plugins *.exe *.exe~ @@ -18,9 +21,8 @@ # Dependency directories (remove the comment below to include it) # vendor/ -### Go Patch ### -/vendor/ -/Godeps/ +# Go workspace file +go.work ### JetBrains+all ### # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider @@ -33,6 +35,9 @@ .idea/**/dictionaries .idea/**/shelf +# AWS User-specific +.idea/**/aws.xml + # Generated files .idea/**/contentModel.xml @@ -83,6 +88,9 @@ atlassian-ide-plugin.xml # Cursive Clojure plugin .idea/replstate.xml +# SonarLint plugin +.idea/sonarlint/ + # Crashlytics plugin (for Android Studio and IntelliJ) com_crashlytics_export_strings.xml crashlytics.properties @@ -96,20 +104,9 @@ fabric.properties .idea/caches/build_file_checksums.ser ### JetBrains+all Patch ### -# Ignores the whole .idea folder and all .iml files -# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 - -.idea/ +# Ignore everything -# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 - -*.iml -modules.xml -.idea/misc.xml -*.ipr - -# Sonarlint plugin -.idea/sonarlint +.idea/* ### macOS ### # General @@ -140,6 +137,10 @@ Network Trash Folder Temporary Items .apdisk +### macOS Patch ### +# iCloud generated files +*.icloud + ### Windows ### # Windows thumbnail cache files Thumbs.db diff --git a/Makefile b/Makefile index 7a7b302..1deb9ef 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,6 @@ lint: @golangci-lint run ./... test: - @go test ./... + @go test -race ./... pre-commit: tidy fmt lint test diff --git a/go.mod b/go.mod index 359205b..a008680 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,10 @@ go 1.18 require ( github.com/go-playground/locales v0.14.1 github.com/go-playground/universal-translator v0.18.1 - github.com/go-playground/validator/v10 v10.18.0 + github.com/go-playground/validator/v10 v10.19.0 github.com/google/uuid v1.6.0 github.com/shopspring/decimal v1.3.1 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20230420155350-5d9e357047b1 ) diff --git a/go.sum b/go.sum index 63e8043..fa288bf 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,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/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/validator/v10 v10.18.0 h1:BvolUXjp4zuvkZ5YN5t7ebzbhlUtPsPm2S9NAZ5nl9U= -github.com/go-playground/validator/v10 v10.18.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.19.0 h1:ol+5Fu+cSq9JD7SoSqe04GMI92cbn0+wvQ3bZ8b/AU4= +github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= 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/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= @@ -17,8 +17,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/exp v0.0.0-20230420155350-5d9e357047b1 h1:esPLYTcXPu8wpTcWCNGwSDTodgJwTTFNfeELKb4ewTg= diff --git a/validator/validator_test.go b/validator/validator_test.go index 103191b..5e42959 100644 --- a/validator/validator_test.go +++ b/validator/validator_test.go @@ -81,4 +81,18 @@ func TestVerify(t *testing.T) { err = Verify(r) require.Error(t, err) t.Log(err, ParseErr(err)) + + type UpdatePhoneEmailReq struct { + Phone *string `json:"phone,optional" validate:"omitempty,eq=|len=11,eq=|number" label:"联系电话"` // 联系电话 + Email *string `json:"email,optional" validate:"omitempty,eq=|email" label:"邮箱"` // 邮箱 + Description *string `json:"description,optional"` // 备注 + } + + upe := &UpdatePhoneEmailReq{ + Phone: new(string), + Email: new(string), + Description: new(string), + } + err = Verify(upe) + require.NoError(t, err) }