Skip to content

Commit 29e07b2

Browse files
committed
add if check before assigning to ENV
1 parent 8b7c3a5 commit 29e07b2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

utils/env/env.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,19 @@ func Load() {
101101
ENV.API_TOKENS = apiTokens
102102
}
103103

104-
ENV.BLOCKED_ENDPOINTS = utils.GetJson[[]string](blockedEndpointJSON)
105-
ENV.MESSAGE_ALIASES = utils.GetJson[[]middlewares.MessageAlias](messageAliasesJSON)
104+
if blockedEndpointJSON != "" {
105+
ENV.BLOCKED_ENDPOINTS = utils.GetJson[[]string](blockedEndpointJSON)
106+
}
107+
108+
if messageAliasesJSON != "" {
109+
ENV.MESSAGE_ALIASES = utils.GetJson[[]middlewares.MessageAlias](messageAliasesJSON)
110+
}
106111

107-
ENV.VARIABLES = utils.GetJson[map[string]any](variablesJSON)
108-
ENV.VARIABLES["RECIPIENTS"] = utils.GetJson[[]string](recipientsJSON)
112+
if variablesJSON != "" {
113+
ENV.VARIABLES = utils.GetJson[map[string]any](variablesJSON)
114+
}
115+
116+
if recipientsJSON != "" {
117+
ENV.VARIABLES["RECIPIENTS"] = utils.GetJson[[]string](recipientsJSON)
118+
}
109119
}

0 commit comments

Comments
 (0)