From 2a29d59ab1c4fd1a5e57969a11a5452706f559c5 Mon Sep 17 00:00:00 2001 From: Andrew Garner Date: Mon, 20 May 2024 02:03:54 -0500 Subject: [PATCH] replace github.com/pborman/uuid w/ github.com/google/uuid (#311) The github.com/pborman/uuid dependency is no longer maintained and is a wrapper for github.com/google/uuid anyway. This commit removes the github.com/pborman/uuid dependency and bumps to the latest github.com/google/uuid. --- api_suite_test.go | 4 ++-- go.mod | 3 +-- go.sum | 6 ++---- middlewares/correlation_id_header.go | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/api_suite_test.go b/api_suite_test.go index 5a3c166d..bd40e28d 100644 --- a/api_suite_test.go +++ b/api_suite_test.go @@ -21,9 +21,9 @@ import ( "path" "testing" + "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/pborman/uuid" ) func TestAPI(t *testing.T) { @@ -43,7 +43,7 @@ func fixture(name string) string { } func uniqueID() string { - return uuid.NewRandom().String() + return uuid.NewString() } func uniqueInstanceID() string { diff --git a/go.mod b/go.mod index cbbb4965..4e672b73 100644 --- a/go.mod +++ b/go.mod @@ -4,10 +4,10 @@ go 1.21 require ( github.com/go-chi/chi/v5 v5.0.12 + github.com/google/uuid v1.6.0 github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1 github.com/onsi/ginkgo/v2 v2.17.3 github.com/onsi/gomega v1.33.1 - github.com/pborman/uuid v1.2.1 honnef.co/go/tools v0.4.7 ) @@ -17,7 +17,6 @@ require ( github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect - github.com/google/uuid v1.0.0 // indirect github.com/kr/pretty v0.0.0-20160823170715-cfb55aafdaf3 // indirect github.com/kr/text v0.2.0 // indirect golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect diff --git a/go.sum b/go.sum index 1778d443..196d0b3a 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= -github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA= -github.com/google/uuid v1.0.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/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kr/pretty v0.0.0-20160823170715-cfb55aafdaf3 h1:dhwb1Ev84SKKVBfLuhR4bw/29yYHzwtTyTLUWWnvYxI= github.com/kr/pretty v0.0.0-20160823170715-cfb55aafdaf3/go.mod h1:Bvhd+E3laJ0AVkG0c9rmtZcnhV0HQ3+c3YxxqTvc/gA= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -25,8 +25,6 @@ github.com/onsi/ginkgo/v2 v2.17.3 h1:oJcvKpIb7/8uLpDDtnQuf18xVnwKp8DTD7DQ6gTd/MU github.com/onsi/ginkgo/v2 v2.17.3/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= -github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw= -github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= diff --git a/middlewares/correlation_id_header.go b/middlewares/correlation_id_header.go index a314e7d0..05bf7d38 100644 --- a/middlewares/correlation_id_header.go +++ b/middlewares/correlation_id_header.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "github.com/pborman/uuid" + "github.com/google/uuid" ) var correlationIDHeaders = []string{"X-Correlation-ID", "X-CorrelationID", "X-ForRequest-ID", "X-Request-ID", "X-Vcap-Request-Id"} @@ -24,7 +24,7 @@ func AddCorrelationIDToContext(next http.Handler) http.Handler { } if !found { - correlationID = uuid.New() + correlationID = uuid.NewString() } newCtx := context.WithValue(req.Context(), CorrelationIDKey, correlationID)