summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-09 02:17:11 -0400
committerBen Morrison <ben@gbmor.dev>2019-06-09 02:17:11 -0400
commit5e92b610a5f8832e6a389b1acb01fd0cc866780e (patch)
tree0ac688f9e962d7e82c18854f9785c94d8d1c7033
parent21e981bb66c0e7a15fd001844601888098a9333a (diff)
downloadgetwtxt-5e92b610a5f8832e6a389b1acb01fd0cc866780e.tar.gz
test config init using sync.Once
-rw-r--r--svc/init_test.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/svc/init_test.go b/svc/init_test.go
index 009b4e0..9c99a3b 100644
--- a/svc/init_test.go
+++ b/svc/init_test.go
@@ -6,6 +6,7 @@ import (
 	"log"
 	"os"
 	"strings"
+	"sync"
 	"time"
 
 	"github.com/fsnotify/fsnotify"
@@ -15,13 +16,14 @@ import (
 var testport = fmt.Sprintf(":%v", confObj.Port)
 var hasInit = false
 
+var initTestOnce sync.Once
+
 func initTestConf() {
-	if !hasInit {
+	initTestOnce.Do(func() {
 		testConfig()
 		tmpls = testTemplates()
 		logToNull()
-		hasInit = true
-	}
+	})
 }
 
 func logToNull() {
d='n8' href='#n8'>8 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85