From 8b207d632bd19ba8dd5a71773092bd4af242d9fb Mon Sep 17 00:00:00 2001 From: Kevin Franklin Kim Date: Tue, 3 Jun 2025 16:49:35 +0200 Subject: [PATCH] fix: lint issues --- client.go | 4 ++-- http.go | 6 +++--- transport.go | 2 +- typereader.go | 6 +++--- typscriptclient.go | 7 ++++--- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/client.go b/client.go index 67ee8bf..6e27302 100644 --- a/client.go +++ b/client.go @@ -31,7 +31,7 @@ func NewClient() Client { return &bufferedClient{client: defaultHttpFactory(), handle: getHandleForEncoding(EncodingMsgpack), headers: nil} } -func NewClientWithHttpClient(client *http.Client) Client { //nolint:stylecheck +func NewClientWithHttpClient(client *http.Client) Client { //nolint:staticcheck if client != nil { return &bufferedClient{client: client, handle: getHandleForEncoding(EncodingMsgpack), headers: nil} } else { @@ -71,7 +71,7 @@ func (c *bufferedClient) SetClientEncoding(encoding ClientEncoding) { c.handle = getHandleForEncoding(encoding) } -func (c *bufferedClient) SetTransportHttpClient(client *http.Client) { //nolint:stylecheck +func (c *bufferedClient) SetTransportHttpClient(client *http.Client) { //nolint:staticcheck c.client = client } diff --git a/http.go b/http.go index e37fd22..962bf35 100644 --- a/http.go +++ b/http.go @@ -9,7 +9,7 @@ import ( // Default Client Factory // https://medium.com/@nate510/don-t-use-go-s-default-http-client-4804cb19f779 -var defaultHttpFactory HttpClientFactory = func() *http.Client { //nolint:stylecheck +var defaultHttpFactory HttpClientFactory = func() *http.Client { //nolint:staticcheck transport := &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ @@ -28,8 +28,8 @@ var defaultHttpFactory HttpClientFactory = func() *http.Client { //nolint:stylec } } -type HttpClientFactory func() *http.Client //nolint:stylecheck +type HttpClientFactory func() *http.Client //nolint:staticcheck -func SetDefaultHttpClientFactory(factory HttpClientFactory) { //nolint:stylecheck +func SetDefaultHttpClientFactory(factory HttpClientFactory) { //nolint:staticcheck defaultHttpFactory = factory } diff --git a/transport.go b/transport.go index 8ea7d95..8f01e95 100644 --- a/transport.go +++ b/transport.go @@ -13,7 +13,7 @@ type ClientEncoding int const ( EncodingMsgpack = ClientEncoding(0) - EncodingJson = ClientEncoding(1) //nolint:stylecheck + EncodingJson = ClientEncoding(1) //nolint:staticcheck ) var errorType = reflect.TypeOf((*error)(nil)).Elem() diff --git a/typereader.go b/typereader.go index 04c34a4..c9dbcf1 100644 --- a/typereader.go +++ b/typereader.go @@ -91,10 +91,10 @@ func extractJSONInfo(tag string) *JSONInfo { } if len(jsonTags) > 1 { for _, value := range jsonTags[1:] { - switch { - case value == "inline": + switch value { + case "inline": inline = true - case value == "omitempty": + case "omitempty": omit = true } } diff --git a/typscriptclient.go b/typscriptclient.go index 78b171f..59aa972 100644 --- a/typscriptclient.go +++ b/typscriptclient.go @@ -116,11 +116,12 @@ func renderTypescriptClient(service *Service, mappings config.TypeScriptMappings } call := "this.transport<" + innerCallTypeString + ">(\"" + method.Name + "\", [" + strings.Join(callArgs, ", ") + "])" - if countReturns == 0 { + switch countReturns { + case 0: ts.l("await " + call) - } else if countReturns == 1 { + case 1: ts.l("return (await " + call + ")[0]") - } else { + default: ts.l("const response = await " + call) ts.l(responseObject) }