mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-26 12:41:45 +00:00
27 lines
383 B
Go
27 lines
383 B
Go
package util
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
func ReadConfigs() ([]Config, error) {
|
|
file, readErr := os.Open("configs.json")
|
|
|
|
if readErr != nil {
|
|
return nil, readErr
|
|
}
|
|
defer file.Close()
|
|
|
|
bytes, _ := io.ReadAll(file)
|
|
|
|
var config []Config
|
|
unmarshalErr := json.Unmarshal(bytes, &config)
|
|
|
|
if unmarshalErr != nil {
|
|
return nil, unmarshalErr
|
|
}
|
|
return config, nil
|
|
}
|