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 {
  `
 
 	return head + buttons + middle + MOTD + tail
-
 }
diff --git a/mock_engine.go b/mock_engine.go
index 446723c..0386066 100644
--- a/mock_engine.go
+++ b/mock_engine.go
@@ -2,8 +2,7 @@ package ocrworker
 
 const MockEngineResponse = "mock engine decoder response"
 
-type MockEngine struct {
-}
+type MockEngine struct{}
 
 // ProcessRequest will process incoming OCR request by routing it through the whole process chain
 func (m MockEngine) ProcessRequest(ocrRequest *OcrRequest, workerConfig *WorkerConfig) (OcrResult, error) {
diff --git a/ocr_engine.go b/ocr_engine.go
index b51f06b..444b957 100644
--- a/ocr_engine.go
+++ b/ocr_engine.go
@@ -48,7 +48,6 @@ func (e OcrEngineType) String() string {
 }
 
 func (e *OcrEngineType) UnmarshalJSON(b []byte) (err error) {
-
 	var engineTypeStr string
 
 	if err := json.Unmarshal(b, &engineTypeStr); err == nil {
@@ -78,5 +77,4 @@ func (e *OcrEngineType) UnmarshalJSON(b []byte) (err error) {
 	} else {
 		return err
 	}
-
 }
diff --git a/ocr_engine_test.go b/ocr_engine_test.go
index 9470de4..886f6b0 100644
--- a/ocr_engine_test.go
+++ b/ocr_engine_test.go
@@ -2,23 +2,21 @@ package ocrworker
 
 import (
 	"encoding/json"
-	"github.com/rs/zerolog/log"
 	"testing"
 
+	"github.com/rs/zerolog/log"
+
 	"github.com/couchbaselabs/go.assert"
 )
 
 func TestOcrEngineTypeJson(t *testing.T) {
-
 	testJson := `{"img_url":"foo", "engine":"tesseract"}`
 	ocrRequest := OcrRequest{}
 	err := json.Unmarshal([]byte(testJson), &ocrRequest)
 	if err != nil {
 		log.Error().Str("component", "TEST").Err(err)
-
 	}
 	assert.True(t, err == nil)
 	assert.Equals(t, ocrRequest.EngineType, EngineTesseract)
 	log.Error().Str("component", "TEST").Interface("ocrRequest", ocrRequest)
-
 }
diff --git a/ocr_http_handler.go b/ocr_http_handler.go
index df856ac..f4dfdf5 100644
--- a/ocr_http_handler.go
+++ b/ocr_http_handler.go
@@ -35,7 +35,7 @@ var (
 
 func (s *OcrHTTPStatusHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
 	// _ = pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
-	var requestIDRaw = ksuid.New()
+	requestIDRaw := ksuid.New()
 	requestID := requestIDRaw.String()
 	log.Info().Str("component", "OCR_HTTP").Str("RequestID", requestID).
 		Msg("serveHttp called")
@@ -45,7 +45,7 @@ func (s *OcrHTTPStatusHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques
 			log.Warn().Err(err).Caller().Str("component", "OCR_HTTP").Msg(req.RequestURI + " request Body could not be removed")
 		}
 	}(req.Body)
-	var httpStatus = 200
+	httpStatus := 200
 
 	ServiceCanAcceptMu.Lock()
 	serviceCanAcceptLocal := ServiceCanAccept
@@ -84,7 +84,6 @@ func (s *OcrHTTPStatusHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques
 	}
 
 	ocrResult, httpStatus, err := HandleOcrRequest(&ocrRequest, &s.RabbitConfig)
-
 	if err != nil {
 		msg := "Unable to perform OCR decode. Error: %v"
 		errMsg := fmt.Sprintf(msg, err)
@@ -108,7 +107,7 @@ func (s *OcrHTTPStatusHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques
 
 // HandleOcrRequest will process incoming OCR request by routing it through the whole process chain
 func HandleOcrRequest(ocrRequest *OcrRequest, workerConfig *RabbitConfig) (OcrResult, int, error) {
-	var httpStatus = 200
+	httpStatus := 200
 	ocrResult := newOcrResult(ocrRequest.RequestID)
 	// set the context for zerolog, RequestID will be printed on each logging event
 	logger := zerolog.New(os.Stdout).With().
@@ -120,7 +119,6 @@ func HandleOcrRequest(ocrRequest *OcrRequest, workerConfig *RabbitConfig) (OcrRe
 
 		workingConfig := WorkerConfig{}
 		ocrResult, err := ocrEngine.ProcessRequest(ocrRequest, &workingConfig)
-
 		if err != nil {
 			logger.Error().Err(err).Str("component", "OCR_HTTP").Msg("Error processing ocr request")
 			httpStatus = 500
@@ -145,5 +143,4 @@ func HandleOcrRequest(ocrRequest *OcrRequest, workerConfig *RabbitConfig) (OcrRe
 
 		return ocrResult, httpStatus, nil
 	}
-
 }
diff --git a/ocr_http_handler_test.go b/ocr_http_handler_test.go
index 905b3b1..4e9f97c 100644
--- a/ocr_http_handler_test.go
+++ b/ocr_http_handler_test.go
@@ -14,7 +14,6 @@ import (
 
 // This test assumes that rabbit mq is running
 func DisabledTestOcrHttpHandlerIntegration(t *testing.T) {
-
 	rabbitConfig := rabbitConfigForTests()
 	workerConfig := workerConfigForTests()
 
@@ -59,7 +58,6 @@ func DisabledTestOcrHttpHandlerIntegration(t *testing.T) {
 }
 
 func spawnOcrWorker(workerConfig *WorkerConfig) error {
-
 	// kick off a worker
 	// this would normally happen on a different machine ..
 	ocrWorker, err := NewOcrRpcWorker(workerConfig)
@@ -68,5 +66,4 @@ func spawnOcrWorker(workerConfig *WorkerConfig) error {
 	}
 	ocrWorker.Run()
 	return nil
-
 }
diff --git a/ocr_http_multipart_handler.go b/ocr_http_multipart_handler.go
index 717fae3..1ea529b 100644
--- a/ocr_http_multipart_handler.go
+++ b/ocr_http_multipart_handler.go
@@ -23,7 +23,6 @@ func NewOcrHttpMultipartHandler(r *RabbitConfig) *OcrHttpMultipartHandler {
 }
 
 func (*OcrHttpMultipartHandler) extractParts(req *http.Request) (OcrRequest, error) {
-
 	log.Info().Str("component", "OCR_HTTP").Msg("request to ocr-file-upload")
 	ocrReq := OcrRequest{}
 
@@ -87,18 +86,16 @@ func (*OcrHttpMultipartHandler) extractParts(req *http.Request) (OcrRequest, err
 	default:
 		return ocrReq, fmt.Errorf("this endpoint only accepts POST requests")
 	}
-
 }
 
 func (s *OcrHttpMultipartHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
-
 	defer func(Body io.ReadCloser) {
 		err := Body.Close()
 		if err != nil {
 			log.Warn().Err(err).Caller().Str("component", "OCR_HTTP").Msg(req.RequestURI + " request Body could not be removed")
 		}
 	}(req.Body)
-	var httpStatus = 200
+	httpStatus := 200
 	ocrRequest, err := s.extractParts(req)
 	if err != nil {
 		log.Error().Err(err).Str("component", "OCR_HTTP")
@@ -108,7 +105,6 @@ func (s *OcrHttpMultipartHandler) ServeHTTP(w http.ResponseWriter, req *http.Req
 	}
 
 	ocrResult, httpStatus, err := HandleOcrRequest(&ocrRequest, &s.RabbitConfig)
-
 	if err != nil {
 		msg := "Unable to perform OCR decode."
 		log.Error().Err(err).Str("component", "OCR_HTTP").Msg(msg)
@@ -117,5 +113,4 @@ func (s *OcrHttpMultipartHandler) ServeHTTP(w http.ResponseWriter, req *http.Req
 	}
 
 	_, _ = fmt.Fprintf(w, ocrResult.Text)
-
 }
diff --git a/ocr_http_status_handler.go b/ocr_http_status_handler.go
index a3483fe..56fcd29 100644
--- a/ocr_http_status_handler.go
+++ b/ocr_http_status_handler.go
@@ -7,15 +7,13 @@ import (
 	"github.com/rs/zerolog/log"
 )
 
-type OcrHttpStatusHandler struct {
-}
+type OcrHttpStatusHandler struct{}
 
 func NewOcrHttpStatusHandler() *OcrHttpStatusHandler {
 	return &OcrHttpStatusHandler{}
 }
 
 func (s *OcrHttpStatusHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
-
 	log.Debug().Str("component", "OCR_STATUS").Msg("OcrHttpStatusHandler called")
 
 	ocrRequest := OcrRequest{}
diff --git a/ocr_postback_client.go b/ocr_postback_client.go
index 639ee83..67d9784 100644
--- a/ocr_postback_client.go
+++ b/ocr_postback_client.go
@@ -15,8 +15,7 @@ import (
 
 var postTimeout = 50 * time.Second
 
-type ocrPostClient struct {
-}
+type ocrPostClient struct{}
 
 func newOcrPostClient() *ocrPostClient {
 	return &ocrPostClient{}
diff --git a/ocr_request.go b/ocr_request.go
index 1f77943..b6ff2ce 100644
--- a/ocr_request.go
+++ b/ocr_request.go
@@ -1,7 +1,9 @@
 package ocrworker
 
-import "fmt"
-import "encoding/base64"
+import (
+	"encoding/base64"
+	"fmt"
+)
 
 type OcrRequest struct {
 	ImgUrl            string                 `json:"img_url"`
@@ -38,7 +40,6 @@ func (ocrRequest *OcrRequest) nextPreprocessor(processorRoutingKey string) strin
 }
 
 func (ocrRequest *OcrRequest) decodeBase64() error {
-
 	bytes, decodeError := base64.StdEncoding.DecodeString(ocrRequest.ImgBase64)
 
 	if decodeError != nil {
@@ -52,12 +53,10 @@ func (ocrRequest *OcrRequest) decodeBase64() error {
 }
 
 func (ocrRequest *OcrRequest) hasBase64() bool {
-
 	return ocrRequest.ImgBase64 != ""
 }
 
 func (ocrRequest *OcrRequest) downloadImgUrl() error {
-
 	bytes, err := url2bytes(ocrRequest.ImgUrl)
 	if err != nil {
 		return err
diff --git a/ocr_res_manager.go b/ocr_res_manager.go
index 5a8acd7..4f7efb7 100644
--- a/ocr_res_manager.go
+++ b/ocr_res_manager.go
@@ -43,7 +43,6 @@ var (
 
 // CheckForAcceptRequest will check by reading the RabbitMQ API if resources for incoming request are available
 func CheckForAcceptRequest(urlQueue, urlStat string, statusChanged bool) bool {
-
 	isAvailable := false
 	TechnicalErrorResManager = false
 	jsonQueueStat, err := url2bytes(urlQueue)
@@ -147,8 +146,8 @@ func SetResManagerState(ampqAPIConfig *RabbitConfig) {
 	urlStat := ampqAPIConfig.AmqpAPIURI + ampqAPIConfig.APIPathStats
 	factorForMessageAccept = ampqAPIConfig.FactorForMessageAccept
 
-	var boolCurValue = false
-	var boolOldValue = true
+	boolCurValue := false
+	boolOldValue := true
 Loop:
 	for {
 		if AppStop {
diff --git a/ocr_results_storage.go b/ocr_results_storage.go
index 186d467..cc1e026 100644
--- a/ocr_results_storage.go
+++ b/ocr_results_storage.go
@@ -13,7 +13,6 @@ var (
 
 // CheckOcrStatusByID checks status of an ocr request based on origin of request
 func CheckOcrStatusByID(requestID string) (OcrResult, bool) {
-
 	if _, ok := RequestsTrack.Load(requestID); !ok {
 		// log.Info().Str("component", "OCR_CLIENT").Str("RequestID", requestID).Msg("no such request found in the queue")
 		return OcrResult{}, false
@@ -41,19 +40,16 @@ func CheckOcrStatusByID(requestID string) (OcrResult, bool) {
 }
 
 func getQueueLen() uint {
-
 	return uint(atomic.LoadUint32(&RequestTrackLength))
 }
 
 func deleteRequestFromQueue(requestID string) {
-
 	inFlightGauge.Dec()
 	atomic.AddUint32(&RequestTrackLength, ^uint32(0))
 	RequestsTrack.Delete(requestID)
 }
 
 func addNewOcrResultToQueue(requestID string, rpcResponseChan chan OcrResult) {
-
 	inFlightGauge.Inc()
 	atomic.AddUint32(&RequestTrackLength, 1)
 	RequestsTrack.Store(requestID, rpcResponseChan)
diff --git a/ocr_rpc_client.go b/ocr_rpc_client.go
index 17886c1..ed45603 100644
--- a/ocr_rpc_client.go
+++ b/ocr_rpc_client.go
@@ -36,9 +36,7 @@ func newOcrResult(id string) OcrResult {
 	return *ocrResult
 }
 
-var (
-	numRetries uint = 3
-)
+var numRetries uint = 3
 
 func NewOcrRpcClient(rc *RabbitConfig) (*OcrRpcClient, error) {
 	ocrRpcClient := &OcrRpcClient{
@@ -153,7 +151,6 @@ func (c *OcrRpcClient) DecodeImage(ocrRequest *OcrRequest) (OcrResult, int, erro
 	// as open-ocr, it will be expensive in terms of bandwidth
 	// to have image binary in messages
 	if ocrRequest.ImgBytes == nil {
-
 		// if we do not have bytes use base 64 file by converting it to bytes
 		if ocrRequest.hasBase64() {
 			logger.Info().Msg("OCR request has base 64 convert it to bytes")
@@ -295,7 +292,6 @@ func (c *OcrRpcClient) DecodeImage(ocrRequest *OcrRequest) (OcrResult, int, erro
 }
 
 func (c *OcrRpcClient) subscribeCallbackQueue(correlationID string, rpcResponseChan chan OcrResult) (amqp.Queue, error) {
-
 	queueArgs := make(amqp.Table)
 	queueArgs["x-max-priority"] = uint8(10)
 
@@ -341,7 +337,6 @@ func (c *OcrRpcClient) subscribeCallbackQueue(correlationID string, rpcResponseC
 	go c.handleRPCResponse(deliveries, correlationID, rpcResponseChan)
 
 	return callbackQueue, nil
-
 }
 
 func (c *OcrRpcClient) handleRPCResponse(deliveries <-chan amqp.Delivery, correlationID string, rpcResponseChan chan OcrResult) {
diff --git a/ocr_rpc_client_test.go b/ocr_rpc_client_test.go
index dd88cf7..d39e9ed 100644
--- a/ocr_rpc_client_test.go
+++ b/ocr_rpc_client_test.go
@@ -23,7 +23,6 @@ func rabbitConfigForTests() RabbitConfig {
 
 // This test assumes that rabbit mq is running
 func DisabledTestOcrRpcClientIntegration(t *testing.T) {
-
 	// TODO: serve this up through a fake webserver
 	// that reads from the filesystem
 	testImageUrl := "http://localhost:8080/img"
@@ -31,7 +30,7 @@ func DisabledTestOcrRpcClientIntegration(t *testing.T) {
 	rabbitConfig := rabbitConfigForTests()
 	workerConfig := workerConfigForTests()
 
-	//requestID := "426d0ef9-a0c9-48cb-4562-f9d6f29a6ba5"
+	// requestID := "426d0ef9-a0c9-48cb-4562-f9d6f29a6ba5"
 
 	// kick off a worker
 	// this would normally happen on a different machine ..
@@ -59,5 +58,4 @@ func DisabledTestOcrRpcClientIntegration(t *testing.T) {
 		assert.Equals(t, decodeResult.Text, MockEngineResponse)
 
 	}
-
 }
diff --git a/ocr_rpc_worker.go b/ocr_rpc_worker.go
index 333855d..1107c14 100644
--- a/ocr_rpc_worker.go
+++ b/ocr_rpc_worker.go
@@ -4,11 +4,12 @@ import (
 	"context"
 	"encoding/json"
 	"fmt"
-	amqp "github.com/rabbitmq/amqp091-go"
 	"net/url"
 	"os"
 	"time"
 
+	amqp "github.com/rabbitmq/amqp091-go"
+
 	"github.com/rs/zerolog"
 	"github.com/rs/zerolog/log"
 	"github.com/segmentio/ksuid"
@@ -22,10 +23,8 @@ type OcrRpcWorker struct {
 	Done         chan error
 }
 
-var (
-	// tag is based on K-Sortable Globally Unique IDs
-	tag = ksuid.New().String()
-)
+// tag is based on K-Sortable Globally Unique IDs
+var tag = ksuid.New().String()
 
 // NewOcrRpcWorker is needed to establish a connection to a message broker
 func NewOcrRpcWorker(wc *WorkerConfig) (*OcrRpcWorker, error) {
@@ -40,7 +39,6 @@ func NewOcrRpcWorker(wc *WorkerConfig) (*OcrRpcWorker, error) {
 }
 
 func (w *OcrRpcWorker) Run() error {
-
 	var err error
 	queueArgs := make(amqp.Table)
 	queueArgs["x-max-priority"] = uint8(9)
@@ -214,7 +212,6 @@ func (w *OcrRpcWorker) handle(deliveries <-chan amqp.Delivery, done chan error)
 }
 
 func (w *OcrRpcWorker) resultForDelivery(d *amqp.Delivery) (OcrResult, error) {
-
 	ocrRequest := OcrRequest{}
 	ocrResult := OcrResult{ID: d.CorrelationId}
 	err := json.Unmarshal(d.Body, &ocrRequest)
@@ -247,7 +244,6 @@ func (w *OcrRpcWorker) resultForDelivery(d *amqp.Delivery) (OcrResult, error) {
 	}
 
 	return ocrResult, nil
-
 }
 
 func (w *OcrRpcWorker) sendRpcResponse(r OcrResult, replyTo, correlationId string) error {
@@ -306,7 +302,6 @@ func (w *OcrRpcWorker) sendRpcResponse(r OcrResult, replyTo, correlationId strin
 		Str("replyTo", replyTo).
 		Msg("sendRpcResponse succeeded")
 	return nil
-
 }
 
 func confirmDeliveryWorker(ack, nack chan uint64) {
diff --git a/ocr_util.go b/ocr_util.go
index 434bba9..72bc56f 100644
--- a/ocr_util.go
+++ b/ocr_util.go
@@ -16,7 +16,6 @@ import (
 )
 
 func saveUrlContentToFileName(uri, tmpFileName string) error {
-
 	outFile, err := os.Create(tmpFileName)
 	if err != nil {
 		return err
@@ -56,8 +55,7 @@ func saveBytesToFileName(bytes []byte, tmpFileName string) error {
 }
 
 func url2bytes(uri string) ([]byte, error) {
-
-	var client = &http.Client{Timeout: 10 * time.Second}
+	client := &http.Client{Timeout: 10 * time.Second}
 	resp, err := client.Get(uri)
 	if err != nil {
 		return nil, err
@@ -77,7 +75,6 @@ func url2bytes(uri string) ([]byte, error) {
 	}
 
 	return bodyBytes, nil
-
 }
 
 // createTempFileName generating a file name within of a temp directory. If function argument ist empty string
@@ -94,7 +91,6 @@ func createTempFileName(fileName string) (string, error) {
 }
 
 func readFirstBytes(filePath string, nBytesToRead uint) ([]byte, error) {
-
 	file, err := os.Open(filePath)
 	if err != nil {
 		return nil, err
@@ -151,7 +147,6 @@ func convertImageToPdf(inputFilename string) string {
 	}
 
 	return tmpFileImgToPdf
-
 }
 
 // if sandwich engine gets a TIFF image instead of PDF file
@@ -199,7 +194,6 @@ func timeTrack(start time.Time, operation, message, requestID string) {
 
 // StripPasswordFromUrl strips passwords from URL
 func StripPasswordFromUrl(urlToLog *url.URL) string {
-
 	pass, passSet := urlToLog.User.Password()
 
 	if passSet {
diff --git a/preprocessor.go b/preprocessor.go
index f1fef14..837fe3b 100644
--- a/preprocessor.go
+++ b/preprocessor.go
@@ -1,15 +1,16 @@
 package ocrworker
 
-const PreprocessorIdentity = "identity"
-const PreprocessorStrokeWidthTransform = "stroke-width-transform"
-const PreprocessorConvertPdf = "convert-pdf"
+const (
+	PreprocessorIdentity             = "identity"
+	PreprocessorStrokeWidthTransform = "stroke-width-transform"
+	PreprocessorConvertPdf           = "convert-pdf"
+)
 
 type Preprocessor interface {
 	preprocess(ocrRequest *OcrRequest) error
 }
 
-type IdentityPreprocessor struct {
-}
+type IdentityPreprocessor struct{}
 
 func (i IdentityPreprocessor) preprocess(ocrRequest *OcrRequest) error {
 	return nil
diff --git a/preprocessor_rpc_worker.go b/preprocessor_rpc_worker.go
index beff520..aaceaad 100644
--- a/preprocessor_rpc_worker.go
+++ b/preprocessor_rpc_worker.go
@@ -27,7 +27,6 @@ type PreprocessorRpcWorker struct {
 var preprocessorTag = ksuid.New().String()
 
 func NewPreprocessorRpcWorker(rc *RabbitConfig, preprocessor string) (*PreprocessorRpcWorker, error) {
-
 	preprocessorMap := make(map[string]Preprocessor)
 	preprocessorMap[PreprocessorStrokeWidthTransform] = StrokeWidthTransformer{}
 	preprocessorMap[PreprocessorIdentity] = IdentityPreprocessor{}
@@ -51,7 +50,6 @@ func NewPreprocessorRpcWorker(rc *RabbitConfig, preprocessor string) (*Preproces
 }
 
 func (w *PreprocessorRpcWorker) Run() error {
-
 	var err error
 	log.Info().Str("component", "PREPROCESSOR_WORKER").Msg("Run() called...")
 	log.Info().Str("component", "PREPROCESSOR_WORKER").
@@ -168,7 +166,6 @@ func (w *PreprocessorRpcWorker) handle(deliveries <-chan amqp.Delivery, done cha
 }
 
 func (w *PreprocessorRpcWorker) preprocessImage(ocrRequest *OcrRequest) error {
-
 	descriptor := w.bindingKey // eg, "stroke-width-transform"
 	preprocessor := w.preprocessorMap[descriptor]
 	log.Info().Str("component", "PREPROCESSOR_WORKER").
@@ -183,11 +180,9 @@ func (w *PreprocessorRpcWorker) preprocessImage(ocrRequest *OcrRequest) error {
 		return err
 	}
 	return nil
-
 }
 
 func (*PreprocessorRpcWorker) strokeWidthTransform(ocrRequest *OcrRequest) error {
-
 	// write bytes to a temp file
 
 	tmpFileNameInput, err := createTempFileName("")
@@ -239,11 +234,9 @@ func (*PreprocessorRpcWorker) strokeWidthTransform(ocrRequest *OcrRequest) error
 	ocrRequest.ImgBytes = resultBytes
 
 	return nil
-
 }
 
 func (w *PreprocessorRpcWorker) handleDelivery(d *amqp.Delivery) error {
-
 	ocrRequest := OcrRequest{}
 	err := json.Unmarshal(d.Body, &ocrRequest)
 	if err != nil {
diff --git a/prometheus_metrics.go b/prometheus_metrics.go
index aba9b5e..328e1e0 100644
--- a/prometheus_metrics.go
+++ b/prometheus_metrics.go
@@ -44,7 +44,6 @@ var (
 
 // InstrumentHttpStatusHandler wraps httpHandler to provide prometheus metrics
 func InstrumentHttpStatusHandler(ocrHttpHandler *OcrHTTPStatusHandler) http.Handler {
-
 	// Register all the metrics in the standard registry.
 	prometheus.MustRegister(inFlightGauge, counter, duration, requestSize)
 
diff --git a/rabbit_config.go b/rabbit_config.go
index 0413228..36c550d 100644
--- a/rabbit_config.go
+++ b/rabbit_config.go
@@ -29,7 +29,6 @@ type RabbitConfig struct {
 }
 
 func DefaultTestConfig() RabbitConfig {
-
 	// Reliable: false due to major issues that would completely
 	// wedge the rpc worker.  Setting the buffered channels length
 	// higher would delay the problem, but then it would still happen later.
@@ -51,7 +50,6 @@ func DefaultTestConfig() RabbitConfig {
 		FactorForMessageAccept: 2,
 	}
 	return rabbitConfig
-
 }
 
 type FlagFunction func()
diff --git a/sandwich_engine.go b/sandwich_engine.go
index 15b6264..5b55b79 100644
--- a/sandwich_engine.go
+++ b/sandwich_engine.go
@@ -19,8 +19,7 @@ import (
 // This implementation returns either the pdf with ocr layer only
 // or merged variant of pdf plus ocr layer with the ability to
 // optimize the output pdf file by calling "gs" tool
-type SandwichEngine struct {
-}
+type SandwichEngine struct{}
 
 type SandwichEngineArgs struct {
 	configVars   map[string]string `json:"config_vars"`
@@ -102,7 +101,6 @@ func NewSandwichEngineArgs(ocrRequest *OcrRequest, workerConfig *WorkerConfig) (
 	engineArgs.t2pConverter = workerConfig.Tiff2pdfConverter
 
 	return engineArgs, nil
-
 }
 
 // Export return a slice that can be passed to tesseract binary as command line
@@ -126,7 +124,6 @@ func (t *SandwichEngineArgs) Export() []string {
 
 // ProcessRequest will process incoming OCR request by routing it through the whole process chain
 func (t SandwichEngine) ProcessRequest(ocrRequest *OcrRequest, workerConfig *WorkerConfig) (OcrResult, error) {
-
 	logger := zerolog.New(os.Stdout).With().
 		Str("component", "OCR_SANDWICH").
 		Str("RequestID", ocrRequest.RequestID).Timestamp().Logger()
@@ -164,7 +161,6 @@ func (t SandwichEngine) ProcessRequest(ocrRequest *OcrRequest, workerConfig *Wor
 			return t.tmpFileFromImageBytes(ocrRequest.ImgBytes, ocrRequest.RequestID)
 		}
 	}()
-
 	if err != nil {
 		logger.Error().Caller().Err(err).Msg("error getting tmpFileName")
 		return OcrResult{Text: "Internal server error", Status: "error"}, err
@@ -203,7 +199,6 @@ func (t SandwichEngine) ProcessRequest(ocrRequest *OcrRequest, workerConfig *Wor
 }
 
 func (SandwichEngine) tmpFileFromImageBytes(imgBytes []byte, tmpFileName string) (string, error) {
-
 	log.Info().Str("component", "OCR_SANDWICH").Msg("Use pdfsandwich with bytes image")
 	var err error
 	tmpFileName, err = createTempFileName(tmpFileName)
@@ -219,11 +214,9 @@ func (SandwichEngine) tmpFileFromImageBytes(imgBytes []byte, tmpFileName string)
 	}
 
 	return tmpFileName, nil
-
 }
 
 func (SandwichEngine) tmpFileFromImageBase64(base64Image, tmpFileName string) (string, error) {
-
 	log.Info().Str("component", "OCR_SANDWICH").Msg("Use pdfsandwich with base 64")
 	var err error
 	if tmpFileName == "" {
@@ -245,11 +238,9 @@ func (SandwichEngine) tmpFileFromImageBase64(base64Image, tmpFileName string) (s
 	}
 
 	return tmpFileName, nil
-
 }
 
 func (SandwichEngine) tmpFileFromImageURL(imgURL, tmpFileName string) (string, error) {
-
 	log.Info().Str("component", "OCR_SANDWICH").Msg("Use pdfsandwich with url")
 	var err error
 	if tmpFileName == "" {
@@ -266,11 +257,9 @@ func (SandwichEngine) tmpFileFromImageURL(imgURL, tmpFileName string) (string, e
 	}
 
 	return tmpFileName, nil
-
 }
 
 func (SandwichEngine) buildCmdLineArgs(inputFilename string, engineArgs *SandwichEngineArgs) (cmdArgs []string, ocrLayerFile string) {
-
 	// sets output file name for pdfsandwich output file
 	// and builds the argument list for external program
 	// since pdfsandwich can only return pdf files the will deliver work with pdf intermediates
@@ -287,7 +276,6 @@ func (SandwichEngine) buildCmdLineArgs(inputFilename string, engineArgs *Sandwic
 	log.Info().Str("component", "OCR_SANDWICH").Interface("cmdArgs", cmdArgs)
 
 	return cmdArgs, ocrLayerFile
-
 }
 
 func (SandwichEngine) runExternalCmd(commandToRun string, cmdArgs []string, defaultTimeOutSeconds time.Duration) (string, error) {
diff --git a/sandwich_engine_test.go b/sandwich_engine_test.go
index 40e7580..2c29258 100644
--- a/sandwich_engine_test.go
+++ b/sandwich_engine_test.go
@@ -11,7 +11,6 @@ import (
 )
 
 func TestSandwichEngineWithRequest(t *testing.T) {
-
 	if testing.Short() {
 		t.Skip("skipping test in short mode.")
 	}
@@ -38,11 +37,9 @@ func TestSandwichEngineWithRequest(t *testing.T) {
 	result, err := engine.ProcessRequest(&ocrRequest, &workerConfig)
 	assert.True(t, err == nil)
 	log.Info().Str("component", "TEST").Interface("result", result)
-
 }
 
 func TestSandwichEngineWithJson(t *testing.T) {
-
 	if testing.Short() {
 		t.Skip("skipping test in short mode.")
 	}
@@ -73,7 +70,6 @@ func TestSandwichEngineWithJson(t *testing.T) {
 		log.Info().Str("component", "TEST").Interface("result", result)
 
 	}
-
 }
 
 func TestNewsandwichEngineArgs(t *testing.T) {
@@ -88,11 +84,9 @@ func TestNewsandwichEngineArgs(t *testing.T) {
 	assert.Equals(t, engineArgs.configVars["tessedit_char_whitelist"], "0123456789")
 	// assert.Equals(t, engineArgs.pageSegMode, "0")
 	assert.Equals(t, engineArgs.lang, "eng")
-
 }
 
 func TestSandwichEngineWithFile(t *testing.T) {
-
 	if testing.Short() {
 		t.Skip("skipping test in short mode.")
 	}
@@ -108,5 +102,4 @@ func TestSandwichEngineWithFile(t *testing.T) {
 	assert.True(t, err == nil)
 
 	log.Info().Str("component", "TEST").Interface("result", result)
-
 }
diff --git a/stroke_width_transform.go b/stroke_width_transform.go
index 54ffdf0..0bddf7c 100644
--- a/stroke_width_transform.go
+++ b/stroke_width_transform.go
@@ -8,11 +8,9 @@ import (
 	"github.com/rs/zerolog/log"
 )
 
-type StrokeWidthTransformer struct {
-}
+type StrokeWidthTransformer struct{}
 
 func (s StrokeWidthTransformer) preprocess(ocrRequest *OcrRequest) error {
-
 	// write bytes to a temp file
 
 	tmpFileNameInput, err := createTempFileName("")
@@ -69,11 +67,9 @@ func (s StrokeWidthTransformer) preprocess(ocrRequest *OcrRequest) error {
 	ocrRequest.ImgBytes = resultBytes
 
 	return nil
-
 }
 
 func (StrokeWidthTransformer) extractDarkOnLightParam(ocrRequest *OcrRequest) string {
-
 	log.Info().Str("component", "PREPROCESSOR_WORKER").
 		Msg("extract dark on light param")
 
diff --git a/stroke_width_transform_test.go b/stroke_width_transform_test.go
index f7f0765..1e233d6 100644
--- a/stroke_width_transform_test.go
+++ b/stroke_width_transform_test.go
@@ -8,7 +8,6 @@ import (
 )
 
 func TestParamExtraction(t *testing.T) {
-
 	testJson := `{"img_url":"foo", "engine":"tesseract", "preprocessor-args":{"stroke-width-transform":"0"}}`
 	ocrRequest := OcrRequest{}
 	err := json.Unmarshal([]byte(testJson), &ocrRequest)
@@ -17,11 +16,9 @@ func TestParamExtraction(t *testing.T) {
 	swt := StrokeWidthTransformer{}
 	param := swt.extractDarkOnLightParam(&ocrRequest)
 	assert.Equals(t, param, "0")
-
 }
 
 func TestParamExtractionNegative(t *testing.T) {
-
 	testJson := `{"img_url":"foo", "engine":"tesseract"}`
 	ocrRequest := OcrRequest{}
 	err := json.Unmarshal([]byte(testJson), &ocrRequest)
@@ -30,5 +27,4 @@ func TestParamExtractionNegative(t *testing.T) {
 	swt := StrokeWidthTransformer{}
 	param := swt.extractDarkOnLightParam(&ocrRequest)
 	assert.Equals(t, param, "1")
-
 }
diff --git a/tesseract_engine.go b/tesseract_engine.go
index 7ada77c..7800347 100644
--- a/tesseract_engine.go
+++ b/tesseract_engine.go
@@ -10,8 +10,7 @@ import (
 )
 
 // TesseractEngine calls tesseract via exec
-type TesseractEngine struct {
-}
+type TesseractEngine struct{}
 
 type TesseractEngineArgs struct {
 	configVars  map[string]string `json:"config_vars"`
@@ -21,7 +20,6 @@ type TesseractEngineArgs struct {
 }
 
 func NewTesseractEngineArgs(ocrRequest *OcrRequest) (*TesseractEngineArgs, error) {
-
 	engineArgs := &TesseractEngineArgs{}
 
 	if ocrRequest.EngineArgs == nil {
@@ -73,7 +71,6 @@ func NewTesseractEngineArgs(ocrRequest *OcrRequest) (*TesseractEngineArgs, error
 	}
 
 	return engineArgs, nil
-
 }
 
 // Export return a slice that can be passed to tesseract binary as command line
@@ -97,7 +94,6 @@ func (t TesseractEngineArgs) Export() []string {
 
 // ProcessRequest will process incoming OCR request by routing it through the whole process chain
 func (t TesseractEngine) ProcessRequest(ocrRequest *OcrRequest, _ *WorkerConfig) (OcrResult, error) {
-
 	tmpFileName, err := func() (string, error) {
 		switch {
 		case ocrRequest.ImgBase64 != "":
@@ -108,7 +104,6 @@ func (t TesseractEngine) ProcessRequest(ocrRequest *OcrRequest, _ *WorkerConfig)
 			return t.tmpFileFromImageBytes(ocrRequest.ImgBytes)
 		}
 	}()
-
 	if err != nil {
 		log.Error().Err(err).Str("component", "OCR_TESSERACT").Msg("error getting tmpFileName")
 		return OcrResult{}, err
@@ -132,11 +127,9 @@ func (t TesseractEngine) ProcessRequest(ocrRequest *OcrRequest, _ *WorkerConfig)
 	ocrResult, err := t.processImageFile(tmpFileName, *engineArgs)
 
 	return ocrResult, err
-
 }
 
 func (TesseractEngine) tmpFileFromImageBytes(imgBytes []byte) (string, error) {
-
 	log.Info().Str("component", "OCR_TESSERACT").Msg("Use tesseract with bytes image")
 
 	tmpFileName, err := createTempFileName("")
@@ -152,11 +145,9 @@ func (TesseractEngine) tmpFileFromImageBytes(imgBytes []byte) (string, error) {
 	}
 
 	return tmpFileName, nil
-
 }
 
 func (TesseractEngine) tmpFileFromImageBase64(base64Image string) (string, error) {
-
 	log.Info().Str("component", "OCR_TESSERACT").Msg("Use tesseract with base 64")
 
 	tmpFileName, err := createTempFileName("")
@@ -177,11 +168,9 @@ func (TesseractEngine) tmpFileFromImageBase64(base64Image string) (string, error
 	}
 
 	return tmpFileName, nil
-
 }
 
 func (TesseractEngine) tmpFileFromImageUrl(imgUrl string) (string, error) {
-
 	log.Info().Str("component", "OCR_TESSERACT").Msg("Use tesseract with url")
 
 	tmpFileName, err := createTempFileName("")
@@ -196,11 +185,9 @@ func (TesseractEngine) tmpFileFromImageUrl(imgUrl string) (string, error) {
 	}
 
 	return tmpFileName, nil
-
 }
 
 func (TesseractEngine) processImageFile(inputFilename string, engineArgs TesseractEngineArgs) (OcrResult, error) {
-
 	// if the input filename is /tmp/ocrimage, set the output file basename
 	// to /tmp/ocrimage as well, which will produce /tmp/ocrimage.txt output
 	tmpOutFileBaseName := inputFilename
@@ -244,11 +231,9 @@ func (TesseractEngine) processImageFile(inputFilename string, engineArgs Tessera
 		Text:   string(outBytes),
 		Status: "done",
 	}, nil
-
 }
 
 func findOutfile(outfileBaseName string, fileExtensions []string) (string, error) {
-
 	for _, fileExtension := range fileExtensions {
 
 		outFile := fmt.Sprintf("%v.%v", outfileBaseName, fileExtension)
@@ -262,11 +247,9 @@ func findOutfile(outfileBaseName string, fileExtensions []string) (string, error
 	}
 
 	return "", fmt.Errorf("Could not find outfile.  Basename: %v Extensions: %v", outfileBaseName, fileExtensions)
-
 }
 
 func findAndReadOutfile(outfileBaseName string, fileExtensions []string) (outBytes []byte, outfile string, err error) {
-
 	outfile, err = findOutfile(outfileBaseName, fileExtensions)
 	if err != nil {
 		return nil, "", err
@@ -276,5 +259,4 @@ func findAndReadOutfile(outfileBaseName string, fileExtensions []string) (outByt
 		return nil, "", err
 	}
 	return outBytes, outfile, nil
-
 }
diff --git a/tesseract_engine_test.go b/tesseract_engine_test.go
index 68f752a..804bb57 100644
--- a/tesseract_engine_test.go
+++ b/tesseract_engine_test.go
@@ -11,7 +11,6 @@ import (
 )
 
 func TestTesseractEngineWithRequest(t *testing.T) {
-
 	if testing.Short() {
 		t.Skip("skipping test in short mode.")
 	}
@@ -33,11 +32,9 @@ func TestTesseractEngineWithRequest(t *testing.T) {
 	result, err := engine.ProcessRequest(&ocrRequest, &workerConfig)
 	assert.True(t, err == nil)
 	log.Info().Str("component", "TEST").Interface("result", result)
-
 }
 
 func TestTesseractEngineWithJson(t *testing.T) {
-
 	if testing.Short() {
 		t.Skip("skipping test in short mode.")
 	}
@@ -65,7 +62,6 @@ func TestTesseractEngineWithJson(t *testing.T) {
 		assert.True(t, err == nil)
 		log.Info().Str("component", "TEST").Interface("result", result)
 	}
-
 }
 
 func TestNewTesseractEngineArgs(t *testing.T) {
@@ -79,11 +75,9 @@ func TestNewTesseractEngineArgs(t *testing.T) {
 	assert.Equals(t, engineArgs.configVars["tessedit_char_whitelist"], "0123456789")
 	assert.Equals(t, engineArgs.pageSegMode, "0")
 	assert.Equals(t, engineArgs.lang, "jpn")
-
 }
 
 func TestTesseractEngineWithFile(t *testing.T) {
-
 	if testing.Short() {
 		t.Skip("skipping test in short mode.")
 	}
@@ -93,5 +87,4 @@ func TestTesseractEngineWithFile(t *testing.T) {
 	result, err := engine.processImageFile("docs/testimage.png", engineArgs)
 	assert.True(t, err == nil)
 	log.Info().Str("component", "TEST").Interface("result", result)
-
 }
diff --git a/worker_config.go b/worker_config.go
index d2fa71d..3681eb7 100644
--- a/worker_config.go
+++ b/worker_config.go
@@ -31,7 +31,6 @@ type WorkerConfig struct {
 
 // DefaultWorkerConfig will set the default set of worker parameters which are needed for testing and connecting to a broker
 func DefaultWorkerConfig() WorkerConfig {
-
 	// Reliable: false due to major issues that would completely
 	// wedge the rpc worker.  Setting the buffered channels length
 	// higher would delay the problem, but then it would still happen later.
@@ -52,7 +51,6 @@ func DefaultWorkerConfig() WorkerConfig {
 		NumParallelJobs:   1,
 	}
 	return workerConfig
-
 }
 
 // FlagFunctionWorker will be used as argument type for DefaultConfigFlagsWorkerOverride