chore: misc go 1.27 tweaks (#39069)

Follow-up to https://github.com/go-gitea/gitea/pull/39068, which
disabled `modernize` entirely.

- re-enable `modernize`, with only the new `embedlit` rule disabled. It
flattens embedded struct literals across ~145 files, and orphans imports
in 6 of them that the fixer does not remove
- apply the rest of the suite: `errors.AsType`, `reflect.TypeAssert`,
`strings.Cut`, and dropping the legacy import comment
- use the new stdlib `uuid` package, `github.com/google/uuid` becomes
indirect
- use `strings.CutLast` in place of manual `LastIndex` slicing in label
scopes, email domains and the diff tree list
- take the header lint skip dirs from the `go.mod` `ignore` directive
and skip dot-directories, instead of hardcoding the list

Assisted-by: Claude Code:claude-opus-5
This commit is contained in:
silverwind
2026-08-24 18:26:10 +00:00
committed by GitHub
parent 59a43c8733
commit 32728fc581
32 changed files with 83 additions and 72 deletions
+2 -3
View File
@@ -7,14 +7,13 @@ package auth
import (
"net/http"
"strings"
"uuid"
user_model "gitea.dev/models/user"
"gitea.dev/modules/log"
"gitea.dev/modules/optional"
"gitea.dev/modules/session"
"gitea.dev/modules/setting"
gouuid "github.com/google/uuid"
)
// Ensure the struct implements the interface.
@@ -143,7 +142,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 {