ProxySwitcher/util/config.go

27 lines
345 B
Go
Raw Normal View History

2024-08-30 16:08:24 +00:00
package util
import (
"encoding/json"
"io"
"os"
)
2024-08-31 16:04:53 +00:00
func ReadConfigs() ([]*Config, error) {
file, err := os.Open("configs.json")
2024-08-30 16:08:24 +00:00
2024-08-31 16:04:53 +00:00
if err != nil {
return nil, err
2024-08-30 16:08:24 +00:00
}
defer file.Close()
bytes, _ := io.ReadAll(file)
2024-08-31 16:04:53 +00:00
var config []*Config
err = json.Unmarshal(bytes, &config)
2024-08-30 16:08:24 +00:00
2024-08-31 16:04:53 +00:00
if err != nil {
return nil, err
2024-08-30 16:08:24 +00:00
}
return config, nil
}