Skip to content

Commit 574f9a6

Browse files
Don't panic when defer a cache that has failed to init (#73)
1 parent c101f1a commit 574f9a6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

feature_flag.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,14 @@ func New(config Config) (*GoFeatureFlag, error) {
8282

8383
// Close wait until thread are done
8484
func (g *GoFeatureFlag) Close() {
85-
// clear the cache
86-
g.cache.Close()
85+
if g != nil {
86+
if g.cache != nil {
87+
// clear the cache
88+
g.cache.Close()
89+
}
8790

88-
// stop the background updater
89-
g.bgUpdater.close()
91+
g.bgUpdater.close()
92+
}
9093
}
9194

9295
// startFlagUpdaterDaemon is the daemon that refresh the cache every X seconds.

0 commit comments

Comments
 (0)