From 71da5542a681a4927ac38702f86dead3e887a705 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Fri, 26 Apr 2024 11:18:50 -0700 Subject: [PATCH] Split out pattern symbol lookups --- internal/tools/inspect/cmd/offsetgen/main.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/tools/inspect/cmd/offsetgen/main.go b/internal/tools/inspect/cmd/offsetgen/main.go index f5ac36aba..ad5dec96b 100644 --- a/internal/tools/inspect/cmd/offsetgen/main.go +++ b/internal/tools/inspect/cmd/offsetgen/main.go @@ -70,6 +70,11 @@ func manifests() ([]inspect.Manifest, error) { return nil, fmt.Errorf("failed to get Go versions: %w", err) } + goVers22, err := GoVersions(">= 1.22.0") + if err != nil { + return nil, fmt.Errorf("failed to get Go versions >= 1.22.0: %w", err) + } + grpcVers, err := PkgVersions("google.golang.org/grpc") if err != nil { return nil, fmt.Errorf("failed to get \"google.golang.org/grpc\" versions: %w", err) @@ -122,13 +127,23 @@ func manifests() ([]inspect.Manifest, error) { structfield.NewID("std", "net/http", "Request", "Proto"), structfield.NewID("std", "net/http", "Request", "RequestURI"), structfield.NewID("std", "net/http", "Request", "Host"), - structfield.NewID("std", "net/http", "Request", "pat"), - structfield.NewID("std", "net/http", "pattern", "str"), structfield.NewID("std", "net/url", "URL", "Path"), structfield.NewID("std", "bufio", "Writer", "buf"), structfield.NewID("std", "bufio", "Writer", "n"), }, }, + { + // These symbols were added in 1.22.0. Do not waste time/space + // doing lookups for all versions of Go < 1.22. + Application: inspect.Application{ + Renderer: ren("templates/net/http/*.tmpl"), + GoVerions: goVers22, + }, + StructFields: []structfield.ID{ + structfield.NewID("std", "net/http", "Request", "pat"), + structfield.NewID("std", "net/http", "pattern", "str"), + }, + }, { Application: inspect.Application{ Renderer: ren("templates/google.golang.org/grpc/*.tmpl"),