按t录音

This commit is contained in:
zyj
2025-08-01 01:00:23 +08:00
parent 872bf1c018
commit 3e94544443
6 changed files with 306 additions and 192 deletions

36
config/index.go Normal file
View File

@@ -0,0 +1,36 @@
package config
import (
"os"
"gopkg.in/yaml.v3"
)
type DatabaseConfig struct {
Username string `yaml:"username"`
Password string `yaml:"password"`
Host string `yaml:"host"`
Port int `yaml:"port"`
Database string `yaml:"database"`
}
type AppConfig struct {
Port int `yaml:"port"`
Database DatabaseConfig `yaml:"database"`
}
func LoadConfig() (*AppConfig, error) {
// 读取文件内容
data, err := os.ReadFile("config.yaml")
if err != nil {
return nil, err
}
// 解析 YAML
var cfg AppConfig
if err := yaml.Unmarshal(data, &cfg); err != nil {
return nil, err
}
return &cfg, nil
}