MCPcopy Create free account
hub / github.com/basecamp/hey-cli / loadFile

Method loadFile

internal/config/config.go:147–173  ·  view source on GitHub ↗
(path string, source Source)

Source from the content-addressed store, hash-verified

145}
146
147func (c *Config) loadFile(path string, source Source) error {
148 if path == "" {
149 return nil
150 }
151
152 data, err := os.ReadFile(path)
153 if err != nil {
154 if os.IsNotExist(err) {
155 return nil
156 }
157 return fmt.Errorf("could not read config %s: %w", path, err)
158 }
159
160 var file struct {
161 BaseURL string `json:"base_url"`
162 }
163 if err := json.Unmarshal(data, &file); err != nil {
164 return fmt.Errorf("could not parse config %s: %w", path, err)
165 }
166
167 if file.BaseURL != "" {
168 c.BaseURL = file.BaseURL
169 c.sources["base_url"] = source
170 }
171
172 return nil
173}
174
175func (c *Config) SourceOf(key string) Source {
176 if c.sources == nil {

Callers 1

LoadFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected