From b80853de90b10171155b8f3fde47d64ec7bfa0dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Thu, 17 Mar 2022 22:03:27 +0100 Subject: all: gofmt -w -r 'interface{} -> any' . Updates #9687 --- output/docshelper.go | 4 ++-- output/outputFormat.go | 6 +++--- output/outputFormat_test.go | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'output') diff --git a/output/docshelper.go b/output/docshelper.go index 7e1f502df..abfedd148 100644 --- a/output/docshelper.go +++ b/output/docshelper.go @@ -12,7 +12,7 @@ import ( func init() { docsProvider := func() docshelper.DocProvider { return docshelper.DocProvider{ - "output": map[string]interface{}{ + "output": map[string]any{ "formats": DefaultFormats, "layouts": createLayoutExamples(), }, @@ -22,7 +22,7 @@ func init() { docshelper.AddDocProviderFunc(docsProvider) } -func createLayoutExamples() interface{} { +func createLayoutExamples() any { type Example struct { Example string Kind string diff --git a/output/outputFormat.go b/output/outputFormat.go index 091d3accb..34bec9911 100644 --- a/output/outputFormat.go +++ b/output/outputFormat.go @@ -292,7 +292,7 @@ func (formats Formats) FromFilename(filename string) (f Format, found bool) { // DecodeFormats takes a list of output format configurations and merges those, // in the order given, with the Hugo defaults as the last resort. -func DecodeFormats(mediaTypes media.Types, maps ...map[string]interface{}) (Formats, error) { +func DecodeFormats(mediaTypes media.Types, maps ...map[string]any) (Formats, error) { f := make(Formats, len(DefaultFormats)) copy(f, DefaultFormats) @@ -334,12 +334,12 @@ func DecodeFormats(mediaTypes media.Types, maps ...map[string]interface{}) (Form return f, nil } -func decode(mediaTypes media.Types, input interface{}, output *Format) error { +func decode(mediaTypes media.Types, input any, output *Format) error { config := &mapstructure.DecoderConfig{ Metadata: nil, Result: output, WeaklyTypedInput: true, - DecodeHook: func(a reflect.Type, b reflect.Type, c interface{}) (interface{}, error) { + DecodeHook: func(a reflect.Type, b reflect.Type, c any) (any, error) { if a.Kind() == reflect.Map { dataVal := reflect.Indirect(reflect.ValueOf(c)) for _, key := range dataVal.MapKeys() { diff --git a/output/outputFormat_test.go b/output/outputFormat_test.go index fc45099f3..a150dbe7c 100644 --- a/output/outputFormat_test.go +++ b/output/outputFormat_test.go @@ -145,15 +145,15 @@ func TestDecodeFormats(t *testing.T) { tests := []struct { name string - maps []map[string]interface{} + maps []map[string]any shouldError bool assert func(t *testing.T, name string, f Formats) }{ { "Redefine JSON", - []map[string]interface{}{ + []map[string]any{ { - "JsON": map[string]interface{}{ + "JsON": map[string]any{ "baseName": "myindex", "isPlainText": "false", }, @@ -171,9 +171,9 @@ func TestDecodeFormats(t *testing.T) { }, { "Add XML format with string as mediatype", - []map[string]interface{}{ + []map[string]any{ { - "MYXMLFORMAT": map[string]interface{}{ + "MYXMLFORMAT": map[string]any{ "baseName": "myxml", "mediaType": "application/xml", }, @@ -194,9 +194,9 @@ func TestDecodeFormats(t *testing.T) { }, { "Add format unknown mediatype", - []map[string]interface{}{ + []map[string]any{ { - "MYINVALID": map[string]interface{}{ + "MYINVALID": map[string]any{ "baseName": "mymy", "mediaType": "application/hugo", }, @@ -208,15 +208,15 @@ func TestDecodeFormats(t *testing.T) { }, { "Add and redefine XML format", - []map[string]interface{}{ + []map[string]any{ { - "MYOTHERXMLFORMAT": map[string]interface{}{ + "MYOTHERXMLFORMAT": map[string]any{ "baseName": "myotherxml", "mediaType": media.XMLType, }, }, { - "MYOTHERXMLFORMAT": map[string]interface{}{ + "MYOTHERXMLFORMAT": map[string]any{ "baseName": "myredefined", }, }, -- cgit v1.2.3