MCPcopy Create free account
hub / github.com/alibaba/open-code-review / loadOrCreateConfig

Function loadOrCreateConfig

cmd/opencodereview/config_cmd.go:318–331  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

316}
317
318func loadOrCreateConfig(path string) (*Config, error) {
319 data, err := os.ReadFile(path)
320 if err != nil {
321 if os.IsNotExist(err) {
322 return &Config{}, nil
323 }
324 return nil, err
325 }
326 var cfg Config
327 if err := json.Unmarshal(data, &cfg); err != nil {
328 return nil, fmt.Errorf("parse config: %w", err)
329 }
330 return &cfg, nil
331}
332
333// LoadAppConfig loads config from path. Returns nil, nil if file does not exist.
334func LoadAppConfig(path string) (*Config, error) {

Calls

no outgoing calls