id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26,200 | alecthomas/chroma | style.go | Inherit | func (s StyleEntry) Inherit(ancestors ...StyleEntry) StyleEntry {
out := s
for i := len(ancestors) - 1; i >= 0; i-- {
if out.NoInherit {
return out
}
ancestor := ancestors[i]
if !out.Colour.IsSet() {
out.Colour = ancestor.Colour
}
if !out.Background.IsSet() {
out.Background = ancestor.Background
... | go | func (s StyleEntry) Inherit(ancestors ...StyleEntry) StyleEntry {
out := s
for i := len(ancestors) - 1; i >= 0; i-- {
if out.NoInherit {
return out
}
ancestor := ancestors[i]
if !out.Colour.IsSet() {
out.Colour = ancestor.Colour
}
if !out.Background.IsSet() {
out.Background = ancestor.Background
... | [
"func",
"(",
"s",
"StyleEntry",
")",
"Inherit",
"(",
"ancestors",
"...",
"StyleEntry",
")",
"StyleEntry",
"{",
"out",
":=",
"s",
"\n",
"for",
"i",
":=",
"len",
"(",
"ancestors",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"if",
"out"... | // Inherit styles from ancestors.
//
// Ancestors should be provided from oldest to newest. | [
"Inherit",
"styles",
"from",
"ancestors",
".",
"Ancestors",
"should",
"be",
"provided",
"from",
"oldest",
"to",
"newest",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/style.go#L105-L132 |
26,201 | alecthomas/chroma | style.go | NewStyle | func NewStyle(name string, entries StyleEntries) (*Style, error) {
return NewStyleBuilder(name).AddAll(entries).Build()
} | go | func NewStyle(name string, entries StyleEntries) (*Style, error) {
return NewStyleBuilder(name).AddAll(entries).Build()
} | [
"func",
"NewStyle",
"(",
"name",
"string",
",",
"entries",
"StyleEntries",
")",
"(",
"*",
"Style",
",",
"error",
")",
"{",
"return",
"NewStyleBuilder",
"(",
"name",
")",
".",
"AddAll",
"(",
"entries",
")",
".",
"Build",
"(",
")",
"\n",
"}"
] | // NewStyle creates a new style definition. | [
"NewStyle",
"creates",
"a",
"new",
"style",
"definition",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/style.go#L198-L200 |
26,202 | alecthomas/chroma | style.go | MustNewStyle | func MustNewStyle(name string, entries StyleEntries) *Style {
style, err := NewStyle(name, entries)
if err != nil {
panic(err)
}
return style
} | go | func MustNewStyle(name string, entries StyleEntries) *Style {
style, err := NewStyle(name, entries)
if err != nil {
panic(err)
}
return style
} | [
"func",
"MustNewStyle",
"(",
"name",
"string",
",",
"entries",
"StyleEntries",
")",
"*",
"Style",
"{",
"style",
",",
"err",
":=",
"NewStyle",
"(",
"name",
",",
"entries",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
... | // MustNewStyle creates a new style or panics. | [
"MustNewStyle",
"creates",
"a",
"new",
"style",
"or",
"panics",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/style.go#L203-L209 |
26,203 | alecthomas/chroma | style.go | Types | func (s *Style) Types() []TokenType {
dedupe := map[TokenType]bool{}
for tt := range s.entries {
dedupe[tt] = true
}
if s.parent != nil {
for _, tt := range s.parent.Types() {
dedupe[tt] = true
}
}
out := make([]TokenType, 0, len(dedupe))
for tt := range dedupe {
out = append(out, tt)
}
return out
} | go | func (s *Style) Types() []TokenType {
dedupe := map[TokenType]bool{}
for tt := range s.entries {
dedupe[tt] = true
}
if s.parent != nil {
for _, tt := range s.parent.Types() {
dedupe[tt] = true
}
}
out := make([]TokenType, 0, len(dedupe))
for tt := range dedupe {
out = append(out, tt)
}
return out
} | [
"func",
"(",
"s",
"*",
"Style",
")",
"Types",
"(",
")",
"[",
"]",
"TokenType",
"{",
"dedupe",
":=",
"map",
"[",
"TokenType",
"]",
"bool",
"{",
"}",
"\n",
"for",
"tt",
":=",
"range",
"s",
".",
"entries",
"{",
"dedupe",
"[",
"tt",
"]",
"=",
"true... | // Types that are styled. | [
"Types",
"that",
"are",
"styled",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/style.go#L221-L236 |
26,204 | alecthomas/chroma | style.go | Builder | func (s *Style) Builder() *StyleBuilder {
return &StyleBuilder{
name: s.Name,
entries: map[TokenType]string{},
parent: s,
}
} | go | func (s *Style) Builder() *StyleBuilder {
return &StyleBuilder{
name: s.Name,
entries: map[TokenType]string{},
parent: s,
}
} | [
"func",
"(",
"s",
"*",
"Style",
")",
"Builder",
"(",
")",
"*",
"StyleBuilder",
"{",
"return",
"&",
"StyleBuilder",
"{",
"name",
":",
"s",
".",
"Name",
",",
"entries",
":",
"map",
"[",
"TokenType",
"]",
"string",
"{",
"}",
",",
"parent",
":",
"s",
... | // Builder creates a mutable builder from this Style.
//
// The builder can then be safely modified. This is a cheap operation. | [
"Builder",
"creates",
"a",
"mutable",
"builder",
"from",
"this",
"Style",
".",
"The",
"builder",
"can",
"then",
"be",
"safely",
"modified",
".",
"This",
"is",
"a",
"cheap",
"operation",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/style.go#L241-L247 |
26,205 | alecthomas/chroma | style.go | Get | func (s *Style) Get(ttype TokenType) StyleEntry {
return s.get(ttype).Inherit(
s.get(Background),
s.get(Text),
s.get(ttype.Category()),
s.get(ttype.SubCategory()))
} | go | func (s *Style) Get(ttype TokenType) StyleEntry {
return s.get(ttype).Inherit(
s.get(Background),
s.get(Text),
s.get(ttype.Category()),
s.get(ttype.SubCategory()))
} | [
"func",
"(",
"s",
"*",
"Style",
")",
"Get",
"(",
"ttype",
"TokenType",
")",
"StyleEntry",
"{",
"return",
"s",
".",
"get",
"(",
"ttype",
")",
".",
"Inherit",
"(",
"s",
".",
"get",
"(",
"Background",
")",
",",
"s",
".",
"get",
"(",
"Text",
")",
"... | // Get a style entry. Will try sub-category or category if an exact match is not found, and
// finally return the Background. | [
"Get",
"a",
"style",
"entry",
".",
"Will",
"try",
"sub",
"-",
"category",
"or",
"category",
"if",
"an",
"exact",
"match",
"is",
"not",
"found",
"and",
"finally",
"return",
"the",
"Background",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/style.go#L258-L264 |
26,206 | alecthomas/chroma | style.go | ParseStyleEntry | func ParseStyleEntry(entry string) (StyleEntry, error) { // nolint: gocyclo
out := StyleEntry{}
parts := strings.Fields(entry)
for _, part := range parts {
switch {
case part == "italic":
out.Italic = Yes
case part == "noitalic":
out.Italic = No
case part == "bold":
out.Bold = Yes
case part == "no... | go | func ParseStyleEntry(entry string) (StyleEntry, error) { // nolint: gocyclo
out := StyleEntry{}
parts := strings.Fields(entry)
for _, part := range parts {
switch {
case part == "italic":
out.Italic = Yes
case part == "noitalic":
out.Italic = No
case part == "bold":
out.Bold = Yes
case part == "no... | [
"func",
"ParseStyleEntry",
"(",
"entry",
"string",
")",
"(",
"StyleEntry",
",",
"error",
")",
"{",
"// nolint: gocyclo",
"out",
":=",
"StyleEntry",
"{",
"}",
"\n",
"parts",
":=",
"strings",
".",
"Fields",
"(",
"entry",
")",
"\n",
"for",
"_",
",",
"part",... | // ParseStyleEntry parses a Pygments style entry. | [
"ParseStyleEntry",
"parses",
"a",
"Pygments",
"style",
"entry",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/style.go#L299-L342 |
26,207 | alecthomas/chroma | styles/api.go | Register | func Register(style *chroma.Style) *chroma.Style {
Registry[style.Name] = style
return style
} | go | func Register(style *chroma.Style) *chroma.Style {
Registry[style.Name] = style
return style
} | [
"func",
"Register",
"(",
"style",
"*",
"chroma",
".",
"Style",
")",
"*",
"chroma",
".",
"Style",
"{",
"Registry",
"[",
"style",
".",
"Name",
"]",
"=",
"style",
"\n",
"return",
"style",
"\n",
"}"
] | // Register a chroma.Style. | [
"Register",
"a",
"chroma",
".",
"Style",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/styles/api.go#L16-L19 |
26,208 | alecthomas/chroma | styles/api.go | Get | func Get(name string) *chroma.Style {
if style, ok := Registry[name]; ok {
return style
}
return Fallback
} | go | func Get(name string) *chroma.Style {
if style, ok := Registry[name]; ok {
return style
}
return Fallback
} | [
"func",
"Get",
"(",
"name",
"string",
")",
"*",
"chroma",
".",
"Style",
"{",
"if",
"style",
",",
"ok",
":=",
"Registry",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"style",
"\n",
"}",
"\n",
"return",
"Fallback",
"\n",
"}"
] | // Get named style, or Fallback. | [
"Get",
"named",
"style",
"or",
"Fallback",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/styles/api.go#L32-L37 |
26,209 | alecthomas/chroma | colour.go | NewColour | func NewColour(r, g, b uint8) Colour {
return ParseColour(fmt.Sprintf("%02x%02x%02x", r, g, b))
} | go | func NewColour(r, g, b uint8) Colour {
return ParseColour(fmt.Sprintf("%02x%02x%02x", r, g, b))
} | [
"func",
"NewColour",
"(",
"r",
",",
"g",
",",
"b",
"uint8",
")",
"Colour",
"{",
"return",
"ParseColour",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r",
",",
"g",
",",
"b",
")",
")",
"\n",
"}"
] | // NewColour creates a Colour directly from RGB values. | [
"NewColour",
"creates",
"a",
"Colour",
"directly",
"from",
"RGB",
"values",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/colour.go#L54-L56 |
26,210 | alecthomas/chroma | colour.go | MustParseColour | func MustParseColour(colour string) Colour {
parsed := ParseColour(colour)
if !parsed.IsSet() {
panic(fmt.Errorf("invalid colour %q", colour))
}
return parsed
} | go | func MustParseColour(colour string) Colour {
parsed := ParseColour(colour)
if !parsed.IsSet() {
panic(fmt.Errorf("invalid colour %q", colour))
}
return parsed
} | [
"func",
"MustParseColour",
"(",
"colour",
"string",
")",
"Colour",
"{",
"parsed",
":=",
"ParseColour",
"(",
"colour",
")",
"\n",
"if",
"!",
"parsed",
".",
"IsSet",
"(",
")",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"colour",
")"... | // MustParseColour is like ParseColour except it panics if the colour is invalid.
//
// Will panic if colour is in an invalid format. | [
"MustParseColour",
"is",
"like",
"ParseColour",
"except",
"it",
"panics",
"if",
"the",
"colour",
"is",
"invalid",
".",
"Will",
"panic",
"if",
"colour",
"is",
"in",
"an",
"invalid",
"format",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/colour.go#L122-L128 |
26,211 | alecthomas/chroma | formatters/html/html.go | HighlightLines | func HighlightLines(ranges [][2]int) Option {
return func(f *Formatter) {
f.highlightRanges = ranges
sort.Sort(f.highlightRanges)
}
} | go | func HighlightLines(ranges [][2]int) Option {
return func(f *Formatter) {
f.highlightRanges = ranges
sort.Sort(f.highlightRanges)
}
} | [
"func",
"HighlightLines",
"(",
"ranges",
"[",
"]",
"[",
"2",
"]",
"int",
")",
"Option",
"{",
"return",
"func",
"(",
"f",
"*",
"Formatter",
")",
"{",
"f",
".",
"highlightRanges",
"=",
"ranges",
"\n",
"sort",
".",
"Sort",
"(",
"f",
".",
"highlightRange... | // HighlightLines higlights the given line ranges with the Highlight style.
//
// A range is the beginning and ending of a range as 1-based line numbers, inclusive. | [
"HighlightLines",
"higlights",
"the",
"given",
"line",
"ranges",
"with",
"the",
"Highlight",
"style",
".",
"A",
"range",
"is",
"the",
"beginning",
"and",
"ending",
"of",
"a",
"range",
"as",
"1",
"-",
"based",
"line",
"numbers",
"inclusive",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/formatters/html/html.go#L49-L54 |
26,212 | alecthomas/chroma | formatters/html/html.go | New | func New(options ...Option) *Formatter {
f := &Formatter{
baseLineNumber: 1,
}
for _, option := range options {
option(f)
}
return f
} | go | func New(options ...Option) *Formatter {
f := &Formatter{
baseLineNumber: 1,
}
for _, option := range options {
option(f)
}
return f
} | [
"func",
"New",
"(",
"options",
"...",
"Option",
")",
"*",
"Formatter",
"{",
"f",
":=",
"&",
"Formatter",
"{",
"baseLineNumber",
":",
"1",
",",
"}",
"\n",
"for",
"_",
",",
"option",
":=",
"range",
"options",
"{",
"option",
"(",
"f",
")",
"\n",
"}",
... | // New HTML formatter. | [
"New",
"HTML",
"formatter",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/formatters/html/html.go#L64-L72 |
26,213 | alecthomas/chroma | formatters/html/html.go | StyleEntryToCSS | func StyleEntryToCSS(e chroma.StyleEntry) string {
styles := []string{}
if e.Colour.IsSet() {
styles = append(styles, "color: "+e.Colour.String())
}
if e.Background.IsSet() {
styles = append(styles, "background-color: "+e.Background.String())
}
if e.Bold == chroma.Yes {
styles = append(styles, "font-weight:... | go | func StyleEntryToCSS(e chroma.StyleEntry) string {
styles := []string{}
if e.Colour.IsSet() {
styles = append(styles, "color: "+e.Colour.String())
}
if e.Background.IsSet() {
styles = append(styles, "background-color: "+e.Background.String())
}
if e.Bold == chroma.Yes {
styles = append(styles, "font-weight:... | [
"func",
"StyleEntryToCSS",
"(",
"e",
"chroma",
".",
"StyleEntry",
")",
"string",
"{",
"styles",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"if",
"e",
".",
"Colour",
".",
"IsSet",
"(",
")",
"{",
"styles",
"=",
"append",
"(",
"styles",
",",
"\"",
"\""... | // StyleEntryToCSS converts a chroma.StyleEntry to CSS attributes. | [
"StyleEntryToCSS",
"converts",
"a",
"chroma",
".",
"StyleEntry",
"to",
"CSS",
"attributes",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/formatters/html/html.go#L328-L346 |
26,214 | alecthomas/chroma | formatters/html/html.go | compressStyle | func compressStyle(s string) string {
parts := strings.Split(s, ";")
out := []string{}
for _, p := range parts {
p = strings.Join(strings.Fields(p), " ")
p = strings.Replace(p, ": ", ":", 1)
if strings.Contains(p, "#") {
c := p[len(p)-6:]
if c[0] == c[1] && c[2] == c[3] && c[4] == c[5] {
p = p[:len(p... | go | func compressStyle(s string) string {
parts := strings.Split(s, ";")
out := []string{}
for _, p := range parts {
p = strings.Join(strings.Fields(p), " ")
p = strings.Replace(p, ": ", ":", 1)
if strings.Contains(p, "#") {
c := p[len(p)-6:]
if c[0] == c[1] && c[2] == c[3] && c[4] == c[5] {
p = p[:len(p... | [
"func",
"compressStyle",
"(",
"s",
"string",
")",
"string",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"out",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"parts",
"{",
"... | // Compress CSS attributes - remove spaces, transform 6-digit colours to 3. | [
"Compress",
"CSS",
"attributes",
"-",
"remove",
"spaces",
"transform",
"6",
"-",
"digit",
"colours",
"to",
"3",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/formatters/html/html.go#L349-L364 |
26,215 | alecthomas/chroma | remap.go | RemappingLexer | func RemappingLexer(lexer Lexer, mapper func(Token) []Token) Lexer {
return &remappingLexer{lexer, mapper}
} | go | func RemappingLexer(lexer Lexer, mapper func(Token) []Token) Lexer {
return &remappingLexer{lexer, mapper}
} | [
"func",
"RemappingLexer",
"(",
"lexer",
"Lexer",
",",
"mapper",
"func",
"(",
"Token",
")",
"[",
"]",
"Token",
")",
"Lexer",
"{",
"return",
"&",
"remappingLexer",
"{",
"lexer",
",",
"mapper",
"}",
"\n",
"}"
] | // RemappingLexer remaps a token to a set of, potentially empty, tokens. | [
"RemappingLexer",
"remaps",
"a",
"token",
"to",
"a",
"set",
"of",
"potentially",
"empty",
"tokens",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/remap.go#L9-L11 |
26,216 | alecthomas/chroma | regexp.go | ByGroups | func ByGroups(emitters ...Emitter) Emitter {
return EmitterFunc(func(groups []string, lexer Lexer) Iterator {
iterators := make([]Iterator, 0, len(groups)-1)
// NOTE: If this panics, there is a mismatch with groups
for i, group := range groups[1:] {
iterators = append(iterators, emitters[i].Emit([]string{grou... | go | func ByGroups(emitters ...Emitter) Emitter {
return EmitterFunc(func(groups []string, lexer Lexer) Iterator {
iterators := make([]Iterator, 0, len(groups)-1)
// NOTE: If this panics, there is a mismatch with groups
for i, group := range groups[1:] {
iterators = append(iterators, emitters[i].Emit([]string{grou... | [
"func",
"ByGroups",
"(",
"emitters",
"...",
"Emitter",
")",
"Emitter",
"{",
"return",
"EmitterFunc",
"(",
"func",
"(",
"groups",
"[",
"]",
"string",
",",
"lexer",
"Lexer",
")",
"Iterator",
"{",
"iterators",
":=",
"make",
"(",
"[",
"]",
"Iterator",
",",
... | // ByGroups emits a token for each matching group in the rule's regex. | [
"ByGroups",
"emits",
"a",
"token",
"for",
"each",
"matching",
"group",
"in",
"the",
"rule",
"s",
"regex",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/regexp.go#L34-L43 |
26,217 | alecthomas/chroma | regexp.go | Using | func Using(lexer Lexer) Emitter {
return EmitterFunc(func(groups []string, _ Lexer) Iterator {
it, err := lexer.Tokenise(&TokeniseOptions{State: "root", Nested: true}, groups[0])
if err != nil {
panic(err)
}
return it
})
} | go | func Using(lexer Lexer) Emitter {
return EmitterFunc(func(groups []string, _ Lexer) Iterator {
it, err := lexer.Tokenise(&TokeniseOptions{State: "root", Nested: true}, groups[0])
if err != nil {
panic(err)
}
return it
})
} | [
"func",
"Using",
"(",
"lexer",
"Lexer",
")",
"Emitter",
"{",
"return",
"EmitterFunc",
"(",
"func",
"(",
"groups",
"[",
"]",
"string",
",",
"_",
"Lexer",
")",
"Iterator",
"{",
"it",
",",
"err",
":=",
"lexer",
".",
"Tokenise",
"(",
"&",
"TokeniseOptions"... | // Using returns an Emitter that uses a given Lexer for parsing and emitting. | [
"Using",
"returns",
"an",
"Emitter",
"that",
"uses",
"a",
"given",
"Lexer",
"for",
"parsing",
"and",
"emitting",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/regexp.go#L114-L122 |
26,218 | alecthomas/chroma | regexp.go | Words | func Words(prefix, suffix string, words ...string) string {
for i, word := range words {
words[i] = regexp.QuoteMeta(word)
}
return prefix + `(` + strings.Join(words, `|`) + `)` + suffix
} | go | func Words(prefix, suffix string, words ...string) string {
for i, word := range words {
words[i] = regexp.QuoteMeta(word)
}
return prefix + `(` + strings.Join(words, `|`) + `)` + suffix
} | [
"func",
"Words",
"(",
"prefix",
",",
"suffix",
"string",
",",
"words",
"...",
"string",
")",
"string",
"{",
"for",
"i",
",",
"word",
":=",
"range",
"words",
"{",
"words",
"[",
"i",
"]",
"=",
"regexp",
".",
"QuoteMeta",
"(",
"word",
")",
"\n",
"}",
... | // Words creates a regex that matches any of the given literal words. | [
"Words",
"creates",
"a",
"regex",
"that",
"matches",
"any",
"of",
"the",
"given",
"literal",
"words",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/regexp.go#L136-L141 |
26,219 | alecthomas/chroma | regexp.go | Tokenise | func Tokenise(lexer Lexer, options *TokeniseOptions, text string) ([]Token, error) {
var out []Token
it, err := lexer.Tokenise(options, text)
if err != nil {
return nil, err
}
for t := it(); t != EOF; t = it() {
out = append(out, t)
}
return out, nil
} | go | func Tokenise(lexer Lexer, options *TokeniseOptions, text string) ([]Token, error) {
var out []Token
it, err := lexer.Tokenise(options, text)
if err != nil {
return nil, err
}
for t := it(); t != EOF; t = it() {
out = append(out, t)
}
return out, nil
} | [
"func",
"Tokenise",
"(",
"lexer",
"Lexer",
",",
"options",
"*",
"TokeniseOptions",
",",
"text",
"string",
")",
"(",
"[",
"]",
"Token",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"Token",
"\n",
"it",
",",
"err",
":=",
"lexer",
".",
"Tokenise",
... | // Tokenise text using lexer, returning tokens as a slice. | [
"Tokenise",
"text",
"using",
"lexer",
"returning",
"tokens",
"as",
"a",
"slice",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/regexp.go#L144-L154 |
26,220 | alecthomas/chroma | regexp.go | Clone | func (r Rules) Clone() Rules {
out := map[string][]Rule{}
for key, rules := range r {
out[key] = make([]Rule, len(rules))
copy(out[key], rules)
}
return out
} | go | func (r Rules) Clone() Rules {
out := map[string][]Rule{}
for key, rules := range r {
out[key] = make([]Rule, len(rules))
copy(out[key], rules)
}
return out
} | [
"func",
"(",
"r",
"Rules",
")",
"Clone",
"(",
")",
"Rules",
"{",
"out",
":=",
"map",
"[",
"string",
"]",
"[",
"]",
"Rule",
"{",
"}",
"\n",
"for",
"key",
",",
"rules",
":=",
"range",
"r",
"{",
"out",
"[",
"key",
"]",
"=",
"make",
"(",
"[",
"... | // Clone returns a clone of the Rules. | [
"Clone",
"returns",
"a",
"clone",
"of",
"the",
"Rules",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/regexp.go#L160-L167 |
26,221 | alecthomas/chroma | regexp.go | MustNewLexer | func MustNewLexer(config *Config, rules Rules) *RegexLexer {
lexer, err := NewLexer(config, rules)
if err != nil {
panic(err)
}
return lexer
} | go | func MustNewLexer(config *Config, rules Rules) *RegexLexer {
lexer, err := NewLexer(config, rules)
if err != nil {
panic(err)
}
return lexer
} | [
"func",
"MustNewLexer",
"(",
"config",
"*",
"Config",
",",
"rules",
"Rules",
")",
"*",
"RegexLexer",
"{",
"lexer",
",",
"err",
":=",
"NewLexer",
"(",
"config",
",",
"rules",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
... | // MustNewLexer creates a new Lexer or panics. | [
"MustNewLexer",
"creates",
"a",
"new",
"Lexer",
"or",
"panics",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/regexp.go#L170-L176 |
26,222 | alecthomas/chroma | regexp.go | NewLexer | func NewLexer(config *Config, rules Rules) (*RegexLexer, error) {
if config == nil {
config = &Config{}
}
if _, ok := rules["root"]; !ok {
return nil, fmt.Errorf("no \"root\" state")
}
compiledRules := map[string][]*CompiledRule{}
for state, rules := range rules {
compiledRules[state] = nil
for _, rule :=... | go | func NewLexer(config *Config, rules Rules) (*RegexLexer, error) {
if config == nil {
config = &Config{}
}
if _, ok := rules["root"]; !ok {
return nil, fmt.Errorf("no \"root\" state")
}
compiledRules := map[string][]*CompiledRule{}
for state, rules := range rules {
compiledRules[state] = nil
for _, rule :=... | [
"func",
"NewLexer",
"(",
"config",
"*",
"Config",
",",
"rules",
"Rules",
")",
"(",
"*",
"RegexLexer",
",",
"error",
")",
"{",
"if",
"config",
"==",
"nil",
"{",
"config",
"=",
"&",
"Config",
"{",
"}",
"\n",
"}",
"\n",
"if",
"_",
",",
"ok",
":=",
... | // NewLexer creates a new regex-based Lexer.
//
// "rules" is a state machine transitition map. Each key is a state. Values are sets of rules
// that match input, optionally modify lexer state, and output tokens. | [
"NewLexer",
"creates",
"a",
"new",
"regex",
"-",
"based",
"Lexer",
".",
"rules",
"is",
"a",
"state",
"machine",
"transitition",
"map",
".",
"Each",
"key",
"is",
"a",
"state",
".",
"Values",
"are",
"sets",
"of",
"rules",
"that",
"match",
"input",
"optiona... | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/regexp.go#L182-L210 |
26,223 | alecthomas/chroma | regexp.go | Trace | func (r *RegexLexer) Trace(trace bool) *RegexLexer {
r.trace = trace
return r
} | go | func (r *RegexLexer) Trace(trace bool) *RegexLexer {
r.trace = trace
return r
} | [
"func",
"(",
"r",
"*",
"RegexLexer",
")",
"Trace",
"(",
"trace",
"bool",
")",
"*",
"RegexLexer",
"{",
"r",
".",
"trace",
"=",
"trace",
"\n",
"return",
"r",
"\n",
"}"
] | // Trace enables debug tracing. | [
"Trace",
"enables",
"debug",
"tracing",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/regexp.go#L213-L216 |
26,224 | alecthomas/chroma | regexp.go | Iterator | func (l *LexerState) Iterator() Token {
for l.Pos < len(l.Text) && len(l.Stack) > 0 {
// Exhaust the iterator stack, if any.
for len(l.iteratorStack) > 0 {
n := len(l.iteratorStack) - 1
t := l.iteratorStack[n]()
if t == EOF {
l.iteratorStack = l.iteratorStack[:n]
continue
}
return t
}
l... | go | func (l *LexerState) Iterator() Token {
for l.Pos < len(l.Text) && len(l.Stack) > 0 {
// Exhaust the iterator stack, if any.
for len(l.iteratorStack) > 0 {
n := len(l.iteratorStack) - 1
t := l.iteratorStack[n]()
if t == EOF {
l.iteratorStack = l.iteratorStack[:n]
continue
}
return t
}
l... | [
"func",
"(",
"l",
"*",
"LexerState",
")",
"Iterator",
"(",
")",
"Token",
"{",
"for",
"l",
".",
"Pos",
"<",
"len",
"(",
"l",
".",
"Text",
")",
"&&",
"len",
"(",
"l",
".",
"Stack",
")",
">",
"0",
"{",
"// Exhaust the iterator stack, if any.",
"for",
... | // Iterator returns the next Token from the lexer. | [
"Iterator",
"returns",
"the",
"next",
"Token",
"from",
"the",
"lexer",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/regexp.go#L258-L326 |
26,225 | alecthomas/chroma | regexp.go | SetAnalyser | func (r *RegexLexer) SetAnalyser(analyser func(text string) float32) *RegexLexer {
r.analyser = analyser
return r
} | go | func (r *RegexLexer) SetAnalyser(analyser func(text string) float32) *RegexLexer {
r.analyser = analyser
return r
} | [
"func",
"(",
"r",
"*",
"RegexLexer",
")",
"SetAnalyser",
"(",
"analyser",
"func",
"(",
"text",
"string",
")",
"float32",
")",
"*",
"RegexLexer",
"{",
"r",
".",
"analyser",
"=",
"analyser",
"\n",
"return",
"r",
"\n",
"}"
] | // SetAnalyser sets the analyser function used to perform content inspection. | [
"SetAnalyser",
"sets",
"the",
"analyser",
"function",
"used",
"to",
"perform",
"content",
"inspection",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/regexp.go#L340-L343 |
26,226 | alecthomas/chroma | iterator.go | Tokens | func (i Iterator) Tokens() []Token {
var out []Token
for t := i(); t != EOF; t = i() {
out = append(out, t)
}
return out
} | go | func (i Iterator) Tokens() []Token {
var out []Token
for t := i(); t != EOF; t = i() {
out = append(out, t)
}
return out
} | [
"func",
"(",
"i",
"Iterator",
")",
"Tokens",
"(",
")",
"[",
"]",
"Token",
"{",
"var",
"out",
"[",
"]",
"Token",
"\n",
"for",
"t",
":=",
"i",
"(",
")",
";",
"t",
"!=",
"EOF",
";",
"t",
"=",
"i",
"(",
")",
"{",
"out",
"=",
"append",
"(",
"o... | // Tokens consumes all tokens from the iterator and returns them as a slice. | [
"Tokens",
"consumes",
"all",
"tokens",
"from",
"the",
"iterator",
"and",
"returns",
"them",
"as",
"a",
"slice",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/iterator.go#L13-L19 |
26,227 | alecthomas/chroma | iterator.go | Concaterator | func Concaterator(iterators ...Iterator) Iterator {
return func() Token {
for len(iterators) > 0 {
t := iterators[0]()
if t != EOF {
return t
}
iterators = iterators[1:]
}
return EOF
}
} | go | func Concaterator(iterators ...Iterator) Iterator {
return func() Token {
for len(iterators) > 0 {
t := iterators[0]()
if t != EOF {
return t
}
iterators = iterators[1:]
}
return EOF
}
} | [
"func",
"Concaterator",
"(",
"iterators",
"...",
"Iterator",
")",
"Iterator",
"{",
"return",
"func",
"(",
")",
"Token",
"{",
"for",
"len",
"(",
"iterators",
")",
">",
"0",
"{",
"t",
":=",
"iterators",
"[",
"0",
"]",
"(",
")",
"\n",
"if",
"t",
"!=",... | // Concaterator concatenates tokens from a series of iterators. | [
"Concaterator",
"concatenates",
"tokens",
"from",
"a",
"series",
"of",
"iterators",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/iterator.go#L22-L33 |
26,228 | alecthomas/chroma | iterator.go | Literator | func Literator(tokens ...Token) Iterator {
return func() Token {
if len(tokens) == 0 {
return EOF
}
token := tokens[0]
tokens = tokens[1:]
return token
}
} | go | func Literator(tokens ...Token) Iterator {
return func() Token {
if len(tokens) == 0 {
return EOF
}
token := tokens[0]
tokens = tokens[1:]
return token
}
} | [
"func",
"Literator",
"(",
"tokens",
"...",
"Token",
")",
"Iterator",
"{",
"return",
"func",
"(",
")",
"Token",
"{",
"if",
"len",
"(",
"tokens",
")",
"==",
"0",
"{",
"return",
"EOF",
"\n",
"}",
"\n",
"token",
":=",
"tokens",
"[",
"0",
"]",
"\n",
"... | // Literator converts a sequence of literal Tokens into an Iterator. | [
"Literator",
"converts",
"a",
"sequence",
"of",
"literal",
"Tokens",
"into",
"an",
"Iterator",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/iterator.go#L36-L45 |
26,229 | alecthomas/chroma | iterator.go | SplitTokensIntoLines | func SplitTokensIntoLines(tokens []Token) (out [][]Token) {
var line []Token // nolint: prealloc
for _, token := range tokens {
for strings.Contains(token.Value, "\n") {
parts := strings.SplitAfterN(token.Value, "\n", 2)
// Token becomes the tail.
token.Value = parts[1]
// Append the head to the line a... | go | func SplitTokensIntoLines(tokens []Token) (out [][]Token) {
var line []Token // nolint: prealloc
for _, token := range tokens {
for strings.Contains(token.Value, "\n") {
parts := strings.SplitAfterN(token.Value, "\n", 2)
// Token becomes the tail.
token.Value = parts[1]
// Append the head to the line a... | [
"func",
"SplitTokensIntoLines",
"(",
"tokens",
"[",
"]",
"Token",
")",
"(",
"out",
"[",
"]",
"[",
"]",
"Token",
")",
"{",
"var",
"line",
"[",
"]",
"Token",
"// nolint: prealloc",
"\n",
"for",
"_",
",",
"token",
":=",
"range",
"tokens",
"{",
"for",
"s... | // SplitTokensIntoLines splits tokens containing newlines in two. | [
"SplitTokensIntoLines",
"splits",
"tokens",
"containing",
"newlines",
"in",
"two",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/iterator.go#L48-L76 |
26,230 | alecthomas/chroma | lexers/internal/api.go | Names | func Names(withAliases bool) []string {
out := []string{}
for _, lexer := range Registry.Lexers {
config := lexer.Config()
out = append(out, config.Name)
if withAliases {
out = append(out, config.Aliases...)
}
}
sort.Strings(out)
return out
} | go | func Names(withAliases bool) []string {
out := []string{}
for _, lexer := range Registry.Lexers {
config := lexer.Config()
out = append(out, config.Name)
if withAliases {
out = append(out, config.Aliases...)
}
}
sort.Strings(out)
return out
} | [
"func",
"Names",
"(",
"withAliases",
"bool",
")",
"[",
"]",
"string",
"{",
"out",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"lexer",
":=",
"range",
"Registry",
".",
"Lexers",
"{",
"config",
":=",
"lexer",
".",
"Config",
"(",
")",
... | // Names of all lexers, optionally including aliases. | [
"Names",
"of",
"all",
"lexers",
"optionally",
"including",
"aliases",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/lexers/internal/api.go#L24-L35 |
26,231 | alecthomas/chroma | lexers/internal/api.go | Get | func Get(name string) chroma.Lexer {
candidates := chroma.PrioritisedLexers{}
if lexer := Registry.byName[name]; lexer != nil {
candidates = append(candidates, lexer)
}
if lexer := Registry.byAlias[name]; lexer != nil {
candidates = append(candidates, lexer)
}
if lexer := Registry.byName[strings.ToLower(name)... | go | func Get(name string) chroma.Lexer {
candidates := chroma.PrioritisedLexers{}
if lexer := Registry.byName[name]; lexer != nil {
candidates = append(candidates, lexer)
}
if lexer := Registry.byAlias[name]; lexer != nil {
candidates = append(candidates, lexer)
}
if lexer := Registry.byName[strings.ToLower(name)... | [
"func",
"Get",
"(",
"name",
"string",
")",
"chroma",
".",
"Lexer",
"{",
"candidates",
":=",
"chroma",
".",
"PrioritisedLexers",
"{",
"}",
"\n",
"if",
"lexer",
":=",
"Registry",
".",
"byName",
"[",
"name",
"]",
";",
"lexer",
"!=",
"nil",
"{",
"candidate... | // Get a Lexer by name, alias or file extension. | [
"Get",
"a",
"Lexer",
"by",
"name",
"alias",
"or",
"file",
"extension",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/lexers/internal/api.go#L38-L65 |
26,232 | alecthomas/chroma | lexers/internal/api.go | MatchMimeType | func MatchMimeType(mimeType string) chroma.Lexer {
matched := chroma.PrioritisedLexers{}
for _, l := range Registry.Lexers {
for _, lmt := range l.Config().MimeTypes {
if mimeType == lmt {
matched = append(matched, l)
}
}
}
if len(matched) != 0 {
sort.Sort(matched)
return matched[0]
}
return nil... | go | func MatchMimeType(mimeType string) chroma.Lexer {
matched := chroma.PrioritisedLexers{}
for _, l := range Registry.Lexers {
for _, lmt := range l.Config().MimeTypes {
if mimeType == lmt {
matched = append(matched, l)
}
}
}
if len(matched) != 0 {
sort.Sort(matched)
return matched[0]
}
return nil... | [
"func",
"MatchMimeType",
"(",
"mimeType",
"string",
")",
"chroma",
".",
"Lexer",
"{",
"matched",
":=",
"chroma",
".",
"PrioritisedLexers",
"{",
"}",
"\n",
"for",
"_",
",",
"l",
":=",
"range",
"Registry",
".",
"Lexers",
"{",
"for",
"_",
",",
"lmt",
":="... | // MatchMimeType attempts to find a lexer for the given MIME type. | [
"MatchMimeType",
"attempts",
"to",
"find",
"a",
"lexer",
"for",
"the",
"given",
"MIME",
"type",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/lexers/internal/api.go#L68-L82 |
26,233 | alecthomas/chroma | lexers/internal/api.go | Match | func Match(filename string) chroma.Lexer {
filename = filepath.Base(filename)
matched := chroma.PrioritisedLexers{}
// First, try primary filename matches.
for _, lexer := range Registry.Lexers {
config := lexer.Config()
for _, glob := range config.Filenames {
if fnmatch.Match(glob, filename, 0) {
matche... | go | func Match(filename string) chroma.Lexer {
filename = filepath.Base(filename)
matched := chroma.PrioritisedLexers{}
// First, try primary filename matches.
for _, lexer := range Registry.Lexers {
config := lexer.Config()
for _, glob := range config.Filenames {
if fnmatch.Match(glob, filename, 0) {
matche... | [
"func",
"Match",
"(",
"filename",
"string",
")",
"chroma",
".",
"Lexer",
"{",
"filename",
"=",
"filepath",
".",
"Base",
"(",
"filename",
")",
"\n",
"matched",
":=",
"chroma",
".",
"PrioritisedLexers",
"{",
"}",
"\n",
"// First, try primary filename matches.",
... | // Match returns the first lexer matching filename. | [
"Match",
"returns",
"the",
"first",
"lexer",
"matching",
"filename",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/lexers/internal/api.go#L85-L116 |
26,234 | alecthomas/chroma | lexers/internal/api.go | Analyse | func Analyse(text string) chroma.Lexer {
var picked chroma.Lexer
highest := float32(0.0)
for _, lexer := range Registry.Lexers {
if analyser, ok := lexer.(chroma.Analyser); ok {
weight := analyser.AnalyseText(text)
if weight > highest {
picked = lexer
highest = weight
}
}
}
return picked
} | go | func Analyse(text string) chroma.Lexer {
var picked chroma.Lexer
highest := float32(0.0)
for _, lexer := range Registry.Lexers {
if analyser, ok := lexer.(chroma.Analyser); ok {
weight := analyser.AnalyseText(text)
if weight > highest {
picked = lexer
highest = weight
}
}
}
return picked
} | [
"func",
"Analyse",
"(",
"text",
"string",
")",
"chroma",
".",
"Lexer",
"{",
"var",
"picked",
"chroma",
".",
"Lexer",
"\n",
"highest",
":=",
"float32",
"(",
"0.0",
")",
"\n",
"for",
"_",
",",
"lexer",
":=",
"range",
"Registry",
".",
"Lexers",
"{",
"if... | // Analyse text content and return the "best" lexer.. | [
"Analyse",
"text",
"content",
"and",
"return",
"the",
"best",
"lexer",
".."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/lexers/internal/api.go#L119-L132 |
26,235 | alecthomas/chroma | lexers/internal/api.go | Register | func Register(lexer chroma.Lexer) chroma.Lexer {
config := lexer.Config()
Registry.byName[config.Name] = lexer
Registry.byName[strings.ToLower(config.Name)] = lexer
for _, alias := range config.Aliases {
Registry.byAlias[alias] = lexer
Registry.byAlias[strings.ToLower(alias)] = lexer
}
Registry.Lexers = appen... | go | func Register(lexer chroma.Lexer) chroma.Lexer {
config := lexer.Config()
Registry.byName[config.Name] = lexer
Registry.byName[strings.ToLower(config.Name)] = lexer
for _, alias := range config.Aliases {
Registry.byAlias[alias] = lexer
Registry.byAlias[strings.ToLower(alias)] = lexer
}
Registry.Lexers = appen... | [
"func",
"Register",
"(",
"lexer",
"chroma",
".",
"Lexer",
")",
"chroma",
".",
"Lexer",
"{",
"config",
":=",
"lexer",
".",
"Config",
"(",
")",
"\n",
"Registry",
".",
"byName",
"[",
"config",
".",
"Name",
"]",
"=",
"lexer",
"\n",
"Registry",
".",
"byNa... | // Register a Lexer with the global registry. | [
"Register",
"a",
"Lexer",
"with",
"the",
"global",
"registry",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/lexers/internal/api.go#L135-L145 |
26,236 | alecthomas/chroma | mutators.go | Mutators | func Mutators(modifiers ...Mutator) MutatorFunc {
return func(state *LexerState) error {
for _, modifier := range modifiers {
if err := modifier.Mutate(state); err != nil {
return err
}
}
return nil
}
} | go | func Mutators(modifiers ...Mutator) MutatorFunc {
return func(state *LexerState) error {
for _, modifier := range modifiers {
if err := modifier.Mutate(state); err != nil {
return err
}
}
return nil
}
} | [
"func",
"Mutators",
"(",
"modifiers",
"...",
"Mutator",
")",
"MutatorFunc",
"{",
"return",
"func",
"(",
"state",
"*",
"LexerState",
")",
"error",
"{",
"for",
"_",
",",
"modifier",
":=",
"range",
"modifiers",
"{",
"if",
"err",
":=",
"modifier",
".",
"Muta... | // Mutators applies a set of Mutators in order. | [
"Mutators",
"applies",
"a",
"set",
"of",
"Mutators",
"in",
"order",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/mutators.go#L27-L36 |
26,237 | alecthomas/chroma | mutators.go | Push | func Push(states ...string) MutatorFunc {
return func(s *LexerState) error {
if len(states) == 0 {
s.Stack = append(s.Stack, s.State)
} else {
for _, state := range states {
if state == "#pop" {
s.Stack = s.Stack[:len(s.Stack)-1]
} else {
s.Stack = append(s.Stack, state)
}
}
}
re... | go | func Push(states ...string) MutatorFunc {
return func(s *LexerState) error {
if len(states) == 0 {
s.Stack = append(s.Stack, s.State)
} else {
for _, state := range states {
if state == "#pop" {
s.Stack = s.Stack[:len(s.Stack)-1]
} else {
s.Stack = append(s.Stack, state)
}
}
}
re... | [
"func",
"Push",
"(",
"states",
"...",
"string",
")",
"MutatorFunc",
"{",
"return",
"func",
"(",
"s",
"*",
"LexerState",
")",
"error",
"{",
"if",
"len",
"(",
"states",
")",
"==",
"0",
"{",
"s",
".",
"Stack",
"=",
"append",
"(",
"s",
".",
"Stack",
... | // Push states onto the stack. | [
"Push",
"states",
"onto",
"the",
"stack",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/mutators.go#L91-L106 |
26,238 | alecthomas/chroma | mutators.go | Pop | func Pop(n int) MutatorFunc {
return func(state *LexerState) error {
if len(state.Stack) == 0 {
return fmt.Errorf("nothing to pop")
}
state.Stack = state.Stack[:len(state.Stack)-n]
return nil
}
} | go | func Pop(n int) MutatorFunc {
return func(state *LexerState) error {
if len(state.Stack) == 0 {
return fmt.Errorf("nothing to pop")
}
state.Stack = state.Stack[:len(state.Stack)-n]
return nil
}
} | [
"func",
"Pop",
"(",
"n",
"int",
")",
"MutatorFunc",
"{",
"return",
"func",
"(",
"state",
"*",
"LexerState",
")",
"error",
"{",
"if",
"len",
"(",
"state",
".",
"Stack",
")",
"==",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n... | // Pop state from the stack when rule matches. | [
"Pop",
"state",
"from",
"the",
"stack",
"when",
"rule",
"matches",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/mutators.go#L109-L117 |
26,239 | alecthomas/chroma | mutators.go | Stringify | func Stringify(tokens ...Token) string {
out := []string{}
for _, t := range tokens {
out = append(out, t.Value)
}
return strings.Join(out, "")
} | go | func Stringify(tokens ...Token) string {
out := []string{}
for _, t := range tokens {
out = append(out, t.Value)
}
return strings.Join(out, "")
} | [
"func",
"Stringify",
"(",
"tokens",
"...",
"Token",
")",
"string",
"{",
"out",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"t",
":=",
"range",
"tokens",
"{",
"out",
"=",
"append",
"(",
"out",
",",
"t",
".",
"Value",
")",
"\n",
"}... | // Stringify returns the raw string for a set of tokens. | [
"Stringify",
"returns",
"the",
"raw",
"string",
"for",
"a",
"set",
"of",
"tokens",
"."
] | 1327f9145ea6a0c6e7651d973270190a814bd92b | https://github.com/alecthomas/chroma/blob/1327f9145ea6a0c6e7651d973270190a814bd92b/mutators.go#L125-L131 |
26,240 | stripe/stripe-go | issuing_transaction.go | UnmarshalJSON | func (i *IssuingTransaction) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingTransaction IssuingTransaction
var v issuingTransaction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingTransaction(v)
return nil
} | go | func (i *IssuingTransaction) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingTransaction IssuingTransaction
var v issuingTransaction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingTransaction(v)
return nil
} | [
"func",
"(",
"i",
"*",
"IssuingTransaction",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",... | // UnmarshalJSON handles deserialization of an IssuingTransaction.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"IssuingTransaction",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expande... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/issuing_transaction.go#L58-L72 |
26,241 | stripe/stripe-go | paymentintent/client.go | Cancel | func Cancel(id string, params *stripe.PaymentIntentCancelParams) (*stripe.PaymentIntent, error) {
return getC().Cancel(id, params)
} | go | func Cancel(id string, params *stripe.PaymentIntentCancelParams) (*stripe.PaymentIntent, error) {
return getC().Cancel(id, params)
} | [
"func",
"Cancel",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"PaymentIntentCancelParams",
")",
"(",
"*",
"stripe",
".",
"PaymentIntent",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Cancel",
"(",
"id",
",",
"params",
")",
"\n"... | // Cancel cancels a payment intent. | [
"Cancel",
"cancels",
"a",
"payment",
"intent",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentintent/client.go#L58-L60 |
26,242 | stripe/stripe-go | paymentintent/client.go | Capture | func Capture(id string, params *stripe.PaymentIntentCaptureParams) (*stripe.PaymentIntent, error) {
return getC().Capture(id, params)
} | go | func Capture(id string, params *stripe.PaymentIntentCaptureParams) (*stripe.PaymentIntent, error) {
return getC().Capture(id, params)
} | [
"func",
"Capture",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"PaymentIntentCaptureParams",
")",
"(",
"*",
"stripe",
".",
"PaymentIntent",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Capture",
"(",
"id",
",",
"params",
")",
"... | // Capture captures a payment intent. | [
"Capture",
"captures",
"a",
"payment",
"intent",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentintent/client.go#L71-L73 |
26,243 | stripe/stripe-go | paymentintent/client.go | Confirm | func Confirm(id string, params *stripe.PaymentIntentConfirmParams) (*stripe.PaymentIntent, error) {
return getC().Confirm(id, params)
} | go | func Confirm(id string, params *stripe.PaymentIntentConfirmParams) (*stripe.PaymentIntent, error) {
return getC().Confirm(id, params)
} | [
"func",
"Confirm",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"PaymentIntentConfirmParams",
")",
"(",
"*",
"stripe",
".",
"PaymentIntent",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Confirm",
"(",
"id",
",",
"params",
")",
"... | // Confirm confirms a payment intent. | [
"Confirm",
"confirms",
"a",
"payment",
"intent",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentintent/client.go#L84-L86 |
26,244 | stripe/stripe-go | payout.go | UnmarshalJSON | func (p *Payout) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type payout Payout
var v payout
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = Payout(v)
return nil
} | go | func (p *Payout) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type payout Payout
var v payout
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*p = Payout(v)
return nil
} | [
"func",
"(",
"p",
"*",
"Payout",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"p",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\... | // UnmarshalJSON handles deserialization of a Payout.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Payout",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/payout.go#L142-L156 |
26,245 | stripe/stripe-go | payout.go | UnmarshalJSON | func (d *PayoutDestination) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
d.ID = id
return nil
}
type payoutDestination PayoutDestination
var v payoutDestination
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*d = PayoutDestination(v)
switch d.Type {
... | go | func (d *PayoutDestination) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
d.ID = id
return nil
}
type payoutDestination PayoutDestination
var v payoutDestination
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*d = PayoutDestination(v)
switch d.Type {
... | [
"func",
"(",
"d",
"*",
"PayoutDestination",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"d",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
... | // UnmarshalJSON handles deserialization of a PayoutDestination.
// This custom unmarshaling is needed because the specific
// type of destination it refers to is specified in the JSON | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"PayoutDestination",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"specific",
"type",
"of",
"destination",
"it",
"refers",
"to",
"is",
"specified",
"in",
"the",
"JSON"
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/payout.go#L161-L184 |
26,246 | stripe/stripe-go | plan/client.go | Get | func (c Client) Get(id string, params *stripe.PlanParams) (*stripe.Plan, error) {
path := stripe.FormatURLPath("/v1/plans/%s", id)
plan := &stripe.Plan{}
err := c.B.Call(http.MethodGet, path, c.Key, params, plan)
return plan, err
} | go | func (c Client) Get(id string, params *stripe.PlanParams) (*stripe.Plan, error) {
path := stripe.FormatURLPath("/v1/plans/%s", id)
plan := &stripe.Plan{}
err := c.B.Call(http.MethodGet, path, c.Key, params, plan)
return plan, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"PlanParams",
")",
"(",
"*",
"stripe",
".",
"Plan",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"id",
... | // Get returns the details of a plan. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"plan",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/plan/client.go#L35-L40 |
26,247 | stripe/stripe-go | plan/client.go | Update | func Update(id string, params *stripe.PlanParams) (*stripe.Plan, error) {
return getC().Update(id, params)
} | go | func Update(id string, params *stripe.PlanParams) (*stripe.Plan, error) {
return getC().Update(id, params)
} | [
"func",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"PlanParams",
")",
"(",
"*",
"stripe",
".",
"Plan",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Update",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Update updates a plan's properties. | [
"Update",
"updates",
"a",
"plan",
"s",
"properties",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/plan/client.go#L43-L45 |
26,248 | stripe/stripe-go | stripe.go | formatUserAgent | func (a *AppInfo) formatUserAgent() string {
str := a.Name
if a.Version != "" {
str += "/" + a.Version
}
if a.URL != "" {
str += " (" + a.URL + ")"
}
return str
} | go | func (a *AppInfo) formatUserAgent() string {
str := a.Name
if a.Version != "" {
str += "/" + a.Version
}
if a.URL != "" {
str += " (" + a.URL + ")"
}
return str
} | [
"func",
"(",
"a",
"*",
"AppInfo",
")",
"formatUserAgent",
"(",
")",
"string",
"{",
"str",
":=",
"a",
".",
"Name",
"\n",
"if",
"a",
".",
"Version",
"!=",
"\"",
"\"",
"{",
"str",
"+=",
"\"",
"\"",
"+",
"a",
".",
"Version",
"\n",
"}",
"\n",
"if",
... | // formatUserAgent formats an AppInfo in a way that's suitable to be appended
// to a User-Agent string. Note that this format is shared between all
// libraries so if it's changed, it should be changed everywhere. | [
"formatUserAgent",
"formats",
"an",
"AppInfo",
"in",
"a",
"way",
"that",
"s",
"suitable",
"to",
"be",
"appended",
"to",
"a",
"User",
"-",
"Agent",
"string",
".",
"Note",
"that",
"this",
"format",
"is",
"shared",
"between",
"all",
"libraries",
"so",
"if",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L82-L91 |
26,249 | stripe/stripe-go | stripe.go | Call | func (s *BackendImplementation) Call(method, path, key string, params ParamsContainer, v interface{}) error {
var body *form.Values
var commonParams *Params
if params != nil {
// This is a little unfortunate, but Go makes it impossible to compare
// an interface value to nil without the use of the reflect packa... | go | func (s *BackendImplementation) Call(method, path, key string, params ParamsContainer, v interface{}) error {
var body *form.Values
var commonParams *Params
if params != nil {
// This is a little unfortunate, but Go makes it impossible to compare
// an interface value to nil without the use of the reflect packa... | [
"func",
"(",
"s",
"*",
"BackendImplementation",
")",
"Call",
"(",
"method",
",",
"path",
",",
"key",
"string",
",",
"params",
"ParamsContainer",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"body",
"*",
"form",
".",
"Values",
"\n",
"var",... | // Call is the Backend.Call implementation for invoking Stripe APIs. | [
"Call",
"is",
"the",
"Backend",
".",
"Call",
"implementation",
"for",
"invoking",
"Stripe",
"APIs",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L182-L205 |
26,250 | stripe/stripe-go | stripe.go | CallMultipart | func (s *BackendImplementation) CallMultipart(method, path, key, boundary string, body *bytes.Buffer, params *Params, v interface{}) error {
contentType := "multipart/form-data; boundary=" + boundary
req, err := s.NewRequest(method, path, key, contentType, params)
if err != nil {
return err
}
if err := s.Do(re... | go | func (s *BackendImplementation) CallMultipart(method, path, key, boundary string, body *bytes.Buffer, params *Params, v interface{}) error {
contentType := "multipart/form-data; boundary=" + boundary
req, err := s.NewRequest(method, path, key, contentType, params)
if err != nil {
return err
}
if err := s.Do(re... | [
"func",
"(",
"s",
"*",
"BackendImplementation",
")",
"CallMultipart",
"(",
"method",
",",
"path",
",",
"key",
",",
"boundary",
"string",
",",
"body",
"*",
"bytes",
".",
"Buffer",
",",
"params",
"*",
"Params",
",",
"v",
"interface",
"{",
"}",
")",
"erro... | // CallMultipart is the Backend.CallMultipart implementation for invoking Stripe APIs. | [
"CallMultipart",
"is",
"the",
"Backend",
".",
"CallMultipart",
"implementation",
"for",
"invoking",
"Stripe",
"APIs",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L208-L221 |
26,251 | stripe/stripe-go | stripe.go | CallRaw | func (s *BackendImplementation) CallRaw(method, path, key string, form *form.Values, params *Params, v interface{}) error {
var body string
if form != nil && !form.Empty() {
body = form.Encode()
// On `GET`, move the payload into the URL
if method == http.MethodGet {
path += "?" + body
body = ""
}
}
... | go | func (s *BackendImplementation) CallRaw(method, path, key string, form *form.Values, params *Params, v interface{}) error {
var body string
if form != nil && !form.Empty() {
body = form.Encode()
// On `GET`, move the payload into the URL
if method == http.MethodGet {
path += "?" + body
body = ""
}
}
... | [
"func",
"(",
"s",
"*",
"BackendImplementation",
")",
"CallRaw",
"(",
"method",
",",
"path",
",",
"key",
"string",
",",
"form",
"*",
"form",
".",
"Values",
",",
"params",
"*",
"Params",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"body"... | // CallRaw is the implementation for invoking Stripe APIs internally without a backend. | [
"CallRaw",
"is",
"the",
"implementation",
"for",
"invoking",
"Stripe",
"APIs",
"internally",
"without",
"a",
"backend",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L224-L247 |
26,252 | stripe/stripe-go | stripe.go | NewRequest | func (s *BackendImplementation) NewRequest(method, path, key, contentType string, params *Params) (*http.Request, error) {
if !strings.HasPrefix(path, "/") {
path = "/" + path
}
path = s.URL + path
// Body is set later by `Do`.
req, err := http.NewRequest(method, path, nil)
if err != nil {
s.LeveledLogger.E... | go | func (s *BackendImplementation) NewRequest(method, path, key, contentType string, params *Params) (*http.Request, error) {
if !strings.HasPrefix(path, "/") {
path = "/" + path
}
path = s.URL + path
// Body is set later by `Do`.
req, err := http.NewRequest(method, path, nil)
if err != nil {
s.LeveledLogger.E... | [
"func",
"(",
"s",
"*",
"BackendImplementation",
")",
"NewRequest",
"(",
"method",
",",
"path",
",",
"key",
",",
"contentType",
"string",
",",
"params",
"*",
"Params",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"if",
"!",
"strings",
... | // NewRequest is used by Call to generate an http.Request. It handles encoding
// parameters and attaching the appropriate headers. | [
"NewRequest",
"is",
"used",
"by",
"Call",
"to",
"generate",
"an",
"http",
".",
"Request",
".",
"It",
"handles",
"encoding",
"parameters",
"and",
"attaching",
"the",
"appropriate",
"headers",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L251-L302 |
26,253 | stripe/stripe-go | stripe.go | ResponseToError | func (s *BackendImplementation) ResponseToError(res *http.Response, resBody []byte) error {
var raw rawError
if err := s.UnmarshalJSONVerbose(res.StatusCode, resBody, &raw); err != nil {
return err
}
// no error in resBody
if raw.E == nil {
err := errors.New(string(resBody))
s.LeveledLogger.Errorf("Unparsab... | go | func (s *BackendImplementation) ResponseToError(res *http.Response, resBody []byte) error {
var raw rawError
if err := s.UnmarshalJSONVerbose(res.StatusCode, resBody, &raw); err != nil {
return err
}
// no error in resBody
if raw.E == nil {
err := errors.New(string(resBody))
s.LeveledLogger.Errorf("Unparsab... | [
"func",
"(",
"s",
"*",
"BackendImplementation",
")",
"ResponseToError",
"(",
"res",
"*",
"http",
".",
"Response",
",",
"resBody",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"raw",
"rawError",
"\n",
"if",
"err",
":=",
"s",
".",
"UnmarshalJSONVerbose",
"(... | // ResponseToError converts a stripe response to an Error. | [
"ResponseToError",
"converts",
"a",
"stripe",
"response",
"to",
"an",
"Error",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L451-L491 |
26,254 | stripe/stripe-go | stripe.go | UnmarshalJSONVerbose | func (s *BackendImplementation) UnmarshalJSONVerbose(statusCode int, body []byte, v interface{}) error {
err := json.Unmarshal(body, v)
if err != nil {
// If we got invalid JSON back then something totally unexpected is
// happening (caused by a bug on the server side). Put a sample of the
// response body into... | go | func (s *BackendImplementation) UnmarshalJSONVerbose(statusCode int, body []byte, v interface{}) error {
err := json.Unmarshal(body, v)
if err != nil {
// If we got invalid JSON back then something totally unexpected is
// happening (caused by a bug on the server side). Put a sample of the
// response body into... | [
"func",
"(",
"s",
"*",
"BackendImplementation",
")",
"UnmarshalJSONVerbose",
"(",
"statusCode",
"int",
",",
"body",
"[",
"]",
"byte",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"body",
",",
"v",
")",... | // UnmarshalJSONVerbose unmarshals JSON, but in case of a failure logs and
// produces a more descriptive error. | [
"UnmarshalJSONVerbose",
"unmarshals",
"JSON",
"but",
"in",
"case",
"of",
"a",
"failure",
"logs",
"and",
"produces",
"a",
"more",
"descriptive",
"error",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L511-L533 |
26,255 | stripe/stripe-go | stripe.go | shouldRetry | func (s *BackendImplementation) shouldRetry(err error, resp *http.Response, numRetries int) bool {
if numRetries >= s.MaxNetworkRetries {
return false
}
if err != nil {
return true
}
if resp.StatusCode == http.StatusConflict {
return true
}
return false
} | go | func (s *BackendImplementation) shouldRetry(err error, resp *http.Response, numRetries int) bool {
if numRetries >= s.MaxNetworkRetries {
return false
}
if err != nil {
return true
}
if resp.StatusCode == http.StatusConflict {
return true
}
return false
} | [
"func",
"(",
"s",
"*",
"BackendImplementation",
")",
"shouldRetry",
"(",
"err",
"error",
",",
"resp",
"*",
"http",
".",
"Response",
",",
"numRetries",
"int",
")",
"bool",
"{",
"if",
"numRetries",
">=",
"s",
".",
"MaxNetworkRetries",
"{",
"return",
"false",... | // Checks if an error is a problem that we should retry on. This includes both
// socket errors that may represent an intermittent problem and some special
// HTTP statuses. | [
"Checks",
"if",
"an",
"error",
"is",
"a",
"problem",
"that",
"we",
"should",
"retry",
"on",
".",
"This",
"includes",
"both",
"socket",
"errors",
"that",
"may",
"represent",
"an",
"intermittent",
"problem",
"and",
"some",
"special",
"HTTP",
"statuses",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L538-L551 |
26,256 | stripe/stripe-go | stripe.go | BoolSlice | func BoolSlice(v []bool) []*bool {
out := make([]*bool, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | go | func BoolSlice(v []bool) []*bool {
out := make([]*bool, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | [
"func",
"BoolSlice",
"(",
"v",
"[",
"]",
"bool",
")",
"[",
"]",
"*",
"bool",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"*",
"bool",
",",
"len",
"(",
"v",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"v",
"{",
"out",
"[",
"i",
"]",
"=",
"&",
... | // BoolSlice returns a slice of bool pointers given a slice of bools. | [
"BoolSlice",
"returns",
"a",
"slice",
"of",
"bool",
"pointers",
"given",
"a",
"slice",
"of",
"bools",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L610-L616 |
26,257 | stripe/stripe-go | stripe.go | Float64Slice | func Float64Slice(v []float64) []*float64 {
out := make([]*float64, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | go | func Float64Slice(v []float64) []*float64 {
out := make([]*float64, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | [
"func",
"Float64Slice",
"(",
"v",
"[",
"]",
"float64",
")",
"[",
"]",
"*",
"float64",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"*",
"float64",
",",
"len",
"(",
"v",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"v",
"{",
"out",
"[",
"i",
"]",
... | // Float64Slice returns a slice of float64 pointers given a slice of float64s. | [
"Float64Slice",
"returns",
"a",
"slice",
"of",
"float64",
"pointers",
"given",
"a",
"slice",
"of",
"float64s",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L633-L639 |
26,258 | stripe/stripe-go | stripe.go | GetBackend | func GetBackend(backendType SupportedBackend) Backend {
var backend Backend
backends.mu.RLock()
switch backendType {
case APIBackend:
backend = backends.API
case UploadsBackend:
backend = backends.Uploads
}
backends.mu.RUnlock()
if backend != nil {
return backend
}
backend = GetBackendWithConfig(
ba... | go | func GetBackend(backendType SupportedBackend) Backend {
var backend Backend
backends.mu.RLock()
switch backendType {
case APIBackend:
backend = backends.API
case UploadsBackend:
backend = backends.Uploads
}
backends.mu.RUnlock()
if backend != nil {
return backend
}
backend = GetBackendWithConfig(
ba... | [
"func",
"GetBackend",
"(",
"backendType",
"SupportedBackend",
")",
"Backend",
"{",
"var",
"backend",
"Backend",
"\n\n",
"backends",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"switch",
"backendType",
"{",
"case",
"APIBackend",
":",
"backend",
"=",
"backends",
... | // GetBackend returns one of the library's supported backends based off of the
// given argument.
//
// It returns an existing default backend if one's already been created. | [
"GetBackend",
"returns",
"one",
"of",
"the",
"library",
"s",
"supported",
"backends",
"based",
"off",
"of",
"the",
"given",
"argument",
".",
"It",
"returns",
"an",
"existing",
"default",
"backend",
"if",
"one",
"s",
"already",
"been",
"created",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L666-L704 |
26,259 | stripe/stripe-go | stripe.go | GetBackendWithConfig | func GetBackendWithConfig(backendType SupportedBackend, config *BackendConfig) Backend {
if config.HTTPClient == nil {
config.HTTPClient = httpClient
}
if config.LeveledLogger == nil {
if config.Logger == nil {
config.Logger = Logger
}
config.LeveledLogger = &leveledLoggerPrintferShim{
level: printf... | go | func GetBackendWithConfig(backendType SupportedBackend, config *BackendConfig) Backend {
if config.HTTPClient == nil {
config.HTTPClient = httpClient
}
if config.LeveledLogger == nil {
if config.Logger == nil {
config.Logger = Logger
}
config.LeveledLogger = &leveledLoggerPrintferShim{
level: printf... | [
"func",
"GetBackendWithConfig",
"(",
"backendType",
"SupportedBackend",
",",
"config",
"*",
"BackendConfig",
")",
"Backend",
"{",
"if",
"config",
".",
"HTTPClient",
"==",
"nil",
"{",
"config",
".",
"HTTPClient",
"=",
"httpClient",
"\n",
"}",
"\n\n",
"if",
"con... | // GetBackendWithConfig is the same as GetBackend except that it can be given a
// configuration struct that will configure certain aspects of the backend
// that's return. | [
"GetBackendWithConfig",
"is",
"the",
"same",
"as",
"GetBackend",
"except",
"that",
"it",
"can",
"be",
"given",
"a",
"configuration",
"struct",
"that",
"will",
"configure",
"certain",
"aspects",
"of",
"the",
"backend",
"that",
"s",
"return",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L709-L746 |
26,260 | stripe/stripe-go | stripe.go | Int64Slice | func Int64Slice(v []int64) []*int64 {
out := make([]*int64, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | go | func Int64Slice(v []int64) []*int64 {
out := make([]*int64, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | [
"func",
"Int64Slice",
"(",
"v",
"[",
"]",
"int64",
")",
"[",
"]",
"*",
"int64",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"*",
"int64",
",",
"len",
"(",
"v",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"v",
"{",
"out",
"[",
"i",
"]",
"=",
"... | // Int64Slice returns a slice of int64 pointers given a slice of int64s. | [
"Int64Slice",
"returns",
"a",
"slice",
"of",
"int64",
"pointers",
"given",
"a",
"slice",
"of",
"int64s",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L763-L769 |
26,261 | stripe/stripe-go | stripe.go | NewBackends | func NewBackends(httpClient *http.Client) *Backends {
apiConfig := &BackendConfig{HTTPClient: httpClient}
uploadConfig := &BackendConfig{HTTPClient: httpClient}
return &Backends{
API: GetBackendWithConfig(APIBackend, apiConfig),
Uploads: GetBackendWithConfig(UploadsBackend, uploadConfig),
}
} | go | func NewBackends(httpClient *http.Client) *Backends {
apiConfig := &BackendConfig{HTTPClient: httpClient}
uploadConfig := &BackendConfig{HTTPClient: httpClient}
return &Backends{
API: GetBackendWithConfig(APIBackend, apiConfig),
Uploads: GetBackendWithConfig(UploadsBackend, uploadConfig),
}
} | [
"func",
"NewBackends",
"(",
"httpClient",
"*",
"http",
".",
"Client",
")",
"*",
"Backends",
"{",
"apiConfig",
":=",
"&",
"BackendConfig",
"{",
"HTTPClient",
":",
"httpClient",
"}",
"\n",
"uploadConfig",
":=",
"&",
"BackendConfig",
"{",
"HTTPClient",
":",
"ht... | // NewBackends creates a new set of backends with the given HTTP client. You
// should only need to use this for testing purposes or on App Engine. | [
"NewBackends",
"creates",
"a",
"new",
"set",
"of",
"backends",
"with",
"the",
"given",
"HTTP",
"client",
".",
"You",
"should",
"only",
"need",
"to",
"use",
"this",
"for",
"testing",
"purposes",
"or",
"on",
"App",
"Engine",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L773-L780 |
26,262 | stripe/stripe-go | stripe.go | SetAppInfo | func SetAppInfo(info *AppInfo) {
if info != nil && info.Name == "" {
panic(fmt.Errorf("App info name cannot be empty"))
}
appInfo = info
// This is run in init, but we need to reinitialize it now that we have
// some app info.
initUserAgent()
} | go | func SetAppInfo(info *AppInfo) {
if info != nil && info.Name == "" {
panic(fmt.Errorf("App info name cannot be empty"))
}
appInfo = info
// This is run in init, but we need to reinitialize it now that we have
// some app info.
initUserAgent()
} | [
"func",
"SetAppInfo",
"(",
"info",
"*",
"AppInfo",
")",
"{",
"if",
"info",
"!=",
"nil",
"&&",
"info",
".",
"Name",
"==",
"\"",
"\"",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"appInfo",
"=",
"info",
"\... | // SetAppInfo sets app information. See AppInfo. | [
"SetAppInfo",
"sets",
"app",
"information",
".",
"See",
"AppInfo",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L804-L813 |
26,263 | stripe/stripe-go | stripe.go | SetBackend | func SetBackend(backend SupportedBackend, b Backend) {
switch backend {
case APIBackend:
backends.API = b
case UploadsBackend:
backends.Uploads = b
}
} | go | func SetBackend(backend SupportedBackend, b Backend) {
switch backend {
case APIBackend:
backends.API = b
case UploadsBackend:
backends.Uploads = b
}
} | [
"func",
"SetBackend",
"(",
"backend",
"SupportedBackend",
",",
"b",
"Backend",
")",
"{",
"switch",
"backend",
"{",
"case",
"APIBackend",
":",
"backends",
".",
"API",
"=",
"b",
"\n",
"case",
"UploadsBackend",
":",
"backends",
".",
"Uploads",
"=",
"b",
"\n",... | // SetBackend sets the backend used in the binding. | [
"SetBackend",
"sets",
"the",
"backend",
"used",
"in",
"the",
"binding",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L816-L823 |
26,264 | stripe/stripe-go | stripe.go | StringSlice | func StringSlice(v []string) []*string {
out := make([]*string, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | go | func StringSlice(v []string) []*string {
out := make([]*string, len(v))
for i := range v {
out[i] = &v[i]
}
return out
} | [
"func",
"StringSlice",
"(",
"v",
"[",
"]",
"string",
")",
"[",
"]",
"*",
"string",
"{",
"out",
":=",
"make",
"(",
"[",
"]",
"*",
"string",
",",
"len",
"(",
"v",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"v",
"{",
"out",
"[",
"i",
"]",
"=",... | // StringSlice returns a slice of string pointers given a slice of strings. | [
"StringSlice",
"returns",
"a",
"slice",
"of",
"string",
"pointers",
"given",
"a",
"slice",
"of",
"strings",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L847-L853 |
26,265 | stripe/stripe-go | stripe.go | newBackendImplementation | func newBackendImplementation(backendType SupportedBackend, config *BackendConfig) Backend {
var requestMetricsBuffer chan requestMetrics
enableTelemetry := config.EnableTelemetry || EnableTelemetry
// only allocate the requestMetrics buffer if client telemetry is enabled.
if enableTelemetry {
requestMetricsBuff... | go | func newBackendImplementation(backendType SupportedBackend, config *BackendConfig) Backend {
var requestMetricsBuffer chan requestMetrics
enableTelemetry := config.EnableTelemetry || EnableTelemetry
// only allocate the requestMetrics buffer if client telemetry is enabled.
if enableTelemetry {
requestMetricsBuff... | [
"func",
"newBackendImplementation",
"(",
"backendType",
"SupportedBackend",
",",
"config",
"*",
"BackendConfig",
")",
"Backend",
"{",
"var",
"requestMetricsBuffer",
"chan",
"requestMetrics",
"\n",
"enableTelemetry",
":=",
"config",
".",
"EnableTelemetry",
"||",
"EnableT... | // newBackendImplementation returns a new Backend based off a given type and
// fully initialized BackendConfig struct.
//
// The vast majority of the time you should be calling GetBackendWithConfig
// instead of this function. | [
"newBackendImplementation",
"returns",
"a",
"new",
"Backend",
"based",
"off",
"a",
"given",
"type",
"and",
"fully",
"initialized",
"BackendConfig",
"struct",
".",
"The",
"vast",
"majority",
"of",
"the",
"time",
"you",
"should",
"be",
"calling",
"GetBackendWithConf... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/stripe.go#L989-L1008 |
26,266 | stripe/stripe-go | dispute.go | UnmarshalJSON | func (d *Dispute) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
d.ID = id
return nil
}
type dispute Dispute
var v dispute
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*d = Dispute(v)
return nil
} | go | func (d *Dispute) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
d.ID = id
return nil
}
type dispute Dispute
var v dispute
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*d = Dispute(v)
return nil
} | [
"func",
"(",
"d",
"*",
"Dispute",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"d",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"... | // UnmarshalJSON handles deserialization of a Dispute.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Dispute",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/dispute.go#L155-L169 |
26,267 | stripe/stripe-go | account/client.go | Get | func (c Client) Get() (*stripe.Account, error) {
account := &stripe.Account{}
err := c.B.Call(http.MethodGet, "/v1/account", c.Key, nil, account)
return account, err
} | go | func (c Client) Get() (*stripe.Account, error) {
account := &stripe.Account{}
err := c.B.Call(http.MethodGet, "/v1/account", c.Key, nil, account)
return account, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
")",
"(",
"*",
"stripe",
".",
"Account",
",",
"error",
")",
"{",
"account",
":=",
"&",
"stripe",
".",
"Account",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"B",
".",
"Call",
"(",
"http",
".",
"MethodGet"... | // Get retrieves the authenticating account. | [
"Get",
"retrieves",
"the",
"authenticating",
"account",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account/client.go#L37-L41 |
26,268 | stripe/stripe-go | account/client.go | Del | func (c Client) Del(id string, params *stripe.AccountParams) (*stripe.Account, error) {
path := stripe.FormatURLPath("/v1/accounts/%s", id)
acct := &stripe.Account{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, acct)
return acct, err
} | go | func (c Client) Del(id string, params *stripe.AccountParams) (*stripe.Account, error) {
path := stripe.FormatURLPath("/v1/accounts/%s", id)
acct := &stripe.Account{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, acct)
return acct, err
} | [
"func",
"(",
"c",
"Client",
")",
"Del",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"AccountParams",
")",
"(",
"*",
"stripe",
".",
"Account",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"i... | // Del deletes an account. | [
"Del",
"deletes",
"an",
"account",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account/client.go#L75-L80 |
26,269 | stripe/stripe-go | account/client.go | Reject | func Reject(id string, params *stripe.AccountRejectParams) (*stripe.Account, error) {
return getC().Reject(id, params)
} | go | func Reject(id string, params *stripe.AccountRejectParams) (*stripe.Account, error) {
return getC().Reject(id, params)
} | [
"func",
"Reject",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"AccountRejectParams",
")",
"(",
"*",
"stripe",
".",
"Account",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Reject",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Reject rejects an account. | [
"Reject",
"rejects",
"an",
"account",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account/client.go#L83-L85 |
26,270 | stripe/stripe-go | reversal/client.go | New | func New(params *stripe.ReversalParams) (*stripe.Reversal, error) {
return getC().New(params)
} | go | func New(params *stripe.ReversalParams) (*stripe.Reversal, error) {
return getC().New(params)
} | [
"func",
"New",
"(",
"params",
"*",
"stripe",
".",
"ReversalParams",
")",
"(",
"*",
"stripe",
".",
"Reversal",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"New",
"(",
"params",
")",
"\n",
"}"
] | // New creates a new transfer reversal. | [
"New",
"creates",
"a",
"new",
"transfer",
"reversal",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/reversal/client.go#L19-L21 |
26,271 | stripe/stripe-go | reversal/client.go | Update | func (c Client) Update(id string, params *stripe.ReversalParams) (*stripe.Reversal, error) {
path := stripe.FormatURLPath("/v1/transfers/%s/reversals/%s",
stripe.StringValue(params.Transfer), id)
reversal := &stripe.Reversal{}
err := c.B.Call(http.MethodPost, path, c.Key, params, reversal)
return reversal, err
} | go | func (c Client) Update(id string, params *stripe.ReversalParams) (*stripe.Reversal, error) {
path := stripe.FormatURLPath("/v1/transfers/%s/reversals/%s",
stripe.StringValue(params.Transfer), id)
reversal := &stripe.Reversal{}
err := c.B.Call(http.MethodPost, path, c.Key, params, reversal)
return reversal, err
} | [
"func",
"(",
"c",
"Client",
")",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ReversalParams",
")",
"(",
"*",
"stripe",
".",
"Reversal",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",... | // Update updates a transfer reversal's properties. | [
"Update",
"updates",
"a",
"transfer",
"reversal",
"s",
"properties",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/reversal/client.go#L55-L61 |
26,272 | stripe/stripe-go | bitcoinreceiver/client.go | Get | func (c Client) Get(id string) (*stripe.BitcoinReceiver, error) {
path := stripe.FormatURLPath("/v1/bitcoin/receivers/%s", id)
bitcoinReceiver := &stripe.BitcoinReceiver{}
err := c.B.Call(http.MethodGet, path, c.Key, nil, bitcoinReceiver)
return bitcoinReceiver, err
} | go | func (c Client) Get(id string) (*stripe.BitcoinReceiver, error) {
path := stripe.FormatURLPath("/v1/bitcoin/receivers/%s", id)
bitcoinReceiver := &stripe.BitcoinReceiver{}
err := c.B.Call(http.MethodGet, path, c.Key, nil, bitcoinReceiver)
return bitcoinReceiver, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
")",
"(",
"*",
"stripe",
".",
"BitcoinReceiver",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"bitcoinReceiver",
":=",
"&",
... | // Get returns the details of a bitcoin receiver. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"bitcoin",
"receiver",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/bitcoinreceiver/client.go#L26-L31 |
26,273 | stripe/stripe-go | subitem/client.go | Get | func (c Client) Get(id string, params *stripe.SubscriptionItemParams) (*stripe.SubscriptionItem, error) {
path := stripe.FormatURLPath("/v1/subscription_items/%s", id)
item := &stripe.SubscriptionItem{}
err := c.B.Call(http.MethodGet, path, c.Key, params, item)
return item, err
} | go | func (c Client) Get(id string, params *stripe.SubscriptionItemParams) (*stripe.SubscriptionItem, error) {
path := stripe.FormatURLPath("/v1/subscription_items/%s", id)
item := &stripe.SubscriptionItem{}
err := c.B.Call(http.MethodGet, path, c.Key, params, item)
return item, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"SubscriptionItemParams",
")",
"(",
"*",
"stripe",
".",
"SubscriptionItem",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
... | // Get returns the details of a subscription item. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"subscription",
"item",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/subitem/client.go#L35-L40 |
26,274 | stripe/stripe-go | coupon.go | UnmarshalJSON | func (c *Coupon) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type coupon Coupon
var v coupon
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Coupon(v)
return nil
} | go | func (c *Coupon) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type coupon Coupon
var v coupon
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Coupon(v)
return nil
} | [
"func",
"(",
"c",
"*",
"Coupon",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\... | // UnmarshalJSON handles deserialization of a Coupon.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Coupon",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/coupon.go#L67-L81 |
26,275 | stripe/stripe-go | balance.go | UnmarshalJSON | func (t *BalanceTransaction) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
t.ID = id
return nil
}
type balanceTransaction BalanceTransaction
var v balanceTransaction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*t = BalanceTransaction(v)
return nil
} | go | func (t *BalanceTransaction) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
t.ID = id
return nil
}
type balanceTransaction BalanceTransaction
var v balanceTransaction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*t = BalanceTransaction(v)
return nil
} | [
"func",
"(",
"t",
"*",
"BalanceTransaction",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"t",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",... | // UnmarshalJSON handles deserialization of a Transaction.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Transaction",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
".... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/balance.go#L153-L167 |
26,276 | stripe/stripe-go | balance.go | UnmarshalJSON | func (s *BalanceTransactionSource) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type balanceTransactionSource BalanceTransactionSource
var v balanceTransactionSource
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*s = BalanceTran... | go | func (s *BalanceTransactionSource) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type balanceTransactionSource BalanceTransactionSource
var v balanceTransactionSource
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*s = BalanceTran... | [
"func",
"(",
"s",
"*",
"BalanceTransactionSource",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"s",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
... | // UnmarshalJSON handles deserialization of a BalanceTransactionSource.
// This custom unmarshaling is needed because the specific
// type of transaction source it refers to is specified in the JSON | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"BalanceTransactionSource",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"specific",
"type",
"of",
"transaction",
"source",
"it",
"refers",
"to",
"is",
"specified",
"in",
"the",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/balance.go#L172-L211 |
26,277 | stripe/stripe-go | fee/client.go | Get | func Get(id string, params *stripe.ApplicationFeeParams) (*stripe.ApplicationFee, error) {
return getC().Get(id, params)
} | go | func Get(id string, params *stripe.ApplicationFeeParams) (*stripe.ApplicationFee, error) {
return getC().Get(id, params)
} | [
"func",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ApplicationFeeParams",
")",
"(",
"*",
"stripe",
".",
"ApplicationFee",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Get",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Get returns the details of an application fee. | [
"Get",
"returns",
"the",
"details",
"of",
"an",
"application",
"fee",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/fee/client.go#L18-L20 |
26,278 | stripe/stripe-go | order.go | SetSource | func (op *OrderPayParams) SetSource(sp interface{}) error {
source, err := SourceParamsFor(sp)
op.Source = source
return err
} | go | func (op *OrderPayParams) SetSource(sp interface{}) error {
source, err := SourceParamsFor(sp)
op.Source = source
return err
} | [
"func",
"(",
"op",
"*",
"OrderPayParams",
")",
"SetSource",
"(",
"sp",
"interface",
"{",
"}",
")",
"error",
"{",
"source",
",",
"err",
":=",
"SourceParamsFor",
"(",
"sp",
")",
"\n",
"op",
".",
"Source",
"=",
"source",
"\n",
"return",
"err",
"\n",
"}"... | // SetSource adds valid sources to a OrderParams object,
// returning an error for unsupported sources. | [
"SetSource",
"adds",
"valid",
"sources",
"to",
"a",
"OrderParams",
"object",
"returning",
"an",
"error",
"for",
"unsupported",
"sources",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/order.go#L224-L228 |
26,279 | stripe/stripe-go | order.go | UnmarshalJSON | func (p *OrderItemParent) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type orderItemParent OrderItemParent
var v orderItemParent
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*p = OrderItemParent(v)
switch p.Type {
case Orde... | go | func (p *OrderItemParent) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
p.ID = id
return nil
}
type orderItemParent OrderItemParent
var v orderItemParent
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*p = OrderItemParent(v)
switch p.Type {
case Orde... | [
"func",
"(",
"p",
"*",
"OrderItemParent",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"p",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
... | // UnmarshalJSON handles deserialization of an OrderItemParent.
// This custom unmarshaling is needed because the resulting
// property may be an id or a full SKU struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"OrderItemParent",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"a",
"full",
"SKU",
"struct",
"if",
"it",
"was",
"exp... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/order.go#L233-L259 |
26,280 | stripe/stripe-go | order.go | UnmarshalJSON | func (o *Order) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
o.ID = id
return nil
}
type order Order
var v order
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*o = Order(v)
return nil
} | go | func (o *Order) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
o.ID = id
return nil
}
type order Order
var v order
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*o = Order(v)
return nil
} | [
"func",
"(",
"o",
"*",
"Order",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"o",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n... | // UnmarshalJSON handles deserialization of an Order.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"Order",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/order.go#L264-L278 |
26,281 | stripe/stripe-go | paymentmethod.go | UnmarshalJSON | func (i *PaymentMethod) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type pm PaymentMethod
var v pm
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = PaymentMethod(v)
return nil
} | go | func (i *PaymentMethod) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type pm PaymentMethod
var v pm
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = PaymentMethod(v)
return nil
} | [
"func",
"(",
"i",
"*",
"PaymentMethod",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}... | // UnmarshalJSON handles deserialization of a PaymentMethod.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"PaymentMethod",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentmethod.go#L169-L183 |
26,282 | stripe/stripe-go | form/form.go | AppendTo | func AppendTo(values *Values, i interface{}) {
reflectValue(values, reflect.ValueOf(i), false, nil)
} | go | func AppendTo(values *Values, i interface{}) {
reflectValue(values, reflect.ValueOf(i), false, nil)
} | [
"func",
"AppendTo",
"(",
"values",
"*",
"Values",
",",
"i",
"interface",
"{",
"}",
")",
"{",
"reflectValue",
"(",
"values",
",",
"reflect",
".",
"ValueOf",
"(",
"i",
")",
",",
"false",
",",
"nil",
")",
"\n",
"}"
] | // AppendTo uses reflection to form encode into the given values collection
// based off the form tags that it defines. | [
"AppendTo",
"uses",
"reflection",
"to",
"form",
"encode",
"into",
"the",
"given",
"values",
"collection",
"based",
"off",
"the",
"form",
"tags",
"that",
"it",
"defines",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/form/form.go#L104-L106 |
26,283 | stripe/stripe-go | form/form.go | AppendToPrefixed | func AppendToPrefixed(values *Values, i interface{}, keyParts []string) {
reflectValue(values, reflect.ValueOf(i), false, keyParts)
} | go | func AppendToPrefixed(values *Values, i interface{}, keyParts []string) {
reflectValue(values, reflect.ValueOf(i), false, keyParts)
} | [
"func",
"AppendToPrefixed",
"(",
"values",
"*",
"Values",
",",
"i",
"interface",
"{",
"}",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"reflectValue",
"(",
"values",
",",
"reflect",
".",
"ValueOf",
"(",
"i",
")",
",",
"false",
",",
"keyParts",
")",
... | // AppendToPrefixed is the same as AppendTo, but it allows a slice of key parts
// to be specified to prefix the form values.
//
// I was hoping not to have to expose this function, but I ended up needing it
// for recipients. Recipients is going away, and when it does, we can probably
// remove it again. | [
"AppendToPrefixed",
"is",
"the",
"same",
"as",
"AppendTo",
"but",
"it",
"allows",
"a",
"slice",
"of",
"key",
"parts",
"to",
"be",
"specified",
"to",
"prefix",
"the",
"form",
"values",
".",
"I",
"was",
"hoping",
"not",
"to",
"have",
"to",
"expose",
"this"... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/form/form.go#L114-L116 |
26,284 | stripe/stripe-go | form/form.go | FormatKey | func FormatKey(parts []string) string {
if len(parts) < 1 {
panic("Not allowed 0-length parts slice")
}
key := parts[0]
for i := 1; i < len(parts); i++ {
key += "[" + parts[i] + "]"
}
return key
} | go | func FormatKey(parts []string) string {
if len(parts) < 1 {
panic("Not allowed 0-length parts slice")
}
key := parts[0]
for i := 1; i < len(parts); i++ {
key += "[" + parts[i] + "]"
}
return key
} | [
"func",
"FormatKey",
"(",
"parts",
"[",
"]",
"string",
")",
"string",
"{",
"if",
"len",
"(",
"parts",
")",
"<",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"key",
":=",
"parts",
"[",
"0",
"]",
"\n",
"for",
"i",
":=",
"1",
";",... | // FormatKey takes a series of key parts that may be parameter keyParts, map keys,
// or array indices and unifies them into a single key suitable for Stripe's
// style of form encoding. | [
"FormatKey",
"takes",
"a",
"series",
"of",
"key",
"parts",
"that",
"may",
"be",
"parameter",
"keyParts",
"map",
"keys",
"or",
"array",
"indices",
"and",
"unifies",
"them",
"into",
"a",
"single",
"key",
"suitable",
"for",
"Stripe",
"s",
"style",
"of",
"form... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/form/form.go#L121-L131 |
26,285 | stripe/stripe-go | form/form.go | getCachedOrBuildTypeEncoder | func getCachedOrBuildTypeEncoder(t reflect.Type) encoderFunc {
// Just acquire a read lock when extracting a value (note that in Go, a map
// cannot be read while it's also being written).
encoderCache.mu.RLock()
f := encoderCache.m[t]
encoderCache.mu.RUnlock()
if f != nil {
return f
}
// We do the work to ... | go | func getCachedOrBuildTypeEncoder(t reflect.Type) encoderFunc {
// Just acquire a read lock when extracting a value (note that in Go, a map
// cannot be read while it's also being written).
encoderCache.mu.RLock()
f := encoderCache.m[t]
encoderCache.mu.RUnlock()
if f != nil {
return f
}
// We do the work to ... | [
"func",
"getCachedOrBuildTypeEncoder",
"(",
"t",
"reflect",
".",
"Type",
")",
"encoderFunc",
"{",
"// Just acquire a read lock when extracting a value (note that in Go, a map",
"// cannot be read while it's also being written).",
"encoderCache",
".",
"mu",
".",
"RLock",
"(",
")",... | // getCachedOrBuildTypeEncoder tries to get an encoderFunc for the type from
// the cache, and falls back to building one if there wasn't a cached one
// available. If an encoder is built, it's stored back to the cache. | [
"getCachedOrBuildTypeEncoder",
"tries",
"to",
"get",
"an",
"encoderFunc",
"for",
"the",
"type",
"from",
"the",
"cache",
"and",
"falls",
"back",
"to",
"building",
"one",
"if",
"there",
"wasn",
"t",
"a",
"cached",
"one",
"available",
".",
"If",
"an",
"encoder"... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/form/form.go#L260-L287 |
26,286 | stripe/stripe-go | feerefund/client.go | Get | func Get(id string, params *stripe.FeeRefundParams) (*stripe.FeeRefund, error) {
return getC().Get(id, params)
} | go | func Get(id string, params *stripe.FeeRefundParams) (*stripe.FeeRefund, error) {
return getC().Get(id, params)
} | [
"func",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"FeeRefundParams",
")",
"(",
"*",
"stripe",
".",
"FeeRefund",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Get",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Get returns the details of an application fee refund. | [
"Get",
"returns",
"the",
"details",
"of",
"an",
"application",
"fee",
"refund",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/feerefund/client.go#L40-L42 |
26,287 | stripe/stripe-go | bankaccount.go | AppendTo | func (p *BankAccountListParams) AppendTo(body *form.Values, keyParts []string) {
body.Add(form.FormatKey(append(keyParts, "object")), "bank_account")
} | go | func (p *BankAccountListParams) AppendTo(body *form.Values, keyParts []string) {
body.Add(form.FormatKey(append(keyParts, "object")), "bank_account")
} | [
"func",
"(",
"p",
"*",
"BankAccountListParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"body",
".",
"Add",
"(",
"form",
".",
"FormatKey",
"(",
"append",
"(",
"keyParts",
",",
"\"",
"\"... | // AppendTo implements custom encoding logic for BankAccountListParams
// so that we can send the special required `object` field up along with the
// other specified parameters. | [
"AppendTo",
"implements",
"custom",
"encoding",
"logic",
"for",
"BankAccountListParams",
"so",
"that",
"we",
"can",
"send",
"the",
"special",
"required",
"object",
"field",
"up",
"along",
"with",
"the",
"other",
"specified",
"parameters",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/bankaccount.go#L138-L140 |
26,288 | stripe/stripe-go | bankaccount.go | UnmarshalJSON | func (b *BankAccount) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
b.ID = id
return nil
}
type bankAccount BankAccount
var v bankAccount
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*b = BankAccount(v)
return nil
} | go | func (b *BankAccount) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
b.ID = id
return nil
}
type bankAccount BankAccount
var v bankAccount
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*b = BankAccount(v)
return nil
} | [
"func",
"(",
"b",
"*",
"BankAccount",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"b",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",... | // UnmarshalJSON handles deserialization of a BankAccount.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"BankAccount",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
".... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/bankaccount.go#L169-L183 |
26,289 | stripe/stripe-go | filelink/client.go | Get | func (c Client) Get(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) {
path := stripe.FormatURLPath("/v1/file_links/%s", id)
fileLink := &stripe.FileLink{}
err := c.B.Call(http.MethodGet, path, c.Key, params, fileLink)
return fileLink, err
} | go | func (c Client) Get(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) {
path := stripe.FormatURLPath("/v1/file_links/%s", id)
fileLink := &stripe.FileLink{}
err := c.B.Call(http.MethodGet, path, c.Key, params, fileLink)
return fileLink, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"FileLinkParams",
")",
"(",
"*",
"stripe",
".",
"FileLink",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
... | // Get retrieves a file link. | [
"Get",
"retrieves",
"a",
"file",
"link",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/filelink/client.go#L37-L42 |
26,290 | stripe/stripe-go | filelink/client.go | Update | func Update(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) {
return getC().Update(id, params)
} | go | func Update(id string, params *stripe.FileLinkParams) (*stripe.FileLink, error) {
return getC().Update(id, params)
} | [
"func",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"FileLinkParams",
")",
"(",
"*",
"stripe",
".",
"FileLink",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Update",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Update updates a file link. | [
"Update",
"updates",
"a",
"file",
"link",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/filelink/client.go#L45-L47 |
26,291 | stripe/stripe-go | filelink/client.go | List | func (c Client) List(listParams *stripe.FileLinkListParams) *Iter {
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.FileLinkList{}
err := c.B.CallRaw(http.MethodGet, "/v1/file_links", c.Key, b, p, list)
ret := make([]interf... | go | func (c Client) List(listParams *stripe.FileLinkListParams) *Iter {
return &Iter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.FileLinkList{}
err := c.B.CallRaw(http.MethodGet, "/v1/file_links", c.Key, b, p, list)
ret := make([]interf... | [
"func",
"(",
"c",
"Client",
")",
"List",
"(",
"listParams",
"*",
"stripe",
".",
"FileLinkListParams",
")",
"*",
"Iter",
"{",
"return",
"&",
"Iter",
"{",
"stripe",
".",
"GetIter",
"(",
"listParams",
",",
"func",
"(",
"p",
"*",
"stripe",
".",
"Params",
... | // List returns an iterator that iterates all file links. | [
"List",
"returns",
"an",
"iterator",
"that",
"iterates",
"all",
"file",
"links",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/filelink/client.go#L63-L75 |
26,292 | stripe/stripe-go | sku.go | UnmarshalJSON | func (s *SKU) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type sku SKU
var v sku
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = SKU(v)
return nil
} | go | func (s *SKU) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type sku SKU
var v sku
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = SKU(v)
return nil
} | [
"func",
"(",
"s",
"*",
"SKU",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"s",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n... | // UnmarshalJSON handles deserialization of a SKU.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"SKU",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/sku.go#L92-L106 |
26,293 | stripe/stripe-go | feerefund.go | UnmarshalJSON | func (r *FeeRefund) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type feeRefund FeeRefund
var v feeRefund
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = FeeRefund(v)
return nil
} | go | func (r *FeeRefund) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type feeRefund FeeRefund
var v feeRefund
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = FeeRefund(v)
return nil
} | [
"func",
"(",
"r",
"*",
"FeeRefund",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"r",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
... | // UnmarshalJSON handles deserialization of a FeeRefund.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"FeeRefund",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/feerefund.go#L43-L57 |
26,294 | stripe/stripe-go | radar/valuelist/client.go | Update | func (c Client) Update(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) {
path := stripe.FormatURLPath("/v1/radar/value_lists/%s", id)
vl := &stripe.RadarValueList{}
err := c.B.Call(http.MethodPost, path, c.Key, params, vl)
return vl, err
} | go | func (c Client) Update(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) {
path := stripe.FormatURLPath("/v1/radar/value_lists/%s", id)
vl := &stripe.RadarValueList{}
err := c.B.Call(http.MethodPost, path, c.Key, params, vl)
return vl, err
} | [
"func",
"(",
"c",
"Client",
")",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"RadarValueListParams",
")",
"(",
"*",
"stripe",
".",
"RadarValueList",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
... | // Update updates a vl's properties. | [
"Update",
"updates",
"a",
"vl",
"s",
"properties",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/radar/valuelist/client.go#L50-L55 |
26,295 | stripe/stripe-go | radar/valuelist/client.go | Del | func Del(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) {
return getC().Del(id, params)
} | go | func Del(id string, params *stripe.RadarValueListParams) (*stripe.RadarValueList, error) {
return getC().Del(id, params)
} | [
"func",
"Del",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"RadarValueListParams",
")",
"(",
"*",
"stripe",
".",
"RadarValueList",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Del",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Del removes a value list. | [
"Del",
"removes",
"a",
"value",
"list",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/radar/valuelist/client.go#L58-L60 |
26,296 | stripe/stripe-go | person.go | UnmarshalJSON | func (c *Person) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type person Person
var v person
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Person(v)
return nil
} | go | func (c *Person) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type person Person
var v person
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Person(v)
return nil
} | [
"func",
"(",
"c",
"*",
"Person",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\... | // UnmarshalJSON handles deserialization of a Person.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Person",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/person.go#L195-L209 |
26,297 | stripe/stripe-go | card.go | AppendTo | func (p *CardListParams) AppendTo(body *form.Values, keyParts []string) {
if p.Account != nil || p.Customer != nil {
body.Add(form.FormatKey(append(keyParts, "object")), "card")
}
} | go | func (p *CardListParams) AppendTo(body *form.Values, keyParts []string) {
if p.Account != nil || p.Customer != nil {
body.Add(form.FormatKey(append(keyParts, "object")), "card")
}
} | [
"func",
"(",
"p",
"*",
"CardListParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"p",
".",
"Account",
"!=",
"nil",
"||",
"p",
".",
"Customer",
"!=",
"nil",
"{",
"body",
".",
"... | // AppendTo implements custom encoding logic for CardListParams
// so that we can send the special required `object` field up along with the
// other specified parameters. | [
"AppendTo",
"implements",
"custom",
"encoding",
"logic",
"for",
"CardListParams",
"so",
"that",
"we",
"can",
"send",
"the",
"special",
"required",
"object",
"field",
"up",
"along",
"with",
"the",
"other",
"specified",
"parameters",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/card.go#L190-L194 |
26,298 | stripe/stripe-go | card.go | UnmarshalJSON | func (c *Card) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type card Card
var v card
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Card(v)
return nil
} | go | func (c *Card) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type card Card
var v card
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Card(v)
return nil
} | [
"func",
"(",
"c",
"*",
"Card",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\... | // UnmarshalJSON handles deserialization of a Card.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Card",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/card.go#L258-L272 |
26,299 | stripe/stripe-go | taxid.go | UnmarshalJSON | func (c *TaxID) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type taxid TaxID
var v taxid
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = TaxID(v)
return nil
} | go | func (c *TaxID) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type taxid TaxID
var v taxid
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = TaxID(v)
return nil
} | [
"func",
"(",
"c",
"*",
"TaxID",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n... | // UnmarshalJSON handles deserialization of a TaxID.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"TaxID",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/taxid.go#L74-L88 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.