├── .gitignore ├── Makefile ├── README.md ├── go.mod ├── go.sum ├── herder ├── command.go ├── command_test.go ├── herder.go ├── herder_test.go └── options.go ├── main.go ├── robots ├── about.go ├── about_test.go ├── commit.go ├── definitions.go ├── echo.go ├── eval.go ├── excuse.go ├── flip.go ├── giphy.go ├── help.go ├── hi.go ├── ping.go └── shared.go └── vendor ├── github.com ├── PuerkitoBio │ └── goquery │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── array.go │ │ ├── doc.go │ │ ├── expand.go │ │ ├── filter.go │ │ ├── iteration.go │ │ ├── manipulation.go │ │ ├── property.go │ │ ├── query.go │ │ ├── traversal.go │ │ ├── type.go │ │ └── utilities.go ├── andybalholm │ └── cascadia │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── parser.go │ │ ├── pseudo_classes.go │ │ ├── selector.go │ │ ├── serialize.go │ │ └── specificity.go ├── dlclark │ └── regexp2 │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── ATTRIB │ │ ├── LICENSE │ │ ├── README.md │ │ ├── fastclock.go │ │ ├── match.go │ │ ├── regexp.go │ │ ├── replace.go │ │ ├── runner.go │ │ ├── syntax │ │ ├── charclass.go │ │ ├── code.go │ │ ├── escape.go │ │ ├── fuzz.go │ │ ├── parser.go │ │ ├── prefix.go │ │ ├── replacerdata.go │ │ ├── tree.go │ │ └── writer.go │ │ └── testoutput1 ├── dop251 │ └── goja │ │ ├── .gitignore │ │ ├── .tc39_test262_checkout.sh │ │ ├── LICENSE │ │ ├── README.md │ │ ├── array.go │ │ ├── array_sparse.go │ │ ├── ast │ │ ├── README.markdown │ │ └── node.go │ │ ├── builtin_array.go │ │ ├── builtin_boolean.go │ │ ├── builtin_date.go │ │ ├── builtin_error.go │ │ ├── builtin_function.go │ │ ├── builtin_global.go │ │ ├── builtin_json.go │ │ ├── builtin_map.go │ │ ├── builtin_math.go │ │ ├── builtin_number.go │ │ ├── builtin_object.go │ │ ├── builtin_promise.go │ │ ├── builtin_proxy.go │ │ ├── builtin_reflect.go │ │ ├── builtin_regexp.go │ │ ├── builtin_set.go │ │ ├── builtin_string.go │ │ ├── builtin_symbol.go │ │ ├── builtin_typedarrays.go │ │ ├── builtin_weakmap.go │ │ ├── builtin_weakset.go │ │ ├── compiler.go │ │ ├── compiler_expr.go │ │ ├── compiler_stmt.go │ │ ├── date.go │ │ ├── date_parser.go │ │ ├── destruct.go │ │ ├── extract_failed_tests.sh │ │ ├── file │ │ ├── README.markdown │ │ └── file.go │ │ ├── ftoa │ │ ├── LICENSE_LUCENE │ │ ├── common.go │ │ ├── ftoa.go │ │ ├── ftobasestr.go │ │ ├── ftostr.go │ │ └── internal │ │ │ └── fast │ │ │ ├── LICENSE_V8 │ │ │ ├── cachedpower.go │ │ │ ├── common.go │ │ │ ├── diyfp.go │ │ │ └── dtoa.go │ │ ├── func.go │ │ ├── ipow.go │ │ ├── map.go │ │ ├── object.go │ │ ├── object_args.go │ │ ├── object_dynamic.go │ │ ├── object_goarray_reflect.go │ │ ├── object_gomap.go │ │ ├── object_gomap_reflect.go │ │ ├── object_goreflect.go │ │ ├── object_goslice.go │ │ ├── object_goslice_reflect.go │ │ ├── object_lazy.go │ │ ├── parser │ │ ├── README.markdown │ │ ├── error.go │ │ ├── expression.go │ │ ├── lexer.go │ │ ├── parser.go │ │ ├── regexp.go │ │ ├── scope.go │ │ └── statement.go │ │ ├── proxy.go │ │ ├── regexp.go │ │ ├── runtime.go │ │ ├── staticcheck.conf │ │ ├── string.go │ │ ├── string_ascii.go │ │ ├── string_imported.go │ │ ├── string_unicode.go │ │ ├── token │ │ ├── Makefile │ │ ├── README.markdown │ │ ├── token.go │ │ ├── token_const.go │ │ └── tokenfmt │ │ ├── typedarrays.go │ │ ├── unistring │ │ └── string.go │ │ ├── value.go │ │ └── vm.go ├── go-sourcemap │ └── sourcemap │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.md │ │ ├── consumer.go │ │ ├── internal │ │ └── base64vlq │ │ │ └── base64vlq.go │ │ └── mappings.go └── peterhellberg │ ├── flip │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ └── flip.go │ ├── giphy │ ├── LICENSE │ ├── README.md │ ├── client.go │ ├── env.go │ ├── errors.go │ ├── gif.go │ ├── options.go │ ├── random.go │ ├── search.go │ ├── translate.go │ ├── trending.go │ └── types.go │ └── hi │ ├── .travis.yml │ ├── README.md │ └── hi.go ├── golang.org └── x │ ├── crypto │ ├── LICENSE │ ├── PATENTS │ ├── blowfish │ │ ├── block.go │ │ ├── cipher.go │ │ └── const.go │ ├── chacha20 │ │ ├── chacha_arm64.go │ │ ├── chacha_arm64.s │ │ ├── chacha_generic.go │ │ ├── chacha_noasm.go │ │ ├── chacha_ppc64le.go │ │ ├── chacha_ppc64le.s │ │ ├── chacha_s390x.go │ │ ├── chacha_s390x.s │ │ └── xor.go │ ├── curve25519 │ │ ├── curve25519.go │ │ └── internal │ │ │ └── field │ │ │ ├── README │ │ │ ├── fe.go │ │ │ ├── fe_amd64.go │ │ │ ├── fe_amd64.s │ │ │ ├── fe_amd64_noasm.go │ │ │ ├── fe_arm64.go │ │ │ ├── fe_arm64.s │ │ │ ├── fe_arm64_noasm.go │ │ │ ├── fe_generic.go │ │ │ ├── sync.checkpoint │ │ │ └── sync.sh │ ├── ed25519 │ │ └── ed25519.go │ ├── internal │ │ ├── alias │ │ │ ├── alias.go │ │ │ └── alias_purego.go │ │ └── poly1305 │ │ │ ├── bits_compat.go │ │ │ ├── bits_go1.13.go │ │ │ ├── mac_noasm.go │ │ │ ├── poly1305.go │ │ │ ├── sum_amd64.go │ │ │ ├── sum_amd64.s │ │ │ ├── sum_generic.go │ │ │ ├── sum_ppc64le.go │ │ │ ├── sum_ppc64le.s │ │ │ ├── sum_s390x.go │ │ │ └── sum_s390x.s │ └── ssh │ │ ├── buffer.go │ │ ├── certs.go │ │ ├── channel.go │ │ ├── cipher.go │ │ ├── client.go │ │ ├── client_auth.go │ │ ├── common.go │ │ ├── connection.go │ │ ├── doc.go │ │ ├── handshake.go │ │ ├── internal │ │ └── bcrypt_pbkdf │ │ │ └── bcrypt_pbkdf.go │ │ ├── kex.go │ │ ├── keys.go │ │ ├── mac.go │ │ ├── messages.go │ │ ├── mux.go │ │ ├── server.go │ │ ├── session.go │ │ ├── ssh_gss.go │ │ ├── streamlocal.go │ │ ├── tcpip.go │ │ └── transport.go │ ├── net │ ├── LICENSE │ ├── PATENTS │ └── html │ │ ├── atom │ │ ├── atom.go │ │ └── table.go │ │ ├── const.go │ │ ├── doc.go │ │ ├── doctype.go │ │ ├── entity.go │ │ ├── escape.go │ │ ├── foreign.go │ │ ├── node.go │ │ ├── parse.go │ │ ├── render.go │ │ └── token.go │ ├── sys │ ├── LICENSE │ ├── PATENTS │ └── cpu │ │ ├── asm_aix_ppc64.s │ │ ├── byteorder.go │ │ ├── cpu.go │ │ ├── cpu_aix.go │ │ ├── cpu_arm.go │ │ ├── cpu_arm64.go │ │ ├── cpu_arm64.s │ │ ├── cpu_gc_arm64.go │ │ ├── cpu_gc_s390x.go │ │ ├── cpu_gc_x86.go │ │ ├── cpu_gccgo_arm64.go │ │ ├── cpu_gccgo_s390x.go │ │ ├── cpu_gccgo_x86.c │ │ ├── cpu_gccgo_x86.go │ │ ├── cpu_linux.go │ │ ├── cpu_linux_arm.go │ │ ├── cpu_linux_arm64.go │ │ ├── cpu_linux_mips64x.go │ │ ├── cpu_linux_noinit.go │ │ ├── cpu_linux_ppc64x.go │ │ ├── cpu_linux_s390x.go │ │ ├── cpu_loong64.go │ │ ├── cpu_mips64x.go │ │ ├── cpu_mipsx.go │ │ ├── cpu_netbsd_arm64.go │ │ ├── cpu_openbsd_arm64.go │ │ ├── cpu_openbsd_arm64.s │ │ ├── cpu_other_arm.go │ │ ├── cpu_other_arm64.go │ │ ├── cpu_other_mips64x.go │ │ ├── cpu_other_ppc64x.go │ │ ├── cpu_other_riscv64.go │ │ ├── cpu_ppc64x.go │ │ ├── cpu_riscv64.go │ │ ├── cpu_s390x.go │ │ ├── cpu_s390x.s │ │ ├── cpu_wasm.go │ │ ├── cpu_x86.go │ │ ├── cpu_x86.s │ │ ├── cpu_zos.go │ │ ├── cpu_zos_s390x.go │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── hwcap_linux.go │ │ ├── parse.go │ │ ├── proc_cpuinfo_linux.go │ │ ├── syscall_aix_gccgo.go │ │ └── syscall_aix_ppc64_gc.go │ └── text │ ├── LICENSE │ ├── PATENTS │ ├── cases │ ├── cases.go │ ├── context.go │ ├── fold.go │ ├── icu.go │ ├── info.go │ ├── map.go │ ├── tables10.0.0.go │ ├── tables11.0.0.go │ ├── tables12.0.0.go │ ├── tables13.0.0.go │ ├── tables9.0.0.go │ └── trieval.go │ ├── collate │ ├── collate.go │ ├── index.go │ ├── option.go │ ├── sort.go │ └── tables.go │ ├── internal │ ├── colltab │ │ ├── collelem.go │ │ ├── colltab.go │ │ ├── contract.go │ │ ├── iter.go │ │ ├── numeric.go │ │ ├── table.go │ │ ├── trie.go │ │ └── weighter.go │ ├── internal.go │ ├── language │ │ ├── common.go │ │ ├── compact.go │ │ ├── compact │ │ │ ├── compact.go │ │ │ ├── language.go │ │ │ ├── parents.go │ │ │ ├── tables.go │ │ │ └── tags.go │ │ ├── compose.go │ │ ├── coverage.go │ │ ├── language.go │ │ ├── lookup.go │ │ ├── match.go │ │ ├── parse.go │ │ ├── tables.go │ │ └── tags.go │ ├── match.go │ └── tag │ │ └── tag.go │ ├── language │ ├── coverage.go │ ├── doc.go │ ├── language.go │ ├── match.go │ ├── parse.go │ ├── tables.go │ └── tags.go │ ├── transform │ └── transform.go │ └── unicode │ ├── norm │ ├── composition.go │ ├── forminfo.go │ ├── input.go │ ├── iter.go │ ├── normalize.go │ ├── readwriter.go │ ├── tables10.0.0.go │ ├── tables11.0.0.go │ ├── tables12.0.0.go │ ├── tables13.0.0.go │ ├── tables9.0.0.go │ ├── transform.go │ └── trie.go │ └── rangetable │ ├── merge.go │ ├── rangetable.go │ ├── tables10.0.0.go │ ├── tables11.0.0.go │ ├── tables12.0.0.go │ ├── tables13.0.0.go │ └── tables9.0.0.go └── modules.txt /.gitignore: -------------------------------------------------------------------------------- 1 | ssh-chat-bot 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | BINARY = ssh-chat-bot 2 | 3 | all: $(BINARY) 4 | 5 | **/*.go: 6 | go build ./... 7 | 8 | $(BINARY): **/*.go *.go 9 | go build -ldflags "-X main.buildCommit=`git rev-parse --short HEAD`" . 10 | 11 | build: $(BINARY) 12 | 13 | clean: 14 | rm -f $(BINARY) 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ssh-chat-bot 2 | 3 | A small chatbot for [ssh-chat](https://github.com/shazow/ssh-chat). 4 | 5 | [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/peterhellberg/ssh-chat-bot) 6 | [![License MIT](https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/peterhellberg/ssh-chat-bot#mit-license) 7 | 8 | ## Installation 9 | 10 | ```bash 11 | go get -u github.com/peterhellberg/ssh-chat-bot 12 | ``` 13 | 14 | You can also clone the repo and then run `make` in 15 | order to populate the `main.buildCommit` variable. 16 | 17 | ## Usage 18 | 19 | ```bash 20 | usage: ./ssh-chat-bot [-h hostname] [-v] 21 | 22 | flags: 23 | -c=30s: Duration between alive checks 24 | -d=5s: Delay 25 | -h="localhost": Hostname 26 | -n="ssh-chat-bot": Username 27 | -o="peterhellberg": Bot owner username 28 | -p=2200: Port 29 | -v=false: Verbose output 30 | ``` 31 | 32 | ## Robots 33 | 34 | [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/peterhellberg/ssh-chat-bot/robots) 35 | 36 | ### Robot skeleton 37 | 38 | ```go 39 | package robots 40 | 41 | // PingBot is a simple ping/pong bot 42 | type PingBot struct{} 43 | 44 | func init() { 45 | RegisterRobot("ping", func() (robot Robot) { return new(PingBot) }) 46 | } 47 | 48 | // Run executes a command 49 | func (b PingBot) Run(c *Command) string { 50 | return "pong" 51 | } 52 | 53 | // Description describes what the robot does 54 | func (b PingBot) Description() string { 55 | return "pong" 56 | } 57 | 58 | ``` 59 | 60 | ## MIT License 61 | 62 | *Copyright (C) 2015-2018 [Peter Hellberg](https://c7.se/)* 63 | 64 | > Permission is hereby granted, free of charge, to any person obtaining 65 | > a copy of this software and associated documentation files (the "Software"), 66 | > to deal in the Software without restriction, including without limitation 67 | > the rights to use, copy, modify, merge, publish, distribute, sublicense, 68 | > and/or sell copies of the Software, and to permit persons to whom the 69 | > Software is furnished to do so, subject to the following conditions: 70 | > 71 | > The above copyright notice and this permission notice shall be included 72 | > in all copies or substantial portions of the Software. 73 | > 74 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 75 | > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 76 | > OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 77 | > IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 78 | > DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 79 | > TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 80 | > OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 81 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/peterhellberg/ssh-chat-bot 2 | 3 | go 1.20 4 | 5 | require ( 6 | github.com/PuerkitoBio/goquery v1.8.0 7 | github.com/dop251/goja v0.0.0-20230203172422-5460598cfa32 8 | github.com/peterhellberg/flip v0.0.0-20190124112217-35a0e6f6e8e6 9 | github.com/peterhellberg/giphy v0.0.2 10 | github.com/peterhellberg/hi v0.0.0-20190124111154-9ac9cb027a95 11 | golang.org/x/crypto v0.5.0 12 | ) 13 | 14 | require ( 15 | github.com/andybalholm/cascadia v1.3.1 // indirect 16 | github.com/dlclark/regexp2 v1.8.0 // indirect 17 | github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect 18 | golang.org/x/net v0.5.0 // indirect 19 | golang.org/x/sys v0.5.0 // indirect 20 | golang.org/x/text v0.6.0 // indirect 21 | ) 22 | -------------------------------------------------------------------------------- /herder/command.go: -------------------------------------------------------------------------------- 1 | package herder 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | 7 | "github.com/peterhellberg/ssh-chat-bot/robots" 8 | ) 9 | 10 | var ( 11 | errWrongUser = fmt.Errorf("wrong user") 12 | errNotEnoughFieldsInLine = fmt.Errorf("not enough fields in line") 13 | ) 14 | 15 | func parsePublicCommand(line, user string) (*robots.Command, error) { 16 | fields := strings.Fields(line) 17 | 18 | if len(fields) < 3 { 19 | return nil, errNotEnoughFieldsInLine 20 | } 21 | 22 | if strings.TrimRight(fields[1], ":") != user { 23 | return nil, errWrongUser 24 | } 25 | 26 | args := []string{} 27 | 28 | if len(fields) > 3 { 29 | for _, f := range fields[3:] { 30 | args = append(args, strings.TrimRight(f, "\a")) 31 | } 32 | } 33 | 34 | return &robots.Command{ 35 | From: strings.TrimRight(fields[0], ":"), 36 | Command: strings.TrimRight(fields[2], "\a"), 37 | Args: args, 38 | }, nil 39 | } 40 | 41 | func parsePrivateCommand(line string) (*robots.Command, error) { 42 | fields := strings.Fields(strings.TrimPrefix(line, "[PM from ")) 43 | 44 | if len(fields) < 2 { 45 | return nil, errNotEnoughFieldsInLine 46 | } 47 | 48 | args := []string{} 49 | 50 | if len(fields) > 2 { 51 | for _, f := range fields[2:] { 52 | args = append(args, strings.TrimRight(f, "\a")) 53 | } 54 | } 55 | 56 | return &robots.Command{ 57 | From: strings.TrimRight(fields[0], "]"), 58 | Command: strings.TrimRight(fields[1], "\a"), 59 | Args: args, 60 | }, nil 61 | } 62 | -------------------------------------------------------------------------------- /herder/command_test.go: -------------------------------------------------------------------------------- 1 | package herder 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | 7 | "github.com/peterhellberg/ssh-chat-bot/robots" 8 | ) 9 | 10 | func TestParsePublicCommand(t *testing.T) { 11 | for _, tt := range []struct { 12 | line string 13 | user string 14 | want *robots.Command 15 | err error 16 | }{ 17 | { 18 | "", 19 | "", 20 | nil, 21 | errNotEnoughFieldsInLine, 22 | }, 23 | { 24 | "peter: wrong-user: eval 5 * 110\r", 25 | "ssh-chat-bot", 26 | nil, 27 | errWrongUser, 28 | }, 29 | { 30 | "peter: ssh-chat-bot: eval 5 * 110\r", 31 | "ssh-chat-bot", 32 | &robots.Command{ 33 | From: "peter", 34 | Command: "eval", 35 | Args: []string{ 36 | "5", 37 | "*", 38 | "110", 39 | }, 40 | }, 41 | nil, 42 | }, 43 | } { 44 | got, err := parsePublicCommand(tt.line, tt.user) 45 | if err != tt.err { 46 | t.Fatalf("unexpected error: %v", err) 47 | } 48 | 49 | if !reflect.DeepEqual(got, tt.want) { 50 | t.Fatalf("got %#v, want %#v", got, tt.want) 51 | } 52 | } 53 | } 54 | 55 | func TestParsePrivateCommand(t *testing.T) { 56 | for _, tt := range []struct { 57 | line string 58 | want *robots.Command 59 | err error 60 | }{ 61 | { 62 | "", 63 | nil, 64 | errNotEnoughFieldsInLine, 65 | }, 66 | { 67 | "[PM from peter] eval 1 + 2", 68 | &robots.Command{ 69 | From: "peter", 70 | Command: "eval", 71 | Args: []string{ 72 | "1", 73 | "+", 74 | "2", 75 | }, 76 | }, 77 | nil, 78 | }, 79 | } { 80 | got, err := parsePrivateCommand(tt.line) 81 | if err != tt.err { 82 | t.Fatalf("unexpected error: %v", err) 83 | } 84 | 85 | if !reflect.DeepEqual(got, tt.want) { 86 | t.Fatalf("got %#v, want %#v", got, tt.want) 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /herder/herder_test.go: -------------------------------------------------------------------------------- 1 | package herder 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | func TestNew(t *testing.T) { 9 | h := New( 10 | User("u"), 11 | Owner("o"), 12 | Addr("a"), 13 | Delay(time.Second), 14 | Check(time.Minute), 15 | Verbose(true), 16 | ) 17 | 18 | if err := h.validate(); err != nil { 19 | t.Fatalf("unexpected error: %v", err) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /herder/options.go: -------------------------------------------------------------------------------- 1 | package herder 2 | 3 | import "time" 4 | 5 | type Option func(*Herder) 6 | 7 | func User(u string) Option { 8 | return func(h *Herder) { 9 | h.user = u 10 | } 11 | } 12 | 13 | func Owner(o string) Option { 14 | return func(h *Herder) { 15 | h.owner = o 16 | } 17 | } 18 | 19 | func Addr(a string) Option { 20 | return func(h *Herder) { 21 | h.addr = a 22 | } 23 | } 24 | 25 | func Delay(d time.Duration) Option { 26 | return func(h *Herder) { 27 | h.delay = d 28 | } 29 | } 30 | 31 | func Check(c time.Duration) Option { 32 | return func(h *Herder) { 33 | h.check = c 34 | } 35 | } 36 | 37 | func Verbose(v bool) Option { 38 | return func(h *Herder) { 39 | h.verbose = v 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | ssh-chat-bot 4 | 5 | A small chatbot for ssh-chat 6 | 7 | */ 8 | package main 9 | 10 | import ( 11 | "flag" 12 | "fmt" 13 | "os" 14 | "time" 15 | 16 | "github.com/peterhellberg/ssh-chat-bot/herder" 17 | ) 18 | 19 | const repoURL = "https://github.com/peterhellberg/ssh-chat-bot" 20 | 21 | var buildCommit string 22 | 23 | func main() { 24 | var ( 25 | user = flag.String("n", "ssh-chat-bot", "Username") 26 | owner = flag.String("o", "peter", "Bot owner username") 27 | host = flag.String("h", "localhost", "Hostname") 28 | port = flag.Int("p", 2022, "Port") 29 | delay = flag.Duration("d", 2*time.Second, "Delay") 30 | check = flag.Duration("c", 30*time.Second, "Duration between alive checks") 31 | verbose = flag.Bool("v", false, "Verbose output") 32 | ) 33 | 34 | flag.Usage = usage 35 | 36 | flag.Parse() 37 | 38 | h := herder.New( 39 | herder.User(*user), 40 | herder.Owner(*owner), 41 | herder.Addr(fmt.Sprintf("%s:%d", *host, *port)), 42 | herder.Delay(*delay), 43 | herder.Check(*check), 44 | herder.Verbose(*verbose), 45 | ) 46 | 47 | if err := h.Run(); err != nil { 48 | fmt.Printf("Error: %v\n", err) 49 | os.Exit(1) 50 | } 51 | } 52 | 53 | func usage() { 54 | fmt.Fprintf(os.Stderr, "usage: ./ssh-chat-bot [-h hostname] [-v]\n\n") 55 | 56 | if buildCommit != "" { 57 | fmt.Fprintf(os.Stderr, "build: "+repoURL+"/commit/"+buildCommit+"\n\n") 58 | } 59 | 60 | fmt.Fprintf(os.Stderr, "flags:\n") 61 | flag.PrintDefaults() 62 | fmt.Fprintf(os.Stderr, "\n") 63 | os.Exit(2) 64 | } 65 | -------------------------------------------------------------------------------- /robots/about.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | // AboutBot describes ssh-chat-bot 4 | type AboutBot struct{} 5 | 6 | func init() { 7 | RegisterRobot("about", func() (robot Robot) { return new(AboutBot) }) 8 | } 9 | 10 | const aboutRawurl = "https://github.com/peterhellberg/ssh-chat-bot" 11 | 12 | // Run executes a command 13 | func (b AboutBot) Run(c *Command) string { 14 | return aboutRawurl 15 | } 16 | 17 | // Description describes what the robot does 18 | func (b AboutBot) Description() string { 19 | return "" 20 | } 21 | -------------------------------------------------------------------------------- /robots/about_test.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | import "testing" 4 | 5 | func TestAboutBot(t *testing.T) { 6 | bot, err := GetRobot("about") 7 | if err != nil { 8 | t.Fatalf("unexpected error: %v", err) 9 | } 10 | 11 | cmd := &Command{} 12 | 13 | if got, want := bot.Run(cmd), aboutRawurl; got != want { 14 | t.Fatalf("bot.Run(cmd) = %q, want %q", got, want) 15 | } 16 | 17 | if got, want := bot.Description(), ""; got != want { 18 | t.Fatalf("bot.Description() = %q, want %q", got, want) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /robots/commit.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | import ( 4 | "io/ioutil" 5 | "net/http" 6 | ) 7 | 8 | // CommitBot replies with fun commit messages 9 | type CommitBot struct{} 10 | 11 | func init() { 12 | RegisterRobot("commit", func() (robot Robot) { return new(CommitBot) }) 13 | } 14 | 15 | // Run executes a command 16 | func (b CommitBot) Run(c *Command) string { 17 | resp, err := http.Get("http://whatthecommit.com/index.txt") 18 | if err != nil { 19 | return "" 20 | } 21 | 22 | defer resp.Body.Close() 23 | 24 | body, err := ioutil.ReadAll(resp.Body) 25 | if err != nil { 26 | return "" 27 | } 28 | 29 | return string(body) 30 | } 31 | 32 | // Description describes what the robot does 33 | func (b CommitBot) Description() string { 34 | return "" 35 | } 36 | -------------------------------------------------------------------------------- /robots/definitions.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | // Robot is the interface all robots must follow 4 | type Robot interface { 5 | Run(*Command) string 6 | Description() string 7 | } 8 | 9 | // Command represents the fields in a ssh-chat-bot command 10 | type Command struct { 11 | From string 12 | Command string 13 | Args []string 14 | } 15 | -------------------------------------------------------------------------------- /robots/echo.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | import "strings" 4 | 5 | // EchoBot is a simple echo bot 6 | type EchoBot struct{} 7 | 8 | func init() { 9 | RegisterRobot("echo", func() (robot Robot) { return new(EchoBot) }) 10 | } 11 | 12 | // Run executes a command 13 | func (b EchoBot) Run(c *Command) string { 14 | return strings.Join(c.Args, " ") 15 | } 16 | 17 | // Description describes what the robot does 18 | func (b EchoBot) Description() string { 19 | return "" 20 | } 21 | -------------------------------------------------------------------------------- /robots/eval.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "time" 7 | 8 | "github.com/dop251/goja" 9 | ) 10 | 11 | // EvalBot is a bot that evaluates JavaScript 12 | type EvalBot struct{} 13 | 14 | func init() { 15 | RegisterRobot("eval", func() (robot Robot) { return new(EvalBot) }) 16 | } 17 | 18 | // Run executes a command 19 | func (b EvalBot) Run(c *Command) string { 20 | vm := goja.New() 21 | 22 | time.AfterFunc(1*time.Second, func() { 23 | vm.Interrupt("JS timeout") 24 | }) 25 | 26 | value, err := vm.RunString(strings.Join(c.Args, " ")) 27 | if err != nil { 28 | return err.Error() 29 | } 30 | 31 | out := fmt.Sprintf("%v", value) 32 | 33 | if strings.HasPrefix(out, "/") || 34 | strings.Contains(out, "\r") || 35 | strings.Contains(out, "\b") || 36 | strings.Contains(out, "/me") || 37 | strings.Contains(out, "/msg") || 38 | strings.Contains(out, "/nick") || 39 | strings.Contains(out, "exit") { 40 | return "Sorry, I won’t do that" 41 | } 42 | 43 | if len(out) > 128 { 44 | return "Output too big!" 45 | } 46 | 47 | return out 48 | } 49 | 50 | // Description describes what the robot does 51 | func (b EvalBot) Description() string { 52 | return "" 53 | } 54 | -------------------------------------------------------------------------------- /robots/excuse.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | import "github.com/PuerkitoBio/goquery" 4 | 5 | // ExcuseBot is a simple echo bot 6 | type ExcuseBot struct{} 7 | 8 | func init() { 9 | RegisterRobot("excuse", func() (robot Robot) { return new(ExcuseBot) }) 10 | } 11 | 12 | // Run executes a command 13 | func (b ExcuseBot) Run(c *Command) string { 14 | doc, err := goquery.NewDocument("http://developerexcuses.com/") 15 | if err != nil { 16 | return "" 17 | } 18 | 19 | return doc.Find(".wrapper center a").First().Text() 20 | } 21 | 22 | // Description describes what the robot does 23 | func (b ExcuseBot) Description() string { 24 | return "" 25 | } 26 | -------------------------------------------------------------------------------- /robots/flip.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/peterhellberg/flip" 7 | ) 8 | 9 | // FlipBot is a bot who flips text 10 | type FlipBot struct{} 11 | 12 | func init() { 13 | RegisterRobot("flip", func() (robot Robot) { return new(FlipBot) }) 14 | } 15 | 16 | // Run executes a deferred action 17 | func (b FlipBot) Run(c *Command) string { 18 | switch c.Args[0] { 19 | default: 20 | return flip.UpsideDown(strings.Join(c.Args, " ")) 21 | case "table", "t": 22 | return flip.Table(strings.Join(c.Args[1:], " ")) 23 | case "gopher", "g": 24 | return flip.Gopher(strings.Join(c.Args[1:], " ")) 25 | } 26 | 27 | return "" 28 | } 29 | 30 | // Description describes what the robot does 31 | func (b FlipBot) Description() string { 32 | return "" 33 | } 34 | -------------------------------------------------------------------------------- /robots/giphy.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/peterhellberg/giphy" 7 | ) 8 | 9 | // GiphyBot is a robot who speak in GIFs 10 | type GiphyBot struct { 11 | // Client is a client for the Giphy API 12 | Client *giphy.Client 13 | } 14 | 15 | func init() { 16 | RegisterRobot("giphy", func() (robot Robot) { 17 | return &GiphyBot{Client: giphy.DefaultClient} 18 | }) 19 | } 20 | 21 | // Run executes a deferred action 22 | func (b GiphyBot) Run(c *Command) string { 23 | args := []string{} 24 | 25 | for _, a := range c.Args { 26 | args = append(args, strings.ToLower(a)) 27 | } 28 | 29 | switch args[0] { 30 | default: 31 | return b.search(c, args) 32 | case "search", "s": 33 | return b.search(c, args[1:]) 34 | case "gif", "id": 35 | return b.gif(c, args[1:]) 36 | case "random", "rand", "r": 37 | return b.random(c, args[1:]) 38 | case "translate", "trans", "t": 39 | return b.translate(c, args[1:]) 40 | case "trending", "trend", "tr": 41 | return b.trending(c, args[1:]) 42 | } 43 | 44 | return "" 45 | } 46 | 47 | // Description describes what the robot does 48 | func (b GiphyBot) Description() string { 49 | return " [args]" 50 | } 51 | 52 | func (b GiphyBot) search(c *Command, args []string) string { 53 | res, err := b.Client.Search(args) 54 | if err != nil || len(res.Data) == 0 { 55 | return "" 56 | } 57 | 58 | return strings.Join(args, " ") + ": " + res.Data[0].Images.FixedHeight.URL 59 | } 60 | 61 | func (b GiphyBot) gif(c *Command, args []string) string { 62 | if len(args) == 0 { 63 | return "" 64 | } 65 | 66 | res, err := b.Client.GIF(args[0]) 67 | if err != nil { 68 | return err.Error() 69 | } 70 | 71 | return "GIF: " + res.Data.Images.FixedHeightDownsampled.URL 72 | } 73 | 74 | func (b GiphyBot) random(c *Command, args []string) string { 75 | res, err := b.Client.Random(args) 76 | if err != nil { 77 | return err.Error() 78 | } 79 | 80 | return "Random: " + res.Data.FixedHeightDownsampledURL 81 | } 82 | 83 | func (b GiphyBot) translate(c *Command, args []string) string { 84 | res, err := b.Client.Translate(args) 85 | if err != nil { 86 | return err.Error() 87 | } 88 | 89 | return res.Data.Images.FixedHeight.URL 90 | } 91 | 92 | func (b GiphyBot) trending(c *Command, args []string) string { 93 | res, err := b.Client.Trending(args) 94 | if err != nil { 95 | return err.Error() 96 | } 97 | 98 | return "Trending: " + res.Data[0].Images.FixedHeight.URL 99 | } 100 | -------------------------------------------------------------------------------- /robots/help.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | import "strings" 4 | 5 | // HelpBot is a robot that list all the robots 6 | type HelpBot struct{} 7 | 8 | func init() { 9 | RegisterRobot("help", func() (robot Robot) { return new(HelpBot) }) 10 | } 11 | 12 | // Run returns a list of all robots 13 | func (b HelpBot) Run(c *Command) string { 14 | outputs := []string{} 15 | 16 | for name, fn := range Robots { 17 | if name != "help" { 18 | output := name 19 | 20 | if desc := fn().Description(); desc != "" { 21 | output += " " + desc 22 | } 23 | 24 | outputs = append(outputs, output) 25 | } 26 | } 27 | 28 | return strings.Join(outputs, ", ") 29 | } 30 | 31 | // Description describes what the robot does 32 | func (b HelpBot) Description() string { 33 | return "" 34 | } 35 | -------------------------------------------------------------------------------- /robots/hi.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | import "github.com/peterhellberg/hi" 4 | 5 | // HiBot is a bot that finds images for a given hashtag 6 | type HiBot struct{} 7 | 8 | func init() { 9 | RegisterRobot("hi", func() (robot Robot) { return new(HiBot) }) 10 | } 11 | 12 | // Run executes a deferred action 13 | func (b HiBot) Run(c *Command) string { 14 | if len(c.Args) > 0 { 15 | img, err := hi.FindShuffledImage(c.Args[0]) 16 | if err == nil { 17 | return img.URL 18 | } 19 | } 20 | 21 | return "" 22 | } 23 | 24 | // Description describes what the robot does 25 | func (b HiBot) Description() string { 26 | return "" 27 | } 28 | -------------------------------------------------------------------------------- /robots/ping.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | // PingBot is a simple ping/pong bot 4 | type PingBot struct{} 5 | 6 | func init() { 7 | RegisterRobot("ping", func() (robot Robot) { return new(PingBot) }) 8 | } 9 | 10 | // Run executes a command 11 | func (b PingBot) Run(c *Command) string { 12 | return "pong" 13 | } 14 | 15 | // Description describes what the robot does 16 | func (b PingBot) Description() string { 17 | return "" 18 | } 19 | -------------------------------------------------------------------------------- /robots/shared.go: -------------------------------------------------------------------------------- 1 | package robots 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | ) 7 | 8 | // Robots contains a map of robots 9 | var Robots = make(map[string]func() Robot) 10 | 11 | // RegisterRobot registers a command and init function for a robot 12 | func RegisterRobot(command string, robotInitFunction func() Robot) { 13 | if _, ok := Robots[command]; ok { 14 | log.Printf("There are two robots mapped to %s!", command) 15 | } else { 16 | Robots[command] = robotInitFunction 17 | } 18 | } 19 | 20 | func GetRobot(command string) (Robot, error) { 21 | if fn, ok := Robots[command]; ok { 22 | return fn(), nil 23 | } 24 | 25 | return nil, fmt.Errorf("unknown robot: %s", command) 26 | 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/.gitattributes: -------------------------------------------------------------------------------- 1 | testdata/* linguist-vendored 2 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/.gitignore: -------------------------------------------------------------------------------- 1 | # editor temporary files 2 | *.sublime-* 3 | .DS_Store 4 | *.swp 5 | #*.*# 6 | tags 7 | 8 | # direnv config 9 | .env* 10 | 11 | # test binaries 12 | *.test 13 | 14 | # coverage and profilte outputs 15 | *.out 16 | 17 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2021, Martin Angers & Contributors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/expand.go: -------------------------------------------------------------------------------- 1 | package goquery 2 | 3 | import "golang.org/x/net/html" 4 | 5 | // Add adds the selector string's matching nodes to those in the current 6 | // selection and returns a new Selection object. 7 | // The selector string is run in the context of the document of the current 8 | // Selection object. 9 | func (s *Selection) Add(selector string) *Selection { 10 | return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, compileMatcher(selector))...) 11 | } 12 | 13 | // AddMatcher adds the matcher's matching nodes to those in the current 14 | // selection and returns a new Selection object. 15 | // The matcher is run in the context of the document of the current 16 | // Selection object. 17 | func (s *Selection) AddMatcher(m Matcher) *Selection { 18 | return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, m)...) 19 | } 20 | 21 | // AddSelection adds the specified Selection object's nodes to those in the 22 | // current selection and returns a new Selection object. 23 | func (s *Selection) AddSelection(sel *Selection) *Selection { 24 | if sel == nil { 25 | return s.AddNodes() 26 | } 27 | return s.AddNodes(sel.Nodes...) 28 | } 29 | 30 | // Union is an alias for AddSelection. 31 | func (s *Selection) Union(sel *Selection) *Selection { 32 | return s.AddSelection(sel) 33 | } 34 | 35 | // AddNodes adds the specified nodes to those in the 36 | // current selection and returns a new Selection object. 37 | func (s *Selection) AddNodes(nodes ...*html.Node) *Selection { 38 | return pushStack(s, appendWithoutDuplicates(s.Nodes, nodes, nil)) 39 | } 40 | 41 | // AndSelf adds the previous set of elements on the stack to the current set. 42 | // It returns a new Selection object containing the current Selection combined 43 | // with the previous one. 44 | // Deprecated: This function has been deprecated and is now an alias for AddBack(). 45 | func (s *Selection) AndSelf() *Selection { 46 | return s.AddBack() 47 | } 48 | 49 | // AddBack adds the previous set of elements on the stack to the current set. 50 | // It returns a new Selection object containing the current Selection combined 51 | // with the previous one. 52 | func (s *Selection) AddBack() *Selection { 53 | return s.AddSelection(s.prevSel) 54 | } 55 | 56 | // AddBackFiltered reduces the previous set of elements on the stack to those that 57 | // match the selector string, and adds them to the current set. 58 | // It returns a new Selection object containing the current Selection combined 59 | // with the filtered previous one 60 | func (s *Selection) AddBackFiltered(selector string) *Selection { 61 | return s.AddSelection(s.prevSel.Filter(selector)) 62 | } 63 | 64 | // AddBackMatcher reduces the previous set of elements on the stack to those that match 65 | // the mateher, and adds them to the curernt set. 66 | // It returns a new Selection object containing the current Selection combined 67 | // with the filtered previous one 68 | func (s *Selection) AddBackMatcher(m Matcher) *Selection { 69 | return s.AddSelection(s.prevSel.FilterMatcher(m)) 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/iteration.go: -------------------------------------------------------------------------------- 1 | package goquery 2 | 3 | // Each iterates over a Selection object, executing a function for each 4 | // matched element. It returns the current Selection object. The function 5 | // f is called for each element in the selection with the index of the 6 | // element in that selection starting at 0, and a *Selection that contains 7 | // only that element. 8 | func (s *Selection) Each(f func(int, *Selection)) *Selection { 9 | for i, n := range s.Nodes { 10 | f(i, newSingleSelection(n, s.document)) 11 | } 12 | return s 13 | } 14 | 15 | // EachWithBreak iterates over a Selection object, executing a function for each 16 | // matched element. It is identical to Each except that it is possible to break 17 | // out of the loop by returning false in the callback function. It returns the 18 | // current Selection object. 19 | func (s *Selection) EachWithBreak(f func(int, *Selection) bool) *Selection { 20 | for i, n := range s.Nodes { 21 | if !f(i, newSingleSelection(n, s.document)) { 22 | return s 23 | } 24 | } 25 | return s 26 | } 27 | 28 | // Map passes each element in the current matched set through a function, 29 | // producing a slice of string holding the returned values. The function 30 | // f is called for each element in the selection with the index of the 31 | // element in that selection starting at 0, and a *Selection that contains 32 | // only that element. 33 | func (s *Selection) Map(f func(int, *Selection) string) (result []string) { 34 | for i, n := range s.Nodes { 35 | result = append(result, f(i, newSingleSelection(n, s.document))) 36 | } 37 | 38 | return result 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/PuerkitoBio/goquery/query.go: -------------------------------------------------------------------------------- 1 | package goquery 2 | 3 | import "golang.org/x/net/html" 4 | 5 | // Is checks the current matched set of elements against a selector and 6 | // returns true if at least one of these elements matches. 7 | func (s *Selection) Is(selector string) bool { 8 | return s.IsMatcher(compileMatcher(selector)) 9 | } 10 | 11 | // IsMatcher checks the current matched set of elements against a matcher and 12 | // returns true if at least one of these elements matches. 13 | func (s *Selection) IsMatcher(m Matcher) bool { 14 | if len(s.Nodes) > 0 { 15 | if len(s.Nodes) == 1 { 16 | return m.Match(s.Nodes[0]) 17 | } 18 | return len(m.Filter(s.Nodes)) > 0 19 | } 20 | 21 | return false 22 | } 23 | 24 | // IsFunction checks the current matched set of elements against a predicate and 25 | // returns true if at least one of these elements matches. 26 | func (s *Selection) IsFunction(f func(int, *Selection) bool) bool { 27 | return s.FilterFunction(f).Length() > 0 28 | } 29 | 30 | // IsSelection checks the current matched set of elements against a Selection object 31 | // and returns true if at least one of these elements matches. 32 | func (s *Selection) IsSelection(sel *Selection) bool { 33 | return s.FilterSelection(sel).Length() > 0 34 | } 35 | 36 | // IsNodes checks the current matched set of elements against the specified nodes 37 | // and returns true if at least one of these elements matches. 38 | func (s *Selection) IsNodes(nodes ...*html.Node) bool { 39 | return s.FilterNodes(nodes...).Length() > 0 40 | } 41 | 42 | // Contains returns true if the specified Node is within, 43 | // at any depth, one of the nodes in the Selection object. 44 | // It is NOT inclusive, to behave like jQuery's implementation, and 45 | // unlike Javascript's .contains, so if the contained 46 | // node is itself in the selection, it returns false. 47 | func (s *Selection) Contains(n *html.Node) bool { 48 | return sliceContains(s.Nodes, n) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/andybalholm/cascadia/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.3 5 | - 1.4 6 | 7 | install: 8 | - go get github.com/andybalholm/cascadia 9 | 10 | script: 11 | - go test -v 12 | 13 | notifications: 14 | email: false 15 | -------------------------------------------------------------------------------- /vendor/github.com/andybalholm/cascadia/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Andy Balholm. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /vendor/github.com/andybalholm/cascadia/README.md: -------------------------------------------------------------------------------- 1 | # cascadia 2 | 3 | [![](https://travis-ci.org/andybalholm/cascadia.svg)](https://travis-ci.org/andybalholm/cascadia) 4 | 5 | The Cascadia package implements CSS selectors for use with the parse trees produced by the html package. 6 | 7 | To test CSS selectors without writing Go code, check out [cascadia](https://github.com/suntong/cascadia) the command line tool, a thin wrapper around this package. 8 | 9 | [Refer to godoc here](https://godoc.org/github.com/andybalholm/cascadia). 10 | -------------------------------------------------------------------------------- /vendor/github.com/andybalholm/cascadia/specificity.go: -------------------------------------------------------------------------------- 1 | package cascadia 2 | 3 | // Specificity is the CSS specificity as defined in 4 | // https://www.w3.org/TR/selectors/#specificity-rules 5 | // with the convention Specificity = [A,B,C]. 6 | type Specificity [3]int 7 | 8 | // returns `true` if s < other (strictly), false otherwise 9 | func (s Specificity) Less(other Specificity) bool { 10 | for i := range s { 11 | if s[i] < other[i] { 12 | return true 13 | } 14 | if s[i] > other[i] { 15 | return false 16 | } 17 | } 18 | return false 19 | } 20 | 21 | func (s Specificity) Add(other Specificity) Specificity { 22 | for i, sp := range other { 23 | s[i] += sp 24 | } 25 | return s 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | *.out 26 | 27 | .DS_Store 28 | -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | arch: 3 | - AMD64 4 | - ppc64le 5 | go: 6 | - 1.9 7 | - tip 8 | -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Doug Clark 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/fastclock.go: -------------------------------------------------------------------------------- 1 | package regexp2 2 | 3 | import ( 4 | "sync" 5 | "sync/atomic" 6 | "time" 7 | ) 8 | 9 | // fasttime holds a time value (ticks since clock initialization) 10 | type fasttime int64 11 | 12 | // fastclock provides a fast clock implementation. 13 | // 14 | // A background goroutine periodically stores the current time 15 | // into an atomic variable. 16 | // 17 | // A deadline can be quickly checked for expiration by comparing 18 | // its value to the clock stored in the atomic variable. 19 | // 20 | // The goroutine automatically stops once clockEnd is reached. 21 | // (clockEnd covers the largest deadline seen so far + some 22 | // extra time). This ensures that if regexp2 with timeouts 23 | // stops being used we will stop background work. 24 | type fastclock struct { 25 | // current and clockEnd can be read via atomic loads. 26 | // Reads and writes of other fields require mu to be held. 27 | mu sync.Mutex 28 | 29 | start time.Time // Time corresponding to fasttime(0) 30 | current atomicTime // Current time (approximate) 31 | clockEnd atomicTime // When clock updater is supposed to stop (>= any existing deadline) 32 | running bool // Is a clock updater running? 33 | } 34 | 35 | var fast fastclock 36 | 37 | // reached returns true if current time is at or past t. 38 | func (t fasttime) reached() bool { 39 | return fast.current.read() >= t 40 | } 41 | 42 | // makeDeadline returns a time that is approximately time.Now().Add(d) 43 | func makeDeadline(d time.Duration) fasttime { 44 | // Increase the deadline since the clock we are reading may be 45 | // just about to tick forwards. 46 | end := fast.current.read() + durationToTicks(d+clockPeriod) 47 | 48 | // Start or extend clock if necessary. 49 | if end > fast.clockEnd.read() { 50 | extendClock(end) 51 | } 52 | return end 53 | } 54 | 55 | // extendClock ensures that clock is live and will run until at least end. 56 | func extendClock(end fasttime) { 57 | fast.mu.Lock() 58 | defer fast.mu.Unlock() 59 | 60 | if fast.start.IsZero() { 61 | fast.start = time.Now() 62 | } 63 | 64 | // Extend the running time to cover end as well as a bit of slop. 65 | if shutdown := end + durationToTicks(time.Second); shutdown > fast.clockEnd.read() { 66 | fast.clockEnd.write(shutdown) 67 | } 68 | 69 | // Start clock if necessary 70 | if !fast.running { 71 | fast.running = true 72 | go runClock() 73 | } 74 | } 75 | 76 | func durationToTicks(d time.Duration) fasttime { 77 | // Downscale nanoseconds to approximately a millisecond so that we can avoid 78 | // overflow even if the caller passes in math.MaxInt64. 79 | return fasttime(d) >> 20 80 | } 81 | 82 | // clockPeriod is the approximate interval between updates of approximateClock. 83 | const clockPeriod = 100 * time.Millisecond 84 | 85 | func runClock() { 86 | fast.mu.Lock() 87 | defer fast.mu.Unlock() 88 | 89 | for fast.current.read() <= fast.clockEnd.read() { 90 | // Unlock while sleeping. 91 | fast.mu.Unlock() 92 | time.Sleep(clockPeriod) 93 | fast.mu.Lock() 94 | 95 | newTime := durationToTicks(time.Since(fast.start)) 96 | fast.current.write(newTime) 97 | } 98 | fast.running = false 99 | } 100 | 101 | type atomicTime struct{ v int64 } // Should change to atomic.Int64 when we can use go 1.19 102 | 103 | func (t *atomicTime) read() fasttime { return fasttime(atomic.LoadInt64(&t.v)) } 104 | func (t *atomicTime) write(v fasttime) { atomic.StoreInt64(&t.v, int64(v)) } 105 | -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/syntax/escape.go: -------------------------------------------------------------------------------- 1 | package syntax 2 | 3 | import ( 4 | "bytes" 5 | "strconv" 6 | "strings" 7 | "unicode" 8 | ) 9 | 10 | func Escape(input string) string { 11 | b := &bytes.Buffer{} 12 | for _, r := range input { 13 | escape(b, r, false) 14 | } 15 | return b.String() 16 | } 17 | 18 | const meta = `\.+*?()|[]{}^$# ` 19 | 20 | func escape(b *bytes.Buffer, r rune, force bool) { 21 | if unicode.IsPrint(r) { 22 | if strings.IndexRune(meta, r) >= 0 || force { 23 | b.WriteRune('\\') 24 | } 25 | b.WriteRune(r) 26 | return 27 | } 28 | 29 | switch r { 30 | case '\a': 31 | b.WriteString(`\a`) 32 | case '\f': 33 | b.WriteString(`\f`) 34 | case '\n': 35 | b.WriteString(`\n`) 36 | case '\r': 37 | b.WriteString(`\r`) 38 | case '\t': 39 | b.WriteString(`\t`) 40 | case '\v': 41 | b.WriteString(`\v`) 42 | default: 43 | if r < 0x100 { 44 | b.WriteString(`\x`) 45 | s := strconv.FormatInt(int64(r), 16) 46 | if len(s) == 1 { 47 | b.WriteRune('0') 48 | } 49 | b.WriteString(s) 50 | break 51 | } 52 | b.WriteString(`\u`) 53 | b.WriteString(strconv.FormatInt(int64(r), 16)) 54 | } 55 | } 56 | 57 | func Unescape(input string) (string, error) { 58 | idx := strings.IndexRune(input, '\\') 59 | // no slashes means no unescape needed 60 | if idx == -1 { 61 | return input, nil 62 | } 63 | 64 | buf := bytes.NewBufferString(input[:idx]) 65 | // get the runes for the rest of the string -- we're going full parser scan on this 66 | 67 | p := parser{} 68 | p.setPattern(input[idx+1:]) 69 | for { 70 | if p.rightMost() { 71 | return "", p.getErr(ErrIllegalEndEscape) 72 | } 73 | r, err := p.scanCharEscape() 74 | if err != nil { 75 | return "", err 76 | } 77 | buf.WriteRune(r) 78 | // are we done? 79 | if p.rightMost() { 80 | return buf.String(), nil 81 | } 82 | 83 | r = p.moveRightGetChar() 84 | for r != '\\' { 85 | buf.WriteRune(r) 86 | if p.rightMost() { 87 | // we're done, no more slashes 88 | return buf.String(), nil 89 | } 90 | // keep scanning until we get another slash 91 | r = p.moveRightGetChar() 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/syntax/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package syntax 4 | 5 | // Fuzz is the input point for go-fuzz 6 | func Fuzz(data []byte) int { 7 | sdata := string(data) 8 | tree, err := Parse(sdata, RegexOptions(0)) 9 | if err != nil { 10 | return 0 11 | } 12 | 13 | // translate it to code 14 | _, err = Write(tree) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | return 1 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/syntax/replacerdata.go: -------------------------------------------------------------------------------- 1 | package syntax 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | ) 7 | 8 | type ReplacerData struct { 9 | Rep string 10 | Strings []string 11 | Rules []int 12 | } 13 | 14 | const ( 15 | replaceSpecials = 4 16 | replaceLeftPortion = -1 17 | replaceRightPortion = -2 18 | replaceLastGroup = -3 19 | replaceWholeString = -4 20 | ) 21 | 22 | //ErrReplacementError is a general error during parsing the replacement text 23 | var ErrReplacementError = errors.New("Replacement pattern error.") 24 | 25 | // NewReplacerData will populate a reusable replacer data struct based on the given replacement string 26 | // and the capture group data from a regexp 27 | func NewReplacerData(rep string, caps map[int]int, capsize int, capnames map[string]int, op RegexOptions) (*ReplacerData, error) { 28 | p := parser{ 29 | options: op, 30 | caps: caps, 31 | capsize: capsize, 32 | capnames: capnames, 33 | } 34 | p.setPattern(rep) 35 | concat, err := p.scanReplacement() 36 | if err != nil { 37 | return nil, err 38 | } 39 | 40 | if concat.t != ntConcatenate { 41 | panic(ErrReplacementError) 42 | } 43 | 44 | sb := &bytes.Buffer{} 45 | var ( 46 | strings []string 47 | rules []int 48 | ) 49 | 50 | for _, child := range concat.children { 51 | switch child.t { 52 | case ntMulti: 53 | child.writeStrToBuf(sb) 54 | 55 | case ntOne: 56 | sb.WriteRune(child.ch) 57 | 58 | case ntRef: 59 | if sb.Len() > 0 { 60 | rules = append(rules, len(strings)) 61 | strings = append(strings, sb.String()) 62 | sb.Reset() 63 | } 64 | slot := child.m 65 | 66 | if len(caps) > 0 && slot >= 0 { 67 | slot = caps[slot] 68 | } 69 | 70 | rules = append(rules, -replaceSpecials-1-slot) 71 | 72 | default: 73 | panic(ErrReplacementError) 74 | } 75 | } 76 | 77 | if sb.Len() > 0 { 78 | rules = append(rules, len(strings)) 79 | strings = append(strings, sb.String()) 80 | } 81 | 82 | return &ReplacerData{ 83 | Rep: rep, 84 | Strings: strings, 85 | Rules: rules, 86 | }, nil 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | testdata/test262 4 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/.tc39_test262_checkout.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this is just the commit it was last tested with 3 | sha=926b0960d737b9f1dfd0ec0c1dfd95d836016d33 4 | 5 | mkdir -p testdata/test262 6 | cd testdata/test262 7 | git init 8 | git remote add origin https://github.com/tc39/test262.git 9 | git fetch origin --depth=1 "${sha}" 10 | git reset --hard "${sha}" 11 | cd - 12 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Dmitry Panov 2 | 3 | Copyright (c) 2012 Robert Krimen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 6 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 13 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 15 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/builtin_boolean.go: -------------------------------------------------------------------------------- 1 | package goja 2 | 3 | func (r *Runtime) booleanproto_toString(call FunctionCall) Value { 4 | var b bool 5 | switch o := call.This.(type) { 6 | case valueBool: 7 | b = bool(o) 8 | goto success 9 | case *Object: 10 | if p, ok := o.self.(*primitiveValueObject); ok { 11 | if b1, ok := p.pValue.(valueBool); ok { 12 | b = bool(b1) 13 | goto success 14 | } 15 | } 16 | } 17 | r.typeErrorResult(true, "Method Boolean.prototype.toString is called on incompatible receiver") 18 | 19 | success: 20 | if b { 21 | return stringTrue 22 | } 23 | return stringFalse 24 | } 25 | 26 | func (r *Runtime) booleanproto_valueOf(call FunctionCall) Value { 27 | switch o := call.This.(type) { 28 | case valueBool: 29 | return o 30 | case *Object: 31 | if p, ok := o.self.(*primitiveValueObject); ok { 32 | if b, ok := p.pValue.(valueBool); ok { 33 | return b 34 | } 35 | } 36 | } 37 | 38 | r.typeErrorResult(true, "Method Boolean.prototype.valueOf is called on incompatible receiver") 39 | return nil 40 | } 41 | 42 | func (r *Runtime) initBoolean() { 43 | r.global.BooleanPrototype = r.newPrimitiveObject(valueFalse, r.global.ObjectPrototype, classBoolean) 44 | o := r.global.BooleanPrototype.self 45 | o._putProp("toString", r.newNativeFunc(r.booleanproto_toString, nil, "toString", nil, 0), true, false, true) 46 | o._putProp("valueOf", r.newNativeFunc(r.booleanproto_valueOf, nil, "valueOf", nil, 0), true, false, true) 47 | 48 | r.global.Boolean = r.newNativeFunc(r.builtin_Boolean, r.builtin_newBoolean, "Boolean", r.global.BooleanPrototype, 1) 49 | r.addToGlobal("Boolean", r.global.Boolean) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/extract_failed_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sed -En 's/^.*FAIL: TestTC39\/tc39\/(test\/.*.js).*$/"\1": true,/p' 4 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/file/README.markdown: -------------------------------------------------------------------------------- 1 | # file 2 | -- 3 | import "github.com/dop251/goja/file" 4 | 5 | Package file encapsulates the file abstractions used by the ast & parser. 6 | 7 | ## Usage 8 | 9 | #### type File 10 | 11 | ```go 12 | type File struct { 13 | } 14 | ``` 15 | 16 | 17 | #### func NewFile 18 | 19 | ```go 20 | func NewFile(filename, src string, base int) *File 21 | ``` 22 | 23 | #### func (*File) Base 24 | 25 | ```go 26 | func (fl *File) Base() int 27 | ``` 28 | 29 | #### func (*File) Name 30 | 31 | ```go 32 | func (fl *File) Name() string 33 | ``` 34 | 35 | #### func (*File) Source 36 | 37 | ```go 38 | func (fl *File) Source() string 39 | ``` 40 | 41 | #### type FileSet 42 | 43 | ```go 44 | type FileSet struct { 45 | } 46 | ``` 47 | 48 | A FileSet represents a set of source files. 49 | 50 | #### func (*FileSet) AddFile 51 | 52 | ```go 53 | func (self *FileSet) AddFile(filename, src string) int 54 | ``` 55 | AddFile adds a new file with the given filename and src. 56 | 57 | This an internal method, but exported for cross-package use. 58 | 59 | #### func (*FileSet) File 60 | 61 | ```go 62 | func (self *FileSet) File(idx Idx) *File 63 | ``` 64 | 65 | #### func (*FileSet) Position 66 | 67 | ```go 68 | func (self *FileSet) Position(idx Idx) *Position 69 | ``` 70 | Position converts an Idx in the FileSet into a Position. 71 | 72 | #### type Idx 73 | 74 | ```go 75 | type Idx int 76 | ``` 77 | 78 | Idx is a compact encoding of a source position within a file set. It can be 79 | converted into a Position for a more convenient, but much larger, 80 | representation. 81 | 82 | #### type Position 83 | 84 | ```go 85 | type Position struct { 86 | Filename string // The filename where the error occurred, if any 87 | Offset int // The src offset 88 | Line int // The line number, starting at 1 89 | Column int // The column number, starting at 1 (The character count) 90 | 91 | } 92 | ``` 93 | 94 | Position describes an arbitrary source position including the filename, line, 95 | and column location. 96 | 97 | #### func (*Position) String 98 | 99 | ```go 100 | func (self *Position) String() string 101 | ``` 102 | String returns a string in one of several forms: 103 | 104 | file:line:column A valid position with filename 105 | line:column A valid position without filename 106 | file An invalid position with filename 107 | - An invalid position without filename 108 | 109 | -- 110 | **godocdown** http://github.com/robertkrimen/godocdown 111 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/ftoa/LICENSE_LUCENE: -------------------------------------------------------------------------------- 1 | Copyright (C) 1998, 1999 by Lucent Technologies 2 | All Rights Reserved 3 | 4 | Permission to use, copy, modify, and distribute this software and 5 | its documentation for any purpose and without fee is hereby 6 | granted, provided that the above copyright notice appear in all 7 | copies and that both that the copyright notice and this 8 | permission notice and warranty disclaimer appear in supporting 9 | documentation, and that the name of Lucent or any of its entities 10 | not be used in advertising or publicity pertaining to 11 | distribution of the software without specific, written prior 12 | permission. 13 | 14 | LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 16 | IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 17 | SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 19 | IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 20 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 21 | THIS SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/ftoa/common.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package ftoa provides ECMAScript-compliant floating point number conversion to string. 3 | 4 | It contains code ported from Rhino (https://github.com/mozilla/rhino/blob/master/src/org/mozilla/javascript/DToA.java) 5 | as well as from the original code by David M. Gay. 6 | 7 | See LICENSE_LUCENE for the original copyright message and disclaimer. 8 | */ 9 | package ftoa 10 | 11 | import ( 12 | "math" 13 | ) 14 | 15 | const ( 16 | frac_mask = 0xfffff 17 | exp_shift = 20 18 | exp_msk1 = 0x100000 19 | 20 | exp_shiftL = 52 21 | exp_mask_shifted = 0x7ff 22 | frac_maskL = 0xfffffffffffff 23 | exp_msk1L = 0x10000000000000 24 | exp_shift1 = 20 25 | exp_mask = 0x7ff00000 26 | bias = 1023 27 | p = 53 28 | bndry_mask = 0xfffff 29 | log2P = 1 30 | ) 31 | 32 | func lo0bits(x uint32) (k int) { 33 | 34 | if (x & 7) != 0 { 35 | if (x & 1) != 0 { 36 | return 0 37 | } 38 | if (x & 2) != 0 { 39 | return 1 40 | } 41 | return 2 42 | } 43 | if (x & 0xffff) == 0 { 44 | k = 16 45 | x >>= 16 46 | } 47 | if (x & 0xff) == 0 { 48 | k += 8 49 | x >>= 8 50 | } 51 | if (x & 0xf) == 0 { 52 | k += 4 53 | x >>= 4 54 | } 55 | if (x & 0x3) == 0 { 56 | k += 2 57 | x >>= 2 58 | } 59 | if (x & 1) == 0 { 60 | k++ 61 | x >>= 1 62 | if (x & 1) == 0 { 63 | return 32 64 | } 65 | } 66 | return 67 | } 68 | 69 | func hi0bits(x uint32) (k int) { 70 | 71 | if (x & 0xffff0000) == 0 { 72 | k = 16 73 | x <<= 16 74 | } 75 | if (x & 0xff000000) == 0 { 76 | k += 8 77 | x <<= 8 78 | } 79 | if (x & 0xf0000000) == 0 { 80 | k += 4 81 | x <<= 4 82 | } 83 | if (x & 0xc0000000) == 0 { 84 | k += 2 85 | x <<= 2 86 | } 87 | if (x & 0x80000000) == 0 { 88 | k++ 89 | if (x & 0x40000000) == 0 { 90 | return 32 91 | } 92 | } 93 | return 94 | } 95 | 96 | func stuffBits(bits []byte, offset int, val uint32) { 97 | bits[offset] = byte(val >> 24) 98 | bits[offset+1] = byte(val >> 16) 99 | bits[offset+2] = byte(val >> 8) 100 | bits[offset+3] = byte(val) 101 | } 102 | 103 | func d2b(d float64, b []byte) (e, bits int, dblBits []byte) { 104 | dBits := math.Float64bits(d) 105 | d0 := uint32(dBits >> 32) 106 | d1 := uint32(dBits) 107 | 108 | z := d0 & frac_mask 109 | d0 &= 0x7fffffff /* clear sign bit, which we ignore */ 110 | 111 | var de, k, i int 112 | if de = int(d0 >> exp_shift); de != 0 { 113 | z |= exp_msk1 114 | } 115 | 116 | y := d1 117 | if y != 0 { 118 | dblBits = b[:8] 119 | k = lo0bits(y) 120 | y >>= k 121 | if k != 0 { 122 | stuffBits(dblBits, 4, y|z<<(32-k)) 123 | z >>= k 124 | } else { 125 | stuffBits(dblBits, 4, y) 126 | } 127 | stuffBits(dblBits, 0, z) 128 | if z != 0 { 129 | i = 2 130 | } else { 131 | i = 1 132 | } 133 | } else { 134 | dblBits = b[:4] 135 | k = lo0bits(z) 136 | z >>= k 137 | stuffBits(dblBits, 0, z) 138 | k += 32 139 | i = 1 140 | } 141 | 142 | if de != 0 { 143 | e = de - bias - (p - 1) + k 144 | bits = p - k 145 | } else { 146 | e = de - bias - (p - 1) + 1 + k 147 | bits = 32*i - hi0bits(z) 148 | } 149 | return 150 | } 151 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/ftoa/internal/fast/LICENSE_V8: -------------------------------------------------------------------------------- 1 | Copyright 2014, the V8 project authors. All rights reserved. 2 | Redistribution and use in source and binary forms, with or without 3 | modification, are permitted provided that the following conditions are 4 | met: 5 | 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above 9 | copyright notice, this list of conditions and the following 10 | disclaimer in the documentation and/or other materials provided 11 | with the distribution. 12 | * Neither the name of Google Inc. nor the names of its 13 | contributors may be used to endorse or promote products derived 14 | from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/ftoa/internal/fast/common.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package fast contains code ported from V8 (https://github.com/v8/v8/blob/master/src/numbers/fast-dtoa.cc) 3 | 4 | See LICENSE_V8 for the original copyright message and disclaimer. 5 | */ 6 | package fast 7 | 8 | import "errors" 9 | 10 | var ( 11 | dcheckFailure = errors.New("DCHECK assertion failed") 12 | ) 13 | 14 | func _DCHECK(f bool) { 15 | if !f { 16 | panic(dcheckFailure) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/ipow.go: -------------------------------------------------------------------------------- 1 | package goja 2 | 3 | // ported from https://gist.github.com/orlp/3551590 4 | 5 | var highest_bit_set = [256]byte{ 6 | 0, 1, 2, 2, 3, 3, 3, 3, 7 | 4, 4, 4, 4, 4, 4, 4, 4, 8 | 5, 5, 5, 5, 5, 5, 5, 5, 9 | 5, 5, 5, 5, 5, 5, 5, 5, 10 | 6, 6, 6, 6, 6, 6, 6, 6, 11 | 6, 6, 6, 6, 6, 6, 6, 6, 12 | 6, 6, 6, 6, 6, 6, 6, 6, 13 | 6, 6, 6, 6, 6, 6, 6, 255, // anything past 63 is a guaranteed overflow with base > 1 14 | 255, 255, 255, 255, 255, 255, 255, 255, 15 | 255, 255, 255, 255, 255, 255, 255, 255, 16 | 255, 255, 255, 255, 255, 255, 255, 255, 17 | 255, 255, 255, 255, 255, 255, 255, 255, 18 | 255, 255, 255, 255, 255, 255, 255, 255, 19 | 255, 255, 255, 255, 255, 255, 255, 255, 20 | 255, 255, 255, 255, 255, 255, 255, 255, 21 | 255, 255, 255, 255, 255, 255, 255, 255, 22 | 255, 255, 255, 255, 255, 255, 255, 255, 23 | 255, 255, 255, 255, 255, 255, 255, 255, 24 | 255, 255, 255, 255, 255, 255, 255, 255, 25 | 255, 255, 255, 255, 255, 255, 255, 255, 26 | 255, 255, 255, 255, 255, 255, 255, 255, 27 | 255, 255, 255, 255, 255, 255, 255, 255, 28 | 255, 255, 255, 255, 255, 255, 255, 255, 29 | 255, 255, 255, 255, 255, 255, 255, 255, 30 | 255, 255, 255, 255, 255, 255, 255, 255, 31 | 255, 255, 255, 255, 255, 255, 255, 255, 32 | 255, 255, 255, 255, 255, 255, 255, 255, 33 | 255, 255, 255, 255, 255, 255, 255, 255, 34 | 255, 255, 255, 255, 255, 255, 255, 255, 35 | 255, 255, 255, 255, 255, 255, 255, 255, 36 | 255, 255, 255, 255, 255, 255, 255, 255, 37 | 255, 255, 255, 255, 255, 255, 255, 255, 38 | } 39 | 40 | func ipow(base, exp int64) (result int64) { 41 | result = 1 42 | 43 | switch highest_bit_set[byte(exp)] { 44 | case 255: // we use 255 as an overflow marker and return 0 on overflow/underflow 45 | if base == 1 { 46 | return 1 47 | } 48 | 49 | if base == -1 { 50 | return 1 - 2*(exp&1) 51 | } 52 | 53 | return 0 54 | case 6: 55 | if exp&1 != 0 { 56 | result *= base 57 | } 58 | exp >>= 1 59 | base *= base 60 | fallthrough 61 | case 5: 62 | if exp&1 != 0 { 63 | result *= base 64 | } 65 | exp >>= 1 66 | base *= base 67 | fallthrough 68 | case 4: 69 | if exp&1 != 0 { 70 | result *= base 71 | } 72 | exp >>= 1 73 | base *= base 74 | fallthrough 75 | case 3: 76 | if exp&1 != 0 { 77 | result *= base 78 | } 79 | exp >>= 1 80 | base *= base 81 | fallthrough 82 | case 2: 83 | if exp&1 != 0 { 84 | result *= base 85 | } 86 | exp >>= 1 87 | base *= base 88 | fallthrough 89 | case 1: 90 | if exp&1 != 0 { 91 | result *= base 92 | } 93 | fallthrough 94 | default: 95 | return result 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/object_goslice_reflect.go: -------------------------------------------------------------------------------- 1 | package goja 2 | 3 | import ( 4 | "math" 5 | "math/bits" 6 | "reflect" 7 | 8 | "github.com/dop251/goja/unistring" 9 | ) 10 | 11 | type objectGoSliceReflect struct { 12 | objectGoArrayReflect 13 | } 14 | 15 | func (o *objectGoSliceReflect) init() { 16 | o.objectGoArrayReflect._init() 17 | o.lengthProp.writable = true 18 | o.putIdx = o._putIdx 19 | } 20 | 21 | func (o *objectGoSliceReflect) _putIdx(idx int, v Value, throw bool) bool { 22 | if idx >= o.fieldsValue.Len() { 23 | o.grow(idx + 1) 24 | } 25 | return o.objectGoArrayReflect._putIdx(idx, v, throw) 26 | } 27 | 28 | func (o *objectGoSliceReflect) grow(size int) { 29 | oldcap := o.fieldsValue.Cap() 30 | if oldcap < size { 31 | n := reflect.MakeSlice(o.fieldsValue.Type(), size, growCap(size, o.fieldsValue.Len(), oldcap)) 32 | reflect.Copy(n, o.fieldsValue) 33 | o.fieldsValue.Set(n) 34 | l := len(o.valueCache) 35 | if l > size { 36 | l = size 37 | } 38 | for i, w := range o.valueCache[:l] { 39 | if w != nil { 40 | w.setReflectValue(o.fieldsValue.Index(i)) 41 | } 42 | } 43 | } else { 44 | tail := o.fieldsValue.Slice(o.fieldsValue.Len(), size) 45 | zero := reflect.Zero(o.fieldsValue.Type().Elem()) 46 | for i := 0; i < tail.Len(); i++ { 47 | tail.Index(i).Set(zero) 48 | } 49 | o.fieldsValue.SetLen(size) 50 | } 51 | o.updateLen() 52 | } 53 | 54 | func (o *objectGoSliceReflect) shrink(size int) { 55 | o.valueCache.shrink(size) 56 | tail := o.fieldsValue.Slice(size, o.fieldsValue.Len()) 57 | zero := reflect.Zero(o.fieldsValue.Type().Elem()) 58 | for i := 0; i < tail.Len(); i++ { 59 | tail.Index(i).Set(zero) 60 | } 61 | o.fieldsValue.SetLen(size) 62 | o.updateLen() 63 | } 64 | 65 | func (o *objectGoSliceReflect) putLength(v uint32, throw bool) bool { 66 | if bits.UintSize == 32 && v > math.MaxInt32 { 67 | panic(rangeError("Integer value overflows 32-bit int")) 68 | } 69 | newLen := int(v) 70 | curLen := o.fieldsValue.Len() 71 | if newLen > curLen { 72 | o.grow(newLen) 73 | } else if newLen < curLen { 74 | o.shrink(newLen) 75 | } 76 | return true 77 | } 78 | 79 | func (o *objectGoSliceReflect) setOwnStr(name unistring.String, val Value, throw bool) bool { 80 | if name == "length" { 81 | return o.putLength(o.val.runtime.toLengthUint32(val), throw) 82 | } 83 | return o.objectGoArrayReflect.setOwnStr(name, val, throw) 84 | } 85 | 86 | func (o *objectGoSliceReflect) defineOwnPropertyStr(name unistring.String, descr PropertyDescriptor, throw bool) bool { 87 | if name == "length" { 88 | return o.val.runtime.defineArrayLength(&o.lengthProp, descr, o.putLength, throw) 89 | } 90 | return o.objectGoArrayReflect.defineOwnPropertyStr(name, descr, throw) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/parser/scope.go: -------------------------------------------------------------------------------- 1 | package parser 2 | 3 | import ( 4 | "github.com/dop251/goja/ast" 5 | "github.com/dop251/goja/unistring" 6 | ) 7 | 8 | type _scope struct { 9 | outer *_scope 10 | allowIn bool 11 | allowLet bool 12 | inIteration bool 13 | inSwitch bool 14 | inFuncParams bool 15 | inFunction bool 16 | inAsync bool 17 | allowAwait bool 18 | allowYield bool 19 | declarationList []*ast.VariableDeclaration 20 | 21 | labels []unistring.String 22 | } 23 | 24 | func (self *_parser) openScope() { 25 | self.scope = &_scope{ 26 | outer: self.scope, 27 | allowIn: true, 28 | } 29 | } 30 | 31 | func (self *_parser) closeScope() { 32 | self.scope = self.scope.outer 33 | } 34 | 35 | func (self *_scope) declare(declaration *ast.VariableDeclaration) { 36 | self.declarationList = append(self.declarationList, declaration) 37 | } 38 | 39 | func (self *_scope) hasLabel(name unistring.String) bool { 40 | for _, label := range self.labels { 41 | if label == name { 42 | return true 43 | } 44 | } 45 | if self.outer != nil && !self.inFunction { 46 | // Crossing a function boundary to look for a label is verboten 47 | return self.outer.hasLabel(name) 48 | } 49 | return false 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/staticcheck.conf: -------------------------------------------------------------------------------- 1 | checks = ["all", "-ST1000", "-ST1003", "-ST1005", "-ST1006", "-ST1012", "-ST1021", "-ST1020", "-ST1008"] 2 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/token/Makefile: -------------------------------------------------------------------------------- 1 | token_const.go: tokenfmt 2 | ./$^ | gofmt > $@ 3 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/token/token.go: -------------------------------------------------------------------------------- 1 | // Package token defines constants representing the lexical tokens of JavaScript (ECMA5). 2 | package token 3 | 4 | import ( 5 | "strconv" 6 | ) 7 | 8 | // Token is the set of lexical tokens in JavaScript (ECMA5). 9 | type Token int 10 | 11 | // String returns the string corresponding to the token. 12 | // For operators, delimiters, and keywords the string is the actual 13 | // token string (e.g., for the token PLUS, the String() is 14 | // "+"). For all other tokens the string corresponds to the token 15 | // name (e.g. for the token IDENTIFIER, the string is "IDENTIFIER"). 16 | func (tkn Token) String() string { 17 | if tkn == 0 { 18 | return "UNKNOWN" 19 | } 20 | if tkn < Token(len(token2string)) { 21 | return token2string[tkn] 22 | } 23 | return "token(" + strconv.Itoa(int(tkn)) + ")" 24 | } 25 | 26 | //lint:ignore U1000 This is not used for anything 27 | func (tkn Token) precedence(in bool) int { 28 | 29 | switch tkn { 30 | case LOGICAL_OR: 31 | return 1 32 | 33 | case LOGICAL_AND: 34 | return 2 35 | 36 | case OR, OR_ASSIGN: 37 | return 3 38 | 39 | case EXCLUSIVE_OR: 40 | return 4 41 | 42 | case AND, AND_ASSIGN: 43 | return 5 44 | 45 | case EQUAL, 46 | NOT_EQUAL, 47 | STRICT_EQUAL, 48 | STRICT_NOT_EQUAL: 49 | return 6 50 | 51 | case LESS, GREATER, LESS_OR_EQUAL, GREATER_OR_EQUAL, INSTANCEOF: 52 | return 7 53 | 54 | case IN: 55 | if in { 56 | return 7 57 | } 58 | return 0 59 | 60 | case SHIFT_LEFT, SHIFT_RIGHT, UNSIGNED_SHIFT_RIGHT: 61 | fallthrough 62 | case SHIFT_LEFT_ASSIGN, SHIFT_RIGHT_ASSIGN, UNSIGNED_SHIFT_RIGHT_ASSIGN: 63 | return 8 64 | 65 | case PLUS, MINUS, ADD_ASSIGN, SUBTRACT_ASSIGN: 66 | return 9 67 | 68 | case MULTIPLY, SLASH, REMAINDER, MULTIPLY_ASSIGN, QUOTIENT_ASSIGN, REMAINDER_ASSIGN: 69 | return 11 70 | } 71 | return 0 72 | } 73 | 74 | type _keyword struct { 75 | token Token 76 | futureKeyword bool 77 | strict bool 78 | } 79 | 80 | // IsKeyword returns the keyword token if literal is a keyword, a KEYWORD token 81 | // if the literal is a future keyword (const, let, class, super, ...), or 0 if the literal is not a keyword. 82 | // 83 | // If the literal is a keyword, IsKeyword returns a second value indicating if the literal 84 | // is considered a future keyword in strict-mode only. 85 | // 86 | // 7.6.1.2 Future Reserved Words: 87 | // 88 | // const 89 | // class 90 | // enum 91 | // export 92 | // extends 93 | // import 94 | // super 95 | // 96 | // 7.6.1.2 Future Reserved Words (strict): 97 | // 98 | // implements 99 | // interface 100 | // let 101 | // package 102 | // private 103 | // protected 104 | // public 105 | // static 106 | func IsKeyword(literal string) (Token, bool) { 107 | if keyword, exists := keywordTable[literal]; exists { 108 | if keyword.futureKeyword { 109 | return KEYWORD, keyword.strict 110 | } 111 | return keyword.token, false 112 | } 113 | return 0, false 114 | } 115 | 116 | func IsId(tkn Token) bool { 117 | return tkn >= IDENTIFIER 118 | } 119 | 120 | func IsUnreservedWord(tkn Token) bool { 121 | return tkn > ESCAPED_RESERVED_WORD 122 | } 123 | -------------------------------------------------------------------------------- /vendor/github.com/dop251/goja/unistring/string.go: -------------------------------------------------------------------------------- 1 | // Package unistring contains an implementation of a hybrid ASCII/UTF-16 string. 2 | // For ASCII strings the underlying representation is equivalent to a normal Go string. 3 | // For unicode strings the underlying representation is UTF-16 as []uint16 with 0th element set to 0xFEFF. 4 | // unicode.String allows representing malformed UTF-16 values (e.g. stand-alone parts of surrogate pairs) 5 | // which cannot be represented in UTF-8. 6 | // At the same time it is possible to use unicode.String as property keys just as efficiently as simple strings, 7 | // (the leading 0xFEFF ensures there is no clash with ASCII string), and it is possible to convert it 8 | // to valueString without extra allocations. 9 | package unistring 10 | 11 | import ( 12 | "reflect" 13 | "unicode/utf16" 14 | "unicode/utf8" 15 | "unsafe" 16 | ) 17 | 18 | const ( 19 | BOM = 0xFEFF 20 | ) 21 | 22 | type String string 23 | 24 | // Scan checks if the string contains any unicode characters. If it does, converts to an array suitable for creating 25 | // a String using FromUtf16, otherwise returns nil. 26 | func Scan(s string) []uint16 { 27 | utf16Size := 0 28 | for ; utf16Size < len(s); utf16Size++ { 29 | if s[utf16Size] >= utf8.RuneSelf { 30 | goto unicode 31 | } 32 | } 33 | return nil 34 | unicode: 35 | for _, chr := range s[utf16Size:] { 36 | utf16Size++ 37 | if chr > 0xFFFF { 38 | utf16Size++ 39 | } 40 | } 41 | 42 | buf := make([]uint16, utf16Size+1) 43 | buf[0] = BOM 44 | c := 1 45 | for _, chr := range s { 46 | if chr <= 0xFFFF { 47 | buf[c] = uint16(chr) 48 | } else { 49 | first, second := utf16.EncodeRune(chr) 50 | buf[c] = uint16(first) 51 | c++ 52 | buf[c] = uint16(second) 53 | } 54 | c++ 55 | } 56 | 57 | return buf 58 | } 59 | 60 | func NewFromString(s string) String { 61 | if buf := Scan(s); buf != nil { 62 | return FromUtf16(buf) 63 | } 64 | return String(s) 65 | } 66 | 67 | func NewFromRunes(s []rune) String { 68 | ascii := true 69 | size := 0 70 | for _, c := range s { 71 | if c >= utf8.RuneSelf { 72 | ascii = false 73 | if c > 0xFFFF { 74 | size++ 75 | } 76 | } 77 | size++ 78 | } 79 | if ascii { 80 | return String(s) 81 | } 82 | b := make([]uint16, size+1) 83 | b[0] = BOM 84 | i := 1 85 | for _, c := range s { 86 | if c <= 0xFFFF { 87 | b[i] = uint16(c) 88 | } else { 89 | first, second := utf16.EncodeRune(c) 90 | b[i] = uint16(first) 91 | i++ 92 | b[i] = uint16(second) 93 | } 94 | i++ 95 | } 96 | return FromUtf16(b) 97 | } 98 | 99 | func FromUtf16(b []uint16) String { 100 | var str string 101 | hdr := (*reflect.StringHeader)(unsafe.Pointer(&str)) 102 | hdr.Data = uintptr(unsafe.Pointer(&b[0])) 103 | hdr.Len = len(b) * 2 104 | 105 | return String(str) 106 | } 107 | 108 | func (s String) String() string { 109 | if b := s.AsUtf16(); b != nil { 110 | return string(utf16.Decode(b[1:])) 111 | } 112 | 113 | return string(s) 114 | } 115 | 116 | func (s String) AsUtf16() []uint16 { 117 | if len(s) < 4 || len(s)&1 != 0 { 118 | return nil 119 | } 120 | 121 | var a []uint16 122 | raw := string(s) 123 | 124 | sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&a)) 125 | sliceHeader.Data = (*reflect.StringHeader)(unsafe.Pointer(&raw)).Data 126 | 127 | l := len(raw) / 2 128 | 129 | sliceHeader.Len = l 130 | sliceHeader.Cap = l 131 | 132 | if a[0] == BOM { 133 | return a 134 | } 135 | 136 | return nil 137 | } 138 | -------------------------------------------------------------------------------- /vendor/github.com/go-sourcemap/sourcemap/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | 4 | go: 5 | - 1.12.x 6 | - 1.13.x 7 | - 1.14.x 8 | - tip 9 | 10 | matrix: 11 | allow_failures: 12 | - go: tip 13 | -------------------------------------------------------------------------------- /vendor/github.com/go-sourcemap/sourcemap/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 The github.com/go-sourcemap/sourcemap Contributors. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /vendor/github.com/go-sourcemap/sourcemap/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | go test ./... 3 | go test ./... -short -race 4 | go vet 5 | -------------------------------------------------------------------------------- /vendor/github.com/go-sourcemap/sourcemap/README.md: -------------------------------------------------------------------------------- 1 | # Source maps consumer for Golang 2 | 3 | [![Build Status](https://travis-ci.org/go-sourcemap/sourcemap.svg)](https://travis-ci.org/go-sourcemap/sourcemap) 4 | 5 | API docs: https://godoc.org/github.com/go-sourcemap/sourcemap. 6 | Examples: https://godoc.org/github.com/go-sourcemap/sourcemap#pkg-examples. 7 | Spec: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit. 8 | 9 | ## Installation 10 | 11 | Install: 12 | 13 | ```shell 14 | go get -u github.com/go-sourcemap/sourcemap 15 | ``` 16 | 17 | ## Quickstart 18 | 19 | ```go 20 | func ExampleParse() { 21 | mapURL := "http://code.jquery.com/jquery-2.0.3.min.map" 22 | resp, err := http.Get(mapURL) 23 | if err != nil { 24 | panic(err) 25 | } 26 | defer resp.Body.Close() 27 | 28 | b, err := ioutil.ReadAll(resp.Body) 29 | if err != nil { 30 | panic(err) 31 | } 32 | 33 | smap, err := sourcemap.Parse(mapURL, b) 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | line, column := 5, 6789 39 | file, fn, line, col, ok := smap.Source(line, column) 40 | fmt.Println(file, fn, line, col, ok) 41 | // Output: http://code.jquery.com/jquery-2.0.3.js apply 4360 27 true 42 | } 43 | ``` 44 | -------------------------------------------------------------------------------- /vendor/github.com/go-sourcemap/sourcemap/internal/base64vlq/base64vlq.go: -------------------------------------------------------------------------------- 1 | package base64vlq 2 | 3 | import "io" 4 | 5 | const encodeStd = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" 6 | 7 | const ( 8 | vlqBaseShift = 5 9 | vlqBase = 1 << vlqBaseShift 10 | vlqBaseMask = vlqBase - 1 11 | vlqSignBit = 1 12 | vlqContinuationBit = vlqBase 13 | ) 14 | 15 | var decodeMap [256]byte 16 | 17 | func init() { 18 | for i := 0; i < len(encodeStd); i++ { 19 | decodeMap[encodeStd[i]] = byte(i) 20 | } 21 | } 22 | 23 | func toVLQSigned(n int32) int32 { 24 | if n < 0 { 25 | return -n<<1 + 1 26 | } 27 | return n << 1 28 | } 29 | 30 | func fromVLQSigned(n int32) int32 { 31 | isNeg := n&vlqSignBit != 0 32 | n >>= 1 33 | if isNeg { 34 | return -n 35 | } 36 | return n 37 | } 38 | 39 | type Encoder struct { 40 | w io.ByteWriter 41 | } 42 | 43 | func NewEncoder(w io.ByteWriter) *Encoder { 44 | return &Encoder{ 45 | w: w, 46 | } 47 | } 48 | 49 | func (enc Encoder) Encode(n int32) error { 50 | n = toVLQSigned(n) 51 | for digit := int32(vlqContinuationBit); digit&vlqContinuationBit != 0; { 52 | digit = n & vlqBaseMask 53 | n >>= vlqBaseShift 54 | if n > 0 { 55 | digit |= vlqContinuationBit 56 | } 57 | 58 | err := enc.w.WriteByte(encodeStd[digit]) 59 | if err != nil { 60 | return err 61 | } 62 | } 63 | return nil 64 | } 65 | 66 | type Decoder struct { 67 | r io.ByteReader 68 | } 69 | 70 | func NewDecoder(r io.ByteReader) Decoder { 71 | return Decoder{ 72 | r: r, 73 | } 74 | } 75 | 76 | func (dec Decoder) Decode() (n int32, err error) { 77 | shift := uint(0) 78 | for continuation := true; continuation; { 79 | c, err := dec.r.ReadByte() 80 | if err != nil { 81 | return 0, err 82 | } 83 | 84 | c = decodeMap[c] 85 | continuation = c&vlqContinuationBit != 0 86 | n += int32(c&vlqBaseMask) << shift 87 | shift += vlqBaseShift 88 | } 89 | return fromVLQSigned(n), nil 90 | } 91 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/flip/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | dist: xenial 4 | 5 | go: 6 | - "1.11.5" 7 | - "1.10.8" 8 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/flip/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2019 Peter Hellberg https://c7.se 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included 11 | in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 18 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 19 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/flip/README.md: -------------------------------------------------------------------------------- 1 | flip (╯°□°)╯︵ʇxǝʇ 2 | =================== 3 | 4 | Go library used to flip text. 5 | 6 | [![Build Status](https://travis-ci.org/peterhellberg/flip.svg?branch=master)](https://travis-ci.org/peterhellberg/flip) 7 | [![Go Report Card](https://goreportcard.com/badge/github.com/peterhellberg/flip)](https://goreportcard.com/report/github.com/peterhellberg/flip) 8 | [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/peterhellberg/flip) 9 | [![License MIT](https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/peterhellberg/flip#license-mit) 10 | 11 | ## Command line tool 12 | 13 | ### Installation 14 | 15 | ```bash 16 | go get -u github.com/peterhellberg/flip/cmd/flip 17 | ``` 18 | 19 | ### Usage 20 | 21 | You can flip a string on its own or decorate it with a named emoticon 22 | 23 | ```bash 24 | flip foo #=> ooɟ 25 | flip table bar #=> (╯°□°)╯︵ɹɐq 26 | flip gopher baz #=> ʕ╯◔ϖ◔ʔ╯︵zɐq 27 | ``` 28 | 29 | You can also specify a custom emoticon 30 | 31 | ```bash 32 | flip '(#`д´)ノ︵' baz #=> (#`д´)ノ︵zɐq 33 | ``` 34 | 35 | ## Examples 36 | 37 | ### table.go 38 | 39 | ```go 40 | package main 41 | 42 | import ( 43 | "fmt" 44 | "os" 45 | "strings" 46 | 47 | "github.com/peterhellberg/flip" 48 | ) 49 | 50 | func main() { 51 | fmt.Println(flip.Table(strings.Join(os.Args[1:], " "))) 52 | } 53 | ``` 54 | 55 | ## License (MIT) 56 | 57 | *Copyright (C) 2014-2019 [Peter Hellberg](https://c7.se)* 58 | 59 | > Permission is hereby granted, free of charge, to any person obtaining 60 | > a copy of this software and associated documentation files (the "Software"), 61 | > to deal in the Software without restriction, including without limitation 62 | > the rights to use, copy, modify, merge, publish, distribute, sublicense, 63 | > and/or sell copies of the Software, and to permit persons to whom the 64 | > Software is furnished to do so, subject to the following conditions: 65 | > 66 | > The above copyright notice and this permission notice shall be included 67 | > in all copies or substantial portions of the Software. 68 | > 69 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 70 | > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 71 | > OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 72 | > IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 73 | > DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 74 | > TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 75 | > OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 76 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/giphy/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2015-2022 Peter Hellberg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/giphy/client.go: -------------------------------------------------------------------------------- 1 | package giphy 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/http" 7 | "net/url" 8 | ) 9 | 10 | // DefaultClient is the default Giphy API client 11 | var DefaultClient = NewClient() 12 | 13 | // A Client communicates with the Giphy API. 14 | type Client struct { 15 | // APIKey is the key used for requests to the Giphy API 16 | APIKey string 17 | 18 | // Limit is the limit used for requests to the Giphy API 19 | Limit int 20 | 21 | // Rating is the rating used for requests to the Giphy API 22 | Rating string 23 | 24 | // BaseURL is the base url for Giphy API. 25 | BaseURL *url.URL 26 | 27 | // BasePath is the base path for the gifs endpoints 28 | BasePath string 29 | 30 | // User agent used for HTTP requests to Giphy API. 31 | UserAgent string 32 | 33 | // HTTP client used to communicate with the Giphy API. 34 | httpClient *http.Client 35 | } 36 | 37 | // NewClient returns a new Giphy API client. 38 | // If HTTPClient were not provided then http.DefaultClient is used. 39 | func NewClient(options ...Option) *Client { 40 | cloned := *http.DefaultClient 41 | 42 | c := &Client{ 43 | APIKey: Env("GIPHY_API_KEY", ""), 44 | Rating: Env("GIPHY_RATING", "g"), 45 | Limit: EnvInt("GIPHY_LIMIT", 10), 46 | BaseURL: &url.URL{ 47 | Scheme: Env("GIPHY_BASE_URL_SCHEME", "https"), 48 | Host: Env("GIPHY_BASE_URL_HOST", "api.giphy.com"), 49 | }, 50 | BasePath: Env("GIPHY_BASE_PATH", "/v1"), 51 | UserAgent: Env("GIPHY_USER_AGENT", "giphy.go"), 52 | httpClient: &cloned, 53 | } 54 | 55 | for _, option := range options { 56 | option(c) 57 | } 58 | 59 | return c 60 | } 61 | 62 | // NewRequest creates an API request. 63 | func (c *Client) NewRequest(s string) (*http.Request, error) { 64 | rel, err := url.Parse(c.BasePath + s) 65 | if err != nil { 66 | return nil, err 67 | } 68 | 69 | q := rel.Query() 70 | q.Set("api_key", c.APIKey) 71 | q.Set("rating", c.Rating) 72 | rel.RawQuery = q.Encode() 73 | 74 | u := c.BaseURL.ResolveReference(rel) 75 | 76 | if EnvBool("GIPHY_VERBOSE", false) { 77 | fmt.Println("giphy: GET", u.String()) 78 | } 79 | 80 | req, err := http.NewRequest("GET", u.String(), nil) 81 | if err != nil { 82 | return nil, err 83 | } 84 | 85 | req.Header.Add("User-Agent", c.UserAgent) 86 | return req, nil 87 | } 88 | 89 | // Do sends an API request and returns the API response. The API response is 90 | // decoded and stored in the value pointed to by v, or returned as an error if 91 | // an API error has occurred. 92 | func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) { 93 | // Make sure to close the connection after replying to this request 94 | req.Close = true 95 | 96 | resp, err := c.httpClient.Do(req) 97 | if err != nil { 98 | return resp, err 99 | } 100 | defer resp.Body.Close() 101 | 102 | if v != nil { 103 | err = json.NewDecoder(resp.Body).Decode(v) 104 | } 105 | 106 | if err != nil { 107 | return nil, fmt.Errorf("error reading response from %s %s: %s", req.Method, req.URL.RequestURI(), err) 108 | } 109 | 110 | return resp, nil 111 | } 112 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/giphy/env.go: -------------------------------------------------------------------------------- 1 | package giphy 2 | 3 | import ( 4 | "os" 5 | "strconv" 6 | ) 7 | 8 | // Env returns a string from the ENV, or fallback variable 9 | func Env(key, fallback string) string { 10 | v := os.Getenv(key) 11 | if v != "" { 12 | return v 13 | } 14 | 15 | return fallback 16 | } 17 | 18 | // EnvBool returns a bool from the ENV, or fallback variable 19 | func EnvBool(key string, fallback bool) bool { 20 | if b, err := strconv.ParseBool(os.Getenv(key)); err == nil { 21 | return b 22 | } 23 | 24 | return fallback 25 | } 26 | 27 | // EnvInt returns an int from the ENV, or fallback variable 28 | func EnvInt(key string, fallback int) int { 29 | if i, err := strconv.Atoi(os.Getenv(key)); err == nil { 30 | return i 31 | } 32 | 33 | return fallback 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/giphy/errors.go: -------------------------------------------------------------------------------- 1 | package giphy 2 | 3 | import "errors" 4 | 5 | var ( 6 | // ErrNoImageFound is the error returned when no image was found 7 | ErrNoImageFound = errors.New("no image found") 8 | 9 | // ErrUnknown is used for unknown errors from the Giphy API 10 | ErrUnknown = errors.New("unknown error") 11 | 12 | // ErrNoTrendingImagesFound is returned when no trending images were found 13 | ErrNoTrendingImagesFound = errors.New("no trending images found") 14 | 15 | // ErrNoRawData is returned if there was no data property in response 16 | ErrNoRawData = errors.New("no raw data") 17 | ) 18 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/giphy/gif.go: -------------------------------------------------------------------------------- 1 | package giphy 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "strings" 7 | ) 8 | 9 | // GIF returns a ID response from the Giphy API 10 | func (c *Client) GIF(id string) (GIF, error) { 11 | if strings.ContainsAny(id, "/&?") { 12 | return GIF{}, fmt.Errorf("Invalid giphy id: `%v`", id) 13 | } 14 | 15 | req, err := c.NewRequest("/gifs/" + id) 16 | if err != nil { 17 | return GIF{}, err 18 | } 19 | 20 | var gif GIF 21 | if _, err = c.Do(req, &gif); err != nil { 22 | return GIF{}, err 23 | } 24 | 25 | if gif.RawData == nil || gif.RawData[0] == '[' { 26 | return GIF{}, ErrNoImageFound 27 | } 28 | 29 | // Check if the first character in Data is a { 30 | if gif.RawData[0] == '{' { 31 | var d Data 32 | 33 | err = json.Unmarshal(gif.RawData, &d) 34 | if err != nil { 35 | return GIF{}, err 36 | } 37 | 38 | gif.Data = d 39 | 40 | return gif, nil 41 | } 42 | 43 | return GIF{}, ErrUnknown 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/giphy/options.go: -------------------------------------------------------------------------------- 1 | package giphy 2 | 3 | import "net/http" 4 | 5 | // Option function used by the Giphy client 6 | type Option func(*Client) 7 | 8 | // APIKey option used by the Giphy client 9 | func APIKey(apiKey string) Option { 10 | return func(c *Client) { 11 | c.APIKey = apiKey 12 | } 13 | } 14 | 15 | // Rating option used by the Giphy client 16 | func Rating(rating string) Option { 17 | return func(c *Client) { 18 | c.Rating = rating 19 | } 20 | } 21 | 22 | // Limit option used by the Giphy client 23 | func Limit(limit int) Option { 24 | return func(c *Client) { 25 | c.Limit = limit 26 | } 27 | } 28 | 29 | // HTTPClient option used by the Giphy client 30 | func HTTPClient(httpClient *http.Client) Option { 31 | return func(c *Client) { 32 | c.httpClient = httpClient 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/giphy/random.go: -------------------------------------------------------------------------------- 1 | package giphy 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | ) 7 | 8 | // Random returns a random response from the Giphy API 9 | func (c *Client) Random(args []string) (Random, error) { 10 | argsStr := strings.Join(args, " ") 11 | 12 | req, err := c.NewRequest("/gifs/random?tag=" + argsStr) 13 | if err != nil { 14 | return Random{}, err 15 | } 16 | 17 | var random Random 18 | if _, err = c.Do(req, &random); err != nil { 19 | return Random{}, err 20 | } 21 | 22 | // Check if the first character in Data is a [ 23 | if random.RawData == nil || random.RawData[0] == '[' { 24 | return Random{}, ErrNoImageFound 25 | } 26 | 27 | var d RandomData 28 | 29 | err = json.Unmarshal(random.RawData, &d) 30 | if err != nil { 31 | return Random{}, err 32 | } 33 | 34 | random.Data = d 35 | 36 | return random, nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/giphy/search.go: -------------------------------------------------------------------------------- 1 | package giphy 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // Search returns a search response from the Giphy API 9 | func (c *Client) Search(args []string) (Search, error) { 10 | argsStr := strings.Join(args, " ") 11 | 12 | path := fmt.Sprintf("/gifs/search?limit=%v&q=%s", c.Limit, argsStr) 13 | req, err := c.NewRequest(path) 14 | if err != nil { 15 | return Search{}, err 16 | } 17 | 18 | var search Search 19 | if _, err = c.Do(req, &search); err != nil { 20 | return Search{}, err 21 | } 22 | 23 | return search, nil 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/giphy/translate.go: -------------------------------------------------------------------------------- 1 | package giphy 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | ) 7 | 8 | // Translate returns a translate response from the Giphy API 9 | func (c *Client) Translate(args []string) (Translate, error) { 10 | argsStr := strings.Join(args, " ") 11 | 12 | req, err := c.NewRequest("/gifs/translate?s=" + argsStr) 13 | if err != nil { 14 | return Translate{}, err 15 | } 16 | 17 | var translate Translate 18 | if _, err = c.Do(req, &translate); err != nil { 19 | return Translate{}, err 20 | } 21 | 22 | if len(translate.RawData) == 0 { 23 | return Translate{}, ErrNoRawData 24 | } 25 | 26 | // Check if the first character in Data is a [ 27 | if translate.RawData[0] == '[' { 28 | return Translate{}, ErrNoImageFound 29 | } 30 | 31 | err = json.Unmarshal(translate.RawData, &translate.Data) 32 | if err != nil { 33 | return Translate{}, err 34 | } 35 | 36 | return translate, nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/giphy/trending.go: -------------------------------------------------------------------------------- 1 | package giphy 2 | 3 | import "fmt" 4 | 5 | // Trending returns a trending response from the Giphy API 6 | func (c *Client) Trending(args ...[]string) (Trending, error) { 7 | path := fmt.Sprintf("/gifs/trending?limit=%v", c.Limit) 8 | req, err := c.NewRequest(path) 9 | if err != nil { 10 | return Trending{}, err 11 | } 12 | 13 | var res Trending 14 | if _, err = c.Do(req, &res); err != nil { 15 | return res, err 16 | } 17 | 18 | if len(res.Data) == 0 { 19 | return res, ErrNoTrendingImagesFound 20 | } 21 | 22 | return res, nil 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/hi/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | dist: xenial 4 | 5 | go: "1.11.5" 6 | -------------------------------------------------------------------------------- /vendor/github.com/peterhellberg/hi/README.md: -------------------------------------------------------------------------------- 1 | # hi 2 | 3 | [![Build Status](https://travis-ci.org/peterhellberg/hi.svg?branch=master)](https://travis-ci.org/peterhellberg/hi) 4 | [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/peterhellberg/hi) 5 | [![License MIT](https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/peterhellberg/hi#license-mit) 6 | 7 | Find images for a given hashtag 8 | 9 | ## Installation 10 | 11 | go get -u github.com/peterhellberg/hi 12 | 13 | If you want to install the command line application: 14 | 15 | go get -u github.com/peterhellberg/hi/cmd/hi 16 | 17 | ## Usage 18 | 19 | ```go 20 | package main 21 | 22 | import ( 23 | "fmt" 24 | 25 | "github.com/peterhellberg/hi" 26 | ) 27 | 28 | func main() { 29 | image, err := hi.FindShuffledImage("pixel_dailies") 30 | 31 | if err == nil { 32 | fmt.Println(image.URL) 33 | } 34 | } 35 | ``` 36 | 37 | ## Dependencies 38 | 39 | The scraping is performed using the lovely [github.com/PuerkitoBio/goquery](https://github.com/PuerkitoBio/goquery) 40 | 41 | ## License (MIT) 42 | 43 | Copyright (c) 2015-2019 [Peter Hellberg](https://c7.se) 44 | 45 | > Permission is hereby granted, free of charge, to any person obtaining 46 | > a copy of this software and associated documentation files (the 47 | > "Software"), to deal in the Software without restriction, including 48 | > without limitation the rights to use, copy, modify, merge, publish, 49 | > distribute, sublicense, and/or sell copies of the Software, and to 50 | > permit persons to whom the Software is furnished to do so, subject to 51 | > the following conditions: 52 | 53 | > The above copyright notice and this permission notice shall be 54 | > included in all copies or substantial portions of the Software. 55 | 56 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 57 | > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 58 | > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 59 | > NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 60 | > LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 61 | > OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 62 | > WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/chacha20/chacha_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build go1.11 && gc && !purego 6 | // +build go1.11,gc,!purego 7 | 8 | package chacha20 9 | 10 | const bufSize = 256 11 | 12 | //go:noescape 13 | func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32) 14 | 15 | func (c *Cipher) xorKeyStreamBlocks(dst, src []byte) { 16 | xorKeyStreamVX(dst, src, &c.key, &c.nonce, &c.counter) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/chacha20/chacha_noasm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (!arm64 && !s390x && !ppc64le) || (arm64 && !go1.11) || !gc || purego 6 | // +build !arm64,!s390x,!ppc64le arm64,!go1.11 !gc purego 7 | 8 | package chacha20 9 | 10 | const bufSize = blockSize 11 | 12 | func (s *Cipher) xorKeyStreamBlocks(dst, src []byte) { 13 | s.xorKeyStreamBlocksGeneric(dst, src) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/chacha20/chacha_ppc64le.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc && !purego 6 | // +build gc,!purego 7 | 8 | package chacha20 9 | 10 | const bufSize = 256 11 | 12 | //go:noescape 13 | func chaCha20_ctr32_vsx(out, inp *byte, len int, key *[8]uint32, counter *uint32) 14 | 15 | func (c *Cipher) xorKeyStreamBlocks(dst, src []byte) { 16 | chaCha20_ctr32_vsx(&dst[0], &src[0], len(src), &c.key, &c.counter) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/chacha20/chacha_s390x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc && !purego 6 | // +build gc,!purego 7 | 8 | package chacha20 9 | 10 | import "golang.org/x/sys/cpu" 11 | 12 | var haveAsm = cpu.S390X.HasVX 13 | 14 | const bufSize = 256 15 | 16 | // xorKeyStreamVX is an assembly implementation of XORKeyStream. It must only 17 | // be called when the vector facility is available. Implementation in asm_s390x.s. 18 | // 19 | //go:noescape 20 | func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32) 21 | 22 | func (c *Cipher) xorKeyStreamBlocks(dst, src []byte) { 23 | if cpu.S390X.HasVX { 24 | xorKeyStreamVX(dst, src, &c.key, &c.nonce, &c.counter) 25 | } else { 26 | c.xorKeyStreamBlocksGeneric(dst, src) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/chacha20/xor.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found src the LICENSE file. 4 | 5 | package chacha20 6 | 7 | import "runtime" 8 | 9 | // Platforms that have fast unaligned 32-bit little endian accesses. 10 | const unaligned = runtime.GOARCH == "386" || 11 | runtime.GOARCH == "amd64" || 12 | runtime.GOARCH == "arm64" || 13 | runtime.GOARCH == "ppc64le" || 14 | runtime.GOARCH == "s390x" 15 | 16 | // addXor reads a little endian uint32 from src, XORs it with (a + b) and 17 | // places the result in little endian byte order in dst. 18 | func addXor(dst, src []byte, a, b uint32) { 19 | _, _ = src[3], dst[3] // bounds check elimination hint 20 | if unaligned { 21 | // The compiler should optimize this code into 22 | // 32-bit unaligned little endian loads and stores. 23 | // TODO: delete once the compiler does a reliably 24 | // good job with the generic code below. 25 | // See issue #25111 for more details. 26 | v := uint32(src[0]) 27 | v |= uint32(src[1]) << 8 28 | v |= uint32(src[2]) << 16 29 | v |= uint32(src[3]) << 24 30 | v ^= a + b 31 | dst[0] = byte(v) 32 | dst[1] = byte(v >> 8) 33 | dst[2] = byte(v >> 16) 34 | dst[3] = byte(v >> 24) 35 | } else { 36 | a += b 37 | dst[0] = src[0] ^ byte(a) 38 | dst[1] = src[1] ^ byte(a>>8) 39 | dst[2] = src[2] ^ byte(a>>16) 40 | dst[3] = src[3] ^ byte(a>>24) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/internal/field/README: -------------------------------------------------------------------------------- 1 | This package is kept in sync with crypto/ed25519/internal/edwards25519/field in 2 | the standard library. 3 | 4 | If there are any changes in the standard library that need to be synced to this 5 | package, run sync.sh. It will not overwrite any local changes made since the 6 | previous sync, so it's ok to land changes in this package first, and then sync 7 | to the standard library later. 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.go: -------------------------------------------------------------------------------- 1 | // Code generated by command: go run fe_amd64_asm.go -out ../fe_amd64.s -stubs ../fe_amd64.go -pkg field. DO NOT EDIT. 2 | 3 | //go:build amd64 && gc && !purego 4 | // +build amd64,gc,!purego 5 | 6 | package field 7 | 8 | // feMul sets out = a * b. It works like feMulGeneric. 9 | // 10 | //go:noescape 11 | func feMul(out *Element, a *Element, b *Element) 12 | 13 | // feSquare sets out = a * a. It works like feSquareGeneric. 14 | // 15 | //go:noescape 16 | func feSquare(out *Element, a *Element) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64_noasm.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !amd64 || !gc || purego 6 | // +build !amd64 !gc purego 7 | 8 | package field 9 | 10 | func feMul(v, x, y *Element) { feMulGeneric(v, x, y) } 11 | 12 | func feSquare(v, x *Element) { feSquareGeneric(v, x) } 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm64 && gc && !purego 6 | // +build arm64,gc,!purego 7 | 8 | package field 9 | 10 | //go:noescape 11 | func carryPropagate(v *Element) 12 | 13 | func (v *Element) carryPropagate() *Element { 14 | carryPropagate(v) 15 | return v 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build arm64 && gc && !purego 6 | // +build arm64,gc,!purego 7 | 8 | #include "textflag.h" 9 | 10 | // carryPropagate works exactly like carryPropagateGeneric and uses the 11 | // same AND, ADD, and LSR+MADD instructions emitted by the compiler, but 12 | // avoids loading R0-R4 twice and uses LDP and STP. 13 | // 14 | // See https://golang.org/issues/43145 for the main compiler issue. 15 | // 16 | // func carryPropagate(v *Element) 17 | TEXT ·carryPropagate(SB),NOFRAME|NOSPLIT,$0-8 18 | MOVD v+0(FP), R20 19 | 20 | LDP 0(R20), (R0, R1) 21 | LDP 16(R20), (R2, R3) 22 | MOVD 32(R20), R4 23 | 24 | AND $0x7ffffffffffff, R0, R10 25 | AND $0x7ffffffffffff, R1, R11 26 | AND $0x7ffffffffffff, R2, R12 27 | AND $0x7ffffffffffff, R3, R13 28 | AND $0x7ffffffffffff, R4, R14 29 | 30 | ADD R0>>51, R11, R11 31 | ADD R1>>51, R12, R12 32 | ADD R2>>51, R13, R13 33 | ADD R3>>51, R14, R14 34 | // R4>>51 * 19 + R10 -> R10 35 | LSR $51, R4, R21 36 | MOVD $19, R22 37 | MADD R22, R10, R21, R10 38 | 39 | STP (R10, R11), 0(R20) 40 | STP (R12, R13), 16(R20) 41 | MOVD R14, 32(R20) 42 | 43 | RET 44 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64_noasm.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !arm64 || !gc || purego 6 | // +build !arm64 !gc purego 7 | 8 | package field 9 | 10 | func (v *Element) carryPropagate() *Element { 11 | return v.carryPropagateGeneric() 12 | } 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/internal/field/sync.checkpoint: -------------------------------------------------------------------------------- 1 | b0c49ae9f59d233526f8934262c5bbbe14d4358d 2 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/internal/field/sync.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -euo pipefail 3 | 4 | cd "$(git rev-parse --show-toplevel)" 5 | 6 | STD_PATH=src/crypto/ed25519/internal/edwards25519/field 7 | LOCAL_PATH=curve25519/internal/field 8 | LAST_SYNC_REF=$(cat $LOCAL_PATH/sync.checkpoint) 9 | 10 | git fetch https://go.googlesource.com/go master 11 | 12 | if git diff --quiet $LAST_SYNC_REF:$STD_PATH FETCH_HEAD:$STD_PATH; then 13 | echo "No changes." 14 | else 15 | NEW_REF=$(git rev-parse FETCH_HEAD | tee $LOCAL_PATH/sync.checkpoint) 16 | echo "Applying changes from $LAST_SYNC_REF to $NEW_REF..." 17 | git diff $LAST_SYNC_REF:$STD_PATH FETCH_HEAD:$STD_PATH | \ 18 | git apply -3 --directory=$LOCAL_PATH 19 | fi 20 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ed25519/ed25519.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package ed25519 implements the Ed25519 signature algorithm. See 6 | // https://ed25519.cr.yp.to/. 7 | // 8 | // These functions are also compatible with the “Ed25519” function defined in 9 | // RFC 8032. However, unlike RFC 8032's formulation, this package's private key 10 | // representation includes a public key suffix to make multiple signing 11 | // operations with the same key more efficient. This package refers to the RFC 12 | // 8032 private key as the “seed”. 13 | // 14 | // Beginning with Go 1.13, the functionality of this package was moved to the 15 | // standard library as crypto/ed25519. This package only acts as a compatibility 16 | // wrapper. 17 | package ed25519 18 | 19 | import ( 20 | "crypto/ed25519" 21 | "io" 22 | ) 23 | 24 | const ( 25 | // PublicKeySize is the size, in bytes, of public keys as used in this package. 26 | PublicKeySize = 32 27 | // PrivateKeySize is the size, in bytes, of private keys as used in this package. 28 | PrivateKeySize = 64 29 | // SignatureSize is the size, in bytes, of signatures generated and verified by this package. 30 | SignatureSize = 64 31 | // SeedSize is the size, in bytes, of private key seeds. These are the private key representations used by RFC 8032. 32 | SeedSize = 32 33 | ) 34 | 35 | // PublicKey is the type of Ed25519 public keys. 36 | // 37 | // This type is an alias for crypto/ed25519's PublicKey type. 38 | // See the crypto/ed25519 package for the methods on this type. 39 | type PublicKey = ed25519.PublicKey 40 | 41 | // PrivateKey is the type of Ed25519 private keys. It implements crypto.Signer. 42 | // 43 | // This type is an alias for crypto/ed25519's PrivateKey type. 44 | // See the crypto/ed25519 package for the methods on this type. 45 | type PrivateKey = ed25519.PrivateKey 46 | 47 | // GenerateKey generates a public/private key pair using entropy from rand. 48 | // If rand is nil, crypto/rand.Reader will be used. 49 | func GenerateKey(rand io.Reader) (PublicKey, PrivateKey, error) { 50 | return ed25519.GenerateKey(rand) 51 | } 52 | 53 | // NewKeyFromSeed calculates a private key from a seed. It will panic if 54 | // len(seed) is not SeedSize. This function is provided for interoperability 55 | // with RFC 8032. RFC 8032's private keys correspond to seeds in this 56 | // package. 57 | func NewKeyFromSeed(seed []byte) PrivateKey { 58 | return ed25519.NewKeyFromSeed(seed) 59 | } 60 | 61 | // Sign signs the message with privateKey and returns a signature. It will 62 | // panic if len(privateKey) is not PrivateKeySize. 63 | func Sign(privateKey PrivateKey, message []byte) []byte { 64 | return ed25519.Sign(privateKey, message) 65 | } 66 | 67 | // Verify reports whether sig is a valid signature of message by publicKey. It 68 | // will panic if len(publicKey) is not PublicKeySize. 69 | func Verify(publicKey PublicKey, message, sig []byte) bool { 70 | return ed25519.Verify(publicKey, message, sig) 71 | } 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/alias/alias.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !purego 6 | // +build !purego 7 | 8 | // Package alias implements memory aliasing tests. 9 | package alias 10 | 11 | import "unsafe" 12 | 13 | // AnyOverlap reports whether x and y share memory at any (not necessarily 14 | // corresponding) index. The memory beyond the slice length is ignored. 15 | func AnyOverlap(x, y []byte) bool { 16 | return len(x) > 0 && len(y) > 0 && 17 | uintptr(unsafe.Pointer(&x[0])) <= uintptr(unsafe.Pointer(&y[len(y)-1])) && 18 | uintptr(unsafe.Pointer(&y[0])) <= uintptr(unsafe.Pointer(&x[len(x)-1])) 19 | } 20 | 21 | // InexactOverlap reports whether x and y share memory at any non-corresponding 22 | // index. The memory beyond the slice length is ignored. Note that x and y can 23 | // have different lengths and still not have any inexact overlap. 24 | // 25 | // InexactOverlap can be used to implement the requirements of the crypto/cipher 26 | // AEAD, Block, BlockMode and Stream interfaces. 27 | func InexactOverlap(x, y []byte) bool { 28 | if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] { 29 | return false 30 | } 31 | return AnyOverlap(x, y) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/alias/alias_purego.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build purego 6 | // +build purego 7 | 8 | // Package alias implements memory aliasing tests. 9 | package alias 10 | 11 | // This is the Google App Engine standard variant based on reflect 12 | // because the unsafe package and cgo are disallowed. 13 | 14 | import "reflect" 15 | 16 | // AnyOverlap reports whether x and y share memory at any (not necessarily 17 | // corresponding) index. The memory beyond the slice length is ignored. 18 | func AnyOverlap(x, y []byte) bool { 19 | return len(x) > 0 && len(y) > 0 && 20 | reflect.ValueOf(&x[0]).Pointer() <= reflect.ValueOf(&y[len(y)-1]).Pointer() && 21 | reflect.ValueOf(&y[0]).Pointer() <= reflect.ValueOf(&x[len(x)-1]).Pointer() 22 | } 23 | 24 | // InexactOverlap reports whether x and y share memory at any non-corresponding 25 | // index. The memory beyond the slice length is ignored. Note that x and y can 26 | // have different lengths and still not have any inexact overlap. 27 | // 28 | // InexactOverlap can be used to implement the requirements of the crypto/cipher 29 | // AEAD, Block, BlockMode and Stream interfaces. 30 | func InexactOverlap(x, y []byte) bool { 31 | if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] { 32 | return false 33 | } 34 | return AnyOverlap(x, y) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/bits_compat.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !go1.13 6 | // +build !go1.13 7 | 8 | package poly1305 9 | 10 | // Generic fallbacks for the math/bits intrinsics, copied from 11 | // src/math/bits/bits.go. They were added in Go 1.12, but Add64 and Sum64 had 12 | // variable time fallbacks until Go 1.13. 13 | 14 | func bitsAdd64(x, y, carry uint64) (sum, carryOut uint64) { 15 | sum = x + y + carry 16 | carryOut = ((x & y) | ((x | y) &^ sum)) >> 63 17 | return 18 | } 19 | 20 | func bitsSub64(x, y, borrow uint64) (diff, borrowOut uint64) { 21 | diff = x - y - borrow 22 | borrowOut = ((^x & y) | (^(x ^ y) & diff)) >> 63 23 | return 24 | } 25 | 26 | func bitsMul64(x, y uint64) (hi, lo uint64) { 27 | const mask32 = 1<<32 - 1 28 | x0 := x & mask32 29 | x1 := x >> 32 30 | y0 := y & mask32 31 | y1 := y >> 32 32 | w0 := x0 * y0 33 | t := x1*y0 + w0>>32 34 | w1 := t & mask32 35 | w2 := t >> 32 36 | w1 += x0 * y1 37 | hi = x1*y1 + w2 + w1>>32 38 | lo = x * y 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/bits_go1.13.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build go1.13 6 | // +build go1.13 7 | 8 | package poly1305 9 | 10 | import "math/bits" 11 | 12 | func bitsAdd64(x, y, carry uint64) (sum, carryOut uint64) { 13 | return bits.Add64(x, y, carry) 14 | } 15 | 16 | func bitsSub64(x, y, borrow uint64) (diff, borrowOut uint64) { 17 | return bits.Sub64(x, y, borrow) 18 | } 19 | 20 | func bitsMul64(x, y uint64) (hi, lo uint64) { 21 | return bits.Mul64(x, y) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (!amd64 && !ppc64le && !s390x) || !gc || purego 6 | // +build !amd64,!ppc64le,!s390x !gc purego 7 | 8 | package poly1305 9 | 10 | type mac struct{ macGeneric } 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc && !purego 6 | // +build gc,!purego 7 | 8 | package poly1305 9 | 10 | //go:noescape 11 | func update(state *macState, msg []byte) 12 | 13 | // mac is a wrapper for macGeneric that redirects calls that would have gone to 14 | // updateGeneric to update. 15 | // 16 | // Its Write and Sum methods are otherwise identical to the macGeneric ones, but 17 | // using function pointers would carry a major performance cost. 18 | type mac struct{ macGeneric } 19 | 20 | func (h *mac) Write(p []byte) (int, error) { 21 | nn := len(p) 22 | if h.offset > 0 { 23 | n := copy(h.buffer[h.offset:], p) 24 | if h.offset+n < TagSize { 25 | h.offset += n 26 | return nn, nil 27 | } 28 | p = p[n:] 29 | h.offset = 0 30 | update(&h.macState, h.buffer[:]) 31 | } 32 | if n := len(p) - (len(p) % TagSize); n > 0 { 33 | update(&h.macState, p[:n]) 34 | p = p[n:] 35 | } 36 | if len(p) > 0 { 37 | h.offset += copy(h.buffer[h.offset:], p) 38 | } 39 | return nn, nil 40 | } 41 | 42 | func (h *mac) Sum(out *[16]byte) { 43 | state := h.macState 44 | if h.offset > 0 { 45 | update(&state, h.buffer[:h.offset]) 46 | } 47 | finalize(out, &state.h, &state.s) 48 | } 49 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc && !purego 6 | // +build gc,!purego 7 | 8 | #include "textflag.h" 9 | 10 | #define POLY1305_ADD(msg, h0, h1, h2) \ 11 | ADDQ 0(msg), h0; \ 12 | ADCQ 8(msg), h1; \ 13 | ADCQ $1, h2; \ 14 | LEAQ 16(msg), msg 15 | 16 | #define POLY1305_MUL(h0, h1, h2, r0, r1, t0, t1, t2, t3) \ 17 | MOVQ r0, AX; \ 18 | MULQ h0; \ 19 | MOVQ AX, t0; \ 20 | MOVQ DX, t1; \ 21 | MOVQ r0, AX; \ 22 | MULQ h1; \ 23 | ADDQ AX, t1; \ 24 | ADCQ $0, DX; \ 25 | MOVQ r0, t2; \ 26 | IMULQ h2, t2; \ 27 | ADDQ DX, t2; \ 28 | \ 29 | MOVQ r1, AX; \ 30 | MULQ h0; \ 31 | ADDQ AX, t1; \ 32 | ADCQ $0, DX; \ 33 | MOVQ DX, h0; \ 34 | MOVQ r1, t3; \ 35 | IMULQ h2, t3; \ 36 | MOVQ r1, AX; \ 37 | MULQ h1; \ 38 | ADDQ AX, t2; \ 39 | ADCQ DX, t3; \ 40 | ADDQ h0, t2; \ 41 | ADCQ $0, t3; \ 42 | \ 43 | MOVQ t0, h0; \ 44 | MOVQ t1, h1; \ 45 | MOVQ t2, h2; \ 46 | ANDQ $3, h2; \ 47 | MOVQ t2, t0; \ 48 | ANDQ $0xFFFFFFFFFFFFFFFC, t0; \ 49 | ADDQ t0, h0; \ 50 | ADCQ t3, h1; \ 51 | ADCQ $0, h2; \ 52 | SHRQ $2, t3, t2; \ 53 | SHRQ $2, t3; \ 54 | ADDQ t2, h0; \ 55 | ADCQ t3, h1; \ 56 | ADCQ $0, h2 57 | 58 | // func update(state *[7]uint64, msg []byte) 59 | TEXT ·update(SB), $0-32 60 | MOVQ state+0(FP), DI 61 | MOVQ msg_base+8(FP), SI 62 | MOVQ msg_len+16(FP), R15 63 | 64 | MOVQ 0(DI), R8 // h0 65 | MOVQ 8(DI), R9 // h1 66 | MOVQ 16(DI), R10 // h2 67 | MOVQ 24(DI), R11 // r0 68 | MOVQ 32(DI), R12 // r1 69 | 70 | CMPQ R15, $16 71 | JB bytes_between_0_and_15 72 | 73 | loop: 74 | POLY1305_ADD(SI, R8, R9, R10) 75 | 76 | multiply: 77 | POLY1305_MUL(R8, R9, R10, R11, R12, BX, CX, R13, R14) 78 | SUBQ $16, R15 79 | CMPQ R15, $16 80 | JAE loop 81 | 82 | bytes_between_0_and_15: 83 | TESTQ R15, R15 84 | JZ done 85 | MOVQ $1, BX 86 | XORQ CX, CX 87 | XORQ R13, R13 88 | ADDQ R15, SI 89 | 90 | flush_buffer: 91 | SHLQ $8, BX, CX 92 | SHLQ $8, BX 93 | MOVB -1(SI), R13 94 | XORQ R13, BX 95 | DECQ SI 96 | DECQ R15 97 | JNZ flush_buffer 98 | 99 | ADDQ BX, R8 100 | ADCQ CX, R9 101 | ADCQ $0, R10 102 | MOVQ $16, R15 103 | JMP multiply 104 | 105 | done: 106 | MOVQ R8, 0(DI) 107 | MOVQ R9, 8(DI) 108 | MOVQ R10, 16(DI) 109 | RET 110 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc && !purego 6 | // +build gc,!purego 7 | 8 | package poly1305 9 | 10 | //go:noescape 11 | func update(state *macState, msg []byte) 12 | 13 | // mac is a wrapper for macGeneric that redirects calls that would have gone to 14 | // updateGeneric to update. 15 | // 16 | // Its Write and Sum methods are otherwise identical to the macGeneric ones, but 17 | // using function pointers would carry a major performance cost. 18 | type mac struct{ macGeneric } 19 | 20 | func (h *mac) Write(p []byte) (int, error) { 21 | nn := len(p) 22 | if h.offset > 0 { 23 | n := copy(h.buffer[h.offset:], p) 24 | if h.offset+n < TagSize { 25 | h.offset += n 26 | return nn, nil 27 | } 28 | p = p[n:] 29 | h.offset = 0 30 | update(&h.macState, h.buffer[:]) 31 | } 32 | if n := len(p) - (len(p) % TagSize); n > 0 { 33 | update(&h.macState, p[:n]) 34 | p = p[n:] 35 | } 36 | if len(p) > 0 { 37 | h.offset += copy(h.buffer[h.offset:], p) 38 | } 39 | return nn, nil 40 | } 41 | 42 | func (h *mac) Sum(out *[16]byte) { 43 | state := h.macState 44 | if h.offset > 0 { 45 | update(&state, h.buffer[:h.offset]) 46 | } 47 | finalize(out, &state.h, &state.s) 48 | } 49 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc && !purego 6 | // +build gc,!purego 7 | 8 | package poly1305 9 | 10 | import ( 11 | "golang.org/x/sys/cpu" 12 | ) 13 | 14 | // updateVX is an assembly implementation of Poly1305 that uses vector 15 | // instructions. It must only be called if the vector facility (vx) is 16 | // available. 17 | // 18 | //go:noescape 19 | func updateVX(state *macState, msg []byte) 20 | 21 | // mac is a replacement for macGeneric that uses a larger buffer and redirects 22 | // calls that would have gone to updateGeneric to updateVX if the vector 23 | // facility is installed. 24 | // 25 | // A larger buffer is required for good performance because the vector 26 | // implementation has a higher fixed cost per call than the generic 27 | // implementation. 28 | type mac struct { 29 | macState 30 | 31 | buffer [16 * TagSize]byte // size must be a multiple of block size (16) 32 | offset int 33 | } 34 | 35 | func (h *mac) Write(p []byte) (int, error) { 36 | nn := len(p) 37 | if h.offset > 0 { 38 | n := copy(h.buffer[h.offset:], p) 39 | if h.offset+n < len(h.buffer) { 40 | h.offset += n 41 | return nn, nil 42 | } 43 | p = p[n:] 44 | h.offset = 0 45 | if cpu.S390X.HasVX { 46 | updateVX(&h.macState, h.buffer[:]) 47 | } else { 48 | updateGeneric(&h.macState, h.buffer[:]) 49 | } 50 | } 51 | 52 | tail := len(p) % len(h.buffer) // number of bytes to copy into buffer 53 | body := len(p) - tail // number of bytes to process now 54 | if body > 0 { 55 | if cpu.S390X.HasVX { 56 | updateVX(&h.macState, p[:body]) 57 | } else { 58 | updateGeneric(&h.macState, p[:body]) 59 | } 60 | } 61 | h.offset = copy(h.buffer[:], p[body:]) // copy tail bytes - can be 0 62 | return nn, nil 63 | } 64 | 65 | func (h *mac) Sum(out *[TagSize]byte) { 66 | state := h.macState 67 | remainder := h.buffer[:h.offset] 68 | 69 | // Use the generic implementation if we have 2 or fewer blocks left 70 | // to sum. The vector implementation has a higher startup time. 71 | if cpu.S390X.HasVX && len(remainder) > 2*TagSize { 72 | updateVX(&state, remainder) 73 | } else if len(remainder) > 0 { 74 | updateGeneric(&state, remainder) 75 | } 76 | finalize(out, &state.h, &state.s) 77 | } 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/buffer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | import ( 8 | "io" 9 | "sync" 10 | ) 11 | 12 | // buffer provides a linked list buffer for data exchange 13 | // between producer and consumer. Theoretically the buffer is 14 | // of unlimited capacity as it does no allocation of its own. 15 | type buffer struct { 16 | // protects concurrent access to head, tail and closed 17 | *sync.Cond 18 | 19 | head *element // the buffer that will be read first 20 | tail *element // the buffer that will be read last 21 | 22 | closed bool 23 | } 24 | 25 | // An element represents a single link in a linked list. 26 | type element struct { 27 | buf []byte 28 | next *element 29 | } 30 | 31 | // newBuffer returns an empty buffer that is not closed. 32 | func newBuffer() *buffer { 33 | e := new(element) 34 | b := &buffer{ 35 | Cond: newCond(), 36 | head: e, 37 | tail: e, 38 | } 39 | return b 40 | } 41 | 42 | // write makes buf available for Read to receive. 43 | // buf must not be modified after the call to write. 44 | func (b *buffer) write(buf []byte) { 45 | b.Cond.L.Lock() 46 | e := &element{buf: buf} 47 | b.tail.next = e 48 | b.tail = e 49 | b.Cond.Signal() 50 | b.Cond.L.Unlock() 51 | } 52 | 53 | // eof closes the buffer. Reads from the buffer once all 54 | // the data has been consumed will receive io.EOF. 55 | func (b *buffer) eof() { 56 | b.Cond.L.Lock() 57 | b.closed = true 58 | b.Cond.Signal() 59 | b.Cond.L.Unlock() 60 | } 61 | 62 | // Read reads data from the internal buffer in buf. Reads will block 63 | // if no data is available, or until the buffer is closed. 64 | func (b *buffer) Read(buf []byte) (n int, err error) { 65 | b.Cond.L.Lock() 66 | defer b.Cond.L.Unlock() 67 | 68 | for len(buf) > 0 { 69 | // if there is data in b.head, copy it 70 | if len(b.head.buf) > 0 { 71 | r := copy(buf, b.head.buf) 72 | buf, b.head.buf = buf[r:], b.head.buf[r:] 73 | n += r 74 | continue 75 | } 76 | // if there is a next buffer, make it the head 77 | if len(b.head.buf) == 0 && b.head != b.tail { 78 | b.head = b.head.next 79 | continue 80 | } 81 | 82 | // if at least one byte has been copied, return 83 | if n > 0 { 84 | break 85 | } 86 | 87 | // if nothing was read, and there is nothing outstanding 88 | // check to see if the buffer is closed. 89 | if b.closed { 90 | err = io.EOF 91 | break 92 | } 93 | // out of buffers, wait for producer 94 | b.Cond.Wait() 95 | } 96 | return 97 | } 98 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package ssh implements an SSH client and server. 7 | 8 | SSH is a transport security protocol, an authentication protocol and a 9 | family of application protocols. The most typical application level 10 | protocol is a remote shell and this is specifically implemented. However, 11 | the multiplexed nature of SSH is exposed to users that wish to support 12 | others. 13 | 14 | References: 15 | 16 | [PROTOCOL.certkeys]: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys?rev=HEAD 17 | [SSH-PARAMETERS]: http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1 18 | 19 | This package does not fall under the stability promise of the Go language itself, 20 | so its API may be changed when pressing needs arise. 21 | */ 22 | package ssh // import "golang.org/x/crypto/ssh" 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/internal/bcrypt_pbkdf/bcrypt_pbkdf.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package bcrypt_pbkdf implements bcrypt_pbkdf(3) from OpenBSD. 6 | // 7 | // See https://flak.tedunangst.com/post/bcrypt-pbkdf and 8 | // https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libutil/bcrypt_pbkdf.c. 9 | package bcrypt_pbkdf 10 | 11 | import ( 12 | "crypto/sha512" 13 | "errors" 14 | "golang.org/x/crypto/blowfish" 15 | ) 16 | 17 | const blockSize = 32 18 | 19 | // Key derives a key from the password, salt and rounds count, returning a 20 | // []byte of length keyLen that can be used as cryptographic key. 21 | func Key(password, salt []byte, rounds, keyLen int) ([]byte, error) { 22 | if rounds < 1 { 23 | return nil, errors.New("bcrypt_pbkdf: number of rounds is too small") 24 | } 25 | if len(password) == 0 { 26 | return nil, errors.New("bcrypt_pbkdf: empty password") 27 | } 28 | if len(salt) == 0 || len(salt) > 1<<20 { 29 | return nil, errors.New("bcrypt_pbkdf: bad salt length") 30 | } 31 | if keyLen > 1024 { 32 | return nil, errors.New("bcrypt_pbkdf: keyLen is too large") 33 | } 34 | 35 | numBlocks := (keyLen + blockSize - 1) / blockSize 36 | key := make([]byte, numBlocks*blockSize) 37 | 38 | h := sha512.New() 39 | h.Write(password) 40 | shapass := h.Sum(nil) 41 | 42 | shasalt := make([]byte, 0, sha512.Size) 43 | cnt, tmp := make([]byte, 4), make([]byte, blockSize) 44 | for block := 1; block <= numBlocks; block++ { 45 | h.Reset() 46 | h.Write(salt) 47 | cnt[0] = byte(block >> 24) 48 | cnt[1] = byte(block >> 16) 49 | cnt[2] = byte(block >> 8) 50 | cnt[3] = byte(block) 51 | h.Write(cnt) 52 | bcryptHash(tmp, shapass, h.Sum(shasalt)) 53 | 54 | out := make([]byte, blockSize) 55 | copy(out, tmp) 56 | for i := 2; i <= rounds; i++ { 57 | h.Reset() 58 | h.Write(tmp) 59 | bcryptHash(tmp, shapass, h.Sum(shasalt)) 60 | for j := 0; j < len(out); j++ { 61 | out[j] ^= tmp[j] 62 | } 63 | } 64 | 65 | for i, v := range out { 66 | key[i*numBlocks+(block-1)] = v 67 | } 68 | } 69 | return key[:keyLen], nil 70 | } 71 | 72 | var magic = []byte("OxychromaticBlowfishSwatDynamite") 73 | 74 | func bcryptHash(out, shapass, shasalt []byte) { 75 | c, err := blowfish.NewSaltedCipher(shapass, shasalt) 76 | if err != nil { 77 | panic(err) 78 | } 79 | for i := 0; i < 64; i++ { 80 | blowfish.ExpandKey(shasalt, c) 81 | blowfish.ExpandKey(shapass, c) 82 | } 83 | copy(out, magic) 84 | for i := 0; i < 32; i += 8 { 85 | for j := 0; j < 64; j++ { 86 | c.Encrypt(out[i:i+8], out[i:i+8]) 87 | } 88 | } 89 | // Swap bytes due to different endianness. 90 | for i := 0; i < 32; i += 4 { 91 | out[i+3], out[i+2], out[i+1], out[i] = out[i], out[i+1], out[i+2], out[i+3] 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/mac.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | // Message authentication support 8 | 9 | import ( 10 | "crypto/hmac" 11 | "crypto/sha1" 12 | "crypto/sha256" 13 | "hash" 14 | ) 15 | 16 | type macMode struct { 17 | keySize int 18 | etm bool 19 | new func(key []byte) hash.Hash 20 | } 21 | 22 | // truncatingMAC wraps around a hash.Hash and truncates the output digest to 23 | // a given size. 24 | type truncatingMAC struct { 25 | length int 26 | hmac hash.Hash 27 | } 28 | 29 | func (t truncatingMAC) Write(data []byte) (int, error) { 30 | return t.hmac.Write(data) 31 | } 32 | 33 | func (t truncatingMAC) Sum(in []byte) []byte { 34 | out := t.hmac.Sum(in) 35 | return out[:len(in)+t.length] 36 | } 37 | 38 | func (t truncatingMAC) Reset() { 39 | t.hmac.Reset() 40 | } 41 | 42 | func (t truncatingMAC) Size() int { 43 | return t.length 44 | } 45 | 46 | func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() } 47 | 48 | var macModes = map[string]*macMode{ 49 | "hmac-sha2-256-etm@openssh.com": {32, true, func(key []byte) hash.Hash { 50 | return hmac.New(sha256.New, key) 51 | }}, 52 | "hmac-sha2-256": {32, false, func(key []byte) hash.Hash { 53 | return hmac.New(sha256.New, key) 54 | }}, 55 | "hmac-sha1": {20, false, func(key []byte) hash.Hash { 56 | return hmac.New(sha1.New, key) 57 | }}, 58 | "hmac-sha1-96": {20, false, func(key []byte) hash.Hash { 59 | return truncatingMAC{12, hmac.New(sha1.New, key)} 60 | }}, 61 | } 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/html/atom/atom.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package atom provides integer codes (also known as atoms) for a fixed set of 6 | // frequently occurring HTML strings: tag names and attribute keys such as "p" 7 | // and "id". 8 | // 9 | // Sharing an atom's name between all elements with the same tag can result in 10 | // fewer string allocations when tokenizing and parsing HTML. Integer 11 | // comparisons are also generally faster than string comparisons. 12 | // 13 | // The value of an atom's particular code is not guaranteed to stay the same 14 | // between versions of this package. Neither is any ordering guaranteed: 15 | // whether atom.H1 < atom.H2 may also change. The codes are not guaranteed to 16 | // be dense. The only guarantees are that e.g. looking up "div" will yield 17 | // atom.Div, calling atom.Div.String will return "div", and atom.Div != 0. 18 | package atom // import "golang.org/x/net/html/atom" 19 | 20 | // Atom is an integer code for a string. The zero value maps to "". 21 | type Atom uint32 22 | 23 | // String returns the atom's name. 24 | func (a Atom) String() string { 25 | start := uint32(a >> 8) 26 | n := uint32(a & 0xff) 27 | if start+n > uint32(len(atomText)) { 28 | return "" 29 | } 30 | return atomText[start : start+n] 31 | } 32 | 33 | func (a Atom) string() string { 34 | return atomText[a>>8 : a>>8+a&0xff] 35 | } 36 | 37 | // fnv computes the FNV hash with an arbitrary starting value h. 38 | func fnv(h uint32, s []byte) uint32 { 39 | for i := range s { 40 | h ^= uint32(s[i]) 41 | h *= 16777619 42 | } 43 | return h 44 | } 45 | 46 | func match(s string, t []byte) bool { 47 | for i, c := range t { 48 | if s[i] != c { 49 | return false 50 | } 51 | } 52 | return true 53 | } 54 | 55 | // Lookup returns the atom whose name is s. It returns zero if there is no 56 | // such atom. The lookup is case sensitive. 57 | func Lookup(s []byte) Atom { 58 | if len(s) == 0 || len(s) > maxAtomLen { 59 | return 0 60 | } 61 | h := fnv(hash0, s) 62 | if a := table[h&uint32(len(table)-1)]; int(a&0xff) == len(s) && match(a.string(), s) { 63 | return a 64 | } 65 | if a := table[(h>>16)&uint32(len(table)-1)]; int(a&0xff) == len(s) && match(a.string(), s) { 66 | return a 67 | } 68 | return 0 69 | } 70 | 71 | // String returns a string whose contents are equal to s. In that sense, it is 72 | // equivalent to string(s) but may be more efficient. 73 | func String(s []byte) string { 74 | if a := Lookup(s); a != 0 { 75 | return a.String() 76 | } 77 | return string(s) 78 | } 79 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/html/const.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package html 6 | 7 | // Section 12.2.4.2 of the HTML5 specification says "The following elements 8 | // have varying levels of special parsing rules". 9 | // https://html.spec.whatwg.org/multipage/syntax.html#the-stack-of-open-elements 10 | var isSpecialElementMap = map[string]bool{ 11 | "address": true, 12 | "applet": true, 13 | "area": true, 14 | "article": true, 15 | "aside": true, 16 | "base": true, 17 | "basefont": true, 18 | "bgsound": true, 19 | "blockquote": true, 20 | "body": true, 21 | "br": true, 22 | "button": true, 23 | "caption": true, 24 | "center": true, 25 | "col": true, 26 | "colgroup": true, 27 | "dd": true, 28 | "details": true, 29 | "dir": true, 30 | "div": true, 31 | "dl": true, 32 | "dt": true, 33 | "embed": true, 34 | "fieldset": true, 35 | "figcaption": true, 36 | "figure": true, 37 | "footer": true, 38 | "form": true, 39 | "frame": true, 40 | "frameset": true, 41 | "h1": true, 42 | "h2": true, 43 | "h3": true, 44 | "h4": true, 45 | "h5": true, 46 | "h6": true, 47 | "head": true, 48 | "header": true, 49 | "hgroup": true, 50 | "hr": true, 51 | "html": true, 52 | "iframe": true, 53 | "img": true, 54 | "input": true, 55 | "keygen": true, // "keygen" has been removed from the spec, but are kept here for backwards compatibility. 56 | "li": true, 57 | "link": true, 58 | "listing": true, 59 | "main": true, 60 | "marquee": true, 61 | "menu": true, 62 | "meta": true, 63 | "nav": true, 64 | "noembed": true, 65 | "noframes": true, 66 | "noscript": true, 67 | "object": true, 68 | "ol": true, 69 | "p": true, 70 | "param": true, 71 | "plaintext": true, 72 | "pre": true, 73 | "script": true, 74 | "section": true, 75 | "select": true, 76 | "source": true, 77 | "style": true, 78 | "summary": true, 79 | "table": true, 80 | "tbody": true, 81 | "td": true, 82 | "template": true, 83 | "textarea": true, 84 | "tfoot": true, 85 | "th": true, 86 | "thead": true, 87 | "title": true, 88 | "tr": true, 89 | "track": true, 90 | "ul": true, 91 | "wbr": true, 92 | "xmp": true, 93 | } 94 | 95 | func isSpecialElement(element *Node) bool { 96 | switch element.Namespace { 97 | case "", "html": 98 | return isSpecialElementMap[element.Data] 99 | case "math": 100 | switch element.Data { 101 | case "mi", "mo", "mn", "ms", "mtext", "annotation-xml": 102 | return true 103 | } 104 | case "svg": 105 | switch element.Data { 106 | case "foreignObject", "desc", "title": 107 | return true 108 | } 109 | } 110 | return false 111 | } 112 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/asm_aix_ppc64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 12 | // 13 | 14 | TEXT ·syscall6(SB),NOSPLIT,$0-88 15 | JMP syscall·syscall6(SB) 16 | 17 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 18 | JMP syscall·rawSyscall6(SB) 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/byteorder.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu 6 | 7 | import ( 8 | "runtime" 9 | ) 10 | 11 | // byteOrder is a subset of encoding/binary.ByteOrder. 12 | type byteOrder interface { 13 | Uint32([]byte) uint32 14 | Uint64([]byte) uint64 15 | } 16 | 17 | type littleEndian struct{} 18 | type bigEndian struct{} 19 | 20 | func (littleEndian) Uint32(b []byte) uint32 { 21 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 22 | return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 23 | } 24 | 25 | func (littleEndian) Uint64(b []byte) uint64 { 26 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 27 | return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | 28 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 29 | } 30 | 31 | func (bigEndian) Uint32(b []byte) uint32 { 32 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 33 | return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 34 | } 35 | 36 | func (bigEndian) Uint64(b []byte) uint64 { 37 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 38 | return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | 39 | uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 40 | } 41 | 42 | // hostByteOrder returns littleEndian on little-endian machines and 43 | // bigEndian on big-endian machines. 44 | func hostByteOrder() byteOrder { 45 | switch runtime.GOARCH { 46 | case "386", "amd64", "amd64p32", 47 | "alpha", 48 | "arm", "arm64", 49 | "loong64", 50 | "mipsle", "mips64le", "mips64p32le", 51 | "nios2", 52 | "ppc64le", 53 | "riscv", "riscv64", 54 | "sh": 55 | return littleEndian{} 56 | case "armbe", "arm64be", 57 | "m68k", 58 | "mips", "mips64", "mips64p32", 59 | "ppc", "ppc64", 60 | "s390", "s390x", 61 | "shbe", 62 | "sparc", "sparc64": 63 | return bigEndian{} 64 | } 65 | panic("unknown architecture") 66 | } 67 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_aix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build aix 6 | // +build aix 7 | 8 | package cpu 9 | 10 | const ( 11 | // getsystemcfg constants 12 | _SC_IMPL = 2 13 | _IMPL_POWER8 = 0x10000 14 | _IMPL_POWER9 = 0x20000 15 | ) 16 | 17 | func archInit() { 18 | impl := getsystemcfg(_SC_IMPL) 19 | if impl&_IMPL_POWER8 != 0 { 20 | PPC64.IsPOWER8 = true 21 | } 22 | if impl&_IMPL_POWER9 != 0 { 23 | PPC64.IsPOWER8 = true 24 | PPC64.IsPOWER9 = true 25 | } 26 | 27 | Initialized = true 28 | } 29 | 30 | func getsystemcfg(label int) (n uint64) { 31 | r0, _ := callgetsystemcfg(label) 32 | n = uint64(r0) 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu 6 | 7 | const cacheLineSize = 32 8 | 9 | // HWCAP/HWCAP2 bits. 10 | // These are specific to Linux. 11 | const ( 12 | hwcap_SWP = 1 << 0 13 | hwcap_HALF = 1 << 1 14 | hwcap_THUMB = 1 << 2 15 | hwcap_26BIT = 1 << 3 16 | hwcap_FAST_MULT = 1 << 4 17 | hwcap_FPA = 1 << 5 18 | hwcap_VFP = 1 << 6 19 | hwcap_EDSP = 1 << 7 20 | hwcap_JAVA = 1 << 8 21 | hwcap_IWMMXT = 1 << 9 22 | hwcap_CRUNCH = 1 << 10 23 | hwcap_THUMBEE = 1 << 11 24 | hwcap_NEON = 1 << 12 25 | hwcap_VFPv3 = 1 << 13 26 | hwcap_VFPv3D16 = 1 << 14 27 | hwcap_TLS = 1 << 15 28 | hwcap_VFPv4 = 1 << 16 29 | hwcap_IDIVA = 1 << 17 30 | hwcap_IDIVT = 1 << 18 31 | hwcap_VFPD32 = 1 << 19 32 | hwcap_LPAE = 1 << 20 33 | hwcap_EVTSTRM = 1 << 21 34 | 35 | hwcap2_AES = 1 << 0 36 | hwcap2_PMULL = 1 << 1 37 | hwcap2_SHA1 = 1 << 2 38 | hwcap2_SHA2 = 1 << 3 39 | hwcap2_CRC32 = 1 << 4 40 | ) 41 | 42 | func initOptions() { 43 | options = []option{ 44 | {Name: "pmull", Feature: &ARM.HasPMULL}, 45 | {Name: "sha1", Feature: &ARM.HasSHA1}, 46 | {Name: "sha2", Feature: &ARM.HasSHA2}, 47 | {Name: "swp", Feature: &ARM.HasSWP}, 48 | {Name: "thumb", Feature: &ARM.HasTHUMB}, 49 | {Name: "thumbee", Feature: &ARM.HasTHUMBEE}, 50 | {Name: "tls", Feature: &ARM.HasTLS}, 51 | {Name: "vfp", Feature: &ARM.HasVFP}, 52 | {Name: "vfpd32", Feature: &ARM.HasVFPD32}, 53 | {Name: "vfpv3", Feature: &ARM.HasVFPv3}, 54 | {Name: "vfpv3d16", Feature: &ARM.HasVFPv3D16}, 55 | {Name: "vfpv4", Feature: &ARM.HasVFPv4}, 56 | {Name: "half", Feature: &ARM.HasHALF}, 57 | {Name: "26bit", Feature: &ARM.Has26BIT}, 58 | {Name: "fastmul", Feature: &ARM.HasFASTMUL}, 59 | {Name: "fpa", Feature: &ARM.HasFPA}, 60 | {Name: "edsp", Feature: &ARM.HasEDSP}, 61 | {Name: "java", Feature: &ARM.HasJAVA}, 62 | {Name: "iwmmxt", Feature: &ARM.HasIWMMXT}, 63 | {Name: "crunch", Feature: &ARM.HasCRUNCH}, 64 | {Name: "neon", Feature: &ARM.HasNEON}, 65 | {Name: "idivt", Feature: &ARM.HasIDIVT}, 66 | {Name: "idiva", Feature: &ARM.HasIDIVA}, 67 | {Name: "lpae", Feature: &ARM.HasLPAE}, 68 | {Name: "evtstrm", Feature: &ARM.HasEVTSTRM}, 69 | {Name: "aes", Feature: &ARM.HasAES}, 70 | {Name: "crc32", Feature: &ARM.HasCRC32}, 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // func getisar0() uint64 11 | TEXT ·getisar0(SB),NOSPLIT,$0-8 12 | // get Instruction Set Attributes 0 into x0 13 | // mrs x0, ID_AA64ISAR0_EL1 = d5380600 14 | WORD $0xd5380600 15 | MOVD R0, ret+0(FP) 16 | RET 17 | 18 | // func getisar1() uint64 19 | TEXT ·getisar1(SB),NOSPLIT,$0-8 20 | // get Instruction Set Attributes 1 into x0 21 | // mrs x0, ID_AA64ISAR1_EL1 = d5380620 22 | WORD $0xd5380620 23 | MOVD R0, ret+0(FP) 24 | RET 25 | 26 | // func getpfr0() uint64 27 | TEXT ·getpfr0(SB),NOSPLIT,$0-8 28 | // get Processor Feature Register 0 into x0 29 | // mrs x0, ID_AA64PFR0_EL1 = d5380400 30 | WORD $0xd5380400 31 | MOVD R0, ret+0(FP) 32 | RET 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | // +build gc 7 | 8 | package cpu 9 | 10 | func getisar0() uint64 11 | func getisar1() uint64 12 | func getpfr0() uint64 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | // +build gc 7 | 8 | package cpu 9 | 10 | // haveAsmFunctions reports whether the other functions in this file can 11 | // be safely called. 12 | func haveAsmFunctions() bool { return true } 13 | 14 | // The following feature detection functions are defined in cpu_s390x.s. 15 | // They are likely to be expensive to call so the results should be cached. 16 | func stfle() facilityList 17 | func kmQuery() queryResult 18 | func kmcQuery() queryResult 19 | func kmctrQuery() queryResult 20 | func kmaQuery() queryResult 21 | func kimdQuery() queryResult 22 | func klmdQuery() queryResult 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gc_x86.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (386 || amd64 || amd64p32) && gc 6 | // +build 386 amd64 amd64p32 7 | // +build gc 8 | 9 | package cpu 10 | 11 | // cpuid is implemented in cpu_x86.s for gc compiler 12 | // and in cpu_gccgo.c for gccgo. 13 | func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) 14 | 15 | // xgetbv with ecx = 0 is implemented in cpu_x86.s for gc compiler 16 | // and in cpu_gccgo.c for gccgo. 17 | func xgetbv() (eax, edx uint32) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gccgo 6 | // +build gccgo 7 | 8 | package cpu 9 | 10 | func getisar0() uint64 { return 0 } 11 | func getisar1() uint64 { return 0 } 12 | func getpfr0() uint64 { return 0 } 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gccgo 6 | // +build gccgo 7 | 8 | package cpu 9 | 10 | // haveAsmFunctions reports whether the other functions in this file can 11 | // be safely called. 12 | func haveAsmFunctions() bool { return false } 13 | 14 | // TODO(mundaym): the following feature detection functions are currently 15 | // stubs. See https://golang.org/cl/162887 for how to fix this. 16 | // They are likely to be expensive to call so the results should be cached. 17 | func stfle() facilityList { panic("not implemented for gccgo") } 18 | func kmQuery() queryResult { panic("not implemented for gccgo") } 19 | func kmcQuery() queryResult { panic("not implemented for gccgo") } 20 | func kmctrQuery() queryResult { panic("not implemented for gccgo") } 21 | func kmaQuery() queryResult { panic("not implemented for gccgo") } 22 | func kimdQuery() queryResult { panic("not implemented for gccgo") } 23 | func klmdQuery() queryResult { panic("not implemented for gccgo") } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (386 || amd64 || amd64p32) && gccgo 6 | // +build 386 amd64 amd64p32 7 | // +build gccgo 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | // Need to wrap __get_cpuid_count because it's declared as static. 14 | int 15 | gccgoGetCpuidCount(uint32_t leaf, uint32_t subleaf, 16 | uint32_t *eax, uint32_t *ebx, 17 | uint32_t *ecx, uint32_t *edx) 18 | { 19 | return __get_cpuid_count(leaf, subleaf, eax, ebx, ecx, edx); 20 | } 21 | 22 | #pragma GCC diagnostic ignored "-Wunknown-pragmas" 23 | #pragma GCC push_options 24 | #pragma GCC target("xsave") 25 | #pragma clang attribute push (__attribute__((target("xsave"))), apply_to=function) 26 | 27 | // xgetbv reads the contents of an XCR (Extended Control Register) 28 | // specified in the ECX register into registers EDX:EAX. 29 | // Currently, the only supported value for XCR is 0. 30 | void 31 | gccgoXgetbv(uint32_t *eax, uint32_t *edx) 32 | { 33 | uint64_t v = _xgetbv(0); 34 | *eax = v & 0xffffffff; 35 | *edx = v >> 32; 36 | } 37 | 38 | #pragma clang attribute pop 39 | #pragma GCC pop_options 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (386 || amd64 || amd64p32) && gccgo 6 | // +build 386 amd64 amd64p32 7 | // +build gccgo 8 | 9 | package cpu 10 | 11 | //extern gccgoGetCpuidCount 12 | func gccgoGetCpuidCount(eaxArg, ecxArg uint32, eax, ebx, ecx, edx *uint32) 13 | 14 | func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) { 15 | var a, b, c, d uint32 16 | gccgoGetCpuidCount(eaxArg, ecxArg, &a, &b, &c, &d) 17 | return a, b, c, d 18 | } 19 | 20 | //extern gccgoXgetbv 21 | func gccgoXgetbv(eax, edx *uint32) 22 | 23 | func xgetbv() (eax, edx uint32) { 24 | var a, d uint32 25 | gccgoXgetbv(&a, &d) 26 | return a, d 27 | } 28 | 29 | // gccgo doesn't build on Darwin, per: 30 | // https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/gcc.rb#L76 31 | func darwinSupportsAVX512() bool { 32 | return false 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !386 && !amd64 && !amd64p32 && !arm64 6 | // +build !386,!amd64,!amd64p32,!arm64 7 | 8 | package cpu 9 | 10 | func archInit() { 11 | if err := readHWCAP(); err != nil { 12 | return 13 | } 14 | doinit() 15 | Initialized = true 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_linux_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu 6 | 7 | func doinit() { 8 | ARM.HasSWP = isSet(hwCap, hwcap_SWP) 9 | ARM.HasHALF = isSet(hwCap, hwcap_HALF) 10 | ARM.HasTHUMB = isSet(hwCap, hwcap_THUMB) 11 | ARM.Has26BIT = isSet(hwCap, hwcap_26BIT) 12 | ARM.HasFASTMUL = isSet(hwCap, hwcap_FAST_MULT) 13 | ARM.HasFPA = isSet(hwCap, hwcap_FPA) 14 | ARM.HasVFP = isSet(hwCap, hwcap_VFP) 15 | ARM.HasEDSP = isSet(hwCap, hwcap_EDSP) 16 | ARM.HasJAVA = isSet(hwCap, hwcap_JAVA) 17 | ARM.HasIWMMXT = isSet(hwCap, hwcap_IWMMXT) 18 | ARM.HasCRUNCH = isSet(hwCap, hwcap_CRUNCH) 19 | ARM.HasTHUMBEE = isSet(hwCap, hwcap_THUMBEE) 20 | ARM.HasNEON = isSet(hwCap, hwcap_NEON) 21 | ARM.HasVFPv3 = isSet(hwCap, hwcap_VFPv3) 22 | ARM.HasVFPv3D16 = isSet(hwCap, hwcap_VFPv3D16) 23 | ARM.HasTLS = isSet(hwCap, hwcap_TLS) 24 | ARM.HasVFPv4 = isSet(hwCap, hwcap_VFPv4) 25 | ARM.HasIDIVA = isSet(hwCap, hwcap_IDIVA) 26 | ARM.HasIDIVT = isSet(hwCap, hwcap_IDIVT) 27 | ARM.HasVFPD32 = isSet(hwCap, hwcap_VFPD32) 28 | ARM.HasLPAE = isSet(hwCap, hwcap_LPAE) 29 | ARM.HasEVTSTRM = isSet(hwCap, hwcap_EVTSTRM) 30 | ARM.HasAES = isSet(hwCap2, hwcap2_AES) 31 | ARM.HasPMULL = isSet(hwCap2, hwcap2_PMULL) 32 | ARM.HasSHA1 = isSet(hwCap2, hwcap2_SHA1) 33 | ARM.HasSHA2 = isSet(hwCap2, hwcap2_SHA2) 34 | ARM.HasCRC32 = isSet(hwCap2, hwcap2_CRC32) 35 | } 36 | 37 | func isSet(hwc uint, value uint) bool { 38 | return hwc&value != 0 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (mips64 || mips64le) 6 | // +build linux 7 | // +build mips64 mips64le 8 | 9 | package cpu 10 | 11 | // HWCAP bits. These are exposed by the Linux kernel 5.4. 12 | const ( 13 | // CPU features 14 | hwcap_MIPS_MSA = 1 << 1 15 | ) 16 | 17 | func doinit() { 18 | // HWCAP feature bits 19 | MIPS64X.HasMSA = isSet(hwCap, hwcap_MIPS_MSA) 20 | } 21 | 22 | func isSet(hwc uint, value uint) bool { 23 | return hwc&value != 0 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x 6 | // +build linux,!arm,!arm64,!mips64,!mips64le,!ppc64,!ppc64le,!s390x 7 | 8 | package cpu 9 | 10 | func doinit() {} 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && (ppc64 || ppc64le) 6 | // +build linux 7 | // +build ppc64 ppc64le 8 | 9 | package cpu 10 | 11 | // HWCAP/HWCAP2 bits. These are exposed by the kernel. 12 | const ( 13 | // ISA Level 14 | _PPC_FEATURE2_ARCH_2_07 = 0x80000000 15 | _PPC_FEATURE2_ARCH_3_00 = 0x00800000 16 | 17 | // CPU features 18 | _PPC_FEATURE2_DARN = 0x00200000 19 | _PPC_FEATURE2_SCV = 0x00100000 20 | ) 21 | 22 | func doinit() { 23 | // HWCAP2 feature bits 24 | PPC64.IsPOWER8 = isSet(hwCap2, _PPC_FEATURE2_ARCH_2_07) 25 | PPC64.IsPOWER9 = isSet(hwCap2, _PPC_FEATURE2_ARCH_3_00) 26 | PPC64.HasDARN = isSet(hwCap2, _PPC_FEATURE2_DARN) 27 | PPC64.HasSCV = isSet(hwCap2, _PPC_FEATURE2_SCV) 28 | } 29 | 30 | func isSet(hwc uint, value uint) bool { 31 | return hwc&value != 0 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu 6 | 7 | const ( 8 | // bit mask values from /usr/include/bits/hwcap.h 9 | hwcap_ZARCH = 2 10 | hwcap_STFLE = 4 11 | hwcap_MSA = 8 12 | hwcap_LDISP = 16 13 | hwcap_EIMM = 32 14 | hwcap_DFP = 64 15 | hwcap_ETF3EH = 256 16 | hwcap_VX = 2048 17 | hwcap_VXE = 8192 18 | ) 19 | 20 | func initS390Xbase() { 21 | // test HWCAP bit vector 22 | has := func(featureMask uint) bool { 23 | return hwCap&featureMask == featureMask 24 | } 25 | 26 | // mandatory 27 | S390X.HasZARCH = has(hwcap_ZARCH) 28 | 29 | // optional 30 | S390X.HasSTFLE = has(hwcap_STFLE) 31 | S390X.HasLDISP = has(hwcap_LDISP) 32 | S390X.HasEIMM = has(hwcap_EIMM) 33 | S390X.HasETF3EH = has(hwcap_ETF3EH) 34 | S390X.HasDFP = has(hwcap_DFP) 35 | S390X.HasMSA = has(hwcap_MSA) 36 | S390X.HasVX = has(hwcap_VX) 37 | if S390X.HasVX { 38 | S390X.HasVXE = has(hwcap_VXE) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_loong64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build loong64 6 | // +build loong64 7 | 8 | package cpu 9 | 10 | const cacheLineSize = 64 11 | 12 | func initOptions() { 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_mips64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build mips64 || mips64le 6 | // +build mips64 mips64le 7 | 8 | package cpu 9 | 10 | const cacheLineSize = 32 11 | 12 | func initOptions() { 13 | options = []option{ 14 | {Name: "msa", Feature: &MIPS64X.HasMSA}, 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_mipsx.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build mips || mipsle 6 | // +build mips mipsle 7 | 8 | package cpu 9 | 10 | const cacheLineSize = 32 11 | 12 | func initOptions() {} 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | // Minimal copy of functionality from x/sys/unix so the cpu package can call 13 | // sysctl without depending on x/sys/unix. 14 | 15 | const ( 16 | // From OpenBSD's sys/sysctl.h. 17 | _CTL_MACHDEP = 7 18 | 19 | // From OpenBSD's machine/cpu.h. 20 | _CPU_ID_AA64ISAR0 = 2 21 | _CPU_ID_AA64ISAR1 = 3 22 | ) 23 | 24 | // Implemented in the runtime package (runtime/sys_openbsd3.go) 25 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 26 | 27 | //go:linkname syscall_syscall6 syscall.syscall6 28 | 29 | func sysctl(mib []uint32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { 30 | _, _, errno := syscall_syscall6(libc_sysctl_trampoline_addr, uintptr(unsafe.Pointer(&mib[0])), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) 31 | if errno != 0 { 32 | return errno 33 | } 34 | return nil 35 | } 36 | 37 | var libc_sysctl_trampoline_addr uintptr 38 | 39 | //go:cgo_import_dynamic libc_sysctl sysctl "libc.so" 40 | 41 | func sysctlUint64(mib []uint32) (uint64, bool) { 42 | var out uint64 43 | nout := unsafe.Sizeof(out) 44 | if err := sysctl(mib, (*byte)(unsafe.Pointer(&out)), &nout, nil, 0); err != nil { 45 | return 0, false 46 | } 47 | return out, true 48 | } 49 | 50 | func doinit() { 51 | setMinimalFeatures() 52 | 53 | // Get ID_AA64ISAR0 and ID_AA64ISAR1 from sysctl. 54 | isar0, ok := sysctlUint64([]uint32{_CTL_MACHDEP, _CPU_ID_AA64ISAR0}) 55 | if !ok { 56 | return 57 | } 58 | isar1, ok := sysctlUint64([]uint32{_CTL_MACHDEP, _CPU_ID_AA64ISAR1}) 59 | if !ok { 60 | return 61 | } 62 | parseARM64SystemRegisters(isar0, isar1, 0) 63 | 64 | Initialized = true 65 | } 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 8 | JMP libc_sysctl(SB) 9 | 10 | GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 11 | DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB) 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_other_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !linux && arm 6 | // +build !linux,arm 7 | 8 | package cpu 9 | 10 | func archInit() {} 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_other_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !linux && !netbsd && !openbsd && arm64 6 | // +build !linux,!netbsd,!openbsd,arm64 7 | 8 | package cpu 9 | 10 | func doinit() {} 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_other_mips64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !linux && (mips64 || mips64le) 6 | // +build !linux 7 | // +build mips64 mips64le 8 | 9 | package cpu 10 | 11 | func archInit() { 12 | Initialized = true 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !aix && !linux && (ppc64 || ppc64le) 6 | // +build !aix 7 | // +build !linux 8 | // +build ppc64 ppc64le 9 | 10 | package cpu 11 | 12 | func archInit() { 13 | PPC64.IsPOWER8 = true 14 | Initialized = true 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_other_riscv64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build !linux && riscv64 6 | // +build !linux,riscv64 7 | 8 | package cpu 9 | 10 | func archInit() { 11 | Initialized = true 12 | } 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build ppc64 || ppc64le 6 | // +build ppc64 ppc64le 7 | 8 | package cpu 9 | 10 | const cacheLineSize = 128 11 | 12 | func initOptions() { 13 | options = []option{ 14 | {Name: "darn", Feature: &PPC64.HasDARN}, 15 | {Name: "scv", Feature: &PPC64.HasSCV}, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_riscv64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build riscv64 6 | // +build riscv64 7 | 8 | package cpu 9 | 10 | const cacheLineSize = 32 11 | 12 | func initOptions() {} 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // func stfle() facilityList 11 | TEXT ·stfle(SB), NOSPLIT|NOFRAME, $0-32 12 | MOVD $ret+0(FP), R1 13 | MOVD $3, R0 // last doubleword index to store 14 | XC $32, (R1), (R1) // clear 4 doublewords (32 bytes) 15 | WORD $0xb2b01000 // store facility list extended (STFLE) 16 | RET 17 | 18 | // func kmQuery() queryResult 19 | TEXT ·kmQuery(SB), NOSPLIT|NOFRAME, $0-16 20 | MOVD $0, R0 // set function code to 0 (KM-Query) 21 | MOVD $ret+0(FP), R1 // address of 16-byte return value 22 | WORD $0xB92E0024 // cipher message (KM) 23 | RET 24 | 25 | // func kmcQuery() queryResult 26 | TEXT ·kmcQuery(SB), NOSPLIT|NOFRAME, $0-16 27 | MOVD $0, R0 // set function code to 0 (KMC-Query) 28 | MOVD $ret+0(FP), R1 // address of 16-byte return value 29 | WORD $0xB92F0024 // cipher message with chaining (KMC) 30 | RET 31 | 32 | // func kmctrQuery() queryResult 33 | TEXT ·kmctrQuery(SB), NOSPLIT|NOFRAME, $0-16 34 | MOVD $0, R0 // set function code to 0 (KMCTR-Query) 35 | MOVD $ret+0(FP), R1 // address of 16-byte return value 36 | WORD $0xB92D4024 // cipher message with counter (KMCTR) 37 | RET 38 | 39 | // func kmaQuery() queryResult 40 | TEXT ·kmaQuery(SB), NOSPLIT|NOFRAME, $0-16 41 | MOVD $0, R0 // set function code to 0 (KMA-Query) 42 | MOVD $ret+0(FP), R1 // address of 16-byte return value 43 | WORD $0xb9296024 // cipher message with authentication (KMA) 44 | RET 45 | 46 | // func kimdQuery() queryResult 47 | TEXT ·kimdQuery(SB), NOSPLIT|NOFRAME, $0-16 48 | MOVD $0, R0 // set function code to 0 (KIMD-Query) 49 | MOVD $ret+0(FP), R1 // address of 16-byte return value 50 | WORD $0xB93E0024 // compute intermediate message digest (KIMD) 51 | RET 52 | 53 | // func klmdQuery() queryResult 54 | TEXT ·klmdQuery(SB), NOSPLIT|NOFRAME, $0-16 55 | MOVD $0, R0 // set function code to 0 (KLMD-Query) 56 | MOVD $ret+0(FP), R1 // address of 16-byte return value 57 | WORD $0xB93F0024 // compute last message digest (KLMD) 58 | RET 59 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_wasm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build wasm 6 | // +build wasm 7 | 8 | package cpu 9 | 10 | // We're compiling the cpu package for an unknown (software-abstracted) CPU. 11 | // Make CacheLinePad an empty struct and hope that the usual struct alignment 12 | // rules are good enough. 13 | 14 | const cacheLineSize = 0 15 | 16 | func initOptions() {} 17 | 18 | func archInit() {} 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_x86.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build (386 || amd64 || amd64p32) && gc 6 | // +build 386 amd64 amd64p32 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) 12 | TEXT ·cpuid(SB), NOSPLIT, $0-24 13 | MOVL eaxArg+0(FP), AX 14 | MOVL ecxArg+4(FP), CX 15 | CPUID 16 | MOVL AX, eax+8(FP) 17 | MOVL BX, ebx+12(FP) 18 | MOVL CX, ecx+16(FP) 19 | MOVL DX, edx+20(FP) 20 | RET 21 | 22 | // func xgetbv() (eax, edx uint32) 23 | TEXT ·xgetbv(SB),NOSPLIT,$0-8 24 | MOVL $0, CX 25 | XGETBV 26 | MOVL AX, eax+0(FP) 27 | MOVL DX, edx+4(FP) 28 | RET 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_zos.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu 6 | 7 | func archInit() { 8 | doinit() 9 | Initialized = true 10 | } 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_zos_s390x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu 6 | 7 | func initS390Xbase() { 8 | // get the facilities list 9 | facilities := stfle() 10 | 11 | // mandatory 12 | S390X.HasZARCH = facilities.Has(zarch) 13 | S390X.HasSTFLE = facilities.Has(stflef) 14 | S390X.HasLDISP = facilities.Has(ldisp) 15 | S390X.HasEIMM = facilities.Has(eimm) 16 | 17 | // optional 18 | S390X.HasETF3EH = facilities.Has(etf3eh) 19 | S390X.HasDFP = facilities.Has(dfp) 20 | S390X.HasMSA = facilities.Has(msa) 21 | S390X.HasVX = facilities.Has(vx) 22 | if S390X.HasVX { 23 | S390X.HasVXE = facilities.Has(vxe) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64 6 | // +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64 7 | 8 | package cpu 9 | 10 | // IsBigEndian records whether the GOARCH's byte order is big endian. 11 | const IsBigEndian = true 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh 6 | // +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh 7 | 8 | package cpu 9 | 10 | // IsBigEndian records whether the GOARCH's byte order is big endian. 11 | const IsBigEndian = false 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/hwcap_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu 6 | 7 | import ( 8 | "io/ioutil" 9 | ) 10 | 11 | const ( 12 | _AT_HWCAP = 16 13 | _AT_HWCAP2 = 26 14 | 15 | procAuxv = "/proc/self/auxv" 16 | 17 | uintSize = int(32 << (^uint(0) >> 63)) 18 | ) 19 | 20 | // For those platforms don't have a 'cpuid' equivalent we use HWCAP/HWCAP2 21 | // These are initialized in cpu_$GOARCH.go 22 | // and should not be changed after they are initialized. 23 | var hwCap uint 24 | var hwCap2 uint 25 | 26 | func readHWCAP() error { 27 | buf, err := ioutil.ReadFile(procAuxv) 28 | if err != nil { 29 | // e.g. on android /proc/self/auxv is not accessible, so silently 30 | // ignore the error and leave Initialized = false. On some 31 | // architectures (e.g. arm64) doinit() implements a fallback 32 | // readout and will set Initialized = true again. 33 | return err 34 | } 35 | bo := hostByteOrder() 36 | for len(buf) >= 2*(uintSize/8) { 37 | var tag, val uint 38 | switch uintSize { 39 | case 32: 40 | tag = uint(bo.Uint32(buf[0:])) 41 | val = uint(bo.Uint32(buf[4:])) 42 | buf = buf[8:] 43 | case 64: 44 | tag = uint(bo.Uint64(buf[0:])) 45 | val = uint(bo.Uint64(buf[8:])) 46 | buf = buf[16:] 47 | } 48 | switch tag { 49 | case _AT_HWCAP: 50 | hwCap = val 51 | case _AT_HWCAP2: 52 | hwCap2 = val 53 | } 54 | } 55 | return nil 56 | } 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/parse.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cpu 6 | 7 | import "strconv" 8 | 9 | // parseRelease parses a dot-separated version number. It follows the semver 10 | // syntax, but allows the minor and patch versions to be elided. 11 | // 12 | // This is a copy of the Go runtime's parseRelease from 13 | // https://golang.org/cl/209597. 14 | func parseRelease(rel string) (major, minor, patch int, ok bool) { 15 | // Strip anything after a dash or plus. 16 | for i := 0; i < len(rel); i++ { 17 | if rel[i] == '-' || rel[i] == '+' { 18 | rel = rel[:i] 19 | break 20 | } 21 | } 22 | 23 | next := func() (int, bool) { 24 | for i := 0; i < len(rel); i++ { 25 | if rel[i] == '.' { 26 | ver, err := strconv.Atoi(rel[:i]) 27 | rel = rel[i+1:] 28 | return ver, err == nil 29 | } 30 | } 31 | ver, err := strconv.Atoi(rel) 32 | rel = "" 33 | return ver, err == nil 34 | } 35 | if major, ok = next(); !ok || rel == "" { 36 | return 37 | } 38 | if minor, ok = next(); !ok || rel == "" { 39 | return 40 | } 41 | patch, ok = next() 42 | return 43 | } 44 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build linux && arm64 6 | // +build linux,arm64 7 | 8 | package cpu 9 | 10 | import ( 11 | "errors" 12 | "io" 13 | "os" 14 | "strings" 15 | ) 16 | 17 | func readLinuxProcCPUInfo() error { 18 | f, err := os.Open("/proc/cpuinfo") 19 | if err != nil { 20 | return err 21 | } 22 | defer f.Close() 23 | 24 | var buf [1 << 10]byte // enough for first CPU 25 | n, err := io.ReadFull(f, buf[:]) 26 | if err != nil && err != io.ErrUnexpectedEOF { 27 | return err 28 | } 29 | in := string(buf[:n]) 30 | const features = "\nFeatures : " 31 | i := strings.Index(in, features) 32 | if i == -1 { 33 | return errors.New("no CPU features found") 34 | } 35 | in = in[i+len(features):] 36 | if i := strings.Index(in, "\n"); i != -1 { 37 | in = in[:i] 38 | } 39 | m := map[string]*bool{} 40 | 41 | initOptions() // need it early here; it's harmless to call twice 42 | for _, o := range options { 43 | m[o.Name] = o.Feature 44 | } 45 | // The EVTSTRM field has alias "evstrm" in Go, but Linux calls it "evtstrm". 46 | m["evtstrm"] = &ARM64.HasEVTSTRM 47 | 48 | for _, f := range strings.Fields(in) { 49 | if p, ok := m[f]; ok { 50 | *p = true 51 | } 52 | } 53 | return nil 54 | } 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Recreate a getsystemcfg syscall handler instead of 6 | // using the one provided by x/sys/unix to avoid having 7 | // the dependency between them. (See golang.org/issue/32102) 8 | // Moreover, this file will be used during the building of 9 | // gccgo's libgo and thus must not used a CGo method. 10 | 11 | //go:build aix && gccgo 12 | // +build aix,gccgo 13 | 14 | package cpu 15 | 16 | import ( 17 | "syscall" 18 | ) 19 | 20 | //extern getsystemcfg 21 | func gccgoGetsystemcfg(label uint32) (r uint64) 22 | 23 | func callgetsystemcfg(label int) (r1 uintptr, e1 syscall.Errno) { 24 | r1 = uintptr(gccgoGetsystemcfg(uint32(label))) 25 | e1 = syscall.GetErrno() 26 | return 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Minimal copy of x/sys/unix so the cpu package can make a 6 | // system call on AIX without depending on x/sys/unix. 7 | // (See golang.org/issue/32102) 8 | 9 | //go:build aix && ppc64 && gc 10 | // +build aix,ppc64,gc 11 | 12 | package cpu 13 | 14 | import ( 15 | "syscall" 16 | "unsafe" 17 | ) 18 | 19 | //go:cgo_import_dynamic libc_getsystemcfg getsystemcfg "libc.a/shr_64.o" 20 | 21 | //go:linkname libc_getsystemcfg libc_getsystemcfg 22 | 23 | type syscallFunc uintptr 24 | 25 | var libc_getsystemcfg syscallFunc 26 | 27 | type errno = syscall.Errno 28 | 29 | // Implemented in runtime/syscall_aix.go. 30 | func rawSyscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err errno) 31 | func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err errno) 32 | 33 | func callgetsystemcfg(label int) (r1 uintptr, e1 errno) { 34 | r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getsystemcfg)), 1, uintptr(label), 0, 0, 0, 0, 0) 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/cases/fold.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cases 6 | 7 | import "golang.org/x/text/transform" 8 | 9 | type caseFolder struct{ transform.NopResetter } 10 | 11 | // caseFolder implements the Transformer interface for doing case folding. 12 | func (t *caseFolder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { 13 | c := context{dst: dst, src: src, atEOF: atEOF} 14 | for c.next() { 15 | foldFull(&c) 16 | c.checkpoint() 17 | } 18 | return c.ret() 19 | } 20 | 21 | func (t *caseFolder) Span(src []byte, atEOF bool) (n int, err error) { 22 | c := context{src: src, atEOF: atEOF} 23 | for c.next() && isFoldFull(&c) { 24 | c.checkpoint() 25 | } 26 | return c.retSpan() 27 | } 28 | 29 | func makeFold(o options) transform.SpanningTransformer { 30 | // TODO: Special case folding, through option Language, Special/Turkic, or 31 | // both. 32 | // TODO: Implement Compact options. 33 | return &caseFolder{} 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/cases/icu.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build icu 6 | // +build icu 7 | 8 | package cases 9 | 10 | // Ideally these functions would be defined in a test file, but go test doesn't 11 | // allow CGO in tests. The build tag should ensure either way that these 12 | // functions will not end up in the package. 13 | 14 | // TODO: Ensure that the correct ICU version is set. 15 | 16 | /* 17 | #cgo LDFLAGS: -licui18n.57 -licuuc.57 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | */ 24 | import "C" 25 | 26 | import "unsafe" 27 | 28 | func doICU(tag, caser, input string) string { 29 | err := C.UErrorCode(0) 30 | loc := C.CString(tag) 31 | cm := C.ucasemap_open(loc, C.uint32_t(0), &err) 32 | 33 | buf := make([]byte, len(input)*4) 34 | dst := (*C.char)(unsafe.Pointer(&buf[0])) 35 | src := C.CString(input) 36 | 37 | cn := C.int32_t(0) 38 | 39 | switch caser { 40 | case "fold": 41 | cn = C.ucasemap_utf8FoldCase(cm, 42 | dst, C.int32_t(len(buf)), 43 | src, C.int32_t(len(input)), 44 | &err) 45 | case "lower": 46 | cn = C.ucasemap_utf8ToLower(cm, 47 | dst, C.int32_t(len(buf)), 48 | src, C.int32_t(len(input)), 49 | &err) 50 | case "upper": 51 | cn = C.ucasemap_utf8ToUpper(cm, 52 | dst, C.int32_t(len(buf)), 53 | src, C.int32_t(len(input)), 54 | &err) 55 | case "title": 56 | cn = C.ucasemap_utf8ToTitle(cm, 57 | dst, C.int32_t(len(buf)), 58 | src, C.int32_t(len(input)), 59 | &err) 60 | } 61 | return string(buf[:cn]) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/cases/info.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cases 6 | 7 | func (c info) cccVal() info { 8 | if c&exceptionBit != 0 { 9 | return info(exceptions[c>>exceptionShift]) & cccMask 10 | } 11 | return c & cccMask 12 | } 13 | 14 | func (c info) cccType() info { 15 | ccc := c.cccVal() 16 | if ccc <= cccZero { 17 | return cccZero 18 | } 19 | return ccc 20 | } 21 | 22 | // TODO: Implement full Unicode breaking algorithm: 23 | // 1) Implement breaking in separate package. 24 | // 2) Use the breaker here. 25 | // 3) Compare table size and performance of using the more generic breaker. 26 | // 27 | // Note that we can extend the current algorithm to be much more accurate. This 28 | // only makes sense, though, if the performance and/or space penalty of using 29 | // the generic breaker is big. Extra data will only be needed for non-cased 30 | // runes, which means there are sufficient bits left in the caseType. 31 | // ICU prohibits breaking in such cases as well. 32 | 33 | // For the purpose of title casing we use an approximation of the Unicode Word 34 | // Breaking algorithm defined in Annex #29: 35 | // https://www.unicode.org/reports/tr29/#Default_Grapheme_Cluster_Table. 36 | // 37 | // For our approximation, we group the Word Break types into the following 38 | // categories, with associated rules: 39 | // 40 | // 1) Letter: 41 | // ALetter, Hebrew_Letter, Numeric, ExtendNumLet, Extend, Format_FE, ZWJ. 42 | // Rule: Never break between consecutive runes of this category. 43 | // 44 | // 2) Mid: 45 | // MidLetter, MidNumLet, Single_Quote. 46 | // (Cf. case-ignorable: MidLetter, MidNumLet, Single_Quote or cat is Mn, 47 | // Me, Cf, Lm or Sk). 48 | // Rule: Don't break between Letter and Mid, but break between two Mids. 49 | // 50 | // 3) Break: 51 | // Any other category: NewLine, MidNum, CR, LF, Double_Quote, Katakana, and 52 | // Other. 53 | // These categories should always result in a break between two cased letters. 54 | // Rule: Always break. 55 | // 56 | // Note 1: the Katakana and MidNum categories can, in esoteric cases, result in 57 | // preventing a break between two cased letters. For now we will ignore this 58 | // (e.g. [ALetter] [ExtendNumLet] [Katakana] [ExtendNumLet] [ALetter] and 59 | // [ALetter] [Numeric] [MidNum] [Numeric] [ALetter].) 60 | // 61 | // Note 2: the rule for Mid is very approximate, but works in most cases. To 62 | // improve, we could store the categories in the trie value and use a FA to 63 | // manage breaks. See TODO comment above. 64 | // 65 | // Note 3: according to the spec, it is possible for the Extend category to 66 | // introduce breaks between other categories grouped in Letter. However, this 67 | // is undesirable for our purposes. ICU prevents breaks in such cases as well. 68 | 69 | // isBreak returns whether this rune should introduce a break. 70 | func (c info) isBreak() bool { 71 | return c.cccVal() == cccBreak 72 | } 73 | 74 | // isLetter returns whether the rune is of break type ALetter, Hebrew_Letter, 75 | // Numeric, ExtendNumLet, or Extend. 76 | func (c info) isLetter() bool { 77 | ccc := c.cccVal() 78 | if ccc == cccZero { 79 | return !c.isCaseIgnorable() 80 | } 81 | return ccc != cccBreak 82 | } 83 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/collate/index.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package collate 6 | 7 | import "golang.org/x/text/internal/colltab" 8 | 9 | const blockSize = 64 10 | 11 | func getTable(t tableIndex) *colltab.Table { 12 | return &colltab.Table{ 13 | Index: colltab.Trie{ 14 | Index0: mainLookup[:][blockSize*t.lookupOffset:], 15 | Values0: mainValues[:][blockSize*t.valuesOffset:], 16 | Index: mainLookup[:], 17 | Values: mainValues[:], 18 | }, 19 | ExpandElem: mainExpandElem[:], 20 | ContractTries: colltab.ContractTrieSet(mainCTEntries[:]), 21 | ContractElem: mainContractElem[:], 22 | MaxContractLen: 18, 23 | VariableTop: varTop, 24 | } 25 | } 26 | 27 | // tableIndex holds information for constructing a table 28 | // for a certain locale based on the main table. 29 | type tableIndex struct { 30 | lookupOffset uint32 31 | valuesOffset uint32 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/collate/sort.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package collate 6 | 7 | import ( 8 | "bytes" 9 | "sort" 10 | ) 11 | 12 | const ( 13 | maxSortBuffer = 40960 14 | maxSortEntries = 4096 15 | ) 16 | 17 | type swapper interface { 18 | Swap(i, j int) 19 | } 20 | 21 | type sorter struct { 22 | buf *Buffer 23 | keys [][]byte 24 | src swapper 25 | } 26 | 27 | func (s *sorter) init(n int) { 28 | if s.buf == nil { 29 | s.buf = &Buffer{} 30 | s.buf.init() 31 | } 32 | if cap(s.keys) < n { 33 | s.keys = make([][]byte, n) 34 | } 35 | s.keys = s.keys[0:n] 36 | } 37 | 38 | func (s *sorter) sort(src swapper) { 39 | s.src = src 40 | sort.Sort(s) 41 | } 42 | 43 | func (s sorter) Len() int { 44 | return len(s.keys) 45 | } 46 | 47 | func (s sorter) Less(i, j int) bool { 48 | return bytes.Compare(s.keys[i], s.keys[j]) == -1 49 | } 50 | 51 | func (s sorter) Swap(i, j int) { 52 | s.keys[i], s.keys[j] = s.keys[j], s.keys[i] 53 | s.src.Swap(i, j) 54 | } 55 | 56 | // A Lister can be sorted by Collator's Sort method. 57 | type Lister interface { 58 | Len() int 59 | Swap(i, j int) 60 | // Bytes returns the bytes of the text at index i. 61 | Bytes(i int) []byte 62 | } 63 | 64 | // Sort uses sort.Sort to sort the strings represented by x using the rules of c. 65 | func (c *Collator) Sort(x Lister) { 66 | n := x.Len() 67 | c.sorter.init(n) 68 | for i := 0; i < n; i++ { 69 | c.sorter.keys[i] = c.Key(c.sorter.buf, x.Bytes(i)) 70 | } 71 | c.sorter.sort(x) 72 | } 73 | 74 | // SortStrings uses sort.Sort to sort the strings in x using the rules of c. 75 | func (c *Collator) SortStrings(x []string) { 76 | c.sorter.init(len(x)) 77 | for i, s := range x { 78 | c.sorter.keys[i] = c.KeyFromString(c.sorter.buf, s) 79 | } 80 | c.sorter.sort(sort.StringSlice(x)) 81 | } 82 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/colltab/weighter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package colltab // import "golang.org/x/text/internal/colltab" 6 | 7 | // A Weighter can be used as a source for Collator and Searcher. 8 | type Weighter interface { 9 | // Start finds the start of the segment that includes position p. 10 | Start(p int, b []byte) int 11 | 12 | // StartString finds the start of the segment that includes position p. 13 | StartString(p int, s string) int 14 | 15 | // AppendNext appends Elems to buf corresponding to the longest match 16 | // of a single character or contraction from the start of s. 17 | // It returns the new buf and the number of bytes consumed. 18 | AppendNext(buf []Elem, s []byte) (ce []Elem, n int) 19 | 20 | // AppendNextString appends Elems to buf corresponding to the longest match 21 | // of a single character or contraction from the start of s. 22 | // It returns the new buf and the number of bytes consumed. 23 | AppendNextString(buf []Elem, s string) (ce []Elem, n int) 24 | 25 | // Domain returns a slice of all single characters and contractions for which 26 | // collation elements are defined in this table. 27 | Domain() []string 28 | 29 | // Top returns the highest variable primary value. 30 | Top() uint32 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package internal contains non-exported functionality that are used by 6 | // packages in the text repository. 7 | package internal // import "golang.org/x/text/internal" 8 | 9 | import ( 10 | "sort" 11 | 12 | "golang.org/x/text/language" 13 | ) 14 | 15 | // SortTags sorts tags in place. 16 | func SortTags(tags []language.Tag) { 17 | sort.Sort(sorter(tags)) 18 | } 19 | 20 | type sorter []language.Tag 21 | 22 | func (s sorter) Len() int { 23 | return len(s) 24 | } 25 | 26 | func (s sorter) Swap(i, j int) { 27 | s[i], s[j] = s[j], s[i] 28 | } 29 | 30 | func (s sorter) Less(i, j int) bool { 31 | return s[i].String() < s[j].String() 32 | } 33 | 34 | // UniqueTags sorts and filters duplicate tags in place and returns a slice with 35 | // only unique tags. 36 | func UniqueTags(tags []language.Tag) []language.Tag { 37 | if len(tags) <= 1 { 38 | return tags 39 | } 40 | SortTags(tags) 41 | k := 0 42 | for i := 1; i < len(tags); i++ { 43 | if tags[k].String() < tags[i].String() { 44 | k++ 45 | tags[k] = tags[i] 46 | } 47 | } 48 | return tags[:k+1] 49 | } 50 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/language/common.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package language 4 | 5 | // This file contains code common to the maketables.go and the package code. 6 | 7 | // AliasType is the type of an alias in AliasMap. 8 | type AliasType int8 9 | 10 | const ( 11 | Deprecated AliasType = iota 12 | Macro 13 | Legacy 14 | 15 | AliasTypeUnknown AliasType = -1 16 | ) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/language/compact.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package language 6 | 7 | // CompactCoreInfo is a compact integer with the three core tags encoded. 8 | type CompactCoreInfo uint32 9 | 10 | // GetCompactCore generates a uint32 value that is guaranteed to be unique for 11 | // different language, region, and script values. 12 | func GetCompactCore(t Tag) (cci CompactCoreInfo, ok bool) { 13 | if t.LangID > langNoIndexOffset { 14 | return 0, false 15 | } 16 | cci |= CompactCoreInfo(t.LangID) << (8 + 12) 17 | cci |= CompactCoreInfo(t.ScriptID) << 12 18 | cci |= CompactCoreInfo(t.RegionID) 19 | return cci, true 20 | } 21 | 22 | // Tag generates a tag from c. 23 | func (c CompactCoreInfo) Tag() Tag { 24 | return Tag{ 25 | LangID: Language(c >> 20), 26 | RegionID: Region(c & 0x3ff), 27 | ScriptID: Script(c>>12) & 0xff, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/language/compact/compact.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package compact defines a compact representation of language tags. 6 | // 7 | // Common language tags (at least all for which locale information is defined 8 | // in CLDR) are assigned a unique index. Each Tag is associated with such an 9 | // ID for selecting language-related resources (such as translations) as well 10 | // as one for selecting regional defaults (currency, number formatting, etc.) 11 | // 12 | // It may want to export this functionality at some point, but at this point 13 | // this is only available for use within x/text. 14 | package compact // import "golang.org/x/text/internal/language/compact" 15 | 16 | import ( 17 | "sort" 18 | "strings" 19 | 20 | "golang.org/x/text/internal/language" 21 | ) 22 | 23 | // ID is an integer identifying a single tag. 24 | type ID uint16 25 | 26 | func getCoreIndex(t language.Tag) (id ID, ok bool) { 27 | cci, ok := language.GetCompactCore(t) 28 | if !ok { 29 | return 0, false 30 | } 31 | i := sort.Search(len(coreTags), func(i int) bool { 32 | return cci <= coreTags[i] 33 | }) 34 | if i == len(coreTags) || coreTags[i] != cci { 35 | return 0, false 36 | } 37 | return ID(i), true 38 | } 39 | 40 | // Parent returns the ID of the parent or the root ID if id is already the root. 41 | func (id ID) Parent() ID { 42 | return parents[id] 43 | } 44 | 45 | // Tag converts id to an internal language Tag. 46 | func (id ID) Tag() language.Tag { 47 | if int(id) >= len(coreTags) { 48 | return specialTags[int(id)-len(coreTags)] 49 | } 50 | return coreTags[id].Tag() 51 | } 52 | 53 | var specialTags []language.Tag 54 | 55 | func init() { 56 | tags := strings.Split(specialTagsStr, " ") 57 | specialTags = make([]language.Tag, len(tags)) 58 | for i, t := range tags { 59 | specialTags[i] = language.MustParse(t) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/language/coverage.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package language 6 | 7 | // BaseLanguages returns the list of all supported base languages. It generates 8 | // the list by traversing the internal structures. 9 | func BaseLanguages() []Language { 10 | base := make([]Language, 0, NumLanguages) 11 | for i := 0; i < langNoIndexOffset; i++ { 12 | // We included "und" already for the value 0. 13 | if i != nonCanonicalUnd { 14 | base = append(base, Language(i)) 15 | } 16 | } 17 | i := langNoIndexOffset 18 | for _, v := range langNoIndex { 19 | for k := 0; k < 8; k++ { 20 | if v&1 == 1 { 21 | base = append(base, Language(i)) 22 | } 23 | v >>= 1 24 | i++ 25 | } 26 | } 27 | return base 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/language/tags.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package language 6 | 7 | // MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed. 8 | // It simplifies safe initialization of Tag values. 9 | func MustParse(s string) Tag { 10 | t, err := Parse(s) 11 | if err != nil { 12 | panic(err) 13 | } 14 | return t 15 | } 16 | 17 | // MustParseBase is like ParseBase, but panics if the given base cannot be parsed. 18 | // It simplifies safe initialization of Base values. 19 | func MustParseBase(s string) Language { 20 | b, err := ParseBase(s) 21 | if err != nil { 22 | panic(err) 23 | } 24 | return b 25 | } 26 | 27 | // MustParseScript is like ParseScript, but panics if the given script cannot be 28 | // parsed. It simplifies safe initialization of Script values. 29 | func MustParseScript(s string) Script { 30 | scr, err := ParseScript(s) 31 | if err != nil { 32 | panic(err) 33 | } 34 | return scr 35 | } 36 | 37 | // MustParseRegion is like ParseRegion, but panics if the given region cannot be 38 | // parsed. It simplifies safe initialization of Region values. 39 | func MustParseRegion(s string) Region { 40 | r, err := ParseRegion(s) 41 | if err != nil { 42 | panic(err) 43 | } 44 | return r 45 | } 46 | 47 | // Und is the root language. 48 | var Und Tag 49 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/match.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | // This file contains matchers that implement CLDR inheritance. 8 | // 9 | // See https://unicode.org/reports/tr35/#Locale_Inheritance. 10 | // 11 | // Some of the inheritance described in this document is already handled by 12 | // the cldr package. 13 | 14 | import ( 15 | "golang.org/x/text/language" 16 | ) 17 | 18 | // TODO: consider if (some of the) matching algorithm needs to be public after 19 | // getting some feel about what is generic and what is specific. 20 | 21 | // NewInheritanceMatcher returns a matcher that matches based on the inheritance 22 | // chain. 23 | // 24 | // The matcher uses canonicalization and the parent relationship to find a 25 | // match. The resulting match will always be either Und or a language with the 26 | // same language and script as the requested language. It will not match 27 | // languages for which there is understood to be mutual or one-directional 28 | // intelligibility. 29 | // 30 | // A Match will indicate an Exact match if the language matches after 31 | // canonicalization and High if the matched tag is a parent. 32 | func NewInheritanceMatcher(t []language.Tag) *InheritanceMatcher { 33 | tags := &InheritanceMatcher{make(map[language.Tag]int)} 34 | for i, tag := range t { 35 | ct, err := language.All.Canonicalize(tag) 36 | if err != nil { 37 | ct = tag 38 | } 39 | tags.index[ct] = i 40 | } 41 | return tags 42 | } 43 | 44 | type InheritanceMatcher struct { 45 | index map[language.Tag]int 46 | } 47 | 48 | func (m InheritanceMatcher) Match(want ...language.Tag) (language.Tag, int, language.Confidence) { 49 | for _, t := range want { 50 | ct, err := language.All.Canonicalize(t) 51 | if err != nil { 52 | ct = t 53 | } 54 | conf := language.Exact 55 | for { 56 | if index, ok := m.index[ct]; ok { 57 | return ct, index, conf 58 | } 59 | if ct == language.Und { 60 | break 61 | } 62 | ct = ct.Parent() 63 | conf = language.High 64 | } 65 | } 66 | return language.Und, 0, language.No 67 | } 68 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/tag/tag.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package tag contains functionality handling tags and related data. 6 | package tag // import "golang.org/x/text/internal/tag" 7 | 8 | import "sort" 9 | 10 | // An Index converts tags to a compact numeric value. 11 | // 12 | // All elements are of size 4. Tags may be up to 4 bytes long. Excess bytes can 13 | // be used to store additional information about the tag. 14 | type Index string 15 | 16 | // Elem returns the element data at the given index. 17 | func (s Index) Elem(x int) string { 18 | return string(s[x*4 : x*4+4]) 19 | } 20 | 21 | // Index reports the index of the given key or -1 if it could not be found. 22 | // Only the first len(key) bytes from the start of the 4-byte entries will be 23 | // considered for the search and the first match in Index will be returned. 24 | func (s Index) Index(key []byte) int { 25 | n := len(key) 26 | // search the index of the first entry with an equal or higher value than 27 | // key in s. 28 | index := sort.Search(len(s)/4, func(i int) bool { 29 | return cmp(s[i*4:i*4+n], key) != -1 30 | }) 31 | i := index * 4 32 | if cmp(s[i:i+len(key)], key) != 0 { 33 | return -1 34 | } 35 | return index 36 | } 37 | 38 | // Next finds the next occurrence of key after index x, which must have been 39 | // obtained from a call to Index using the same key. It returns x+1 or -1. 40 | func (s Index) Next(key []byte, x int) int { 41 | if x++; x*4 < len(s) && cmp(s[x*4:x*4+len(key)], key) == 0 { 42 | return x 43 | } 44 | return -1 45 | } 46 | 47 | // cmp returns an integer comparing a and b lexicographically. 48 | func cmp(a Index, b []byte) int { 49 | n := len(a) 50 | if len(b) < n { 51 | n = len(b) 52 | } 53 | for i, c := range b[:n] { 54 | switch { 55 | case a[i] > c: 56 | return 1 57 | case a[i] < c: 58 | return -1 59 | } 60 | } 61 | switch { 62 | case len(a) < len(b): 63 | return -1 64 | case len(a) > len(b): 65 | return 1 66 | } 67 | return 0 68 | } 69 | 70 | // Compare returns an integer comparing a and b lexicographically. 71 | func Compare(a string, b []byte) int { 72 | return cmp(Index(a), b) 73 | } 74 | 75 | // FixCase reformats b to the same pattern of cases as form. 76 | // If returns false if string b is malformed. 77 | func FixCase(form string, b []byte) bool { 78 | if len(form) != len(b) { 79 | return false 80 | } 81 | for i, c := range b { 82 | if form[i] <= 'Z' { 83 | if c >= 'a' { 84 | c -= 'z' - 'Z' 85 | } 86 | if c < 'A' || 'Z' < c { 87 | return false 88 | } 89 | } else { 90 | if c <= 'Z' { 91 | c += 'z' - 'Z' 92 | } 93 | if c < 'a' || 'z' < c { 94 | return false 95 | } 96 | } 97 | b[i] = c 98 | } 99 | return true 100 | } 101 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/input.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | import "unicode/utf8" 8 | 9 | type input struct { 10 | str string 11 | bytes []byte 12 | } 13 | 14 | func inputBytes(str []byte) input { 15 | return input{bytes: str} 16 | } 17 | 18 | func inputString(str string) input { 19 | return input{str: str} 20 | } 21 | 22 | func (in *input) setBytes(str []byte) { 23 | in.str = "" 24 | in.bytes = str 25 | } 26 | 27 | func (in *input) setString(str string) { 28 | in.str = str 29 | in.bytes = nil 30 | } 31 | 32 | func (in *input) _byte(p int) byte { 33 | if in.bytes == nil { 34 | return in.str[p] 35 | } 36 | return in.bytes[p] 37 | } 38 | 39 | func (in *input) skipASCII(p, max int) int { 40 | if in.bytes == nil { 41 | for ; p < max && in.str[p] < utf8.RuneSelf; p++ { 42 | } 43 | } else { 44 | for ; p < max && in.bytes[p] < utf8.RuneSelf; p++ { 45 | } 46 | } 47 | return p 48 | } 49 | 50 | func (in *input) skipContinuationBytes(p int) int { 51 | if in.bytes == nil { 52 | for ; p < len(in.str) && !utf8.RuneStart(in.str[p]); p++ { 53 | } 54 | } else { 55 | for ; p < len(in.bytes) && !utf8.RuneStart(in.bytes[p]); p++ { 56 | } 57 | } 58 | return p 59 | } 60 | 61 | func (in *input) appendSlice(buf []byte, b, e int) []byte { 62 | if in.bytes != nil { 63 | return append(buf, in.bytes[b:e]...) 64 | } 65 | for i := b; i < e; i++ { 66 | buf = append(buf, in.str[i]) 67 | } 68 | return buf 69 | } 70 | 71 | func (in *input) copySlice(buf []byte, b, e int) int { 72 | if in.bytes == nil { 73 | return copy(buf, in.str[b:e]) 74 | } 75 | return copy(buf, in.bytes[b:e]) 76 | } 77 | 78 | func (in *input) charinfoNFC(p int) (uint16, int) { 79 | if in.bytes == nil { 80 | return nfcData.lookupString(in.str[p:]) 81 | } 82 | return nfcData.lookup(in.bytes[p:]) 83 | } 84 | 85 | func (in *input) charinfoNFKC(p int) (uint16, int) { 86 | if in.bytes == nil { 87 | return nfkcData.lookupString(in.str[p:]) 88 | } 89 | return nfkcData.lookup(in.bytes[p:]) 90 | } 91 | 92 | func (in *input) hangul(p int) (r rune) { 93 | var size int 94 | if in.bytes == nil { 95 | if !isHangulString(in.str[p:]) { 96 | return 0 97 | } 98 | r, size = utf8.DecodeRuneInString(in.str[p:]) 99 | } else { 100 | if !isHangul(in.bytes[p:]) { 101 | return 0 102 | } 103 | r, size = utf8.DecodeRune(in.bytes[p:]) 104 | } 105 | if size != hangulUTF8Size { 106 | return 0 107 | } 108 | return r 109 | } 110 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/transform.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | import ( 8 | "unicode/utf8" 9 | 10 | "golang.org/x/text/transform" 11 | ) 12 | 13 | // Reset implements the Reset method of the transform.Transformer interface. 14 | func (Form) Reset() {} 15 | 16 | // Transform implements the Transform method of the transform.Transformer 17 | // interface. It may need to write segments of up to MaxSegmentSize at once. 18 | // Users should either catch ErrShortDst and allow dst to grow or have dst be at 19 | // least of size MaxTransformChunkSize to be guaranteed of progress. 20 | func (f Form) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { 21 | // Cap the maximum number of src bytes to check. 22 | b := src 23 | eof := atEOF 24 | if ns := len(dst); ns < len(b) { 25 | err = transform.ErrShortDst 26 | eof = false 27 | b = b[:ns] 28 | } 29 | i, ok := formTable[f].quickSpan(inputBytes(b), 0, len(b), eof) 30 | n := copy(dst, b[:i]) 31 | if !ok { 32 | nDst, nSrc, err = f.transform(dst[n:], src[n:], atEOF) 33 | return nDst + n, nSrc + n, err 34 | } 35 | 36 | if err == nil && n < len(src) && !atEOF { 37 | err = transform.ErrShortSrc 38 | } 39 | return n, n, err 40 | } 41 | 42 | func flushTransform(rb *reorderBuffer) bool { 43 | // Write out (must fully fit in dst, or else it is an ErrShortDst). 44 | if len(rb.out) < rb.nrune*utf8.UTFMax { 45 | return false 46 | } 47 | rb.out = rb.out[rb.flushCopy(rb.out):] 48 | return true 49 | } 50 | 51 | var errs = []error{nil, transform.ErrShortDst, transform.ErrShortSrc} 52 | 53 | // transform implements the transform.Transformer interface. It is only called 54 | // when quickSpan does not pass for a given string. 55 | func (f Form) transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { 56 | // TODO: get rid of reorderBuffer. See CL 23460044. 57 | rb := reorderBuffer{} 58 | rb.init(f, src) 59 | for { 60 | // Load segment into reorder buffer. 61 | rb.setFlusher(dst[nDst:], flushTransform) 62 | end := decomposeSegment(&rb, nSrc, atEOF) 63 | if end < 0 { 64 | return nDst, nSrc, errs[-end] 65 | } 66 | nDst = len(dst) - len(rb.out) 67 | nSrc = end 68 | 69 | // Next quickSpan. 70 | end = rb.nsrc 71 | eof := atEOF 72 | if n := nSrc + len(dst) - nDst; n < end { 73 | err = transform.ErrShortDst 74 | end = n 75 | eof = false 76 | } 77 | end, ok := rb.f.quickSpan(rb.src, nSrc, end, eof) 78 | n := copy(dst[nDst:], rb.src.bytes[nSrc:end]) 79 | nSrc += n 80 | nDst += n 81 | if ok { 82 | if err == nil && n < rb.nsrc && !atEOF { 83 | err = transform.ErrShortSrc 84 | } 85 | return nDst, nSrc, err 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/trie.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | type valueRange struct { 8 | value uint16 // header: value:stride 9 | lo, hi byte // header: lo:n 10 | } 11 | 12 | type sparseBlocks struct { 13 | values []valueRange 14 | offset []uint16 15 | } 16 | 17 | var nfcSparse = sparseBlocks{ 18 | values: nfcSparseValues[:], 19 | offset: nfcSparseOffset[:], 20 | } 21 | 22 | var nfkcSparse = sparseBlocks{ 23 | values: nfkcSparseValues[:], 24 | offset: nfkcSparseOffset[:], 25 | } 26 | 27 | var ( 28 | nfcData = newNfcTrie(0) 29 | nfkcData = newNfkcTrie(0) 30 | ) 31 | 32 | // lookupValue determines the type of block n and looks up the value for b. 33 | // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block 34 | // is a list of ranges with an accompanying value. Given a matching range r, 35 | // the value for b is by r.value + (b - r.lo) * stride. 36 | func (t *sparseBlocks) lookup(n uint32, b byte) uint16 { 37 | offset := t.offset[n] 38 | header := t.values[offset] 39 | lo := offset + 1 40 | hi := lo + uint16(header.lo) 41 | for lo < hi { 42 | m := lo + (hi-lo)/2 43 | r := t.values[m] 44 | if r.lo <= b && b <= r.hi { 45 | return r.value + uint16(b-r.lo)*header.value 46 | } 47 | if b < r.lo { 48 | hi = m 49 | } else { 50 | lo = m + 1 51 | } 52 | } 53 | return 0 54 | } 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/rangetable/rangetable.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package rangetable provides utilities for creating and inspecting 6 | // unicode.RangeTables. 7 | package rangetable 8 | 9 | import ( 10 | "sort" 11 | "unicode" 12 | ) 13 | 14 | // New creates a RangeTable from the given runes, which may contain duplicates. 15 | func New(r ...rune) *unicode.RangeTable { 16 | if len(r) == 0 { 17 | return &unicode.RangeTable{} 18 | } 19 | 20 | sort.Sort(byRune(r)) 21 | 22 | // Remove duplicates. 23 | k := 1 24 | for i := 1; i < len(r); i++ { 25 | if r[k-1] != r[i] { 26 | r[k] = r[i] 27 | k++ 28 | } 29 | } 30 | 31 | var rt unicode.RangeTable 32 | for _, r := range r[:k] { 33 | if r <= 0xFFFF { 34 | rt.R16 = append(rt.R16, unicode.Range16{Lo: uint16(r), Hi: uint16(r), Stride: 1}) 35 | } else { 36 | rt.R32 = append(rt.R32, unicode.Range32{Lo: uint32(r), Hi: uint32(r), Stride: 1}) 37 | } 38 | } 39 | 40 | // Optimize RangeTable. 41 | return Merge(&rt) 42 | } 43 | 44 | type byRune []rune 45 | 46 | func (r byRune) Len() int { return len(r) } 47 | func (r byRune) Swap(i, j int) { r[i], r[j] = r[j], r[i] } 48 | func (r byRune) Less(i, j int) bool { return r[i] < r[j] } 49 | 50 | // Visit visits all runes in the given RangeTable in order, calling fn for each. 51 | func Visit(rt *unicode.RangeTable, fn func(rune)) { 52 | for _, r16 := range rt.R16 { 53 | for r := rune(r16.Lo); r <= rune(r16.Hi); r += rune(r16.Stride) { 54 | fn(r) 55 | } 56 | } 57 | for _, r32 := range rt.R32 { 58 | for r := rune(r32.Lo); r <= rune(r32.Hi); r += rune(r32.Stride) { 59 | fn(r) 60 | } 61 | } 62 | } 63 | 64 | // Assigned returns a RangeTable with all assigned code points for a given 65 | // Unicode version. This includes graphic, format, control, and private-use 66 | // characters. It returns nil if the data for the given version is not 67 | // available. 68 | func Assigned(version string) *unicode.RangeTable { 69 | return assigned[version] 70 | } 71 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/PuerkitoBio/goquery v1.8.0 2 | ## explicit; go 1.13 3 | github.com/PuerkitoBio/goquery 4 | # github.com/andybalholm/cascadia v1.3.1 5 | ## explicit; go 1.16 6 | github.com/andybalholm/cascadia 7 | # github.com/dlclark/regexp2 v1.8.0 8 | ## explicit; go 1.13 9 | github.com/dlclark/regexp2 10 | github.com/dlclark/regexp2/syntax 11 | # github.com/dop251/goja v0.0.0-20230203172422-5460598cfa32 12 | ## explicit; go 1.16 13 | github.com/dop251/goja 14 | github.com/dop251/goja/ast 15 | github.com/dop251/goja/file 16 | github.com/dop251/goja/ftoa 17 | github.com/dop251/goja/ftoa/internal/fast 18 | github.com/dop251/goja/parser 19 | github.com/dop251/goja/token 20 | github.com/dop251/goja/unistring 21 | # github.com/go-sourcemap/sourcemap v2.1.3+incompatible 22 | ## explicit 23 | github.com/go-sourcemap/sourcemap 24 | github.com/go-sourcemap/sourcemap/internal/base64vlq 25 | # github.com/peterhellberg/flip v0.0.0-20190124112217-35a0e6f6e8e6 26 | ## explicit 27 | github.com/peterhellberg/flip 28 | # github.com/peterhellberg/giphy v0.0.2 29 | ## explicit; go 1.17 30 | github.com/peterhellberg/giphy 31 | # github.com/peterhellberg/hi v0.0.0-20190124111154-9ac9cb027a95 32 | ## explicit 33 | github.com/peterhellberg/hi 34 | # golang.org/x/crypto v0.5.0 35 | ## explicit; go 1.17 36 | golang.org/x/crypto/blowfish 37 | golang.org/x/crypto/chacha20 38 | golang.org/x/crypto/curve25519 39 | golang.org/x/crypto/curve25519/internal/field 40 | golang.org/x/crypto/ed25519 41 | golang.org/x/crypto/internal/alias 42 | golang.org/x/crypto/internal/poly1305 43 | golang.org/x/crypto/ssh 44 | golang.org/x/crypto/ssh/internal/bcrypt_pbkdf 45 | # golang.org/x/net v0.5.0 46 | ## explicit; go 1.17 47 | golang.org/x/net/html 48 | golang.org/x/net/html/atom 49 | # golang.org/x/sys v0.5.0 50 | ## explicit; go 1.17 51 | golang.org/x/sys/cpu 52 | # golang.org/x/text v0.6.0 53 | ## explicit; go 1.17 54 | golang.org/x/text/cases 55 | golang.org/x/text/collate 56 | golang.org/x/text/internal 57 | golang.org/x/text/internal/colltab 58 | golang.org/x/text/internal/language 59 | golang.org/x/text/internal/language/compact 60 | golang.org/x/text/internal/tag 61 | golang.org/x/text/language 62 | golang.org/x/text/transform 63 | golang.org/x/text/unicode/norm 64 | golang.org/x/text/unicode/rangetable 65 | --------------------------------------------------------------------------------