misc

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Funcs = map[string]interface{}{

	"join": strings.Join,
	"elem": func(i interface{}) interface{} {
		v := reflect.ValueOf(i)
		for v.Kind() == reflect.Ptr {
			v = v.Elem()
		}
		return v.Interface()
	},
	"trimZero": func(v interface{}) interface{} {
		s := fmt.Sprint(v)
		if s == "0" {
			return ""
		}
		return s
	},
	"trimPrefix": func(s, prefix string) string {
		return strings.TrimPrefix(s, prefix)
	},
}
View Source
var Options = &struct {
	DockerEndpoint   string
	DockerAPIVersion string
	DBType           string
	DBAddress        string
	AuthTimeout      time.Duration
}{
	DBType:      "mongo",
	DBAddress:   "localhost:27017/swirl",
	AuthTimeout: 30 * time.Minute,
}

Options holds custom options of swirl.

View Source
var TimeZones = []struct {
	Name   string
	Offset int32 // seconds east of UTC
}{
	{"GMT", 0},
	{"GMT+12", 12 * 60 * 60},
	{"GMT+11", 11 * 60 * 60},
	{"GMT+10", 10 * 60 * 60},
	{"GMT+9", 9 * 60 * 60},
	{"GMT+8(Asia/Shanghai)", 8 * 60 * 60},
	{"GMT+7", 7 * 60 * 60},
	{"GMT+6", 6 * 60 * 60},
	{"GMT+5", 5 * 60 * 60},
	{"GMT+4", 4 * 60 * 60},
	{"GMT+3", 3 * 60 * 60},
	{"GMT+2", 2 * 60 * 60},
	{"GMT+1", 1 * 60 * 60},
	{"GMT-1", -1 * 60 * 60},
	{"GMT-2", -2 * 60 * 60},
	{"GMT-3", -3 * 60 * 60},
	{"GMT-4", -4 * 60 * 60},
	{"GMT-5", -5 * 60 * 60},
	{"GMT-6", -6 * 60 * 60},
	{"GMT-7", -7 * 60 * 60},
	{"GMT-8", -8 * 60 * 60},
	{"GMT-9", -9 * 60 * 60},
	{"GMT-10", -10 * 60 * 60},
	{"GMT-11", -11 * 60 * 60},
	{"GMT-12", -12 * 60 * 60},
}

TimeZones holds some commonly used time-zones.

Functions

func BindOptions

func BindOptions()

BindOptions binds options to environment variables.

func FormatTime

func FormatTime(offset int32) func(t time.Time) string

func JSONIndent

func JSONIndent(raw []byte) (s string, err error)

func Message

func Message(lang string) func(key string, args ...interface{}) string

func NewID

func NewID() string

func Page

func Page(count, pageIndex, pageSize int) (start, end int)

Types

This section is empty.

Jump to

Keyboard shortcuts

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