common

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Author = "陌竹"
	Email  = "mozhu233@outlook.com"
)
View Source
const CONFIG_FILE = "config.yaml"

Variables

View Source
var (
	DebugMode bool   = false
	Mode      string = "dev"
)
View Source
var (
	// ConfigName -
	ConfigName = "config.yaml"
)

Functions

func CompletionCommand

func CompletionCommand() *cobra.Command

func GetFileBytes

func GetFileBytes(path string) ([]byte, error)

func GetFileOrPipe added in v0.1.3

func GetFileOrPipe(args []string) ([]byte, error)

func GetFileString

func GetFileString(path string) (string, error)

func GetFirstArg

func GetFirstArg(args []string) (string, error)

GetFirstArg -

func LoadConfig

func LoadConfig() (err error)

LoadConfig -

func Output

func Output(s string) error

Output -

func OutputBytes added in v0.1.3

func OutputBytes(s []byte) error

OutputBytes -

func TableOutput

func TableOutput(data []map[int]string, header_footer ...[]string) string

TableOutput func(data []map[int]string, header,footer []string)

func TableOutputV2

func TableOutputV2(datas [][]*simpletable.Cell, header_footer ...[]*simpletable.Cell) string

func TemplateConfig

func TemplateConfig() (data []byte, err error)

TemplateConfig show config template

func VersionCommand

func VersionCommand(name, version, buildID string) *cobra.Command

Types

type Config

type Config struct {
	MySQL  MySQLConfig  `yaml:"mysql"`
	Redis  RedisConfig  `yaml:"redis"`
	Server ServerConfig `yaml:"server"`
	DNS    DNSConfig    `yaml:"dns"`
	Jwt    JWTConfig    `yaml:"jwt"`
	WeChat WeChatConfig `yaml:"wechat"`
	Qiniu  QiniuConfig  `yaml:"qiniu"`
	QQ     QQConfig     `yaml:"qq"`
	Mail   MailConfig   `yaml:"mail"`
}
var Conf Config

func GetConfig

func GetConfig() *Config

type DNSConfig

type DNSConfig struct {
	Domain  string `yaml:"domain"`
	Host    string `yaml:"host"`
	Port    int    `yaml:"port"`
	Timeout int    `yaml:"timeout"`
	TTL     int    `yaml:"ttl"`
}

type JWTConfig

type JWTConfig struct {
	Secret  string `yaml:"secret"`
	Expires int    `yaml:"expires"`
}

type MailConfig

type MailConfig struct {
	User string `yaml:"user"`
	Stmp struct {
		Host string `yaml:"host"`
		Port int    `yaml:"port"`
		Pass string `yaml:"pass"`
	} `yaml:"stmp"`
	AliDirect struct {
		Region string `yaml:"region"`
		Access string `yaml:"access"`
		Secret string `yaml:"secret"`
	} `yaml:"alidirect"`
}

type MySQLConfig

type MySQLConfig struct {
	Host    string `yaml:"host"`
	User    string `yaml:"user"`
	Pass    string `yaml:"pass"`
	Name    string `yaml:"name"`
	Charset string `yaml:"charset"`
}

type QQConfig

type QQConfig struct {
	Appid  string `yaml:"appid"`
	Secret string `yaml:"secret"`
	Token  string `yaml:"token"`
}

type QiniuConfig

type QiniuConfig struct {
	Access string `yaml:"access"`
	Secret string `yaml:"secret"`
	Bucket string `yaml:"bucket"`
}

type RedisConfig

type RedisConfig struct {
	Host string `yaml:"host"`
	Port int    `yaml:"port"`
	Pass string `yaml:"pass"`
	Db   int    `yaml:"db"`
}

type ServerConfig

type ServerConfig struct {
	Host string `yaml:"host"`
	Port int    `yaml:"port"`
}

type WeChatConfig

type WeChatConfig struct {
	AppID     string `yaml:"appid"`
	AppSecret string `yaml:"secret"`
	Token     string `yaml:"token"`
	AesKey    string `yaml:"aeskey"`
	WeChatDb  int    `yaml:"wxdb"`
}

Jump to

Keyboard shortcuts

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