MCPcopy Create free account
hub / github.com/cogentcore/core / SaveSettings

Function SaveSettings

core/settings.go:128–138  ·  view source on GitHub ↗

SaveSettings saves the given settings to their [Settings.Filename]. The settings will be encoded in TOML unless they have a .json file extension. If they satisfy the [SettingsSaver] interface, [SettingsSaver.Save] will be used instead. Any non default fields are not saved, following [reflectx.NonDef

(se Settings)

Source from the content-addressed store, hash-verified

126// [SettingsSaver.Save] will be used instead. Any non default
127// fields are not saved, following [reflectx.NonDefaultFields].
128func SaveSettings(se Settings) error {
129 if ss, ok := se.(SettingsSaver); ok {
130 return ss.Save()
131 }
132 fnm := se.Filename()
133 ndf := reflectx.NonDefaultFields(se)
134 if filepath.Ext(fnm) == ".json" {
135 return jsonx.Save(ndf, fnm)
136 }
137 return tomlx.Save(ndf, fnm)
138}
139
140// resetSettings resets the given settings to their default values.
141func resetSettings(se Settings) error {

Callers 5

addPathToFavoritesMethod · 0.85
saveSortSettingsMethod · 0.85
setZoomMethod · 0.85
UpdateSettingsFunction · 0.85
SaveScreenZoomMethod · 0.85

Calls 5

NonDefaultFieldsFunction · 0.92
SaveFunction · 0.92
SaveFunction · 0.92
SaveMethod · 0.65
FilenameMethod · 0.65

Tested by

no test coverage detected