Repository: go
Issue: cmd/go: record -mod=vendor in buildinfo
Labels: help wanted,NeedsInvestigation,GoCommand

<!--
Please answer these questions before submitting your issue. Thanks!
-->

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version devel go1.20-245e95dfabd Wed Jan 11 22:29:34 2023 +0000 linux/amd64
</pre>

### Does this issue reproduce with the latest release?

tip

### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/arccy/.cache/go-build"
GOENV="/home/arccy/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/arccy/.data/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/arccy/.data/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/arccy/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/arccy/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.20-245e95dfabd Wed Jan 11 22:29:34 2023 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/arccy/tmp/testrepo0078/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 -fdebug-prefix-map=/tmp/go-build1173344524=/tmp/go-build -gno-record-gcc-switches"
</pre></details>

### What did you do?

```
14:47:59 ~/tmp/testrepo0078 0:00:00
main » cat go.mod 
module go.seankhliao.com/testrepo0078

go 1.20

require rsc.io/quote/v4 v4.0.1

require (
	golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
	rsc.io/sampler v1.3.0 // indirect
)

14:48:02 ~/tmp/testrepo0078 0:00:00
main » cat main.go         
package main

import (
	"fmt"

	"rsc.io/quote/v4"
)

func main() {
	fmt.Println(quote.Hello())
}

14:48:14 ~/tmp/testrepo0078 0:00:00
main » go mod vendor       

14:48:19 ~/tmp/testrepo0078 0:00:00
main » go build -mod=vendor

14:48:24 ~/tmp/testrepo0078 0:00:00
main » go version -m testrepo0078            
testrepo0078: devel go1.20-245e95dfabd Wed Jan 11 22:29:34 2023 +0000
	path	go.seankhliao.com/testrepo0078
	mod	go.seankhliao.com/testrepo0078	(devel)	
	dep	golang.org/x/text	v0.0.0-20170915032832-14c0d48ead0c	h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8=
	dep	rsc.io/quote/v4	v4.0.1	h1:i/LHLEinr65wwTCqlP4OnMoMWeCgnFIZFvifdXNK+5M=
	dep	rsc.io/sampler	v1.3.0	h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
	build	-buildmode=exe
	build	-compiler=gc
	build	CGO_ENABLED=1
	build	CGO_CFLAGS=
	build	CGO_CPPFLAGS=
	build	CGO_CXXFLAGS=
	build	CGO_LDFLAGS=
	build	GOARCH=amd64
	build	GOOS=linux
	build	GOAMD64=v1
	build	vcs=git
	build	vcs.revision=bfd01d01b57dc4c4d2a0127ee6a38b5a3933eeb8
	build	vcs.time=2023-01-13T14:45:45Z
	build	vcs.modified=true
```


### What did you expect to see?

usage of vendor (and/or `-mod` flag) recorded in build info

### What did you see instead?

no difference from buildinfo built without vendor:

```
14:50:43 ~/tmp/testrepo0078 0:00:00
main » rm -rf vendor

14:51:07 ~/tmp/testrepo0078 0:00:00
main » go build -mod=readonly     

14:51:10 ~/tmp/testrepo0078 0:00:00
main » go version -m testrepo0078 
testrepo0078: devel go1.20-245e95dfabd Wed Jan 11 22:29:34 2023 +0000
	path	go.seankhliao.com/testrepo0078
	mod	go.seankhliao.com/testrepo0078	(devel)	
	dep	golang.org/x/text	v0.0.0-20170915032832-14c0d48ead0c	h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8=
	dep	rsc.io/quote/v4	v4.0.1	h1:i/LHLEinr65wwTCqlP4OnMoMWeCgnFIZFvifdXNK+5M=
	dep	rsc.io/sampler	v1.3.0	h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
	build	-buildmode=exe
	build	-compiler=gc
	build	CGO_ENABLED=1
	build	CGO_CFLAGS=
	build	CGO_CPPFLAGS=
	build	CGO_CXXFLAGS=
	build	CGO_LDFLAGS=
	build	GOARCH=amd64
	build	GOOS=linux
	build	GOAMD64=v1
	build	vcs=git
	build	vcs.revision=bfd01d01b57dc4c4d2a0127ee6a38b5a3933eeb8
	build	vcs.time=2023-01-13T14:45:45Z
	build	vcs.modified=true
```