Skip to content

Commit da4db68

Browse files
author
Mrunal Patel
authored
Merge pull request #80 from Mashimiao/add-env-begin-with-digit-check
validate/env: add env name begins with digit check
2 parents 683a2aa + 5a03d31 commit da4db68

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
@@ -271,10 +271,13 @@ func envValid(env string) bool {
271271
if len(items) < 2 {
272272
return false
273273
}
274-
for _, ch := range strings.TrimSpace(items[0]) {
274+
for i, ch := range strings.TrimSpace(items[0]) {
275275
if !unicode.IsDigit(ch) && !unicode.IsLetter(ch) && ch != '_' {
276276
return false
277277
}
278+
if i == 0 && unicode.IsDigit(ch) {
279+
logrus.Warnf("Env %v: variable name beginning with digit is not recommended.", env)
280+
}
278281
}
279282
return true
280283
}

0 commit comments

Comments
 (0)