Repository: go
Issue: all: audit which generate directives depend on version of vendored packages
Labels: NeedsFix

The Go standard library uses vendored copies of some external packages. These packages are updated as needed to fix bugs or bring in new features, and in bulk as part of release cycle maintenance (issue #36905).

There are some generate directives that depend on data in vendored packages, and so they need to be re-run whenever vendored versions change.

We are currently aware of:

```
net/http:
    //go:generate bundle -o=h2_bundle.go -prefix=http2 -tags=!nethttpomithttp2 
    //go:generate bundle -o socks_bundle.go -prefix socks golang.org/x/net/internal/socks

syscall:
    //go:generate go run ./mksyscall_windows.go -systemdll -output zsyscall_windows.go syscall_windows.go security_windows.go
internal/syscall/windows:
    //go:generate go run ../../../syscall/mksyscall_windows.go -output zsyscall_windows.go syscall_windows.go security_windows.go psapi_windows.go symlink_windows.go
internal/syscall/windows/registry:
    //go:generate go run ../../../../syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go
```

So at the very least:

- `go generate -run=bundle net/http` needs to be re-run whenever golang.org/x/net version changes
- `go generate syscall internal/syscall/...` whenever golang.org/x/sys version changes

This is the tracking issue to audit the rest and find out if there any more. We can incorporate findings here into tests that are being added for #36852 and #41409. Thanks to @bcmills for raising this question in [CL 275446 (comment)](https://go-review.googlesource.com/c/go/+/275446/1..2//COMMIT_MSG#b49).

As of commit 20d0991b86f533a734cad96b2002678d9750e6d8, there are a total of 60 generate directives in GOROOT/src, not counting testdata and vendored packages:

```
Searching 4051 files for "^//go:generate " (regex)

cmd/compile/internal/gc/alg.go:
   18: //go:generate stringer -type AlgKind -trimprefix A

cmd/compile/internal/gc/go.go:
   61: //go:generate stringer -type=Class

cmd/compile/internal/gc/main.go:
    5: //go:generate go run mkbuiltin.go

cmd/compile/internal/gc/syntax.go:
  741: //go:generate stringer -type=Op -trimprefix=O

cmd/compile/internal/syntax/tokens.go:
    9: //go:generate stringer -type token -linecomment
  108: //go:generate stringer -type Operator -linecomment

cmd/compile/internal/types/type.go:
   18: //go:generate stringer -type EType -trimprefix T

cmd/go/internal/test/testflag.go:
   22: //go:generate go run ./genflags.go

cmd/go/main.go:
    5: //go:generate ./mkalldocs.sh

cmd/internal/goobj/builtin.go:
   36: //go:generate go run mkbuiltin.go

cmd/internal/obj/arm/a.out.go:
   35: //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p arm

cmd/internal/obj/arm64/a.out.go:
  511: //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p arm64

cmd/internal/obj/link.go:
  219: //go:generate stringer -type AddrType
  542: //go:generate stringer -type ABI

cmd/internal/obj/mips/a.out.go:
   36: //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p mips

cmd/internal/obj/ppc64/a.out.go:
   34: //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p ppc64

cmd/internal/obj/riscv/cpu.go:
   33: //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p riscv

cmd/internal/obj/s390x/a.out.go:
   34: //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p s390x

cmd/internal/obj/wasm/a.out.go:
    9: //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p wasm

cmd/internal/obj/x86/aenum.go:
    7: //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p x86

cmd/internal/objabi/reloctype.go:
   35: //go:generate stringer -type=RelocType

cmd/internal/objabi/symkind.go:
   40: //go:generate stringer -type=SymKind

cmd/link/internal/sym/symkind.go:
   39: //go:generate stringer -type=SymKind

crypto/md5/md5.go:
    5: //go:generate go run gen.go -output md5block.go

crypto/tls/common.go:
  367: //go:generate stringer -type=SignatureScheme,CurveID,ClientAuthType -output=common_string.go

crypto/x509/root.go:
    7: //go:generate go run root_ios_gen.go -version 55161.140.3

debug/dwarf/const.go:
    9: //go:generate stringer -type Attr -trimprefix=Attr
  204: //go:generate stringer -type Tag -trimprefix=Tag

debug/dwarf/entry.go:
  372: //go:generate stringer -type=Class

debug/macho/reloctype.go:
    7: //go:generate stringer -type=RelocTypeGeneric,RelocTypeX86_64,RelocTypeARM,RelocTypeARM64 -output reloctype_string.go

encoding/gob/decode.go:
    5: //go:generate go run decgen.go -output dec_helpers.go

encoding/gob/encode.go:
    5: //go:generate go run encgen.go -output enc_helpers.go

html/template/context.go:
   84: //go:generate stringer -type state
  168: //go:generate stringer -type delim
  186: //go:generate stringer -type urlPart
  207: //go:generate stringer -type jsCtx
  225: //go:generate stringer -type element
  241: //go:generate stringer -type attr

image/color/palette/generate.go:
    5: //go:generate go run gen.go -output palette.go

image/internal/imageutil/imageutil.go:
    5: //go:generate go run gen.go

index/suffixarray/sais.go:
  121: //go:generate go run gen.go

internal/syscall/windows/mksyscall.go:
    9: //go:generate go run ../../../syscall/mksyscall_windows.go -output zsyscall_windows.go syscall_windows.go security_windows.go psapi_windows.go symlink_windows.go

internal/syscall/windows/registry/mksyscall.go:
    9: //go:generate go run ../../../../syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go

math/big/float.go:
  144: //go:generate stringer -type=RoundingMode
  157: //go:generate stringer -type=Accuracy

math/bits/bits.go:
    5: //go:generate go run make_tables.go

net/http/http.go:
    5: //go:generate bundle -o=h2_bundle.go -prefix=http2 -tags=!nethttpomithttp2 golang.org/x/net/http2

net/http/socks_bundle.go:
    2: //go:generate bundle -o socks_bundle.go -prefix socks golang.org/x/net/internal/socks

regexp/syntax/regexp.go:
   29: //go:generate stringer -type Op -trimprefix Op

runtime/internal/sys/sys.go:
   15: //go:generate go run gengoos.go

runtime/preempt.go:
  291: //go:generate go run mkpreempt.go

runtime/runtime.go:
   12: //go:generate go run wincallback.go
   13: //go:generate go run mkduff.go
   14: //go:generate go run mkfastlog2table.go

runtime/sizeclasses.go:
    2: //go:generate go run mksizeclasses.go

sort/sort.go:
    5: //go:generate go run genzfunc.go

strconv/quote.go:
    5: //go:generate go run makeisprint.go -output isprint.go

syscall/syscall.go:
   29: //go:generate go run ./mksyscall_windows.go -systemdll -output zsyscall_windows.go syscall_windows.go security_windows.go

time/tzdata/tzdata.go:
    5: //go:generate go run generate_zipdata.go

time/zoneinfo.go:
   13: //go:generate env ZONEINFO=$GOROOT/lib/time/zoneinfo.zip go run genzabbrs.go -output zoneinfo_abbrs_windows.go

60 matches across 49 files
```

CC @golang/release.