I would expect this to print the same thing six times but the /**/ seems to behave differently if it's on the first line.
false
true
true
true
true
true
package main
import (
"fmt"
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclsyntax"
)
func containsInitialPos(content string) bool {
file, _ := hclsyntax.ParseConfig([]byte(content), "", hcl.InitialPos)
body, _ := file.Body.(*hclsyntax.Body)
return body.Range().ContainsPos(hcl.InitialPos)
}
func main() {
fmt.Println(containsInitialPos("/**/\ntarget{}"))
fmt.Println(containsInitialPos("#\ntarget{}"))
fmt.Println(containsInitialPos("//\ntarget{}"))
fmt.Println(containsInitialPos("\n/**/\ntarget{}"))
fmt.Println(containsInitialPos("\n#\ntarget{}"))
fmt.Println(containsInitialPos("\n//\ntarget{}"))
}