mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Fixing issues go vet reports.
This commit is contained in:
parent
2c0ded7f9f
commit
2540d884d8
11 changed files with 25 additions and 33 deletions
|
@ -213,12 +213,12 @@ func NewWatcher(port int) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if static_changed {
|
if static_changed {
|
||||||
fmt.Println("Static file changed, syncing\n")
|
fmt.Print("Static file changed, syncing\n\n")
|
||||||
utils.CheckErr(copyStatic(), fmt.Sprintf("Error copying static files to %s", Config.GetAbsPath(Config.PublishDir)))
|
utils.CheckErr(copyStatic(), fmt.Sprintf("Error copying static files to %s", Config.GetAbsPath(Config.PublishDir)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if dynamic_changed {
|
if dynamic_changed {
|
||||||
fmt.Println("Change detected, rebuilding site\n")
|
fmt.Print("Change detected, rebuilding site\n\n")
|
||||||
utils.StopOnErr(buildSite(true))
|
utils.StopOnErr(buildSite(true))
|
||||||
}
|
}
|
||||||
case err := <-watcher.Error:
|
case err := <-watcher.Error:
|
||||||
|
|
|
@ -116,5 +116,4 @@ func PrettifyPath(in string) string {
|
||||||
return path.Join(path.Dir(in), name, "index"+ext)
|
return path.Join(path.Dir(in), name, "index"+ext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return in
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,4 @@ func Uglify(in string) string {
|
||||||
return path.Clean(in)
|
return path.Clean(in)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return in
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ func BenchmarkParsePage(b *testing.B) {
|
||||||
sample.ReadFrom(f)
|
sample.ReadFrom(f)
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
p, _ := ReadFrom(bytes.NewReader(sample.Bytes()), "bench")
|
ReadFrom(bytes.NewReader(sample.Bytes()), "bench")
|
||||||
p = p
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ func interfaceToTime(i interface{}) time.Time {
|
||||||
if e == nil {
|
if e == nil {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
errorf("Could not parse Date/Time format:", e)
|
errorln("Could not parse Date/Time format:", e)
|
||||||
default:
|
default:
|
||||||
errorf("Only Time is supported for this key")
|
errorln("Only Time is supported for this key")
|
||||||
}
|
}
|
||||||
|
|
||||||
return *new(time.Time)
|
return *new(time.Time)
|
||||||
|
@ -54,7 +54,7 @@ func stringToDate(s string) (time.Time, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remove this and return a proper error.
|
// TODO remove this and return a proper error.
|
||||||
func errorf(str string, a ...interface{}) {
|
func errorln(str string, a ...interface{}) {
|
||||||
fmt.Fprintln(os.Stderr, str, a)
|
fmt.Fprintln(os.Stderr, str, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ func interfaceToBool(i interface{}) bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
default:
|
default:
|
||||||
errorf("Only Boolean values are supported for this YAML key")
|
errorln("Only Boolean values are supported for this YAML key")
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
@ -109,11 +109,11 @@ func interfaceToFloat64(i interface{}) float64 {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return float64(v)
|
return float64(v)
|
||||||
} else {
|
} else {
|
||||||
errorf("Only Floats are supported for this key\nErr:", err)
|
errorln("Only Floats are supported for this key\nErr:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
errorf("Only Floats are supported for this key")
|
errorln("Only Floats are supported for this key")
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0.0
|
return 0.0
|
||||||
|
@ -136,10 +136,10 @@ func interfaceToInt(i interface{}) int {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return int(v)
|
return int(v)
|
||||||
} else {
|
} else {
|
||||||
errorf("Only Ints are supported for this key\nErr:", err)
|
errorln("Only Ints are supported for this key\nErr:", err)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
errorf("Only Ints are supported for this key")
|
errorln("Only Ints are supported for this key")
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
@ -154,7 +154,7 @@ func interfaceToString(i interface{}) string {
|
||||||
case int:
|
case int:
|
||||||
return strconv.FormatInt(int64(i.(int)), 10)
|
return strconv.FormatInt(int64(i.(int)), 10)
|
||||||
default:
|
default:
|
||||||
errorf(fmt.Sprintf("Only Strings are supported for this key (got type '%T'): %s", s, s))
|
errorln(fmt.Sprintf("Only Strings are supported for this key (got type '%T'): %s", s, s))
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -457,10 +457,10 @@ func TestDifferentFrontMatterVarTypes(t *testing.T) {
|
||||||
t.Errorf("frontmatter not handling ints correctly should be %s, got: %s", "1", page.GetParam("an_integer"))
|
t.Errorf("frontmatter not handling ints correctly should be %s, got: %s", "1", page.GetParam("an_integer"))
|
||||||
}
|
}
|
||||||
if page.GetParam("a_float") != 1.3 {
|
if page.GetParam("a_float") != 1.3 {
|
||||||
t.Errorf("frontmatter not handling floats correctly should be %s, got: %s", 1.3, page.GetParam("a_float"))
|
t.Errorf("frontmatter not handling floats correctly should be %f, got: %s", 1.3, page.GetParam("a_float"))
|
||||||
}
|
}
|
||||||
if page.GetParam("a_bool") != false {
|
if page.GetParam("a_bool") != false {
|
||||||
t.Errorf("frontmatter not handling bools correctly should be %s, got: %s", false, page.GetParam("a_bool"))
|
t.Errorf("frontmatter not handling bools correctly should be %t, got: %s", false, page.GetParam("a_bool"))
|
||||||
}
|
}
|
||||||
if page.GetParam("a_date") != dateval {
|
if page.GetParam("a_date") != dateval {
|
||||||
t.Errorf("frontmatter not handling dates correctly should be %s, got: %s", dateval, page.GetParam("a_date"))
|
t.Errorf("frontmatter not handling dates correctly should be %s, got: %s", dateval, page.GetParam("a_date"))
|
||||||
|
|
|
@ -34,7 +34,7 @@ func TestRSSOutput(t *testing.T) {
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Target: target,
|
Target: target,
|
||||||
Config: Config{BaseUrl: "http://auth/bub/"},
|
Config: Config{BaseUrl: "http://auth/bub/"},
|
||||||
Source: &source.InMemorySource{WEIGHTED_SOURCES},
|
Source: &source.InMemorySource{ByteSource: WEIGHTED_SOURCES},
|
||||||
}
|
}
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
s.prepTemplates()
|
s.prepTemplates()
|
||||||
|
|
|
@ -41,7 +41,7 @@ func TestDegenerateNoFiles(t *testing.T) {
|
||||||
|
|
||||||
func TestDegenerateNoTarget(t *testing.T) {
|
func TestDegenerateNoTarget(t *testing.T) {
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{fakeSource},
|
Source: &source.InMemorySource{ByteSource: fakeSource},
|
||||||
}
|
}
|
||||||
must(s.CreatePages())
|
must(s.CreatePages())
|
||||||
expected := "foo/bar/file.md (renderer: markdown)\n canonical => !no target specified!\n\n" +
|
expected := "foo/bar/file.md (renderer: markdown)\n canonical => !no target specified!\n\n" +
|
||||||
|
@ -52,7 +52,7 @@ func TestDegenerateNoTarget(t *testing.T) {
|
||||||
|
|
||||||
func TestFileTarget(t *testing.T) {
|
func TestFileTarget(t *testing.T) {
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{fakeSource},
|
Source: &source.InMemorySource{ByteSource: fakeSource},
|
||||||
Target: new(target.Filesystem),
|
Target: new(target.Filesystem),
|
||||||
Alias: new(target.HTMLRedirectAlias),
|
Alias: new(target.HTMLRedirectAlias),
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ func TestFileTarget(t *testing.T) {
|
||||||
func TestFileTargetUgly(t *testing.T) {
|
func TestFileTargetUgly(t *testing.T) {
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Target: &target.Filesystem{UglyUrls: true},
|
Target: &target.Filesystem{UglyUrls: true},
|
||||||
Source: &source.InMemorySource{fakeSource},
|
Source: &source.InMemorySource{ByteSource: fakeSource},
|
||||||
Alias: new(target.HTMLRedirectAlias),
|
Alias: new(target.HTMLRedirectAlias),
|
||||||
}
|
}
|
||||||
s.CreatePages()
|
s.CreatePages()
|
||||||
|
@ -86,7 +86,7 @@ func TestFileTargetUgly(t *testing.T) {
|
||||||
func TestFileTargetPublishDir(t *testing.T) {
|
func TestFileTargetPublishDir(t *testing.T) {
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Target: &target.Filesystem{PublishDir: "../public"},
|
Target: &target.Filesystem{PublishDir: "../public"},
|
||||||
Source: &source.InMemorySource{fakeSource},
|
Source: &source.InMemorySource{ByteSource: fakeSource},
|
||||||
Alias: &target.HTMLRedirectAlias{PublishDir: "../public"},
|
Alias: &target.HTMLRedirectAlias{PublishDir: "../public"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ func TestSkipRender(t *testing.T) {
|
||||||
BaseUrl: "http://auth/bub",
|
BaseUrl: "http://auth/bub",
|
||||||
CanonifyUrls: true,
|
CanonifyUrls: true,
|
||||||
},
|
},
|
||||||
Source: &source.InMemorySource{sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
}
|
}
|
||||||
|
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
@ -301,7 +301,7 @@ func TestAbsUrlify(t *testing.T) {
|
||||||
BaseUrl: "http://auth/bub",
|
BaseUrl: "http://auth/bub",
|
||||||
CanonifyUrls: canonify,
|
CanonifyUrls: canonify,
|
||||||
},
|
},
|
||||||
Source: &source.InMemorySource{sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
}
|
}
|
||||||
t.Logf("Rendering with BaseUrl %q and CanonifyUrls set %v", s.Config.BaseUrl, canonify)
|
t.Logf("Rendering with BaseUrl %q and CanonifyUrls set %v", s.Config.BaseUrl, canonify)
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
@ -383,7 +383,7 @@ func TestOrderedPages(t *testing.T) {
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Target: target,
|
Target: target,
|
||||||
Config: Config{BaseUrl: "http://auth/bub/"},
|
Config: Config{BaseUrl: "http://auth/bub/"},
|
||||||
Source: &source.InMemorySource{WEIGHTED_SOURCES},
|
Source: &source.InMemorySource{ByteSource: WEIGHTED_SOURCES},
|
||||||
}
|
}
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ func TestOrderedPages(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Sections["sect"][0].Weight != 2 || s.Sections["sect"][3].Weight != 6 {
|
if s.Sections["sect"][0].Weight != 2 || s.Sections["sect"][3].Weight != 6 {
|
||||||
t.Errorf("Pages in unexpected order. First should be '%s', got '%s'", 2, s.Sections["sect"][0].Weight)
|
t.Errorf("Pages in unexpected order. First should be '%d', got '%d'", 2, s.Sections["sect"][0].Weight)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Sections["sect"][1].Page.Title != "Three" || s.Sections["sect"][2].Page.Title != "Four" {
|
if s.Sections["sect"][1].Page.Title != "Three" || s.Sections["sect"][2].Page.Title != "Four" {
|
||||||
|
@ -469,7 +469,7 @@ func TestWeightedIndexes(t *testing.T) {
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Target: target,
|
Target: target,
|
||||||
Config: Config{BaseUrl: "http://auth/bub/", Indexes: indexes},
|
Config: Config{BaseUrl: "http://auth/bub/", Indexes: indexes},
|
||||||
Source: &source.InMemorySource{sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
}
|
}
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ func TestPageCount(t *testing.T) {
|
||||||
Target: target,
|
Target: target,
|
||||||
Alias: alias,
|
Alias: alias,
|
||||||
Config: Config{UglyUrls: false},
|
Config: Config{UglyUrls: false},
|
||||||
Source: &source.InMemorySource{urlFakeSource},
|
Source: &source.InMemorySource{ByteSource: urlFakeSource},
|
||||||
}
|
}
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
s.prepTemplates()
|
s.prepTemplates()
|
||||||
|
|
|
@ -3,7 +3,6 @@ package parser
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
@ -106,7 +105,6 @@ func chompWhitespace(r io.RuneScanner) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func peekLine(r *bufio.Reader) (line []byte, err error) {
|
func peekLine(r *bufio.Reader) (line []byte, err error) {
|
||||||
|
@ -165,7 +163,6 @@ func determineDelims(firstLine []byte) (left, right []byte) {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("Unable to determine delims from %q", firstLine))
|
panic(fmt.Sprintf("Unable to determine delims from %q", firstLine))
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractFrontMatterDelims(r *bufio.Reader, left, right []byte) (fm FrontMatter, err error) {
|
func extractFrontMatterDelims(r *bufio.Reader, left, right []byte) (fm FrontMatter, err error) {
|
||||||
|
@ -243,7 +240,6 @@ func extractFrontMatterDelims(r *bufio.Reader, left, right []byte) (fm FrontMatt
|
||||||
return wr.Bytes(), nil
|
return wr.Bytes(), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, errors.New("Could not find front matter.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func matches_quick(buf, expected []byte) (ok bool, err error) {
|
func matches_quick(buf, expected []byte) (ok bool, err error) {
|
||||||
|
|
Loading…
Reference in a new issue