mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-16 01:43: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:
@@ -10,6 +10,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"uuid"
|
||||
|
||||
"gitea.dev/models/db"
|
||||
repo_model "gitea.dev/models/repo"
|
||||
@@ -17,8 +18,6 @@ import (
|
||||
"gitea.dev/modules/storage"
|
||||
"gitea.dev/modules/util"
|
||||
"gitea.dev/services/context/upload"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// NewAttachment creates a new attachment object, but do not verify.
|
||||
@@ -85,8 +84,7 @@ func uploadAttachment(ctx context.Context, file *UploaderFile, allowedTypes stri
|
||||
}
|
||||
|
||||
attach, err := NewAttachment(ctx, attach, io.MultiReader(bytes.NewReader(buf), src), file.size)
|
||||
var maxBytesError *http.MaxBytesError
|
||||
if errors.As(err, &maxBytesError) {
|
||||
if _, ok := errors.AsType[*http.MaxBytesError](err); ok {
|
||||
return nil, util.ErrorWrap(util.ErrContentTooLarge, "attachment exceeds limit %d", maxFileSize)
|
||||
}
|
||||
return attach, err
|
||||
|
||||
Reference in New Issue
Block a user