wireguard-dashboard/component/wireguard.go

34 lines
639 B
Go
Raw Normal View History

2024-03-07 17:32:38 +08:00
package component
import (
"gitee.ltd/lxh/logger/log"
"wireguard-dashboard/utils"
)
type wireguard struct{}
func Wireguard() wireguard {
return wireguard{}
}
// Apply
// @description: 应用配置
// @receiver wireguard
// @return err
func (wireguard) Apply(templateFilePath, configFilePath string, data any) (err error) {
parseTemplate, err := utils.Template().Parse(templateFilePath)
if err != nil {
log.Errorf("解析模板信息失败")
return err
}
err = utils.Template().Execute(parseTemplate, data, configFilePath)
if err != nil {
log.Errorf("应用配置失败: %v", err.Error())
return err
}
return nil
}