wasn't using Format()
This commit is contained in:
parent
2943d44b4a
commit
fe4b47339a
7
load.go
7
load.go
|
@ -34,9 +34,11 @@ func ConfigLoad(pb proto.Message, argname string, protoname string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
fullname = filepath.Join(homeDir, ".config", argname, protoname+".text")
|
fullname = filepath.Join(homeDir, ".config", argname, protoname+".text")
|
||||||
|
|
||||||
if data, err = loadFile(fullname); err != nil {
|
if data, err = loadFile(fullname); err != nil {
|
||||||
log.Warn("config file failed to load", err)
|
log.Warn("config file failed to load", err)
|
||||||
// something went wrong loading the file
|
// set pb.Filename that was attempted
|
||||||
|
SetFilename(pb, fullname)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,9 +52,6 @@ func ConfigLoad(pb proto.Message, argname string, protoname string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// set pb.Filename if it is there in the .proto file
|
|
||||||
SetFilename(pb, fullname)
|
|
||||||
|
|
||||||
log.Infof("ConfigLoad() arg=%s, proto=%s\n", argname, protoname)
|
log.Infof("ConfigLoad() arg=%s, proto=%s\n", argname, protoname)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
11
save.go
11
save.go
|
@ -20,22 +20,19 @@ func ConfigSave(pb proto.Message) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal()
|
// Unmarshal()
|
||||||
data, err := prototext.Marshal(pb)
|
s := prototext.Format(pb)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
dir, name := filepath.Split(fullname)
|
dir, name := filepath.Split(fullname)
|
||||||
if name == "" {
|
if name == "" {
|
||||||
return fmt.Errorf("filename was blank")
|
return fmt.Errorf("filename was blank")
|
||||||
}
|
}
|
||||||
err = os.MkdirAll(dir, os.ModePerm)
|
err := os.MkdirAll(dir, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("ConfigSave() filename=%s %d\n", fullname, len(data))
|
log.Infof("ConfigSave() filename=%s %d\n", fullname, len(s))
|
||||||
return configWrite(fullname, data)
|
return configWrite(fullname, []byte(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
func configWrite(fullname string, data []byte) error {
|
func configWrite(fullname string, data []byte) error {
|
||||||
|
|
Loading…
Reference in New Issue