una

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: MIT Imports: 13 Imported by: 0

README

una

包含的功能列表

config 配置(toml)
logger 日志(zap)
gin-middleware Gin框架中间件
  • access log
  • recovery
  • request ID
project info 项目基础信息
  • 项目名称
  • 程序名称
  • 项目相关目录:根目录、资源目录等
tools 常用工具函数
  • 文件下载
  • 哈希函数:MD5
  • 文件/目录相关函数:判断文件/目录是否存在
  • AES 加解密
  • 随机数
  • IP 相关函数:ip2long,判断是否在指定 IP 段内

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ProjectName = ""
	ModuleName  = ""
	RootPath    = ""
	ConfigPath  = ""
	LogsPath    = ""
	AssetsPath  = ""
	RunPath     = ""
	TmpPath     = ""
)
View Source
var (
	ErrInvalidParseConfig = errors.New("conf param must be a pointer type")
)

Functions

func AccessLogger

func AccessLogger() *zap.Logger

func Load

func Load(filename string) (*toml.Tree, error)

func Logger

func Logger() *zap.Logger

func Parse

func Parse(filename string, v interface{}) error

func ReloadConfigHandler

func ReloadConfigHandler()

func Setup

func Setup(options ProjectOptions)

func SetupConfig

func SetupConfig(filename string, conf interface{})

func SugarLogger

func SugarLogger() *zap.SugaredLogger

Types

type LoggerOptions

type LoggerOptions struct {
	MaxSize    int
	MaxBackups int
}

type ProjectOptions

type ProjectOptions struct {
	Name           string
	Module         string
	RootPath       string
	Env            string      // 环境标识,dev: 开发环境;test:测试环境;prod:生产环境;
	ConfigFilename string      // 配置文件,若未指定,则默认为 {ConfigPath}/app.{Env}.toml
	Config         interface{} // 接收配置数据的参数

	LoggerOptions       *LoggerOptions
	AccessLoggerOptions *LoggerOptions
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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