Use an init() method to create the HugoInfo instance - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit c23dfd99dd3a719b03d735161082022abaafa208
DIR parent 7257ab6855df7c5c0a1614daee39bdc684ae8056
HTML Author: bep <bjorn.erik.pedersen@gmail.com>
Date: Mon, 19 Jan 2015 03:06:07 +0100
Use an init() method to create the HugoInfo instance
See #570
Diffstat:
M hugolib/hugo.go | 15 ++++++---------
M hugolib/node.go | 2 +-
2 files changed, 7 insertions(+), 10 deletions(-)
---
DIR diff --git a/hugolib/hugo.go b/hugolib/hugo.go
@@ -17,14 +17,11 @@ type HugoInfo struct {
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
}
DIR diff --git a/hugolib/node.go b/hugolib/node.go
@@ -78,7 +78,7 @@ func (n *Node) IsMenuCurrent(menuId string, inme *MenuEntry) bool {
}
func (n *Node) Hugo() *HugoInfo {
- return getHugoInfo()
+ return hugoInfo
}
func (n *Node) isSameAsDescendantMenu(inme *MenuEntry, parent *MenuEntry) bool {