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 --- config/commonConfig.go | 8 ++------ config/commonConfig_test.go | 8 ++++---- config/configLoader.go | 1 - config/privacy/privacyConfig_test.go | 1 - config/services/servicesConfig_test.go | 1 - 5 files changed, 6 insertions(+), 13 deletions(-) (limited to 'config') diff --git a/config/commonConfig.go b/config/commonConfig.go index 9b4edfd90..260ebe73e 100644 --- a/config/commonConfig.go +++ b/config/commonConfig.go @@ -14,12 +14,12 @@ package config import ( - "github.com/pkg/errors" - "sort" "strings" "sync" + "github.com/pkg/errors" + "github.com/gohugoio/hugo/common/types" "github.com/gobwas/glob" @@ -88,7 +88,6 @@ type Sitemap struct { } func DecodeSitemap(prototype Sitemap, input map[string]interface{}) Sitemap { - for key, value := range input { switch key { case "changefreq": @@ -116,7 +115,6 @@ type Server struct { } func (s *Server) init() { - s.compiledInit.Do(func() { for _, h := range s.Headers { s.compiledHeaders = append(s.compiledHeaders, glob.MustCompile(h.For)) @@ -150,7 +148,6 @@ func (s *Server) MatchHeaders(pattern string) []types.KeyValueStr { }) return matches - } func (s *Server) MatchRedirect(pattern string) Redirect { @@ -176,7 +173,6 @@ func (s *Server) MatchRedirect(pattern string) Redirect { } return Redirect{} - } type Headers struct { diff --git a/config/commonConfig_test.go b/config/commonConfig_test.go index b8b6e6795..d4273277a 100644 --- a/config/commonConfig_test.go +++ b/config/commonConfig_test.go @@ -57,7 +57,6 @@ func TestBuild(t *testing.T) { c.Assert(b.UseResourceCache(herrors.ErrFeatureNotAvailable), qt.Equals, false) c.Assert(b.UseResourceCache(errors.New("err")), qt.Equals, false) c.Assert(b.UseResourceCache(nil), qt.Equals, false) - } func TestServer(t *testing.T) { @@ -98,7 +97,8 @@ status = 301 c.Assert(s.MatchHeaders("/foo.jpg"), qt.DeepEquals, []types.KeyValueStr{ {Key: "X-Content-Type-Options", Value: "nosniff"}, {Key: "X-Frame-Options", Value: "DENY"}, - {Key: "X-XSS-Protection", Value: "1; mode=block"}}) + {Key: "X-XSS-Protection", Value: "1; mode=block"}, + }) c.Assert(s.MatchRedirect("/foo/bar/baz"), qt.DeepEquals, Redirect{ From: "/foo/**", @@ -122,7 +122,8 @@ status = 301 c.Assert(s.MatchRedirect("/default/index.html"), qt.DeepEquals, Redirect{}) c.Assert(s.MatchRedirect("/default/"), qt.DeepEquals, Redirect{}) - for _, errorCase := range []string{`[[server.redirects]] + for _, errorCase := range []string{ + `[[server.redirects]] from = "/**" to = "/file" status = 301`, @@ -138,5 +139,4 @@ status = 301`, c.Assert(err, qt.Not(qt.IsNil)) } - } diff --git a/config/configLoader.go b/config/configLoader.go index 2e37a5b35..6d94f0b79 100644 --- a/config/configLoader.go +++ b/config/configLoader.go @@ -86,7 +86,6 @@ func readConfig(format metadecoders.Format, data []byte) (map[string]interface{} RenameKeys(m) return m, nil - } func loadConfigFromFile(fs afero.Fs, filename string) (map[string]interface{}, error) { diff --git a/config/privacy/privacyConfig_test.go b/config/privacy/privacyConfig_test.go index a750ba282..0fb599c0a 100644 --- a/config/privacy/privacyConfig_test.go +++ b/config/privacy/privacyConfig_test.go @@ -69,7 +69,6 @@ simple = true } c.Assert(got, qt.All(qt.Equals), true) - } func TestDecodeConfigFromTOMLCaseInsensitive(t *testing.T) { diff --git a/config/services/servicesConfig_test.go b/config/services/servicesConfig_test.go index ed3038159..6e979b999 100644 --- a/config/services/servicesConfig_test.go +++ b/config/services/servicesConfig_test.go @@ -65,5 +65,4 @@ func TestUseSettingsFromRootIfSet(t *testing.T) { c.Assert(config.Disqus.Shortname, qt.Equals, "root_short") c.Assert(config.GoogleAnalytics.ID, qt.Equals, "ga_root") - } -- cgit v1.2.3