From d4a4f7de1b51b2e727e791125dbc4172f9296e02 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 4 Aug 2022 10:51:09 +0000 Subject: [PATCH] Format code with gofmt and gofumpt (#52) This commit fixes the style issues introduced in a0ec5c1 according to the output from gofmt and gofumpt. Details: https://deepsource.io/gh/xf0e/open-ocr/transform/d2bea675-6ef1-45fd-9014-78b413628865/ Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> --- cli-httpd/main.go | 5 ++--- cli-preprocessor/main.go | 6 ++---- cli-worker/main.go | 1 - convert-pdf.go | 5 +---- generate_landing_page.go | 2 -- mock_engine.go | 3 +-- ocr_engine.go | 2 -- ocr_engine_test.go | 6 ++---- ocr_http_handler.go | 9 +++------ ocr_http_handler_test.go | 3 --- ocr_http_multipart_handler.go | 7 +------ ocr_http_status_handler.go | 4 +--- ocr_postback_client.go | 3 +-- ocr_request.go | 9 ++++----- ocr_res_manager.go | 5 ++--- ocr_results_storage.go | 4 ---- ocr_rpc_client.go | 7 +------ ocr_rpc_client_test.go | 4 +--- ocr_rpc_worker.go | 13 ++++--------- ocr_util.go | 8 +------- preprocessor.go | 11 ++++++----- preprocessor_rpc_worker.go | 7 ------- prometheus_metrics.go | 1 - rabbit_config.go | 2 -- sandwich_engine.go | 14 +------------- sandwich_engine_test.go | 7 ------- stroke_width_transform.go | 6 +----- stroke_width_transform_test.go | 4 ---- tesseract_engine.go | 20 +------------------- tesseract_engine_test.go | 7 ------- worker_config.go | 2 -- 31 files changed, 36 insertions(+), 151 deletions(-) diff --git a/cli-httpd/main.go b/cli-httpd/main.go index c0419fd..4308566 100644 --- a/cli-httpd/main.go +++ b/cli-httpd/main.go @@ -70,7 +70,6 @@ func makeHTTPServer(rabbitConfig *ocrworker.RabbitConfig, ocrChain http.Handler) mux.HandleFunc("/debug/pprof/trace", pprof.Trace) return makeServerFromMux(mux) - } func main() { @@ -183,7 +182,7 @@ func main() { if certFile == "" || keyFile == "" { log.Fatal().Msg("usehttps flag only makes sense if both the private key and a certificate are available") } - var httpsSrv = makeHTTPServer(&rabbitConfig, ocrChain) + httpsSrv := makeHTTPServer(&rabbitConfig, ocrChain) httpsSrv.Addr = listenAddr // crypto settings @@ -204,7 +203,7 @@ func main() { log.Fatal().Err(err).Str("component", "CLI_HTTP").Caller().Msg("cli_https has failed to start") } } else { - var httpSrv = makeHTTPServer(&rabbitConfig, ocrChain) + httpSrv := makeHTTPServer(&rabbitConfig, ocrChain) httpSrv.Addr = listenAddr if err := httpSrv.ListenAndServe(); err != nil { log.Fatal().Err(err).Str("component", "CLI_HTTP").Caller().Msg("cli_http has failed to start") diff --git a/cli-preprocessor/main.go b/cli-preprocessor/main.go index 57b6b6c..21c1916 100644 --- a/cli-preprocessor/main.go +++ b/cli-preprocessor/main.go @@ -2,9 +2,10 @@ package main import ( "flag" + "time" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" - "time" "github.com/xf0e/open-ocr" ) @@ -17,7 +18,6 @@ func init() { } func main() { - var preprocessor string flagFunc := func() { flag.StringVar( @@ -26,7 +26,6 @@ func main() { "identity", "The preprocessor to use, eg, stroke-width-transform", ) - } rabbitConfig := ocrworker.DefaultConfigFlagsOverride(flagFunc) @@ -51,5 +50,4 @@ func main() { err = <-preprocessorWorker.Done log.Error().Err(err).Str("component", "MAIN_PREPROSSOR").Msg("preprocessor worker failed") } - } diff --git a/cli-worker/main.go b/cli-worker/main.go index bf90d60..29b1eaa 100644 --- a/cli-worker/main.go +++ b/cli-worker/main.go @@ -67,5 +67,4 @@ func main() { Str("component", "OCR_WORKER").Err(err). Msg("OCR Worker failed with error") } - } diff --git a/convert-pdf.go b/convert-pdf.go index 2188c78..dc75f8a 100644 --- a/convert-pdf.go +++ b/convert-pdf.go @@ -17,11 +17,9 @@ import ( "github.com/rs/zerolog/log" ) -type ConvertPdf struct { -} +type ConvertPdf struct{} func (ConvertPdf) preprocess(ocrRequest *OcrRequest) error { - tmpFileNameInput, err := createTempFileName("") tmpFileNameInput = fmt.Sprintf("%s.pdf", tmpFileNameInput) if err != nil { @@ -72,7 +70,6 @@ func (ConvertPdf) preprocess(ocrRequest *OcrRequest) error { // read bytes from output file resultBytes, err := os.ReadFile(tmpFileNameOutput) - if err != nil { return err } diff --git a/generate_landing_page.go b/generate_landing_page.go index 7b3a79e..396fc7a 100644 --- a/generate_landing_page.go +++ b/generate_landing_page.go @@ -5,7 +5,6 @@ import ( ) func randomMOTD() string { - names := [...]string{ `
Nice day to put slinkies on an escalator!
__ ; '.' : @@ -198,5 +197,4 @@ pre {