Code cleanup from emmanuels comment
This commit is contained in:
parent
9640547c01
commit
95b16b3830
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue