Fixed Write bugs

This should address a fix #93 and #94
This has not been addressed in any tests.
pull/95/head
orxobo 2020-02-11 17:05:34 +10:00 committed by GitHub
parent b09de681dc
commit dbcf4b53b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

@ -147,15 +147,20 @@ func Exec(filenames []string, cmd string, cmdArgs []string) error {
// Write serializes the given environment and writes it to a file
func Write(envMap map[string]string, filename string) error {
content, error := Marshal(envMap)
if error != nil {
return error
content, err := Marshal(envMap)
if err != nil {
return err
}
file, error := os.Create(filename)
if error != nil {
return error
file, err := os.Create(filename)
if err != nil {
return err
}
_, err := file.WriteString(content)
defer file.Close()
_, err = file.WriteString(content)
if err != nil {
return err
}
file.Sync()
return err
}