From 6da23f7449366e7699e406adb3334e71ffd1e70e Mon Sep 17 00:00:00 2001 From: Caleb Spare Date: Sun, 24 Nov 2013 13:48:57 -0800 Subject: [PATCH] Gofmt Command: `gofmt -l -s -w .` --- commands/hugo.go | 1 - hugolib/index.go | 2 +- hugolib/rss_test.go | 4 ++-- hugolib/shortcode.go | 2 +- hugolib/site.go | 6 +++--- hugolib/siteinfo_test.go | 3 +-- template/bundle/template_test.go | 36 ++++++++++++++++---------------- transform/absurl.go | 8 +++---- 8 files changed, 30 insertions(+), 32 deletions(-) diff --git a/commands/hugo.go b/commands/hugo.go index a10dcce4a..a99feb7c0 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -43,7 +43,6 @@ Complete documentation is available at http://hugo.spf13.com`, } var hugoCmdV *cobra.Command - var BuildWatch, Draft, UglyUrls, Verbose bool var Source, Destination, BaseUrl, CfgFile string diff --git a/hugolib/index.go b/hugolib/index.go index 38441d463..2c690e185 100644 --- a/hugolib/index.go +++ b/hugolib/index.go @@ -39,7 +39,7 @@ func (p IndexedPages) Less(i, j int) bool { func (ip IndexedPages) Pages() Pages { pages := make(Pages, len(ip)) - for i, _ := range ip { + for i := range ip { pages[i] = ip[i].Page } return pages diff --git a/hugolib/rss_test.go b/hugolib/rss_test.go index b4c9e01d7..1d6f95b56 100644 --- a/hugolib/rss_test.go +++ b/hugolib/rss_test.go @@ -1,10 +1,10 @@ package hugolib import ( - "testing" "bytes" "github.com/spf13/hugo/source" "github.com/spf13/hugo/target" + "testing" ) const RSS_TEMPLATE = ` @@ -39,7 +39,7 @@ func TestRSSOutput(t *testing.T) { s.initializeSiteInfo() s.prepTemplates() // Add an rss.xml template to invoke the rss build. - s.addTemplate("rss.xml", RSS_TEMPLATE) + s.addTemplate("rss.xml", RSS_TEMPLATE) if err := s.CreatePages(); err != nil { t.Fatalf("Unable to create pages: %s", err) diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go index f08d30cd7..2e91e02ea 100644 --- a/hugolib/shortcode.go +++ b/hugolib/shortcode.go @@ -185,7 +185,7 @@ func Tokenize(in string) interface{} { // No closing "... just make remainder the final token if inQuote && i == len(first) { - final = append(final, first[start:len(first)]...) + final = append(final, first[start:]...) } } diff --git a/hugolib/site.go b/hugolib/site.go index ef27d0979..d34fa5acf 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -326,7 +326,7 @@ func (s *Site) BuildSiteMeta() (err error) { } } } - for k, _ := range s.Indexes[plural] { + for k := range s.Indexes[plural] { s.Indexes[plural][k].Sort() } } @@ -335,7 +335,7 @@ func (s *Site) BuildSiteMeta() (err error) { s.Sections.Add(p.Section, WeightedIndexEntry{s.Pages[i].Weight, s.Pages[i]}) } - for k, _ := range s.Sections { + for k := range s.Sections { s.Sections[k].Sort() } @@ -356,7 +356,7 @@ func (s *Site) BuildSiteMeta() (err error) { func (s *Site) possibleIndexes() (indexes []string) { for _, p := range s.Pages { - for k, _ := range p.Params { + for k := range p.Params { if !inStringArray(indexes, k) { indexes = append(indexes, k) } diff --git a/hugolib/siteinfo_test.go b/hugolib/siteinfo_test.go index f855dd970..c0ae56575 100644 --- a/hugolib/siteinfo_test.go +++ b/hugolib/siteinfo_test.go @@ -1,13 +1,12 @@ package hugolib import ( - "testing" "bytes" + "testing" ) const SITE_INFO_PARAM_TEMPLATE = `{{ .Site.Params.MyGlobalParam }}` - func TestSiteInfoParams(t *testing.T) { s := &Site{ Config: Config{Params: map[string]interface{}{"MyGlobalParam": "FOOBAR_PARAM"}}, diff --git a/template/bundle/template_test.go b/template/bundle/template_test.go index 1d0fce1fb..019816f6e 100644 --- a/template/bundle/template_test.go +++ b/template/bundle/template_test.go @@ -6,19 +6,19 @@ import ( ) func TestGt(t *testing.T) { - for i, this := range []struct{ - left interface{} - right interface{} + for i, this := range []struct { + left interface{} + right interface{} leftShouldWin bool }{ - { 5, 8, false }, - { 8, 5, true }, - { 5, 5, false }, - { -2, 1, false }, - { 2, -5, true }, - { "8", "5", true }, - { "5", "0001", true }, - { []int{100,99}, []int{1,2,3,4}, false }, + {5, 8, false}, + {8, 5, true}, + {5, 5, false}, + {-2, 1, false}, + {2, -5, true}, + {"8", "5", true}, + {"5", "0001", true}, + {[]int{100, 99}, []int{1, 2, 3, 4}, false}, } { leftIsBigger := Gt(this.left, this.right) if leftIsBigger != this.leftShouldWin { @@ -34,14 +34,14 @@ func TestGt(t *testing.T) { } func TestFirst(t *testing.T) { - for i, this := range []struct{ - count int + for i, this := range []struct { + count int sequence interface{} - expect interface{} - } { - { 2, []string{"a", "b", "c"}, []string{"a", "b"} }, - { 3, []string{"a", "b"}, []string{"a", "b"} }, - { 2, []int{100, 200, 300}, []int{100, 200} }, + expect interface{} + }{ + {2, []string{"a", "b", "c"}, []string{"a", "b"}}, + {3, []string{"a", "b"}, []string{"a", "b"}}, + {2, []int{100, 200, 300}, []int{100, 200}}, } { results, err := First(this.count, this.sequence) if err != nil { diff --git a/transform/absurl.go b/transform/absurl.go index 8bdd36515..9838cbe51 100644 --- a/transform/absurl.go +++ b/transform/absurl.go @@ -33,10 +33,10 @@ func AbsURL(absURL string) (trs []link, err error) { } func guardReplace(content, guard, match, replace []byte) []byte { - if !bytes.Contains(content, guard) { - content = bytes.Replace(content, match, replace, -1) - } - return content + if !bytes.Contains(content, guard) { + content = bytes.Replace(content, match, replace, -1) + } + return content } type elattr struct {