repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
llgcode/draw2d
samples/postscript/postscript.go
Draw
func Draw(gc draw2d.GraphicContext, filename string) { // Open the postscript src, err := os.OpenFile(filename, 0, 0) if err != nil { panic(err) } defer src.Close() bytes, err := ioutil.ReadAll(src) reader := strings.NewReader(string(bytes)) // Initialize and interpret the postscript interpreter := ps.NewIn...
go
func Draw(gc draw2d.GraphicContext, filename string) { // Open the postscript src, err := os.OpenFile(filename, 0, 0) if err != nil { panic(err) } defer src.Close() bytes, err := ioutil.ReadAll(src) reader := strings.NewReader(string(bytes)) // Initialize and interpret the postscript interpreter := ps.NewIn...
[ "func", "Draw", "(", "gc", "draw2d", ".", "GraphicContext", ",", "filename", "string", ")", "{", "src", ",", "err", ":=", "os", ".", "OpenFile", "(", "filename", ",", "0", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", "...
// Draw a tiger
[ "Draw", "a", "tiger" ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/postscript/postscript.go#L36-L49
test
llgcode/draw2d
samples/geometry/geometry.go
Main
func Main(gc draw2d.GraphicContext, ext string) (string, error) { // Draw the droid Draw(gc, 297, 210) // Return the output filename return samples.Output("geometry", ext), nil }
go
func Main(gc draw2d.GraphicContext, ext string) (string, error) { // Draw the droid Draw(gc, 297, 210) // Return the output filename return samples.Output("geometry", ext), nil }
[ "func", "Main", "(", "gc", "draw2d", ".", "GraphicContext", ",", "ext", "string", ")", "(", "string", ",", "error", ")", "{", "Draw", "(", "gc", ",", "297", ",", "210", ")", "\n", "return", "samples", ".", "Output", "(", "\"geometry\"", ",", "ext", ...
// Main draws geometry and returns the filename. This should only be // used during testing.
[ "Main", "draws", "geometry", "and", "returns", "the", "filename", ".", "This", "should", "only", "be", "used", "during", "testing", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/geometry/geometry.go#L20-L26
test
llgcode/draw2d
samples/geometry/geometry.go
Bubble
func Bubble(gc draw2d.GraphicContext, x, y, width, height float64) { sx, sy := width/100, height/100 gc.MoveTo(x+sx*50, y) gc.QuadCurveTo(x, y, x, y+sy*37.5) gc.QuadCurveTo(x, y+sy*75, x+sx*25, y+sy*75) gc.QuadCurveTo(x+sx*25, y+sy*95, x+sx*5, y+sy*100) gc.QuadCurveTo(x+sx*35, y+sy*95, x+sx*40, y+sy*75) gc.QuadC...
go
func Bubble(gc draw2d.GraphicContext, x, y, width, height float64) { sx, sy := width/100, height/100 gc.MoveTo(x+sx*50, y) gc.QuadCurveTo(x, y, x, y+sy*37.5) gc.QuadCurveTo(x, y+sy*75, x+sx*25, y+sy*75) gc.QuadCurveTo(x+sx*25, y+sy*95, x+sx*5, y+sy*100) gc.QuadCurveTo(x+sx*35, y+sy*95, x+sx*40, y+sy*75) gc.QuadC...
[ "func", "Bubble", "(", "gc", "draw2d", ".", "GraphicContext", ",", "x", ",", "y", ",", "width", ",", "height", "float64", ")", "{", "sx", ",", "sy", ":=", "width", "/", "100", ",", "height", "/", "100", "\n", "gc", ".", "MoveTo", "(", "x", "+", ...
// Bubble draws a text balloon.
[ "Bubble", "draws", "a", "text", "balloon", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/geometry/geometry.go#L29-L39
test
llgcode/draw2d
samples/geometry/geometry.go
Dash
func Dash(gc draw2d.GraphicContext, x, y, width, height float64) { sx, sy := width/162, height/205 gc.SetStrokeColor(image.Black) gc.SetLineDash([]float64{height / 10, height / 50, height / 50, height / 50}, -50.0) gc.SetLineCap(draw2d.ButtCap) gc.SetLineJoin(draw2d.RoundJoin) gc.SetLineWidth(height / 50) gc.Mo...
go
func Dash(gc draw2d.GraphicContext, x, y, width, height float64) { sx, sy := width/162, height/205 gc.SetStrokeColor(image.Black) gc.SetLineDash([]float64{height / 10, height / 50, height / 50, height / 50}, -50.0) gc.SetLineCap(draw2d.ButtCap) gc.SetLineJoin(draw2d.RoundJoin) gc.SetLineWidth(height / 50) gc.Mo...
[ "func", "Dash", "(", "gc", "draw2d", ".", "GraphicContext", ",", "x", ",", "y", ",", "width", ",", "height", "float64", ")", "{", "sx", ",", "sy", ":=", "width", "/", "162", ",", "height", "/", "205", "\n", "gc", ".", "SetStrokeColor", "(", "image"...
// Dash draws a line with a dash pattern
[ "Dash", "draws", "a", "line", "with", "a", "dash", "pattern" ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/geometry/geometry.go#L91-L106
test
llgcode/draw2d
samples/geometry/geometry.go
CubicCurve
func CubicCurve(gc draw2d.GraphicContext, x, y, width, height float64) { sx, sy := width/162, height/205 x0, y0 := x, y+sy*100.0 x1, y1 := x+sx*75, y+sy*205 x2, y2 := x+sx*125, y x3, y3 := x+sx*205, y+sy*100 gc.SetStrokeColor(image.Black) gc.SetFillColor(color.NRGBA{0xAA, 0xAA, 0xAA, 0xFF}) gc.SetLineWidth(wid...
go
func CubicCurve(gc draw2d.GraphicContext, x, y, width, height float64) { sx, sy := width/162, height/205 x0, y0 := x, y+sy*100.0 x1, y1 := x+sx*75, y+sy*205 x2, y2 := x+sx*125, y x3, y3 := x+sx*205, y+sy*100 gc.SetStrokeColor(image.Black) gc.SetFillColor(color.NRGBA{0xAA, 0xAA, 0xAA, 0xFF}) gc.SetLineWidth(wid...
[ "func", "CubicCurve", "(", "gc", "draw2d", ".", "GraphicContext", ",", "x", ",", "y", ",", "width", ",", "height", "float64", ")", "{", "sx", ",", "sy", ":=", "width", "/", "162", ",", "height", "/", "205", "\n", "x0", ",", "y0", ":=", "x", ",", ...
// CubicCurve draws a cubic curve with its control points.
[ "CubicCurve", "draws", "a", "cubic", "curve", "with", "its", "control", "points", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/geometry/geometry.go#L166-L189
test
llgcode/draw2d
samples/geometry/geometry.go
FillStroke
func FillStroke(gc draw2d.GraphicContext, x, y, width, height float64) { sx, sy := width/210, height/215 gc.MoveTo(x+sx*113.0, y) gc.LineTo(x+sx*215.0, y+sy*215) rLineTo(gc, sx*-100, 0) gc.CubicCurveTo(x+sx*35, y+sy*215, x+sx*35, y+sy*113, x+sx*113.0, y+sy*113) gc.Close() gc.MoveTo(x+sx*50.0, y) rLineTo(gc, sx...
go
func FillStroke(gc draw2d.GraphicContext, x, y, width, height float64) { sx, sy := width/210, height/215 gc.MoveTo(x+sx*113.0, y) gc.LineTo(x+sx*215.0, y+sy*215) rLineTo(gc, sx*-100, 0) gc.CubicCurveTo(x+sx*35, y+sy*215, x+sx*35, y+sy*113, x+sx*113.0, y+sy*113) gc.Close() gc.MoveTo(x+sx*50.0, y) rLineTo(gc, sx...
[ "func", "FillStroke", "(", "gc", "draw2d", ".", "GraphicContext", ",", "x", ",", "y", ",", "width", ",", "height", "float64", ")", "{", "sx", ",", "sy", ":=", "width", "/", "210", ",", "height", "/", "215", "\n", "gc", ".", "MoveTo", "(", "x", "+...
// FillStroke first fills and afterwards strokes a path.
[ "FillStroke", "first", "fills", "and", "afterwards", "strokes", "a", "path", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/geometry/geometry.go#L231-L249
test
llgcode/draw2d
samples/geometry/geometry.go
FillStyle
func FillStyle(gc draw2d.GraphicContext, x, y, width, height float64) { sx, sy := width/232, height/220 gc.SetLineWidth(width / 40) draw2dkit.Rectangle(gc, x+sx*0, y+sy*12, x+sx*232, y+sy*70) var wheel1, wheel2 draw2d.Path wheel1.ArcTo(x+sx*52, y+sy*70, sx*40, sy*40, 0, 2*math.Pi) wheel2.ArcTo(x+sx*180, y+sy*70...
go
func FillStyle(gc draw2d.GraphicContext, x, y, width, height float64) { sx, sy := width/232, height/220 gc.SetLineWidth(width / 40) draw2dkit.Rectangle(gc, x+sx*0, y+sy*12, x+sx*232, y+sy*70) var wheel1, wheel2 draw2d.Path wheel1.ArcTo(x+sx*52, y+sy*70, sx*40, sy*40, 0, 2*math.Pi) wheel2.ArcTo(x+sx*180, y+sy*70...
[ "func", "FillStyle", "(", "gc", "draw2d", ".", "GraphicContext", ",", "x", ",", "y", ",", "width", ",", "height", "float64", ")", "{", "sx", ",", "sy", ":=", "width", "/", "232", ",", "height", "/", "220", "\n", "gc", ".", "SetLineWidth", "(", "wid...
// FillStyle demonstrates the difference between even odd and non zero winding rule.
[ "FillStyle", "demonstrates", "the", "difference", "between", "even", "odd", "and", "non", "zero", "winding", "rule", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/geometry/geometry.go#L257-L282
test
llgcode/draw2d
samples/geometry/geometry.go
PathTransform
func PathTransform(gc draw2d.GraphicContext, x, y, width, height float64) { gc.Save() gc.SetLineWidth(width / 10) gc.Translate(x+width/2, y+height/2) gc.Scale(1, 4) gc.ArcTo(0, 0, width/8, height/8, 0, math.Pi*2) gc.Close() gc.Stroke() gc.Restore() }
go
func PathTransform(gc draw2d.GraphicContext, x, y, width, height float64) { gc.Save() gc.SetLineWidth(width / 10) gc.Translate(x+width/2, y+height/2) gc.Scale(1, 4) gc.ArcTo(0, 0, width/8, height/8, 0, math.Pi*2) gc.Close() gc.Stroke() gc.Restore() }
[ "func", "PathTransform", "(", "gc", "draw2d", ".", "GraphicContext", ",", "x", ",", "y", ",", "width", ",", "height", "float64", ")", "{", "gc", ".", "Save", "(", ")", "\n", "gc", ".", "SetLineWidth", "(", "width", "/", "10", ")", "\n", "gc", ".", ...
// PathTransform scales a path differently in horizontal and vertical direction.
[ "PathTransform", "scales", "a", "path", "differently", "in", "horizontal", "and", "vertical", "direction", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/geometry/geometry.go#L285-L294
test
llgcode/draw2d
samples/geometry/geometry.go
Star
func Star(gc draw2d.GraphicContext, x, y, width, height float64) { gc.Save() gc.Translate(x+width/2, y+height/2) gc.SetLineWidth(width / 40) for i := 0.0; i < 360; i = i + 10 { // Go from 0 to 360 degrees in 10 degree steps gc.Save() // Keep rotations temporary gc.Rotate(i * (math.Pi / 18...
go
func Star(gc draw2d.GraphicContext, x, y, width, height float64) { gc.Save() gc.Translate(x+width/2, y+height/2) gc.SetLineWidth(width / 40) for i := 0.0; i < 360; i = i + 10 { // Go from 0 to 360 degrees in 10 degree steps gc.Save() // Keep rotations temporary gc.Rotate(i * (math.Pi / 18...
[ "func", "Star", "(", "gc", "draw2d", ".", "GraphicContext", ",", "x", ",", "y", ",", "width", ",", "height", "float64", ")", "{", "gc", ".", "Save", "(", ")", "\n", "gc", ".", "Translate", "(", "x", "+", "width", "/", "2", ",", "y", "+", "heigh...
// Star draws many lines from a center.
[ "Star", "draws", "many", "lines", "from", "a", "center", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/geometry/geometry.go#L297-L310
test
llgcode/draw2d
samples/geometry/geometry.go
Draw
func Draw(gc draw2d.GraphicContext, width, height float64) { mx, my := width*0.025, height*0.025 // margin dx, dy := (width-2*mx)/4, (height-2*my)/3 w, h := dx-2*mx, dy-2*my x0, y := 2*mx, 2*my x := x0 Bubble(gc, x, y, w, h) x += dx CurveRectangle(gc, x, y, w, h, color.NRGBA{0x80, 0, 0, 0x80}, color.NRGBA{0x80,...
go
func Draw(gc draw2d.GraphicContext, width, height float64) { mx, my := width*0.025, height*0.025 // margin dx, dy := (width-2*mx)/4, (height-2*my)/3 w, h := dx-2*mx, dy-2*my x0, y := 2*mx, 2*my x := x0 Bubble(gc, x, y, w, h) x += dx CurveRectangle(gc, x, y, w, h, color.NRGBA{0x80, 0, 0, 0x80}, color.NRGBA{0x80,...
[ "func", "Draw", "(", "gc", "draw2d", ".", "GraphicContext", ",", "width", ",", "height", "float64", ")", "{", "mx", ",", "my", ":=", "width", "*", "0.025", ",", "height", "*", "0.025", "\n", "dx", ",", "dy", ":=", "(", "width", "-", "2", "*", "mx...
// Draw all figures in a nice 4x3 grid.
[ "Draw", "all", "figures", "in", "a", "nice", "4x3", "grid", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/geometry/geometry.go#L313-L344
test
llgcode/draw2d
draw2dpdf/path_converter.go
ConvertPath
func ConvertPath(path *draw2d.Path, pdf Vectorizer) { var startX, startY float64 = 0, 0 i := 0 for _, cmp := range path.Components { switch cmp { case draw2d.MoveToCmp: startX, startY = path.Points[i], path.Points[i+1] pdf.MoveTo(startX, startY) i += 2 case draw2d.LineToCmp: pdf.LineTo(path.Points[...
go
func ConvertPath(path *draw2d.Path, pdf Vectorizer) { var startX, startY float64 = 0, 0 i := 0 for _, cmp := range path.Components { switch cmp { case draw2d.MoveToCmp: startX, startY = path.Points[i], path.Points[i+1] pdf.MoveTo(startX, startY) i += 2 case draw2d.LineToCmp: pdf.LineTo(path.Points[...
[ "func", "ConvertPath", "(", "path", "*", "draw2d", ".", "Path", ",", "pdf", "Vectorizer", ")", "{", "var", "startX", ",", "startY", "float64", "=", "0", ",", "0", "\n", "i", ":=", "0", "\n", "for", "_", ",", "cmp", ":=", "range", "path", ".", "Co...
// ConvertPath converts a paths to the pdf api
[ "ConvertPath", "converts", "a", "paths", "to", "the", "pdf", "api" ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dpdf/path_converter.go#L15-L44
test
llgcode/draw2d
samples/linecapjoin/linecapjoin.go
Main
func Main(gc draw2d.GraphicContext, ext string) (string, error) { // Draw the line const offset = 75.0 x := 35.0 caps := []draw2d.LineCap{draw2d.ButtCap, draw2d.SquareCap, draw2d.RoundCap} joins := []draw2d.LineJoin{draw2d.BevelJoin, draw2d.MiterJoin, draw2d.RoundJoin} for i := range caps { Draw(gc, caps[i], jo...
go
func Main(gc draw2d.GraphicContext, ext string) (string, error) { // Draw the line const offset = 75.0 x := 35.0 caps := []draw2d.LineCap{draw2d.ButtCap, draw2d.SquareCap, draw2d.RoundCap} joins := []draw2d.LineJoin{draw2d.BevelJoin, draw2d.MiterJoin, draw2d.RoundJoin} for i := range caps { Draw(gc, caps[i], jo...
[ "func", "Main", "(", "gc", "draw2d", ".", "GraphicContext", ",", "ext", "string", ")", "(", "string", ",", "error", ")", "{", "const", "offset", "=", "75.0", "\n", "x", ":=", "35.0", "\n", "caps", ":=", "[", "]", "draw2d", ".", "LineCap", "{", "dra...
// Main draws the different line caps and joins. // This should only be used during testing.
[ "Main", "draws", "the", "different", "line", "caps", "and", "joins", ".", "This", "should", "only", "be", "used", "during", "testing", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/linecapjoin/linecapjoin.go#L16-L29
test
llgcode/draw2d
samples/linecapjoin/linecapjoin.go
Draw
func Draw(gc draw2d.GraphicContext, cap draw2d.LineCap, join draw2d.LineJoin, x0, y0, x1, y1, offset float64) { gc.SetLineCap(cap) gc.SetLineJoin(join) // Draw thick line gc.SetStrokeColor(color.NRGBA{0x33, 0x33, 0x33, 0xFF}) gc.SetLineWidth(30.0) gc.MoveTo(x0, y0) gc.LineTo((x0+x1)/2+offset, (y0+y1)/2) gc.Li...
go
func Draw(gc draw2d.GraphicContext, cap draw2d.LineCap, join draw2d.LineJoin, x0, y0, x1, y1, offset float64) { gc.SetLineCap(cap) gc.SetLineJoin(join) // Draw thick line gc.SetStrokeColor(color.NRGBA{0x33, 0x33, 0x33, 0xFF}) gc.SetLineWidth(30.0) gc.MoveTo(x0, y0) gc.LineTo((x0+x1)/2+offset, (y0+y1)/2) gc.Li...
[ "func", "Draw", "(", "gc", "draw2d", ".", "GraphicContext", ",", "cap", "draw2d", ".", "LineCap", ",", "join", "draw2d", ".", "LineJoin", ",", "x0", ",", "y0", ",", "x1", ",", "y1", ",", "offset", "float64", ")", "{", "gc", ".", "SetLineCap", "(", ...
// Draw a line with an angle with specified line cap and join
[ "Draw", "a", "line", "with", "an", "angle", "with", "specified", "line", "cap", "and", "join" ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/linecapjoin/linecapjoin.go#L32-L52
test
llgcode/draw2d
draw2dimg/text.go
DrawContour
func DrawContour(path draw2d.PathBuilder, ps []truetype.Point, dx, dy float64) { if len(ps) == 0 { return } startX, startY := pointToF64Point(ps[0]) path.MoveTo(startX+dx, startY+dy) q0X, q0Y, on0 := startX, startY, true for _, p := range ps[1:] { qX, qY := pointToF64Point(p) on := p.Flags&0x01 != 0 if on...
go
func DrawContour(path draw2d.PathBuilder, ps []truetype.Point, dx, dy float64) { if len(ps) == 0 { return } startX, startY := pointToF64Point(ps[0]) path.MoveTo(startX+dx, startY+dy) q0X, q0Y, on0 := startX, startY, true for _, p := range ps[1:] { qX, qY := pointToF64Point(p) on := p.Flags&0x01 != 0 if on...
[ "func", "DrawContour", "(", "path", "draw2d", ".", "PathBuilder", ",", "ps", "[", "]", "truetype", ".", "Point", ",", "dx", ",", "dy", "float64", ")", "{", "if", "len", "(", "ps", ")", "==", "0", "{", "return", "\n", "}", "\n", "startX", ",", "st...
// DrawContour draws the given closed contour at the given sub-pixel offset.
[ "DrawContour", "draws", "the", "given", "closed", "contour", "at", "the", "given", "sub", "-", "pixel", "offset", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dimg/text.go#L11-L44
test
llgcode/draw2d
draw2dbase/flattener.go
Flatten
func Flatten(path *draw2d.Path, flattener Flattener, scale float64) { // First Point var startX, startY float64 = 0, 0 // Current Point var x, y float64 = 0, 0 i := 0 for _, cmp := range path.Components { switch cmp { case draw2d.MoveToCmp: x, y = path.Points[i], path.Points[i+1] startX, startY = x, y ...
go
func Flatten(path *draw2d.Path, flattener Flattener, scale float64) { // First Point var startX, startY float64 = 0, 0 // Current Point var x, y float64 = 0, 0 i := 0 for _, cmp := range path.Components { switch cmp { case draw2d.MoveToCmp: x, y = path.Points[i], path.Points[i+1] startX, startY = x, y ...
[ "func", "Flatten", "(", "path", "*", "draw2d", ".", "Path", ",", "flattener", "Flattener", ",", "scale", "float64", ")", "{", "var", "startX", ",", "startY", "float64", "=", "0", ",", "0", "\n", "var", "x", ",", "y", "float64", "=", "0", ",", "0", ...
// Flatten convert curves into straight segments keeping join segments info
[ "Flatten", "convert", "curves", "into", "straight", "segments", "keeping", "join", "segments", "info" ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dbase/flattener.go#L31-L72
test
llgcode/draw2d
draw2dimg/ftgc.go
Clear
func (gc *GraphicContext) Clear() { width, height := gc.img.Bounds().Dx(), gc.img.Bounds().Dy() gc.ClearRect(0, 0, width, height) }
go
func (gc *GraphicContext) Clear() { width, height := gc.img.Bounds().Dx(), gc.img.Bounds().Dy() gc.ClearRect(0, 0, width, height) }
[ "func", "(", "gc", "*", "GraphicContext", ")", "Clear", "(", ")", "{", "width", ",", "height", ":=", "gc", ".", "img", ".", "Bounds", "(", ")", ".", "Dx", "(", ")", ",", "gc", ".", "img", ".", "Bounds", "(", ")", ".", "Dy", "(", ")", "\n", ...
// Clear fills the current canvas with a default transparent color
[ "Clear", "fills", "the", "current", "canvas", "with", "a", "default", "transparent", "color" ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dimg/ftgc.go#L92-L95
test
llgcode/draw2d
draw2dimg/ftgc.go
ClearRect
func (gc *GraphicContext) ClearRect(x1, y1, x2, y2 int) { imageColor := image.NewUniform(gc.Current.FillColor) draw.Draw(gc.img, image.Rect(x1, y1, x2, y2), imageColor, image.ZP, draw.Over) }
go
func (gc *GraphicContext) ClearRect(x1, y1, x2, y2 int) { imageColor := image.NewUniform(gc.Current.FillColor) draw.Draw(gc.img, image.Rect(x1, y1, x2, y2), imageColor, image.ZP, draw.Over) }
[ "func", "(", "gc", "*", "GraphicContext", ")", "ClearRect", "(", "x1", ",", "y1", ",", "x2", ",", "y2", "int", ")", "{", "imageColor", ":=", "image", ".", "NewUniform", "(", "gc", ".", "Current", ".", "FillColor", ")", "\n", "draw", ".", "Draw", "(...
// ClearRect fills the current canvas with a default transparent color at the specified rectangle
[ "ClearRect", "fills", "the", "current", "canvas", "with", "a", "default", "transparent", "color", "at", "the", "specified", "rectangle" ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dimg/ftgc.go#L98-L101
test
llgcode/draw2d
draw2dimg/ftgc.go
DrawImage
func DrawImage(src image.Image, dest draw.Image, tr draw2d.Matrix, op draw.Op, filter ImageFilter) { var transformer draw.Transformer switch filter { case LinearFilter: transformer = draw.NearestNeighbor case BilinearFilter: transformer = draw.BiLinear case BicubicFilter: transformer = draw.CatmullRom } tr...
go
func DrawImage(src image.Image, dest draw.Image, tr draw2d.Matrix, op draw.Op, filter ImageFilter) { var transformer draw.Transformer switch filter { case LinearFilter: transformer = draw.NearestNeighbor case BilinearFilter: transformer = draw.BiLinear case BicubicFilter: transformer = draw.CatmullRom } tr...
[ "func", "DrawImage", "(", "src", "image", ".", "Image", ",", "dest", "draw", ".", "Image", ",", "tr", "draw2d", ".", "Matrix", ",", "op", "draw", ".", "Op", ",", "filter", "ImageFilter", ")", "{", "var", "transformer", "draw", ".", "Transformer", "\n",...
// DrawImage draws an image into dest using an affine transformation matrix, an op and a filter
[ "DrawImage", "draws", "an", "image", "into", "dest", "using", "an", "affine", "transformation", "matrix", "an", "op", "and", "a", "filter" ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dimg/ftgc.go#L104-L115
test
llgcode/draw2d
samples/frameimage/frameimage.go
Main
func Main(gc draw2d.GraphicContext, ext string) (string, error) { // Margin between the image and the frame const margin = 30 // Line width od the frame const lineWidth = 3 // Gopher image gopher := samples.Resource("image", "gopher.png", ext) // Draw gopher err := Draw(gc, gopher, 297, 210, margin, lineWidth...
go
func Main(gc draw2d.GraphicContext, ext string) (string, error) { // Margin between the image and the frame const margin = 30 // Line width od the frame const lineWidth = 3 // Gopher image gopher := samples.Resource("image", "gopher.png", ext) // Draw gopher err := Draw(gc, gopher, 297, 210, margin, lineWidth...
[ "func", "Main", "(", "gc", "draw2d", ".", "GraphicContext", ",", "ext", "string", ")", "(", "string", ",", "error", ")", "{", "const", "margin", "=", "30", "\n", "const", "lineWidth", "=", "3", "\n", "gopher", ":=", "samples", ".", "Resource", "(", "...
// Main draws the image frame and returns the filename. // This should only be used during testing.
[ "Main", "draws", "the", "image", "frame", "and", "returns", "the", "filename", ".", "This", "should", "only", "be", "used", "during", "testing", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/frameimage/frameimage.go#L18-L32
test
llgcode/draw2d
samples/frameimage/frameimage.go
Draw
func Draw(gc draw2d.GraphicContext, png string, dw, dh, margin, lineWidth float64) error { // Draw frame draw2dkit.RoundedRectangle(gc, lineWidth, lineWidth, dw-lineWidth, dh-lineWidth, 100, 100) gc.SetLineWidth(lineWidth) gc.FillStroke() // load the source image source, err := draw2dimg.LoadFromPngFile(png) i...
go
func Draw(gc draw2d.GraphicContext, png string, dw, dh, margin, lineWidth float64) error { // Draw frame draw2dkit.RoundedRectangle(gc, lineWidth, lineWidth, dw-lineWidth, dh-lineWidth, 100, 100) gc.SetLineWidth(lineWidth) gc.FillStroke() // load the source image source, err := draw2dimg.LoadFromPngFile(png) i...
[ "func", "Draw", "(", "gc", "draw2d", ".", "GraphicContext", ",", "png", "string", ",", "dw", ",", "dh", ",", "margin", ",", "lineWidth", "float64", ")", "error", "{", "draw2dkit", ".", "RoundedRectangle", "(", "gc", ",", "lineWidth", ",", "lineWidth", ",...
// Draw the image frame with certain parameters.
[ "Draw", "the", "image", "frame", "with", "certain", "parameters", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/frameimage/frameimage.go#L35-L60
test
llgcode/draw2d
samples/android/android.go
Draw
func Draw(gc draw2d.GraphicContext, x, y float64) { // set the fill and stroke color of the droid gc.SetFillColor(color.RGBA{0x44, 0xff, 0x44, 0xff}) gc.SetStrokeColor(color.RGBA{0x44, 0x44, 0x44, 0xff}) // set line properties gc.SetLineCap(draw2d.RoundCap) gc.SetLineWidth(5) // head gc.MoveTo(x+30, y+70) gc...
go
func Draw(gc draw2d.GraphicContext, x, y float64) { // set the fill and stroke color of the droid gc.SetFillColor(color.RGBA{0x44, 0xff, 0x44, 0xff}) gc.SetStrokeColor(color.RGBA{0x44, 0x44, 0x44, 0xff}) // set line properties gc.SetLineCap(draw2d.RoundCap) gc.SetLineWidth(5) // head gc.MoveTo(x+30, y+70) gc...
[ "func", "Draw", "(", "gc", "draw2d", ".", "GraphicContext", ",", "x", ",", "y", "float64", ")", "{", "gc", ".", "SetFillColor", "(", "color", ".", "RGBA", "{", "0x44", ",", "0xff", ",", "0x44", ",", "0xff", "}", ")", "\n", "gc", ".", "SetStrokeColo...
// Draw the droid on a certain position.
[ "Draw", "the", "droid", "on", "a", "certain", "position", "." ]
f52c8a71aff06ab8df41843d33ab167b36c971cd
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/android/android.go#L27-L76
test
OneOfOne/xxhash
xxhash_unsafe.go
ChecksumString32S
func ChecksumString32S(s string, seed uint32) uint32 { if len(s) == 0 { return Checksum32S(nil, seed) } ss := (*reflect.StringHeader)(unsafe.Pointer(&s)) return Checksum32S((*[maxInt32]byte)(unsafe.Pointer(ss.Data))[:len(s):len(s)], seed) }
go
func ChecksumString32S(s string, seed uint32) uint32 { if len(s) == 0 { return Checksum32S(nil, seed) } ss := (*reflect.StringHeader)(unsafe.Pointer(&s)) return Checksum32S((*[maxInt32]byte)(unsafe.Pointer(ss.Data))[:len(s):len(s)], seed) }
[ "func", "ChecksumString32S", "(", "s", "string", ",", "seed", "uint32", ")", "uint32", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "Checksum32S", "(", "nil", ",", "seed", ")", "\n", "}", "\n", "ss", ":=", "(", "*", "reflect", ".", ...
// ChecksumString32S returns the checksum of the input data, without creating a copy, with the specific seed.
[ "ChecksumString32S", "returns", "the", "checksum", "of", "the", "input", "data", "without", "creating", "a", "copy", "with", "the", "specific", "seed", "." ]
c1e3185f167680b62832a0a11938a04b1ab265fc
https://github.com/OneOfOne/xxhash/blob/c1e3185f167680b62832a0a11938a04b1ab265fc/xxhash_unsafe.go#L20-L26
test
OneOfOne/xxhash
xxhash_unsafe.go
ChecksumString64S
func ChecksumString64S(s string, seed uint64) uint64 { if len(s) == 0 { return Checksum64S(nil, seed) } ss := (*reflect.StringHeader)(unsafe.Pointer(&s)) return Checksum64S((*[maxInt32]byte)(unsafe.Pointer(ss.Data))[:len(s):len(s)], seed) }
go
func ChecksumString64S(s string, seed uint64) uint64 { if len(s) == 0 { return Checksum64S(nil, seed) } ss := (*reflect.StringHeader)(unsafe.Pointer(&s)) return Checksum64S((*[maxInt32]byte)(unsafe.Pointer(ss.Data))[:len(s):len(s)], seed) }
[ "func", "ChecksumString64S", "(", "s", "string", ",", "seed", "uint64", ")", "uint64", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "Checksum64S", "(", "nil", ",", "seed", ")", "\n", "}", "\n", "ss", ":=", "(", "*", "reflect", ".", ...
// ChecksumString64S returns the checksum of the input data, without creating a copy, with the specific seed.
[ "ChecksumString64S", "returns", "the", "checksum", "of", "the", "input", "data", "without", "creating", "a", "copy", "with", "the", "specific", "seed", "." ]
c1e3185f167680b62832a0a11938a04b1ab265fc
https://github.com/OneOfOne/xxhash/blob/c1e3185f167680b62832a0a11938a04b1ab265fc/xxhash_unsafe.go#L38-L45
test
OneOfOne/xxhash
xxhash.go
NewS32
func NewS32(seed uint32) (xx *XXHash32) { xx = &XXHash32{ seed: seed, } xx.Reset() return }
go
func NewS32(seed uint32) (xx *XXHash32) { xx = &XXHash32{ seed: seed, } xx.Reset() return }
[ "func", "NewS32", "(", "seed", "uint32", ")", "(", "xx", "*", "XXHash32", ")", "{", "xx", "=", "&", "XXHash32", "{", "seed", ":", "seed", ",", "}", "\n", "xx", ".", "Reset", "(", ")", "\n", "return", "\n", "}" ]
// NewS32 creates a new hash.Hash32 computing the 32bit xxHash checksum starting with the specific seed.
[ "NewS32", "creates", "a", "new", "hash", ".", "Hash32", "computing", "the", "32bit", "xxHash", "checksum", "starting", "with", "the", "specific", "seed", "." ]
c1e3185f167680b62832a0a11938a04b1ab265fc
https://github.com/OneOfOne/xxhash/blob/c1e3185f167680b62832a0a11938a04b1ab265fc/xxhash.go#L56-L62
test
OneOfOne/xxhash
xxhash.go
NewS64
func NewS64(seed uint64) (xx *XXHash64) { xx = &XXHash64{ seed: seed, } xx.Reset() return }
go
func NewS64(seed uint64) (xx *XXHash64) { xx = &XXHash64{ seed: seed, } xx.Reset() return }
[ "func", "NewS64", "(", "seed", "uint64", ")", "(", "xx", "*", "XXHash64", ")", "{", "xx", "=", "&", "XXHash64", "{", "seed", ":", "seed", ",", "}", "\n", "xx", ".", "Reset", "(", ")", "\n", "return", "\n", "}" ]
// NewS64 creates a new hash.Hash64 computing the 64bit xxHash checksum starting with the specific seed.
[ "NewS64", "creates", "a", "new", "hash", ".", "Hash64", "computing", "the", "64bit", "xxHash", "checksum", "starting", "with", "the", "specific", "seed", "." ]
c1e3185f167680b62832a0a11938a04b1ab265fc
https://github.com/OneOfOne/xxhash/blob/c1e3185f167680b62832a0a11938a04b1ab265fc/xxhash.go#L116-L122
test
OneOfOne/xxhash
xxhash.go
round64
func round64(h, v uint64) uint64 { h += v * prime64x2 h = rotl64_31(h) h *= prime64x1 return h }
go
func round64(h, v uint64) uint64 { h += v * prime64x2 h = rotl64_31(h) h *= prime64x1 return h }
[ "func", "round64", "(", "h", ",", "v", "uint64", ")", "uint64", "{", "h", "+=", "v", "*", "prime64x2", "\n", "h", "=", "rotl64_31", "(", "h", ")", "\n", "h", "*=", "prime64x1", "\n", "return", "h", "\n", "}" ]
// borrowed from cespare
[ "borrowed", "from", "cespare" ]
c1e3185f167680b62832a0a11938a04b1ab265fc
https://github.com/OneOfOne/xxhash/blob/c1e3185f167680b62832a0a11938a04b1ab265fc/xxhash.go#L177-L182
test
OneOfOne/xxhash
xxhash_go17.go
Checksum32S
func Checksum32S(in []byte, seed uint32) (h uint32) { var i int if len(in) > 15 { var ( v1 = seed + prime32x1 + prime32x2 v2 = seed + prime32x2 v3 = seed + 0 v4 = seed - prime32x1 ) for ; i < len(in)-15; i += 16 { in := in[i : i+16 : len(in)] v1 += u32(in[0:4:len(in)]) * prime32x2 v1 = rot...
go
func Checksum32S(in []byte, seed uint32) (h uint32) { var i int if len(in) > 15 { var ( v1 = seed + prime32x1 + prime32x2 v2 = seed + prime32x2 v3 = seed + 0 v4 = seed - prime32x1 ) for ; i < len(in)-15; i += 16 { in := in[i : i+16 : len(in)] v1 += u32(in[0:4:len(in)]) * prime32x2 v1 = rot...
[ "func", "Checksum32S", "(", "in", "[", "]", "byte", ",", "seed", "uint32", ")", "(", "h", "uint32", ")", "{", "var", "i", "int", "\n", "if", "len", "(", "in", ")", ">", "15", "{", "var", "(", "v1", "=", "seed", "+", "prime32x1", "+", "prime32x2...
// Checksum32S returns the checksum of the input bytes with the specific seed.
[ "Checksum32S", "returns", "the", "checksum", "of", "the", "input", "bytes", "with", "the", "specific", "seed", "." ]
c1e3185f167680b62832a0a11938a04b1ab265fc
https://github.com/OneOfOne/xxhash/blob/c1e3185f167680b62832a0a11938a04b1ab265fc/xxhash_go17.go#L12-L62
test
OneOfOne/xxhash
xxhash_go17.go
Checksum64S
func Checksum64S(in []byte, seed uint64) uint64 { if len(in) == 0 && seed == 0 { return 0xef46db3751d8e999 } if len(in) > 31 { return checksum64(in, seed) } return checksum64Short(in, seed) }
go
func Checksum64S(in []byte, seed uint64) uint64 { if len(in) == 0 && seed == 0 { return 0xef46db3751d8e999 } if len(in) > 31 { return checksum64(in, seed) } return checksum64Short(in, seed) }
[ "func", "Checksum64S", "(", "in", "[", "]", "byte", ",", "seed", "uint64", ")", "uint64", "{", "if", "len", "(", "in", ")", "==", "0", "&&", "seed", "==", "0", "{", "return", "0xef46db3751d8e999", "\n", "}", "\n", "if", "len", "(", "in", ")", ">"...
// Checksum64S returns the 64bit xxhash checksum for a single input
[ "Checksum64S", "returns", "the", "64bit", "xxhash", "checksum", "for", "a", "single", "input" ]
c1e3185f167680b62832a0a11938a04b1ab265fc
https://github.com/OneOfOne/xxhash/blob/c1e3185f167680b62832a0a11938a04b1ab265fc/xxhash_go17.go#L151-L161
test
VividCortex/godaemon
daemon.go
getStage
func getStage() (stage int, advanceStage func() error, resetEnv func() error) { var origValue string stage = 0 daemonStage := os.Getenv(stageVar) stageTag := strings.SplitN(daemonStage, ":", 2) stageInfo := strings.SplitN(stageTag[0], "/", 3) if len(stageInfo) == 3 { stageStr, tm, check := stageInfo[0], stage...
go
func getStage() (stage int, advanceStage func() error, resetEnv func() error) { var origValue string stage = 0 daemonStage := os.Getenv(stageVar) stageTag := strings.SplitN(daemonStage, ":", 2) stageInfo := strings.SplitN(stageTag[0], "/", 3) if len(stageInfo) == 3 { stageStr, tm, check := stageInfo[0], stage...
[ "func", "getStage", "(", ")", "(", "stage", "int", ",", "advanceStage", "func", "(", ")", "error", ",", "resetEnv", "func", "(", ")", "error", ")", "{", "var", "origValue", "string", "\n", "stage", "=", "0", "\n", "daemonStage", ":=", "os", ".", "Get...
// Returns the current stage in the "daemonization process", that's kept in // an environment variable. The variable is instrumented with a digital // signature, to avoid misbehavior if it was present in the user's // environment. The original value is restored after the last stage, so that // there's no final effect o...
[ "Returns", "the", "current", "stage", "in", "the", "daemonization", "process", "that", "s", "kept", "in", "an", "environment", "variable", ".", "The", "variable", "is", "instrumented", "with", "a", "digital", "signature", "to", "avoid", "misbehavior", "if", "i...
3d9f6e0b234fe7d17448b345b2e14ac05814a758
https://github.com/VividCortex/godaemon/blob/3d9f6e0b234fe7d17448b345b2e14ac05814a758/daemon.go#L342-L386
test
kpango/glg
glg.go
New
func New() *Glg { g := &Glg{ levelCounter: new(uint32), buffer: sync.Pool{ New: func() interface{} { return bytes.NewBuffer(make([]byte, 0, bufferSize)) }, }, } atomic.StoreUint32(g.levelCounter, uint32(FATAL)) for lev, log := range map[LEVEL]*logger{ // standard out PRINT: { std: os.S...
go
func New() *Glg { g := &Glg{ levelCounter: new(uint32), buffer: sync.Pool{ New: func() interface{} { return bytes.NewBuffer(make([]byte, 0, bufferSize)) }, }, } atomic.StoreUint32(g.levelCounter, uint32(FATAL)) for lev, log := range map[LEVEL]*logger{ // standard out PRINT: { std: os.S...
[ "func", "New", "(", ")", "*", "Glg", "{", "g", ":=", "&", "Glg", "{", "levelCounter", ":", "new", "(", "uint32", ")", ",", "buffer", ":", "sync", ".", "Pool", "{", "New", ":", "func", "(", ")", "interface", "{", "}", "{", "return", "bytes", "."...
// New returns plain glg instance
[ "New", "returns", "plain", "glg", "instance" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L177-L254
test
kpango/glg
glg.go
Get
func Get() *Glg { once.Do(func() { fastime.SetFormat(timeFormat) glg = New() }) return glg }
go
func Get() *Glg { once.Do(func() { fastime.SetFormat(timeFormat) glg = New() }) return glg }
[ "func", "Get", "(", ")", "*", "Glg", "{", "once", ".", "Do", "(", "func", "(", ")", "{", "fastime", ".", "SetFormat", "(", "timeFormat", ")", "\n", "glg", "=", "New", "(", ")", "\n", "}", ")", "\n", "return", "glg", "\n", "}" ]
// Get returns singleton glg instance
[ "Get", "returns", "singleton", "glg", "instance" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L257-L263
test
kpango/glg
glg.go
SetMode
func (g *Glg) SetMode(mode MODE) *Glg { g.logger.Range(func(key, val interface{}) bool { l := val.(*logger) l.mode = mode l.updateMode() g.logger.Store(key.(LEVEL), l) return true }) return g }
go
func (g *Glg) SetMode(mode MODE) *Glg { g.logger.Range(func(key, val interface{}) bool { l := val.(*logger) l.mode = mode l.updateMode() g.logger.Store(key.(LEVEL), l) return true }) return g }
[ "func", "(", "g", "*", "Glg", ")", "SetMode", "(", "mode", "MODE", ")", "*", "Glg", "{", "g", ".", "logger", ".", "Range", "(", "func", "(", "key", ",", "val", "interface", "{", "}", ")", "bool", "{", "l", ":=", "val", ".", "(", "*", "logger"...
// SetMode sets glg logging mode
[ "SetMode", "sets", "glg", "logging", "mode" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L266-L276
test
kpango/glg
glg.go
SetPrefix
func (g *Glg) SetPrefix(pref string) *Glg { v, ok := g.logger.Load(PRINT) if ok { value := v.(*logger) value.tag = pref g.logger.Store(PRINT, value) } return g }
go
func (g *Glg) SetPrefix(pref string) *Glg { v, ok := g.logger.Load(PRINT) if ok { value := v.(*logger) value.tag = pref g.logger.Store(PRINT, value) } return g }
[ "func", "(", "g", "*", "Glg", ")", "SetPrefix", "(", "pref", "string", ")", "*", "Glg", "{", "v", ",", "ok", ":=", "g", ".", "logger", ".", "Load", "(", "PRINT", ")", "\n", "if", "ok", "{", "value", ":=", "v", ".", "(", "*", "logger", ")", ...
// SetPrefix set Print logger prefix
[ "SetPrefix", "set", "Print", "logger", "prefix" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L297-L305
test
kpango/glg
glg.go
GetCurrentMode
func (g *Glg) GetCurrentMode(level LEVEL) MODE { l, ok := g.logger.Load(level) if ok { return l.(*logger).mode } return NONE }
go
func (g *Glg) GetCurrentMode(level LEVEL) MODE { l, ok := g.logger.Load(level) if ok { return l.(*logger).mode } return NONE }
[ "func", "(", "g", "*", "Glg", ")", "GetCurrentMode", "(", "level", "LEVEL", ")", "MODE", "{", "l", ",", "ok", ":=", "g", ".", "logger", ".", "Load", "(", "level", ")", "\n", "if", "ok", "{", "return", "l", ".", "(", "*", "logger", ")", ".", "...
// GetCurrentMode returns current logging mode
[ "GetCurrentMode", "returns", "current", "logging", "mode" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L308-L314
test
kpango/glg
glg.go
InitWriter
func (g *Glg) InitWriter() *Glg { g.logger.Range(func(key, val interface{}) bool { l := val.(*logger) l.writer = nil l.updateMode() g.logger.Store(key.(LEVEL), l) return true }) return g }
go
func (g *Glg) InitWriter() *Glg { g.logger.Range(func(key, val interface{}) bool { l := val.(*logger) l.writer = nil l.updateMode() g.logger.Store(key.(LEVEL), l) return true }) return g }
[ "func", "(", "g", "*", "Glg", ")", "InitWriter", "(", ")", "*", "Glg", "{", "g", ".", "logger", ".", "Range", "(", "func", "(", "key", ",", "val", "interface", "{", "}", ")", "bool", "{", "l", ":=", "val", ".", "(", "*", "logger", ")", "\n", ...
// InitWriter is initialize glg writer
[ "InitWriter", "is", "initialize", "glg", "writer" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L317-L326
test
kpango/glg
glg.go
SetWriter
func (g *Glg) SetWriter(writer io.Writer) *Glg { if writer == nil { return g } g.logger.Range(func(key, val interface{}) bool { l := val.(*logger) l.writer = writer l.updateMode() g.logger.Store(key.(LEVEL), l) return true }) return g }
go
func (g *Glg) SetWriter(writer io.Writer) *Glg { if writer == nil { return g } g.logger.Range(func(key, val interface{}) bool { l := val.(*logger) l.writer = writer l.updateMode() g.logger.Store(key.(LEVEL), l) return true }) return g }
[ "func", "(", "g", "*", "Glg", ")", "SetWriter", "(", "writer", "io", ".", "Writer", ")", "*", "Glg", "{", "if", "writer", "==", "nil", "{", "return", "g", "\n", "}", "\n", "g", ".", "logger", ".", "Range", "(", "func", "(", "key", ",", "val", ...
// SetWriter sets writer to glg std writers
[ "SetWriter", "sets", "writer", "to", "glg", "std", "writers" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L329-L343
test
kpango/glg
glg.go
SetLevelColor
func (g *Glg) SetLevelColor(level LEVEL, color func(string) string) *Glg { lev, ok := g.logger.Load(level) if ok { l := lev.(*logger) l.color = color g.logger.Store(level, l) } return g }
go
func (g *Glg) SetLevelColor(level LEVEL, color func(string) string) *Glg { lev, ok := g.logger.Load(level) if ok { l := lev.(*logger) l.color = color g.logger.Store(level, l) } return g }
[ "func", "(", "g", "*", "Glg", ")", "SetLevelColor", "(", "level", "LEVEL", ",", "color", "func", "(", "string", ")", "string", ")", "*", "Glg", "{", "lev", ",", "ok", ":=", "g", ".", "logger", ".", "Load", "(", "level", ")", "\n", "if", "ok", "...
// SetLevelColor sets the color for each level
[ "SetLevelColor", "sets", "the", "color", "for", "each", "level" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L367-L376
test
kpango/glg
glg.go
SetLevelWriter
func (g *Glg) SetLevelWriter(level LEVEL, writer io.Writer) *Glg { if writer == nil { return g } lev, ok := g.logger.Load(level) if ok { l := lev.(*logger) l.writer = writer l.updateMode() g.logger.Store(level, l) } return g }
go
func (g *Glg) SetLevelWriter(level LEVEL, writer io.Writer) *Glg { if writer == nil { return g } lev, ok := g.logger.Load(level) if ok { l := lev.(*logger) l.writer = writer l.updateMode() g.logger.Store(level, l) } return g }
[ "func", "(", "g", "*", "Glg", ")", "SetLevelWriter", "(", "level", "LEVEL", ",", "writer", "io", ".", "Writer", ")", "*", "Glg", "{", "if", "writer", "==", "nil", "{", "return", "g", "\n", "}", "\n", "lev", ",", "ok", ":=", "g", ".", "logger", ...
// SetLevelWriter sets writer to glg std writer per logging level
[ "SetLevelWriter", "sets", "writer", "to", "glg", "std", "writer", "per", "logging", "level" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L379-L393
test
kpango/glg
glg.go
AddStdLevel
func (g *Glg) AddStdLevel(tag string, mode MODE, isColor bool) *Glg { atomic.AddUint32(g.levelCounter, 1) lev := LEVEL(atomic.LoadUint32(g.levelCounter)) g.levelMap.Store(tag, lev) l := &logger{ writer: nil, std: os.Stdout, color: Colorless, isColor: isColor, mode: mode, tag: tag, } l.up...
go
func (g *Glg) AddStdLevel(tag string, mode MODE, isColor bool) *Glg { atomic.AddUint32(g.levelCounter, 1) lev := LEVEL(atomic.LoadUint32(g.levelCounter)) g.levelMap.Store(tag, lev) l := &logger{ writer: nil, std: os.Stdout, color: Colorless, isColor: isColor, mode: mode, tag: tag, } l.up...
[ "func", "(", "g", "*", "Glg", ")", "AddStdLevel", "(", "tag", "string", ",", "mode", "MODE", ",", "isColor", "bool", ")", "*", "Glg", "{", "atomic", ".", "AddUint32", "(", "g", ".", "levelCounter", ",", "1", ")", "\n", "lev", ":=", "LEVEL", "(", ...
// AddStdLevel adds std log level and returns LEVEL
[ "AddStdLevel", "adds", "std", "log", "level", "and", "returns", "LEVEL" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L417-L432
test
kpango/glg
glg.go
EnableColor
func (g *Glg) EnableColor() *Glg { g.logger.Range(func(key, val interface{}) bool { l := val.(*logger) l.isColor = true l.updateMode() g.logger.Store(key.(LEVEL), l) return true }) return g }
go
func (g *Glg) EnableColor() *Glg { g.logger.Range(func(key, val interface{}) bool { l := val.(*logger) l.isColor = true l.updateMode() g.logger.Store(key.(LEVEL), l) return true }) return g }
[ "func", "(", "g", "*", "Glg", ")", "EnableColor", "(", ")", "*", "Glg", "{", "g", ".", "logger", ".", "Range", "(", "func", "(", "key", ",", "val", "interface", "{", "}", ")", "bool", "{", "l", ":=", "val", ".", "(", "*", "logger", ")", "\n",...
// EnableColor enables color output
[ "EnableColor", "enables", "color", "output" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L453-L464
test
kpango/glg
glg.go
EnableLevelColor
func (g *Glg) EnableLevelColor(lv LEVEL) *Glg { ins, ok := g.logger.Load(lv) if ok { l := ins.(*logger) l.isColor = true l.updateMode() g.logger.Store(lv, l) } return g }
go
func (g *Glg) EnableLevelColor(lv LEVEL) *Glg { ins, ok := g.logger.Load(lv) if ok { l := ins.(*logger) l.isColor = true l.updateMode() g.logger.Store(lv, l) } return g }
[ "func", "(", "g", "*", "Glg", ")", "EnableLevelColor", "(", "lv", "LEVEL", ")", "*", "Glg", "{", "ins", ",", "ok", ":=", "g", ".", "logger", ".", "Load", "(", "lv", ")", "\n", "if", "ok", "{", "l", ":=", "ins", ".", "(", "*", "logger", ")", ...
// EnableLevelColor enables color output
[ "EnableLevelColor", "enables", "color", "output" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L481-L490
test
kpango/glg
glg.go
DisableLevelColor
func (g *Glg) DisableLevelColor(lv LEVEL) *Glg { ins, ok := g.logger.Load(lv) if ok { l := ins.(*logger) l.isColor = false l.updateMode() g.logger.Store(lv, l) } return g }
go
func (g *Glg) DisableLevelColor(lv LEVEL) *Glg { ins, ok := g.logger.Load(lv) if ok { l := ins.(*logger) l.isColor = false l.updateMode() g.logger.Store(lv, l) } return g }
[ "func", "(", "g", "*", "Glg", ")", "DisableLevelColor", "(", "lv", "LEVEL", ")", "*", "Glg", "{", "ins", ",", "ok", ":=", "g", ".", "logger", ".", "Load", "(", "lv", ")", "\n", "if", "ok", "{", "l", ":=", "ins", ".", "(", "*", "logger", ")", ...
// DisableLevelColor disables color output
[ "DisableLevelColor", "disables", "color", "output" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L493-L502
test
kpango/glg
glg.go
RawString
func (g *Glg) RawString(data []byte) string { str := *(*string)(unsafe.Pointer(&data)) return str[strings.Index(str, sep)+sepl : len(str)-rcl] }
go
func (g *Glg) RawString(data []byte) string { str := *(*string)(unsafe.Pointer(&data)) return str[strings.Index(str, sep)+sepl : len(str)-rcl] }
[ "func", "(", "g", "*", "Glg", ")", "RawString", "(", "data", "[", "]", "byte", ")", "string", "{", "str", ":=", "*", "(", "*", "string", ")", "(", "unsafe", ".", "Pointer", "(", "&", "data", ")", ")", "\n", "return", "str", "[", "strings", ".",...
// RawString returns raw log string exclude time & tags
[ "RawString", "returns", "raw", "log", "string", "exclude", "time", "&", "tags" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L505-L508
test
kpango/glg
glg.go
TagStringToLevel
func (g *Glg) TagStringToLevel(tag string) LEVEL { l, ok := g.levelMap.Load(tag) if !ok { return 255 } return l.(LEVEL) }
go
func (g *Glg) TagStringToLevel(tag string) LEVEL { l, ok := g.levelMap.Load(tag) if !ok { return 255 } return l.(LEVEL) }
[ "func", "(", "g", "*", "Glg", ")", "TagStringToLevel", "(", "tag", "string", ")", "LEVEL", "{", "l", ",", "ok", ":=", "g", ".", "levelMap", ".", "Load", "(", "tag", ")", "\n", "if", "!", "ok", "{", "return", "255", "\n", "}", "\n", "return", "l...
// TagStringToLevel converts level string to Glg.LEVEL
[ "TagStringToLevel", "converts", "level", "string", "to", "Glg", ".", "LEVEL" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L516-L522
test
kpango/glg
glg.go
Println
func Println(val ...interface{}) error { return glg.out(PRINT, blankFormat(len(val)), val...) }
go
func Println(val ...interface{}) error { return glg.out(PRINT, blankFormat(len(val)), val...) }
[ "func", "Println", "(", "val", "...", "interface", "{", "}", ")", "error", "{", "return", "glg", ".", "out", "(", "PRINT", ",", "blankFormat", "(", "len", "(", "val", ")", ")", ",", "val", "...", ")", "\n", "}" ]
// Println outputs fixed line Print log
[ "Println", "outputs", "fixed", "line", "Print", "log" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L949-L951
test
kpango/glg
glg.go
Fatal
func (g *Glg) Fatal(val ...interface{}) { err := g.out(FATAL, blankFormat(len(val)), val...) if err != nil { err = g.Error(err.Error()) if err != nil { panic(err) } } exit(1) }
go
func (g *Glg) Fatal(val ...interface{}) { err := g.out(FATAL, blankFormat(len(val)), val...) if err != nil { err = g.Error(err.Error()) if err != nil { panic(err) } } exit(1) }
[ "func", "(", "g", "*", "Glg", ")", "Fatal", "(", "val", "...", "interface", "{", "}", ")", "{", "err", ":=", "g", ".", "out", "(", "FATAL", ",", "blankFormat", "(", "len", "(", "val", ")", ")", ",", "val", "...", ")", "\n", "if", "err", "!=",...
// Fatal outputs Failed log and exit program
[ "Fatal", "outputs", "Failed", "log", "and", "exit", "program" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L1039-L1048
test
kpango/glg
glg.go
Fatalf
func (g *Glg) Fatalf(format string, val ...interface{}) { err := g.out(FATAL, format, val...) if err != nil { err = g.Error(err.Error()) if err != nil { panic(err) } } exit(1) }
go
func (g *Glg) Fatalf(format string, val ...interface{}) { err := g.out(FATAL, format, val...) if err != nil { err = g.Error(err.Error()) if err != nil { panic(err) } } exit(1) }
[ "func", "(", "g", "*", "Glg", ")", "Fatalf", "(", "format", "string", ",", "val", "...", "interface", "{", "}", ")", "{", "err", ":=", "g", ".", "out", "(", "FATAL", ",", "format", ",", "val", "...", ")", "\n", "if", "err", "!=", "nil", "{", ...
// Fatalf outputs formatted Failed log and exit program
[ "Fatalf", "outputs", "formatted", "Failed", "log", "and", "exit", "program" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L1063-L1072
test
kpango/glg
glg.go
isModeEnable
func (g *Glg) isModeEnable(l LEVEL) bool { return g.GetCurrentMode(l) != NONE }
go
func (g *Glg) isModeEnable(l LEVEL) bool { return g.GetCurrentMode(l) != NONE }
[ "func", "(", "g", "*", "Glg", ")", "isModeEnable", "(", "l", "LEVEL", ")", "bool", "{", "return", "g", ".", "GetCurrentMode", "(", "l", ")", "!=", "NONE", "\n", "}" ]
// isModeEnable returns the level has already turned on the logging
[ "isModeEnable", "returns", "the", "level", "has", "already", "turned", "on", "the", "logging" ]
68d2670cb2dbff047331daad841149a82ac37796
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L1119-L1121
test
felixge/httpsnoop
capture_metrics.go
CaptureMetrics
func CaptureMetrics(hnd http.Handler, w http.ResponseWriter, r *http.Request) Metrics { return CaptureMetricsFn(w, func(ww http.ResponseWriter) { hnd.ServeHTTP(ww, r) }) }
go
func CaptureMetrics(hnd http.Handler, w http.ResponseWriter, r *http.Request) Metrics { return CaptureMetricsFn(w, func(ww http.ResponseWriter) { hnd.ServeHTTP(ww, r) }) }
[ "func", "CaptureMetrics", "(", "hnd", "http", ".", "Handler", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "Metrics", "{", "return", "CaptureMetricsFn", "(", "w", ",", "func", "(", "ww", "http", ".", "ResponseWrite...
// CaptureMetrics wraps the given hnd, executes it with the given w and r, and // returns the metrics it captured from it.
[ "CaptureMetrics", "wraps", "the", "given", "hnd", "executes", "it", "with", "the", "given", "w", "and", "r", "and", "returns", "the", "metrics", "it", "captured", "from", "it", "." ]
eadd4fad6aac69ae62379194fe0219f3dbc80fd3
https://github.com/felixge/httpsnoop/blob/eadd4fad6aac69ae62379194fe0219f3dbc80fd3/capture_metrics.go#L28-L32
test
adamzy/cedar-go
cedar.go
get
func (da *cedar) get(key []byte, from, pos int) *int { for ; pos < len(key); pos++ { if value := da.Array[from].Value; value >= 0 && value != ValueLimit { to := da.follow(from, 0) da.Array[to].Value = value } from = da.follow(from, key[pos]) } to := from if da.Array[from].Value < 0 { to = da.follow(fr...
go
func (da *cedar) get(key []byte, from, pos int) *int { for ; pos < len(key); pos++ { if value := da.Array[from].Value; value >= 0 && value != ValueLimit { to := da.follow(from, 0) da.Array[to].Value = value } from = da.follow(from, key[pos]) } to := from if da.Array[from].Value < 0 { to = da.follow(fr...
[ "func", "(", "da", "*", "cedar", ")", "get", "(", "key", "[", "]", "byte", ",", "from", ",", "pos", "int", ")", "*", "int", "{", "for", ";", "pos", "<", "len", "(", "key", ")", ";", "pos", "++", "{", "if", "value", ":=", "da", ".", "Array",...
// Get value by key, insert the key if not exist
[ "Get", "value", "by", "key", "insert", "the", "key", "if", "not", "exist" ]
80a9c64b256db37ac20aff007907c649afb714f1
https://github.com/adamzy/cedar-go/blob/80a9c64b256db37ac20aff007907c649afb714f1/cedar.go#L72-L85
test
adamzy/cedar-go
io.go
Save
func (da *Cedar) Save(out io.Writer, dataType string) error { switch dataType { case "gob", "GOB": dataEecoder := gob.NewEncoder(out) return dataEecoder.Encode(da.cedar) case "json", "JSON": dataEecoder := json.NewEncoder(out) return dataEecoder.Encode(da.cedar) } return ErrInvalidDataType }
go
func (da *Cedar) Save(out io.Writer, dataType string) error { switch dataType { case "gob", "GOB": dataEecoder := gob.NewEncoder(out) return dataEecoder.Encode(da.cedar) case "json", "JSON": dataEecoder := json.NewEncoder(out) return dataEecoder.Encode(da.cedar) } return ErrInvalidDataType }
[ "func", "(", "da", "*", "Cedar", ")", "Save", "(", "out", "io", ".", "Writer", ",", "dataType", "string", ")", "error", "{", "switch", "dataType", "{", "case", "\"gob\"", ",", "\"GOB\"", ":", "dataEecoder", ":=", "gob", ".", "NewEncoder", "(", "out", ...
// Save saves the cedar to an io.Writer, // where dataType is either "json" or "gob".
[ "Save", "saves", "the", "cedar", "to", "an", "io", ".", "Writer", "where", "dataType", "is", "either", "json", "or", "gob", "." ]
80a9c64b256db37ac20aff007907c649afb714f1
https://github.com/adamzy/cedar-go/blob/80a9c64b256db37ac20aff007907c649afb714f1/io.go#L13-L23
test
adamzy/cedar-go
io.go
SaveToFile
func (da *Cedar) SaveToFile(fileName string, dataType string) error { file, err := os.OpenFile(fileName, os.O_CREATE|os.O_WRONLY, 0666) if err != nil { return err } defer file.Close() out := bufio.NewWriter(file) defer out.Flush() da.Save(out, dataType) return nil }
go
func (da *Cedar) SaveToFile(fileName string, dataType string) error { file, err := os.OpenFile(fileName, os.O_CREATE|os.O_WRONLY, 0666) if err != nil { return err } defer file.Close() out := bufio.NewWriter(file) defer out.Flush() da.Save(out, dataType) return nil }
[ "func", "(", "da", "*", "Cedar", ")", "SaveToFile", "(", "fileName", "string", ",", "dataType", "string", ")", "error", "{", "file", ",", "err", ":=", "os", ".", "OpenFile", "(", "fileName", ",", "os", ".", "O_CREATE", "|", "os", ".", "O_WRONLY", ","...
// SaveToFile saves the cedar to a file, // where dataType is either "json" or "gob".
[ "SaveToFile", "saves", "the", "cedar", "to", "a", "file", "where", "dataType", "is", "either", "json", "or", "gob", "." ]
80a9c64b256db37ac20aff007907c649afb714f1
https://github.com/adamzy/cedar-go/blob/80a9c64b256db37ac20aff007907c649afb714f1/io.go#L27-L37
test
adamzy/cedar-go
io.go
Load
func (da *Cedar) Load(in io.Reader, dataType string) error { switch dataType { case "gob", "GOB": dataDecoder := gob.NewDecoder(in) return dataDecoder.Decode(da.cedar) case "json", "JSON": dataDecoder := json.NewDecoder(in) return dataDecoder.Decode(da.cedar) } return ErrInvalidDataType }
go
func (da *Cedar) Load(in io.Reader, dataType string) error { switch dataType { case "gob", "GOB": dataDecoder := gob.NewDecoder(in) return dataDecoder.Decode(da.cedar) case "json", "JSON": dataDecoder := json.NewDecoder(in) return dataDecoder.Decode(da.cedar) } return ErrInvalidDataType }
[ "func", "(", "da", "*", "Cedar", ")", "Load", "(", "in", "io", ".", "Reader", ",", "dataType", "string", ")", "error", "{", "switch", "dataType", "{", "case", "\"gob\"", ",", "\"GOB\"", ":", "dataDecoder", ":=", "gob", ".", "NewDecoder", "(", "in", "...
// Load loads the cedar from an io.Writer, // where dataType is either "json" or "gob".
[ "Load", "loads", "the", "cedar", "from", "an", "io", ".", "Writer", "where", "dataType", "is", "either", "json", "or", "gob", "." ]
80a9c64b256db37ac20aff007907c649afb714f1
https://github.com/adamzy/cedar-go/blob/80a9c64b256db37ac20aff007907c649afb714f1/io.go#L41-L51
test
adamzy/cedar-go
io.go
LoadFromFile
func (da *Cedar) LoadFromFile(fileName string, dataType string) error { file, err := os.OpenFile(fileName, os.O_RDONLY, 0600) defer file.Close() if err != nil { return err } in := bufio.NewReader(file) return da.Load(in, dataType) }
go
func (da *Cedar) LoadFromFile(fileName string, dataType string) error { file, err := os.OpenFile(fileName, os.O_RDONLY, 0600) defer file.Close() if err != nil { return err } in := bufio.NewReader(file) return da.Load(in, dataType) }
[ "func", "(", "da", "*", "Cedar", ")", "LoadFromFile", "(", "fileName", "string", ",", "dataType", "string", ")", "error", "{", "file", ",", "err", ":=", "os", ".", "OpenFile", "(", "fileName", ",", "os", ".", "O_RDONLY", ",", "0600", ")", "\n", "defe...
// LoadFromFile loads the cedar from a file, // where dataType is either "json" or "gob".
[ "LoadFromFile", "loads", "the", "cedar", "from", "a", "file", "where", "dataType", "is", "either", "json", "or", "gob", "." ]
80a9c64b256db37ac20aff007907c649afb714f1
https://github.com/adamzy/cedar-go/blob/80a9c64b256db37ac20aff007907c649afb714f1/io.go#L55-L63
test
adamzy/cedar-go
api.go
Key
func (da *Cedar) Key(id int) (key []byte, err error) { for id > 0 { from := da.Array[id].Check if from < 0 { return nil, ErrNoPath } if char := byte(da.Array[from].base() ^ id); char != 0 { key = append(key, char) } id = from } if id != 0 || len(key) == 0 { return nil, ErrInvalidKey } for i := ...
go
func (da *Cedar) Key(id int) (key []byte, err error) { for id > 0 { from := da.Array[id].Check if from < 0 { return nil, ErrNoPath } if char := byte(da.Array[from].base() ^ id); char != 0 { key = append(key, char) } id = from } if id != 0 || len(key) == 0 { return nil, ErrInvalidKey } for i := ...
[ "func", "(", "da", "*", "Cedar", ")", "Key", "(", "id", "int", ")", "(", "key", "[", "]", "byte", ",", "err", "error", ")", "{", "for", "id", ">", "0", "{", "from", ":=", "da", ".", "Array", "[", "id", "]", ".", "Check", "\n", "if", "from",...
// Key returns the key of the node with the given `id`. // It will return ErrNoPath, if the node does not exist.
[ "Key", "returns", "the", "key", "of", "the", "node", "with", "the", "given", "id", ".", "It", "will", "return", "ErrNoPath", "if", "the", "node", "does", "not", "exist", "." ]
80a9c64b256db37ac20aff007907c649afb714f1
https://github.com/adamzy/cedar-go/blob/80a9c64b256db37ac20aff007907c649afb714f1/api.go#L47-L65
test
adamzy/cedar-go
api.go
Value
func (da *Cedar) Value(id int) (value int, err error) { value = da.Array[id].Value if value >= 0 { return value, nil } to := da.Array[id].base() if da.Array[to].Check == id && da.Array[to].Value >= 0 { return da.Array[to].Value, nil } return 0, ErrNoValue }
go
func (da *Cedar) Value(id int) (value int, err error) { value = da.Array[id].Value if value >= 0 { return value, nil } to := da.Array[id].base() if da.Array[to].Check == id && da.Array[to].Value >= 0 { return da.Array[to].Value, nil } return 0, ErrNoValue }
[ "func", "(", "da", "*", "Cedar", ")", "Value", "(", "id", "int", ")", "(", "value", "int", ",", "err", "error", ")", "{", "value", "=", "da", ".", "Array", "[", "id", "]", ".", "Value", "\n", "if", "value", ">=", "0", "{", "return", "value", ...
// Value returns the value of the node with the given `id`. // It will return ErrNoValue, if the node does not have a value.
[ "Value", "returns", "the", "value", "of", "the", "node", "with", "the", "given", "id", ".", "It", "will", "return", "ErrNoValue", "if", "the", "node", "does", "not", "have", "a", "value", "." ]
80a9c64b256db37ac20aff007907c649afb714f1
https://github.com/adamzy/cedar-go/blob/80a9c64b256db37ac20aff007907c649afb714f1/api.go#L69-L79
test
adamzy/cedar-go
api.go
Delete
func (da *Cedar) Delete(key []byte) error { // if the path does not exist, or the end is not a leaf, nothing to delete to, err := da.Jump(key, 0) if err != nil { return ErrNoPath } if da.Array[to].Value < 0 { base := da.Array[to].base() if da.Array[base].Check == to { to = base } } for to > 0 { fr...
go
func (da *Cedar) Delete(key []byte) error { // if the path does not exist, or the end is not a leaf, nothing to delete to, err := da.Jump(key, 0) if err != nil { return ErrNoPath } if da.Array[to].Value < 0 { base := da.Array[to].base() if da.Array[base].Check == to { to = base } } for to > 0 { fr...
[ "func", "(", "da", "*", "Cedar", ")", "Delete", "(", "key", "[", "]", "byte", ")", "error", "{", "to", ",", "err", ":=", "da", ".", "Jump", "(", "key", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ErrNoPath", "\n", "}", "\n"...
// Delete removes a key-value pair from the cedar. // It will return ErrNoPath, if the key has not been added.
[ "Delete", "removes", "a", "key", "-", "value", "pair", "from", "the", "cedar", ".", "It", "will", "return", "ErrNoPath", "if", "the", "key", "has", "not", "been", "added", "." ]
80a9c64b256db37ac20aff007907c649afb714f1
https://github.com/adamzy/cedar-go/blob/80a9c64b256db37ac20aff007907c649afb714f1/api.go#L114-L147
test
coreos/go-semver
semver/semver.go
Set
func (v *Version) Set(version string) error { metadata := splitOff(&version, "+") preRelease := PreRelease(splitOff(&version, "-")) dotParts := strings.SplitN(version, ".", 3) if len(dotParts) != 3 { return fmt.Errorf("%s is not in dotted-tri format", version) } if err := validateIdentifier(string(preRelease)...
go
func (v *Version) Set(version string) error { metadata := splitOff(&version, "+") preRelease := PreRelease(splitOff(&version, "-")) dotParts := strings.SplitN(version, ".", 3) if len(dotParts) != 3 { return fmt.Errorf("%s is not in dotted-tri format", version) } if err := validateIdentifier(string(preRelease)...
[ "func", "(", "v", "*", "Version", ")", "Set", "(", "version", "string", ")", "error", "{", "metadata", ":=", "splitOff", "(", "&", "version", ",", "\"+\"", ")", "\n", "preRelease", ":=", "PreRelease", "(", "splitOff", "(", "&", "version", ",", "\"-\"",...
// Set parses and updates v from the given version string. Implements flag.Value
[ "Set", "parses", "and", "updates", "v", "from", "the", "given", "version", "string", ".", "Implements", "flag", ".", "Value" ]
e214231b295a8ea9479f11b70b35d5acf3556d9b
https://github.com/coreos/go-semver/blob/e214231b295a8ea9479f11b70b35d5acf3556d9b/semver/semver.go#L71-L104
test
coreos/go-semver
semver/semver.go
Compare
func (v Version) Compare(versionB Version) int { if cmp := recursiveCompare(v.Slice(), versionB.Slice()); cmp != 0 { return cmp } return preReleaseCompare(v, versionB) }
go
func (v Version) Compare(versionB Version) int { if cmp := recursiveCompare(v.Slice(), versionB.Slice()); cmp != 0 { return cmp } return preReleaseCompare(v, versionB) }
[ "func", "(", "v", "Version", ")", "Compare", "(", "versionB", "Version", ")", "int", "{", "if", "cmp", ":=", "recursiveCompare", "(", "v", ".", "Slice", "(", ")", ",", "versionB", ".", "Slice", "(", ")", ")", ";", "cmp", "!=", "0", "{", "return", ...
// Compare tests if v is less than, equal to, or greater than versionB, // returning -1, 0, or +1 respectively.
[ "Compare", "tests", "if", "v", "is", "less", "than", "equal", "to", "or", "greater", "than", "versionB", "returning", "-", "1", "0", "or", "+", "1", "respectively", "." ]
e214231b295a8ea9479f11b70b35d5acf3556d9b
https://github.com/coreos/go-semver/blob/e214231b295a8ea9479f11b70b35d5acf3556d9b/semver/semver.go#L147-L152
test
coreos/go-semver
semver/semver.go
Slice
func (v Version) Slice() []int64 { return []int64{v.Major, v.Minor, v.Patch} }
go
func (v Version) Slice() []int64 { return []int64{v.Major, v.Minor, v.Patch} }
[ "func", "(", "v", "Version", ")", "Slice", "(", ")", "[", "]", "int64", "{", "return", "[", "]", "int64", "{", "v", ".", "Major", ",", "v", ".", "Minor", ",", "v", ".", "Patch", "}", "\n", "}" ]
// Slice converts the comparable parts of the semver into a slice of integers.
[ "Slice", "converts", "the", "comparable", "parts", "of", "the", "semver", "into", "a", "slice", "of", "integers", "." ]
e214231b295a8ea9479f11b70b35d5acf3556d9b
https://github.com/coreos/go-semver/blob/e214231b295a8ea9479f11b70b35d5acf3556d9b/semver/semver.go#L165-L167
test
coreos/go-semver
semver/semver.go
BumpMajor
func (v *Version) BumpMajor() { v.Major += 1 v.Minor = 0 v.Patch = 0 v.PreRelease = PreRelease("") v.Metadata = "" }
go
func (v *Version) BumpMajor() { v.Major += 1 v.Minor = 0 v.Patch = 0 v.PreRelease = PreRelease("") v.Metadata = "" }
[ "func", "(", "v", "*", "Version", ")", "BumpMajor", "(", ")", "{", "v", ".", "Major", "+=", "1", "\n", "v", ".", "Minor", "=", "0", "\n", "v", ".", "Patch", "=", "0", "\n", "v", ".", "PreRelease", "=", "PreRelease", "(", "\"\"", ")", "\n", "v...
// BumpMajor increments the Major field by 1 and resets all other fields to their default values
[ "BumpMajor", "increments", "the", "Major", "field", "by", "1", "and", "resets", "all", "other", "fields", "to", "their", "default", "values" ]
e214231b295a8ea9479f11b70b35d5acf3556d9b
https://github.com/coreos/go-semver/blob/e214231b295a8ea9479f11b70b35d5acf3556d9b/semver/semver.go#L263-L269
test
coreos/go-semver
semver/semver.go
BumpMinor
func (v *Version) BumpMinor() { v.Minor += 1 v.Patch = 0 v.PreRelease = PreRelease("") v.Metadata = "" }
go
func (v *Version) BumpMinor() { v.Minor += 1 v.Patch = 0 v.PreRelease = PreRelease("") v.Metadata = "" }
[ "func", "(", "v", "*", "Version", ")", "BumpMinor", "(", ")", "{", "v", ".", "Minor", "+=", "1", "\n", "v", ".", "Patch", "=", "0", "\n", "v", ".", "PreRelease", "=", "PreRelease", "(", "\"\"", ")", "\n", "v", ".", "Metadata", "=", "\"\"", "\n"...
// BumpMinor increments the Minor field by 1 and resets all other fields to their default values
[ "BumpMinor", "increments", "the", "Minor", "field", "by", "1", "and", "resets", "all", "other", "fields", "to", "their", "default", "values" ]
e214231b295a8ea9479f11b70b35d5acf3556d9b
https://github.com/coreos/go-semver/blob/e214231b295a8ea9479f11b70b35d5acf3556d9b/semver/semver.go#L272-L277
test
coreos/go-semver
semver/semver.go
BumpPatch
func (v *Version) BumpPatch() { v.Patch += 1 v.PreRelease = PreRelease("") v.Metadata = "" }
go
func (v *Version) BumpPatch() { v.Patch += 1 v.PreRelease = PreRelease("") v.Metadata = "" }
[ "func", "(", "v", "*", "Version", ")", "BumpPatch", "(", ")", "{", "v", ".", "Patch", "+=", "1", "\n", "v", ".", "PreRelease", "=", "PreRelease", "(", "\"\"", ")", "\n", "v", ".", "Metadata", "=", "\"\"", "\n", "}" ]
// BumpPatch increments the Patch field by 1 and resets all other fields to their default values
[ "BumpPatch", "increments", "the", "Patch", "field", "by", "1", "and", "resets", "all", "other", "fields", "to", "their", "default", "values" ]
e214231b295a8ea9479f11b70b35d5acf3556d9b
https://github.com/coreos/go-semver/blob/e214231b295a8ea9479f11b70b35d5acf3556d9b/semver/semver.go#L280-L284
test
coreos/go-semver
semver/semver.go
validateIdentifier
func validateIdentifier(id string) error { if id != "" && !reIdentifier.MatchString(id) { return fmt.Errorf("%s is not a valid semver identifier", id) } return nil }
go
func validateIdentifier(id string) error { if id != "" && !reIdentifier.MatchString(id) { return fmt.Errorf("%s is not a valid semver identifier", id) } return nil }
[ "func", "validateIdentifier", "(", "id", "string", ")", "error", "{", "if", "id", "!=", "\"\"", "&&", "!", "reIdentifier", ".", "MatchString", "(", "id", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"%s is not a valid semver identifier\"", ",", "id", ")"...
// validateIdentifier makes sure the provided identifier satisfies semver spec
[ "validateIdentifier", "makes", "sure", "the", "provided", "identifier", "satisfies", "semver", "spec" ]
e214231b295a8ea9479f11b70b35d5acf3556d9b
https://github.com/coreos/go-semver/blob/e214231b295a8ea9479f11b70b35d5acf3556d9b/semver/semver.go#L287-L292
test
r3labs/sse
stream.go
newStream
func newStream(bufsize int, replay bool) *Stream { return &Stream{ AutoReplay: replay, subscribers: make([]*Subscriber, 0), register: make(chan *Subscriber), deregister: make(chan *Subscriber), event: make(chan *Event, bufsize), quit: make(chan bool), Eventlog: make(EventLog, 0), } ...
go
func newStream(bufsize int, replay bool) *Stream { return &Stream{ AutoReplay: replay, subscribers: make([]*Subscriber, 0), register: make(chan *Subscriber), deregister: make(chan *Subscriber), event: make(chan *Event, bufsize), quit: make(chan bool), Eventlog: make(EventLog, 0), } ...
[ "func", "newStream", "(", "bufsize", "int", ",", "replay", "bool", ")", "*", "Stream", "{", "return", "&", "Stream", "{", "AutoReplay", ":", "replay", ",", "subscribers", ":", "make", "(", "[", "]", "*", "Subscriber", ",", "0", ")", ",", "register", ...
// newStream returns a new stream
[ "newStream", "returns", "a", "new", "stream" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/stream.go#L27-L37
test
r3labs/sse
stream.go
addSubscriber
func (str *Stream) addSubscriber(eventid string) *Subscriber { sub := &Subscriber{ eventid: eventid, quit: str.deregister, connection: make(chan *Event, 64), } str.register <- sub return sub }
go
func (str *Stream) addSubscriber(eventid string) *Subscriber { sub := &Subscriber{ eventid: eventid, quit: str.deregister, connection: make(chan *Event, 64), } str.register <- sub return sub }
[ "func", "(", "str", "*", "Stream", ")", "addSubscriber", "(", "eventid", "string", ")", "*", "Subscriber", "{", "sub", ":=", "&", "Subscriber", "{", "eventid", ":", "eventid", ",", "quit", ":", "str", ".", "deregister", ",", "connection", ":", "make", ...
// addSubscriber will create a new subscriber on a stream
[ "addSubscriber", "will", "create", "a", "new", "subscriber", "on", "a", "stream" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/stream.go#L90-L99
test
r3labs/sse
server.go
New
func New() *Server { return &Server{ BufferSize: DefaultBufferSize, AutoStream: false, AutoReplay: true, Streams: make(map[string]*Stream), } }
go
func New() *Server { return &Server{ BufferSize: DefaultBufferSize, AutoStream: false, AutoReplay: true, Streams: make(map[string]*Stream), } }
[ "func", "New", "(", ")", "*", "Server", "{", "return", "&", "Server", "{", "BufferSize", ":", "DefaultBufferSize", ",", "AutoStream", ":", "false", ",", "AutoReplay", ":", "true", ",", "Streams", ":", "make", "(", "map", "[", "string", "]", "*", "Strea...
// New will create a server and setup defaults
[ "New", "will", "create", "a", "server", "and", "setup", "defaults" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/server.go#L33-L40
test
r3labs/sse
server.go
Close
func (s *Server) Close() { s.mu.Lock() defer s.mu.Unlock() for id := range s.Streams { s.Streams[id].quit <- true delete(s.Streams, id) } }
go
func (s *Server) Close() { s.mu.Lock() defer s.mu.Unlock() for id := range s.Streams { s.Streams[id].quit <- true delete(s.Streams, id) } }
[ "func", "(", "s", "*", "Server", ")", "Close", "(", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "for", "id", ":=", "range", "s", ".", "Streams", "{", "s", ".", "Streams", "[...
// Close shuts down the server, closes all of the streams and connections
[ "Close", "shuts", "down", "the", "server", "closes", "all", "of", "the", "streams", "and", "connections" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/server.go#L43-L51
test
r3labs/sse
server.go
CreateStream
func (s *Server) CreateStream(id string) *Stream { s.mu.Lock() defer s.mu.Unlock() if s.Streams[id] != nil { return s.Streams[id] } str := newStream(s.BufferSize, s.AutoReplay) str.run() s.Streams[id] = str return str }
go
func (s *Server) CreateStream(id string) *Stream { s.mu.Lock() defer s.mu.Unlock() if s.Streams[id] != nil { return s.Streams[id] } str := newStream(s.BufferSize, s.AutoReplay) str.run() s.Streams[id] = str return str }
[ "func", "(", "s", "*", "Server", ")", "CreateStream", "(", "id", "string", ")", "*", "Stream", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "Streams", "[", "id", "]"...
// CreateStream will create a new stream and register it
[ "CreateStream", "will", "create", "a", "new", "stream", "and", "register", "it" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/server.go#L54-L68
test
r3labs/sse
server.go
RemoveStream
func (s *Server) RemoveStream(id string) { s.mu.Lock() defer s.mu.Unlock() if s.Streams[id] != nil { s.Streams[id].close() delete(s.Streams, id) } }
go
func (s *Server) RemoveStream(id string) { s.mu.Lock() defer s.mu.Unlock() if s.Streams[id] != nil { s.Streams[id].close() delete(s.Streams, id) } }
[ "func", "(", "s", "*", "Server", ")", "RemoveStream", "(", "id", "string", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "Streams", "[", "id", "]", "!=", "nil", ...
// RemoveStream will remove a stream
[ "RemoveStream", "will", "remove", "a", "stream" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/server.go#L71-L79
test
r3labs/sse
server.go
StreamExists
func (s *Server) StreamExists(id string) bool { s.mu.Lock() defer s.mu.Unlock() return s.Streams[id] != nil }
go
func (s *Server) StreamExists(id string) bool { s.mu.Lock() defer s.mu.Unlock() return s.Streams[id] != nil }
[ "func", "(", "s", "*", "Server", ")", "StreamExists", "(", "id", "string", ")", "bool", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "s", ".", "Streams", "[", "id", "]", "...
// StreamExists checks whether a stream by a given id exists
[ "StreamExists", "checks", "whether", "a", "stream", "by", "a", "given", "id", "exists" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/server.go#L82-L87
test
r3labs/sse
server.go
Publish
func (s *Server) Publish(id string, event *Event) { s.mu.Lock() defer s.mu.Unlock() if s.Streams[id] != nil { s.Streams[id].event <- s.process(event) } }
go
func (s *Server) Publish(id string, event *Event) { s.mu.Lock() defer s.mu.Unlock() if s.Streams[id] != nil { s.Streams[id].event <- s.process(event) } }
[ "func", "(", "s", "*", "Server", ")", "Publish", "(", "id", "string", ",", "event", "*", "Event", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "Streams", "[", ...
// Publish sends a mesage to every client in a streamID
[ "Publish", "sends", "a", "mesage", "to", "every", "client", "in", "a", "streamID" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/server.go#L90-L96
test
r3labs/sse
client.go
NewClient
func NewClient(url string) *Client { return &Client{ URL: url, Connection: &http.Client{}, Headers: make(map[string]string), subscribed: make(map[chan *Event]chan bool), } }
go
func NewClient(url string) *Client { return &Client{ URL: url, Connection: &http.Client{}, Headers: make(map[string]string), subscribed: make(map[chan *Event]chan bool), } }
[ "func", "NewClient", "(", "url", "string", ")", "*", "Client", "{", "return", "&", "Client", "{", "URL", ":", "url", ",", "Connection", ":", "&", "http", ".", "Client", "{", "}", ",", "Headers", ":", "make", "(", "map", "[", "string", "]", "string"...
// NewClient creates a new client
[ "NewClient", "creates", "a", "new", "client" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/client.go#L44-L51
test
r3labs/sse
client.go
Subscribe
func (c *Client) Subscribe(stream string, handler func(msg *Event)) error { operation := func() error { resp, err := c.request(stream) if err != nil { return err } defer resp.Body.Close() reader := NewEventStreamReader(resp.Body) for { // Read each new line and process the type of event event, e...
go
func (c *Client) Subscribe(stream string, handler func(msg *Event)) error { operation := func() error { resp, err := c.request(stream) if err != nil { return err } defer resp.Body.Close() reader := NewEventStreamReader(resp.Body) for { // Read each new line and process the type of event event, e...
[ "func", "(", "c", "*", "Client", ")", "Subscribe", "(", "stream", "string", ",", "handler", "func", "(", "msg", "*", "Event", ")", ")", "error", "{", "operation", ":=", "func", "(", ")", "error", "{", "resp", ",", "err", ":=", "c", ".", "request", ...
// Subscribe to a data stream
[ "Subscribe", "to", "a", "data", "stream" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/client.go#L54-L93
test
r3labs/sse
client.go
SubscribeChan
func (c *Client) SubscribeChan(stream string, ch chan *Event) error { var connected bool errch := make(chan error) c.mu.Lock() c.subscribed[ch] = make(chan bool) c.mu.Unlock() go func() { operation := func() error { resp, err := c.request(stream) if err != nil { c.cleanup(resp, ch) return err ...
go
func (c *Client) SubscribeChan(stream string, ch chan *Event) error { var connected bool errch := make(chan error) c.mu.Lock() c.subscribed[ch] = make(chan bool) c.mu.Unlock() go func() { operation := func() error { resp, err := c.request(stream) if err != nil { c.cleanup(resp, ch) return err ...
[ "func", "(", "c", "*", "Client", ")", "SubscribeChan", "(", "stream", "string", ",", "ch", "chan", "*", "Event", ")", "error", "{", "var", "connected", "bool", "\n", "errch", ":=", "make", "(", "chan", "error", ")", "\n", "c", ".", "mu", ".", "Lock...
// SubscribeChan sends all events to the provided channel
[ "SubscribeChan", "sends", "all", "events", "to", "the", "provided", "channel" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/client.go#L96-L168
test
r3labs/sse
client.go
SubscribeRaw
func (c *Client) SubscribeRaw(handler func(msg *Event)) error { return c.Subscribe("", handler) }
go
func (c *Client) SubscribeRaw(handler func(msg *Event)) error { return c.Subscribe("", handler) }
[ "func", "(", "c", "*", "Client", ")", "SubscribeRaw", "(", "handler", "func", "(", "msg", "*", "Event", ")", ")", "error", "{", "return", "c", ".", "Subscribe", "(", "\"\"", ",", "handler", ")", "\n", "}" ]
// SubscribeRaw to an sse endpoint
[ "SubscribeRaw", "to", "an", "sse", "endpoint" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/client.go#L171-L173
test
r3labs/sse
client.go
Unsubscribe
func (c *Client) Unsubscribe(ch chan *Event) { c.mu.Lock() defer c.mu.Unlock() if c.subscribed[ch] != nil { c.subscribed[ch] <- true } }
go
func (c *Client) Unsubscribe(ch chan *Event) { c.mu.Lock() defer c.mu.Unlock() if c.subscribed[ch] != nil { c.subscribed[ch] <- true } }
[ "func", "(", "c", "*", "Client", ")", "Unsubscribe", "(", "ch", "chan", "*", "Event", ")", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "c", ".", "subscribed", "[", "ch", "]",...
// Unsubscribe unsubscribes a channel
[ "Unsubscribe", "unsubscribes", "a", "channel" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/client.go#L181-L188
test
r3labs/sse
event.go
NewEventStreamReader
func NewEventStreamReader(eventStream io.Reader) *EventStreamReader { scanner := bufio.NewScanner(eventStream) split := func(data []byte, atEOF bool) (int, []byte, error) { if atEOF && len(data) == 0 { return 0, nil, nil } // We have a full event payload to parse. if i := bytes.Index(data, []byte("\r\n\r\...
go
func NewEventStreamReader(eventStream io.Reader) *EventStreamReader { scanner := bufio.NewScanner(eventStream) split := func(data []byte, atEOF bool) (int, []byte, error) { if atEOF && len(data) == 0 { return 0, nil, nil } // We have a full event payload to parse. if i := bytes.Index(data, []byte("\r\n\r\...
[ "func", "NewEventStreamReader", "(", "eventStream", "io", ".", "Reader", ")", "*", "EventStreamReader", "{", "scanner", ":=", "bufio", ".", "NewScanner", "(", "eventStream", ")", "\n", "split", ":=", "func", "(", "data", "[", "]", "byte", ",", "atEOF", "bo...
// NewEventStreamReader creates an instance of EventStreamReader.
[ "NewEventStreamReader", "creates", "an", "instance", "of", "EventStreamReader", "." ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/event.go#L31-L61
test
r3labs/sse
event.go
ReadEvent
func (e *EventStreamReader) ReadEvent() ([]byte, error) { if e.scanner.Scan() { event := e.scanner.Bytes() return event, nil } if err := e.scanner.Err(); err != nil { return nil, err } return nil, io.EOF }
go
func (e *EventStreamReader) ReadEvent() ([]byte, error) { if e.scanner.Scan() { event := e.scanner.Bytes() return event, nil } if err := e.scanner.Err(); err != nil { return nil, err } return nil, io.EOF }
[ "func", "(", "e", "*", "EventStreamReader", ")", "ReadEvent", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "e", ".", "scanner", ".", "Scan", "(", ")", "{", "event", ":=", "e", ".", "scanner", ".", "Bytes", "(", ")", "\n", "ret...
// ReadEvent scans the EventStream for events.
[ "ReadEvent", "scans", "the", "EventStream", "for", "events", "." ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/event.go#L64-L73
test
r3labs/sse
http.go
HTTPHandler
func (s *Server) HTTPHandler(w http.ResponseWriter, r *http.Request) { flusher, err := w.(http.Flusher) if !err { http.Error(w, "Streaming unsupported!", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "text/event-stream") w.Header().Set("Cache-Control", "no-cache") w.Header().Set("Co...
go
func (s *Server) HTTPHandler(w http.ResponseWriter, r *http.Request) { flusher, err := w.(http.Flusher) if !err { http.Error(w, "Streaming unsupported!", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "text/event-stream") w.Header().Set("Cache-Control", "no-cache") w.Header().Set("Co...
[ "func", "(", "s", "*", "Server", ")", "HTTPHandler", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "flusher", ",", "err", ":=", "w", ".", "(", "http", ".", "Flusher", ")", "\n", "if", "!", "err", "{", ...
// HTTPHandler serves new connections with events for a given stream ...
[ "HTTPHandler", "serves", "new", "connections", "with", "events", "for", "a", "given", "stream", "..." ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/http.go#L14-L87
test
r3labs/sse
event_log.go
Add
func (e *EventLog) Add(ev *Event) { ev.ID = []byte(e.currentindex()) ev.timestamp = time.Now() (*e) = append((*e), ev) }
go
func (e *EventLog) Add(ev *Event) { ev.ID = []byte(e.currentindex()) ev.timestamp = time.Now() (*e) = append((*e), ev) }
[ "func", "(", "e", "*", "EventLog", ")", "Add", "(", "ev", "*", "Event", ")", "{", "ev", ".", "ID", "=", "[", "]", "byte", "(", "e", ".", "currentindex", "(", ")", ")", "\n", "ev", ".", "timestamp", "=", "time", ".", "Now", "(", ")", "\n", "...
// Add event to eventlog
[ "Add", "event", "to", "eventlog" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/event_log.go#L16-L20
test
r3labs/sse
event_log.go
Replay
func (e *EventLog) Replay(s *Subscriber) { for i := 0; i < len((*e)); i++ { if string((*e)[i].ID) >= s.eventid { s.connection <- (*e)[i] } } }
go
func (e *EventLog) Replay(s *Subscriber) { for i := 0; i < len((*e)); i++ { if string((*e)[i].ID) >= s.eventid { s.connection <- (*e)[i] } } }
[ "func", "(", "e", "*", "EventLog", ")", "Replay", "(", "s", "*", "Subscriber", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "(", "*", "e", ")", ")", ";", "i", "++", "{", "if", "string", "(", "(", "*", "e", ")", "[", "i", ...
// Replay events to a subscriber
[ "Replay", "events", "to", "a", "subscriber" ]
2f90368216802092e9ed520c43e974e11d50438d
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/event_log.go#L28-L34
test
google/acme
config.go
readKey
func readKey(path string) (crypto.Signer, error) { b, err := ioutil.ReadFile(path) if err != nil { return nil, err } d, _ := pem.Decode(b) if d == nil { return nil, fmt.Errorf("no block found in %q", path) } switch d.Type { case rsaPrivateKey: return x509.ParsePKCS1PrivateKey(d.Bytes) case ecPrivateKey: ...
go
func readKey(path string) (crypto.Signer, error) { b, err := ioutil.ReadFile(path) if err != nil { return nil, err } d, _ := pem.Decode(b) if d == nil { return nil, fmt.Errorf("no block found in %q", path) } switch d.Type { case rsaPrivateKey: return x509.ParsePKCS1PrivateKey(d.Bytes) case ecPrivateKey: ...
[ "func", "readKey", "(", "path", "string", ")", "(", "crypto", ".", "Signer", ",", "error", ")", "{", "b", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", ...
// readKey reads a private rsa key from path. // The key is expected to be in PEM format.
[ "readKey", "reads", "a", "private", "rsa", "key", "from", "path", ".", "The", "key", "is", "expected", "to", "be", "in", "PEM", "format", "." ]
7c6dfc908d68ed254a16c126f6770f4d9d9352da
https://github.com/google/acme/blob/7c6dfc908d68ed254a16c126f6770f4d9d9352da/config.go#L106-L123
test
google/acme
config.go
writeKey
func writeKey(path string, k *ecdsa.PrivateKey) error { f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } bytes, err := x509.MarshalECPrivateKey(k) if err != nil { return err } b := &pem.Block{Type: ecPrivateKey, Bytes: bytes} if err := pem.Encode(f, b); err ...
go
func writeKey(path string, k *ecdsa.PrivateKey) error { f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } bytes, err := x509.MarshalECPrivateKey(k) if err != nil { return err } b := &pem.Block{Type: ecPrivateKey, Bytes: bytes} if err := pem.Encode(f, b); err ...
[ "func", "writeKey", "(", "path", "string", ",", "k", "*", "ecdsa", ".", "PrivateKey", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "OpenFile", "(", "path", ",", "os", ".", "O_WRONLY", "|", "os", ".", "O_CREATE", "|", "os", ".", "O_TRUNC", ...
// writeKey writes k to the specified path in PEM format. // If file does not exists, it will be created with 0600 mod.
[ "writeKey", "writes", "k", "to", "the", "specified", "path", "in", "PEM", "format", ".", "If", "file", "does", "not", "exists", "it", "will", "be", "created", "with", "0600", "mod", "." ]
7c6dfc908d68ed254a16c126f6770f4d9d9352da
https://github.com/google/acme/blob/7c6dfc908d68ed254a16c126f6770f4d9d9352da/config.go#L127-L142
test
google/acme
config.go
anyKey
func anyKey(filename string, gen bool) (crypto.Signer, error) { k, err := readKey(filename) if err == nil { return k, nil } if !os.IsNotExist(err) || !gen { return nil, err } ecKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { return nil, err } return ecKey, writeKey(filename, e...
go
func anyKey(filename string, gen bool) (crypto.Signer, error) { k, err := readKey(filename) if err == nil { return k, nil } if !os.IsNotExist(err) || !gen { return nil, err } ecKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { return nil, err } return ecKey, writeKey(filename, e...
[ "func", "anyKey", "(", "filename", "string", ",", "gen", "bool", ")", "(", "crypto", ".", "Signer", ",", "error", ")", "{", "k", ",", "err", ":=", "readKey", "(", "filename", ")", "\n", "if", "err", "==", "nil", "{", "return", "k", ",", "nil", "\...
// anyKey reads the key from file or generates a new one if gen == true. // It returns an error if filename exists but cannot be read. // A newly generated key is also stored to filename.
[ "anyKey", "reads", "the", "key", "from", "file", "or", "generates", "a", "new", "one", "if", "gen", "==", "true", ".", "It", "returns", "an", "error", "if", "filename", "exists", "but", "cannot", "be", "read", ".", "A", "newly", "generated", "key", "is...
7c6dfc908d68ed254a16c126f6770f4d9d9352da
https://github.com/google/acme/blob/7c6dfc908d68ed254a16c126f6770f4d9d9352da/config.go#L147-L160
test
google/acme
config.go
sameDir
func sameDir(existing, filename string) string { return filepath.Join(filepath.Dir(existing), filename) }
go
func sameDir(existing, filename string) string { return filepath.Join(filepath.Dir(existing), filename) }
[ "func", "sameDir", "(", "existing", ",", "filename", "string", ")", "string", "{", "return", "filepath", ".", "Join", "(", "filepath", ".", "Dir", "(", "existing", ")", ",", "filename", ")", "\n", "}" ]
// sameDir returns filename path placing it in the same dir as existing file.
[ "sameDir", "returns", "filename", "path", "placing", "it", "in", "the", "same", "dir", "as", "existing", "file", "." ]
7c6dfc908d68ed254a16c126f6770f4d9d9352da
https://github.com/google/acme/blob/7c6dfc908d68ed254a16c126f6770f4d9d9352da/config.go#L163-L165
test
google/acme
config.go
printAccount
func printAccount(w io.Writer, a *acme.Account, kp string) { tw := tabwriter.NewWriter(w, 0, 8, 0, '\t', 0) fmt.Fprintln(tw, "URI:\t", a.URI) fmt.Fprintln(tw, "Key:\t", kp) fmt.Fprintln(tw, "Contact:\t", strings.Join(a.Contact, ", ")) fmt.Fprintln(tw, "Terms:\t", a.CurrentTerms) agreed := a.AgreedTerms if a.Agre...
go
func printAccount(w io.Writer, a *acme.Account, kp string) { tw := tabwriter.NewWriter(w, 0, 8, 0, '\t', 0) fmt.Fprintln(tw, "URI:\t", a.URI) fmt.Fprintln(tw, "Key:\t", kp) fmt.Fprintln(tw, "Contact:\t", strings.Join(a.Contact, ", ")) fmt.Fprintln(tw, "Terms:\t", a.CurrentTerms) agreed := a.AgreedTerms if a.Agre...
[ "func", "printAccount", "(", "w", "io", ".", "Writer", ",", "a", "*", "acme", ".", "Account", ",", "kp", "string", ")", "{", "tw", ":=", "tabwriter", ".", "NewWriter", "(", "w", ",", "0", ",", "8", ",", "0", ",", "'\\t'", ",", "0", ")", "\n", ...
// printAccount outputs account into into w using tabwriter.
[ "printAccount", "outputs", "account", "into", "into", "w", "using", "tabwriter", "." ]
7c6dfc908d68ed254a16c126f6770f4d9d9352da
https://github.com/google/acme/blob/7c6dfc908d68ed254a16c126f6770f4d9d9352da/config.go#L168-L183
test
google/acme
usage.go
tmpl
func tmpl(w io.Writer, text string, data interface{}) { t := template.New("top") t.Funcs(template.FuncMap{ "trim": strings.TrimSpace, "capitalize": capitalize, }) template.Must(t.Parse(text)) ew := &errWriter{w: w} err := t.Execute(ew, data) if ew.err != nil { // I/O error writing; ignore write on cl...
go
func tmpl(w io.Writer, text string, data interface{}) { t := template.New("top") t.Funcs(template.FuncMap{ "trim": strings.TrimSpace, "capitalize": capitalize, }) template.Must(t.Parse(text)) ew := &errWriter{w: w} err := t.Execute(ew, data) if ew.err != nil { // I/O error writing; ignore write on cl...
[ "func", "tmpl", "(", "w", "io", ".", "Writer", ",", "text", "string", ",", "data", "interface", "{", "}", ")", "{", "t", ":=", "template", ".", "New", "(", "\"top\"", ")", "\n", "t", ".", "Funcs", "(", "template", ".", "FuncMap", "{", "\"trim\"", ...
// tmpl executes the given template text on data, writing the result to w.
[ "tmpl", "executes", "the", "given", "template", "text", "on", "data", "writing", "the", "result", "to", "w", "." ]
7c6dfc908d68ed254a16c126f6770f4d9d9352da
https://github.com/google/acme/blob/7c6dfc908d68ed254a16c126f6770f4d9d9352da/usage.go#L85-L104
test
google/acme
usage.go
printUsage
func printUsage(w io.Writer) { bw := bufio.NewWriter(w) tmpl(bw, usageTemplate, commands) bw.Flush() }
go
func printUsage(w io.Writer) { bw := bufio.NewWriter(w) tmpl(bw, usageTemplate, commands) bw.Flush() }
[ "func", "printUsage", "(", "w", "io", ".", "Writer", ")", "{", "bw", ":=", "bufio", ".", "NewWriter", "(", "w", ")", "\n", "tmpl", "(", "bw", ",", "usageTemplate", ",", "commands", ")", "\n", "bw", ".", "Flush", "(", ")", "\n", "}" ]
// printUsage prints usageTemplate to w.
[ "printUsage", "prints", "usageTemplate", "to", "w", "." ]
7c6dfc908d68ed254a16c126f6770f4d9d9352da
https://github.com/google/acme/blob/7c6dfc908d68ed254a16c126f6770f4d9d9352da/usage.go#L121-L125
test
tomasen/realip
realip.go
FromRequest
func FromRequest(r *http.Request) string { // Fetch header value xRealIP := r.Header.Get("X-Real-Ip") xForwardedFor := r.Header.Get("X-Forwarded-For") // If both empty, return IP from remote address if xRealIP == "" && xForwardedFor == "" { var remoteIP string // If there are colon in remote address, remove ...
go
func FromRequest(r *http.Request) string { // Fetch header value xRealIP := r.Header.Get("X-Real-Ip") xForwardedFor := r.Header.Get("X-Forwarded-For") // If both empty, return IP from remote address if xRealIP == "" && xForwardedFor == "" { var remoteIP string // If there are colon in remote address, remove ...
[ "func", "FromRequest", "(", "r", "*", "http", ".", "Request", ")", "string", "{", "xRealIP", ":=", "r", ".", "Header", ".", "Get", "(", "\"X-Real-Ip\"", ")", "\n", "xForwardedFor", ":=", "r", ".", "Header", ".", "Get", "(", "\"X-Forwarded-For\"", ")", ...
// FromRequest return client's real public IP address from http request headers.
[ "FromRequest", "return", "client", "s", "real", "public", "IP", "address", "from", "http", "request", "headers", "." ]
f0c99a92ddcedd3964a269d23c8e89d9a9229be6
https://github.com/tomasen/realip/blob/f0c99a92ddcedd3964a269d23c8e89d9a9229be6/realip.go#L53-L84
test
chromedp/cdproto
domstorage/domstorage.go
Do
func (p *ClearParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandClear, p, nil) }
go
func (p *ClearParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandClear, p, nil) }
[ "func", "(", "p", "*", "ClearParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandClear", ",", "p", ",", "nil", ")", "\n", "}" ]
// Do executes DOMStorage.clear against the provided context.
[ "Do", "executes", "DOMStorage", ".", "clear", "against", "the", "provided", "context", "." ]
d40c70bcdf242660a32f2eadf323662dd75378b5
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/domstorage/domstorage.go#L35-L37
test
chromedp/cdproto
domstorage/domstorage.go
Do
func (p *DisableParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandDisable, nil, nil) }
go
func (p *DisableParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandDisable, nil, nil) }
[ "func", "(", "p", "*", "DisableParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandDisable", ",", "nil", ",", "nil", ")", "\n", "}" ]
// Do executes DOMStorage.disable against the provided context.
[ "Do", "executes", "DOMStorage", ".", "disable", "against", "the", "provided", "context", "." ]
d40c70bcdf242660a32f2eadf323662dd75378b5
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/domstorage/domstorage.go#L52-L54
test
chromedp/cdproto
domstorage/domstorage.go
Do
func (p *RemoveDOMStorageItemParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandRemoveDOMStorageItem, p, nil) }
go
func (p *RemoveDOMStorageItemParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandRemoveDOMStorageItem, p, nil) }
[ "func", "(", "p", "*", "RemoveDOMStorageItemParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandRemoveDOMStorageItem", ",", "p", ",", "nil", ")", "\n", ...
// Do executes DOMStorage.removeDOMStorageItem against the provided context.
[ "Do", "executes", "DOMStorage", ".", "removeDOMStorageItem", "against", "the", "provided", "context", "." ]
d40c70bcdf242660a32f2eadf323662dd75378b5
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/domstorage/domstorage.go#L131-L133
test
chromedp/cdproto
domstorage/domstorage.go
Do
func (p *SetDOMStorageItemParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandSetDOMStorageItem, p, nil) }
go
func (p *SetDOMStorageItemParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandSetDOMStorageItem, p, nil) }
[ "func", "(", "p", "*", "SetDOMStorageItemParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetDOMStorageItem", ",", "p", ",", "nil", ")", "\n", "}" ]
// Do executes DOMStorage.setDOMStorageItem against the provided context.
[ "Do", "executes", "DOMStorage", ".", "setDOMStorageItem", "against", "the", "provided", "context", "." ]
d40c70bcdf242660a32f2eadf323662dd75378b5
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/domstorage/domstorage.go#L159-L161
test
chromedp/cdproto
serviceworker/serviceworker.go
Do
func (p *DeliverPushMessageParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandDeliverPushMessage, p, nil) }
go
func (p *DeliverPushMessageParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandDeliverPushMessage, p, nil) }
[ "func", "(", "p", "*", "DeliverPushMessageParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandDeliverPushMessage", ",", "p", ",", "nil", ")", "\n", "}"...
// Do executes ServiceWorker.deliverPushMessage against the provided context.
[ "Do", "executes", "ServiceWorker", ".", "deliverPushMessage", "against", "the", "provided", "context", "." ]
d40c70bcdf242660a32f2eadf323662dd75378b5
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/serviceworker.go#L39-L41
test
chromedp/cdproto
serviceworker/serviceworker.go
Do
func (p *DispatchSyncEventParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandDispatchSyncEvent, p, nil) }
go
func (p *DispatchSyncEventParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandDispatchSyncEvent, p, nil) }
[ "func", "(", "p", "*", "DispatchSyncEventParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandDispatchSyncEvent", ",", "p", ",", "nil", ")", "\n", "}" ]
// Do executes ServiceWorker.dispatchSyncEvent against the provided context.
[ "Do", "executes", "ServiceWorker", ".", "dispatchSyncEvent", "against", "the", "provided", "context", "." ]
d40c70bcdf242660a32f2eadf323662dd75378b5
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/serviceworker.go#L85-L87
test
chromedp/cdproto
serviceworker/serviceworker.go
Do
func (p *InspectWorkerParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandInspectWorker, p, nil) }
go
func (p *InspectWorkerParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandInspectWorker, p, nil) }
[ "func", "(", "p", "*", "InspectWorkerParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandInspectWorker", ",", "p", ",", "nil", ")", "\n", "}" ]
// Do executes ServiceWorker.inspectWorker against the provided context.
[ "Do", "executes", "ServiceWorker", ".", "inspectWorker", "against", "the", "provided", "context", "." ]
d40c70bcdf242660a32f2eadf323662dd75378b5
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/serviceworker.go#L122-L124
test
chromedp/cdproto
serviceworker/serviceworker.go
Do
func (p *SetForceUpdateOnPageLoadParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandSetForceUpdateOnPageLoad, p, nil) }
go
func (p *SetForceUpdateOnPageLoadParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandSetForceUpdateOnPageLoad, p, nil) }
[ "func", "(", "p", "*", "SetForceUpdateOnPageLoadParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetForceUpdateOnPageLoad", ",", "p", ",", "nil", ")", ...
// Do executes ServiceWorker.setForceUpdateOnPageLoad against the provided context.
[ "Do", "executes", "ServiceWorker", ".", "setForceUpdateOnPageLoad", "against", "the", "provided", "context", "." ]
d40c70bcdf242660a32f2eadf323662dd75378b5
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/serviceworker.go#L144-L146
test
chromedp/cdproto
serviceworker/serviceworker.go
Do
func (p *SkipWaitingParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandSkipWaiting, p, nil) }
go
func (p *SkipWaitingParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandSkipWaiting, p, nil) }
[ "func", "(", "p", "*", "SkipWaitingParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSkipWaiting", ",", "p", ",", "nil", ")", "\n", "}" ]
// Do executes ServiceWorker.skipWaiting against the provided context.
[ "Do", "executes", "ServiceWorker", ".", "skipWaiting", "against", "the", "provided", "context", "." ]
d40c70bcdf242660a32f2eadf323662dd75378b5
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/serviceworker.go#L166-L168
test
chromedp/cdproto
serviceworker/serviceworker.go
Do
func (p *StartWorkerParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandStartWorker, p, nil) }
go
func (p *StartWorkerParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandStartWorker, p, nil) }
[ "func", "(", "p", "*", "StartWorkerParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandStartWorker", ",", "p", ",", "nil", ")", "\n", "}" ]
// Do executes ServiceWorker.startWorker against the provided context.
[ "Do", "executes", "ServiceWorker", ".", "startWorker", "against", "the", "provided", "context", "." ]
d40c70bcdf242660a32f2eadf323662dd75378b5
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/serviceworker.go#L188-L190
test