Command: `gofmt -l -s -w .`
This commit is contained in:
Caleb Spare 2013-11-24 13:48:57 -08:00 committed by spf13
parent 1abc2f0b86
commit 6da23f7449
8 changed files with 30 additions and 32 deletions

View file

@ -43,7 +43,6 @@ Complete documentation is available at http://hugo.spf13.com`,
} }
var hugoCmdV *cobra.Command var hugoCmdV *cobra.Command
var BuildWatch, Draft, UglyUrls, Verbose bool var BuildWatch, Draft, UglyUrls, Verbose bool
var Source, Destination, BaseUrl, CfgFile string var Source, Destination, BaseUrl, CfgFile string

View file

@ -39,7 +39,7 @@ func (p IndexedPages) Less(i, j int) bool {
func (ip IndexedPages) Pages() Pages { func (ip IndexedPages) Pages() Pages {
pages := make(Pages, len(ip)) pages := make(Pages, len(ip))
for i, _ := range ip { for i := range ip {
pages[i] = ip[i].Page pages[i] = ip[i].Page
} }
return pages return pages

View file

@ -1,10 +1,10 @@
package hugolib package hugolib
import ( import (
"testing"
"bytes" "bytes"
"github.com/spf13/hugo/source" "github.com/spf13/hugo/source"
"github.com/spf13/hugo/target" "github.com/spf13/hugo/target"
"testing"
) )
const RSS_TEMPLATE = `<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> const RSS_TEMPLATE = `<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
@ -39,7 +39,7 @@ func TestRSSOutput(t *testing.T) {
s.initializeSiteInfo() s.initializeSiteInfo()
s.prepTemplates() s.prepTemplates()
// Add an rss.xml template to invoke the rss build. // 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 { if err := s.CreatePages(); err != nil {
t.Fatalf("Unable to create pages: %s", err) t.Fatalf("Unable to create pages: %s", err)

View file

@ -185,7 +185,7 @@ func Tokenize(in string) interface{} {
// No closing "... just make remainder the final token // No closing "... just make remainder the final token
if inQuote && i == len(first) { if inQuote && i == len(first) {
final = append(final, first[start:len(first)]...) final = append(final, first[start:]...)
} }
} }

View file

@ -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() 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]}) 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() s.Sections[k].Sort()
} }
@ -356,7 +356,7 @@ func (s *Site) BuildSiteMeta() (err error) {
func (s *Site) possibleIndexes() (indexes []string) { func (s *Site) possibleIndexes() (indexes []string) {
for _, p := range s.Pages { for _, p := range s.Pages {
for k, _ := range p.Params { for k := range p.Params {
if !inStringArray(indexes, k) { if !inStringArray(indexes, k) {
indexes = append(indexes, k) indexes = append(indexes, k)
} }

View file

@ -1,13 +1,12 @@
package hugolib package hugolib
import ( import (
"testing"
"bytes" "bytes"
"testing"
) )
const SITE_INFO_PARAM_TEMPLATE = `{{ .Site.Params.MyGlobalParam }}` const SITE_INFO_PARAM_TEMPLATE = `{{ .Site.Params.MyGlobalParam }}`
func TestSiteInfoParams(t *testing.T) { func TestSiteInfoParams(t *testing.T) {
s := &Site{ s := &Site{
Config: Config{Params: map[string]interface{}{"MyGlobalParam": "FOOBAR_PARAM"}}, Config: Config{Params: map[string]interface{}{"MyGlobalParam": "FOOBAR_PARAM"}},

View file

@ -6,19 +6,19 @@ import (
) )
func TestGt(t *testing.T) { func TestGt(t *testing.T) {
for i, this := range []struct{ for i, this := range []struct {
left interface{} left interface{}
right interface{} right interface{}
leftShouldWin bool leftShouldWin bool
}{ }{
{ 5, 8, false }, {5, 8, false},
{ 8, 5, true }, {8, 5, true},
{ 5, 5, false }, {5, 5, false},
{ -2, 1, false }, {-2, 1, false},
{ 2, -5, true }, {2, -5, true},
{ "8", "5", true }, {"8", "5", true},
{ "5", "0001", true }, {"5", "0001", true},
{ []int{100,99}, []int{1,2,3,4}, false }, {[]int{100, 99}, []int{1, 2, 3, 4}, false},
} { } {
leftIsBigger := Gt(this.left, this.right) leftIsBigger := Gt(this.left, this.right)
if leftIsBigger != this.leftShouldWin { if leftIsBigger != this.leftShouldWin {
@ -34,14 +34,14 @@ func TestGt(t *testing.T) {
} }
func TestFirst(t *testing.T) { func TestFirst(t *testing.T) {
for i, this := range []struct{ for i, this := range []struct {
count int count int
sequence interface{} sequence interface{}
expect interface{} expect interface{}
} { }{
{ 2, []string{"a", "b", "c"}, []string{"a", "b"} }, {2, []string{"a", "b", "c"}, []string{"a", "b"}},
{ 3, []string{"a", "b"}, []string{"a", "b"} }, {3, []string{"a", "b"}, []string{"a", "b"}},
{ 2, []int{100, 200, 300}, []int{100, 200} }, {2, []int{100, 200, 300}, []int{100, 200}},
} { } {
results, err := First(this.count, this.sequence) results, err := First(this.count, this.sequence)
if err != nil { if err != nil {

View file

@ -33,10 +33,10 @@ func AbsURL(absURL string) (trs []link, err error) {
} }
func guardReplace(content, guard, match, replace []byte) []byte { func guardReplace(content, guard, match, replace []byte) []byte {
if !bytes.Contains(content, guard) { if !bytes.Contains(content, guard) {
content = bytes.Replace(content, match, replace, -1) content = bytes.Replace(content, match, replace, -1)
} }
return content return content
} }
type elattr struct { type elattr struct {