forked from lug/matterbridge
Update dependencies and go1.18 (#1873)
* Update dependencies and go1.18 * Exclude unnecessary linters and update build to go1.18
This commit is contained in:
12
vendor/github.com/SevereCloud/vksdk/v2/api/api.go
generated
vendored
12
vendor/github.com/SevereCloud/vksdk/v2/api/api.go
generated
vendored
@@ -203,10 +203,13 @@ func buildQuery(sliceParams ...Params) (context.Context, url.Values) {
|
||||
|
||||
for _, params := range sliceParams {
|
||||
for key, value := range params {
|
||||
if key != ":context" {
|
||||
query.Set(key, FmtValue(value, 0))
|
||||
} else {
|
||||
switch key {
|
||||
case "access_token":
|
||||
continue
|
||||
case ":context":
|
||||
ctx = value.(context.Context)
|
||||
default:
|
||||
query.Set(key, FmtValue(value, 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,6 +258,9 @@ func (vk *VK) DefaultHandler(method string, sliceParams ...Params) (Response, er
|
||||
acceptEncoding = "zstd"
|
||||
}
|
||||
|
||||
token := sliceParams[len(sliceParams)-1]["access_token"].(string)
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
|
||||
req.Header.Set("User-Agent", vk.UserAgent)
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
|
||||
48
vendor/github.com/SevereCloud/vksdk/v2/api/apps.go
generated
vendored
48
vendor/github.com/SevereCloud/vksdk/v2/api/apps.go
generated
vendored
@@ -4,6 +4,14 @@ import (
|
||||
"github.com/SevereCloud/vksdk/v2/object"
|
||||
)
|
||||
|
||||
// AppsAddUsersToTestingGroup method.
|
||||
//
|
||||
// https://vk.com/dev/apps.addUsersToTestingGroup
|
||||
func (vk *VK) AppsAddUsersToTestingGroup(params Params) (response int, err error) {
|
||||
err = vk.RequestUnmarshal("apps.addUsersToTestingGroup", &response, params)
|
||||
return
|
||||
}
|
||||
|
||||
// AppsDeleteAppRequests deletes all request notifications from the current app.
|
||||
//
|
||||
// https://vk.com/dev/apps.deleteAppRequests
|
||||
@@ -140,6 +148,33 @@ func (vk *VK) AppsGetScore(params Params) (response string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// AppsGetTestingGroupsResponse struct.
|
||||
type AppsGetTestingGroupsResponse []object.AppsTestingGroup
|
||||
|
||||
// AppsGetTestingGroups method.
|
||||
//
|
||||
// https://vk.com/dev/apps.getTestingGroups
|
||||
func (vk *VK) AppsGetTestingGroups(params Params) (response AppsGetTestingGroupsResponse, err error) {
|
||||
err = vk.RequestUnmarshal("apps.getTestingGroups", &response, params)
|
||||
return
|
||||
}
|
||||
|
||||
// AppsRemoveTestingGroup method.
|
||||
//
|
||||
// https://vk.com/dev/apps.removeTestingGroup
|
||||
func (vk *VK) AppsRemoveTestingGroup(params Params) (response int, err error) {
|
||||
err = vk.RequestUnmarshal("apps.removeTestingGroup", &response, params)
|
||||
return
|
||||
}
|
||||
|
||||
// AppsRemoveUsersFromTestingGroups method.
|
||||
//
|
||||
// https://vk.com/dev/apps.removeUsersFromTestingGroups
|
||||
func (vk *VK) AppsRemoveUsersFromTestingGroups(params Params) (response int, err error) {
|
||||
err = vk.RequestUnmarshal("apps.removeUsersFromTestingGroups", &response, params)
|
||||
return
|
||||
}
|
||||
|
||||
// AppsSendRequest sends a request to another user in an app that uses VK authorization.
|
||||
//
|
||||
// https://vk.com/dev/apps.sendRequest
|
||||
@@ -147,3 +182,16 @@ func (vk *VK) AppsSendRequest(params Params) (response int, err error) {
|
||||
err = vk.RequestUnmarshal("apps.sendRequest", &response, params)
|
||||
return
|
||||
}
|
||||
|
||||
// AppsUpdateMetaForTestingGroupResponse struct.
|
||||
type AppsUpdateMetaForTestingGroupResponse struct {
|
||||
GroupID int `json:"group_id"`
|
||||
}
|
||||
|
||||
// AppsUpdateMetaForTestingGroup method.
|
||||
//
|
||||
// https://vk.com/dev/apps.updateMetaForTestingGroup
|
||||
func (vk *VK) AppsUpdateMetaForTestingGroup(params Params) (response AppsUpdateMetaForTestingGroupResponse, err error) {
|
||||
err = vk.RequestUnmarshal("apps.updateMetaForTestingGroup", &response, params)
|
||||
return
|
||||
}
|
||||
|
||||
6
vendor/github.com/SevereCloud/vksdk/v2/api/errors.go
generated
vendored
6
vendor/github.com/SevereCloud/vksdk/v2/api/errors.go
generated
vendored
@@ -622,6 +622,12 @@ const (
|
||||
// Anonymous token is invalid.
|
||||
ErrAnonymousTokenInvalid ErrorType = 1116
|
||||
|
||||
// Access token has expired.
|
||||
ErrAuthAccessTokenHasExpired ErrorType = 1117
|
||||
|
||||
// Anonymous token ip mismatch.
|
||||
ErrAuthAnonymousTokenIPMismatch ErrorType = 1118
|
||||
|
||||
// Invalid document id.
|
||||
ErrParamDocID ErrorType = 1150
|
||||
|
||||
|
||||
22
vendor/github.com/SevereCloud/vksdk/v2/api/messages.go
generated
vendored
22
vendor/github.com/SevereCloud/vksdk/v2/api/messages.go
generated
vendored
@@ -116,6 +116,14 @@ func (vk *VK) MessagesEditChat(params Params) (response int, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// MessagesForceCallFinish method.
|
||||
//
|
||||
// https://vk.com/dev/messages.forceCallFinish
|
||||
func (vk *VK) MessagesForceCallFinish(params Params) (response int, err error) {
|
||||
err = vk.RequestUnmarshal("messages.forceCallFinish", &response, params)
|
||||
return
|
||||
}
|
||||
|
||||
// MessagesGetByConversationMessageIDResponse struct.
|
||||
type MessagesGetByConversationMessageIDResponse struct {
|
||||
Count int `json:"count"`
|
||||
@@ -633,6 +641,20 @@ func (vk *VK) MessagesSetChatPhoto(params Params) (response MessagesSetChatPhoto
|
||||
return
|
||||
}
|
||||
|
||||
// MessagesStartCallResponse struct.
|
||||
type MessagesStartCallResponse struct {
|
||||
JoinLink string `json:"join_link"`
|
||||
CallID string `json:"call_id"`
|
||||
}
|
||||
|
||||
// MessagesStartCall method.
|
||||
//
|
||||
// https://vk.com/dev/messages.startCall
|
||||
func (vk *VK) MessagesStartCall(params Params) (response MessagesStartCallResponse, err error) {
|
||||
err = vk.RequestUnmarshal("messages.startCall", &response, params)
|
||||
return
|
||||
}
|
||||
|
||||
// MessagesUnpin messages.unpin.
|
||||
//
|
||||
// https://vk.com/dev/messages.unpin
|
||||
|
||||
2
vendor/github.com/SevereCloud/vksdk/v2/doc.go
generated
vendored
2
vendor/github.com/SevereCloud/vksdk/v2/doc.go
generated
vendored
@@ -7,6 +7,6 @@ package vksdk
|
||||
|
||||
// Module constants.
|
||||
const (
|
||||
Version = "2.14.1"
|
||||
Version = "2.15.0"
|
||||
API = "5.131"
|
||||
)
|
||||
|
||||
9
vendor/github.com/SevereCloud/vksdk/v2/object/apps.go
generated
vendored
9
vendor/github.com/SevereCloud/vksdk/v2/object/apps.go
generated
vendored
@@ -100,3 +100,12 @@ type AppsScope struct {
|
||||
Name string `json:"name"` // Scope name
|
||||
Title string `json:"title"` // Scope title
|
||||
}
|
||||
|
||||
// AppsTestingGroup testing group description.
|
||||
type AppsTestingGroup struct {
|
||||
GroupID int `json:"group_id"`
|
||||
UserIDs []int `json:"user_ids"`
|
||||
Name string `json:"name"`
|
||||
Webview string `json:"webview"`
|
||||
Platforms []string `json:"platforms"`
|
||||
}
|
||||
|
||||
2
vendor/github.com/d5/tengo/v2/README.md
generated
vendored
2
vendor/github.com/d5/tengo/v2/README.md
generated
vendored
@@ -144,7 +144,7 @@ fmt.Println(res) // "success"
|
||||
- [Interoperability](https://github.com/d5/tengo/blob/master/docs/interoperability.md)
|
||||
- [Tengo CLI](https://github.com/d5/tengo/blob/master/docs/tengo-cli.md)
|
||||
- [Standard Library](https://github.com/d5/tengo/blob/master/docs/stdlib.md)
|
||||
- Syntax Highlighters: [VSCode](https://github.com/lissein/vscode-tengo), [Atom](https://github.com/d5/tengo-atom)
|
||||
- Syntax Highlighters: [VSCode](https://github.com/lissein/vscode-tengo), [Atom](https://github.com/d5/tengo-atom), [Vim](https://github.com/geseq/tengo-vim)
|
||||
- **Why the name Tengo?** It's from [1Q84](https://en.wikipedia.org/wiki/1Q84).
|
||||
|
||||
|
||||
|
||||
9
vendor/github.com/d5/tengo/v2/compiler.go
generated
vendored
9
vendor/github.com/d5/tengo/v2/compiler.go
generated
vendored
@@ -692,12 +692,15 @@ func (c *Compiler) compileAssign(
|
||||
return c.errorf(node, "operator ':=' not allowed with selector")
|
||||
}
|
||||
|
||||
_, isFunc := rhs[0].(*parser.FuncLit)
|
||||
symbol, depth, exists := c.symbolTable.Resolve(ident, false)
|
||||
if op == token.Define {
|
||||
if depth == 0 && exists {
|
||||
return c.errorf(node, "'%s' redeclared in this block", ident)
|
||||
}
|
||||
symbol = c.symbolTable.Define(ident)
|
||||
if isFunc {
|
||||
symbol = c.symbolTable.Define(ident)
|
||||
}
|
||||
} else {
|
||||
if !exists {
|
||||
return c.errorf(node, "unresolved reference '%s'", ident)
|
||||
@@ -718,6 +721,10 @@ func (c *Compiler) compileAssign(
|
||||
}
|
||||
}
|
||||
|
||||
if op == token.Define && !isFunc {
|
||||
symbol = c.symbolTable.Define(ident)
|
||||
}
|
||||
|
||||
switch op {
|
||||
case token.AddAssign:
|
||||
c.emit(node, parser.OpBinaryOp, int(token.Add))
|
||||
|
||||
24
vendor/github.com/gomarkdown/markdown/README.md
generated
vendored
24
vendor/github.com/gomarkdown/markdown/README.md
generated
vendored
@@ -2,9 +2,11 @@
|
||||
|
||||
[](https://pkg.go.dev/github.com/gomarkdown/markdown)
|
||||
|
||||
Package `github.com/gomarkdown/markdown` is a very fast Go library for parsing [Markdown](https://daringfireball.net/projects/markdown/) documents and rendering them to HTML.
|
||||
Package `github.com/gomarkdown/markdown` is a Go library for parsing Markdown text and rendering as HTML.
|
||||
|
||||
It's fast and supports common extensions.
|
||||
It's very fast and supports common extensions.
|
||||
|
||||
Try code examples online: https://replit.com/@kjk1?path=folder/gomarkdown
|
||||
|
||||
## API Docs:
|
||||
|
||||
@@ -15,17 +17,7 @@ It's fast and supports common extensions.
|
||||
|
||||
## Users
|
||||
|
||||
Some tools using this package:
|
||||
|
||||
- https://github.com/MichaelMure/go-term-markdown : markdown renderer for the terminal
|
||||
- https://github.com/artyom/mdserver : web server that serves markdown files
|
||||
- https://github.com/rsdoiel/mkpage : content management system generating static websites
|
||||
- https://github.com/cugu/dashboard : creates a badge dashboard from a yaml file
|
||||
- https://github.com/ieyasu/go-bwiki : simple wiki
|
||||
- https://github.com/romanyx/mdopen : view markdown files in the default browser
|
||||
- https://github.com/ystyle/sqlmanager : a library for manager sql with markdown like beetsql
|
||||
- https://gitlab.com/kendellfab/fazer : library for making templates
|
||||
- https://github.com/blmayer/tasker : a simple task list web app
|
||||
Some tools using this package: https://pkg.go.dev/github.com/gomarkdown/markdown?tab=importedby
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -36,6 +28,8 @@ md := []byte("## markdown document")
|
||||
output := markdown.ToHTML(md, nil, nil)
|
||||
```
|
||||
|
||||
Try it online: https://replit.com/@kjk1/gomarkdown-basic
|
||||
|
||||
## Customizing markdown parser
|
||||
|
||||
Markdown format is loosely specified and there are multiple extensions invented after original specification was created.
|
||||
@@ -57,6 +51,8 @@ md := []byte("markdown text")
|
||||
html := markdown.ToHTML(md, parser, nil)
|
||||
```
|
||||
|
||||
Try it online: https://replit.com/@kjk1/gomarkdown-customized-html-renderer
|
||||
|
||||
## Customizing HTML renderer
|
||||
|
||||
Similarly, HTML renderer can be configured with different [options](https://pkg.go.dev/github.com/gomarkdown/markdown/html#RendererOptions)
|
||||
@@ -77,6 +73,8 @@ md := []byte("markdown text")
|
||||
html := markdown.ToHTML(md, nil, renderer)
|
||||
```
|
||||
|
||||
Try it online: https://replit.com/@kjk1/gomarkdown-customized-html-renderer
|
||||
|
||||
HTML renderer also supports reusing most of the logic and overriding rendering of only specific nodes.
|
||||
|
||||
You can provide [RenderNodeFunc](https://pkg.go.dev/github.com/gomarkdown/markdown/html#RenderNodeFunc) in [RendererOptions](https://pkg.go.dev/github.com/gomarkdown/markdown/html#RendererOptions).
|
||||
|
||||
36
vendor/github.com/gomarkdown/markdown/html/renderer.go
generated
vendored
36
vendor/github.com/gomarkdown/markdown/html/renderer.go
generated
vendored
@@ -133,6 +133,9 @@ type Renderer struct {
|
||||
// if > 0, will strip html tags in Out and Outs
|
||||
DisableTags int
|
||||
|
||||
// TODO: documentation
|
||||
IsSafeURLOverride func(url []byte) bool
|
||||
|
||||
sr *SPRenderer
|
||||
|
||||
documentMatter ast.DocumentMatters // keep track of front/main/back matter.
|
||||
@@ -281,11 +284,16 @@ func isMailto(link []byte) bool {
|
||||
return bytes.HasPrefix(link, []byte("mailto:"))
|
||||
}
|
||||
|
||||
func needSkipLink(flags Flags, dest []byte) bool {
|
||||
func needSkipLink(r *Renderer, dest []byte) bool {
|
||||
flags := r.opts.Flags
|
||||
if flags&SkipLinks != 0 {
|
||||
return true
|
||||
}
|
||||
return flags&Safelink != 0 && !isSafeLink(dest) && !isMailto(dest)
|
||||
isSafeURL := r.IsSafeURLOverride
|
||||
if isSafeURL == nil {
|
||||
isSafeURL = valid.IsSafeURL
|
||||
}
|
||||
return flags&Safelink != 0 && !isSafeURL(dest) && !isMailto(dest)
|
||||
}
|
||||
|
||||
func appendLanguageAttr(attrs []string, info []byte) []string {
|
||||
@@ -481,7 +489,7 @@ func (r *Renderer) linkExit(w io.Writer, link *ast.Link) {
|
||||
// Link writes ast.Link node
|
||||
func (r *Renderer) Link(w io.Writer, link *ast.Link, entering bool) {
|
||||
// mark it but don't link it if it is not a safe link: no smartypants
|
||||
if needSkipLink(r.opts.Flags, link.Destination) {
|
||||
if needSkipLink(r, link.Destination) {
|
||||
r.OutOneOf(w, entering, "<tt>", "</tt>")
|
||||
return
|
||||
}
|
||||
@@ -1226,28 +1234,6 @@ func isListItemTerm(node ast.Node) bool {
|
||||
return ok && data.ListFlags&ast.ListTypeTerm != 0
|
||||
}
|
||||
|
||||
func isSafeLink(link []byte) bool {
|
||||
for _, path := range valid.Paths {
|
||||
if len(link) >= len(path) && bytes.Equal(link[:len(path)], path) {
|
||||
if len(link) == len(path) {
|
||||
return true
|
||||
} else if isAlnum(link[len(path)]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, prefix := range valid.URIs {
|
||||
// TODO: handle unicode here
|
||||
// case-insensitive prefix test
|
||||
if len(link) > len(prefix) && bytes.Equal(bytes.ToLower(link[:len(prefix)]), prefix) && isAlnum(link[len(prefix)]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: move to internal package
|
||||
// Create a url-safe slug for fragments
|
||||
func slugify(in []byte) []byte {
|
||||
|
||||
45
vendor/github.com/gomarkdown/markdown/internal/valid/valid.go
generated
vendored
45
vendor/github.com/gomarkdown/markdown/internal/valid/valid.go
generated
vendored
@@ -1,5 +1,9 @@
|
||||
package valid
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
)
|
||||
|
||||
var URIs = [][]byte{
|
||||
[]byte("http://"),
|
||||
[]byte("https://"),
|
||||
@@ -12,3 +16,44 @@ var Paths = [][]byte{
|
||||
[]byte("./"),
|
||||
[]byte("../"),
|
||||
}
|
||||
|
||||
// TODO: documentation
|
||||
func IsSafeURL(url []byte) bool {
|
||||
nLink := len(url)
|
||||
for _, path := range Paths {
|
||||
nPath := len(path)
|
||||
linkPrefix := url[:nPath]
|
||||
if nLink >= nPath && bytes.Equal(linkPrefix, path) {
|
||||
if nLink == nPath {
|
||||
return true
|
||||
} else if isAlnum(url[nPath]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, prefix := range URIs {
|
||||
// TODO: handle unicode here
|
||||
// case-insensitive prefix test
|
||||
nPrefix := len(prefix)
|
||||
if nLink > nPrefix {
|
||||
linkPrefix := bytes.ToLower(url[:nPrefix])
|
||||
if bytes.Equal(linkPrefix, prefix) && isAlnum(url[nPrefix]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// isAlnum returns true if c is a digit or letter
|
||||
// TODO: check when this is looking for ASCII alnum and when it should use unicode
|
||||
func isAlnum(c byte) bool {
|
||||
return (c >= '0' && c <= '9') || isLetter(c)
|
||||
}
|
||||
|
||||
// isLetter returns true if c is ascii letter
|
||||
func isLetter(c byte) bool {
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
|
||||
}
|
||||
|
||||
35
vendor/github.com/gomarkdown/markdown/parser/inline.go
generated
vendored
35
vendor/github.com/gomarkdown/markdown/parser/inline.go
generated
vendored
@@ -899,7 +899,11 @@ func autoLink(p *Parser, data []byte, offset int) (int, ast.Node) {
|
||||
origData := data
|
||||
data = data[offset-rewind:]
|
||||
|
||||
if !isSafeLink(data) {
|
||||
isSafeURL := p.IsSafeURLOverride
|
||||
if isSafeURL == nil {
|
||||
isSafeURL = valid.IsSafeURL
|
||||
}
|
||||
if !isSafeURL(data) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
@@ -995,35 +999,6 @@ func isEndOfLink(char byte) bool {
|
||||
return isSpace(char) || char == '<'
|
||||
}
|
||||
|
||||
func isSafeLink(link []byte) bool {
|
||||
nLink := len(link)
|
||||
for _, path := range valid.Paths {
|
||||
nPath := len(path)
|
||||
linkPrefix := link[:nPath]
|
||||
if nLink >= nPath && bytes.Equal(linkPrefix, path) {
|
||||
if nLink == nPath {
|
||||
return true
|
||||
} else if isAlnum(link[nPath]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, prefix := range valid.URIs {
|
||||
// TODO: handle unicode here
|
||||
// case-insensitive prefix test
|
||||
nPrefix := len(prefix)
|
||||
if nLink > nPrefix {
|
||||
linkPrefix := bytes.ToLower(link[:nPrefix])
|
||||
if bytes.Equal(linkPrefix, prefix) && isAlnum(link[nPrefix]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// return the length of the given tag, or 0 is it's not valid
|
||||
func tagLength(data []byte) (autolink autolinkType, end int) {
|
||||
var i, j int
|
||||
|
||||
3
vendor/github.com/gomarkdown/markdown/parser/parser.go
generated
vendored
3
vendor/github.com/gomarkdown/markdown/parser/parser.go
generated
vendored
@@ -84,6 +84,9 @@ type Parser struct {
|
||||
// the bottom will be used to fill in the link details.
|
||||
ReferenceOverride ReferenceOverrideFunc
|
||||
|
||||
// TODO: documentation
|
||||
IsSafeURLOverride func(url []byte) bool
|
||||
|
||||
Opts Options
|
||||
|
||||
// after parsing, this is AST root of parsed markdown text
|
||||
|
||||
6
vendor/github.com/google/gops/agent/agent.go
generated
vendored
6
vendor/github.com/google/gops/agent/agent.go
generated
vendored
@@ -120,14 +120,14 @@ func Listen(opts Options) error {
|
||||
return err
|
||||
}
|
||||
|
||||
go listen()
|
||||
go listen(listener)
|
||||
return nil
|
||||
}
|
||||
|
||||
func listen() {
|
||||
func listen(l net.Listener) {
|
||||
buf := make([]byte, 1)
|
||||
for {
|
||||
fd, err := listener.Accept()
|
||||
fd, err := l.Accept()
|
||||
if err != nil {
|
||||
// No great way to check for this, see https://golang.org/issues/4373.
|
||||
if !strings.Contains(err.Error(), "use of closed network connection") {
|
||||
|
||||
4
vendor/github.com/google/gops/internal/internal.go
generated
vendored
4
vendor/github.com/google/gops/internal/internal.go
generated
vendored
@@ -22,8 +22,8 @@ func ConfigDir() (string, error) {
|
||||
return configDir, nil
|
||||
}
|
||||
|
||||
if osUserConfigDir := getOSUserConfigDir(); osUserConfigDir != "" {
|
||||
return filepath.Join(osUserConfigDir, "gops"), nil
|
||||
if userConfigDir, err := os.UserConfigDir(); err == nil {
|
||||
return filepath.Join(userConfigDir, "gops"), nil
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
|
||||
20
vendor/github.com/google/gops/internal/internal_go1_13.go
generated
vendored
20
vendor/github.com/google/gops/internal/internal_go1_13.go
generated
vendored
@@ -1,20 +0,0 @@
|
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build go1.13
|
||||
// +build go1.13
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func getOSUserConfigDir() string {
|
||||
configDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return configDir
|
||||
}
|
||||
12
vendor/github.com/google/gops/internal/internal_lt_go1_13.go
generated
vendored
12
vendor/github.com/google/gops/internal/internal_lt_go1_13.go
generated
vendored
@@ -1,12 +0,0 @@
|
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !go1.13
|
||||
// +build !go1.13
|
||||
|
||||
package internal
|
||||
|
||||
func getOSUserConfigDir() string {
|
||||
return ""
|
||||
}
|
||||
21
vendor/github.com/klauspost/compress/README.md
generated
vendored
21
vendor/github.com/klauspost/compress/README.md
generated
vendored
@@ -17,6 +17,27 @@ This package provides various compression algorithms.
|
||||
|
||||
# changelog
|
||||
|
||||
* June 29, 2022 (v1.15.7)
|
||||
|
||||
* s2: Fix absolute forward seeks https://github.com/klauspost/compress/pull/633
|
||||
* zip: Merge upstream https://github.com/klauspost/compress/pull/631
|
||||
* zip: Re-add zip64 fix https://github.com/klauspost/compress/pull/624
|
||||
* zstd: translate fseDecoder.buildDtable into asm by @WojciechMula in https://github.com/klauspost/compress/pull/598
|
||||
* flate: Faster histograms https://github.com/klauspost/compress/pull/620
|
||||
* deflate: Use compound hcode https://github.com/klauspost/compress/pull/622
|
||||
|
||||
* June 3, 2022 (v1.15.6)
|
||||
* s2: Improve coding for long, close matches https://github.com/klauspost/compress/pull/613
|
||||
* s2c: Add Snappy/S2 stream recompression https://github.com/klauspost/compress/pull/611
|
||||
* zstd: Always use configured block size https://github.com/klauspost/compress/pull/605
|
||||
* zstd: Fix incorrect hash table placement for dict encoding in default https://github.com/klauspost/compress/pull/606
|
||||
* zstd: Apply default config to ZipDecompressor without options https://github.com/klauspost/compress/pull/608
|
||||
* gzhttp: Exclude more common archive formats https://github.com/klauspost/compress/pull/612
|
||||
* s2: Add ReaderIgnoreCRC https://github.com/klauspost/compress/pull/609
|
||||
* s2: Remove sanity load on index creation https://github.com/klauspost/compress/pull/607
|
||||
* snappy: Use dedicated function for scoring https://github.com/klauspost/compress/pull/614
|
||||
* s2c+s2d: Use official snappy framed extension https://github.com/klauspost/compress/pull/610
|
||||
|
||||
* May 25, 2022 (v1.15.5)
|
||||
* s2: Add concurrent stream decompression https://github.com/klauspost/compress/pull/602
|
||||
* s2: Fix final emit oob read crash on amd64 https://github.com/klauspost/compress/pull/601
|
||||
|
||||
10
vendor/github.com/klauspost/compress/huff0/decompress_amd64.go
generated
vendored
10
vendor/github.com/klauspost/compress/huff0/decompress_amd64.go
generated
vendored
@@ -27,10 +27,7 @@ func decompress4x_8b_main_loop_amd64(ctx *decompress4xContext)
|
||||
const fallback8BitSize = 800
|
||||
|
||||
type decompress4xContext struct {
|
||||
pbr0 *bitReaderShifted
|
||||
pbr1 *bitReaderShifted
|
||||
pbr2 *bitReaderShifted
|
||||
pbr3 *bitReaderShifted
|
||||
pbr *[4]bitReaderShifted
|
||||
peekBits uint8
|
||||
out *byte
|
||||
dstEvery int
|
||||
@@ -89,10 +86,7 @@ func (d *Decoder) Decompress4X(dst, src []byte) ([]byte, error) {
|
||||
|
||||
if len(out) > 4*4 && !(br[0].off < 4 || br[1].off < 4 || br[2].off < 4 || br[3].off < 4) {
|
||||
ctx := decompress4xContext{
|
||||
pbr0: &br[0],
|
||||
pbr1: &br[1],
|
||||
pbr2: &br[2],
|
||||
pbr3: &br[3],
|
||||
pbr: &br,
|
||||
peekBits: uint8((64 - d.actualTableLog) & 63), // see: bitReaderShifted.peekBitsFast()
|
||||
out: &out[0],
|
||||
dstEvery: dstEvery,
|
||||
|
||||
666
vendor/github.com/klauspost/compress/huff0/decompress_amd64.s
generated
vendored
666
vendor/github.com/klauspost/compress/huff0/decompress_amd64.s
generated
vendored
@@ -4,45 +4,40 @@
|
||||
// +build amd64,!appengine,!noasm,gc
|
||||
|
||||
// func decompress4x_main_loop_amd64(ctx *decompress4xContext)
|
||||
TEXT ·decompress4x_main_loop_amd64(SB), $8-8
|
||||
TEXT ·decompress4x_main_loop_amd64(SB), $0-8
|
||||
XORQ DX, DX
|
||||
|
||||
// Preload values
|
||||
MOVQ ctx+0(FP), AX
|
||||
MOVBQZX 32(AX), SI
|
||||
MOVQ 40(AX), DI
|
||||
MOVQ DI, BX
|
||||
MOVQ 72(AX), CX
|
||||
MOVQ CX, (SP)
|
||||
MOVQ 48(AX), R8
|
||||
MOVQ 56(AX), R9
|
||||
MOVQ (AX), R10
|
||||
MOVQ 8(AX), R11
|
||||
MOVQ 16(AX), R12
|
||||
MOVQ 24(AX), R13
|
||||
MOVBQZX 8(AX), DI
|
||||
MOVQ 16(AX), SI
|
||||
MOVQ 48(AX), BX
|
||||
MOVQ 24(AX), R9
|
||||
MOVQ 32(AX), R10
|
||||
MOVQ (AX), R11
|
||||
|
||||
// Main loop
|
||||
main_loop:
|
||||
MOVQ BX, DI
|
||||
CMPQ DI, (SP)
|
||||
MOVQ SI, R8
|
||||
CMPQ R8, BX
|
||||
SETGE DL
|
||||
|
||||
// br0.fillFast32()
|
||||
MOVQ 32(R10), R14
|
||||
MOVBQZX 40(R10), R15
|
||||
CMPQ R15, $0x20
|
||||
MOVQ 32(R11), R12
|
||||
MOVBQZX 40(R11), R13
|
||||
CMPQ R13, $0x20
|
||||
JBE skip_fill0
|
||||
MOVQ 24(R10), AX
|
||||
SUBQ $0x20, R15
|
||||
MOVQ 24(R11), AX
|
||||
SUBQ $0x20, R13
|
||||
SUBQ $0x04, AX
|
||||
MOVQ (R10), BP
|
||||
MOVQ (R11), R14
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (AX)(BP*1), BP
|
||||
MOVQ R15, CX
|
||||
SHLQ CL, BP
|
||||
MOVQ AX, 24(R10)
|
||||
ORQ BP, R14
|
||||
MOVL (AX)(R14*1), R14
|
||||
MOVQ R13, CX
|
||||
SHLQ CL, R14
|
||||
MOVQ AX, 24(R11)
|
||||
ORQ R14, R12
|
||||
|
||||
// exhausted = exhausted || (br0.off < 4)
|
||||
CMPQ AX, $0x04
|
||||
@@ -51,57 +46,57 @@ main_loop:
|
||||
|
||||
skip_fill0:
|
||||
// val0 := br0.peekTopBits(peekBits)
|
||||
MOVQ R14, BP
|
||||
MOVQ SI, CX
|
||||
SHRQ CL, BP
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(BP*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br0.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R14
|
||||
ADDB CL, R15
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val1 := br0.peekTopBits(peekBits)
|
||||
MOVQ SI, CX
|
||||
MOVQ R14, BP
|
||||
SHRQ CL, BP
|
||||
MOVQ DI, CX
|
||||
MOVQ R12, R14
|
||||
SHRQ CL, R14
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
MOVW (R9)(BP*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br0.advance(uint8(v1.entry))
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R14
|
||||
ADDB CL, R15
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// these two writes get coalesced
|
||||
// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
MOVW AX, (DI)
|
||||
MOVW AX, (R8)
|
||||
|
||||
// update the bitrader reader structure
|
||||
MOVQ R14, 32(R10)
|
||||
MOVB R15, 40(R10)
|
||||
ADDQ R8, DI
|
||||
// update the bitreader structure
|
||||
MOVQ R12, 32(R11)
|
||||
MOVB R13, 40(R11)
|
||||
ADDQ R9, R8
|
||||
|
||||
// br1.fillFast32()
|
||||
MOVQ 32(R11), R14
|
||||
MOVBQZX 40(R11), R15
|
||||
CMPQ R15, $0x20
|
||||
MOVQ 80(R11), R12
|
||||
MOVBQZX 88(R11), R13
|
||||
CMPQ R13, $0x20
|
||||
JBE skip_fill1
|
||||
MOVQ 24(R11), AX
|
||||
SUBQ $0x20, R15
|
||||
MOVQ 72(R11), AX
|
||||
SUBQ $0x20, R13
|
||||
SUBQ $0x04, AX
|
||||
MOVQ (R11), BP
|
||||
MOVQ 48(R11), R14
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (AX)(BP*1), BP
|
||||
MOVQ R15, CX
|
||||
SHLQ CL, BP
|
||||
MOVQ AX, 24(R11)
|
||||
ORQ BP, R14
|
||||
MOVL (AX)(R14*1), R14
|
||||
MOVQ R13, CX
|
||||
SHLQ CL, R14
|
||||
MOVQ AX, 72(R11)
|
||||
ORQ R14, R12
|
||||
|
||||
// exhausted = exhausted || (br1.off < 4)
|
||||
CMPQ AX, $0x04
|
||||
@@ -110,57 +105,57 @@ skip_fill0:
|
||||
|
||||
skip_fill1:
|
||||
// val0 := br1.peekTopBits(peekBits)
|
||||
MOVQ R14, BP
|
||||
MOVQ SI, CX
|
||||
SHRQ CL, BP
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(BP*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br1.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R14
|
||||
ADDB CL, R15
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val1 := br1.peekTopBits(peekBits)
|
||||
MOVQ SI, CX
|
||||
MOVQ R14, BP
|
||||
SHRQ CL, BP
|
||||
MOVQ DI, CX
|
||||
MOVQ R12, R14
|
||||
SHRQ CL, R14
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
MOVW (R9)(BP*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br1.advance(uint8(v1.entry))
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R14
|
||||
ADDB CL, R15
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// these two writes get coalesced
|
||||
// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
MOVW AX, (DI)
|
||||
MOVW AX, (R8)
|
||||
|
||||
// update the bitrader reader structure
|
||||
MOVQ R14, 32(R11)
|
||||
MOVB R15, 40(R11)
|
||||
ADDQ R8, DI
|
||||
// update the bitreader structure
|
||||
MOVQ R12, 80(R11)
|
||||
MOVB R13, 88(R11)
|
||||
ADDQ R9, R8
|
||||
|
||||
// br2.fillFast32()
|
||||
MOVQ 32(R12), R14
|
||||
MOVBQZX 40(R12), R15
|
||||
CMPQ R15, $0x20
|
||||
MOVQ 128(R11), R12
|
||||
MOVBQZX 136(R11), R13
|
||||
CMPQ R13, $0x20
|
||||
JBE skip_fill2
|
||||
MOVQ 24(R12), AX
|
||||
SUBQ $0x20, R15
|
||||
MOVQ 120(R11), AX
|
||||
SUBQ $0x20, R13
|
||||
SUBQ $0x04, AX
|
||||
MOVQ (R12), BP
|
||||
MOVQ 96(R11), R14
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (AX)(BP*1), BP
|
||||
MOVQ R15, CX
|
||||
SHLQ CL, BP
|
||||
MOVQ AX, 24(R12)
|
||||
ORQ BP, R14
|
||||
MOVL (AX)(R14*1), R14
|
||||
MOVQ R13, CX
|
||||
SHLQ CL, R14
|
||||
MOVQ AX, 120(R11)
|
||||
ORQ R14, R12
|
||||
|
||||
// exhausted = exhausted || (br2.off < 4)
|
||||
CMPQ AX, $0x04
|
||||
@@ -169,57 +164,57 @@ skip_fill1:
|
||||
|
||||
skip_fill2:
|
||||
// val0 := br2.peekTopBits(peekBits)
|
||||
MOVQ R14, BP
|
||||
MOVQ SI, CX
|
||||
SHRQ CL, BP
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(BP*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br2.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R14
|
||||
ADDB CL, R15
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val1 := br2.peekTopBits(peekBits)
|
||||
MOVQ SI, CX
|
||||
MOVQ R14, BP
|
||||
SHRQ CL, BP
|
||||
MOVQ DI, CX
|
||||
MOVQ R12, R14
|
||||
SHRQ CL, R14
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
MOVW (R9)(BP*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br2.advance(uint8(v1.entry))
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R14
|
||||
ADDB CL, R15
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// these two writes get coalesced
|
||||
// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
MOVW AX, (DI)
|
||||
MOVW AX, (R8)
|
||||
|
||||
// update the bitrader reader structure
|
||||
MOVQ R14, 32(R12)
|
||||
MOVB R15, 40(R12)
|
||||
ADDQ R8, DI
|
||||
// update the bitreader structure
|
||||
MOVQ R12, 128(R11)
|
||||
MOVB R13, 136(R11)
|
||||
ADDQ R9, R8
|
||||
|
||||
// br3.fillFast32()
|
||||
MOVQ 32(R13), R14
|
||||
MOVBQZX 40(R13), R15
|
||||
CMPQ R15, $0x20
|
||||
MOVQ 176(R11), R12
|
||||
MOVBQZX 184(R11), R13
|
||||
CMPQ R13, $0x20
|
||||
JBE skip_fill3
|
||||
MOVQ 24(R13), AX
|
||||
SUBQ $0x20, R15
|
||||
MOVQ 168(R11), AX
|
||||
SUBQ $0x20, R13
|
||||
SUBQ $0x04, AX
|
||||
MOVQ (R13), BP
|
||||
MOVQ 144(R11), R14
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (AX)(BP*1), BP
|
||||
MOVQ R15, CX
|
||||
SHLQ CL, BP
|
||||
MOVQ AX, 24(R13)
|
||||
ORQ BP, R14
|
||||
MOVL (AX)(R14*1), R14
|
||||
MOVQ R13, CX
|
||||
SHLQ CL, R14
|
||||
MOVQ AX, 168(R11)
|
||||
ORQ R14, R12
|
||||
|
||||
// exhausted = exhausted || (br3.off < 4)
|
||||
CMPQ AX, $0x04
|
||||
@@ -228,149 +223,142 @@ skip_fill2:
|
||||
|
||||
skip_fill3:
|
||||
// val0 := br3.peekTopBits(peekBits)
|
||||
MOVQ R14, BP
|
||||
MOVQ SI, CX
|
||||
SHRQ CL, BP
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R9)(BP*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br3.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R14
|
||||
ADDB CL, R15
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val1 := br3.peekTopBits(peekBits)
|
||||
MOVQ SI, CX
|
||||
MOVQ R14, BP
|
||||
SHRQ CL, BP
|
||||
MOVQ DI, CX
|
||||
MOVQ R12, R14
|
||||
SHRQ CL, R14
|
||||
|
||||
// v1 := table[val1&mask]
|
||||
MOVW (R9)(BP*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br3.advance(uint8(v1.entry))
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R14
|
||||
ADDB CL, R15
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// these two writes get coalesced
|
||||
// out[id * dstEvery + 0] = uint8(v0.entry >> 8)
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
MOVW AX, (DI)
|
||||
MOVW AX, (R8)
|
||||
|
||||
// update the bitrader reader structure
|
||||
MOVQ R14, 32(R13)
|
||||
MOVB R15, 40(R13)
|
||||
ADDQ $0x02, BX
|
||||
// update the bitreader structure
|
||||
MOVQ R12, 176(R11)
|
||||
MOVB R13, 184(R11)
|
||||
ADDQ $0x02, SI
|
||||
TESTB DL, DL
|
||||
JZ main_loop
|
||||
MOVQ ctx+0(FP), AX
|
||||
MOVQ 40(AX), CX
|
||||
MOVQ BX, DX
|
||||
SUBQ CX, DX
|
||||
SHLQ $0x02, DX
|
||||
MOVQ DX, 64(AX)
|
||||
SUBQ 16(AX), SI
|
||||
SHLQ $0x02, SI
|
||||
MOVQ SI, 40(AX)
|
||||
RET
|
||||
|
||||
// func decompress4x_8b_main_loop_amd64(ctx *decompress4xContext)
|
||||
TEXT ·decompress4x_8b_main_loop_amd64(SB), $16-8
|
||||
TEXT ·decompress4x_8b_main_loop_amd64(SB), $0-8
|
||||
XORQ DX, DX
|
||||
|
||||
// Preload values
|
||||
MOVQ ctx+0(FP), CX
|
||||
MOVBQZX 32(CX), BX
|
||||
MOVQ 40(CX), SI
|
||||
MOVQ SI, (SP)
|
||||
MOVQ 72(CX), DX
|
||||
MOVQ DX, 8(SP)
|
||||
MOVQ 48(CX), DI
|
||||
MOVQ 56(CX), R8
|
||||
MOVQ (CX), R9
|
||||
MOVQ 8(CX), R10
|
||||
MOVQ 16(CX), R11
|
||||
MOVQ 24(CX), R12
|
||||
MOVBQZX 8(CX), DI
|
||||
MOVQ 16(CX), BX
|
||||
MOVQ 48(CX), SI
|
||||
MOVQ 24(CX), R9
|
||||
MOVQ 32(CX), R10
|
||||
MOVQ (CX), R11
|
||||
|
||||
// Main loop
|
||||
main_loop:
|
||||
MOVQ (SP), SI
|
||||
CMPQ SI, 8(SP)
|
||||
MOVQ BX, R8
|
||||
CMPQ R8, SI
|
||||
SETGE DL
|
||||
|
||||
// br1000.fillFast32()
|
||||
MOVQ 32(R9), R13
|
||||
MOVBQZX 40(R9), R14
|
||||
CMPQ R14, $0x20
|
||||
JBE skip_fill1000
|
||||
MOVQ 24(R9), R15
|
||||
SUBQ $0x20, R14
|
||||
SUBQ $0x04, R15
|
||||
MOVQ (R9), BP
|
||||
// br0.fillFast32()
|
||||
MOVQ 32(R11), R12
|
||||
MOVBQZX 40(R11), R13
|
||||
CMPQ R13, $0x20
|
||||
JBE skip_fill0
|
||||
MOVQ 24(R11), R14
|
||||
SUBQ $0x20, R13
|
||||
SUBQ $0x04, R14
|
||||
MOVQ (R11), R15
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (R15)(BP*1), BP
|
||||
MOVQ R14, CX
|
||||
SHLQ CL, BP
|
||||
MOVQ R15, 24(R9)
|
||||
ORQ BP, R13
|
||||
MOVL (R14)(R15*1), R15
|
||||
MOVQ R13, CX
|
||||
SHLQ CL, R15
|
||||
MOVQ R14, 24(R11)
|
||||
ORQ R15, R12
|
||||
|
||||
// exhausted = exhausted || (br1000.off < 4)
|
||||
CMPQ R15, $0x04
|
||||
// exhausted = exhausted || (br0.off < 4)
|
||||
CMPQ R14, $0x04
|
||||
SETLT AL
|
||||
ORB AL, DL
|
||||
|
||||
skip_fill1000:
|
||||
skip_fill0:
|
||||
// val0 := br0.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br0.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val1 := br0.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br0.advance(uint8(v1.entry)
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
BSWAPL AX
|
||||
|
||||
// val2 := br0.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br0.advance(uint8(v2.entry)
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val3 := br0.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br0.advance(uint8(v3.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
BSWAPL AX
|
||||
|
||||
// these four writes get coalesced
|
||||
@@ -378,88 +366,88 @@ skip_fill1000:
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
// out[id * dstEvery + 3] = uint8(v2.entry >> 8)
|
||||
// out[id * dstEvery + 4] = uint8(v3.entry >> 8)
|
||||
MOVL AX, (SI)
|
||||
MOVL AX, (R8)
|
||||
|
||||
// update the bitreader reader structure
|
||||
MOVQ R13, 32(R9)
|
||||
MOVB R14, 40(R9)
|
||||
ADDQ DI, SI
|
||||
// update the bitreader structure
|
||||
MOVQ R12, 32(R11)
|
||||
MOVB R13, 40(R11)
|
||||
ADDQ R9, R8
|
||||
|
||||
// br1001.fillFast32()
|
||||
MOVQ 32(R10), R13
|
||||
MOVBQZX 40(R10), R14
|
||||
CMPQ R14, $0x20
|
||||
JBE skip_fill1001
|
||||
MOVQ 24(R10), R15
|
||||
SUBQ $0x20, R14
|
||||
SUBQ $0x04, R15
|
||||
MOVQ (R10), BP
|
||||
// br1.fillFast32()
|
||||
MOVQ 80(R11), R12
|
||||
MOVBQZX 88(R11), R13
|
||||
CMPQ R13, $0x20
|
||||
JBE skip_fill1
|
||||
MOVQ 72(R11), R14
|
||||
SUBQ $0x20, R13
|
||||
SUBQ $0x04, R14
|
||||
MOVQ 48(R11), R15
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (R15)(BP*1), BP
|
||||
MOVQ R14, CX
|
||||
SHLQ CL, BP
|
||||
MOVQ R15, 24(R10)
|
||||
ORQ BP, R13
|
||||
MOVL (R14)(R15*1), R15
|
||||
MOVQ R13, CX
|
||||
SHLQ CL, R15
|
||||
MOVQ R14, 72(R11)
|
||||
ORQ R15, R12
|
||||
|
||||
// exhausted = exhausted || (br1001.off < 4)
|
||||
CMPQ R15, $0x04
|
||||
// exhausted = exhausted || (br1.off < 4)
|
||||
CMPQ R14, $0x04
|
||||
SETLT AL
|
||||
ORB AL, DL
|
||||
|
||||
skip_fill1001:
|
||||
skip_fill1:
|
||||
// val0 := br1.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br1.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val1 := br1.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br1.advance(uint8(v1.entry)
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
BSWAPL AX
|
||||
|
||||
// val2 := br1.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br1.advance(uint8(v2.entry)
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val3 := br1.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br1.advance(uint8(v3.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
BSWAPL AX
|
||||
|
||||
// these four writes get coalesced
|
||||
@@ -467,88 +455,88 @@ skip_fill1001:
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
// out[id * dstEvery + 3] = uint8(v2.entry >> 8)
|
||||
// out[id * dstEvery + 4] = uint8(v3.entry >> 8)
|
||||
MOVL AX, (SI)
|
||||
MOVL AX, (R8)
|
||||
|
||||
// update the bitreader reader structure
|
||||
MOVQ R13, 32(R10)
|
||||
MOVB R14, 40(R10)
|
||||
ADDQ DI, SI
|
||||
// update the bitreader structure
|
||||
MOVQ R12, 80(R11)
|
||||
MOVB R13, 88(R11)
|
||||
ADDQ R9, R8
|
||||
|
||||
// br1002.fillFast32()
|
||||
MOVQ 32(R11), R13
|
||||
MOVBQZX 40(R11), R14
|
||||
CMPQ R14, $0x20
|
||||
JBE skip_fill1002
|
||||
MOVQ 24(R11), R15
|
||||
SUBQ $0x20, R14
|
||||
SUBQ $0x04, R15
|
||||
MOVQ (R11), BP
|
||||
// br2.fillFast32()
|
||||
MOVQ 128(R11), R12
|
||||
MOVBQZX 136(R11), R13
|
||||
CMPQ R13, $0x20
|
||||
JBE skip_fill2
|
||||
MOVQ 120(R11), R14
|
||||
SUBQ $0x20, R13
|
||||
SUBQ $0x04, R14
|
||||
MOVQ 96(R11), R15
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (R15)(BP*1), BP
|
||||
MOVQ R14, CX
|
||||
SHLQ CL, BP
|
||||
MOVQ R15, 24(R11)
|
||||
ORQ BP, R13
|
||||
MOVL (R14)(R15*1), R15
|
||||
MOVQ R13, CX
|
||||
SHLQ CL, R15
|
||||
MOVQ R14, 120(R11)
|
||||
ORQ R15, R12
|
||||
|
||||
// exhausted = exhausted || (br1002.off < 4)
|
||||
CMPQ R15, $0x04
|
||||
// exhausted = exhausted || (br2.off < 4)
|
||||
CMPQ R14, $0x04
|
||||
SETLT AL
|
||||
ORB AL, DL
|
||||
|
||||
skip_fill1002:
|
||||
skip_fill2:
|
||||
// val0 := br2.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br2.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val1 := br2.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br2.advance(uint8(v1.entry)
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
BSWAPL AX
|
||||
|
||||
// val2 := br2.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br2.advance(uint8(v2.entry)
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val3 := br2.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br2.advance(uint8(v3.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
BSWAPL AX
|
||||
|
||||
// these four writes get coalesced
|
||||
@@ -556,88 +544,88 @@ skip_fill1002:
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
// out[id * dstEvery + 3] = uint8(v2.entry >> 8)
|
||||
// out[id * dstEvery + 4] = uint8(v3.entry >> 8)
|
||||
MOVL AX, (SI)
|
||||
MOVL AX, (R8)
|
||||
|
||||
// update the bitreader reader structure
|
||||
MOVQ R13, 32(R11)
|
||||
MOVB R14, 40(R11)
|
||||
ADDQ DI, SI
|
||||
// update the bitreader structure
|
||||
MOVQ R12, 128(R11)
|
||||
MOVB R13, 136(R11)
|
||||
ADDQ R9, R8
|
||||
|
||||
// br1003.fillFast32()
|
||||
MOVQ 32(R12), R13
|
||||
MOVBQZX 40(R12), R14
|
||||
CMPQ R14, $0x20
|
||||
JBE skip_fill1003
|
||||
MOVQ 24(R12), R15
|
||||
SUBQ $0x20, R14
|
||||
SUBQ $0x04, R15
|
||||
MOVQ (R12), BP
|
||||
// br3.fillFast32()
|
||||
MOVQ 176(R11), R12
|
||||
MOVBQZX 184(R11), R13
|
||||
CMPQ R13, $0x20
|
||||
JBE skip_fill3
|
||||
MOVQ 168(R11), R14
|
||||
SUBQ $0x20, R13
|
||||
SUBQ $0x04, R14
|
||||
MOVQ 144(R11), R15
|
||||
|
||||
// b.value |= uint64(low) << (b.bitsRead & 63)
|
||||
MOVL (R15)(BP*1), BP
|
||||
MOVQ R14, CX
|
||||
SHLQ CL, BP
|
||||
MOVQ R15, 24(R12)
|
||||
ORQ BP, R13
|
||||
MOVL (R14)(R15*1), R15
|
||||
MOVQ R13, CX
|
||||
SHLQ CL, R15
|
||||
MOVQ R14, 168(R11)
|
||||
ORQ R15, R12
|
||||
|
||||
// exhausted = exhausted || (br1003.off < 4)
|
||||
CMPQ R15, $0x04
|
||||
// exhausted = exhausted || (br3.off < 4)
|
||||
CMPQ R14, $0x04
|
||||
SETLT AL
|
||||
ORB AL, DL
|
||||
|
||||
skip_fill1003:
|
||||
skip_fill3:
|
||||
// val0 := br3.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v0 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br3.advance(uint8(v0.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val1 := br3.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v1 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br3.advance(uint8(v1.entry)
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
BSWAPL AX
|
||||
|
||||
// val2 := br3.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v2 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br3.advance(uint8(v2.entry)
|
||||
MOVB CH, AH
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
|
||||
// val3 := br3.peekTopBits(peekBits)
|
||||
MOVQ R13, R15
|
||||
MOVQ BX, CX
|
||||
SHRQ CL, R15
|
||||
MOVQ R12, R14
|
||||
MOVQ DI, CX
|
||||
SHRQ CL, R14
|
||||
|
||||
// v3 := table[val0&mask]
|
||||
MOVW (R8)(R15*2), CX
|
||||
MOVW (R10)(R14*2), CX
|
||||
|
||||
// br3.advance(uint8(v3.entry)
|
||||
MOVB CH, AL
|
||||
SHLQ CL, R13
|
||||
ADDB CL, R14
|
||||
SHLQ CL, R12
|
||||
ADDB CL, R13
|
||||
BSWAPL AX
|
||||
|
||||
// these four writes get coalesced
|
||||
@@ -645,20 +633,18 @@ skip_fill1003:
|
||||
// out[id * dstEvery + 1] = uint8(v1.entry >> 8)
|
||||
// out[id * dstEvery + 3] = uint8(v2.entry >> 8)
|
||||
// out[id * dstEvery + 4] = uint8(v3.entry >> 8)
|
||||
MOVL AX, (SI)
|
||||
MOVL AX, (R8)
|
||||
|
||||
// update the bitreader reader structure
|
||||
MOVQ R13, 32(R12)
|
||||
MOVB R14, 40(R12)
|
||||
ADDQ $0x04, (SP)
|
||||
// update the bitreader structure
|
||||
MOVQ R12, 176(R11)
|
||||
MOVB R13, 184(R11)
|
||||
ADDQ $0x04, BX
|
||||
TESTB DL, DL
|
||||
JZ main_loop
|
||||
MOVQ ctx+0(FP), AX
|
||||
MOVQ 40(AX), CX
|
||||
MOVQ (SP), DX
|
||||
SUBQ CX, DX
|
||||
SHLQ $0x02, DX
|
||||
MOVQ DX, 64(AX)
|
||||
SUBQ 16(AX), BX
|
||||
SHLQ $0x02, BX
|
||||
MOVQ BX, 40(AX)
|
||||
RET
|
||||
|
||||
// func decompress1x_main_loop_amd64(ctx *decompress1xContext)
|
||||
@@ -750,10 +736,8 @@ loop_condition:
|
||||
|
||||
// Update ctx structure
|
||||
MOVQ ctx+0(FP), AX
|
||||
MOVQ DX, CX
|
||||
MOVQ 16(AX), DX
|
||||
SUBQ DX, CX
|
||||
MOVQ CX, 40(AX)
|
||||
SUBQ 16(AX), DX
|
||||
MOVQ DX, 40(AX)
|
||||
MOVQ (AX), AX
|
||||
MOVQ R9, 24(AX)
|
||||
MOVQ R10, 32(AX)
|
||||
@@ -847,10 +831,8 @@ loop_condition:
|
||||
|
||||
// Update ctx structure
|
||||
MOVQ ctx+0(FP), AX
|
||||
MOVQ DX, CX
|
||||
MOVQ 16(AX), DX
|
||||
SUBQ DX, CX
|
||||
MOVQ CX, 40(AX)
|
||||
SUBQ 16(AX), DX
|
||||
MOVQ DX, 40(AX)
|
||||
MOVQ (AX), AX
|
||||
MOVQ R9, 24(AX)
|
||||
MOVQ R10, 32(AX)
|
||||
|
||||
10
vendor/github.com/klauspost/compress/s2/decode.go
generated
vendored
10
vendor/github.com/klauspost/compress/s2/decode.go
generated
vendored
@@ -791,6 +791,7 @@ func (r *Reader) Skip(n int64) error {
|
||||
} else {
|
||||
// Skip block completely
|
||||
n -= int64(dLen)
|
||||
r.blockStart += int64(dLen)
|
||||
dLen = 0
|
||||
}
|
||||
r.i, r.j = 0, dLen
|
||||
@@ -921,6 +922,15 @@ func (r *Reader) ReadSeeker(random bool, index []byte) (*ReadSeeker, error) {
|
||||
err = r.index.LoadStream(rs)
|
||||
if err != nil {
|
||||
if err == ErrUnsupported {
|
||||
// If we don't require random seeking, reset input and return.
|
||||
if !random {
|
||||
_, err = rs.Seek(pos, io.SeekStart)
|
||||
if err != nil {
|
||||
return nil, ErrCantSeek{Reason: "resetting stream returned: " + err.Error()}
|
||||
}
|
||||
r.index = nil
|
||||
return &ReadSeeker{Reader: r}, nil
|
||||
}
|
||||
return nil, ErrCantSeek{Reason: "input stream does not contain an index"}
|
||||
}
|
||||
return nil, ErrCantSeek{Reason: "reading index returned: " + err.Error()}
|
||||
|
||||
63
vendor/github.com/klauspost/compress/s2/index.go
generated
vendored
63
vendor/github.com/klauspost/compress/s2/index.go
generated
vendored
@@ -533,3 +533,66 @@ func (i *Index) JSON() []byte {
|
||||
b, _ := json.MarshalIndent(x, "", " ")
|
||||
return b
|
||||
}
|
||||
|
||||
// RemoveIndexHeaders will trim all headers and trailers from a given index.
|
||||
// This is expected to save 20 bytes.
|
||||
// These can be restored using RestoreIndexHeaders.
|
||||
// This removes a layer of security, but is the most compact representation.
|
||||
// Returns nil if headers contains errors.
|
||||
// The returned slice references the provided slice.
|
||||
func RemoveIndexHeaders(b []byte) []byte {
|
||||
const save = 4 + len(S2IndexHeader) + len(S2IndexTrailer) + 4
|
||||
if len(b) <= save {
|
||||
return nil
|
||||
}
|
||||
if b[0] != ChunkTypeIndex {
|
||||
return nil
|
||||
}
|
||||
chunkLen := int(b[1]) | int(b[2])<<8 | int(b[3])<<16
|
||||
b = b[4:]
|
||||
|
||||
// Validate we have enough...
|
||||
if len(b) < chunkLen {
|
||||
return nil
|
||||
}
|
||||
b = b[:chunkLen]
|
||||
|
||||
if !bytes.Equal(b[:len(S2IndexHeader)], []byte(S2IndexHeader)) {
|
||||
return nil
|
||||
}
|
||||
b = b[len(S2IndexHeader):]
|
||||
if !bytes.HasSuffix(b, []byte(S2IndexTrailer)) {
|
||||
return nil
|
||||
}
|
||||
b = bytes.TrimSuffix(b, []byte(S2IndexTrailer))
|
||||
|
||||
if len(b) < 4 {
|
||||
return nil
|
||||
}
|
||||
return b[:len(b)-4]
|
||||
}
|
||||
|
||||
// RestoreIndexHeaders will index restore headers removed by RemoveIndexHeaders.
|
||||
// No error checking is performed on the input.
|
||||
// If a 0 length slice is sent, it is returned without modification.
|
||||
func RestoreIndexHeaders(in []byte) []byte {
|
||||
if len(in) == 0 {
|
||||
return in
|
||||
}
|
||||
b := make([]byte, 0, 4+len(S2IndexHeader)+len(in)+len(S2IndexTrailer)+4)
|
||||
b = append(b, ChunkTypeIndex, 0, 0, 0)
|
||||
b = append(b, []byte(S2IndexHeader)...)
|
||||
b = append(b, in...)
|
||||
|
||||
var tmp [4]byte
|
||||
binary.LittleEndian.PutUint32(tmp[:], uint32(len(b)+4+len(S2IndexTrailer)))
|
||||
b = append(b, tmp[:4]...)
|
||||
// Trailer
|
||||
b = append(b, []byte(S2IndexTrailer)...)
|
||||
|
||||
chunkLen := len(b) - skippableFrameHeader
|
||||
b[1] = uint8(chunkLen >> 0)
|
||||
b[2] = uint8(chunkLen >> 8)
|
||||
b[3] = uint8(chunkLen >> 16)
|
||||
return b
|
||||
}
|
||||
|
||||
63
vendor/github.com/klauspost/compress/zstd/fse_decoder.go
generated
vendored
63
vendor/github.com/klauspost/compress/zstd/fse_decoder.go
generated
vendored
@@ -180,7 +180,6 @@ func (s *fseDecoder) readNCount(b *byteReader, maxSymbol uint16) error {
|
||||
return fmt.Errorf("corruption detected (total %d != %d)", gotTotal, 1<<s.actualTableLog)
|
||||
}
|
||||
b.advance((bitCount + 7) >> 3)
|
||||
// println(s.norm[:s.symbolLen], s.symbolLen)
|
||||
return s.buildDtable()
|
||||
}
|
||||
|
||||
@@ -269,68 +268,6 @@ func (s *fseDecoder) setRLE(symbol decSymbol) {
|
||||
s.dt[0] = symbol
|
||||
}
|
||||
|
||||
// buildDtable will build the decoding table.
|
||||
func (s *fseDecoder) buildDtable() error {
|
||||
tableSize := uint32(1 << s.actualTableLog)
|
||||
highThreshold := tableSize - 1
|
||||
symbolNext := s.stateTable[:256]
|
||||
|
||||
// Init, lay down lowprob symbols
|
||||
{
|
||||
for i, v := range s.norm[:s.symbolLen] {
|
||||
if v == -1 {
|
||||
s.dt[highThreshold].setAddBits(uint8(i))
|
||||
highThreshold--
|
||||
symbolNext[i] = 1
|
||||
} else {
|
||||
symbolNext[i] = uint16(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Spread symbols
|
||||
{
|
||||
tableMask := tableSize - 1
|
||||
step := tableStep(tableSize)
|
||||
position := uint32(0)
|
||||
for ss, v := range s.norm[:s.symbolLen] {
|
||||
for i := 0; i < int(v); i++ {
|
||||
s.dt[position].setAddBits(uint8(ss))
|
||||
position = (position + step) & tableMask
|
||||
for position > highThreshold {
|
||||
// lowprob area
|
||||
position = (position + step) & tableMask
|
||||
}
|
||||
}
|
||||
}
|
||||
if position != 0 {
|
||||
// position must reach all cells once, otherwise normalizedCounter is incorrect
|
||||
return errors.New("corrupted input (position != 0)")
|
||||
}
|
||||
}
|
||||
|
||||
// Build Decoding table
|
||||
{
|
||||
tableSize := uint16(1 << s.actualTableLog)
|
||||
for u, v := range s.dt[:tableSize] {
|
||||
symbol := v.addBits()
|
||||
nextState := symbolNext[symbol]
|
||||
symbolNext[symbol] = nextState + 1
|
||||
nBits := s.actualTableLog - byte(highBits(uint32(nextState)))
|
||||
s.dt[u&maxTableMask].setNBits(nBits)
|
||||
newState := (nextState << nBits) - tableSize
|
||||
if newState > tableSize {
|
||||
return fmt.Errorf("newState (%d) outside table size (%d)", newState, tableSize)
|
||||
}
|
||||
if newState == uint16(u) && nBits == 0 {
|
||||
// Seems weird that this is possible with nbits > 0.
|
||||
return fmt.Errorf("newState (%d) == oldState (%d) and no bits", newState, u)
|
||||
}
|
||||
s.dt[u&maxTableMask].setNewState(newState)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// transform will transform the decoder table into a table usable for
|
||||
// decoding without having to apply the transformation while decoding.
|
||||
// The state will contain the base value and the number of bits to read.
|
||||
|
||||
64
vendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.go
generated
vendored
Normal file
64
vendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.go
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
//go:build amd64 && !appengine && !noasm && gc
|
||||
// +build amd64,!appengine,!noasm,gc
|
||||
|
||||
package zstd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type buildDtableAsmContext struct {
|
||||
// inputs
|
||||
stateTable *uint16
|
||||
norm *int16
|
||||
dt *uint64
|
||||
|
||||
// outputs --- set by the procedure in the case of error;
|
||||
// for interpretation please see the error handling part below
|
||||
errParam1 uint64
|
||||
errParam2 uint64
|
||||
}
|
||||
|
||||
// buildDtable_asm is an x86 assembly implementation of fseDecoder.buildDtable.
|
||||
// Function returns non-zero exit code on error.
|
||||
// go:noescape
|
||||
func buildDtable_asm(s *fseDecoder, ctx *buildDtableAsmContext) int
|
||||
|
||||
// please keep in sync with _generate/gen_fse.go
|
||||
const (
|
||||
errorCorruptedNormalizedCounter = 1
|
||||
errorNewStateTooBig = 2
|
||||
errorNewStateNoBits = 3
|
||||
)
|
||||
|
||||
// buildDtable will build the decoding table.
|
||||
func (s *fseDecoder) buildDtable() error {
|
||||
ctx := buildDtableAsmContext{
|
||||
stateTable: (*uint16)(&s.stateTable[0]),
|
||||
norm: (*int16)(&s.norm[0]),
|
||||
dt: (*uint64)(&s.dt[0]),
|
||||
}
|
||||
code := buildDtable_asm(s, &ctx)
|
||||
|
||||
if code != 0 {
|
||||
switch code {
|
||||
case errorCorruptedNormalizedCounter:
|
||||
position := ctx.errParam1
|
||||
return fmt.Errorf("corrupted input (position=%d, expected 0)", position)
|
||||
|
||||
case errorNewStateTooBig:
|
||||
newState := decSymbol(ctx.errParam1)
|
||||
size := ctx.errParam2
|
||||
return fmt.Errorf("newState (%d) outside table size (%d)", newState, size)
|
||||
|
||||
case errorNewStateNoBits:
|
||||
newState := decSymbol(ctx.errParam1)
|
||||
oldState := decSymbol(ctx.errParam2)
|
||||
return fmt.Errorf("newState (%d) == oldState (%d) and no bits", newState, oldState)
|
||||
|
||||
default:
|
||||
return fmt.Errorf("buildDtable_asm returned unhandled nonzero code = %d", code)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
127
vendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.s
generated
vendored
Normal file
127
vendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.s
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
// Code generated by command: go run gen_fse.go -out ../fse_decoder_amd64.s -pkg=zstd. DO NOT EDIT.
|
||||
|
||||
//go:build !appengine && !noasm && gc && !noasm
|
||||
// +build !appengine,!noasm,gc,!noasm
|
||||
|
||||
// func buildDtable_asm(s *fseDecoder, ctx *buildDtableAsmContext) int
|
||||
TEXT ·buildDtable_asm(SB), $0-24
|
||||
MOVQ ctx+8(FP), CX
|
||||
MOVQ s+0(FP), DI
|
||||
|
||||
// Load values
|
||||
MOVBQZX 4098(DI), DX
|
||||
XORQ AX, AX
|
||||
BTSQ DX, AX
|
||||
MOVQ (CX), BX
|
||||
MOVQ 16(CX), SI
|
||||
LEAQ -1(AX), R8
|
||||
MOVQ 8(CX), CX
|
||||
MOVWQZX 4096(DI), DI
|
||||
|
||||
// End load values
|
||||
// Init, lay down lowprob symbols
|
||||
XORQ R9, R9
|
||||
JMP init_main_loop_condition
|
||||
|
||||
init_main_loop:
|
||||
MOVWQSX (CX)(R9*2), R10
|
||||
CMPW R10, $-1
|
||||
JNE do_not_update_high_threshold
|
||||
MOVB R9, 1(SI)(R8*8)
|
||||
DECQ R8
|
||||
MOVQ $0x0000000000000001, R10
|
||||
|
||||
do_not_update_high_threshold:
|
||||
MOVW R10, (BX)(R9*2)
|
||||
INCQ R9
|
||||
|
||||
init_main_loop_condition:
|
||||
CMPQ R9, DI
|
||||
JL init_main_loop
|
||||
|
||||
// Spread symbols
|
||||
// Calculate table step
|
||||
MOVQ AX, R9
|
||||
SHRQ $0x01, R9
|
||||
MOVQ AX, R10
|
||||
SHRQ $0x03, R10
|
||||
LEAQ 3(R9)(R10*1), R9
|
||||
|
||||
// Fill add bits values
|
||||
LEAQ -1(AX), R10
|
||||
XORQ R11, R11
|
||||
XORQ R12, R12
|
||||
JMP spread_main_loop_condition
|
||||
|
||||
spread_main_loop:
|
||||
XORQ R13, R13
|
||||
MOVWQSX (CX)(R12*2), R14
|
||||
JMP spread_inner_loop_condition
|
||||
|
||||
spread_inner_loop:
|
||||
MOVB R12, 1(SI)(R11*8)
|
||||
|
||||
adjust_position:
|
||||
ADDQ R9, R11
|
||||
ANDQ R10, R11
|
||||
CMPQ R11, R8
|
||||
JG adjust_position
|
||||
INCQ R13
|
||||
|
||||
spread_inner_loop_condition:
|
||||
CMPQ R13, R14
|
||||
JL spread_inner_loop
|
||||
INCQ R12
|
||||
|
||||
spread_main_loop_condition:
|
||||
CMPQ R12, DI
|
||||
JL spread_main_loop
|
||||
TESTQ R11, R11
|
||||
JZ spread_check_ok
|
||||
MOVQ ctx+8(FP), AX
|
||||
MOVQ R11, 24(AX)
|
||||
MOVQ $+1, ret+16(FP)
|
||||
RET
|
||||
|
||||
spread_check_ok:
|
||||
// Build Decoding table
|
||||
XORQ DI, DI
|
||||
|
||||
build_table_main_table:
|
||||
MOVBQZX 1(SI)(DI*8), CX
|
||||
MOVWQZX (BX)(CX*2), R8
|
||||
LEAQ 1(R8), R9
|
||||
MOVW R9, (BX)(CX*2)
|
||||
MOVQ R8, R9
|
||||
BSRQ R9, R9
|
||||
MOVQ DX, CX
|
||||
SUBQ R9, CX
|
||||
SHLQ CL, R8
|
||||
SUBQ AX, R8
|
||||
MOVB CL, (SI)(DI*8)
|
||||
MOVW R8, 2(SI)(DI*8)
|
||||
CMPQ R8, AX
|
||||
JLE build_table_check1_ok
|
||||
MOVQ ctx+8(FP), CX
|
||||
MOVQ R8, 24(CX)
|
||||
MOVQ AX, 32(CX)
|
||||
MOVQ $+2, ret+16(FP)
|
||||
RET
|
||||
|
||||
build_table_check1_ok:
|
||||
TESTB CL, CL
|
||||
JNZ build_table_check2_ok
|
||||
CMPW R8, DI
|
||||
JNE build_table_check2_ok
|
||||
MOVQ ctx+8(FP), AX
|
||||
MOVQ R8, 24(AX)
|
||||
MOVQ DI, 32(AX)
|
||||
MOVQ $+3, ret+16(FP)
|
||||
RET
|
||||
|
||||
build_table_check2_ok:
|
||||
INCQ DI
|
||||
CMPQ DI, AX
|
||||
JL build_table_main_table
|
||||
MOVQ $+0, ret+16(FP)
|
||||
RET
|
||||
72
vendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go
generated
vendored
Normal file
72
vendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
//go:build !amd64 || appengine || !gc || noasm
|
||||
// +build !amd64 appengine !gc noasm
|
||||
|
||||
package zstd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// buildDtable will build the decoding table.
|
||||
func (s *fseDecoder) buildDtable() error {
|
||||
tableSize := uint32(1 << s.actualTableLog)
|
||||
highThreshold := tableSize - 1
|
||||
symbolNext := s.stateTable[:256]
|
||||
|
||||
// Init, lay down lowprob symbols
|
||||
{
|
||||
for i, v := range s.norm[:s.symbolLen] {
|
||||
if v == -1 {
|
||||
s.dt[highThreshold].setAddBits(uint8(i))
|
||||
highThreshold--
|
||||
symbolNext[i] = 1
|
||||
} else {
|
||||
symbolNext[i] = uint16(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spread symbols
|
||||
{
|
||||
tableMask := tableSize - 1
|
||||
step := tableStep(tableSize)
|
||||
position := uint32(0)
|
||||
for ss, v := range s.norm[:s.symbolLen] {
|
||||
for i := 0; i < int(v); i++ {
|
||||
s.dt[position].setAddBits(uint8(ss))
|
||||
position = (position + step) & tableMask
|
||||
for position > highThreshold {
|
||||
// lowprob area
|
||||
position = (position + step) & tableMask
|
||||
}
|
||||
}
|
||||
}
|
||||
if position != 0 {
|
||||
// position must reach all cells once, otherwise normalizedCounter is incorrect
|
||||
return errors.New("corrupted input (position != 0)")
|
||||
}
|
||||
}
|
||||
|
||||
// Build Decoding table
|
||||
{
|
||||
tableSize := uint16(1 << s.actualTableLog)
|
||||
for u, v := range s.dt[:tableSize] {
|
||||
symbol := v.addBits()
|
||||
nextState := symbolNext[symbol]
|
||||
symbolNext[symbol] = nextState + 1
|
||||
nBits := s.actualTableLog - byte(highBits(uint32(nextState)))
|
||||
s.dt[u&maxTableMask].setNBits(nBits)
|
||||
newState := (nextState << nBits) - tableSize
|
||||
if newState > tableSize {
|
||||
return fmt.Errorf("newState (%d) outside table size (%d)", newState, tableSize)
|
||||
}
|
||||
if newState == uint16(u) && nBits == 0 {
|
||||
// Seems weird that this is possible with nbits > 0.
|
||||
return fmt.Errorf("newState (%d) == oldState (%d) and no bits", newState, u)
|
||||
}
|
||||
s.dt[u&maxTableMask].setNewState(newState)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
1923
vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s
generated
vendored
1923
vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s
generated
vendored
File diff suppressed because it is too large
Load Diff
6
vendor/github.com/kyokomi/emoji/v2/emoji_codemap.go
generated
vendored
6
vendor/github.com/kyokomi/emoji/v2/emoji_codemap.go
generated
vendored
@@ -367,7 +367,7 @@ func emojiCode() map[string]string {
|
||||
":bouncing_ball_woman:": "\u26f9\ufe0f\u200d\u2640\ufe0f",
|
||||
":bouquet:": "\U0001f490",
|
||||
":bouvet_island:": "\U0001f1e7\U0001f1fb",
|
||||
":bow:": "\U0001f647\u200d\u2642\ufe0f",
|
||||
":bow:": "\U0001f647",
|
||||
":bow_and_arrow:": "\U0001f3f9",
|
||||
":bowing_man:": "\U0001f647\u200d\u2642\ufe0f",
|
||||
":bowing_woman:": "\U0001f647\u200d\u2640\ufe0f",
|
||||
@@ -6513,7 +6513,7 @@ func emojiRevCode() map[string][]string {
|
||||
"\U0001f646\U0001f3ff\u200d\u2642\ufe0f": {":man_gesturing_ok_tone5:"},
|
||||
"\U0001f646\u200d\u2640\ufe0f": {":ok_woman:", ":woman-gesturing-ok:", ":woman_gesturing_OK:", ":woman_gesturing_ok:"},
|
||||
"\U0001f646\u200d\u2642\ufe0f": {":ok_man:", ":man-gesturing-ok:", ":man_gesturing_OK:", ":man_gesturing_ok:"},
|
||||
"\U0001f647": {":person_bowing:"},
|
||||
"\U0001f647": {":bow:", ":person_bowing:"},
|
||||
"\U0001f647\U0001f3fb": {":person_bowing_tone1:"},
|
||||
"\U0001f647\U0001f3fb\u200d\u2640\ufe0f": {":woman_bowing_tone1:"},
|
||||
"\U0001f647\U0001f3fb\u200d\u2642\ufe0f": {":man_bowing_tone1:"},
|
||||
@@ -6530,7 +6530,7 @@ func emojiRevCode() map[string][]string {
|
||||
"\U0001f647\U0001f3ff\u200d\u2640\ufe0f": {":woman_bowing_tone5:"},
|
||||
"\U0001f647\U0001f3ff\u200d\u2642\ufe0f": {":man_bowing_tone5:"},
|
||||
"\U0001f647\u200d\u2640\ufe0f": {":bowing_woman:", ":woman-bowing:", ":woman_bowing:"},
|
||||
"\U0001f647\u200d\u2642\ufe0f": {":bow:", ":bowing_man:", ":man-bowing:", ":man_bowing:"},
|
||||
"\U0001f647\u200d\u2642\ufe0f": {":bowing_man:", ":man-bowing:", ":man_bowing:"},
|
||||
"\U0001f648": {":see_no_evil:", ":see-no-evil_monkey:"},
|
||||
"\U0001f649": {":hear_no_evil:", ":hear-no-evil_monkey:"},
|
||||
"\U0001f64a": {":speak_no_evil:", ":speak-no-evil_monkey:"},
|
||||
|
||||
4
vendor/github.com/kyokomi/emoji/v2/wercker.yml
generated
vendored
4
vendor/github.com/kyokomi/emoji/v2/wercker.yml
generated
vendored
@@ -8,8 +8,8 @@ build:
|
||||
- script:
|
||||
name: install tools
|
||||
code: |
|
||||
go get github.com/mattn/goveralls
|
||||
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
go install github.com/mattn/goveralls@latest
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
- script:
|
||||
name: go get
|
||||
code: |
|
||||
|
||||
31
vendor/github.com/labstack/echo/v4/CHANGELOG.md
generated
vendored
31
vendor/github.com/labstack/echo/v4/CHANGELOG.md
generated
vendored
@@ -1,5 +1,36 @@
|
||||
# Changelog
|
||||
|
||||
## v4.8.0 - 2022-08-10
|
||||
|
||||
**Most notable things**
|
||||
|
||||
You can now add any arbitrary HTTP method type as a route [#2237](https://github.com/labstack/echo/pull/2237)
|
||||
```go
|
||||
e.Add("COPY", "/*", func(c echo.Context) error
|
||||
return c.String(http.StatusOK, "OK COPY")
|
||||
})
|
||||
```
|
||||
|
||||
You can add custom 404 handler for specific paths [#2217](https://github.com/labstack/echo/pull/2217)
|
||||
```go
|
||||
e.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })
|
||||
|
||||
g := e.Group("/images")
|
||||
g.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })
|
||||
```
|
||||
|
||||
**Enhancements**
|
||||
|
||||
* Add new value binding methods (UnixTimeMilli,TextUnmarshaler,JSONUnmarshaler) to Valuebinder [#2127](https://github.com/labstack/echo/pull/2127)
|
||||
* Refactor: body_limit middleware unit test [#2145](https://github.com/labstack/echo/pull/2145)
|
||||
* Refactor: Timeout mw: rework how test waits for timeout. [#2187](https://github.com/labstack/echo/pull/2187)
|
||||
* BasicAuth middleware returns 500 InternalServerError on invalid base64 strings but should return 400 [#2191](https://github.com/labstack/echo/pull/2191)
|
||||
* Refactor: duplicated findStaticChild process at findChildWithLabel [#2176](https://github.com/labstack/echo/pull/2176)
|
||||
* Allow different param names in different methods with same path scheme [#2209](https://github.com/labstack/echo/pull/2209)
|
||||
* Add support for registering handlers for different 404 routes [#2217](https://github.com/labstack/echo/pull/2217)
|
||||
* Middlewares should use errors.As() instead of type assertion on HTTPError [#2227](https://github.com/labstack/echo/pull/2227)
|
||||
* Allow arbitrary HTTP method types to be added as routes [#2237](https://github.com/labstack/echo/pull/2237)
|
||||
|
||||
## v4.7.2 - 2022-03-16
|
||||
|
||||
**Fixes**
|
||||
|
||||
6
vendor/github.com/labstack/echo/v4/Makefile
generated
vendored
6
vendor/github.com/labstack/echo/v4/Makefile
generated
vendored
@@ -9,7 +9,7 @@ tag:
|
||||
check: lint vet race ## Check project
|
||||
|
||||
init:
|
||||
@go get -u golang.org/x/lint/golint
|
||||
@go install golang.org/x/lint/golint@latest
|
||||
|
||||
lint: ## Lint the files
|
||||
@golint -set_exit_status ${PKG_LIST}
|
||||
@@ -29,6 +29,6 @@ benchmark: ## Run benchmarks
|
||||
help: ## Display this help screen
|
||||
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
goversion ?= "1.15"
|
||||
test_version: ## Run tests inside Docker with given version (defaults to 1.15 oldest supported). Example: make test_version goversion=1.15
|
||||
goversion ?= "1.16"
|
||||
test_version: ## Run tests inside Docker with given version (defaults to 1.15 oldest supported). Example: make test_version goversion=1.16
|
||||
@docker run --rm -it -v $(shell pwd):/project golang:$(goversion) /bin/sh -c "cd /project && make init check"
|
||||
|
||||
19
vendor/github.com/labstack/echo/v4/README.md
generated
vendored
19
vendor/github.com/labstack/echo/v4/README.md
generated
vendored
@@ -93,15 +93,16 @@ func hello(c echo.Context) error {
|
||||
|
||||
# Third-party middlewares
|
||||
|
||||
| Repository | Description |
|
||||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [github.com/labstack/echo-contrib](https://github.com/labstack/echo-contrib) | (by Echo team) [casbin](https://github.com/casbin/casbin), [gorilla/sessions](https://github.com/gorilla/sessions), [jaegertracing](github.com/uber/jaeger-client-go), [prometheus](https://github.com/prometheus/client_golang/), [pprof](https://pkg.go.dev/net/http/pprof), [zipkin](https://github.com/openzipkin/zipkin-go) middlewares |
|
||||
| [deepmap/oapi-codegen](https://github.com/deepmap/oapi-codegen) | Automatically generate RESTful API documentation with [OpenAPI](https://swagger.io/specification/) Client and Server Code Generator |
|
||||
| [github.com/swaggo/echo-swagger](https://github.com/swaggo/echo-swagger) | Automatically generate RESTful API documentation with [Swagger](https://swagger.io/) 2.0. |
|
||||
| [github.com/ziflex/lecho](https://github.com/ziflex/lecho) | [Zerolog](https://github.com/rs/zerolog) logging library wrapper for Echo logger interface. |
|
||||
| [github.com/brpaz/echozap](https://github.com/brpaz/echozap) | Uber´s [Zap](https://github.com/uber-go/zap) logging library wrapper for Echo logger interface. |
|
||||
| [github.com/darkweak/souin/plugins/echo](https://github.com/darkweak/souin/tree/master/plugins/echo) | HTTP cache system based on [Souin](https://github.com/darkweak/souin) to automatically get your endpoints cached. It supports some distributed and non-distributed storage systems depending your needs. |
|
||||
| [github.com/mikestefanello/pagoda](https://github.com/mikestefanello/pagoda) | Rapid, easy full-stack web development starter kit built with Echo.
|
||||
| Repository | Description |
|
||||
|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [github.com/labstack/echo-contrib](https://github.com/labstack/echo-contrib) | (by Echo team) [casbin](https://github.com/casbin/casbin), [gorilla/sessions](https://github.com/gorilla/sessions), [jaegertracing](github.com/uber/jaeger-client-go), [prometheus](https://github.com/prometheus/client_golang/), [pprof](https://pkg.go.dev/net/http/pprof), [zipkin](https://github.com/openzipkin/zipkin-go) middlewares |
|
||||
| [deepmap/oapi-codegen](https://github.com/deepmap/oapi-codegen) | Automatically generate RESTful API documentation with [OpenAPI](https://swagger.io/specification/) Client and Server Code Generator |
|
||||
| [github.com/swaggo/echo-swagger](https://github.com/swaggo/echo-swagger) | Automatically generate RESTful API documentation with [Swagger](https://swagger.io/) 2.0. |
|
||||
| [github.com/ziflex/lecho](https://github.com/ziflex/lecho) | [Zerolog](https://github.com/rs/zerolog) logging library wrapper for Echo logger interface. |
|
||||
| [github.com/brpaz/echozap](https://github.com/brpaz/echozap) | Uber´s [Zap](https://github.com/uber-go/zap) logging library wrapper for Echo logger interface. |
|
||||
| [github.com/darkweak/souin/plugins/echo](https://github.com/darkweak/souin/tree/master/plugins/echo) | HTTP cache system based on [Souin](https://github.com/darkweak/souin) to automatically get your endpoints cached. It supports some distributed and non-distributed storage systems depending your needs. |
|
||||
| [github.com/mikestefanello/pagoda](https://github.com/mikestefanello/pagoda) | Rapid, easy full-stack web development starter kit built with Echo. |
|
||||
| [github.com/go-woo/protoc-gen-echo](https://github.com/go-woo/protoc-gen-echo) | ProtoBuf generate Echo server side code |
|
||||
|
||||
Please send a PR to add your own library here.
|
||||
|
||||
|
||||
197
vendor/github.com/labstack/echo/v4/binder.go
generated
vendored
197
vendor/github.com/labstack/echo/v4/binder.go
generated
vendored
@@ -1,6 +1,8 @@
|
||||
package echo
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -52,8 +54,11 @@ import (
|
||||
* time
|
||||
* duration
|
||||
* BindUnmarshaler() interface
|
||||
* TextUnmarshaler() interface
|
||||
* JSONUnmarshaler() interface
|
||||
* UnixTime() - converts unix time (integer) to time.Time
|
||||
* UnixTimeNano() - converts unix time with nano second precision (integer) to time.Time
|
||||
* UnixTimeMilli() - converts unix time with millisecond precision (integer) to time.Time
|
||||
* UnixTimeNano() - converts unix time with nanosecond precision (integer) to time.Time
|
||||
* CustomFunc() - callback function for your custom conversion logic. Signature `func(values []string) []error`
|
||||
*/
|
||||
|
||||
@@ -204,7 +209,7 @@ func (b *ValueBinder) CustomFunc(sourceParam string, customFunc func(values []st
|
||||
return b.customFunc(sourceParam, customFunc, false)
|
||||
}
|
||||
|
||||
// MustCustomFunc requires parameter values to exist to be bind with Func. Returns error when value does not exist.
|
||||
// MustCustomFunc requires parameter values to exist to bind with Func. Returns error when value does not exist.
|
||||
func (b *ValueBinder) MustCustomFunc(sourceParam string, customFunc func(values []string) []error) *ValueBinder {
|
||||
return b.customFunc(sourceParam, customFunc, true)
|
||||
}
|
||||
@@ -241,7 +246,7 @@ func (b *ValueBinder) String(sourceParam string, dest *string) *ValueBinder {
|
||||
return b
|
||||
}
|
||||
|
||||
// MustString requires parameter value to exist to be bind to string variable. Returns error when value does not exist
|
||||
// MustString requires parameter value to exist to bind to string variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustString(sourceParam string, dest *string) *ValueBinder {
|
||||
if b.failFast && b.errors != nil {
|
||||
return b
|
||||
@@ -270,7 +275,7 @@ func (b *ValueBinder) Strings(sourceParam string, dest *[]string) *ValueBinder {
|
||||
return b
|
||||
}
|
||||
|
||||
// MustStrings requires parameter values to exist to be bind to slice of string variables. Returns error when value does not exist
|
||||
// MustStrings requires parameter values to exist to bind to slice of string variables. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustStrings(sourceParam string, dest *[]string) *ValueBinder {
|
||||
if b.failFast && b.errors != nil {
|
||||
return b
|
||||
@@ -302,7 +307,7 @@ func (b *ValueBinder) BindUnmarshaler(sourceParam string, dest BindUnmarshaler)
|
||||
return b
|
||||
}
|
||||
|
||||
// MustBindUnmarshaler requires parameter value to exist to be bind to destination implementing BindUnmarshaler interface.
|
||||
// MustBindUnmarshaler requires parameter value to exist to bind to destination implementing BindUnmarshaler interface.
|
||||
// Returns error when value does not exist
|
||||
func (b *ValueBinder) MustBindUnmarshaler(sourceParam string, dest BindUnmarshaler) *ValueBinder {
|
||||
if b.failFast && b.errors != nil {
|
||||
@@ -321,13 +326,85 @@ func (b *ValueBinder) MustBindUnmarshaler(sourceParam string, dest BindUnmarshal
|
||||
return b
|
||||
}
|
||||
|
||||
// JSONUnmarshaler binds parameter to destination implementing json.Unmarshaler interface
|
||||
func (b *ValueBinder) JSONUnmarshaler(sourceParam string, dest json.Unmarshaler) *ValueBinder {
|
||||
if b.failFast && b.errors != nil {
|
||||
return b
|
||||
}
|
||||
|
||||
tmp := b.ValueFunc(sourceParam)
|
||||
if tmp == "" {
|
||||
return b
|
||||
}
|
||||
|
||||
if err := dest.UnmarshalJSON([]byte(tmp)); err != nil {
|
||||
b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to json.Unmarshaler interface", err))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// MustJSONUnmarshaler requires parameter value to exist to bind to destination implementing json.Unmarshaler interface.
|
||||
// Returns error when value does not exist
|
||||
func (b *ValueBinder) MustJSONUnmarshaler(sourceParam string, dest json.Unmarshaler) *ValueBinder {
|
||||
if b.failFast && b.errors != nil {
|
||||
return b
|
||||
}
|
||||
|
||||
tmp := b.ValueFunc(sourceParam)
|
||||
if tmp == "" {
|
||||
b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "required field value is empty", nil))
|
||||
return b
|
||||
}
|
||||
|
||||
if err := dest.UnmarshalJSON([]byte(tmp)); err != nil {
|
||||
b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to json.Unmarshaler interface", err))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// TextUnmarshaler binds parameter to destination implementing encoding.TextUnmarshaler interface
|
||||
func (b *ValueBinder) TextUnmarshaler(sourceParam string, dest encoding.TextUnmarshaler) *ValueBinder {
|
||||
if b.failFast && b.errors != nil {
|
||||
return b
|
||||
}
|
||||
|
||||
tmp := b.ValueFunc(sourceParam)
|
||||
if tmp == "" {
|
||||
return b
|
||||
}
|
||||
|
||||
if err := dest.UnmarshalText([]byte(tmp)); err != nil {
|
||||
b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to encoding.TextUnmarshaler interface", err))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// MustTextUnmarshaler requires parameter value to exist to bind to destination implementing encoding.TextUnmarshaler interface.
|
||||
// Returns error when value does not exist
|
||||
func (b *ValueBinder) MustTextUnmarshaler(sourceParam string, dest encoding.TextUnmarshaler) *ValueBinder {
|
||||
if b.failFast && b.errors != nil {
|
||||
return b
|
||||
}
|
||||
|
||||
tmp := b.ValueFunc(sourceParam)
|
||||
if tmp == "" {
|
||||
b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "required field value is empty", nil))
|
||||
return b
|
||||
}
|
||||
|
||||
if err := dest.UnmarshalText([]byte(tmp)); err != nil {
|
||||
b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to encoding.TextUnmarshaler interface", err))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// BindWithDelimiter binds parameter to destination by suitable conversion function.
|
||||
// Delimiter is used before conversion to split parameter value to separate values
|
||||
func (b *ValueBinder) BindWithDelimiter(sourceParam string, dest interface{}, delimiter string) *ValueBinder {
|
||||
return b.bindWithDelimiter(sourceParam, dest, delimiter, false)
|
||||
}
|
||||
|
||||
// MustBindWithDelimiter requires parameter value to exist to be bind destination by suitable conversion function.
|
||||
// MustBindWithDelimiter requires parameter value to exist to bind destination by suitable conversion function.
|
||||
// Delimiter is used before conversion to split parameter value to separate values
|
||||
func (b *ValueBinder) MustBindWithDelimiter(sourceParam string, dest interface{}, delimiter string) *ValueBinder {
|
||||
return b.bindWithDelimiter(sourceParam, dest, delimiter, true)
|
||||
@@ -376,7 +453,7 @@ func (b *ValueBinder) Int64(sourceParam string, dest *int64) *ValueBinder {
|
||||
return b.intValue(sourceParam, dest, 64, false)
|
||||
}
|
||||
|
||||
// MustInt64 requires parameter value to exist to be bind to int64 variable. Returns error when value does not exist
|
||||
// MustInt64 requires parameter value to exist to bind to int64 variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustInt64(sourceParam string, dest *int64) *ValueBinder {
|
||||
return b.intValue(sourceParam, dest, 64, true)
|
||||
}
|
||||
@@ -386,7 +463,7 @@ func (b *ValueBinder) Int32(sourceParam string, dest *int32) *ValueBinder {
|
||||
return b.intValue(sourceParam, dest, 32, false)
|
||||
}
|
||||
|
||||
// MustInt32 requires parameter value to exist to be bind to int32 variable. Returns error when value does not exist
|
||||
// MustInt32 requires parameter value to exist to bind to int32 variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustInt32(sourceParam string, dest *int32) *ValueBinder {
|
||||
return b.intValue(sourceParam, dest, 32, true)
|
||||
}
|
||||
@@ -396,7 +473,7 @@ func (b *ValueBinder) Int16(sourceParam string, dest *int16) *ValueBinder {
|
||||
return b.intValue(sourceParam, dest, 16, false)
|
||||
}
|
||||
|
||||
// MustInt16 requires parameter value to exist to be bind to int16 variable. Returns error when value does not exist
|
||||
// MustInt16 requires parameter value to exist to bind to int16 variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustInt16(sourceParam string, dest *int16) *ValueBinder {
|
||||
return b.intValue(sourceParam, dest, 16, true)
|
||||
}
|
||||
@@ -406,7 +483,7 @@ func (b *ValueBinder) Int8(sourceParam string, dest *int8) *ValueBinder {
|
||||
return b.intValue(sourceParam, dest, 8, false)
|
||||
}
|
||||
|
||||
// MustInt8 requires parameter value to exist to be bind to int8 variable. Returns error when value does not exist
|
||||
// MustInt8 requires parameter value to exist to bind to int8 variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustInt8(sourceParam string, dest *int8) *ValueBinder {
|
||||
return b.intValue(sourceParam, dest, 8, true)
|
||||
}
|
||||
@@ -416,7 +493,7 @@ func (b *ValueBinder) Int(sourceParam string, dest *int) *ValueBinder {
|
||||
return b.intValue(sourceParam, dest, 0, false)
|
||||
}
|
||||
|
||||
// MustInt requires parameter value to exist to be bind to int variable. Returns error when value does not exist
|
||||
// MustInt requires parameter value to exist to bind to int variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustInt(sourceParam string, dest *int) *ValueBinder {
|
||||
return b.intValue(sourceParam, dest, 0, true)
|
||||
}
|
||||
@@ -544,7 +621,7 @@ func (b *ValueBinder) Int64s(sourceParam string, dest *[]int64) *ValueBinder {
|
||||
return b.intsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustInt64s requires parameter value to exist to be bind to int64 slice variable. Returns error when value does not exist
|
||||
// MustInt64s requires parameter value to exist to bind to int64 slice variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustInt64s(sourceParam string, dest *[]int64) *ValueBinder {
|
||||
return b.intsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -554,7 +631,7 @@ func (b *ValueBinder) Int32s(sourceParam string, dest *[]int32) *ValueBinder {
|
||||
return b.intsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustInt32s requires parameter value to exist to be bind to int32 slice variable. Returns error when value does not exist
|
||||
// MustInt32s requires parameter value to exist to bind to int32 slice variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustInt32s(sourceParam string, dest *[]int32) *ValueBinder {
|
||||
return b.intsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -564,7 +641,7 @@ func (b *ValueBinder) Int16s(sourceParam string, dest *[]int16) *ValueBinder {
|
||||
return b.intsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustInt16s requires parameter value to exist to be bind to int16 slice variable. Returns error when value does not exist
|
||||
// MustInt16s requires parameter value to exist to bind to int16 slice variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustInt16s(sourceParam string, dest *[]int16) *ValueBinder {
|
||||
return b.intsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -574,7 +651,7 @@ func (b *ValueBinder) Int8s(sourceParam string, dest *[]int8) *ValueBinder {
|
||||
return b.intsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustInt8s requires parameter value to exist to be bind to int8 slice variable. Returns error when value does not exist
|
||||
// MustInt8s requires parameter value to exist to bind to int8 slice variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustInt8s(sourceParam string, dest *[]int8) *ValueBinder {
|
||||
return b.intsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -584,7 +661,7 @@ func (b *ValueBinder) Ints(sourceParam string, dest *[]int) *ValueBinder {
|
||||
return b.intsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustInts requires parameter value to exist to be bind to int slice variable. Returns error when value does not exist
|
||||
// MustInts requires parameter value to exist to bind to int slice variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustInts(sourceParam string, dest *[]int) *ValueBinder {
|
||||
return b.intsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -594,7 +671,7 @@ func (b *ValueBinder) Uint64(sourceParam string, dest *uint64) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 64, false)
|
||||
}
|
||||
|
||||
// MustUint64 requires parameter value to exist to be bind to uint64 variable. Returns error when value does not exist
|
||||
// MustUint64 requires parameter value to exist to bind to uint64 variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustUint64(sourceParam string, dest *uint64) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 64, true)
|
||||
}
|
||||
@@ -604,7 +681,7 @@ func (b *ValueBinder) Uint32(sourceParam string, dest *uint32) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 32, false)
|
||||
}
|
||||
|
||||
// MustUint32 requires parameter value to exist to be bind to uint32 variable. Returns error when value does not exist
|
||||
// MustUint32 requires parameter value to exist to bind to uint32 variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustUint32(sourceParam string, dest *uint32) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 32, true)
|
||||
}
|
||||
@@ -614,7 +691,7 @@ func (b *ValueBinder) Uint16(sourceParam string, dest *uint16) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 16, false)
|
||||
}
|
||||
|
||||
// MustUint16 requires parameter value to exist to be bind to uint16 variable. Returns error when value does not exist
|
||||
// MustUint16 requires parameter value to exist to bind to uint16 variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustUint16(sourceParam string, dest *uint16) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 16, true)
|
||||
}
|
||||
@@ -624,7 +701,7 @@ func (b *ValueBinder) Uint8(sourceParam string, dest *uint8) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 8, false)
|
||||
}
|
||||
|
||||
// MustUint8 requires parameter value to exist to be bind to uint8 variable. Returns error when value does not exist
|
||||
// MustUint8 requires parameter value to exist to bind to uint8 variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustUint8(sourceParam string, dest *uint8) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 8, true)
|
||||
}
|
||||
@@ -634,7 +711,7 @@ func (b *ValueBinder) Byte(sourceParam string, dest *byte) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 8, false)
|
||||
}
|
||||
|
||||
// MustByte requires parameter value to exist to be bind to byte variable. Returns error when value does not exist
|
||||
// MustByte requires parameter value to exist to bind to byte variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustByte(sourceParam string, dest *byte) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 8, true)
|
||||
}
|
||||
@@ -644,7 +721,7 @@ func (b *ValueBinder) Uint(sourceParam string, dest *uint) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 0, false)
|
||||
}
|
||||
|
||||
// MustUint requires parameter value to exist to be bind to uint variable. Returns error when value does not exist
|
||||
// MustUint requires parameter value to exist to bind to uint variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustUint(sourceParam string, dest *uint) *ValueBinder {
|
||||
return b.uintValue(sourceParam, dest, 0, true)
|
||||
}
|
||||
@@ -772,7 +849,7 @@ func (b *ValueBinder) Uint64s(sourceParam string, dest *[]uint64) *ValueBinder {
|
||||
return b.uintsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustUint64s requires parameter value to exist to be bind to uint64 slice variable. Returns error when value does not exist
|
||||
// MustUint64s requires parameter value to exist to bind to uint64 slice variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustUint64s(sourceParam string, dest *[]uint64) *ValueBinder {
|
||||
return b.uintsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -782,7 +859,7 @@ func (b *ValueBinder) Uint32s(sourceParam string, dest *[]uint32) *ValueBinder {
|
||||
return b.uintsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustUint32s requires parameter value to exist to be bind to uint32 slice variable. Returns error when value does not exist
|
||||
// MustUint32s requires parameter value to exist to bind to uint32 slice variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustUint32s(sourceParam string, dest *[]uint32) *ValueBinder {
|
||||
return b.uintsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -792,7 +869,7 @@ func (b *ValueBinder) Uint16s(sourceParam string, dest *[]uint16) *ValueBinder {
|
||||
return b.uintsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustUint16s requires parameter value to exist to be bind to uint16 slice variable. Returns error when value does not exist
|
||||
// MustUint16s requires parameter value to exist to bind to uint16 slice variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustUint16s(sourceParam string, dest *[]uint16) *ValueBinder {
|
||||
return b.uintsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -802,7 +879,7 @@ func (b *ValueBinder) Uint8s(sourceParam string, dest *[]uint8) *ValueBinder {
|
||||
return b.uintsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustUint8s requires parameter value to exist to be bind to uint8 slice variable. Returns error when value does not exist
|
||||
// MustUint8s requires parameter value to exist to bind to uint8 slice variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustUint8s(sourceParam string, dest *[]uint8) *ValueBinder {
|
||||
return b.uintsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -812,7 +889,7 @@ func (b *ValueBinder) Uints(sourceParam string, dest *[]uint) *ValueBinder {
|
||||
return b.uintsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustUints requires parameter value to exist to be bind to uint slice variable. Returns error when value does not exist
|
||||
// MustUints requires parameter value to exist to bind to uint slice variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustUints(sourceParam string, dest *[]uint) *ValueBinder {
|
||||
return b.uintsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -822,7 +899,7 @@ func (b *ValueBinder) Bool(sourceParam string, dest *bool) *ValueBinder {
|
||||
return b.boolValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustBool requires parameter value to exist to be bind to bool variable. Returns error when value does not exist
|
||||
// MustBool requires parameter value to exist to bind to bool variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustBool(sourceParam string, dest *bool) *ValueBinder {
|
||||
return b.boolValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -887,7 +964,7 @@ func (b *ValueBinder) Bools(sourceParam string, dest *[]bool) *ValueBinder {
|
||||
return b.boolsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustBools requires parameter values to exist to be bind to slice of bool variables. Returns error when values does not exist
|
||||
// MustBools requires parameter values to exist to bind to slice of bool variables. Returns error when values does not exist
|
||||
func (b *ValueBinder) MustBools(sourceParam string, dest *[]bool) *ValueBinder {
|
||||
return b.boolsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -897,7 +974,7 @@ func (b *ValueBinder) Float64(sourceParam string, dest *float64) *ValueBinder {
|
||||
return b.floatValue(sourceParam, dest, 64, false)
|
||||
}
|
||||
|
||||
// MustFloat64 requires parameter value to exist to be bind to float64 variable. Returns error when value does not exist
|
||||
// MustFloat64 requires parameter value to exist to bind to float64 variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustFloat64(sourceParam string, dest *float64) *ValueBinder {
|
||||
return b.floatValue(sourceParam, dest, 64, true)
|
||||
}
|
||||
@@ -907,7 +984,7 @@ func (b *ValueBinder) Float32(sourceParam string, dest *float32) *ValueBinder {
|
||||
return b.floatValue(sourceParam, dest, 32, false)
|
||||
}
|
||||
|
||||
// MustFloat32 requires parameter value to exist to be bind to float32 variable. Returns error when value does not exist
|
||||
// MustFloat32 requires parameter value to exist to bind to float32 variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustFloat32(sourceParam string, dest *float32) *ValueBinder {
|
||||
return b.floatValue(sourceParam, dest, 32, true)
|
||||
}
|
||||
@@ -992,7 +1069,7 @@ func (b *ValueBinder) Float64s(sourceParam string, dest *[]float64) *ValueBinder
|
||||
return b.floatsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustFloat64s requires parameter values to exist to be bind to slice of float64 variables. Returns error when values does not exist
|
||||
// MustFloat64s requires parameter values to exist to bind to slice of float64 variables. Returns error when values does not exist
|
||||
func (b *ValueBinder) MustFloat64s(sourceParam string, dest *[]float64) *ValueBinder {
|
||||
return b.floatsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -1002,7 +1079,7 @@ func (b *ValueBinder) Float32s(sourceParam string, dest *[]float32) *ValueBinder
|
||||
return b.floatsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustFloat32s requires parameter values to exist to be bind to slice of float32 variables. Returns error when values does not exist
|
||||
// MustFloat32s requires parameter values to exist to bind to slice of float32 variables. Returns error when values does not exist
|
||||
func (b *ValueBinder) MustFloat32s(sourceParam string, dest *[]float32) *ValueBinder {
|
||||
return b.floatsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -1012,7 +1089,7 @@ func (b *ValueBinder) Time(sourceParam string, dest *time.Time, layout string) *
|
||||
return b.time(sourceParam, dest, layout, false)
|
||||
}
|
||||
|
||||
// MustTime requires parameter value to exist to be bind to time.Time variable. Returns error when value does not exist
|
||||
// MustTime requires parameter value to exist to bind to time.Time variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustTime(sourceParam string, dest *time.Time, layout string) *ValueBinder {
|
||||
return b.time(sourceParam, dest, layout, true)
|
||||
}
|
||||
@@ -1043,7 +1120,7 @@ func (b *ValueBinder) Times(sourceParam string, dest *[]time.Time, layout string
|
||||
return b.times(sourceParam, dest, layout, false)
|
||||
}
|
||||
|
||||
// MustTimes requires parameter values to exist to be bind to slice of time.Time variables. Returns error when values does not exist
|
||||
// MustTimes requires parameter values to exist to bind to slice of time.Time variables. Returns error when values does not exist
|
||||
func (b *ValueBinder) MustTimes(sourceParam string, dest *[]time.Time, layout string) *ValueBinder {
|
||||
return b.times(sourceParam, dest, layout, true)
|
||||
}
|
||||
@@ -1084,7 +1161,7 @@ func (b *ValueBinder) Duration(sourceParam string, dest *time.Duration) *ValueBi
|
||||
return b.duration(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustDuration requires parameter value to exist to be bind to time.Duration variable. Returns error when value does not exist
|
||||
// MustDuration requires parameter value to exist to bind to time.Duration variable. Returns error when value does not exist
|
||||
func (b *ValueBinder) MustDuration(sourceParam string, dest *time.Duration) *ValueBinder {
|
||||
return b.duration(sourceParam, dest, true)
|
||||
}
|
||||
@@ -1115,7 +1192,7 @@ func (b *ValueBinder) Durations(sourceParam string, dest *[]time.Duration) *Valu
|
||||
return b.durationsValue(sourceParam, dest, false)
|
||||
}
|
||||
|
||||
// MustDurations requires parameter values to exist to be bind to slice of time.Duration variables. Returns error when values does not exist
|
||||
// MustDurations requires parameter values to exist to bind to slice of time.Duration variables. Returns error when values does not exist
|
||||
func (b *ValueBinder) MustDurations(sourceParam string, dest *[]time.Duration) *ValueBinder {
|
||||
return b.durationsValue(sourceParam, dest, true)
|
||||
}
|
||||
@@ -1161,10 +1238,10 @@ func (b *ValueBinder) durations(sourceParam string, values []string, dest *[]tim
|
||||
// Note:
|
||||
// * time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
|
||||
func (b *ValueBinder) UnixTime(sourceParam string, dest *time.Time) *ValueBinder {
|
||||
return b.unixTime(sourceParam, dest, false, false)
|
||||
return b.unixTime(sourceParam, dest, false, time.Second)
|
||||
}
|
||||
|
||||
// MustUnixTime requires parameter value to exist to be bind to time.Duration variable (in local Time corresponding
|
||||
// MustUnixTime requires parameter value to exist to bind to time.Duration variable (in local time corresponding
|
||||
// to the given Unix time). Returns error when value does not exist.
|
||||
//
|
||||
// Example: 1609180603 bind to 2020-12-28T18:36:43.000000000+00:00
|
||||
@@ -1172,10 +1249,31 @@ func (b *ValueBinder) UnixTime(sourceParam string, dest *time.Time) *ValueBinder
|
||||
// Note:
|
||||
// * time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
|
||||
func (b *ValueBinder) MustUnixTime(sourceParam string, dest *time.Time) *ValueBinder {
|
||||
return b.unixTime(sourceParam, dest, true, false)
|
||||
return b.unixTime(sourceParam, dest, true, time.Second)
|
||||
}
|
||||
|
||||
// UnixTimeNano binds parameter to time.Time variable (in local Time corresponding to the given Unix time in nano second precision).
|
||||
// UnixTimeMilli binds parameter to time.Time variable (in local time corresponding to the given Unix time in millisecond precision).
|
||||
//
|
||||
// Example: 1647184410140 bind to 2022-03-13T15:13:30.140000000+00:00
|
||||
//
|
||||
// Note:
|
||||
// * time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
|
||||
func (b *ValueBinder) UnixTimeMilli(sourceParam string, dest *time.Time) *ValueBinder {
|
||||
return b.unixTime(sourceParam, dest, false, time.Millisecond)
|
||||
}
|
||||
|
||||
// MustUnixTimeMilli requires parameter value to exist to bind to time.Duration variable (in local time corresponding
|
||||
// to the given Unix time in millisecond precision). Returns error when value does not exist.
|
||||
//
|
||||
// Example: 1647184410140 bind to 2022-03-13T15:13:30.140000000+00:00
|
||||
//
|
||||
// Note:
|
||||
// * time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
|
||||
func (b *ValueBinder) MustUnixTimeMilli(sourceParam string, dest *time.Time) *ValueBinder {
|
||||
return b.unixTime(sourceParam, dest, true, time.Millisecond)
|
||||
}
|
||||
|
||||
// UnixTimeNano binds parameter to time.Time variable (in local time corresponding to the given Unix time in nanosecond precision).
|
||||
//
|
||||
// Example: 1609180603123456789 binds to 2020-12-28T18:36:43.123456789+00:00
|
||||
// Example: 1000000000 binds to 1970-01-01T00:00:01.000000000+00:00
|
||||
@@ -1185,10 +1283,10 @@ func (b *ValueBinder) MustUnixTime(sourceParam string, dest *time.Time) *ValueBi
|
||||
// * time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
|
||||
// * Javascript's Number type only has about 53 bits of precision (Number.MAX_SAFE_INTEGER = 9007199254740991). Compare it to 1609180603123456789 in example.
|
||||
func (b *ValueBinder) UnixTimeNano(sourceParam string, dest *time.Time) *ValueBinder {
|
||||
return b.unixTime(sourceParam, dest, false, true)
|
||||
return b.unixTime(sourceParam, dest, false, time.Nanosecond)
|
||||
}
|
||||
|
||||
// MustUnixTimeNano requires parameter value to exist to be bind to time.Duration variable (in local Time corresponding
|
||||
// MustUnixTimeNano requires parameter value to exist to bind to time.Duration variable (in local Time corresponding
|
||||
// to the given Unix time value in nano second precision). Returns error when value does not exist.
|
||||
//
|
||||
// Example: 1609180603123456789 binds to 2020-12-28T18:36:43.123456789+00:00
|
||||
@@ -1199,10 +1297,10 @@ func (b *ValueBinder) UnixTimeNano(sourceParam string, dest *time.Time) *ValueBi
|
||||
// * time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
|
||||
// * Javascript's Number type only has about 53 bits of precision (Number.MAX_SAFE_INTEGER = 9007199254740991). Compare it to 1609180603123456789 in example.
|
||||
func (b *ValueBinder) MustUnixTimeNano(sourceParam string, dest *time.Time) *ValueBinder {
|
||||
return b.unixTime(sourceParam, dest, true, true)
|
||||
return b.unixTime(sourceParam, dest, true, time.Nanosecond)
|
||||
}
|
||||
|
||||
func (b *ValueBinder) unixTime(sourceParam string, dest *time.Time, valueMustExist bool, isNano bool) *ValueBinder {
|
||||
func (b *ValueBinder) unixTime(sourceParam string, dest *time.Time, valueMustExist bool, precision time.Duration) *ValueBinder {
|
||||
if b.failFast && b.errors != nil {
|
||||
return b
|
||||
}
|
||||
@@ -1221,10 +1319,13 @@ func (b *ValueBinder) unixTime(sourceParam string, dest *time.Time, valueMustExi
|
||||
return b
|
||||
}
|
||||
|
||||
if isNano {
|
||||
*dest = time.Unix(0, n)
|
||||
} else {
|
||||
switch precision {
|
||||
case time.Second:
|
||||
*dest = time.Unix(n, 0)
|
||||
case time.Millisecond:
|
||||
*dest = time.Unix(n/1e3, (n%1e3)*1e6) // TODO: time.UnixMilli(n) exists since Go1.17 switch to that when min version allows
|
||||
case time.Nanosecond:
|
||||
*dest = time.Unix(0, n)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
20
vendor/github.com/labstack/echo/v4/echo.go
generated
vendored
20
vendor/github.com/labstack/echo/v4/echo.go
generated
vendored
@@ -183,6 +183,8 @@ const (
|
||||
PROPFIND = "PROPFIND"
|
||||
// REPORT Method can be used to get information about a resource, see rfc 3253
|
||||
REPORT = "REPORT"
|
||||
// RouteNotFound is special method type for routes handling "route not found" (404) cases
|
||||
RouteNotFound = "echo_route_not_found"
|
||||
)
|
||||
|
||||
// Headers
|
||||
@@ -246,7 +248,7 @@ const (
|
||||
|
||||
const (
|
||||
// Version of Echo
|
||||
Version = "4.7.2"
|
||||
Version = "4.8.0"
|
||||
website = "https://echo.labstack.com"
|
||||
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
|
||||
banner = `
|
||||
@@ -480,8 +482,21 @@ func (e *Echo) TRACE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
|
||||
return e.Add(http.MethodTrace, path, h, m...)
|
||||
}
|
||||
|
||||
// Any registers a new route for all HTTP methods and path with matching handler
|
||||
// RouteNotFound registers a special-case route which is executed when no other route is found (i.e. HTTP 404 cases)
|
||||
// for current request URL.
|
||||
// Path supports static and named/any parameters just like other http method is defined. Generally path is ended with
|
||||
// wildcard/match-any character (`/*`, `/download/*` etc).
|
||||
//
|
||||
// Example: `e.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })`
|
||||
func (e *Echo) RouteNotFound(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
|
||||
return e.Add(RouteNotFound, path, h, m...)
|
||||
}
|
||||
|
||||
// Any registers a new route for all HTTP methods (supported by Echo) and path with matching handler
|
||||
// in the router with optional route-level middleware.
|
||||
//
|
||||
// Note: this method only adds specific set of supported HTTP methods as handler and is not true
|
||||
// "catch-any-arbitrary-method" way of matching requests.
|
||||
func (e *Echo) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route {
|
||||
routes := make([]*Route, len(methods))
|
||||
for i, m := range methods {
|
||||
@@ -515,6 +530,7 @@ func (e *Echo) File(path, file string, m ...MiddlewareFunc) *Route {
|
||||
func (e *Echo) add(host, method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route {
|
||||
name := handlerName(handler)
|
||||
router := e.findRouter(host)
|
||||
// FIXME: when handler+middleware are both nil ... make it behave like handler removal
|
||||
router.Add(method, path, func(c Context) error {
|
||||
h := applyMiddleware(handler, middleware...)
|
||||
return h(c)
|
||||
|
||||
7
vendor/github.com/labstack/echo/v4/group.go
generated
vendored
7
vendor/github.com/labstack/echo/v4/group.go
generated
vendored
@@ -107,6 +107,13 @@ func (g *Group) File(path, file string) {
|
||||
g.file(path, file, g.GET)
|
||||
}
|
||||
|
||||
// RouteNotFound implements `Echo#RouteNotFound()` for sub-routes within the Group.
|
||||
//
|
||||
// Example: `g.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })`
|
||||
func (g *Group) RouteNotFound(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
|
||||
return g.Add(RouteNotFound, path, h, m...)
|
||||
}
|
||||
|
||||
// Add implements `Echo#Add()` for sub-routes within the Group.
|
||||
func (g *Group) Add(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route {
|
||||
// Combine into a new slice to avoid accidentally passing the same slice for
|
||||
|
||||
6
vendor/github.com/labstack/echo/v4/middleware/basic_auth.go
generated
vendored
6
vendor/github.com/labstack/echo/v4/middleware/basic_auth.go
generated
vendored
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/base64"
|
||||
"strconv"
|
||||
"strings"
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
@@ -74,10 +75,13 @@ func BasicAuthWithConfig(config BasicAuthConfig) echo.MiddlewareFunc {
|
||||
l := len(basic)
|
||||
|
||||
if len(auth) > l+1 && strings.EqualFold(auth[:l], basic) {
|
||||
// Invalid base64 shouldn't be treated as error
|
||||
// instead should be treated as invalid client input
|
||||
b, err := base64.StdEncoding.DecodeString(auth[l+1:])
|
||||
if err != nil {
|
||||
return err
|
||||
return echo.NewHTTPError(http.StatusBadRequest).SetInternal(err)
|
||||
}
|
||||
|
||||
cred := string(b)
|
||||
for i := 0; i < len(cred); i++ {
|
||||
if cred[i] == ':' {
|
||||
|
||||
8
vendor/github.com/labstack/echo/v4/middleware/logger.go
generated
vendored
8
vendor/github.com/labstack/echo/v4/middleware/logger.go
generated
vendored
@@ -23,6 +23,8 @@ type (
|
||||
// Tags to construct the logger format.
|
||||
//
|
||||
// - time_unix
|
||||
// - time_unix_milli
|
||||
// - time_unix_micro
|
||||
// - time_unix_nano
|
||||
// - time_rfc3339
|
||||
// - time_rfc3339_nano
|
||||
@@ -126,6 +128,12 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc {
|
||||
switch tag {
|
||||
case "time_unix":
|
||||
return buf.WriteString(strconv.FormatInt(time.Now().Unix(), 10))
|
||||
case "time_unix_milli":
|
||||
// go 1.17 or later, it supports time#UnixMilli()
|
||||
return buf.WriteString(strconv.FormatInt(time.Now().UnixNano()/1000000, 10))
|
||||
case "time_unix_micro":
|
||||
// go 1.17 or later, it supports time#UnixMicro()
|
||||
return buf.WriteString(strconv.FormatInt(time.Now().UnixNano()/1000, 10))
|
||||
case "time_unix_nano":
|
||||
return buf.WriteString(strconv.FormatInt(time.Now().UnixNano(), 10))
|
||||
case "time_rfc3339":
|
||||
|
||||
6
vendor/github.com/labstack/echo/v4/middleware/request_logger.go
generated
vendored
6
vendor/github.com/labstack/echo/v4/middleware/request_logger.go
generated
vendored
@@ -2,9 +2,10 @@ package middleware
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/labstack/echo/v4"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// Example for `fmt.Printf`
|
||||
@@ -264,7 +265,8 @@ func (config RequestLoggerConfig) ToMiddleware() (echo.MiddlewareFunc, error) {
|
||||
if config.LogStatus {
|
||||
v.Status = res.Status
|
||||
if err != nil {
|
||||
if httpErr, ok := err.(*echo.HTTPError); ok {
|
||||
var httpErr *echo.HTTPError
|
||||
if errors.As(err, &httpErr) {
|
||||
v.Status = httpErr.Code
|
||||
}
|
||||
}
|
||||
|
||||
5
vendor/github.com/labstack/echo/v4/middleware/static.go
generated
vendored
5
vendor/github.com/labstack/echo/v4/middleware/static.go
generated
vendored
@@ -1,6 +1,7 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
@@ -196,8 +197,8 @@ func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc {
|
||||
return err
|
||||
}
|
||||
|
||||
he, ok := err.(*echo.HTTPError)
|
||||
if !(ok && config.HTML5 && he.Code == http.StatusNotFound) {
|
||||
var he *echo.HTTPError
|
||||
if !(errors.As(err, &he) && config.HTML5 && he.Code == http.StatusNotFound) {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
323
vendor/github.com/labstack/echo/v4/router.go
generated
vendored
323
vendor/github.com/labstack/echo/v4/router.go
generated
vendored
@@ -19,30 +19,39 @@ type (
|
||||
prefix string
|
||||
parent *node
|
||||
staticChildren children
|
||||
ppath string
|
||||
pnames []string
|
||||
methodHandler *methodHandler
|
||||
originalPath string
|
||||
methods *routeMethods
|
||||
paramChild *node
|
||||
anyChild *node
|
||||
paramsCount int
|
||||
// isLeaf indicates that node does not have child routes
|
||||
isLeaf bool
|
||||
// isHandler indicates that node has at least one handler registered to it
|
||||
isHandler bool
|
||||
|
||||
// notFoundHandler is handler registered with RouteNotFound method and is executed for 404 cases
|
||||
notFoundHandler *routeMethod
|
||||
}
|
||||
kind uint8
|
||||
children []*node
|
||||
methodHandler struct {
|
||||
connect HandlerFunc
|
||||
delete HandlerFunc
|
||||
get HandlerFunc
|
||||
head HandlerFunc
|
||||
options HandlerFunc
|
||||
patch HandlerFunc
|
||||
post HandlerFunc
|
||||
propfind HandlerFunc
|
||||
put HandlerFunc
|
||||
trace HandlerFunc
|
||||
report HandlerFunc
|
||||
kind uint8
|
||||
children []*node
|
||||
routeMethod struct {
|
||||
ppath string
|
||||
pnames []string
|
||||
handler HandlerFunc
|
||||
}
|
||||
routeMethods struct {
|
||||
connect *routeMethod
|
||||
delete *routeMethod
|
||||
get *routeMethod
|
||||
head *routeMethod
|
||||
options *routeMethod
|
||||
patch *routeMethod
|
||||
post *routeMethod
|
||||
propfind *routeMethod
|
||||
put *routeMethod
|
||||
trace *routeMethod
|
||||
report *routeMethod
|
||||
anyOther map[string]*routeMethod
|
||||
allowHeader string
|
||||
}
|
||||
)
|
||||
@@ -56,7 +65,7 @@ const (
|
||||
anyLabel = byte('*')
|
||||
)
|
||||
|
||||
func (m *methodHandler) isHandler() bool {
|
||||
func (m *routeMethods) isHandler() bool {
|
||||
return m.connect != nil ||
|
||||
m.delete != nil ||
|
||||
m.get != nil ||
|
||||
@@ -67,10 +76,12 @@ func (m *methodHandler) isHandler() bool {
|
||||
m.propfind != nil ||
|
||||
m.put != nil ||
|
||||
m.trace != nil ||
|
||||
m.report != nil
|
||||
m.report != nil ||
|
||||
len(m.anyOther) != 0
|
||||
// RouteNotFound/404 is not considered as a handler
|
||||
}
|
||||
|
||||
func (m *methodHandler) updateAllowHeader() {
|
||||
func (m *routeMethods) updateAllowHeader() {
|
||||
buf := new(bytes.Buffer)
|
||||
buf.WriteString(http.MethodOptions)
|
||||
|
||||
@@ -112,6 +123,10 @@ func (m *methodHandler) updateAllowHeader() {
|
||||
if m.report != nil {
|
||||
buf.WriteString(", REPORT")
|
||||
}
|
||||
for method := range m.anyOther { // for simplicity, we use map and therefore order is not deterministic here
|
||||
buf.WriteString(", ")
|
||||
buf.WriteString(method)
|
||||
}
|
||||
m.allowHeader = buf.String()
|
||||
}
|
||||
|
||||
@@ -119,7 +134,7 @@ func (m *methodHandler) updateAllowHeader() {
|
||||
func NewRouter(e *Echo) *Router {
|
||||
return &Router{
|
||||
tree: &node{
|
||||
methodHandler: new(methodHandler),
|
||||
methods: new(routeMethods),
|
||||
},
|
||||
routes: map[string]*Route{},
|
||||
echo: e,
|
||||
@@ -153,7 +168,7 @@ func (r *Router) Add(method, path string, h HandlerFunc) {
|
||||
}
|
||||
j := i + 1
|
||||
|
||||
r.insert(method, path[:i], nil, staticKind, "", nil)
|
||||
r.insert(method, path[:i], staticKind, routeMethod{})
|
||||
for ; i < lcpIndex && path[i] != '/'; i++ {
|
||||
}
|
||||
|
||||
@@ -163,23 +178,23 @@ func (r *Router) Add(method, path string, h HandlerFunc) {
|
||||
|
||||
if i == lcpIndex {
|
||||
// path node is last fragment of route path. ie. `/users/:id`
|
||||
r.insert(method, path[:i], h, paramKind, ppath, pnames)
|
||||
r.insert(method, path[:i], paramKind, routeMethod{ppath, pnames, h})
|
||||
} else {
|
||||
r.insert(method, path[:i], nil, paramKind, "", nil)
|
||||
r.insert(method, path[:i], paramKind, routeMethod{})
|
||||
}
|
||||
} else if path[i] == '*' {
|
||||
r.insert(method, path[:i], nil, staticKind, "", nil)
|
||||
r.insert(method, path[:i], staticKind, routeMethod{})
|
||||
pnames = append(pnames, "*")
|
||||
r.insert(method, path[:i+1], h, anyKind, ppath, pnames)
|
||||
r.insert(method, path[:i+1], anyKind, routeMethod{ppath, pnames, h})
|
||||
}
|
||||
}
|
||||
|
||||
r.insert(method, path, h, staticKind, ppath, pnames)
|
||||
r.insert(method, path, staticKind, routeMethod{ppath, pnames, h})
|
||||
}
|
||||
|
||||
func (r *Router) insert(method, path string, h HandlerFunc, t kind, ppath string, pnames []string) {
|
||||
func (r *Router) insert(method, path string, t kind, rm routeMethod) {
|
||||
// Adjust max param
|
||||
paramLen := len(pnames)
|
||||
paramLen := len(rm.pnames)
|
||||
if *r.echo.maxParam < paramLen {
|
||||
*r.echo.maxParam = paramLen
|
||||
}
|
||||
@@ -207,25 +222,31 @@ func (r *Router) insert(method, path string, h HandlerFunc, t kind, ppath string
|
||||
// At root node
|
||||
currentNode.label = search[0]
|
||||
currentNode.prefix = search
|
||||
if h != nil {
|
||||
if rm.handler != nil {
|
||||
currentNode.kind = t
|
||||
currentNode.addHandler(method, h)
|
||||
currentNode.ppath = ppath
|
||||
currentNode.pnames = pnames
|
||||
currentNode.addMethod(method, &rm)
|
||||
currentNode.paramsCount = len(rm.pnames)
|
||||
currentNode.originalPath = rm.ppath
|
||||
}
|
||||
currentNode.isLeaf = currentNode.staticChildren == nil && currentNode.paramChild == nil && currentNode.anyChild == nil
|
||||
} else if lcpLen < prefixLen {
|
||||
// Split node
|
||||
// Split node into two before we insert new node.
|
||||
// This happens when we are inserting path that is submatch of any existing inserted paths.
|
||||
// For example, we have node `/test` and now are about to insert `/te/*`. In that case
|
||||
// 1. overlapping part is `/te` that is used as parent node
|
||||
// 2. `st` is part from existing node that is not matching - it gets its own node (child to `/te`)
|
||||
// 3. `/*` is the new part we are about to insert (child to `/te`)
|
||||
n := newNode(
|
||||
currentNode.kind,
|
||||
currentNode.prefix[lcpLen:],
|
||||
currentNode,
|
||||
currentNode.staticChildren,
|
||||
currentNode.methodHandler,
|
||||
currentNode.ppath,
|
||||
currentNode.pnames,
|
||||
currentNode.originalPath,
|
||||
currentNode.methods,
|
||||
currentNode.paramsCount,
|
||||
currentNode.paramChild,
|
||||
currentNode.anyChild,
|
||||
currentNode.notFoundHandler,
|
||||
)
|
||||
// Update parent path for all children to new node
|
||||
for _, child := range currentNode.staticChildren {
|
||||
@@ -243,13 +264,14 @@ func (r *Router) insert(method, path string, h HandlerFunc, t kind, ppath string
|
||||
currentNode.label = currentNode.prefix[0]
|
||||
currentNode.prefix = currentNode.prefix[:lcpLen]
|
||||
currentNode.staticChildren = nil
|
||||
currentNode.methodHandler = new(methodHandler)
|
||||
currentNode.ppath = ""
|
||||
currentNode.pnames = nil
|
||||
currentNode.originalPath = ""
|
||||
currentNode.methods = new(routeMethods)
|
||||
currentNode.paramsCount = 0
|
||||
currentNode.paramChild = nil
|
||||
currentNode.anyChild = nil
|
||||
currentNode.isLeaf = false
|
||||
currentNode.isHandler = false
|
||||
currentNode.notFoundHandler = nil
|
||||
|
||||
// Only Static children could reach here
|
||||
currentNode.addStaticChild(n)
|
||||
@@ -257,13 +279,19 @@ func (r *Router) insert(method, path string, h HandlerFunc, t kind, ppath string
|
||||
if lcpLen == searchLen {
|
||||
// At parent node
|
||||
currentNode.kind = t
|
||||
currentNode.addHandler(method, h)
|
||||
currentNode.ppath = ppath
|
||||
currentNode.pnames = pnames
|
||||
if rm.handler != nil {
|
||||
currentNode.addMethod(method, &rm)
|
||||
currentNode.paramsCount = len(rm.pnames)
|
||||
currentNode.originalPath = rm.ppath
|
||||
}
|
||||
} else {
|
||||
// Create child node
|
||||
n = newNode(t, search[lcpLen:], currentNode, nil, new(methodHandler), ppath, pnames, nil, nil)
|
||||
n.addHandler(method, h)
|
||||
n = newNode(t, search[lcpLen:], currentNode, nil, "", new(routeMethods), 0, nil, nil, nil)
|
||||
if rm.handler != nil {
|
||||
n.addMethod(method, &rm)
|
||||
n.paramsCount = len(rm.pnames)
|
||||
n.originalPath = rm.ppath
|
||||
}
|
||||
// Only Static children could reach here
|
||||
currentNode.addStaticChild(n)
|
||||
}
|
||||
@@ -277,8 +305,12 @@ func (r *Router) insert(method, path string, h HandlerFunc, t kind, ppath string
|
||||
continue
|
||||
}
|
||||
// Create child node
|
||||
n := newNode(t, search, currentNode, nil, new(methodHandler), ppath, pnames, nil, nil)
|
||||
n.addHandler(method, h)
|
||||
n := newNode(t, search, currentNode, nil, rm.ppath, new(routeMethods), 0, nil, nil, nil)
|
||||
if rm.handler != nil {
|
||||
n.addMethod(method, &rm)
|
||||
n.paramsCount = len(rm.pnames)
|
||||
}
|
||||
|
||||
switch t {
|
||||
case staticKind:
|
||||
currentNode.addStaticChild(n)
|
||||
@@ -290,32 +322,42 @@ func (r *Router) insert(method, path string, h HandlerFunc, t kind, ppath string
|
||||
currentNode.isLeaf = currentNode.staticChildren == nil && currentNode.paramChild == nil && currentNode.anyChild == nil
|
||||
} else {
|
||||
// Node already exists
|
||||
if h != nil {
|
||||
currentNode.addHandler(method, h)
|
||||
currentNode.ppath = ppath
|
||||
if len(currentNode.pnames) == 0 { // Issue #729
|
||||
currentNode.pnames = pnames
|
||||
}
|
||||
if rm.handler != nil {
|
||||
currentNode.addMethod(method, &rm)
|
||||
currentNode.paramsCount = len(rm.pnames)
|
||||
currentNode.originalPath = rm.ppath
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func newNode(t kind, pre string, p *node, sc children, mh *methodHandler, ppath string, pnames []string, paramChildren, anyChildren *node) *node {
|
||||
func newNode(
|
||||
t kind,
|
||||
pre string,
|
||||
p *node,
|
||||
sc children,
|
||||
originalPath string,
|
||||
methods *routeMethods,
|
||||
paramsCount int,
|
||||
paramChildren,
|
||||
anyChildren *node,
|
||||
notFoundHandler *routeMethod,
|
||||
) *node {
|
||||
return &node{
|
||||
kind: t,
|
||||
label: pre[0],
|
||||
prefix: pre,
|
||||
parent: p,
|
||||
staticChildren: sc,
|
||||
ppath: ppath,
|
||||
pnames: pnames,
|
||||
methodHandler: mh,
|
||||
paramChild: paramChildren,
|
||||
anyChild: anyChildren,
|
||||
isLeaf: sc == nil && paramChildren == nil && anyChildren == nil,
|
||||
isHandler: mh.isHandler(),
|
||||
kind: t,
|
||||
label: pre[0],
|
||||
prefix: pre,
|
||||
parent: p,
|
||||
staticChildren: sc,
|
||||
originalPath: originalPath,
|
||||
methods: methods,
|
||||
paramsCount: paramsCount,
|
||||
paramChild: paramChildren,
|
||||
anyChild: anyChildren,
|
||||
isLeaf: sc == nil && paramChildren == nil && anyChildren == nil,
|
||||
isHandler: methods.isHandler(),
|
||||
notFoundHandler: notFoundHandler,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,10 +375,8 @@ func (n *node) findStaticChild(l byte) *node {
|
||||
}
|
||||
|
||||
func (n *node) findChildWithLabel(l byte) *node {
|
||||
for _, c := range n.staticChildren {
|
||||
if c.label == l {
|
||||
return c
|
||||
}
|
||||
if c := n.findStaticChild(l); c != nil {
|
||||
return c
|
||||
}
|
||||
if l == paramLabel {
|
||||
return n.paramChild
|
||||
@@ -347,66 +387,74 @@ func (n *node) findChildWithLabel(l byte) *node {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *node) addHandler(method string, h HandlerFunc) {
|
||||
func (n *node) addMethod(method string, h *routeMethod) {
|
||||
switch method {
|
||||
case http.MethodConnect:
|
||||
n.methodHandler.connect = h
|
||||
n.methods.connect = h
|
||||
case http.MethodDelete:
|
||||
n.methodHandler.delete = h
|
||||
n.methods.delete = h
|
||||
case http.MethodGet:
|
||||
n.methodHandler.get = h
|
||||
n.methods.get = h
|
||||
case http.MethodHead:
|
||||
n.methodHandler.head = h
|
||||
n.methods.head = h
|
||||
case http.MethodOptions:
|
||||
n.methodHandler.options = h
|
||||
n.methods.options = h
|
||||
case http.MethodPatch:
|
||||
n.methodHandler.patch = h
|
||||
n.methods.patch = h
|
||||
case http.MethodPost:
|
||||
n.methodHandler.post = h
|
||||
n.methods.post = h
|
||||
case PROPFIND:
|
||||
n.methodHandler.propfind = h
|
||||
n.methods.propfind = h
|
||||
case http.MethodPut:
|
||||
n.methodHandler.put = h
|
||||
n.methods.put = h
|
||||
case http.MethodTrace:
|
||||
n.methodHandler.trace = h
|
||||
n.methods.trace = h
|
||||
case REPORT:
|
||||
n.methodHandler.report = h
|
||||
n.methods.report = h
|
||||
case RouteNotFound:
|
||||
n.notFoundHandler = h
|
||||
return // RouteNotFound/404 is not considered as a handler so no further logic needs to be executed
|
||||
default:
|
||||
if n.methods.anyOther == nil {
|
||||
n.methods.anyOther = make(map[string]*routeMethod)
|
||||
}
|
||||
if h.handler == nil {
|
||||
delete(n.methods.anyOther, method)
|
||||
} else {
|
||||
n.methods.anyOther[method] = h
|
||||
}
|
||||
}
|
||||
|
||||
n.methodHandler.updateAllowHeader()
|
||||
if h != nil {
|
||||
n.isHandler = true
|
||||
} else {
|
||||
n.isHandler = n.methodHandler.isHandler()
|
||||
}
|
||||
n.methods.updateAllowHeader()
|
||||
n.isHandler = true
|
||||
}
|
||||
|
||||
func (n *node) findHandler(method string) HandlerFunc {
|
||||
func (n *node) findMethod(method string) *routeMethod {
|
||||
switch method {
|
||||
case http.MethodConnect:
|
||||
return n.methodHandler.connect
|
||||
return n.methods.connect
|
||||
case http.MethodDelete:
|
||||
return n.methodHandler.delete
|
||||
return n.methods.delete
|
||||
case http.MethodGet:
|
||||
return n.methodHandler.get
|
||||
return n.methods.get
|
||||
case http.MethodHead:
|
||||
return n.methodHandler.head
|
||||
return n.methods.head
|
||||
case http.MethodOptions:
|
||||
return n.methodHandler.options
|
||||
return n.methods.options
|
||||
case http.MethodPatch:
|
||||
return n.methodHandler.patch
|
||||
return n.methods.patch
|
||||
case http.MethodPost:
|
||||
return n.methodHandler.post
|
||||
return n.methods.post
|
||||
case PROPFIND:
|
||||
return n.methodHandler.propfind
|
||||
return n.methods.propfind
|
||||
case http.MethodPut:
|
||||
return n.methodHandler.put
|
||||
return n.methods.put
|
||||
case http.MethodTrace:
|
||||
return n.methodHandler.trace
|
||||
return n.methods.trace
|
||||
case REPORT:
|
||||
return n.methodHandler.report
|
||||
default:
|
||||
return nil
|
||||
return n.methods.report
|
||||
default: // RouteNotFound/404 is not considered as a handler
|
||||
return n.methods.anyOther[method]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,7 +483,7 @@ func (r *Router) Find(method, path string, c Context) {
|
||||
|
||||
var (
|
||||
previousBestMatchNode *node
|
||||
matchedHandler HandlerFunc
|
||||
matchedRouteMethod *routeMethod
|
||||
// search stores the remaining path to check for match. By each iteration we move from start of path to end of the path
|
||||
// and search value gets shorter and shorter.
|
||||
search = path
|
||||
@@ -508,7 +556,7 @@ func (r *Router) Find(method, path string, c Context) {
|
||||
// No matching prefix, let's backtrack to the first possible alternative node of the decision path
|
||||
nk, ok := backtrackToNextNodeKind(staticKind)
|
||||
if !ok {
|
||||
return // No other possibilities on the decision path
|
||||
return // No other possibilities on the decision path, handler will be whatever context is reset to.
|
||||
} else if nk == paramKind {
|
||||
goto Param
|
||||
// NOTE: this case (backtracking from static node to previous any node) can not happen by current any matching logic. Any node is end of search currently
|
||||
@@ -524,15 +572,21 @@ func (r *Router) Find(method, path string, c Context) {
|
||||
search = search[lcpLen:]
|
||||
searchIndex = searchIndex + lcpLen
|
||||
|
||||
// Finish routing if no remaining search and we are on a node with handler and matching method type
|
||||
if search == "" && currentNode.isHandler {
|
||||
// check if current node has handler registered for http method we are looking for. we store currentNode as
|
||||
// best matching in case we do no find no more routes matching this path+method
|
||||
if previousBestMatchNode == nil {
|
||||
previousBestMatchNode = currentNode
|
||||
}
|
||||
if h := currentNode.findHandler(method); h != nil {
|
||||
matchedHandler = h
|
||||
// Finish routing if is no request path remaining to search
|
||||
if search == "" {
|
||||
// in case of node that is handler we have exact method type match or something for 405 to use
|
||||
if currentNode.isHandler {
|
||||
// check if current node has handler registered for http method we are looking for. we store currentNode as
|
||||
// best matching in case we do no find no more routes matching this path+method
|
||||
if previousBestMatchNode == nil {
|
||||
previousBestMatchNode = currentNode
|
||||
}
|
||||
if h := currentNode.findMethod(method); h != nil {
|
||||
matchedRouteMethod = h
|
||||
break
|
||||
}
|
||||
} else if currentNode.notFoundHandler != nil {
|
||||
matchedRouteMethod = currentNode.notFoundHandler
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -552,7 +606,8 @@ func (r *Router) Find(method, path string, c Context) {
|
||||
i := 0
|
||||
l := len(search)
|
||||
if currentNode.isLeaf {
|
||||
// when param node does not have any children then param node should act similarly to any node - consider all remaining search as match
|
||||
// when param node does not have any children (path param is last piece of route path) then param node should
|
||||
// act similarly to any node - consider all remaining search as match
|
||||
i = l
|
||||
} else {
|
||||
for ; i < l && search[i] != '/'; i++ {
|
||||
@@ -571,19 +626,23 @@ func (r *Router) Find(method, path string, c Context) {
|
||||
if child := currentNode.anyChild; child != nil {
|
||||
// If any node is found, use remaining path for paramValues
|
||||
currentNode = child
|
||||
paramValues[len(currentNode.pnames)-1] = search
|
||||
paramValues[currentNode.paramsCount-1] = search
|
||||
|
||||
// update indexes/search in case we need to backtrack when no handler match is found
|
||||
paramIndex++
|
||||
searchIndex += +len(search)
|
||||
search = ""
|
||||
|
||||
// check if current node has handler registered for http method we are looking for. we store currentNode as
|
||||
// best matching in case we do no find no more routes matching this path+method
|
||||
if h := currentNode.findMethod(method); h != nil {
|
||||
matchedRouteMethod = h
|
||||
break
|
||||
}
|
||||
// we store currentNode as best matching in case we do not find more routes matching this path+method. Needed for 405
|
||||
if previousBestMatchNode == nil {
|
||||
previousBestMatchNode = currentNode
|
||||
}
|
||||
if h := currentNode.findHandler(method); h != nil {
|
||||
matchedHandler = h
|
||||
if currentNode.notFoundHandler != nil {
|
||||
matchedRouteMethod = currentNode.notFoundHandler
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -606,22 +665,34 @@ func (r *Router) Find(method, path string, c Context) {
|
||||
return // nothing matched at all
|
||||
}
|
||||
|
||||
if matchedHandler != nil {
|
||||
ctx.handler = matchedHandler
|
||||
// matchedHandler could be method+path handler that we matched or notFoundHandler from node with matching path
|
||||
// user provided not found (404) handler has priority over generic method not found (405) handler or global 404 handler
|
||||
var rPath string
|
||||
var rPNames []string
|
||||
if matchedRouteMethod != nil {
|
||||
rPath = matchedRouteMethod.ppath
|
||||
rPNames = matchedRouteMethod.pnames
|
||||
ctx.handler = matchedRouteMethod.handler
|
||||
} else {
|
||||
// use previous match as basis. although we have no matching handler we have path match.
|
||||
// so we can send http.StatusMethodNotAllowed (405) instead of http.StatusNotFound (404)
|
||||
currentNode = previousBestMatchNode
|
||||
|
||||
rPath = currentNode.originalPath
|
||||
rPNames = nil // no params here
|
||||
ctx.handler = NotFoundHandler
|
||||
if currentNode.isHandler {
|
||||
ctx.Set(ContextKeyHeaderAllow, currentNode.methodHandler.allowHeader)
|
||||
if currentNode.notFoundHandler != nil {
|
||||
rPath = currentNode.notFoundHandler.ppath
|
||||
rPNames = currentNode.notFoundHandler.pnames
|
||||
ctx.handler = currentNode.notFoundHandler.handler
|
||||
} else if currentNode.isHandler {
|
||||
ctx.Set(ContextKeyHeaderAllow, currentNode.methods.allowHeader)
|
||||
ctx.handler = MethodNotAllowedHandler
|
||||
if method == http.MethodOptions {
|
||||
ctx.handler = optionsMethodHandler(currentNode.methodHandler.allowHeader)
|
||||
ctx.handler = optionsMethodHandler(currentNode.methods.allowHeader)
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.path = currentNode.ppath
|
||||
ctx.pnames = currentNode.pnames
|
||||
ctx.path = rPath
|
||||
ctx.pnames = rPNames
|
||||
}
|
||||
|
||||
9
vendor/github.com/lrstanley/girc/README.md
generated
vendored
9
vendor/github.com/lrstanley/girc/README.md
generated
vendored
@@ -1,6 +1,7 @@
|
||||
<p align="center"><a href="https://pkg.go.dev/github.com/lrstanley/girc"><img width="270" src="http://i.imgur.com/DEnyrdB.png"></a></p>
|
||||
<!-- template:begin:header -->
|
||||
<!-- do not edit anything in this "template" block, its auto-generated -->
|
||||
|
||||
<p align="center">girc -- :bomb: girc is a flexible IRC library for Go :ok_hand:</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/lrstanley/girc/tags">
|
||||
@@ -46,13 +47,7 @@
|
||||
<!-- do not edit anything in this "template" block, its auto-generated -->
|
||||
## :link: Table of Contents
|
||||
|
||||
- [Features](#features)
|
||||
- [Installing](#installing)
|
||||
- [Examples](#examples)
|
||||
- [References](#references)
|
||||
- [Support & Assistance](#raising_hand_man-support--assistance)
|
||||
- [Contributing](#handshake-contributing)
|
||||
- [License](#balance_scale-license)
|
||||
- []()
|
||||
<!-- template:end:toc -->
|
||||
|
||||
## Features
|
||||
|
||||
4
vendor/github.com/lrstanley/girc/conn.go
generated
vendored
4
vendor/github.com/lrstanley/girc/conn.go
generated
vendored
@@ -588,6 +588,7 @@ func (c *Client) pingLoop(ctx context.Context, errs chan error, wg *sync.WaitGro
|
||||
|
||||
started := time.Now()
|
||||
past := false
|
||||
pingSent := false
|
||||
|
||||
for {
|
||||
select {
|
||||
@@ -603,7 +604,7 @@ func (c *Client) pingLoop(ctx context.Context, errs chan error, wg *sync.WaitGro
|
||||
}
|
||||
|
||||
c.conn.mu.RLock()
|
||||
if time.Since(c.conn.lastPong) > c.Config.PingDelay+(60*time.Second) {
|
||||
if pingSent && time.Since(c.conn.lastPong) > c.Config.PingDelay+(60*time.Second) {
|
||||
// It's 60 seconds over what out ping delay is, connection
|
||||
// has probably dropped.
|
||||
err := ErrTimedOut{
|
||||
@@ -625,6 +626,7 @@ func (c *Client) pingLoop(ctx context.Context, errs chan error, wg *sync.WaitGro
|
||||
c.conn.mu.Unlock()
|
||||
|
||||
c.Cmd.Ping(fmt.Sprintf("%d", time.Now().UnixNano()))
|
||||
pingSent = true
|
||||
case <-ctx.Done():
|
||||
wg.Done()
|
||||
return
|
||||
|
||||
8
vendor/github.com/mattermost/mattermost-server/v6/model/config.go
generated
vendored
8
vendor/github.com/mattermost/mattermost-server/v6/model/config.go
generated
vendored
@@ -536,13 +536,7 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
|
||||
s.Forward80To443 = NewBool(false)
|
||||
}
|
||||
|
||||
if isUpdate {
|
||||
// When updating an existing configuration, ensure that defaults are set.
|
||||
if s.TrustedProxyIPHeader == nil {
|
||||
s.TrustedProxyIPHeader = []string{HeaderForwarded, HeaderRealIP}
|
||||
}
|
||||
} else {
|
||||
// When generating a blank configuration, leave the list empty.
|
||||
if s.TrustedProxyIPHeader == nil {
|
||||
s.TrustedProxyIPHeader = []string{}
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/mattermost/mattermost-server/v6/model/version.go
generated
vendored
2
vendor/github.com/mattermost/mattermost-server/v6/model/version.go
generated
vendored
@@ -13,6 +13,8 @@ import (
|
||||
// It should be maintained in chronological order with most current
|
||||
// release at the front of the list.
|
||||
var versions = []string{
|
||||
"6.7.2",
|
||||
"6.7.1",
|
||||
"6.7.0",
|
||||
"6.6.0",
|
||||
"6.5.0",
|
||||
|
||||
4
vendor/github.com/sirupsen/logrus/README.md
generated
vendored
4
vendor/github.com/sirupsen/logrus/README.md
generated
vendored
@@ -1,4 +1,4 @@
|
||||
# Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/> [](https://travis-ci.org/sirupsen/logrus) [](https://godoc.org/github.com/sirupsen/logrus)
|
||||
# Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/> [](https://github.com/sirupsen/logrus/actions?query=workflow%3ACI) [](https://travis-ci.org/sirupsen/logrus) [](https://pkg.go.dev/github.com/sirupsen/logrus)
|
||||
|
||||
Logrus is a structured logger for Go (golang), completely API compatible with
|
||||
the standard library logger.
|
||||
@@ -341,7 +341,7 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
init() {
|
||||
func init() {
|
||||
// do something here to set environment depending on an environment variable
|
||||
// or command-line flag
|
||||
if Environment == "production" {
|
||||
|
||||
9
vendor/github.com/sirupsen/logrus/buffer_pool.go
generated
vendored
9
vendor/github.com/sirupsen/logrus/buffer_pool.go
generated
vendored
@@ -26,15 +26,6 @@ func (p *defaultPool) Get() *bytes.Buffer {
|
||||
return p.pool.Get().(*bytes.Buffer)
|
||||
}
|
||||
|
||||
func getBuffer() *bytes.Buffer {
|
||||
return bufferPool.Get()
|
||||
}
|
||||
|
||||
func putBuffer(buf *bytes.Buffer) {
|
||||
buf.Reset()
|
||||
bufferPool.Put(buf)
|
||||
}
|
||||
|
||||
// SetBufferPool allows to replace the default logrus buffer pool
|
||||
// to better meets the specific needs of an application.
|
||||
func SetBufferPool(bp BufferPool) {
|
||||
|
||||
21
vendor/github.com/sirupsen/logrus/entry.go
generated
vendored
21
vendor/github.com/sirupsen/logrus/entry.go
generated
vendored
@@ -232,6 +232,7 @@ func (entry *Entry) log(level Level, msg string) {
|
||||
|
||||
newEntry.Logger.mu.Lock()
|
||||
reportCaller := newEntry.Logger.ReportCaller
|
||||
bufPool := newEntry.getBufferPool()
|
||||
newEntry.Logger.mu.Unlock()
|
||||
|
||||
if reportCaller {
|
||||
@@ -239,11 +240,11 @@ func (entry *Entry) log(level Level, msg string) {
|
||||
}
|
||||
|
||||
newEntry.fireHooks()
|
||||
|
||||
buffer = getBuffer()
|
||||
buffer = bufPool.Get()
|
||||
defer func() {
|
||||
newEntry.Buffer = nil
|
||||
putBuffer(buffer)
|
||||
buffer.Reset()
|
||||
bufPool.Put(buffer)
|
||||
}()
|
||||
buffer.Reset()
|
||||
newEntry.Buffer = buffer
|
||||
@@ -260,6 +261,13 @@ func (entry *Entry) log(level Level, msg string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) getBufferPool() (pool BufferPool) {
|
||||
if entry.Logger.BufferPool != nil {
|
||||
return entry.Logger.BufferPool
|
||||
}
|
||||
return bufferPool
|
||||
}
|
||||
|
||||
func (entry *Entry) fireHooks() {
|
||||
var tmpHooks LevelHooks
|
||||
entry.Logger.mu.Lock()
|
||||
@@ -276,18 +284,21 @@ func (entry *Entry) fireHooks() {
|
||||
}
|
||||
|
||||
func (entry *Entry) write() {
|
||||
entry.Logger.mu.Lock()
|
||||
defer entry.Logger.mu.Unlock()
|
||||
serialized, err := entry.Logger.Formatter.Format(entry)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
|
||||
return
|
||||
}
|
||||
entry.Logger.mu.Lock()
|
||||
defer entry.Logger.mu.Unlock()
|
||||
if _, err := entry.Logger.Out.Write(serialized); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Log will log a message at the level given as parameter.
|
||||
// Warning: using Log at Panic or Fatal level will not respectively Panic nor Exit.
|
||||
// For this behaviour Entry.Panic or Entry.Fatal should be used instead.
|
||||
func (entry *Entry) Log(level Level, args ...interface{}) {
|
||||
if entry.Logger.IsLevelEnabled(level) {
|
||||
entry.log(level, fmt.Sprint(args...))
|
||||
|
||||
13
vendor/github.com/sirupsen/logrus/logger.go
generated
vendored
13
vendor/github.com/sirupsen/logrus/logger.go
generated
vendored
@@ -44,6 +44,9 @@ type Logger struct {
|
||||
entryPool sync.Pool
|
||||
// Function to exit the application, defaults to `os.Exit()`
|
||||
ExitFunc exitFunc
|
||||
// The buffer pool used to format the log. If it is nil, the default global
|
||||
// buffer pool will be used.
|
||||
BufferPool BufferPool
|
||||
}
|
||||
|
||||
type exitFunc func(int)
|
||||
@@ -192,6 +195,9 @@ func (logger *Logger) Panicf(format string, args ...interface{}) {
|
||||
logger.Logf(PanicLevel, format, args...)
|
||||
}
|
||||
|
||||
// Log will log a message at the level given as parameter.
|
||||
// Warning: using Log at Panic or Fatal level will not respectively Panic nor Exit.
|
||||
// For this behaviour Logger.Panic or Logger.Fatal should be used instead.
|
||||
func (logger *Logger) Log(level Level, args ...interface{}) {
|
||||
if logger.IsLevelEnabled(level) {
|
||||
entry := logger.newEntry()
|
||||
@@ -402,3 +408,10 @@ func (logger *Logger) ReplaceHooks(hooks LevelHooks) LevelHooks {
|
||||
logger.mu.Unlock()
|
||||
return oldHooks
|
||||
}
|
||||
|
||||
// SetBufferPool sets the logger buffer pool.
|
||||
func (logger *Logger) SetBufferPool(pool BufferPool) {
|
||||
logger.mu.Lock()
|
||||
defer logger.mu.Unlock()
|
||||
logger.BufferPool = pool
|
||||
}
|
||||
|
||||
19
vendor/github.com/slack-go/slack/chat.go
generated
vendored
19
vendor/github.com/slack-go/slack/chat.go
generated
vendored
@@ -64,6 +64,9 @@ type PostMessageParameters struct {
|
||||
// chat.postEphemeral support
|
||||
Channel string `json:"channel"`
|
||||
User string `json:"user"`
|
||||
|
||||
// chat metadata support
|
||||
MetaData SlackMetadata `json:"metadata"`
|
||||
}
|
||||
|
||||
// NewPostMessageParameters provides an instance of PostMessageParameters with all the sane default values set
|
||||
@@ -285,6 +288,7 @@ type sendConfig struct {
|
||||
endpoint string
|
||||
values url.Values
|
||||
attachments []Attachment
|
||||
metadata SlackMetadata
|
||||
blocks Blocks
|
||||
responseType string
|
||||
replaceOriginal bool
|
||||
@@ -306,6 +310,7 @@ func (t sendConfig) BuildRequestContext(ctx context.Context, token, channelID st
|
||||
endpoint: t.endpoint,
|
||||
values: t.values,
|
||||
attachments: t.attachments,
|
||||
metadata: t.metadata,
|
||||
blocks: t.blocks,
|
||||
responseType: t.responseType,
|
||||
replaceOriginal: t.replaceOriginal,
|
||||
@@ -336,6 +341,7 @@ type responseURLSender struct {
|
||||
endpoint string
|
||||
values url.Values
|
||||
attachments []Attachment
|
||||
metadata SlackMetadata
|
||||
blocks Blocks
|
||||
responseType string
|
||||
replaceOriginal bool
|
||||
@@ -352,6 +358,7 @@ func (t responseURLSender) BuildRequestContext(ctx context.Context) (*http.Reque
|
||||
Timestamp: t.values.Get("ts"),
|
||||
Attachments: t.attachments,
|
||||
Blocks: t.blocks,
|
||||
Metadata: t.metadata,
|
||||
ResponseType: t.responseType,
|
||||
ReplaceOriginal: t.replaceOriginal,
|
||||
DeleteOriginal: t.deleteOriginal,
|
||||
@@ -662,6 +669,18 @@ func MsgOptionIconEmoji(iconEmoji string) MsgOption {
|
||||
}
|
||||
}
|
||||
|
||||
// MsgOptionMetadata sets message metadata
|
||||
func MsgOptionMetadata(metadata SlackMetadata) MsgOption {
|
||||
return func(config *sendConfig) error {
|
||||
config.metadata = metadata
|
||||
meta, err := json.Marshal(metadata)
|
||||
if err == nil {
|
||||
config.values.Set("metadata", string(meta))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// UnsafeMsgOptionEndpoint deliver the message to the specified endpoint.
|
||||
// NOTE: USE AT YOUR OWN RISK: No issues relating to the use of this Option
|
||||
// will be supported by the library, it is subject to change without notice that
|
||||
|
||||
18
vendor/github.com/slack-go/slack/conversation.go
generated
vendored
18
vendor/github.com/slack-go/slack/conversation.go
generated
vendored
@@ -571,12 +571,13 @@ func (api *Client) JoinConversationContext(ctx context.Context, channelID string
|
||||
}
|
||||
|
||||
type GetConversationHistoryParameters struct {
|
||||
ChannelID string
|
||||
Cursor string
|
||||
Inclusive bool
|
||||
Latest string
|
||||
Limit int
|
||||
Oldest string
|
||||
ChannelID string
|
||||
Cursor string
|
||||
Inclusive bool
|
||||
Latest string
|
||||
Limit int
|
||||
Oldest string
|
||||
IncludeAllMetadata bool
|
||||
}
|
||||
|
||||
type GetConversationHistoryResponse struct {
|
||||
@@ -615,6 +616,11 @@ func (api *Client) GetConversationHistoryContext(ctx context.Context, params *Ge
|
||||
if params.Oldest != "" {
|
||||
values.Add("oldest", params.Oldest)
|
||||
}
|
||||
if params.IncludeAllMetadata {
|
||||
values.Add("include_all_metadata", "1")
|
||||
} else {
|
||||
values.Add("include_all_metadata", "0")
|
||||
}
|
||||
|
||||
response := GetConversationHistoryResponse{}
|
||||
|
||||
|
||||
5
vendor/github.com/slack-go/slack/messages.go
generated
vendored
5
vendor/github.com/slack-go/slack/messages.go
generated
vendored
@@ -129,8 +129,13 @@ type Msg struct {
|
||||
ReplaceOriginal bool `json:"replace_original"`
|
||||
DeleteOriginal bool `json:"delete_original"`
|
||||
|
||||
// metadata
|
||||
Metadata SlackMetadata `json:"metadata,omitempty"`
|
||||
|
||||
// Block type Message
|
||||
Blocks Blocks `json:"blocks,omitempty"`
|
||||
// permalink
|
||||
Permalink string `json:"permalink,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
7
vendor/github.com/slack-go/slack/metadata.go
generated
vendored
Normal file
7
vendor/github.com/slack-go/slack/metadata.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package slack
|
||||
|
||||
// SlackMetadata https://api.slack.com/reference/metadata
|
||||
type SlackMetadata struct {
|
||||
EventType string `json:"event_type"`
|
||||
EventPayload map[string]interface{} `json:"event_payload"`
|
||||
}
|
||||
69
vendor/github.com/slack-go/slack/usergroups.go
generated
vendored
69
vendor/github.com/slack-go/slack/usergroups.go
generated
vendored
@@ -183,32 +183,77 @@ func (api *Client) GetUserGroupsContext(ctx context.Context, options ...GetUserG
|
||||
return response.UserGroups, nil
|
||||
}
|
||||
|
||||
// UpdateUserGroupsOption options for the UpdateUserGroup method call.
|
||||
type UpdateUserGroupsOption func(*UpdateUserGroupsParams)
|
||||
|
||||
// UpdateUserGroupsOptionName change the name of the User Group (default: empty, so it's no-op)
|
||||
func UpdateUserGroupsOptionName(name string) UpdateUserGroupsOption {
|
||||
return func(params *UpdateUserGroupsParams) {
|
||||
params.Name = name
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateUserGroupsOptionHandle change the handle of the User Group (default: empty, so it's no-op)
|
||||
func UpdateUserGroupsOptionHandle(handle string) UpdateUserGroupsOption {
|
||||
return func(params *UpdateUserGroupsParams) {
|
||||
params.Handle = handle
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateUserGroupsOptionDescription change the description of the User Group. (default: nil, so it's no-op)
|
||||
func UpdateUserGroupsOptionDescription(description *string) UpdateUserGroupsOption {
|
||||
return func(params *UpdateUserGroupsParams) {
|
||||
params.Description = description
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateUserGroupsOptionChannels change the default channels of the User Group. (default: unspecified, so it's no-op)
|
||||
func UpdateUserGroupsOptionChannels(channels []string) UpdateUserGroupsOption {
|
||||
return func(params *UpdateUserGroupsParams) {
|
||||
params.Channels = &channels
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateUserGroupsParams contains arguments for UpdateUserGroup method call
|
||||
type UpdateUserGroupsParams struct {
|
||||
Name string
|
||||
Handle string
|
||||
Description *string
|
||||
Channels *[]string
|
||||
}
|
||||
|
||||
// UpdateUserGroup will update an existing user group
|
||||
func (api *Client) UpdateUserGroup(userGroup UserGroup) (UserGroup, error) {
|
||||
return api.UpdateUserGroupContext(context.Background(), userGroup)
|
||||
func (api *Client) UpdateUserGroup(userGroupID string, options ...UpdateUserGroupsOption) (UserGroup, error) {
|
||||
return api.UpdateUserGroupContext(context.Background(), userGroupID, options...)
|
||||
}
|
||||
|
||||
// UpdateUserGroupContext will update an existing user group with a custom context
|
||||
func (api *Client) UpdateUserGroupContext(ctx context.Context, userGroup UserGroup) (UserGroup, error) {
|
||||
func (api *Client) UpdateUserGroupContext(ctx context.Context, userGroupID string, options ...UpdateUserGroupsOption) (UserGroup, error) {
|
||||
params := UpdateUserGroupsParams{}
|
||||
|
||||
for _, opt := range options {
|
||||
opt(¶ms)
|
||||
}
|
||||
|
||||
values := url.Values{
|
||||
"token": {api.token},
|
||||
"usergroup": {userGroup.ID},
|
||||
"usergroup": {userGroupID},
|
||||
}
|
||||
|
||||
if userGroup.Name != "" {
|
||||
values["name"] = []string{userGroup.Name}
|
||||
if params.Name != "" {
|
||||
values["name"] = []string{params.Name}
|
||||
}
|
||||
|
||||
if userGroup.Handle != "" {
|
||||
values["handle"] = []string{userGroup.Handle}
|
||||
if params.Handle != "" {
|
||||
values["handle"] = []string{params.Handle}
|
||||
}
|
||||
|
||||
if userGroup.Description != "" {
|
||||
values["description"] = []string{userGroup.Description}
|
||||
if params.Description != nil {
|
||||
values["description"] = []string{*params.Description}
|
||||
}
|
||||
|
||||
if len(userGroup.Prefs.Channels) > 0 {
|
||||
values["channels"] = []string{strings.Join(userGroup.Prefs.Channels, ",")}
|
||||
if params.Channels != nil {
|
||||
values["channels"] = []string{strings.Join(*params.Channels, ",")}
|
||||
}
|
||||
|
||||
response, err := api.userGroupRequest(ctx, "usergroups.update", values)
|
||||
|
||||
17
vendor/github.com/slack-go/slack/users.go
generated
vendored
17
vendor/github.com/slack-go/slack/users.go
generated
vendored
@@ -292,6 +292,13 @@ func GetUsersOptionPresence(n bool) GetUsersOption {
|
||||
}
|
||||
}
|
||||
|
||||
// GetUsersOptionTeamID include team Id
|
||||
func GetUsersOptionTeamID(teamId string) GetUsersOption {
|
||||
return func(p *UserPagination) {
|
||||
p.teamId = teamId
|
||||
}
|
||||
}
|
||||
|
||||
func newUserPagination(c *Client, options ...GetUsersOption) (up UserPagination) {
|
||||
up = UserPagination{
|
||||
c: c,
|
||||
@@ -310,6 +317,7 @@ type UserPagination struct {
|
||||
Users []User
|
||||
limit int
|
||||
presence bool
|
||||
teamId string
|
||||
previousResp *ResponseMetadata
|
||||
c *Client
|
||||
}
|
||||
@@ -344,6 +352,7 @@ func (t UserPagination) Next(ctx context.Context) (_ UserPagination, err error)
|
||||
"presence": {strconv.FormatBool(t.presence)},
|
||||
"token": {t.c.token},
|
||||
"cursor": {t.previousResp.Cursor},
|
||||
"team_id": {t.teamId},
|
||||
"include_locale": {strconv.FormatBool(true)},
|
||||
}
|
||||
|
||||
@@ -364,13 +373,13 @@ func (api *Client) GetUsersPaginated(options ...GetUsersOption) UserPagination {
|
||||
}
|
||||
|
||||
// GetUsers returns the list of users (with their detailed information)
|
||||
func (api *Client) GetUsers() ([]User, error) {
|
||||
return api.GetUsersContext(context.Background())
|
||||
func (api *Client) GetUsers(options ...GetUsersOption) ([]User, error) {
|
||||
return api.GetUsersContext(context.Background(), options...)
|
||||
}
|
||||
|
||||
// GetUsersContext returns the list of users (with their detailed information) with a custom context
|
||||
func (api *Client) GetUsersContext(ctx context.Context) (results []User, err error) {
|
||||
p := api.GetUsersPaginated()
|
||||
func (api *Client) GetUsersContext(ctx context.Context, options ...GetUsersOption) (results []User, err error) {
|
||||
p := api.GetUsersPaginated(options...)
|
||||
for err == nil {
|
||||
p, err = p.Next(ctx)
|
||||
if err == nil {
|
||||
|
||||
27
vendor/github.com/slack-go/slack/websocket_managed_conn.go
generated
vendored
27
vendor/github.com/slack-go/slack/websocket_managed_conn.go
generated
vendored
@@ -16,6 +16,31 @@ import (
|
||||
"github.com/slack-go/slack/internal/timex"
|
||||
)
|
||||
|
||||
// UnmappedError represents error occurred when there is no mapping between given event name
|
||||
// and corresponding Go struct.
|
||||
type UnmappedError struct {
|
||||
// EventType returns event type name.
|
||||
EventType string
|
||||
// RawEvent returns raw event body.
|
||||
RawEvent json.RawMessage
|
||||
|
||||
ctxMsg string
|
||||
}
|
||||
|
||||
// NewUnmappedError returns new UnmappedError instance.
|
||||
func NewUnmappedError(ctxMsg, eventType string, raw json.RawMessage) *UnmappedError {
|
||||
return &UnmappedError{
|
||||
ctxMsg: ctxMsg,
|
||||
EventType: eventType,
|
||||
RawEvent: raw,
|
||||
}
|
||||
}
|
||||
|
||||
// Error returns human-readable error message.
|
||||
func (u UnmappedError) Error() string {
|
||||
return fmt.Sprintf("%s: Received unmapped event %q", u.ctxMsg, u.EventType)
|
||||
}
|
||||
|
||||
// ManageConnection can be called on a Slack RTM instance returned by the
|
||||
// NewRTM method. It will connect to the slack RTM API and handle all incoming
|
||||
// and outgoing events. If a connection fails then it will attempt to reconnect
|
||||
@@ -474,7 +499,7 @@ func (rtm *RTM) handleEvent(typeStr string, event json.RawMessage) {
|
||||
v, exists := EventMapping[typeStr]
|
||||
if !exists {
|
||||
rtm.Debugf("RTM Error - received unmapped event %q: %s\n", typeStr, string(event))
|
||||
err := fmt.Errorf("RTM Error: Received unmapped event %q", typeStr)
|
||||
err := NewUnmappedError("RTM Error", typeStr, event)
|
||||
rtm.IncomingEvents <- RTMEvent{"unmarshalling_error", &UnmarshallingErrorEvent{err}}
|
||||
return
|
||||
}
|
||||
|
||||
85
vendor/github.com/slack-go/slack/workflow_step_execute.go
generated
vendored
Normal file
85
vendor/github.com/slack-go/slack/workflow_step_execute.go
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
package slack
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type (
|
||||
WorkflowStepCompletedRequest struct {
|
||||
WorkflowStepExecuteID string `json:"workflow_step_execute_id"`
|
||||
Outputs map[string]string `json:"outputs"`
|
||||
}
|
||||
|
||||
WorkflowStepFailedRequest struct {
|
||||
WorkflowStepExecuteID string `json:"workflow_step_execute_id"`
|
||||
Error struct {
|
||||
Message string `json:"message"`
|
||||
} `json:"error"`
|
||||
}
|
||||
)
|
||||
|
||||
type WorkflowStepCompletedRequestOption func(opt WorkflowStepCompletedRequest) error
|
||||
|
||||
func WorkflowStepCompletedRequestOptionOutput(outputs map[string]string) WorkflowStepCompletedRequestOption {
|
||||
return func(opt WorkflowStepCompletedRequest) error {
|
||||
if len(outputs) > 0 {
|
||||
opt.Outputs = outputs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WorkflowStepCompleted indicates step is completed
|
||||
func (api *Client) WorkflowStepCompleted(workflowStepExecuteID string, options ...WorkflowStepCompletedRequestOption) error {
|
||||
// More information: https://api.slack.com/methods/workflows.stepCompleted
|
||||
r := WorkflowStepCompletedRequest{
|
||||
WorkflowStepExecuteID: workflowStepExecuteID,
|
||||
}
|
||||
for _, option := range options {
|
||||
option(r)
|
||||
}
|
||||
|
||||
endpoint := api.endpoint + "workflows.stepCompleted"
|
||||
jsonData, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
response := &SlackResponse{}
|
||||
if err := postJSON(context.Background(), api.httpclient, endpoint, api.token, jsonData, response, api); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !response.Ok {
|
||||
return response.Err()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// WorkflowStepFailed indicates step is failed
|
||||
func (api *Client) WorkflowStepFailed(workflowStepExecuteID string, errorMessage string) error {
|
||||
// More information: https://api.slack.com/methods/workflows.stepFailed
|
||||
r := WorkflowStepFailedRequest{
|
||||
WorkflowStepExecuteID: workflowStepExecuteID,
|
||||
}
|
||||
r.Error.Message = errorMessage
|
||||
|
||||
endpoint := api.endpoint + "workflows.stepFailed"
|
||||
jsonData, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
response := &SlackResponse{}
|
||||
if err := postJSON(context.Background(), api.httpclient, endpoint, api.token, jsonData, response, api); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !response.Ok {
|
||||
return response.Err()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
24
vendor/github.com/stretchr/testify/assert/assertion_compare.go
generated
vendored
24
vendor/github.com/stretchr/testify/assert/assertion_compare.go
generated
vendored
@@ -1,6 +1,7 @@
|
||||
package assert
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"time"
|
||||
@@ -32,7 +33,8 @@ var (
|
||||
|
||||
stringType = reflect.TypeOf("")
|
||||
|
||||
timeType = reflect.TypeOf(time.Time{})
|
||||
timeType = reflect.TypeOf(time.Time{})
|
||||
bytesType = reflect.TypeOf([]byte{})
|
||||
)
|
||||
|
||||
func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
|
||||
@@ -323,6 +325,26 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
|
||||
|
||||
return compare(timeObj1.UnixNano(), timeObj2.UnixNano(), reflect.Int64)
|
||||
}
|
||||
case reflect.Slice:
|
||||
{
|
||||
// We only care about the []byte type.
|
||||
if !canConvert(obj1Value, bytesType) {
|
||||
break
|
||||
}
|
||||
|
||||
// []byte can be compared!
|
||||
bytesObj1, ok := obj1.([]byte)
|
||||
if !ok {
|
||||
bytesObj1 = obj1Value.Convert(bytesType).Interface().([]byte)
|
||||
|
||||
}
|
||||
bytesObj2, ok := obj2.([]byte)
|
||||
if !ok {
|
||||
bytesObj2 = obj2Value.Convert(bytesType).Interface().([]byte)
|
||||
}
|
||||
|
||||
return CompareType(bytes.Compare(bytesObj1, bytesObj2)), true
|
||||
}
|
||||
}
|
||||
|
||||
return compareEqual, false
|
||||
|
||||
10
vendor/github.com/stretchr/testify/assert/assertion_format.go
generated
vendored
10
vendor/github.com/stretchr/testify/assert/assertion_format.go
generated
vendored
@@ -736,6 +736,16 @@ func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta tim
|
||||
return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
|
||||
}
|
||||
|
||||
// WithinRangef asserts that a time is within a time range (inclusive).
|
||||
//
|
||||
// assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
|
||||
func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
|
||||
if h, ok := t.(tHelper); ok {
|
||||
h.Helper()
|
||||
}
|
||||
return WithinRange(t, actual, start, end, append([]interface{}{msg}, args...)...)
|
||||
}
|
||||
|
||||
// YAMLEqf asserts that two YAML strings are equivalent.
|
||||
func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
|
||||
if h, ok := t.(tHelper); ok {
|
||||
|
||||
20
vendor/github.com/stretchr/testify/assert/assertion_forward.go
generated
vendored
20
vendor/github.com/stretchr/testify/assert/assertion_forward.go
generated
vendored
@@ -1461,6 +1461,26 @@ func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta
|
||||
return WithinDurationf(a.t, expected, actual, delta, msg, args...)
|
||||
}
|
||||
|
||||
// WithinRange asserts that a time is within a time range (inclusive).
|
||||
//
|
||||
// a.WithinRange(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
|
||||
func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool {
|
||||
if h, ok := a.t.(tHelper); ok {
|
||||
h.Helper()
|
||||
}
|
||||
return WithinRange(a.t, actual, start, end, msgAndArgs...)
|
||||
}
|
||||
|
||||
// WithinRangef asserts that a time is within a time range (inclusive).
|
||||
//
|
||||
// a.WithinRangef(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
|
||||
func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
|
||||
if h, ok := a.t.(tHelper); ok {
|
||||
h.Helper()
|
||||
}
|
||||
return WithinRangef(a.t, actual, start, end, msg, args...)
|
||||
}
|
||||
|
||||
// YAMLEq asserts that two YAML strings are equivalent.
|
||||
func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool {
|
||||
if h, ok := a.t.(tHelper); ok {
|
||||
|
||||
78
vendor/github.com/stretchr/testify/assert/assertions.go
generated
vendored
78
vendor/github.com/stretchr/testify/assert/assertions.go
generated
vendored
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"runtime"
|
||||
@@ -144,7 +145,8 @@ func CallerInfo() []string {
|
||||
if len(parts) > 1 {
|
||||
dir := parts[len(parts)-2]
|
||||
if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" {
|
||||
callers = append(callers, fmt.Sprintf("%s:%d", file, line))
|
||||
path, _ := filepath.Abs(file)
|
||||
callers = append(callers, fmt.Sprintf("%s:%d", path, line))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,16 +565,17 @@ func isEmpty(object interface{}) bool {
|
||||
|
||||
switch objValue.Kind() {
|
||||
// collection types are empty when they have no element
|
||||
case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
|
||||
case reflect.Chan, reflect.Map, reflect.Slice:
|
||||
return objValue.Len() == 0
|
||||
// pointers are empty if nil or if the value they point to is empty
|
||||
// pointers are empty if nil or if the value they point to is empty
|
||||
case reflect.Ptr:
|
||||
if objValue.IsNil() {
|
||||
return true
|
||||
}
|
||||
deref := objValue.Elem().Interface()
|
||||
return isEmpty(deref)
|
||||
// for all other types, compare against the zero value
|
||||
// for all other types, compare against the zero value
|
||||
// array types are empty when they match their zero-initialized state
|
||||
default:
|
||||
zero := reflect.Zero(objValue.Type())
|
||||
return reflect.DeepEqual(object, zero.Interface())
|
||||
@@ -815,7 +818,6 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok
|
||||
return true // we consider nil to be equal to the nil set
|
||||
}
|
||||
|
||||
subsetValue := reflect.ValueOf(subset)
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ok = false
|
||||
@@ -825,14 +827,32 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok
|
||||
listKind := reflect.TypeOf(list).Kind()
|
||||
subsetKind := reflect.TypeOf(subset).Kind()
|
||||
|
||||
if listKind != reflect.Array && listKind != reflect.Slice {
|
||||
if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map {
|
||||
return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...)
|
||||
}
|
||||
|
||||
if subsetKind != reflect.Array && subsetKind != reflect.Slice {
|
||||
if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map {
|
||||
return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...)
|
||||
}
|
||||
|
||||
subsetValue := reflect.ValueOf(subset)
|
||||
if subsetKind == reflect.Map && listKind == reflect.Map {
|
||||
listValue := reflect.ValueOf(list)
|
||||
subsetKeys := subsetValue.MapKeys()
|
||||
|
||||
for i := 0; i < len(subsetKeys); i++ {
|
||||
subsetKey := subsetKeys[i]
|
||||
subsetElement := subsetValue.MapIndex(subsetKey).Interface()
|
||||
listElement := listValue.MapIndex(subsetKey).Interface()
|
||||
|
||||
if !ObjectsAreEqual(subsetElement, listElement) {
|
||||
return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, subsetElement), msgAndArgs...)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
for i := 0; i < subsetValue.Len(); i++ {
|
||||
element := subsetValue.Index(i).Interface()
|
||||
ok, found := containsElement(list, element)
|
||||
@@ -859,7 +879,6 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{})
|
||||
return Fail(t, "nil is the empty set which is a subset of every set", msgAndArgs...)
|
||||
}
|
||||
|
||||
subsetValue := reflect.ValueOf(subset)
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ok = false
|
||||
@@ -869,14 +888,32 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{})
|
||||
listKind := reflect.TypeOf(list).Kind()
|
||||
subsetKind := reflect.TypeOf(subset).Kind()
|
||||
|
||||
if listKind != reflect.Array && listKind != reflect.Slice {
|
||||
if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map {
|
||||
return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...)
|
||||
}
|
||||
|
||||
if subsetKind != reflect.Array && subsetKind != reflect.Slice {
|
||||
if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map {
|
||||
return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...)
|
||||
}
|
||||
|
||||
subsetValue := reflect.ValueOf(subset)
|
||||
if subsetKind == reflect.Map && listKind == reflect.Map {
|
||||
listValue := reflect.ValueOf(list)
|
||||
subsetKeys := subsetValue.MapKeys()
|
||||
|
||||
for i := 0; i < len(subsetKeys); i++ {
|
||||
subsetKey := subsetKeys[i]
|
||||
subsetElement := subsetValue.MapIndex(subsetKey).Interface()
|
||||
listElement := listValue.MapIndex(subsetKey).Interface()
|
||||
|
||||
if !ObjectsAreEqual(subsetElement, listElement) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...)
|
||||
}
|
||||
|
||||
for i := 0; i < subsetValue.Len(); i++ {
|
||||
element := subsetValue.Index(i).Interface()
|
||||
ok, found := containsElement(list, element)
|
||||
@@ -1109,6 +1146,27 @@ func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration,
|
||||
return true
|
||||
}
|
||||
|
||||
// WithinRange asserts that a time is within a time range (inclusive).
|
||||
//
|
||||
// assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
|
||||
func WithinRange(t TestingT, actual, start, end time.Time, msgAndArgs ...interface{}) bool {
|
||||
if h, ok := t.(tHelper); ok {
|
||||
h.Helper()
|
||||
}
|
||||
|
||||
if end.Before(start) {
|
||||
return Fail(t, "Start should be before end", msgAndArgs...)
|
||||
}
|
||||
|
||||
if actual.Before(start) {
|
||||
return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is before the range", actual, start, end), msgAndArgs...)
|
||||
} else if actual.After(end) {
|
||||
return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is after the range", actual, start, end), msgAndArgs...)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func toFloat(x interface{}) (float64, bool) {
|
||||
var xf float64
|
||||
xok := true
|
||||
|
||||
26
vendor/github.com/stretchr/testify/require/require.go
generated
vendored
26
vendor/github.com/stretchr/testify/require/require.go
generated
vendored
@@ -1864,6 +1864,32 @@ func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta tim
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
// WithinRange asserts that a time is within a time range (inclusive).
|
||||
//
|
||||
// assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
|
||||
func WithinRange(t TestingT, actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) {
|
||||
if h, ok := t.(tHelper); ok {
|
||||
h.Helper()
|
||||
}
|
||||
if assert.WithinRange(t, actual, start, end, msgAndArgs...) {
|
||||
return
|
||||
}
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
// WithinRangef asserts that a time is within a time range (inclusive).
|
||||
//
|
||||
// assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
|
||||
func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) {
|
||||
if h, ok := t.(tHelper); ok {
|
||||
h.Helper()
|
||||
}
|
||||
if assert.WithinRangef(t, actual, start, end, msg, args...) {
|
||||
return
|
||||
}
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
// YAMLEq asserts that two YAML strings are equivalent.
|
||||
func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
|
||||
if h, ok := t.(tHelper); ok {
|
||||
|
||||
20
vendor/github.com/stretchr/testify/require/require_forward.go
generated
vendored
20
vendor/github.com/stretchr/testify/require/require_forward.go
generated
vendored
@@ -1462,6 +1462,26 @@ func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta
|
||||
WithinDurationf(a.t, expected, actual, delta, msg, args...)
|
||||
}
|
||||
|
||||
// WithinRange asserts that a time is within a time range (inclusive).
|
||||
//
|
||||
// a.WithinRange(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
|
||||
func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) {
|
||||
if h, ok := a.t.(tHelper); ok {
|
||||
h.Helper()
|
||||
}
|
||||
WithinRange(a.t, actual, start, end, msgAndArgs...)
|
||||
}
|
||||
|
||||
// WithinRangef asserts that a time is within a time range (inclusive).
|
||||
//
|
||||
// a.WithinRangef(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
|
||||
func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) {
|
||||
if h, ok := a.t.(tHelper); ok {
|
||||
h.Helper()
|
||||
}
|
||||
WithinRangef(a.t, actual, start, end, msg, args...)
|
||||
}
|
||||
|
||||
// YAMLEq asserts that two YAML strings are equivalent.
|
||||
func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) {
|
||||
if h, ok := a.t.(tHelper); ok {
|
||||
|
||||
15
vendor/github.com/stretchr/testify/suite/suite.go
generated
vendored
15
vendor/github.com/stretchr/testify/suite/suite.go
generated
vendored
@@ -67,8 +67,12 @@ func (suite *Suite) Assert() *assert.Assertions {
|
||||
return suite.Assertions
|
||||
}
|
||||
|
||||
func failOnPanic(t *testing.T) {
|
||||
func recoverAndFailOnPanic(t *testing.T) {
|
||||
r := recover()
|
||||
failOnPanic(t, r)
|
||||
}
|
||||
|
||||
func failOnPanic(t *testing.T, r interface{}) {
|
||||
if r != nil {
|
||||
t.Errorf("test panicked: %v\n%s", r, debug.Stack())
|
||||
t.FailNow()
|
||||
@@ -91,7 +95,7 @@ func (suite *Suite) Run(name string, subtest func()) bool {
|
||||
// Run takes a testing suite and runs all of the tests attached
|
||||
// to it.
|
||||
func Run(t *testing.T, suite TestingSuite) {
|
||||
defer failOnPanic(t)
|
||||
defer recoverAndFailOnPanic(t)
|
||||
|
||||
suite.SetT(t)
|
||||
|
||||
@@ -136,10 +140,12 @@ func Run(t *testing.T, suite TestingSuite) {
|
||||
F: func(t *testing.T) {
|
||||
parentT := suite.T()
|
||||
suite.SetT(t)
|
||||
defer failOnPanic(t)
|
||||
defer recoverAndFailOnPanic(t)
|
||||
defer func() {
|
||||
r := recover()
|
||||
|
||||
if stats != nil {
|
||||
passed := !t.Failed()
|
||||
passed := !t.Failed() && r == nil
|
||||
stats.end(method.Name, passed)
|
||||
}
|
||||
|
||||
@@ -152,6 +158,7 @@ func Run(t *testing.T, suite TestingSuite) {
|
||||
}
|
||||
|
||||
suite.SetT(parentT)
|
||||
failOnPanic(t, r)
|
||||
}()
|
||||
|
||||
if setupTestSuite, ok := suite.(SetupTestSuite); ok {
|
||||
|
||||
Reference in New Issue
Block a user