mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Replace interface{}
with any
(#25686)
Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`.
Basically the same [as golang did](2580d0e08d
).
This commit is contained in:
@@ -116,7 +116,7 @@ func getVariablesOfTask(ctx context.Context, task *actions_model.ActionTask) map
|
||||
}
|
||||
|
||||
func generateTaskContext(t *actions_model.ActionTask) *structpb.Struct {
|
||||
event := map[string]interface{}{}
|
||||
event := map[string]any{}
|
||||
_ = json.Unmarshal([]byte(t.Job.Run.EventPayload), &event)
|
||||
|
||||
// TriggerEvent is added in https://github.com/go-gitea/gitea/pull/25229
|
||||
@@ -136,7 +136,7 @@ func generateTaskContext(t *actions_model.ActionTask) *structpb.Struct {
|
||||
|
||||
refName := git.RefName(t.Job.Run.Ref)
|
||||
|
||||
taskContext, err := structpb.NewStruct(map[string]interface{}{
|
||||
taskContext, err := structpb.NewStruct(map[string]any{
|
||||
// standard contexts, see https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
|
||||
"action": "", // string, The name of the action currently running, or the id of a step. GitHub removes special characters, and uses the name __run when the current step runs a script without an id. If you use the same action more than once in the same job, the name will include a suffix with the sequence number with underscore before it. For example, the first script you run will have the name __run, and the second script will be named __run_2. Similarly, the second invocation of actions/checkout will be actionscheckout2.
|
||||
"action_path": "", // string, The path where an action is located. This property is only supported in composite actions. You can use this path to access files located in the same repository as the action.
|
||||
|
@@ -24,7 +24,7 @@ import (
|
||||
alpine_service "code.gitea.io/gitea/services/packages/alpine"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.PlainText(status, message)
|
||||
})
|
||||
|
@@ -33,7 +33,7 @@ type StatusMessage struct {
|
||||
Message string `json:"detail"`
|
||||
}
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.JSON(status, StatusResponse{
|
||||
OK: false,
|
||||
|
@@ -24,7 +24,7 @@ import (
|
||||
packages_service "code.gitea.io/gitea/services/packages"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
type Error struct {
|
||||
ErrorMessages []string `json:"error_messages"`
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ import (
|
||||
"github.com/hashicorp/go-version"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
type Error struct {
|
||||
Status int `json:"status"`
|
||||
|
@@ -47,7 +47,7 @@ var (
|
||||
)
|
||||
)
|
||||
|
||||
func jsonResponse(ctx *context.Context, status int, obj interface{}) {
|
||||
func jsonResponse(ctx *context.Context, status int, obj any) {
|
||||
// https://github.com/conan-io/conan/issues/6613
|
||||
ctx.Resp.Header().Set("Content-Type", "application/json")
|
||||
ctx.Status(status)
|
||||
@@ -56,7 +56,7 @@ func jsonResponse(ctx *context.Context, status int, obj interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
jsonResponse(ctx, status, map[string]string{
|
||||
"message": message,
|
||||
@@ -796,13 +796,13 @@ func listRevisionFiles(ctx *context.Context, fileKey string) {
|
||||
return
|
||||
}
|
||||
|
||||
files := make(map[string]interface{})
|
||||
files := make(map[string]any)
|
||||
for _, pf := range pfs {
|
||||
files[pf.Name] = nil
|
||||
}
|
||||
|
||||
type FileList struct {
|
||||
Files map[string]interface{} `json:"files"`
|
||||
Files map[string]any `json:"files"`
|
||||
}
|
||||
|
||||
jsonResponse(ctx, http.StatusOK, &FileList{
|
||||
|
@@ -24,7 +24,7 @@ import (
|
||||
"github.com/dsnet/compress/bzip2"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.JSON(status, struct {
|
||||
Reason string `json:"reason"`
|
||||
|
@@ -75,7 +75,7 @@ func setResponseHeaders(resp http.ResponseWriter, h *containerHeaders) {
|
||||
resp.WriteHeader(h.Status)
|
||||
}
|
||||
|
||||
func jsonResponse(ctx *context.Context, status int, obj interface{}) {
|
||||
func jsonResponse(ctx *context.Context, status int, obj any) {
|
||||
setResponseHeaders(ctx.Resp, &containerHeaders{
|
||||
Status: status,
|
||||
ContentType: "application/json",
|
||||
|
@@ -21,7 +21,7 @@ import (
|
||||
packages_service "code.gitea.io/gitea/services/packages"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.PlainText(status, message)
|
||||
})
|
||||
|
@@ -23,7 +23,7 @@ import (
|
||||
debian_service "code.gitea.io/gitea/services/packages/debian"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.PlainText(status, message)
|
||||
})
|
||||
|
@@ -22,7 +22,7 @@ var (
|
||||
filenameRegex = packageNameRegex
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.PlainText(status, message)
|
||||
})
|
||||
|
@@ -20,7 +20,7 @@ import (
|
||||
packages_service "code.gitea.io/gitea/services/packages"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.PlainText(status, message)
|
||||
})
|
||||
|
@@ -26,7 +26,7 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
type Error struct {
|
||||
Error string `json:"error"`
|
||||
|
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
// LogAndProcessError logs an error and calls a custom callback with the processed error message.
|
||||
// If the error is an InternalServerError the message is stripped if the user is not an admin.
|
||||
func LogAndProcessError(ctx *context.Context, status int, obj interface{}, cb func(string)) {
|
||||
func LogAndProcessError(ctx *context.Context, status int, obj any, cb func(string)) {
|
||||
var message string
|
||||
if err, ok := obj.(error); ok {
|
||||
message = err.Error()
|
||||
|
@@ -47,7 +47,7 @@ var (
|
||||
illegalCharacters = regexp.MustCompile(`[\\/:"<>|?\*]`)
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.PlainText(status, message)
|
||||
})
|
||||
|
@@ -30,7 +30,7 @@ import (
|
||||
// errInvalidTagName indicates an invalid tag name
|
||||
var errInvalidTagName = errors.New("The tag name is invalid")
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.JSON(status, map[string]string{
|
||||
"error": message,
|
||||
|
@@ -25,7 +25,7 @@ import (
|
||||
packages_service "code.gitea.io/gitea/services/packages"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.JSON(status, map[string]string{
|
||||
"Message": message,
|
||||
@@ -33,7 +33,7 @@ func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
})
|
||||
}
|
||||
|
||||
func xmlResponse(ctx *context.Context, status int, obj interface{}) {
|
||||
func xmlResponse(ctx *context.Context, status int, obj any) {
|
||||
ctx.Resp.Header().Set("Content-Type", "application/atom+xml; charset=utf-8")
|
||||
ctx.Resp.WriteHeader(status)
|
||||
if _, err := ctx.Resp.Write([]byte(xml.Header)); err != nil {
|
||||
|
@@ -25,7 +25,7 @@ import (
|
||||
packages_service "code.gitea.io/gitea/services/packages"
|
||||
)
|
||||
|
||||
func jsonResponse(ctx *context.Context, status int, obj interface{}) {
|
||||
func jsonResponse(ctx *context.Context, status int, obj any) {
|
||||
resp := ctx.Resp
|
||||
resp.Header().Set("Content-Type", "application/vnd.pub.v2+json")
|
||||
resp.WriteHeader(status)
|
||||
@@ -34,7 +34,7 @@ func jsonResponse(ctx *context.Context, status int, obj interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
type Error struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
@@ -60,10 +60,10 @@ type packageVersions struct {
|
||||
}
|
||||
|
||||
type versionMetadata struct {
|
||||
Version string `json:"version"`
|
||||
ArchiveURL string `json:"archive_url"`
|
||||
Published time.Time `json:"published"`
|
||||
Pubspec interface{} `json:"pubspec,omitempty"`
|
||||
Version string `json:"version"`
|
||||
ArchiveURL string `json:"archive_url"`
|
||||
Published time.Time `json:"published"`
|
||||
Pubspec any `json:"pubspec,omitempty"`
|
||||
}
|
||||
|
||||
func packageDescriptorToMetadata(baseURL string, pd *packages_model.PackageDescriptor) *versionMetadata {
|
||||
|
@@ -37,7 +37,7 @@ var versionMatcher = regexp.MustCompile(`\Av?` +
|
||||
`(?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)?` + // local version
|
||||
`\z`)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.PlainText(status, message)
|
||||
})
|
||||
|
@@ -25,7 +25,7 @@ import (
|
||||
rpm_service "code.gitea.io/gitea/services/packages/rpm"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.PlainText(status, message)
|
||||
})
|
||||
|
@@ -21,7 +21,7 @@ import (
|
||||
packages_service "code.gitea.io/gitea/services/packages"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.PlainText(status, message)
|
||||
})
|
||||
@@ -65,9 +65,9 @@ func enumeratePackages(ctx *context.Context, filename string, pvs []*packages_mo
|
||||
return
|
||||
}
|
||||
|
||||
specs := make([]interface{}, 0, len(pds))
|
||||
specs := make([]any, 0, len(pds))
|
||||
for _, p := range pds {
|
||||
specs = append(specs, []interface{}{
|
||||
specs = append(specs, []any{
|
||||
p.Package.Name,
|
||||
&rubygems_module.RubyUserMarshal{
|
||||
Name: "Gem::Version",
|
||||
@@ -129,7 +129,7 @@ func ServePackageSpecification(ctx *context.Context) {
|
||||
// create a Ruby Gem::Specification object
|
||||
spec := &rubygems_module.RubyUserDef{
|
||||
Name: "Gem::Specification",
|
||||
Value: []interface{}{
|
||||
Value: []any{
|
||||
"3.2.3", // @rubygems_version
|
||||
4, // @specification_version,
|
||||
pd.Package.Name,
|
||||
@@ -142,7 +142,7 @@ func ServePackageSpecification(ctx *context.Context) {
|
||||
nil, // @required_ruby_version
|
||||
nil, // @required_rubygems_version
|
||||
metadata.Platform, // @original_platform
|
||||
[]interface{}{}, // @dependencies
|
||||
[]any{}, // @dependencies
|
||||
nil, // rubyforge_project
|
||||
"", // @email
|
||||
metadata.Authors,
|
||||
|
@@ -69,7 +69,7 @@ func setResponseHeaders(resp http.ResponseWriter, h *headers) {
|
||||
}
|
||||
|
||||
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#33-error-handling
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
// https://www.rfc-editor.org/rfc/rfc7807
|
||||
type Problem struct {
|
||||
Status int `json:"status"`
|
||||
|
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/hashicorp/go-version"
|
||||
)
|
||||
|
||||
func apiError(ctx *context.Context, status int, obj interface{}) {
|
||||
func apiError(ctx *context.Context, status int, obj any) {
|
||||
helper.LogAndProcessError(ctx, status, obj, func(message string) {
|
||||
ctx.JSON(status, struct {
|
||||
Errors []string `json:"errors"`
|
||||
|
@@ -792,7 +792,7 @@ func SearchTeam(ctx *context.APIContext) {
|
||||
teams, maxResults, err := organization.SearchTeam(opts)
|
||||
if err != nil {
|
||||
log.Error("SearchTeam failed: %v", err)
|
||||
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
|
||||
ctx.JSON(http.StatusInternalServerError, map[string]any{
|
||||
"ok": false,
|
||||
"error": "SearchTeam internal failure",
|
||||
})
|
||||
@@ -807,7 +807,7 @@ func SearchTeam(ctx *context.APIContext) {
|
||||
|
||||
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
|
||||
ctx.SetTotalCountHeader(maxResults)
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"ok": true,
|
||||
"data": apiTeams,
|
||||
})
|
||||
|
@@ -378,7 +378,7 @@ func Generate(ctx *context.APIContext) {
|
||||
ctxUser, err = user_model.GetUserByName(ctx, form.Owner)
|
||||
if err != nil {
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
ctx.JSON(http.StatusNotFound, map[string]interface{}{
|
||||
ctx.JSON(http.StatusNotFound, map[string]any{
|
||||
"error": "request owner `" + form.Owner + "` does not exist",
|
||||
})
|
||||
return
|
||||
|
@@ -63,7 +63,7 @@ func ListTopics(ctx *context.APIContext) {
|
||||
}
|
||||
|
||||
ctx.SetTotalCountHeader(total)
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"topics": topicNames,
|
||||
})
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func UpdateTopics(ctx *context.APIContext) {
|
||||
validTopics, invalidTopics := repo_model.SanitizeAndValidateTopics(topicNames)
|
||||
|
||||
if len(validTopics) > 25 {
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
|
||||
"invalidTopics": nil,
|
||||
"message": "Exceeding maximum number of topics per repo",
|
||||
})
|
||||
@@ -109,7 +109,7 @@ func UpdateTopics(ctx *context.APIContext) {
|
||||
}
|
||||
|
||||
if len(invalidTopics) > 0 {
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
|
||||
"invalidTopics": invalidTopics,
|
||||
"message": "Topic names are invalid",
|
||||
})
|
||||
@@ -158,7 +158,7 @@ func AddTopic(ctx *context.APIContext) {
|
||||
topicName := strings.TrimSpace(strings.ToLower(ctx.Params(":topic")))
|
||||
|
||||
if !repo_model.ValidateTopic(topicName) {
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
|
||||
"invalidTopics": topicName,
|
||||
"message": "Topic name is invalid",
|
||||
})
|
||||
@@ -175,7 +175,7 @@ func AddTopic(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
if count >= 25 {
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
|
||||
"message": "Exceeding maximum allowed topics per repo.",
|
||||
})
|
||||
return
|
||||
@@ -223,7 +223,7 @@ func DeleteTopic(ctx *context.APIContext) {
|
||||
topicName := strings.TrimSpace(strings.ToLower(ctx.Params(":topic")))
|
||||
|
||||
if !repo_model.ValidateTopic(topicName) {
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
|
||||
"invalidTopics": topicName,
|
||||
"message": "Topic name is invalid",
|
||||
})
|
||||
@@ -289,7 +289,7 @@ func TopicSearch(ctx *context.APIContext) {
|
||||
}
|
||||
|
||||
ctx.SetTotalCountHeader(total)
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"topics": topicResponses,
|
||||
})
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ func Search(ctx *context.APIContext) {
|
||||
ListOptions: listOptions,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
|
||||
ctx.JSON(http.StatusInternalServerError, map[string]any{
|
||||
"ok": false,
|
||||
"error": err.Error(),
|
||||
})
|
||||
@@ -72,7 +72,7 @@ func Search(ctx *context.APIContext) {
|
||||
ctx.SetLinkHeader(int(maxResults), listOptions.PageSize)
|
||||
ctx.SetTotalCountHeader(maxResults)
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"ok": true,
|
||||
"data": convert.ToUsers(ctx, ctx.Doer, users),
|
||||
})
|
||||
|
Reference in New Issue
Block a user