mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-05 20:11:14 +08:00
* feat: optimize openim reset code * feat: optimize openim reset code * feat: optimize openim reset code * feat: optimize openim reset code * feat: optimize openim reset code * feat: optimize openim reset code * feat: optimize openim reset code * feat: optimize openim reset code
36 lines
657 B
Go
36 lines
657 B
Go
package config
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type Config struct {
|
|
Directory string `yaml:"directory"`
|
|
FileTypes []string `yaml:"file_types"`
|
|
Languages []string `yaml:"languages"`
|
|
}
|
|
|
|
func ParseConfig() (Config, error) {
|
|
var configPath string
|
|
flag.StringVar(&configPath, "config", "./", "Path to config file")
|
|
flag.Parse()
|
|
|
|
var config Config
|
|
if configPath != "" {
|
|
configFile, err := os.ReadFile(configPath)
|
|
if err != nil {
|
|
return Config{}, err
|
|
}
|
|
if err := yaml.Unmarshal(configFile, &config); err != nil {
|
|
return Config{}, err
|
|
}
|
|
} else {
|
|
log.Fatal("Config file must be provided")
|
|
}
|
|
return config, nil
|
|
}
|