1
0

initial commit

This commit is contained in:
konrad
2018-06-10 11:11:41 +02:00
committed by kolaente
commit 479cf54ada
595 changed files with 427508 additions and 0 deletions

22
vendor/github.com/labstack/gommon/LICENSE generated vendored Normal file
View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 labstack
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

29
vendor/github.com/labstack/gommon/bytes/README.md generated vendored Normal file
View File

@ -0,0 +1,29 @@
# Bytes
- Format bytes integer to human readable bytes string.
- Parse human readable bytes string to bytes integer.
## Installation
```go
go get github.com/labstack/gommon/bytes
```
## [Usage](https://github.com/labstack/gommon/blob/master/bytes/bytes_test.go)
### Format
```go
println(bytes.Format(13231323))
```
`12.62MB`
### Parse
```go
b, _ = Parse("2M")
println(b)
```
`2097152`

106
vendor/github.com/labstack/gommon/bytes/bytes.go generated vendored Normal file
View File

@ -0,0 +1,106 @@
package bytes
import (
"fmt"
"regexp"
"strconv"
)
type (
Bytes struct {
}
)
const (
B = 1 << (10 * iota)
KB
MB
GB
TB
PB
EB
)
var (
pattern = regexp.MustCompile(`(?i)^(-?\d+)([KMGTP]B?|B)$`)
global = New()
)
// New creates a Bytes instance.
func New() *Bytes {
return &Bytes{}
}
// Format formats bytes integer to human readable string.
// For example, 31323 bytes will return 30.59KB.
func (*Bytes) Format(b int64) string {
multiple := ""
value := float64(b)
switch {
case b < KB:
return strconv.FormatInt(b, 10) + "B"
case b < MB:
value /= KB
multiple = "KB"
case b < MB:
value /= KB
multiple = "KB"
case b < GB:
value /= MB
multiple = "MB"
case b < TB:
value /= GB
multiple = "GB"
case b < PB:
value /= TB
multiple = "TB"
case b < EB:
value /= PB
multiple = "PB"
}
return fmt.Sprintf("%.02f%s", value, multiple)
}
// Parse parses human readable bytes string to bytes integer.
// For example, 6GB (6G is also valid) will return 6442450944.
func (*Bytes) Parse(value string) (i int64, err error) {
parts := pattern.FindStringSubmatch(value)
if len(parts) < 3 {
return 0, fmt.Errorf("error parsing value=%s", value)
}
bytesString := parts[1]
multiple := parts[2]
bytes, err := strconv.ParseInt(bytesString, 10, 64)
if err != nil {
return
}
switch multiple {
case "B":
return bytes * B, nil
case "K", "KB":
return bytes * KB, nil
case "M", "MB":
return bytes * MB, nil
case "G", "GB":
return bytes * GB, nil
case "T", "TB":
return bytes * TB, nil
case "P", "PB":
return bytes * PB, nil
}
return
}
// Format wraps global Bytes's Format function.
func Format(b int64) string {
return global.Format(b)
}
// Parse wraps global Bytes's Parse function.
func Parse(val string) (int64, error) {
return global.Parse(val)
}

86
vendor/github.com/labstack/gommon/color/README.md generated vendored Normal file
View File

@ -0,0 +1,86 @@
# Color
Style terminal text.
## Installation
```sh
go get github.com/labstack/gommon/color
```
## Windows?
Try [cmder](http://bliker.github.io/cmder) or https://github.com/mattn/go-colorable
## [Usage](https://github.com/labstack/gommon/blob/master/color/color_test.go)
```sh
import github.com/labstack/gommon/color
```
### Colored text
```go
color.Println(color.Black("black"))
color.Println(color.Red("red"))
color.Println(color.Green("green"))
color.Println(color.Yellow("yellow"))
color.Println(color.Blue("blue"))
color.Println(color.Magenta("magenta"))
color.Println(color.Cyan("cyan"))
color.Println(color.White("white"))
color.Println(color.Grey("grey"))
```
![Colored Text](http://i.imgur.com/8RtY1QR.png)
### Colored background
```go
color.Println(color.BlackBg("black background", color.Wht))
color.Println(color.RedBg("red background"))
color.Println(color.GreenBg("green background"))
color.Println(color.YellowBg("yellow background"))
color.Println(color.BlueBg("blue background"))
color.Println(color.MagentaBg("magenta background"))
color.Println(color.CyanBg("cyan background"))
color.Println(color.WhiteBg("white background"))
```
![Colored Background](http://i.imgur.com/SrrS6lw.png)
### Emphasis
```go
color.Println(color.Bold("bold"))
color.Println(color.Dim("dim"))
color.Println(color.Italic("italic"))
color.Println(color.Underline("underline"))
color.Println(color.Inverse("inverse"))
color.Println(color.Hidden("hidden"))
color.Println(color.Strikeout("strikeout"))
```
![Emphasis](http://i.imgur.com/3RSJBbc.png)
### Mix and match
```go
color.Println(color.Green("bold green with white background", color.B, color.WhtBg))
color.Println(color.Red("underline red", color.U))
color.Println(color.Yellow("dim yellow", color.D))
color.Println(color.Cyan("inverse cyan", color.In))
color.Println(color.Blue("bold underline dim blue", color.B, color.U, color.D))
```
![Mix and match](http://i.imgur.com/jWGq9Ca.png)
### Enable/Disable the package
```go
color.Disable()
color.Enable()
```
### New instance
```go
c := New()
c.Green("green")
```

407
vendor/github.com/labstack/gommon/color/color.go generated vendored Normal file
View File

@ -0,0 +1,407 @@
package color
import (
"bytes"
"fmt"
"io"
"os"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
)
type (
inner func(interface{}, []string, *Color) string
)
// Color styles
const (
// Blk Black text style
Blk = "30"
// Rd red text style
Rd = "31"
// Grn green text style
Grn = "32"
// Yel yellow text style
Yel = "33"
// Blu blue text style
Blu = "34"
// Mgn magenta text style
Mgn = "35"
// Cyn cyan text style
Cyn = "36"
// Wht white text style
Wht = "37"
// Gry grey text style
Gry = "90"
// BlkBg black background style
BlkBg = "40"
// RdBg red background style
RdBg = "41"
// GrnBg green background style
GrnBg = "42"
// YelBg yellow background style
YelBg = "43"
// BluBg blue background style
BluBg = "44"
// MgnBg magenta background style
MgnBg = "45"
// CynBg cyan background style
CynBg = "46"
// WhtBg white background style
WhtBg = "47"
// R reset emphasis style
R = "0"
// B bold emphasis style
B = "1"
// D dim emphasis style
D = "2"
// I italic emphasis style
I = "3"
// U underline emphasis style
U = "4"
// In inverse emphasis style
In = "7"
// H hidden emphasis style
H = "8"
// S strikeout emphasis style
S = "9"
)
var (
black = outer(Blk)
red = outer(Rd)
green = outer(Grn)
yellow = outer(Yel)
blue = outer(Blu)
magenta = outer(Mgn)
cyan = outer(Cyn)
white = outer(Wht)
grey = outer(Gry)
blackBg = outer(BlkBg)
redBg = outer(RdBg)
greenBg = outer(GrnBg)
yellowBg = outer(YelBg)
blueBg = outer(BluBg)
magentaBg = outer(MgnBg)
cyanBg = outer(CynBg)
whiteBg = outer(WhtBg)
reset = outer(R)
bold = outer(B)
dim = outer(D)
italic = outer(I)
underline = outer(U)
inverse = outer(In)
hidden = outer(H)
strikeout = outer(S)
global = New()
)
func outer(n string) inner {
return func(msg interface{}, styles []string, c *Color) string {
// TODO: Drop fmt to boost performance?
if c.disabled {
return fmt.Sprintf("%v", msg)
}
b := new(bytes.Buffer)
b.WriteString("\x1b[")
b.WriteString(n)
for _, s := range styles {
b.WriteString(";")
b.WriteString(s)
}
b.WriteString("m")
return fmt.Sprintf("%s%v\x1b[0m", b.String(), msg)
}
}
type (
Color struct {
output io.Writer
disabled bool
}
)
// New creates a Color instance.
func New() (c *Color) {
c = new(Color)
c.SetOutput(colorable.NewColorableStdout())
return
}
// Output returns the output.
func (c *Color) Output() io.Writer {
return c.output
}
// SetOutput sets the output.
func (c *Color) SetOutput(w io.Writer) {
c.output = w
if w, ok := w.(*os.File); !ok || !isatty.IsTerminal(w.Fd()) {
c.disabled = true
}
}
// Disable disables the colors and styles.
func (c *Color) Disable() {
c.disabled = true
}
// Enable enables the colors and styles.
func (c *Color) Enable() {
c.disabled = false
}
// Print is analogous to `fmt.Print` with termial detection.
func (c *Color) Print(args ...interface{}) {
fmt.Fprint(c.output, args...)
}
// Println is analogous to `fmt.Println` with termial detection.
func (c *Color) Println(args ...interface{}) {
fmt.Fprintln(c.output, args...)
}
// Printf is analogous to `fmt.Printf` with termial detection.
func (c *Color) Printf(format string, args ...interface{}) {
fmt.Fprintf(c.output, format, args...)
}
func (c *Color) Black(msg interface{}, styles ...string) string {
return black(msg, styles, c)
}
func (c *Color) Red(msg interface{}, styles ...string) string {
return red(msg, styles, c)
}
func (c *Color) Green(msg interface{}, styles ...string) string {
return green(msg, styles, c)
}
func (c *Color) Yellow(msg interface{}, styles ...string) string {
return yellow(msg, styles, c)
}
func (c *Color) Blue(msg interface{}, styles ...string) string {
return blue(msg, styles, c)
}
func (c *Color) Magenta(msg interface{}, styles ...string) string {
return magenta(msg, styles, c)
}
func (c *Color) Cyan(msg interface{}, styles ...string) string {
return cyan(msg, styles, c)
}
func (c *Color) White(msg interface{}, styles ...string) string {
return white(msg, styles, c)
}
func (c *Color) Grey(msg interface{}, styles ...string) string {
return grey(msg, styles, c)
}
func (c *Color) BlackBg(msg interface{}, styles ...string) string {
return blackBg(msg, styles, c)
}
func (c *Color) RedBg(msg interface{}, styles ...string) string {
return redBg(msg, styles, c)
}
func (c *Color) GreenBg(msg interface{}, styles ...string) string {
return greenBg(msg, styles, c)
}
func (c *Color) YellowBg(msg interface{}, styles ...string) string {
return yellowBg(msg, styles, c)
}
func (c *Color) BlueBg(msg interface{}, styles ...string) string {
return blueBg(msg, styles, c)
}
func (c *Color) MagentaBg(msg interface{}, styles ...string) string {
return magentaBg(msg, styles, c)
}
func (c *Color) CyanBg(msg interface{}, styles ...string) string {
return cyanBg(msg, styles, c)
}
func (c *Color) WhiteBg(msg interface{}, styles ...string) string {
return whiteBg(msg, styles, c)
}
func (c *Color) Reset(msg interface{}, styles ...string) string {
return reset(msg, styles, c)
}
func (c *Color) Bold(msg interface{}, styles ...string) string {
return bold(msg, styles, c)
}
func (c *Color) Dim(msg interface{}, styles ...string) string {
return dim(msg, styles, c)
}
func (c *Color) Italic(msg interface{}, styles ...string) string {
return italic(msg, styles, c)
}
func (c *Color) Underline(msg interface{}, styles ...string) string {
return underline(msg, styles, c)
}
func (c *Color) Inverse(msg interface{}, styles ...string) string {
return inverse(msg, styles, c)
}
func (c *Color) Hidden(msg interface{}, styles ...string) string {
return hidden(msg, styles, c)
}
func (c *Color) Strikeout(msg interface{}, styles ...string) string {
return strikeout(msg, styles, c)
}
// Output returns the output.
func Output() io.Writer {
return global.output
}
// SetOutput sets the output.
func SetOutput(w io.Writer) {
global.SetOutput(w)
}
func Disable() {
global.Disable()
}
func Enable() {
global.Enable()
}
// Print is analogous to `fmt.Print` with termial detection.
func Print(args ...interface{}) {
global.Print(args...)
}
// Println is analogous to `fmt.Println` with termial detection.
func Println(args ...interface{}) {
global.Println(args...)
}
// Printf is analogous to `fmt.Printf` with termial detection.
func Printf(format string, args ...interface{}) {
global.Printf(format, args...)
}
func Black(msg interface{}, styles ...string) string {
return global.Black(msg, styles...)
}
func Red(msg interface{}, styles ...string) string {
return global.Red(msg, styles...)
}
func Green(msg interface{}, styles ...string) string {
return global.Green(msg, styles...)
}
func Yellow(msg interface{}, styles ...string) string {
return global.Yellow(msg, styles...)
}
func Blue(msg interface{}, styles ...string) string {
return global.Blue(msg, styles...)
}
func Magenta(msg interface{}, styles ...string) string {
return global.Magenta(msg, styles...)
}
func Cyan(msg interface{}, styles ...string) string {
return global.Cyan(msg, styles...)
}
func White(msg interface{}, styles ...string) string {
return global.White(msg, styles...)
}
func Grey(msg interface{}, styles ...string) string {
return global.Grey(msg, styles...)
}
func BlackBg(msg interface{}, styles ...string) string {
return global.BlackBg(msg, styles...)
}
func RedBg(msg interface{}, styles ...string) string {
return global.RedBg(msg, styles...)
}
func GreenBg(msg interface{}, styles ...string) string {
return global.GreenBg(msg, styles...)
}
func YellowBg(msg interface{}, styles ...string) string {
return global.YellowBg(msg, styles...)
}
func BlueBg(msg interface{}, styles ...string) string {
return global.BlueBg(msg, styles...)
}
func MagentaBg(msg interface{}, styles ...string) string {
return global.MagentaBg(msg, styles...)
}
func CyanBg(msg interface{}, styles ...string) string {
return global.CyanBg(msg, styles...)
}
func WhiteBg(msg interface{}, styles ...string) string {
return global.WhiteBg(msg, styles...)
}
func Reset(msg interface{}, styles ...string) string {
return global.Reset(msg, styles...)
}
func Bold(msg interface{}, styles ...string) string {
return global.Bold(msg, styles...)
}
func Dim(msg interface{}, styles ...string) string {
return global.Dim(msg, styles...)
}
func Italic(msg interface{}, styles ...string) string {
return global.Italic(msg, styles...)
}
func Underline(msg interface{}, styles ...string) string {
return global.Underline(msg, styles...)
}
func Inverse(msg interface{}, styles ...string) string {
return global.Inverse(msg, styles...)
}
func Hidden(msg interface{}, styles ...string) string {
return global.Hidden(msg, styles...)
}
func Strikeout(msg interface{}, styles ...string) string {
return global.Strikeout(msg, styles...)
}

5
vendor/github.com/labstack/gommon/log/README.md generated vendored Normal file
View File

@ -0,0 +1,5 @@
## WORK IN PROGRESS
### Usage
[log_test.go](log_test.go)

13
vendor/github.com/labstack/gommon/log/color.go generated vendored Normal file
View File

@ -0,0 +1,13 @@
// +build !appengine
package log
import (
"io"
"github.com/mattn/go-colorable"
)
func output() io.Writer {
return colorable.NewColorableStdout()
}

405
vendor/github.com/labstack/gommon/log/log.go generated vendored Normal file
View File

@ -0,0 +1,405 @@
package log
import (
"bytes"
"encoding/json"
"fmt"
"io"
"os"
"path"
"runtime"
"sync"
"time"
"strconv"
"github.com/mattn/go-isatty"
"github.com/valyala/fasttemplate"
"github.com/labstack/gommon/color"
)
type (
Logger struct {
prefix string
level Lvl
output io.Writer
template *fasttemplate.Template
levels []string
color *color.Color
bufferPool sync.Pool
mutex sync.Mutex
}
Lvl uint8
JSON map[string]interface{}
)
const (
DEBUG Lvl = iota + 1
INFO
WARN
ERROR
OFF
)
var (
global = New("-")
defaultHeader = `{"time":"${time_rfc3339_nano}","level":"${level}","prefix":"${prefix}",` +
`"file":"${short_file}","line":"${line}"}`
)
func New(prefix string) (l *Logger) {
l = &Logger{
level: INFO,
prefix: prefix,
template: l.newTemplate(defaultHeader),
color: color.New(),
bufferPool: sync.Pool{
New: func() interface{} {
return bytes.NewBuffer(make([]byte, 256))
},
},
}
l.initLevels()
l.SetOutput(output())
return
}
func (l *Logger) initLevels() {
l.levels = []string{
"-",
l.color.Blue("DEBUG"),
l.color.Green("INFO"),
l.color.Yellow("WARN"),
l.color.Red("ERROR"),
}
}
func (l *Logger) newTemplate(format string) *fasttemplate.Template {
return fasttemplate.New(format, "${", "}")
}
func (l *Logger) DisableColor() {
l.color.Disable()
l.initLevels()
}
func (l *Logger) EnableColor() {
l.color.Enable()
l.initLevels()
}
func (l *Logger) Prefix() string {
return l.prefix
}
func (l *Logger) SetPrefix(p string) {
l.prefix = p
}
func (l *Logger) Level() Lvl {
return l.level
}
func (l *Logger) SetLevel(v Lvl) {
l.level = v
}
func (l *Logger) Output() io.Writer {
return l.output
}
func (l *Logger) SetOutput(w io.Writer) {
l.output = w
if w, ok := w.(*os.File); !ok || !isatty.IsTerminal(w.Fd()) {
l.DisableColor()
}
}
func (l *Logger) Color() *color.Color {
return l.color
}
func (l *Logger) SetHeader(h string) {
l.template = l.newTemplate(h)
}
func (l *Logger) Print(i ...interface{}) {
l.log(0, "", i...)
// fmt.Fprintln(l.output, i...)
}
func (l *Logger) Printf(format string, args ...interface{}) {
l.log(0, format, args...)
}
func (l *Logger) Printj(j JSON) {
l.log(0, "json", j)
}
func (l *Logger) Debug(i ...interface{}) {
l.log(DEBUG, "", i...)
}
func (l *Logger) Debugf(format string, args ...interface{}) {
l.log(DEBUG, format, args...)
}
func (l *Logger) Debugj(j JSON) {
l.log(DEBUG, "json", j)
}
func (l *Logger) Info(i ...interface{}) {
l.log(INFO, "", i...)
}
func (l *Logger) Infof(format string, args ...interface{}) {
l.log(INFO, format, args...)
}
func (l *Logger) Infoj(j JSON) {
l.log(INFO, "json", j)
}
func (l *Logger) Warn(i ...interface{}) {
l.log(WARN, "", i...)
}
func (l *Logger) Warnf(format string, args ...interface{}) {
l.log(WARN, format, args...)
}
func (l *Logger) Warnj(j JSON) {
l.log(WARN, "json", j)
}
func (l *Logger) Error(i ...interface{}) {
l.log(ERROR, "", i...)
}
func (l *Logger) Errorf(format string, args ...interface{}) {
l.log(ERROR, format, args...)
}
func (l *Logger) Errorj(j JSON) {
l.log(ERROR, "json", j)
}
func (l *Logger) Fatal(i ...interface{}) {
l.Print(i...)
os.Exit(1)
}
func (l *Logger) Fatalf(format string, args ...interface{}) {
l.Printf(format, args...)
os.Exit(1)
}
func (l *Logger) Fatalj(j JSON) {
l.Printj(j)
os.Exit(1)
}
func (l *Logger) Panic(i ...interface{}) {
l.Print(i...)
panic(fmt.Sprint(i...))
}
func (l *Logger) Panicf(format string, args ...interface{}) {
l.Printf(format, args...)
panic(fmt.Sprintf(format, args))
}
func (l *Logger) Panicj(j JSON) {
l.Printj(j)
panic(j)
}
func DisableColor() {
global.DisableColor()
}
func EnableColor() {
global.EnableColor()
}
func Prefix() string {
return global.Prefix()
}
func SetPrefix(p string) {
global.SetPrefix(p)
}
func Level() Lvl {
return global.Level()
}
func SetLevel(v Lvl) {
global.SetLevel(v)
}
func Output() io.Writer {
return global.Output()
}
func SetOutput(w io.Writer) {
global.SetOutput(w)
}
func SetHeader(h string) {
global.SetHeader(h)
}
func Print(i ...interface{}) {
global.Print(i...)
}
func Printf(format string, args ...interface{}) {
global.Printf(format, args...)
}
func Printj(j JSON) {
global.Printj(j)
}
func Debug(i ...interface{}) {
global.Debug(i...)
}
func Debugf(format string, args ...interface{}) {
global.Debugf(format, args...)
}
func Debugj(j JSON) {
global.Debugj(j)
}
func Info(i ...interface{}) {
global.Info(i...)
}
func Infof(format string, args ...interface{}) {
global.Infof(format, args...)
}
func Infoj(j JSON) {
global.Infoj(j)
}
func Warn(i ...interface{}) {
global.Warn(i...)
}
func Warnf(format string, args ...interface{}) {
global.Warnf(format, args...)
}
func Warnj(j JSON) {
global.Warnj(j)
}
func Error(i ...interface{}) {
global.Error(i...)
}
func Errorf(format string, args ...interface{}) {
global.Errorf(format, args...)
}
func Errorj(j JSON) {
global.Errorj(j)
}
func Fatal(i ...interface{}) {
global.Fatal(i...)
}
func Fatalf(format string, args ...interface{}) {
global.Fatalf(format, args...)
}
func Fatalj(j JSON) {
global.Fatalj(j)
}
func Panic(i ...interface{}) {
global.Panic(i...)
}
func Panicf(format string, args ...interface{}) {
global.Panicf(format, args...)
}
func Panicj(j JSON) {
global.Panicj(j)
}
func (l *Logger) log(v Lvl, format string, args ...interface{}) {
l.mutex.Lock()
defer l.mutex.Unlock()
buf := l.bufferPool.Get().(*bytes.Buffer)
buf.Reset()
defer l.bufferPool.Put(buf)
_, file, line, _ := runtime.Caller(3)
if v >= l.level || v == 0 {
message := ""
if format == "" {
message = fmt.Sprint(args...)
} else if format == "json" {
b, err := json.Marshal(args[0])
if err != nil {
panic(err)
}
message = string(b)
} else {
message = fmt.Sprintf(format, args...)
}
_, err := l.template.ExecuteFunc(buf, func(w io.Writer, tag string) (int, error) {
switch tag {
case "time_rfc3339":
return w.Write([]byte(time.Now().Format(time.RFC3339)))
case "time_rfc3339_nano":
return w.Write([]byte(time.Now().Format(time.RFC3339Nano)))
case "level":
return w.Write([]byte(l.levels[v]))
case "prefix":
return w.Write([]byte(l.prefix))
case "long_file":
return w.Write([]byte(file))
case "short_file":
return w.Write([]byte(path.Base(file)))
case "line":
return w.Write([]byte(strconv.Itoa(line)))
}
return 0, nil
})
if err == nil {
s := buf.String()
i := buf.Len() - 1
if s[i] == '}' {
// JSON header
buf.Truncate(i)
buf.WriteByte(',')
if format == "json" {
buf.WriteString(message[1:])
} else {
buf.WriteString(`"message":`)
buf.WriteString(strconv.Quote(message))
buf.WriteString(`}`)
}
} else {
// Text header
buf.WriteByte(' ')
buf.WriteString(message)
}
buf.WriteByte('\n')
l.output.Write(buf.Bytes())
}
}
}

12
vendor/github.com/labstack/gommon/log/white.go generated vendored Normal file
View File

@ -0,0 +1,12 @@
// +build appengine
package log
import (
"io"
"os"
)
func output() io.Writer {
return os.Stdout
}

48
vendor/github.com/labstack/gommon/random/random.go generated vendored Normal file
View File

@ -0,0 +1,48 @@
package random
import (
"math/rand"
"strings"
"time"
)
type (
Random struct {
}
)
// Charsets
const (
Uppercase string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Lowercase = "abcdefghijklmnopqrstuvwxyz"
Alphabetic = Uppercase + Lowercase
Numeric = "0123456789"
Alphanumeric = Alphabetic + Numeric
Symbols = "`" + `~!@#$%^&*()-_+={}[]|\;:"<>,./?`
Hex = Numeric + "abcdef"
)
var (
global = New()
)
func New() *Random {
rand.Seed(time.Now().UnixNano())
return new(Random)
}
func (r *Random) String(length uint8, charsets ...string) string {
charset := strings.Join(charsets, "")
if charset == "" {
charset = Alphanumeric
}
b := make([]byte, length)
for i := range b {
b[i] = charset[rand.Int63()%int64(len(charset))]
}
return string(b)
}
func String(length uint8, charsets ...string) string {
return global.String(length, charsets...)
}