Skip to content

Commit

Permalink
all: gofmt -w -r 'interface{} -> any' .
Browse files Browse the repository at this point in the history
Updates #9687
  • Loading branch information
bep committed Mar 17, 2022
1 parent 423594e commit b80853d
Show file tree
Hide file tree
Showing 342 changed files with 2,118 additions and 2,102 deletions.
2 changes: 1 addition & 1 deletion bufferpool/bufpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
)

var bufferPool = &sync.Pool{
New: func() interface{} {
New: func() any {
return &bytes.Buffer{}
},
}
Expand Down
4 changes: 2 additions & 2 deletions cache/namedmemcache/named_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Cache struct {
}

type cacheEntry struct {
value interface{}
value any
err error
}

Expand All @@ -55,7 +55,7 @@ func (c *Cache) Clear() {
// create will be called and cached.
// This method is thread safe. It also guarantees that the create func for a given
// key is invoked only once for this cache.
func (c *Cache) GetOrCreate(key string, create func() (interface{}, error)) (interface{}, error) {
func (c *Cache) GetOrCreate(key string, create func() (any, error)) (any, error) {
c.mu.RLock()
entry, found := c.cache[key]
c.mu.RUnlock()
Expand Down
6 changes: 3 additions & 3 deletions cache/namedmemcache/named_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestNamedCache(t *testing.T) {
cache := New()

counter := 0
create := func() (interface{}, error) {
create := func() (any, error) {
counter++
return counter, nil
}
Expand Down Expand Up @@ -58,8 +58,8 @@ func TestNamedCacheConcurrent(t *testing.T) {

cache := New()

create := func(i int) func() (interface{}, error) {
return func() (interface{}, error) {
create := func(i int) func() (any, error) {
return func() (any, error) {
return i, nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion codegen/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ func typeName(name, pkg string) string {

func uniqueNonEmptyStrings(s []string) []string {
var unique []string
set := map[string]interface{}{}
set := map[string]any{}
for _, val := range s {
if val == "" {
continue
Expand Down
2 changes: 1 addition & 1 deletion codegen/methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ type I interface {
Method3(myint int, mystring string)
Method5() (string, error)
Method6() *net.IP
Method7() interface{}
Method7() any
Method8() herrors.ErrorContext
method2()
method9() os.FileInfo
Expand Down
6 changes: 3 additions & 3 deletions commands/commandeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ func (c *commandeer) errCount() int {
return int(c.logger.LogCounters().ErrorCounter.Count())
}

func (c *commandeer) getErrorWithContext() interface{} {
func (c *commandeer) getErrorWithContext() any {
errCount := c.errCount()

if errCount == 0 {
return nil
}

m := make(map[string]interface{})
m := make(map[string]any)

m["Error"] = errors.New(removeErrorPrefixFromLog(c.logger.Errors()))
m["Version"] = hugo.BuildVersionString()
Expand All @@ -146,7 +146,7 @@ func (c *commandeer) getErrorWithContext() interface{} {
return m
}

func (c *commandeer) Set(key string, value interface{}) {
func (c *commandeer) Set(key string, value any) {
if c.configured {
panic("commandeer cannot be changed")
}
Expand Down
14 changes: 7 additions & 7 deletions commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
if m.verbose {
config := m.m.Config()
return json.Marshal(&struct {
Path string `json:"path"`
Version string `json:"version"`
Time time.Time `json:"time"`
Owner string `json:"owner"`
Dir string `json:"dir"`
Meta map[string]interface{} `json:"meta"`
HugoVersion modules.HugoVersion `json:"hugoVersion"`
Path string `json:"path"`
Version string `json:"version"`
Time time.Time `json:"time"`
Owner string `json:"owner"`
Dir string `json:"dir"`
Meta map[string]any `json:"meta"`
HugoVersion modules.HugoVersion `json:"hugoVersion"`

Mounts []modMount `json:"mounts"`
}{
Expand Down
2 changes: 1 addition & 1 deletion commands/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (cc *convertCmd) convertAndSavePage(p page.Page, site *hugolib.Site, target
type parsedFile struct {
frontMatterFormat metadecoders.Format
frontMatterSource []byte
frontMatter map[string]interface{}
frontMatter map[string]any

// Everything after Front Matter
content []byte
Expand Down
1 change: 1 addition & 0 deletions commands/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !nodeploy
// +build !nodeploy

package commands
Expand Down
6 changes: 3 additions & 3 deletions commands/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ func (c commandError) isUserError() bool {
return c.userError
}

func newUserError(a ...interface{}) commandError {
func newUserError(a ...any) commandError {
return commandError{s: fmt.Sprintln(a...), userError: true}
}

func newSystemError(a ...interface{}) commandError {
func newSystemError(a ...any) commandError {
return commandError{s: fmt.Sprintln(a...), userError: false}
}

func newSystemErrorF(format string, a ...interface{}) commandError {
func newSystemErrorF(format string, a ...any) commandError {
return commandError{s: fmt.Sprintf(format, a...), userError: false}
}

Expand Down
10 changes: 5 additions & 5 deletions commands/import_jekyll.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (i *importCmd) createSiteFromJekyll(jekyllRoot, targetDir string, jekyllPos
return nil
}

func (i *importCmd) loadJekyllConfig(fs afero.Fs, jekyllRoot string) map[string]interface{} {
func (i *importCmd) loadJekyllConfig(fs afero.Fs, jekyllRoot string) map[string]any {
path := filepath.Join(jekyllRoot, "_config.yml")

exists, err := helpers.Exists(path, fs)
Expand Down Expand Up @@ -265,7 +265,7 @@ func (i *importCmd) loadJekyllConfig(fs afero.Fs, jekyllRoot string) map[string]
return c
}

func (i *importCmd) createConfigFromJekyll(fs afero.Fs, inpath string, kind metadecoders.Format, jekyllConfig map[string]interface{}) (err error) {
func (i *importCmd) createConfigFromJekyll(fs afero.Fs, inpath string, kind metadecoders.Format, jekyllConfig map[string]any) (err error) {
title := "My New Hugo Site"
baseURL := "http://example.org/"

Expand All @@ -285,7 +285,7 @@ func (i *importCmd) createConfigFromJekyll(fs afero.Fs, inpath string, kind meta
}
}

in := map[string]interface{}{
in := map[string]any{
"baseURL": baseURL,
"title": title,
"languageCode": "en-us",
Expand Down Expand Up @@ -423,7 +423,7 @@ func convertJekyllPost(path, relPath, targetDir string, draft bool) error {
return nil
}

func convertJekyllMetaData(m interface{}, postName string, postDate time.Time, draft bool) (interface{}, error) {
func convertJekyllMetaData(m any, postName string, postDate time.Time, draft bool) (any, error) {
metadata, err := maps.ToStringMapE(m)
if err != nil {
return nil, err
Expand Down Expand Up @@ -475,7 +475,7 @@ func convertJekyllMetaData(m interface{}, postName string, postDate time.Time, d
return metadata, nil
}

func convertJekyllContent(m interface{}, content string) (string, error) {
func convertJekyllContent(m any, content string) (string, error) {
metadata, _ := maps.ToStringMapE(m)

lines := strings.Split(content, "\n")
Expand Down
46 changes: 23 additions & 23 deletions commands/import_jekyll_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,44 +47,44 @@ func TestParseJekyllFilename(t *testing.T) {
func TestConvertJekyllMetadata(t *testing.T) {
c := qt.New(t)
testDataList := []struct {
metadata interface{}
metadata any
postName string
postDate time.Time
draft bool
expect string
}{
{
map[interface{}]interface{}{},
map[any]any{},
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
`{"date":"2015-10-01T00:00:00Z"}`,
},
{
map[interface{}]interface{}{},
map[any]any{},
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), true,
`{"date":"2015-10-01T00:00:00Z","draft":true}`,
},
{
map[interface{}]interface{}{"Permalink": "/permalink.html", "layout": "post"},
map[any]any{"Permalink": "/permalink.html", "layout": "post"},
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
`{"date":"2015-10-01T00:00:00Z","url":"/permalink.html"}`,
},
{
map[interface{}]interface{}{"permalink": "/permalink.html"},
map[any]any{"permalink": "/permalink.html"},
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
`{"date":"2015-10-01T00:00:00Z","url":"/permalink.html"}`,
},
{
map[interface{}]interface{}{"category": nil, "permalink": 123},
map[any]any{"category": nil, "permalink": 123},
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
`{"date":"2015-10-01T00:00:00Z"}`,
},
{
map[interface{}]interface{}{"Excerpt_Separator": "sep"},
map[any]any{"Excerpt_Separator": "sep"},
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
`{"date":"2015-10-01T00:00:00Z","excerpt_separator":"sep"}`,
},
{
map[interface{}]interface{}{"category": "book", "layout": "post", "Others": "Goods", "Date": "2015-10-01 12:13:11"},
map[any]any{"category": "book", "layout": "post", "Others": "Goods", "Date": "2015-10-01 12:13:11"},
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
`{"Others":"Goods","categories":["book"],"date":"2015-10-01T12:13:11Z"}`,
},
Expand All @@ -102,69 +102,69 @@ func TestConvertJekyllMetadata(t *testing.T) {
func TestConvertJekyllContent(t *testing.T) {
c := qt.New(t)
testDataList := []struct {
metadata interface{}
metadata any
content string
expect string
}{
{
map[interface{}]interface{}{},
map[any]any{},
"Test content\r\n<!-- more -->\npart2 content", "Test content\n<!--more-->\npart2 content",
},
{
map[interface{}]interface{}{},
map[any]any{},
"Test content\n<!-- More -->\npart2 content", "Test content\n<!--more-->\npart2 content",
},
{
map[interface{}]interface{}{"excerpt_separator": "<!--sep-->"},
map[any]any{"excerpt_separator": "<!--sep-->"},
"Test content\n<!--sep-->\npart2 content",
"---\nexcerpt_separator: <!--sep-->\n---\nTest content\n<!--more-->\npart2 content",
},
{map[interface{}]interface{}{}, "{% raw %}text{% endraw %}", "text"},
{map[interface{}]interface{}{}, "{%raw%} text2 {%endraw %}", "text2"},
{map[any]any{}, "{% raw %}text{% endraw %}", "text"},
{map[any]any{}, "{%raw%} text2 {%endraw %}", "text2"},
{
map[interface{}]interface{}{},
map[any]any{},
"{% highlight go %}\nvar s int\n{% endhighlight %}",
"{{< highlight go >}}\nvar s int\n{{< / highlight >}}",
},
{
map[interface{}]interface{}{},
map[any]any{},
"{% highlight go linenos hl_lines=\"1 2\" %}\nvar s string\nvar i int\n{% endhighlight %}",
"{{< highlight go \"linenos=table,hl_lines=1 2\" >}}\nvar s string\nvar i int\n{{< / highlight >}}",
},

// Octopress image tag
{
map[interface{}]interface{}{},
map[any]any{},
"{% img http://placekitten.com/890/280 %}",
"{{< figure src=\"http://placekitten.com/890/280\" >}}",
},
{
map[interface{}]interface{}{},
map[any]any{},
"{% img left http://placekitten.com/320/250 Place Kitten #2 %}",
"{{< figure class=\"left\" src=\"http://placekitten.com/320/250\" title=\"Place Kitten #2\" >}}",
},
{
map[interface{}]interface{}{},
map[any]any{},
"{% img right http://placekitten.com/300/500 150 250 'Place Kitten #3' %}",
"{{< figure class=\"right\" src=\"http://placekitten.com/300/500\" width=\"150\" height=\"250\" title=\"Place Kitten #3\" >}}",
},
{
map[interface{}]interface{}{},
map[any]any{},
"{% img right http://placekitten.com/300/500 150 250 'Place Kitten #4' 'An image of a very cute kitten' %}",
"{{< figure class=\"right\" src=\"http://placekitten.com/300/500\" width=\"150\" height=\"250\" title=\"Place Kitten #4\" alt=\"An image of a very cute kitten\" >}}",
},
{
map[interface{}]interface{}{},
map[any]any{},
"{% img http://placekitten.com/300/500 150 250 'Place Kitten #4' 'An image of a very cute kitten' %}",
"{{< figure src=\"http://placekitten.com/300/500\" width=\"150\" height=\"250\" title=\"Place Kitten #4\" alt=\"An image of a very cute kitten\" >}}",
},
{
map[interface{}]interface{}{},
map[any]any{},
"{% img right /placekitten/300/500 'Place Kitten #4' 'An image of a very cute kitten' %}",
"{{< figure class=\"right\" src=\"/placekitten/300/500\" title=\"Place Kitten #4\" alt=\"An image of a very cute kitten\" >}}",
},
{
map[interface{}]interface{}{"category": "book", "layout": "post", "Date": "2015-10-01 12:13:11"},
map[any]any{"category": "book", "layout": "post", "Date": "2015-10-01 12:13:11"},
"somecontent",
"---\nDate: \"2015-10-01 12:13:11\"\ncategory: book\nlayout: post\n---\nsomecontent",
},
Expand Down
1 change: 1 addition & 0 deletions commands/limit_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !darwin
// +build !darwin

package commands
Expand Down
10 changes: 5 additions & 5 deletions commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type listCmd struct {
*baseBuilderCmd
}

func (lc *listCmd) buildSites(config map[string]interface{}) (*hugolib.HugoSites, error) {
func (lc *listCmd) buildSites(config map[string]any) (*hugolib.HugoSites, error) {
cfgInit := func(c *commandeer) error {
for key, value := range config {
c.Set(key, value)
Expand Down Expand Up @@ -75,7 +75,7 @@ List requires a subcommand, e.g. ` + "`hugo list drafts`.",
Short: "List all drafts",
Long: `List all of the drafts in your content directory.`,
RunE: func(cmd *cobra.Command, args []string) error {
sites, err := cc.buildSites(map[string]interface{}{"buildDrafts": true})
sites, err := cc.buildSites(map[string]any{"buildDrafts": true})
if err != nil {
return newSystemError("Error building sites", err)
}
Expand All @@ -94,7 +94,7 @@ List requires a subcommand, e.g. ` + "`hugo list drafts`.",
Short: "List all posts dated in the future",
Long: `List all of the posts in your content directory which will be posted in the future.`,
RunE: func(cmd *cobra.Command, args []string) error {
sites, err := cc.buildSites(map[string]interface{}{"buildFuture": true})
sites, err := cc.buildSites(map[string]any{"buildFuture": true})
if err != nil {
return newSystemError("Error building sites", err)
}
Expand Down Expand Up @@ -122,7 +122,7 @@ List requires a subcommand, e.g. ` + "`hugo list drafts`.",
Short: "List all posts already expired",
Long: `List all of the posts in your content directory which has already expired.`,
RunE: func(cmd *cobra.Command, args []string) error {
sites, err := cc.buildSites(map[string]interface{}{"buildExpired": true})
sites, err := cc.buildSites(map[string]any{"buildExpired": true})
if err != nil {
return newSystemError("Error building sites", err)
}
Expand Down Expand Up @@ -150,7 +150,7 @@ List requires a subcommand, e.g. ` + "`hugo list drafts`.",
Short: "List all posts",
Long: `List all of the posts in your content directory, include drafts, future and expired pages.`,
RunE: func(cmd *cobra.Command, args []string) error {
sites, err := cc.buildSites(map[string]interface{}{
sites, err := cc.buildSites(map[string]any{
"buildExpired": true,
"buildDrafts": true,
"buildFuture": true,
Expand Down
1 change: 1 addition & 0 deletions commands/nodeploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build nodeploy
// +build nodeploy

package commands
Expand Down
1 change: 1 addition & 0 deletions commands/release.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build release
// +build release

// Copyright 2017-present The Hugo Authors. All rights reserved.
Expand Down
Loading

0 comments on commit b80853d

Please sign in to comment.