1 Star 0 Fork 0

天雨流芳 / go-micro-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
options.go 966 Bytes
一键复制 编辑 原始数据 按行查看 历史
天雨流芳 提交于 2024-03-26 20:01 . consul的服务注册
package registry
import (
"errors"
"github.com/spf13/pflag"
)
// RegistryOptions 注册中心的配置对象
type RegistryOptions struct {
// Address , registry center host and port ,like 127.0.0.1:8500
Address string `mapstructure:"address" json:"address,omitempty"`
// Scheme , like http or https
Scheme string `mapstructure:"scheme" json:"scheme,omitempty"`
// Tags
Tags []string `mapstructure:"tags" json:"tags,omitempty"`
}
func NewRegistryOptions() *RegistryOptions {
return &RegistryOptions{
Address: "127.0.0.1:8500",
Scheme: "http",
}
}
func (o *RegistryOptions) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.Address, "registry.address", o.Address, "registry address .")
fs.StringVar(&o.Scheme, "registry.scheme", o.Scheme, "registry scheme.")
}
func (o *RegistryOptions) Validate() error {
if o.Address == "" {
return errors.New("address is empty")
}
if o.Scheme == "" {
return errors.New("scheme is empty")
}
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tylf2018/go-micro-framework.git
git@gitee.com:tylf2018/go-micro-framework.git
tylf2018
go-micro-framework
go-micro-framework
4cc90ded505a

搜索帮助

344bd9b3 5694891 D2dac590 5694891