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

Callers 1

ResolvedKeyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected