ref: 724357a2425354f85b80280c03da96175908eb01
parent: 109e6f95fdbb809b0a2759a06a1aac9d1cacc9b3
author: bep <[email protected]>
date: Sun Jan 18 21:53:07 EST 2015
Make sure there are only one HugoInfo instance See #570
--- a/hugolib/hugo.go
+++ b/hugolib/hugo.go
@@ -7,6 +7,8 @@
BuildDate string
)
+var hugoInfo *HugoInfo
+
// HugoInfo contains information about the current Hugo environment
type HugoInfo struct {
Version string
@@ -15,11 +17,14 @@
BuildDate string
}
-func newHugoInfo() *HugoInfo {
- return &HugoInfo{
- Version: Version,
- CommitHash: CommitHash,
- BuildDate: BuildDate,
- Generator: `<meta name="generator" content="Hugo ` + Version + `" />`,
+func getHugoInfo() *HugoInfo {
+ if hugoInfo == nil {
+ 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
@@ -29,7 +29,6 @@
Params map[string]interface{}
Date time.Time
Sitemap Sitemap
- hugo *HugoInfo
UrlPath
}
@@ -79,10 +78,7 @@
}
func (n *Node) Hugo() *HugoInfo {
- if n.hugo == nil {
- n.hugo = newHugoInfo()
- }
- return n.hugo
+ return getHugoInfo()
}
func (n *Node) isSameAsDescendantMenu(inme *MenuEntry, parent *MenuEntry) bool {