econf

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 9 Imported by: 0

README

## 基于etcd的配置模块

因此,一定要在etcd可连接的情况下new econf,否则会报错

## 使用方法
1. InitConfig() 调用初始化
2. 使用 String() StringDef()等方法直接获取

Documentation

Index

Constants

View Source
const (
	EconfAliveDuration = 5 // 5秒探活时间
)

Variables

View Source
var ErrNil = errors.New("nil or type error")

Functions

func Int

func Int(name string) int

func Int64

func Int64(name string) int64

func Int64Def

func Int64Def(name string, def int64) int64

func IntDef

func IntDef(name string, def int) int

func String

func String(name string) string

获取配置

func StringDef

func StringDef(name, def string) string

Types

type Config

type Config struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(prefix, url, username, password string) *Config

兼容旧的使用方式,不推荐

func (*Config) Int

func (p *Config) Int(name string) int

func (*Config) Int64

func (p *Config) Int64(name string) int64

func (*Config) Int64Def

func (p *Config) Int64Def(name string, def int64) int64

func (*Config) IntDef

func (p *Config) IntDef(name string, def int) int

func (*Config) Map

func (p *Config) Map() (map[string]string, error)

遍历全部配置

func (*Config) String

func (p *Config) String(name string) string

获取配置

func (*Config) StringDef

func (p *Config) StringDef(name, def string) string

type ConfigSvc

type ConfigSvc struct {
	// contains filtered or unexported fields
}

func InitConfig

func InitConfig(prefix, url, username, password string) *ConfigSvc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL