diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-03-17 22:03:27 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-03-17 22:03:27 +0100 |
commit | b80853de90b10171155b8f3fde47d64ec7bfa0dd (patch) | |
tree | 435d3dbf7a495a0c6ce64c9769e037179aa0d27b /commands | |
parent | 423594e03a906ef4150f433666ff588b022c3c92 (diff) |
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'commands')
-rw-r--r-- | commands/commandeer.go | 6 | ||||
-rw-r--r-- | commands/config.go | 14 | ||||
-rw-r--r-- | commands/convert.go | 2 | ||||
-rw-r--r-- | commands/deploy.go | 1 | ||||
-rw-r--r-- | commands/helpers.go | 6 | ||||
-rw-r--r-- | commands/import_jekyll.go | 10 | ||||
-rw-r--r-- | commands/import_jekyll_test.go | 46 | ||||
-rw-r--r-- | commands/limit_others.go | 1 | ||||
-rw-r--r-- | commands/list.go | 10 | ||||
-rw-r--r-- | commands/nodeploy.go | 1 | ||||
-rw-r--r-- | commands/release.go | 1 | ||||
-rw-r--r-- | commands/release_noop.go | 1 | ||||
-rw-r--r-- | commands/server.go | 4 |
13 files changed, 54 insertions, 49 deletions
diff --git a/commands/commandeer.go b/commands/commandeer.go index bf42501e0..507ec430d 100644 --- a/commands/commandeer.go +++ b/commands/commandeer.go @@ -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() @@ -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") } diff --git a/commands/config.go b/commands/config.go index 645331953..7fda2d40e 100644 --- a/commands/config.go +++ b/commands/config.go @@ -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"` }{ diff --git a/commands/convert.go b/commands/convert.go index 8c84423f5..d3cad2bd6 100644 --- a/commands/convert.go +++ b/commands/convert.go @@ -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 diff --git a/commands/deploy.go b/commands/deploy.go index 2b6d91246..071e10a6a 100644 --- a/commands/deploy.go +++ b/commands/deploy.go @@ -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 diff --git a/commands/helpers.go b/commands/helpers.go index 8bd7b18a3..71f686953 100644 --- a/commands/helpers.go +++ b/commands/helpers.go @@ -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} } diff --git a/commands/import_jekyll.go b/commands/import_jekyll.go index b9ea56d4b..4f17b2e39 100644 --- a/commands/import_jekyll.go +++ b/commands/import_jekyll.go @@ -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) @@ -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/" @@ -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", @@ -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 @@ -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") diff --git a/commands/import_jekyll_test.go b/commands/import_jekyll_test.go index 3819d03a5..dbe4e25d0 100644 --- a/commands/import_jekyll_test.go +++ b/commands/import_jekyll_test.go @@ -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"}`, }, @@ -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", }, diff --git a/commands/limit_others.go b/commands/limit_others.go index 8d3e6ad70..b141b7004 100644 --- a/commands/limit_others.go +++ b/commands/limit_others.go @@ -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 diff --git a/commands/list.go b/commands/list.go index d62672f61..f4321d031 100644 --- a/commands/list.go +++ b/commands/list.go @@ -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) @@ -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) } @@ -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) } @@ -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) } @@ -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, diff --git a/commands/nodeploy.go b/commands/nodeploy.go index 363602c51..061ea503e 100644 --- a/commands/nodeploy.go +++ b/commands/nodeploy.go @@ -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 diff --git a/commands/release.go b/commands/release.go index 3b78590e6..6decda9ea 100644 --- a/commands/release.go +++ b/commands/release.go @@ -1,3 +1,4 @@ +//go:build release // +build release // Copyright 2017-present The Hugo Authors. All rights reserved. diff --git a/commands/release_noop.go b/commands/release_noop.go index ccf34b68e..176dc9794 100644 --- a/commands/release_noop.go +++ b/commands/release_noop.go @@ -1,3 +1,4 @@ +//go:build !release // +build !release // Copyright 2018 The Hugo Authors. All rights reserved. diff --git a/commands/server.go b/commands/server.go index 89ece40ae..4dd9116c7 100644 --- a/commands/server.go +++ b/commands/server.go @@ -304,7 +304,7 @@ func getRootWatchDirsStr(baseDir string, watchDirs []string) string { type fileServer struct { baseURLs []string roots []string - errorTemplate func(err interface{}) (io.Reader, error) + errorTemplate func(err any) (io.Reader, error) c *commandeer s *serverCmd } @@ -497,7 +497,7 @@ func (c *commandeer) serve(s *serverCmd) error { roots: roots, c: c, s: s, - errorTemplate: func(ctx interface{}) (io.Reader, error) { + errorTemplate: func(ctx any) (io.Reader, error) { b := &bytes.Buffer{} err := c.hugo().Tmpl().Execute(templ, b, ctx) return b, err |