Skip to content

Commit b9bd253

Browse files
author
Ma Shimiao
committed
validate/env: add env name begins with digit check
Signed-off-by: Ma Shimiao <[email protected]>
1 parent f5b89dd commit b9bd253

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

validate.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,13 @@ func envValid(env string) bool {
266266
if len(items) < 2 {
267267
return false
268268
}
269-
for _, ch := range strings.TrimSpace(items[0]) {
269+
for i, ch := range strings.TrimSpace(items[0]) {
270270
if !unicode.IsDigit(ch) && !unicode.IsLetter(ch) && ch != '_' {
271271
return false
272272
}
273+
if i == 0 && unicode.IsDigit(ch) {
274+
logrus.Warnf("Env %v: variable name begin with digit is not recommended.", env)
275+
}
273276
}
274277
return true
275278
}

0 commit comments

Comments
 (0)