Skip to content

Commit

Permalink
create file func
Browse files Browse the repository at this point in the history
Signed-off-by: Thiago Pagotto <pagottoo@gmail.com>
  • Loading branch information
pagottoo committed Jul 19, 2022
1 parent 3395922 commit 006ed9d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,16 @@ func SetupViper(config *configs.Config) error {

return nil
}

func CreateFile(fileName string, fileContent []byte) error {
file, err := os.Create(fileName)
if err != nil {
return fmt.Errorf("error creating file: %s", err)
}
defer file.Close()
_, err = file.Write(fileContent)
if err != nil {
return fmt.Errorf("unable to write the file: %s", err)
}
return nil
}

0 comments on commit 006ed9d

Please sign in to comment.