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

@@ -49,7 +49,7 @@ type FrontMatterHandler struct {
type FrontMatterDescriptor struct {
// This the Page's front matter.
Frontmatter map[string]interface{}
Frontmatter map[string]any
// This is the Page's base filename (BaseFilename), e.g. page.md., or
// if page is a leaf bundle, the bundle folder name (ContentBaseName).
@@ -64,7 +64,7 @@ type FrontMatterDescriptor struct {
// The below are pointers to values on Page and will be modified.
// This is the Page's params.
Params map[string]interface{}
Params map[string]any
// This is the Page's dates.
Dates *resource.Dates
@@ -253,7 +253,7 @@ func expandDefaultValues(values []string, defaults []string) []string {
return out
}
func toLowerSlice(in interface{}) []string {
func toLowerSlice(in any) []string {
out := cast.ToStringSlice(in)
for i := 0; i < len(out); i++ {
out[i] = strings.ToLower(out[i])
@@ -335,7 +335,7 @@ func (f *FrontMatterHandler) createHandlers() error {
return nil
}
func setParamIfNotSet(key string, value interface{}, d *FrontMatterDescriptor) {
func setParamIfNotSet(key string, value any, d *FrontMatterDescriptor) {
if _, found := d.Params[key]; found {
return
}

View File

@@ -63,8 +63,8 @@ func TestDateAndSlugFromBaseFilename(t *testing.T) {
func newTestFd() *FrontMatterDescriptor {
return &FrontMatterDescriptor{
Frontmatter: make(map[string]interface{}),
Params: make(map[string]interface{}),
Frontmatter: make(map[string]any),
Params: make(map[string]any),
Dates: &resource.Dates{},
PageURLs: &URLPath{},
Location: time.UTC,
@@ -76,7 +76,7 @@ func TestFrontMatterNewConfig(t *testing.T) {
cfg := config.New()
cfg.Set("frontmatter", map[string]interface{}{
cfg.Set("frontmatter", map[string]any{
"date": []string{"publishDate", "LastMod"},
"Lastmod": []string{"publishDate"},
"expiryDate": []string{"lastMod"},
@@ -100,7 +100,7 @@ func TestFrontMatterNewConfig(t *testing.T) {
c.Assert(fc.publishDate, qt.DeepEquals, []string{"publishdate", "pubdate", "published", "date"})
// :default keyword
cfg.Set("frontmatter", map[string]interface{}{
cfg.Set("frontmatter", map[string]any{
"date": []string{"d1", ":default"},
"lastmod": []string{"d2", ":default"},
"expiryDate": []string{"d3", ":default"},
@@ -121,7 +121,7 @@ func TestFrontMatterDatesHandlers(t *testing.T) {
cfg := config.New()
cfg.Set("frontmatter", map[string]interface{}{
cfg.Set("frontmatter", map[string]any{
"date": []string{handlerID, "date"},
})
@@ -160,7 +160,7 @@ func TestFrontMatterDatesCustomConfig(t *testing.T) {
c := qt.New(t)
cfg := config.New()
cfg.Set("frontmatter", map[string]interface{}{
cfg.Set("frontmatter", map[string]any{
"date": []string{"mydate"},
"lastmod": []string{"publishdate"},
"publishdate": []string{"publishdate"},
@@ -208,7 +208,7 @@ func TestFrontMatterDatesDefaultKeyword(t *testing.T) {
cfg := config.New()
cfg.Set("frontmatter", map[string]interface{}{
cfg.Set("frontmatter", map[string]any{
"date": []string{"mydate", ":default"},
"publishdate": []string{":default", "mypubdate"},
})

View File

@@ -75,7 +75,7 @@ func (b BuildConfig) IsZero() bool {
return !b.set
}
func DecodeBuildConfig(m interface{}) (BuildConfig, error) {
func DecodeBuildConfig(m any) (BuildConfig, error) {
b := defaultBuildConfig
if m == nil {
return b, nil

View File

@@ -36,11 +36,11 @@ list = %s
publishResources = true`
for _, test := range []struct {
args []interface{}
args []any
expect BuildConfig
}{
{
[]interface{}{"true", "true"},
[]any{"true", "true"},
BuildConfig{
Render: Always,
List: Always,
@@ -48,31 +48,31 @@ publishResources = true`
set: true,
},
},
{[]interface{}{"true", "false"}, BuildConfig{
{[]any{"true", "false"}, BuildConfig{
Render: Always,
List: Never,
PublishResources: true,
set: true,
}},
{[]interface{}{`"always"`, `"always"`}, BuildConfig{
{[]any{`"always"`, `"always"`}, BuildConfig{
Render: Always,
List: Always,
PublishResources: true,
set: true,
}},
{[]interface{}{`"never"`, `"never"`}, BuildConfig{
{[]any{`"never"`, `"never"`}, BuildConfig{
Render: Never,
List: Never,
PublishResources: true,
set: true,
}},
{[]interface{}{`"link"`, `"local"`}, BuildConfig{
{[]any{`"link"`, `"local"`}, BuildConfig{
Render: Link,
List: ListLocally,
PublishResources: true,
set: true,
}},
{[]interface{}{`"always"`, `"asdfadf"`}, BuildConfig{
{[]any{`"always"`, `"asdfadf"`}, BuildConfig{
Render: Always,
List: Always,
PublishResources: true,