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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
25,700 | wcharczuk/go-chart | drawing/stack_graphic_context.go | MoveTo | func (gc *StackGraphicContext) MoveTo(x, y float64) {
gc.current.Path.MoveTo(x, y)
} | go | func (gc *StackGraphicContext) MoveTo(x, y float64) {
gc.current.Path.MoveTo(x, y)
} | [
"func",
"(",
"gc",
"*",
"StackGraphicContext",
")",
"MoveTo",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"gc",
".",
"current",
".",
"Path",
".",
"MoveTo",
"(",
"x",
",",
"y",
")",
"\n",
"}"
] | // MoveTo moves the cursor for a path. | [
"MoveTo",
"moves",
"the",
"cursor",
"for",
"a",
"path",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/stack_graphic_context.go#L154-L156 |
25,701 | wcharczuk/go-chart | drawing/stack_graphic_context.go | LineTo | func (gc *StackGraphicContext) LineTo(x, y float64) {
gc.current.Path.LineTo(x, y)
} | go | func (gc *StackGraphicContext) LineTo(x, y float64) {
gc.current.Path.LineTo(x, y)
} | [
"func",
"(",
"gc",
"*",
"StackGraphicContext",
")",
"LineTo",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"gc",
".",
"current",
".",
"Path",
".",
"LineTo",
"(",
"x",
",",
"y",
")",
"\n",
"}"
] | // LineTo draws a line. | [
"LineTo",
"draws",
"a",
"line",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/stack_graphic_context.go#L159-L161 |
25,702 | wcharczuk/go-chart | drawing/stack_graphic_context.go | ArcTo | func (gc *StackGraphicContext) ArcTo(cx, cy, rx, ry, startAngle, delta float64) {
gc.current.Path.ArcTo(cx, cy, rx, ry, startAngle, delta)
} | go | func (gc *StackGraphicContext) ArcTo(cx, cy, rx, ry, startAngle, delta float64) {
gc.current.Path.ArcTo(cx, cy, rx, ry, startAngle, delta)
} | [
"func",
"(",
"gc",
"*",
"StackGraphicContext",
")",
"ArcTo",
"(",
"cx",
",",
"cy",
",",
"rx",
",",
"ry",
",",
"startAngle",
",",
"delta",
"float64",
")",
"{",
"gc",
".",
"current",
".",
"Path",
".",
"ArcTo",
"(",
"cx",
",",
"cy",
",",
"rx",
",",
... | // ArcTo draws an arc. | [
"ArcTo",
"draws",
"an",
"arc",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/stack_graphic_context.go#L174-L176 |
25,703 | wcharczuk/go-chart | drawing/stack_graphic_context.go | Save | func (gc *StackGraphicContext) Save() {
context := new(ContextStack)
context.FontSizePoints = gc.current.FontSizePoints
context.Font = gc.current.Font
context.LineWidth = gc.current.LineWidth
context.StrokeColor = gc.current.StrokeColor
context.FillColor = gc.current.FillColor
context.FillRule = gc.current.FillR... | go | func (gc *StackGraphicContext) Save() {
context := new(ContextStack)
context.FontSizePoints = gc.current.FontSizePoints
context.Font = gc.current.Font
context.LineWidth = gc.current.LineWidth
context.StrokeColor = gc.current.StrokeColor
context.FillColor = gc.current.FillColor
context.FillRule = gc.current.FillR... | [
"func",
"(",
"gc",
"*",
"StackGraphicContext",
")",
"Save",
"(",
")",
"{",
"context",
":=",
"new",
"(",
"ContextStack",
")",
"\n",
"context",
".",
"FontSizePoints",
"=",
"gc",
".",
"current",
".",
"FontSizePoints",
"\n",
"context",
".",
"Font",
"=",
"gc"... | // Save pushes a context onto the stack. | [
"Save",
"pushes",
"a",
"context",
"onto",
"the",
"stack",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/stack_graphic_context.go#L184-L202 |
25,704 | wcharczuk/go-chart | drawing/stack_graphic_context.go | Restore | func (gc *StackGraphicContext) Restore() {
if gc.current.Previous != nil {
oldContext := gc.current
gc.current = gc.current.Previous
oldContext.Previous = nil
}
} | go | func (gc *StackGraphicContext) Restore() {
if gc.current.Previous != nil {
oldContext := gc.current
gc.current = gc.current.Previous
oldContext.Previous = nil
}
} | [
"func",
"(",
"gc",
"*",
"StackGraphicContext",
")",
"Restore",
"(",
")",
"{",
"if",
"gc",
".",
"current",
".",
"Previous",
"!=",
"nil",
"{",
"oldContext",
":=",
"gc",
".",
"current",
"\n",
"gc",
".",
"current",
"=",
"gc",
".",
"current",
".",
"Previo... | // Restore restores the previous context. | [
"Restore",
"restores",
"the",
"previous",
"context",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/stack_graphic_context.go#L205-L211 |
25,705 | wcharczuk/go-chart | linear_regression_series.go | Coefficients | func (lrs LinearRegressionSeries) Coefficients() (m, b, stdev, avg float64) {
if lrs.IsZero() {
lrs.computeCoefficients()
}
m = lrs.m
b = lrs.b
stdev = lrs.stddevx
avg = lrs.avgx
return
} | go | func (lrs LinearRegressionSeries) Coefficients() (m, b, stdev, avg float64) {
if lrs.IsZero() {
lrs.computeCoefficients()
}
m = lrs.m
b = lrs.b
stdev = lrs.stddevx
avg = lrs.avgx
return
} | [
"func",
"(",
"lrs",
"LinearRegressionSeries",
")",
"Coefficients",
"(",
")",
"(",
"m",
",",
"b",
",",
"stdev",
",",
"avg",
"float64",
")",
"{",
"if",
"lrs",
".",
"IsZero",
"(",
")",
"{",
"lrs",
".",
"computeCoefficients",
"(",
")",
"\n",
"}",
"\n\n",... | // Coefficients returns the linear coefficients for the series. | [
"Coefficients",
"returns",
"the",
"linear",
"coefficients",
"for",
"the",
"series",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/linear_regression_series.go#L36-L46 |
25,706 | wcharczuk/go-chart | linear_regression_series.go | GetLastValues | func (lrs *LinearRegressionSeries) GetLastValues() (x, y float64) {
if lrs.InnerSeries == nil || lrs.InnerSeries.Len() == 0 {
return
}
if lrs.IsZero() {
lrs.computeCoefficients()
}
endIndex := lrs.GetEndIndex()
x, y = lrs.InnerSeries.GetValues(endIndex)
y = (lrs.m * lrs.normalize(x)) + lrs.b
return
} | go | func (lrs *LinearRegressionSeries) GetLastValues() (x, y float64) {
if lrs.InnerSeries == nil || lrs.InnerSeries.Len() == 0 {
return
}
if lrs.IsZero() {
lrs.computeCoefficients()
}
endIndex := lrs.GetEndIndex()
x, y = lrs.InnerSeries.GetValues(endIndex)
y = (lrs.m * lrs.normalize(x)) + lrs.b
return
} | [
"func",
"(",
"lrs",
"*",
"LinearRegressionSeries",
")",
"GetLastValues",
"(",
")",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"if",
"lrs",
".",
"InnerSeries",
"==",
"nil",
"||",
"lrs",
".",
"InnerSeries",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",... | // GetLastValues computes the last linear regression value. | [
"GetLastValues",
"computes",
"the",
"last",
"linear",
"regression",
"value",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/linear_regression_series.go#L120-L131 |
25,707 | wcharczuk/go-chart | util/file_util.go | ReadByLines | func (fu fileUtil) ReadByLines(filePath string, handler func(line string) error) error {
var f *os.File
var err error
if f, err = os.Open(filePath); err == nil {
defer f.Close()
var line string
scanner := bufio.NewScanner(f)
for scanner.Scan() {
line = scanner.Text()
err = handler(line)
if err != ni... | go | func (fu fileUtil) ReadByLines(filePath string, handler func(line string) error) error {
var f *os.File
var err error
if f, err = os.Open(filePath); err == nil {
defer f.Close()
var line string
scanner := bufio.NewScanner(f)
for scanner.Scan() {
line = scanner.Text()
err = handler(line)
if err != ni... | [
"func",
"(",
"fu",
"fileUtil",
")",
"ReadByLines",
"(",
"filePath",
"string",
",",
"handler",
"func",
"(",
"line",
"string",
")",
"error",
")",
"error",
"{",
"var",
"f",
"*",
"os",
".",
"File",
"\n",
"var",
"err",
"error",
"\n",
"if",
"f",
",",
"er... | // ReadByLines reads a file and calls the handler for each line. | [
"ReadByLines",
"reads",
"a",
"file",
"and",
"calls",
"the",
"handler",
"for",
"each",
"line",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/file_util.go#L17-L34 |
25,708 | wcharczuk/go-chart | util/file_util.go | ReadByChunks | func (fu fileUtil) ReadByChunks(filePath string, chunkSize int, handler func(line []byte) error) error {
var f *os.File
var err error
if f, err = os.Open(filePath); err == nil {
defer f.Close()
chunk := make([]byte, chunkSize)
for {
readBytes, err := f.Read(chunk)
if err == io.EOF {
break
}
re... | go | func (fu fileUtil) ReadByChunks(filePath string, chunkSize int, handler func(line []byte) error) error {
var f *os.File
var err error
if f, err = os.Open(filePath); err == nil {
defer f.Close()
chunk := make([]byte, chunkSize)
for {
readBytes, err := f.Read(chunk)
if err == io.EOF {
break
}
re... | [
"func",
"(",
"fu",
"fileUtil",
")",
"ReadByChunks",
"(",
"filePath",
"string",
",",
"chunkSize",
"int",
",",
"handler",
"func",
"(",
"line",
"[",
"]",
"byte",
")",
"error",
")",
"error",
"{",
"var",
"f",
"*",
"os",
".",
"File",
"\n",
"var",
"err",
... | // ReadByChunks reads a file in `chunkSize` pieces, dispatched to the handler. | [
"ReadByChunks",
"reads",
"a",
"file",
"in",
"chunkSize",
"pieces",
"dispatched",
"to",
"the",
"handler",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/file_util.go#L37-L57 |
25,709 | wcharczuk/go-chart | seq/buffer.go | NewBuffer | func NewBuffer(values ...float64) *Buffer {
var tail int
array := make([]float64, util.Math.MaxInt(len(values), bufferDefaultCapacity))
if len(values) > 0 {
copy(array, values)
tail = len(values)
}
return &Buffer{
array: array,
head: 0,
tail: tail,
size: len(values),
}
} | go | func NewBuffer(values ...float64) *Buffer {
var tail int
array := make([]float64, util.Math.MaxInt(len(values), bufferDefaultCapacity))
if len(values) > 0 {
copy(array, values)
tail = len(values)
}
return &Buffer{
array: array,
head: 0,
tail: tail,
size: len(values),
}
} | [
"func",
"NewBuffer",
"(",
"values",
"...",
"float64",
")",
"*",
"Buffer",
"{",
"var",
"tail",
"int",
"\n",
"array",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"util",
".",
"Math",
".",
"MaxInt",
"(",
"len",
"(",
"values",
")",
",",
"bufferDefaultCa... | // NewBuffer creates a new value buffer with an optional set of values. | [
"NewBuffer",
"creates",
"a",
"new",
"value",
"buffer",
"with",
"an",
"optional",
"set",
"of",
"values",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L22-L35 |
25,710 | wcharczuk/go-chart | seq/buffer.go | NewBufferWithCapacity | func NewBufferWithCapacity(capacity int) *Buffer {
return &Buffer{
array: make([]float64, capacity),
head: 0,
tail: 0,
size: 0,
}
} | go | func NewBufferWithCapacity(capacity int) *Buffer {
return &Buffer{
array: make([]float64, capacity),
head: 0,
tail: 0,
size: 0,
}
} | [
"func",
"NewBufferWithCapacity",
"(",
"capacity",
"int",
")",
"*",
"Buffer",
"{",
"return",
"&",
"Buffer",
"{",
"array",
":",
"make",
"(",
"[",
"]",
"float64",
",",
"capacity",
")",
",",
"head",
":",
"0",
",",
"tail",
":",
"0",
",",
"size",
":",
"0... | // NewBufferWithCapacity creates a new ValueBuffer pre-allocated with the given capacity. | [
"NewBufferWithCapacity",
"creates",
"a",
"new",
"ValueBuffer",
"pre",
"-",
"allocated",
"with",
"the",
"given",
"capacity",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L38-L45 |
25,711 | wcharczuk/go-chart | seq/buffer.go | GetValue | func (b *Buffer) GetValue(index int) float64 {
effectiveIndex := (b.head + index) % len(b.array)
return b.array[effectiveIndex]
} | go | func (b *Buffer) GetValue(index int) float64 {
effectiveIndex := (b.head + index) % len(b.array)
return b.array[effectiveIndex]
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"GetValue",
"(",
"index",
"int",
")",
"float64",
"{",
"effectiveIndex",
":=",
"(",
"b",
".",
"head",
"+",
"index",
")",
"%",
"len",
"(",
"b",
".",
"array",
")",
"\n",
"return",
"b",
".",
"array",
"[",
"effect... | // GetValue implements seq provider. | [
"GetValue",
"implements",
"seq",
"provider",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L65-L68 |
25,712 | wcharczuk/go-chart | seq/buffer.go | SetCapacity | func (b *Buffer) SetCapacity(capacity int) {
newArray := make([]float64, capacity)
if b.size > 0 {
if b.head < b.tail {
arrayCopy(b.array, b.head, newArray, 0, b.size)
} else {
arrayCopy(b.array, b.head, newArray, 0, len(b.array)-b.head)
arrayCopy(b.array, 0, newArray, len(b.array)-b.head, b.tail)
}
}... | go | func (b *Buffer) SetCapacity(capacity int) {
newArray := make([]float64, capacity)
if b.size > 0 {
if b.head < b.tail {
arrayCopy(b.array, b.head, newArray, 0, b.size)
} else {
arrayCopy(b.array, b.head, newArray, 0, len(b.array)-b.head)
arrayCopy(b.array, 0, newArray, len(b.array)-b.head, b.tail)
}
}... | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"SetCapacity",
"(",
"capacity",
"int",
")",
"{",
"newArray",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"capacity",
")",
"\n",
"if",
"b",
".",
"size",
">",
"0",
"{",
"if",
"b",
".",
"head",
"<",
"b",
".",... | // SetCapacity sets the capacity of the Buffer. | [
"SetCapacity",
"sets",
"the",
"capacity",
"of",
"the",
"Buffer",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L76-L93 |
25,713 | wcharczuk/go-chart | seq/buffer.go | Clear | func (b *Buffer) Clear() {
b.array = make([]float64, bufferDefaultCapacity)
b.head = 0
b.tail = 0
b.size = 0
} | go | func (b *Buffer) Clear() {
b.array = make([]float64, bufferDefaultCapacity)
b.head = 0
b.tail = 0
b.size = 0
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Clear",
"(",
")",
"{",
"b",
".",
"array",
"=",
"make",
"(",
"[",
"]",
"float64",
",",
"bufferDefaultCapacity",
")",
"\n",
"b",
".",
"head",
"=",
"0",
"\n",
"b",
".",
"tail",
"=",
"0",
"\n",
"b",
".",
"si... | // Clear removes all objects from the Buffer. | [
"Clear",
"removes",
"all",
"objects",
"from",
"the",
"Buffer",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L96-L101 |
25,714 | wcharczuk/go-chart | seq/buffer.go | Enqueue | func (b *Buffer) Enqueue(value float64) {
if b.size == len(b.array) {
newCapacity := int(len(b.array) * int(bufferGrowFactor/100))
if newCapacity < (len(b.array) + bufferMinimumGrow) {
newCapacity = len(b.array) + bufferMinimumGrow
}
b.SetCapacity(newCapacity)
}
b.array[b.tail] = value
b.tail = (b.tail ... | go | func (b *Buffer) Enqueue(value float64) {
if b.size == len(b.array) {
newCapacity := int(len(b.array) * int(bufferGrowFactor/100))
if newCapacity < (len(b.array) + bufferMinimumGrow) {
newCapacity = len(b.array) + bufferMinimumGrow
}
b.SetCapacity(newCapacity)
}
b.array[b.tail] = value
b.tail = (b.tail ... | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Enqueue",
"(",
"value",
"float64",
")",
"{",
"if",
"b",
".",
"size",
"==",
"len",
"(",
"b",
".",
"array",
")",
"{",
"newCapacity",
":=",
"int",
"(",
"len",
"(",
"b",
".",
"array",
")",
"*",
"int",
"(",
"... | // Enqueue adds an element to the "back" of the Buffer. | [
"Enqueue",
"adds",
"an",
"element",
"to",
"the",
"back",
"of",
"the",
"Buffer",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L104-L116 |
25,715 | wcharczuk/go-chart | seq/buffer.go | Dequeue | func (b *Buffer) Dequeue() float64 {
if b.size == 0 {
return 0
}
removed := b.array[b.head]
b.head = (b.head + 1) % len(b.array)
b.size--
return removed
} | go | func (b *Buffer) Dequeue() float64 {
if b.size == 0 {
return 0
}
removed := b.array[b.head]
b.head = (b.head + 1) % len(b.array)
b.size--
return removed
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Dequeue",
"(",
")",
"float64",
"{",
"if",
"b",
".",
"size",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"removed",
":=",
"b",
".",
"array",
"[",
"b",
".",
"head",
"]",
"\n",
"b",
".",
"head",
"=",
... | // Dequeue removes the first element from the RingBuffer. | [
"Dequeue",
"removes",
"the",
"first",
"element",
"from",
"the",
"RingBuffer",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L119-L128 |
25,716 | wcharczuk/go-chart | seq/buffer.go | Peek | func (b *Buffer) Peek() float64 {
if b.size == 0 {
return 0
}
return b.array[b.head]
} | go | func (b *Buffer) Peek() float64 {
if b.size == 0 {
return 0
}
return b.array[b.head]
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Peek",
"(",
")",
"float64",
"{",
"if",
"b",
".",
"size",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"b",
".",
"array",
"[",
"b",
".",
"head",
"]",
"\n",
"}"
] | // Peek returns but does not remove the first element. | [
"Peek",
"returns",
"but",
"does",
"not",
"remove",
"the",
"first",
"element",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L131-L136 |
25,717 | wcharczuk/go-chart | seq/buffer.go | PeekBack | func (b *Buffer) PeekBack() float64 {
if b.size == 0 {
return 0
}
if b.tail == 0 {
return b.array[len(b.array)-1]
}
return b.array[b.tail-1]
} | go | func (b *Buffer) PeekBack() float64 {
if b.size == 0 {
return 0
}
if b.tail == 0 {
return b.array[len(b.array)-1]
}
return b.array[b.tail-1]
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"PeekBack",
"(",
")",
"float64",
"{",
"if",
"b",
".",
"size",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"if",
"b",
".",
"tail",
"==",
"0",
"{",
"return",
"b",
".",
"array",
"[",
"len",
"(",
"b",
"... | // PeekBack returns but does not remove the last element. | [
"PeekBack",
"returns",
"but",
"does",
"not",
"remove",
"the",
"last",
"element",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L139-L147 |
25,718 | wcharczuk/go-chart | seq/buffer.go | TrimExcess | func (b *Buffer) TrimExcess() {
threshold := float64(len(b.array)) * 0.9
if b.size < int(threshold) {
b.SetCapacity(b.size)
}
} | go | func (b *Buffer) TrimExcess() {
threshold := float64(len(b.array)) * 0.9
if b.size < int(threshold) {
b.SetCapacity(b.size)
}
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"TrimExcess",
"(",
")",
"{",
"threshold",
":=",
"float64",
"(",
"len",
"(",
"b",
".",
"array",
")",
")",
"*",
"0.9",
"\n",
"if",
"b",
".",
"size",
"<",
"int",
"(",
"threshold",
")",
"{",
"b",
".",
"SetCapac... | // TrimExcess resizes the capacity of the buffer to better fit the contents. | [
"TrimExcess",
"resizes",
"the",
"capacity",
"of",
"the",
"buffer",
"to",
"better",
"fit",
"the",
"contents",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L150-L155 |
25,719 | wcharczuk/go-chart | seq/buffer.go | Array | func (b *Buffer) Array() Array {
newArray := make([]float64, b.size)
if b.size == 0 {
return newArray
}
if b.head < b.tail {
arrayCopy(b.array, b.head, newArray, 0, b.size)
} else {
arrayCopy(b.array, b.head, newArray, 0, len(b.array)-b.head)
arrayCopy(b.array, 0, newArray, len(b.array)-b.head, b.tail)
... | go | func (b *Buffer) Array() Array {
newArray := make([]float64, b.size)
if b.size == 0 {
return newArray
}
if b.head < b.tail {
arrayCopy(b.array, b.head, newArray, 0, b.size)
} else {
arrayCopy(b.array, b.head, newArray, 0, len(b.array)-b.head)
arrayCopy(b.array, 0, newArray, len(b.array)-b.head, b.tail)
... | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Array",
"(",
")",
"Array",
"{",
"newArray",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"b",
".",
"size",
")",
"\n\n",
"if",
"b",
".",
"size",
"==",
"0",
"{",
"return",
"newArray",
"\n",
"}",
"\n\n",
"if"... | // Array returns the ring buffer, in order, as an array. | [
"Array",
"returns",
"the",
"ring",
"buffer",
"in",
"order",
"as",
"an",
"array",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L158-L173 |
25,720 | wcharczuk/go-chart | seq/buffer.go | Each | func (b *Buffer) Each(mapfn func(int, float64)) {
if b.size == 0 {
return
}
var index int
if b.head < b.tail {
for cursor := b.head; cursor < b.tail; cursor++ {
mapfn(index, b.array[cursor])
index++
}
} else {
for cursor := b.head; cursor < len(b.array); cursor++ {
mapfn(index, b.array[cursor])
... | go | func (b *Buffer) Each(mapfn func(int, float64)) {
if b.size == 0 {
return
}
var index int
if b.head < b.tail {
for cursor := b.head; cursor < b.tail; cursor++ {
mapfn(index, b.array[cursor])
index++
}
} else {
for cursor := b.head; cursor < len(b.array); cursor++ {
mapfn(index, b.array[cursor])
... | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Each",
"(",
"mapfn",
"func",
"(",
"int",
",",
"float64",
")",
")",
"{",
"if",
"b",
".",
"size",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"var",
"index",
"int",
"\n",
"if",
"b",
".",
"head",
"<",
"b",... | // Each calls the consumer for each element in the buffer. | [
"Each",
"calls",
"the",
"consumer",
"for",
"each",
"element",
"in",
"the",
"buffer",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L176-L197 |
25,721 | wcharczuk/go-chart | seq/buffer.go | String | func (b *Buffer) String() string {
var values []string
for _, elem := range b.Array() {
values = append(values, fmt.Sprintf("%v", elem))
}
return strings.Join(values, " <= ")
} | go | func (b *Buffer) String() string {
var values []string
for _, elem := range b.Array() {
values = append(values, fmt.Sprintf("%v", elem))
}
return strings.Join(values, " <= ")
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"String",
"(",
")",
"string",
"{",
"var",
"values",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"elem",
":=",
"range",
"b",
".",
"Array",
"(",
")",
"{",
"values",
"=",
"append",
"(",
"values",
",",
"fmt",
".... | // String returns a string representation for value buffers. | [
"String",
"returns",
"a",
"string",
"representation",
"for",
"value",
"buffers",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/buffer.go#L200-L206 |
25,722 | wcharczuk/go-chart | drawing/stroker.go | NewLineStroker | func NewLineStroker(c LineCap, j LineJoin, flattener Flattener) *LineStroker {
l := new(LineStroker)
l.Flattener = flattener
l.HalfLineWidth = 0.5
l.Cap = c
l.Join = j
return l
} | go | func NewLineStroker(c LineCap, j LineJoin, flattener Flattener) *LineStroker {
l := new(LineStroker)
l.Flattener = flattener
l.HalfLineWidth = 0.5
l.Cap = c
l.Join = j
return l
} | [
"func",
"NewLineStroker",
"(",
"c",
"LineCap",
",",
"j",
"LineJoin",
",",
"flattener",
"Flattener",
")",
"*",
"LineStroker",
"{",
"l",
":=",
"new",
"(",
"LineStroker",
")",
"\n",
"l",
".",
"Flattener",
"=",
"flattener",
"\n",
"l",
".",
"HalfLineWidth",
"... | // NewLineStroker creates a new line stroker. | [
"NewLineStroker",
"creates",
"a",
"new",
"line",
"stroker",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/stroker.go#L7-L14 |
25,723 | wcharczuk/go-chart | drawing/stroker.go | Close | func (l *LineStroker) Close() {
if len(l.vertices) > 1 {
l.appendVertex(l.vertices[0], l.vertices[1], l.rewind[0], l.rewind[1])
}
} | go | func (l *LineStroker) Close() {
if len(l.vertices) > 1 {
l.appendVertex(l.vertices[0], l.vertices[1], l.rewind[0], l.rewind[1])
}
} | [
"func",
"(",
"l",
"*",
"LineStroker",
")",
"Close",
"(",
")",
"{",
"if",
"len",
"(",
"l",
".",
"vertices",
")",
">",
"1",
"{",
"l",
".",
"appendVertex",
"(",
"l",
".",
"vertices",
"[",
"0",
"]",
",",
"l",
".",
"vertices",
"[",
"1",
"]",
",",
... | // Close implements the path builder interface. | [
"Close",
"implements",
"the",
"path",
"builder",
"interface",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/stroker.go#L53-L57 |
25,724 | wcharczuk/go-chart | drawing/stroker.go | End | func (l *LineStroker) End() {
if len(l.vertices) > 1 {
l.Flattener.MoveTo(l.vertices[0], l.vertices[1])
for i, j := 2, 3; j < len(l.vertices); i, j = i+2, j+2 {
l.Flattener.LineTo(l.vertices[i], l.vertices[j])
}
}
for i, j := len(l.rewind)-2, len(l.rewind)-1; j > 0; i, j = i-2, j-2 {
l.Flattener.LineTo(l.... | go | func (l *LineStroker) End() {
if len(l.vertices) > 1 {
l.Flattener.MoveTo(l.vertices[0], l.vertices[1])
for i, j := 2, 3; j < len(l.vertices); i, j = i+2, j+2 {
l.Flattener.LineTo(l.vertices[i], l.vertices[j])
}
}
for i, j := len(l.rewind)-2, len(l.rewind)-1; j > 0; i, j = i-2, j-2 {
l.Flattener.LineTo(l.... | [
"func",
"(",
"l",
"*",
"LineStroker",
")",
"End",
"(",
")",
"{",
"if",
"len",
"(",
"l",
".",
"vertices",
")",
">",
"1",
"{",
"l",
".",
"Flattener",
".",
"MoveTo",
"(",
"l",
".",
"vertices",
"[",
"0",
"]",
",",
"l",
".",
"vertices",
"[",
"1",
... | // End implements the path builder interface. | [
"End",
"implements",
"the",
"path",
"builder",
"interface",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/stroker.go#L60-L79 |
25,725 | wcharczuk/go-chart | viridis.go | Viridis | func Viridis(v, vmin, vmax float64) drawing.Color {
normalized := (v - vmin) / (vmax - vmin)
index := uint8(normalized * 255)
return viridisColors[index]
} | go | func Viridis(v, vmin, vmax float64) drawing.Color {
normalized := (v - vmin) / (vmax - vmin)
index := uint8(normalized * 255)
return viridisColors[index]
} | [
"func",
"Viridis",
"(",
"v",
",",
"vmin",
",",
"vmax",
"float64",
")",
"drawing",
".",
"Color",
"{",
"normalized",
":=",
"(",
"v",
"-",
"vmin",
")",
"/",
"(",
"vmax",
"-",
"vmin",
")",
"\n",
"index",
":=",
"uint8",
"(",
"normalized",
"*",
"255",
... | // Viridis creates a color map provider. | [
"Viridis",
"creates",
"a",
"color",
"map",
"provider",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/viridis.go#L265-L269 |
25,726 | go-resty/resty | client.go | R | func (c *Client) R() *Request {
r := &Request{
QueryParam: url.Values{},
FormData: url.Values{},
Header: http.Header{},
client: c,
multipartFiles: []*File{},
multipartFields: []*MultipartField{},
pathParams: map[string]string{},
jsonEscapeHTML: true,
}
return r
} | go | func (c *Client) R() *Request {
r := &Request{
QueryParam: url.Values{},
FormData: url.Values{},
Header: http.Header{},
client: c,
multipartFiles: []*File{},
multipartFields: []*MultipartField{},
pathParams: map[string]string{},
jsonEscapeHTML: true,
}
return r
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"R",
"(",
")",
"*",
"Request",
"{",
"r",
":=",
"&",
"Request",
"{",
"QueryParam",
":",
"url",
".",
"Values",
"{",
"}",
",",
"FormData",
":",
"url",
".",
"Values",
"{",
"}",
",",
"Header",
":",
"http",
".",
... | // R method creates a request instance, its used for Get, Post, Put, Delete, Patch, Head and Options. | [
"R",
"method",
"creates",
"a",
"request",
"instance",
"its",
"used",
"for",
"Get",
"Post",
"Put",
"Delete",
"Patch",
"Head",
"and",
"Options",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L306-L320 |
25,727 | go-resty/resty | client.go | OnRequestLog | func (c *Client) OnRequestLog(rl func(*RequestLog) error) *Client {
if c.requestLog != nil {
c.Log.Printf("Overwriting an existing on-request-log callback from=%s to=%s", functionName(c.requestLog), functionName(rl))
}
c.requestLog = rl
return c
} | go | func (c *Client) OnRequestLog(rl func(*RequestLog) error) *Client {
if c.requestLog != nil {
c.Log.Printf("Overwriting an existing on-request-log callback from=%s to=%s", functionName(c.requestLog), functionName(rl))
}
c.requestLog = rl
return c
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"OnRequestLog",
"(",
"rl",
"func",
"(",
"*",
"RequestLog",
")",
"error",
")",
"*",
"Client",
"{",
"if",
"c",
".",
"requestLog",
"!=",
"nil",
"{",
"c",
".",
"Log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"functio... | // OnRequestLog method used to set request log callback into resty. Registered callback gets
// called before the resty actually logs the information. | [
"OnRequestLog",
"method",
"used",
"to",
"set",
"request",
"log",
"callback",
"into",
"resty",
".",
"Registered",
"callback",
"gets",
"called",
"before",
"the",
"resty",
"actually",
"logs",
"the",
"information",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L390-L396 |
25,728 | go-resty/resty | client.go | OnResponseLog | func (c *Client) OnResponseLog(rl func(*ResponseLog) error) *Client {
if c.responseLog != nil {
c.Log.Printf("Overwriting an existing on-response-log callback from=%s to=%s", functionName(c.responseLog), functionName(rl))
}
c.responseLog = rl
return c
} | go | func (c *Client) OnResponseLog(rl func(*ResponseLog) error) *Client {
if c.responseLog != nil {
c.Log.Printf("Overwriting an existing on-response-log callback from=%s to=%s", functionName(c.responseLog), functionName(rl))
}
c.responseLog = rl
return c
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"OnResponseLog",
"(",
"rl",
"func",
"(",
"*",
"ResponseLog",
")",
"error",
")",
"*",
"Client",
"{",
"if",
"c",
".",
"responseLog",
"!=",
"nil",
"{",
"c",
".",
"Log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"func... | // OnResponseLog method used to set response log callback into resty. Registered callback gets
// called before the resty actually logs the information. | [
"OnResponseLog",
"method",
"used",
"to",
"set",
"response",
"log",
"callback",
"into",
"resty",
".",
"Registered",
"callback",
"gets",
"called",
"before",
"the",
"resty",
"actually",
"logs",
"the",
"information",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L400-L406 |
25,729 | go-resty/resty | client.go | SetRetryCount | func (c *Client) SetRetryCount(count int) *Client {
c.RetryCount = count
return c
} | go | func (c *Client) SetRetryCount(count int) *Client {
c.RetryCount = count
return c
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetRetryCount",
"(",
"count",
"int",
")",
"*",
"Client",
"{",
"c",
".",
"RetryCount",
"=",
"count",
"\n",
"return",
"c",
"\n",
"}"
] | // SetRetryCount method enables retry on `go-resty` client and allows you
// to set no. of retry count. Resty uses a Backoff mechanism. | [
"SetRetryCount",
"method",
"enables",
"retry",
"on",
"go",
"-",
"resty",
"client",
"and",
"allows",
"you",
"to",
"set",
"no",
".",
"of",
"retry",
"count",
".",
"Resty",
"uses",
"a",
"Backoff",
"mechanism",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L498-L501 |
25,730 | go-resty/resty | client.go | SetRetryWaitTime | func (c *Client) SetRetryWaitTime(waitTime time.Duration) *Client {
c.RetryWaitTime = waitTime
return c
} | go | func (c *Client) SetRetryWaitTime(waitTime time.Duration) *Client {
c.RetryWaitTime = waitTime
return c
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetRetryWaitTime",
"(",
"waitTime",
"time",
".",
"Duration",
")",
"*",
"Client",
"{",
"c",
".",
"RetryWaitTime",
"=",
"waitTime",
"\n",
"return",
"c",
"\n",
"}"
] | // SetRetryWaitTime method sets default wait time to sleep before retrying
// request.
// Default is 100 milliseconds. | [
"SetRetryWaitTime",
"method",
"sets",
"default",
"wait",
"time",
"to",
"sleep",
"before",
"retrying",
"request",
".",
"Default",
"is",
"100",
"milliseconds",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L506-L509 |
25,731 | go-resty/resty | client.go | SetRetryMaxWaitTime | func (c *Client) SetRetryMaxWaitTime(maxWaitTime time.Duration) *Client {
c.RetryMaxWaitTime = maxWaitTime
return c
} | go | func (c *Client) SetRetryMaxWaitTime(maxWaitTime time.Duration) *Client {
c.RetryMaxWaitTime = maxWaitTime
return c
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetRetryMaxWaitTime",
"(",
"maxWaitTime",
"time",
".",
"Duration",
")",
"*",
"Client",
"{",
"c",
".",
"RetryMaxWaitTime",
"=",
"maxWaitTime",
"\n",
"return",
"c",
"\n",
"}"
] | // SetRetryMaxWaitTime method sets max wait time to sleep before retrying
// request.
// Default is 2 seconds. | [
"SetRetryMaxWaitTime",
"method",
"sets",
"max",
"wait",
"time",
"to",
"sleep",
"before",
"retrying",
"request",
".",
"Default",
"is",
"2",
"seconds",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L514-L517 |
25,732 | go-resty/resty | client.go | AddRetryCondition | func (c *Client) AddRetryCondition(condition RetryConditionFunc) *Client {
c.RetryConditions = append(c.RetryConditions, condition)
return c
} | go | func (c *Client) AddRetryCondition(condition RetryConditionFunc) *Client {
c.RetryConditions = append(c.RetryConditions, condition)
return c
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AddRetryCondition",
"(",
"condition",
"RetryConditionFunc",
")",
"*",
"Client",
"{",
"c",
".",
"RetryConditions",
"=",
"append",
"(",
"c",
".",
"RetryConditions",
",",
"condition",
")",
"\n",
"return",
"c",
"\n",
"}"
... | // AddRetryCondition method adds a retry condition function to array of functions
// that are checked to determine if the request is retried. The request will
// retry if any of the functions return true and error is nil. | [
"AddRetryCondition",
"method",
"adds",
"a",
"retry",
"condition",
"function",
"to",
"array",
"of",
"functions",
"that",
"are",
"checked",
"to",
"determine",
"if",
"the",
"request",
"is",
"retried",
".",
"The",
"request",
"will",
"retry",
"if",
"any",
"of",
"... | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L522-L525 |
25,733 | go-resty/resty | client.go | SetCertificates | func (c *Client) SetCertificates(certs ...tls.Certificate) *Client {
config, err := c.getTLSConfig()
if err != nil {
c.Log.Printf("ERROR %v", err)
return c
}
config.Certificates = append(config.Certificates, certs...)
return c
} | go | func (c *Client) SetCertificates(certs ...tls.Certificate) *Client {
config, err := c.getTLSConfig()
if err != nil {
c.Log.Printf("ERROR %v", err)
return c
}
config.Certificates = append(config.Certificates, certs...)
return c
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetCertificates",
"(",
"certs",
"...",
"tls",
".",
"Certificate",
")",
"*",
"Client",
"{",
"config",
",",
"err",
":=",
"c",
".",
"getTLSConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"Log",
... | // SetCertificates method helps to set client certificates into resty conveniently.
// | [
"SetCertificates",
"method",
"helps",
"to",
"set",
"client",
"certificates",
"into",
"resty",
"conveniently",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L639-L647 |
25,734 | go-resty/resty | client.go | SetLogPrefix | func (c *Client) SetLogPrefix(prefix string) *Client {
c.logPrefix = prefix
c.Log.SetPrefix(prefix)
return c
} | go | func (c *Client) SetLogPrefix(prefix string) *Client {
c.logPrefix = prefix
c.Log.SetPrefix(prefix)
return c
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetLogPrefix",
"(",
"prefix",
"string",
")",
"*",
"Client",
"{",
"c",
".",
"logPrefix",
"=",
"prefix",
"\n",
"c",
".",
"Log",
".",
"SetPrefix",
"(",
"prefix",
")",
"\n",
"return",
"c",
"\n",
"}"
] | // SetLogPrefix method sets the Resty logger prefix value. | [
"SetLogPrefix",
"method",
"sets",
"the",
"Resty",
"logger",
"prefix",
"value",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L739-L743 |
25,735 | go-resty/resty | client.go | enableLogPrefix | func (c *Client) enableLogPrefix() {
c.Log.SetFlags(log.LstdFlags)
c.Log.SetPrefix(c.logPrefix)
} | go | func (c *Client) enableLogPrefix() {
c.Log.SetFlags(log.LstdFlags)
c.Log.SetPrefix(c.logPrefix)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"enableLogPrefix",
"(",
")",
"{",
"c",
".",
"Log",
".",
"SetFlags",
"(",
"log",
".",
"LstdFlags",
")",
"\n",
"c",
".",
"Log",
".",
"SetPrefix",
"(",
"c",
".",
"logPrefix",
")",
"\n",
"}"
] | // enables a log prefix | [
"enables",
"a",
"log",
"prefix"
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L868-L871 |
25,736 | go-resty/resty | client.go | getTLSConfig | func (c *Client) getTLSConfig() (*tls.Config, error) {
transport, err := c.getTransport()
if err != nil {
return nil, err
}
if transport.TLSClientConfig == nil {
transport.TLSClientConfig = &tls.Config{}
}
return transport.TLSClientConfig, nil
} | go | func (c *Client) getTLSConfig() (*tls.Config, error) {
transport, err := c.getTransport()
if err != nil {
return nil, err
}
if transport.TLSClientConfig == nil {
transport.TLSClientConfig = &tls.Config{}
}
return transport.TLSClientConfig, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"getTLSConfig",
"(",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"transport",
",",
"err",
":=",
"c",
".",
"getTransport",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
... | // getting TLS client config if not exists then create one | [
"getting",
"TLS",
"client",
"config",
"if",
"not",
"exists",
"then",
"create",
"one"
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L880-L889 |
25,737 | go-resty/resty | client.go | String | func (f *File) String() string {
return fmt.Sprintf("ParamName: %v; FileName: %v", f.ParamName, f.Name)
} | go | func (f *File) String() string {
return fmt.Sprintf("ParamName: %v; FileName: %v", f.ParamName, f.Name)
} | [
"func",
"(",
"f",
"*",
"File",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"f",
".",
"ParamName",
",",
"f",
".",
"Name",
")",
"\n",
"}"
] | // String returns string value of current file details | [
"String",
"returns",
"string",
"value",
"of",
"current",
"file",
"details"
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/client.go#L916-L918 |
25,738 | go-resty/resty | util.go | DetectContentType | func DetectContentType(body interface{}) string {
contentType := plainTextType
kind := kindOf(body)
switch kind {
case reflect.Struct, reflect.Map:
contentType = jsonContentType
case reflect.String:
contentType = plainTextType
default:
if b, ok := body.([]byte); ok {
contentType = http.DetectContentType(... | go | func DetectContentType(body interface{}) string {
contentType := plainTextType
kind := kindOf(body)
switch kind {
case reflect.Struct, reflect.Map:
contentType = jsonContentType
case reflect.String:
contentType = plainTextType
default:
if b, ok := body.([]byte); ok {
contentType = http.DetectContentType(... | [
"func",
"DetectContentType",
"(",
"body",
"interface",
"{",
"}",
")",
"string",
"{",
"contentType",
":=",
"plainTextType",
"\n",
"kind",
":=",
"kindOf",
"(",
"body",
")",
"\n",
"switch",
"kind",
"{",
"case",
"reflect",
".",
"Struct",
",",
"reflect",
".",
... | // DetectContentType method is used to figure out `Request.Body` content type for request header | [
"DetectContentType",
"method",
"is",
"used",
"to",
"figure",
"out",
"Request",
".",
"Body",
"content",
"type",
"for",
"request",
"header"
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/util.go#L35-L52 |
25,739 | go-resty/resty | util.go | Unmarshalc | func Unmarshalc(c *Client, ct string, b []byte, d interface{}) (err error) {
if IsJSONType(ct) {
err = c.JSONUnmarshal(b, d)
} else if IsXMLType(ct) {
err = xml.Unmarshal(b, d)
}
return
} | go | func Unmarshalc(c *Client, ct string, b []byte, d interface{}) (err error) {
if IsJSONType(ct) {
err = c.JSONUnmarshal(b, d)
} else if IsXMLType(ct) {
err = xml.Unmarshal(b, d)
}
return
} | [
"func",
"Unmarshalc",
"(",
"c",
"*",
"Client",
",",
"ct",
"string",
",",
"b",
"[",
"]",
"byte",
",",
"d",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"if",
"IsJSONType",
"(",
"ct",
")",
"{",
"err",
"=",
"c",
".",
"JSONUnmarshal",
... | // Unmarshalc content into object from JSON or XML | [
"Unmarshalc",
"content",
"into",
"object",
"from",
"JSON",
"or",
"XML"
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/util.go#L77-L85 |
25,740 | go-resty/resty | default.go | New | func New() *Client {
cookieJar, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
return createClient(&http.Client{Jar: cookieJar})
} | go | func New() *Client {
cookieJar, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
return createClient(&http.Client{Jar: cookieJar})
} | [
"func",
"New",
"(",
")",
"*",
"Client",
"{",
"cookieJar",
",",
"_",
":=",
"cookiejar",
".",
"New",
"(",
"&",
"cookiejar",
".",
"Options",
"{",
"PublicSuffixList",
":",
"publicsuffix",
".",
"List",
"}",
")",
"\n",
"return",
"createClient",
"(",
"&",
"ht... | // New method creates a new go-resty client. | [
"New",
"method",
"creates",
"a",
"new",
"go",
"-",
"resty",
"client",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/default.go#L25-L28 |
25,741 | go-resty/resty | request.go | SetMultipartField | func (r *Request) SetMultipartField(param, fileName, contentType string, reader io.Reader) *Request {
r.isMultiPart = true
r.multipartFields = append(r.multipartFields, &MultipartField{
Param: param,
FileName: fileName,
ContentType: contentType,
Reader: reader,
})
return r
} | go | func (r *Request) SetMultipartField(param, fileName, contentType string, reader io.Reader) *Request {
r.isMultiPart = true
r.multipartFields = append(r.multipartFields, &MultipartField{
Param: param,
FileName: fileName,
ContentType: contentType,
Reader: reader,
})
return r
} | [
"func",
"(",
"r",
"*",
"Request",
")",
"SetMultipartField",
"(",
"param",
",",
"fileName",
",",
"contentType",
"string",
",",
"reader",
"io",
".",
"Reader",
")",
"*",
"Request",
"{",
"r",
".",
"isMultiPart",
"=",
"true",
"\n",
"r",
".",
"multipartFields"... | // SetMultipartField method is to set custom data using io.Reader for multipart upload. | [
"SetMultipartField",
"method",
"is",
"to",
"set",
"custom",
"data",
"using",
"io",
".",
"Reader",
"for",
"multipart",
"upload",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/request.go#L284-L293 |
25,742 | go-resty/resty | request.go | ExpectContentType | func (r *Request) ExpectContentType(contentType string) *Request {
r.fallbackContentType = contentType
return r
} | go | func (r *Request) ExpectContentType(contentType string) *Request {
r.fallbackContentType = contentType
return r
} | [
"func",
"(",
"r",
"*",
"Request",
")",
"ExpectContentType",
"(",
"contentType",
"string",
")",
"*",
"Request",
"{",
"r",
".",
"fallbackContentType",
"=",
"contentType",
"\n",
"return",
"r",
"\n",
"}"
] | // ExpectContentType method allows to provide fallback `Content-Type` for automatic unmarshalling
// when `Content-Type` response header is unavailable. | [
"ExpectContentType",
"method",
"allows",
"to",
"provide",
"fallback",
"Content",
"-",
"Type",
"for",
"automatic",
"unmarshalling",
"when",
"Content",
"-",
"Type",
"response",
"header",
"is",
"unavailable",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/request.go#L414-L417 |
25,743 | go-resty/resty | request.go | Head | func (r *Request) Head(url string) (*Response, error) {
return r.Execute(MethodHead, url)
} | go | func (r *Request) Head(url string) (*Response, error) {
return r.Execute(MethodHead, url)
} | [
"func",
"(",
"r",
"*",
"Request",
")",
"Head",
"(",
"url",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"return",
"r",
".",
"Execute",
"(",
"MethodHead",
",",
"url",
")",
"\n",
"}"
] | // Head method does HEAD HTTP request. It's defined in section 4.3.2 of RFC7231. | [
"Head",
"method",
"does",
"HEAD",
"HTTP",
"request",
".",
"It",
"s",
"defined",
"in",
"section",
"4",
".",
"3",
".",
"2",
"of",
"RFC7231",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/request.go#L437-L439 |
25,744 | go-resty/resty | request.go | Post | func (r *Request) Post(url string) (*Response, error) {
return r.Execute(MethodPost, url)
} | go | func (r *Request) Post(url string) (*Response, error) {
return r.Execute(MethodPost, url)
} | [
"func",
"(",
"r",
"*",
"Request",
")",
"Post",
"(",
"url",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"return",
"r",
".",
"Execute",
"(",
"MethodPost",
",",
"url",
")",
"\n",
"}"
] | // Post method does POST HTTP request. It's defined in section 4.3.3 of RFC7231. | [
"Post",
"method",
"does",
"POST",
"HTTP",
"request",
".",
"It",
"s",
"defined",
"in",
"section",
"4",
".",
"3",
".",
"3",
"of",
"RFC7231",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/request.go#L442-L444 |
25,745 | go-resty/resty | request.go | Put | func (r *Request) Put(url string) (*Response, error) {
return r.Execute(MethodPut, url)
} | go | func (r *Request) Put(url string) (*Response, error) {
return r.Execute(MethodPut, url)
} | [
"func",
"(",
"r",
"*",
"Request",
")",
"Put",
"(",
"url",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"return",
"r",
".",
"Execute",
"(",
"MethodPut",
",",
"url",
")",
"\n",
"}"
] | // Put method does PUT HTTP request. It's defined in section 4.3.4 of RFC7231. | [
"Put",
"method",
"does",
"PUT",
"HTTP",
"request",
".",
"It",
"s",
"defined",
"in",
"section",
"4",
".",
"3",
".",
"4",
"of",
"RFC7231",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/request.go#L447-L449 |
25,746 | go-resty/resty | request.go | Delete | func (r *Request) Delete(url string) (*Response, error) {
return r.Execute(MethodDelete, url)
} | go | func (r *Request) Delete(url string) (*Response, error) {
return r.Execute(MethodDelete, url)
} | [
"func",
"(",
"r",
"*",
"Request",
")",
"Delete",
"(",
"url",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"return",
"r",
".",
"Execute",
"(",
"MethodDelete",
",",
"url",
")",
"\n",
"}"
] | // Delete method does DELETE HTTP request. It's defined in section 4.3.5 of RFC7231. | [
"Delete",
"method",
"does",
"DELETE",
"HTTP",
"request",
".",
"It",
"s",
"defined",
"in",
"section",
"4",
".",
"3",
".",
"5",
"of",
"RFC7231",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/request.go#L452-L454 |
25,747 | go-resty/resty | request.go | Options | func (r *Request) Options(url string) (*Response, error) {
return r.Execute(MethodOptions, url)
} | go | func (r *Request) Options(url string) (*Response, error) {
return r.Execute(MethodOptions, url)
} | [
"func",
"(",
"r",
"*",
"Request",
")",
"Options",
"(",
"url",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"return",
"r",
".",
"Execute",
"(",
"MethodOptions",
",",
"url",
")",
"\n",
"}"
] | // Options method does OPTIONS HTTP request. It's defined in section 4.3.7 of RFC7231. | [
"Options",
"method",
"does",
"OPTIONS",
"HTTP",
"request",
".",
"It",
"s",
"defined",
"in",
"section",
"4",
".",
"3",
".",
"7",
"of",
"RFC7231",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/request.go#L457-L459 |
25,748 | go-resty/resty | request.go | Patch | func (r *Request) Patch(url string) (*Response, error) {
return r.Execute(MethodPatch, url)
} | go | func (r *Request) Patch(url string) (*Response, error) {
return r.Execute(MethodPatch, url)
} | [
"func",
"(",
"r",
"*",
"Request",
")",
"Patch",
"(",
"url",
"string",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"return",
"r",
".",
"Execute",
"(",
"MethodPatch",
",",
"url",
")",
"\n",
"}"
] | // Patch method does PATCH HTTP request. It's defined in section 2 of RFC5789. | [
"Patch",
"method",
"does",
"PATCH",
"HTTP",
"request",
".",
"It",
"s",
"defined",
"in",
"section",
"2",
"of",
"RFC5789",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/request.go#L462-L464 |
25,749 | go-resty/resty | response.go | Header | func (r *Response) Header() http.Header {
if r.RawResponse == nil {
return http.Header{}
}
return r.RawResponse.Header
} | go | func (r *Response) Header() http.Header {
if r.RawResponse == nil {
return http.Header{}
}
return r.RawResponse.Header
} | [
"func",
"(",
"r",
"*",
"Response",
")",
"Header",
"(",
")",
"http",
".",
"Header",
"{",
"if",
"r",
".",
"RawResponse",
"==",
"nil",
"{",
"return",
"http",
".",
"Header",
"{",
"}",
"\n",
"}",
"\n\n",
"return",
"r",
".",
"RawResponse",
".",
"Header",... | // Header method returns the response headers | [
"Header",
"method",
"returns",
"the",
"response",
"headers"
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/response.go#L66-L72 |
25,750 | go-resty/resty | response.go | Cookies | func (r *Response) Cookies() []*http.Cookie {
if r.RawResponse == nil {
return make([]*http.Cookie, 0)
}
return r.RawResponse.Cookies()
} | go | func (r *Response) Cookies() []*http.Cookie {
if r.RawResponse == nil {
return make([]*http.Cookie, 0)
}
return r.RawResponse.Cookies()
} | [
"func",
"(",
"r",
"*",
"Response",
")",
"Cookies",
"(",
")",
"[",
"]",
"*",
"http",
".",
"Cookie",
"{",
"if",
"r",
".",
"RawResponse",
"==",
"nil",
"{",
"return",
"make",
"(",
"[",
"]",
"*",
"http",
".",
"Cookie",
",",
"0",
")",
"\n",
"}",
"\... | // Cookies method to access all the response cookies | [
"Cookies",
"method",
"to",
"access",
"all",
"the",
"response",
"cookies"
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/response.go#L75-L81 |
25,751 | go-resty/resty | response.go | String | func (r *Response) String() string {
if r.body == nil {
return ""
}
return strings.TrimSpace(string(r.body))
} | go | func (r *Response) String() string {
if r.body == nil {
return ""
}
return strings.TrimSpace(string(r.body))
} | [
"func",
"(",
"r",
"*",
"Response",
")",
"String",
"(",
")",
"string",
"{",
"if",
"r",
".",
"body",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"strings",
".",
"TrimSpace",
"(",
"string",
"(",
"r",
".",
"body",
")",
")",
... | // String method returns the body of the server response as String. | [
"String",
"method",
"returns",
"the",
"body",
"of",
"the",
"server",
"response",
"as",
"String",
"."
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/response.go#L84-L90 |
25,752 | go-resty/resty | response.go | Time | func (r *Response) Time() time.Duration {
return r.receivedAt.Sub(r.Request.Time)
} | go | func (r *Response) Time() time.Duration {
return r.receivedAt.Sub(r.Request.Time)
} | [
"func",
"(",
"r",
"*",
"Response",
")",
"Time",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"r",
".",
"receivedAt",
".",
"Sub",
"(",
"r",
".",
"Request",
".",
"Time",
")",
"\n",
"}"
] | // Time method returns the time of HTTP response time that from request we sent and received a request.
// See `response.ReceivedAt` to know when client recevied response and see `response.Request.Time` to know
// when client sent a request. | [
"Time",
"method",
"returns",
"the",
"time",
"of",
"HTTP",
"response",
"time",
"that",
"from",
"request",
"we",
"sent",
"and",
"received",
"a",
"request",
".",
"See",
"response",
".",
"ReceivedAt",
"to",
"know",
"when",
"client",
"recevied",
"response",
"and"... | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/response.go#L95-L97 |
25,753 | go-resty/resty | retry.go | WaitTime | func WaitTime(value time.Duration) Option {
return func(o *Options) {
o.waitTime = value
}
} | go | func WaitTime(value time.Duration) Option {
return func(o *Options) {
o.waitTime = value
}
} | [
"func",
"WaitTime",
"(",
"value",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"waitTime",
"=",
"value",
"\n",
"}",
"\n",
"}"
] | // WaitTime sets the default wait time to sleep between requests | [
"WaitTime",
"sets",
"the",
"default",
"wait",
"time",
"to",
"sleep",
"between",
"requests"
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/retry.go#L43-L47 |
25,754 | go-resty/resty | retry.go | MaxWaitTime | func MaxWaitTime(value time.Duration) Option {
return func(o *Options) {
o.maxWaitTime = value
}
} | go | func MaxWaitTime(value time.Duration) Option {
return func(o *Options) {
o.maxWaitTime = value
}
} | [
"func",
"MaxWaitTime",
"(",
"value",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"maxWaitTime",
"=",
"value",
"\n",
"}",
"\n",
"}"
] | // MaxWaitTime sets the max wait time to sleep between requests | [
"MaxWaitTime",
"sets",
"the",
"max",
"wait",
"time",
"to",
"sleep",
"between",
"requests"
] | fa5875c0caa5c260ab78acec5a244215a730247f | https://github.com/go-resty/resty/blob/fa5875c0caa5c260ab78acec5a244215a730247f/retry.go#L50-L54 |
25,755 | nsf/gocode | _goremote/goremote.go | generate_server_rpc_wrapper | func generate_server_rpc_wrapper(out io.Writer, fun *ast.FuncDecl, name string, argcnt, replycnt int) {
fmt.Fprintf(out, "func (r *RPC) RPC_%s(args *Args_%s, reply *Reply_%s) error {\n",
name, name, name)
fmt.Fprintf(out, "\t")
for i := 0; i < replycnt; i++ {
fmt.Fprintf(out, "reply.Arg%d", i)
if i != replycn... | go | func generate_server_rpc_wrapper(out io.Writer, fun *ast.FuncDecl, name string, argcnt, replycnt int) {
fmt.Fprintf(out, "func (r *RPC) RPC_%s(args *Args_%s, reply *Reply_%s) error {\n",
name, name, name)
fmt.Fprintf(out, "\t")
for i := 0; i < replycnt; i++ {
fmt.Fprintf(out, "reply.Arg%d", i)
if i != replycn... | [
"func",
"generate_server_rpc_wrapper",
"(",
"out",
"io",
".",
"Writer",
",",
"fun",
"*",
"ast",
".",
"FuncDecl",
",",
"name",
"string",
",",
"argcnt",
",",
"replycnt",
"int",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"out",
",",
"\"",
"\\n",
"\"",
",",
"... | // function that is being exposed to an RPC API, but calls simple "Server_" one | [
"function",
"that",
"is",
"being",
"exposed",
"to",
"an",
"RPC",
"API",
"but",
"calls",
"simple",
"Server_",
"one"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/_goremote/goremote.go#L154-L174 |
25,756 | nsf/gocode | _gccgo/package.go | expect | func (this *import_data_parser) expect(x rune) string {
if x == scanner.Ident {
// special case, in gccgo import data identifier is not exactly a scanner.Ident
return this.read_ident()
}
if x == scanner.Int {
// another special case, handle negative ints as well
return this.read_int()
}
if this.toktype !... | go | func (this *import_data_parser) expect(x rune) string {
if x == scanner.Ident {
// special case, in gccgo import data identifier is not exactly a scanner.Ident
return this.read_ident()
}
if x == scanner.Int {
// another special case, handle negative ints as well
return this.read_int()
}
if this.toktype !... | [
"func",
"(",
"this",
"*",
"import_data_parser",
")",
"expect",
"(",
"x",
"rune",
")",
"string",
"{",
"if",
"x",
"==",
"scanner",
".",
"Ident",
"{",
"// special case, in gccgo import data identifier is not exactly a scanner.Ident",
"return",
"this",
".",
"read_ident",
... | // makes sure that the current token is 'x', returns it and reads the next one | [
"makes",
"sure",
"that",
"the",
"current",
"token",
"is",
"x",
"returns",
"it",
"and",
"reads",
"the",
"next",
"one"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/_gccgo/package.go#L215-L233 |
25,757 | nsf/gocode | _gccgo/package.go | expect_special | func (this *import_data_parser) expect_special(special string) {
i := 0
for i < len(special) {
if this.toktype != rune(special[i]) {
break
}
this.next()
i++
}
if i < len(special) {
this.errorf("expected: \"%s\", got something else", special)
}
} | go | func (this *import_data_parser) expect_special(special string) {
i := 0
for i < len(special) {
if this.toktype != rune(special[i]) {
break
}
this.next()
i++
}
if i < len(special) {
this.errorf("expected: \"%s\", got something else", special)
}
} | [
"func",
"(",
"this",
"*",
"import_data_parser",
")",
"expect_special",
"(",
"special",
"string",
")",
"{",
"i",
":=",
"0",
"\n",
"for",
"i",
"<",
"len",
"(",
"special",
")",
"{",
"if",
"this",
".",
"toktype",
"!=",
"rune",
"(",
"special",
"[",
"i",
... | // makes sure that the following set of tokens matches 'special', reads the next one | [
"makes",
"sure",
"that",
"the",
"following",
"set",
"of",
"tokens",
"matches",
"special",
"reads",
"the",
"next",
"one"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/_gccgo/package.go#L236-L250 |
25,758 | nsf/gocode | _gccgo/package.go | expect_ident | func (this *import_data_parser) expect_ident(ident string) {
tok := this.expect(scanner.Ident)
if tok != ident {
this.errorf("expected identifier: \"%s\", got: \"%s\"", ident, tok)
}
} | go | func (this *import_data_parser) expect_ident(ident string) {
tok := this.expect(scanner.Ident)
if tok != ident {
this.errorf("expected identifier: \"%s\", got: \"%s\"", ident, tok)
}
} | [
"func",
"(",
"this",
"*",
"import_data_parser",
")",
"expect_ident",
"(",
"ident",
"string",
")",
"{",
"tok",
":=",
"this",
".",
"expect",
"(",
"scanner",
".",
"Ident",
")",
"\n",
"if",
"tok",
"!=",
"ident",
"{",
"this",
".",
"errorf",
"(",
"\"",
"\\... | // makes sure that the current token is scanner.Ident and is equals to 'ident', reads the next one | [
"makes",
"sure",
"that",
"the",
"current",
"token",
"is",
"scanner",
".",
"Ident",
"and",
"is",
"equals",
"to",
"ident",
"reads",
"the",
"next",
"one"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/_gccgo/package.go#L253-L258 |
25,759 | nsf/gocode | autocompletefile.go | process_data | func (f *auto_complete_file) process_data(data []byte) {
cur, filedata, block := rip_off_decl(data, f.cursor)
file, err := parser.ParseFile(f.fset, "", filedata, parser.AllErrors)
if err != nil && *g_debug {
log_parse_error("Error parsing input file (outer block)", err)
}
f.package_name = package_name(file)
f.... | go | func (f *auto_complete_file) process_data(data []byte) {
cur, filedata, block := rip_off_decl(data, f.cursor)
file, err := parser.ParseFile(f.fset, "", filedata, parser.AllErrors)
if err != nil && *g_debug {
log_parse_error("Error parsing input file (outer block)", err)
}
f.package_name = package_name(file)
f.... | [
"func",
"(",
"f",
"*",
"auto_complete_file",
")",
"process_data",
"(",
"data",
"[",
"]",
"byte",
")",
"{",
"cur",
",",
"filedata",
",",
"block",
":=",
"rip_off_decl",
"(",
"data",
",",
"f",
".",
"cursor",
")",
"\n",
"file",
",",
"err",
":=",
"parser"... | // this one is used for current file buffer exclusively | [
"this",
"one",
"is",
"used",
"for",
"current",
"file",
"buffer",
"exclusively"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/autocompletefile.go#L67-L110 |
25,760 | nsf/gocode | package_ibin.go | pos | func (r *importReader) pos() {
if r.int64() != deltaNewFile {
} else if l := r.int64(); l == -1 {
} else {
r.string()
}
} | go | func (r *importReader) pos() {
if r.int64() != deltaNewFile {
} else if l := r.int64(); l == -1 {
} else {
r.string()
}
} | [
"func",
"(",
"r",
"*",
"importReader",
")",
"pos",
"(",
")",
"{",
"if",
"r",
".",
"int64",
"(",
")",
"!=",
"deltaNewFile",
"{",
"}",
"else",
"if",
"l",
":=",
"r",
".",
"int64",
"(",
")",
";",
"l",
"==",
"-",
"1",
"{",
"}",
"else",
"{",
"r",... | // we don't care about that, let's just skip it | [
"we",
"don",
"t",
"care",
"about",
"that",
"let",
"s",
"just",
"skip",
"it"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/package_ibin.go#L340-L346 |
25,761 | nsf/gocode | utils.go | readdir_lstat | func readdir_lstat(name string) ([]os.FileInfo, error) {
f, err := os.Open(name)
if err != nil {
return nil, err
}
defer f.Close()
names, err := f.Readdirnames(-1)
if err != nil {
return nil, err
}
out := make([]os.FileInfo, 0, len(names))
for _, lname := range names {
s, err := os.Lstat(filepath.Join(... | go | func readdir_lstat(name string) ([]os.FileInfo, error) {
f, err := os.Open(name)
if err != nil {
return nil, err
}
defer f.Close()
names, err := f.Readdirnames(-1)
if err != nil {
return nil, err
}
out := make([]os.FileInfo, 0, len(names))
for _, lname := range names {
s, err := os.Lstat(filepath.Join(... | [
"func",
"readdir_lstat",
"(",
"name",
"string",
")",
"(",
"[",
"]",
"os",
".",
"FileInfo",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n... | // our own readdir, which skips the files it cannot lstat | [
"our",
"own",
"readdir",
"which",
"skips",
"the",
"files",
"it",
"cannot",
"lstat"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/utils.go#L17-L38 |
25,762 | nsf/gocode | utils.go | readdir | func readdir(dirname string) []os.FileInfo {
f, err := os.Open(dirname)
if err != nil {
return nil
}
fi, err := f.Readdir(-1)
f.Close()
if err != nil {
panic(err)
}
return fi
} | go | func readdir(dirname string) []os.FileInfo {
f, err := os.Open(dirname)
if err != nil {
return nil
}
fi, err := f.Readdir(-1)
f.Close()
if err != nil {
panic(err)
}
return fi
} | [
"func",
"readdir",
"(",
"dirname",
"string",
")",
"[",
"]",
"os",
".",
"FileInfo",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"dirname",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"fi",
",",
"err",
":="... | // our other readdir function, only opens and reads | [
"our",
"other",
"readdir",
"function",
"only",
"opens",
"and",
"reads"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/utils.go#L41-L52 |
25,763 | nsf/gocode | utils.go | find_gb_project_root | func find_gb_project_root(path string) (string, error) {
path = filepath.Dir(path)
if path == "" {
return "", fmt.Errorf("project root is blank")
}
start := path
for path != "/" {
root := filepath.Join(path, "src")
if _, err := os.Stat(root); err != nil {
if os.IsNotExist(err) {
path = filepath.Dir(pa... | go | func find_gb_project_root(path string) (string, error) {
path = filepath.Dir(path)
if path == "" {
return "", fmt.Errorf("project root is blank")
}
start := path
for path != "/" {
root := filepath.Join(path, "src")
if _, err := os.Stat(root); err != nil {
if os.IsNotExist(err) {
path = filepath.Dir(pa... | [
"func",
"find_gb_project_root",
"(",
"path",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"path",
"=",
"filepath",
".",
"Dir",
"(",
"path",
")",
"\n",
"if",
"path",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(... | // Code taken directly from `gb`, I hope author doesn't mind. | [
"Code",
"taken",
"directly",
"from",
"gb",
"I",
"hope",
"author",
"doesn",
"t",
"mind",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/utils.go#L130-L152 |
25,764 | nsf/gocode | autocompletecontext.go | check_type_expr | func check_type_expr(e ast.Expr) bool {
switch t := e.(type) {
case *ast.StarExpr:
return check_type_expr(t.X)
case *ast.ArrayType:
return check_type_expr(t.Elt)
case *ast.SelectorExpr:
return check_type_expr(t.X)
case *ast.FuncType:
a := check_func_field_list(t.Params)
b := check_func_field_list(t.Resul... | go | func check_type_expr(e ast.Expr) bool {
switch t := e.(type) {
case *ast.StarExpr:
return check_type_expr(t.X)
case *ast.ArrayType:
return check_type_expr(t.Elt)
case *ast.SelectorExpr:
return check_type_expr(t.X)
case *ast.FuncType:
a := check_func_field_list(t.Params)
b := check_func_field_list(t.Resul... | [
"func",
"check_type_expr",
"(",
"e",
"ast",
".",
"Expr",
")",
"bool",
"{",
"switch",
"t",
":=",
"e",
".",
"(",
"type",
")",
"{",
"case",
"*",
"ast",
".",
"StarExpr",
":",
"return",
"check_type_expr",
"(",
"t",
".",
"X",
")",
"\n",
"case",
"*",
"a... | // checks for a type expression correctness, it the type expression has
// ast.BadExpr somewhere, returns false, otherwise true | [
"checks",
"for",
"a",
"type",
"expression",
"correctness",
"it",
"the",
"type",
"expression",
"has",
"ast",
".",
"BadExpr",
"somewhere",
"returns",
"false",
"otherwise",
"true"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/autocompletecontext.go#L653-L678 |
25,765 | nsf/gocode | package_bin.go | rawInt64 | func (p *gc_bin_parser) rawInt64() int64 {
i, err := binary.ReadVarint(p)
if err != nil {
panic(fmt.Sprintf("read error: %v", err))
}
return i
} | go | func (p *gc_bin_parser) rawInt64() int64 {
i, err := binary.ReadVarint(p)
if err != nil {
panic(fmt.Sprintf("read error: %v", err))
}
return i
} | [
"func",
"(",
"p",
"*",
"gc_bin_parser",
")",
"rawInt64",
"(",
")",
"int64",
"{",
"i",
",",
"err",
":=",
"binary",
".",
"ReadVarint",
"(",
"p",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
... | // rawInt64 should only be used by low-level decoders. | [
"rawInt64",
"should",
"only",
"be",
"used",
"by",
"low",
"-",
"level",
"decoders",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/package_bin.go#L696-L702 |
25,766 | nsf/gocode | package_bin.go | rawStringln | func (p *gc_bin_parser) rawStringln(b byte) string {
p.buf = p.buf[:0]
for b != '\n' {
p.buf = append(p.buf, b)
b = p.rawByte()
}
return string(p.buf)
} | go | func (p *gc_bin_parser) rawStringln(b byte) string {
p.buf = p.buf[:0]
for b != '\n' {
p.buf = append(p.buf, b)
b = p.rawByte()
}
return string(p.buf)
} | [
"func",
"(",
"p",
"*",
"gc_bin_parser",
")",
"rawStringln",
"(",
"b",
"byte",
")",
"string",
"{",
"p",
".",
"buf",
"=",
"p",
".",
"buf",
"[",
":",
"0",
"]",
"\n",
"for",
"b",
"!=",
"'\\n'",
"{",
"p",
".",
"buf",
"=",
"append",
"(",
"p",
".",
... | // rawStringln should only be used to read the initial version string. | [
"rawStringln",
"should",
"only",
"be",
"used",
"to",
"read",
"the",
"initial",
"version",
"string",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/package_bin.go#L705-L712 |
25,767 | nsf/gocode | declcache.go | collect_package_imports | func collect_package_imports(filename string, decls []ast.Decl, context *package_lookup_context) []package_import {
pi := make([]package_import, 0, 16)
for _, decl := range decls {
if gd, ok := decl.(*ast.GenDecl); ok && gd.Tok == token.IMPORT {
for _, spec := range gd.Specs {
imp := spec.(*ast.ImportSpec)
... | go | func collect_package_imports(filename string, decls []ast.Decl, context *package_lookup_context) []package_import {
pi := make([]package_import, 0, 16)
for _, decl := range decls {
if gd, ok := decl.(*ast.GenDecl); ok && gd.Tok == token.IMPORT {
for _, spec := range gd.Specs {
imp := spec.(*ast.ImportSpec)
... | [
"func",
"collect_package_imports",
"(",
"filename",
"string",
",",
"decls",
"[",
"]",
"ast",
".",
"Decl",
",",
"context",
"*",
"package_lookup_context",
")",
"[",
"]",
"package_import",
"{",
"pi",
":=",
"make",
"(",
"[",
"]",
"package_import",
",",
"0",
",... | // Parses import declarations until the first non-import declaration and fills
// `packages` array with import information. | [
"Parses",
"import",
"declarations",
"until",
"the",
"first",
"non",
"-",
"import",
"declaration",
"and",
"fills",
"packages",
"array",
"with",
"import",
"information",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/declcache.go#L29-L46 |
25,768 | nsf/gocode | declcache.go | autobuild | func autobuild(p *build.Package) error {
if p.Dir == "" {
return fmt.Errorf("no files to build")
}
ps, err := os.Stat(p.PkgObj)
if err != nil {
// Assume package file does not exist and build for the first time.
return build_package(p)
}
pt := ps.ModTime()
fs, err := readdir_lstat(p.Dir)
if err != nil {
... | go | func autobuild(p *build.Package) error {
if p.Dir == "" {
return fmt.Errorf("no files to build")
}
ps, err := os.Stat(p.PkgObj)
if err != nil {
// Assume package file does not exist and build for the first time.
return build_package(p)
}
pt := ps.ModTime()
fs, err := readdir_lstat(p.Dir)
if err != nil {
... | [
"func",
"autobuild",
"(",
"p",
"*",
"build",
".",
"Package",
")",
"error",
"{",
"if",
"p",
".",
"Dir",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"ps",
",",
"err",
":=",
"os",
".",
"Stat",
"(... | // autobuild compares the mod time of the source files of the package, and if any of them is newer
// than the package object file will rebuild it. | [
"autobuild",
"compares",
"the",
"mod",
"time",
"of",
"the",
"source",
"files",
"of",
"the",
"package",
"and",
"if",
"any",
"of",
"them",
"is",
"newer",
"than",
"the",
"package",
"object",
"file",
"will",
"rebuild",
"it",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/declcache.go#L192-L216 |
25,769 | nsf/gocode | declcache.go | try_autobuild | func try_autobuild(p *build.Package) {
if g_config.Autobuild {
err := autobuild(p)
if err != nil && *g_debug {
log.Printf("Autobuild error: %s\n", err)
}
}
} | go | func try_autobuild(p *build.Package) {
if g_config.Autobuild {
err := autobuild(p)
if err != nil && *g_debug {
log.Printf("Autobuild error: %s\n", err)
}
}
} | [
"func",
"try_autobuild",
"(",
"p",
"*",
"build",
".",
"Package",
")",
"{",
"if",
"g_config",
".",
"Autobuild",
"{",
"err",
":=",
"autobuild",
"(",
"p",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"*",
"g_debug",
"{",
"log",
".",
"Printf",
"(",
"\"",... | // executes autobuild function if autobuild option is enabled, logs error and
// ignores it | [
"executes",
"autobuild",
"function",
"if",
"autobuild",
"option",
"is",
"enabled",
"logs",
"error",
"and",
"ignores",
"it"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/declcache.go#L257-L264 |
25,770 | nsf/gocode | declcache.go | gopath | func (ctxt *package_lookup_context) gopath() []string {
var all []string
for _, p := range filepath.SplitList(ctxt.GOPATH) {
if p == "" || p == ctxt.GOROOT {
// Empty paths are uninteresting.
// If the path is the GOROOT, ignore it.
// People sometimes set GOPATH=$GOROOT.
// Do not get confused by this ... | go | func (ctxt *package_lookup_context) gopath() []string {
var all []string
for _, p := range filepath.SplitList(ctxt.GOPATH) {
if p == "" || p == ctxt.GOROOT {
// Empty paths are uninteresting.
// If the path is the GOROOT, ignore it.
// People sometimes set GOPATH=$GOROOT.
// Do not get confused by this ... | [
"func",
"(",
"ctxt",
"*",
"package_lookup_context",
")",
"gopath",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"all",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"filepath",
".",
"SplitList",
"(",
"ctxt",
".",
"GOPATH",
")",
"{",
"... | // gopath returns the list of Go path directories. | [
"gopath",
"returns",
"the",
"list",
"of",
"Go",
"path",
"directories",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/declcache.go#L431-L459 |
25,771 | nsf/gocode | decl.go | infer_type | func (d *decl) infer_type() (ast.Expr, *scope) {
// special case for range vars
if d.is_rangevar() {
var scope *scope
d.typ, scope = infer_range_type(d.value, d.scope, d.value_index)
return d.typ, scope
}
switch d.class {
case decl_package:
// package is handled specially in inferType
return nil, nil
c... | go | func (d *decl) infer_type() (ast.Expr, *scope) {
// special case for range vars
if d.is_rangevar() {
var scope *scope
d.typ, scope = infer_range_type(d.value, d.scope, d.value_index)
return d.typ, scope
}
switch d.class {
case decl_package:
// package is handled specially in inferType
return nil, nil
c... | [
"func",
"(",
"d",
"*",
"decl",
")",
"infer_type",
"(",
")",
"(",
"ast",
".",
"Expr",
",",
"*",
"scope",
")",
"{",
"// special case for range vars",
"if",
"d",
".",
"is_rangevar",
"(",
")",
"{",
"var",
"scope",
"*",
"scope",
"\n",
"d",
".",
"typ",
"... | // Uses Value, ValueIndex and Scope to infer the type of this
// declaration. Returns the type itself and the scope where this type
// makes sense. | [
"Uses",
"Value",
"ValueIndex",
"and",
"Scope",
"to",
"infer",
"the",
"type",
"of",
"this",
"declaration",
".",
"Returns",
"the",
"type",
"itself",
"and",
"the",
"scope",
"where",
"this",
"type",
"makes",
"sense",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/decl.go#L954-L985 |
25,772 | nsf/gocode | scope.go | add_named_decl | func (s *scope) add_named_decl(d *decl) *decl {
return s.add_decl(d.name, d)
} | go | func (s *scope) add_named_decl(d *decl) *decl {
return s.add_decl(d.name, d)
} | [
"func",
"(",
"s",
"*",
"scope",
")",
"add_named_decl",
"(",
"d",
"*",
"decl",
")",
"*",
"decl",
"{",
"return",
"s",
".",
"add_decl",
"(",
"d",
".",
"name",
",",
"d",
")",
"\n",
"}"
] | // adds declaration or returns an existing one | [
"adds",
"declaration",
"or",
"returns",
"an",
"existing",
"one"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/scope.go#L39-L41 |
25,773 | nsf/gocode | cursorcontext.go | deduce_cursor_decl | func (c *auto_complete_context) deduce_cursor_decl(iter *token_iterator) (*decl, ast.Expr) {
expr, err := parser.ParseExpr(iter.extract_go_expr())
if err != nil {
return nil, nil
}
return expr_to_decl(expr, c.current.scope), expr
} | go | func (c *auto_complete_context) deduce_cursor_decl(iter *token_iterator) (*decl, ast.Expr) {
expr, err := parser.ParseExpr(iter.extract_go_expr())
if err != nil {
return nil, nil
}
return expr_to_decl(expr, c.current.scope), expr
} | [
"func",
"(",
"c",
"*",
"auto_complete_context",
")",
"deduce_cursor_decl",
"(",
"iter",
"*",
"token_iterator",
")",
"(",
"*",
"decl",
",",
"ast",
".",
"Expr",
")",
"{",
"expr",
",",
"err",
":=",
"parser",
".",
"ParseExpr",
"(",
"iter",
".",
"extract_go_e... | // this function is called when the cursor is at the '.' and you need to get the
// declaration before that dot | [
"this",
"function",
"is",
"called",
"when",
"the",
"cursor",
"is",
"at",
"the",
".",
"and",
"you",
"need",
"to",
"get",
"the",
"declaration",
"before",
"that",
"dot"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/cursorcontext.go#L264-L270 |
25,774 | nsf/gocode | cursorcontext.go | deduce_struct_type_decl | func (c *auto_complete_context) deduce_struct_type_decl(iter *token_iterator) *decl {
typ := iter.extract_struct_type()
if typ == "" {
return nil
}
expr, err := parser.ParseExpr(typ)
if err != nil {
return nil
}
decl := type_to_decl(expr, c.current.scope)
if decl == nil {
return nil
}
// we allow only... | go | func (c *auto_complete_context) deduce_struct_type_decl(iter *token_iterator) *decl {
typ := iter.extract_struct_type()
if typ == "" {
return nil
}
expr, err := parser.ParseExpr(typ)
if err != nil {
return nil
}
decl := type_to_decl(expr, c.current.scope)
if decl == nil {
return nil
}
// we allow only... | [
"func",
"(",
"c",
"*",
"auto_complete_context",
")",
"deduce_struct_type_decl",
"(",
"iter",
"*",
"token_iterator",
")",
"*",
"decl",
"{",
"typ",
":=",
"iter",
".",
"extract_struct_type",
"(",
")",
"\n",
"if",
"typ",
"==",
"\"",
"\"",
"{",
"return",
"nil",... | // try to find and extract the surrounding struct literal type | [
"try",
"to",
"find",
"and",
"extract",
"the",
"surrounding",
"struct",
"literal",
"type"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/cursorcontext.go#L273-L298 |
25,775 | nsf/gocode | package.go | new_package_file_cache_forever | func new_package_file_cache_forever(name, defalias string) *package_file_cache {
m := new(package_file_cache)
m.name = name
m.mtime = -1
m.defalias = defalias
return m
} | go | func new_package_file_cache_forever(name, defalias string) *package_file_cache {
m := new(package_file_cache)
m.name = name
m.mtime = -1
m.defalias = defalias
return m
} | [
"func",
"new_package_file_cache_forever",
"(",
"name",
",",
"defalias",
"string",
")",
"*",
"package_file_cache",
"{",
"m",
":=",
"new",
"(",
"package_file_cache",
")",
"\n",
"m",
".",
"name",
"=",
"name",
"\n",
"m",
".",
"mtime",
"=",
"-",
"1",
"\n",
"m... | // Creates a cache that stays in cache forever. Useful for built-in packages. | [
"Creates",
"a",
"cache",
"that",
"stays",
"in",
"cache",
"forever",
".",
"Useful",
"for",
"built",
"-",
"in",
"packages",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/package.go#L43-L49 |
25,776 | nsf/gocode | package.go | append_packages | func (c package_cache) append_packages(ps map[string]*package_file_cache, pkgs []package_import) {
for _, m := range pkgs {
if _, ok := ps[m.abspath]; ok {
continue
}
if mod, ok := c[m.abspath]; ok {
ps[m.abspath] = mod
} else {
mod = new_package_file_cache(m.abspath, m.path)
ps[m.abspath] = mod
... | go | func (c package_cache) append_packages(ps map[string]*package_file_cache, pkgs []package_import) {
for _, m := range pkgs {
if _, ok := ps[m.abspath]; ok {
continue
}
if mod, ok := c[m.abspath]; ok {
ps[m.abspath] = mod
} else {
mod = new_package_file_cache(m.abspath, m.path)
ps[m.abspath] = mod
... | [
"func",
"(",
"c",
"package_cache",
")",
"append_packages",
"(",
"ps",
"map",
"[",
"string",
"]",
"*",
"package_file_cache",
",",
"pkgs",
"[",
"]",
"package_import",
")",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"pkgs",
"{",
"if",
"_",
",",
"ok",
":=... | // Function fills 'ps' set with packages from 'packages' import information.
// In case if package is not in the cache, it creates one and adds one to the cache. | [
"Function",
"fills",
"ps",
"set",
"with",
"packages",
"from",
"packages",
"import",
"information",
".",
"In",
"case",
"if",
"package",
"is",
"not",
"in",
"the",
"cache",
"it",
"creates",
"one",
"and",
"adds",
"one",
"to",
"the",
"cache",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/package.go#L228-L242 |
25,777 | nsf/gocode | package_text.go | parse_package | func (p *gc_parser) parse_package() *ast.Ident {
path, err := strconv.Unquote(p.expect(scanner.String))
if err != nil {
panic(err)
}
return ast.NewIdent(path)
} | go | func (p *gc_parser) parse_package() *ast.Ident {
path, err := strconv.Unquote(p.expect(scanner.String))
if err != nil {
panic(err)
}
return ast.NewIdent(path)
} | [
"func",
"(",
"p",
"*",
"gc_parser",
")",
"parse_package",
"(",
")",
"*",
"ast",
".",
"Ident",
"{",
"path",
",",
"err",
":=",
"strconv",
".",
"Unquote",
"(",
"p",
".",
"expect",
"(",
"scanner",
".",
"String",
")",
")",
"\n",
"if",
"err",
"!=",
"ni... | // ImportPath = string_lit .
// quoted name of the path, but we return it as an identifier, taking an alias
// from 'pathToAlias' map, it is filled by import statements | [
"ImportPath",
"=",
"string_lit",
".",
"quoted",
"name",
"of",
"the",
"path",
"but",
"we",
"return",
"it",
"as",
"an",
"identifier",
"taking",
"an",
"alias",
"from",
"pathToAlias",
"map",
"it",
"is",
"filled",
"by",
"import",
"statements"
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/package_text.go#L161-L168 |
25,778 | nsf/gocode | package_text.go | parse_name | func (p *gc_parser) parse_name() (string, ast.Expr) {
switch p.tok {
case scanner.Ident:
name := p.lit
p.next()
return name, ast.NewIdent(name)
case '?':
p.next()
return "?", ast.NewIdent("?")
case '@':
en := p.parse_exported_name()
return en.Sel.Name, en
}
p.error("name expected")
return "", nil
} | go | func (p *gc_parser) parse_name() (string, ast.Expr) {
switch p.tok {
case scanner.Ident:
name := p.lit
p.next()
return name, ast.NewIdent(name)
case '?':
p.next()
return "?", ast.NewIdent("?")
case '@':
en := p.parse_exported_name()
return en.Sel.Name, en
}
p.error("name expected")
return "", nil
} | [
"func",
"(",
"p",
"*",
"gc_parser",
")",
"parse_name",
"(",
")",
"(",
"string",
",",
"ast",
".",
"Expr",
")",
"{",
"switch",
"p",
".",
"tok",
"{",
"case",
"scanner",
".",
"Ident",
":",
"name",
":=",
"p",
".",
"lit",
"\n",
"p",
".",
"next",
"(",... | // Name = identifier | "?" | ExportedName . | [
"Name",
"=",
"identifier",
"|",
"?",
"|",
"ExportedName",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/package_text.go#L185-L200 |
25,779 | nsf/gocode | package_text.go | parse_type_decl | func (p *gc_parser) parse_type_decl() (string, *ast.GenDecl) {
p.expect_keyword("type")
name := p.parse_exported_name()
typ := p.parse_type()
return name.X.(*ast.Ident).Name, &ast.GenDecl{
Tok: token.TYPE,
Specs: []ast.Spec{
&ast.TypeSpec{
Name: name.Sel,
Type: typ,
},
},
}
} | go | func (p *gc_parser) parse_type_decl() (string, *ast.GenDecl) {
p.expect_keyword("type")
name := p.parse_exported_name()
typ := p.parse_type()
return name.X.(*ast.Ident).Name, &ast.GenDecl{
Tok: token.TYPE,
Specs: []ast.Spec{
&ast.TypeSpec{
Name: name.Sel,
Type: typ,
},
},
}
} | [
"func",
"(",
"p",
"*",
"gc_parser",
")",
"parse_type_decl",
"(",
")",
"(",
"string",
",",
"*",
"ast",
".",
"GenDecl",
")",
"{",
"p",
".",
"expect_keyword",
"(",
"\"",
"\"",
")",
"\n",
"name",
":=",
"p",
".",
"parse_exported_name",
"(",
")",
"\n",
"... | // TypeDecl = "type" ExportedName Type . | [
"TypeDecl",
"=",
"type",
"ExportedName",
"Type",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/package_text.go#L538-L551 |
25,780 | nsf/gocode | package_text.go | parse_var_decl | func (p *gc_parser) parse_var_decl() (string, *ast.GenDecl) {
p.expect_keyword("var")
name := p.parse_exported_name()
typ := p.parse_type()
return name.X.(*ast.Ident).Name, &ast.GenDecl{
Tok: token.VAR,
Specs: []ast.Spec{
&ast.ValueSpec{
Names: []*ast.Ident{name.Sel},
Type: typ,
},
},
}
} | go | func (p *gc_parser) parse_var_decl() (string, *ast.GenDecl) {
p.expect_keyword("var")
name := p.parse_exported_name()
typ := p.parse_type()
return name.X.(*ast.Ident).Name, &ast.GenDecl{
Tok: token.VAR,
Specs: []ast.Spec{
&ast.ValueSpec{
Names: []*ast.Ident{name.Sel},
Type: typ,
},
},
}
} | [
"func",
"(",
"p",
"*",
"gc_parser",
")",
"parse_var_decl",
"(",
")",
"(",
"string",
",",
"*",
"ast",
".",
"GenDecl",
")",
"{",
"p",
".",
"expect_keyword",
"(",
"\"",
"\"",
")",
"\n",
"name",
":=",
"p",
".",
"parse_exported_name",
"(",
")",
"\n",
"t... | // VarDecl = "var" ExportedName Type . | [
"VarDecl",
"=",
"var",
"ExportedName",
"Type",
"."
] | 5bee97b488366fd20b054d0861b89834ff5bbfb2 | https://github.com/nsf/gocode/blob/5bee97b488366fd20b054d0861b89834ff5bbfb2/package_text.go#L554-L567 |
25,781 | veandco/go-sdl2 | ttf/sdl_ttf.go | RenderUTF8BlendedWrapped | func (f *Font) RenderUTF8BlendedWrapped(text string, fg sdl.Color, wrapLength int) (*sdl.Surface, error) {
_text := C.CString(text)
defer C.free(unsafe.Pointer(_text))
_c := C.SDL_Color{C.Uint8(fg.R), C.Uint8(fg.G), C.Uint8(fg.B), C.Uint8(fg.A)}
surface := (*sdl.Surface)(unsafe.Pointer(C.TTF_RenderUTF8_Blended_Wrap... | go | func (f *Font) RenderUTF8BlendedWrapped(text string, fg sdl.Color, wrapLength int) (*sdl.Surface, error) {
_text := C.CString(text)
defer C.free(unsafe.Pointer(_text))
_c := C.SDL_Color{C.Uint8(fg.R), C.Uint8(fg.G), C.Uint8(fg.B), C.Uint8(fg.A)}
surface := (*sdl.Surface)(unsafe.Pointer(C.TTF_RenderUTF8_Blended_Wrap... | [
"func",
"(",
"f",
"*",
"Font",
")",
"RenderUTF8BlendedWrapped",
"(",
"text",
"string",
",",
"fg",
"sdl",
".",
"Color",
",",
"wrapLength",
"int",
")",
"(",
"*",
"sdl",
".",
"Surface",
",",
"error",
")",
"{",
"_text",
":=",
"C",
".",
"CString",
"(",
... | // RenderUTF8BlendedWrapped creates a 32-bit ARGB surface and render the given text at high quality, using alpha blending to dither the font with the given color. Text is wrapped to multiple lines on line endings and on word boundaries if it extends beyond wrapLength in pixels. | [
"RenderUTF8BlendedWrapped",
"creates",
"a",
"32",
"-",
"bit",
"ARGB",
"surface",
"and",
"render",
"the",
"given",
"text",
"at",
"high",
"quality",
"using",
"alpha",
"blending",
"to",
"dither",
"the",
"font",
"with",
"the",
"given",
"color",
".",
"Text",
"is"... | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/ttf/sdl_ttf.go#L176-L185 |
25,782 | veandco/go-sdl2 | raster/painter.go | Paint | func (p *ImagePainter) Paint(ss []raster.Span, done bool) {
// Convert color to RGBA
dr, dg, db, da := p.c.RGBA() // 16 bit values
// Alpha mask
const m = 1<<16 - 1
// Draw spans
b := p.Image.Bounds()
for _, s := range ss {
if s.Y < b.Min.Y || s.Y >= b.Max.Y {
continue
}
if s.X0 < b.Min.X {
s.X0 = b.... | go | func (p *ImagePainter) Paint(ss []raster.Span, done bool) {
// Convert color to RGBA
dr, dg, db, da := p.c.RGBA() // 16 bit values
// Alpha mask
const m = 1<<16 - 1
// Draw spans
b := p.Image.Bounds()
for _, s := range ss {
if s.Y < b.Min.Y || s.Y >= b.Max.Y {
continue
}
if s.X0 < b.Min.X {
s.X0 = b.... | [
"func",
"(",
"p",
"*",
"ImagePainter",
")",
"Paint",
"(",
"ss",
"[",
"]",
"raster",
".",
"Span",
",",
"done",
"bool",
")",
"{",
"// Convert color to RGBA",
"dr",
",",
"dg",
",",
"db",
",",
"da",
":=",
"p",
".",
"c",
".",
"RGBA",
"(",
")",
"// 16 ... | // Paint a batch of Spans using the current ImagePainter image and color.
// Image's Color model will be used to convert the color. | [
"Paint",
"a",
"batch",
"of",
"Spans",
"using",
"the",
"current",
"ImagePainter",
"image",
"and",
"color",
".",
"Image",
"s",
"Color",
"model",
"will",
"be",
"used",
"to",
"convert",
"the",
"color",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/raster/painter.go#L23-L58 |
25,783 | veandco/go-sdl2 | mix/sdl_mixer.go | LoadMUSTypeRW | func LoadMUSTypeRW(src *sdl.RWops, type_ MusicType, freesrc int) (mus *Music, err error) {
_src := (*C.SDL_RWops)(unsafe.Pointer(src))
_type := (C.Mix_MusicType)(type_)
_freesrc := (C.int)(freesrc)
mus = (*Music)(unsafe.Pointer(C.Mix_LoadMUSType_RW(_src, _type,
_freesrc)))
if mus == nil {
err = sdl.GetError()
... | go | func LoadMUSTypeRW(src *sdl.RWops, type_ MusicType, freesrc int) (mus *Music, err error) {
_src := (*C.SDL_RWops)(unsafe.Pointer(src))
_type := (C.Mix_MusicType)(type_)
_freesrc := (C.int)(freesrc)
mus = (*Music)(unsafe.Pointer(C.Mix_LoadMUSType_RW(_src, _type,
_freesrc)))
if mus == nil {
err = sdl.GetError()
... | [
"func",
"LoadMUSTypeRW",
"(",
"src",
"*",
"sdl",
".",
"RWops",
",",
"type_",
"MusicType",
",",
"freesrc",
"int",
")",
"(",
"mus",
"*",
"Music",
",",
"err",
"error",
")",
"{",
"_src",
":=",
"(",
"*",
"C",
".",
"SDL_RWops",
")",
"(",
"unsafe",
".",
... | // LoadMUSTypeRW loads a music file from an sdl.RWop object assuming a specific format. | [
"LoadMUSTypeRW",
"loads",
"a",
"music",
"file",
"from",
"an",
"sdl",
".",
"RWop",
"object",
"assuming",
"a",
"specific",
"format",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/mix/sdl_mixer.go#L209-L219 |
25,784 | veandco/go-sdl2 | mix/sdl_mixer.go | LengthInMs | func (chunk *Chunk) LengthInMs() int {
_chunk := (*C.Mix_Chunk)(unsafe.Pointer(chunk))
return int(C.getChunkTimeMilliseconds(_chunk))
} | go | func (chunk *Chunk) LengthInMs() int {
_chunk := (*C.Mix_Chunk)(unsafe.Pointer(chunk))
return int(C.getChunkTimeMilliseconds(_chunk))
} | [
"func",
"(",
"chunk",
"*",
"Chunk",
")",
"LengthInMs",
"(",
")",
"int",
"{",
"_chunk",
":=",
"(",
"*",
"C",
".",
"Mix_Chunk",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"chunk",
")",
")",
"\n",
"return",
"int",
"(",
"C",
".",
"getChunkTimeMilliseconds"... | // LengthInMs returns the playing time of the chunk in milliseconds. | [
"LengthInMs",
"returns",
"the",
"playing",
"time",
"of",
"the",
"chunk",
"in",
"milliseconds",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/mix/sdl_mixer.go#L378-L381 |
25,785 | veandco/go-sdl2 | mix/sdl_mixer.go | SetSynchroValue | func SetSynchroValue(value int) bool {
_value := (C.int)(value)
return int(C.Mix_SetSynchroValue(_value)) == 0
} | go | func SetSynchroValue(value int) bool {
_value := (C.int)(value)
return int(C.Mix_SetSynchroValue(_value)) == 0
} | [
"func",
"SetSynchroValue",
"(",
"value",
"int",
")",
"bool",
"{",
"_value",
":=",
"(",
"C",
".",
"int",
")",
"(",
"value",
")",
"\n",
"return",
"int",
"(",
"C",
".",
"Mix_SetSynchroValue",
"(",
"_value",
")",
")",
"==",
"0",
"\n",
"}"
] | // SetSynchroValue sets the synchro value. | [
"SetSynchroValue",
"sets",
"the",
"synchro",
"value",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/mix/sdl_mixer.go#L620-L623 |
25,786 | veandco/go-sdl2 | sdl/audio.go | AllocBuf | func (cvt *AudioCVT) AllocBuf(size uintptr) {
cvt.Buf = C.malloc(C.size_t(size))
} | go | func (cvt *AudioCVT) AllocBuf(size uintptr) {
cvt.Buf = C.malloc(C.size_t(size))
} | [
"func",
"(",
"cvt",
"*",
"AudioCVT",
")",
"AllocBuf",
"(",
"size",
"uintptr",
")",
"{",
"cvt",
".",
"Buf",
"=",
"C",
".",
"malloc",
"(",
"C",
".",
"size_t",
"(",
"size",
")",
")",
"\n",
"}"
] | // AllocBuf allocates the requested memory for AudioCVT buffer. | [
"AllocBuf",
"allocates",
"the",
"requested",
"memory",
"for",
"AudioCVT",
"buffer",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/sdl/audio.go#L295-L297 |
25,787 | veandco/go-sdl2 | sdl/render.go | SetDrawColorArray | func (renderer *Renderer) SetDrawColorArray(bs ...uint8) error {
_bs := []C.Uint8{0, 0, 0, 255}
for i := 0; i < len(_bs) && i < len(bs); i++ {
_bs[i] = C.Uint8(bs[i])
}
return errorFromInt(int(
C.SDL_SetRenderDrawColor(
renderer.cptr(),
_bs[0],
_bs[1],
_bs[2],
_bs[3])))
} | go | func (renderer *Renderer) SetDrawColorArray(bs ...uint8) error {
_bs := []C.Uint8{0, 0, 0, 255}
for i := 0; i < len(_bs) && i < len(bs); i++ {
_bs[i] = C.Uint8(bs[i])
}
return errorFromInt(int(
C.SDL_SetRenderDrawColor(
renderer.cptr(),
_bs[0],
_bs[1],
_bs[2],
_bs[3])))
} | [
"func",
"(",
"renderer",
"*",
"Renderer",
")",
"SetDrawColorArray",
"(",
"bs",
"...",
"uint8",
")",
"error",
"{",
"_bs",
":=",
"[",
"]",
"C",
".",
"Uint8",
"{",
"0",
",",
"0",
",",
"0",
",",
"255",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
... | // SetDrawColorArray is a custom variant of SetDrawColor. | [
"SetDrawColorArray",
"is",
"a",
"custom",
"variant",
"of",
"SetDrawColor",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/sdl/render.go#L539-L551 |
25,788 | veandco/go-sdl2 | sdl/gamecontroller.go | GameControllerMappingForIndex | func GameControllerMappingForIndex(index int) string {
mappingString := C.SDL_GameControllerMappingForIndex(C.int(index))
defer C.free(unsafe.Pointer(mappingString))
return C.GoString(mappingString)
} | go | func GameControllerMappingForIndex(index int) string {
mappingString := C.SDL_GameControllerMappingForIndex(C.int(index))
defer C.free(unsafe.Pointer(mappingString))
return C.GoString(mappingString)
} | [
"func",
"GameControllerMappingForIndex",
"(",
"index",
"int",
")",
"string",
"{",
"mappingString",
":=",
"C",
".",
"SDL_GameControllerMappingForIndex",
"(",
"C",
".",
"int",
"(",
"index",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointe... | // GameControllerMappingForIndex returns the game controller mapping string at a particular index. | [
"GameControllerMappingForIndex",
"returns",
"the",
"game",
"controller",
"mapping",
"string",
"at",
"a",
"particular",
"index",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/sdl/gamecontroller.go#L160-L164 |
25,789 | veandco/go-sdl2 | sdl/gamecontroller.go | Axis | func (bind *GameControllerButtonBind) Axis() int {
val, _ := binary.Varint(bind.value[:4])
return int(val)
} | go | func (bind *GameControllerButtonBind) Axis() int {
val, _ := binary.Varint(bind.value[:4])
return int(val)
} | [
"func",
"(",
"bind",
"*",
"GameControllerButtonBind",
")",
"Axis",
"(",
")",
"int",
"{",
"val",
",",
"_",
":=",
"binary",
".",
"Varint",
"(",
"bind",
".",
"value",
"[",
":",
"4",
"]",
")",
"\n",
"return",
"int",
"(",
"val",
")",
"\n",
"}"
] | // Axis returns axis mapped for this SDL joystick layer binding. | [
"Axis",
"returns",
"axis",
"mapped",
"for",
"this",
"SDL",
"joystick",
"layer",
"binding",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/sdl/gamecontroller.go#L321-L324 |
25,790 | veandco/go-sdl2 | img/sdl_image.go | LoadTexture | func LoadTexture(renderer *sdl.Renderer, file string) (*sdl.Texture, error) {
_renderer := (*C.SDL_Renderer)(unsafe.Pointer(renderer))
_file := C.CString(file)
defer C.free(unsafe.Pointer(_file))
_surface := C.IMG_LoadTexture(_renderer, _file)
if _surface == nil {
return nil, GetError()
}
return (*sdl.Texture)... | go | func LoadTexture(renderer *sdl.Renderer, file string) (*sdl.Texture, error) {
_renderer := (*C.SDL_Renderer)(unsafe.Pointer(renderer))
_file := C.CString(file)
defer C.free(unsafe.Pointer(_file))
_surface := C.IMG_LoadTexture(_renderer, _file)
if _surface == nil {
return nil, GetError()
}
return (*sdl.Texture)... | [
"func",
"LoadTexture",
"(",
"renderer",
"*",
"sdl",
".",
"Renderer",
",",
"file",
"string",
")",
"(",
"*",
"sdl",
".",
"Texture",
",",
"error",
")",
"{",
"_renderer",
":=",
"(",
"*",
"C",
".",
"SDL_Renderer",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
... | // LoadTexture loads an image directly into a render texture. | [
"LoadTexture",
"loads",
"an",
"image",
"directly",
"into",
"a",
"render",
"texture",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/img/sdl_image.go#L87-L96 |
25,791 | veandco/go-sdl2 | img/sdl_image.go | LoadTextureRW | func LoadTextureRW(renderer *sdl.Renderer, src *sdl.RWops, freesrc bool) (*sdl.Texture, error) {
_renderer := (*C.SDL_Renderer)(unsafe.Pointer(renderer))
_src := (*C.SDL_RWops)(unsafe.Pointer(src))
_freesrc := (C.int)(sdl.Btoi(freesrc))
_surface := C.IMG_LoadTexture_RW(_renderer, _src, _freesrc)
if _surface == nil... | go | func LoadTextureRW(renderer *sdl.Renderer, src *sdl.RWops, freesrc bool) (*sdl.Texture, error) {
_renderer := (*C.SDL_Renderer)(unsafe.Pointer(renderer))
_src := (*C.SDL_RWops)(unsafe.Pointer(src))
_freesrc := (C.int)(sdl.Btoi(freesrc))
_surface := C.IMG_LoadTexture_RW(_renderer, _src, _freesrc)
if _surface == nil... | [
"func",
"LoadTextureRW",
"(",
"renderer",
"*",
"sdl",
".",
"Renderer",
",",
"src",
"*",
"sdl",
".",
"RWops",
",",
"freesrc",
"bool",
")",
"(",
"*",
"sdl",
".",
"Texture",
",",
"error",
")",
"{",
"_renderer",
":=",
"(",
"*",
"C",
".",
"SDL_Renderer",
... | // LoadTextureRW loads an image from an SDL data source directly into a render texture. | [
"LoadTextureRW",
"loads",
"an",
"image",
"from",
"an",
"SDL",
"data",
"source",
"directly",
"into",
"a",
"render",
"texture",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/img/sdl_image.go#L99-L108 |
25,792 | veandco/go-sdl2 | img/sdl_image.go | IsWEBP | func IsWEBP(src *sdl.RWops) bool {
_src := (*C.SDL_RWops)(unsafe.Pointer(src))
return int(C.IMG_isWEBP(_src)) > 0
} | go | func IsWEBP(src *sdl.RWops) bool {
_src := (*C.SDL_RWops)(unsafe.Pointer(src))
return int(C.IMG_isWEBP(_src)) > 0
} | [
"func",
"IsWEBP",
"(",
"src",
"*",
"sdl",
".",
"RWops",
")",
"bool",
"{",
"_src",
":=",
"(",
"*",
"C",
".",
"SDL_RWops",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"src",
")",
")",
"\n",
"return",
"int",
"(",
"C",
".",
"IMG_isWEBP",
"(",
"_src",
... | // IsWEBP reports whether WEBP format is supported and image data is readable as a WEBP. | [
"IsWEBP",
"reports",
"whether",
"WEBP",
"format",
"is",
"supported",
"and",
"image",
"data",
"is",
"readable",
"as",
"a",
"WEBP",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/img/sdl_image.go#L202-L205 |
25,793 | veandco/go-sdl2 | img/sdl_image.go | LoadWEBPRW | func LoadWEBPRW(src *sdl.RWops) (*sdl.Surface, error) {
_src := (*C.SDL_RWops)(unsafe.Pointer(src))
_surface := C.IMG_LoadWEBP_RW(_src)
if _surface == nil {
return nil, GetError()
}
return (*sdl.Surface)(unsafe.Pointer(_surface)), nil
} | go | func LoadWEBPRW(src *sdl.RWops) (*sdl.Surface, error) {
_src := (*C.SDL_RWops)(unsafe.Pointer(src))
_surface := C.IMG_LoadWEBP_RW(_src)
if _surface == nil {
return nil, GetError()
}
return (*sdl.Surface)(unsafe.Pointer(_surface)), nil
} | [
"func",
"LoadWEBPRW",
"(",
"src",
"*",
"sdl",
".",
"RWops",
")",
"(",
"*",
"sdl",
".",
"Surface",
",",
"error",
")",
"{",
"_src",
":=",
"(",
"*",
"C",
".",
"SDL_RWops",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"src",
")",
")",
"\n",
"_surface",
... | // LoadWEBPRW loads a WEBP image from an SDL data source for use as a surface. | [
"LoadWEBPRW",
"loads",
"a",
"WEBP",
"image",
"from",
"an",
"SDL",
"data",
"source",
"for",
"use",
"as",
"a",
"surface",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/img/sdl_image.go#L362-L369 |
25,794 | veandco/go-sdl2 | img/sdl_image.go | SavePNG | func SavePNG(surface *sdl.Surface, file string) error {
_surface := (*C.SDL_Surface)(unsafe.Pointer(surface))
_file := C.CString(file)
defer C.free(unsafe.Pointer(_file))
_ret := C.IMG_SavePNG(_surface, _file)
if _ret < 0 {
return GetError()
}
return nil
} | go | func SavePNG(surface *sdl.Surface, file string) error {
_surface := (*C.SDL_Surface)(unsafe.Pointer(surface))
_file := C.CString(file)
defer C.free(unsafe.Pointer(_file))
_ret := C.IMG_SavePNG(_surface, _file)
if _ret < 0 {
return GetError()
}
return nil
} | [
"func",
"SavePNG",
"(",
"surface",
"*",
"sdl",
".",
"Surface",
",",
"file",
"string",
")",
"error",
"{",
"_surface",
":=",
"(",
"*",
"C",
".",
"SDL_Surface",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"surface",
")",
")",
"\n",
"_file",
":=",
"C",
".... | // SavePNG saves a surface as PNG file. | [
"SavePNG",
"saves",
"a",
"surface",
"as",
"PNG",
"file",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/img/sdl_image.go#L384-L393 |
25,795 | veandco/go-sdl2 | img/sdl_image.go | SavePNGRW | func SavePNGRW(surface *sdl.Surface, dst *sdl.RWops, freedst int) error {
_surface := (*C.SDL_Surface)(unsafe.Pointer(surface))
_dst := (*C.SDL_RWops)(unsafe.Pointer(dst))
_freedst := (C.int)(freedst)
_ret := C.IMG_SavePNG_RW(_surface, _dst, _freedst)
if _ret < 0 {
return GetError()
}
return nil
} | go | func SavePNGRW(surface *sdl.Surface, dst *sdl.RWops, freedst int) error {
_surface := (*C.SDL_Surface)(unsafe.Pointer(surface))
_dst := (*C.SDL_RWops)(unsafe.Pointer(dst))
_freedst := (C.int)(freedst)
_ret := C.IMG_SavePNG_RW(_surface, _dst, _freedst)
if _ret < 0 {
return GetError()
}
return nil
} | [
"func",
"SavePNGRW",
"(",
"surface",
"*",
"sdl",
".",
"Surface",
",",
"dst",
"*",
"sdl",
".",
"RWops",
",",
"freedst",
"int",
")",
"error",
"{",
"_surface",
":=",
"(",
"*",
"C",
".",
"SDL_Surface",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"surface",
... | // SavePNGRW saves a surface to an SDL data source. | [
"SavePNGRW",
"saves",
"a",
"surface",
"to",
"an",
"SDL",
"data",
"source",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/img/sdl_image.go#L396-L405 |
25,796 | veandco/go-sdl2 | sdl/events.go | GetText | func (e *TextEditingEvent) GetText() string {
length := func(buf []byte) int {
for i := range buf {
if buf[i] == 0 {
return i
}
}
return 0
}(e.Text[:])
text := e.Text[:length]
return string(text)
} | go | func (e *TextEditingEvent) GetText() string {
length := func(buf []byte) int {
for i := range buf {
if buf[i] == 0 {
return i
}
}
return 0
}(e.Text[:])
text := e.Text[:length]
return string(text)
} | [
"func",
"(",
"e",
"*",
"TextEditingEvent",
")",
"GetText",
"(",
")",
"string",
"{",
"length",
":=",
"func",
"(",
"buf",
"[",
"]",
"byte",
")",
"int",
"{",
"for",
"i",
":=",
"range",
"buf",
"{",
"if",
"buf",
"[",
"i",
"]",
"==",
"0",
"{",
"retur... | // GetText returns the text as string | [
"GetText",
"returns",
"the",
"text",
"as",
"string"
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/sdl/events.go#L303-L316 |
25,797 | veandco/go-sdl2 | sdl/surface.go | Pixels | func (surface *Surface) Pixels() []byte {
var b []byte
length := int(surface.W*surface.H) * int(surface.Format.BytesPerPixel)
sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&b))
sliceHeader.Cap = int(length)
sliceHeader.Len = int(length)
sliceHeader.Data = uintptr(surface.pixels)
return b
} | go | func (surface *Surface) Pixels() []byte {
var b []byte
length := int(surface.W*surface.H) * int(surface.Format.BytesPerPixel)
sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&b))
sliceHeader.Cap = int(length)
sliceHeader.Len = int(length)
sliceHeader.Data = uintptr(surface.pixels)
return b
} | [
"func",
"(",
"surface",
"*",
"Surface",
")",
"Pixels",
"(",
")",
"[",
"]",
"byte",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n",
"length",
":=",
"int",
"(",
"surface",
".",
"W",
"*",
"surface",
".",
"H",
")",
"*",
"int",
"(",
"surface",
".",
"Format... | // Pixels returns the actual pixel data of the surface. | [
"Pixels",
"returns",
"the",
"actual",
"pixel",
"data",
"of",
"the",
"surface",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/sdl/surface.go#L500-L508 |
25,798 | veandco/go-sdl2 | sdl/surface.go | Duplicate | func (surface *Surface) Duplicate() (newSurface *Surface, err error) {
_newSurface := C.SDL_DuplicateSurface(surface.cptr())
if _newSurface == nil {
err = GetError()
return
}
newSurface = (*Surface)(unsafe.Pointer(_newSurface))
return
} | go | func (surface *Surface) Duplicate() (newSurface *Surface, err error) {
_newSurface := C.SDL_DuplicateSurface(surface.cptr())
if _newSurface == nil {
err = GetError()
return
}
newSurface = (*Surface)(unsafe.Pointer(_newSurface))
return
} | [
"func",
"(",
"surface",
"*",
"Surface",
")",
"Duplicate",
"(",
")",
"(",
"newSurface",
"*",
"Surface",
",",
"err",
"error",
")",
"{",
"_newSurface",
":=",
"C",
".",
"SDL_DuplicateSurface",
"(",
"surface",
".",
"cptr",
"(",
")",
")",
"\n",
"if",
"_newSu... | // Duplicate creates a new surface identical to the existing surface | [
"Duplicate",
"creates",
"a",
"new",
"surface",
"identical",
"to",
"the",
"existing",
"surface"
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/sdl/surface.go#L516-L525 |
25,799 | veandco/go-sdl2 | sdl/surface.go | ColorModel | func (surface *Surface) ColorModel() color.Model {
switch surface.Format.Format {
case PIXELFORMAT_ARGB8888, PIXELFORMAT_ABGR8888:
return color.RGBAModel
case PIXELFORMAT_RGB888:
return color.RGBAModel
default:
panic("Not implemented yet")
}
} | go | func (surface *Surface) ColorModel() color.Model {
switch surface.Format.Format {
case PIXELFORMAT_ARGB8888, PIXELFORMAT_ABGR8888:
return color.RGBAModel
case PIXELFORMAT_RGB888:
return color.RGBAModel
default:
panic("Not implemented yet")
}
} | [
"func",
"(",
"surface",
"*",
"Surface",
")",
"ColorModel",
"(",
")",
"color",
".",
"Model",
"{",
"switch",
"surface",
".",
"Format",
".",
"Format",
"{",
"case",
"PIXELFORMAT_ARGB8888",
",",
"PIXELFORMAT_ABGR8888",
":",
"return",
"color",
".",
"RGBAModel",
"\... | // ColorModel returns the color model used by this Surface. | [
"ColorModel",
"returns",
"the",
"color",
"model",
"used",
"by",
"this",
"Surface",
"."
] | 649ea85188106bf99d15daf5cdcd93b0da65ada9 | https://github.com/veandco/go-sdl2/blob/649ea85188106bf99d15daf5cdcd93b0da65ada9/sdl/surface.go#L528-L537 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.