diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/go.mod b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/go.mod index ac6035a..a6ae456 100644 --- a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/go.mod +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/go.mod @@ -17,7 +17,7 @@ require ( github.com/spf13/pflag v0.0.0-20170417173400-9e4c21054fa1 // indirect go.starlark.net v0.0.0-20200821142938-949cc6f4b097 golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4 - golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae + golang.org/x/sys v0.1.0 golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f gopkg.in/yaml.v2 v2.2.1 ) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/go.sum b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/go.sum index 3d011c8..6225d0c 100644 --- a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/go.sum +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/go.sum @@ -1,5 +1,4 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/cosiner/argv v0.1.0 h1:BVDiEL32lwHukgJKP87btEPenzrrHUjajs/8yzaqcXg= @@ -40,21 +39,17 @@ go.starlark.net v0.0.0-20200821142938-949cc6f4b097 h1:YiRMXXgG+Pg26t1fjq+iAjaauK go.starlark.net v0.0.0-20200821142938-949cc6f4b097/go.mod h1:f0znQkUKRrkk36XxWbGjMqQM8wGv/xHBVE2qc3B5oFU= golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4 h1:QlVATYS7JBoZMVaf+cNjb90WD/beKVHnIxFKT4QaHVI= golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f h1:3MlESg/jvTr87F4ttA/q4B+uhe/q6qleC9/DP+IwQmY= golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/.travis.yml b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/.travis.yml new file mode 100644 index 0000000..583c9b8 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/.travis.yml @@ -0,0 +1,70 @@ +language: go +sudo: false +go: + - 1.8 + - 1.7.5 + - 1.7.4 + - 1.7.3 + - 1.7.2 + - 1.7.1 + - 1.7 + - tip + - 1.6.4 + - 1.6.3 + - 1.6.2 + - 1.6.1 + - 1.6 + - 1.5.4 + - 1.5.3 + - 1.5.2 + - 1.5.1 + - 1.5 + - 1.4.3 + - 1.4.2 + - 1.4.1 + - 1.4 + - 1.3.3 + - 1.3.2 + - 1.3.1 + - 1.3 + - 1.2.2 + - 1.2.1 + - 1.2 + - 1.1.2 + - 1.1.1 + - 1.1 +before_install: + - go get github.com/mattn/goveralls +script: + - $HOME/gopath/bin/goveralls -service=travis-ci +notifications: + email: + on_success: never +matrix: + fast_finish: true + allow_failures: + - go: tip + - go: 1.6.4 + - go: 1.6.3 + - go: 1.6.2 + - go: 1.6.1 + - go: 1.6 + - go: 1.5.4 + - go: 1.5.3 + - go: 1.5.2 + - go: 1.5.1 + - go: 1.5 + - go: 1.4.3 + - go: 1.4.2 + - go: 1.4.1 + - go: 1.4 + - go: 1.3.3 + - go: 1.3.2 + - go: 1.3.1 + - go: 1.3 + - go: 1.2.2 + - go: 1.2.1 + - go: 1.2 + - go: 1.1.2 + - go: 1.1.1 + - go: 1.1 \ No newline at end of file diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/LICENSE b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/LICENSE new file mode 100644 index 0000000..9755f6b --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/LICENSE @@ -0,0 +1,24 @@ +The MIT License (MIT) + +Copyright (c) 2017 aihui zhu + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/README.md b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/README.md new file mode 100644 index 0000000..6e2b495 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/README.md @@ -0,0 +1,31 @@ +# Argv + +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/cosiner/argv) +[![Build Status](https://travis-ci.org/cosiner/argv.svg?branch=master&style=flat)](https://travis-ci.org/cosiner/argv) +[![Coverage Status](https://coveralls.io/repos/github/cosiner/argv/badge.svg?style=flat)](https://coveralls.io/github/cosiner/argv) +[![Go Report Card](https://goreportcard.com/badge/github.com/cosiner/argv?style=flat)](https://goreportcard.com/report/github.com/cosiner/argv) + +Argv is a library for [Go](https://golang.org) to split command line string into arguments array. + +# Documentation +Documentation can be found at [Godoc](https://godoc.org/github.com/cosiner/argv) + +# Example +```Go +func TestArgv(t *testing.T) { + args, err := argv.Argv([]rune(" ls `echo /` | wc -l "), argv.ParseEnv(os.Environ()), argv.Run) + if err != nil { + t.Fatal(err) + } + expects := [][]string{ + []string{"ls", "/"}, + []string{"wc", "-l"}, + } + if !reflect.DeepEqual(args, expects) { + t.Fatal(args) + } +} +``` + +# LICENSE +MIT. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/argv.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/argv.go new file mode 100644 index 0000000..eebf801 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/argv.go @@ -0,0 +1,10 @@ +// Package argv parse command line string into arguments array using the bash syntax. +package argv + +// Argv split cmdline string as array of argument array by the '|' character. +// +// The parsing rules is same as bash. The environment variable will be replaced +// and string surround by '`' will be passed to reverse quote parser. +func Argv(cmdline string, backquoteExpander, stringExpander Expander) ([][]string, error) { + return NewParser(NewScanner(cmdline), backquoteExpander, stringExpander).Parse() +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/cmd.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/cmd.go new file mode 100644 index 0000000..f723c60 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/cmd.go @@ -0,0 +1,67 @@ +package argv + +import ( + "errors" + "io" + "os" + "os/exec" +) + +func Cmds(args ...[]string) ([]*exec.Cmd, error) { + var cmds []*exec.Cmd + for _, argv := range args { + if len(argv) == 0 { + return nil, errors.New("invalid cmd") + } + + cmds = append(cmds, exec.Command(argv[0], argv[1:]...)) + } + return cmds, nil +} + +func Pipe(stdin io.Reader, stdout, stderr io.Writer, cmds ...*exec.Cmd) error { + if stdin == nil { + stdin = os.Stdin + } + if stdout == nil { + stdout = os.Stdout + } + if stderr == nil { + stderr = os.Stderr + } + l := len(cmds) + if l == 0 { + return nil + } + var err error + for i := 0; i < l; i++ { + if i == 0 { + cmds[i].Stdin = stdin + } else { + cmds[i].Stdin, err = cmds[i-1].StdoutPipe() + if stderr != nil { + break + } + } + cmds[i].Stderr = stderr + if i == l-1 { + cmds[i].Stdout = stdout + } + } + if err != nil { + return err + } + for i := range cmds { + err = cmds[i].Start() + if err != nil { + return err + } + } + for i := range cmds { + err = cmds[i].Wait() + if err != nil { + return err + } + } + return nil +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/go.mod b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/go.mod new file mode 100644 index 0000000..6ed4dda --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/go.mod @@ -0,0 +1,3 @@ +module github.com/cosiner/argv + +go 1.13 diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/parser.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/parser.go new file mode 100644 index 0000000..3473b8a --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/parser.go @@ -0,0 +1,246 @@ +package argv + +import ( + "errors" + "fmt" + "os" +) + +type ( + Expander func(string) (string, error) + + // Parser take tokens from Scanner, and do syntax checking, and generate the splitted arguments array. + Parser struct { + s *Scanner + tokbuf []Token + backQuoteExpander Expander + stringExpander Expander + + sections [][]string + currSection []string + + currStrValid bool + currStr []rune + } +) + +// NewParser create a cmdline string parser. +func NewParser(s *Scanner, backQuoteExpander, stringExpander Expander) *Parser { + if backQuoteExpander == nil { + backQuoteExpander = func(r string) (string, error) { + return r, fmt.Errorf("back quote doesn't allowed") + } + } + if stringExpander == nil { + stringExpander = func(runes string) (string, error) { + s := os.ExpandEnv(string(runes)) + return s, nil + } + } + + return &Parser{ + s: s, + backQuoteExpander: backQuoteExpander, + stringExpander: stringExpander, + } +} + +func (p *Parser) nextToken() (Token, error) { + if l := len(p.tokbuf); l > 0 { + tok := p.tokbuf[l-1] + p.tokbuf = p.tokbuf[:l-1] + return tok, nil + } + + return p.s.Next() +} + +var ( + // ErrInvalidSyntax was reported if there is a syntax error in command line string. + ErrInvalidSyntax = errors.New("invalid syntax") +) + +func (p *Parser) unreadToken(tok Token) { + p.tokbuf = append(p.tokbuf, tok) +} + +// Parse split command line string into arguments array. +// +// EBNF: +// Cmdline = Section [ Pipe Cmdline ] +// Section = [Space] SpacedSection { SpacedSection } +// SpacedSection = MultipleUnit [Space] +// MultipleUnit = Unit {Unit} +// Unit = String | BackQuote | SingleQuote | DoubleQuote +func (p *Parser) Parse() ([][]string, error) { + err := p.cmdline() + if err != nil { + return nil, err + } + return p.sections, nil +} + +func (p *Parser) cmdline() error { + err := p.section() + if err != nil { + return err + } + p.endSection() + + tok, err := p.nextToken() + if err != nil { + return err + } + if tok.Type == TokEOF { + return nil + } + if !p.accept(tok.Type, TokPipe) { + return ErrInvalidSyntax + } + return p.cmdline() +} + +func (p *Parser) section() error { + leftSpace, err := p.optional(TokSpace) + if err != nil { + return err + } + + var hasUnit bool + for { + unit, ok, err := p.spacedSection() + if err != nil { + return err + } + if !ok { + break + } + hasUnit = true + + err = p.appendUnit(leftSpace, unit) + if err != nil { + return err + } + leftSpace = unit.rightSpace + } + if !hasUnit { + return ErrInvalidSyntax + } + return nil +} + +type unit struct { + rightSpace bool + toks []Token +} + +func (p *Parser) spacedSection() (u unit, ok bool, err error) { + u.toks, ok, err = p.multipleUnit() + if err != nil { + return + } + if !ok { + return u, false, nil + } + u.rightSpace, err = p.optional(TokSpace) + return +} + +func (p *Parser) multipleUnit() ([]Token, bool, error) { + var ( + toks []Token + ) + for { + tok, ok, err := p.unit() + if err != nil { + return nil, false, err + } + if !ok { + break + } + toks = append(toks, tok) + } + return toks, len(toks) > 0, nil +} + +func (p *Parser) unit() (Token, bool, error) { + tok, err := p.nextToken() + if err != nil { + return tok, false, err + } + if p.accept(tok.Type, TokString, TokStringSingleQuote, TokStringDoubleQuote, TokBackQuote) { + return tok, true, nil + } + p.unreadToken(tok) + return tok, false, nil +} + +func (p *Parser) optional(typ TokenType) (bool, error) { + tok, err := p.nextToken() + if err != nil { + return false, err + } + var ok bool + if ok = p.accept(tok.Type, typ); !ok { + p.unreadToken(tok) + } + return ok, nil +} + +func (p *Parser) accept(t TokenType, types ...TokenType) bool { + for _, typ := range types { + if t == typ { + return true + } + } + return false +} + +func (p *Parser) appendUnit(leftSpace bool, u unit) error { + if leftSpace { + p.currStr = p.currStr[:0] + } + for _, tok := range u.toks { + switch tok.Type { + case TokBackQuote: + expanded, err := p.backQuoteExpander(string(tok.Value)) + if err != nil { + return fmt.Errorf("expand string back quoted failed: %s, %w", string(tok.Value), err) + } + p.currStr = append(p.currStr, []rune(expanded)...) + case TokString: + expanded, err := p.stringExpander(string(tok.Value)) + if err != nil { + return fmt.Errorf("expand string failed: %s, %w", string(tok.Value), err) + } + p.currStr = append(p.currStr, []rune(expanded)...) + case TokStringSingleQuote: + p.currStr = append(p.currStr, tok.Value...) + case TokStringDoubleQuote: + expanded, err := p.stringExpander(string(tok.Value)) + if err != nil { + return fmt.Errorf("expand string double quoted failed: %s, %w", string(tok.Value), err) + } + p.currStr = append(p.currStr, []rune(expanded)...) + } + } + p.currStrValid = true + if u.rightSpace { + p.currSection = append(p.currSection, string(p.currStr)) + p.currStr = p.currStr[:0] + p.currStrValid = false + } + return nil +} + +func (p *Parser) endSection() { + if p.currStrValid { + p.currSection = append(p.currSection, string(p.currStr)) + } + p.currStr = p.currStr[:0] + p.currStrValid = false + if len(p.currSection) > 0 { + p.sections = append(p.sections, p.currSection) + p.currSection = nil + } +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/scanner.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/scanner.go new file mode 100644 index 0000000..287061a --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cosiner/argv/scanner.go @@ -0,0 +1,206 @@ +package argv + +import ( + "unicode" +) + +// Scanner is a cmdline string scanner. +// +// It split cmdline string to tokens: space, string, pipe, reverse quote string. +type Scanner struct { + text []rune + rpos int +} + +// NewScanner create a scanner and init it's internal states. +func NewScanner(text string) *Scanner { + return &Scanner{ + text: []rune(text), + } +} + +const _RuneEOF = 0 + +func (s *Scanner) nextRune() rune { + if s.rpos >= len(s.text) { + return _RuneEOF + } + + r := s.text[s.rpos] + s.rpos++ + return r +} + +func (s *Scanner) unreadRune(r rune) { + if r != _RuneEOF { + s.rpos-- + } +} + +func (s *Scanner) isEscapeChars(r rune) (rune, bool) { + switch r { + case 'a': + return '\a', true + case 'b': + return '\b', true + case 'f': + return '\f', true + case 'n': + return '\n', true + case 'r': + return '\r', true + case 't': + return '\t', true + case 'v': + return '\v', true + case '\\': + return '\\', true + case '$': + return '$', true + } + return r, false +} + +// TokenType is the type of tokens recognized by the scanner. +type TokenType uint32 + +// Token is generated by the scanner with a type and value. +type Token struct { + Type TokenType + Value []rune +} + +const ( + // TokString for string + TokString TokenType = iota + 1 + TokStringSingleQuote + TokStringDoubleQuote + // TokPipe is the '|' character + TokPipe + // TokBackQuote is reverse quoted string + TokBackQuote + // TokSpace represent space character sequence + TokSpace + // TokEOF means the input end. + TokEOF +) + +// Next return next token, if it reach the end, TOK_EOF will be returned. +// +// Error is returned for invalid syntax such as unpaired quotes. +func (s *Scanner) Next() (Token, error) { + const ( + Initial = iota + 1 + Space + BackQuote + String + StringSingleQuote + StringDoubleQuote + ) + + var ( + tok Token + + state uint8 = Initial + ) + for { + r := s.nextRune() + switch state { + case Initial: + switch { + case r == _RuneEOF: + tok.Type = TokEOF + return tok, nil + case r == '|': + tok.Type = TokPipe + return tok, nil + case r == '`': + state = BackQuote + case unicode.IsSpace(r): + state = Space + s.unreadRune(r) + case r == '\'': + state = StringSingleQuote + case r == '"': + state = StringDoubleQuote + default: + state = String + s.unreadRune(r) + } + case Space: + if r == _RuneEOF || !unicode.IsSpace(r) { + s.unreadRune(r) + tok.Type = TokSpace + return tok, nil + } + case BackQuote: + switch r { + case _RuneEOF: + return tok, ErrInvalidSyntax + case '`': + tok.Type = TokBackQuote + return tok, nil + default: + tok.Value = append(tok.Value, r) + } + case String: + switch { + case r == _RuneEOF, r == '|', r == '`', r == '\'', r == '"', unicode.IsSpace(r): + tok.Type = TokString + s.unreadRune(r) + return tok, nil + case r == '\\': + nr := s.nextRune() + if nr == _RuneEOF { + return tok, ErrInvalidSyntax + } + tok.Value = append(tok.Value, nr) + default: + tok.Value = append(tok.Value, r) + } + case StringSingleQuote, StringDoubleQuote: + switch r { + case _RuneEOF: + return tok, ErrInvalidSyntax + case '\'', '"': + if singleQuote := state == StringSingleQuote; singleQuote == (r == '\'') { + if singleQuote { + tok.Type = TokStringSingleQuote + } else { + tok.Type = TokStringDoubleQuote + } + return tok, nil + } else { + tok.Value = append(tok.Value, r) + } + case '\\': + nr := s.nextRune() + if escape, ok := s.isEscapeChars(nr); ok { + tok.Value = append(tok.Value, escape) + } else { + tok.Value = append(tok.Value, r) + s.unreadRune(nr) + } + default: + tok.Value = append(tok.Value, r) + } + } + } +} + +// Scan is a utility function help split input text as tokens. +func Scan(text string) ([]Token, error) { + s := NewScanner(text) + var tokens []Token + for { + tok, err := s.Next() + if err != nil { + return nil, err + } + tokens = append(tokens, tok) + if tok.Type == TokEOF { + break + } + } + return tokens, nil +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cpuguy83/go-md2man/LICENSE.md b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cpuguy83/go-md2man/LICENSE.md new file mode 100644 index 0000000..1cade6c --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cpuguy83/go-md2man/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Brian Goff + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cpuguy83/go-md2man/md2man/md2man.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cpuguy83/go-md2man/md2man/md2man.go new file mode 100644 index 0000000..af62279 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cpuguy83/go-md2man/md2man/md2man.go @@ -0,0 +1,20 @@ +package md2man + +import ( + "github.com/russross/blackfriday" +) + +// Render converts a markdown document into a roff formatted document. +func Render(doc []byte) []byte { + renderer := RoffRenderer(0) + extensions := 0 + extensions |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS + extensions |= blackfriday.EXTENSION_TABLES + extensions |= blackfriday.EXTENSION_FENCED_CODE + extensions |= blackfriday.EXTENSION_AUTOLINK + extensions |= blackfriday.EXTENSION_SPACE_HEADERS + extensions |= blackfriday.EXTENSION_FOOTNOTES + extensions |= blackfriday.EXTENSION_TITLEBLOCK + + return blackfriday.Markdown(doc, renderer, extensions) +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cpuguy83/go-md2man/md2man/roff.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cpuguy83/go-md2man/md2man/roff.go new file mode 100644 index 0000000..8c29ec6 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/cpuguy83/go-md2man/md2man/roff.go @@ -0,0 +1,285 @@ +package md2man + +import ( + "bytes" + "fmt" + "html" + "strings" + + "github.com/russross/blackfriday" +) + +type roffRenderer struct { + ListCounters []int +} + +// RoffRenderer creates a new blackfriday Renderer for generating roff documents +// from markdown +func RoffRenderer(flags int) blackfriday.Renderer { + return &roffRenderer{} +} + +func (r *roffRenderer) GetFlags() int { + return 0 +} + +func (r *roffRenderer) TitleBlock(out *bytes.Buffer, text []byte) { + out.WriteString(".TH ") + + splitText := bytes.Split(text, []byte("\n")) + for i, line := range splitText { + line = bytes.TrimPrefix(line, []byte("% ")) + if i == 0 { + line = bytes.Replace(line, []byte("("), []byte("\" \""), 1) + line = bytes.Replace(line, []byte(")"), []byte("\" \""), 1) + } + line = append([]byte("\""), line...) + line = append(line, []byte("\" ")...) + out.Write(line) + } + out.WriteString("\n") + + // disable hyphenation + out.WriteString(".nh\n") + // disable justification (adjust text to left margin only) + out.WriteString(".ad l\n") +} + +func (r *roffRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) { + out.WriteString("\n.PP\n.RS\n\n.nf\n") + escapeSpecialChars(out, text) + out.WriteString("\n.fi\n.RE\n") +} + +func (r *roffRenderer) BlockQuote(out *bytes.Buffer, text []byte) { + out.WriteString("\n.PP\n.RS\n") + out.Write(text) + out.WriteString("\n.RE\n") +} + +func (r *roffRenderer) BlockHtml(out *bytes.Buffer, text []byte) { // nolint: golint + out.Write(text) +} + +func (r *roffRenderer) Header(out *bytes.Buffer, text func() bool, level int, id string) { + marker := out.Len() + + switch { + case marker == 0: + // This is the doc header + out.WriteString(".TH ") + case level == 1: + out.WriteString("\n\n.SH ") + case level == 2: + out.WriteString("\n.SH ") + default: + out.WriteString("\n.SS ") + } + + if !text() { + out.Truncate(marker) + return + } +} + +func (r *roffRenderer) HRule(out *bytes.Buffer) { + out.WriteString("\n.ti 0\n\\l'\\n(.lu'\n") +} + +func (r *roffRenderer) List(out *bytes.Buffer, text func() bool, flags int) { + marker := out.Len() + r.ListCounters = append(r.ListCounters, 1) + out.WriteString("\n.RS\n") + if !text() { + out.Truncate(marker) + return + } + r.ListCounters = r.ListCounters[:len(r.ListCounters)-1] + out.WriteString("\n.RE\n") +} + +func (r *roffRenderer) ListItem(out *bytes.Buffer, text []byte, flags int) { + if flags&blackfriday.LIST_TYPE_ORDERED != 0 { + out.WriteString(fmt.Sprintf(".IP \"%3d.\" 5\n", r.ListCounters[len(r.ListCounters)-1])) + r.ListCounters[len(r.ListCounters)-1]++ + } else { + out.WriteString(".IP \\(bu 2\n") + } + out.Write(text) + out.WriteString("\n") +} + +func (r *roffRenderer) Paragraph(out *bytes.Buffer, text func() bool) { + marker := out.Len() + out.WriteString("\n.PP\n") + if !text() { + out.Truncate(marker) + return + } + if marker != 0 { + out.WriteString("\n") + } +} + +func (r *roffRenderer) Table(out *bytes.Buffer, header []byte, body []byte, columnData []int) { + out.WriteString("\n.TS\nallbox;\n") + + maxDelims := 0 + lines := strings.Split(strings.TrimRight(string(header), "\n")+"\n"+strings.TrimRight(string(body), "\n"), "\n") + for _, w := range lines { + curDelims := strings.Count(w, "\t") + if curDelims > maxDelims { + maxDelims = curDelims + } + } + out.Write([]byte(strings.Repeat("l ", maxDelims+1) + "\n")) + out.Write([]byte(strings.Repeat("l ", maxDelims+1) + ".\n")) + out.Write(header) + if len(header) > 0 { + out.Write([]byte("\n")) + } + + out.Write(body) + out.WriteString("\n.TE\n") +} + +func (r *roffRenderer) TableRow(out *bytes.Buffer, text []byte) { + if out.Len() > 0 { + out.WriteString("\n") + } + out.Write(text) +} + +func (r *roffRenderer) TableHeaderCell(out *bytes.Buffer, text []byte, align int) { + if out.Len() > 0 { + out.WriteString("\t") + } + if len(text) == 0 { + text = []byte{' '} + } + out.Write([]byte("\\fB\\fC" + string(text) + "\\fR")) +} + +func (r *roffRenderer) TableCell(out *bytes.Buffer, text []byte, align int) { + if out.Len() > 0 { + out.WriteString("\t") + } + if len(text) > 30 { + text = append([]byte("T{\n"), text...) + text = append(text, []byte("\nT}")...) + } + if len(text) == 0 { + text = []byte{' '} + } + out.Write(text) +} + +func (r *roffRenderer) Footnotes(out *bytes.Buffer, text func() bool) { + +} + +func (r *roffRenderer) FootnoteItem(out *bytes.Buffer, name, text []byte, flags int) { + +} + +func (r *roffRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int) { + out.WriteString("\n\\[la]") + out.Write(link) + out.WriteString("\\[ra]") +} + +func (r *roffRenderer) CodeSpan(out *bytes.Buffer, text []byte) { + out.WriteString("\\fB\\fC") + escapeSpecialChars(out, text) + out.WriteString("\\fR") +} + +func (r *roffRenderer) DoubleEmphasis(out *bytes.Buffer, text []byte) { + out.WriteString("\\fB") + out.Write(text) + out.WriteString("\\fP") +} + +func (r *roffRenderer) Emphasis(out *bytes.Buffer, text []byte) { + out.WriteString("\\fI") + out.Write(text) + out.WriteString("\\fP") +} + +func (r *roffRenderer) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte) { +} + +func (r *roffRenderer) LineBreak(out *bytes.Buffer) { + out.WriteString("\n.br\n") +} + +func (r *roffRenderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) { + out.Write(content) + r.AutoLink(out, link, 0) +} + +func (r *roffRenderer) RawHtmlTag(out *bytes.Buffer, tag []byte) { // nolint: golint + out.Write(tag) +} + +func (r *roffRenderer) TripleEmphasis(out *bytes.Buffer, text []byte) { + out.WriteString("\\s+2") + out.Write(text) + out.WriteString("\\s-2") +} + +func (r *roffRenderer) StrikeThrough(out *bytes.Buffer, text []byte) { +} + +func (r *roffRenderer) FootnoteRef(out *bytes.Buffer, ref []byte, id int) { + +} + +func (r *roffRenderer) Entity(out *bytes.Buffer, entity []byte) { + out.WriteString(html.UnescapeString(string(entity))) +} + +func (r *roffRenderer) NormalText(out *bytes.Buffer, text []byte) { + escapeSpecialChars(out, text) +} + +func (r *roffRenderer) DocumentHeader(out *bytes.Buffer) { +} + +func (r *roffRenderer) DocumentFooter(out *bytes.Buffer) { +} + +func needsBackslash(c byte) bool { + for _, r := range []byte("-_&\\~") { + if c == r { + return true + } + } + return false +} + +func escapeSpecialChars(out *bytes.Buffer, text []byte) { + for i := 0; i < len(text); i++ { + // escape initial apostrophe or period + if len(text) >= 1 && (text[0] == '\'' || text[0] == '.') { + out.WriteString("\\&") + } + + // directly copy normal characters + org := i + + for i < len(text) && !needsBackslash(text[i]) { + i++ + } + if i > org { + out.Write(text[org:i]) + } + + // escape a character + if i >= len(text) { + break + } + out.WriteByte('\\') + out.WriteByte(text[i]) + } +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/.gitignore b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/.gitignore new file mode 100644 index 0000000..1f0a99f --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/.gitignore @@ -0,0 +1,4 @@ +[568].out +_go* +_test* +_obj diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/Dockerfile.riscv b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/Dockerfile.riscv new file mode 100644 index 0000000..adfdf82 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/Dockerfile.riscv @@ -0,0 +1,14 @@ +FROM golang:1.13 + +# Clone and complie a riscv compatible version of the go compiler. +RUN git clone https://review.gerrithub.io/riscv/riscv-go /riscv-go +# riscvdev branch HEAD as of 2019-06-29. +RUN cd /riscv-go && git checkout 04885fddd096d09d4450726064d06dd107e374bf +ENV PATH=/riscv-go/misc/riscv:/riscv-go/bin:$PATH +RUN cd /riscv-go/src && GOROOT_BOOTSTRAP=$(go env GOROOT) ./make.bash +ENV GOROOT=/riscv-go + +# Make sure we compile. +WORKDIR pty +ADD . . +RUN GOOS=linux GOARCH=riscv go build diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/LICENSE b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/LICENSE new file mode 100644 index 0000000..6b7558b --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2011 Keith Rarick + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall +be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/README.md b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/README.md new file mode 100644 index 0000000..5275014 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/README.md @@ -0,0 +1,100 @@ +# pty + +Pty is a Go package for using unix pseudo-terminals. + +## Install + + go get github.com/creack/pty + +## Example + +### Command + +```go +package main + +import ( + "github.com/creack/pty" + "io" + "os" + "os/exec" +) + +func main() { + c := exec.Command("grep", "--color=auto", "bar") + f, err := pty.Start(c) + if err != nil { + panic(err) + } + + go func() { + f.Write([]byte("foo\n")) + f.Write([]byte("bar\n")) + f.Write([]byte("baz\n")) + f.Write([]byte{4}) // EOT + }() + io.Copy(os.Stdout, f) +} +``` + +### Shell + +```go +package main + +import ( + "io" + "log" + "os" + "os/exec" + "os/signal" + "syscall" + + "github.com/creack/pty" + "golang.org/x/crypto/ssh/terminal" +) + +func test() error { + // Create arbitrary command. + c := exec.Command("bash") + + // Start the command with a pty. + ptmx, err := pty.Start(c) + if err != nil { + return err + } + // Make sure to close the pty at the end. + defer func() { _ = ptmx.Close() }() // Best effort. + + // Handle pty size. + ch := make(chan os.Signal, 1) + signal.Notify(ch, syscall.SIGWINCH) + go func() { + for range ch { + if err := pty.InheritSize(os.Stdin, ptmx); err != nil { + log.Printf("error resizing pty: %s", err) + } + } + }() + ch <- syscall.SIGWINCH // Initial resize. + + // Set stdin in raw mode. + oldState, err := terminal.MakeRaw(int(os.Stdin.Fd())) + if err != nil { + panic(err) + } + defer func() { _ = terminal.Restore(int(os.Stdin.Fd()), oldState) }() // Best effort. + + // Copy stdin to the pty and the pty to stdout. + go func() { _, _ = io.Copy(ptmx, os.Stdin) }() + _, _ = io.Copy(os.Stdout, ptmx) + + return nil +} + +func main() { + if err := test(); err != nil { + log.Fatal(err) + } +} +``` diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/doc.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/doc.go new file mode 100644 index 0000000..190cfbe --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/doc.go @@ -0,0 +1,16 @@ +// Package pty provides functions for working with Unix terminals. +package pty + +import ( + "errors" + "os" +) + +// ErrUnsupported is returned if a function is not +// available on the current platform. +var ErrUnsupported = errors.New("unsupported") + +// Opens a pty and its corresponding tty. +func Open() (pty, tty *os.File, err error) { + return open() +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/go.mod b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/go.mod new file mode 100644 index 0000000..e48deca --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/go.mod @@ -0,0 +1,4 @@ +module github.com/creack/pty + +go 1.13 + diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ioctl.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ioctl.go new file mode 100644 index 0000000..c85cdcd --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ioctl.go @@ -0,0 +1,13 @@ +// +build !windows,!solaris + +package pty + +import "syscall" + +func ioctl(fd, cmd, ptr uintptr) error { + _, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr) + if e != 0 { + return e + } + return nil +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ioctl_bsd.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ioctl_bsd.go new file mode 100644 index 0000000..73b12c5 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ioctl_bsd.go @@ -0,0 +1,39 @@ +// +build darwin dragonfly freebsd netbsd openbsd + +package pty + +// from +const ( + _IOC_VOID uintptr = 0x20000000 + _IOC_OUT uintptr = 0x40000000 + _IOC_IN uintptr = 0x80000000 + _IOC_IN_OUT uintptr = _IOC_OUT | _IOC_IN + _IOC_DIRMASK = _IOC_VOID | _IOC_OUT | _IOC_IN + + _IOC_PARAM_SHIFT = 13 + _IOC_PARAM_MASK = (1 << _IOC_PARAM_SHIFT) - 1 +) + +func _IOC_PARM_LEN(ioctl uintptr) uintptr { + return (ioctl >> 16) & _IOC_PARAM_MASK +} + +func _IOC(inout uintptr, group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return inout | (param_len&_IOC_PARAM_MASK)<<16 | uintptr(group)<<8 | ioctl_num +} + +func _IO(group byte, ioctl_num uintptr) uintptr { + return _IOC(_IOC_VOID, group, ioctl_num, 0) +} + +func _IOR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return _IOC(_IOC_OUT, group, ioctl_num, param_len) +} + +func _IOW(group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return _IOC(_IOC_IN, group, ioctl_num, param_len) +} + +func _IOWR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return _IOC(_IOC_IN_OUT, group, ioctl_num, param_len) +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ioctl_solaris.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ioctl_solaris.go new file mode 100644 index 0000000..f63985f --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ioctl_solaris.go @@ -0,0 +1,30 @@ +package pty + +import ( + "golang.org/x/sys/unix" + "unsafe" +) + +const ( + // see /usr/include/sys/stropts.h + I_PUSH = uintptr((int32('S')<<8 | 002)) + I_STR = uintptr((int32('S')<<8 | 010)) + I_FIND = uintptr((int32('S')<<8 | 013)) + // see /usr/include/sys/ptms.h + ISPTM = (int32('P') << 8) | 1 + UNLKPT = (int32('P') << 8) | 2 + PTSSTTY = (int32('P') << 8) | 3 + ZONEPT = (int32('P') << 8) | 4 + OWNERPT = (int32('P') << 8) | 5 +) + +type strioctl struct { + ic_cmd int32 + ic_timout int32 + ic_len int32 + ic_dp unsafe.Pointer +} + +func ioctl(fd, cmd, ptr uintptr) error { + return unix.IoctlSetInt(int(fd), uint(cmd), int(ptr)) +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/mktypes.bash b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/mktypes.bash new file mode 100644 index 0000000..82ee167 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/mktypes.bash @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +GOOSARCH="${GOOS}_${GOARCH}" +case "$GOOSARCH" in +_* | *_ | _) + echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2 + exit 1 + ;; +esac + +GODEFS="go tool cgo -godefs" + +$GODEFS types.go |gofmt > ztypes_$GOARCH.go + +case $GOOS in +freebsd|dragonfly|openbsd) + $GODEFS types_$GOOS.go |gofmt > ztypes_$GOOSARCH.go + ;; +esac diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_darwin.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_darwin.go new file mode 100644 index 0000000..6344b6b --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_darwin.go @@ -0,0 +1,65 @@ +package pty + +import ( + "errors" + "os" + "syscall" + "unsafe" +) + +func open() (pty, tty *os.File, err error) { + pFD, err := syscall.Open("/dev/ptmx", syscall.O_RDWR|syscall.O_CLOEXEC, 0) + if err != nil { + return nil, nil, err + } + p := os.NewFile(uintptr(pFD), "/dev/ptmx") + // In case of error after this point, make sure we close the ptmx fd. + defer func() { + if err != nil { + _ = p.Close() // Best effort. + } + }() + + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + if err := grantpt(p); err != nil { + return nil, nil, err + } + + if err := unlockpt(p); err != nil { + return nil, nil, err + } + + t, err := os.OpenFile(sname, os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + return p, t, nil +} + +func ptsname(f *os.File) (string, error) { + n := make([]byte, _IOC_PARM_LEN(syscall.TIOCPTYGNAME)) + + err := ioctl(f.Fd(), syscall.TIOCPTYGNAME, uintptr(unsafe.Pointer(&n[0]))) + if err != nil { + return "", err + } + + for i, c := range n { + if c == 0 { + return string(n[:i]), nil + } + } + return "", errors.New("TIOCPTYGNAME string not NUL-terminated") +} + +func grantpt(f *os.File) error { + return ioctl(f.Fd(), syscall.TIOCPTYGRANT, 0) +} + +func unlockpt(f *os.File) error { + return ioctl(f.Fd(), syscall.TIOCPTYUNLK, 0) +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_dragonfly.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_dragonfly.go new file mode 100644 index 0000000..b7d1f20 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_dragonfly.go @@ -0,0 +1,80 @@ +package pty + +import ( + "errors" + "os" + "strings" + "syscall" + "unsafe" +) + +// same code as pty_darwin.go +func open() (pty, tty *os.File, err error) { + p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + // In case of error after this point, make sure we close the ptmx fd. + defer func() { + if err != nil { + _ = p.Close() // Best effort. + } + }() + + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + if err := grantpt(p); err != nil { + return nil, nil, err + } + + if err := unlockpt(p); err != nil { + return nil, nil, err + } + + t, err := os.OpenFile(sname, os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + return p, t, nil +} + +func grantpt(f *os.File) error { + _, err := isptmaster(f.Fd()) + return err +} + +func unlockpt(f *os.File) error { + _, err := isptmaster(f.Fd()) + return err +} + +func isptmaster(fd uintptr) (bool, error) { + err := ioctl(fd, syscall.TIOCISPTMASTER, 0) + return err == nil, err +} + +var ( + emptyFiodgnameArg fiodgnameArg + ioctl_FIODNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) +) + +func ptsname(f *os.File) (string, error) { + name := make([]byte, _C_SPECNAMELEN) + fa := fiodgnameArg{Name: (*byte)(unsafe.Pointer(&name[0])), Len: _C_SPECNAMELEN, Pad_cgo_0: [4]byte{0, 0, 0, 0}} + + err := ioctl(f.Fd(), ioctl_FIODNAME, uintptr(unsafe.Pointer(&fa))) + if err != nil { + return "", err + } + + for i, c := range name { + if c == 0 { + s := "/dev/" + string(name[:i]) + return strings.Replace(s, "ptm", "pts", -1), nil + } + } + return "", errors.New("TIOCPTYGNAME string not NUL-terminated") +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_freebsd.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_freebsd.go new file mode 100644 index 0000000..63b6d91 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_freebsd.go @@ -0,0 +1,78 @@ +package pty + +import ( + "errors" + "os" + "syscall" + "unsafe" +) + +func posixOpenpt(oflag int) (fd int, err error) { + r0, _, e1 := syscall.Syscall(syscall.SYS_POSIX_OPENPT, uintptr(oflag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = e1 + } + return fd, err +} + +func open() (pty, tty *os.File, err error) { + fd, err := posixOpenpt(syscall.O_RDWR | syscall.O_CLOEXEC) + if err != nil { + return nil, nil, err + } + p := os.NewFile(uintptr(fd), "/dev/pts") + // In case of error after this point, make sure we close the pts fd. + defer func() { + if err != nil { + _ = p.Close() // Best effort. + } + }() + + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + t, err := os.OpenFile("/dev/"+sname, os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + return p, t, nil +} + +func isptmaster(fd uintptr) (bool, error) { + err := ioctl(fd, syscall.TIOCPTMASTER, 0) + return err == nil, err +} + +var ( + emptyFiodgnameArg fiodgnameArg + ioctlFIODGNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) +) + +func ptsname(f *os.File) (string, error) { + master, err := isptmaster(f.Fd()) + if err != nil { + return "", err + } + if !master { + return "", syscall.EINVAL + } + + const n = _C_SPECNAMELEN + 1 + var ( + buf = make([]byte, n) + arg = fiodgnameArg{Len: n, Buf: (*byte)(unsafe.Pointer(&buf[0]))} + ) + if err := ioctl(f.Fd(), ioctlFIODGNAME, uintptr(unsafe.Pointer(&arg))); err != nil { + return "", err + } + + for i, c := range buf { + if c == 0 { + return string(buf[:i]), nil + } + } + return "", errors.New("FIODGNAME string not NUL-terminated") +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_linux.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_linux.go new file mode 100644 index 0000000..4a833de --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_linux.go @@ -0,0 +1,51 @@ +package pty + +import ( + "os" + "strconv" + "syscall" + "unsafe" +) + +func open() (pty, tty *os.File, err error) { + p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + // In case of error after this point, make sure we close the ptmx fd. + defer func() { + if err != nil { + _ = p.Close() // Best effort. + } + }() + + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + if err := unlockpt(p); err != nil { + return nil, nil, err + } + + t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0) + if err != nil { + return nil, nil, err + } + return p, t, nil +} + +func ptsname(f *os.File) (string, error) { + var n _C_uint + err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) + if err != nil { + return "", err + } + return "/dev/pts/" + strconv.Itoa(int(n)), nil +} + +func unlockpt(f *os.File) error { + var u _C_int + // use TIOCSPTLCK with a pointer to zero to clear the lock + return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_openbsd.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_openbsd.go new file mode 100644 index 0000000..a6a35d1 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_openbsd.go @@ -0,0 +1,33 @@ +package pty + +import ( + "os" + "syscall" + "unsafe" +) + +func open() (pty, tty *os.File, err error) { + /* + * from ptm(4): + * The PTMGET command allocates a free pseudo terminal, changes its + * ownership to the caller, revokes the access privileges for all previous + * users, opens the file descriptors for the pty and tty devices and + * returns them to the caller in struct ptmget. + */ + + p, err := os.OpenFile("/dev/ptm", os.O_RDWR|syscall.O_CLOEXEC, 0) + if err != nil { + return nil, nil, err + } + defer p.Close() + + var ptm ptmget + if err := ioctl(p.Fd(), uintptr(ioctl_PTMGET), uintptr(unsafe.Pointer(&ptm))); err != nil { + return nil, nil, err + } + + pty = os.NewFile(uintptr(ptm.Cfd), "/dev/ptm") + tty = os.NewFile(uintptr(ptm.Sfd), "/dev/ptm") + + return pty, tty, nil +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_solaris.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_solaris.go new file mode 100644 index 0000000..09ec1b7 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_solaris.go @@ -0,0 +1,139 @@ +package pty + +/* based on: +http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/pt.c +*/ + +import ( + "errors" + "golang.org/x/sys/unix" + "os" + "strconv" + "syscall" + "unsafe" +) + +const NODEV = ^uint64(0) + +func open() (pty, tty *os.File, err error) { + masterfd, err := syscall.Open("/dev/ptmx", syscall.O_RDWR|unix.O_NOCTTY, 0) + //masterfd, err := syscall.Open("/dev/ptmx", syscall.O_RDWR|syscall.O_CLOEXEC|unix.O_NOCTTY, 0) + if err != nil { + return nil, nil, err + } + p := os.NewFile(uintptr(masterfd), "/dev/ptmx") + + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + err = grantpt(p) + if err != nil { + return nil, nil, err + } + + err = unlockpt(p) + if err != nil { + return nil, nil, err + } + + slavefd, err := syscall.Open(sname, os.O_RDWR|unix.O_NOCTTY, 0) + if err != nil { + return nil, nil, err + } + t := os.NewFile(uintptr(slavefd), sname) + + // pushing terminal driver STREAMS modules as per pts(7) + for _, mod := range([]string{"ptem", "ldterm", "ttcompat"}) { + err = streams_push(t, mod) + if err != nil { + return nil, nil, err + } + } + + return p, t, nil +} + +func minor(x uint64) uint64 { + return x & 0377 +} + +func ptsdev(fd uintptr) uint64 { + istr := strioctl{ISPTM, 0, 0, nil} + err := ioctl(fd, I_STR, uintptr(unsafe.Pointer(&istr))) + if err != nil { + return NODEV + } + var status unix.Stat_t + err = unix.Fstat(int(fd), &status) + if err != nil { + return NODEV + } + return uint64(minor(status.Rdev)) +} + +func ptsname(f *os.File) (string, error) { + dev := ptsdev(f.Fd()) + if dev == NODEV { + return "", errors.New("not a master pty") + } + fn := "/dev/pts/" + strconv.FormatInt(int64(dev), 10) + // access(2) creates the slave device (if the pty exists) + // F_OK == 0 (unistd.h) + err := unix.Access(fn, 0) + if err != nil { + return "", err + } + return fn, nil +} + +type pt_own struct { + pto_ruid int32 + pto_rgid int32 +} + +func grantpt(f *os.File) error { + if ptsdev(f.Fd()) == NODEV { + return errors.New("not a master pty") + } + var pto pt_own + pto.pto_ruid = int32(os.Getuid()) + // XXX should first attempt to get gid of DEFAULT_TTY_GROUP="tty" + pto.pto_rgid = int32(os.Getgid()) + var istr strioctl + istr.ic_cmd = OWNERPT + istr.ic_timout = 0 + istr.ic_len = int32(unsafe.Sizeof(istr)) + istr.ic_dp = unsafe.Pointer(&pto) + err := ioctl(f.Fd(), I_STR, uintptr(unsafe.Pointer(&istr))) + if err != nil { + return errors.New("access denied") + } + return nil +} + +func unlockpt(f *os.File) error { + istr := strioctl{UNLKPT, 0, 0, nil} + return ioctl(f.Fd(), I_STR, uintptr(unsafe.Pointer(&istr))) +} + +// push STREAMS modules if not already done so +func streams_push(f *os.File, mod string) error { + var err error + buf := []byte(mod) + // XXX I_FIND is not returning an error when the module + // is already pushed even though truss reports a return + // value of 1. A bug in the Go Solaris syscall interface? + // XXX without this we are at risk of the issue + // https://www.illumos.org/issues/9042 + // but since we are not using libc or XPG4.2, we should not be + // double-pushing modules + + err = ioctl(f.Fd(), I_FIND, uintptr(unsafe.Pointer(&buf[0]))) + if err != nil { + return nil + } + err = ioctl(f.Fd(), I_PUSH, uintptr(unsafe.Pointer(&buf[0]))) + return err +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_unsupported.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_unsupported.go new file mode 100644 index 0000000..ceb425b --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/pty_unsupported.go @@ -0,0 +1,11 @@ +// +build !linux,!darwin,!freebsd,!dragonfly,!openbsd,!solaris + +package pty + +import ( + "os" +) + +func open() (pty, tty *os.File, err error) { + return nil, nil, ErrUnsupported +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/run.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/run.go new file mode 100644 index 0000000..959be26 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/run.go @@ -0,0 +1,57 @@ +// +build !windows + +package pty + +import ( + "os" + "os/exec" + "syscall" +) + +// Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, +// and c.Stderr, calls c.Start, and returns the File of the tty's +// corresponding pty. +func Start(c *exec.Cmd) (pty *os.File, err error) { + return StartWithSize(c, nil) +} + +// StartWithSize assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, +// and c.Stderr, calls c.Start, and returns the File of the tty's +// corresponding pty. +// +// This will resize the pty to the specified size before starting the command +func StartWithSize(c *exec.Cmd, sz *Winsize) (pty *os.File, err error) { + pty, tty, err := Open() + if err != nil { + return nil, err + } + defer tty.Close() + if sz != nil { + err = Setsize(pty, sz) + if err != nil { + pty.Close() + return nil, err + } + } + if c.Stdout == nil { + c.Stdout = tty + } + if c.Stderr == nil { + c.Stderr = tty + } + if c.Stdin == nil { + c.Stdin = tty + } + if c.SysProcAttr == nil { + c.SysProcAttr = &syscall.SysProcAttr{} + } + c.SysProcAttr.Setctty = true + c.SysProcAttr.Setsid = true + c.SysProcAttr.Ctty = int(tty.Fd()) + err = c.Start() + if err != nil { + pty.Close() + return nil, err + } + return pty, err +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/test_crosscompile.sh b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/test_crosscompile.sh new file mode 100644 index 0000000..f0b1dca --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/test_crosscompile.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env sh + +# Test script checking that all expected os/arch compile properly. +# Does not actually test the logic, just the compilation so we make sure we don't break code depending on the lib. + +echo2() { + echo $@ >&2 +} + +trap end 0 +end() { + [ "$?" = 0 ] && echo2 "Pass." || (echo2 "Fail."; exit 1) +} + +cross() { + os=$1 + shift + echo2 "Build for $os." + for arch in $@; do + echo2 " - $os/$arch" + GOOS=$os GOARCH=$arch go build + done + echo2 +} + +set -e + +cross linux amd64 386 arm arm64 ppc64 ppc64le s390x mips mipsle mips64 mips64le +cross darwin amd64 386 arm arm64 +cross freebsd amd64 386 arm +cross netbsd amd64 386 arm +cross openbsd amd64 386 +cross dragonfly amd64 +cross solaris amd64 + +# Not expected to work but should still compile. +cross windows amd64 386 arm + +# TODO: Fix compilation error on openbsd/arm. +# TODO: Merge the solaris PR. + +# Some os/arch require a different compiler. Run in docker. +if ! hash docker; then + # If docker is not present, stop here. + return +fi + +echo2 "Build for linux." +echo2 " - linux/riscv" +docker build -t test -f Dockerfile.riscv . diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/util.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/util.go new file mode 100644 index 0000000..8fdde0b --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/util.go @@ -0,0 +1,64 @@ +// +build !windows,!solaris + +package pty + +import ( + "os" + "syscall" + "unsafe" +) + +// InheritSize applies the terminal size of pty to tty. This should be run +// in a signal handler for syscall.SIGWINCH to automatically resize the tty when +// the pty receives a window size change notification. +func InheritSize(pty, tty *os.File) error { + size, err := GetsizeFull(pty) + if err != nil { + return err + } + err = Setsize(tty, size) + if err != nil { + return err + } + return nil +} + +// Setsize resizes t to s. +func Setsize(t *os.File, ws *Winsize) error { + return windowRectCall(ws, t.Fd(), syscall.TIOCSWINSZ) +} + +// GetsizeFull returns the full terminal size description. +func GetsizeFull(t *os.File) (size *Winsize, err error) { + var ws Winsize + err = windowRectCall(&ws, t.Fd(), syscall.TIOCGWINSZ) + return &ws, err +} + +// Getsize returns the number of rows (lines) and cols (positions +// in each line) in terminal t. +func Getsize(t *os.File) (rows, cols int, err error) { + ws, err := GetsizeFull(t) + return int(ws.Rows), int(ws.Cols), err +} + +// Winsize describes the terminal size. +type Winsize struct { + Rows uint16 // ws_row: Number of rows (in cells) + Cols uint16 // ws_col: Number of columns (in cells) + X uint16 // ws_xpixel: Width in pixels + Y uint16 // ws_ypixel: Height in pixels +} + +func windowRectCall(ws *Winsize, fd, a2 uintptr) error { + _, _, errno := syscall.Syscall( + syscall.SYS_IOCTL, + fd, + a2, + uintptr(unsafe.Pointer(ws)), + ) + if errno != 0 { + return syscall.Errno(errno) + } + return nil +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/util_solaris.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/util_solaris.go new file mode 100644 index 0000000..e889692 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/util_solaris.go @@ -0,0 +1,51 @@ +// + +package pty + +import ( + "os" + "golang.org/x/sys/unix" +) + +const ( + TIOCGWINSZ = 21608 // 'T' << 8 | 104 + TIOCSWINSZ = 21607 // 'T' << 8 | 103 +) + +// Winsize describes the terminal size. +type Winsize struct { + Rows uint16 // ws_row: Number of rows (in cells) + Cols uint16 // ws_col: Number of columns (in cells) + X uint16 // ws_xpixel: Width in pixels + Y uint16 // ws_ypixel: Height in pixels +} + +// GetsizeFull returns the full terminal size description. +func GetsizeFull(t *os.File) (size *Winsize, err error) { + var wsz *unix.Winsize + wsz, err = unix.IoctlGetWinsize(int(t.Fd()), TIOCGWINSZ) + + if err != nil { + return nil, err + } else { + return &Winsize{wsz.Row, wsz.Col, wsz.Xpixel, wsz.Ypixel}, nil + } +} + +// Get Windows Size +func Getsize(t *os.File) (rows, cols int, err error) { + var wsz *unix.Winsize + wsz, err = unix.IoctlGetWinsize(int(t.Fd()), TIOCGWINSZ) + + if err != nil { + return 80, 25, err + } else { + return int(wsz.Row), int(wsz.Col), nil + } +} + +// Setsize resizes t to s. +func Setsize(t *os.File, ws *Winsize) error { + wsz := unix.Winsize{ws.Rows, ws.Cols, ws.X, ws.Y} + return unix.IoctlSetWinsize(int(t.Fd()), TIOCSWINSZ, &wsz) +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_386.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_386.go new file mode 100644 index 0000000..ff0b8fd --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_386.go @@ -0,0 +1,9 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_amd64.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_amd64.go new file mode 100644 index 0000000..ff0b8fd --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_amd64.go @@ -0,0 +1,9 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_arm.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_arm.go new file mode 100644 index 0000000..ff0b8fd --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_arm.go @@ -0,0 +1,9 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_arm64.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_arm64.go new file mode 100644 index 0000000..6c29a4b --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_arm64.go @@ -0,0 +1,11 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +// +build arm64 + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_dragonfly_amd64.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_dragonfly_amd64.go new file mode 100644 index 0000000..6b0ba03 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_dragonfly_amd64.go @@ -0,0 +1,14 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_dragonfly.go + +package pty + +const ( + _C_SPECNAMELEN = 0x3f +) + +type fiodgnameArg struct { + Name *byte + Len uint32 + Pad_cgo_0 [4]byte +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_freebsd_386.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_freebsd_386.go new file mode 100644 index 0000000..d997537 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_freebsd_386.go @@ -0,0 +1,13 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package pty + +const ( + _C_SPECNAMELEN = 0x3f +) + +type fiodgnameArg struct { + Len int32 + Buf *byte +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_freebsd_amd64.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_freebsd_amd64.go new file mode 100644 index 0000000..5fa102f --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_freebsd_amd64.go @@ -0,0 +1,14 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package pty + +const ( + _C_SPECNAMELEN = 0x3f +) + +type fiodgnameArg struct { + Len int32 + Pad_cgo_0 [4]byte + Buf *byte +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_freebsd_arm.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_freebsd_arm.go new file mode 100644 index 0000000..d997537 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_freebsd_arm.go @@ -0,0 +1,13 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package pty + +const ( + _C_SPECNAMELEN = 0x3f +) + +type fiodgnameArg struct { + Len int32 + Buf *byte +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_mipsx.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_mipsx.go new file mode 100644 index 0000000..f0ce740 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_mipsx.go @@ -0,0 +1,12 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +// +build linux +// +build mips mipsle mips64 mips64le + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_openbsd_386.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_openbsd_386.go new file mode 100644 index 0000000..ccb3aab --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_openbsd_386.go @@ -0,0 +1,13 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_openbsd.go + +package pty + +type ptmget struct { + Cfd int32 + Sfd int32 + Cn [16]int8 + Sn [16]int8 +} + +var ioctl_PTMGET = 0x40287401 diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_openbsd_amd64.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_openbsd_amd64.go new file mode 100644 index 0000000..e670516 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_openbsd_amd64.go @@ -0,0 +1,13 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_openbsd.go + +package pty + +type ptmget struct { + Cfd int32 + Sfd int32 + Cn [16]int8 + Sn [16]int8 +} + +var ioctl_PTMGET = 0x40287401 diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_ppc64.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_ppc64.go new file mode 100644 index 0000000..4e1af84 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_ppc64.go @@ -0,0 +1,11 @@ +// +build ppc64 + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_ppc64le.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_ppc64le.go new file mode 100644 index 0000000..e6780f4 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_ppc64le.go @@ -0,0 +1,11 @@ +// +build ppc64le + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_riscvx.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_riscvx.go new file mode 100644 index 0000000..99eec8e --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_riscvx.go @@ -0,0 +1,11 @@ +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs types.go + +// +build riscv riscv64 + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_s390x.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_s390x.go new file mode 100644 index 0000000..a7452b6 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/creack/pty/ztypes_s390x.go @@ -0,0 +1,11 @@ +// +build s390x + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/.travis.yml b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/.travis.yml new file mode 100644 index 0000000..f793df8 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/.travis.yml @@ -0,0 +1,16 @@ +# For Travis to run this for pending PRs and pushes to the master branch, make +# sure to add a Webhook in the Github repository Settings to send all events to +# https://notify.travis-ci.org +language: go + +go: + - 1.14.x + - 1.15.x + +env: + global: + - GOPROXY=https://proxy.golang.org + - GO111MODULE=on + +script: + - 'internal/test.sh' diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/LICENSE b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/README.md b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/README.md new file mode 100644 index 0000000..bfec616 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/README.md @@ -0,0 +1,19 @@ +# go-dap: Go implementation of the Debug Adapter Protocol + +[![Build Status](https://travis-ci.org/google/go-dap.svg?branch=master)](https://travis-ci.org/google/go-dap) +[![Go Report Card](https://goreportcard.com/badge/github.com/google/go-dap)](https://goreportcard.com/report/github.com/google/go-dap) + +For an overview of DAP, see +https://microsoft.github.io/debug-adapter-protocol/overview + +## Contributing + +We'd love to accept your patches and contributions to this project. See +[docs/contributing](https://github.com/google/go-dap/blob/master/docs/contributing.md) +for more details. + +## License + +This project is licensed under the Apache License 2.0 + +This is not an officially supported Google product. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/codec.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/codec.go new file mode 100644 index 0000000..f9cd799 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/codec.go @@ -0,0 +1,229 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file contains utilities for decoding JSON-encoded bytes into DAP message. + +package dap + +import ( + "encoding/json" + "fmt" +) + +// DecodeProtocolMessageFieldError describes which JSON attribute +// has an unsupported value that the decoding cannot handle. +type DecodeProtocolMessageFieldError struct { + Seq int + SubType string + FieldName string + FieldValue string +} + +func (e *DecodeProtocolMessageFieldError) Error() string { + return fmt.Sprintf("%s %s '%s' is not supported (seq: %d)", e.SubType, e.FieldName, e.FieldValue, e.Seq) +} + +// DecodeProtocolMessage parses the JSON-encoded data and returns the result of +// the appropriate type within the ProtocolMessage hierarchy. If message type, +// command, etc cannot be cast, returns DecodeProtocolMessageFieldError. +// See also godoc for json.Unmarshal, which is used for underlying decoding. +func DecodeProtocolMessage(data []byte) (Message, error) { + var protomsg ProtocolMessage + if err := json.Unmarshal(data, &protomsg); err != nil { + return nil, err + } + switch protomsg.Type { + case "request": + return decodeRequest(data) + case "response": + return decodeResponse(data) + case "event": + return decodeEvent(data) + default: + return nil, &DecodeProtocolMessageFieldError{protomsg.GetSeq(), "ProtocolMessage", "type", protomsg.Type} + } +} + +type messageCtor func() Message + +// decodeRequest determines what request type in the ProtocolMessage hierarchy +// data corresponds to and uses json.Unmarshal to populate the corresponding +// struct to be returned. +func decodeRequest(data []byte) (Message, error) { + var r Request + if err := json.Unmarshal(data, &r); err != nil { + return nil, err + } + if ctor, ok := requestCtor[r.Command]; ok { + requestPtr := ctor() + err := json.Unmarshal(data, requestPtr) + return requestPtr, err + } + return nil, &DecodeProtocolMessageFieldError{r.GetSeq(), "Request", "command", r.Command} +} + +// Mapping of request commands and corresponding struct constructors that +// can be passed to json.Unmarshal. +var requestCtor = map[string]messageCtor{ + "cancel": func() Message { return &CancelRequest{} }, + "runInTerminal": func() Message { return &RunInTerminalRequest{} }, + "initialize": func() Message { + return &InitializeRequest{ + Arguments: InitializeRequestArguments{ + // Set the default values specified here: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Initialize. + LinesStartAt1: true, + ColumnsStartAt1: true, + PathFormat: "path", + }, + } + }, + "configurationDone": func() Message { return &ConfigurationDoneRequest{} }, + "launch": func() Message { return &LaunchRequest{} }, + "attach": func() Message { return &AttachRequest{} }, + "restart": func() Message { return &RestartRequest{} }, + "disconnect": func() Message { return &DisconnectRequest{} }, + "terminate": func() Message { return &TerminateRequest{} }, + "breakpointLocations": func() Message { return &BreakpointLocationsRequest{} }, + "setBreakpoints": func() Message { return &SetBreakpointsRequest{} }, + "setFunctionBreakpoints": func() Message { return &SetFunctionBreakpointsRequest{} }, + "setExceptionBreakpoints": func() Message { return &SetExceptionBreakpointsRequest{} }, + "dataBreakpointInfo": func() Message { return &DataBreakpointInfoRequest{} }, + "setDataBreakpoints": func() Message { return &SetDataBreakpointsRequest{} }, + "continue": func() Message { return &ContinueRequest{} }, + "next": func() Message { return &NextRequest{} }, + "stepIn": func() Message { return &StepInRequest{} }, + "stepOut": func() Message { return &StepOutRequest{} }, + "stepBack": func() Message { return &StepBackRequest{} }, + "reverseContinue": func() Message { return &ReverseContinueRequest{} }, + "restartFrame": func() Message { return &RestartFrameRequest{} }, + "goto": func() Message { return &GotoRequest{} }, + "pause": func() Message { return &PauseRequest{} }, + "stackTrace": func() Message { return &StackTraceRequest{} }, + "scopes": func() Message { return &ScopesRequest{} }, + "variables": func() Message { return &VariablesRequest{} }, + "setVariable": func() Message { return &SetVariableRequest{} }, + "source": func() Message { return &SourceRequest{} }, + "threads": func() Message { return &ThreadsRequest{} }, + "terminateThreads": func() Message { return &TerminateThreadsRequest{} }, + "modules": func() Message { return &ModulesRequest{} }, + "loadedSources": func() Message { return &LoadedSourcesRequest{} }, + "evaluate": func() Message { return &EvaluateRequest{} }, + "setExpression": func() Message { return &SetExpressionRequest{} }, + "stepInTargets": func() Message { return &StepInTargetsRequest{} }, + "gotoTargets": func() Message { return &GotoTargetsRequest{} }, + "completions": func() Message { return &CompletionsRequest{} }, + "exceptionInfo": func() Message { return &ExceptionInfoRequest{} }, + "readMemory": func() Message { return &ReadMemoryRequest{} }, + "disassemble": func() Message { return &DisassembleRequest{} }, +} + +// decodeResponse determines what response type in the ProtocolMessage hierarchy +// data corresponds to and uses json.Unmarshal to populate the corresponding +// struct to be returned. +func decodeResponse(data []byte) (Message, error) { + var r Response + if err := json.Unmarshal(data, &r); err != nil { + return nil, err + } + if !r.Success { + var er ErrorResponse + err := json.Unmarshal(data, &er) + return &er, err + } + if ctor, ok := responseCtor[r.Command]; ok { + responsePtr := ctor() + err := json.Unmarshal(data, responsePtr) + return responsePtr, err + } + return nil, &DecodeProtocolMessageFieldError{r.GetSeq(), "Response", "command", r.Command} +} + +// Mapping of response commands and corresponding struct constructors that +// can be passed to json.Unmarshal. +var responseCtor = map[string]messageCtor{ + "cancel": func() Message { return &CancelResponse{} }, + "runInTerminal": func() Message { return &RunInTerminalResponse{} }, + "initialize": func() Message { return &InitializeResponse{} }, + "configurationDone": func() Message { return &ConfigurationDoneResponse{} }, + "launch": func() Message { return &LaunchResponse{} }, + "attach": func() Message { return &AttachResponse{} }, + "restart": func() Message { return &RestartResponse{} }, + "disconnect": func() Message { return &DisconnectResponse{} }, + "terminate": func() Message { return &TerminateResponse{} }, + "breakpointLocations": func() Message { return &BreakpointLocationsResponse{} }, + "setBreakpoints": func() Message { return &SetBreakpointsResponse{} }, + "setFunctionBreakpoints": func() Message { return &SetFunctionBreakpointsResponse{} }, + "setExceptionBreakpoints": func() Message { return &SetExceptionBreakpointsResponse{} }, + "dataBreakpointInfo": func() Message { return &DataBreakpointInfoResponse{} }, + "setDataBreakpoints": func() Message { return &SetDataBreakpointsResponse{} }, + "continue": func() Message { return &ContinueResponse{} }, + "next": func() Message { return &NextResponse{} }, + "stepIn": func() Message { return &StepInResponse{} }, + "stepOut": func() Message { return &StepOutResponse{} }, + "stepBack": func() Message { return &StepBackResponse{} }, + "reverseContinue": func() Message { return &ReverseContinueResponse{} }, + "restartFrame": func() Message { return &RestartFrameResponse{} }, + "goto": func() Message { return &GotoResponse{} }, + "pause": func() Message { return &PauseResponse{} }, + "stackTrace": func() Message { return &StackTraceResponse{} }, + "scopes": func() Message { return &ScopesResponse{} }, + "variables": func() Message { return &VariablesResponse{} }, + "setVariable": func() Message { return &SetVariableResponse{} }, + "source": func() Message { return &SourceResponse{} }, + "threads": func() Message { return &ThreadsResponse{} }, + "terminateThreads": func() Message { return &TerminateThreadsResponse{} }, + "modules": func() Message { return &ModulesResponse{} }, + "loadedSources": func() Message { return &LoadedSourcesResponse{} }, + "evaluate": func() Message { return &EvaluateResponse{} }, + "setExpression": func() Message { return &SetExpressionResponse{} }, + "stepInTargets": func() Message { return &StepInTargetsResponse{} }, + "gotoTargets": func() Message { return &GotoTargetsResponse{} }, + "completions": func() Message { return &CompletionsResponse{} }, + "exceptionInfo": func() Message { return &ExceptionInfoResponse{} }, + "readMemory": func() Message { return &ReadMemoryResponse{} }, + "disassemble": func() Message { return &DisassembleResponse{} }, +} + +// decodeEvent determines what event type in the ProtocolMessage hierarchy +// data corresponds to and uses json.Unmarshal to populate the corresponding +// struct to be returned. +func decodeEvent(data []byte) (Message, error) { + var e Event + if err := json.Unmarshal(data, &e); err != nil { + return nil, err + } + if ctor, ok := eventCtor[e.Event]; ok { + eventPtr := ctor() + err := json.Unmarshal(data, eventPtr) + return eventPtr, err + } + return nil, &DecodeProtocolMessageFieldError{e.GetSeq(), "Event", "event", e.Event} +} + +// Mapping of event ids and corresponding struct constructors that +// can be passed to json.Unmarshal. +var eventCtor = map[string]messageCtor{ + "initialized": func() Message { return &InitializedEvent{} }, + "stopped": func() Message { return &StoppedEvent{} }, + "continued": func() Message { return &ContinuedEvent{} }, + "exited": func() Message { return &ExitedEvent{} }, + "terminated": func() Message { return &TerminatedEvent{} }, + "thread": func() Message { return &ThreadEvent{} }, + "output": func() Message { return &OutputEvent{} }, + "breakpoint": func() Message { return &BreakpointEvent{} }, + "module": func() Message { return &ModuleEvent{} }, + "loadedSource": func() Message { return &LoadedSourceEvent{} }, + "process": func() Message { return &ProcessEvent{} }, + "capabilities": func() Message { return &CapabilitiesEvent{} }, +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/doc.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/doc.go new file mode 100644 index 0000000..95cb28f --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/doc.go @@ -0,0 +1,20 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package dap contains data types and code for Debug Adapter Protocol (DAP) specification. +// https://github.com/microsoft/vscode-debugadapter-node/blob/main/debugProtocol.json +package dap + +//go:generate go run ./cmd/gentypes/gentypes.go -o schematypes.go -u cmd/gentypes/debugProtocol.json + diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/go.mod b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/go.mod new file mode 100644 index 0000000..6a37a23 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/go.mod @@ -0,0 +1,3 @@ +module github.com/google/go-dap + +go 1.13 diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/io.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/io.go new file mode 100644 index 0000000..87125ef --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/io.go @@ -0,0 +1,137 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file contains utilities for DAP Base protocol I/O. +// For additional information, see "Base protocol" section in +// https://microsoft.github.io/debug-adapter-protocol/overview. + +package dap + +import ( + "bufio" + "encoding/json" + "fmt" + "io" + "regexp" + "strconv" + "strings" +) + +// BaseProtocolError represents base protocol error, which occurs when the raw +// message does not conform to the header+content format of the base protocol. +type BaseProtocolError struct { + Err string +} + +func (bpe *BaseProtocolError) Error() string { return bpe.Err } + +var ( + // ErrHeaderDelimiterNotCrLfCrLf is returned when only partial header + // delimiter \r\n\r\n is encountered. + ErrHeaderDelimiterNotCrLfCrLf = &BaseProtocolError{fmt.Sprintf("header delimiter is not %q", crLfcrLf)} + + // ErrHeaderNotContentLength is returned when the parsed header is + // not of valid Content-Length format. + ErrHeaderNotContentLength = &BaseProtocolError{fmt.Sprintf("header format is not %q", contentLengthHeaderRegex)} + + // ErrHeaderContentTooLong is returned when the content length specified in + // the header is above contentMaxLength. + ErrHeaderContentTooLong = &BaseProtocolError{fmt.Sprintf("content length over %v bytes", contentMaxLength)} +) + +const ( + crLfcrLf = "\r\n\r\n" + contentLengthHeaderFmt = "Content-Length: %d\r\n\r\n" + contentMaxLength = 4 * 1024 * 1024 +) + +var ( + contentLengthHeaderRegex = regexp.MustCompile("^Content-Length: ([0-9]+)$") +) + +// WriteBaseMessage formats content with Content-Length header and delimiters +// as per the base protocol and writes the resulting message to w. +func WriteBaseMessage(w io.Writer, content []byte) error { + header := fmt.Sprintf(contentLengthHeaderFmt, len(content)) + if _, err := w.Write([]byte(header)); err != nil { + return err + } + _, err := w.Write(content) + return err +} + +// ReadBaseMessage reads one message from r consisting of a Content-Length +// header and a content part. It parses the header to determine the size of +// the content part and extracts and returns the actual content of the message. +// Returns nil bytes on error, which can be one of the standard IO errors or +// a BaseProtocolError defined in this package. +func ReadBaseMessage(r *bufio.Reader) ([]byte, error) { + contentLength, err := readContentLengthHeader(r) + if err != nil { + return nil, err + } + if contentLength > contentMaxLength { + return nil, ErrHeaderContentTooLong + } + content := make([]byte, contentLength) + if _, err = io.ReadFull(r, content); err != nil { + return nil, err + } + return content, nil +} + +// readContentLengthHeader looks for the only header field that is supported +// and required: +// Content-Length: [0-9]+\r\n\r\n +// Extracts and returns the content length. +func readContentLengthHeader(r *bufio.Reader) (contentLength int64, err error) { + // Look for \r\n\r\n + headerWithCr, err := r.ReadString('\r') + if err != nil { + return 0, err + } + nextThree := make([]byte, 3) + if _, err = io.ReadFull(r, nextThree); err != nil { + return 0, err + } + if string(nextThree) != "\n\r\n" { + return 0, ErrHeaderDelimiterNotCrLfCrLf + } + + // If header is in the right format, get the length + header := strings.TrimSuffix(headerWithCr, "\r") + headerAndLength := contentLengthHeaderRegex.FindStringSubmatch(header) + if len(headerAndLength) < 2 { + return 0, ErrHeaderNotContentLength + } + return strconv.ParseInt(headerAndLength[1], 10, 64) +} + +// WriteProtocolMessage encodes message and writes it to w. +func WriteProtocolMessage(w io.Writer, message Message) error { + b, err := json.Marshal(message) + if err != nil { + return err + } + return WriteBaseMessage(w, b) +} + +// ReadProtocolMessage reads a message from r, decodes and returns it. +func ReadProtocolMessage(r *bufio.Reader) (Message, error) { + content, err := ReadBaseMessage(r) + if err != nil { + return nil, err + } + return DecodeProtocolMessage(content) +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/schematypes.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/schematypes.go new file mode 100644 index 0000000..219159e --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/google/go-dap/schematypes.go @@ -0,0 +1,1901 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "cmd/gentypes/gentypes.go"; DO NOT EDIT. +// DAP spec: https://microsoft.github.io/debug-adapter-protocol/specification +// See cmd/gentypes/README.md for additional details. + +package dap + +// Message is an interface that all DAP message types implement with pointer +// receivers. It's not part of the protocol but is used to enforce static +// typing in Go code and provide some common accessors. +// +// Note: the DAP type "Message" (which is used in the body of ErrorResponse) +// is renamed to ErrorMessage to avoid collision with this interface. +type Message interface { + GetSeq() int +} + +// RequestMessage is an interface implemented by all Request-types. +type RequestMessage interface { + Message + // GetRequest provides access to the embedded Request. + GetRequest() *Request +} + +// ResponseMessage is an interface implemented by all Response-types. +type ResponseMessage interface { + Message + // GetResponse provides access to the embedded Response. + GetResponse() *Response +} + +// EventMessage is an interface implemented by all Event-types. +type EventMessage interface { + Message + // GetEvent provides access to the embedded Event. + GetEvent() *Event +} + +// LaunchAttachRequest is an interface implemented by +// LaunchRequest and AttachRequest as they contain shared +// implementation specific arguments that are not part of +// the specification. +type LaunchAttachRequest interface { + RequestMessage + // GetArguments provides access to the Arguments map. + GetArguments() map[string]interface{} +} + +// ProtocolMessage: Base class of requests, responses, and events. +type ProtocolMessage struct { + Seq int `json:"seq"` + Type string `json:"type"` +} + +func (m *ProtocolMessage) GetSeq() int { return m.Seq } + +// Request: A client or debug adapter initiated request. +type Request struct { + ProtocolMessage + + Command string `json:"command"` +} + +// Event: A debug adapter initiated event. +type Event struct { + ProtocolMessage + + Event string `json:"event"` +} + +// Response: Response for a request. +type Response struct { + ProtocolMessage + + RequestSeq int `json:"request_seq"` + Success bool `json:"success"` + Command string `json:"command"` + Message string `json:"message,omitempty"` +} + +// ErrorResponse: On error (whenever 'success' is false), the body can provide more details. +type ErrorResponse struct { + Response + + Body ErrorResponseBody `json:"body"` +} + +type ErrorResponseBody struct { + Error ErrorMessage `json:"error,omitempty"` +} + +func (r *ErrorResponse) GetResponse() *Response { return &r.Response } + +// CancelRequest: The 'cancel' request is used by the frontend in two situations: +// - to indicate that it is no longer interested in the result produced by a specific request issued earlier +// - to cancel a progress sequence. Clients should only call this request if the capability 'supportsCancelRequest' is true. +// This request has a hint characteristic: a debug adapter can only be expected to make a 'best effort' in honouring this request but there are no guarantees. +// The 'cancel' request may return an error if it could not cancel an operation but a frontend should refrain from presenting this error to end users. +// A frontend client should only call this request if the capability 'supportsCancelRequest' is true. +// The request that got canceled still needs to send a response back. This can either be a normal result ('success' attribute true) +// or an error response ('success' attribute false and the 'message' set to 'cancelled'). +// Returning partial results from a cancelled request is possible but please note that a frontend client has no generic way for detecting that a response is partial or not. +// The progress that got cancelled still needs to send a 'progressEnd' event back. +// A client should not assume that progress just got cancelled after sending the 'cancel' request. +type CancelRequest struct { + Request + + Arguments CancelArguments `json:"arguments,omitempty"` +} + +func (r *CancelRequest) GetRequest() *Request { return &r.Request } + +// CancelArguments: Arguments for 'cancel' request. +type CancelArguments struct { + RequestId int `json:"requestId,omitempty"` + ProgressId string `json:"progressId,omitempty"` +} + +// CancelResponse: Response to 'cancel' request. This is just an acknowledgement, so no body field is required. +type CancelResponse struct { + Response +} + +func (r *CancelResponse) GetResponse() *Response { return &r.Response } + +// InitializedEvent: This event indicates that the debug adapter is ready to accept configuration requests (e.g. SetBreakpointsRequest, SetExceptionBreakpointsRequest). +// A debug adapter is expected to send this event when it is ready to accept configuration requests (but not before the 'initialize' request has finished). +// The sequence of events/requests is as follows: +// - adapters sends 'initialized' event (after the 'initialize' request has returned) +// - frontend sends zero or more 'setBreakpoints' requests +// - frontend sends one 'setFunctionBreakpoints' request (if capability 'supportsFunctionBreakpoints' is true) +// - frontend sends a 'setExceptionBreakpoints' request if one or more 'exceptionBreakpointFilters' have been defined (or if 'supportsConfigurationDoneRequest' is not defined or false) +// - frontend sends other future configuration requests +// - frontend sends one 'configurationDone' request to indicate the end of the configuration. +type InitializedEvent struct { + Event +} + +func (e *InitializedEvent) GetEvent() *Event { return &e.Event } + +// StoppedEvent: The event indicates that the execution of the debuggee has stopped due to some condition. +// This can be caused by a break point previously set, a stepping request has completed, by executing a debugger statement etc. +type StoppedEvent struct { + Event + + Body StoppedEventBody `json:"body"` +} + +type StoppedEventBody struct { + Reason string `json:"reason"` + Description string `json:"description,omitempty"` + ThreadId int `json:"threadId,omitempty"` + PreserveFocusHint bool `json:"preserveFocusHint,omitempty"` + Text string `json:"text,omitempty"` + AllThreadsStopped bool `json:"allThreadsStopped,omitempty"` + HitBreakpointIds []int `json:"hitBreakpointIds,omitempty"` +} + +func (e *StoppedEvent) GetEvent() *Event { return &e.Event } + +// ContinuedEvent: The event indicates that the execution of the debuggee has continued. +// Please note: a debug adapter is not expected to send this event in response to a request that implies that execution continues, e.g. 'launch' or 'continue'. +// It is only necessary to send a 'continued' event if there was no previous request that implied this. +type ContinuedEvent struct { + Event + + Body ContinuedEventBody `json:"body"` +} + +type ContinuedEventBody struct { + ThreadId int `json:"threadId"` + AllThreadsContinued bool `json:"allThreadsContinued,omitempty"` +} + +func (e *ContinuedEvent) GetEvent() *Event { return &e.Event } + +// ExitedEvent: The event indicates that the debuggee has exited and returns its exit code. +type ExitedEvent struct { + Event + + Body ExitedEventBody `json:"body"` +} + +type ExitedEventBody struct { + ExitCode int `json:"exitCode"` +} + +func (e *ExitedEvent) GetEvent() *Event { return &e.Event } + +// TerminatedEvent: The event indicates that debugging of the debuggee has terminated. This does **not** mean that the debuggee itself has exited. +type TerminatedEvent struct { + Event + + Body TerminatedEventBody `json:"body,omitempty"` +} + +type TerminatedEventBody struct { + Restart interface{} `json:"restart,omitempty"` +} + +func (e *TerminatedEvent) GetEvent() *Event { return &e.Event } + +// ThreadEvent: The event indicates that a thread has started or exited. +type ThreadEvent struct { + Event + + Body ThreadEventBody `json:"body"` +} + +type ThreadEventBody struct { + Reason string `json:"reason"` + ThreadId int `json:"threadId"` +} + +func (e *ThreadEvent) GetEvent() *Event { return &e.Event } + +// OutputEvent: The event indicates that the target has produced some output. +type OutputEvent struct { + Event + + Body OutputEventBody `json:"body"` +} + +type OutputEventBody struct { + Category string `json:"category,omitempty"` + Output string `json:"output"` + Group string `json:"group,omitempty"` + VariablesReference int `json:"variablesReference,omitempty"` + Source Source `json:"source,omitempty"` + Line int `json:"line,omitempty"` + Column int `json:"column,omitempty"` + Data interface{} `json:"data,omitempty"` +} + +func (e *OutputEvent) GetEvent() *Event { return &e.Event } + +// BreakpointEvent: The event indicates that some information about a breakpoint has changed. +type BreakpointEvent struct { + Event + + Body BreakpointEventBody `json:"body"` +} + +type BreakpointEventBody struct { + Reason string `json:"reason"` + Breakpoint Breakpoint `json:"breakpoint"` +} + +func (e *BreakpointEvent) GetEvent() *Event { return &e.Event } + +// ModuleEvent: The event indicates that some information about a module has changed. +type ModuleEvent struct { + Event + + Body ModuleEventBody `json:"body"` +} + +type ModuleEventBody struct { + Reason string `json:"reason"` + Module Module `json:"module"` +} + +func (e *ModuleEvent) GetEvent() *Event { return &e.Event } + +// LoadedSourceEvent: The event indicates that some source has been added, changed, or removed from the set of all loaded sources. +type LoadedSourceEvent struct { + Event + + Body LoadedSourceEventBody `json:"body"` +} + +type LoadedSourceEventBody struct { + Reason string `json:"reason"` + Source Source `json:"source"` +} + +func (e *LoadedSourceEvent) GetEvent() *Event { return &e.Event } + +// ProcessEvent: The event indicates that the debugger has begun debugging a new process. Either one that it has launched, or one that it has attached to. +type ProcessEvent struct { + Event + + Body ProcessEventBody `json:"body"` +} + +type ProcessEventBody struct { + Name string `json:"name"` + SystemProcessId int `json:"systemProcessId,omitempty"` + IsLocalProcess bool `json:"isLocalProcess,omitempty"` + StartMethod string `json:"startMethod,omitempty"` + PointerSize int `json:"pointerSize,omitempty"` +} + +func (e *ProcessEvent) GetEvent() *Event { return &e.Event } + +// CapabilitiesEvent: The event indicates that one or more capabilities have changed. +// Since the capabilities are dependent on the frontend and its UI, it might not be possible to change that at random times (or too late). +// Consequently this event has a hint characteristic: a frontend can only be expected to make a 'best effort' in honouring individual capabilities but there are no guarantees. +// Only changed capabilities need to be included, all other capabilities keep their values. +type CapabilitiesEvent struct { + Event + + Body CapabilitiesEventBody `json:"body"` +} + +type CapabilitiesEventBody struct { + Capabilities Capabilities `json:"capabilities"` +} + +func (e *CapabilitiesEvent) GetEvent() *Event { return &e.Event } + +// ProgressStartEvent: The event signals that a long running operation is about to start and +// provides additional information for the client to set up a corresponding progress and cancellation UI. +// The client is free to delay the showing of the UI in order to reduce flicker. +// This event should only be sent if the client has passed the value true for the 'supportsProgressReporting' capability of the 'initialize' request. +type ProgressStartEvent struct { + Event + + Body ProgressStartEventBody `json:"body"` +} + +type ProgressStartEventBody struct { + ProgressId string `json:"progressId"` + Title string `json:"title"` + RequestId int `json:"requestId,omitempty"` + Cancellable bool `json:"cancellable,omitempty"` + Message string `json:"message,omitempty"` + Percentage int `json:"percentage,omitempty"` +} + +func (e *ProgressStartEvent) GetEvent() *Event { return &e.Event } + +// ProgressUpdateEvent: The event signals that the progress reporting needs to updated with a new message and/or percentage. +// The client does not have to update the UI immediately, but the clients needs to keep track of the message and/or percentage values. +// This event should only be sent if the client has passed the value true for the 'supportsProgressReporting' capability of the 'initialize' request. +type ProgressUpdateEvent struct { + Event + + Body ProgressUpdateEventBody `json:"body"` +} + +type ProgressUpdateEventBody struct { + ProgressId string `json:"progressId"` + Message string `json:"message,omitempty"` + Percentage int `json:"percentage,omitempty"` +} + +func (e *ProgressUpdateEvent) GetEvent() *Event { return &e.Event } + +// ProgressEndEvent: The event signals the end of the progress reporting with an optional final message. +// This event should only be sent if the client has passed the value true for the 'supportsProgressReporting' capability of the 'initialize' request. +type ProgressEndEvent struct { + Event + + Body ProgressEndEventBody `json:"body"` +} + +type ProgressEndEventBody struct { + ProgressId string `json:"progressId"` + Message string `json:"message,omitempty"` +} + +func (e *ProgressEndEvent) GetEvent() *Event { return &e.Event } + +// InvalidatedEvent: This event signals that some state in the debug adapter has changed and requires that the client needs to re-render the data snapshot previously requested. +// Debug adapters do not have to emit this event for runtime changes like stopped or thread events because in that case the client refetches the new state anyway. But the event can be used for example to refresh the UI after rendering formatting has changed in the debug adapter. +// This event should only be sent if the debug adapter has received a value true for the 'supportsInvalidatedEvent' capability of the 'initialize' request. +type InvalidatedEvent struct { + Event + + Body InvalidatedEventBody `json:"body"` +} + +type InvalidatedEventBody struct { + Areas []InvalidatedAreas `json:"areas,omitempty"` + ThreadId int `json:"threadId,omitempty"` + StackFrameId int `json:"stackFrameId,omitempty"` +} + +func (e *InvalidatedEvent) GetEvent() *Event { return &e.Event } + +// RunInTerminalRequest: This optional request is sent from the debug adapter to the client to run a command in a terminal. +// This is typically used to launch the debuggee in a terminal provided by the client. +// This request should only be called if the client has passed the value true for the 'supportsRunInTerminalRequest' capability of the 'initialize' request. +type RunInTerminalRequest struct { + Request + + Arguments RunInTerminalRequestArguments `json:"arguments"` +} + +func (r *RunInTerminalRequest) GetRequest() *Request { return &r.Request } + +// RunInTerminalRequestArguments: Arguments for 'runInTerminal' request. +type RunInTerminalRequestArguments struct { + Kind string `json:"kind,omitempty"` + Title string `json:"title,omitempty"` + Cwd string `json:"cwd"` + Args []string `json:"args"` + Env map[string]interface{} `json:"env,omitempty"` +} + +// RunInTerminalResponse: Response to 'runInTerminal' request. +type RunInTerminalResponse struct { + Response + + Body RunInTerminalResponseBody `json:"body"` +} + +type RunInTerminalResponseBody struct { + ProcessId int `json:"processId,omitempty"` + ShellProcessId int `json:"shellProcessId,omitempty"` +} + +func (r *RunInTerminalResponse) GetResponse() *Response { return &r.Response } + +// InitializeRequest: The 'initialize' request is sent as the first request from the client to the debug adapter +// in order to configure it with client capabilities and to retrieve capabilities from the debug adapter. +// Until the debug adapter has responded to with an 'initialize' response, the client must not send any additional requests or events to the debug adapter. +// In addition the debug adapter is not allowed to send any requests or events to the client until it has responded with an 'initialize' response. +// The 'initialize' request may only be sent once. +type InitializeRequest struct { + Request + + Arguments InitializeRequestArguments `json:"arguments"` +} + +func (r *InitializeRequest) GetRequest() *Request { return &r.Request } + +// InitializeRequestArguments: Arguments for 'initialize' request. +type InitializeRequestArguments struct { + ClientID string `json:"clientID,omitempty"` + ClientName string `json:"clientName,omitempty"` + AdapterID string `json:"adapterID"` + Locale string `json:"locale,omitempty"` + LinesStartAt1 bool `json:"linesStartAt1"` + ColumnsStartAt1 bool `json:"columnsStartAt1"` + PathFormat string `json:"pathFormat,omitempty"` + SupportsVariableType bool `json:"supportsVariableType,omitempty"` + SupportsVariablePaging bool `json:"supportsVariablePaging,omitempty"` + SupportsRunInTerminalRequest bool `json:"supportsRunInTerminalRequest,omitempty"` + SupportsMemoryReferences bool `json:"supportsMemoryReferences,omitempty"` + SupportsProgressReporting bool `json:"supportsProgressReporting,omitempty"` + SupportsInvalidatedEvent bool `json:"supportsInvalidatedEvent,omitempty"` +} + +// InitializeResponse: Response to 'initialize' request. +type InitializeResponse struct { + Response + + Body Capabilities `json:"body,omitempty"` +} + +func (r *InitializeResponse) GetResponse() *Response { return &r.Response } + +// ConfigurationDoneRequest: This optional request indicates that the client has finished initialization of the debug adapter. +// So it is the last request in the sequence of configuration requests (which was started by the 'initialized' event). +// Clients should only call this request if the capability 'supportsConfigurationDoneRequest' is true. +type ConfigurationDoneRequest struct { + Request + + Arguments ConfigurationDoneArguments `json:"arguments,omitempty"` +} + +func (r *ConfigurationDoneRequest) GetRequest() *Request { return &r.Request } + +// ConfigurationDoneArguments: Arguments for 'configurationDone' request. +type ConfigurationDoneArguments struct { +} + +// ConfigurationDoneResponse: Response to 'configurationDone' request. This is just an acknowledgement, so no body field is required. +type ConfigurationDoneResponse struct { + Response +} + +func (r *ConfigurationDoneResponse) GetResponse() *Response { return &r.Response } + +// LaunchRequest: This launch request is sent from the client to the debug adapter to start the debuggee with or without debugging (if 'noDebug' is true). +// Since launching is debugger/runtime specific, the arguments for this request are not part of this specification. +type LaunchRequest struct { + Request + + Arguments map[string]interface{} `json:"arguments"` +} + +func (r *LaunchRequest) GetRequest() *Request { return &r.Request } +func (r *LaunchRequest) GetArguments() map[string]interface{} { return r.Arguments } + +// LaunchResponse: Response to 'launch' request. This is just an acknowledgement, so no body field is required. +type LaunchResponse struct { + Response +} + +func (r *LaunchResponse) GetResponse() *Response { return &r.Response } + +// AttachRequest: The attach request is sent from the client to the debug adapter to attach to a debuggee that is already running. +// Since attaching is debugger/runtime specific, the arguments for this request are not part of this specification. +type AttachRequest struct { + Request + + Arguments map[string]interface{} `json:"arguments"` +} + +func (r *AttachRequest) GetRequest() *Request { return &r.Request } +func (r *AttachRequest) GetArguments() map[string]interface{} { return r.Arguments } + +// AttachResponse: Response to 'attach' request. This is just an acknowledgement, so no body field is required. +type AttachResponse struct { + Response +} + +func (r *AttachResponse) GetResponse() *Response { return &r.Response } + +// RestartRequest: Restarts a debug session. Clients should only call this request if the capability 'supportsRestartRequest' is true. +// If the capability is missing or has the value false, a typical client will emulate 'restart' by terminating the debug adapter first and then launching it anew. +type RestartRequest struct { + Request + + Arguments RestartArguments `json:"arguments,omitempty"` +} + +func (r *RestartRequest) GetRequest() *Request { return &r.Request } + +// RestartArguments: Arguments for 'restart' request. +type RestartArguments struct { + Arguments interface{} `json:"arguments,omitempty"` +} + +// RestartResponse: Response to 'restart' request. This is just an acknowledgement, so no body field is required. +type RestartResponse struct { + Response +} + +func (r *RestartResponse) GetResponse() *Response { return &r.Response } + +// DisconnectRequest: The 'disconnect' request is sent from the client to the debug adapter in order to stop debugging. +// It asks the debug adapter to disconnect from the debuggee and to terminate the debug adapter. +// If the debuggee has been started with the 'launch' request, the 'disconnect' request terminates the debuggee. +// If the 'attach' request was used to connect to the debuggee, 'disconnect' does not terminate the debuggee. +// This behavior can be controlled with the 'terminateDebuggee' argument (if supported by the debug adapter). +type DisconnectRequest struct { + Request + + Arguments DisconnectArguments `json:"arguments,omitempty"` +} + +func (r *DisconnectRequest) GetRequest() *Request { return &r.Request } + +// DisconnectArguments: Arguments for 'disconnect' request. +type DisconnectArguments struct { + Restart bool `json:"restart,omitempty"` + TerminateDebuggee bool `json:"terminateDebuggee,omitempty"` + SuspendDebuggee bool `json:"suspendDebuggee,omitempty"` +} + +// DisconnectResponse: Response to 'disconnect' request. This is just an acknowledgement, so no body field is required. +type DisconnectResponse struct { + Response +} + +func (r *DisconnectResponse) GetResponse() *Response { return &r.Response } + +// TerminateRequest: The 'terminate' request is sent from the client to the debug adapter in order to give the debuggee a chance for terminating itself. +// Clients should only call this request if the capability 'supportsTerminateRequest' is true. +type TerminateRequest struct { + Request + + Arguments TerminateArguments `json:"arguments,omitempty"` +} + +func (r *TerminateRequest) GetRequest() *Request { return &r.Request } + +// TerminateArguments: Arguments for 'terminate' request. +type TerminateArguments struct { + Restart bool `json:"restart,omitempty"` +} + +// TerminateResponse: Response to 'terminate' request. This is just an acknowledgement, so no body field is required. +type TerminateResponse struct { + Response +} + +func (r *TerminateResponse) GetResponse() *Response { return &r.Response } + +// BreakpointLocationsRequest: The 'breakpointLocations' request returns all possible locations for source breakpoints in a given range. +// Clients should only call this request if the capability 'supportsBreakpointLocationsRequest' is true. +type BreakpointLocationsRequest struct { + Request + + Arguments BreakpointLocationsArguments `json:"arguments,omitempty"` +} + +func (r *BreakpointLocationsRequest) GetRequest() *Request { return &r.Request } + +// BreakpointLocationsArguments: Arguments for 'breakpointLocations' request. +type BreakpointLocationsArguments struct { + Source Source `json:"source"` + Line int `json:"line"` + Column int `json:"column,omitempty"` + EndLine int `json:"endLine,omitempty"` + EndColumn int `json:"endColumn,omitempty"` +} + +// BreakpointLocationsResponse: Response to 'breakpointLocations' request. +// Contains possible locations for source breakpoints. +type BreakpointLocationsResponse struct { + Response + + Body BreakpointLocationsResponseBody `json:"body"` +} + +type BreakpointLocationsResponseBody struct { + Breakpoints []BreakpointLocation `json:"breakpoints"` +} + +func (r *BreakpointLocationsResponse) GetResponse() *Response { return &r.Response } + +// SetBreakpointsRequest: Sets multiple breakpoints for a single source and clears all previous breakpoints in that source. +// To clear all breakpoint for a source, specify an empty array. +// When a breakpoint is hit, a 'stopped' event (with reason 'breakpoint') is generated. +type SetBreakpointsRequest struct { + Request + + Arguments SetBreakpointsArguments `json:"arguments"` +} + +func (r *SetBreakpointsRequest) GetRequest() *Request { return &r.Request } + +// SetBreakpointsArguments: Arguments for 'setBreakpoints' request. +type SetBreakpointsArguments struct { + Source Source `json:"source"` + Breakpoints []SourceBreakpoint `json:"breakpoints,omitempty"` + Lines []int `json:"lines,omitempty"` + SourceModified bool `json:"sourceModified,omitempty"` +} + +// SetBreakpointsResponse: Response to 'setBreakpoints' request. +// Returned is information about each breakpoint created by this request. +// This includes the actual code location and whether the breakpoint could be verified. +// The breakpoints returned are in the same order as the elements of the 'breakpoints' +// (or the deprecated 'lines') array in the arguments. +type SetBreakpointsResponse struct { + Response + + Body SetBreakpointsResponseBody `json:"body"` +} + +type SetBreakpointsResponseBody struct { + Breakpoints []Breakpoint `json:"breakpoints"` +} + +func (r *SetBreakpointsResponse) GetResponse() *Response { return &r.Response } + +// SetFunctionBreakpointsRequest: Replaces all existing function breakpoints with new function breakpoints. +// To clear all function breakpoints, specify an empty array. +// When a function breakpoint is hit, a 'stopped' event (with reason 'function breakpoint') is generated. +// Clients should only call this request if the capability 'supportsFunctionBreakpoints' is true. +type SetFunctionBreakpointsRequest struct { + Request + + Arguments SetFunctionBreakpointsArguments `json:"arguments"` +} + +func (r *SetFunctionBreakpointsRequest) GetRequest() *Request { return &r.Request } + +// SetFunctionBreakpointsArguments: Arguments for 'setFunctionBreakpoints' request. +type SetFunctionBreakpointsArguments struct { + Breakpoints []FunctionBreakpoint `json:"breakpoints"` +} + +// SetFunctionBreakpointsResponse: Response to 'setFunctionBreakpoints' request. +// Returned is information about each breakpoint created by this request. +type SetFunctionBreakpointsResponse struct { + Response + + Body SetFunctionBreakpointsResponseBody `json:"body"` +} + +type SetFunctionBreakpointsResponseBody struct { + Breakpoints []Breakpoint `json:"breakpoints"` +} + +func (r *SetFunctionBreakpointsResponse) GetResponse() *Response { return &r.Response } + +// SetExceptionBreakpointsRequest: The request configures the debuggers response to thrown exceptions. +// If an exception is configured to break, a 'stopped' event is fired (with reason 'exception'). +// Clients should only call this request if the capability 'exceptionBreakpointFilters' returns one or more filters. +type SetExceptionBreakpointsRequest struct { + Request + + Arguments SetExceptionBreakpointsArguments `json:"arguments"` +} + +func (r *SetExceptionBreakpointsRequest) GetRequest() *Request { return &r.Request } + +// SetExceptionBreakpointsArguments: Arguments for 'setExceptionBreakpoints' request. +type SetExceptionBreakpointsArguments struct { + Filters []string `json:"filters"` + FilterOptions []ExceptionFilterOptions `json:"filterOptions,omitempty"` + ExceptionOptions []ExceptionOptions `json:"exceptionOptions,omitempty"` +} + +// SetExceptionBreakpointsResponse: Response to 'setExceptionBreakpoints' request. +// The response contains an array of Breakpoint objects with information about each exception breakpoint or filter. The Breakpoint objects are in the same order as the elements of the 'filters', 'filterOptions', 'exceptionOptions' arrays given as arguments. If both 'filters' and 'filterOptions' are given, the returned array must start with 'filters' information first, followed by 'filterOptions' information. +// The mandatory 'verified' property of a Breakpoint object signals whether the exception breakpoint or filter could be successfully created and whether the optional condition or hit count expressions are valid. In case of an error the 'message' property explains the problem. An optional 'id' property can be used to introduce a unique ID for the exception breakpoint or filter so that it can be updated subsequently by sending breakpoint events. +// For backward compatibility both the 'breakpoints' array and the enclosing 'body' are optional. If these elements are missing a client will not be able to show problems for individual exception breakpoints or filters. +type SetExceptionBreakpointsResponse struct { + Response + + Body SetExceptionBreakpointsResponseBody `json:"body,omitempty"` +} + +type SetExceptionBreakpointsResponseBody struct { + Breakpoints []Breakpoint `json:"breakpoints,omitempty"` +} + +func (r *SetExceptionBreakpointsResponse) GetResponse() *Response { return &r.Response } + +// DataBreakpointInfoRequest: Obtains information on a possible data breakpoint that could be set on an expression or variable. +// Clients should only call this request if the capability 'supportsDataBreakpoints' is true. +type DataBreakpointInfoRequest struct { + Request + + Arguments DataBreakpointInfoArguments `json:"arguments"` +} + +func (r *DataBreakpointInfoRequest) GetRequest() *Request { return &r.Request } + +// DataBreakpointInfoArguments: Arguments for 'dataBreakpointInfo' request. +type DataBreakpointInfoArguments struct { + VariablesReference int `json:"variablesReference,omitempty"` + Name string `json:"name"` +} + +// DataBreakpointInfoResponse: Response to 'dataBreakpointInfo' request. +type DataBreakpointInfoResponse struct { + Response + + Body DataBreakpointInfoResponseBody `json:"body"` +} + +type DataBreakpointInfoResponseBody struct { + DataId interface{} `json:"dataId"` + Description string `json:"description"` + AccessTypes []DataBreakpointAccessType `json:"accessTypes,omitempty"` + CanPersist bool `json:"canPersist,omitempty"` +} + +func (r *DataBreakpointInfoResponse) GetResponse() *Response { return &r.Response } + +// SetDataBreakpointsRequest: Replaces all existing data breakpoints with new data breakpoints. +// To clear all data breakpoints, specify an empty array. +// When a data breakpoint is hit, a 'stopped' event (with reason 'data breakpoint') is generated. +// Clients should only call this request if the capability 'supportsDataBreakpoints' is true. +type SetDataBreakpointsRequest struct { + Request + + Arguments SetDataBreakpointsArguments `json:"arguments"` +} + +func (r *SetDataBreakpointsRequest) GetRequest() *Request { return &r.Request } + +// SetDataBreakpointsArguments: Arguments for 'setDataBreakpoints' request. +type SetDataBreakpointsArguments struct { + Breakpoints []DataBreakpoint `json:"breakpoints"` +} + +// SetDataBreakpointsResponse: Response to 'setDataBreakpoints' request. +// Returned is information about each breakpoint created by this request. +type SetDataBreakpointsResponse struct { + Response + + Body SetDataBreakpointsResponseBody `json:"body"` +} + +type SetDataBreakpointsResponseBody struct { + Breakpoints []Breakpoint `json:"breakpoints"` +} + +func (r *SetDataBreakpointsResponse) GetResponse() *Response { return &r.Response } + +// SetInstructionBreakpointsRequest: Replaces all existing instruction breakpoints. Typically, instruction breakpoints would be set from a diassembly window. +// To clear all instruction breakpoints, specify an empty array. +// When an instruction breakpoint is hit, a 'stopped' event (with reason 'instruction breakpoint') is generated. +// Clients should only call this request if the capability 'supportsInstructionBreakpoints' is true. +type SetInstructionBreakpointsRequest struct { + Request + + Arguments SetInstructionBreakpointsArguments `json:"arguments"` +} + +func (r *SetInstructionBreakpointsRequest) GetRequest() *Request { return &r.Request } + +// SetInstructionBreakpointsArguments: Arguments for 'setInstructionBreakpoints' request +type SetInstructionBreakpointsArguments struct { + Breakpoints []InstructionBreakpoint `json:"breakpoints"` +} + +// SetInstructionBreakpointsResponse: Response to 'setInstructionBreakpoints' request +type SetInstructionBreakpointsResponse struct { + Response + + Body SetInstructionBreakpointsResponseBody `json:"body"` +} + +type SetInstructionBreakpointsResponseBody struct { + Breakpoints []Breakpoint `json:"breakpoints"` +} + +func (r *SetInstructionBreakpointsResponse) GetResponse() *Response { return &r.Response } + +// ContinueRequest: The request starts the debuggee to run again. +type ContinueRequest struct { + Request + + Arguments ContinueArguments `json:"arguments"` +} + +func (r *ContinueRequest) GetRequest() *Request { return &r.Request } + +// ContinueArguments: Arguments for 'continue' request. +type ContinueArguments struct { + ThreadId int `json:"threadId"` +} + +// ContinueResponse: Response to 'continue' request. +type ContinueResponse struct { + Response + + Body ContinueResponseBody `json:"body"` +} + +type ContinueResponseBody struct { + AllThreadsContinued bool `json:"allThreadsContinued"` +} + +func (r *ContinueResponse) GetResponse() *Response { return &r.Response } + +// NextRequest: The request starts the debuggee to run again for one step. +// The debug adapter first sends the response and then a 'stopped' event (with reason 'step') after the step has completed. +type NextRequest struct { + Request + + Arguments NextArguments `json:"arguments"` +} + +func (r *NextRequest) GetRequest() *Request { return &r.Request } + +// NextArguments: Arguments for 'next' request. +type NextArguments struct { + ThreadId int `json:"threadId"` + Granularity SteppingGranularity `json:"granularity,omitempty"` +} + +// NextResponse: Response to 'next' request. This is just an acknowledgement, so no body field is required. +type NextResponse struct { + Response +} + +func (r *NextResponse) GetResponse() *Response { return &r.Response } + +// StepInRequest: The request starts the debuggee to step into a function/method if possible. +// If it cannot step into a target, 'stepIn' behaves like 'next'. +// The debug adapter first sends the response and then a 'stopped' event (with reason 'step') after the step has completed. +// If there are multiple function/method calls (or other targets) on the source line, +// the optional argument 'targetId' can be used to control into which target the 'stepIn' should occur. +// The list of possible targets for a given source line can be retrieved via the 'stepInTargets' request. +type StepInRequest struct { + Request + + Arguments StepInArguments `json:"arguments"` +} + +func (r *StepInRequest) GetRequest() *Request { return &r.Request } + +// StepInArguments: Arguments for 'stepIn' request. +type StepInArguments struct { + ThreadId int `json:"threadId"` + TargetId int `json:"targetId,omitempty"` + Granularity SteppingGranularity `json:"granularity,omitempty"` +} + +// StepInResponse: Response to 'stepIn' request. This is just an acknowledgement, so no body field is required. +type StepInResponse struct { + Response +} + +func (r *StepInResponse) GetResponse() *Response { return &r.Response } + +// StepOutRequest: The request starts the debuggee to run again for one step. +// The debug adapter first sends the response and then a 'stopped' event (with reason 'step') after the step has completed. +type StepOutRequest struct { + Request + + Arguments StepOutArguments `json:"arguments"` +} + +func (r *StepOutRequest) GetRequest() *Request { return &r.Request } + +// StepOutArguments: Arguments for 'stepOut' request. +type StepOutArguments struct { + ThreadId int `json:"threadId"` + Granularity SteppingGranularity `json:"granularity,omitempty"` +} + +// StepOutResponse: Response to 'stepOut' request. This is just an acknowledgement, so no body field is required. +type StepOutResponse struct { + Response +} + +func (r *StepOutResponse) GetResponse() *Response { return &r.Response } + +// StepBackRequest: The request starts the debuggee to run one step backwards. +// The debug adapter first sends the response and then a 'stopped' event (with reason 'step') after the step has completed. +// Clients should only call this request if the capability 'supportsStepBack' is true. +type StepBackRequest struct { + Request + + Arguments StepBackArguments `json:"arguments"` +} + +func (r *StepBackRequest) GetRequest() *Request { return &r.Request } + +// StepBackArguments: Arguments for 'stepBack' request. +type StepBackArguments struct { + ThreadId int `json:"threadId"` + Granularity SteppingGranularity `json:"granularity,omitempty"` +} + +// StepBackResponse: Response to 'stepBack' request. This is just an acknowledgement, so no body field is required. +type StepBackResponse struct { + Response +} + +func (r *StepBackResponse) GetResponse() *Response { return &r.Response } + +// ReverseContinueRequest: The request starts the debuggee to run backward. +// Clients should only call this request if the capability 'supportsStepBack' is true. +type ReverseContinueRequest struct { + Request + + Arguments ReverseContinueArguments `json:"arguments"` +} + +func (r *ReverseContinueRequest) GetRequest() *Request { return &r.Request } + +// ReverseContinueArguments: Arguments for 'reverseContinue' request. +type ReverseContinueArguments struct { + ThreadId int `json:"threadId"` +} + +// ReverseContinueResponse: Response to 'reverseContinue' request. This is just an acknowledgement, so no body field is required. +type ReverseContinueResponse struct { + Response +} + +func (r *ReverseContinueResponse) GetResponse() *Response { return &r.Response } + +// RestartFrameRequest: The request restarts execution of the specified stackframe. +// The debug adapter first sends the response and then a 'stopped' event (with reason 'restart') after the restart has completed. +// Clients should only call this request if the capability 'supportsRestartFrame' is true. +type RestartFrameRequest struct { + Request + + Arguments RestartFrameArguments `json:"arguments"` +} + +func (r *RestartFrameRequest) GetRequest() *Request { return &r.Request } + +// RestartFrameArguments: Arguments for 'restartFrame' request. +type RestartFrameArguments struct { + FrameId int `json:"frameId"` +} + +// RestartFrameResponse: Response to 'restartFrame' request. This is just an acknowledgement, so no body field is required. +type RestartFrameResponse struct { + Response +} + +func (r *RestartFrameResponse) GetResponse() *Response { return &r.Response } + +// GotoRequest: The request sets the location where the debuggee will continue to run. +// This makes it possible to skip the execution of code or to executed code again. +// The code between the current location and the goto target is not executed but skipped. +// The debug adapter first sends the response and then a 'stopped' event with reason 'goto'. +// Clients should only call this request if the capability 'supportsGotoTargetsRequest' is true (because only then goto targets exist that can be passed as arguments). +type GotoRequest struct { + Request + + Arguments GotoArguments `json:"arguments"` +} + +func (r *GotoRequest) GetRequest() *Request { return &r.Request } + +// GotoArguments: Arguments for 'goto' request. +type GotoArguments struct { + ThreadId int `json:"threadId"` + TargetId int `json:"targetId"` +} + +// GotoResponse: Response to 'goto' request. This is just an acknowledgement, so no body field is required. +type GotoResponse struct { + Response +} + +func (r *GotoResponse) GetResponse() *Response { return &r.Response } + +// PauseRequest: The request suspends the debuggee. +// The debug adapter first sends the response and then a 'stopped' event (with reason 'pause') after the thread has been paused successfully. +type PauseRequest struct { + Request + + Arguments PauseArguments `json:"arguments"` +} + +func (r *PauseRequest) GetRequest() *Request { return &r.Request } + +// PauseArguments: Arguments for 'pause' request. +type PauseArguments struct { + ThreadId int `json:"threadId"` +} + +// PauseResponse: Response to 'pause' request. This is just an acknowledgement, so no body field is required. +type PauseResponse struct { + Response +} + +func (r *PauseResponse) GetResponse() *Response { return &r.Response } + +// StackTraceRequest: The request returns a stacktrace from the current execution state of a given thread. +// A client can request all stack frames by omitting the startFrame and levels arguments. For performance conscious clients and if the debug adapter's 'supportsDelayedStackTraceLoading' capability is true, stack frames can be retrieved in a piecemeal way with the startFrame and levels arguments. The response of the stackTrace request may contain a totalFrames property that hints at the total number of frames in the stack. If a client needs this total number upfront, it can issue a request for a single (first) frame and depending on the value of totalFrames decide how to proceed. In any case a client should be prepared to receive less frames than requested, which is an indication that the end of the stack has been reached. +type StackTraceRequest struct { + Request + + Arguments StackTraceArguments `json:"arguments"` +} + +func (r *StackTraceRequest) GetRequest() *Request { return &r.Request } + +// StackTraceArguments: Arguments for 'stackTrace' request. +type StackTraceArguments struct { + ThreadId int `json:"threadId"` + StartFrame int `json:"startFrame,omitempty"` + Levels int `json:"levels,omitempty"` + Format StackFrameFormat `json:"format,omitempty"` +} + +// StackTraceResponse: Response to 'stackTrace' request. +type StackTraceResponse struct { + Response + + Body StackTraceResponseBody `json:"body"` +} + +type StackTraceResponseBody struct { + StackFrames []StackFrame `json:"stackFrames"` + TotalFrames int `json:"totalFrames,omitempty"` +} + +func (r *StackTraceResponse) GetResponse() *Response { return &r.Response } + +// ScopesRequest: The request returns the variable scopes for a given stackframe ID. +type ScopesRequest struct { + Request + + Arguments ScopesArguments `json:"arguments"` +} + +func (r *ScopesRequest) GetRequest() *Request { return &r.Request } + +// ScopesArguments: Arguments for 'scopes' request. +type ScopesArguments struct { + FrameId int `json:"frameId"` +} + +// ScopesResponse: Response to 'scopes' request. +type ScopesResponse struct { + Response + + Body ScopesResponseBody `json:"body"` +} + +type ScopesResponseBody struct { + Scopes []Scope `json:"scopes"` +} + +func (r *ScopesResponse) GetResponse() *Response { return &r.Response } + +// VariablesRequest: Retrieves all child variables for the given variable reference. +// An optional filter can be used to limit the fetched children to either named or indexed children. +type VariablesRequest struct { + Request + + Arguments VariablesArguments `json:"arguments"` +} + +func (r *VariablesRequest) GetRequest() *Request { return &r.Request } + +// VariablesArguments: Arguments for 'variables' request. +type VariablesArguments struct { + VariablesReference int `json:"variablesReference"` + Filter string `json:"filter,omitempty"` + Start int `json:"start,omitempty"` + Count int `json:"count,omitempty"` + Format ValueFormat `json:"format,omitempty"` +} + +// VariablesResponse: Response to 'variables' request. +type VariablesResponse struct { + Response + + Body VariablesResponseBody `json:"body"` +} + +type VariablesResponseBody struct { + Variables []Variable `json:"variables"` +} + +func (r *VariablesResponse) GetResponse() *Response { return &r.Response } + +// SetVariableRequest: Set the variable with the given name in the variable container to a new value. Clients should only call this request if the capability 'supportsSetVariable' is true. +type SetVariableRequest struct { + Request + + Arguments SetVariableArguments `json:"arguments"` +} + +func (r *SetVariableRequest) GetRequest() *Request { return &r.Request } + +// SetVariableArguments: Arguments for 'setVariable' request. +type SetVariableArguments struct { + VariablesReference int `json:"variablesReference"` + Name string `json:"name"` + Value string `json:"value"` + Format ValueFormat `json:"format,omitempty"` +} + +// SetVariableResponse: Response to 'setVariable' request. +type SetVariableResponse struct { + Response + + Body SetVariableResponseBody `json:"body"` +} + +type SetVariableResponseBody struct { + Value string `json:"value"` + Type string `json:"type,omitempty"` + VariablesReference int `json:"variablesReference,omitempty"` + NamedVariables int `json:"namedVariables,omitempty"` + IndexedVariables int `json:"indexedVariables,omitempty"` +} + +func (r *SetVariableResponse) GetResponse() *Response { return &r.Response } + +// SourceRequest: The request retrieves the source code for a given source reference. +type SourceRequest struct { + Request + + Arguments SourceArguments `json:"arguments"` +} + +func (r *SourceRequest) GetRequest() *Request { return &r.Request } + +// SourceArguments: Arguments for 'source' request. +type SourceArguments struct { + Source Source `json:"source,omitempty"` + SourceReference int `json:"sourceReference"` +} + +// SourceResponse: Response to 'source' request. +type SourceResponse struct { + Response + + Body SourceResponseBody `json:"body"` +} + +type SourceResponseBody struct { + Content string `json:"content"` + MimeType string `json:"mimeType,omitempty"` +} + +func (r *SourceResponse) GetResponse() *Response { return &r.Response } + +// ThreadsRequest: The request retrieves a list of all threads. +type ThreadsRequest struct { + Request +} + +func (r *ThreadsRequest) GetRequest() *Request { return &r.Request } + +// ThreadsResponse: Response to 'threads' request. +type ThreadsResponse struct { + Response + + Body ThreadsResponseBody `json:"body"` +} + +type ThreadsResponseBody struct { + Threads []Thread `json:"threads"` +} + +func (r *ThreadsResponse) GetResponse() *Response { return &r.Response } + +// TerminateThreadsRequest: The request terminates the threads with the given ids. +// Clients should only call this request if the capability 'supportsTerminateThreadsRequest' is true. +type TerminateThreadsRequest struct { + Request + + Arguments TerminateThreadsArguments `json:"arguments"` +} + +func (r *TerminateThreadsRequest) GetRequest() *Request { return &r.Request } + +// TerminateThreadsArguments: Arguments for 'terminateThreads' request. +type TerminateThreadsArguments struct { + ThreadIds []int `json:"threadIds,omitempty"` +} + +// TerminateThreadsResponse: Response to 'terminateThreads' request. This is just an acknowledgement, so no body field is required. +type TerminateThreadsResponse struct { + Response +} + +func (r *TerminateThreadsResponse) GetResponse() *Response { return &r.Response } + +// ModulesRequest: Modules can be retrieved from the debug adapter with this request which can either return all modules or a range of modules to support paging. +// Clients should only call this request if the capability 'supportsModulesRequest' is true. +type ModulesRequest struct { + Request + + Arguments ModulesArguments `json:"arguments"` +} + +func (r *ModulesRequest) GetRequest() *Request { return &r.Request } + +// ModulesArguments: Arguments for 'modules' request. +type ModulesArguments struct { + StartModule int `json:"startModule,omitempty"` + ModuleCount int `json:"moduleCount,omitempty"` +} + +// ModulesResponse: Response to 'modules' request. +type ModulesResponse struct { + Response + + Body ModulesResponseBody `json:"body"` +} + +type ModulesResponseBody struct { + Modules []Module `json:"modules"` + TotalModules int `json:"totalModules,omitempty"` +} + +func (r *ModulesResponse) GetResponse() *Response { return &r.Response } + +// LoadedSourcesRequest: Retrieves the set of all sources currently loaded by the debugged process. +// Clients should only call this request if the capability 'supportsLoadedSourcesRequest' is true. +type LoadedSourcesRequest struct { + Request + + Arguments LoadedSourcesArguments `json:"arguments,omitempty"` +} + +func (r *LoadedSourcesRequest) GetRequest() *Request { return &r.Request } + +// LoadedSourcesArguments: Arguments for 'loadedSources' request. +type LoadedSourcesArguments struct { +} + +// LoadedSourcesResponse: Response to 'loadedSources' request. +type LoadedSourcesResponse struct { + Response + + Body LoadedSourcesResponseBody `json:"body"` +} + +type LoadedSourcesResponseBody struct { + Sources []Source `json:"sources"` +} + +func (r *LoadedSourcesResponse) GetResponse() *Response { return &r.Response } + +// EvaluateRequest: Evaluates the given expression in the context of the top most stack frame. +// The expression has access to any variables and arguments that are in scope. +type EvaluateRequest struct { + Request + + Arguments EvaluateArguments `json:"arguments"` +} + +func (r *EvaluateRequest) GetRequest() *Request { return &r.Request } + +// EvaluateArguments: Arguments for 'evaluate' request. +type EvaluateArguments struct { + Expression string `json:"expression"` + FrameId int `json:"frameId,omitempty"` + Context string `json:"context,omitempty"` + Format ValueFormat `json:"format,omitempty"` +} + +// EvaluateResponse: Response to 'evaluate' request. +type EvaluateResponse struct { + Response + + Body EvaluateResponseBody `json:"body"` +} + +type EvaluateResponseBody struct { + Result string `json:"result"` + Type string `json:"type,omitempty"` + PresentationHint VariablePresentationHint `json:"presentationHint,omitempty"` + VariablesReference int `json:"variablesReference"` + NamedVariables int `json:"namedVariables,omitempty"` + IndexedVariables int `json:"indexedVariables,omitempty"` + MemoryReference string `json:"memoryReference,omitempty"` +} + +func (r *EvaluateResponse) GetResponse() *Response { return &r.Response } + +// SetExpressionRequest: Evaluates the given 'value' expression and assigns it to the 'expression' which must be a modifiable l-value. +// The expressions have access to any variables and arguments that are in scope of the specified frame. +// Clients should only call this request if the capability 'supportsSetExpression' is true. +type SetExpressionRequest struct { + Request + + Arguments SetExpressionArguments `json:"arguments"` +} + +func (r *SetExpressionRequest) GetRequest() *Request { return &r.Request } + +// SetExpressionArguments: Arguments for 'setExpression' request. +type SetExpressionArguments struct { + Expression string `json:"expression"` + Value string `json:"value"` + FrameId int `json:"frameId,omitempty"` + Format ValueFormat `json:"format,omitempty"` +} + +// SetExpressionResponse: Response to 'setExpression' request. +type SetExpressionResponse struct { + Response + + Body SetExpressionResponseBody `json:"body"` +} + +type SetExpressionResponseBody struct { + Value string `json:"value"` + Type string `json:"type,omitempty"` + PresentationHint VariablePresentationHint `json:"presentationHint,omitempty"` + VariablesReference int `json:"variablesReference,omitempty"` + NamedVariables int `json:"namedVariables,omitempty"` + IndexedVariables int `json:"indexedVariables,omitempty"` +} + +func (r *SetExpressionResponse) GetResponse() *Response { return &r.Response } + +// StepInTargetsRequest: This request retrieves the possible stepIn targets for the specified stack frame. +// These targets can be used in the 'stepIn' request. +// The StepInTargets may only be called if the 'supportsStepInTargetsRequest' capability exists and is true. +// Clients should only call this request if the capability 'supportsStepInTargetsRequest' is true. +type StepInTargetsRequest struct { + Request + + Arguments StepInTargetsArguments `json:"arguments"` +} + +func (r *StepInTargetsRequest) GetRequest() *Request { return &r.Request } + +// StepInTargetsArguments: Arguments for 'stepInTargets' request. +type StepInTargetsArguments struct { + FrameId int `json:"frameId"` +} + +// StepInTargetsResponse: Response to 'stepInTargets' request. +type StepInTargetsResponse struct { + Response + + Body StepInTargetsResponseBody `json:"body"` +} + +type StepInTargetsResponseBody struct { + Targets []StepInTarget `json:"targets"` +} + +func (r *StepInTargetsResponse) GetResponse() *Response { return &r.Response } + +// GotoTargetsRequest: This request retrieves the possible goto targets for the specified source location. +// These targets can be used in the 'goto' request. +// Clients should only call this request if the capability 'supportsGotoTargetsRequest' is true. +type GotoTargetsRequest struct { + Request + + Arguments GotoTargetsArguments `json:"arguments"` +} + +func (r *GotoTargetsRequest) GetRequest() *Request { return &r.Request } + +// GotoTargetsArguments: Arguments for 'gotoTargets' request. +type GotoTargetsArguments struct { + Source Source `json:"source"` + Line int `json:"line"` + Column int `json:"column,omitempty"` +} + +// GotoTargetsResponse: Response to 'gotoTargets' request. +type GotoTargetsResponse struct { + Response + + Body GotoTargetsResponseBody `json:"body"` +} + +type GotoTargetsResponseBody struct { + Targets []GotoTarget `json:"targets"` +} + +func (r *GotoTargetsResponse) GetResponse() *Response { return &r.Response } + +// CompletionsRequest: Returns a list of possible completions for a given caret position and text. +// Clients should only call this request if the capability 'supportsCompletionsRequest' is true. +type CompletionsRequest struct { + Request + + Arguments CompletionsArguments `json:"arguments"` +} + +func (r *CompletionsRequest) GetRequest() *Request { return &r.Request } + +// CompletionsArguments: Arguments for 'completions' request. +type CompletionsArguments struct { + FrameId int `json:"frameId,omitempty"` + Text string `json:"text"` + Column int `json:"column"` + Line int `json:"line,omitempty"` +} + +// CompletionsResponse: Response to 'completions' request. +type CompletionsResponse struct { + Response + + Body CompletionsResponseBody `json:"body"` +} + +type CompletionsResponseBody struct { + Targets []CompletionItem `json:"targets"` +} + +func (r *CompletionsResponse) GetResponse() *Response { return &r.Response } + +// ExceptionInfoRequest: Retrieves the details of the exception that caused this event to be raised. +// Clients should only call this request if the capability 'supportsExceptionInfoRequest' is true. +type ExceptionInfoRequest struct { + Request + + Arguments ExceptionInfoArguments `json:"arguments"` +} + +func (r *ExceptionInfoRequest) GetRequest() *Request { return &r.Request } + +// ExceptionInfoArguments: Arguments for 'exceptionInfo' request. +type ExceptionInfoArguments struct { + ThreadId int `json:"threadId"` +} + +// ExceptionInfoResponse: Response to 'exceptionInfo' request. +type ExceptionInfoResponse struct { + Response + + Body ExceptionInfoResponseBody `json:"body"` +} + +type ExceptionInfoResponseBody struct { + ExceptionId string `json:"exceptionId"` + Description string `json:"description,omitempty"` + BreakMode ExceptionBreakMode `json:"breakMode"` + Details ExceptionDetails `json:"details,omitempty"` +} + +func (r *ExceptionInfoResponse) GetResponse() *Response { return &r.Response } + +// ReadMemoryRequest: Reads bytes from memory at the provided location. +// Clients should only call this request if the capability 'supportsReadMemoryRequest' is true. +type ReadMemoryRequest struct { + Request + + Arguments ReadMemoryArguments `json:"arguments"` +} + +func (r *ReadMemoryRequest) GetRequest() *Request { return &r.Request } + +// ReadMemoryArguments: Arguments for 'readMemory' request. +type ReadMemoryArguments struct { + MemoryReference string `json:"memoryReference"` + Offset int `json:"offset,omitempty"` + Count int `json:"count"` +} + +// ReadMemoryResponse: Response to 'readMemory' request. +type ReadMemoryResponse struct { + Response + + Body ReadMemoryResponseBody `json:"body,omitempty"` +} + +type ReadMemoryResponseBody struct { + Address string `json:"address"` + UnreadableBytes int `json:"unreadableBytes,omitempty"` + Data string `json:"data,omitempty"` +} + +func (r *ReadMemoryResponse) GetResponse() *Response { return &r.Response } + +// DisassembleRequest: Disassembles code stored at the provided location. +// Clients should only call this request if the capability 'supportsDisassembleRequest' is true. +type DisassembleRequest struct { + Request + + Arguments DisassembleArguments `json:"arguments"` +} + +func (r *DisassembleRequest) GetRequest() *Request { return &r.Request } + +// DisassembleArguments: Arguments for 'disassemble' request. +type DisassembleArguments struct { + MemoryReference string `json:"memoryReference"` + Offset int `json:"offset,omitempty"` + InstructionOffset int `json:"instructionOffset,omitempty"` + InstructionCount int `json:"instructionCount"` + ResolveSymbols bool `json:"resolveSymbols,omitempty"` +} + +// DisassembleResponse: Response to 'disassemble' request. +type DisassembleResponse struct { + Response + + Body DisassembleResponseBody `json:"body,omitempty"` +} + +type DisassembleResponseBody struct { + Instructions []DisassembledInstruction `json:"instructions"` +} + +func (r *DisassembleResponse) GetResponse() *Response { return &r.Response } + +// Capabilities: Information about the capabilities of a debug adapter. +type Capabilities struct { + SupportsConfigurationDoneRequest bool `json:"supportsConfigurationDoneRequest,omitempty"` + SupportsFunctionBreakpoints bool `json:"supportsFunctionBreakpoints,omitempty"` + SupportsConditionalBreakpoints bool `json:"supportsConditionalBreakpoints,omitempty"` + SupportsHitConditionalBreakpoints bool `json:"supportsHitConditionalBreakpoints,omitempty"` + SupportsEvaluateForHovers bool `json:"supportsEvaluateForHovers,omitempty"` + ExceptionBreakpointFilters []ExceptionBreakpointsFilter `json:"exceptionBreakpointFilters,omitempty"` + SupportsStepBack bool `json:"supportsStepBack,omitempty"` + SupportsSetVariable bool `json:"supportsSetVariable,omitempty"` + SupportsRestartFrame bool `json:"supportsRestartFrame,omitempty"` + SupportsGotoTargetsRequest bool `json:"supportsGotoTargetsRequest,omitempty"` + SupportsStepInTargetsRequest bool `json:"supportsStepInTargetsRequest,omitempty"` + SupportsCompletionsRequest bool `json:"supportsCompletionsRequest,omitempty"` + CompletionTriggerCharacters []string `json:"completionTriggerCharacters,omitempty"` + SupportsModulesRequest bool `json:"supportsModulesRequest,omitempty"` + AdditionalModuleColumns []ColumnDescriptor `json:"additionalModuleColumns,omitempty"` + SupportedChecksumAlgorithms []ChecksumAlgorithm `json:"supportedChecksumAlgorithms,omitempty"` + SupportsRestartRequest bool `json:"supportsRestartRequest,omitempty"` + SupportsExceptionOptions bool `json:"supportsExceptionOptions,omitempty"` + SupportsValueFormattingOptions bool `json:"supportsValueFormattingOptions,omitempty"` + SupportsExceptionInfoRequest bool `json:"supportsExceptionInfoRequest,omitempty"` + SupportTerminateDebuggee bool `json:"supportTerminateDebuggee,omitempty"` + SupportSuspendDebuggee bool `json:"supportSuspendDebuggee,omitempty"` + SupportsDelayedStackTraceLoading bool `json:"supportsDelayedStackTraceLoading,omitempty"` + SupportsLoadedSourcesRequest bool `json:"supportsLoadedSourcesRequest,omitempty"` + SupportsLogPoints bool `json:"supportsLogPoints,omitempty"` + SupportsTerminateThreadsRequest bool `json:"supportsTerminateThreadsRequest,omitempty"` + SupportsSetExpression bool `json:"supportsSetExpression,omitempty"` + SupportsTerminateRequest bool `json:"supportsTerminateRequest,omitempty"` + SupportsDataBreakpoints bool `json:"supportsDataBreakpoints,omitempty"` + SupportsReadMemoryRequest bool `json:"supportsReadMemoryRequest,omitempty"` + SupportsDisassembleRequest bool `json:"supportsDisassembleRequest,omitempty"` + SupportsCancelRequest bool `json:"supportsCancelRequest,omitempty"` + SupportsBreakpointLocationsRequest bool `json:"supportsBreakpointLocationsRequest,omitempty"` + SupportsClipboardContext bool `json:"supportsClipboardContext,omitempty"` + SupportsSteppingGranularity bool `json:"supportsSteppingGranularity,omitempty"` + SupportsInstructionBreakpoints bool `json:"supportsInstructionBreakpoints,omitempty"` + SupportsExceptionFilterOptions bool `json:"supportsExceptionFilterOptions,omitempty"` +} + +// ExceptionBreakpointsFilter: An ExceptionBreakpointsFilter is shown in the UI as an filter option for configuring how exceptions are dealt with. +type ExceptionBreakpointsFilter struct { + Filter string `json:"filter"` + Label string `json:"label"` + Description string `json:"description,omitempty"` + Default bool `json:"default,omitempty"` + SupportsCondition bool `json:"supportsCondition,omitempty"` + ConditionDescription string `json:"conditionDescription,omitempty"` +} + +// ErrorMessage: A structured message object. Used to return errors from requests. +type ErrorMessage struct { + Id int `json:"id"` + Format string `json:"format"` + Variables map[string]string `json:"variables,omitempty"` + SendTelemetry bool `json:"sendTelemetry,omitempty"` + ShowUser bool `json:"showUser,omitempty"` + Url string `json:"url,omitempty"` + UrlLabel string `json:"urlLabel,omitempty"` +} + +// Module: A Module object represents a row in the modules view. +// Two attributes are mandatory: an id identifies a module in the modules view and is used in a ModuleEvent for identifying a module for adding, updating or deleting. +// The name is used to minimally render the module in the UI. +// +// Additional attributes can be added to the module. They will show up in the module View if they have a corresponding ColumnDescriptor. +// +// To avoid an unnecessary proliferation of additional attributes with similar semantics but different names +// we recommend to re-use attributes from the 'recommended' list below first, and only introduce new attributes if nothing appropriate could be found. +type Module struct { + Id interface{} `json:"id"` + Name string `json:"name"` + Path string `json:"path,omitempty"` + IsOptimized bool `json:"isOptimized,omitempty"` + IsUserCode bool `json:"isUserCode,omitempty"` + Version string `json:"version,omitempty"` + SymbolStatus string `json:"symbolStatus,omitempty"` + SymbolFilePath string `json:"symbolFilePath,omitempty"` + DateTimeStamp string `json:"dateTimeStamp,omitempty"` + AddressRange string `json:"addressRange,omitempty"` +} + +// ColumnDescriptor: A ColumnDescriptor specifies what module attribute to show in a column of the ModulesView, how to format it, +// and what the column's label should be. +// It is only used if the underlying UI actually supports this level of customization. +type ColumnDescriptor struct { + AttributeName string `json:"attributeName"` + Label string `json:"label"` + Format string `json:"format,omitempty"` + Type string `json:"type,omitempty"` + Width int `json:"width,omitempty"` +} + +// ModulesViewDescriptor: The ModulesViewDescriptor is the container for all declarative configuration options of a ModuleView. +// For now it only specifies the columns to be shown in the modules view. +type ModulesViewDescriptor struct { + Columns []ColumnDescriptor `json:"columns"` +} + +// Thread: A Thread +type Thread struct { + Id int `json:"id"` + Name string `json:"name"` +} + +// Source: A Source is a descriptor for source code. +// It is returned from the debug adapter as part of a StackFrame and it is used by clients when specifying breakpoints. +type Source struct { + Name string `json:"name,omitempty"` + Path string `json:"path,omitempty"` + SourceReference int `json:"sourceReference,omitempty"` + PresentationHint string `json:"presentationHint,omitempty"` + Origin string `json:"origin,omitempty"` + Sources []Source `json:"sources,omitempty"` + AdapterData interface{} `json:"adapterData,omitempty"` + Checksums []Checksum `json:"checksums,omitempty"` +} + +// StackFrame: A Stackframe contains the source location. +type StackFrame struct { + Id int `json:"id"` + Name string `json:"name"` + Source Source `json:"source,omitempty"` + Line int `json:"line"` + Column int `json:"column"` + EndLine int `json:"endLine,omitempty"` + EndColumn int `json:"endColumn,omitempty"` + CanRestart bool `json:"canRestart,omitempty"` + InstructionPointerReference string `json:"instructionPointerReference,omitempty"` + ModuleId interface{} `json:"moduleId,omitempty"` + PresentationHint string `json:"presentationHint,omitempty"` +} + +// Scope: A Scope is a named container for variables. Optionally a scope can map to a source or a range within a source. +type Scope struct { + Name string `json:"name"` + PresentationHint string `json:"presentationHint,omitempty"` + VariablesReference int `json:"variablesReference"` + NamedVariables int `json:"namedVariables,omitempty"` + IndexedVariables int `json:"indexedVariables,omitempty"` + Expensive bool `json:"expensive"` + Source Source `json:"source,omitempty"` + Line int `json:"line,omitempty"` + Column int `json:"column,omitempty"` + EndLine int `json:"endLine,omitempty"` + EndColumn int `json:"endColumn,omitempty"` +} + +// Variable: A Variable is a name/value pair. +// Optionally a variable can have a 'type' that is shown if space permits or when hovering over the variable's name. +// An optional 'kind' is used to render additional properties of the variable, e.g. different icons can be used to indicate that a variable is public or private. +// If the value is structured (has children), a handle is provided to retrieve the children with the VariablesRequest. +// If the number of named or indexed children is large, the numbers should be returned via the optional 'namedVariables' and 'indexedVariables' attributes. +// The client can use this optional information to present the children in a paged UI and fetch them in chunks. +type Variable struct { + Name string `json:"name"` + Value string `json:"value"` + Type string `json:"type,omitempty"` + PresentationHint VariablePresentationHint `json:"presentationHint,omitempty"` + EvaluateName string `json:"evaluateName,omitempty"` + VariablesReference int `json:"variablesReference"` + NamedVariables int `json:"namedVariables,omitempty"` + IndexedVariables int `json:"indexedVariables,omitempty"` + MemoryReference string `json:"memoryReference,omitempty"` +} + +// VariablePresentationHint: Optional properties of a variable that can be used to determine how to render the variable in the UI. +type VariablePresentationHint struct { + Kind string `json:"kind,omitempty"` + Attributes []string `json:"attributes,omitempty"` + Visibility string `json:"visibility,omitempty"` +} + +// BreakpointLocation: Properties of a breakpoint location returned from the 'breakpointLocations' request. +type BreakpointLocation struct { + Line int `json:"line"` + Column int `json:"column,omitempty"` + EndLine int `json:"endLine,omitempty"` + EndColumn int `json:"endColumn,omitempty"` +} + +// SourceBreakpoint: Properties of a breakpoint or logpoint passed to the setBreakpoints request. +type SourceBreakpoint struct { + Line int `json:"line"` + Column int `json:"column,omitempty"` + Condition string `json:"condition,omitempty"` + HitCondition string `json:"hitCondition,omitempty"` + LogMessage string `json:"logMessage,omitempty"` +} + +// FunctionBreakpoint: Properties of a breakpoint passed to the setFunctionBreakpoints request. +type FunctionBreakpoint struct { + Name string `json:"name"` + Condition string `json:"condition,omitempty"` + HitCondition string `json:"hitCondition,omitempty"` +} + +// DataBreakpointAccessType: This enumeration defines all possible access types for data breakpoints. +type DataBreakpointAccessType string + +// DataBreakpoint: Properties of a data breakpoint passed to the setDataBreakpoints request. +type DataBreakpoint struct { + DataId string `json:"dataId"` + AccessType DataBreakpointAccessType `json:"accessType,omitempty"` + Condition string `json:"condition,omitempty"` + HitCondition string `json:"hitCondition,omitempty"` +} + +// InstructionBreakpoint: Properties of a breakpoint passed to the setInstructionBreakpoints request +type InstructionBreakpoint struct { + InstructionReference string `json:"instructionReference"` + Offset int `json:"offset,omitempty"` + Condition string `json:"condition,omitempty"` + HitCondition string `json:"hitCondition,omitempty"` +} + +// Breakpoint: Information about a Breakpoint created in setBreakpoints, setFunctionBreakpoints, setInstructionBreakpoints, or setDataBreakpoints. +type Breakpoint struct { + Id int `json:"id,omitempty"` + Verified bool `json:"verified"` + Message string `json:"message,omitempty"` + Source Source `json:"source,omitempty"` + Line int `json:"line,omitempty"` + Column int `json:"column,omitempty"` + EndLine int `json:"endLine,omitempty"` + EndColumn int `json:"endColumn,omitempty"` + InstructionReference string `json:"instructionReference,omitempty"` + Offset int `json:"offset,omitempty"` +} + +// SteppingGranularity: The granularity of one 'step' in the stepping requests 'next', 'stepIn', 'stepOut', and 'stepBack'. +type SteppingGranularity string + +// StepInTarget: A StepInTarget can be used in the 'stepIn' request and determines into which single target the stepIn request should step. +type StepInTarget struct { + Id int `json:"id"` + Label string `json:"label"` +} + +// GotoTarget: A GotoTarget describes a code location that can be used as a target in the 'goto' request. +// The possible goto targets can be determined via the 'gotoTargets' request. +type GotoTarget struct { + Id int `json:"id"` + Label string `json:"label"` + Line int `json:"line"` + Column int `json:"column,omitempty"` + EndLine int `json:"endLine,omitempty"` + EndColumn int `json:"endColumn,omitempty"` + InstructionPointerReference string `json:"instructionPointerReference,omitempty"` +} + +// CompletionItem: CompletionItems are the suggestions returned from the CompletionsRequest. +type CompletionItem struct { + Label string `json:"label"` + Text string `json:"text,omitempty"` + SortText string `json:"sortText,omitempty"` + Type CompletionItemType `json:"type,omitempty"` + Start int `json:"start,omitempty"` + Length int `json:"length,omitempty"` + SelectionStart int `json:"selectionStart,omitempty"` + SelectionLength int `json:"selectionLength,omitempty"` +} + +// CompletionItemType: Some predefined types for the CompletionItem. Please note that not all clients have specific icons for all of them. +type CompletionItemType string + +// ChecksumAlgorithm: Names of checksum algorithms that may be supported by a debug adapter. +type ChecksumAlgorithm string + +// Checksum: The checksum of an item calculated by the specified algorithm. +type Checksum struct { + Algorithm ChecksumAlgorithm `json:"algorithm"` + Checksum string `json:"checksum"` +} + +// ValueFormat: Provides formatting information for a value. +type ValueFormat struct { + Hex bool `json:"hex,omitempty"` +} + +// StackFrameFormat: Provides formatting information for a stack frame. +type StackFrameFormat struct { + ValueFormat + + Parameters bool `json:"parameters,omitempty"` + ParameterTypes bool `json:"parameterTypes,omitempty"` + ParameterNames bool `json:"parameterNames,omitempty"` + ParameterValues bool `json:"parameterValues,omitempty"` + Line bool `json:"line,omitempty"` + Module bool `json:"module,omitempty"` + IncludeAll bool `json:"includeAll,omitempty"` +} + +// ExceptionFilterOptions: An ExceptionFilterOptions is used to specify an exception filter together with a condition for the setExceptionsFilter request. +type ExceptionFilterOptions struct { + FilterId string `json:"filterId"` + Condition string `json:"condition,omitempty"` +} + +// ExceptionOptions: An ExceptionOptions assigns configuration options to a set of exceptions. +type ExceptionOptions struct { + Path []ExceptionPathSegment `json:"path,omitempty"` + BreakMode ExceptionBreakMode `json:"breakMode"` +} + +// ExceptionBreakMode: This enumeration defines all possible conditions when a thrown exception should result in a break. +// never: never breaks, +// always: always breaks, +// unhandled: breaks when exception unhandled, +// userUnhandled: breaks if the exception is not handled by user code. +type ExceptionBreakMode string + +// ExceptionPathSegment: An ExceptionPathSegment represents a segment in a path that is used to match leafs or nodes in a tree of exceptions. +// If a segment consists of more than one name, it matches the names provided if 'negate' is false or missing or +// it matches anything except the names provided if 'negate' is true. +type ExceptionPathSegment struct { + Negate bool `json:"negate,omitempty"` + Names []string `json:"names"` +} + +// ExceptionDetails: Detailed information about an exception that has occurred. +type ExceptionDetails struct { + Message string `json:"message,omitempty"` + TypeName string `json:"typeName,omitempty"` + FullTypeName string `json:"fullTypeName,omitempty"` + EvaluateName string `json:"evaluateName,omitempty"` + StackTrace string `json:"stackTrace,omitempty"` + InnerException []ExceptionDetails `json:"innerException,omitempty"` +} + +// DisassembledInstruction: Represents a single disassembled instruction. +type DisassembledInstruction struct { + Address string `json:"address"` + InstructionBytes string `json:"instructionBytes,omitempty"` + Instruction string `json:"instruction"` + Symbol string `json:"symbol,omitempty"` + Location Source `json:"location,omitempty"` + Line int `json:"line,omitempty"` + Column int `json:"column,omitempty"` + EndLine int `json:"endLine,omitempty"` + EndColumn int `json:"endColumn,omitempty"` +} + +// InvalidatedAreas: Logical areas that can be invalidated by the 'invalidated' event. +type InvalidatedAreas string diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/hashicorp/golang-lru/LICENSE b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/hashicorp/golang-lru/LICENSE new file mode 100644 index 0000000..be2cc4d --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/hashicorp/golang-lru/LICENSE @@ -0,0 +1,362 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the terms of + a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a + separate file or files, that is not Covered Software. + +1.8. "License" + + means this document. + +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether + at the time of the initial grant or subsequently, any and all of the + rights conveyed by this License. + +1.10. "Modifications" + + means any of the following: + + a. any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the License, + by the making, using, selling, offering for sale, having made, import, + or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, "control" means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights to + grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter the + recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, or + limitations of liability) contained within the Source Code Form of the + Covered Software, except that You may alter any license notices to the + extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, + judicial order, or regulation then You must: (a) comply with the terms of + this License to the maximum extent possible; and (b) describe the + limitations and the code they affect. Such description must be placed in a + text file included with all distributions of the Covered Software under + this License. Except to the extent prohibited by statute or regulation, + such description must be sufficiently detailed for a recipient of ordinary + skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing + basis, if such Contributor fails to notify You of the non-compliance by + some reasonable means prior to 60 days after You have come back into + compliance. Moreover, Your grants from a particular Contributor are + reinstated on an ongoing basis if such Contributor notifies You of the + non-compliance by some reasonable means, this is the first time You have + received notice of non-compliance with this License from such + Contributor, and You become compliant prior to 30 days after Your receipt + of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an "as is" basis, + without warranty of any kind, either expressed, implied, or statutory, + including, without limitation, warranties that the Covered Software is free + of defects, merchantable, fit for a particular purpose or non-infringing. + The entire risk as to the quality and performance of the Covered Software + is with You. Should any Covered Software prove defective in any respect, + You (not any Contributor) assume the cost of any necessary servicing, + repair, or correction. This disclaimer of warranty constitutes an essential + part of this License. No use of any Covered Software is authorized under + this License except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from + such party's negligence to the extent applicable law prohibits such + limitation. Some jurisdictions do not allow the exclusion or limitation of + incidental or consequential damages, so this exclusion and limitation may + not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts + of a jurisdiction where the defendant maintains its principal place of + business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. Nothing + in this Section shall prevent a party's ability to bring cross-claims or + counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides that + the language of a contract shall be construed against the drafter shall not + be used to construe this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses If You choose to distribute Source Code Form that is + Incompatible With Secondary Licenses under the terms of this version of + the License, the notice described in Exhibit B of this License must be + attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, +then You may include the notice in a location (such as a LICENSE file in a +relevant directory) where a recipient would be likely to look for such a +notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible + With Secondary Licenses", as defined by + the Mozilla Public License, v. 2.0. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go new file mode 100644 index 0000000..a86c853 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go @@ -0,0 +1,177 @@ +package simplelru + +import ( + "container/list" + "errors" +) + +// EvictCallback is used to get a callback when a cache entry is evicted +type EvictCallback func(key interface{}, value interface{}) + +// LRU implements a non-thread safe fixed size LRU cache +type LRU struct { + size int + evictList *list.List + items map[interface{}]*list.Element + onEvict EvictCallback +} + +// entry is used to hold a value in the evictList +type entry struct { + key interface{} + value interface{} +} + +// NewLRU constructs an LRU of the given size +func NewLRU(size int, onEvict EvictCallback) (*LRU, error) { + if size <= 0 { + return nil, errors.New("Must provide a positive size") + } + c := &LRU{ + size: size, + evictList: list.New(), + items: make(map[interface{}]*list.Element), + onEvict: onEvict, + } + return c, nil +} + +// Purge is used to completely clear the cache. +func (c *LRU) Purge() { + for k, v := range c.items { + if c.onEvict != nil { + c.onEvict(k, v.Value.(*entry).value) + } + delete(c.items, k) + } + c.evictList.Init() +} + +// Add adds a value to the cache. Returns true if an eviction occurred. +func (c *LRU) Add(key, value interface{}) (evicted bool) { + // Check for existing item + if ent, ok := c.items[key]; ok { + c.evictList.MoveToFront(ent) + ent.Value.(*entry).value = value + return false + } + + // Add new item + ent := &entry{key, value} + entry := c.evictList.PushFront(ent) + c.items[key] = entry + + evict := c.evictList.Len() > c.size + // Verify size not exceeded + if evict { + c.removeOldest() + } + return evict +} + +// Get looks up a key's value from the cache. +func (c *LRU) Get(key interface{}) (value interface{}, ok bool) { + if ent, ok := c.items[key]; ok { + c.evictList.MoveToFront(ent) + if ent.Value.(*entry) == nil { + return nil, false + } + return ent.Value.(*entry).value, true + } + return +} + +// Contains checks if a key is in the cache, without updating the recent-ness +// or deleting it for being stale. +func (c *LRU) Contains(key interface{}) (ok bool) { + _, ok = c.items[key] + return ok +} + +// Peek returns the key value (or undefined if not found) without updating +// the "recently used"-ness of the key. +func (c *LRU) Peek(key interface{}) (value interface{}, ok bool) { + var ent *list.Element + if ent, ok = c.items[key]; ok { + return ent.Value.(*entry).value, true + } + return nil, ok +} + +// Remove removes the provided key from the cache, returning if the +// key was contained. +func (c *LRU) Remove(key interface{}) (present bool) { + if ent, ok := c.items[key]; ok { + c.removeElement(ent) + return true + } + return false +} + +// RemoveOldest removes the oldest item from the cache. +func (c *LRU) RemoveOldest() (key interface{}, value interface{}, ok bool) { + ent := c.evictList.Back() + if ent != nil { + c.removeElement(ent) + kv := ent.Value.(*entry) + return kv.key, kv.value, true + } + return nil, nil, false +} + +// GetOldest returns the oldest entry +func (c *LRU) GetOldest() (key interface{}, value interface{}, ok bool) { + ent := c.evictList.Back() + if ent != nil { + kv := ent.Value.(*entry) + return kv.key, kv.value, true + } + return nil, nil, false +} + +// Keys returns a slice of the keys in the cache, from oldest to newest. +func (c *LRU) Keys() []interface{} { + keys := make([]interface{}, len(c.items)) + i := 0 + for ent := c.evictList.Back(); ent != nil; ent = ent.Prev() { + keys[i] = ent.Value.(*entry).key + i++ + } + return keys +} + +// Len returns the number of items in the cache. +func (c *LRU) Len() int { + return c.evictList.Len() +} + +// Resize changes the cache size. +func (c *LRU) Resize(size int) (evicted int) { + diff := c.Len() - size + if diff < 0 { + diff = 0 + } + for i := 0; i < diff; i++ { + c.removeOldest() + } + c.size = size + return diff +} + +// removeOldest removes the oldest item from the cache. +func (c *LRU) removeOldest() { + ent := c.evictList.Back() + if ent != nil { + c.removeElement(ent) + } +} + +// removeElement is used to remove a given list element from the cache +func (c *LRU) removeElement(e *list.Element) { + c.evictList.Remove(e) + kv := e.Value.(*entry) + delete(c.items, kv.key) + if c.onEvict != nil { + c.onEvict(kv.key, kv.value) + } +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go new file mode 100644 index 0000000..92d7093 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go @@ -0,0 +1,39 @@ +package simplelru + +// LRUCache is the interface for simple LRU cache. +type LRUCache interface { + // Adds a value to the cache, returns true if an eviction occurred and + // updates the "recently used"-ness of the key. + Add(key, value interface{}) bool + + // Returns key's value from the cache and + // updates the "recently used"-ness of the key. #value, isFound + Get(key interface{}) (value interface{}, ok bool) + + // Checks if a key exists in cache without updating the recent-ness. + Contains(key interface{}) (ok bool) + + // Returns key's value without updating the "recently used"-ness of the key. + Peek(key interface{}) (value interface{}, ok bool) + + // Removes a key from the cache. + Remove(key interface{}) bool + + // Removes the oldest entry from cache. + RemoveOldest() (interface{}, interface{}, bool) + + // Returns the oldest entry from the cache. #key, value, isFound + GetOldest() (interface{}, interface{}, bool) + + // Returns a slice of the keys in the cache, from oldest to newest. + Keys() []interface{} + + // Returns the number of items in the cache. + Len() int + + // Clears all cache entries. + Purge() + + // Resizes cache, returning number evicted + Resize(int) int +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/LICENSE b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/LICENSE new file mode 100644 index 0000000..5f0d1fb --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/LICENSE @@ -0,0 +1,13 @@ +Copyright 2014 Alan Shreve + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/README.md b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/README.md new file mode 100644 index 0000000..7a950d1 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/README.md @@ -0,0 +1,23 @@ +# mousetrap + +mousetrap is a tiny library that answers a single question. + +On a Windows machine, was the process invoked by someone double clicking on +the executable file while browsing in explorer? + +### Motivation + +Windows developers unfamiliar with command line tools will often "double-click" +the executable for a tool. Because most CLI tools print the help and then exit +when invoked without arguments, this is often very frustrating for those users. + +mousetrap provides a way to detect these invocations so that you can provide +more helpful behavior and instructions on how to run the CLI tool. To see what +this looks like, both from an organizational and a technical perspective, see +https://inconshreveable.com/09-09-2014/sweat-the-small-stuff/ + +### The interface + +The library exposes a single interface: + + func StartedByExplorer() (bool) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/trap_others.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/trap_others.go new file mode 100644 index 0000000..9d2d8a4 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/trap_others.go @@ -0,0 +1,15 @@ +// +build !windows + +package mousetrap + +// StartedByExplorer returns true if the program was invoked by the user +// double-clicking on the executable from explorer.exe +// +// It is conservative and returns false if any of the internal calls fail. +// It does not guarantee that the program was run from a terminal. It only can tell you +// whether it was launched from explorer.exe +// +// On non-Windows platforms, it always returns false. +func StartedByExplorer() bool { + return false +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/trap_windows.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/trap_windows.go new file mode 100644 index 0000000..336142a --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/trap_windows.go @@ -0,0 +1,98 @@ +// +build windows +// +build !go1.4 + +package mousetrap + +import ( + "fmt" + "os" + "syscall" + "unsafe" +) + +const ( + // defined by the Win32 API + th32cs_snapprocess uintptr = 0x2 +) + +var ( + kernel = syscall.MustLoadDLL("kernel32.dll") + CreateToolhelp32Snapshot = kernel.MustFindProc("CreateToolhelp32Snapshot") + Process32First = kernel.MustFindProc("Process32FirstW") + Process32Next = kernel.MustFindProc("Process32NextW") +) + +// ProcessEntry32 structure defined by the Win32 API +type processEntry32 struct { + dwSize uint32 + cntUsage uint32 + th32ProcessID uint32 + th32DefaultHeapID int + th32ModuleID uint32 + cntThreads uint32 + th32ParentProcessID uint32 + pcPriClassBase int32 + dwFlags uint32 + szExeFile [syscall.MAX_PATH]uint16 +} + +func getProcessEntry(pid int) (pe *processEntry32, err error) { + snapshot, _, e1 := CreateToolhelp32Snapshot.Call(th32cs_snapprocess, uintptr(0)) + if snapshot == uintptr(syscall.InvalidHandle) { + err = fmt.Errorf("CreateToolhelp32Snapshot: %v", e1) + return + } + defer syscall.CloseHandle(syscall.Handle(snapshot)) + + var processEntry processEntry32 + processEntry.dwSize = uint32(unsafe.Sizeof(processEntry)) + ok, _, e1 := Process32First.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) + if ok == 0 { + err = fmt.Errorf("Process32First: %v", e1) + return + } + + for { + if processEntry.th32ProcessID == uint32(pid) { + pe = &processEntry + return + } + + ok, _, e1 = Process32Next.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) + if ok == 0 { + err = fmt.Errorf("Process32Next: %v", e1) + return + } + } +} + +func getppid() (pid int, err error) { + pe, err := getProcessEntry(os.Getpid()) + if err != nil { + return + } + + pid = int(pe.th32ParentProcessID) + return +} + +// StartedByExplorer returns true if the program was invoked by the user double-clicking +// on the executable from explorer.exe +// +// It is conservative and returns false if any of the internal calls fail. +// It does not guarantee that the program was run from a terminal. It only can tell you +// whether it was launched from explorer.exe +func StartedByExplorer() bool { + ppid, err := getppid() + if err != nil { + return false + } + + pe, err := getProcessEntry(ppid) + if err != nil { + return false + } + + name := syscall.UTF16ToString(pe.szExeFile[:]) + return name == "explorer.exe" +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go new file mode 100644 index 0000000..9a28e57 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go @@ -0,0 +1,46 @@ +// +build windows +// +build go1.4 + +package mousetrap + +import ( + "os" + "syscall" + "unsafe" +) + +func getProcessEntry(pid int) (*syscall.ProcessEntry32, error) { + snapshot, err := syscall.CreateToolhelp32Snapshot(syscall.TH32CS_SNAPPROCESS, 0) + if err != nil { + return nil, err + } + defer syscall.CloseHandle(snapshot) + var procEntry syscall.ProcessEntry32 + procEntry.Size = uint32(unsafe.Sizeof(procEntry)) + if err = syscall.Process32First(snapshot, &procEntry); err != nil { + return nil, err + } + for { + if procEntry.ProcessID == uint32(pid) { + return &procEntry, nil + } + err = syscall.Process32Next(snapshot, &procEntry) + if err != nil { + return nil, err + } + } +} + +// StartedByExplorer returns true if the program was invoked by the user double-clicking +// on the executable from explorer.exe +// +// It is conservative and returns false if any of the internal calls fail. +// It does not guarantee that the program was run from a terminal. It only can tell you +// whether it was launched from explorer.exe +func StartedByExplorer() bool { + pe, err := getProcessEntry(os.Getppid()) + if err != nil { + return false + } + return "explorer.exe" == syscall.UTF16ToString(pe.ExeFile[:]) +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE new file mode 100644 index 0000000..14127cd --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE @@ -0,0 +1,9 @@ +(The MIT License) + +Copyright (c) 2017 marvin + konsorten GmbH (open-source@konsorten.de) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md new file mode 100644 index 0000000..09a4a35 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md @@ -0,0 +1,42 @@ +# Windows Terminal Sequences + +This library allow for enabling Windows terminal color support for Go. + +See [Console Virtual Terminal Sequences](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) for details. + +## Usage + +```go +import ( + "syscall" + + sequences "github.com/konsorten/go-windows-terminal-sequences" +) + +func main() { + sequences.EnableVirtualTerminalProcessing(syscall.Stdout, true) +} + +``` + +## Authors + +The tool is sponsored by the [marvin + konsorten GmbH](http://www.konsorten.de). + +We thank all the authors who provided code to this library: + +* Felix Kollmann +* Nicolas Perraut +* @dirty49374 + +## License + +(The MIT License) + +Copyright (c) 2018 marvin + konsorten GmbH (open-source@konsorten.de) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod new file mode 100644 index 0000000..716c613 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod @@ -0,0 +1 @@ +module github.com/konsorten/go-windows-terminal-sequences diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go new file mode 100644 index 0000000..57f530a --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go @@ -0,0 +1,35 @@ +// +build windows + +package sequences + +import ( + "syscall" +) + +var ( + kernel32Dll *syscall.LazyDLL = syscall.NewLazyDLL("Kernel32.dll") + setConsoleMode *syscall.LazyProc = kernel32Dll.NewProc("SetConsoleMode") +) + +func EnableVirtualTerminalProcessing(stream syscall.Handle, enable bool) error { + const ENABLE_VIRTUAL_TERMINAL_PROCESSING uint32 = 0x4 + + var mode uint32 + err := syscall.GetConsoleMode(syscall.Stdout, &mode) + if err != nil { + return err + } + + if enable { + mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING + } else { + mode &^= ENABLE_VIRTUAL_TERMINAL_PROCESSING + } + + ret, _, err := setConsoleMode.Call(uintptr(stream), uintptr(mode)) + if ret == 0 { + return err + } + + return nil +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences_dummy.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences_dummy.go new file mode 100644 index 0000000..df61a6f --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences_dummy.go @@ -0,0 +1,11 @@ +// +build linux darwin + +package sequences + +import ( + "fmt" +) + +func EnableVirtualTerminalProcessing(stream uintptr, enable bool) error { + return fmt.Errorf("windows only package") +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/.travis.yml b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/.travis.yml new file mode 100644 index 0000000..98db8f0 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/.travis.yml @@ -0,0 +1,9 @@ +language: go +go: + - tip + +before_install: + - go get github.com/mattn/goveralls + - go get golang.org/x/tools/cmd/cover +script: + - $HOME/gopath/bin/goveralls -repotoken xnXqRGwgW3SXIguzxf90ZSK1GPYZPaGrw diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/LICENSE b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/LICENSE new file mode 100644 index 0000000..91b5cef --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Yasuhiro Matsumoto + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/README.md b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/README.md new file mode 100644 index 0000000..56729a9 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/README.md @@ -0,0 +1,48 @@ +# go-colorable + +[![Godoc Reference](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable) +[![Build Status](https://travis-ci.org/mattn/go-colorable.svg?branch=master)](https://travis-ci.org/mattn/go-colorable) +[![Coverage Status](https://coveralls.io/repos/github/mattn/go-colorable/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-colorable?branch=master) +[![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable) + +Colorable writer for windows. + +For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.) +This package is possible to handle escape sequence for ansi color on windows. + +## Too Bad! + +![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png) + + +## So Good! + +![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png) + +## Usage + +```go +logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) +logrus.SetOutput(colorable.NewColorableStdout()) + +logrus.Info("succeeded") +logrus.Warn("not correct") +logrus.Error("something error") +logrus.Fatal("panic") +``` + +You can compile above code on non-windows OSs. + +## Installation + +``` +$ go get github.com/mattn/go-colorable +``` + +# License + +MIT + +# Author + +Yasuhiro Matsumoto (a.k.a mattn) diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/colorable_appengine.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/colorable_appengine.go new file mode 100644 index 0000000..49343e5 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/colorable_appengine.go @@ -0,0 +1,27 @@ +// +build appengine + +package colorable + +import ( + "io" + "os" +) + +// NewColorable return new instance of Writer which handle escape sequence. +func NewColorable(file *os.File) io.Writer { + if file == nil { + panic("nil passed instead of *os.File to NewColorable()") + } + + return file +} + +// NewColorableStdout return new instance of Writer which handle escape sequence for stdout. +func NewColorableStdout() io.Writer { + return os.Stdout +} + +// NewColorableStderr return new instance of Writer which handle escape sequence for stderr. +func NewColorableStderr() io.Writer { + return os.Stderr +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/colorable_others.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/colorable_others.go new file mode 100644 index 0000000..d28f542 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/colorable_others.go @@ -0,0 +1,28 @@ +// +build !windows +// +build !appengine + +package colorable + +import ( + "io" + "os" +) + +// NewColorable return new instance of Writer which handle escape sequence. +func NewColorable(file *os.File) io.Writer { + if file == nil { + panic("nil passed instead of *os.File to NewColorable()") + } + + return file +} + +// NewColorableStdout return new instance of Writer which handle escape sequence for stdout. +func NewColorableStdout() io.Writer { + return os.Stdout +} + +// NewColorableStderr return new instance of Writer which handle escape sequence for stderr. +func NewColorableStderr() io.Writer { + return os.Stderr +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/colorable_windows.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/colorable_windows.go new file mode 100644 index 0000000..6194eb9 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/colorable_windows.go @@ -0,0 +1,870 @@ +// +build windows +// +build !appengine + +package colorable + +import ( + "bytes" + "io" + "math" + "os" + "strconv" + "strings" + "syscall" + "unsafe" + + "github.com/mattn/go-isatty" +) + +const ( + foregroundBlue = 0x1 + foregroundGreen = 0x2 + foregroundRed = 0x4 + foregroundIntensity = 0x8 + foregroundMask = (foregroundRed | foregroundBlue | foregroundGreen | foregroundIntensity) + backgroundBlue = 0x10 + backgroundGreen = 0x20 + backgroundRed = 0x40 + backgroundIntensity = 0x80 + backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity) +) + +type wchar uint16 +type short int16 +type dword uint32 +type word uint16 + +type coord struct { + x short + y short +} + +type smallRect struct { + left short + top short + right short + bottom short +} + +type consoleScreenBufferInfo struct { + size coord + cursorPosition coord + attributes word + window smallRect + maximumWindowSize coord +} + +type consoleCursorInfo struct { + size dword + visible int32 +} + +var ( + kernel32 = syscall.NewLazyDLL("kernel32.dll") + procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") + procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute") + procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition") + procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW") + procFillConsoleOutputAttribute = kernel32.NewProc("FillConsoleOutputAttribute") + procGetConsoleCursorInfo = kernel32.NewProc("GetConsoleCursorInfo") + procSetConsoleCursorInfo = kernel32.NewProc("SetConsoleCursorInfo") + procSetConsoleTitle = kernel32.NewProc("SetConsoleTitleW") +) + +// Writer provide colorable Writer to the console +type Writer struct { + out io.Writer + handle syscall.Handle + oldattr word + oldpos coord +} + +// NewColorable return new instance of Writer which handle escape sequence from File. +func NewColorable(file *os.File) io.Writer { + if file == nil { + panic("nil passed instead of *os.File to NewColorable()") + } + + if isatty.IsTerminal(file.Fd()) { + var csbi consoleScreenBufferInfo + handle := syscall.Handle(file.Fd()) + procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi))) + return &Writer{out: file, handle: handle, oldattr: csbi.attributes, oldpos: coord{0, 0}} + } + return file +} + +// NewColorableStdout return new instance of Writer which handle escape sequence for stdout. +func NewColorableStdout() io.Writer { + return NewColorable(os.Stdout) +} + +// NewColorableStderr return new instance of Writer which handle escape sequence for stderr. +func NewColorableStderr() io.Writer { + return NewColorable(os.Stderr) +} + +var color256 = map[int]int{ + 0: 0x000000, + 1: 0x800000, + 2: 0x008000, + 3: 0x808000, + 4: 0x000080, + 5: 0x800080, + 6: 0x008080, + 7: 0xc0c0c0, + 8: 0x808080, + 9: 0xff0000, + 10: 0x00ff00, + 11: 0xffff00, + 12: 0x0000ff, + 13: 0xff00ff, + 14: 0x00ffff, + 15: 0xffffff, + 16: 0x000000, + 17: 0x00005f, + 18: 0x000087, + 19: 0x0000af, + 20: 0x0000d7, + 21: 0x0000ff, + 22: 0x005f00, + 23: 0x005f5f, + 24: 0x005f87, + 25: 0x005faf, + 26: 0x005fd7, + 27: 0x005fff, + 28: 0x008700, + 29: 0x00875f, + 30: 0x008787, + 31: 0x0087af, + 32: 0x0087d7, + 33: 0x0087ff, + 34: 0x00af00, + 35: 0x00af5f, + 36: 0x00af87, + 37: 0x00afaf, + 38: 0x00afd7, + 39: 0x00afff, + 40: 0x00d700, + 41: 0x00d75f, + 42: 0x00d787, + 43: 0x00d7af, + 44: 0x00d7d7, + 45: 0x00d7ff, + 46: 0x00ff00, + 47: 0x00ff5f, + 48: 0x00ff87, + 49: 0x00ffaf, + 50: 0x00ffd7, + 51: 0x00ffff, + 52: 0x5f0000, + 53: 0x5f005f, + 54: 0x5f0087, + 55: 0x5f00af, + 56: 0x5f00d7, + 57: 0x5f00ff, + 58: 0x5f5f00, + 59: 0x5f5f5f, + 60: 0x5f5f87, + 61: 0x5f5faf, + 62: 0x5f5fd7, + 63: 0x5f5fff, + 64: 0x5f8700, + 65: 0x5f875f, + 66: 0x5f8787, + 67: 0x5f87af, + 68: 0x5f87d7, + 69: 0x5f87ff, + 70: 0x5faf00, + 71: 0x5faf5f, + 72: 0x5faf87, + 73: 0x5fafaf, + 74: 0x5fafd7, + 75: 0x5fafff, + 76: 0x5fd700, + 77: 0x5fd75f, + 78: 0x5fd787, + 79: 0x5fd7af, + 80: 0x5fd7d7, + 81: 0x5fd7ff, + 82: 0x5fff00, + 83: 0x5fff5f, + 84: 0x5fff87, + 85: 0x5fffaf, + 86: 0x5fffd7, + 87: 0x5fffff, + 88: 0x870000, + 89: 0x87005f, + 90: 0x870087, + 91: 0x8700af, + 92: 0x8700d7, + 93: 0x8700ff, + 94: 0x875f00, + 95: 0x875f5f, + 96: 0x875f87, + 97: 0x875faf, + 98: 0x875fd7, + 99: 0x875fff, + 100: 0x878700, + 101: 0x87875f, + 102: 0x878787, + 103: 0x8787af, + 104: 0x8787d7, + 105: 0x8787ff, + 106: 0x87af00, + 107: 0x87af5f, + 108: 0x87af87, + 109: 0x87afaf, + 110: 0x87afd7, + 111: 0x87afff, + 112: 0x87d700, + 113: 0x87d75f, + 114: 0x87d787, + 115: 0x87d7af, + 116: 0x87d7d7, + 117: 0x87d7ff, + 118: 0x87ff00, + 119: 0x87ff5f, + 120: 0x87ff87, + 121: 0x87ffaf, + 122: 0x87ffd7, + 123: 0x87ffff, + 124: 0xaf0000, + 125: 0xaf005f, + 126: 0xaf0087, + 127: 0xaf00af, + 128: 0xaf00d7, + 129: 0xaf00ff, + 130: 0xaf5f00, + 131: 0xaf5f5f, + 132: 0xaf5f87, + 133: 0xaf5faf, + 134: 0xaf5fd7, + 135: 0xaf5fff, + 136: 0xaf8700, + 137: 0xaf875f, + 138: 0xaf8787, + 139: 0xaf87af, + 140: 0xaf87d7, + 141: 0xaf87ff, + 142: 0xafaf00, + 143: 0xafaf5f, + 144: 0xafaf87, + 145: 0xafafaf, + 146: 0xafafd7, + 147: 0xafafff, + 148: 0xafd700, + 149: 0xafd75f, + 150: 0xafd787, + 151: 0xafd7af, + 152: 0xafd7d7, + 153: 0xafd7ff, + 154: 0xafff00, + 155: 0xafff5f, + 156: 0xafff87, + 157: 0xafffaf, + 158: 0xafffd7, + 159: 0xafffff, + 160: 0xd70000, + 161: 0xd7005f, + 162: 0xd70087, + 163: 0xd700af, + 164: 0xd700d7, + 165: 0xd700ff, + 166: 0xd75f00, + 167: 0xd75f5f, + 168: 0xd75f87, + 169: 0xd75faf, + 170: 0xd75fd7, + 171: 0xd75fff, + 172: 0xd78700, + 173: 0xd7875f, + 174: 0xd78787, + 175: 0xd787af, + 176: 0xd787d7, + 177: 0xd787ff, + 178: 0xd7af00, + 179: 0xd7af5f, + 180: 0xd7af87, + 181: 0xd7afaf, + 182: 0xd7afd7, + 183: 0xd7afff, + 184: 0xd7d700, + 185: 0xd7d75f, + 186: 0xd7d787, + 187: 0xd7d7af, + 188: 0xd7d7d7, + 189: 0xd7d7ff, + 190: 0xd7ff00, + 191: 0xd7ff5f, + 192: 0xd7ff87, + 193: 0xd7ffaf, + 194: 0xd7ffd7, + 195: 0xd7ffff, + 196: 0xff0000, + 197: 0xff005f, + 198: 0xff0087, + 199: 0xff00af, + 200: 0xff00d7, + 201: 0xff00ff, + 202: 0xff5f00, + 203: 0xff5f5f, + 204: 0xff5f87, + 205: 0xff5faf, + 206: 0xff5fd7, + 207: 0xff5fff, + 208: 0xff8700, + 209: 0xff875f, + 210: 0xff8787, + 211: 0xff87af, + 212: 0xff87d7, + 213: 0xff87ff, + 214: 0xffaf00, + 215: 0xffaf5f, + 216: 0xffaf87, + 217: 0xffafaf, + 218: 0xffafd7, + 219: 0xffafff, + 220: 0xffd700, + 221: 0xffd75f, + 222: 0xffd787, + 223: 0xffd7af, + 224: 0xffd7d7, + 225: 0xffd7ff, + 226: 0xffff00, + 227: 0xffff5f, + 228: 0xffff87, + 229: 0xffffaf, + 230: 0xffffd7, + 231: 0xffffff, + 232: 0x080808, + 233: 0x121212, + 234: 0x1c1c1c, + 235: 0x262626, + 236: 0x303030, + 237: 0x3a3a3a, + 238: 0x444444, + 239: 0x4e4e4e, + 240: 0x585858, + 241: 0x626262, + 242: 0x6c6c6c, + 243: 0x767676, + 244: 0x808080, + 245: 0x8a8a8a, + 246: 0x949494, + 247: 0x9e9e9e, + 248: 0xa8a8a8, + 249: 0xb2b2b2, + 250: 0xbcbcbc, + 251: 0xc6c6c6, + 252: 0xd0d0d0, + 253: 0xdadada, + 254: 0xe4e4e4, + 255: 0xeeeeee, +} + +// `\033]0;TITLESTR\007` +func doTitleSequence(er *bytes.Reader) error { + var c byte + var err error + + c, err = er.ReadByte() + if err != nil { + return err + } + if c != '0' && c != '2' { + return nil + } + c, err = er.ReadByte() + if err != nil { + return err + } + if c != ';' { + return nil + } + title := make([]byte, 0, 80) + for { + c, err = er.ReadByte() + if err != nil { + return err + } + if c == 0x07 || c == '\n' { + break + } + title = append(title, c) + } + if len(title) > 0 { + title8, err := syscall.UTF16PtrFromString(string(title)) + if err == nil { + procSetConsoleTitle.Call(uintptr(unsafe.Pointer(title8))) + } + } + return nil +} + +// Write write data on console +func (w *Writer) Write(data []byte) (n int, err error) { + var csbi consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) + + er := bytes.NewReader(data) + var bw [1]byte +loop: + for { + r1, _, err := procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) + if r1 == 0 { + break loop + } + + c1, err := er.ReadByte() + if err != nil { + break loop + } + if c1 != 0x1b { + bw[0] = c1 + w.out.Write(bw[:]) + continue + } + c2, err := er.ReadByte() + if err != nil { + break loop + } + + if c2 == ']' { + if err := doTitleSequence(er); err != nil { + break loop + } + continue + } + if c2 != 0x5b { + continue + } + + var buf bytes.Buffer + var m byte + for { + c, err := er.ReadByte() + if err != nil { + break loop + } + if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { + m = c + break + } + buf.Write([]byte(string(c))) + } + + switch m { + case 'A': + n, err = strconv.Atoi(buf.String()) + if err != nil { + continue + } + csbi.cursorPosition.y -= short(n) + procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) + case 'B': + n, err = strconv.Atoi(buf.String()) + if err != nil { + continue + } + csbi.cursorPosition.y += short(n) + procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) + case 'C': + n, err = strconv.Atoi(buf.String()) + if err != nil { + continue + } + csbi.cursorPosition.x -= short(n) + procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) + case 'D': + n, err = strconv.Atoi(buf.String()) + if err != nil { + continue + } + if n, err = strconv.Atoi(buf.String()); err == nil { + var csbi consoleScreenBufferInfo + csbi.cursorPosition.x += short(n) + procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) + } + case 'E': + n, err = strconv.Atoi(buf.String()) + if err != nil { + continue + } + csbi.cursorPosition.x = 0 + csbi.cursorPosition.y += short(n) + procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) + case 'F': + n, err = strconv.Atoi(buf.String()) + if err != nil { + continue + } + csbi.cursorPosition.x = 0 + csbi.cursorPosition.y -= short(n) + procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) + case 'G': + n, err = strconv.Atoi(buf.String()) + if err != nil { + continue + } + csbi.cursorPosition.x = short(n - 1) + procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) + case 'H': + if buf.Len() > 0 { + token := strings.Split(buf.String(), ";") + switch len(token) { + case 1: + n1, err := strconv.Atoi(token[0]) + if err != nil { + continue + } + csbi.cursorPosition.y = short(n1 - 1) + case 2: + n1, err := strconv.Atoi(token[0]) + if err != nil { + continue + } + n2, err := strconv.Atoi(token[1]) + if err != nil { + continue + } + csbi.cursorPosition.x = short(n2 - 1) + csbi.cursorPosition.y = short(n1 - 1) + } + } else { + csbi.cursorPosition.y = 0 + } + procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition))) + case 'J': + n := 0 + if buf.Len() > 0 { + n, err = strconv.Atoi(buf.String()) + if err != nil { + continue + } + } + var count, written dword + var cursor coord + switch n { + case 0: + cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y} + count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x) + case 1: + cursor = coord{x: csbi.window.left, y: csbi.window.top} + count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.window.top-csbi.cursorPosition.y)*csbi.size.x) + case 2: + cursor = coord{x: csbi.window.left, y: csbi.window.top} + count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x) + } + procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) + procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) + case 'K': + n := 0 + if buf.Len() > 0 { + n, err = strconv.Atoi(buf.String()) + if err != nil { + continue + } + } + var cursor coord + switch n { + case 0: + cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y} + case 1: + cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y} + case 2: + cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y} + } + var count, written dword + count = dword(csbi.size.x - csbi.cursorPosition.x) + procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) + procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written))) + case 'm': + attr := csbi.attributes + cs := buf.String() + if cs == "" { + procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(w.oldattr)) + continue + } + token := strings.Split(cs, ";") + for i := 0; i < len(token); i++ { + ns := token[i] + if n, err = strconv.Atoi(ns); err == nil { + switch { + case n == 0 || n == 100: + attr = w.oldattr + case 1 <= n && n <= 5: + attr |= foregroundIntensity + case n == 7: + attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4) + case n == 22 || n == 25: + attr |= foregroundIntensity + case n == 27: + attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4) + case 30 <= n && n <= 37: + attr &= backgroundMask + if (n-30)&1 != 0 { + attr |= foregroundRed + } + if (n-30)&2 != 0 { + attr |= foregroundGreen + } + if (n-30)&4 != 0 { + attr |= foregroundBlue + } + case n == 38: // set foreground color. + if i < len(token)-2 && (token[i+1] == "5" || token[i+1] == "05") { + if n256, err := strconv.Atoi(token[i+2]); err == nil { + if n256foreAttr == nil { + n256setup() + } + attr &= backgroundMask + attr |= n256foreAttr[n256] + i += 2 + } + } else { + attr = attr & (w.oldattr & backgroundMask) + } + case n == 39: // reset foreground color. + attr &= backgroundMask + attr |= w.oldattr & foregroundMask + case 40 <= n && n <= 47: + attr &= foregroundMask + if (n-40)&1 != 0 { + attr |= backgroundRed + } + if (n-40)&2 != 0 { + attr |= backgroundGreen + } + if (n-40)&4 != 0 { + attr |= backgroundBlue + } + case n == 48: // set background color. + if i < len(token)-2 && token[i+1] == "5" { + if n256, err := strconv.Atoi(token[i+2]); err == nil { + if n256backAttr == nil { + n256setup() + } + attr &= foregroundMask + attr |= n256backAttr[n256] + i += 2 + } + } else { + attr = attr & (w.oldattr & foregroundMask) + } + case n == 49: // reset foreground color. + attr &= foregroundMask + attr |= w.oldattr & backgroundMask + case 90 <= n && n <= 97: + attr = (attr & backgroundMask) + attr |= foregroundIntensity + if (n-90)&1 != 0 { + attr |= foregroundRed + } + if (n-90)&2 != 0 { + attr |= foregroundGreen + } + if (n-90)&4 != 0 { + attr |= foregroundBlue + } + case 100 <= n && n <= 107: + attr = (attr & foregroundMask) + attr |= backgroundIntensity + if (n-100)&1 != 0 { + attr |= backgroundRed + } + if (n-100)&2 != 0 { + attr |= backgroundGreen + } + if (n-100)&4 != 0 { + attr |= backgroundBlue + } + } + procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(attr)) + } + } + case 'h': + cs := buf.String() + if cs == "?25" { + var ci consoleCursorInfo + procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) + ci.visible = 1 + procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) + } + case 'l': + cs := buf.String() + if cs == "?25" { + var ci consoleCursorInfo + procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) + ci.visible = 0 + procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci))) + } + case 's': + w.oldpos = csbi.cursorPosition + case 'u': + procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&w.oldpos))) + } + } + + return len(data), nil +} + +type consoleColor struct { + rgb int + red bool + green bool + blue bool + intensity bool +} + +func (c consoleColor) foregroundAttr() (attr word) { + if c.red { + attr |= foregroundRed + } + if c.green { + attr |= foregroundGreen + } + if c.blue { + attr |= foregroundBlue + } + if c.intensity { + attr |= foregroundIntensity + } + return +} + +func (c consoleColor) backgroundAttr() (attr word) { + if c.red { + attr |= backgroundRed + } + if c.green { + attr |= backgroundGreen + } + if c.blue { + attr |= backgroundBlue + } + if c.intensity { + attr |= backgroundIntensity + } + return +} + +var color16 = []consoleColor{ + {0x000000, false, false, false, false}, + {0x000080, false, false, true, false}, + {0x008000, false, true, false, false}, + {0x008080, false, true, true, false}, + {0x800000, true, false, false, false}, + {0x800080, true, false, true, false}, + {0x808000, true, true, false, false}, + {0xc0c0c0, true, true, true, false}, + {0x808080, false, false, false, true}, + {0x0000ff, false, false, true, true}, + {0x00ff00, false, true, false, true}, + {0x00ffff, false, true, true, true}, + {0xff0000, true, false, false, true}, + {0xff00ff, true, false, true, true}, + {0xffff00, true, true, false, true}, + {0xffffff, true, true, true, true}, +} + +type hsv struct { + h, s, v float32 +} + +func (a hsv) dist(b hsv) float32 { + dh := a.h - b.h + switch { + case dh > 0.5: + dh = 1 - dh + case dh < -0.5: + dh = -1 - dh + } + ds := a.s - b.s + dv := a.v - b.v + return float32(math.Sqrt(float64(dh*dh + ds*ds + dv*dv))) +} + +func toHSV(rgb int) hsv { + r, g, b := float32((rgb&0xFF0000)>>16)/256.0, + float32((rgb&0x00FF00)>>8)/256.0, + float32(rgb&0x0000FF)/256.0 + min, max := minmax3f(r, g, b) + h := max - min + if h > 0 { + if max == r { + h = (g - b) / h + if h < 0 { + h += 6 + } + } else if max == g { + h = 2 + (b-r)/h + } else { + h = 4 + (r-g)/h + } + } + h /= 6.0 + s := max - min + if max != 0 { + s /= max + } + v := max + return hsv{h: h, s: s, v: v} +} + +type hsvTable []hsv + +func toHSVTable(rgbTable []consoleColor) hsvTable { + t := make(hsvTable, len(rgbTable)) + for i, c := range rgbTable { + t[i] = toHSV(c.rgb) + } + return t +} + +func (t hsvTable) find(rgb int) consoleColor { + hsv := toHSV(rgb) + n := 7 + l := float32(5.0) + for i, p := range t { + d := hsv.dist(p) + if d < l { + l, n = d, i + } + } + return color16[n] +} + +func minmax3f(a, b, c float32) (min, max float32) { + if a < b { + if b < c { + return a, c + } else if a < c { + return a, b + } else { + return c, b + } + } else { + if a < c { + return b, c + } else if b < c { + return b, a + } else { + return c, a + } + } +} + +var n256foreAttr []word +var n256backAttr []word + +func n256setup() { + n256foreAttr = make([]word, 256) + n256backAttr = make([]word, 256) + t := toHSVTable(color16) + for i, rgb := range color256 { + c := t.find(rgb) + n256foreAttr[i] = c.foregroundAttr() + n256backAttr[i] = c.backgroundAttr() + } +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/noncolorable.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/noncolorable.go new file mode 100644 index 0000000..9721e16 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-colorable/noncolorable.go @@ -0,0 +1,55 @@ +package colorable + +import ( + "bytes" + "io" +) + +// NonColorable hold writer but remove escape sequence. +type NonColorable struct { + out io.Writer +} + +// NewNonColorable return new instance of Writer which remove escape sequence from Writer. +func NewNonColorable(w io.Writer) io.Writer { + return &NonColorable{out: w} +} + +// Write write data on console +func (w *NonColorable) Write(data []byte) (n int, err error) { + er := bytes.NewReader(data) + var bw [1]byte +loop: + for { + c1, err := er.ReadByte() + if err != nil { + break loop + } + if c1 != 0x1b { + bw[0] = c1 + w.out.Write(bw[:]) + continue + } + c2, err := er.ReadByte() + if err != nil { + break loop + } + if c2 != 0x5b { + continue + } + + var buf bytes.Buffer + for { + c, err := er.ReadByte() + if err != nil { + break loop + } + if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { + break + } + buf.Write([]byte(string(c))) + } + } + + return len(data), nil +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/.travis.yml b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/.travis.yml new file mode 100644 index 0000000..b9f8b23 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/.travis.yml @@ -0,0 +1,9 @@ +language: go +go: + - tip + +before_install: + - go get github.com/mattn/goveralls + - go get golang.org/x/tools/cmd/cover +script: + - $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5 diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/LICENSE b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/LICENSE new file mode 100644 index 0000000..65dc692 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/LICENSE @@ -0,0 +1,9 @@ +Copyright (c) Yasuhiro MATSUMOTO + +MIT License (Expat) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/README.md b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/README.md new file mode 100644 index 0000000..1e69004 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/README.md @@ -0,0 +1,50 @@ +# go-isatty + +[![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty) +[![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty) +[![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master) +[![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty) + +isatty for golang + +## Usage + +```go +package main + +import ( + "fmt" + "github.com/mattn/go-isatty" + "os" +) + +func main() { + if isatty.IsTerminal(os.Stdout.Fd()) { + fmt.Println("Is Terminal") + } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) { + fmt.Println("Is Cygwin/MSYS2 Terminal") + } else { + fmt.Println("Is Not Terminal") + } +} +``` + +## Installation + +``` +$ go get github.com/mattn/go-isatty +``` + +## License + +MIT + +## Author + +Yasuhiro Matsumoto (a.k.a mattn) + +## Thanks + +* k-takata: base idea for IsCygwinTerminal + + https://github.com/k-takata/go-iscygpty diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/doc.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/doc.go new file mode 100644 index 0000000..17d4f90 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/doc.go @@ -0,0 +1,2 @@ +// Package isatty implements interface to isatty +package isatty diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_appengine.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_appengine.go new file mode 100644 index 0000000..9584a98 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_appengine.go @@ -0,0 +1,15 @@ +// +build appengine + +package isatty + +// IsTerminal returns true if the file descriptor is terminal which +// is always false on on appengine classic which is a sandboxed PaaS. +func IsTerminal(fd uintptr) bool { + return false +} + +// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 +// terminal. This is also always false on this environment. +func IsCygwinTerminal(fd uintptr) bool { + return false +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_bsd.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_bsd.go new file mode 100644 index 0000000..42f2514 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_bsd.go @@ -0,0 +1,18 @@ +// +build darwin freebsd openbsd netbsd dragonfly +// +build !appengine + +package isatty + +import ( + "syscall" + "unsafe" +) + +const ioctlReadTermios = syscall.TIOCGETA + +// IsTerminal return true if the file descriptor is terminal. +func IsTerminal(fd uintptr) bool { + var termios syscall.Termios + _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) + return err == 0 +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_linux.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_linux.go new file mode 100644 index 0000000..7384cf9 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_linux.go @@ -0,0 +1,18 @@ +// +build linux +// +build !appengine,!ppc64,!ppc64le + +package isatty + +import ( + "syscall" + "unsafe" +) + +const ioctlReadTermios = syscall.TCGETS + +// IsTerminal return true if the file descriptor is terminal. +func IsTerminal(fd uintptr) bool { + var termios syscall.Termios + _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) + return err == 0 +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go new file mode 100644 index 0000000..44e5d21 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go @@ -0,0 +1,19 @@ +// +build linux +// +build ppc64 ppc64le + +package isatty + +import ( + "unsafe" + + syscall "golang.org/x/sys/unix" +) + +const ioctlReadTermios = syscall.TCGETS + +// IsTerminal return true if the file descriptor is terminal. +func IsTerminal(fd uintptr) bool { + var termios syscall.Termios + _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) + return err == 0 +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_others.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_others.go new file mode 100644 index 0000000..ff4de3d --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_others.go @@ -0,0 +1,10 @@ +// +build !windows +// +build !appengine + +package isatty + +// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 +// terminal. This is also always false on this environment. +func IsCygwinTerminal(fd uintptr) bool { + return false +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_solaris.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_solaris.go new file mode 100644 index 0000000..1f0c6bf --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_solaris.go @@ -0,0 +1,16 @@ +// +build solaris +// +build !appengine + +package isatty + +import ( + "golang.org/x/sys/unix" +) + +// IsTerminal returns true if the given file descriptor is a terminal. +// see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c +func IsTerminal(fd uintptr) bool { + var termio unix.Termio + err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) + return err == nil +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_windows.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_windows.go new file mode 100644 index 0000000..af51cbc --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/mattn/go-isatty/isatty_windows.go @@ -0,0 +1,94 @@ +// +build windows +// +build !appengine + +package isatty + +import ( + "strings" + "syscall" + "unicode/utf16" + "unsafe" +) + +const ( + fileNameInfo uintptr = 2 + fileTypePipe = 3 +) + +var ( + kernel32 = syscall.NewLazyDLL("kernel32.dll") + procGetConsoleMode = kernel32.NewProc("GetConsoleMode") + procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx") + procGetFileType = kernel32.NewProc("GetFileType") +) + +func init() { + // Check if GetFileInformationByHandleEx is available. + if procGetFileInformationByHandleEx.Find() != nil { + procGetFileInformationByHandleEx = nil + } +} + +// IsTerminal return true if the file descriptor is terminal. +func IsTerminal(fd uintptr) bool { + var st uint32 + r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) + return r != 0 && e == 0 +} + +// Check pipe name is used for cygwin/msys2 pty. +// Cygwin/MSYS2 PTY has a name like: +// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master +func isCygwinPipeName(name string) bool { + token := strings.Split(name, "-") + if len(token) < 5 { + return false + } + + if token[0] != `\msys` && token[0] != `\cygwin` { + return false + } + + if token[1] == "" { + return false + } + + if !strings.HasPrefix(token[2], "pty") { + return false + } + + if token[3] != `from` && token[3] != `to` { + return false + } + + if token[4] != "master" { + return false + } + + return true +} + +// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 +// terminal. +func IsCygwinTerminal(fd uintptr) bool { + if procGetFileInformationByHandleEx == nil { + return false + } + + // Cygwin/msys's pty is a pipe. + ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0) + if ft != fileTypePipe || e != 0 { + return false + } + + var buf [2 + syscall.MAX_PATH]uint16 + r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), + 4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)), + uintptr(len(buf)*2), 0, 0) + if r == 0 || e != 0 { + return false + } + + l := *(*uint32)(unsafe.Pointer(&buf)) + return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2]))) +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/COPYING b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/COPYING new file mode 100644 index 0000000..9e8c9f2 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/COPYING @@ -0,0 +1,21 @@ +Copyright © 2012 Peter Harris + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/README.md b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/README.md new file mode 100644 index 0000000..9148b24 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/README.md @@ -0,0 +1,100 @@ +Liner +===== + +Liner is a command line editor with history. It was inspired by linenoise; +everything Unix-like is a VT100 (or is trying very hard to be). If your +terminal is not pretending to be a VT100, change it. Liner also support +Windows. + +Liner is released under the X11 license (which is similar to the new BSD +license). + +Line Editing +------------ + +The following line editing commands are supported on platforms and terminals +that Liner supports: + +Keystroke | Action +--------- | ------ +Ctrl-A, Home | Move cursor to beginning of line +Ctrl-E, End | Move cursor to end of line +Ctrl-B, Left | Move cursor one character left +Ctrl-F, Right| Move cursor one character right +Ctrl-Left, Alt-B | Move cursor to previous word +Ctrl-Right, Alt-F | Move cursor to next word +Ctrl-D, Del | (if line is *not* empty) Delete character under cursor +Ctrl-D | (if line *is* empty) End of File - usually quits application +Ctrl-C | Reset input (create new empty prompt) +Ctrl-L | Clear screen (line is unmodified) +Ctrl-T | Transpose previous character with current character +Ctrl-H, BackSpace | Delete character before cursor +Ctrl-W | Delete word leading up to cursor +Ctrl-K | Delete from cursor to end of line +Ctrl-U | Delete from start of line to cursor +Ctrl-P, Up | Previous match from history +Ctrl-N, Down | Next match from history +Ctrl-R | Reverse Search history (Ctrl-S forward, Ctrl-G cancel) +Ctrl-Y | Paste from Yank buffer (Alt-Y to paste next yank instead) +Tab | Next completion +Shift-Tab | (after Tab) Previous completion + +Getting started +----------------- + +```go +package main + +import ( + "log" + "os" + "path/filepath" + "strings" + + "github.com/peterh/liner" +) + +var ( + history_fn = filepath.Join(os.TempDir(), ".liner_example_history") + names = []string{"john", "james", "mary", "nancy"} +) + +func main() { + line := liner.NewLiner() + defer line.Close() + + line.SetCtrlCAborts(true) + + line.SetCompleter(func(line string) (c []string) { + for _, n := range names { + if strings.HasPrefix(n, strings.ToLower(line)) { + c = append(c, n) + } + } + return + }) + + if f, err := os.Open(history_fn); err == nil { + line.ReadHistory(f) + f.Close() + } + + if name, err := line.Prompt("What is your name? "); err == nil { + log.Print("Got: ", name) + line.AppendHistory(name) + } else if err == liner.ErrPromptAborted { + log.Print("Aborted") + } else { + log.Print("Error reading line: ", err) + } + + if f, err := os.Create(history_fn); err != nil { + log.Print("Error writing history file: ", err) + } else { + line.WriteHistory(f) + f.Close() + } +} +``` + +For documentation, see http://godoc.org/github.com/peterh/liner diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/bsdinput.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/bsdinput.go new file mode 100644 index 0000000..3593398 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/bsdinput.go @@ -0,0 +1,41 @@ +// +build openbsd freebsd netbsd + +package liner + +import "syscall" + +const ( + getTermios = syscall.TIOCGETA + setTermios = syscall.TIOCSETA +) + +const ( + // Input flags + inpck = 0x010 + istrip = 0x020 + icrnl = 0x100 + ixon = 0x200 + + // Output flags + opost = 0x1 + + // Control flags + cs8 = 0x300 + + // Local flags + isig = 0x080 + icanon = 0x100 + iexten = 0x400 +) + +type termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]byte + Ispeed int32 + Ospeed int32 +} + +const cursorColumn = false diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/common.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/common.go new file mode 100644 index 0000000..7923c38 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/common.go @@ -0,0 +1,255 @@ +/* +Package liner implements a simple command line editor, inspired by linenoise +(https://github.com/antirez/linenoise/). This package supports WIN32 in +addition to the xterm codes supported by everything else. +*/ +package liner + +import ( + "bufio" + "container/ring" + "errors" + "fmt" + "io" + "strings" + "sync" + "unicode/utf8" +) + +type commonState struct { + terminalSupported bool + outputRedirected bool + inputRedirected bool + history []string + historyMutex sync.RWMutex + completer WordCompleter + columns int + killRing *ring.Ring + ctrlCAborts bool + r *bufio.Reader + tabStyle TabStyle + multiLineMode bool + cursorRows int + maxRows int + shouldRestart ShouldRestart + needRefresh bool +} + +// TabStyle is used to select how tab completions are displayed. +type TabStyle int + +// Two tab styles are currently available: +// +// TabCircular cycles through each completion item and displays it directly on +// the prompt +// +// TabPrints prints the list of completion items to the screen after a second +// tab key is pressed. This behaves similar to GNU readline and BASH (which +// uses readline) +const ( + TabCircular TabStyle = iota + TabPrints +) + +// ErrPromptAborted is returned from Prompt or PasswordPrompt when the user presses Ctrl-C +// if SetCtrlCAborts(true) has been called on the State +var ErrPromptAborted = errors.New("prompt aborted") + +// ErrNotTerminalOutput is returned from Prompt or PasswordPrompt if the +// platform is normally supported, but stdout has been redirected +var ErrNotTerminalOutput = errors.New("standard output is not a terminal") + +// ErrInvalidPrompt is returned from Prompt or PasswordPrompt if the +// prompt contains any unprintable runes (including substrings that could +// be colour codes on some platforms). +var ErrInvalidPrompt = errors.New("invalid prompt") + +// ErrInternal is returned when liner experiences an error that it cannot +// handle. For example, if the number of colums becomes zero during an +// active call to Prompt +var ErrInternal = errors.New("liner: internal error") + +// KillRingMax is the max number of elements to save on the killring. +const KillRingMax = 60 + +// HistoryLimit is the maximum number of entries saved in the scrollback history. +const HistoryLimit = 1000 + +// ReadHistory reads scrollback history from r. Returns the number of lines +// read, and any read error (except io.EOF). +func (s *State) ReadHistory(r io.Reader) (num int, err error) { + s.historyMutex.Lock() + defer s.historyMutex.Unlock() + + in := bufio.NewReader(r) + num = 0 + for { + line, part, err := in.ReadLine() + if err == io.EOF { + break + } + if err != nil { + return num, err + } + if part { + return num, fmt.Errorf("line %d is too long", num+1) + } + if !utf8.Valid(line) { + return num, fmt.Errorf("invalid string at line %d", num+1) + } + num++ + s.history = append(s.history, string(line)) + if len(s.history) > HistoryLimit { + s.history = s.history[1:] + } + } + return num, nil +} + +// WriteHistory writes scrollback history to w. Returns the number of lines +// successfully written, and any write error. +// +// Unlike the rest of liner's API, WriteHistory is safe to call +// from another goroutine while Prompt is in progress. +// This exception is to facilitate the saving of the history buffer +// during an unexpected exit (for example, due to Ctrl-C being invoked) +func (s *State) WriteHistory(w io.Writer) (num int, err error) { + s.historyMutex.RLock() + defer s.historyMutex.RUnlock() + + for _, item := range s.history { + _, err := fmt.Fprintln(w, item) + if err != nil { + return num, err + } + num++ + } + return num, nil +} + +// AppendHistory appends an entry to the scrollback history. AppendHistory +// should be called iff Prompt returns a valid command. +func (s *State) AppendHistory(item string) { + s.historyMutex.Lock() + defer s.historyMutex.Unlock() + + if len(s.history) > 0 { + if item == s.history[len(s.history)-1] { + return + } + } + s.history = append(s.history, item) + if len(s.history) > HistoryLimit { + s.history = s.history[1:] + } +} + +// ClearHistory clears the scroollback history. +func (s *State) ClearHistory() { + s.historyMutex.Lock() + defer s.historyMutex.Unlock() + s.history = nil +} + +// Returns the history lines starting with prefix +func (s *State) getHistoryByPrefix(prefix string) (ph []string) { + for _, h := range s.history { + if strings.HasPrefix(h, prefix) { + ph = append(ph, h) + } + } + return +} + +// Returns the history lines matching the inteligent search +func (s *State) getHistoryByPattern(pattern string) (ph []string, pos []int) { + if pattern == "" { + return + } + for _, h := range s.history { + if i := strings.Index(h, pattern); i >= 0 { + ph = append(ph, h) + pos = append(pos, i) + } + } + return +} + +// Completer takes the currently edited line content at the left of the cursor +// and returns a list of completion candidates. +// If the line is "Hello, wo!!!" and the cursor is before the first '!', "Hello, wo" is passed +// to the completer which may return {"Hello, world", "Hello, Word"} to have "Hello, world!!!". +type Completer func(line string) []string + +// WordCompleter takes the currently edited line with the cursor position and +// returns the completion candidates for the partial word to be completed. +// If the line is "Hello, wo!!!" and the cursor is before the first '!', ("Hello, wo!!!", 9) is passed +// to the completer which may returns ("Hello, ", {"world", "Word"}, "!!!") to have "Hello, world!!!". +type WordCompleter func(line string, pos int) (head string, completions []string, tail string) + +// SetCompleter sets the completion function that Liner will call to +// fetch completion candidates when the user presses tab. +func (s *State) SetCompleter(f Completer) { + if f == nil { + s.completer = nil + return + } + s.completer = func(line string, pos int) (string, []string, string) { + return "", f(string([]rune(line)[:pos])), string([]rune(line)[pos:]) + } +} + +// SetWordCompleter sets the completion function that Liner will call to +// fetch completion candidates when the user presses tab. +func (s *State) SetWordCompleter(f WordCompleter) { + s.completer = f +} + +// SetTabCompletionStyle sets the behvavior when the Tab key is pressed +// for auto-completion. TabCircular is the default behavior and cycles +// through the list of candidates at the prompt. TabPrints will print +// the available completion candidates to the screen similar to BASH +// and GNU Readline +func (s *State) SetTabCompletionStyle(tabStyle TabStyle) { + s.tabStyle = tabStyle +} + +// ModeApplier is the interface that wraps a representation of the terminal +// mode. ApplyMode sets the terminal to this mode. +type ModeApplier interface { + ApplyMode() error +} + +// SetCtrlCAborts sets whether Prompt on a supported terminal will return an +// ErrPromptAborted when Ctrl-C is pressed. The default is false (will not +// return when Ctrl-C is pressed). Unsupported terminals typically raise SIGINT +// (and Prompt does not return) regardless of the value passed to SetCtrlCAborts. +func (s *State) SetCtrlCAborts(aborts bool) { + s.ctrlCAborts = aborts +} + +// SetMultiLineMode sets whether line is auto-wrapped. The default is false (single line). +func (s *State) SetMultiLineMode(mlmode bool) { + s.multiLineMode = mlmode +} + +// ShouldRestart is passed the error generated by readNext and returns true if +// the the read should be restarted or false if the error should be returned. +type ShouldRestart func(err error) bool + +// SetShouldRestart sets the restart function that Liner will call to determine +// whether to retry the call to, or return the error returned by, readNext. +func (s *State) SetShouldRestart(f ShouldRestart) { + s.shouldRestart = f +} + +func (s *State) promptUnsupported(p string) (string, error) { + if !s.inputRedirected || !s.terminalSupported { + fmt.Print(p) + } + linebuf, _, err := s.r.ReadLine() + if err != nil { + return "", err + } + return string(linebuf), nil +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/fallbackinput.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/fallbackinput.go new file mode 100644 index 0000000..d9eb79d --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/fallbackinput.go @@ -0,0 +1,57 @@ +// +build !windows,!linux,!darwin,!openbsd,!freebsd,!netbsd + +package liner + +import ( + "bufio" + "errors" + "os" +) + +// State represents an open terminal +type State struct { + commonState +} + +// Prompt displays p, and then waits for user input. Prompt does not support +// line editing on this operating system. +func (s *State) Prompt(p string) (string, error) { + return s.promptUnsupported(p) +} + +// PasswordPrompt is not supported in this OS. +func (s *State) PasswordPrompt(p string) (string, error) { + return "", errors.New("liner: function not supported in this terminal") +} + +// NewLiner initializes a new *State +// +// Note that this operating system uses a fallback mode without line +// editing. Patches welcome. +func NewLiner() *State { + var s State + s.r = bufio.NewReader(os.Stdin) + return &s +} + +// Close returns the terminal to its previous mode +func (s *State) Close() error { + return nil +} + +// TerminalSupported returns false because line editing is not +// supported on this platform. +func TerminalSupported() bool { + return false +} + +type noopMode struct{} + +func (n noopMode) ApplyMode() error { + return nil +} + +// TerminalMode returns a noop InputModeSetter on this platform. +func TerminalMode() (ModeApplier, error) { + return noopMode{}, nil +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input.go new file mode 100644 index 0000000..95dd5d1 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input.go @@ -0,0 +1,364 @@ +// +build linux darwin openbsd freebsd netbsd + +package liner + +import ( + "bufio" + "errors" + "os" + "os/signal" + "strconv" + "strings" + "syscall" + "time" +) + +type nexter struct { + r rune + err error +} + +// State represents an open terminal +type State struct { + commonState + origMode termios + defaultMode termios + next <-chan nexter + winch chan os.Signal + pending []rune + useCHA bool +} + +// NewLiner initializes a new *State, and sets the terminal into raw mode. To +// restore the terminal to its previous state, call State.Close(). +func NewLiner() *State { + var s State + s.r = bufio.NewReader(os.Stdin) + + s.terminalSupported = TerminalSupported() + if m, err := TerminalMode(); err == nil { + s.origMode = *m.(*termios) + } else { + s.inputRedirected = true + } + if _, err := getMode(syscall.Stdout); err != 0 { + s.outputRedirected = true + } + if s.inputRedirected && s.outputRedirected { + s.terminalSupported = false + } + if s.terminalSupported && !s.inputRedirected && !s.outputRedirected { + mode := s.origMode + mode.Iflag &^= icrnl | inpck | istrip | ixon + mode.Cflag |= cs8 + mode.Lflag &^= syscall.ECHO | icanon | iexten + mode.ApplyMode() + + winch := make(chan os.Signal, 1) + signal.Notify(winch, syscall.SIGWINCH) + s.winch = winch + + s.checkOutput() + } + + if !s.outputRedirected { + s.outputRedirected = !s.getColumns() + } + + return &s +} + +var errTimedOut = errors.New("timeout") + +func (s *State) startPrompt() { + if s.terminalSupported { + if m, err := TerminalMode(); err == nil { + s.defaultMode = *m.(*termios) + mode := s.defaultMode + mode.Lflag &^= isig + mode.ApplyMode() + } + } + s.restartPrompt() +} + +func (s *State) inputWaiting() bool { + return len(s.next) > 0 +} + +func (s *State) restartPrompt() { + next := make(chan nexter, 200) + go func() { + for { + var n nexter + n.r, _, n.err = s.r.ReadRune() + next <- n + // Shut down nexter loop when an end condition has been reached + if n.err != nil || n.r == '\n' || n.r == '\r' || n.r == ctrlC || n.r == ctrlD { + close(next) + return + } + } + }() + s.next = next +} + +func (s *State) stopPrompt() { + if s.terminalSupported { + s.defaultMode.ApplyMode() + } +} + +func (s *State) nextPending(timeout <-chan time.Time) (rune, error) { + select { + case thing, ok := <-s.next: + if !ok { + return 0, ErrInternal + } + if thing.err != nil { + return 0, thing.err + } + s.pending = append(s.pending, thing.r) + return thing.r, nil + case <-timeout: + rv := s.pending[0] + s.pending = s.pending[1:] + return rv, errTimedOut + } +} + +func (s *State) readNext() (interface{}, error) { + if len(s.pending) > 0 { + rv := s.pending[0] + s.pending = s.pending[1:] + return rv, nil + } + var r rune + select { + case thing, ok := <-s.next: + if !ok { + return 0, ErrInternal + } + if thing.err != nil { + return nil, thing.err + } + r = thing.r + case <-s.winch: + s.getColumns() + return winch, nil + } + if r != esc { + return r, nil + } + s.pending = append(s.pending, r) + + // Wait at most 50 ms for the rest of the escape sequence + // If nothing else arrives, it was an actual press of the esc key + timeout := time.After(50 * time.Millisecond) + flag, err := s.nextPending(timeout) + if err != nil { + if err == errTimedOut { + return flag, nil + } + return unknown, err + } + + switch flag { + case '[': + code, err := s.nextPending(timeout) + if err != nil { + if err == errTimedOut { + return code, nil + } + return unknown, err + } + switch code { + case 'A': + s.pending = s.pending[:0] // escape code complete + return up, nil + case 'B': + s.pending = s.pending[:0] // escape code complete + return down, nil + case 'C': + s.pending = s.pending[:0] // escape code complete + return right, nil + case 'D': + s.pending = s.pending[:0] // escape code complete + return left, nil + case 'F': + s.pending = s.pending[:0] // escape code complete + return end, nil + case 'H': + s.pending = s.pending[:0] // escape code complete + return home, nil + case 'Z': + s.pending = s.pending[:0] // escape code complete + return shiftTab, nil + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + num := []rune{code} + for { + code, err := s.nextPending(timeout) + if err != nil { + if err == errTimedOut { + return code, nil + } + return nil, err + } + switch code { + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + num = append(num, code) + case ';': + // Modifier code to follow + // This only supports Ctrl-left and Ctrl-right for now + x, _ := strconv.ParseInt(string(num), 10, 32) + if x != 1 { + // Can't be left or right + rv := s.pending[0] + s.pending = s.pending[1:] + return rv, nil + } + num = num[:0] + for { + code, err = s.nextPending(timeout) + if err != nil { + if err == errTimedOut { + rv := s.pending[0] + s.pending = s.pending[1:] + return rv, nil + } + return nil, err + } + switch code { + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + num = append(num, code) + case 'C', 'D': + // right, left + mod, _ := strconv.ParseInt(string(num), 10, 32) + if mod != 5 { + // Not bare Ctrl + rv := s.pending[0] + s.pending = s.pending[1:] + return rv, nil + } + s.pending = s.pending[:0] // escape code complete + if code == 'C' { + return wordRight, nil + } + return wordLeft, nil + default: + // Not left or right + rv := s.pending[0] + s.pending = s.pending[1:] + return rv, nil + } + } + case '~': + s.pending = s.pending[:0] // escape code complete + x, _ := strconv.ParseInt(string(num), 10, 32) + switch x { + case 2: + return insert, nil + case 3: + return del, nil + case 5: + return pageUp, nil + case 6: + return pageDown, nil + case 7: + return home, nil + case 8: + return end, nil + case 15: + return f5, nil + case 17: + return f6, nil + case 18: + return f7, nil + case 19: + return f8, nil + case 20: + return f9, nil + case 21: + return f10, nil + case 23: + return f11, nil + case 24: + return f12, nil + default: + return unknown, nil + } + default: + // unrecognized escape code + rv := s.pending[0] + s.pending = s.pending[1:] + return rv, nil + } + } + } + + case 'O': + code, err := s.nextPending(timeout) + if err != nil { + if err == errTimedOut { + return code, nil + } + return nil, err + } + s.pending = s.pending[:0] // escape code complete + switch code { + case 'c': + return wordRight, nil + case 'd': + return wordLeft, nil + case 'H': + return home, nil + case 'F': + return end, nil + case 'P': + return f1, nil + case 'Q': + return f2, nil + case 'R': + return f3, nil + case 'S': + return f4, nil + default: + return unknown, nil + } + case 'b': + s.pending = s.pending[:0] // escape code complete + return altB, nil + case 'f': + s.pending = s.pending[:0] // escape code complete + return altF, nil + case 'y': + s.pending = s.pending[:0] // escape code complete + return altY, nil + default: + rv := s.pending[0] + s.pending = s.pending[1:] + return rv, nil + } + + // not reached + return r, nil +} + +// Close returns the terminal to its previous mode +func (s *State) Close() error { + signal.Stop(s.winch) + if !s.inputRedirected { + s.origMode.ApplyMode() + } + return nil +} + +// TerminalSupported returns true if the current terminal supports +// line editing features, and false if liner will use the 'dumb' +// fallback for input. +// Note that TerminalSupported does not check all factors that may +// cause liner to not fully support the terminal (such as stdin redirection) +func TerminalSupported() bool { + bad := map[string]bool{"": true, "dumb": true, "cons25": true} + return !bad[strings.ToLower(os.Getenv("TERM"))] +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input_darwin.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input_darwin.go new file mode 100644 index 0000000..e98ab4a --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input_darwin.go @@ -0,0 +1,43 @@ +// +build darwin + +package liner + +import "syscall" + +const ( + getTermios = syscall.TIOCGETA + setTermios = syscall.TIOCSETA +) + +const ( + // Input flags + inpck = 0x010 + istrip = 0x020 + icrnl = 0x100 + ixon = 0x200 + + // Output flags + opost = 0x1 + + // Control flags + cs8 = 0x300 + + // Local flags + isig = 0x080 + icanon = 0x100 + iexten = 0x400 +) + +type termios struct { + Iflag uintptr + Oflag uintptr + Cflag uintptr + Lflag uintptr + Cc [20]byte + Ispeed uintptr + Ospeed uintptr +} + +// Terminal.app needs a column for the cursor when the input line is at the +// bottom of the window. +const cursorColumn = true diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input_linux.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input_linux.go new file mode 100644 index 0000000..56ed185 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input_linux.go @@ -0,0 +1,28 @@ +// +build linux + +package liner + +import "syscall" + +const ( + getTermios = syscall.TCGETS + setTermios = syscall.TCSETS +) + +const ( + icrnl = syscall.ICRNL + inpck = syscall.INPCK + istrip = syscall.ISTRIP + ixon = syscall.IXON + opost = syscall.OPOST + cs8 = syscall.CS8 + isig = syscall.ISIG + icanon = syscall.ICANON + iexten = syscall.IEXTEN +) + +type termios struct { + syscall.Termios +} + +const cursorColumn = false diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input_windows.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input_windows.go new file mode 100644 index 0000000..a48eb0f --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/input_windows.go @@ -0,0 +1,339 @@ +package liner + +import ( + "bufio" + "os" + "syscall" + "unsafe" +) + +var ( + kernel32 = syscall.NewLazyDLL("kernel32.dll") + + procGetStdHandle = kernel32.NewProc("GetStdHandle") + procReadConsoleInput = kernel32.NewProc("ReadConsoleInputW") + procGetNumberOfConsoleInputEvents = kernel32.NewProc("GetNumberOfConsoleInputEvents") + procGetConsoleMode = kernel32.NewProc("GetConsoleMode") + procSetConsoleMode = kernel32.NewProc("SetConsoleMode") + procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition") + procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") + procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW") +) + +// These names are from the Win32 api, so they use underscores (contrary to +// what golint suggests) +const ( + std_input_handle = uint32(-10 & 0xFFFFFFFF) + std_output_handle = uint32(-11 & 0xFFFFFFFF) + std_error_handle = uint32(-12 & 0xFFFFFFFF) + invalid_handle_value = ^uintptr(0) +) + +type inputMode uint32 + +// State represents an open terminal +type State struct { + commonState + handle syscall.Handle + hOut syscall.Handle + origMode inputMode + defaultMode inputMode + key interface{} + repeat uint16 +} + +const ( + enableEchoInput = 0x4 + enableInsertMode = 0x20 + enableLineInput = 0x2 + enableMouseInput = 0x10 + enableProcessedInput = 0x1 + enableQuickEditMode = 0x40 + enableWindowInput = 0x8 +) + +// NewLiner initializes a new *State, and sets the terminal into raw mode. To +// restore the terminal to its previous state, call State.Close(). +func NewLiner() *State { + var s State + hIn, _, _ := procGetStdHandle.Call(uintptr(std_input_handle)) + s.handle = syscall.Handle(hIn) + hOut, _, _ := procGetStdHandle.Call(uintptr(std_output_handle)) + s.hOut = syscall.Handle(hOut) + + s.terminalSupported = true + if m, err := TerminalMode(); err == nil { + s.origMode = m.(inputMode) + mode := s.origMode + mode &^= enableEchoInput + mode &^= enableInsertMode + mode &^= enableLineInput + mode &^= enableMouseInput + mode |= enableWindowInput + mode.ApplyMode() + } else { + s.inputRedirected = true + s.r = bufio.NewReader(os.Stdin) + } + + s.getColumns() + s.outputRedirected = s.columns <= 0 + + return &s +} + +// These names are from the Win32 api, so they use underscores (contrary to +// what golint suggests) +const ( + focus_event = 0x0010 + key_event = 0x0001 + menu_event = 0x0008 + mouse_event = 0x0002 + window_buffer_size_event = 0x0004 +) + +type input_record struct { + eventType uint16 + pad uint16 + blob [16]byte +} + +type key_event_record struct { + KeyDown int32 + RepeatCount uint16 + VirtualKeyCode uint16 + VirtualScanCode uint16 + Char int16 + ControlKeyState uint32 +} + +// These names are from the Win32 api, so they use underscores (contrary to +// what golint suggests) +const ( + vk_tab = 0x09 + vk_prior = 0x21 + vk_next = 0x22 + vk_end = 0x23 + vk_home = 0x24 + vk_left = 0x25 + vk_up = 0x26 + vk_right = 0x27 + vk_down = 0x28 + vk_insert = 0x2d + vk_delete = 0x2e + vk_f1 = 0x70 + vk_f2 = 0x71 + vk_f3 = 0x72 + vk_f4 = 0x73 + vk_f5 = 0x74 + vk_f6 = 0x75 + vk_f7 = 0x76 + vk_f8 = 0x77 + vk_f9 = 0x78 + vk_f10 = 0x79 + vk_f11 = 0x7a + vk_f12 = 0x7b + bKey = 0x42 + fKey = 0x46 + yKey = 0x59 +) + +const ( + shiftPressed = 0x0010 + leftAltPressed = 0x0002 + leftCtrlPressed = 0x0008 + rightAltPressed = 0x0001 + rightCtrlPressed = 0x0004 + + modKeys = shiftPressed | leftAltPressed | rightAltPressed | leftCtrlPressed | rightCtrlPressed +) + +// inputWaiting only returns true if the next call to readNext will return immediately. +func (s *State) inputWaiting() bool { + var num uint32 + ok, _, _ := procGetNumberOfConsoleInputEvents.Call(uintptr(s.handle), uintptr(unsafe.Pointer(&num))) + if ok == 0 { + // call failed, so we cannot guarantee a non-blocking readNext + return false + } + + // during a "paste" input events are always an odd number, and + // the last one results in a blocking readNext, so return false + // when num is 1 or 0. + return num > 1 +} + +func (s *State) readNext() (interface{}, error) { + if s.repeat > 0 { + s.repeat-- + return s.key, nil + } + + var input input_record + pbuf := uintptr(unsafe.Pointer(&input)) + var rv uint32 + prv := uintptr(unsafe.Pointer(&rv)) + + for { + ok, _, err := procReadConsoleInput.Call(uintptr(s.handle), pbuf, 1, prv) + + if ok == 0 { + return nil, err + } + + if input.eventType == window_buffer_size_event { + xy := (*coord)(unsafe.Pointer(&input.blob[0])) + s.columns = int(xy.x) + if s.columns > 1 { + s.columns-- + } + return winch, nil + } + if input.eventType != key_event { + continue + } + ke := (*key_event_record)(unsafe.Pointer(&input.blob[0])) + if ke.KeyDown == 0 { + continue + } + + if ke.VirtualKeyCode == vk_tab && ke.ControlKeyState&modKeys == shiftPressed { + s.key = shiftTab + } else if ke.VirtualKeyCode == bKey && (ke.ControlKeyState&modKeys == leftAltPressed || + ke.ControlKeyState&modKeys == rightAltPressed) { + s.key = altB + } else if ke.VirtualKeyCode == fKey && (ke.ControlKeyState&modKeys == leftAltPressed || + ke.ControlKeyState&modKeys == rightAltPressed) { + s.key = altF + } else if ke.VirtualKeyCode == yKey && (ke.ControlKeyState&modKeys == leftAltPressed || + ke.ControlKeyState&modKeys == rightAltPressed) { + s.key = altY + } else if ke.Char > 0 { + s.key = rune(ke.Char) + } else { + switch ke.VirtualKeyCode { + case vk_prior: + s.key = pageUp + case vk_next: + s.key = pageDown + case vk_end: + s.key = end + case vk_home: + s.key = home + case vk_left: + s.key = left + if ke.ControlKeyState&(leftCtrlPressed|rightCtrlPressed) != 0 { + if ke.ControlKeyState&modKeys == ke.ControlKeyState&(leftCtrlPressed|rightCtrlPressed) { + s.key = wordLeft + } + } + case vk_right: + s.key = right + if ke.ControlKeyState&(leftCtrlPressed|rightCtrlPressed) != 0 { + if ke.ControlKeyState&modKeys == ke.ControlKeyState&(leftCtrlPressed|rightCtrlPressed) { + s.key = wordRight + } + } + case vk_up: + s.key = up + case vk_down: + s.key = down + case vk_insert: + s.key = insert + case vk_delete: + s.key = del + case vk_f1: + s.key = f1 + case vk_f2: + s.key = f2 + case vk_f3: + s.key = f3 + case vk_f4: + s.key = f4 + case vk_f5: + s.key = f5 + case vk_f6: + s.key = f6 + case vk_f7: + s.key = f7 + case vk_f8: + s.key = f8 + case vk_f9: + s.key = f9 + case vk_f10: + s.key = f10 + case vk_f11: + s.key = f11 + case vk_f12: + s.key = f12 + default: + // Eat modifier keys + // TODO: return Action(Unknown) if the key isn't a + // modifier. + continue + } + } + + if ke.RepeatCount > 1 { + s.repeat = ke.RepeatCount - 1 + } + return s.key, nil + } +} + +// Close returns the terminal to its previous mode +func (s *State) Close() error { + s.origMode.ApplyMode() + return nil +} + +func (s *State) startPrompt() { + if m, err := TerminalMode(); err == nil { + s.defaultMode = m.(inputMode) + mode := s.defaultMode + mode &^= enableProcessedInput + mode.ApplyMode() + } +} + +func (s *State) restartPrompt() { +} + +func (s *State) stopPrompt() { + s.defaultMode.ApplyMode() +} + +// TerminalSupported returns true because line editing is always +// supported on Windows. +func TerminalSupported() bool { + return true +} + +func (mode inputMode) ApplyMode() error { + hIn, _, err := procGetStdHandle.Call(uintptr(std_input_handle)) + if hIn == invalid_handle_value || hIn == 0 { + return err + } + ok, _, err := procSetConsoleMode.Call(hIn, uintptr(mode)) + if ok != 0 { + err = nil + } + return err +} + +// TerminalMode returns the current terminal input mode as an InputModeSetter. +// +// This function is provided for convenience, and should +// not be necessary for most users of liner. +func TerminalMode() (ModeApplier, error) { + var mode inputMode + hIn, _, err := procGetStdHandle.Call(uintptr(std_input_handle)) + if hIn == invalid_handle_value || hIn == 0 { + return nil, err + } + ok, _, err := procGetConsoleMode.Call(hIn, uintptr(unsafe.Pointer(&mode))) + if ok != 0 { + err = nil + } + return mode, err +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/line.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/line.go new file mode 100644 index 0000000..d61f069 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/line.go @@ -0,0 +1,1129 @@ +// +build windows linux darwin openbsd freebsd netbsd + +package liner + +import ( + "bufio" + "container/ring" + "errors" + "fmt" + "io" + "os" + "strings" + "unicode" + "unicode/utf8" +) + +type action int + +const ( + left action = iota + right + up + down + home + end + insert + del + pageUp + pageDown + f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + altB + altF + altY + shiftTab + wordLeft + wordRight + winch + unknown +) + +const ( + ctrlA = 1 + ctrlB = 2 + ctrlC = 3 + ctrlD = 4 + ctrlE = 5 + ctrlF = 6 + ctrlG = 7 + ctrlH = 8 + tab = 9 + lf = 10 + ctrlK = 11 + ctrlL = 12 + cr = 13 + ctrlN = 14 + ctrlO = 15 + ctrlP = 16 + ctrlQ = 17 + ctrlR = 18 + ctrlS = 19 + ctrlT = 20 + ctrlU = 21 + ctrlV = 22 + ctrlW = 23 + ctrlX = 24 + ctrlY = 25 + ctrlZ = 26 + esc = 27 + bs = 127 +) + +const ( + beep = "\a" +) + +type tabDirection int + +const ( + tabForward tabDirection = iota + tabReverse +) + +func (s *State) refresh(prompt []rune, buf []rune, pos int) error { + if s.columns == 0 { + return ErrInternal + } + + s.needRefresh = false + if s.multiLineMode { + return s.refreshMultiLine(prompt, buf, pos) + } + return s.refreshSingleLine(prompt, buf, pos) +} + +func (s *State) refreshSingleLine(prompt []rune, buf []rune, pos int) error { + s.cursorPos(0) + _, err := fmt.Print(string(prompt)) + if err != nil { + return err + } + + pLen := countGlyphs(prompt) + bLen := countGlyphs(buf) + pos = countGlyphs(buf[:pos]) + if pLen+bLen < s.columns { + _, err = fmt.Print(string(buf)) + s.eraseLine() + s.cursorPos(pLen + pos) + } else { + // Find space available + space := s.columns - pLen + space-- // space for cursor + start := pos - space/2 + end := start + space + if end > bLen { + end = bLen + start = end - space + } + if start < 0 { + start = 0 + end = space + } + pos -= start + + // Leave space for markers + if start > 0 { + start++ + } + if end < bLen { + end-- + } + startRune := len(getPrefixGlyphs(buf, start)) + line := getPrefixGlyphs(buf[startRune:], end-start) + + // Output + if start > 0 { + fmt.Print("{") + } + fmt.Print(string(line)) + if end < bLen { + fmt.Print("}") + } + + // Set cursor position + s.eraseLine() + s.cursorPos(pLen + pos) + } + return err +} + +func (s *State) refreshMultiLine(prompt []rune, buf []rune, pos int) error { + promptColumns := countMultiLineGlyphs(prompt, s.columns, 0) + totalColumns := countMultiLineGlyphs(buf, s.columns, promptColumns) + totalRows := (totalColumns + s.columns - 1) / s.columns + maxRows := s.maxRows + if totalRows > s.maxRows { + s.maxRows = totalRows + } + cursorRows := s.cursorRows + if cursorRows == 0 { + cursorRows = 1 + } + + /* First step: clear all the lines used before. To do so start by + * going to the last row. */ + if maxRows-cursorRows > 0 { + s.moveDown(maxRows - cursorRows) + } + + /* Now for every row clear it, go up. */ + for i := 0; i < maxRows-1; i++ { + s.cursorPos(0) + s.eraseLine() + s.moveUp(1) + } + + /* Clean the top line. */ + s.cursorPos(0) + s.eraseLine() + + /* Write the prompt and the current buffer content */ + if _, err := fmt.Print(string(prompt)); err != nil { + return err + } + if _, err := fmt.Print(string(buf)); err != nil { + return err + } + + /* If we are at the very end of the screen with our prompt, we need to + * emit a newline and move the prompt to the first column. */ + cursorColumns := countMultiLineGlyphs(buf[:pos], s.columns, promptColumns) + if cursorColumns == totalColumns && totalColumns%s.columns == 0 { + s.emitNewLine() + s.cursorPos(0) + totalRows++ + if totalRows > s.maxRows { + s.maxRows = totalRows + } + } + + /* Move cursor to right position. */ + cursorRows = (cursorColumns + s.columns) / s.columns + if s.cursorRows > 0 && totalRows-cursorRows > 0 { + s.moveUp(totalRows - cursorRows) + } + /* Set column. */ + s.cursorPos(cursorColumns % s.columns) + + s.cursorRows = cursorRows + return nil +} + +func (s *State) resetMultiLine(prompt []rune, buf []rune, pos int) { + columns := countMultiLineGlyphs(prompt, s.columns, 0) + columns = countMultiLineGlyphs(buf[:pos], s.columns, columns) + columns += 2 // ^C + cursorRows := (columns + s.columns) / s.columns + if s.maxRows-cursorRows > 0 { + for i := 0; i < s.maxRows-cursorRows; i++ { + fmt.Println() // always moves the cursor down or scrolls the window up as needed + } + } + s.maxRows = 1 + s.cursorRows = 0 +} + +func longestCommonPrefix(strs []string) string { + if len(strs) == 0 { + return "" + } + longest := strs[0] + + for _, str := range strs[1:] { + for !strings.HasPrefix(str, longest) { + longest = longest[:len(longest)-1] + } + } + // Remove trailing partial runes + longest = strings.TrimRight(longest, "\uFFFD") + return longest +} + +func (s *State) circularTabs(items []string) func(tabDirection) (string, error) { + item := -1 + return func(direction tabDirection) (string, error) { + if direction == tabForward { + if item < len(items)-1 { + item++ + } else { + item = 0 + } + } else if direction == tabReverse { + if item > 0 { + item-- + } else { + item = len(items) - 1 + } + } + return items[item], nil + } +} + +func calculateColumns(screenWidth int, items []string) (numColumns, numRows, maxWidth int) { + for _, item := range items { + if len(item) >= screenWidth { + return 1, len(items), screenWidth - 1 + } + if len(item) >= maxWidth { + maxWidth = len(item) + 1 + } + } + + numColumns = screenWidth / maxWidth + numRows = len(items) / numColumns + if len(items)%numColumns > 0 { + numRows++ + } + + if len(items) <= numColumns { + maxWidth = 0 + } + + return +} + +func (s *State) printedTabs(items []string) func(tabDirection) (string, error) { + numTabs := 1 + prefix := longestCommonPrefix(items) + return func(direction tabDirection) (string, error) { + if len(items) == 1 { + return items[0], nil + } + + if numTabs == 2 { + if len(items) > 100 { + fmt.Printf("\nDisplay all %d possibilities? (y or n) ", len(items)) + prompt: + for { + next, err := s.readNext() + if err != nil { + return prefix, err + } + + if key, ok := next.(rune); ok { + switch key { + case 'n', 'N': + return prefix, nil + case 'y', 'Y': + break prompt + case ctrlC, ctrlD, cr, lf: + s.restartPrompt() + } + } + } + } + fmt.Println("") + + numColumns, numRows, maxWidth := calculateColumns(s.columns, items) + + for i := 0; i < numRows; i++ { + for j := 0; j < numColumns*numRows; j += numRows { + if i+j < len(items) { + if maxWidth > 0 { + fmt.Printf("%-*.[1]*s", maxWidth, items[i+j]) + } else { + fmt.Printf("%v ", items[i+j]) + } + } + } + fmt.Println("") + } + } else { + numTabs++ + } + return prefix, nil + } +} + +func (s *State) tabComplete(p []rune, line []rune, pos int) ([]rune, int, interface{}, error) { + if s.completer == nil { + return line, pos, rune(esc), nil + } + head, list, tail := s.completer(string(line), pos) + if len(list) <= 0 { + return line, pos, rune(esc), nil + } + hl := utf8.RuneCountInString(head) + if len(list) == 1 { + err := s.refresh(p, []rune(head+list[0]+tail), hl+utf8.RuneCountInString(list[0])) + return []rune(head + list[0] + tail), hl + utf8.RuneCountInString(list[0]), rune(esc), err + } + + direction := tabForward + tabPrinter := s.circularTabs(list) + if s.tabStyle == TabPrints { + tabPrinter = s.printedTabs(list) + } + + for { + pick, err := tabPrinter(direction) + if err != nil { + return line, pos, rune(esc), err + } + err = s.refresh(p, []rune(head+pick+tail), hl+utf8.RuneCountInString(pick)) + if err != nil { + return line, pos, rune(esc), err + } + + next, err := s.readNext() + if err != nil { + return line, pos, rune(esc), err + } + if key, ok := next.(rune); ok { + if key == tab { + direction = tabForward + continue + } + if key == esc { + return line, pos, rune(esc), nil + } + } + if a, ok := next.(action); ok && a == shiftTab { + direction = tabReverse + continue + } + return []rune(head + pick + tail), hl + utf8.RuneCountInString(pick), next, nil + } +} + +// reverse intelligent search, implements a bash-like history search. +func (s *State) reverseISearch(origLine []rune, origPos int) ([]rune, int, interface{}, error) { + p := "(reverse-i-search)`': " + err := s.refresh([]rune(p), origLine, origPos) + if err != nil { + return origLine, origPos, rune(esc), err + } + + line := []rune{} + pos := 0 + foundLine := string(origLine) + foundPos := origPos + + getLine := func() ([]rune, []rune, int) { + search := string(line) + prompt := "(reverse-i-search)`%s': " + return []rune(fmt.Sprintf(prompt, search)), []rune(foundLine), foundPos + } + + history, positions := s.getHistoryByPattern(string(line)) + historyPos := len(history) - 1 + + for { + next, err := s.readNext() + if err != nil { + return []rune(foundLine), foundPos, rune(esc), err + } + + switch v := next.(type) { + case rune: + switch v { + case ctrlR: // Search backwards + if historyPos > 0 && historyPos < len(history) { + historyPos-- + foundLine = history[historyPos] + foundPos = positions[historyPos] + } else { + fmt.Print(beep) + } + case ctrlS: // Search forward + if historyPos < len(history)-1 && historyPos >= 0 { + historyPos++ + foundLine = history[historyPos] + foundPos = positions[historyPos] + } else { + fmt.Print(beep) + } + case ctrlH, bs: // Backspace + if pos <= 0 { + fmt.Print(beep) + } else { + n := len(getSuffixGlyphs(line[:pos], 1)) + line = append(line[:pos-n], line[pos:]...) + pos -= n + + // For each char deleted, display the last matching line of history + history, positions := s.getHistoryByPattern(string(line)) + historyPos = len(history) - 1 + if len(history) > 0 { + foundLine = history[historyPos] + foundPos = positions[historyPos] + } else { + foundLine = "" + foundPos = 0 + } + } + case ctrlG: // Cancel + return origLine, origPos, rune(esc), err + + case tab, cr, lf, ctrlA, ctrlB, ctrlD, ctrlE, ctrlF, ctrlK, + ctrlL, ctrlN, ctrlO, ctrlP, ctrlQ, ctrlT, ctrlU, ctrlV, ctrlW, ctrlX, ctrlY, ctrlZ: + fallthrough + case 0, ctrlC, esc, 28, 29, 30, 31: + return []rune(foundLine), foundPos, next, err + default: + line = append(line[:pos], append([]rune{v}, line[pos:]...)...) + pos++ + + // For each keystroke typed, display the last matching line of history + history, positions = s.getHistoryByPattern(string(line)) + historyPos = len(history) - 1 + if len(history) > 0 { + foundLine = history[historyPos] + foundPos = positions[historyPos] + } else { + foundLine = "" + foundPos = 0 + } + } + case action: + return []rune(foundLine), foundPos, next, err + } + err = s.refresh(getLine()) + if err != nil { + return []rune(foundLine), foundPos, rune(esc), err + } + } +} + +// addToKillRing adds some text to the kill ring. If mode is 0 it adds it to a +// new node in the end of the kill ring, and move the current pointer to the new +// node. If mode is 1 or 2 it appends or prepends the text to the current entry +// of the killRing. +func (s *State) addToKillRing(text []rune, mode int) { + // Don't use the same underlying array as text + killLine := make([]rune, len(text)) + copy(killLine, text) + + // Point killRing to a newNode, procedure depends on the killring state and + // append mode. + if mode == 0 { // Add new node to killRing + if s.killRing == nil { // if killring is empty, create a new one + s.killRing = ring.New(1) + } else if s.killRing.Len() >= KillRingMax { // if killring is "full" + s.killRing = s.killRing.Next() + } else { // Normal case + s.killRing.Link(ring.New(1)) + s.killRing = s.killRing.Next() + } + } else { + if s.killRing == nil { // if killring is empty, create a new one + s.killRing = ring.New(1) + s.killRing.Value = []rune{} + } + if mode == 1 { // Append to last entry + killLine = append(s.killRing.Value.([]rune), killLine...) + } else if mode == 2 { // Prepend to last entry + killLine = append(killLine, s.killRing.Value.([]rune)...) + } + } + + // Save text in the current killring node + s.killRing.Value = killLine +} + +func (s *State) yank(p []rune, text []rune, pos int) ([]rune, int, interface{}, error) { + if s.killRing == nil { + return text, pos, rune(esc), nil + } + + lineStart := text[:pos] + lineEnd := text[pos:] + var line []rune + + for { + value := s.killRing.Value.([]rune) + line = make([]rune, 0) + line = append(line, lineStart...) + line = append(line, value...) + line = append(line, lineEnd...) + + pos = len(lineStart) + len(value) + err := s.refresh(p, line, pos) + if err != nil { + return line, pos, 0, err + } + + next, err := s.readNext() + if err != nil { + return line, pos, next, err + } + + switch v := next.(type) { + case rune: + return line, pos, next, nil + case action: + switch v { + case altY: + s.killRing = s.killRing.Prev() + default: + return line, pos, next, nil + } + } + } +} + +// Prompt displays p and returns a line of user input, not including a trailing +// newline character. An io.EOF error is returned if the user signals end-of-file +// by pressing Ctrl-D. Prompt allows line editing if the terminal supports it. +func (s *State) Prompt(prompt string) (string, error) { + return s.PromptWithSuggestion(prompt, "", 0) +} + +// PromptWithSuggestion displays prompt and an editable text with cursor at +// given position. The cursor will be set to the end of the line if given position +// is negative or greater than length of text. Returns a line of user input, not +// including a trailing newline character. An io.EOF error is returned if the user +// signals end-of-file by pressing Ctrl-D. +func (s *State) PromptWithSuggestion(prompt string, text string, pos int) (string, error) { + for _, r := range prompt { + if unicode.Is(unicode.C, r) { + return "", ErrInvalidPrompt + } + } + if s.inputRedirected || !s.terminalSupported { + return s.promptUnsupported(prompt) + } + p := []rune(prompt) + const minWorkingSpace = 10 + if s.columns < countGlyphs(p)+minWorkingSpace { + return s.tooNarrow(prompt) + } + if s.outputRedirected { + return "", ErrNotTerminalOutput + } + + s.historyMutex.RLock() + defer s.historyMutex.RUnlock() + + fmt.Print(prompt) + var line = []rune(text) + historyEnd := "" + var historyPrefix []string + historyPos := 0 + historyStale := true + historyAction := false // used to mark history related actions + killAction := 0 // used to mark kill related actions + + defer s.stopPrompt() + + if pos < 0 || len(text) < pos { + pos = len(text) + } + if len(line) > 0 { + err := s.refresh(p, line, pos) + if err != nil { + return "", err + } + } + +restart: + s.startPrompt() + s.getColumns() + +mainLoop: + for { + next, err := s.readNext() + haveNext: + if err != nil { + if s.shouldRestart != nil && s.shouldRestart(err) { + goto restart + } + return "", err + } + + historyAction = false + switch v := next.(type) { + case rune: + switch v { + case cr, lf: + if s.needRefresh { + err := s.refresh(p, line, pos) + if err != nil { + return "", err + } + } + if s.multiLineMode { + s.resetMultiLine(p, line, pos) + } + fmt.Println() + break mainLoop + case ctrlA: // Start of line + pos = 0 + s.needRefresh = true + case ctrlE: // End of line + pos = len(line) + s.needRefresh = true + case ctrlB: // left + if pos > 0 { + pos -= len(getSuffixGlyphs(line[:pos], 1)) + s.needRefresh = true + } else { + fmt.Print(beep) + } + case ctrlF: // right + if pos < len(line) { + pos += len(getPrefixGlyphs(line[pos:], 1)) + s.needRefresh = true + } else { + fmt.Print(beep) + } + case ctrlD: // del + if pos == 0 && len(line) == 0 { + // exit + return "", io.EOF + } + + // ctrlD is a potential EOF, so the rune reader shuts down. + // Therefore, if it isn't actually an EOF, we must re-startPrompt. + s.restartPrompt() + + if pos >= len(line) { + fmt.Print(beep) + } else { + n := len(getPrefixGlyphs(line[pos:], 1)) + line = append(line[:pos], line[pos+n:]...) + s.needRefresh = true + } + case ctrlK: // delete remainder of line + if pos >= len(line) { + fmt.Print(beep) + } else { + if killAction > 0 { + s.addToKillRing(line[pos:], 1) // Add in apend mode + } else { + s.addToKillRing(line[pos:], 0) // Add in normal mode + } + + killAction = 2 // Mark that there was a kill action + line = line[:pos] + s.needRefresh = true + } + case ctrlP: // up + historyAction = true + if historyStale { + historyPrefix = s.getHistoryByPrefix(string(line)) + historyPos = len(historyPrefix) + historyStale = false + } + if historyPos > 0 { + if historyPos == len(historyPrefix) { + historyEnd = string(line) + } + historyPos-- + line = []rune(historyPrefix[historyPos]) + pos = len(line) + s.needRefresh = true + } else { + fmt.Print(beep) + } + case ctrlN: // down + historyAction = true + if historyStale { + historyPrefix = s.getHistoryByPrefix(string(line)) + historyPos = len(historyPrefix) + historyStale = false + } + if historyPos < len(historyPrefix) { + historyPos++ + if historyPos == len(historyPrefix) { + line = []rune(historyEnd) + } else { + line = []rune(historyPrefix[historyPos]) + } + pos = len(line) + s.needRefresh = true + } else { + fmt.Print(beep) + } + case ctrlT: // transpose prev glyph with glyph under cursor + if len(line) < 2 || pos < 1 { + fmt.Print(beep) + } else { + if pos == len(line) { + pos -= len(getSuffixGlyphs(line, 1)) + } + prev := getSuffixGlyphs(line[:pos], 1) + next := getPrefixGlyphs(line[pos:], 1) + scratch := make([]rune, len(prev)) + copy(scratch, prev) + copy(line[pos-len(prev):], next) + copy(line[pos-len(prev)+len(next):], scratch) + pos += len(next) + s.needRefresh = true + } + case ctrlL: // clear screen + s.eraseScreen() + s.needRefresh = true + case ctrlC: // reset + fmt.Println("^C") + if s.multiLineMode { + s.resetMultiLine(p, line, pos) + } + if s.ctrlCAborts { + return "", ErrPromptAborted + } + line = line[:0] + pos = 0 + fmt.Print(prompt) + s.restartPrompt() + case ctrlH, bs: // Backspace + if pos <= 0 { + fmt.Print(beep) + } else { + n := len(getSuffixGlyphs(line[:pos], 1)) + line = append(line[:pos-n], line[pos:]...) + pos -= n + s.needRefresh = true + } + case ctrlU: // Erase line before cursor + if killAction > 0 { + s.addToKillRing(line[:pos], 2) // Add in prepend mode + } else { + s.addToKillRing(line[:pos], 0) // Add in normal mode + } + + killAction = 2 // Mark that there was some killing + line = line[pos:] + pos = 0 + s.needRefresh = true + case ctrlW: // Erase word + if pos == 0 { + fmt.Print(beep) + break + } + // Remove whitespace to the left + var buf []rune // Store the deleted chars in a buffer + for { + if pos == 0 || !unicode.IsSpace(line[pos-1]) { + break + } + buf = append(buf, line[pos-1]) + line = append(line[:pos-1], line[pos:]...) + pos-- + } + // Remove non-whitespace to the left + for { + if pos == 0 || unicode.IsSpace(line[pos-1]) { + break + } + buf = append(buf, line[pos-1]) + line = append(line[:pos-1], line[pos:]...) + pos-- + } + // Invert the buffer and save the result on the killRing + var newBuf []rune + for i := len(buf) - 1; i >= 0; i-- { + newBuf = append(newBuf, buf[i]) + } + if killAction > 0 { + s.addToKillRing(newBuf, 2) // Add in prepend mode + } else { + s.addToKillRing(newBuf, 0) // Add in normal mode + } + killAction = 2 // Mark that there was some killing + + s.needRefresh = true + case ctrlY: // Paste from Yank buffer + line, pos, next, err = s.yank(p, line, pos) + goto haveNext + case ctrlR: // Reverse Search + line, pos, next, err = s.reverseISearch(line, pos) + s.needRefresh = true + goto haveNext + case tab: // Tab completion + line, pos, next, err = s.tabComplete(p, line, pos) + goto haveNext + // Catch keys that do nothing, but you don't want them to beep + case esc: + // DO NOTHING + // Unused keys + case ctrlG, ctrlO, ctrlQ, ctrlS, ctrlV, ctrlX, ctrlZ: + fallthrough + // Catch unhandled control codes (anything <= 31) + case 0, 28, 29, 30, 31: + fmt.Print(beep) + default: + if pos == len(line) && !s.multiLineMode && + len(p)+len(line) < s.columns*4 && // Avoid countGlyphs on large lines + countGlyphs(p)+countGlyphs(line) < s.columns-1 { + line = append(line, v) + fmt.Printf("%c", v) + pos++ + } else { + line = append(line[:pos], append([]rune{v}, line[pos:]...)...) + pos++ + s.needRefresh = true + } + } + case action: + switch v { + case del: + if pos >= len(line) { + fmt.Print(beep) + } else { + n := len(getPrefixGlyphs(line[pos:], 1)) + line = append(line[:pos], line[pos+n:]...) + } + case left: + if pos > 0 { + pos -= len(getSuffixGlyphs(line[:pos], 1)) + } else { + fmt.Print(beep) + } + case wordLeft, altB: + if pos > 0 { + var spaceHere, spaceLeft, leftKnown bool + for { + pos-- + if pos == 0 { + break + } + if leftKnown { + spaceHere = spaceLeft + } else { + spaceHere = unicode.IsSpace(line[pos]) + } + spaceLeft, leftKnown = unicode.IsSpace(line[pos-1]), true + if !spaceHere && spaceLeft { + break + } + } + } else { + fmt.Print(beep) + } + case right: + if pos < len(line) { + pos += len(getPrefixGlyphs(line[pos:], 1)) + } else { + fmt.Print(beep) + } + case wordRight, altF: + if pos < len(line) { + var spaceHere, spaceLeft, hereKnown bool + for { + pos++ + if pos == len(line) { + break + } + if hereKnown { + spaceLeft = spaceHere + } else { + spaceLeft = unicode.IsSpace(line[pos-1]) + } + spaceHere, hereKnown = unicode.IsSpace(line[pos]), true + if spaceHere && !spaceLeft { + break + } + } + } else { + fmt.Print(beep) + } + case up: + historyAction = true + if historyStale { + historyPrefix = s.getHistoryByPrefix(string(line)) + historyPos = len(historyPrefix) + historyStale = false + } + if historyPos > 0 { + if historyPos == len(historyPrefix) { + historyEnd = string(line) + } + historyPos-- + line = []rune(historyPrefix[historyPos]) + pos = len(line) + } else { + fmt.Print(beep) + } + case down: + historyAction = true + if historyStale { + historyPrefix = s.getHistoryByPrefix(string(line)) + historyPos = len(historyPrefix) + historyStale = false + } + if historyPos < len(historyPrefix) { + historyPos++ + if historyPos == len(historyPrefix) { + line = []rune(historyEnd) + } else { + line = []rune(historyPrefix[historyPos]) + } + pos = len(line) + } else { + fmt.Print(beep) + } + case home: // Start of line + pos = 0 + case end: // End of line + pos = len(line) + case winch: // Window change + if s.multiLineMode { + if s.maxRows-s.cursorRows > 0 { + s.moveDown(s.maxRows - s.cursorRows) + } + for i := 0; i < s.maxRows-1; i++ { + s.cursorPos(0) + s.eraseLine() + s.moveUp(1) + } + s.maxRows = 1 + s.cursorRows = 1 + } + } + s.needRefresh = true + } + if s.needRefresh && !s.inputWaiting() { + err := s.refresh(p, line, pos) + if err != nil { + return "", err + } + } + if !historyAction { + historyStale = true + } + if killAction > 0 { + killAction-- + } + } + return string(line), nil +} + +// PasswordPrompt displays p, and then waits for user input. The input typed by +// the user is not displayed in the terminal. +func (s *State) PasswordPrompt(prompt string) (string, error) { + for _, r := range prompt { + if unicode.Is(unicode.C, r) { + return "", ErrInvalidPrompt + } + } + if !s.terminalSupported || s.columns == 0 { + return "", errors.New("liner: function not supported in this terminal") + } + if s.inputRedirected { + return s.promptUnsupported(prompt) + } + if s.outputRedirected { + return "", ErrNotTerminalOutput + } + + p := []rune(prompt) + const minWorkingSpace = 1 + if s.columns < countGlyphs(p)+minWorkingSpace { + return s.tooNarrow(prompt) + } + + defer s.stopPrompt() + +restart: + s.startPrompt() + s.getColumns() + + fmt.Print(prompt) + var line []rune + pos := 0 + +mainLoop: + for { + next, err := s.readNext() + if err != nil { + if s.shouldRestart != nil && s.shouldRestart(err) { + goto restart + } + return "", err + } + + switch v := next.(type) { + case rune: + switch v { + case cr, lf: + if s.needRefresh { + err := s.refresh(p, line, pos) + if err != nil { + return "", err + } + } + if s.multiLineMode { + s.resetMultiLine(p, line, pos) + } + fmt.Println() + break mainLoop + case ctrlD: // del + if pos == 0 && len(line) == 0 { + // exit + return "", io.EOF + } + + // ctrlD is a potential EOF, so the rune reader shuts down. + // Therefore, if it isn't actually an EOF, we must re-startPrompt. + s.restartPrompt() + case ctrlL: // clear screen + s.eraseScreen() + err := s.refresh(p, []rune{}, 0) + if err != nil { + return "", err + } + case ctrlH, bs: // Backspace + if pos <= 0 { + fmt.Print(beep) + } else { + n := len(getSuffixGlyphs(line[:pos], 1)) + line = append(line[:pos-n], line[pos:]...) + pos -= n + } + case ctrlC: + fmt.Println("^C") + if s.multiLineMode { + s.resetMultiLine(p, line, pos) + } + if s.ctrlCAborts { + return "", ErrPromptAborted + } + line = line[:0] + pos = 0 + fmt.Print(prompt) + s.restartPrompt() + // Unused keys + case esc, tab, ctrlA, ctrlB, ctrlE, ctrlF, ctrlG, ctrlK, ctrlN, ctrlO, ctrlP, ctrlQ, ctrlR, ctrlS, + ctrlT, ctrlU, ctrlV, ctrlW, ctrlX, ctrlY, ctrlZ: + fallthrough + // Catch unhandled control codes (anything <= 31) + case 0, 28, 29, 30, 31: + fmt.Print(beep) + default: + line = append(line[:pos], append([]rune{v}, line[pos:]...)...) + pos++ + } + } + } + return string(line), nil +} + +func (s *State) tooNarrow(prompt string) (string, error) { + // Docker and OpenWRT and etc sometimes return 0 column width + // Reset mode temporarily. Restore baked mode in case the terminal + // is wide enough for the next Prompt attempt. + m, merr := TerminalMode() + s.origMode.ApplyMode() + if merr == nil { + defer m.ApplyMode() + } + if s.r == nil { + // Windows does not always set s.r + s.r = bufio.NewReader(os.Stdin) + defer func() { s.r = nil }() + } + return s.promptUnsupported(prompt) +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/output.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/output.go new file mode 100644 index 0000000..6d83d4e --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/output.go @@ -0,0 +1,79 @@ +// +build linux darwin openbsd freebsd netbsd + +package liner + +import ( + "fmt" + "os" + "strings" + "syscall" + "unsafe" +) + +func (s *State) cursorPos(x int) { + if s.useCHA { + // 'G' is "Cursor Character Absolute (CHA)" + fmt.Printf("\x1b[%dG", x+1) + } else { + // 'C' is "Cursor Forward (CUF)" + fmt.Print("\r") + if x > 0 { + fmt.Printf("\x1b[%dC", x) + } + } +} + +func (s *State) eraseLine() { + fmt.Print("\x1b[0K") +} + +func (s *State) eraseScreen() { + fmt.Print("\x1b[H\x1b[2J") +} + +func (s *State) moveUp(lines int) { + fmt.Printf("\x1b[%dA", lines) +} + +func (s *State) moveDown(lines int) { + fmt.Printf("\x1b[%dB", lines) +} + +func (s *State) emitNewLine() { + fmt.Print("\n") +} + +type winSize struct { + row, col uint16 + xpixel, ypixel uint16 +} + +func (s *State) getColumns() bool { + var ws winSize + ok, _, _ := syscall.Syscall(syscall.SYS_IOCTL, uintptr(syscall.Stdout), + syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&ws))) + if int(ok) < 0 { + return false + } + s.columns = int(ws.col) + if cursorColumn && s.columns > 1 { + s.columns-- + } + return true +} + +func (s *State) checkOutput() { + // xterm is known to support CHA + if strings.Contains(strings.ToLower(os.Getenv("TERM")), "xterm") { + s.useCHA = true + return + } + + // The test for functional ANSI CHA is unreliable (eg the Windows + // telnet command does not support reading the cursor position with + // an ANSI DSR request, despite setting TERM=ansi) + + // Assume CHA isn't supported (which should be safe, although it + // does result in occasional visible cursor jitter) + s.useCHA = false +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/output_windows.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/output_windows.go new file mode 100644 index 0000000..63c9c5d --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/output_windows.go @@ -0,0 +1,76 @@ +package liner + +import ( + "unsafe" +) + +type coord struct { + x, y int16 +} +type smallRect struct { + left, top, right, bottom int16 +} + +type consoleScreenBufferInfo struct { + dwSize coord + dwCursorPosition coord + wAttributes int16 + srWindow smallRect + dwMaximumWindowSize coord +} + +func (s *State) cursorPos(x int) { + var sbi consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(uintptr(s.hOut), uintptr(unsafe.Pointer(&sbi))) + procSetConsoleCursorPosition.Call(uintptr(s.hOut), + uintptr(int(x)&0xFFFF|int(sbi.dwCursorPosition.y)<<16)) +} + +func (s *State) eraseLine() { + var sbi consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(uintptr(s.hOut), uintptr(unsafe.Pointer(&sbi))) + var numWritten uint32 + procFillConsoleOutputCharacter.Call(uintptr(s.hOut), uintptr(' '), + uintptr(sbi.dwSize.x-sbi.dwCursorPosition.x), + uintptr(int(sbi.dwCursorPosition.x)&0xFFFF|int(sbi.dwCursorPosition.y)<<16), + uintptr(unsafe.Pointer(&numWritten))) +} + +func (s *State) eraseScreen() { + var sbi consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(uintptr(s.hOut), uintptr(unsafe.Pointer(&sbi))) + var numWritten uint32 + procFillConsoleOutputCharacter.Call(uintptr(s.hOut), uintptr(' '), + uintptr(sbi.dwSize.x)*uintptr(sbi.dwSize.y), + 0, + uintptr(unsafe.Pointer(&numWritten))) + procSetConsoleCursorPosition.Call(uintptr(s.hOut), 0) +} + +func (s *State) moveUp(lines int) { + var sbi consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(uintptr(s.hOut), uintptr(unsafe.Pointer(&sbi))) + procSetConsoleCursorPosition.Call(uintptr(s.hOut), + uintptr(int(sbi.dwCursorPosition.x)&0xFFFF|(int(sbi.dwCursorPosition.y)-lines)<<16)) +} + +func (s *State) moveDown(lines int) { + var sbi consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(uintptr(s.hOut), uintptr(unsafe.Pointer(&sbi))) + procSetConsoleCursorPosition.Call(uintptr(s.hOut), + uintptr(int(sbi.dwCursorPosition.x)&0xFFFF|(int(sbi.dwCursorPosition.y)+lines)<<16)) +} + +func (s *State) emitNewLine() { + // windows doesn't need to omit a new line +} + +func (s *State) getColumns() { + var sbi consoleScreenBufferInfo + procGetConsoleScreenBufferInfo.Call(uintptr(s.hOut), uintptr(unsafe.Pointer(&sbi))) + s.columns = int(sbi.dwSize.x) + if s.columns > 1 { + // Windows 10 needs a spare column for the cursor + s.columns-- + } +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/unixmode.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/unixmode.go new file mode 100644 index 0000000..9838923 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/unixmode.go @@ -0,0 +1,37 @@ +// +build linux darwin freebsd openbsd netbsd + +package liner + +import ( + "syscall" + "unsafe" +) + +func (mode *termios) ApplyMode() error { + _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(syscall.Stdin), setTermios, uintptr(unsafe.Pointer(mode))) + + if errno != 0 { + return errno + } + return nil +} + +// TerminalMode returns the current terminal input mode as an InputModeSetter. +// +// This function is provided for convenience, and should +// not be necessary for most users of liner. +func TerminalMode() (ModeApplier, error) { + mode, errno := getMode(syscall.Stdin) + + if errno != 0 { + return nil, errno + } + return mode, nil +} + +func getMode(handle int) (*termios, syscall.Errno) { + var mode termios + _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(handle), getTermios, uintptr(unsafe.Pointer(&mode))) + + return &mode, errno +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/width.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/width.go new file mode 100644 index 0000000..42e8999 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/peterh/liner/width.go @@ -0,0 +1,99 @@ +package liner + +import "unicode" + +// These character classes are mostly zero width (when combined). +// A few might not be, depending on the user's font. Fixing this +// is non-trivial, given that some terminals don't support +// ANSI DSR/CPR +var zeroWidth = []*unicode.RangeTable{ + unicode.Mn, + unicode.Me, + unicode.Cc, + unicode.Cf, +} + +var doubleWidth = []*unicode.RangeTable{ + unicode.Han, + unicode.Hangul, + unicode.Hiragana, + unicode.Katakana, +} + +// countGlyphs considers zero-width characters to be zero glyphs wide, +// and members of Chinese, Japanese, and Korean scripts to be 2 glyphs wide. +func countGlyphs(s []rune) int { + n := 0 + for _, r := range s { + // speed up the common case + if r < 127 { + n++ + continue + } + + switch { + case unicode.IsOneOf(zeroWidth, r): + case unicode.IsOneOf(doubleWidth, r): + n += 2 + default: + n++ + } + } + return n +} + +func countMultiLineGlyphs(s []rune, columns int, start int) int { + n := start + for _, r := range s { + if r < 127 { + n++ + continue + } + switch { + case unicode.IsOneOf(zeroWidth, r): + case unicode.IsOneOf(doubleWidth, r): + n += 2 + // no room for a 2-glyphs-wide char in the ending + // so skip a column and display it at the beginning + if n%columns == 1 { + n++ + } + default: + n++ + } + } + return n +} + +func getPrefixGlyphs(s []rune, num int) []rune { + p := 0 + for n := 0; n < num && p < len(s); p++ { + // speed up the common case + if s[p] < 127 { + n++ + continue + } + if !unicode.IsOneOf(zeroWidth, s[p]) { + n++ + } + } + for p < len(s) && unicode.IsOneOf(zeroWidth, s[p]) { + p++ + } + return s[:p] +} + +func getSuffixGlyphs(s []rune, num int) []rune { + p := len(s) + for n := 0; n < num && p > 0; p-- { + // speed up the common case + if s[p-1] < 127 { + n++ + continue + } + if !unicode.IsOneOf(zeroWidth, s[p-1]) { + n++ + } + } + return s[p:] +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/.gitignore b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/.gitignore new file mode 100644 index 0000000..75623dc --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/.gitignore @@ -0,0 +1,8 @@ +*.out +*.swp +*.8 +*.6 +_obj +_test* +markdown +tags diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/.travis.yml b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/.travis.yml new file mode 100644 index 0000000..2f3351d --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/.travis.yml @@ -0,0 +1,17 @@ +sudo: false +language: go +go: + - "1.9.x" + - "1.10.x" + - tip +matrix: + fast_finish: true + allow_failures: + - go: tip +install: + - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step). +script: + - go get -t -v ./... + - diff -u <(echo -n) <(gofmt -d -s .) + - go tool vet . + - go test -v -race ./... diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/LICENSE.txt b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/LICENSE.txt new file mode 100644 index 0000000..2885af3 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/LICENSE.txt @@ -0,0 +1,29 @@ +Blackfriday is distributed under the Simplified BSD License: + +> Copyright © 2011 Russ Ross +> All rights reserved. +> +> Redistribution and use in source and binary forms, with or without +> modification, are permitted provided that the following conditions +> are met: +> +> 1. Redistributions of source code must retain the above copyright +> notice, this list of conditions and the following disclaimer. +> +> 2. 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. +> +> 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. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/README.md b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/README.md new file mode 100644 index 0000000..3c62e13 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/README.md @@ -0,0 +1,369 @@ +Blackfriday +[![Build Status][BuildSVG]][BuildURL] +[![Godoc][GodocV2SVG]][GodocV2URL] +=========== + +Blackfriday is a [Markdown][1] processor implemented in [Go][2]. It +is paranoid about its input (so you can safely feed it user-supplied +data), it is fast, it supports common extensions (tables, smart +punctuation substitutions, etc.), and it is safe for all utf-8 +(unicode) input. + +HTML output is currently supported, along with Smartypants +extensions. + +It started as a translation from C of [Sundown][3]. + + +Installation +------------ + +Blackfriday is compatible with any modern Go release. With Go and git installed: + + go get -u gopkg.in/russross/blackfriday.v2 + +will download, compile, and install the package into your `$GOPATH` directory +hierarchy. + + +Versions +-------- + +Currently maintained and recommended version of Blackfriday is `v2`. It's being +developed on its own branch: https://github.com/russross/blackfriday/tree/v2 and the +documentation is available at +https://godoc.org/gopkg.in/russross/blackfriday.v2. + +It is `go get`-able via [gopkg.in][6] at `gopkg.in/russross/blackfriday.v2`, +but we highly recommend using package management tool like [dep][7] or +[Glide][8] and make use of semantic versioning. With package management you +should import `github.com/russross/blackfriday` and specify that you're using +version 2.0.0. + +Version 2 offers a number of improvements over v1: + +* Cleaned up API +* A separate call to [`Parse`][4], which produces an abstract syntax tree for + the document +* Latest bug fixes +* Flexibility to easily add your own rendering extensions + +Potential drawbacks: + +* Our benchmarks show v2 to be slightly slower than v1. Currently in the + ballpark of around 15%. +* API breakage. If you can't afford modifying your code to adhere to the new API + and don't care too much about the new features, v2 is probably not for you. +* Several bug fixes are trailing behind and still need to be forward-ported to + v2. See issue [#348](https://github.com/russross/blackfriday/issues/348) for + tracking. + +If you are still interested in the legacy `v1`, you can import it from +`github.com/russross/blackfriday`. Documentation for the legacy v1 can be found +here: https://godoc.org/github.com/russross/blackfriday + +### Known issue with `dep` + +There is a known problem with using Blackfriday v1 _transitively_ and `dep`. +Currently `dep` prioritizes semver versions over anything else, and picks the +latest one, plus it does not apply a `[[constraint]]` specifier to transitively +pulled in packages. So if you're using something that uses Blackfriday v1, but +that something does not use `dep` yet, you will get Blackfriday v2 pulled in and +your first dependency will fail to build. + +There are couple of fixes for it, documented here: +https://github.com/golang/dep/blob/master/docs/FAQ.md#how-do-i-constrain-a-transitive-dependencys-version + +Meanwhile, `dep` team is working on a more general solution to the constraints +on transitive dependencies problem: https://github.com/golang/dep/issues/1124. + + +Usage +----- + +### v1 + +For basic usage, it is as simple as getting your input into a byte +slice and calling: + + output := blackfriday.MarkdownBasic(input) + +This renders it with no extensions enabled. To get a more useful +feature set, use this instead: + + output := blackfriday.MarkdownCommon(input) + +### v2 + +For the most sensible markdown processing, it is as simple as getting your input +into a byte slice and calling: + +```go +output := blackfriday.Run(input) +``` + +Your input will be parsed and the output rendered with a set of most popular +extensions enabled. If you want the most basic feature set, corresponding with +the bare Markdown specification, use: + +```go +output := blackfriday.Run(input, blackfriday.WithNoExtensions()) +``` + +### Sanitize untrusted content + +Blackfriday itself does nothing to protect against malicious content. If you are +dealing with user-supplied markdown, we recommend running Blackfriday's output +through HTML sanitizer such as [Bluemonday][5]. + +Here's an example of simple usage of Blackfriday together with Bluemonday: + +```go +import ( + "github.com/microcosm-cc/bluemonday" + "gopkg.in/russross/blackfriday.v2" +) + +// ... +unsafe := blackfriday.Run(input) +html := bluemonday.UGCPolicy().SanitizeBytes(unsafe) +``` + +### Custom options, v1 + +If you want to customize the set of options, first get a renderer +(currently only the HTML output engine), then use it to +call the more general `Markdown` function. For examples, see the +implementations of `MarkdownBasic` and `MarkdownCommon` in +`markdown.go`. + +### Custom options, v2 + +If you want to customize the set of options, use `blackfriday.WithExtensions`, +`blackfriday.WithRenderer` and `blackfriday.WithRefOverride`. + +### `blackfriday-tool` + +You can also check out `blackfriday-tool` for a more complete example +of how to use it. Download and install it using: + + go get github.com/russross/blackfriday-tool + +This is a simple command-line tool that allows you to process a +markdown file using a standalone program. You can also browse the +source directly on github if you are just looking for some example +code: + +* + +Note that if you have not already done so, installing +`blackfriday-tool` will be sufficient to download and install +blackfriday in addition to the tool itself. The tool binary will be +installed in `$GOPATH/bin`. This is a statically-linked binary that +can be copied to wherever you need it without worrying about +dependencies and library versions. + +### Sanitized anchor names + +Blackfriday includes an algorithm for creating sanitized anchor names +corresponding to a given input text. This algorithm is used to create +anchors for headings when `EXTENSION_AUTO_HEADER_IDS` is enabled. The +algorithm has a specification, so that other packages can create +compatible anchor names and links to those anchors. + +The specification is located at https://godoc.org/github.com/russross/blackfriday#hdr-Sanitized_Anchor_Names. + +[`SanitizedAnchorName`](https://godoc.org/github.com/russross/blackfriday#SanitizedAnchorName) exposes this functionality, and can be used to +create compatible links to the anchor names generated by blackfriday. +This algorithm is also implemented in a small standalone package at +[`github.com/shurcooL/sanitized_anchor_name`](https://godoc.org/github.com/shurcooL/sanitized_anchor_name). It can be useful for clients +that want a small package and don't need full functionality of blackfriday. + + +Features +-------- + +All features of Sundown are supported, including: + +* **Compatibility**. The Markdown v1.0.3 test suite passes with + the `--tidy` option. Without `--tidy`, the differences are + mostly in whitespace and entity escaping, where blackfriday is + more consistent and cleaner. + +* **Common extensions**, including table support, fenced code + blocks, autolinks, strikethroughs, non-strict emphasis, etc. + +* **Safety**. Blackfriday is paranoid when parsing, making it safe + to feed untrusted user input without fear of bad things + happening. The test suite stress tests this and there are no + known inputs that make it crash. If you find one, please let me + know and send me the input that does it. + + NOTE: "safety" in this context means *runtime safety only*. In order to + protect yourself against JavaScript injection in untrusted content, see + [this example](https://github.com/russross/blackfriday#sanitize-untrusted-content). + +* **Fast processing**. It is fast enough to render on-demand in + most web applications without having to cache the output. + +* **Thread safety**. You can run multiple parsers in different + goroutines without ill effect. There is no dependence on global + shared state. + +* **Minimal dependencies**. Blackfriday only depends on standard + library packages in Go. The source code is pretty + self-contained, so it is easy to add to any project, including + Google App Engine projects. + +* **Standards compliant**. Output successfully validates using the + W3C validation tool for HTML 4.01 and XHTML 1.0 Transitional. + + +Extensions +---------- + +In addition to the standard markdown syntax, this package +implements the following extensions: + +* **Intra-word emphasis supression**. The `_` character is + commonly used inside words when discussing code, so having + markdown interpret it as an emphasis command is usually the + wrong thing. Blackfriday lets you treat all emphasis markers as + normal characters when they occur inside a word. + +* **Tables**. Tables can be created by drawing them in the input + using a simple syntax: + + ``` + Name | Age + --------|------ + Bob | 27 + Alice | 23 + ``` + +* **Fenced code blocks**. In addition to the normal 4-space + indentation to mark code blocks, you can explicitly mark them + and supply a language (to make syntax highlighting simple). Just + mark it like this: + + ``` go + func getTrue() bool { + return true + } + ``` + + You can use 3 or more backticks to mark the beginning of the + block, and the same number to mark the end of the block. + + To preserve classes of fenced code blocks while using the bluemonday + HTML sanitizer, use the following policy: + + ``` go + p := bluemonday.UGCPolicy() + p.AllowAttrs("class").Matching(regexp.MustCompile("^language-[a-zA-Z0-9]+$")).OnElements("code") + html := p.SanitizeBytes(unsafe) + ``` + +* **Definition lists**. A simple definition list is made of a single-line + term followed by a colon and the definition for that term. + + Cat + : Fluffy animal everyone likes + + Internet + : Vector of transmission for pictures of cats + + Terms must be separated from the previous definition by a blank line. + +* **Footnotes**. A marker in the text that will become a superscript number; + a footnote definition that will be placed in a list of footnotes at the + end of the document. A footnote looks like this: + + This is a footnote.[^1] + + [^1]: the footnote text. + +* **Autolinking**. Blackfriday can find URLs that have not been + explicitly marked as links and turn them into links. + +* **Strikethrough**. Use two tildes (`~~`) to mark text that + should be crossed out. + +* **Hard line breaks**. With this extension enabled (it is off by + default in the `MarkdownBasic` and `MarkdownCommon` convenience + functions), newlines in the input translate into line breaks in + the output. + +* **Smart quotes**. Smartypants-style punctuation substitution is + supported, turning normal double- and single-quote marks into + curly quotes, etc. + +* **LaTeX-style dash parsing** is an additional option, where `--` + is translated into `–`, and `---` is translated into + `—`. This differs from most smartypants processors, which + turn a single hyphen into an ndash and a double hyphen into an + mdash. + +* **Smart fractions**, where anything that looks like a fraction + is translated into suitable HTML (instead of just a few special + cases like most smartypant processors). For example, `4/5` + becomes `45`, which renders as + 45. + + +Other renderers +--------------- + +Blackfriday is structured to allow alternative rendering engines. Here +are a few of note: + +* [github_flavored_markdown](https://godoc.org/github.com/shurcooL/github_flavored_markdown): + provides a GitHub Flavored Markdown renderer with fenced code block + highlighting, clickable heading anchor links. + + It's not customizable, and its goal is to produce HTML output + equivalent to the [GitHub Markdown API endpoint](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode), + except the rendering is performed locally. + +* [markdownfmt](https://github.com/shurcooL/markdownfmt): like gofmt, + but for markdown. + +* [LaTeX output](https://bitbucket.org/ambrevar/blackfriday-latex): + renders output as LaTeX. + +* [bfchroma](https://github.com/Depado/bfchroma/): provides convenience + integration with the [Chroma](https://github.com/alecthomas/chroma) code + highlighting library. bfchroma is only compatible with v2 of Blackfriday and + provides a drop-in renderer ready to use with Blackfriday, as well as + options and means for further customization. + + +TODO +---- + +* More unit testing +* Improve Unicode support. It does not understand all Unicode + rules (about what constitutes a letter, a punctuation symbol, + etc.), so it may fail to detect word boundaries correctly in + some instances. It is safe on all UTF-8 input. + + +License +------- + +[Blackfriday is distributed under the Simplified BSD License](LICENSE.txt) + + + [1]: https://daringfireball.net/projects/markdown/ "Markdown" + [2]: https://golang.org/ "Go Language" + [3]: https://github.com/vmg/sundown "Sundown" + [4]: https://godoc.org/gopkg.in/russross/blackfriday.v2#Parse "Parse func" + [5]: https://github.com/microcosm-cc/bluemonday "Bluemonday" + [6]: https://labix.org/gopkg.in "gopkg.in" + [7]: https://github.com/golang/dep/ "dep" + [8]: https://github.com/Masterminds/glide "Glide" + + [BuildSVG]: https://travis-ci.org/russross/blackfriday.svg?branch=master + [BuildURL]: https://travis-ci.org/russross/blackfriday + [GodocV2SVG]: https://godoc.org/gopkg.in/russross/blackfriday.v2?status.svg + [GodocV2URL]: https://godoc.org/gopkg.in/russross/blackfriday.v2 diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/block.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/block.go new file mode 100644 index 0000000..45c21a6 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/block.go @@ -0,0 +1,1474 @@ +// +// Blackfriday Markdown Processor +// Available at http://github.com/russross/blackfriday +// +// Copyright © 2011 Russ Ross . +// Distributed under the Simplified BSD License. +// See README.md for details. +// + +// +// Functions to parse block-level elements. +// + +package blackfriday + +import ( + "bytes" + "strings" + "unicode" +) + +// Parse block-level data. +// Note: this function and many that it calls assume that +// the input buffer ends with a newline. +func (p *parser) block(out *bytes.Buffer, data []byte) { + if len(data) == 0 || data[len(data)-1] != '\n' { + panic("block input is missing terminating newline") + } + + // this is called recursively: enforce a maximum depth + if p.nesting >= p.maxNesting { + return + } + p.nesting++ + + // parse out one block-level construct at a time + for len(data) > 0 { + // prefixed header: + // + // # Header 1 + // ## Header 2 + // ... + // ###### Header 6 + if p.isPrefixHeader(data) { + data = data[p.prefixHeader(out, data):] + continue + } + + // block of preformatted HTML: + // + //
+ // ... + //
+ if data[0] == '<' { + if i := p.html(out, data, true); i > 0 { + data = data[i:] + continue + } + } + + // title block + // + // % stuff + // % more stuff + // % even more stuff + if p.flags&EXTENSION_TITLEBLOCK != 0 { + if data[0] == '%' { + if i := p.titleBlock(out, data, true); i > 0 { + data = data[i:] + continue + } + } + } + + // blank lines. note: returns the # of bytes to skip + if i := p.isEmpty(data); i > 0 { + data = data[i:] + continue + } + + // indented code block: + // + // func max(a, b int) int { + // if a > b { + // return a + // } + // return b + // } + if p.codePrefix(data) > 0 { + data = data[p.code(out, data):] + continue + } + + // fenced code block: + // + // ``` go info string here + // func fact(n int) int { + // if n <= 1 { + // return n + // } + // return n * fact(n-1) + // } + // ``` + if p.flags&EXTENSION_FENCED_CODE != 0 { + if i := p.fencedCodeBlock(out, data, true); i > 0 { + data = data[i:] + continue + } + } + + // horizontal rule: + // + // ------ + // or + // ****** + // or + // ______ + if p.isHRule(data) { + p.r.HRule(out) + var i int + for i = 0; data[i] != '\n'; i++ { + } + data = data[i:] + continue + } + + // block quote: + // + // > A big quote I found somewhere + // > on the web + if p.quotePrefix(data) > 0 { + data = data[p.quote(out, data):] + continue + } + + // table: + // + // Name | Age | Phone + // ------|-----|--------- + // Bob | 31 | 555-1234 + // Alice | 27 | 555-4321 + if p.flags&EXTENSION_TABLES != 0 { + if i := p.table(out, data); i > 0 { + data = data[i:] + continue + } + } + + // an itemized/unordered list: + // + // * Item 1 + // * Item 2 + // + // also works with + or - + if p.uliPrefix(data) > 0 { + data = data[p.list(out, data, 0):] + continue + } + + // a numbered/ordered list: + // + // 1. Item 1 + // 2. Item 2 + if p.oliPrefix(data) > 0 { + data = data[p.list(out, data, LIST_TYPE_ORDERED):] + continue + } + + // definition lists: + // + // Term 1 + // : Definition a + // : Definition b + // + // Term 2 + // : Definition c + if p.flags&EXTENSION_DEFINITION_LISTS != 0 { + if p.dliPrefix(data) > 0 { + data = data[p.list(out, data, LIST_TYPE_DEFINITION):] + continue + } + } + + // anything else must look like a normal paragraph + // note: this finds underlined headers, too + data = data[p.paragraph(out, data):] + } + + p.nesting-- +} + +func (p *parser) isPrefixHeader(data []byte) bool { + if data[0] != '#' { + return false + } + + if p.flags&EXTENSION_SPACE_HEADERS != 0 { + level := 0 + for level < 6 && data[level] == '#' { + level++ + } + if data[level] != ' ' { + return false + } + } + return true +} + +func (p *parser) prefixHeader(out *bytes.Buffer, data []byte) int { + level := 0 + for level < 6 && data[level] == '#' { + level++ + } + i := skipChar(data, level, ' ') + end := skipUntilChar(data, i, '\n') + skip := end + id := "" + if p.flags&EXTENSION_HEADER_IDS != 0 { + j, k := 0, 0 + // find start/end of header id + for j = i; j < end-1 && (data[j] != '{' || data[j+1] != '#'); j++ { + } + for k = j + 1; k < end && data[k] != '}'; k++ { + } + // extract header id iff found + if j < end && k < end { + id = string(data[j+2 : k]) + end = j + skip = k + 1 + for end > 0 && data[end-1] == ' ' { + end-- + } + } + } + for end > 0 && data[end-1] == '#' { + if isBackslashEscaped(data, end-1) { + break + } + end-- + } + for end > 0 && data[end-1] == ' ' { + end-- + } + if end > i { + if id == "" && p.flags&EXTENSION_AUTO_HEADER_IDS != 0 { + id = SanitizedAnchorName(string(data[i:end])) + } + work := func() bool { + p.inline(out, data[i:end]) + return true + } + p.r.Header(out, work, level, id) + } + return skip +} + +func (p *parser) isUnderlinedHeader(data []byte) int { + // test of level 1 header + if data[0] == '=' { + i := skipChar(data, 1, '=') + i = skipChar(data, i, ' ') + if data[i] == '\n' { + return 1 + } else { + return 0 + } + } + + // test of level 2 header + if data[0] == '-' { + i := skipChar(data, 1, '-') + i = skipChar(data, i, ' ') + if data[i] == '\n' { + return 2 + } else { + return 0 + } + } + + return 0 +} + +func (p *parser) titleBlock(out *bytes.Buffer, data []byte, doRender bool) int { + if data[0] != '%' { + return 0 + } + splitData := bytes.Split(data, []byte("\n")) + var i int + for idx, b := range splitData { + if !bytes.HasPrefix(b, []byte("%")) { + i = idx // - 1 + break + } + } + + data = bytes.Join(splitData[0:i], []byte("\n")) + p.r.TitleBlock(out, data) + + return len(data) +} + +func (p *parser) html(out *bytes.Buffer, data []byte, doRender bool) int { + var i, j int + + // identify the opening tag + if data[0] != '<' { + return 0 + } + curtag, tagfound := p.htmlFindTag(data[1:]) + + // handle special cases + if !tagfound { + // check for an HTML comment + if size := p.htmlComment(out, data, doRender); size > 0 { + return size + } + + // check for an
tag + if size := p.htmlHr(out, data, doRender); size > 0 { + return size + } + + // check for HTML CDATA + if size := p.htmlCDATA(out, data, doRender); size > 0 { + return size + } + + // no special case recognized + return 0 + } + + // look for an unindented matching closing tag + // followed by a blank line + found := false + /* + closetag := []byte("\n") + j = len(curtag) + 1 + for !found { + // scan for a closing tag at the beginning of a line + if skip := bytes.Index(data[j:], closetag); skip >= 0 { + j += skip + len(closetag) + } else { + break + } + + // see if it is the only thing on the line + if skip := p.isEmpty(data[j:]); skip > 0 { + // see if it is followed by a blank line/eof + j += skip + if j >= len(data) { + found = true + i = j + } else { + if skip := p.isEmpty(data[j:]); skip > 0 { + j += skip + found = true + i = j + } + } + } + } + */ + + // if not found, try a second pass looking for indented match + // but not if tag is "ins" or "del" (following original Markdown.pl) + if !found && curtag != "ins" && curtag != "del" { + i = 1 + for i < len(data) { + i++ + for i < len(data) && !(data[i-1] == '<' && data[i] == '/') { + i++ + } + + if i+2+len(curtag) >= len(data) { + break + } + + j = p.htmlFindEnd(curtag, data[i-1:]) + + if j > 0 { + i += j - 1 + found = true + break + } + } + } + + if !found { + return 0 + } + + // the end of the block has been found + if doRender { + // trim newlines + end := i + for end > 0 && data[end-1] == '\n' { + end-- + } + p.r.BlockHtml(out, data[:end]) + } + + return i +} + +func (p *parser) renderHTMLBlock(out *bytes.Buffer, data []byte, start int, doRender bool) int { + // html block needs to end with a blank line + if i := p.isEmpty(data[start:]); i > 0 { + size := start + i + if doRender { + // trim trailing newlines + end := size + for end > 0 && data[end-1] == '\n' { + end-- + } + p.r.BlockHtml(out, data[:end]) + } + return size + } + return 0 +} + +// HTML comment, lax form +func (p *parser) htmlComment(out *bytes.Buffer, data []byte, doRender bool) int { + i := p.inlineHTMLComment(out, data) + return p.renderHTMLBlock(out, data, i, doRender) +} + +// HTML CDATA section +func (p *parser) htmlCDATA(out *bytes.Buffer, data []byte, doRender bool) int { + const cdataTag = "') { + i++ + } + i++ + // no end-of-comment marker + if i >= len(data) { + return 0 + } + return p.renderHTMLBlock(out, data, i, doRender) +} + +// HR, which is the only self-closing block tag considered +func (p *parser) htmlHr(out *bytes.Buffer, data []byte, doRender bool) int { + if data[0] != '<' || (data[1] != 'h' && data[1] != 'H') || (data[2] != 'r' && data[2] != 'R') { + return 0 + } + if data[3] != ' ' && data[3] != '/' && data[3] != '>' { + // not an
tag after all; at least not a valid one + return 0 + } + + i := 3 + for data[i] != '>' && data[i] != '\n' { + i++ + } + + if data[i] == '>' { + return p.renderHTMLBlock(out, data, i+1, doRender) + } + + return 0 +} + +func (p *parser) htmlFindTag(data []byte) (string, bool) { + i := 0 + for isalnum(data[i]) { + i++ + } + key := string(data[:i]) + if _, ok := blockTags[key]; ok { + return key, true + } + return "", false +} + +func (p *parser) htmlFindEnd(tag string, data []byte) int { + // assume data[0] == '<' && data[1] == '/' already tested + + // check if tag is a match + closetag := []byte("") + if !bytes.HasPrefix(data, closetag) { + return 0 + } + i := len(closetag) + + // check that the rest of the line is blank + skip := 0 + if skip = p.isEmpty(data[i:]); skip == 0 { + return 0 + } + i += skip + skip = 0 + + if i >= len(data) { + return i + } + + if p.flags&EXTENSION_LAX_HTML_BLOCKS != 0 { + return i + } + if skip = p.isEmpty(data[i:]); skip == 0 { + // following line must be blank + return 0 + } + + return i + skip +} + +func (*parser) isEmpty(data []byte) int { + // it is okay to call isEmpty on an empty buffer + if len(data) == 0 { + return 0 + } + + var i int + for i = 0; i < len(data) && data[i] != '\n'; i++ { + if data[i] != ' ' && data[i] != '\t' { + return 0 + } + } + return i + 1 +} + +func (*parser) isHRule(data []byte) bool { + i := 0 + + // skip up to three spaces + for i < 3 && data[i] == ' ' { + i++ + } + + // look at the hrule char + if data[i] != '*' && data[i] != '-' && data[i] != '_' { + return false + } + c := data[i] + + // the whole line must be the char or whitespace + n := 0 + for data[i] != '\n' { + switch { + case data[i] == c: + n++ + case data[i] != ' ': + return false + } + i++ + } + + return n >= 3 +} + +// isFenceLine checks if there's a fence line (e.g., ``` or ``` go) at the beginning of data, +// and returns the end index if so, or 0 otherwise. It also returns the marker found. +// If syntax is not nil, it gets set to the syntax specified in the fence line. +// A final newline is mandatory to recognize the fence line, unless newlineOptional is true. +func isFenceLine(data []byte, info *string, oldmarker string, newlineOptional bool) (end int, marker string) { + i, size := 0, 0 + + // skip up to three spaces + for i < len(data) && i < 3 && data[i] == ' ' { + i++ + } + + // check for the marker characters: ~ or ` + if i >= len(data) { + return 0, "" + } + if data[i] != '~' && data[i] != '`' { + return 0, "" + } + + c := data[i] + + // the whole line must be the same char or whitespace + for i < len(data) && data[i] == c { + size++ + i++ + } + + // the marker char must occur at least 3 times + if size < 3 { + return 0, "" + } + marker = string(data[i-size : i]) + + // if this is the end marker, it must match the beginning marker + if oldmarker != "" && marker != oldmarker { + return 0, "" + } + + // TODO(shurcooL): It's probably a good idea to simplify the 2 code paths here + // into one, always get the info string, and discard it if the caller doesn't care. + if info != nil { + infoLength := 0 + i = skipChar(data, i, ' ') + + if i >= len(data) { + if newlineOptional && i == len(data) { + return i, marker + } + return 0, "" + } + + infoStart := i + + if data[i] == '{' { + i++ + infoStart++ + + for i < len(data) && data[i] != '}' && data[i] != '\n' { + infoLength++ + i++ + } + + if i >= len(data) || data[i] != '}' { + return 0, "" + } + + // strip all whitespace at the beginning and the end + // of the {} block + for infoLength > 0 && isspace(data[infoStart]) { + infoStart++ + infoLength-- + } + + for infoLength > 0 && isspace(data[infoStart+infoLength-1]) { + infoLength-- + } + + i++ + } else { + for i < len(data) && !isverticalspace(data[i]) { + infoLength++ + i++ + } + } + + *info = strings.TrimSpace(string(data[infoStart : infoStart+infoLength])) + } + + i = skipChar(data, i, ' ') + if i >= len(data) || data[i] != '\n' { + if newlineOptional && i == len(data) { + return i, marker + } + return 0, "" + } + + return i + 1, marker // Take newline into account. +} + +// fencedCodeBlock returns the end index if data contains a fenced code block at the beginning, +// or 0 otherwise. It writes to out if doRender is true, otherwise it has no side effects. +// If doRender is true, a final newline is mandatory to recognize the fenced code block. +func (p *parser) fencedCodeBlock(out *bytes.Buffer, data []byte, doRender bool) int { + var infoString string + beg, marker := isFenceLine(data, &infoString, "", false) + if beg == 0 || beg >= len(data) { + return 0 + } + + var work bytes.Buffer + + for { + // safe to assume beg < len(data) + + // check for the end of the code block + newlineOptional := !doRender + fenceEnd, _ := isFenceLine(data[beg:], nil, marker, newlineOptional) + if fenceEnd != 0 { + beg += fenceEnd + break + } + + // copy the current line + end := skipUntilChar(data, beg, '\n') + 1 + + // did we reach the end of the buffer without a closing marker? + if end >= len(data) { + return 0 + } + + // verbatim copy to the working buffer + if doRender { + work.Write(data[beg:end]) + } + beg = end + } + + if doRender { + p.r.BlockCode(out, work.Bytes(), infoString) + } + + return beg +} + +func (p *parser) table(out *bytes.Buffer, data []byte) int { + var header bytes.Buffer + i, columns := p.tableHeader(&header, data) + if i == 0 { + return 0 + } + + var body bytes.Buffer + + for i < len(data) { + pipes, rowStart := 0, i + for ; data[i] != '\n'; i++ { + if data[i] == '|' { + pipes++ + } + } + + if pipes == 0 { + i = rowStart + break + } + + // include the newline in data sent to tableRow + i++ + p.tableRow(&body, data[rowStart:i], columns, false) + } + + p.r.Table(out, header.Bytes(), body.Bytes(), columns) + + return i +} + +// check if the specified position is preceded by an odd number of backslashes +func isBackslashEscaped(data []byte, i int) bool { + backslashes := 0 + for i-backslashes-1 >= 0 && data[i-backslashes-1] == '\\' { + backslashes++ + } + return backslashes&1 == 1 +} + +func (p *parser) tableHeader(out *bytes.Buffer, data []byte) (size int, columns []int) { + i := 0 + colCount := 1 + for i = 0; data[i] != '\n'; i++ { + if data[i] == '|' && !isBackslashEscaped(data, i) { + colCount++ + } + } + + // doesn't look like a table header + if colCount == 1 { + return + } + + // include the newline in the data sent to tableRow + header := data[:i+1] + + // column count ignores pipes at beginning or end of line + if data[0] == '|' { + colCount-- + } + if i > 2 && data[i-1] == '|' && !isBackslashEscaped(data, i-1) { + colCount-- + } + + columns = make([]int, colCount) + + // move on to the header underline + i++ + if i >= len(data) { + return + } + + if data[i] == '|' && !isBackslashEscaped(data, i) { + i++ + } + i = skipChar(data, i, ' ') + + // each column header is of form: / *:?-+:? *|/ with # dashes + # colons >= 3 + // and trailing | optional on last column + col := 0 + for data[i] != '\n' { + dashes := 0 + + if data[i] == ':' { + i++ + columns[col] |= TABLE_ALIGNMENT_LEFT + dashes++ + } + for data[i] == '-' { + i++ + dashes++ + } + if data[i] == ':' { + i++ + columns[col] |= TABLE_ALIGNMENT_RIGHT + dashes++ + } + for data[i] == ' ' { + i++ + } + + // end of column test is messy + switch { + case dashes < 3: + // not a valid column + return + + case data[i] == '|' && !isBackslashEscaped(data, i): + // marker found, now skip past trailing whitespace + col++ + i++ + for data[i] == ' ' { + i++ + } + + // trailing junk found after last column + if col >= colCount && data[i] != '\n' { + return + } + + case (data[i] != '|' || isBackslashEscaped(data, i)) && col+1 < colCount: + // something else found where marker was required + return + + case data[i] == '\n': + // marker is optional for the last column + col++ + + default: + // trailing junk found after last column + return + } + } + if col != colCount { + return + } + + p.tableRow(out, header, columns, true) + size = i + 1 + return +} + +func (p *parser) tableRow(out *bytes.Buffer, data []byte, columns []int, header bool) { + i, col := 0, 0 + var rowWork bytes.Buffer + + if data[i] == '|' && !isBackslashEscaped(data, i) { + i++ + } + + for col = 0; col < len(columns) && i < len(data); col++ { + for data[i] == ' ' { + i++ + } + + cellStart := i + + for (data[i] != '|' || isBackslashEscaped(data, i)) && data[i] != '\n' { + i++ + } + + cellEnd := i + + // skip the end-of-cell marker, possibly taking us past end of buffer + i++ + + for cellEnd > cellStart && data[cellEnd-1] == ' ' { + cellEnd-- + } + + var cellWork bytes.Buffer + p.inline(&cellWork, data[cellStart:cellEnd]) + + if header { + p.r.TableHeaderCell(&rowWork, cellWork.Bytes(), columns[col]) + } else { + p.r.TableCell(&rowWork, cellWork.Bytes(), columns[col]) + } + } + + // pad it out with empty columns to get the right number + for ; col < len(columns); col++ { + if header { + p.r.TableHeaderCell(&rowWork, nil, columns[col]) + } else { + p.r.TableCell(&rowWork, nil, columns[col]) + } + } + + // silently ignore rows with too many cells + + p.r.TableRow(out, rowWork.Bytes()) +} + +// returns blockquote prefix length +func (p *parser) quotePrefix(data []byte) int { + i := 0 + for i < 3 && data[i] == ' ' { + i++ + } + if data[i] == '>' { + if data[i+1] == ' ' { + return i + 2 + } + return i + 1 + } + return 0 +} + +// blockquote ends with at least one blank line +// followed by something without a blockquote prefix +func (p *parser) terminateBlockquote(data []byte, beg, end int) bool { + if p.isEmpty(data[beg:]) <= 0 { + return false + } + if end >= len(data) { + return true + } + return p.quotePrefix(data[end:]) == 0 && p.isEmpty(data[end:]) == 0 +} + +// parse a blockquote fragment +func (p *parser) quote(out *bytes.Buffer, data []byte) int { + var raw bytes.Buffer + beg, end := 0, 0 + for beg < len(data) { + end = beg + // Step over whole lines, collecting them. While doing that, check for + // fenced code and if one's found, incorporate it altogether, + // irregardless of any contents inside it + for data[end] != '\n' { + if p.flags&EXTENSION_FENCED_CODE != 0 { + if i := p.fencedCodeBlock(out, data[end:], false); i > 0 { + // -1 to compensate for the extra end++ after the loop: + end += i - 1 + break + } + } + end++ + } + end++ + + if pre := p.quotePrefix(data[beg:]); pre > 0 { + // skip the prefix + beg += pre + } else if p.terminateBlockquote(data, beg, end) { + break + } + + // this line is part of the blockquote + raw.Write(data[beg:end]) + beg = end + } + + var cooked bytes.Buffer + p.block(&cooked, raw.Bytes()) + p.r.BlockQuote(out, cooked.Bytes()) + return end +} + +// returns prefix length for block code +func (p *parser) codePrefix(data []byte) int { + if data[0] == ' ' && data[1] == ' ' && data[2] == ' ' && data[3] == ' ' { + return 4 + } + return 0 +} + +func (p *parser) code(out *bytes.Buffer, data []byte) int { + var work bytes.Buffer + + i := 0 + for i < len(data) { + beg := i + for data[i] != '\n' { + i++ + } + i++ + + blankline := p.isEmpty(data[beg:i]) > 0 + if pre := p.codePrefix(data[beg:i]); pre > 0 { + beg += pre + } else if !blankline { + // non-empty, non-prefixed line breaks the pre + i = beg + break + } + + // verbatim copy to the working buffeu + if blankline { + work.WriteByte('\n') + } else { + work.Write(data[beg:i]) + } + } + + // trim all the \n off the end of work + workbytes := work.Bytes() + eol := len(workbytes) + for eol > 0 && workbytes[eol-1] == '\n' { + eol-- + } + if eol != len(workbytes) { + work.Truncate(eol) + } + + work.WriteByte('\n') + + p.r.BlockCode(out, work.Bytes(), "") + + return i +} + +// returns unordered list item prefix +func (p *parser) uliPrefix(data []byte) int { + i := 0 + + // start with up to 3 spaces + for i < 3 && data[i] == ' ' { + i++ + } + + // need a *, +, or - followed by a space + if (data[i] != '*' && data[i] != '+' && data[i] != '-') || + data[i+1] != ' ' { + return 0 + } + return i + 2 +} + +// returns ordered list item prefix +func (p *parser) oliPrefix(data []byte) int { + i := 0 + + // start with up to 3 spaces + for i < 3 && data[i] == ' ' { + i++ + } + + // count the digits + start := i + for data[i] >= '0' && data[i] <= '9' { + i++ + } + + // we need >= 1 digits followed by a dot and a space + if start == i || data[i] != '.' || data[i+1] != ' ' { + return 0 + } + return i + 2 +} + +// returns definition list item prefix +func (p *parser) dliPrefix(data []byte) int { + i := 0 + + // need a : followed by a spaces + if data[i] != ':' || data[i+1] != ' ' { + return 0 + } + for data[i] == ' ' { + i++ + } + return i + 2 +} + +// parse ordered or unordered list block +func (p *parser) list(out *bytes.Buffer, data []byte, flags int) int { + i := 0 + flags |= LIST_ITEM_BEGINNING_OF_LIST + work := func() bool { + for i < len(data) { + skip := p.listItem(out, data[i:], &flags) + i += skip + + if skip == 0 || flags&LIST_ITEM_END_OF_LIST != 0 { + break + } + flags &= ^LIST_ITEM_BEGINNING_OF_LIST + } + return true + } + + p.r.List(out, work, flags) + return i +} + +// Parse a single list item. +// Assumes initial prefix is already removed if this is a sublist. +func (p *parser) listItem(out *bytes.Buffer, data []byte, flags *int) int { + // keep track of the indentation of the first line + itemIndent := 0 + for itemIndent < 3 && data[itemIndent] == ' ' { + itemIndent++ + } + + i := p.uliPrefix(data) + if i == 0 { + i = p.oliPrefix(data) + } + if i == 0 { + i = p.dliPrefix(data) + // reset definition term flag + if i > 0 { + *flags &= ^LIST_TYPE_TERM + } + } + if i == 0 { + // if in defnition list, set term flag and continue + if *flags&LIST_TYPE_DEFINITION != 0 { + *flags |= LIST_TYPE_TERM + } else { + return 0 + } + } + + // skip leading whitespace on first line + for data[i] == ' ' { + i++ + } + + // find the end of the line + line := i + for i > 0 && data[i-1] != '\n' { + i++ + } + + // get working buffer + var raw bytes.Buffer + + // put the first line into the working buffer + raw.Write(data[line:i]) + line = i + + // process the following lines + containsBlankLine := false + sublist := 0 + codeBlockMarker := "" + +gatherlines: + for line < len(data) { + i++ + + // find the end of this line + for data[i-1] != '\n' { + i++ + } + + // if it is an empty line, guess that it is part of this item + // and move on to the next line + if p.isEmpty(data[line:i]) > 0 { + containsBlankLine = true + raw.Write(data[line:i]) + line = i + continue + } + + // calculate the indentation + indent := 0 + for indent < 4 && line+indent < i && data[line+indent] == ' ' { + indent++ + } + + chunk := data[line+indent : i] + + if p.flags&EXTENSION_FENCED_CODE != 0 { + // determine if in or out of codeblock + // if in codeblock, ignore normal list processing + _, marker := isFenceLine(chunk, nil, codeBlockMarker, false) + if marker != "" { + if codeBlockMarker == "" { + // start of codeblock + codeBlockMarker = marker + } else { + // end of codeblock. + *flags |= LIST_ITEM_CONTAINS_BLOCK + codeBlockMarker = "" + } + } + // we are in a codeblock, write line, and continue + if codeBlockMarker != "" || marker != "" { + raw.Write(data[line+indent : i]) + line = i + continue gatherlines + } + } + + // evaluate how this line fits in + switch { + // is this a nested list item? + case (p.uliPrefix(chunk) > 0 && !p.isHRule(chunk)) || + p.oliPrefix(chunk) > 0 || + p.dliPrefix(chunk) > 0: + + if containsBlankLine { + // end the list if the type changed after a blank line + if indent <= itemIndent && + ((*flags&LIST_TYPE_ORDERED != 0 && p.uliPrefix(chunk) > 0) || + (*flags&LIST_TYPE_ORDERED == 0 && p.oliPrefix(chunk) > 0)) { + + *flags |= LIST_ITEM_END_OF_LIST + break gatherlines + } + *flags |= LIST_ITEM_CONTAINS_BLOCK + } + + // to be a nested list, it must be indented more + // if not, it is the next item in the same list + if indent <= itemIndent { + break gatherlines + } + + // is this the first item in the nested list? + if sublist == 0 { + sublist = raw.Len() + } + + // is this a nested prefix header? + case p.isPrefixHeader(chunk): + // if the header is not indented, it is not nested in the list + // and thus ends the list + if containsBlankLine && indent < 4 { + *flags |= LIST_ITEM_END_OF_LIST + break gatherlines + } + *flags |= LIST_ITEM_CONTAINS_BLOCK + + // anything following an empty line is only part + // of this item if it is indented 4 spaces + // (regardless of the indentation of the beginning of the item) + case containsBlankLine && indent < 4: + if *flags&LIST_TYPE_DEFINITION != 0 && i < len(data)-1 { + // is the next item still a part of this list? + next := i + for data[next] != '\n' { + next++ + } + for next < len(data)-1 && data[next] == '\n' { + next++ + } + if i < len(data)-1 && data[i] != ':' && data[next] != ':' { + *flags |= LIST_ITEM_END_OF_LIST + } + } else { + *flags |= LIST_ITEM_END_OF_LIST + } + break gatherlines + + // a blank line means this should be parsed as a block + case containsBlankLine: + *flags |= LIST_ITEM_CONTAINS_BLOCK + } + + containsBlankLine = false + + // add the line into the working buffer without prefix + raw.Write(data[line+indent : i]) + + line = i + } + + // If reached end of data, the Renderer.ListItem call we're going to make below + // is definitely the last in the list. + if line >= len(data) { + *flags |= LIST_ITEM_END_OF_LIST + } + + rawBytes := raw.Bytes() + + // render the contents of the list item + var cooked bytes.Buffer + if *flags&LIST_ITEM_CONTAINS_BLOCK != 0 && *flags&LIST_TYPE_TERM == 0 { + // intermediate render of block item, except for definition term + if sublist > 0 { + p.block(&cooked, rawBytes[:sublist]) + p.block(&cooked, rawBytes[sublist:]) + } else { + p.block(&cooked, rawBytes) + } + } else { + // intermediate render of inline item + if sublist > 0 { + p.inline(&cooked, rawBytes[:sublist]) + p.block(&cooked, rawBytes[sublist:]) + } else { + p.inline(&cooked, rawBytes) + } + } + + // render the actual list item + cookedBytes := cooked.Bytes() + parsedEnd := len(cookedBytes) + + // strip trailing newlines + for parsedEnd > 0 && cookedBytes[parsedEnd-1] == '\n' { + parsedEnd-- + } + p.r.ListItem(out, cookedBytes[:parsedEnd], *flags) + + return line +} + +// render a single paragraph that has already been parsed out +func (p *parser) renderParagraph(out *bytes.Buffer, data []byte) { + if len(data) == 0 { + return + } + + // trim leading spaces + beg := 0 + for data[beg] == ' ' { + beg++ + } + + // trim trailing newline + end := len(data) - 1 + + // trim trailing spaces + for end > beg && data[end-1] == ' ' { + end-- + } + + work := func() bool { + p.inline(out, data[beg:end]) + return true + } + p.r.Paragraph(out, work) +} + +func (p *parser) paragraph(out *bytes.Buffer, data []byte) int { + // prev: index of 1st char of previous line + // line: index of 1st char of current line + // i: index of cursor/end of current line + var prev, line, i int + + // keep going until we find something to mark the end of the paragraph + for i < len(data) { + // mark the beginning of the current line + prev = line + current := data[i:] + line = i + + // did we find a blank line marking the end of the paragraph? + if n := p.isEmpty(current); n > 0 { + // did this blank line followed by a definition list item? + if p.flags&EXTENSION_DEFINITION_LISTS != 0 { + if i < len(data)-1 && data[i+1] == ':' { + return p.list(out, data[prev:], LIST_TYPE_DEFINITION) + } + } + + p.renderParagraph(out, data[:i]) + return i + n + } + + // an underline under some text marks a header, so our paragraph ended on prev line + if i > 0 { + if level := p.isUnderlinedHeader(current); level > 0 { + // render the paragraph + p.renderParagraph(out, data[:prev]) + + // ignore leading and trailing whitespace + eol := i - 1 + for prev < eol && data[prev] == ' ' { + prev++ + } + for eol > prev && data[eol-1] == ' ' { + eol-- + } + + // render the header + // this ugly double closure avoids forcing variables onto the heap + work := func(o *bytes.Buffer, pp *parser, d []byte) func() bool { + return func() bool { + pp.inline(o, d) + return true + } + }(out, p, data[prev:eol]) + + id := "" + if p.flags&EXTENSION_AUTO_HEADER_IDS != 0 { + id = SanitizedAnchorName(string(data[prev:eol])) + } + + p.r.Header(out, work, level, id) + + // find the end of the underline + for data[i] != '\n' { + i++ + } + return i + } + } + + // if the next line starts a block of HTML, then the paragraph ends here + if p.flags&EXTENSION_LAX_HTML_BLOCKS != 0 { + if data[i] == '<' && p.html(out, current, false) > 0 { + // rewind to before the HTML block + p.renderParagraph(out, data[:i]) + return i + } + } + + // if there's a prefixed header or a horizontal rule after this, paragraph is over + if p.isPrefixHeader(current) || p.isHRule(current) { + p.renderParagraph(out, data[:i]) + return i + } + + // if there's a fenced code block, paragraph is over + if p.flags&EXTENSION_FENCED_CODE != 0 { + if p.fencedCodeBlock(out, current, false) > 0 { + p.renderParagraph(out, data[:i]) + return i + } + } + + // if there's a definition list item, prev line is a definition term + if p.flags&EXTENSION_DEFINITION_LISTS != 0 { + if p.dliPrefix(current) != 0 { + return p.list(out, data[prev:], LIST_TYPE_DEFINITION) + } + } + + // if there's a list after this, paragraph is over + if p.flags&EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK != 0 { + if p.uliPrefix(current) != 0 || + p.oliPrefix(current) != 0 || + p.quotePrefix(current) != 0 || + p.codePrefix(current) != 0 { + p.renderParagraph(out, data[:i]) + return i + } + } + + // otherwise, scan to the beginning of the next line + for data[i] != '\n' { + i++ + } + i++ + } + + p.renderParagraph(out, data[:i]) + return i +} + +// SanitizedAnchorName returns a sanitized anchor name for the given text. +// +// It implements the algorithm specified in the package comment. +func SanitizedAnchorName(text string) string { + var anchorName []rune + futureDash := false + for _, r := range text { + switch { + case unicode.IsLetter(r) || unicode.IsNumber(r): + if futureDash && len(anchorName) > 0 { + anchorName = append(anchorName, '-') + } + futureDash = false + anchorName = append(anchorName, unicode.ToLower(r)) + default: + futureDash = true + } + } + return string(anchorName) +} diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/doc.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/doc.go new file mode 100644 index 0000000..9656c42 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/doc.go @@ -0,0 +1,32 @@ +// Package blackfriday is a Markdown processor. +// +// It translates plain text with simple formatting rules into HTML or LaTeX. +// +// Sanitized Anchor Names +// +// Blackfriday includes an algorithm for creating sanitized anchor names +// corresponding to a given input text. This algorithm is used to create +// anchors for headings when EXTENSION_AUTO_HEADER_IDS is enabled. The +// algorithm is specified below, so that other packages can create +// compatible anchor names and links to those anchors. +// +// The algorithm iterates over the input text, interpreted as UTF-8, +// one Unicode code point (rune) at a time. All runes that are letters (category L) +// or numbers (category N) are considered valid characters. They are mapped to +// lower case, and included in the output. All other runes are considered +// invalid characters. Invalid characters that preceed the first valid character, +// as well as invalid character that follow the last valid character +// are dropped completely. All other sequences of invalid characters +// between two valid characters are replaced with a single dash character '-'. +// +// SanitizedAnchorName exposes this functionality, and can be used to +// create compatible links to the anchor names generated by blackfriday. +// This algorithm is also implemented in a small standalone package at +// github.com/shurcooL/sanitized_anchor_name. It can be useful for clients +// that want a small package and don't need full functionality of blackfriday. +package blackfriday + +// NOTE: Keep Sanitized Anchor Name algorithm in sync with package +// github.com/shurcooL/sanitized_anchor_name. +// Otherwise, users of sanitized_anchor_name will get anchor names +// that are incompatible with those generated by blackfriday. diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/go.mod b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/go.mod new file mode 100644 index 0000000..b05561a --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/go.mod @@ -0,0 +1 @@ +module github.com/russross/blackfriday diff --git a/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/html.go b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/html.go new file mode 100644 index 0000000..e0a6c69 --- /dev/null +++ b/go-work/pkg/mod/github.com/go-delve/delve@v1.6.1/vendor/github.com/russross/blackfriday/html.go @@ -0,0 +1,938 @@ +// +// Blackfriday Markdown Processor +// Available at http://github.com/russross/blackfriday +// +// Copyright © 2011 Russ Ross . +// Distributed under the Simplified BSD License. +// See README.md for details. +// + +// +// +// HTML rendering backend +// +// + +package blackfriday + +import ( + "bytes" + "fmt" + "regexp" + "strconv" + "strings" +) + +// Html renderer configuration options. +const ( + HTML_SKIP_HTML = 1 << iota // skip preformatted HTML blocks + HTML_SKIP_STYLE // skip embedded