conf

package
v0.0.0-...-5259590 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Name string `json:"name" toml:"name"`
}

type Config

type Config struct {
	App *App `json:"app" toml:"app"`
	// [mongodb]
	MongoDB *mongodb `json:"mongodb" toml:"mongodb"`
	// [http]
	Http *Http `json:"http" toml:"http"`
	// [grpc]
	Grpc *Grpc `json:"grpc" toml:"grpc"`
	// 程序接入Jaeger配置
	Jaeger *jaeger `json:"jaeger" toml:"jaeger"`
}

程序的配置对象 config --> object

func C

func C() *Config

把全局对象保护起来

func DefaultConfig

func DefaultConfig() *Config

func LoadConfigFromEnv

func LoadConfigFromEnv() (*Config, error)

func LoadConfigFromToml

func LoadConfigFromToml(path string) (*Config, error)

func (*Config) String

func (c *Config) String() string

格式化成一个json

type Grpc

type Grpc struct {
	Host string `json:"host" toml:"host" env:"GRPC_HOST"`
	Port int    `json:"port" toml:"port" env:"GRPC_PORT"`
}

func NewDefaultGrpc

func NewDefaultGrpc() *Grpc

func (*Grpc) Address

func (h *Grpc) Address() string

type Http

type Http struct {
	Host string `json:"host" toml:"host" env:"HTTP_HOST"`
	Port int    `json:"port" toml:"port" env:"HTTP_PORT"`
}

func (*Http) Address

func (h *Http) Address() string

Jump to

Keyboard shortcuts

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