Better interface for writeconfig

This commit is contained in:
Imbus 2024-02-27 23:11:27 +01:00
parent 9d6cddb724
commit 06632c16da
2 changed files with 3 additions and 3 deletions

View file

@ -22,7 +22,7 @@ type Config struct {
}
// WriteConfigToFile writes a Config to a file
func WriteConfigToFile(c *Config, filename string) error {
func (c *Config) WriteConfigToFile(filename string) error {
f, err := os.Create(filename)
if err != nil {
return err

View file

@ -26,7 +26,7 @@ func TestNewConfig(t *testing.T) {
func TestWriteConfig(t *testing.T) {
c := NewConfig()
err := WriteConfigToFile(c, "test.toml")
err := c.WriteConfigToFile("test.toml")
if err != nil {
t.Errorf("Expected no error, got %s", err)
}
@ -37,7 +37,7 @@ func TestWriteConfig(t *testing.T) {
func TestReadConfig(t *testing.T) {
c := NewConfig()
err := WriteConfigToFile(c, "test.toml")
err := c.WriteConfigToFile("test.toml")
if err != nil {
t.Errorf("Expected no error, got %s", err)
}