MCPcopy Create free account
hub / github.com/codehamr/codehamr / isEnvName

Function isEnvName

internal/config/config.go:246–259  ·  view source on GitHub ↗

isEnvName reports whether s is a POSIX environment variable name ([A-Za-z_][A-Za-z0-9_]*), the only content ${...} expands.

(s string)

Source from the content-addressed store, hash-verified

244
245// isEnvName reports whether s is a POSIX environment variable name
246// ([A-Za-z_][A-Za-z0-9_]*), the only content ${...} expands.
247func isEnvName(s string) bool {
248 if s == "" {
249 return false
250 }
251 for i, r := range s {
252 switch {
253 case r == '_' || r >= 'a' && r <= 'z' || r >= 'A' && r <= 'Z':
254 case r >= '0' && r <= '9' && i > 0:
255 default:
256 return false
257 }
258 }
259 return true
260}
261
262// Save rewrites config.yaml.

Callers 1

ResolvedKeyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected