From d90e37e0c6e812f9913bf256c9c81aa05b7a08aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 2 Dec 2020 13:23:25 +0100 Subject: all: Format code with gofumpt See https://github.com/mvdan/gofumpt --- hugolib/404_test.go | 2 - hugolib/alias.go | 1 - hugolib/alias_test.go | 6 +- hugolib/breaking_changes_test.go | 11 -- hugolib/cascade_test.go | 11 -- hugolib/case_insensitive_test.go | 2 - hugolib/config.go | 11 -- hugolib/config_test.go | 6 - hugolib/configdir_test.go | 2 - hugolib/content_map.go | 14 +- hugolib/content_map_page.go | 8 -- hugolib/content_map_test.go | 12 -- hugolib/content_render_hooks_test.go | 11 -- hugolib/datafiles_test.go | 13 +- hugolib/disableKinds_test.go | 8 +- hugolib/embedded_shortcodes_test.go | 10 +- hugolib/embedded_templates_test.go | 1 - hugolib/fileInfo.go | 2 - hugolib/filesystems/basefs.go | 18 +-- hugolib/filesystems/basefs_test.go | 4 - hugolib/gitinfo.go | 1 - hugolib/hugo_modules_test.go | 28 +--- hugolib/hugo_sites.go | 15 +-- hugolib/hugo_sites_build.go | 12 -- hugolib/hugo_sites_build_errors_test.go | 10 -- hugolib/hugo_sites_build_test.go | 20 +-- hugolib/hugo_sites_multihost_test.go | 3 +- hugolib/hugo_sites_rebuild_test.go | 8 -- hugolib/hugo_smoke_test.go | 4 +- hugolib/image_test.go | 4 - hugolib/js_test.go | 2 - hugolib/language_content_dir_test.go | 11 +- hugolib/language_test.go | 1 - hugolib/menu_test.go | 10 +- hugolib/multilingual.go | 4 +- hugolib/openapi_test.go | 1 - hugolib/page.go | 11 -- hugolib/page__content.go | 1 - hugolib/page__data.go | 1 - hugolib/page__menus.go | 3 - hugolib/page__meta.go | 9 +- hugolib/page__new.go | 9 +- hugolib/page__output.go | 4 - hugolib/page__paginator.go | 2 - hugolib/page__paths.go | 6 +- hugolib/page__per_output.go | 8 -- hugolib/page__position.go | 1 - hugolib/page__ref.go | 2 - hugolib/page__tree.go | 3 - hugolib/page_kinds.go | 7 +- hugolib/page_permalink_test.go | 3 - hugolib/page_test.go | 39 ++---- hugolib/pagebundler_test.go | 29 +--- hugolib/pagecollections.go | 2 - hugolib/pagecollections_test.go | 18 +-- hugolib/pages_capture.go | 18 +-- hugolib/pages_capture_test.go | 5 +- hugolib/pages_language_merge_test.go | 1 - hugolib/pages_process.go | 2 - hugolib/pages_test.go | 14 +- hugolib/paginator_test.go | 2 - hugolib/paths/paths.go | 3 - hugolib/permalinker.go | 4 +- hugolib/resource_chain_babel_test.go | 1 - hugolib/resource_chain_test.go | 28 +--- hugolib/robotstxt_test.go | 1 - hugolib/shortcode.go | 34 ++--- hugolib/shortcode_test.go | 119 +++++++++-------- hugolib/site.go | 36 ++--- hugolib/siteJSONEncode_test.go | 1 - hugolib/site_benchmark_new_test.go | 230 ++++++++++++++++---------------- hugolib/site_output.go | 3 - hugolib/site_output_test.go | 16 +-- hugolib/site_render.go | 11 +- hugolib/site_sections_test.go | 9 -- hugolib/site_stats_test.go | 4 +- hugolib/site_test.go | 32 +---- hugolib/site_url_test.go | 7 +- hugolib/sitemap_test.go | 7 +- hugolib/taxonomy_test.go | 17 +-- hugolib/template_test.go | 34 +---- hugolib/testhelpers_test.go | 38 ++---- 82 files changed, 305 insertions(+), 817 deletions(-) (limited to 'hugolib') diff --git a/hugolib/404_test.go b/hugolib/404_test.go index cd203a669..383302e0b 100644 --- a/hugolib/404_test.go +++ b/hugolib/404_test.go @@ -57,7 +57,6 @@ Page: /404.html| Data: 1| `) - } func Test404WithBase(t *testing.T) { @@ -77,5 +76,4 @@ Page not found b.AssertFileContent("public/404.html", ` Base: Page not found`) - } diff --git a/hugolib/alias.go b/hugolib/alias.go index 6272b7910..891098c9d 100644 --- a/hugolib/alias.go +++ b/hugolib/alias.go @@ -47,7 +47,6 @@ type aliasPage struct { } func (a aliasHandler) renderAlias(permalink string, p page.Page) (io.Reader, error) { - var templ tpl.Template var found bool diff --git a/hugolib/alias_test.go b/hugolib/alias_test.go index 8f3b756ec..d5ffc06fe 100644 --- a/hugolib/alias_test.go +++ b/hugolib/alias_test.go @@ -38,8 +38,10 @@ outputs: ["HTML", "AMP", "JSON"] For some moments the old man did not reply. He stood with bowed head, buried in deep thought. But at last he spoke. ` -const basicTemplate = "{{.Content}}" -const aliasTemplate = "ALIASTEMPLATE" +const ( + basicTemplate = "{{.Content}}" + aliasTemplate = "ALIASTEMPLATE" +) func TestAlias(t *testing.T) { t.Parallel() diff --git a/hugolib/breaking_changes_test.go b/hugolib/breaking_changes_test.go index c935d6e93..a22bc240f 100644 --- a/hugolib/breaking_changes_test.go +++ b/hugolib/breaking_changes_test.go @@ -21,11 +21,9 @@ import ( ) func Test073(t *testing.T) { - asertDisabledTaxonomyAndTerm := func(b *sitesBuilder, taxonomy, term bool) { b.Assert(b.CheckExists("public/tags/index.html"), qt.Equals, taxonomy) b.Assert(b.CheckExists("public/tags/tag1/index.html"), qt.Equals, term) - } assertOutputTaxonomyAndTerm := func(b *sitesBuilder, taxonomy, term bool) { @@ -48,7 +46,6 @@ func Test073(t *testing.T) { func(err error, out string, b *sitesBuilder) { b.Assert(err, qt.IsNil) assertOutputTaxonomyAndTerm(b, true, true) - }, }, { @@ -60,7 +57,6 @@ taxonomyTerm = ["JSON"] func(err error, out string, b *sitesBuilder) { b.Assert(err, qt.IsNil) assertOutputTaxonomyAndTerm(b, true, false) - }, }, { @@ -72,7 +68,6 @@ taxonomy = ["JSON"] func(err error, out string, b *sitesBuilder) { b.Assert(err, qt.Not(qt.IsNil)) b.Assert(out, qt.Contains, `ignoreErrors = ["error-output-taxonomy"]`) - }, }, { @@ -86,7 +81,6 @@ taxonomy = ["JSON"] func(err error, out string, b *sitesBuilder) { b.Assert(err, qt.IsNil) assertOutputTaxonomyAndTerm(b, true, false) - }, }, { @@ -95,7 +89,6 @@ taxonomy = ["JSON"] func(err error, out string, b *sitesBuilder) { b.Assert(err, qt.IsNil) asertDisabledTaxonomyAndTerm(b, false, false) - }, }, { @@ -104,7 +97,6 @@ taxonomy = ["JSON"] func(err error, out string, b *sitesBuilder) { b.Assert(err, qt.IsNil) asertDisabledTaxonomyAndTerm(b, false, true) - }, }, { @@ -125,7 +117,6 @@ taxonomy = ["JSON"] }, }, } { - t.Run(this.name, func(t *testing.T) { b := newTestSitesBuilder(t).WithConfigFile("toml", this.config) b.WithTemplatesAdded("_default/list.json", "JSON") @@ -135,7 +126,5 @@ taxonomy = ["JSON"] fmt.Println(out) this.assert(err, out, b) }) - } - } diff --git a/hugolib/cascade_test.go b/hugolib/cascade_test.go index a112fe10c..78409a4b1 100644 --- a/hugolib/cascade_test.go +++ b/hugolib/cascade_test.go @@ -51,7 +51,6 @@ func BenchmarkCascade(b *testing.B) { } func TestCascade(t *testing.T) { - allLangs := []string{"en", "nn", "nb", "sv"} langs := allLangs[:3] @@ -101,9 +100,7 @@ func TestCascade(t *testing.T) { // Check cascade into bundled page b.AssertFileContent("public/bundle1/index.html", `Resources: bp1.md|home.png|`) - }) - } func TestCascadeEdit(t *testing.T) { @@ -252,7 +249,6 @@ func newCascadeTestBuilder(t testing.TB, langs []string) *sitesBuilder { metaStr := "---\n" + yamlStr + "\n---" return metaStr - } createLangConfig := func(lang string) string { @@ -290,7 +286,6 @@ defaultContentLanguageInSubDir = false b := newTestSitesBuilder(t).WithConfigFile("toml", config) createContentFiles := func(lang string) { - withContent := func(filenameContent ...string) { for i := 0; i < len(filenameContent); i += 2 { b.WithContent(path.Join(lang, filenameContent[i]), filenameContent[i+1]) @@ -414,7 +409,6 @@ S1|p1:{{ $s1.Params.p1 }}|p2:{{ $s1.Params.p2 }}| b.WithContent("s2/p1/index.md", "---\ntitle: p1_2\n---") return b - } c.Run("slice", func(c *qt.C) { @@ -431,7 +425,6 @@ p2 = "p2" b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", "P1|p1:p1|p2:p2") - }) c.Run("slice with _target", func(c *qt.C) { @@ -456,7 +449,6 @@ kind="section" P1|p1:p1|p2:| S1|p1:|p2:p2| `) - }) c.Run("slice with yaml _target", func(c *qt.C) { @@ -480,7 +472,6 @@ cascade: P1|p1:p1|p2:| S1|p1:|p2:p2| `) - }) c.Run("slice with json _target", func(c *qt.C) { @@ -510,7 +501,5 @@ S1|p1:|p2:p2| P1|p1:p1|p2:| S1|p1:|p2:p2| `) - }) - } diff --git a/hugolib/case_insensitive_test.go b/hugolib/case_insensitive_test.go index 42b9d7ef6..9aa88ab5b 100644 --- a/hugolib/case_insensitive_test.go +++ b/hugolib/case_insensitive_test.go @@ -127,7 +127,6 @@ Partial Site Global: {{ site.Params.COLOR }}|{{ site.Params.COLORS.YELLOW }} `) writeToFs(t, fs, "config.toml", caseMixingSiteConfigTOML) - } func TestCaseInsensitiveConfigurationVariations(t *testing.T) { @@ -184,7 +183,6 @@ Page2: {{ $page2.Params.ColoR }} `) sites, err := NewHugoSites(deps.DepsCfg{Fs: fs, Cfg: cfg}) - if err != nil { t.Fatalf("Failed to create sites: %s", err) } diff --git a/hugolib/config.go b/hugolib/config.go index 9acb7d701..5ef78acf4 100644 --- a/hugolib/config.go +++ b/hugolib/config.go @@ -123,7 +123,6 @@ var ErrNoConfigFile = errors.New("Unable to locate config file or config directo // LoadConfig loads Hugo configuration into a new Viper and then adds // a set of defaults. func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provider) error) (*viper.Viper, []string, error) { - if d.Environment == "" { d.Environment = hugo.EnvironmentProduction } @@ -258,7 +257,6 @@ func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provid } return v, configFiles, err - } func loadLanguageSettings(cfg config.Provider, oldLangs langs.Languages) error { @@ -310,7 +308,6 @@ func (l configLoader) loadConfig(configName string, v *viper.Viper) (string, err } return filename, nil - } func (l configLoader) wrapFileError(err error, filename string) error { @@ -414,9 +411,7 @@ func (l configLoader) loadConfigFromConfigDir(v *viper.Viper) ([]string, error) } return nil - }) - if err != nil { return nil, err } @@ -427,7 +422,6 @@ func (l configLoader) loadConfigFromConfigDir(v *viper.Viper) ([]string, error) } func (l configLoader) loadModulesConfig(v1 *viper.Viper) (modules.Config, error) { - modConfig, err := modules.DecodeConfig(v1) if err != nil { return modules.Config{}, err @@ -475,7 +469,6 @@ func (l configLoader) collectModules(modConfig modules.Config, v1 *viper.Viper, } return nil - } modulesClient := modules.NewClient(modules.ClientConfig{ @@ -503,11 +496,9 @@ func (l configLoader) collectModules(modConfig modules.Config, v1 *viper.Viper, } return moduleConfig.ActiveModules, configFilenames, err - } func (l configLoader) applyThemeConfig(v1 *viper.Viper, theme modules.Module) error { - const ( paramsKey = "params" languagesKey = "languages" @@ -560,7 +551,6 @@ func (l configLoader) applyThemeConfig(v1 *viper.Viper, theme modules.Module) er } return nil - } func (configLoader) mergeStringMapKeepLeft(rootKey, key string, v1, v2 config.Provider) { @@ -587,7 +577,6 @@ func (configLoader) mergeStringMapKeepLeft(rootKey, key string, v1, v2 config.Pr } func loadDefaultSettingsFor(v *viper.Viper) error { - v.RegisterAlias("indexes", "taxonomies") /* diff --git a/hugolib/config_test.go b/hugolib/config_test.go index e8dce331d..aeeee5fa5 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -43,7 +43,6 @@ func TestLoadConfig(t *testing.T) { c.Assert(err, qt.IsNil) c.Assert(cfg.GetString("paginatePath"), qt.Equals, "side") - } func TestLoadMultiConfig(t *testing.T) { @@ -359,7 +358,6 @@ map[string]interface {}{ }, }, }`, got["menu"]) - } func TestPrivacyConfig(t *testing.T) { @@ -381,7 +379,6 @@ privacyEnhanced = true b.Build(BuildCfg{SkipRender: true}) c.Assert(b.H.Sites[0].Info.Config().Privacy.YouTube.PrivacyEnhanced, qt.Equals, true) - } func TestLoadConfigModules(t *testing.T) { @@ -477,11 +474,9 @@ project n4 ` c.Assert(graphb.String(), qt.Equals, expected) - } func TestLoadConfigWithOsEnvOverrides(t *testing.T) { - c := qt.New(t) baseConfig := ` @@ -534,5 +529,4 @@ quality = 75 c.Assert(cfg.Get("intSlice"), qt.DeepEquals, []interface{}{5, 8, 9}) c.Assert(cfg.Get("params.api_config.api_key"), qt.Equals, "new_key") c.Assert(cfg.Get("params.api_config.another_key"), qt.Equals, "default another_key") - } diff --git a/hugolib/configdir_test.go b/hugolib/configdir_test.go index bc1732fb2..aa1013ec0 100644 --- a/hugolib/configdir_test.go +++ b/hugolib/configdir_test.go @@ -123,7 +123,6 @@ p3 = "p3params_no_production" noMenus := cfg.Get("languages.no.menus.docs") c.Assert(noMenus, qt.Not(qt.IsNil)) c.Assert(len(noMenus.(([]map[string]interface{}))), qt.Equals, 1) - } func TestLoadConfigDirError(t *testing.T) { @@ -150,5 +149,4 @@ baseURL = "https://example.org" fe := herrors.UnwrapErrorWithFileContext(err) c.Assert(fe, qt.Not(qt.IsNil)) c.Assert(fe.Position().Filename, qt.Equals, filepath.FromSlash("config/development/config.toml")) - } diff --git a/hugolib/content_map.go b/hugolib/content_map.go index 652609e26..ca2aa3672 100644 --- a/hugolib/content_map.go +++ b/hugolib/content_map.go @@ -130,7 +130,7 @@ type cmInsertKeyBuilder struct { } func (b cmInsertKeyBuilder) ForPage(s string) *cmInsertKeyBuilder { - //fmt.Println("ForPage:", s, "baseKey:", b.baseKey, "key:", b.key) + // fmt.Println("ForPage:", s, "baseKey:", b.baseKey, "key:", b.key) baseKey := b.baseKey b.baseKey = s @@ -154,7 +154,7 @@ func (b cmInsertKeyBuilder) ForPage(s string) *cmInsertKeyBuilder { } func (b cmInsertKeyBuilder) ForResource(s string) *cmInsertKeyBuilder { - //fmt.Println("ForResource:", s, "baseKey:", b.baseKey, "key:", b.key) + // fmt.Println("ForResource:", s, "baseKey:", b.baseKey, "key:", b.key) baseKey := helpers.AddTrailingSlash(b.baseKey) s = strings.TrimPrefix(s, baseKey) @@ -287,7 +287,6 @@ func (c *contentBundleViewInfo) sections() []string { } return []string{c.name.plural, c.termKey} - } func (c *contentBundleViewInfo) term() string { @@ -393,7 +392,6 @@ func (m *contentMap) AddFilesBundle(header hugofs.FileMetaInfo, resources ...hug } return nil - } func (m *contentMap) CreateMissingNodes() error { @@ -462,7 +460,6 @@ func (m *contentMap) CreateMissingNodes() error { } return nil - } func (m *contentMap) getBundleDir(meta hugofs.FileMeta) string { @@ -611,7 +608,6 @@ func (m *contentMap) deleteBundleMatching(matches func(b *contentNode) bool) { if s != "" { m.resources.Delete(s) } - } // Deletes any empty root section that's not backed by a content file. @@ -686,7 +682,6 @@ func (m *contentMap) splitKey(k string) []string { } return strings.Split(k, "/")[1:] - } func (m *contentMap) testDump() string { @@ -701,7 +696,6 @@ func (m *contentMap) testDump() string { } for i, r := range []*contentTree{m.pages, m.sections} { - r.Walk(func(s string, v interface{}) bool { c := v.(*contentNode) cpToString := func(c *contentNode) string { @@ -730,7 +724,6 @@ func (m *contentMap) testDump() string { m.resources.WalkPrefix(resourcesPrefix, func(s string, v interface{}) bool { sb.WriteString("\t - R: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename()) + "\n") return false - }) return false @@ -738,7 +731,6 @@ func (m *contentMap) testDump() string { } return sb.String() - } type contentMapConfig struct { @@ -787,7 +779,6 @@ func (b *contentNode) rootSection() string { return b.path } return b.path[:firstSlash] - } type contentTree struct { @@ -906,7 +897,6 @@ func (c *contentTree) WalkBelow(prefix string, fn radix.WalkFn) { } return fn(s, v) }) - } func (c *contentTree) getMatch(matches func(b *contentNode) bool) string { diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index e79228ba3..296363359 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -225,7 +225,6 @@ func (m *pageMap) newPageFromContentNode(n *contentNode, parentBucket *pagesMapB } func (m *pageMap) newResource(fim hugofs.FileMetaInfo, owner *pageState) (resource.Resource, error) { - if owner == nil { panic("owner is nil") } @@ -424,7 +423,6 @@ func (m *pageMap) assembleResources(s string, p *pageState, parentBucket *pagesM } func (m *pageMap) assembleSections() error { - var sectionsToDelete []string var err error @@ -508,7 +506,6 @@ func (m *pageMap) assembleSections() error { } func (m *pageMap) assembleTaxonomies() error { - var taxonomiesToDelete []string var err error @@ -565,7 +562,6 @@ func (m *pageMap) assembleTaxonomies() error { } return err - } func (m *pageMap) attachPageToViews(s string, b *contentNode) { @@ -656,7 +652,6 @@ func (m *pageMap) collectSections(query pageMapQuery, fn func(c *contentNode)) e } func (m *pageMap) collectSectionsFn(query pageMapQuery, fn func(s string, c *contentNode) bool) error { - if !strings.HasSuffix(query.Prefix, "/") { query.Prefix += "/" } @@ -957,11 +952,9 @@ func (w *sectionWalker) applyAggregates() *sectionAggregateHandler { return w.walkLevel("/", func() sectionWalkHandler { return §ionAggregateHandler{} }).(*sectionAggregateHandler) - } func (w *sectionWalker) walkLevel(prefix string, createVisitor func() sectionWalkHandler) sectionWalkHandler { - level := strings.Count(prefix, "/") visitor := createVisitor() @@ -1029,7 +1022,6 @@ func (w *sectionWalker) walkLevel(prefix string, createVisitor func() sectionWal }) return visitor - } type viewName struct { diff --git a/hugolib/content_map_test.go b/hugolib/content_map_test.go index 42a69c26b..9d7212735 100644 --- a/hugolib/content_map_test.go +++ b/hugolib/content_map_test.go @@ -43,7 +43,6 @@ func BenchmarkContentMap(b *testing.B) { mfi := fi.(hugofs.FileMetaInfo) return mfi - } createFs := func(fs afero.Fs, lang string) afero.Fs { @@ -55,7 +54,6 @@ func BenchmarkContentMap(b *testing.B) { meta["lang"] = lang meta["path"] = meta.Filename() meta["classifier"] = files.ClassifyContentFile(fi.Name(), meta.GetOpener()) - }) } @@ -87,7 +85,6 @@ func BenchmarkContentMap(b *testing.B) { b.StartTimer() } }) - } func TestContentMap(t *testing.T) { @@ -104,7 +101,6 @@ func TestContentMap(t *testing.T) { mfi := fi.(hugofs.FileMetaInfo) return mfi - } createFs := func(fs afero.Fs, lang string) afero.Fs { @@ -117,12 +113,10 @@ func TestContentMap(t *testing.T) { meta["path"] = meta.Filename() meta["classifier"] = files.ClassifyContentFile(fi.Name(), meta.GetOpener()) meta["translationBaseName"] = helpers.Filename(fi.Name()) - }) } c.Run("AddFiles", func(c *qt.C) { - memfs := afero.NewMemMapFs() fsl := func(lang string) afero.Fs { @@ -254,11 +248,9 @@ func TestContentMap(t *testing.T) { `, qt.Commentf(m.testDump())) - }) c.Run("CreateMissingNodes", func(c *qt.C) { - memfs := afero.NewMemMapFs() fsl := func(lang string) afero.Fs { @@ -297,7 +289,6 @@ func TestContentMap(t *testing.T) { - P: blog/page.md `, qt.Commentf(got)) - }) c.Run("cleanKey", func(c *qt.C) { @@ -309,15 +300,12 @@ func TestContentMap(t *testing.T) { {filepath.FromSlash("/a/b/"), "/a/b"}, {"/a//b/", "/a/b"}, } { - c.Assert(cleanTreeKey(test.in), qt.Equals, test.expected) - } }) } func TestContentMapSite(t *testing.T) { - b := newTestSitesBuilder(t) pageTempl := ` diff --git a/hugolib/content_render_hooks_test.go b/hugolib/content_render_hooks_test.go index 13bfe216a..197581bb6 100644 --- a/hugolib/content_render_hooks_test.go +++ b/hugolib/content_render_hooks_test.go @@ -54,7 +54,6 @@ title: P1 b.Build(BuildCfg{}) b.AssertFileContent("public/p1/index.html", `Link First Link|PARTIAL1_EDITED PARTIAL2_EDITEDEND`) - } func TestRenderHooks(t *testing.T) { @@ -243,7 +242,6 @@ SHORT3| // https://github.com/gohugoio/hugo/issues/7349 b.AssertFileContent("public/docs/p8/index.html", "Docs Level: 1") - } func TestRenderHooksDeleteTemplate(t *testing.T) { @@ -271,7 +269,6 @@ title: P1 b.Build(BuildCfg{}) b.AssertFileContent("public/p1/index.html", `

First Link

`) - } func TestRenderHookAddTemplate(t *testing.T) { @@ -297,11 +294,9 @@ title: P1 b.Build(BuildCfg{}) b.AssertFileContent("public/p1/index.html", `

html-render-link

`) - } func TestRenderHooksRSS(t *testing.T) { - b := newTestSitesBuilder(t) b.WithTemplates("index.html", ` @@ -352,12 +347,10 @@ P3. [I'm an inline-style link](https://www.example.org) P2:

P1. xml-link: https://www.bep.is|

P3:

P3. xml-link: https://www.example.org|

`) - } // https://github.com/gohugoio/hugo/issues/6629 func TestRenderLinkWithMarkupInText(t *testing.T) { - b := newTestSitesBuilder(t) b.WithConfigFile("toml", ` @@ -400,11 +393,9 @@ Image:

Some regular markup.

html-image: image.jpg|Text: Hello
Goodbye|Plain: Hello GoodbyeEND

`) - } func TestRenderString(t *testing.T) { - b := newTestSitesBuilder(t) b.WithTemplates("index.html", ` @@ -433,7 +424,6 @@ RSTART:

Bold Block Markdown

RSTART:italic org mode:REND RSTART:Hook Heading: 2:REND `) - } // https://github.com/gohugoio/hugo/issues/6882 @@ -460,5 +450,4 @@ func TestRenderStringOnListPage(t *testing.T) { } { b.AssertFileContent("public/"+filename, `Hello`) } - } diff --git a/hugolib/datafiles_test.go b/hugolib/datafiles_test.go index 294dc8379..f31024cf5 100644 --- a/hugolib/datafiles_test.go +++ b/hugolib/datafiles_test.go @@ -14,17 +14,16 @@ package hugolib import ( + "fmt" "path/filepath" "reflect" + "runtime" "testing" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/deps" - "fmt" - "runtime" - qt "github.com/frankban/quicktest" ) @@ -197,7 +196,6 @@ func TestDataDirMultipleSources(t *testing.T) { doTestDataDir(t, dd, expected, "theme", "mytheme") - } // test (and show) the way values from four different sources, @@ -301,7 +299,8 @@ func TestDataDirNestedDirectories(t *testing.T) { expected := map[string]interface{}{ "a": []interface{}{"1", "2", "3"}, - "test1": map[string]interface{}{"20": map[string]interface{}{"05": map[string]interface{}{"b": map[string]interface{}{"artist": "Charlie Parker"}}, "06": map[string]interface{}{"a": map[string]interface{}{"artist": "Michael Brecker"}}}}} + "test1": map[string]interface{}{"20": map[string]interface{}{"05": map[string]interface{}{"b": map[string]interface{}{"artist": "Charlie Parker"}}, "06": map[string]interface{}{"a": map[string]interface{}{"artist": "Michael Brecker"}}}}, + } doTestDataDir(t, dd, expected, "theme", "mytheme") } @@ -331,9 +330,7 @@ func doTestDataDir(t *testing.T, dd dataDir, expected interface{}, configKeyValu } func doTestDataDirImpl(t *testing.T, dd dataDir, expected interface{}, configKeyValues ...interface{}) (err string) { - var ( - cfg, fs = newTestCfg() - ) + cfg, fs := newTestCfg() for i := 0; i < len(configKeyValues); i += 2 { cfg.Set(configKeyValues[i].(string), configKeyValues[i+1]) diff --git a/hugolib/disableKinds_test.go b/hugolib/disableKinds_test.go index 73786c730..87a60d636 100644 --- a/hugolib/disableKinds_test.go +++ b/hugolib/disableKinds_test.go @@ -13,9 +13,8 @@ package hugolib import ( - "testing" - "fmt" + "testing" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/resources/page" @@ -100,7 +99,6 @@ title: Headless Local Lists Sub b.WithSourceFile("content/sect/no-publishresources/data.json", "DATA") return b - } getPage := func(b *sitesBuilder, ref string) page.Page { @@ -210,7 +208,6 @@ title: Headless Local Lists Sub b.Assert(getPageInPagePages(sect, "/sect/page.md"), qt.Not(qt.IsNil)) b.AssertFileContent("public/sitemap.xml", "sitemap") b.AssertFileContent("public/index.xml", "rss") - }) disableKind = kindRSS @@ -269,7 +266,6 @@ title: Headless Local Lists Sub b.Assert(getPageInSitePages(b, ref), qt.IsNil) sect := getPage(b, "/sect") b.Assert(getPageInPagePages(sect, ref), qt.IsNil) - }) c.Run("Build config, local list", func(c *qt.C) { @@ -356,7 +352,6 @@ home = [ "HTML", "RSS" ] // In Hugo 0.65 we consolidated the code paths and made RSS a pure output format, // but we should make sure to not break existing sites. b.Assert(b.CheckExists("public/index.xml"), qt.Equals, false) - } func TestBundleNoPublishResources(t *testing.T) { @@ -419,5 +414,4 @@ Section: MySection|RelPermalink: |Outputs: 0 b.Assert(b.CheckExists("public/sect/no-render/index.html"), qt.Equals, false) b.Assert(b.CheckExists("public/sect-no-render/index.html"), qt.Equals, false) - } diff --git a/hugolib/embedded_shortcodes_test.go b/hugolib/embedded_shortcodes_test.go index b8acb2d80..3ea1d8ab0 100644 --- a/hugolib/embedded_shortcodes_test.go +++ b/hugolib/embedded_shortcodes_test.go @@ -17,13 +17,12 @@ import ( "encoding/json" "fmt" "html/template" + "path/filepath" "strings" "testing" "github.com/spf13/cast" - "path/filepath" - "github.com/gohugoio/hugo/deps" qt "github.com/frankban/quicktest" @@ -86,12 +85,14 @@ func TestShortcodeHighlight(t *testing.T) { for _, this := range []struct { in, expected string }{ - {`{{< highlight java >}} + { + `{{< highlight java >}} void do(); {{< /highlight >}}`, `(?s)
}}
+		{
+			`{{< highlight java "style=friendly" >}}
 void do();
 {{< /highlight >}}`,
 			`(?s)
`,
@@ -205,7 +206,6 @@ title: Shorty
 
 		th.assertFileContentRegexp(filepath.Join("public", "simple", "index.html"), this.expected)
 	}
-
 }
 
 func TestShortcodeVimeo(t *testing.T) {
diff --git a/hugolib/embedded_templates_test.go b/hugolib/embedded_templates_test.go
index 39a905589..840b98232 100644
--- a/hugolib/embedded_templates_test.go
+++ b/hugolib/embedded_templates_test.go
@@ -76,5 +76,4 @@ title: My Site
 
 
 `)
-
 }
diff --git a/hugolib/fileInfo.go b/hugolib/fileInfo.go
index 4997142a1..fdfd34b16 100644
--- a/hugolib/fileInfo.go
+++ b/hugolib/fileInfo.go
@@ -63,7 +63,6 @@ func (fi *fileInfo) String() string {
 
 // TODO(bep) rename
 func newFileInfo(sp *source.SourceSpec, fi hugofs.FileMetaInfo) (*fileInfo, error) {
-
 	baseFi, err := sp.NewFileInfo(fi)
 	if err != nil {
 		return nil, err
@@ -74,7 +73,6 @@ func newFileInfo(sp *source.SourceSpec, fi hugofs.FileMetaInfo) (*fileInfo, erro
 	}
 
 	return f, nil
-
 }
 
 type bundleDirType int
diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go
index ae3807360..e977633c8 100644
--- a/hugolib/filesystems/basefs.go
+++ b/hugolib/filesystems/basefs.go
@@ -16,6 +16,7 @@
 package filesystems
 
 import (
+	"fmt"
 	"io"
 	"os"
 	"path"
@@ -33,8 +34,6 @@ import (
 
 	"github.com/gohugoio/hugo/hugofs"
 
-	"fmt"
-
 	"github.com/gohugoio/hugo/hugolib/paths"
 	"github.com/spf13/afero"
 )
@@ -80,7 +79,7 @@ func (fs *BaseFs) AllDirs() []hugofs.FileMetaInfo {
 		fs.Content.Dirs,
 		fs.Assets.Dirs,
 		fs.Layouts.Dirs,
-		//fs.Resources.Dirs,
+		// fs.Resources.Dirs,
 		fs.StaticDirs,
 	} {
 		dirs = append(dirs, dirSet...)
@@ -160,7 +159,6 @@ func (s *SourceFilesystems) FileSystems() []*SourceFilesystem {
 		s.Archetypes,
 		// TODO(bep) static
 	}
-
 }
 
 // A SourceFilesystem holds the filesystem for a given source type in Hugo (data,
@@ -192,7 +190,6 @@ func (s SourceFilesystems) ContentStaticAssetFs(lang string) afero.Fs {
 
 	base := afero.NewCopyOnWriteFs(s.Assets.Fs, staticFs)
 	return afero.NewCopyOnWriteFs(base, s.Content.Fs)
-
 }
 
 // StaticFs returns the static filesystem for the given language.
@@ -277,7 +274,6 @@ func (s SourceFilesystems) MakeStaticPathRelative(filename string) string {
 
 // MakePathRelative creates a relative path from the given filename.
 func (d *SourceFilesystem) MakePathRelative(filename string) (string, bool) {
-
 	for _, dir := range d.Dirs {
 		meta := dir.(hugofs.FileMetaInfo).Meta()
 		currentPath := meta.Filename()
@@ -416,7 +412,6 @@ func (b *sourceFilesystemsBuilder) newSourceFilesystem(name string, fs afero.Fs,
 }
 
 func (b *sourceFilesystemsBuilder) Build() (*SourceFilesystems, error) {
-
 	if b.theBigFs == nil {
 
 		theBigFs, err := b.createMainOverlayFs(b.p)
@@ -435,7 +430,6 @@ func (b *sourceFilesystemsBuilder) Build() (*SourceFilesystems, error) {
 		dirs := b.theBigFs.overlayDirs[componentID]
 
 		return b.newSourceFilesystem(componentID, afero.NewBasePathFs(b.theBigFs.overlayMounts, componentID), dirs)
-
 	}
 
 	b.theBigFs.finalizeDirs()
@@ -491,11 +485,9 @@ func (b *sourceFilesystemsBuilder) Build() (*SourceFilesystems, error) {
 	}
 
 	return b.result, nil
-
 }
 
 func (b *sourceFilesystemsBuilder) createMainOverlayFs(p *paths.Paths) (*filesystemsCollector, error) {
-
 	var staticFsMap map[string]afero.Fs
 	if b.p.Cfg.GetBool("multihost") {
 		staticFsMap = make(map[string]afero.Fs)
@@ -536,7 +528,6 @@ func (b *sourceFilesystemsBuilder) createMainOverlayFs(p *paths.Paths) (*filesys
 	err := b.createOverlayFs(collector, modsReversed)
 
 	return collector, err
-
 }
 
 func (b *sourceFilesystemsBuilder) isContentMount(mnt modules.Mount) bool {
@@ -550,7 +541,6 @@ func (b *sourceFilesystemsBuilder) isStaticMount(mnt modules.Mount) bool {
 func (b *sourceFilesystemsBuilder) createModFs(
 	collector *filesystemsCollector,
 	md mountsDescriptor) error {
-
 	var (
 		fromTo        []hugofs.RootMapping
 		fromToContent []hugofs.RootMapping
@@ -641,7 +631,6 @@ func (b *sourceFilesystemsBuilder) createModFs(
 			sfs, found := collector.staticPerLanguage[lang]
 			if found {
 				collector.staticPerLanguage[lang] = afero.NewCopyOnWriteFs(sfs, bfs)
-
 			} else {
 				collector.staticPerLanguage[lang] = bfs
 			}
@@ -672,7 +661,6 @@ func (b *sourceFilesystemsBuilder) createModFs(
 	}
 
 	return nil
-
 }
 
 func printFs(fs afero.Fs, path string, w io.Writer) {
@@ -719,7 +707,6 @@ func (c *filesystemsCollector) addDirs(rfs *hugofs.RootMappingFs) {
 	for _, componentFolder := range files.ComponentFolders {
 		c.addDir(rfs, componentFolder)
 	}
-
 }
 
 func (c *filesystemsCollector) addDir(rfs *hugofs.RootMappingFs, componentFolder string) {
@@ -737,7 +724,6 @@ func (c *filesystemsCollector) finalizeDirs() {
 			c.reverseFis(dirs)
 		}
 	})
-
 }
 
 func (c *filesystemsCollector) reverseFis(fis []hugofs.FileMetaInfo) {
diff --git a/hugolib/filesystems/basefs_test.go b/hugolib/filesystems/basefs_test.go
index 2d273ae88..139d0c20e 100644
--- a/hugolib/filesystems/basefs_test.go
+++ b/hugolib/filesystems/basefs_test.go
@@ -274,7 +274,6 @@ func TestRealDirs(t *testing.T) {
 	c.Assert(realDirs[len(realDirs)-1], qt.Equals, filepath.Join(themesDir, "mytheme/assets/scss"))
 
 	c.Assert(bfs.theBigFs, qt.Not(qt.IsNil))
-
 }
 
 func TestStaticFs(t *testing.T) {
@@ -305,7 +304,6 @@ func TestStaticFs(t *testing.T) {
 	sfs := bfs.StaticFs("en")
 	checkFileContent(sfs, "f1.txt", c, "Hugo Rocks!")
 	checkFileContent(sfs, "f2.txt", c, "Hugo Themes Still Rocks!")
-
 }
 
 func TestStaticFsMultiHost(t *testing.T) {
@@ -402,7 +400,6 @@ func TestMakePathRelative(t *testing.T) {
 	c.Assert(makeRel(filepath.Join(workDir, "dist", "d1", "foo.txt")), qt.Equals, filepath.FromSlash("mydist/d1/foo.txt"))
 	c.Assert(makeRel(filepath.Join(workDir, "static", "d2", "foo.txt")), qt.Equals, filepath.FromSlash("d2/foo.txt"))
 	c.Assert(makeRel(filepath.Join(workDir, "dust", "d3", "foo.txt")), qt.Equals, filepath.FromSlash("foo/bar/d3/foo.txt"))
-
 }
 
 func checkFileCount(fs afero.Fs, dirname string, c *qt.C, expected int) {
@@ -412,7 +409,6 @@ func checkFileCount(fs afero.Fs, dirname string, c *qt.C, expected int) {
 }
 
 func checkFileContent(fs afero.Fs, filename string, c *qt.C, expected ...string) {
-
 	b, err := afero.ReadFile(fs, filename)
 	c.Assert(err, qt.IsNil)
 
diff --git a/hugolib/gitinfo.go b/hugolib/gitinfo.go
index 6acc47d17..17717ed52 100644
--- a/hugolib/gitinfo.go
+++ b/hugolib/gitinfo.go
@@ -32,7 +32,6 @@ func (g *gitInfo) forPage(p page.Page) *gitmap.GitInfo {
 	name = strings.TrimPrefix(name, "/")
 
 	return g.repo.Files[name]
-
 }
 
 func newGitInfo(cfg config.Provider) (*gitInfo, error) {
diff --git a/hugolib/hugo_modules_test.go b/hugolib/hugo_modules_test.go
index b2ab59ef0..f63da5a07 100644
--- a/hugolib/hugo_modules_test.go
+++ b/hugolib/hugo_modules_test.go
@@ -93,11 +93,9 @@ github.com/gohugoio/hugoTestModule2 v0.0.0-20200131160637-9657d7697877/go.mod h1
 `)
 
 		return b, clean
-
 	}
 
 	t.Run("Target in subfolder", func(t *testing.T) {
-
 		b, clean := newTestBuilder(t, "ignoreImports=true")
 		defer clean()
 
@@ -107,7 +105,6 @@ github.com/gohugoio/hugoTestModule2 v0.0.0-20200131160637-9657d7697877/go.mod h1
 	})
 
 	t.Run("Ignore config", func(t *testing.T) {
-
 		b, clean := newTestBuilder(t, "ignoreConfig=true")
 		defer clean()
 
@@ -120,7 +117,6 @@ JS imported in module: |
 	})
 
 	t.Run("Ignore imports", func(t *testing.T) {
-
 		b, clean := newTestBuilder(t, "ignoreImports=true")
 		defer clean()
 
@@ -133,7 +129,6 @@ JS imported in module: |
 	})
 
 	t.Run("Create package.json", func(t *testing.T) {
-
 		b, clean := newTestBuilder(t, "")
 		defer clean()
 
@@ -197,7 +192,6 @@ JS imported in module: |
 	})
 
 	t.Run("Create package.json, no default", func(t *testing.T) {
-
 		b, clean := newTestBuilder(t, "")
 		defer clean()
 
@@ -249,11 +243,9 @@ JS imported in module: |
 
 		// https://github.com/gohugoio/hugo/issues/7690
 		b.AssertFileContent("package.hugo.json", origPackageJSON)
-
 	})
 
 	t.Run("Create package.json, no default, no package.json", func(t *testing.T) {
-
 		b, clean := newTestBuilder(t, "")
 		defer clean()
 
@@ -287,11 +279,8 @@ JS imported in module: |
  "name": "myhugosite",
  "version": "0.1.0"
 }`
-
 		})
-
 	})
-
 }
 
 // TODO(bep) this fails when testmodBuilder is also building ...
@@ -532,7 +521,6 @@ other="Theme C"
 		"i18n theme: Theme C",
 		"i18n theme2: Theme2 D",
 	)
-
 }
 
 func TestModulesIgnoreConfig(t *testing.T) {
@@ -560,7 +548,6 @@ a = "Should Be Ignored!"
 	b.AssertFileContentFn("public/index.html", func(s string) bool {
 		return !strings.Contains(s, "Ignored")
 	})
-
 }
 
 func TestModulesDisabled(t *testing.T) {
@@ -596,7 +583,6 @@ b = "B param"
 	b.AssertFileContentFn("public/index.html", func(s string) bool {
 		return strings.Contains(s, "A param") && !strings.Contains(s, "B param")
 	})
-
 }
 
 func TestModulesIncompatible(t *testing.T) {
@@ -650,7 +636,6 @@ min_version = 0.55.0
 	c := qt.New(t)
 
 	c.Assert(logger.LogCounters().WarnCounter.Count(), qt.Equals, uint64(3))
-
 }
 
 func TestModulesSymlinks(t *testing.T) {
@@ -740,7 +725,8 @@ weight = 2
 		bfs.Content.Fs,
 		bfs.Data.Fs,
 		bfs.Assets.Fs,
-		bfs.I18n.Fs} {
+		bfs.I18n.Fs,
+	} {
 
 		if i != 0 {
 			continue
@@ -756,7 +742,6 @@ weight = 2
 				}
 
 				_, err := fs.Stat(filepath.FromSlash(filename))
-
 				if err != nil {
 					if i > 0 && strings.HasSuffix(filename, "toml") && strings.Contains(err.Error(), "files not supported") {
 						// OK
@@ -803,7 +788,7 @@ title: "My Page"
 
 	b.Build(BuildCfg{})
 
-	//helpers.PrintFs(b.H.Fs.Source, "public", os.Stdout)
+	// helpers.PrintFs(b.H.Fs.Source, "public", os.Stdout)
 
 	b.AssertFileContent("public/mypage/index.html", "Permalink: https://example.org/mypage/")
 }
@@ -929,7 +914,6 @@ title: "Readme Edit"
 	b.AssertFileContent("public/index.html", `
 Readme Edit
 `)
-
 }
 
 func TestMountsPaths(t *testing.T) {
@@ -969,7 +953,6 @@ workingDir = %q
 			clean:      clean,
 			workingDir: workingDir,
 		}
-
 	}
 
 	c.Run("Default", func(c *qt.C) {
@@ -991,7 +974,6 @@ title: P1
 		b.Assert(filepath.ToSlash(f.PathFile()), qt.Equals, "content/blog/p1.md")
 
 		b.Assert(b.H.BaseFs.Layouts.Path(filepath.Join(test.workingDir, "layouts", "_default", "single.html")), qt.Equals, filepath.FromSlash("_default/single.html"))
-
 	})
 
 	c.Run("Mounts", func(c *qt.C) {
@@ -1047,9 +1029,7 @@ title: P1
 		b.Assert(b.H.BaseFs.Layouts.Path(filepath.Join(absShortcodesDir, "myshort.html")), qt.Equals, filepath.FromSlash("shortcodes/myshort.html"))
 		b.Assert(b.H.BaseFs.Content.Path(filepath.Join(subContentDir, "p1.md")), qt.Equals, filepath.FromSlash("blog/sub/p1.md"))
 		b.Assert(b.H.BaseFs.Content.Path(filepath.Join(test.workingDir, "README.md")), qt.Equals, filepath.FromSlash("_index.md"))
-
 	})
-
 }
 
 // https://github.com/gohugoio/hugo/issues/6299
@@ -1074,7 +1054,6 @@ func TestSiteWithGoModButNoModules(t *testing.T) {
 
 	b.WithSourceFile("go.mod", "")
 	b.Build(BuildCfg{})
-
 }
 
 // https://github.com/gohugoio/hugo/issues/6622
@@ -1128,5 +1107,4 @@ P1: {{ $p1.Title }}|{{ $p1.RelPermalink }}|Filename: {{ $p1.File.Filename }}
 	b.Build(BuildCfg{})
 
 	b.AssertFileContent("public/index.html", "P1: Abs|/p1/", "Filename: "+contentFilename)
-
 }
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go
index 25ae3dd19..a016cab99 100644
--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -295,13 +295,11 @@ func (h *HugoSites) GetContentPage(filename string) page.Page {
 // NewHugoSites creates a new collection of sites given the input sites, building
 // a language configuration based on those.
 func newHugoSites(cfg deps.DepsCfg, sites ...*Site) (*HugoSites, error) {
-
 	if cfg.Language != nil {
 		return nil, errors.New("Cannot provide Language in Cfg when sites are provided")
 	}
 
 	langConfig, err := newMultiLingualFromSites(cfg.Cfg, sites...)
-
 	if err != nil {
 		return nil, errors.Wrap(err, "failed to create language config")
 	}
@@ -437,7 +435,6 @@ func applyDeps(cfg deps.DepsCfg, sites ...*Site) error {
 				s.outputFormatsConfig,
 				s.mediaTypesConfig,
 			)
-
 			if err != nil {
 				return err
 			}
@@ -535,10 +532,7 @@ func (s *Site) withSiteTemplates(withTemplates ...func(templ tpl.TemplateManager
 }
 
 func createSitesFromConfig(cfg deps.DepsCfg) ([]*Site, error) {
-
-	var (
-		sites []*Site
-	)
+	var sites []*Site
 
 	languages := getLanguages(cfg.Cfg)
 
@@ -619,13 +613,11 @@ func (h *HugoSites) createSitesFromConfig(cfg config.Provider) error {
 	depsCfg := deps.DepsCfg{Fs: h.Fs, Cfg: cfg}
 
 	sites, err := createSitesFromConfig(depsCfg)
-
 	if err != nil {
 		return err
 	}
 
 	langConfig, err := newMultiLingualFromSites(depsCfg.Cfg, sites...)
-
 	if err != nil {
 		return err
 	}
@@ -707,7 +699,6 @@ func (cfg *BuildCfg) shouldRender(p *pageState) bool {
 }
 
 func (h *HugoSites) renderCrossSitesSitemap() error {
-
 	if !h.multilingual.enabled() || h.IsMultihost() {
 		return nil
 	}
@@ -750,7 +741,6 @@ func (h *HugoSites) renderCrossSitesRobotsTXT() error {
 		},
 	},
 		output.RobotsTxtFormat)
-
 	if err != nil {
 		return err
 	}
@@ -779,11 +769,9 @@ func (h *HugoSites) removePageByFilename(filename string) {
 		})
 		return nil
 	})
-
 }
 
 func (h *HugoSites) createPageCollections() error {
-
 	allPages := newLazyPagesFactory(func() page.Pages {
 		var pages page.Pages
 		for _, s := range h.Sites {
@@ -1083,7 +1071,6 @@ func (m *contentChangeMap) resolveAndRemove(filename string) (string, bundleDirT
 	}
 
 	return dir, bundleNot
-
 }
 
 func (m *contentChangeMap) addSymbolicLinkMapping(fim hugofs.FileMetaInfo) {
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
index bd5c2b661..c1a4ab190 100644
--- a/hugolib/hugo_sites_build.go
+++ b/hugolib/hugo_sites_build.go
@@ -44,7 +44,6 @@ import (
 // Build builds all sites. If filesystem events are provided,
 // this is considered to be a potential partial rebuild.
 func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
-
 	if h.running {
 		// Make sure we don't trigger rebuilds in parallel.
 		h.runningMu.Lock()
@@ -70,7 +69,6 @@ func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
 		to <- h.pickOneAndLogTheRest(errors)
 
 		close(to)
-
 	}(errCollector, errs)
 
 	if h.Metrics != nil {
@@ -186,7 +184,6 @@ func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
 	}
 
 	return nil
-
 }
 
 // Build lifecycle methods below.
@@ -242,11 +239,9 @@ func (h *HugoSites) process(config *BuildCfg, init func(config *BuildCfg) error,
 	}
 
 	return firstSite.process(*config)
-
 }
 
 func (h *HugoSites) assemble(bcfg *BuildCfg) error {
-
 	if len(h.Sites) > 1 {
 		// The first is initialized during process; initialize the rest
 		for _, site := range h.Sites[1:] {
@@ -269,7 +264,6 @@ func (h *HugoSites) assemble(bcfg *BuildCfg) error {
 	}
 
 	return nil
-
 }
 
 func (h *HugoSites) render(config *BuildCfg) error {
@@ -327,7 +321,6 @@ func (h *HugoSites) render(config *BuildCfg) error {
 			}
 
 		}
-
 	}
 
 	if !config.SkipRender {
@@ -366,7 +359,6 @@ func (h *HugoSites) postProcess() error {
 					b, err := json.MarshalIndent(jsConfig, "", " ")
 					if err != nil {
 						h.Log.Warnf("Failed to create jsconfig.json: %s", err)
-
 					} else {
 						filename := filepath.Join(assetsDir, "jsconfig.json")
 						if h.running {
@@ -400,7 +392,6 @@ func (h *HugoSites) postProcess() error {
 	g, _ := workers.Start(context.Background())
 
 	handleFile := func(filename string) error {
-
 		content, err := afero.ReadFile(h.BaseFs.PublishFs, filename)
 		if err != nil {
 			return err
@@ -443,7 +434,6 @@ func (h *HugoSites) postProcess() error {
 		}
 
 		return nil
-
 	}
 
 	_ = afero.Walk(h.BaseFs.PublishFs, "", func(path string, info os.FileInfo, err error) error {
@@ -468,7 +458,6 @@ func (h *HugoSites) postProcess() error {
 	}
 
 	return g.Wait()
-
 }
 
 type publishStats struct {
@@ -512,5 +501,4 @@ func (h *HugoSites) writeBuildStats() error {
 	}
 
 	return nil
-
 }
diff --git a/hugolib/hugo_sites_build_errors_test.go b/hugolib/hugo_sites_build_errors_test.go
index d90a8b364..997aae564 100644
--- a/hugolib/hugo_sites_build_errors_test.go
+++ b/hugolib/hugo_sites_build_errors_test.go
@@ -34,11 +34,9 @@ func (t testSiteBuildErrorAsserter) assertErrorMessage(e1, e2 string) {
 	// The error message will contain filenames with OS slashes. Normalize before compare.
 	e1, e2 = filepath.ToSlash(e1), filepath.ToSlash(e2)
 	t.c.Assert(e2, qt.Contains, e1)
-
 }
 
 func TestSiteBuildErrors(t *testing.T) {
-
 	const (
 		yamlcontent = "yamlcontent"
 		tomlcontent = "tomlcontent"
@@ -92,7 +90,6 @@ func TestSiteBuildErrors(t *testing.T) {
 				a.c.Assert(fe.Position().ColumnNumber, qt.Equals, 1)
 				a.c.Assert(fe.ChromaLexer, qt.Equals, "go-html-template")
 				a.assertErrorMessage("\"layouts/foo/single.html:5:1\": parse failed: template: foo/single.html:5: unexpected \"}\" in operand", fe.Error())
-
 			},
 		},
 		{
@@ -107,7 +104,6 @@ func TestSiteBuildErrors(t *testing.T) {
 				a.c.Assert(fe.Position().ColumnNumber, qt.Equals, 14)
 				a.c.Assert(fe.ChromaLexer, qt.Equals, "go-html-template")
 				a.assertErrorMessage("\"layouts/_default/single.html:5:14\": execute of template failed", fe.Error())
-
 			},
 		},
 		{
@@ -122,7 +118,6 @@ func TestSiteBuildErrors(t *testing.T) {
 				a.c.Assert(fe.Position().ColumnNumber, qt.Equals, 14)
 				a.c.Assert(fe.ChromaLexer, qt.Equals, "go-html-template")
 				a.assertErrorMessage("\"layouts/_default/single.html:5:14\": execute of template failed", fe.Error())
-
 			},
 		},
 		{
@@ -184,7 +179,6 @@ func TestSiteBuildErrors(t *testing.T) {
 				fe := a.getFileError(err)
 				a.c.Assert(fe.Position().LineNumber, qt.Equals, 6)
 				a.c.Assert(fe.ErrorContext.ChromaLexer, qt.Equals, "toml")
-
 			},
 		},
 		{
@@ -198,7 +192,6 @@ func TestSiteBuildErrors(t *testing.T) {
 
 				a.c.Assert(fe.Position().LineNumber, qt.Equals, 3)
 				a.c.Assert(fe.ErrorContext.ChromaLexer, qt.Equals, "json")
-
 			},
 		},
 		{
@@ -235,7 +228,6 @@ func TestSiteBuildErrors(t *testing.T) {
 					return content
 				}
 				return test.fileFixer(content)
-
 			}
 
 			b.WithTemplatesAdded("layouts/shortcodes/sc.html", f(shortcode, `SHORTCODE L1
@@ -348,9 +340,7 @@ title: "A page"
 ---
 
 {{< c >}}`)
-
 	}
 
 	b.CreateSites().BuildFail(BuildCfg{})
-
 }
diff --git a/hugolib/hugo_sites_build_test.go b/hugolib/hugo_sites_build_test.go
index 8d0872bd5..4d6a8697c 100644
--- a/hugolib/hugo_sites_build_test.go
+++ b/hugolib/hugo_sites_build_test.go
@@ -2,10 +2,9 @@ package hugolib
 
 import (
 	"fmt"
+	"path/filepath"
 	"strings"
 	"testing"
-
-	"path/filepath"
 	"time"
 
 	qt "github.com/frankban/quicktest"
@@ -199,7 +198,6 @@ p1 = "p1en"
 }
 
 func TestMultiSitesBuild(t *testing.T) {
-
 	for _, config := range []struct {
 		content string
 		suffix  string
@@ -208,7 +206,6 @@ func TestMultiSitesBuild(t *testing.T) {
 		{multiSiteYAMLConfigTemplate, "yml"},
 		{multiSiteJSONConfigTemplate, "json"},
 	} {
-
 		t.Run(config.suffix, func(t *testing.T) {
 			t.Parallel()
 			doTestMultiSitesBuild(t, config.content, config.suffix)
@@ -245,7 +242,7 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
 
 	c.Assert(enSite.language.Lang, qt.Equals, "en")
 
-	//dumpPages(enSite.RegularPages()...)
+	// dumpPages(enSite.RegularPages()...)
 
 	c.Assert(len(enSite.RegularPages()), qt.Equals, 5)
 	c.Assert(len(enSite.AllPages()), qt.Equals, 32)
@@ -412,7 +409,6 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
 	c.Assert(logoEn, qt.Not(qt.IsNil))
 	b.AssertFileContent("public/en/bundles/b1/index.html", "Resources: image/png: /blog/en/bundles/b1/logo.png")
 	b.AssertFileContent("public/en/bundles/b1/logo.png", "PNG Data")
-
 }
 
 func TestMultiSitesRebuild(t *testing.T) {
@@ -470,7 +466,6 @@ func TestMultiSitesRebuild(t *testing.T) {
 			[]fsnotify.Event{{Name: filepath.FromSlash("content/sect/doc2.en.md"), Op: fsnotify.Remove}},
 			func(t *testing.T) {
 				c.Assert(len(enSite.RegularPages()), qt.Equals, 4, qt.Commentf("1 en removed"))
-
 			},
 		},
 		{
@@ -508,7 +503,6 @@ func TestMultiSitesRebuild(t *testing.T) {
 				c.Assert(len(enSite.RegularPages()), qt.Equals, 6)
 				doc1 := readDestination(t, fs, "public/en/sect/doc1-slug/index.html")
 				c.Assert(strings.Contains(doc1, "CHANGED"), qt.Equals, true)
-
 			},
 		},
 		// Rename a file
@@ -527,7 +521,8 @@ func TestMultiSitesRebuild(t *testing.T) {
 				c.Assert(enSite.RegularPages()[1].Title(), qt.Equals, "new_en_1")
 				rendered := readDestination(t, fs, "public/en/new1renamed/index.html")
 				c.Assert(rendered, qt.Contains, "new_en_1")
-			}},
+			},
+		},
 		{
 			// Change a template
 			func(t *testing.T) {
@@ -567,7 +562,6 @@ func TestMultiSitesRebuild(t *testing.T) {
 				c.Assert(homeEn, qt.Not(qt.IsNil))
 				c.Assert(len(homeEn.Translations()), qt.Equals, 3)
 				c.Assert(homeEn.Translations()[0].Language().Lang, qt.Equals, "fr")
-
 			},
 		},
 		// Change a shortcode
@@ -593,14 +587,12 @@ func TestMultiSitesRebuild(t *testing.T) {
 		}
 
 		err := b.H.Build(BuildCfg{}, this.events...)
-
 		if err != nil {
 			t.Fatalf("[%d] Failed to rebuild sites: %s", i, err)
 		}
 
 		this.assertFunc(t)
 	}
-
 }
 
 // https://github.com/gohugoio/hugo/issues/4706
@@ -762,7 +754,6 @@ Title: My categories
 `)
 
 	for _, lang := range []string{"en", "nn"} {
-
 		b.WithContent(lang+"/mysection/page.md", `
 ---
 Title: My Page
@@ -770,7 +761,6 @@ categories: ["mycat"]
 ---
 
 `)
-
 	}
 
 	b.Build(BuildCfg{})
@@ -781,7 +771,6 @@ categories: ["mycat"]
 		"/categories",
 		"/categories/mycat",
 	} {
-
 		t.Run(path, func(t *testing.T) {
 			c := qt.New(t)
 
@@ -802,7 +791,6 @@ categories: ["mycat"]
 			c.Assert(len(m1), qt.Equals, 1)
 			c.Assert(len(m2), qt.Equals, 1)
 		})
-
 	}
 }
 
diff --git a/hugolib/hugo_sites_multihost_test.go b/hugolib/hugo_sites_multihost_test.go
index 4fe496042..b008fbdef 100644
--- a/hugolib/hugo_sites_multihost_test.go
+++ b/hugolib/hugo_sites_multihost_test.go
@@ -13,7 +13,7 @@ func TestMultihosts(t *testing.T) {
 
 	c := qt.New(t)
 
-	var configTemplate = `
+	configTemplate := `
 paginate = 1
 disablePathToLower = true
 defaultContentLanguage = "fr"
@@ -116,5 +116,4 @@ languageName = "Nynorsk"
 	c.Assert(len(bundleFr.Resources()), qt.Equals, 1)
 	b.AssertFileContent("public/fr/bundles/b1/logo.png", "PNG Data")
 	b.AssertFileContent("public/fr/bundles/b1/index.html", " image/png: /bundles/b1/logo.png")
-
 }
diff --git a/hugolib/hugo_sites_rebuild_test.go b/hugolib/hugo_sites_rebuild_test.go
index 4c4741385..d312d2199 100644
--- a/hugolib/hugo_sites_rebuild_test.go
+++ b/hugolib/hugo_sites_rebuild_test.go
@@ -20,7 +20,6 @@ import (
 )
 
 func TestSitesRebuild(t *testing.T) {
-
 	configFile := `
 baseURL = "https://example.com"
 title = "Rebuild this"
@@ -142,7 +141,6 @@ Data Inline: Rocks!
 		b.AssertFileContent("public/index.html", `
 Data: Rules!
 Data Inline: Rules!`)
-
 	})
 
 	// https://github.com/gohugoio/hugo/issues/6968
@@ -165,7 +163,6 @@ Data Inline: Rules!`)
 		b.Build(BuildCfg{testCounters: counters})
 
 		b.Assert(int(counters.contentRenderCounter), qt.Equals, 0)
-
 	})
 
 	t.Run("Page.Render, edit baseof", func(t *testing.T) {
@@ -190,7 +187,6 @@ prender: {{ $p.Title }}|{{ $p.Content }}
 		b.AssertFileContent("public/index.html", `
 Render /prender/: Baseof Edited:Single Main: Page 1|Mypartial1: Mypartial1:END
 `)
-
 	})
 
 	t.Run("Page.Render, edit partial in baseof", func(t *testing.T) {
@@ -215,7 +211,6 @@ prender: {{ $p.Title }}|{{ $p.Content }}
 		b.AssertFileContent("public/index.html", `
 Render /prender/: Baseof:Single Main: Page 1|Mypartial1: Mypartial1|Mypartial3: Mypartial3 Edited:END
 `)
-
 	})
 
 	t.Run("Edit RSS shortcode", func(t *testing.T) {
@@ -255,9 +250,7 @@ Output Shortcode AMP
 		b.AssertFileContent("public/amp/output/index.html", `
 Output Shortcode AMP Edited
 `)
-
 	})
-
 }
 
 // Issues #7623 #7625
@@ -320,5 +313,4 @@ P6 content
 P5 changed content
 P6 changed content
 `)
-
 }
diff --git a/hugolib/hugo_smoke_test.go b/hugolib/hugo_smoke_test.go
index 5aa508290..798504f0d 100644
--- a/hugolib/hugo_smoke_test.go
+++ b/hugolib/hugo_smoke_test.go
@@ -122,7 +122,7 @@ Footnotes:
 
 `
 
-	var pageContentAutoSummary = strings.Replace(pageContentAndSummaryDivider, "", "", 1)
+	pageContentAutoSummary := strings.Replace(pageContentAndSummaryDivider, "", "", 1)
 
 	b := newTestSitesBuilder(t).WithConfigFile("toml", configFile)
 	b.WithTemplatesAdded("shortcodes/markdown-shortcode.html", `
@@ -282,12 +282,10 @@ Some **Markdown** in JSON shortcode.
 	// Markdown vs shortcodes
 	// Check that all footnotes are grouped (even those from inside the shortcode)
 	b.AssertFileContentRe("public/blog/markyshort/index.html", `Footnotes:.*
    .*Fn 1.*Fn 2.*Fn 3.*
`) - } // https://github.com/golang/go/issues/30286 func TestDataRace(t *testing.T) { - const page = ` --- title: "The Page" diff --git a/hugolib/image_test.go b/hugolib/image_test.go index 84d43f5e9..9f0967414 100644 --- a/hugolib/image_test.go +++ b/hugolib/image_test.go @@ -38,7 +38,6 @@ func TestImageOps(t *testing.T) { defer clean() newBuilder := func(timeout interface{}) *sitesBuilder { - v := viper.New() v.Set("workingDir", workDir) v.Set("baseURL", "https://example.org") @@ -169,11 +168,9 @@ IMG SHORTCODE: /images/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_129x239_r b.Build(BuildCfg{}) assertImages() - } func TestImageResizeMultilingual(t *testing.T) { - b := newTestSitesBuilder(t).WithConfigFile("toml", ` baseURL="https://example.org" defaultContentLanguage = "en" @@ -247,5 +244,4 @@ SUNSET2: {{ $resized2.RelPermalink }}/{{ $resized2.Width }}/Lat: {{ $resized2.Ex // TODO(bep) add this as a default assertion after Build()? b.AssertNoDuplicateWrites() - } diff --git a/hugolib/js_test.go b/hugolib/js_test.go index b4f1d2157..fbbd335b3 100644 --- a/hugolib/js_test.go +++ b/hugolib/js_test.go @@ -136,7 +136,6 @@ if (hasSpace.test(string)) var React = __toModule(require("react")); function greeter(person) { `) - } func TestJSBuild(t *testing.T) { @@ -208,5 +207,4 @@ Hello3 from mod2. Date from date-fns: ${today} Hello from lib in the main project Hello5 from mod2. var myparam = "Hugo Rocks!";`) - } diff --git a/hugolib/language_content_dir_test.go b/hugolib/language_content_dir_test.go index 0d1033c1f..117fdfb14 100644 --- a/hugolib/language_content_dir_test.go +++ b/hugolib/language_content_dir_test.go @@ -102,7 +102,7 @@ Content. var contentFiles []string section := "sect" - var contentRoot = func(lang string) string { + contentRoot := func(lang string) string { switch lang { case "nn": return "content/norsk" @@ -111,10 +111,9 @@ Content. default: return "content/main" } - } - var contentSectionRoot = func(lang string) string { + contentSectionRoot := func(lang string) string { return contentRoot(lang) + "/" + section } @@ -215,7 +214,7 @@ Content. err := b.BuildE(BuildCfg{}) - //dumpPages(b.H.Sites[1].RegularPages()...) + // dumpPages(b.H.Sites[1].RegularPages()...) c.Assert(err, qt.IsNil) @@ -228,7 +227,7 @@ Content. b.AssertFileContent("/my/project/public/en/mystatic/file1.yaml", "en") b.AssertFileContent("/my/project/public/nn/mystatic/file1.yaml", "nn") - //dumpPages(nnSite.RegularPages()...) + // dumpPages(nnSite.RegularPages()...) c.Assert(len(nnSite.RegularPages()), qt.Equals, 12) c.Assert(len(enSite.RegularPages()), qt.Equals, 13) @@ -317,7 +316,6 @@ Content. c.Assert(len(nnSect.Pages()), qt.Equals, 12) nnHome, _ := nnSite.Info.Home() c.Assert(nnHome.RelPermalink(), qt.Equals, "/nn/") - } // https://github.com/gohugoio/hugo/issues/6463 @@ -404,5 +402,4 @@ Page: /fr/event/page1/|ev-fr1 Page: /fr/event/page2/|ev-fr2 Page: /fr/other/page1/|other-fr1 Page: /fr/other/page2/|other-fr2`) - } diff --git a/hugolib/language_test.go b/hugolib/language_test.go index 9c3e434c2..16dcbcb03 100644 --- a/hugolib/language_test.go +++ b/hugolib/language_test.go @@ -24,7 +24,6 @@ import ( ) func TestI18n(t *testing.T) { - c := qt.New(t) //https://github.com/gohugoio/hugo/issues/7804 diff --git a/hugolib/menu_test.go b/hugolib/menu_test.go index cfb4b954b..8717fa7db 100644 --- a/hugolib/menu_test.go +++ b/hugolib/menu_test.go @@ -14,9 +14,8 @@ package hugolib import ( - "testing" - "fmt" + "testing" qt "github.com/frankban/quicktest" ) @@ -104,11 +103,9 @@ Menu Main: {{ partial "menu.html" (dict "page" . "menu" "main") }}`, "/sect1/|Section One|Section One|100|-|-|"+ "/sect2/|Sect2s|Sect2s|0|-|HasMenuCurrent|"+ "/sect3/|Sect3s|Sect3s|0|-|-|") - } func TestMenuFrontMatter(t *testing.T) { - b := newTestSitesBuilder(t).WithSimpleConfigFile() b.WithTemplatesAdded("index.html", ` @@ -155,12 +152,10 @@ menu: "Main|P1: /blog/page1/", "Other|P2: /blog/page2/", ) - } // https://github.com/gohugoio/hugo/issues/5849 func TestMenuPageMultipleOutputFormats(t *testing.T) { - config := ` baseURL = "https://example.com" @@ -219,7 +214,6 @@ menu: "main" // https://github.com/gohugoio/hugo/issues/5989 func TestMenuPageSortByDate(t *testing.T) { - b := newTestSitesBuilder(t).WithSimpleConfigFile() b.WithContent("blog/a.md", ` @@ -269,7 +263,6 @@ menu: } func TestMenuParams(t *testing.T) { - b := newTestSitesBuilder(t).WithSimpleConfigFile() b.WithTemplatesAdded("index.html", ` @@ -315,5 +308,4 @@ menu: "Main|P1: /blog/page1/|map[]", "Main|P2: /blog/page2/|map[]", ) - } diff --git a/hugolib/multilingual.go b/hugolib/multilingual.go index 9b34c75e6..baebc9e0f 100644 --- a/hugolib/multilingual.go +++ b/hugolib/multilingual.go @@ -14,9 +14,8 @@ package hugolib import ( - "sync" - "errors" + "sync" "github.com/gohugoio/hugo/langs" @@ -69,7 +68,6 @@ func newMultiLingualFromSites(cfg config.Provider, sites ...*Site) (*Multilingua } return &Multilingual{Languages: languages, DefaultLang: langs.NewLanguage(defaultLang, cfg)}, nil - } func (ml *Multilingual) enabled() bool { diff --git a/hugolib/openapi_test.go b/hugolib/openapi_test.go index 82f080311..3f1bc400d 100644 --- a/hugolib/openapi_test.go +++ b/hugolib/openapi_test.go @@ -65,5 +65,4 @@ API: {{ $api.Info.Title | safeHTML }} b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", `API: Hugo API`) - } diff --git a/hugolib/page.go b/hugolib/page.go index fac3f3492..47aeb6e9a 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -243,7 +243,6 @@ func (p *pageState) RegularPages() page.Pages { } p.regularPages = pages - }) return p.regularPages @@ -358,11 +357,9 @@ func (p *pageState) TranslationKey() string { } else if p.IsNode() { p.translationKey = path.Join(p.Kind(), p.SectionsPath()) } - }) return p.translationKey - } // AllTranslations returns all translations, including the current Page. @@ -469,7 +466,6 @@ func (p *pageState) getLayoutDescriptor() output.LayoutDescriptor { }) return p.layoutDescriptor - } func (p *pageState) resolveTemplate(layouts ...string) (tpl.Template, bool, error) { @@ -500,7 +496,6 @@ func (p *pageState) initOutputFormat(isRenderingSite bool, idx int) error { } return nil - } // Must be run after the site section tree etc. is built and ready. @@ -546,7 +541,6 @@ func (p *pageState) renderResources() (err error) { for _, i := range toBeDeleted { p.deleteResource(i) } - }) return @@ -681,7 +675,6 @@ func (p *pageState) Render(layout ...string) (template.HTML, error) { return "", p.wrapError(errors.Wrapf(err, "failed to execute template %q v", layout)) } return template.HTML(res), nil - } // wrapError adds some more context to the given error if possible/needed @@ -714,7 +707,6 @@ func (p *pageState) getContentConverter() converter.Converter { markup = "markdown" } p.m.contentConverter, err = p.m.newContentConverter(p, markup, p.m.renderingConfigOverrides) - }) if err != nil { @@ -724,7 +716,6 @@ func (p *pageState) getContentConverter() converter.Converter { } func (p *pageState) mapContent(bucket *pagesMapBucket, meta *pageMeta) error { - s := p.shortcodeState rn := &pageContentMap{ @@ -893,7 +884,6 @@ func (p *pageState) parseError(err error, input []byte, offset int) error { } pos := p.posFromInput(input, offset) return herrors.NewFileError("md", -1, pos.LineNumber, pos.ColumnNumber, err) - } func (p *pageState) pathOrTitle() string { @@ -955,7 +945,6 @@ func (p *pageState) shiftToOutputFormat(isRenderingSite bool, idx int) error { if isRenderingSite { cp := p.pageOutput.cp if cp == nil { - // Look for content to reuse. for i := 0; i < len(p.pageOutputs); i++ { if i == idx { diff --git a/hugolib/page__content.go b/hugolib/page__content.go index 91f26dc18..c08ac67af 100644 --- a/hugolib/page__content.go +++ b/hugolib/page__content.go @@ -65,7 +65,6 @@ func (p pageContent) contentToRender(renderedShortcodes map[string]string) []byt // Insert the placeholder so we can insert the content after // markdown processing. c = append(c, []byte(v.placeholder)...) - } default: panic(fmt.Sprintf("unknown item type %T", it)) diff --git a/hugolib/page__data.go b/hugolib/page__data.go index 9fc97f8f6..7ab668503 100644 --- a/hugolib/page__data.go +++ b/hugolib/page__data.go @@ -60,7 +60,6 @@ func (p *pageData) Data() interface{} { // Assign the function to the map to make sure it is lazily initialized p.data["pages"] = p.Pages - }) return p.data diff --git a/hugolib/page__menus.go b/hugolib/page__menus.go index 7b0ef0e43..e64ffa2c9 100644 --- a/hugolib/page__menus.go +++ b/hugolib/page__menus.go @@ -51,7 +51,6 @@ func (p *pageMenus) Menus() navigation.PageMenus { func (p *pageMenus) menus() navigation.PageMenus { p.init() return p.pm - } func (p *pageMenus) init() { @@ -68,7 +67,5 @@ func (p *pageMenus) init() { if err != nil { p.p.s.Log.Errorln(p.p.wrapError(err)) } - }) - } diff --git a/hugolib/page__meta.go b/hugolib/page__meta.go index d23718315..b14938655 100644 --- a/hugolib/page__meta.go +++ b/hugolib/page__meta.go @@ -238,7 +238,6 @@ func (p *pageMeta) Path() string { // RelatedKeywords implements the related.Document interface needed for fast page searches. func (p *pageMeta) RelatedKeywords(cfg related.IndexConfig) ([]related.Keyword, error) { - v, err := p.Param(cfg.Name) if err != nil { return nil, err @@ -269,7 +268,6 @@ func (p *pageMeta) Section() string { } panic("invalid page state") - } func (p *pageMeta) SectionsEntries() []string { @@ -368,9 +366,8 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron } } else { p.bucket.cascade = map[page.PageMatcher]maps.Params{ - page.PageMatcher{}: maps.ToStringMap(cv), + {}: maps.ToStringMap(cv), } - } } } @@ -486,7 +483,6 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron // this may get its language path added twice. // TODO(bep) eventually remove this. p.s.Log.Warnf(`Front matter in %q with the url %q with no leading / has what looks like the language prefix added. In Hugo 0.55 we added support for page relative URLs in front matter, no language prefix needed. Check the URL and consider to either add a leading / or remove the language prefix.`, p.pathOrTitle(), url) - } } pm.urlPaths.URL = url @@ -661,7 +657,6 @@ func (p *pageMeta) noListAlways() bool { } func (p *pageMeta) getListFilter(local bool) contentTreeNodeCallback { - return newContentTreeFilter(func(n *contentNode) bool { if n == nil { return true @@ -763,7 +758,6 @@ func (p *pageMeta) applyDefaultValues(n *contentNode) error { } return nil - } func (p *pageMeta) newContentConverter(ps *pageState, markup string, renderingConfigOverrides map[string]interface{}) (converter.Converter, error) { @@ -791,7 +785,6 @@ func (p *pageMeta) newContentConverter(ps *pageState, markup string, renderingCo ConfigOverrides: renderingConfigOverrides, }, ) - if err != nil { return converter.NopConverter, err } diff --git a/hugolib/page__new.go b/hugolib/page__new.go index 9ec089f27..b37631477 100644 --- a/hugolib/page__new.go +++ b/hugolib/page__new.go @@ -90,7 +90,6 @@ func newPageBase(metaProvider *pageMeta) (*pageState, error) { ps.AlternativeOutputFormatsProvider = ps return ps, nil - } func newPageBucket(p *pageState) *pagesMapBucket { @@ -102,7 +101,6 @@ func newPageFromMeta( parentBucket *pagesMapBucket, meta map[string]interface{}, metaProvider *pageMeta) (*pageState, error) { - if metaProvider.f == nil { metaProvider.f = page.NewZeroFile(metaProvider.s.DistinctWarningLog) } @@ -170,11 +168,9 @@ func newPageFromMeta( } return nil, nil - }) return ps, err - } // Used by the legacy 404, sitemap and robots.txt rendering @@ -182,7 +178,6 @@ func newPageStandalone(m *pageMeta, f output.Format) (*pageState, error) { m.configuredOutputFormats = output.Formats{f} m.standalone = true p, err := newPageFromMeta(nil, nil, nil, m) - if err != nil { return nil, err } @@ -192,7 +187,6 @@ func newPageStandalone(m *pageMeta, f output.Format) (*pageState, error) { } return p, nil - } type pageDeprecatedWarning struct { @@ -205,6 +199,7 @@ func (p *pageDeprecatedWarning) LanguagePrefix() string { return p.p.s.Info.Lang func (p *pageDeprecatedWarning) GetParam(ke