From 28abd7c4ddf936e53fe89fa5e63703c11fe55c0c Mon Sep 17 00:00:00 2001 From: skosito Date: Sat, 20 Apr 2024 04:31:16 +0200 Subject: [PATCH] lint --- testutil/network/util.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/testutil/network/util.go b/testutil/network/util.go index 3d1a6a4b8b..746ad331cc 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -2,7 +2,6 @@ package network import ( "encoding/json" - "fmt" "os" "path/filepath" "time" @@ -15,6 +14,7 @@ import ( tmtypes "github.com/cometbft/cometbft/types" tmtime "github.com/cometbft/cometbft/types/time" + tmos "github.com/cometbft/cometbft/libs/os" "github.com/cosmos/cosmos-sdk/server/api" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" srvtypes "github.com/cosmos/cosmos-sdk/server/types" @@ -227,13 +227,16 @@ func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalance } func writeFile(name string, dir string, contents []byte) error { - file := filepath.Join(dir, name) + writePath := filepath.Join(dir) //nolint:gocritic + file := filepath.Join(writePath, name) - if err := os.MkdirAll(dir, 0o755); err != nil { - return fmt.Errorf("could not create directory %q: %w", dir, err) + err := tmos.EnsureDir(writePath, 0o755) // #nosec G301 + if err != nil { + return err } - if err := os.WriteFile(file, contents, 0o644); err != nil { //nolint: gosec + err = os.WriteFile(file, contents, 0600) + if err != nil { return err }