解决yaml文件部分字段解析不到的问题

This commit is contained in:
mac 2023-02-06 14:35:42 +08:00
parent 334809d657
commit 3464599cd5

View File

@ -2,24 +2,25 @@ package config
import ( import (
"fmt" "fmt"
"github.com/spf13/viper"
"os" "os"
"strings" "strings"
"github.com/spf13/viper"
) )
var config *Config var config *Config
type Config struct { type Config struct {
ChatGpt ChatGptConfig `json:"chatgpt"` ChatGpt ChatGptConfig `json:"chatgpt" mapstructure:"chatgpt" yaml:"chatgpt"`
} }
type ChatGptConfig struct { type ChatGptConfig struct {
Token string `json:"token,omitempty" json:"token,omitempty"` Token string `json:"token,omitempty" mapstructure:"token,omitempty" yaml:"token,omitempty"`
Wechat *string `json:"wechat,omitempty"` Wechat *string `json:"wechat,omitempty" mapstructure:"wechat,omitempty" yaml:"wechat,omitempty"`
WechatKeyword *string `json:"wechat_keyword"` WechatKeyword *string `json:"wechat_keyword" mapstructure:"wechat_keyword" yaml:"wechat_keyword"`
Telegram *string `json:"telegram"` Telegram *string `json:"telegram" mapstructure:"telegram" yaml:"telegram"`
TgWhitelist *string `json:"tg_whitelist"` TgWhitelist *string `json:"tg_whitelist" mapstructure:"tg_whitelist" yaml:"tg_whitelist"`
TgKeyword *string `json:"tg_keyword"` TgKeyword *string `json:"tg_keyword" mapstructure:"tg_keyword" yaml:"tg_keyword"`
} }
func LoadConfig() error { func LoadConfig() error {