go vendor

This commit is contained in:
lealife
2017-11-30 19:55:33 +08:00
parent 2856da6888
commit 0fb92efbf3
670 changed files with 199010 additions and 0 deletions
leanote
vendor
code.google.com
github.com
PuerkitoBio
go-stack
inconshreveable
klauspost
mattn
revel
cmd
config
log15
modules
pathtree
revel
robfig
xeonx
golang.org
x
crypto
net
sys
LICENSEPATENTS
unix
README.mdasm_darwin_386.sasm_darwin_amd64.sasm_darwin_arm.sasm_darwin_arm64.sasm_dragonfly_amd64.sasm_freebsd_386.sasm_freebsd_amd64.sasm_freebsd_arm.sasm_linux_386.sasm_linux_amd64.sasm_linux_arm.sasm_linux_arm64.sasm_linux_mips64x.sasm_linux_mipsx.sasm_linux_ppc64x.sasm_linux_s390x.sasm_netbsd_386.sasm_netbsd_amd64.sasm_netbsd_arm.sasm_openbsd_386.sasm_openbsd_amd64.sasm_solaris_amd64.sbluetooth_linux.goconstants.godirent.goendian_big.goendian_little.goenv_unix.goenv_unset.goflock.goflock_linux_32bit.gogccgo.gogccgo_c.cgccgo_linux_amd64.gogccgo_linux_sparc64.gomkall.shmkerrors.shmkpost.gomksyscall.plmksyscall_solaris.plmksysctl_openbsd.plmksysnum_darwin.plmksysnum_dragonfly.plmksysnum_freebsd.plmksysnum_netbsd.plmksysnum_openbsd.plopenbsd_pledge.gorace.gorace0.gosockcmsg_linux.gosockcmsg_unix.gostr.gosyscall.gosyscall_bsd.gosyscall_darwin.gosyscall_darwin_386.gosyscall_darwin_amd64.gosyscall_darwin_arm.gosyscall_darwin_arm64.gosyscall_dragonfly.gosyscall_dragonfly_amd64.gosyscall_freebsd.gosyscall_freebsd_386.gosyscall_freebsd_amd64.gosyscall_freebsd_arm.gosyscall_linux.gosyscall_linux_386.gosyscall_linux_amd64.gosyscall_linux_amd64_gc.gosyscall_linux_arm.gosyscall_linux_arm64.gosyscall_linux_mips64x.gosyscall_linux_mipsx.gosyscall_linux_ppc64x.gosyscall_linux_s390x.gosyscall_linux_sparc64.gosyscall_netbsd.gosyscall_netbsd_386.gosyscall_netbsd_amd64.gosyscall_netbsd_arm.gosyscall_no_getwd.gosyscall_openbsd.gosyscall_openbsd_386.gosyscall_openbsd_amd64.gosyscall_solaris.gosyscall_solaris_amd64.gosyscall_unix.gosyscall_unix_gc.gotypes_darwin.gotypes_dragonfly.gotypes_freebsd.gotypes_netbsd.gotypes_openbsd.gotypes_solaris.gozerrors_darwin_386.gozerrors_darwin_amd64.gozerrors_darwin_arm.gozerrors_darwin_arm64.gozerrors_dragonfly_amd64.gozerrors_freebsd_386.gozerrors_freebsd_amd64.gozerrors_freebsd_arm.gozerrors_linux_386.gozerrors_linux_amd64.gozerrors_linux_arm.gozerrors_linux_arm64.gozerrors_linux_mips.gozerrors_linux_mips64.gozerrors_linux_mips64le.gozerrors_linux_mipsle.gozerrors_linux_ppc64.gozerrors_linux_ppc64le.gozerrors_linux_s390x.gozerrors_linux_sparc64.gozerrors_netbsd_386.gozerrors_netbsd_amd64.gozerrors_netbsd_arm.gozerrors_openbsd_386.gozerrors_openbsd_amd64.gozerrors_solaris_amd64.gozsyscall_darwin_386.gozsyscall_darwin_amd64.gozsyscall_darwin_arm.gozsyscall_darwin_arm64.gozsyscall_dragonfly_amd64.gozsyscall_freebsd_386.gozsyscall_freebsd_amd64.gozsyscall_freebsd_arm.gozsyscall_linux_386.gozsyscall_linux_amd64.gozsyscall_linux_arm.gozsyscall_linux_arm64.gozsyscall_linux_mips.gozsyscall_linux_mips64.gozsyscall_linux_mips64le.gozsyscall_linux_mipsle.gozsyscall_linux_ppc64.gozsyscall_linux_ppc64le.gozsyscall_linux_s390x.gozsyscall_linux_sparc64.gozsyscall_netbsd_386.gozsyscall_netbsd_amd64.gozsyscall_netbsd_arm.gozsyscall_openbsd_386.gozsyscall_openbsd_amd64.gozsyscall_solaris_amd64.gozsysctl_openbsd.gozsysnum_darwin_386.gozsysnum_darwin_amd64.gozsysnum_darwin_arm.gozsysnum_darwin_arm64.gozsysnum_dragonfly_amd64.gozsysnum_freebsd_386.gozsysnum_freebsd_amd64.gozsysnum_freebsd_arm.gozsysnum_linux_386.gozsysnum_linux_amd64.gozsysnum_linux_arm.gozsysnum_linux_arm64.gozsysnum_linux_mips.gozsysnum_linux_mips64.gozsysnum_linux_mips64le.gozsysnum_linux_mipsle.gozsysnum_linux_ppc64.gozsysnum_linux_ppc64le.gozsysnum_linux_s390x.gozsysnum_linux_sparc64.gozsysnum_netbsd_386.gozsysnum_netbsd_amd64.gozsysnum_netbsd_arm.gozsysnum_openbsd_386.gozsysnum_openbsd_amd64.gozsysnum_solaris_amd64.goztypes_darwin_386.goztypes_darwin_amd64.goztypes_darwin_arm.goztypes_darwin_arm64.goztypes_dragonfly_amd64.goztypes_freebsd_386.goztypes_freebsd_amd64.goztypes_freebsd_arm.goztypes_linux_386.goztypes_linux_amd64.goztypes_linux_arm.goztypes_linux_arm64.goztypes_linux_mips.goztypes_linux_mips64.goztypes_linux_mips64le.goztypes_linux_mipsle.goztypes_linux_ppc64.goztypes_linux_ppc64le.goztypes_linux_s390x.goztypes_linux_sparc64.goztypes_netbsd_386.goztypes_netbsd_amd64.goztypes_netbsd_arm.goztypes_openbsd_386.goztypes_openbsd_amd64.goztypes_solaris_amd64.go
gopkg.in
vendor.json

20
vendor/github.com/xeonx/timeago/LICENSE generated vendored Normal file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Simon HEGE
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.

31
vendor/github.com/xeonx/timeago/README.md generated vendored Normal file

@ -0,0 +1,31 @@
# timeago - A time formatting package
## Install
go get github.com/xeonx/timeago
## Docs
<http://godoc.org/github.com/xeonx/timeago>
## Use
package main
import (
"time"
"github.com/xeonx/timeago"
)
func main() {
t := time.Now().Add(42 * time.Second)
s := timeago.English.Format(t)
//s will contains "less than a minute ago"
//...
}
## Tests
`go test` is used for testing.

263
vendor/github.com/xeonx/timeago/timeago.go generated vendored Normal file

@ -0,0 +1,263 @@
// Copyright 2013 Simon HEGE. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
//timeago allows the formatting of time in terms of fuzzy timestamps.
//For example:
// one minute ago
// 3 years ago
// in 2 minutes
package timeago
import (
"fmt"
"strings"
"time"
)
const (
Day time.Duration = time.Hour * 24
Month time.Duration = Day * 30
Year time.Duration = Day * 365
)
type FormatPeriod struct {
D time.Duration
One string
Many string
}
//Config allows the customization of timeago.
//You may configure string items (language, plurals, ...) and
//maximum allowed duration value for fuzzy formatting.
type Config struct {
PastPrefix string
PastSuffix string
FuturePrefix string
FutureSuffix string
Periods []FormatPeriod
Zero string
Max time.Duration //Maximum duration for using the special formatting.
//DefaultLayout is used if delta is greater than the minimum of last period
//in Periods and Max. It is the desired representation of the date 2nd of
// January 2006.
DefaultLayout string
}
//Predefined english configuration
var English = Config{
PastPrefix: "",
PastSuffix: " ago",
FuturePrefix: "in ",
FutureSuffix: "",
Periods: []FormatPeriod{
FormatPeriod{time.Second, "about a second", "%d seconds"},
FormatPeriod{time.Minute, "about a minute", "%d minutes"},
FormatPeriod{time.Hour, "about an hour", "%d hours"},
FormatPeriod{Day, "one day", "%d days"},
FormatPeriod{Month, "one month", "%d months"},
FormatPeriod{Year, "one year", "%d years"},
},
Zero: "about a second",
Max: 73 * time.Hour,
DefaultLayout: "2006-01-02",
}
var Portuguese = Config{
PastPrefix: "há ",
PastSuffix: "",
FuturePrefix: "daqui a ",
FutureSuffix: "",
Periods: []FormatPeriod{
FormatPeriod{time.Second, "um segundo", "%d segundos"},
FormatPeriod{time.Minute, "um minuto", "%d minutos"},
FormatPeriod{time.Hour, "uma hora", "%d horas"},
FormatPeriod{Day, "um dia", "%d dias"},
FormatPeriod{Month, "um mês", "%d meses"},
FormatPeriod{Year, "um ano", "%d anos"},
},
Zero: "menos de um segundo",
Max: 73 * time.Hour,
DefaultLayout: "02-01-2006",
}
var Chinese = Config{
PastPrefix: "",
PastSuffix: "前",
FuturePrefix: "于 ",
FutureSuffix: "",
Periods: []FormatPeriod{
FormatPeriod{time.Second, "1 秒", "%d 秒"},
FormatPeriod{time.Minute, "1 分钟", "%d 分钟"},
FormatPeriod{time.Hour, "1 小时", "%d 小时"},
FormatPeriod{Day, "1 天", "%d 天"},
FormatPeriod{Month, "1 月", "%d 月"},
FormatPeriod{Year, "1 年", "%d 年"},
},
Zero: "1 秒",
Max: 73 * time.Hour,
DefaultLayout: "2006-01-02",
}
//Predefined french configuration
var French = Config{
PastPrefix: "il y a ",
PastSuffix: "",
FuturePrefix: "dans ",
FutureSuffix: "",
Periods: []FormatPeriod{
FormatPeriod{time.Second, "environ une seconde", "moins d'une minute"},
FormatPeriod{time.Minute, "environ une minute", "%d minutes"},
FormatPeriod{time.Hour, "environ une heure", "%d heures"},
FormatPeriod{Day, "un jour", "%d jours"},
FormatPeriod{Month, "un mois", "%d mois"},
FormatPeriod{Year, "un an", "%d ans"},
},
Zero: "environ une seconde",
Max: 73 * time.Hour,
DefaultLayout: "02/01/2006",
}
//Predefined german configuration
var German = Config{
PastPrefix: "vor ",
PastSuffix: "",
FuturePrefix: "in ",
FutureSuffix: "",
Periods: []FormatPeriod{
FormatPeriod{time.Second, "einer Sekunde", "%d Sekunden"},
FormatPeriod{time.Minute, "einer Minute", "%d Minuten"},
FormatPeriod{time.Hour, "einer Stunde", "%d Stunden"},
FormatPeriod{Day, "einem Tag", "%d Tagen"},
FormatPeriod{Month, "einem Monat", "%d Monaten"},
FormatPeriod{Year, "einem Jahr", "%d Jahren"},
},
Zero: "einer Sekunde",
Max: 73 * time.Hour,
DefaultLayout: "02.01.2006",
}
//Format returns a textual representation of the time value formatted according to the layout
//defined in the Config. The time is compared to time.Now() and is then formatted as a fuzzy
//timestamp (eg. "4 days ago")
func (cfg Config) Format(t time.Time) string {
return cfg.FormatReference(t, time.Now())
}
//FormatReference is the same as Format, but the reference has to be defined by the caller
func (cfg Config) FormatReference(t time.Time, reference time.Time) string {
d := reference.Sub(t)
if (d >= 0 && d >= cfg.Max) || (d < 0 && -d >= cfg.Max) {
return t.Format(cfg.DefaultLayout)
}
return cfg.FormatRelativeDuration(d)
}
//FormatRelativeDuration is the same as Format, but for time.Duration.
//Config.Max is not used in this function, as there is no other alternative.
func (cfg Config) FormatRelativeDuration(d time.Duration) string {
isPast := d >= 0
if d < 0 {
d = -d
}
s, _ := cfg.getTimeText(d, true)
if isPast {
return strings.Join([]string{cfg.PastPrefix, s, cfg.PastSuffix}, "")
} else {
return strings.Join([]string{cfg.FuturePrefix, s, cfg.FutureSuffix}, "")
}
}
//Round the duration d in terms of step.
func round(d time.Duration, step time.Duration, roundCloser bool) time.Duration {
if roundCloser {
return time.Duration(float64(d)/float64(step) + 0.5)
}
return time.Duration(float64(d) / float64(step))
}
//Count the number of parameters in a format string
func nbParamInFormat(f string) int {
return strings.Count(f, "%") - 2*strings.Count(f, "%%")
}
//Convert a duration to a text, based on the current config
func (cfg Config) getTimeText(d time.Duration, roundCloser bool) (string, time.Duration) {
if len(cfg.Periods) == 0 || d < cfg.Periods[0].D {
return cfg.Zero, 0
}
for i, p := range cfg.Periods {
next := p.D
if i+1 < len(cfg.Periods) {
next = cfg.Periods[i+1].D
}
if i+1 == len(cfg.Periods) || d < next {
r := round(d, p.D, roundCloser)
if next != p.D && r == round(next, p.D, roundCloser) {
continue
}
if r == 0 {
return "", d
}
layout := p.Many
if r == 1 {
layout = p.One
}
if nbParamInFormat(layout) == 0 {
return layout, d - r*p.D
}
return fmt.Sprintf(layout, r), d - r*p.D
}
}
return d.String(), 0
}
//NoMax creates an new config without a maximum
func NoMax(cfg Config) Config {
return WithMax(cfg, 9223372036854775807, time.RFC3339)
}
//WithMax creates an new config with special formatting limited to durations less than max.
//Values greater than max will be formatted by the standard time package using the defaultLayout.
func WithMax(cfg Config, max time.Duration, defaultLayout string) Config {
n := cfg
n.Max = max
n.DefaultLayout = defaultLayout
return n
}