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

@@ -19,7 +19,7 @@ import (
"github.com/spf13/cast"
)
func Param(r ResourceParamsProvider, fallback maps.Params, key interface{}) (interface{}, error) {
func Param(r ResourceParamsProvider, fallback maps.Params, key any) (any, error) {
keyStr, err := cast.ToStringE(key)
if err != nil {
return nil, err

View File

@@ -24,17 +24,17 @@ import (
// GetParam will return the param with the given key from the Resource,
// nil if not found.
func GetParam(r Resource, key string) interface{} {
func GetParam(r Resource, key string) any {
return getParam(r, key, false)
}
// GetParamToLower is the same as GetParam but it will lower case any string
// result, including string slices.
func GetParamToLower(r Resource, key string) interface{} {
func GetParamToLower(r Resource, key string) any {
return getParam(r, key, true)
}
func getParam(r Resource, key string, stringToLower bool) interface{} {
func getParam(r Resource, key string, stringToLower bool) any {
v := r.Params()[strings.ToLower(key)]
if v == nil {
@@ -60,9 +60,9 @@ func getParam(r Resource, key string, stringToLower bool) interface{} {
return helpers.SliceToLower(val)
}
return v
case map[string]interface{}: // JSON and TOML
case map[string]any:
return v
case map[interface{}]interface{}: // YAML
case map[any]any:
return v
}

View File

@@ -108,7 +108,7 @@ func (r Resources) MergeByLanguage(r2 Resources) Resources {
// MergeByLanguageInterface is the generic version of MergeByLanguage. It
// is here just so it can be called from the tpl package.
func (r Resources) MergeByLanguageInterface(in interface{}) (interface{}, error) {
func (r Resources) MergeByLanguageInterface(in any) (any, error) {
r2, ok := in.(Resources)
if !ok {
return nil, fmt.Errorf("%T cannot be merged by language", in)

View File

@@ -66,7 +66,7 @@ type ImageOps interface {
Fill(spec string) (Image, error)
Fit(spec string) (Image, error)
Resize(spec string) (Image, error)
Filter(filters ...interface{}) (Image, error)
Filter(filters ...any) (Image, error)
Exif() *exif.Exif
// Internal
@@ -119,7 +119,7 @@ type ResourceParamsProvider interface {
type ResourceDataProvider interface {
// Resource specific data set by Hugo.
// One example would be.Data.Digest for fingerprinted resources.
Data() interface{}
Data() any
}
// ResourcesLanguageMerger describes an interface for merging resources from a
@@ -127,7 +127,7 @@ type ResourceDataProvider interface {
type ResourcesLanguageMerger interface {
MergeByLanguage(other Resources) Resources
// Needed for integration with the tpl package.
MergeByLanguageInterface(other interface{}) (interface{}, error)
MergeByLanguageInterface(other any) (any, error)
}
// Identifier identifies a resource.
@@ -152,7 +152,7 @@ type ContentProvider interface {
// * Page: template.HTML
// * JSON: String
// * Etc.
Content() (interface{}, error)
Content() (any, error)
}
// OpenReadSeekCloser allows setting some other way (than reading from a filesystem)