Proposal Details
Description
Added isEnclosed and extractEnclosed helpers to handle string parsing. These functions allow detecting and extracting content between specific delimiters (like quotes or brackets) by calculating the correct offset, avoiding issues when start and end symbols are identical.
Why
Needed for cleaner string manipulation and to handle quoted arguments or environment variables without pulling in heavy external dependencies.
// isEnclosed checks if a string is enclosed by the given start and end symbols
func isEnclosed(text, start, end string) bool {
return strings.HasPrefix(text, start) && strings.HasSuffix(text, end)
}
// extractEnclosed returns the content between the start and end delimiters
func extractEnclosed(text, start, end string) string {
sIdx := strings.Index(text, start)
if sIdx == -1 { return "" }
cutStart := sIdx + len(start)
eIdx := strings.Index(text[cutStart:], end)
if eIdx == -1 { return "" }
return text[cutStart : cutStart+eIdx]
}
Proposal Details
Description
Added isEnclosed and extractEnclosed helpers to handle string parsing. These functions allow detecting and extracting content between specific delimiters (like quotes or brackets) by calculating the correct offset, avoiding issues when start and end symbols are identical.
Why
Needed for cleaner string manipulation and to handle quoted arguments or environment variables without pulling in heavy external dependencies.