test_viper.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package TestCode
  2. type CommonSettings struct {
  3. UseHttpProxy bool `json:"use_http_proxy"` // 是否使用 http 代理
  4. HttpProxyAddress string `json:"http_proxy_address"` // Http 代理地址,内网
  5. ScanInterval string `json:"scan_interval""` // 一轮字幕扫描的间隔
  6. Threads int `json:"threads"` // 同时扫描的并发数
  7. RunScanAtStartUp bool `json:"run_scan_at_start_up"` // 完成引导设置后,下次运行程序就开始扫描
  8. MoviePaths []string `json:"movie_paths"` // 电影的目录
  9. SeriesPaths []string `json:"series_paths"` // 连续剧的目录
  10. }
  11. //// initConfigure 初始化配置文件实例
  12. //func initConfigure() (*viper.Viper, error) {
  13. //
  14. // v := viper.New()
  15. // v.SetConfigName("ChineseSubFinderConfig") // 设置文件名称(无后缀)
  16. // v.SetConfigType("yaml") // 设置后缀名 {"1.6以后的版本可以不设置该后缀"}
  17. // v.AddConfigPath(".") // 设置文件所在路径
  18. //
  19. // err := v.ReadInConfig()
  20. // if err != nil {
  21. // return nil, errors.New("error reading config:" + err.Error())
  22. // }
  23. //
  24. // return v, nil
  25. //}
  26. //
  27. //func writeConfig(viper *viper.Viper, settings *CommonSettings) error {
  28. // viper.WriteConfig()
  29. //}
  30. //
  31. //// readConfig 读取配置文件
  32. //func readConfig(viper *viper.Viper) (*CommonSettings, error) {
  33. // conf := &CommonSettings{}
  34. // err := viper.Unmarshal(conf)
  35. // if err != nil {
  36. // return nil, err
  37. // }
  38. // return conf, nil
  39. //}