diff options
| author | Jeff Carr <[email protected]> | 2025-09-10 22:35:37 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-10 22:35:37 -0500 |
| commit | fe4b47339a9c2d15d1acc0700263239b73e21b3d (patch) | |
| tree | 6a7eedd4f45481edc0e5a1cf801ff13aed1a494d | |
| parent | 2943d44b4a8d22af330d6aeb77f8808e8929cc86 (diff) | |
wasn't using Format()
| -rw-r--r-- | load.go | 7 | ||||
| -rw-r--r-- | save.go | 11 |
2 files changed, 7 insertions, 11 deletions
@@ -34,9 +34,11 @@ func ConfigLoad(pb proto.Message, argname string, protoname string) error { } fullname = filepath.Join(homeDir, ".config", argname, protoname+".text") + if data, err = loadFile(fullname); err != nil { 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 } @@ -50,9 +52,6 @@ func ConfigLoad(pb proto.Message, argname string, protoname string) error { 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) return nil } @@ -20,22 +20,19 @@ func ConfigSave(pb proto.Message) error { } // Unmarshal() - data, err := prototext.Marshal(pb) - if err != nil { - return err - } + s := prototext.Format(pb) dir, name := filepath.Split(fullname) if name == "" { return fmt.Errorf("filename was blank") } - err = os.MkdirAll(dir, os.ModePerm) + err := os.MkdirAll(dir, os.ModePerm) if err != nil { return err } - log.Infof("ConfigSave() filename=%s %d\n", fullname, len(data)) - return configWrite(fullname, data) + log.Infof("ConfigSave() filename=%s %d\n", fullname, len(s)) + return configWrite(fullname, []byte(s)) } func configWrite(fullname string, data []byte) error { |
