Run gofmt -s with Go 1.10
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 21 Feb 2018 08:23:43 +0000 (09:23 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 21 Feb 2018 08:59:33 +0000 (09:59 +0100)
See #4434

commands/server.go
helpers/path_test.go
helpers/processing_stats.go
hugolib/hugo_sites.go
magefile.go
resource/image_cache.go
resource/image_test.go
resource/resource.go
resource/resource_test.go

index be93489d4e7fb0a2420a599179003e0c46ad78cd..130ac18bef6303efb63de24408a165c538eb5cb3 100644 (file)
@@ -359,7 +359,7 @@ func (c *commandeer) serve() error {
        var sigs = make(chan os.Signal)
        signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
 
-       for i, _ := range baseURLs {
+       for i := range baseURLs {
                mu, serverURL, endpoint, err := srv.createEndpoint(i)
 
                if doLiveReload {
index bb51250347ed35445de1a91ed16ee8b87234d7d3..d2c577daea536d13ce649750357daf56e0713803 100644 (file)
@@ -670,10 +670,10 @@ func TestFindCWD(t *testing.T) {
 
        //cwd, _ := os.Getwd()
        data := []test{
-       //{cwd, nil},
-       // Commenting this out. It doesn't work properly.
-       // There's a good reason why we don't use os.Getwd(), it doesn't actually work the way we want it to.
-       // I really don't know a better way to test this function. - SPF 2014.11.04
+               //{cwd, nil},
+               // Commenting this out. It doesn't work properly.
+               // There's a good reason why we don't use os.Getwd(), it doesn't actually work the way we want it to.
+               // I really don't know a better way to test this function. - SPF 2014.11.04
        }
        for i, d := range data {
                dir, err := FindCWD()
index 36dfcda69a95acab54e23494ab745f78cced1207..2d7fcb4de681d8a65b4c178f17d6451c1e27de03 100644 (file)
@@ -41,14 +41,14 @@ type processingStatsTitleVal struct {
 
 func (s *ProcessingStats) toVals() []processingStatsTitleVal {
        return []processingStatsTitleVal{
-               processingStatsTitleVal{"Pages", s.Pages},
-               processingStatsTitleVal{"Paginator pages", s.PaginatorPages},
-               processingStatsTitleVal{"Non-page files", s.Files},
-               processingStatsTitleVal{"Static files", s.Static},
-               processingStatsTitleVal{"Processed images", s.ProcessedImages},
-               processingStatsTitleVal{"Aliases", s.Aliases},
-               processingStatsTitleVal{"Sitemaps", s.Sitemaps},
-               processingStatsTitleVal{"Cleaned", s.Cleaned},
+               {"Pages", s.Pages},
+               {"Paginator pages", s.PaginatorPages},
+               {"Non-page files", s.Files},
+               {"Static files", s.Static},
+               {"Processed images", s.ProcessedImages},
+               {"Aliases", s.Aliases},
+               {"Sitemaps", s.Sitemaps},
+               {"Cleaned", s.Cleaned},
        }
 }
 
index e6000e06dd02a8018c4d4369065a56588bbf6382..6c2a5c1538f2de9caa3e0c1c43afd3fd65a03baf 100644 (file)
@@ -739,7 +739,7 @@ func (m *contentChangeMap) GetSymbolicLinkMappings(dir string) []string {
        }
        dirs := make([]string, len(mm))
        i := 0
-       for dir, _ := range mm {
+       for dir := range mm {
                dirs[i] = dir
                i++
        }
index 8ab594a020ca481962847b19f65a73f99b9257b8..883f96620cfa34f8427838337c2fff8a1cb7fd4e 100644 (file)
@@ -122,7 +122,7 @@ func TestRace() error {
 
 // Run gofmt linter
 func Fmt() error {
-       if isGoTip() {
+       if !isGoLatest() {
                return nil
        }
        pkgs, err := hugoPackages()
@@ -258,6 +258,6 @@ func CheckVendor() error {
        return nil
 }
 
-func isGoTip() bool {
-       return strings.Contains(runtime.Version(), "devel") || strings.Contains(runtime.Version(), "1.10")
+func isGoLatest() bool {
+       return strings.Contains(runtime.Version(), "1.10")
 }
index 250155db1a7441bd85bfa75a5e0cb7bd8c25e0dc..a1d41ec381abd5b1ff60ee2fde77115e8fa31a0d 100644 (file)
@@ -42,7 +42,7 @@ func (c *imageCache) isInCache(key string) bool {
 func (c *imageCache) deleteByPrefix(prefix string) {
        c.mu.Lock()
        defer c.mu.Unlock()
-       for k, _ := range c.store {
+       for k := range c.store {
                if strings.HasPrefix(k, prefix) {
                        delete(c.store, k)
                }
index 1a937d56b6d55fbbdfdec611cd3fd4d1076de590..03cd1726f28c6a19d2d7ded7d6619ba88ee6f303 100644 (file)
@@ -244,7 +244,7 @@ func TestImageWithMetadata(t *testing.T) {
        image := fetchSunset(assert)
 
        var meta = []map[string]interface{}{
-               map[string]interface{}{
+               {
                        "title": "My Sunset",
                        "name":  "Sunset #:counter",
                        "src":   "*.jpg",
index 66fda4c1bfafdafb87e41665d92f67884c177e3a..67aed39c221c6c9abd59cca20285fbf40b242767 100644 (file)
@@ -332,7 +332,7 @@ func (r *Spec) CacheStats() string {
        s := fmt.Sprintf("Cache entries: %d", len(r.imageCache.store))
 
        count := 0
-       for k, _ := range r.imageCache.store {
+       for k := range r.imageCache.store {
                if count > 5 {
                        break
                }
index 1ff97984633e6b72398b42a82c0a368afb9420de..f4c652d43984a56cb7ff3039841f9f208912c6e4 100644 (file)
@@ -198,7 +198,7 @@ func TestAssignMetadata(t *testing.T) {
                assertFunc func(err error)
        }{
                {[]map[string]interface{}{
-                       map[string]interface{}{
+                       {
                                "title": "My Resource",
                                "name":  "My Name",
                                "src":   "*",
@@ -210,11 +210,11 @@ func TestAssignMetadata(t *testing.T) {
 
                }},
                {[]map[string]interface{}{
-                       map[string]interface{}{
+                       {
                                "title": "My Logo",
                                "src":   "*loGo*",
                        },
-                       map[string]interface{}{
+                       {
                                "title": "My Resource",
                                "name":  "My Name",
                                "src":   "*",
@@ -229,7 +229,7 @@ func TestAssignMetadata(t *testing.T) {
 
                }},
                {[]map[string]interface{}{
-                       map[string]interface{}{
+                       {
                                "title": "My Logo",
                                "src":   "*loGo*",
                                "params": map[string]interface{}{
@@ -237,7 +237,7 @@ func TestAssignMetadata(t *testing.T) {
                                        "icon":   "logo",
                                },
                        },
-                       map[string]interface{}{
+                       {
                                "title": "My Resource",
                                "src":   "*",
                                "params": map[string]interface{}{
@@ -269,11 +269,11 @@ func TestAssignMetadata(t *testing.T) {
 
                }},
                {[]map[string]interface{}{
-                       map[string]interface{}{
+                       {
                                "name": "Logo Name #:counter",
                                "src":  "*logo*",
                        },
-                       map[string]interface{}{
+                       {
                                "title": "Resource #:counter",
                                "name":  "Name #:counter",
                                "src":   "*",
@@ -293,11 +293,11 @@ func TestAssignMetadata(t *testing.T) {
 
                }},
                {[]map[string]interface{}{
-                       map[string]interface{}{
+                       {
                                "title": "Third Logo #:counter",
                                "src":   "logo3.png",
                        },
-                       map[string]interface{}{
+                       {
                                "title": "Other Logo #:counter",
                                "name":  "Name #:counter",
                                "src":   "logo*",
@@ -313,11 +313,11 @@ func TestAssignMetadata(t *testing.T) {
 
                }},
                {[]map[string]interface{}{
-                       map[string]interface{}{
+                       {
                                "title": "Third Logo",
                                "src":   "logo3.png",
                        },
-                       map[string]interface{}{
+                       {
                                "title": "Other Logo #:counter",
                                "name":  "Name #:counter",
                                "src":   "logo*",
@@ -333,11 +333,11 @@ func TestAssignMetadata(t *testing.T) {
 
                }},
                {[]map[string]interface{}{
-                       map[string]interface{}{
+                       {
                                "name": "third-logo",
                                "src":  "logo3.png",
                        },
-                       map[string]interface{}{
+                       {
                                "title": "Logo #:counter",
                                "name":  "Name #:counter",
                                "src":   "logo*",
@@ -353,7 +353,7 @@ func TestAssignMetadata(t *testing.T) {
 
                }},
                {[]map[string]interface{}{
-                       map[string]interface{}{
+                       {
                                "title": "Third Logo #:counter",
                        },
                }, func(err error) {
@@ -362,7 +362,7 @@ func TestAssignMetadata(t *testing.T) {
 
                }},
                {[]map[string]interface{}{
-                       map[string]interface{}{
+                       {
                                "title": "Title",
                                "src":   "[]",
                        },
@@ -469,12 +469,12 @@ func BenchmarkAssignMetadata(b *testing.B) {
                b.StopTimer()
                var resources Resources
                var meta = []map[string]interface{}{
-                       map[string]interface{}{
+                       {
                                "title": "Foo #:counter",
                                "name":  "Foo Name #:counter",
                                "src":   "foo1*",
                        },
-                       map[string]interface{}{
+                       {
                                "title": "Rest #:counter",
                                "name":  "Rest Name #:counter",
                                "src":   "*",