From 062a97fa4d41c3f23e4beb92ab38428b2626b483 Mon Sep 17 00:00:00 2001 From: Chris Broadfoot Date: Mon, 24 Feb 2020 19:39:01 -0800 Subject: [PATCH] google-api-go-generator: correctly report Go version of runtime The Go version of the generator was reported in the x-goog-api-client header, rather than the version of the Go runtime that made the request. Change-Id: Ib0f00e84293460a2c938f7e12b36a5741aef5eea Reviewed-on: https://code-review.googlesource.com/c/google-api-go-client/+/52414 Reviewed-by: Chris Broadfoot --- google-api-go-generator/gen.go | 3 +- google-api-go-generator/gen_test.go | 10 ++- google-api-go-generator/testdata/any.want | 30 ++++----- .../testdata/blogger-3.want | 62 +++++++++---------- .../testdata/getwithoutbody.want | 2 +- .../testdata/http-body.want | 4 +- .../testdata/json-body.want | 60 +++++++++--------- .../testdata/mapofarrayofobjects.want | 2 +- .../testdata/mapofstrings-1.want | 2 +- .../testdata/param-rename.want | 4 +- .../testdata/repeated.want | 2 +- .../testdata/required-query.want | 2 +- .../testdata/resource-named-service.want | 38 ++++++------ internal/gensupport/version.go | 53 ++++++++++++++++ .../{version => gensupport}/version_test.go | 2 +- internal/version/version.go | 48 -------------- 16 files changed, 163 insertions(+), 161 deletions(-) create mode 100644 internal/gensupport/version.go rename internal/{version => gensupport}/version_test.go (96%) diff --git a/google-api-go-generator/gen.go b/google-api-go-generator/gen.go index f4484f37f0f..7990f6fd479 100644 --- a/google-api-go-generator/gen.go +++ b/google-api-go-generator/gen.go @@ -32,7 +32,6 @@ import ( const ( googleDiscoveryURL = "https://www.googleapis.com/discovery/v1/apis" - generatorVersion = "2018018" ) var ( @@ -1937,7 +1936,7 @@ func (meth *Method) generateCode() { pn("\nfunc (c *%s) doRequest(alt string) (*http.Response, error) {", callName) pn(`reqHeaders := make(http.Header)`) - pn(`reqHeaders.Set("x-goog-api-client", "gl-go/%s gdcl/%s")`, version.Go(), version.Repo) + pn(`reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/%s")`, version.Repo) pn("for k, v := range c.header_ {") pn(" reqHeaders[k] = v") pn("}") diff --git a/google-api-go-generator/gen_test.go b/google-api-go-generator/gen_test.go index 183b7cb643f..092483d0194 100644 --- a/google-api-go-generator/gen_test.go +++ b/google-api-go-generator/gen_test.go @@ -59,8 +59,7 @@ func TestAPIs(t *testing.T) { } goldenFile := filepath.Join("testdata", name+".want") if *updateGolden { - clean := strings.Replace(string(clean), fmt.Sprintf("gl-go/%s", version.Go()), "gl-go/1.12.5", -1) - clean = strings.Replace(clean, fmt.Sprintf("gdcl/%s", version.Repo), "gdcl/00000000", -1) + clean := strings.Replace(string(clean), fmt.Sprintf("gdcl/%s", version.Repo), "gdcl/00000000", -1) if err := ioutil.WriteFile(goldenFile, []byte(clean), 0644); err != nil { t.Fatal(err) } @@ -69,10 +68,8 @@ func TestAPIs(t *testing.T) { if err != nil { t.Fatal(err) } - wantStr := strings.Replace(string(want), "gl-go/1.12.5", fmt.Sprintf("gl-go/%s", version.Go()), -1) - wantStr = strings.Replace(wantStr, "gdcl/00000000", fmt.Sprintf("gdcl/%s", version.Repo), -1) - want = []byte(wantStr) - if !bytes.Equal(want, clean) { + wantStr := strings.Replace(string(want), "gdcl/00000000", fmt.Sprintf("gdcl/%s", version.Repo), -1) + if !bytes.Equal([]byte(wantStr), clean) { tf, _ := ioutil.TempFile("", "api-"+name+"-got-json.") if _, err := tf.Write(clean); err != nil { t.Fatal(err) @@ -80,6 +77,7 @@ func TestAPIs(t *testing.T) { if err := tf.Close(); err != nil { t.Fatal(err) } + // NOTE: update golden files with `go test -update_golden` t.Errorf("Output for API %s differs: diff -u %s %s", name, goldenFile, tf.Name()) } }) diff --git a/google-api-go-generator/testdata/any.want b/google-api-go-generator/testdata/any.want index 90a5a3b180e..34a1ae7ea34 100644 --- a/google-api-go-generator/testdata/any.want +++ b/google-api-go-generator/testdata/any.want @@ -856,7 +856,7 @@ func (c *ProjectsLogServicesListCall) Header() http.Header { func (c *ProjectsLogServicesListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -1088,7 +1088,7 @@ func (c *ProjectsLogServicesIndexesListCall) Header() http.Header { func (c *ProjectsLogServicesIndexesListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -1279,7 +1279,7 @@ func (c *ProjectsLogServicesSinksCreateCall) Header() http.Header { func (c *ProjectsLogServicesSinksCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -1427,7 +1427,7 @@ func (c *ProjectsLogServicesSinksDeleteCall) Header() http.Header { func (c *ProjectsLogServicesSinksDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -1586,7 +1586,7 @@ func (c *ProjectsLogServicesSinksGetCall) Header() http.Header { func (c *ProjectsLogServicesSinksGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -1746,7 +1746,7 @@ func (c *ProjectsLogServicesSinksListCall) Header() http.Header { func (c *ProjectsLogServicesSinksListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -1891,7 +1891,7 @@ func (c *ProjectsLogServicesSinksUpdateCall) Header() http.Header { func (c *ProjectsLogServicesSinksUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2046,7 +2046,7 @@ func (c *ProjectsLogsDeleteCall) Header() http.Header { func (c *ProjectsLogsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2234,7 +2234,7 @@ func (c *ProjectsLogsListCall) Header() http.Header { func (c *ProjectsLogsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2418,7 +2418,7 @@ func (c *ProjectsLogsEntriesWriteCall) Header() http.Header { func (c *ProjectsLogsEntriesWriteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2566,7 +2566,7 @@ func (c *ProjectsLogsSinksCreateCall) Header() http.Header { func (c *ProjectsLogsSinksCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2714,7 +2714,7 @@ func (c *ProjectsLogsSinksDeleteCall) Header() http.Header { func (c *ProjectsLogsSinksDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2873,7 +2873,7 @@ func (c *ProjectsLogsSinksGetCall) Header() http.Header { func (c *ProjectsLogsSinksGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3033,7 +3033,7 @@ func (c *ProjectsLogsSinksListCall) Header() http.Header { func (c *ProjectsLogsSinksListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3178,7 +3178,7 @@ func (c *ProjectsLogsSinksUpdateCall) Header() http.Header { func (c *ProjectsLogsSinksUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/google-api-go-generator/testdata/blogger-3.want b/google-api-go-generator/testdata/blogger-3.want index c081581c72e..7492d2cad5f 100644 --- a/google-api-go-generator/testdata/blogger-3.want +++ b/google-api-go-generator/testdata/blogger-3.want @@ -1644,7 +1644,7 @@ func (c *BlogUserInfosGetCall) Header() http.Header { func (c *BlogUserInfosGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -1808,7 +1808,7 @@ func (c *BlogsGetCall) Header() http.Header { func (c *BlogsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -1956,7 +1956,7 @@ func (c *BlogsGetByUrlCall) Header() http.Header { func (c *BlogsGetByUrlCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2115,7 +2115,7 @@ func (c *BlogsListByUserCall) Header() http.Header { func (c *BlogsListByUserCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2270,7 +2270,7 @@ func (c *CommentsApproveCall) Header() http.Header { func (c *CommentsApproveCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2418,7 +2418,7 @@ func (c *CommentsDeleteCall) Header() http.Header { func (c *CommentsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2549,7 +2549,7 @@ func (c *CommentsGetCall) Header() http.Header { func (c *CommentsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2768,7 +2768,7 @@ func (c *CommentsListCall) Header() http.Header { func (c *CommentsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3035,7 +3035,7 @@ func (c *CommentsListByBlogCall) Header() http.Header { func (c *CommentsListByBlogCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3220,7 +3220,7 @@ func (c *CommentsMarkAsSpamCall) Header() http.Header { func (c *CommentsMarkAsSpamCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3368,7 +3368,7 @@ func (c *CommentsRemoveContentCall) Header() http.Header { func (c *CommentsRemoveContentCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3534,7 +3534,7 @@ func (c *PageViewsGetCall) Header() http.Header { func (c *PageViewsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3682,7 +3682,7 @@ func (c *PagesDeleteCall) Header() http.Header { func (c *PagesDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3814,7 +3814,7 @@ func (c *PagesGetCall) Header() http.Header { func (c *PagesGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3970,7 +3970,7 @@ func (c *PagesInsertCall) Header() http.Header { func (c *PagesInsertCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4147,7 +4147,7 @@ func (c *PagesListCall) Header() http.Header { func (c *PagesListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4317,7 +4317,7 @@ func (c *PagesPatchCall) Header() http.Header { func (c *PagesPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4465,7 +4465,7 @@ func (c *PagesUpdateCall) Header() http.Header { func (c *PagesUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4631,7 +4631,7 @@ func (c *PostUserInfosGetCall) Header() http.Header { func (c *PostUserInfosGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4873,7 +4873,7 @@ func (c *PostUserInfosListCall) Header() http.Header { func (c *PostUserInfosListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5112,7 +5112,7 @@ func (c *PostsDeleteCall) Header() http.Header { func (c *PostsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5251,7 +5251,7 @@ func (c *PostsGetCall) Header() http.Header { func (c *PostsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5441,7 +5441,7 @@ func (c *PostsGetByPathCall) Header() http.Header { func (c *PostsGetByPathCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5609,7 +5609,7 @@ func (c *PostsInsertCall) Header() http.Header { func (c *PostsInsertCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5844,7 +5844,7 @@ func (c *PostsListCall) Header() http.Header { func (c *PostsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6083,7 +6083,7 @@ func (c *PostsPatchCall) Header() http.Header { func (c *PostsPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6236,7 +6236,7 @@ func (c *PostsPublishCall) Header() http.Header { func (c *PostsPublishCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6380,7 +6380,7 @@ func (c *PostsRevertCall) Header() http.Header { func (c *PostsRevertCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6547,7 +6547,7 @@ func (c *PostsSearchCall) Header() http.Header { func (c *PostsSearchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6710,7 +6710,7 @@ func (c *PostsUpdateCall) Header() http.Header { func (c *PostsUpdateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6865,7 +6865,7 @@ func (c *UsersGetCall) Header() http.Header { func (c *UsersGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/google-api-go-generator/testdata/getwithoutbody.want b/google-api-go-generator/testdata/getwithoutbody.want index c8c1947f4c8..e8048f4fb57 100644 --- a/google-api-go-generator/testdata/getwithoutbody.want +++ b/google-api-go-generator/testdata/getwithoutbody.want @@ -276,7 +276,7 @@ func (c *MetricDescriptorsListCall) Header() http.Header { func (c *MetricDescriptorsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/google-api-go-generator/testdata/http-body.want b/google-api-go-generator/testdata/http-body.want index 432f0209c18..e32ebcfdc18 100644 --- a/google-api-go-generator/testdata/http-body.want +++ b/google-api-go-generator/testdata/http-body.want @@ -325,7 +325,7 @@ func (c *ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall) Header() htt func (c *ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -468,7 +468,7 @@ func (c *ProjectsLocationsDatasetsFhirStoresFhirReadCall) Header() http.Header { func (c *ProjectsLocationsDatasetsFhirStoresFhirReadCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/google-api-go-generator/testdata/json-body.want b/google-api-go-generator/testdata/json-body.want index fac2028c2fa..270814d4682 100644 --- a/google-api-go-generator/testdata/json-body.want +++ b/google-api-go-generator/testdata/json-body.want @@ -2906,7 +2906,7 @@ func (c *ProjectsGetConfigCall) Header() http.Header { func (c *ProjectsGetConfigCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3048,7 +3048,7 @@ func (c *ProjectsPredictCall) Header() http.Header { func (c *ProjectsPredictCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3193,7 +3193,7 @@ func (c *ProjectsJobsCancelCall) Header() http.Header { func (c *ProjectsJobsCancelCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3333,7 +3333,7 @@ func (c *ProjectsJobsCreateCall) Header() http.Header { func (c *ProjectsJobsCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3482,7 +3482,7 @@ func (c *ProjectsJobsGetCall) Header() http.Header { func (c *ProjectsJobsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3629,7 +3629,7 @@ func (c *ProjectsJobsGetIamPolicyCall) Header() http.Header { func (c *ProjectsJobsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3820,7 +3820,7 @@ func (c *ProjectsJobsListCall) Header() http.Header { func (c *ProjectsJobsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4024,7 +4024,7 @@ func (c *ProjectsJobsPatchCall) Header() http.Header { func (c *ProjectsJobsPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4172,7 +4172,7 @@ func (c *ProjectsJobsSetIamPolicyCall) Header() http.Header { func (c *ProjectsJobsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4322,7 +4322,7 @@ func (c *ProjectsJobsTestIamPermissionsCall) Header() http.Header { func (c *ProjectsJobsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4474,7 +4474,7 @@ func (c *ProjectsLocationsGetCall) Header() http.Header { func (c *ProjectsLocationsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4642,7 +4642,7 @@ func (c *ProjectsLocationsListCall) Header() http.Header { func (c *ProjectsLocationsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4818,7 +4818,7 @@ func (c *ProjectsModelsCreateCall) Header() http.Header { func (c *ProjectsModelsCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4963,7 +4963,7 @@ func (c *ProjectsModelsDeleteCall) Header() http.Header { func (c *ProjectsModelsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5108,7 +5108,7 @@ func (c *ProjectsModelsGetCall) Header() http.Header { func (c *ProjectsModelsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5255,7 +5255,7 @@ func (c *ProjectsModelsGetIamPolicyCall) Header() http.Header { func (c *ProjectsModelsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5437,7 +5437,7 @@ func (c *ProjectsModelsListCall) Header() http.Header { func (c *ProjectsModelsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5639,7 +5639,7 @@ func (c *ProjectsModelsPatchCall) Header() http.Header { func (c *ProjectsModelsPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5787,7 +5787,7 @@ func (c *ProjectsModelsSetIamPolicyCall) Header() http.Header { func (c *ProjectsModelsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5937,7 +5937,7 @@ func (c *ProjectsModelsTestIamPermissionsCall) Header() http.Header { func (c *ProjectsModelsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6092,7 +6092,7 @@ func (c *ProjectsModelsVersionsCreateCall) Header() http.Header { func (c *ProjectsModelsVersionsCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6238,7 +6238,7 @@ func (c *ProjectsModelsVersionsDeleteCall) Header() http.Header { func (c *ProjectsModelsVersionsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6387,7 +6387,7 @@ func (c *ProjectsModelsVersionsGetCall) Header() http.Header { func (c *ProjectsModelsVersionsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6571,7 +6571,7 @@ func (c *ProjectsModelsVersionsListCall) Header() http.Header { func (c *ProjectsModelsVersionsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6769,7 +6769,7 @@ func (c *ProjectsModelsVersionsPatchCall) Header() http.Header { func (c *ProjectsModelsVersionsPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -6926,7 +6926,7 @@ func (c *ProjectsModelsVersionsSetDefaultCall) Header() http.Header { func (c *ProjectsModelsVersionsSetDefaultCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7081,7 +7081,7 @@ func (c *ProjectsOperationsCancelCall) Header() http.Header { func (c *ProjectsOperationsCancelCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7217,7 +7217,7 @@ func (c *ProjectsOperationsDeleteCall) Header() http.Header { func (c *ProjectsOperationsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7362,7 +7362,7 @@ func (c *ProjectsOperationsGetCall) Header() http.Header { func (c *ProjectsOperationsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -7543,7 +7543,7 @@ func (c *ProjectsOperationsListCall) Header() http.Header { func (c *ProjectsOperationsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/google-api-go-generator/testdata/mapofarrayofobjects.want b/google-api-go-generator/testdata/mapofarrayofobjects.want index 99a4469dc66..05d91c1d971 100644 --- a/google-api-go-generator/testdata/mapofarrayofobjects.want +++ b/google-api-go-generator/testdata/mapofarrayofobjects.want @@ -223,7 +223,7 @@ func (c *AtlasGetMapCall) Header() http.Header { func (c *AtlasGetMapCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/google-api-go-generator/testdata/mapofstrings-1.want b/google-api-go-generator/testdata/mapofstrings-1.want index 96f2e86dbf3..931994c9f55 100644 --- a/google-api-go-generator/testdata/mapofstrings-1.want +++ b/google-api-go-generator/testdata/mapofstrings-1.want @@ -220,7 +220,7 @@ func (c *AtlasGetMapCall) Header() http.Header { func (c *AtlasGetMapCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/google-api-go-generator/testdata/param-rename.want b/google-api-go-generator/testdata/param-rename.want index 0d59c862fa1..69114aafb20 100644 --- a/google-api-go-generator/testdata/param-rename.want +++ b/google-api-go-generator/testdata/param-rename.want @@ -198,7 +198,7 @@ func (c *EventsMoveCall) Header() http.Header { func (c *EventsMoveCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -349,7 +349,7 @@ func (c *ReportsQueryCall) Header() http.Header { func (c *ReportsQueryCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/google-api-go-generator/testdata/repeated.want b/google-api-go-generator/testdata/repeated.want index e5c744339af..8bb2713208f 100644 --- a/google-api-go-generator/testdata/repeated.want +++ b/google-api-go-generator/testdata/repeated.want @@ -231,7 +231,7 @@ func (c *AccountsReportsGenerateCall) Header() http.Header { func (c *AccountsReportsGenerateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/google-api-go-generator/testdata/required-query.want b/google-api-go-generator/testdata/required-query.want index f5631a5d9b6..bef9b9186df 100644 --- a/google-api-go-generator/testdata/required-query.want +++ b/google-api-go-generator/testdata/required-query.want @@ -215,7 +215,7 @@ func (c *TechsCountCall) Header() http.Header { func (c *TechsCountCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/google-api-go-generator/testdata/resource-named-service.want b/google-api-go-generator/testdata/resource-named-service.want index 51308c62d0b..9eaedf8bb05 100644 --- a/google-api-go-generator/testdata/resource-named-service.want +++ b/google-api-go-generator/testdata/resource-named-service.want @@ -2234,7 +2234,7 @@ func (c *AppsGetCall) Header() http.Header { func (c *AppsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2371,7 +2371,7 @@ func (c *AppsRepairCall) Header() http.Header { func (c *AppsRepairCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2520,7 +2520,7 @@ func (c *AppsLocationsGetCall) Header() http.Header { func (c *AppsLocationsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2692,7 +2692,7 @@ func (c *AppsLocationsListCall) Header() http.Header { func (c *AppsLocationsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -2875,7 +2875,7 @@ func (c *AppsOperationsGetCall) Header() http.Header { func (c *AppsOperationsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3050,7 +3050,7 @@ func (c *AppsOperationsListCall) Header() http.Header { func (c *AppsOperationsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3220,7 +3220,7 @@ func (c *AppsServicesDeleteCall) Header() http.Header { func (c *AppsServicesDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3369,7 +3369,7 @@ func (c *AppsServicesGetCall) Header() http.Header { func (c *AppsServicesGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3533,7 +3533,7 @@ func (c *AppsServicesListCall) Header() http.Header { func (c *AppsServicesListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3727,7 +3727,7 @@ func (c *AppsServicesPatchCall) Header() http.Header { func (c *AppsServicesPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -3885,7 +3885,7 @@ func (c *AppsServicesVersionsCreateCall) Header() http.Header { func (c *AppsServicesVersionsCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4033,7 +4033,7 @@ func (c *AppsServicesVersionsDeleteCall) Header() http.Header { func (c *AppsServicesVersionsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4205,7 +4205,7 @@ func (c *AppsServicesVersionsGetCall) Header() http.Header { func (c *AppsServicesVersionsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4399,7 +4399,7 @@ func (c *AppsServicesVersionsListCall) Header() http.Header { func (c *AppsServicesVersionsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4610,7 +4610,7 @@ func (c *AppsServicesVersionsPatchCall) Header() http.Header { func (c *AppsServicesVersionsPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4781,7 +4781,7 @@ func (c *AppsServicesVersionsInstancesDebugCall) Header() http.Header { func (c *AppsServicesVersionsInstancesDebugCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -4947,7 +4947,7 @@ func (c *AppsServicesVersionsInstancesDeleteCall) Header() http.Header { func (c *AppsServicesVersionsInstancesDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5116,7 +5116,7 @@ func (c *AppsServicesVersionsInstancesGetCall) Header() http.Header { func (c *AppsServicesVersionsInstancesGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } @@ -5300,7 +5300,7 @@ func (c *AppsServicesVersionsInstancesListCall) Header() http.Header { func (c *AppsServicesVersionsInstancesListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := make(http.Header) - reqHeaders.Set("x-goog-api-client", "gl-go/1.12.5 gdcl/00000000") + reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/00000000") for k, v := range c.header_ { reqHeaders[k] = v } diff --git a/internal/gensupport/version.go b/internal/gensupport/version.go new file mode 100644 index 00000000000..23f6aa24eaf --- /dev/null +++ b/internal/gensupport/version.go @@ -0,0 +1,53 @@ +// Copyright 2020 Google LLC. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package gensupport + +import ( + "runtime" + "strings" + "unicode" +) + +// GoVersion returns the Go runtime version. The returned string +// has no whitespace. +func GoVersion() string { + return goVersion +} + +var goVersion = goVer(runtime.Version()) + +const develPrefix = "devel +" + +func goVer(s string) string { + if strings.HasPrefix(s, develPrefix) { + s = s[len(develPrefix):] + if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { + s = s[:p] + } + return s + } + + if strings.HasPrefix(s, "go1") { + s = s[2:] + var prerelease string + if p := strings.IndexFunc(s, notSemverRune); p >= 0 { + s, prerelease = s[:p], s[p:] + } + if strings.HasSuffix(s, ".") { + s += "0" + } else if strings.Count(s, ".") < 2 { + s += ".0" + } + if prerelease != "" { + s += "-" + prerelease + } + return s + } + return "" +} + +func notSemverRune(r rune) bool { + return !strings.ContainsRune("0123456789.", r) +} diff --git a/internal/version/version_test.go b/internal/gensupport/version_test.go similarity index 96% rename from internal/version/version_test.go rename to internal/gensupport/version_test.go index 25669f3ee1e..cffeab7a325 100644 --- a/internal/version/version_test.go +++ b/internal/gensupport/version_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package version +package gensupport import "testing" diff --git a/internal/version/version.go b/internal/version/version.go index 016d008926c..57b1dd50016 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -8,54 +8,6 @@ // Libraries for Go, as reported in request headers. package version -import ( - "runtime" - "strings" - "unicode" -) - // Repo is the current version of the client libraries in this // repo. It should be a date in YYYYMMDD format. const Repo = "20200226" - -// Go returns the Go runtime version. The returned string -// has no whitespace. -func Go() string { - return goVersion -} - -var goVersion = goVer(runtime.Version()) - -const develPrefix = "devel +" - -func goVer(s string) string { - if strings.HasPrefix(s, develPrefix) { - s = s[len(develPrefix):] - if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { - s = s[:p] - } - return s - } - - if strings.HasPrefix(s, "go1") { - s = s[2:] - var prerelease string - if p := strings.IndexFunc(s, notSemverRune); p >= 0 { - s, prerelease = s[:p], s[p:] - } - if strings.HasSuffix(s, ".") { - s += "0" - } else if strings.Count(s, ".") < 2 { - s += ".0" - } - if prerelease != "" { - s += "-" + prerelease - } - return s - } - return "" -} - -func notSemverRune(r rune) bool { - return !strings.ContainsRune("0123456789.", r) -}