cfg, err := config.Load("config.xml") if err != nil { panic(err) }
cfg.GUI.Address = "127.0.0.1:8080" err := cfg.Save("config.xml") if err != nil { panic(err) }
folder := &config.FolderConfiguration{ ID: "folder1", Path: "/path/to/folder1", Devices: []*config.FolderDeviceConfiguration{ &config.FolderDeviceConfiguration{ DeviceID: "device1", FolderPath: "/path/to/folder1/on/device1", }, }, } cfg.Folders = append(cfg.Folders, folder) err := cfg.Save("config.xml") if err != nil { panic(err) }This code adds a new folder to the Syncthing configuration with an ID of `"folder1"`, a path of `"/path/to/folder1"`, and a device configuration for `device1`. Overall, the `github.com/syncthing/syncthing/lib/config` wrapper is a helpful package for Go programmers who need to manipulate the Syncthing configuration file in their programs.