Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mod/modfile: ParseLax and toolchain #67132

Open
jimmyfrasche opened this issue May 1, 2024 · 1 comment
Open

x/mod/modfile: ParseLax and toolchain #67132

jimmyfrasche opened this issue May 1, 2024 · 1 comment
Labels
modules NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@jimmyfrasche
Copy link
Member

What version of Go are you using (go version)?

$ go version
go version go1.22.0 linux/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/jimmy/.cache/go-build'
GOENV='/home/jimmy/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/jimmy/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/jimmy/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/jimmy/code/autoreadme/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build368045690=/tmp/go-build -gno-record-gcc-switches'
uname -sr: Linux 6.6.15-amd64
Distributor ID:	Debian
Description:	Debian GNU/Linux trixie/sid
Release:	n/a
Codename:	trixie
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Debian GLIBC 2.37-18) stable release version 2.37.
gdb --version: GNU gdb (Debian 13.2-1+b1) 13.2

What did you do?

https://go.dev/play/p/n_SQJPM3hh1

What did you expect to see?

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

  1. change the documentation for ParseLax to specify that it will ignore known directives that are only applicable to main modules
  2. 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
@jimmyfrasche
Copy link
Member Author

cc @matloob and @samthanawalla per owners

@seankhliao seankhliao changed the title golang.org/x/mod/modfile: ParseLax and toolchain x/mod/modfile: ParseLax and toolchain May 1, 2024
@gopherbot gopherbot added this to the Unreleased milestone May 1, 2024
@cherrymui cherrymui added NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. modules labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

3 participants