LoadConfigString loads config information from a JSON string.
(s string)
| 59 | |
| 60 | // LoadConfigString loads config information from a JSON string. |
| 61 | func LoadConfigString(s string) *Config { |
| 62 | result := newConfig() |
| 63 | decoder := json.NewDecoder(strings.NewReader(s)) |
| 64 | decoder.UseNumber() |
| 65 | err := decoder.Decode(&result.data) |
| 66 | if err != nil { |
| 67 | log.Fatalf("error parsing config string %s: %s", s, err) |
| 68 | } |
| 69 | return result |
| 70 | } |
| 71 | |
| 72 | func (c *Config) parse(fileName string) error { |
| 73 | jsonFileBytes, err := os.ReadFile(fileName) |