From 652d3e74fd4fc0379825cb5294adde96d07bbaf4 Mon Sep 17 00:00:00 2001 From: Andreas Pfohl Date: Thu, 23 May 2024 14:46:15 +0200 Subject: [PATCH] Fixed suggestions from PR --- components/printer/loading.go | 4 ++-- components/requests/requests.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/printer/loading.go b/components/printer/loading.go index bb2a8f8..ab7d9ca 100644 --- a/components/printer/loading.go +++ b/components/printer/loading.go @@ -6,7 +6,7 @@ import ( "github.com/briandowns/spinner" ) -type Func[T any] func() (T, error) +type function[T any] func() (T, error) var loadingSpinner *spinner.Spinner @@ -16,7 +16,7 @@ func init() { _ = loadingSpinner.Color("yellow") } -func WithSpinner[T any](f Func[T]) (T, error) { +func WithSpinner[T any](f function[T]) (T, error) { loadingSpinner.Start() t, err := f() diff --git a/components/requests/requests.go b/components/requests/requests.go index db0db4f..63ddff6 100644 --- a/components/requests/requests.go +++ b/components/requests/requests.go @@ -26,24 +26,24 @@ func Init(hostUrl *url.URL, tokenValue string) { } func Get(path string, query *Query) (responseBody []byte, err error) { - loadingFunc := func() ([]byte, error) { return Do("GET", path, query, nil) } + loadingFunc := func() ([]byte, error) { return do("GET", path, query, nil) } return printer.WithSpinner(loadingFunc) } func Post(path string, requestData *RequestData) (responseBody []byte, err error) { - loadingFunc := func() ([]byte, error) { return Do("POST", path, nil, requestData) } + loadingFunc := func() ([]byte, error) { return do("POST", path, nil, requestData) } return printer.WithSpinner(loadingFunc) } func Patch(path string, requestBody *RequestData) (responseBody []byte, err error) { - loadingFunc := func() ([]byte, error) { return Do("PATCH", path, nil, requestBody) } + loadingFunc := func() ([]byte, error) { return do("PATCH", path, nil, requestBody) } return printer.WithSpinner(loadingFunc) } -func Do(method string, path string, query *Query, requestData *RequestData) (responseBody []byte, err error) { +func do(method string, path string, query *Query, requestData *RequestData) (responseBody []byte, err error) { if client == nil || hostUnitialised() { return nil, errors.Custom("Cannot execute requests without initializing request client first. Run `op login`") }