I expected ParseLax to record the toolchain as it is not an "unknown statement"
What did you see instead?
Using Parse, the toolchain info is recorded but, using ParseLax, it's ignored.
I'm not sure if this is a problem with the code or documentation. The documentation states ParseLax is intended for non-main modules which do not need the toolchain directive, but it also implies that it should be identical to Parse except that an unknown directive in the go.mod does not cause an error.
I see two valid fixes
change the documentation for ParseLax to specify that it will ignore known directives that are only applicable to main modules
change the implementation so ParseLax records known directives that are irrelevant to non-main modules
2 would be preferable in my case as I
need info that's not included in go mod edit -json
want everything that's known when a release is cut
do not want to have to do a release whenever a new directive is added, as the new directive may not be important to my tool and, even if it is, I don't want to have to rush to support it
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://go.dev/play/p/n_SQJPM3hh1
What did you expect to see?
I expected
ParseLax
to record thetoolchain
as it is not an "unknown statement"What did you see instead?
Using
Parse
, thetoolchain
info is recorded but, usingParseLax
, it's ignored.I'm not sure if this is a problem with the code or documentation. The documentation states
ParseLax
is intended for non-main modules which do not need thetoolchain
directive, but it also implies that it should be identical to Parse except that an unknown directive in the go.mod does not cause an error.I see two valid fixes
ParseLax
to specify that it will ignore known directives that are only applicable to main modulesParseLax
records known directives that are irrelevant to non-main modules2 would be preferable in my case as I
go mod edit -json