37 lines
692 B
Go
37 lines
692 B
Go
// Package apollo...
|
|
//
|
|
// Description : apollo...
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2021-11-24 10:05 下午
|
|
package apollo
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/apolloconfig/agollo/v4"
|
|
"github.com/apolloconfig/agollo/v4/env/config"
|
|
)
|
|
|
|
var (
|
|
// Client 客户端链接
|
|
Client *agollo.Client
|
|
)
|
|
|
|
// Init 初始化apollo客户端
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 10:12 下午 2021/11/24
|
|
func Init(cfg *config.AppConfig) error {
|
|
var err error
|
|
|
|
if Client, err = agollo.StartWithConfig(func() (*config.AppConfig, error) {
|
|
return cfg, nil
|
|
}); err != nil {
|
|
return errors.New("apollo client init fail : " + err.Error())
|
|
}
|
|
return nil
|
|
}
|