From d6a97b0c39b9802c30bf532cde8e656054abdf19 Mon Sep 17 00:00:00 2001 From: moznion Date: Thu, 17 Feb 2022 19:34:05 -0800 Subject: [PATCH] Remove dummy variable declaration for context.Context from generated go code (#11641) Originally, this dummy declaration was needed because there was the possibility of the generated code doesn't use `context.Context` and then if it imported that package, go compiler complains that and makes an error. ref: https://github.com/OpenAPITools/openapi-generator/blob/3ed1aa8e79687bed63dfa064de27317273080471/modules/swagger-codegen/src/main/resources/go/api.mustache#L30 However, now this dummy placement is no longer needed because the generated code always uses `context.Context`. Signed-off-by: moznion --- .../openapi-generator/src/main/resources/go/api.mustache | 4 ---- .../client/petstore/go/go-petstore/api_another_fake.go | 4 ---- samples/client/petstore/go/go-petstore/api_fake.go | 4 ---- .../petstore/go/go-petstore/api_fake_classname_tags123.go | 4 ---- samples/client/petstore/go/go-petstore/api_pet.go | 4 ---- samples/client/petstore/go/go-petstore/api_store.go | 4 ---- samples/client/petstore/go/go-petstore/api_user.go | 4 ---- samples/client/petstore/go/go.mod | 3 ++- samples/client/petstore/go/go.sum | 8 ++++++++ .../x-auth-id-alias/go-experimental/api_usage.go | 4 ---- .../client/petstore/go/go-petstore/api_another_fake.go | 4 ---- .../client/petstore/go/go-petstore/api_default.go | 4 ---- .../openapi3/client/petstore/go/go-petstore/api_fake.go | 4 ---- .../petstore/go/go-petstore/api_fake_classname_tags123.go | 4 ---- .../openapi3/client/petstore/go/go-petstore/api_pet.go | 4 ---- .../openapi3/client/petstore/go/go-petstore/api_store.go | 4 ---- .../openapi3/client/petstore/go/go-petstore/api_user.go | 4 ---- 17 files changed, 10 insertions(+), 61 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache index f7a31797b01..5048f9d60b8 100644 --- a/modules/openapi-generator/src/main/resources/go/api.mustache +++ b/modules/openapi-generator/src/main/resources/go/api.mustache @@ -12,10 +12,6 @@ import ( {{/imports}} ) -// Linger please -var ( - _ context.Context -) {{#generateInterfaces}} type {{classname}} interface { diff --git a/samples/client/petstore/go/go-petstore/api_another_fake.go b/samples/client/petstore/go/go-petstore/api_another_fake.go index 8199c4fd370..a4d199938c1 100644 --- a/samples/client/petstore/go/go-petstore/api_another_fake.go +++ b/samples/client/petstore/go/go-petstore/api_another_fake.go @@ -18,10 +18,6 @@ import ( "net/url" ) -// Linger please -var ( - _ context.Context -) type AnotherFakeApi interface { diff --git a/samples/client/petstore/go/go-petstore/api_fake.go b/samples/client/petstore/go/go-petstore/api_fake.go index 96a2c5ba9f7..8df181d95af 100644 --- a/samples/client/petstore/go/go-petstore/api_fake.go +++ b/samples/client/petstore/go/go-petstore/api_fake.go @@ -21,10 +21,6 @@ import ( "reflect" ) -// Linger please -var ( - _ context.Context -) type FakeApi interface { diff --git a/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go b/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go index 67b8e6a66c7..ee3e0f69292 100644 --- a/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go +++ b/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go @@ -18,10 +18,6 @@ import ( "net/url" ) -// Linger please -var ( - _ context.Context -) type FakeClassnameTags123Api interface { diff --git a/samples/client/petstore/go/go-petstore/api_pet.go b/samples/client/petstore/go/go-petstore/api_pet.go index 1c97ee676fe..3e1f9df1100 100644 --- a/samples/client/petstore/go/go-petstore/api_pet.go +++ b/samples/client/petstore/go/go-petstore/api_pet.go @@ -20,10 +20,6 @@ import ( "os" ) -// Linger please -var ( - _ context.Context -) type PetApi interface { diff --git a/samples/client/petstore/go/go-petstore/api_store.go b/samples/client/petstore/go/go-petstore/api_store.go index 61dcc483761..7b5aabeb8e2 100644 --- a/samples/client/petstore/go/go-petstore/api_store.go +++ b/samples/client/petstore/go/go-petstore/api_store.go @@ -19,10 +19,6 @@ import ( "strings" ) -// Linger please -var ( - _ context.Context -) type StoreApi interface { diff --git a/samples/client/petstore/go/go-petstore/api_user.go b/samples/client/petstore/go/go-petstore/api_user.go index a8107b6e461..7150fd9d692 100644 --- a/samples/client/petstore/go/go-petstore/api_user.go +++ b/samples/client/petstore/go/go-petstore/api_user.go @@ -19,10 +19,6 @@ import ( "strings" ) -// Linger please -var ( - _ context.Context -) type UserApi interface { diff --git a/samples/client/petstore/go/go.mod b/samples/client/petstore/go/go.mod index b8b87c5fe95..82a1337aea2 100644 --- a/samples/client/petstore/go/go.mod +++ b/samples/client/petstore/go/go.mod @@ -7,5 +7,6 @@ go 1.13 require ( github.com/OpenAPITools/openapi-generator/samples/client/petstore/go/go-petstore v0.0.0-00010101000000-000000000000 github.com/stretchr/testify v1.7.0 - golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558 + golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect + golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 ) diff --git a/samples/client/petstore/go/go.sum b/samples/client/petstore/go/go.sum index 0df1d1a38a0..601abdd5b8a 100644 --- a/samples/client/petstore/go/go.sum +++ b/samples/client/petstore/go/go.sum @@ -184,6 +184,8 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -191,6 +193,8 @@ golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558 h1:D7nTwh4J0i+5mW4Zjzn5omvlr6YBcWywE6KOcatyNxY= golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -224,11 +228,15 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/api_usage.go b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/api_usage.go index 8ba9a49d9d3..55c52687a94 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/api_usage.go +++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/api_usage.go @@ -18,10 +18,6 @@ import ( "net/url" ) -// Linger please -var ( - _ context.Context -) // UsageApiService UsageApi service type UsageApiService service diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_another_fake.go b/samples/openapi3/client/petstore/go/go-petstore/api_another_fake.go index d1ac2900c4c..84371a9856c 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api_another_fake.go +++ b/samples/openapi3/client/petstore/go/go-petstore/api_another_fake.go @@ -18,10 +18,6 @@ import ( "net/url" ) -// Linger please -var ( - _ context.Context -) type AnotherFakeApi interface { diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_default.go b/samples/openapi3/client/petstore/go/go-petstore/api_default.go index f5cd2374541..ec24ae4f7f4 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api_default.go +++ b/samples/openapi3/client/petstore/go/go-petstore/api_default.go @@ -18,10 +18,6 @@ import ( "net/url" ) -// Linger please -var ( - _ context.Context -) type DefaultApi interface { diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go index 1f4a8802ab0..6d342310fab 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api_fake.go +++ b/samples/openapi3/client/petstore/go/go-petstore/api_fake.go @@ -21,10 +21,6 @@ import ( "reflect" ) -// Linger please -var ( - _ context.Context -) type FakeApi interface { diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_fake_classname_tags123.go b/samples/openapi3/client/petstore/go/go-petstore/api_fake_classname_tags123.go index fef8f4cb3d4..73e85680e9f 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api_fake_classname_tags123.go +++ b/samples/openapi3/client/petstore/go/go-petstore/api_fake_classname_tags123.go @@ -18,10 +18,6 @@ import ( "net/url" ) -// Linger please -var ( - _ context.Context -) type FakeClassnameTags123Api interface { diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_pet.go b/samples/openapi3/client/petstore/go/go-petstore/api_pet.go index d0b5aff3871..f6aa8aea7aa 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api_pet.go +++ b/samples/openapi3/client/petstore/go/go-petstore/api_pet.go @@ -20,10 +20,6 @@ import ( "os" ) -// Linger please -var ( - _ context.Context -) type PetApi interface { diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_store.go b/samples/openapi3/client/petstore/go/go-petstore/api_store.go index 3957c73f96a..e257cb5c2d5 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api_store.go +++ b/samples/openapi3/client/petstore/go/go-petstore/api_store.go @@ -19,10 +19,6 @@ import ( "strings" ) -// Linger please -var ( - _ context.Context -) type StoreApi interface { diff --git a/samples/openapi3/client/petstore/go/go-petstore/api_user.go b/samples/openapi3/client/petstore/go/go-petstore/api_user.go index b044e87a435..4fa005f0566 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/api_user.go +++ b/samples/openapi3/client/petstore/go/go-petstore/api_user.go @@ -19,10 +19,6 @@ import ( "strings" ) -// Linger please -var ( - _ context.Context -) type UserApi interface {