goutils

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: MIT Imports: 14 Imported by: 1

README

goutils

Go Utils

常用功能放在goutils包 大的模块功能放在子包内

go mod tidy

go get -u github.com/BurntSushi/toml
go get -u go.mongodb.org/mongo-driver

go list -m -json all
git tag -a v0.0.2 -m 'goutils-v0.0.2'
git push origin --tags

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Fmt = fmt.Sprintf

Fmt shorthand, XXX DEPRECATED

Functions

func DebugPrintInfo added in v0.0.4

func DebugPrintInfo(v reflect.Value)

func DeepCopy

func DeepCopy(dst, src interface{}) error

深拷贝

func DefaultDataDir added in v0.0.4

func DefaultDataDir() string

DefaultDataDir is the default data directory

func EnsureDir added in v0.0.4

func EnsureDir(dir string, mode os.FileMode) error

func Exit added in v0.0.4

func Exit(s string)

exit app

func HomeDir added in v0.0.4

func HomeDir() string

func Inject added in v0.0.4

func Inject(obj interface{}, key string, val interface{}) error

反射注入(struct 结构体)

func IsFileExist added in v0.0.4

func IsFileExist(path string) bool

file and folder

func IsFileNotExist added in v0.0.4

func IsFileNotExist(path string) bool

file and folder

func MustWriteFile added in v0.0.4

func MustWriteFile(filePath string, contents []byte, mode os.FileMode)

func RegisterCustomValidateType added in v0.0.4

func RegisterCustomValidateType(fn validator.CustomTypeFunc, types ...interface{})

func Rootify added in v0.0.4

func Rootify(path, root string) string

helper function to make dir creation independent of root dir

func TrapSignal added in v0.0.4

func TrapSignal(cb func())

TrapSignal catches the SIGTERM and executes cb function. After that it exits with code 1.

func Validate added in v0.0.4

func Validate(obj interface{}, tags ...string) error

func WriteFile added in v0.0.4

func WriteFile(filePath string, contents []byte, mode os.FileMode) error

Types

type Message added in v0.0.4

type Message struct {
	Code int         `json:"code"`
	Text string      `json:"text,omitempty"`
	Data interface{} `json:"data,omitempty"`
}

func NewMessage added in v0.0.4

func NewMessage(code int, text string, data interface{}) *Message

type Msg added in v0.0.4

type Msg = Message

Directories

Path Synopsis
database
mongodb
Created by LonelyPale at 2019-12-06
Created by LonelyPale at 2019-12-06

Jump to

Keyboard shortcuts

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