diff --git a/routes/errors/errors.go b/routes/errors/errors.go index fdcaf618..268e8a4d 100644 --- a/routes/errors/errors.go +++ b/routes/errors/errors.go @@ -32,7 +32,8 @@ func ServeHTTP(w http.ResponseWriter, r *http.Request, code int, err error) (int "Defined": variables.Defined, } - tpl, err := templates.Get(r, functions, "error") + var tpl *template.Template + tpl, err = templates.Get(r, functions, "error") if err != nil { return http.StatusInternalServerError, err diff --git a/tools/frontmatter/frontmatter.go b/tools/frontmatter/frontmatter.go index 1e54c100..dd618457 100644 --- a/tools/frontmatter/frontmatter.go +++ b/tools/frontmatter/frontmatter.go @@ -11,7 +11,11 @@ import ( "github.com/spf13/hugo/parser" ) -const mainName = "#MAIN#" +const ( + mainName = "#MAIN#" + objectType = "object" + arrayType = "array" +) var mainTitle = "" @@ -25,7 +29,7 @@ func Pretty(content []byte) (interface{}, string, error) { } object := new(frontmatter) - object.Type = "object" + object.Type = objectType object.Name = mainName return rawToPretty(front, object), mainTitle, nil @@ -95,12 +99,12 @@ func (f sortByTitle) Less(i, j int) bool { func handleObjects(content interface{}, parent *frontmatter, name string) *frontmatter { c := new(frontmatter) c.Parent = parent - c.Type = "object" + c.Type = objectType c.Title = name if parent.Name == mainName { c.Name = c.Title - } else if parent.Type == "array" { + } else if parent.Type == arrayType { c.Name = parent.Name + "[]" } else { c.Name = parent.Name + "[" + c.Title + "]" @@ -113,7 +117,7 @@ func handleObjects(content interface{}, parent *frontmatter, name string) *front func handleArrays(content interface{}, parent *frontmatter, name string) *frontmatter { c := new(frontmatter) c.Parent = parent - c.Type = "array" + c.Type = arrayType c.Title = name if parent.Name == mainName { @@ -151,10 +155,10 @@ func handleFlatValues(content interface{}, parent *frontmatter, name string) *fr c.HTMLType = "text" } - if parent.Type == "array" { + if parent.Type == arrayType { c.Name = parent.Name + "[]" c.Title = content.(string) - } else if parent.Type == "object" { + } else if parent.Type == objectType { c.Title = name c.Name = parent.Name + "[" + name + "]" diff --git a/tools/installer/installer.go b/tools/installer/installer.go index 4355f0c5..a5d767c7 100644 --- a/tools/installer/installer.go +++ b/tools/installer/installer.go @@ -52,7 +52,7 @@ func GetPath() string { var err error // Check if Hugo is already on $PATH - if hugo, err := exec.LookPath("hugo"); err == nil { + if hugo, err = exec.LookPath("hugo"); err == nil { return hugo }