all: gofmt -w -r 'interface{} -> any' .

Updates #9687
This commit is contained in:
Bjørn Erik Pedersen
2022-03-17 22:03:27 +01:00
parent 423594e03a
commit b80853de90
342 changed files with 2118 additions and 2102 deletions

View File

@@ -21,14 +21,14 @@ const (
FieldNotSupported = "__field_not_supported"
)
func structToMapWithPlaceholders(root string, in interface{}, createPlaceholder func(s string) string) map[string]interface{} {
func structToMapWithPlaceholders(root string, in any, createPlaceholder func(s string) string) map[string]any {
m := structToMap(in)
insertFieldPlaceholders(root, m, createPlaceholder)
return m
}
func structToMap(s interface{}) map[string]interface{} {
m := make(map[string]interface{})
func structToMap(s any) map[string]any {
m := make(map[string]any)
t := reflect.TypeOf(s)
for i := 0; i < t.NumMethod(); i++ {
@@ -52,7 +52,7 @@ func structToMap(s interface{}) map[string]interface{} {
}
// insert placeholder for the templates. Do it very shallow for now.
func insertFieldPlaceholders(root string, m map[string]interface{}, createPlaceholder func(s string) string) {
func insertFieldPlaceholders(root string, m map[string]any, createPlaceholder func(s string) string) {
for k := range m {
m[k] = createPlaceholder(root + "." + k)
}

View File

@@ -30,7 +30,7 @@ func TestCreatePlaceholders(t *testing.T) {
return "pre_" + s + "_post"
})
c.Assert(m, qt.DeepEquals, map[string]interface{}{
c.Assert(m, qt.DeepEquals, map[string]any{
"IsZero": "pre_foo.IsZero_post",
"MarshalJSON": "pre_foo.MarshalJSON_post",
"Suffixes": "pre_foo.Suffixes_post",

View File

@@ -35,7 +35,7 @@ type PostPublishedResource interface {
resource.ResourceDataProvider
resource.OriginProvider
MediaType() map[string]interface{}
MediaType() map[string]any
}
const (
@@ -109,13 +109,13 @@ func (r *PostPublishResource) GetFieldString(pattern string) (string, bool) {
case strings.HasPrefix(fieldAccessor, "MediaType"):
return r.fieldToString(d.MediaType(), fieldAccessor), true
case fieldAccessor == "Data.Integrity":
return cast.ToString((d.Data().(map[string]interface{})["Integrity"])), true
return cast.ToString((d.Data().(map[string]any)["Integrity"])), true
default:
panic(fmt.Sprintf("unknown field accessor %q", fieldAccessor))
}
}
func (r *PostPublishResource) fieldToString(receiver interface{}, path string) string {
func (r *PostPublishResource) fieldToString(receiver any, path string) string {
fieldname := strings.Split(path, ".")[1]
receiverv := reflect.ValueOf(receiver)
@@ -143,15 +143,15 @@ func (r *PostPublishResource) fieldToString(receiver interface{}, path string) s
}
}
func (r *PostPublishResource) Data() interface{} {
m := map[string]interface{}{
func (r *PostPublishResource) Data() any {
m := map[string]any{
"Integrity": "",
}
insertFieldPlaceholders("Data", m, r.field)
return m
}
func (r *PostPublishResource) MediaType() map[string]interface{} {
func (r *PostPublishResource) MediaType() map[string]any {
m := structToMapWithPlaceholders("MediaType", media.Type{}, r.field)
return m
}
@@ -172,7 +172,7 @@ func (r *PostPublishResource) Params() maps.Params {
panic(r.fieldNotSupported("Params"))
}
func (r *PostPublishResource) Content() (interface{}, error) {
func (r *PostPublishResource) Content() (any, error) {
return r.field("Content"), nil
}