shithub: hugo

Download patch

ref: c23dfd99dd3a719b03d735161082022abaafa208
parent: 7257ab6855df7c5c0a1614daee39bdc684ae8056
author: bep <[email protected]>
date: Sun Jan 18 22:06:07 EST 2015

Use an init() method to create the HugoInfo instance

See #570

--- a/hugolib/hugo.go
+++ b/hugolib/hugo.go
@@ -17,14 +17,11 @@
 	BuildDate  string
 }
 
-func getHugoInfo() *HugoInfo {
-	if hugoInfo == nil {
-		hugoInfo = &HugoInfo{
-			Version:    Version,
-			CommitHash: CommitHash,
-			BuildDate:  BuildDate,
-			Generator:  `<meta name="generator" content="Hugo ` + Version + `" />`,
-		}
+func init() {
+	hugoInfo = &HugoInfo{
+		Version:    Version,
+		CommitHash: CommitHash,
+		BuildDate:  BuildDate,
+		Generator:  `<meta name="generator" content="Hugo ` + Version + `" />`,
 	}
-	return hugoInfo
 }
--- a/hugolib/node.go
+++ b/hugolib/node.go
@@ -78,7 +78,7 @@
 }
 
 func (n *Node) Hugo() *HugoInfo {
-	return getHugoInfo()
+	return hugoInfo
 }
 
 func (n *Node) isSameAsDescendantMenu(inme *MenuEntry, parent *MenuEntry) bool {