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

@@ -33,18 +33,18 @@ import (
// Unmarshal unmarshals the data given, which can be either a string, json.RawMessage
// or a Resource. Supported formats are JSON, TOML, YAML, and CSV.
// You can optionally provide an options map as the first argument.
func (ns *Namespace) Unmarshal(args ...interface{}) (interface{}, error) {
func (ns *Namespace) Unmarshal(args ...any) (any, error) {
if len(args) < 1 || len(args) > 2 {
return nil, errors.New("unmarshal takes 1 or 2 arguments")
}
var data interface{}
var data any
decoder := metadecoders.Default
if len(args) == 1 {
data = args[0]
} else {
m, ok := args[0].(map[string]interface{})
m, ok := args[0].(map[string]any)
if !ok {
return nil, errors.New("first argument must be a map")
}
@@ -69,7 +69,7 @@ func (ns *Namespace) Unmarshal(args ...interface{}) (interface{}, error) {
key += decoder.OptionsKey()
}
return ns.cache.GetOrCreate(key, func() (interface{}, error) {
return ns.cache.GetOrCreate(key, func() (any, error) {
f := metadecoders.FormatFromMediaType(r.MediaType())
if f == "" {
return nil, errors.Errorf("MIME %q not supported", r.MediaType())
@@ -101,7 +101,7 @@ func (ns *Namespace) Unmarshal(args ...interface{}) (interface{}, error) {
key := helpers.MD5String(dataStr)
return ns.cache.GetOrCreate(key, func() (interface{}, error) {
return ns.cache.GetOrCreate(key, func() (any, error) {
f := decoder.FormatFromContentString(dataStr)
if f == "" {
return nil, errors.New("unknown format")
@@ -111,7 +111,7 @@ func (ns *Namespace) Unmarshal(args ...interface{}) (interface{}, error) {
})
}
func decodeDecoder(m map[string]interface{}) (metadecoders.Decoder, error) {
func decodeDecoder(m map[string]any) (metadecoders.Decoder, error) {
opts := metadecoders.Default
if m == nil {
@@ -144,7 +144,7 @@ func decodeDecoder(m map[string]interface{}) (metadecoders.Decoder, error) {
return opts, err
}
func stringToRune(v interface{}) (rune, error) {
func stringToRune(v any) (rune, error) {
s, err := cast.ToStringE(v)
if err != nil {
return 0, err