From c15e6e793b7cf9a007c71f1f1a8880e6f98b53b5 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 19 Aug 2026 23:21:38 +0200 Subject: [PATCH] chore: use stdlib uuid package Go 1.27 ships a uuid package with the same API, dropping the direct dependency on github.com/google/uuid. Assisted-by: Claude:Opus 5 --- go.mod | 2 +- models/auth/oauth2.go | 2 +- models/repo/upload.go | 4 ++-- models/webhook/hooktask.go | 4 ++-- models/webhook/webhook_test.go | 2 +- routers/api/actions/runner/runner.go | 4 ++-- routers/web/user/package.go | 2 +- services/attachment/attachment.go | 2 +- services/auth/reverseproxy.go | 4 ++-- services/auth/source/oauth2/init.go | 2 +- services/auth/source/pam/source_authenticate.go | 2 +- services/auth/sspi.go | 4 ++-- services/migrations/dump.go | 2 +- services/migrations/gitea_uploader.go | 2 +- tests/integration/api_packages_terraform_test.go | 2 +- 15 files changed, 20 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index 22fa93dc349..002f3846282 100644 --- a/go.mod +++ b/go.mod @@ -60,7 +60,6 @@ require ( github.com/google/go-github/v89 v89.0.0 github.com/google/licenseclassifier/v2 v2.0.0 github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 - github.com/google/uuid v1.6.0 github.com/gorilla/feeds v1.2.0 github.com/gorilla/sessions v1.4.0 github.com/hashicorp/go-version v1.9.0 @@ -194,6 +193,7 @@ require ( github.com/google/flatbuffers v25.12.19+incompatible // indirect github.com/google/go-querystring v1.2.0 // indirect github.com/google/go-tpm v0.9.8 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/gorilla/css v1.0.1 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/securecookie v1.1.2 // indirect diff --git a/models/auth/oauth2.go b/models/auth/oauth2.go index b9e4a6b0ba5..bc65c70488a 100644 --- a/models/auth/oauth2.go +++ b/models/auth/oauth2.go @@ -21,9 +21,9 @@ import ( "gitea.dev/modules/timeutil" "gitea.dev/modules/util" - uuid "github.com/google/uuid" "golang.org/x/crypto/bcrypt" "golang.org/x/oauth2" + "uuid" "xorm.io/builder" "xorm.io/xorm" ) diff --git a/models/repo/upload.go b/models/repo/upload.go index 6bfcd022aec..0a0a5c09438 100644 --- a/models/repo/upload.go +++ b/models/repo/upload.go @@ -17,7 +17,7 @@ import ( "gitea.dev/modules/setting" "gitea.dev/modules/util" - gouuid "github.com/google/uuid" + "uuid" ) // ErrUploadNotExist represents a "UploadNotExist" kind of error. @@ -60,7 +60,7 @@ func (upload *Upload) LocalPath() string { // NewUpload creates a new upload object. func NewUpload(ctx context.Context, name string, buf []byte, file multipart.File) (_ *Upload, err error) { upload := &Upload{ - UUID: gouuid.New().String(), + UUID: uuid.New().String(), Name: name, } diff --git a/models/webhook/hooktask.go b/models/webhook/hooktask.go index a0a6eef60f4..0464d697aa7 100644 --- a/models/webhook/hooktask.go +++ b/models/webhook/hooktask.go @@ -15,7 +15,7 @@ import ( "gitea.dev/modules/timeutil" webhook_module "gitea.dev/modules/webhook" - gouuid "github.com/google/uuid" + "uuid" "xorm.io/builder" ) @@ -119,7 +119,7 @@ func HookTasks(ctx context.Context, hookID int64, page int) ([]*HookTask, error) // CreateHookTask creates a new hook task, // it handles conversion from Payload to PayloadContent. func CreateHookTask(ctx context.Context, t *HookTask) (*HookTask, error) { - t.UUID = gouuid.New().String() + t.UUID = uuid.New().String() if t.Delivered == 0 { t.Delivered = timeutil.TimeStampNanoNow() } diff --git a/models/webhook/webhook_test.go b/models/webhook/webhook_test.go index cd527d11591..e785325a655 100644 --- a/models/webhook/webhook_test.go +++ b/models/webhook/webhook_test.go @@ -15,9 +15,9 @@ import ( "gitea.dev/modules/timeutil" webhook_module "gitea.dev/modules/webhook" - "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "uuid" "xorm.io/builder" ) diff --git a/routers/api/actions/runner/runner.go b/routers/api/actions/runner/runner.go index 96e6a90e156..dda28793c27 100644 --- a/routers/api/actions/runner/runner.go +++ b/routers/api/actions/runner/runner.go @@ -20,10 +20,10 @@ import ( actions_service "gitea.dev/services/actions" "connectrpc.com/connect" - gouuid "github.com/google/uuid" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" + "uuid" ) func NewRunnerServiceHandler() (string, http.Handler) { @@ -74,7 +74,7 @@ func (s *Service) Register( // create new runner name := util.EllipsisDisplayString(req.Msg.Name, 255) runner := &actions_model.ActionRunner{ - UUID: gouuid.New().String(), + UUID: uuid.New().String(), Name: name, OwnerID: runnerToken.OwnerID, RepoID: runnerToken.RepoID, diff --git a/routers/web/user/package.go b/routers/web/user/package.go index bd363bfc8ce..8f2be83f776 100644 --- a/routers/web/user/package.go +++ b/routers/web/user/package.go @@ -36,7 +36,7 @@ import ( packages_service "gitea.dev/services/packages" container_service "gitea.dev/services/packages/container" - "github.com/google/uuid" + "uuid" ) const ( diff --git a/services/attachment/attachment.go b/services/attachment/attachment.go index 372cfb62f9f..c7ca9ebfc00 100644 --- a/services/attachment/attachment.go +++ b/services/attachment/attachment.go @@ -18,7 +18,7 @@ import ( "gitea.dev/modules/util" "gitea.dev/services/context/upload" - "github.com/google/uuid" + "uuid" ) // NewAttachment creates a new attachment object, but do not verify. diff --git a/services/auth/reverseproxy.go b/services/auth/reverseproxy.go index ff95329c9e6..f6007616c5c 100644 --- a/services/auth/reverseproxy.go +++ b/services/auth/reverseproxy.go @@ -14,7 +14,7 @@ import ( "gitea.dev/modules/session" "gitea.dev/modules/setting" - gouuid "github.com/google/uuid" + "uuid" ) // Ensure the struct implements the interface. @@ -143,7 +143,7 @@ func (r *ReverseProxy) newUser(req *http.Request) *user_model.User { return nil } - email := gouuid.New().String() + "@localhost" + email := uuid.New().String() + "@localhost" if setting.Service.EnableReverseProxyEmail { webAuthEmail := req.Header.Get(setting.ReverseProxyAuthEmail) if len(webAuthEmail) > 0 { diff --git a/services/auth/source/oauth2/init.go b/services/auth/source/oauth2/init.go index e67c695b4a0..676f5187b80 100644 --- a/services/auth/source/oauth2/init.go +++ b/services/auth/source/oauth2/init.go @@ -15,9 +15,9 @@ import ( "gitea.dev/modules/optional" "gitea.dev/modules/setting" - "github.com/google/uuid" "github.com/gorilla/sessions" "github.com/markbates/goth/gothic" + "uuid" ) var gothRWMutex = sync.RWMutex{} diff --git a/services/auth/source/pam/source_authenticate.go b/services/auth/source/pam/source_authenticate.go index 510e1c2b93d..c7b48612ae2 100644 --- a/services/auth/source/pam/source_authenticate.go +++ b/services/auth/source/pam/source_authenticate.go @@ -14,7 +14,7 @@ import ( "gitea.dev/modules/optional" "gitea.dev/modules/setting" - "github.com/google/uuid" + "uuid" ) // Authenticate queries if login/password is valid against the PAM, diff --git a/services/auth/sspi.go b/services/auth/sspi.go index 185c37edda1..3139489a330 100644 --- a/services/auth/sspi.go +++ b/services/auth/sspi.go @@ -20,7 +20,7 @@ import ( "gitea.dev/services/auth/source/sspi" gitea_context "gitea.dev/services/context" - gouuid "github.com/google/uuid" + "uuid" ) const ( @@ -156,7 +156,7 @@ func (s *SSPI) shouldAuthenticate(req *http.Request) (shouldAuth bool) { // newUser creates a new user object for the purpose of automatic registration // and populates its name and email with the information present in request headers. func (s *SSPI) newUser(ctx context.Context, username string, cfg *sspi.Source) (*user_model.User, error) { - email := gouuid.New().String() + "@localhost.localdomain" + email := uuid.New().String() + "@localhost.localdomain" user := &user_model.User{ Name: username, Email: email, diff --git a/services/migrations/dump.go b/services/migrations/dump.go index 6ed155c6989..e979bf38bbe 100644 --- a/services/migrations/dump.go +++ b/services/migrations/dump.go @@ -25,8 +25,8 @@ import ( "gitea.dev/modules/setting" "gitea.dev/modules/structs" - "github.com/google/uuid" "go.yaml.in/yaml/v4" + "uuid" ) var _ base.Uploader = &RepositoryDumper{} diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index 6c87c89d536..25440fd4fe2 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -33,7 +33,7 @@ import ( "gitea.dev/services/pull" repo_service "gitea.dev/services/repository" - "github.com/google/uuid" + "uuid" ) var _ base.Uploader = &GiteaLocalUploader{} diff --git a/tests/integration/api_packages_terraform_test.go b/tests/integration/api_packages_terraform_test.go index c823923692a..4f6019f6cdf 100644 --- a/tests/integration/api_packages_terraform_test.go +++ b/tests/integration/api_packages_terraform_test.go @@ -14,9 +14,9 @@ import ( user_model "gitea.dev/models/user" "gitea.dev/tests" - "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "uuid" ) func TestPackageTerraform(t *testing.T) {