From c60d221db42b728a3429760961290dc0895e035f Mon Sep 17 00:00:00 2001 From: shivamsouravjha <2019145@iiitdmj.ac.in> Date: Fri, 8 Nov 2024 11:54:06 +0530 Subject: [PATCH] fix build errors Signed-off-by: shivamsouravjha <2019145@iiitdmj.ac.in> --- services/parse_service.go | 31 ++++--------------------------- utils/helpers/helpers.go | 4 ++-- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/services/parse_service.go b/services/parse_service.go index f3688b9..adee3cd 100644 --- a/services/parse_service.go +++ b/services/parse_service.go @@ -32,14 +32,6 @@ import ( "gopkg.in/mgo.v2/bson" ) -func assert(b bool, mess string) { - green := "\033[32m" - reset := "\033[0m" - if os.Getenv("DEBUG") == "true" { - fmt.Println(green+"Assert PASSED: ", mess+reset) - } -} - func setupCheck() { if len(os.Getenv("CLOUDINARY_URL")) < 5 { panic("Please provied a CLOUDINARY_URL. Run `export CLOUDINARY_URL=your@url` before in your shell for linux and MacOS") @@ -475,14 +467,11 @@ func processXLSXFile(tempInputFile, month string) error { // Document does not exist, so insert it _, err := collection.InsertOne(context.TODO(), document) if err != nil { - log.Fatal(err) + println(err.Error()) } // fmt.Println("Document inserted with ID:", insertResult.InsertedID) } else if err != nil { - log.Fatal(err) - } else { - // Document already exists - // // fmt.Println("Document already exists, skipping insertion.") + println(err.Error()) } } @@ -719,14 +708,11 @@ func processXLSFile(tempInputFile, month string) error { // Document does not exist, so insert it _, err := collection.InsertOne(context.TODO(), document) if err != nil { - log.Fatal(err) + println(err.Error()) } // // fmt.Println("Document inserted with ID:", insertResult.InsertedID) } else if err != nil { - log.Fatal(err) - } else { - // Document already exists - // // fmt.Println("Document already exists, skipping insertion.") + println(err.Error()) } } @@ -805,15 +791,6 @@ func parseDate(dateStr string) string { return "" } -func checkFileExistence(cld *cloudinary.Cloudinary, publicID string) (bool, error) { - assert(cld == nil, "checkFileExistence cld == null") - assert(publicID == "", "checkFileExistence publicId == \"\"") - _, err := cld.Admin.Asset(context.Background(), admin.AssetParams{ - PublicID: publicID, - }) - return !strings.Contains(err.Error(), "not found"), nil -} - func extractFileName(fileURL string) string { fileName := path.Base(fileURL) return strings.TrimSuffix(fileName, path.Ext(fileName)) diff --git a/utils/helpers/helpers.go b/utils/helpers/helpers.go index 13e7629..81c01f1 100644 --- a/utils/helpers/helpers.go +++ b/utils/helpers/helpers.go @@ -3,7 +3,7 @@ package helpers import ( "errors" "fmt" - "io/ioutil" + "io" "math" "net/http" "os" @@ -379,7 +379,7 @@ func FetchPeerData(dataWarehouseID string) ([]map[string]string, error) { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - bodyBytes, _ := ioutil.ReadAll(resp.Body) + bodyBytes, _ := io.ReadAll(resp.Body) bodyString := string(bodyBytes) zap.L().Error("Received non-200 response code", zap.Int("status_code", resp.StatusCode), zap.String("body", bodyString)) return nil, fmt.Errorf("received non-200 response code from peers API: %d", resp.StatusCode)