mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 14:03:24 +09:00
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:
@@ -25,8 +25,7 @@ func (e ErrUserAuthMessage) Error() string {
|
||||
}
|
||||
|
||||
func ErrAsUserAuthMessage(err error) (string, bool) {
|
||||
var msg ErrUserAuthMessage
|
||||
if errors.As(err, &msg) {
|
||||
if msg, ok := errors.AsType[ErrUserAuthMessage](err); ok {
|
||||
return msg.Error(), true
|
||||
}
|
||||
return "", false
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"encoding/gob"
|
||||
"net/http"
|
||||
"sync"
|
||||
"uuid"
|
||||
|
||||
"gitea.dev/models/auth"
|
||||
"gitea.dev/models/db"
|
||||
@@ -15,7 +16,6 @@ import (
|
||||
"gitea.dev/modules/optional"
|
||||
"gitea.dev/modules/setting"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/markbates/goth/gothic"
|
||||
)
|
||||
|
||||
@@ -7,14 +7,13 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"uuid"
|
||||
|
||||
"gitea.dev/models/auth"
|
||||
user_model "gitea.dev/models/user"
|
||||
"gitea.dev/modules/auth/pam"
|
||||
"gitea.dev/modules/optional"
|
||||
"gitea.dev/modules/setting"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Authenticate queries if login/password is valid against the PAM,
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"uuid"
|
||||
|
||||
"gitea.dev/models/auth"
|
||||
"gitea.dev/models/db"
|
||||
@@ -19,8 +20,6 @@ import (
|
||||
"gitea.dev/modules/templates"
|
||||
"gitea.dev/services/auth/source/sspi"
|
||||
gitea_context "gitea.dev/services/context"
|
||||
|
||||
gouuid "github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -156,7 +155,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,
|
||||
|
||||
Reference in New Issue
Block a user