From f7990873807f7712de0e19a0697adc68d4f80275 Mon Sep 17 00:00:00 2001 From: "jan.hajek@zerops.io" Date: Fri, 5 Apr 2024 13:43:17 +0200 Subject: [PATCH] fix tests --- Makefile | 11 ++++++++++- src/storage/handler.go | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 9c52e7e5..f15fda0c 100644 --- a/Makefile +++ b/Makefile @@ -10,4 +10,13 @@ test: lint: GOOS=darwin GOARCH=arm64 gomodrun golangci-lint run ./cmd/... ./src/... --verbose GOOS=linux GOARCH=amd64 gomodrun golangci-lint run ./cmd/... ./src/... --verbose - GOOS=windows GOARCH=amd64 gomodrun golangci-lint run ./cmd/... ./src/... --verbose \ No newline at end of file + GOOS=windows GOARCH=amd64 gomodrun golangci-lint run ./cmd/... ./src/... --verbose + +build-for-windows-amd: + GOOS=windows GOARCH=amd64 go build -o bin/zcli.exe cmd/zcli/main.go + +build-for-linux-amd: + GOOS=linux GOARCH=amd64 go build -o bin/zcli cmd/zcli/main.go + +build-for-darwin-arm: + GOOS=darwin GOARCH=arm64 go build -o bin/zcli cmd/zcli/main.go diff --git a/src/storage/handler.go b/src/storage/handler.go index 8fe11f0f..2110ceac 100644 --- a/src/storage/handler.go +++ b/src/storage/handler.go @@ -84,15 +84,11 @@ func (h *Handler[T]) save(data T) error { }(); err != nil { return err } - if err := os.Remove(h.config.FilePath); err != nil { - return errors.WithStack(err) - } + os.Remove(h.config.FilePath) + defer os.Remove(h.config.FilePath + ".new") if err := os.Rename(h.config.FilePath+".new", h.config.FilePath); err != nil { return errors.WithStack(err) } - if err := os.Remove(h.config.FilePath + ".new"); err != nil { - return errors.WithStack(err) - } return nil }