compose-go
compose-go copied to clipboard
Recursion in getStatementStart could be a loop
Hey, I just noticed that the recursion here could be a simple loop, I think? (I'm new to Go, not new to programming.)
https://github.com/compose-spec/compose-go/blob/35c575c758afd2a8363bd47290c3ddec0d23ebaf/dotenv/parser.go#L77-L94
Could be something like this:
func (p *parser) getStatementStart(src string) string {
for {
pos := p.indexOfNonSpaceChar(src)
if pos == -1 {
return ""
}
src = src[pos:]
if src[0] != charComment {
return src
}
// skip comment section
pos = strings.IndexFunc(src, isCharFunc('\n'))
if pos == -1 {
return ""
}
src = src[pos:]
}
}
This is not a bug, just something I noticed while reading the source in order to understand exactly what syntax this tool is accepting. :smile: Sorry for the noise.