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

Function loadOrCreateConfig

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

Source from the content-addressed store, hash-verified

246}
247
248func loadOrCreateConfig(path string) (*Config, error) {
249 data, err := os.ReadFile(path)
250 if err != nil {
251 if os.IsNotExist(err) {
252 return &Config{}, nil
253 }
254 return nil, err
255 }
256 var cfg Config
257 if err := json.Unmarshal(data, &cfg); err != nil {
258 return nil, fmt.Errorf("parse config: %w", err)
259 }
260 return &cfg, nil
261}
262
263// LoadAppConfig loads config from path. Returns nil, nil if file does not exist.
264func LoadAppConfig(path string) (*Config, error) {

Calls

no outgoing calls