Code cleanup from emmanuels comment

This commit is contained in:
Ethan Frey 2017-07-22 06:06:14 -04:00
parent 9640547c01
commit 95b16b3830
1 changed files with 6 additions and 10 deletions

View File

@ -48,16 +48,12 @@ func exportSeed(cmd *cobra.Command, args []string) error {
}
func writeSeed(seed certifiers.Seed, path string) (err error) {
var f *os.File
f, err = os.Create(path)
if err == nil {
stream := json.NewEncoder(f)
err = stream.Encode(seed)
f.Close()
}
// we don't write, but this is not an error
if os.IsExist(err) {
return nil
f, err := os.Create(path)
if err != nil {
return errors.WithStack(err)
}
defer f.Close()
stream := json.NewEncoder(f)
err = stream.Encode(seed)
return errors.WithStack(err)
}