From e47be80409b97fd4a00e523bf485d8c79d7c3f10 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Thu, 12 Oct 2023 10:47:05 +0800 Subject: [PATCH] improve coding style by go-staticcheck --- openapi/library_test.go | 12 ------------ openapi/restful.go | 2 +- openapi/waiter.go | 4 ++-- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/openapi/library_test.go b/openapi/library_test.go index ddc59f438..9f459eec2 100644 --- a/openapi/library_test.go +++ b/openapi/library_test.go @@ -18,21 +18,9 @@ import ( "github.com/stretchr/testify/assert" "bytes" - "fmt" "testing" ) -type reader_test struct { - content string -} - -func (r *reader_test) ReadFrom(path string) ([]byte, error) { - if path == "" || r.content == "" { - return nil, fmt.Errorf("Please insert a valid path.") - } - return []byte(r.content), nil -} - func TestLibrary_PrintProducts(t *testing.T) { w := new(bytes.Buffer) library := NewLibrary(w, "en") diff --git a/openapi/restful.go b/openapi/restful.go index c5d2ff765..71a793953 100644 --- a/openapi/restful.go +++ b/openapi/restful.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/openapi/waiter.go b/openapi/waiter.go index 8c911e57a..b076bffb1 100644 --- a/openapi/waiter.go +++ b/openapi/waiter.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -104,7 +104,7 @@ func (a *Waiter) CallWith(invoker Invoker) (string, error) { if v == a.to { return resp.GetHttpContentString(), nil } - duration := time.Now().Sub(begin) + duration := time.Since(begin) if duration > timeout { return "", fmt.Errorf("wait '%s' to '%s' timeout(%dseconds), last='%s'", a.expr, a.to, timeout/time.Second, v)