summaryrefslogtreecommitdiffstats
path: root/modules/issue
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2023-07-04 20:36:08 +0200
committerGitHub <noreply@github.com>2023-07-04 18:36:08 +0000
commit88f835192d1a554d233b0ec4daa33276b7eb2910 (patch)
tree438140c295791e64a3b78dcfeae57701bcf296c3 /modules/issue
parent00dbba7f4266032a2b91b760e7c611950ffad096 (diff)
downloadgitea-88f835192d1a554d233b0ec4daa33276b7eb2910.tar.gz
gitea-88f835192d1a554d233b0ec4daa33276b7eb2910.zip
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](https://github.com/golang/go/commit/2580d0e08d5e9f979b943758d3c49877fb2324cb).
Diffstat (limited to 'modules/issue')
-rw-r--r--modules/issue/template/template.go16
-rw-r--r--modules/issue/template/template_test.go32
2 files changed, 24 insertions, 24 deletions
diff --git a/modules/issue/template/template.go b/modules/issue/template/template.go
index 0f19d87e8d..4e813fc91f 100644
--- a/modules/issue/template/template.go
+++ b/modules/issue/template/template.go
@@ -151,7 +151,7 @@ func validateOptions(field *api.IssueFormField, idx int) error {
}
position := newErrorPosition(idx, field.Type)
- options, ok := field.Attributes["options"].([]interface{})
+ options, ok := field.Attributes["options"].([]any)
if !ok || len(options) == 0 {
return position.Errorf("'options' is required and should be a array")
}
@@ -164,7 +164,7 @@ func validateOptions(field *api.IssueFormField, idx int) error {
return position.Errorf("should be a string")
}
case api.IssueFormFieldTypeCheckboxes:
- opt, ok := option.(map[string]interface{})
+ opt, ok := option.(map[string]any)
if !ok {
return position.Errorf("should be a dictionary")
}
@@ -182,7 +182,7 @@ func validateOptions(field *api.IssueFormField, idx int) error {
return nil
}
-func validateStringItem(position errorPosition, m map[string]interface{}, required bool, names ...string) error {
+func validateStringItem(position errorPosition, m map[string]any, required bool, names ...string) error {
for _, name := range names {
v, ok := m[name]
if !ok {
@@ -202,7 +202,7 @@ func validateStringItem(position errorPosition, m map[string]interface{}, requir
return nil
}
-func validateBoolItem(position errorPosition, m map[string]interface{}, names ...string) error {
+func validateBoolItem(position errorPosition, m map[string]any, names ...string) error {
for _, name := range names {
v, ok := m[name]
if !ok {
@@ -217,7 +217,7 @@ func validateBoolItem(position errorPosition, m map[string]interface{}, names ..
type errorPosition string
-func (p errorPosition) Errorf(format string, a ...interface{}) error {
+func (p errorPosition) Errorf(format string, a ...any) error {
return fmt.Errorf(string(p)+": "+format, a...)
}
@@ -332,7 +332,7 @@ func (f *valuedField) Value() string {
}
func (f *valuedField) Options() []*valuedOption {
- if options, ok := f.Attributes["options"].([]interface{}); ok {
+ if options, ok := f.Attributes["options"].([]any); ok {
ret := make([]*valuedOption, 0, len(options))
for i, option := range options {
ret = append(ret, &valuedOption{
@@ -348,7 +348,7 @@ func (f *valuedField) Options() []*valuedOption {
type valuedOption struct {
index int
- data interface{}
+ data any
field *valuedField
}
@@ -359,7 +359,7 @@ func (o *valuedOption) Label() string {
return label
}
case api.IssueFormFieldTypeCheckboxes:
- if vs, ok := o.data.(map[string]interface{}); ok {
+ if vs, ok := o.data.(map[string]any); ok {
if v, ok := vs["label"].(string); ok {
return v
}
diff --git a/modules/issue/template/template_test.go b/modules/issue/template/template_test.go
index 0cdddd0c85..06e6b70d35 100644
--- a/modules/issue/template/template_test.go
+++ b/modules/issue/template/template_test.go
@@ -387,34 +387,34 @@ body:
{
Type: "markdown",
ID: "id1",
- Attributes: map[string]interface{}{
+ Attributes: map[string]any{
"value": "Value of the markdown",
},
},
{
Type: "textarea",
ID: "id2",
- Attributes: map[string]interface{}{
+ Attributes: map[string]any{
"label": "Label of textarea",
"description": "Description of textarea",
"placeholder": "Placeholder of textarea",
"value": "Value of textarea",
"render": "bash",
},
- Validations: map[string]interface{}{
+ Validations: map[string]any{
"required": true,
},
},
{
Type: "input",
ID: "id3",
- Attributes: map[string]interface{}{
+ Attributes: map[string]any{
"label": "Label of input",
"description": "Description of input",
"placeholder": "Placeholder of input",
"value": "Value of input",
},
- Validations: map[string]interface{}{
+ Validations: map[string]any{
"required": true,
"is_number": true,
"regex": "[a-zA-Z0-9]+",
@@ -423,30 +423,30 @@ body:
{
Type: "dropdown",
ID: "id4",
- Attributes: map[string]interface{}{
+ Attributes: map[string]any{
"label": "Label of dropdown",
"description": "Description of dropdown",
"multiple": true,
- "options": []interface{}{
+ "options": []any{
"Option 1 of dropdown",
"Option 2 of dropdown",
"Option 3 of dropdown",
},
},
- Validations: map[string]interface{}{
+ Validations: map[string]any{
"required": true,
},
},
{
Type: "checkboxes",
ID: "id5",
- Attributes: map[string]interface{}{
+ Attributes: map[string]any{
"label": "Label of checkboxes",
"description": "Description of checkboxes",
- "options": []interface{}{
- map[string]interface{}{"label": "Option 1 of checkboxes", "required": true},
- map[string]interface{}{"label": "Option 2 of checkboxes", "required": false},
- map[string]interface{}{"label": "Option 3 of checkboxes", "required": true},
+ "options": []any{
+ map[string]any{"label": "Option 1 of checkboxes", "required": true},
+ map[string]any{"label": "Option 2 of checkboxes", "required": false},
+ map[string]any{"label": "Option 3 of checkboxes", "required": true},
},
},
},
@@ -479,7 +479,7 @@ body:
{
Type: "markdown",
ID: "id1",
- Attributes: map[string]interface{}{
+ Attributes: map[string]any{
"value": "Value of the markdown",
},
},
@@ -512,7 +512,7 @@ body:
{
Type: "markdown",
ID: "id1",
- Attributes: map[string]interface{}{
+ Attributes: map[string]any{
"value": "Value of the markdown",
},
},
@@ -545,7 +545,7 @@ body:
{
Type: "markdown",
ID: "id1",
- Attributes: map[string]interface{}{
+ Attributes: map[string]any{
"value": "Value of the markdown",
},
},