MCPcopy Create free account
hub / github.com/SamNet-dev/snix / writeYAML

Function writeYAML

tui/profiles.go:195–211  ·  view source on GitHub ↗

writeYAML serialises cfg to path atomically (tmp file + rename).

(path string, cfg *config.Config)

Source from the content-addressed store, hash-verified

193
194// writeYAML serialises cfg to path atomically (tmp file + rename).
195func writeYAML(path string, cfg *config.Config) error {
196 tmp := path + ".tmp"
197 f, err := os.Create(tmp)
198 if err != nil {
199 return err
200 }
201 enc := yaml.NewEncoder(f)
202 enc.SetIndent(2)
203 if err := enc.Encode(cfg); err != nil {
204 f.Close()
205 os.Remove(tmp)
206 return err
207 }
208 enc.Close()
209 f.Close()
210 return os.Rename(tmp, path)
211}

Callers 3

saveToProfileMethod · 0.85
setActiveMethod · 0.85
persistMethod · 0.85

Calls 2

RemoveMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected