id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
147,700 | 4ydx/gltext | fontconfig.go | Load | func (fc *FontConfig) Load(rootPath string) (err error) {
file := fmt.Sprintf("%s/%s.config", rootPath, fc.Name)
data, err := ioutil.ReadFile(file)
if err != nil {
return
}
err = json.Unmarshal(data, fc)
if err != nil {
return err
}
fmt.Printf("%+v\n", time.Now())
fc.Image, err = LoadFontImage(rootPath, fc... | go | func (fc *FontConfig) Load(rootPath string) (err error) {
file := fmt.Sprintf("%s/%s.config", rootPath, fc.Name)
data, err := ioutil.ReadFile(file)
if err != nil {
return
}
err = json.Unmarshal(data, fc)
if err != nil {
return err
}
fmt.Printf("%+v\n", time.Now())
fc.Image, err = LoadFontImage(rootPath, fc... | [
"func",
"(",
"fc",
"*",
"FontConfig",
")",
"Load",
"(",
"rootPath",
"string",
")",
"(",
"err",
"error",
")",
"{",
"file",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"rootPath",
",",
"fc",
".",
"Name",
")",
"\n",
"data",
",",
"err",
":=",
... | // Load reads font configuration data from the given JSON encoded stream. | [
"Load",
"reads",
"font",
"configuration",
"data",
"from",
"the",
"given",
"JSON",
"encoded",
"stream",
"."
] | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/fontconfig.go#L41-L59 |
147,701 | 4ydx/gltext | fontconfig.go | Save | func (fc *FontConfig) Save(rootPath, name string) error {
fc.Name = name
if _, err := os.Stat(rootPath); err != nil {
if os.IsNotExist(err) {
os.MkdirAll(rootPath, os.ModeDir|os.ModePerm)
} else {
return err
}
}
data, err := json.Marshal(fc)
if err != nil {
return err
}
file := fmt.Sprintf("%s/%s.... | go | func (fc *FontConfig) Save(rootPath, name string) error {
fc.Name = name
if _, err := os.Stat(rootPath); err != nil {
if os.IsNotExist(err) {
os.MkdirAll(rootPath, os.ModeDir|os.ModePerm)
} else {
return err
}
}
data, err := json.Marshal(fc)
if err != nil {
return err
}
file := fmt.Sprintf("%s/%s.... | [
"func",
"(",
"fc",
"*",
"FontConfig",
")",
"Save",
"(",
"rootPath",
",",
"name",
"string",
")",
"error",
"{",
"fc",
".",
"Name",
"=",
"name",
"\n\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"rootPath",
")",
";",
"err",
"!=",
"nil",
... | // Save writes font configuration data to the given stream as JSON data. | [
"Save",
"writes",
"font",
"configuration",
"data",
"to",
"the",
"given",
"stream",
"as",
"JSON",
"data",
"."
] | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/fontconfig.go#L62-L90 |
147,702 | 4ydx/gltext | charset.go | Scale | func (c Charset) Scale(factor int) {
if factor <= 1 {
// A factor of zero results in zero-sized glyphs and
// is therefore not valid. A factor of 1 does not change
// the glyphs, so we can ignore it.
return
}
// Multiply each glyph field by the given factor
// to scale them up to the new size.
for i := ra... | go | func (c Charset) Scale(factor int) {
if factor <= 1 {
// A factor of zero results in zero-sized glyphs and
// is therefore not valid. A factor of 1 does not change
// the glyphs, so we can ignore it.
return
}
// Multiply each glyph field by the given factor
// to scale them up to the new size.
for i := ra... | [
"func",
"(",
"c",
"Charset",
")",
"Scale",
"(",
"factor",
"int",
")",
"{",
"if",
"factor",
"<=",
"1",
"{",
"// A factor of zero results in zero-sized glyphs and",
"// is therefore not valid. A factor of 1 does not change",
"// the glyphs, so we can ignore it.",
"return",
"\n"... | // Scale scales all glyphs by the given factor and repositions them
// appropriately. A scale of 1 retains the original size. A scale of 2
// doubles the size of each glyph, etc.
//
// This is useful when the accompanying sprite sheet is scaled by the
// same factor. In this case, we want the glyph data to match up wit... | [
"Scale",
"scales",
"all",
"glyphs",
"by",
"the",
"given",
"factor",
"and",
"repositions",
"them",
"appropriately",
".",
"A",
"scale",
"of",
"1",
"retains",
"the",
"original",
"size",
".",
"A",
"scale",
"of",
"2",
"doubles",
"the",
"size",
"of",
"each",
"... | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/charset.go#L73-L90 |
147,703 | logicmonitor/k8s-collectorset-controller | pkg/distributor/distributor.go | MarshalJSON | func (t *Type) MarshalJSON() ([]byte, error) {
var aux string
switch *t {
case RoundRobin:
aux = roundRobinName
}
b, err := json.Marshal(aux)
if err != nil {
return nil, err
}
return b, nil
} | go | func (t *Type) MarshalJSON() ([]byte, error) {
var aux string
switch *t {
case RoundRobin:
aux = roundRobinName
}
b, err := json.Marshal(aux)
if err != nil {
return nil, err
}
return b, nil
} | [
"func",
"(",
"t",
"*",
"Type",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"aux",
"string",
"\n\n",
"switch",
"*",
"t",
"{",
"case",
"RoundRobin",
":",
"aux",
"=",
"roundRobinName",
"\n",
"}",
"\n\n",
"b",
... | // MarshalJSON implements json.Marshaler | [
"MarshalJSON",
"implements",
"json",
".",
"Marshaler"
] | efaec105bacc60399c4e0d332b1adc93f1282262 | https://github.com/logicmonitor/k8s-collectorset-controller/blob/efaec105bacc60399c4e0d332b1adc93f1282262/pkg/distributor/distributor.go#L27-L41 |
147,704 | 4ydx/gltext | v4.5/text.go | NewText | func NewText(f *Font, scaleMin, scaleMax float32) (t *Text) {
t = &Text{}
t.Font = f
// text hover values
// "resting state" of a text object is the min scale
t.ScaleMin, t.ScaleMax = scaleMin, scaleMax
t.SetScale(1)
glfloat_size := int32(4)
// stride of the buffered data
xy_count := int32(2)
stride := xy_c... | go | func NewText(f *Font, scaleMin, scaleMax float32) (t *Text) {
t = &Text{}
t.Font = f
// text hover values
// "resting state" of a text object is the min scale
t.ScaleMin, t.ScaleMax = scaleMin, scaleMax
t.SetScale(1)
glfloat_size := int32(4)
// stride of the buffered data
xy_count := int32(2)
stride := xy_c... | [
"func",
"NewText",
"(",
"f",
"*",
"Font",
",",
"scaleMin",
",",
"scaleMax",
"float32",
")",
"(",
"t",
"*",
"Text",
")",
"{",
"t",
"=",
"&",
"Text",
"{",
"}",
"\n",
"t",
".",
"Font",
"=",
"f",
"\n\n",
"// text hover values",
"// \"resting state\" of a t... | // NewText creates a new text object with scaling boundaries
// the rest state of the text when not being interacted with
// is scaleMin. most likely one wants to use 1.0. | [
"NewText",
"creates",
"a",
"new",
"text",
"object",
"with",
"scaling",
"boundaries",
"the",
"rest",
"state",
"of",
"the",
"text",
"when",
"not",
"being",
"interacted",
"with",
"is",
"scaleMin",
".",
"most",
"likely",
"one",
"wants",
"to",
"use",
"1",
".",
... | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/v4.5/text.go#L84-L142 |
147,705 | 4ydx/gltext | v4.5/text.go | Release | func (t *Text) Release() {
gl.DeleteBuffers(1, &t.vbo)
gl.DeleteBuffers(1, &t.ebo)
gl.DeleteVertexArrays(1, &t.vao)
} | go | func (t *Text) Release() {
gl.DeleteBuffers(1, &t.vbo)
gl.DeleteBuffers(1, &t.ebo)
gl.DeleteVertexArrays(1, &t.vao)
} | [
"func",
"(",
"t",
"*",
"Text",
")",
"Release",
"(",
")",
"{",
"gl",
".",
"DeleteBuffers",
"(",
"1",
",",
"&",
"t",
".",
"vbo",
")",
"\n",
"gl",
".",
"DeleteBuffers",
"(",
"1",
",",
"&",
"t",
".",
"ebo",
")",
"\n",
"gl",
".",
"DeleteVertexArrays... | // Release releases text resources. | [
"Release",
"releases",
"text",
"resources",
"."
] | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/v4.5/text.go#L145-L149 |
147,706 | 4ydx/gltext | v4.5/text.go | SetScale | func (t *Text) SetScale(s float32) bool {
if s > t.ScaleMax || s < t.ScaleMin {
return false
}
t.Scale = s
t.scaleMatrix = mgl32.Scale3D(s, s, s)
return true
} | go | func (t *Text) SetScale(s float32) bool {
if s > t.ScaleMax || s < t.ScaleMin {
return false
}
t.Scale = s
t.scaleMatrix = mgl32.Scale3D(s, s, s)
return true
} | [
"func",
"(",
"t",
"*",
"Text",
")",
"SetScale",
"(",
"s",
"float32",
")",
"bool",
"{",
"if",
"s",
">",
"t",
".",
"ScaleMax",
"||",
"s",
"<",
"t",
".",
"ScaleMin",
"{",
"return",
"false",
"\n",
"}",
"\n",
"t",
".",
"Scale",
"=",
"s",
"\n",
"t"... | // SetScale returns true when a change occured | [
"SetScale",
"returns",
"true",
"when",
"a",
"change",
"occured"
] | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/v4.5/text.go#L152-L159 |
147,707 | 4ydx/gltext | v4.5/text.go | AddScale | func (t *Text) AddScale(s float32) bool {
if s < 0 && t.Scale <= t.ScaleMin {
return false
}
if s > 0 && t.Scale >= t.ScaleMax {
return false
}
t.Scale += s
t.scaleMatrix = mgl32.Scale3D(t.Scale, t.Scale, t.Scale)
return true
} | go | func (t *Text) AddScale(s float32) bool {
if s < 0 && t.Scale <= t.ScaleMin {
return false
}
if s > 0 && t.Scale >= t.ScaleMax {
return false
}
t.Scale += s
t.scaleMatrix = mgl32.Scale3D(t.Scale, t.Scale, t.Scale)
return true
} | [
"func",
"(",
"t",
"*",
"Text",
")",
"AddScale",
"(",
"s",
"float32",
")",
"bool",
"{",
"if",
"s",
"<",
"0",
"&&",
"t",
".",
"Scale",
"<=",
"t",
".",
"ScaleMin",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"s",
">",
"0",
"&&",
"t",
".",
"... | // AddScale returns true when a change occured | [
"AddScale",
"returns",
"true",
"when",
"a",
"change",
"occured"
] | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/v4.5/text.go#L162-L172 |
147,708 | 4ydx/gltext | v4.5/text.go | SetString | func (t *Text) SetString(fs string, argv ...interface{}) {
indices := []rune(fmt.Sprintf(fs, argv...))
if t.MaxRuneCount > 0 && len(indices) > t.MaxRuneCount+1 {
indices = indices[0:t.MaxRuneCount]
}
t.String = string(indices)
// ebo, vbo data
glfloat_size := int32(4)
t.vboIndexCount = len(indices) * 4 * 2 *... | go | func (t *Text) SetString(fs string, argv ...interface{}) {
indices := []rune(fmt.Sprintf(fs, argv...))
if t.MaxRuneCount > 0 && len(indices) > t.MaxRuneCount+1 {
indices = indices[0:t.MaxRuneCount]
}
t.String = string(indices)
// ebo, vbo data
glfloat_size := int32(4)
t.vboIndexCount = len(indices) * 4 * 2 *... | [
"func",
"(",
"t",
"*",
"Text",
")",
"SetString",
"(",
"fs",
"string",
",",
"argv",
"...",
"interface",
"{",
"}",
")",
"{",
"indices",
":=",
"[",
"]",
"rune",
"(",
"fmt",
".",
"Sprintf",
"(",
"fs",
",",
"argv",
"...",
")",
")",
"\n",
"if",
"t",
... | // SetString performs creates new vbo and ebo objects as well as to perform all
// binding required for displaying text to screen | [
"SetString",
"performs",
"creates",
"new",
"vbo",
"and",
"ebo",
"objects",
"as",
"well",
"as",
"to",
"perform",
"all",
"binding",
"required",
"for",
"displaying",
"text",
"to",
"screen"
] | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/v4.5/text.go#L180-L228 |
147,709 | 4ydx/gltext | v4.5/text.go | SetPosition | func (t *Text) SetPosition(v mgl32.Vec2) {
// transform to orthographic coordinates ranged -1 to 1 for the shader
t.finalPosition[0] = v.X() / (t.Font.WindowWidth / 2)
t.finalPosition[1] = v.Y() / (t.Font.WindowHeight / 2)
if gltext.IsDebug {
t.BoundingBox.finalPosition[0] = v.X() / (t.Font.WindowWidth / 2)
t.B... | go | func (t *Text) SetPosition(v mgl32.Vec2) {
// transform to orthographic coordinates ranged -1 to 1 for the shader
t.finalPosition[0] = v.X() / (t.Font.WindowWidth / 2)
t.finalPosition[1] = v.Y() / (t.Font.WindowHeight / 2)
if gltext.IsDebug {
t.BoundingBox.finalPosition[0] = v.X() / (t.Font.WindowWidth / 2)
t.B... | [
"func",
"(",
"t",
"*",
"Text",
")",
"SetPosition",
"(",
"v",
"mgl32",
".",
"Vec2",
")",
"{",
"// transform to orthographic coordinates ranged -1 to 1 for the shader",
"t",
".",
"finalPosition",
"[",
"0",
"]",
"=",
"v",
".",
"X",
"(",
")",
"/",
"(",
"t",
".... | // SetPosition prepares variables passed to the shader as well as values
// used for bounding box calculations when clicking or hovering above text | [
"SetPosition",
"prepares",
"variables",
"passed",
"to",
"the",
"shader",
"as",
"well",
"as",
"values",
"used",
"for",
"bounding",
"box",
"calculations",
"when",
"clicking",
"or",
"hovering",
"above",
"text"
] | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/v4.5/text.go#L244-L253 |
147,710 | 4ydx/gltext | v4.5/text.go | centerTheData | func (t *Text) centerTheData(lowerLeft gltext.Point) (err error) {
length := len(t.vboData)
for index := 0; index < length; {
// index (0,0)
t.vboData[index] += lowerLeft.X
index++
t.vboData[index] += lowerLeft.Y
index += 3 // skip texture data
// index (1,0)
t.vboData[index] += lowerLeft.X
index++
... | go | func (t *Text) centerTheData(lowerLeft gltext.Point) (err error) {
length := len(t.vboData)
for index := 0; index < length; {
// index (0,0)
t.vboData[index] += lowerLeft.X
index++
t.vboData[index] += lowerLeft.Y
index += 3 // skip texture data
// index (1,0)
t.vboData[index] += lowerLeft.X
index++
... | [
"func",
"(",
"t",
"*",
"Text",
")",
"centerTheData",
"(",
"lowerLeft",
"gltext",
".",
"Point",
")",
"(",
"err",
"error",
")",
"{",
"length",
":=",
"len",
"(",
"t",
".",
"vboData",
")",
"\n",
"for",
"index",
":=",
"0",
";",
"index",
"<",
"length",
... | // centerTheData prepares the value "centered_position" found in the font shader
// as named, the function centers the text around the orthographic center of the screen
// expected to only be called within SetString | [
"centerTheData",
"prepares",
"the",
"value",
"centered_position",
"found",
"in",
"the",
"font",
"shader",
"as",
"named",
"the",
"function",
"centers",
"the",
"text",
"around",
"the",
"orthographic",
"center",
"of",
"the",
"screen",
"expected",
"to",
"only",
"be"... | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/v4.5/text.go#L325-L364 |
147,711 | 4ydx/gltext | v4.5/text.go | PrintCharSpacing | func (t *Text) PrintCharSpacing() {
fmt.Printf("\n%s:\n", t.String)
at := t.X1.X
for i, cs := range t.CharSpacing {
at = cs + at
fmt.Printf("'%c': %.2f ", t.String[i], at)
}
} | go | func (t *Text) PrintCharSpacing() {
fmt.Printf("\n%s:\n", t.String)
at := t.X1.X
for i, cs := range t.CharSpacing {
at = cs + at
fmt.Printf("'%c': %.2f ", t.String[i], at)
}
} | [
"func",
"(",
"t",
"*",
"Text",
")",
"PrintCharSpacing",
"(",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\\n",
"\"",
",",
"t",
".",
"String",
")",
"\n",
"at",
":=",
"t",
".",
"X1",
".",
"X",
"\n",
"for",
"i",
",",
"cs",
":=",
"range",
... | // PrintCharSpacing is used for debugging | [
"PrintCharSpacing",
"is",
"used",
"for",
"debugging"
] | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/v4.5/text.go#L375-L382 |
147,712 | 4ydx/gltext | v4.5/text.go | ClickedCharacter | func (t *Text) ClickedCharacter(xPos, offset float64) (index int, side CharacterSide) {
// transform from screen coordinates to... window coordinates?
xPos = xPos - float64(t.Font.WindowWidth/2) - offset
// could do a binary search...
at := float64(t.X1.X)
for i, cs := range t.CharSpacing {
at = float64(cs) + a... | go | func (t *Text) ClickedCharacter(xPos, offset float64) (index int, side CharacterSide) {
// transform from screen coordinates to... window coordinates?
xPos = xPos - float64(t.Font.WindowWidth/2) - offset
// could do a binary search...
at := float64(t.X1.X)
for i, cs := range t.CharSpacing {
at = float64(cs) + a... | [
"func",
"(",
"t",
"*",
"Text",
")",
"ClickedCharacter",
"(",
"xPos",
",",
"offset",
"float64",
")",
"(",
"index",
"int",
",",
"side",
"CharacterSide",
")",
"{",
"// transform from screen coordinates to... window coordinates?",
"xPos",
"=",
"xPos",
"-",
"float64",
... | // ClickedCharacter should only be called after a bounding box hit is confirmed because
// it does not check y-axis values at all. Returns the index and side of the char clicked. | [
"ClickedCharacter",
"should",
"only",
"be",
"called",
"after",
"a",
"bounding",
"box",
"hit",
"is",
"confirmed",
"because",
"it",
"does",
"not",
"check",
"y",
"-",
"axis",
"values",
"at",
"all",
".",
"Returns",
"the",
"index",
"and",
"side",
"of",
"the",
... | 84bc6aa204bffadd70a6fa2f0f267e6c4d82835e | https://github.com/4ydx/gltext/blob/84bc6aa204bffadd70a6fa2f0f267e6c4d82835e/v4.5/text.go#L386-L409 |
147,713 | mohae/joefriday | sysinfo/uptime/json/uptime_unix.go | Get | func Get() (p []byte, err error) {
var u up.Uptime
err = u.Get()
if err != nil {
return nil, err
}
return json.Marshal(&u)
} | go | func Get() (p []byte, err error) {
var u up.Uptime
err = u.Get()
if err != nil {
return nil, err
}
return json.Marshal(&u)
} | [
"func",
"Get",
"(",
")",
"(",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"u",
"up",
".",
"Uptime",
"\n",
"err",
"=",
"u",
".",
"Get",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
... | // Get returns the current uptime as JSON serialized bytes. | [
"Get",
"returns",
"the",
"current",
"uptime",
"as",
"JSON",
"serialized",
"bytes",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/sysinfo/uptime/json/uptime_unix.go#L31-L38 |
147,714 | mohae/joefriday | cpu/cpufreq/json/cpufreq_unix.go | NewProfiler | func NewProfiler() (prof *Profiler, err error) {
p, err := freq.NewProfiler()
if err != nil {
return nil, err
}
return &Profiler{Profiler: p}, nil
} | go | func NewProfiler() (prof *Profiler, err error) {
p, err := freq.NewProfiler()
if err != nil {
return nil, err
}
return &Profiler{Profiler: p}, nil
} | [
"func",
"NewProfiler",
"(",
")",
"(",
"prof",
"*",
"Profiler",
",",
"err",
"error",
")",
"{",
"p",
",",
"err",
":=",
"freq",
".",
"NewProfiler",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return"... | // Initializes and returns a cpufreq profiler. | [
"Initializes",
"and",
"returns",
"a",
"cpufreq",
"profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpufreq/json/cpufreq_unix.go#L39-L45 |
147,715 | mohae/joefriday | cpu/cpufreq/json/cpufreq_unix.go | Serialize | func (prof *Profiler) Serialize(f *freq.Frequency) ([]byte, error) {
return json.Marshal(f)
} | go | func (prof *Profiler) Serialize(f *freq.Frequency) ([]byte, error) {
return json.Marshal(f)
} | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Serialize",
"(",
"f",
"*",
"freq",
".",
"Frequency",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"f",
")",
"\n",
"}"
] | // Serialize Frequency as JSON. | [
"Serialize",
"Frequency",
"as",
"JSON",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpufreq/json/cpufreq_unix.go#L74-L76 |
147,716 | mohae/joefriday | cpu/cpufreq/json/cpufreq_unix.go | Deserialize | func Deserialize(p []byte) (*freq.Frequency, error) {
f := &freq.Frequency{}
err := json.Unmarshal(p, f)
if err != nil {
return nil, err
}
return f, nil
} | go | func Deserialize(p []byte) (*freq.Frequency, error) {
f := &freq.Frequency{}
err := json.Unmarshal(p, f)
if err != nil {
return nil, err
}
return f, nil
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"*",
"freq",
".",
"Frequency",
",",
"error",
")",
"{",
"f",
":=",
"&",
"freq",
".",
"Frequency",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"p",
",",
"f",
")",
"\n",
... | // Deserialize takes some JSON serialized bytes and unmarshals them as
// cpufreq.Frequency. | [
"Deserialize",
"takes",
"some",
"JSON",
"serialized",
"bytes",
"and",
"unmarshals",
"them",
"as",
"cpufreq",
".",
"Frequency",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/cpu/cpufreq/json/cpufreq_unix.go#L103-L110 |
147,717 | mohae/joefriday | sysinfo/loadavg/flat/loadavg_unix.go | Get | func Get() (p []byte, err error) {
var l load.LoadAvg
err = l.Get()
if err != nil {
return nil, err
}
return Serialize(&l), nil
} | go | func Get() (p []byte, err error) {
var l load.LoadAvg
err = l.Get()
if err != nil {
return nil, err
}
return Serialize(&l), nil
} | [
"func",
"Get",
"(",
")",
"(",
"p",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"l",
"load",
".",
"LoadAvg",
"\n",
"err",
"=",
"l",
".",
"Get",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}"... | // Get returns the current LoadAvg as Flatbuffer serialized bytes. | [
"Get",
"returns",
"the",
"current",
"LoadAvg",
"as",
"Flatbuffer",
"serialized",
"bytes",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/sysinfo/loadavg/flat/loadavg_unix.go#L37-L44 |
147,718 | mohae/joefriday | sysinfo/loadavg/flat/loadavg_unix.go | Serialize | func Serialize(l *load.LoadAvg) []byte {
mu.Lock()
defer mu.Unlock()
// ensure the Builder is in a usable state.
builder.Reset()
structs.LoadAvgStart(builder)
structs.LoadAvgAddTimestamp(builder, l.Timestamp)
structs.LoadAvgAddOne(builder, l.One)
structs.LoadAvgAddFive(builder, l.Five)
structs.LoadAvgAddFiftee... | go | func Serialize(l *load.LoadAvg) []byte {
mu.Lock()
defer mu.Unlock()
// ensure the Builder is in a usable state.
builder.Reset()
structs.LoadAvgStart(builder)
structs.LoadAvgAddTimestamp(builder, l.Timestamp)
structs.LoadAvgAddOne(builder, l.One)
structs.LoadAvgAddFive(builder, l.Five)
structs.LoadAvgAddFiftee... | [
"func",
"Serialize",
"(",
"l",
"*",
"load",
".",
"LoadAvg",
")",
"[",
"]",
"byte",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"// ensure the Builder is in a usable state.",
"builder",
".",
"Reset",
"(",
")",
"... | // Serialize loadAvg.LoadAvg using Flatbuffers. | [
"Serialize",
"loadAvg",
".",
"LoadAvg",
"using",
"Flatbuffers",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/sysinfo/loadavg/flat/loadavg_unix.go#L47-L63 |
147,719 | mohae/joefriday | sysinfo/loadavg/flat/loadavg_unix.go | Deserialize | func Deserialize(p []byte) *load.LoadAvg {
lF := structs.GetRootAsLoadAvg(p, 0)
l := &load.LoadAvg{}
l.Timestamp = lF.Timestamp()
l.One = lF.One()
l.Five = lF.Five()
l.Fifteen = lF.Fifteen()
return l
} | go | func Deserialize(p []byte) *load.LoadAvg {
lF := structs.GetRootAsLoadAvg(p, 0)
l := &load.LoadAvg{}
l.Timestamp = lF.Timestamp()
l.One = lF.One()
l.Five = lF.Five()
l.Fifteen = lF.Fifteen()
return l
} | [
"func",
"Deserialize",
"(",
"p",
"[",
"]",
"byte",
")",
"*",
"load",
".",
"LoadAvg",
"{",
"lF",
":=",
"structs",
".",
"GetRootAsLoadAvg",
"(",
"p",
",",
"0",
")",
"\n",
"l",
":=",
"&",
"load",
".",
"LoadAvg",
"{",
"}",
"\n",
"l",
".",
"Timestamp"... | // Deserialize takes some Flatbuffer serialized bytes and deserialize's them
// as loadavg.LoadAvg. | [
"Deserialize",
"takes",
"some",
"Flatbuffer",
"serialized",
"bytes",
"and",
"deserialize",
"s",
"them",
"as",
"loadavg",
".",
"LoadAvg",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/sysinfo/loadavg/flat/loadavg_unix.go#L67-L75 |
147,720 | mohae/joefriday | processors/processors_unix.go | Get | func (prof *Profiler) Get() (procs *Processors, err error) {
procs = New()
err = prof.getCPUInfo(procs)
if err != nil {
return nil, err
}
// process the system cpu info
err = prof.getSysFSCPU(procs)
if err != nil {
return nil, err
}
procs.CPUs = procs.Sockets * int32(procs.CoresPerSocket) * int32(procs.Thr... | go | func (prof *Profiler) Get() (procs *Processors, err error) {
procs = New()
err = prof.getCPUInfo(procs)
if err != nil {
return nil, err
}
// process the system cpu info
err = prof.getSysFSCPU(procs)
if err != nil {
return nil, err
}
procs.CPUs = procs.Sockets * int32(procs.CoresPerSocket) * int32(procs.Thr... | [
"func",
"(",
"prof",
"*",
"Profiler",
")",
"Get",
"(",
")",
"(",
"procs",
"*",
"Processors",
",",
"err",
"error",
")",
"{",
"procs",
"=",
"New",
"(",
")",
"\n",
"err",
"=",
"prof",
".",
"getCPUInfo",
"(",
"procs",
")",
"\n",
"if",
"err",
"!=",
... | // Get returns the processor information. | [
"Get",
"returns",
"the",
"processor",
"information",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/processors/processors_unix.go#L119-L153 |
147,721 | mohae/joefriday | processors/processors_unix.go | Get | func Get() (procs *Processors, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | go | func Get() (procs *Processors, err error) {
stdMu.Lock()
defer stdMu.Unlock()
if std == nil {
std, err = NewProfiler()
if err != nil {
return nil, err
}
}
return std.Get()
} | [
"func",
"Get",
"(",
")",
"(",
"procs",
"*",
"Processors",
",",
"err",
"error",
")",
"{",
"stdMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"stdMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"std",
"==",
"nil",
"{",
"std",
",",
"err",
"=",
"NewProfiler",
... | // Get returns the information about the processors using the package's global
// Profiler. | [
"Get",
"returns",
"the",
"information",
"about",
"the",
"processors",
"using",
"the",
"package",
"s",
"global",
"Profiler",
"."
] | 2d83fc975dd8b328ca863387d13963f8fd12f260 | https://github.com/mohae/joefriday/blob/2d83fc975dd8b328ca863387d13963f8fd12f260/processors/processors_unix.go#L356-L366 |
147,722 | heketi/rest | asynchttp.go | NewAsyncHttpManager | func NewAsyncHttpManager(route string) *AsyncHttpManager {
return &AsyncHttpManager{
route: route,
handlers: make(map[string]*AsyncHttpHandler),
IdGen: utils.GenUUID,
}
} | go | func NewAsyncHttpManager(route string) *AsyncHttpManager {
return &AsyncHttpManager{
route: route,
handlers: make(map[string]*AsyncHttpHandler),
IdGen: utils.GenUUID,
}
} | [
"func",
"NewAsyncHttpManager",
"(",
"route",
"string",
")",
"*",
"AsyncHttpManager",
"{",
"return",
"&",
"AsyncHttpManager",
"{",
"route",
":",
"route",
",",
"handlers",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"AsyncHttpHandler",
")",
",",
"IdGen",... | // Creates a new manager | [
"Creates",
"a",
"new",
"manager"
] | aa6a652074133e6b0836bb095e847021fcb94b6a | https://github.com/heketi/rest/blob/aa6a652074133e6b0836bb095e847021fcb94b6a/asynchttp.go#L49-L55 |
147,723 | heketi/rest | asynchttp.go | Url | func (h *AsyncHttpHandler) Url() string {
h.manager.lock.RLock()
defer h.manager.lock.RUnlock()
return h.manager.route + "/" + h.id
} | go | func (h *AsyncHttpHandler) Url() string {
h.manager.lock.RLock()
defer h.manager.lock.RUnlock()
return h.manager.route + "/" + h.id
} | [
"func",
"(",
"h",
"*",
"AsyncHttpHandler",
")",
"Url",
"(",
")",
"string",
"{",
"h",
".",
"manager",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"h",
".",
"manager",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"h",
".",
"mana... | // Returns the url for the specified asynchronous handler | [
"Returns",
"the",
"url",
"for",
"the",
"specified",
"asynchronous",
"handler"
] | aa6a652074133e6b0836bb095e847021fcb94b6a | https://github.com/heketi/rest/blob/aa6a652074133e6b0836bb095e847021fcb94b6a/asynchttp.go#L232-L237 |
147,724 | heketi/rest | asynchttp.go | CompletedWithError | func (h *AsyncHttpHandler) CompletedWithError(err error) {
h.manager.lock.RLock()
defer h.manager.lock.RUnlock()
godbc.Require(h.completed == false)
h.err = err
h.completed = true
godbc.Ensure(h.completed == true)
} | go | func (h *AsyncHttpHandler) CompletedWithError(err error) {
h.manager.lock.RLock()
defer h.manager.lock.RUnlock()
godbc.Require(h.completed == false)
h.err = err
h.completed = true
godbc.Ensure(h.completed == true)
} | [
"func",
"(",
"h",
"*",
"AsyncHttpHandler",
")",
"CompletedWithError",
"(",
"err",
"error",
")",
"{",
"h",
".",
"manager",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"h",
".",
"manager",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"godbc",... | // Registers that the handler has completed with an error | [
"Registers",
"that",
"the",
"handler",
"has",
"completed",
"with",
"an",
"error"
] | aa6a652074133e6b0836bb095e847021fcb94b6a | https://github.com/heketi/rest/blob/aa6a652074133e6b0836bb095e847021fcb94b6a/asynchttp.go#L240-L251 |
147,725 | heketi/rest | asynchttp.go | CompletedWithLocation | func (h *AsyncHttpHandler) CompletedWithLocation(location string) {
h.manager.lock.RLock()
defer h.manager.lock.RUnlock()
godbc.Require(h.completed == false)
h.location = location
h.completed = true
godbc.Ensure(h.completed == true)
godbc.Ensure(h.location == location)
godbc.Ensure(h.err == nil)
} | go | func (h *AsyncHttpHandler) CompletedWithLocation(location string) {
h.manager.lock.RLock()
defer h.manager.lock.RUnlock()
godbc.Require(h.completed == false)
h.location = location
h.completed = true
godbc.Ensure(h.completed == true)
godbc.Ensure(h.location == location)
godbc.Ensure(h.err == nil)
} | [
"func",
"(",
"h",
"*",
"AsyncHttpHandler",
")",
"CompletedWithLocation",
"(",
"location",
"string",
")",
"{",
"h",
".",
"manager",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"h",
".",
"manager",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
... | // Registers that the handler has completed and has provided a location
// where information can be retreived | [
"Registers",
"that",
"the",
"handler",
"has",
"completed",
"and",
"has",
"provided",
"a",
"location",
"where",
"information",
"can",
"be",
"retreived"
] | aa6a652074133e6b0836bb095e847021fcb94b6a | https://github.com/heketi/rest/blob/aa6a652074133e6b0836bb095e847021fcb94b6a/asynchttp.go#L255-L268 |
147,726 | novln/docker-parser | parser.go | Parse | func Parse(remote string) (*Reference, error) {
n, err := docker.ParseNamed(clean(remote))
if err != nil {
return nil, err
}
n = docker.WithDefaultTag(n)
var t string
switch x := n.(type) {
case docker.Canonical:
t = "@" + x.Digest().String()
case docker.NamedTagged:
t = ":" + x.Tag()
}
return &Ref... | go | func Parse(remote string) (*Reference, error) {
n, err := docker.ParseNamed(clean(remote))
if err != nil {
return nil, err
}
n = docker.WithDefaultTag(n)
var t string
switch x := n.(type) {
case docker.Canonical:
t = "@" + x.Digest().String()
case docker.NamedTagged:
t = ":" + x.Tag()
}
return &Ref... | [
"func",
"Parse",
"(",
"remote",
"string",
")",
"(",
"*",
"Reference",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"docker",
".",
"ParseNamed",
"(",
"clean",
"(",
"remote",
")",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
... | // Parse returns a Reference from analyzing the given remote identifier. | [
"Parse",
"returns",
"a",
"Reference",
"from",
"analyzing",
"the",
"given",
"remote",
"identifier",
"."
] | b3f122c6978e67dabf9b6c237ec908df8296fff2 | https://github.com/novln/docker-parser/blob/b3f122c6978e67dabf9b6c237ec908df8296fff2/parser.go#L78-L97 |
147,727 | novln/docker-parser | docker/reference.go | ParseNamed | func ParseNamed(s string) (Named, error) {
named, err := reference.ParseNamed(s)
if err != nil {
return nil, fmt.Errorf("Error parsing reference: %q is not a valid repository/tag", s)
}
r, err := WithName(named.Name())
if err != nil {
return nil, err
}
if canonical, isCanonical := named.(reference.Canonical)... | go | func ParseNamed(s string) (Named, error) {
named, err := reference.ParseNamed(s)
if err != nil {
return nil, fmt.Errorf("Error parsing reference: %q is not a valid repository/tag", s)
}
r, err := WithName(named.Name())
if err != nil {
return nil, err
}
if canonical, isCanonical := named.(reference.Canonical)... | [
"func",
"ParseNamed",
"(",
"s",
"string",
")",
"(",
"Named",
",",
"error",
")",
"{",
"named",
",",
"err",
":=",
"reference",
".",
"ParseNamed",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"... | // ParseNamed parses s and returns a syntactically valid reference implementing
// the Named interface. The reference must have a name, otherwise an error is
// returned.
// If an error was encountered it is returned, along with a nil Reference. | [
"ParseNamed",
"parses",
"s",
"and",
"returns",
"a",
"syntactically",
"valid",
"reference",
"implementing",
"the",
"Named",
"interface",
".",
"The",
"reference",
"must",
"have",
"a",
"name",
"otherwise",
"an",
"error",
"is",
"returned",
".",
"If",
"an",
"error"... | b3f122c6978e67dabf9b6c237ec908df8296fff2 | https://github.com/novln/docker-parser/blob/b3f122c6978e67dabf9b6c237ec908df8296fff2/docker/reference.go#L54-L70 |
147,728 | novln/docker-parser | docker/reference.go | WithDefaultTag | func WithDefaultTag(ref Named) Named {
if IsNameOnly(ref) {
ref, _ = WithTag(ref, DefaultTag)
}
return ref
} | go | func WithDefaultTag(ref Named) Named {
if IsNameOnly(ref) {
ref, _ = WithTag(ref, DefaultTag)
}
return ref
} | [
"func",
"WithDefaultTag",
"(",
"ref",
"Named",
")",
"Named",
"{",
"if",
"IsNameOnly",
"(",
"ref",
")",
"{",
"ref",
",",
"_",
"=",
"WithTag",
"(",
"ref",
",",
"DefaultTag",
")",
"\n",
"}",
"\n",
"return",
"ref",
"\n",
"}"
] | // WithDefaultTag adds a default tag to a reference if it only has a repo name. | [
"WithDefaultTag",
"adds",
"a",
"default",
"tag",
"to",
"a",
"reference",
"if",
"it",
"only",
"has",
"a",
"repo",
"name",
"."
] | b3f122c6978e67dabf9b6c237ec908df8296fff2 | https://github.com/novln/docker-parser/blob/b3f122c6978e67dabf9b6c237ec908df8296fff2/docker/reference.go#L139-L144 |
147,729 | novln/docker-parser | docker/reference.go | splitHostname | func splitHostname(name string) (hostname, remoteName string) {
i := strings.IndexRune(name, '/')
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") {
hostname, remoteName = DefaultHostname, name
} else {
hostname, remoteName = name[:i], name[i+1:]
}
if hostname == LegacyDefaultHos... | go | func splitHostname(name string) (hostname, remoteName string) {
i := strings.IndexRune(name, '/')
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") {
hostname, remoteName = DefaultHostname, name
} else {
hostname, remoteName = name[:i], name[i+1:]
}
if hostname == LegacyDefaultHos... | [
"func",
"splitHostname",
"(",
"name",
"string",
")",
"(",
"hostname",
",",
"remoteName",
"string",
")",
"{",
"i",
":=",
"strings",
".",
"IndexRune",
"(",
"name",
",",
"'/'",
")",
"\n",
"if",
"i",
"==",
"-",
"1",
"||",
"(",
"!",
"strings",
".",
"Con... | // splitHostname splits a repository name to hostname and remotename string.
// If no valid hostname is found, the default hostname is used. Repository name
// needs to be already validated before. | [
"splitHostname",
"splits",
"a",
"repository",
"name",
"to",
"hostname",
"and",
"remotename",
"string",
".",
"If",
"no",
"valid",
"hostname",
"is",
"found",
"the",
"default",
"hostname",
"is",
"used",
".",
"Repository",
"name",
"needs",
"to",
"be",
"already",
... | b3f122c6978e67dabf9b6c237ec908df8296fff2 | https://github.com/novln/docker-parser/blob/b3f122c6978e67dabf9b6c237ec908df8296fff2/docker/reference.go#L160-L174 |
147,730 | getgauge/common | common.go | GetProjectRoot | func GetProjectRoot() (string, error) {
pwd, err := os.Getwd()
if err != nil {
return "", fmt.Errorf("Failed to find project root directory. %s\n", err.Error())
}
return findManifestInPath(pwd)
} | go | func GetProjectRoot() (string, error) {
pwd, err := os.Getwd()
if err != nil {
return "", fmt.Errorf("Failed to find project root directory. %s\n", err.Error())
}
return findManifestInPath(pwd)
} | [
"func",
"GetProjectRoot",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"pwd",
",",
"err",
":=",
"os",
".",
"Getwd",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
",",... | // GetProjectRoot returns the Gauge project root
// A project root is where a manifest.json files exists
// this routine keeps going upwards searching for manifest.json | [
"GetProjectRoot",
"returns",
"the",
"Gauge",
"project",
"root",
"A",
"project",
"root",
"is",
"where",
"a",
"manifest",
".",
"json",
"files",
"exists",
"this",
"routine",
"keeps",
"going",
"upwards",
"searching",
"for",
"manifest",
".",
"json"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L81-L87 |
147,731 | getgauge/common | common.go | GetDirInProject | func GetDirInProject(dirName string, specPath string) (string, error) {
projectRoot, err := GetProjectRootFromSpecPath(specPath)
if err != nil {
return "", err
}
requiredDir := filepath.Join(projectRoot, dirName)
if !DirExists(requiredDir) {
return "", fmt.Errorf("Could not find %s directory. %s does not exist... | go | func GetDirInProject(dirName string, specPath string) (string, error) {
projectRoot, err := GetProjectRootFromSpecPath(specPath)
if err != nil {
return "", err
}
requiredDir := filepath.Join(projectRoot, dirName)
if !DirExists(requiredDir) {
return "", fmt.Errorf("Could not find %s directory. %s does not exist... | [
"func",
"GetDirInProject",
"(",
"dirName",
"string",
",",
"specPath",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"projectRoot",
",",
"err",
":=",
"GetProjectRootFromSpecPath",
"(",
"specPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // GetDirInProject returns the path of a particular directory in a Gauge project | [
"GetDirInProject",
"returns",
"the",
"path",
"of",
"a",
"particular",
"directory",
"in",
"a",
"Gauge",
"project"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L115-L126 |
147,732 | getgauge/common | common.go | GetProjectRootFromSpecPath | func GetProjectRootFromSpecPath(specPath string) (string, error) {
projectRoot, err := GetProjectRoot()
if err != nil {
dir, _ := filepath.Split(specPath)
fullPath, pathErr := filepath.Abs(dir)
if pathErr != nil {
return "", fmt.Errorf("Unable to get absolute path to specifications. %s", err)
}
return fi... | go | func GetProjectRootFromSpecPath(specPath string) (string, error) {
projectRoot, err := GetProjectRoot()
if err != nil {
dir, _ := filepath.Split(specPath)
fullPath, pathErr := filepath.Abs(dir)
if pathErr != nil {
return "", fmt.Errorf("Unable to get absolute path to specifications. %s", err)
}
return fi... | [
"func",
"GetProjectRootFromSpecPath",
"(",
"specPath",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"projectRoot",
",",
"err",
":=",
"GetProjectRoot",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"dir",
",",
"_",
":=",
"filepath",
".",
"Split"... | // GetProjectRootFromSpecPath returns the path of the project root from a given spec path | [
"GetProjectRootFromSpecPath",
"returns",
"the",
"path",
"of",
"the",
"project",
"root",
"from",
"a",
"given",
"spec",
"path"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L129-L140 |
147,733 | getgauge/common | common.go | GetDefaultPropertiesFile | func GetDefaultPropertiesFile() (string, error) {
envDir, err := GetDirInProject(EnvDirectoryName, "")
if err != nil {
return "", err
}
defaultEnvFile := filepath.Join(envDir, DefaultEnvDir, DefaultEnvFileName)
if !FileExists(defaultEnvFile) {
return "", fmt.Errorf("Default environment file does not exist: %s ... | go | func GetDefaultPropertiesFile() (string, error) {
envDir, err := GetDirInProject(EnvDirectoryName, "")
if err != nil {
return "", err
}
defaultEnvFile := filepath.Join(envDir, DefaultEnvDir, DefaultEnvFileName)
if !FileExists(defaultEnvFile) {
return "", fmt.Errorf("Default environment file does not exist: %s ... | [
"func",
"GetDefaultPropertiesFile",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"envDir",
",",
"err",
":=",
"GetDirInProject",
"(",
"EnvDirectoryName",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\... | // GetDefaultPropertiesFile returns the path of the default.properties file in the default env | [
"GetDefaultPropertiesFile",
"returns",
"the",
"path",
"of",
"the",
"default",
".",
"properties",
"file",
"in",
"the",
"default",
"env"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L143-L153 |
147,734 | getgauge/common | common.go | AppendProperties | func AppendProperties(propertiesFile string, properties ...*Property) error {
file, err := os.OpenFile(propertiesFile, os.O_RDWR|os.O_APPEND, NewFilePermissions)
if err != nil {
return err
}
for _, property := range properties {
file.WriteString(fmt.Sprintf("\n%s\n", property.String()))
}
return file.Close()
... | go | func AppendProperties(propertiesFile string, properties ...*Property) error {
file, err := os.OpenFile(propertiesFile, os.O_RDWR|os.O_APPEND, NewFilePermissions)
if err != nil {
return err
}
for _, property := range properties {
file.WriteString(fmt.Sprintf("\n%s\n", property.String()))
}
return file.Close()
... | [
"func",
"AppendProperties",
"(",
"propertiesFile",
"string",
",",
"properties",
"...",
"*",
"Property",
")",
"error",
"{",
"file",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"propertiesFile",
",",
"os",
".",
"O_RDWR",
"|",
"os",
".",
"O_APPEND",
",",
... | // AppendProperties appends the given properties to the end of the properties file. | [
"AppendProperties",
"appends",
"the",
"given",
"properties",
"to",
"the",
"end",
"of",
"the",
"properties",
"file",
"."
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L156-L165 |
147,735 | getgauge/common | common.go | FindFilesInDir | func FindFilesInDir(dirPath string, isValidFile func(path string) bool, shouldSkip func(path string, f os.FileInfo) bool) []string {
files := []string{}
filepath.Walk(dirPath, func(path string, f os.FileInfo, err error) error {
if err != nil {
return err
}
if shouldSkip(path, f) {
return filepath.SkipDir
... | go | func FindFilesInDir(dirPath string, isValidFile func(path string) bool, shouldSkip func(path string, f os.FileInfo) bool) []string {
files := []string{}
filepath.Walk(dirPath, func(path string, f os.FileInfo, err error) error {
if err != nil {
return err
}
if shouldSkip(path, f) {
return filepath.SkipDir
... | [
"func",
"FindFilesInDir",
"(",
"dirPath",
"string",
",",
"isValidFile",
"func",
"(",
"path",
"string",
")",
"bool",
",",
"shouldSkip",
"func",
"(",
"path",
"string",
",",
"f",
"os",
".",
"FileInfo",
")",
"bool",
")",
"[",
"]",
"string",
"{",
"files",
"... | // FindFilesInDir returns a list of files for which isValidFile func returns true | [
"FindFilesInDir",
"returns",
"a",
"list",
"of",
"files",
"for",
"which",
"isValidFile",
"func",
"returns",
"true"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L168-L183 |
147,736 | getgauge/common | common.go | GetSkeletonFilePath | func GetSkeletonFilePath(filename string) (string, error) {
searchPath, err := GetConfigurationDir()
if err != nil {
return "", err
}
skelFile := filepath.Join(searchPath, "skel", filename)
if FileExists(skelFile) {
return skelFile, nil
}
return "", fmt.Errorf("Failed to find the skeleton file: %s", filenam... | go | func GetSkeletonFilePath(filename string) (string, error) {
searchPath, err := GetConfigurationDir()
if err != nil {
return "", err
}
skelFile := filepath.Join(searchPath, "skel", filename)
if FileExists(skelFile) {
return skelFile, nil
}
return "", fmt.Errorf("Failed to find the skeleton file: %s", filenam... | [
"func",
"GetSkeletonFilePath",
"(",
"filename",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"searchPath",
",",
"err",
":=",
"GetConfigurationDir",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n... | // GetSkeletonFilePath returns the path skeleton file | [
"GetSkeletonFilePath",
"returns",
"the",
"path",
"skeleton",
"file"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L245-L256 |
147,737 | getgauge/common | common.go | GetPluginsInstallDir | func GetPluginsInstallDir(pluginName string) (string, error) {
pluginInstallPrefixes, err := GetPluginInstallPrefixes()
if err != nil {
return "", err
}
for _, prefix := range pluginInstallPrefixes {
if SubDirectoryExists(prefix, pluginName) {
return prefix, nil
}
}
return "", fmt.Errorf("Plugin '%s' no... | go | func GetPluginsInstallDir(pluginName string) (string, error) {
pluginInstallPrefixes, err := GetPluginInstallPrefixes()
if err != nil {
return "", err
}
for _, prefix := range pluginInstallPrefixes {
if SubDirectoryExists(prefix, pluginName) {
return prefix, nil
}
}
return "", fmt.Errorf("Plugin '%s' no... | [
"func",
"GetPluginsInstallDir",
"(",
"pluginName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"pluginInstallPrefixes",
",",
"err",
":=",
"GetPluginInstallPrefixes",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
... | // GetPluginsInstallDir returns the plugin installation directory | [
"GetPluginsInstallDir",
"returns",
"the",
"plugin",
"installation",
"directory"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L259-L271 |
147,738 | getgauge/common | common.go | SubDirectoryExists | func SubDirectoryExists(pluginDir string, pluginName string) bool {
files, err := ioutil.ReadDir(pluginDir)
if err != nil {
return false
}
for _, f := range files {
if f.Name() == pluginName && f.IsDir() {
return true
}
}
return false
} | go | func SubDirectoryExists(pluginDir string, pluginName string) bool {
files, err := ioutil.ReadDir(pluginDir)
if err != nil {
return false
}
for _, f := range files {
if f.Name() == pluginName && f.IsDir() {
return true
}
}
return false
} | [
"func",
"SubDirectoryExists",
"(",
"pluginDir",
"string",
",",
"pluginName",
"string",
")",
"bool",
"{",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"pluginDir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n"... | // SubDirectoryExists checks if a dir for given plugin exists in the plugin directory | [
"SubDirectoryExists",
"checks",
"if",
"a",
"dir",
"for",
"given",
"plugin",
"exists",
"in",
"the",
"plugin",
"directory"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L274-L286 |
147,739 | getgauge/common | common.go | GetPluginInstallPrefixes | func GetPluginInstallPrefixes() ([]string, error) {
primaryPluginInstallDir, err := GetPrimaryPluginsInstallDir()
if err != nil {
return nil, err
}
return []string{primaryPluginInstallDir}, nil
} | go | func GetPluginInstallPrefixes() ([]string, error) {
primaryPluginInstallDir, err := GetPrimaryPluginsInstallDir()
if err != nil {
return nil, err
}
return []string{primaryPluginInstallDir}, nil
} | [
"func",
"GetPluginInstallPrefixes",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"primaryPluginInstallDir",
",",
"err",
":=",
"GetPrimaryPluginsInstallDir",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}"... | // GetPluginInstallPrefixes returns the installation prefix path for the plugins | [
"GetPluginInstallPrefixes",
"returns",
"the",
"installation",
"prefix",
"path",
"for",
"the",
"plugins"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L289-L295 |
147,740 | getgauge/common | common.go | GetGaugeHomeDirectory | func GetGaugeHomeDirectory() (string, error) {
customPluginRoot := os.Getenv(GaugeHome)
if customPluginRoot != "" {
return customPluginRoot, nil
}
if isWindows() {
appDataDir := os.Getenv(appData)
if appDataDir == "" {
return "", fmt.Errorf("Failed to find plugin installation path. Could not get APPDATA")
... | go | func GetGaugeHomeDirectory() (string, error) {
customPluginRoot := os.Getenv(GaugeHome)
if customPluginRoot != "" {
return customPluginRoot, nil
}
if isWindows() {
appDataDir := os.Getenv(appData)
if appDataDir == "" {
return "", fmt.Errorf("Failed to find plugin installation path. Could not get APPDATA")
... | [
"func",
"GetGaugeHomeDirectory",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"customPluginRoot",
":=",
"os",
".",
"Getenv",
"(",
"GaugeHome",
")",
"\n",
"if",
"customPluginRoot",
"!=",
"\"",
"\"",
"{",
"return",
"customPluginRoot",
",",
"nil",
"\n",
"... | // GetGaugeHomeDirectory returns GAUGE_HOME. This is where all the plugins are installed | [
"GetGaugeHomeDirectory",
"returns",
"GAUGE_HOME",
".",
"This",
"is",
"where",
"all",
"the",
"plugins",
"are",
"installed"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L298-L312 |
147,741 | getgauge/common | common.go | GetPrimaryPluginsInstallDir | func GetPrimaryPluginsInstallDir() (string, error) {
gaugeHome, err := GetGaugeHomeDirectory()
if err != nil {
return "", err
}
return filepath.Join(gaugeHome, Plugins), nil
} | go | func GetPrimaryPluginsInstallDir() (string, error) {
gaugeHome, err := GetGaugeHomeDirectory()
if err != nil {
return "", err
}
return filepath.Join(gaugeHome, Plugins), nil
} | [
"func",
"GetPrimaryPluginsInstallDir",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"gaugeHome",
",",
"err",
":=",
"GetGaugeHomeDirectory",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
... | // GetPrimaryPluginsInstallDir returns the primary plugin installation dir | [
"GetPrimaryPluginsInstallDir",
"returns",
"the",
"primary",
"plugin",
"installation",
"dir"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L315-L321 |
147,742 | getgauge/common | common.go | IsPluginInstalled | func IsPluginInstalled(name, version string) bool {
pluginsDir, err := GetPluginsInstallDir(name)
if err != nil {
return false
}
return DirExists(filepath.Join(pluginsDir, name, version))
} | go | func IsPluginInstalled(name, version string) bool {
pluginsDir, err := GetPluginsInstallDir(name)
if err != nil {
return false
}
return DirExists(filepath.Join(pluginsDir, name, version))
} | [
"func",
"IsPluginInstalled",
"(",
"name",
",",
"version",
"string",
")",
"bool",
"{",
"pluginsDir",
",",
"err",
":=",
"GetPluginsInstallDir",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"DirExists",
... | // IsPluginInstalled checks if the given Gauge plugin version is installed | [
"IsPluginInstalled",
"checks",
"if",
"the",
"given",
"Gauge",
"plugin",
"version",
"is",
"installed"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L324-L330 |
147,743 | getgauge/common | common.go | GetGaugeConfiguration | func GetGaugeConfiguration() (properties.Properties, error) {
configDir, err := GetConfigurationDir()
if err != nil {
return nil, err
}
propertiesFile := filepath.Join(configDir, GaugePropertiesFile)
config, err := properties.Load(propertiesFile)
if err != nil {
return nil, err
}
return config, nil
} | go | func GetGaugeConfiguration() (properties.Properties, error) {
configDir, err := GetConfigurationDir()
if err != nil {
return nil, err
}
propertiesFile := filepath.Join(configDir, GaugePropertiesFile)
config, err := properties.Load(propertiesFile)
if err != nil {
return nil, err
}
return config, nil
} | [
"func",
"GetGaugeConfiguration",
"(",
")",
"(",
"properties",
".",
"Properties",
",",
"error",
")",
"{",
"configDir",
",",
"err",
":=",
"GetConfigurationDir",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
... | // GetGaugeConfiguration parsed the gauge.properties file and other config files from GAUGE_HOME and returns the contents | [
"GetGaugeConfiguration",
"parsed",
"the",
"gauge",
".",
"properties",
"file",
"and",
"other",
"config",
"files",
"from",
"GAUGE_HOME",
"and",
"returns",
"the",
"contents"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L333-L344 |
147,744 | getgauge/common | common.go | ReadFileContents | func ReadFileContents(file string) (string, error) {
if !FileExists(file) {
return "", fmt.Errorf("File %s doesn't exist.", file)
}
bytes, err := ioutil.ReadFile(file)
if err != nil {
return "", fmt.Errorf("Failed to read the file %s.", file)
}
return strings.TrimLeft(string(bytes), "\xef\xbb\xbf"), nil
} | go | func ReadFileContents(file string) (string, error) {
if !FileExists(file) {
return "", fmt.Errorf("File %s doesn't exist.", file)
}
bytes, err := ioutil.ReadFile(file)
if err != nil {
return "", fmt.Errorf("Failed to read the file %s.", file)
}
return strings.TrimLeft(string(bytes), "\xef\xbb\xbf"), nil
} | [
"func",
"ReadFileContents",
"(",
"file",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"!",
"FileExists",
"(",
"file",
")",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"file",
")",
"\n",
"}",
"\n",
"b... | // ReadFileContents returns the contents of the file | [
"ReadFileContents",
"returns",
"the",
"contents",
"of",
"the",
"file"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L347-L356 |
147,745 | getgauge/common | common.go | DirExists | func DirExists(dirPath string) bool {
if stat, err := os.Stat(dirPath); err == nil && stat.IsDir() {
return true
}
return false
} | go | func DirExists(dirPath string) bool {
if stat, err := os.Stat(dirPath); err == nil && stat.IsDir() {
return true
}
return false
} | [
"func",
"DirExists",
"(",
"dirPath",
"string",
")",
"bool",
"{",
"if",
"stat",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"dirPath",
")",
";",
"err",
"==",
"nil",
"&&",
"stat",
".",
"IsDir",
"(",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"retur... | // DirExists checks if the given directory exists | [
"DirExists",
"checks",
"if",
"the",
"given",
"directory",
"exists"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L367-L372 |
147,746 | getgauge/common | common.go | CopyFile | func CopyFile(src, dest string) error {
if !FileExists(src) {
return fmt.Errorf("%s doesn't exist", src)
}
b, err := ioutil.ReadFile(src)
if err != nil {
return err
}
err = ioutil.WriteFile(dest, b, NewFilePermissions)
if err != nil {
return err
}
return nil
} | go | func CopyFile(src, dest string) error {
if !FileExists(src) {
return fmt.Errorf("%s doesn't exist", src)
}
b, err := ioutil.ReadFile(src)
if err != nil {
return err
}
err = ioutil.WriteFile(dest, b, NewFilePermissions)
if err != nil {
return err
}
return nil
} | [
"func",
"CopyFile",
"(",
"src",
",",
"dest",
"string",
")",
"error",
"{",
"if",
"!",
"FileExists",
"(",
"src",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"src",
")",
"\n",
"}",
"\n\n",
"b",
",",
"err",
":=",
"ioutil",
".",
... | // CopyFile creates a copy of source file to destination file | [
"CopyFile",
"creates",
"a",
"copy",
"of",
"source",
"file",
"to",
"destination",
"file"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L465-L481 |
147,747 | getgauge/common | common.go | AppendToFile | func AppendToFile(srcFile, destFile string) error {
if FileExists(destFile) {
f, err := os.OpenFile(destFile, os.O_APPEND|os.O_WRONLY, 0666)
if err != nil {
return fmt.Errorf("Failed to open %s. %s \n", destFile, err.Error())
}
defer f.Close()
srcFileContent, err := ReadFileContents(srcFile)
if err !=... | go | func AppendToFile(srcFile, destFile string) error {
if FileExists(destFile) {
f, err := os.OpenFile(destFile, os.O_APPEND|os.O_WRONLY, 0666)
if err != nil {
return fmt.Errorf("Failed to open %s. %s \n", destFile, err.Error())
}
defer f.Close()
srcFileContent, err := ReadFileContents(srcFile)
if err !=... | [
"func",
"AppendToFile",
"(",
"srcFile",
",",
"destFile",
"string",
")",
"error",
"{",
"if",
"FileExists",
"(",
"destFile",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"destFile",
",",
"os",
".",
"O_APPEND",
"|",
"os",
".",
"O_WRONLY",
... | //Appends contents of source file to destination file.
// If destination file is not present, Copy file action is performed | [
"Appends",
"contents",
"of",
"source",
"file",
"to",
"destination",
"file",
".",
"If",
"destination",
"file",
"is",
"not",
"present",
"Copy",
"file",
"action",
"is",
"performed"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L485-L509 |
147,748 | getgauge/common | common.go | SetEnvVariable | func SetEnvVariable(key, value string) error {
if strings.TrimSpace(value) == "" {
return nil
}
err := os.Setenv(key, value)
if err != nil {
return fmt.Errorf("Failed to set: %s = %s. %s", key, value, err.Error())
}
return nil
} | go | func SetEnvVariable(key, value string) error {
if strings.TrimSpace(value) == "" {
return nil
}
err := os.Setenv(key, value)
if err != nil {
return fmt.Errorf("Failed to set: %s = %s. %s", key, value, err.Error())
}
return nil
} | [
"func",
"SetEnvVariable",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"if",
"strings",
".",
"TrimSpace",
"(",
"value",
")",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"err",
":=",
"os",
".",
"Setenv",
"(",
"key",
",",
"valu... | // SetEnvVariable is a wrapper around os.SetEnv to set env variable | [
"SetEnvVariable",
"is",
"a",
"wrapper",
"around",
"os",
".",
"SetEnv",
"to",
"set",
"env",
"variable"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L512-L521 |
147,749 | getgauge/common | common.go | ExecuteCommand | func ExecuteCommand(command []string, workingDir string, outputStreamWriter io.Writer, errorStreamWriter io.Writer) (*exec.Cmd, error) {
cmd := prepareCommand(false, command, workingDir, outputStreamWriter, errorStreamWriter)
err := cmd.Start()
return cmd, err
} | go | func ExecuteCommand(command []string, workingDir string, outputStreamWriter io.Writer, errorStreamWriter io.Writer) (*exec.Cmd, error) {
cmd := prepareCommand(false, command, workingDir, outputStreamWriter, errorStreamWriter)
err := cmd.Start()
return cmd, err
} | [
"func",
"ExecuteCommand",
"(",
"command",
"[",
"]",
"string",
",",
"workingDir",
"string",
",",
"outputStreamWriter",
"io",
".",
"Writer",
",",
"errorStreamWriter",
"io",
".",
"Writer",
")",
"(",
"*",
"exec",
".",
"Cmd",
",",
"error",
")",
"{",
"cmd",
":... | // ExecuteCommand executes the given command in the working directory. | [
"ExecuteCommand",
"executes",
"the",
"given",
"command",
"in",
"the",
"working",
"directory",
"."
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L524-L528 |
147,750 | getgauge/common | common.go | ExecuteSystemCommand | func ExecuteSystemCommand(command []string, workingDir string, outputStreamWriter io.Writer, errorStreamWriter io.Writer) (*exec.Cmd, error) {
cmd := prepareCommand(true, command, workingDir, outputStreamWriter, errorStreamWriter)
err := cmd.Start()
return cmd, err
} | go | func ExecuteSystemCommand(command []string, workingDir string, outputStreamWriter io.Writer, errorStreamWriter io.Writer) (*exec.Cmd, error) {
cmd := prepareCommand(true, command, workingDir, outputStreamWriter, errorStreamWriter)
err := cmd.Start()
return cmd, err
} | [
"func",
"ExecuteSystemCommand",
"(",
"command",
"[",
"]",
"string",
",",
"workingDir",
"string",
",",
"outputStreamWriter",
"io",
".",
"Writer",
",",
"errorStreamWriter",
"io",
".",
"Writer",
")",
"(",
"*",
"exec",
".",
"Cmd",
",",
"error",
")",
"{",
"cmd"... | // ExecuteSystemCommand executes the given system command in the working directory. | [
"ExecuteSystemCommand",
"executes",
"the",
"given",
"system",
"command",
"in",
"the",
"working",
"directory",
"."
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L531-L535 |
147,751 | getgauge/common | common.go | ExecuteCommandWithEnv | func ExecuteCommandWithEnv(command []string, workingDir string, outputStreamWriter io.Writer, errorStreamWriter io.Writer, env []string) (*exec.Cmd, error) {
cmd := prepareCommand(false, command, workingDir, outputStreamWriter, errorStreamWriter)
cmd.Env = env
err := cmd.Start()
return cmd, err
} | go | func ExecuteCommandWithEnv(command []string, workingDir string, outputStreamWriter io.Writer, errorStreamWriter io.Writer, env []string) (*exec.Cmd, error) {
cmd := prepareCommand(false, command, workingDir, outputStreamWriter, errorStreamWriter)
cmd.Env = env
err := cmd.Start()
return cmd, err
} | [
"func",
"ExecuteCommandWithEnv",
"(",
"command",
"[",
"]",
"string",
",",
"workingDir",
"string",
",",
"outputStreamWriter",
"io",
".",
"Writer",
",",
"errorStreamWriter",
"io",
".",
"Writer",
",",
"env",
"[",
"]",
"string",
")",
"(",
"*",
"exec",
".",
"Cm... | // ExecuteCommandWithEnv executes command after setting the given environment | [
"ExecuteCommandWithEnv",
"executes",
"command",
"after",
"setting",
"the",
"given",
"environment"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L538-L543 |
147,752 | getgauge/common | common.go | GetExecutableCommand | func GetExecutableCommand(isSystemCommand bool, command ...string) *exec.Cmd {
if len(command) == 0 {
panic(fmt.Errorf("Invalid executable command"))
}
cmd := &exec.Cmd{Path: command[0]}
if len(command) > 1 {
if isSystemCommand {
cmd = exec.Command(command[0], command[1:]...)
}
cmd.Args = append([]string... | go | func GetExecutableCommand(isSystemCommand bool, command ...string) *exec.Cmd {
if len(command) == 0 {
panic(fmt.Errorf("Invalid executable command"))
}
cmd := &exec.Cmd{Path: command[0]}
if len(command) > 1 {
if isSystemCommand {
cmd = exec.Command(command[0], command[1:]...)
}
cmd.Args = append([]string... | [
"func",
"GetExecutableCommand",
"(",
"isSystemCommand",
"bool",
",",
"command",
"...",
"string",
")",
"*",
"exec",
".",
"Cmd",
"{",
"if",
"len",
"(",
"command",
")",
"==",
"0",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
")",
"\n",... | // GetExecutableCommand returns the path of the executable file | [
"GetExecutableCommand",
"returns",
"the",
"path",
"of",
"the",
"executable",
"file"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L555-L572 |
147,753 | getgauge/common | common.go | GetTempDir | func GetTempDir() string {
tempGaugeDir := filepath.Join(os.TempDir(), "gauge_temp")
tempGaugeDir += strconv.FormatInt(time.Now().UnixNano(), 10)
if !exists(tempGaugeDir) {
os.MkdirAll(tempGaugeDir, NewDirectoryPermissions)
}
return tempGaugeDir
} | go | func GetTempDir() string {
tempGaugeDir := filepath.Join(os.TempDir(), "gauge_temp")
tempGaugeDir += strconv.FormatInt(time.Now().UnixNano(), 10)
if !exists(tempGaugeDir) {
os.MkdirAll(tempGaugeDir, NewDirectoryPermissions)
}
return tempGaugeDir
} | [
"func",
"GetTempDir",
"(",
")",
"string",
"{",
"tempGaugeDir",
":=",
"filepath",
".",
"Join",
"(",
"os",
".",
"TempDir",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"tempGaugeDir",
"+=",
"strconv",
".",
"FormatInt",
"(",
"time",
".",
"Now",
"(",
")",
".",
... | // GetTempDir returns the system temp directory | [
"GetTempDir",
"returns",
"the",
"system",
"temp",
"directory"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L575-L582 |
147,754 | getgauge/common | common.go | UnzipArchive | func UnzipArchive(zipFile string, dest string) (string, error) {
if !FileExists(zipFile) {
return "", fmt.Errorf("ZipFile %s does not exist", zipFile)
}
r, err := zip.OpenReader(zipFile)
if err != nil {
return "", err
}
defer r.Close()
for _, f := range r.File {
rc, err := f.Open()
if err != nil {
r... | go | func UnzipArchive(zipFile string, dest string) (string, error) {
if !FileExists(zipFile) {
return "", fmt.Errorf("ZipFile %s does not exist", zipFile)
}
r, err := zip.OpenReader(zipFile)
if err != nil {
return "", err
}
defer r.Close()
for _, f := range r.File {
rc, err := f.Open()
if err != nil {
r... | [
"func",
"UnzipArchive",
"(",
"zipFile",
"string",
",",
"dest",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"!",
"FileExists",
"(",
"zipFile",
")",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"zipFile",
... | // UnzipArchive extract the zip file to destination directory | [
"UnzipArchive",
"extract",
"the",
"zip",
"file",
"to",
"destination",
"directory"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L597-L642 |
147,755 | getgauge/common | common.go | SaveFile | func SaveFile(filePath, contents string, takeBackup bool) error {
backupFile := ""
if takeBackup {
tmpDir := os.TempDir()
fileName := fmt.Sprintf("%s_%v", filepath.Base(filePath), GetUniqueID())
backupFile = filepath.Join(tmpDir, fileName)
err := CopyFile(filePath, backupFile)
if err != nil {
return fmt.... | go | func SaveFile(filePath, contents string, takeBackup bool) error {
backupFile := ""
if takeBackup {
tmpDir := os.TempDir()
fileName := fmt.Sprintf("%s_%v", filepath.Base(filePath), GetUniqueID())
backupFile = filepath.Join(tmpDir, fileName)
err := CopyFile(filePath, backupFile)
if err != nil {
return fmt.... | [
"func",
"SaveFile",
"(",
"filePath",
",",
"contents",
"string",
",",
"takeBackup",
"bool",
")",
"error",
"{",
"backupFile",
":=",
"\"",
"\"",
"\n",
"if",
"takeBackup",
"{",
"tmpDir",
":=",
"os",
".",
"TempDir",
"(",
")",
"\n",
"fileName",
":=",
"fmt",
... | // SaveFile saves contents at the given filepath | [
"SaveFile",
"saves",
"contents",
"at",
"the",
"given",
"filepath"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L645-L662 |
147,756 | getgauge/common | common.go | TrimTrailingSpace | func TrimTrailingSpace(str string) string {
var r = regexp.MustCompile(`[ \t]+$`)
return r.ReplaceAllString(str, "")
} | go | func TrimTrailingSpace(str string) string {
var r = regexp.MustCompile(`[ \t]+$`)
return r.ReplaceAllString(str, "")
} | [
"func",
"TrimTrailingSpace",
"(",
"str",
"string",
")",
"string",
"{",
"var",
"r",
"=",
"regexp",
".",
"MustCompile",
"(",
"`[ \\t]+$`",
")",
"\n",
"return",
"r",
".",
"ReplaceAllString",
"(",
"str",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // TrimTrailingSpace trims the trailing spaces in the given string | [
"TrimTrailingSpace",
"trims",
"the",
"trailing",
"spaces",
"in",
"the",
"given",
"string"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L680-L683 |
147,757 | getgauge/common | common.go | UrlExists | func UrlExists(url string) (bool, error) {
resp, err := http.Head(url)
if err != nil {
return false, fmt.Errorf("Failed to resolve host")
}
if resp.StatusCode == 200 {
return true, nil
}
return false, fmt.Errorf("Could not get %s, %d-%s", url, resp.StatusCode, resp.Status)
} | go | func UrlExists(url string) (bool, error) {
resp, err := http.Head(url)
if err != nil {
return false, fmt.Errorf("Failed to resolve host")
}
if resp.StatusCode == 200 {
return true, nil
}
return false, fmt.Errorf("Could not get %s, %d-%s", url, resp.StatusCode, resp.Status)
} | [
"func",
"UrlExists",
"(",
"url",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"http",
".",
"Head",
"(",
"url",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"... | // UrlExists checks if the given url exists | [
"UrlExists",
"checks",
"if",
"the",
"given",
"url",
"exists"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L690-L699 |
147,758 | getgauge/common | common.go | GetPluginProperties | func GetPluginProperties(jsonPropertiesFile string) (map[string]interface{}, error) {
pluginPropertiesJSON, err := ioutil.ReadFile(jsonPropertiesFile)
if err != nil {
return nil, fmt.Errorf("Could not read %s: %s\n", filepath.Base(jsonPropertiesFile), err)
}
var pluginJSON interface{}
if err = json.Unmarshal([]b... | go | func GetPluginProperties(jsonPropertiesFile string) (map[string]interface{}, error) {
pluginPropertiesJSON, err := ioutil.ReadFile(jsonPropertiesFile)
if err != nil {
return nil, fmt.Errorf("Could not read %s: %s\n", filepath.Base(jsonPropertiesFile), err)
}
var pluginJSON interface{}
if err = json.Unmarshal([]b... | [
"func",
"GetPluginProperties",
"(",
"jsonPropertiesFile",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"pluginPropertiesJSON",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"jsonPropertiesFile",
")",
"\n",
... | // GetPluginProperties returns the properties of the given plugin. | [
"GetPluginProperties",
"returns",
"the",
"properties",
"of",
"the",
"given",
"plugin",
"."
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L702-L712 |
147,759 | getgauge/common | common.go | GetGaugePluginVersion | func GetGaugePluginVersion(pluginName string) (string, error) {
pluginProperties, err := GetPluginProperties(fmt.Sprintf("%s.json", pluginName))
if err != nil {
return "", fmt.Errorf("Failed to get gauge %s properties file. %s", pluginName, err)
}
return pluginProperties["version"].(string), nil
} | go | func GetGaugePluginVersion(pluginName string) (string, error) {
pluginProperties, err := GetPluginProperties(fmt.Sprintf("%s.json", pluginName))
if err != nil {
return "", fmt.Errorf("Failed to get gauge %s properties file. %s", pluginName, err)
}
return pluginProperties["version"].(string), nil
} | [
"func",
"GetGaugePluginVersion",
"(",
"pluginName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"pluginProperties",
",",
"err",
":=",
"GetPluginProperties",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"pluginName",
")",
")",
"\n",
"if",
"er... | // GetGaugePluginVersion returns the latest version installed of the given plugin | [
"GetGaugePluginVersion",
"returns",
"the",
"latest",
"version",
"installed",
"of",
"the",
"given",
"plugin"
] | 8966e8b0efde9ddbd0035e7b772723719dc4e69f | https://github.com/getgauge/common/blob/8966e8b0efde9ddbd0035e7b772723719dc4e69f/common.go#L715-L721 |
147,760 | kouhin/envflag | envflag.go | NewEnvFlag | func NewEnvFlag(
flagSet *flag.FlagSet,
minLength int,
envFlagDict map[string]string,
showEnvKeyInUsage bool,
showEnvValInUsage bool) *EnvFlag {
return &EnvFlag{
flagSet: flagSet,
minLength: minLength,
envFlagDict: envFlagDict,
showEnvKeyInUsage: showEnvKeyInUsage,
showEnvValInUs... | go | func NewEnvFlag(
flagSet *flag.FlagSet,
minLength int,
envFlagDict map[string]string,
showEnvKeyInUsage bool,
showEnvValInUsage bool) *EnvFlag {
return &EnvFlag{
flagSet: flagSet,
minLength: minLength,
envFlagDict: envFlagDict,
showEnvKeyInUsage: showEnvKeyInUsage,
showEnvValInUs... | [
"func",
"NewEnvFlag",
"(",
"flagSet",
"*",
"flag",
".",
"FlagSet",
",",
"minLength",
"int",
",",
"envFlagDict",
"map",
"[",
"string",
"]",
"string",
",",
"showEnvKeyInUsage",
"bool",
",",
"showEnvValInUsage",
"bool",
")",
"*",
"EnvFlag",
"{",
"return",
"&",
... | // NewEnvFlag returns a new EnvFlag. | [
"NewEnvFlag",
"returns",
"a",
"new",
"EnvFlag",
"."
] | 0e9a8606164937a324853295ffa8e9803372e765 | https://github.com/kouhin/envflag/blob/0e9a8606164937a324853295ffa8e9803372e765/envflag.go#L173-L186 |
147,761 | SentimensRG/ctx | sigctx/sigctx.go | New | func New() ctx.C {
initC.Do(func() {
initSig.Do(initSigCh)
dc := make(chan struct{})
c = dc
go func() {
select {
case <-sigCh:
close(dc)
case <-c.Done():
}
}()
})
return c
} | go | func New() ctx.C {
initC.Do(func() {
initSig.Do(initSigCh)
dc := make(chan struct{})
c = dc
go func() {
select {
case <-sigCh:
close(dc)
case <-c.Done():
}
}()
})
return c
} | [
"func",
"New",
"(",
")",
"ctx",
".",
"C",
"{",
"initC",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"initSig",
".",
"Do",
"(",
"initSigCh",
")",
"\n\n",
"dc",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"c",
"=",
"dc",
"\n\n",
"go",
... | // New signal-bound ctx.C that terminates when either SIGINT or SIGTERM
// is caught. | [
"New",
"signal",
"-",
"bound",
"ctx",
".",
"C",
"that",
"terminates",
"when",
"either",
"SIGINT",
"or",
"SIGTERM",
"is",
"caught",
"."
] | 0bfd988c655d43237fae626efb200792d576142a | https://github.com/SentimensRG/ctx/blob/0bfd988c655d43237fae626efb200792d576142a/sigctx/sigctx.go#L27-L44 |
147,762 | cloudfoundry/mariadb_ctrl | os_helper/os_helper.go | RunCommand | func (h OsHelperImpl) RunCommand(executable string, args ...string) (string, error) {
cmd := exec.Command(executable, args...)
out, err := cmd.CombinedOutput()
if err != nil {
return string(out), err
}
return string(out), nil
} | go | func (h OsHelperImpl) RunCommand(executable string, args ...string) (string, error) {
cmd := exec.Command(executable, args...)
out, err := cmd.CombinedOutput()
if err != nil {
return string(out), err
}
return string(out), nil
} | [
"func",
"(",
"h",
"OsHelperImpl",
")",
"RunCommand",
"(",
"executable",
"string",
",",
"args",
"...",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"executable",
",",
"args",
"...",
")",
"\n",
"out",
... | // Runs command with stdout and stderr pipes connected to process | [
"Runs",
"command",
"with",
"stdout",
"and",
"stderr",
"pipes",
"connected",
"to",
"process"
] | df6de72178cca32f782c1472fbe8b6307abe1c76 | https://github.com/cloudfoundry/mariadb_ctrl/blob/df6de72178cca32f782c1472fbe8b6307abe1c76/os_helper/os_helper.go#L28-L35 |
147,763 | cloudfoundry/mariadb_ctrl | os_helper/os_helper.go | ReadFile | func (h OsHelperImpl) ReadFile(filename string) (string, error) {
b, err := ioutil.ReadFile(filename)
if err != nil {
return "", err
}
return string(b[:]), nil
} | go | func (h OsHelperImpl) ReadFile(filename string) (string, error) {
b, err := ioutil.ReadFile(filename)
if err != nil {
return "", err
}
return string(b[:]), nil
} | [
"func",
"(",
"h",
"OsHelperImpl",
")",
"ReadFile",
"(",
"filename",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"... | // Read the whole file, panic on err | [
"Read",
"the",
"whole",
"file",
"panic",
"on",
"err"
] | df6de72178cca32f782c1472fbe8b6307abe1c76 | https://github.com/cloudfoundry/mariadb_ctrl/blob/df6de72178cca32f782c1472fbe8b6307abe1c76/os_helper/os_helper.go#L64-L70 |
147,764 | cloudfoundry/mariadb_ctrl | os_helper/os_helper.go | WriteStringToFile | func (h OsHelperImpl) WriteStringToFile(filename string, contents string) error {
err := ioutil.WriteFile(filename, []byte(contents), 0644)
return err
} | go | func (h OsHelperImpl) WriteStringToFile(filename string, contents string) error {
err := ioutil.WriteFile(filename, []byte(contents), 0644)
return err
} | [
"func",
"(",
"h",
"OsHelperImpl",
")",
"WriteStringToFile",
"(",
"filename",
"string",
",",
"contents",
"string",
")",
"error",
"{",
"err",
":=",
"ioutil",
".",
"WriteFile",
"(",
"filename",
",",
"[",
"]",
"byte",
"(",
"contents",
")",
",",
"0644",
")",
... | // Overwrite the contents, creating if necessary. Panic on err | [
"Overwrite",
"the",
"contents",
"creating",
"if",
"necessary",
".",
"Panic",
"on",
"err"
] | df6de72178cca32f782c1472fbe8b6307abe1c76 | https://github.com/cloudfoundry/mariadb_ctrl/blob/df6de72178cca32f782c1472fbe8b6307abe1c76/os_helper/os_helper.go#L73-L76 |
147,765 | SentimensRG/ctx | ctx.go | After | func After(d time.Duration) C {
ch := make(chan struct{})
go func() {
<-time.After(d)
close(ch)
}()
return ch
} | go | func After(d time.Duration) C {
ch := make(chan struct{})
go func() {
<-time.After(d)
close(ch)
}()
return ch
} | [
"func",
"After",
"(",
"d",
"time",
".",
"Duration",
")",
"C",
"{",
"ch",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"<-",
"time",
".",
"After",
"(",
"d",
")",
"\n",
"close",
"(",
"ch",
")",
"\n",
... | // After time time has elapsed, the Doner fires | [
"After",
"time",
"time",
"has",
"elapsed",
"the",
"Doner",
"fires"
] | 0bfd988c655d43237fae626efb200792d576142a | https://github.com/SentimensRG/ctx/blob/0bfd988c655d43237fae626efb200792d576142a/ctx.go#L69-L76 |
147,766 | SentimensRG/ctx | ctx.go | WithCancel | func WithCancel(d Doner) (C, func()) {
var closer sync.Once
cq := make(chan struct{})
cancel := func() { closer.Do(func() { close(cq) }) }
go func() {
select {
case <-cq:
case <-d.Done():
cancel()
}
}()
return cq, cancel
} | go | func WithCancel(d Doner) (C, func()) {
var closer sync.Once
cq := make(chan struct{})
cancel := func() { closer.Do(func() { close(cq) }) }
go func() {
select {
case <-cq:
case <-d.Done():
cancel()
}
}()
return cq, cancel
} | [
"func",
"WithCancel",
"(",
"d",
"Doner",
")",
"(",
"C",
",",
"func",
"(",
")",
")",
"{",
"var",
"closer",
"sync",
".",
"Once",
"\n",
"cq",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"cancel",
":=",
"func",
"(",
")",
"{",
"closer"... | // WithCancel returns a new Doner that can be cancelled via the associated
// function | [
"WithCancel",
"returns",
"a",
"new",
"Doner",
"that",
"can",
"be",
"cancelled",
"via",
"the",
"associated",
"function"
] | 0bfd988c655d43237fae626efb200792d576142a | https://github.com/SentimensRG/ctx/blob/0bfd988c655d43237fae626efb200792d576142a/ctx.go#L80-L94 |
147,767 | SentimensRG/ctx | ctx.go | Tick | func Tick(d Doner) <-chan struct{} {
c := make(chan struct{})
cq := d.Done()
go func() {
for {
select {
case <-cq:
close(c)
return
default:
select {
case c <- struct{}{}:
case <-cq:
}
}
}
}()
return c
} | go | func Tick(d Doner) <-chan struct{} {
c := make(chan struct{})
cq := d.Done()
go func() {
for {
select {
case <-cq:
close(c)
return
default:
select {
case c <- struct{}{}:
case <-cq:
}
}
}
}()
return c
} | [
"func",
"Tick",
"(",
"d",
"Doner",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"c",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"cq",
":=",
"d",
".",
"Done",
"(",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"select",
"... | // Tick returns a <-chan whose range ends when the underlying context cancels | [
"Tick",
"returns",
"a",
"<",
"-",
"chan",
"whose",
"range",
"ends",
"when",
"the",
"underlying",
"context",
"cancels"
] | 0bfd988c655d43237fae626efb200792d576142a | https://github.com/SentimensRG/ctx/blob/0bfd988c655d43237fae626efb200792d576142a/ctx.go#L97-L115 |
147,768 | SentimensRG/ctx | ctx.go | Link | func Link(doners ...Doner) C {
c := make(chan struct{})
cancel := func() { close(c) }
var once sync.Once
for _, d := range doners {
Defer(d, func() { once.Do(cancel) })
}
return c
} | go | func Link(doners ...Doner) C {
c := make(chan struct{})
cancel := func() { close(c) }
var once sync.Once
for _, d := range doners {
Defer(d, func() { once.Do(cancel) })
}
return c
} | [
"func",
"Link",
"(",
"doners",
"...",
"Doner",
")",
"C",
"{",
"c",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"cancel",
":=",
"func",
"(",
")",
"{",
"close",
"(",
"c",
")",
"}",
"\n\n",
"var",
"once",
"sync",
".",
"Once",
"\n",
... | // Link returns a channel that fires if ANY of the constituent Doners have fired | [
"Link",
"returns",
"a",
"channel",
"that",
"fires",
"if",
"ANY",
"of",
"the",
"constituent",
"Doners",
"have",
"fired"
] | 0bfd988c655d43237fae626efb200792d576142a | https://github.com/SentimensRG/ctx/blob/0bfd988c655d43237fae626efb200792d576142a/ctx.go#L126-L136 |
147,769 | SentimensRG/ctx | ctx.go | Join | func Join(doners ...Doner) C {
var wg sync.WaitGroup
wg.Add(len(doners))
for _, d := range doners {
Defer(d, wg.Done)
}
cq := make(chan struct{})
go func() {
wg.Wait()
close(cq)
}()
return cq
} | go | func Join(doners ...Doner) C {
var wg sync.WaitGroup
wg.Add(len(doners))
for _, d := range doners {
Defer(d, wg.Done)
}
cq := make(chan struct{})
go func() {
wg.Wait()
close(cq)
}()
return cq
} | [
"func",
"Join",
"(",
"doners",
"...",
"Doner",
")",
"C",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"wg",
".",
"Add",
"(",
"len",
"(",
"doners",
")",
")",
"\n",
"for",
"_",
",",
"d",
":=",
"range",
"doners",
"{",
"Defer",
"(",
"d",
",",
... | // Join returns a channel that receives when all constituent Doners have fired | [
"Join",
"returns",
"a",
"channel",
"that",
"receives",
"when",
"all",
"constituent",
"Doners",
"have",
"fired"
] | 0bfd988c655d43237fae626efb200792d576142a | https://github.com/SentimensRG/ctx/blob/0bfd988c655d43237fae626efb200792d576142a/ctx.go#L139-L152 |
147,770 | SentimensRG/ctx | ctx.go | FTickInterval | func FTickInterval(d Doner, t time.Duration, f func()) {
for {
select {
case <-d.Done():
return
case <-time.After(t):
f()
}
}
} | go | func FTickInterval(d Doner, t time.Duration, f func()) {
for {
select {
case <-d.Done():
return
case <-time.After(t):
f()
}
}
} | [
"func",
"FTickInterval",
"(",
"d",
"Doner",
",",
"t",
"time",
".",
"Duration",
",",
"f",
"func",
"(",
")",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"d",
".",
"Done",
"(",
")",
":",
"return",
"\n",
"case",
"<-",
"time",
".",
"After",
"... | // FTickInterval calls a function repeatedly at a given internval, until the Doner
// has fired. Note that FTickInterval ignores the time spent executing a function,
// and instead guarantees an interval of `t` between of return of the previous
// function call and the invocation of the next function call. | [
"FTickInterval",
"calls",
"a",
"function",
"repeatedly",
"at",
"a",
"given",
"internval",
"until",
"the",
"Doner",
"has",
"fired",
".",
"Note",
"that",
"FTickInterval",
"ignores",
"the",
"time",
"spent",
"executing",
"a",
"function",
"and",
"instead",
"guarantee... | 0bfd988c655d43237fae626efb200792d576142a | https://github.com/SentimensRG/ctx/blob/0bfd988c655d43237fae626efb200792d576142a/ctx.go#L165-L174 |
147,771 | SentimensRG/ctx | refctx/refctx.go | Add | func (r *RefCtr) Add(i uint32) {
if v := atomic.AddUint32(&r.refcnt, i); v == 0 {
r.cancel()
}
} | go | func (r *RefCtr) Add(i uint32) {
if v := atomic.AddUint32(&r.refcnt, i); v == 0 {
r.cancel()
}
} | [
"func",
"(",
"r",
"*",
"RefCtr",
")",
"Add",
"(",
"i",
"uint32",
")",
"{",
"if",
"v",
":=",
"atomic",
".",
"AddUint32",
"(",
"&",
"r",
".",
"refcnt",
",",
"i",
")",
";",
"v",
"==",
"0",
"{",
"r",
".",
"cancel",
"(",
")",
"\n",
"}",
"\n",
... | // Add i refcounts | [
"Add",
"i",
"refcounts"
] | 0bfd988c655d43237fae626efb200792d576142a | https://github.com/SentimensRG/ctx/blob/0bfd988c655d43237fae626efb200792d576142a/refctx/refctx.go#L21-L25 |
147,772 | SentimensRG/ctx | refctx/refctx.go | WithRefCount | func WithRefCount(d ctx.Doner) (ctx.C, *RefCtr) {
ch, cancel := ctx.WithCancel(d)
return ch, &RefCtr{cancel: cancel}
} | go | func WithRefCount(d ctx.Doner) (ctx.C, *RefCtr) {
ch, cancel := ctx.WithCancel(d)
return ch, &RefCtr{cancel: cancel}
} | [
"func",
"WithRefCount",
"(",
"d",
"ctx",
".",
"Doner",
")",
"(",
"ctx",
".",
"C",
",",
"*",
"RefCtr",
")",
"{",
"ch",
",",
"cancel",
":=",
"ctx",
".",
"WithCancel",
"(",
"d",
")",
"\n",
"return",
"ch",
",",
"&",
"RefCtr",
"{",
"cancel",
":",
"c... | // WithRefCount derives a ctx.C that will be cancelled when all references are
// freed | [
"WithRefCount",
"derives",
"a",
"ctx",
".",
"C",
"that",
"will",
"be",
"cancelled",
"when",
"all",
"references",
"are",
"freed"
] | 0bfd988c655d43237fae626efb200792d576142a | https://github.com/SentimensRG/ctx/blob/0bfd988c655d43237fae626efb200792d576142a/refctx/refctx.go#L32-L35 |
147,773 | SentimensRG/ctx | refctx/refctx.go | ContextWithRefCount | func ContextWithRefCount(c context.Context) (context.Context, *RefCtr) {
c, cancel := context.WithCancel(c)
return c, &RefCtr{cancel: cancel}
} | go | func ContextWithRefCount(c context.Context) (context.Context, *RefCtr) {
c, cancel := context.WithCancel(c)
return c, &RefCtr{cancel: cancel}
} | [
"func",
"ContextWithRefCount",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"context",
".",
"Context",
",",
"*",
"RefCtr",
")",
"{",
"c",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"c",
")",
"\n",
"return",
"c",
",",
"&",
"RefCtr",
"{"... | // ContextWithRefCount derives a context that will be cancelled when all
// references are freed. | [
"ContextWithRefCount",
"derives",
"a",
"context",
"that",
"will",
"be",
"cancelled",
"when",
"all",
"references",
"are",
"freed",
"."
] | 0bfd988c655d43237fae626efb200792d576142a | https://github.com/SentimensRG/ctx/blob/0bfd988c655d43237fae626efb200792d576142a/refctx/refctx.go#L39-L42 |
147,774 | yashtewari/glob-intersection | non_empty.go | NonEmpty | func NonEmpty(lhs string, rhs string) (bool, error) {
g1, err := NewGlob(lhs)
if err != nil {
return false, err
}
g2, err := NewGlob(rhs)
if err != nil {
return false, err
}
var match bool
g1, g2, match = trimGlobs(g1, g2)
if !match {
return false, nil
}
return intersectNormal(g1, g2), nil
} | go | func NonEmpty(lhs string, rhs string) (bool, error) {
g1, err := NewGlob(lhs)
if err != nil {
return false, err
}
g2, err := NewGlob(rhs)
if err != nil {
return false, err
}
var match bool
g1, g2, match = trimGlobs(g1, g2)
if !match {
return false, nil
}
return intersectNormal(g1, g2), nil
} | [
"func",
"NonEmpty",
"(",
"lhs",
"string",
",",
"rhs",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"g1",
",",
"err",
":=",
"NewGlob",
"(",
"lhs",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
... | // NonEmpty is true if the intersection of lhs and rhs matches a non-empty set of non-empty str1ngs. | [
"NonEmpty",
"is",
"true",
"if",
"the",
"intersection",
"of",
"lhs",
"and",
"rhs",
"matches",
"a",
"non",
"-",
"empty",
"set",
"of",
"non",
"-",
"empty",
"str1ngs",
"."
] | 5c77d914dd0ba7bedca923f97232d37137e038f3 | https://github.com/yashtewari/glob-intersection/blob/5c77d914dd0ba7bedca923f97232d37137e038f3/non_empty.go#L4-L22 |
147,775 | yashtewari/glob-intersection | non_empty.go | intersectNormal | func intersectNormal(g1, g2 Glob) bool {
var i, j int
for i, j = 0, 0; i < len(g1) && j < len(g2); i, j = i+1, j+1 {
if g1[i].Flag() == FlagNone && g2[j].Flag() == FlagNone {
if !Match(g1[i], g2[j]) {
return false
}
} else {
return intersectSpecial(g1[i:], g2[j:])
}
}
if i == len(g1) && j == len... | go | func intersectNormal(g1, g2 Glob) bool {
var i, j int
for i, j = 0, 0; i < len(g1) && j < len(g2); i, j = i+1, j+1 {
if g1[i].Flag() == FlagNone && g2[j].Flag() == FlagNone {
if !Match(g1[i], g2[j]) {
return false
}
} else {
return intersectSpecial(g1[i:], g2[j:])
}
}
if i == len(g1) && j == len... | [
"func",
"intersectNormal",
"(",
"g1",
",",
"g2",
"Glob",
")",
"bool",
"{",
"var",
"i",
",",
"j",
"int",
"\n",
"for",
"i",
",",
"j",
"=",
"0",
",",
"0",
";",
"i",
"<",
"len",
"(",
"g1",
")",
"&&",
"j",
"<",
"len",
"(",
"g2",
")",
";",
"i",... | // All uses of `intersection exists` below mean that the intersection of the globs matches a non-empty set of non-empty strings.
// intersectNormal accepts two globs and returns a boolean describing whether their intersection exists.
// It traverses g1, g2 while ensuring that their Tokens match.
// If a flagged Token i... | [
"All",
"uses",
"of",
"intersection",
"exists",
"below",
"mean",
"that",
"the",
"intersection",
"of",
"the",
"globs",
"matches",
"a",
"non",
"-",
"empty",
"set",
"of",
"non",
"-",
"empty",
"strings",
".",
"intersectNormal",
"accepts",
"two",
"globs",
"and",
... | 5c77d914dd0ba7bedca923f97232d37137e038f3 | https://github.com/yashtewari/glob-intersection/blob/5c77d914dd0ba7bedca923f97232d37137e038f3/non_empty.go#L61-L78 |
147,776 | yashtewari/glob-intersection | non_empty.go | intersectSpecial | func intersectSpecial(g1, g2 Glob) bool {
if g1[0].Flag() != FlagNone { // If g1 starts with a Token having a Flag.
switch g1[0].Flag() {
case FlagPlus:
return intersectPlus(g1, g2)
case FlagStar:
return intersectStar(g1, g2)
}
} else { // If g2 starts with a Token having a Flag.
switch g2[0].Flag() {... | go | func intersectSpecial(g1, g2 Glob) bool {
if g1[0].Flag() != FlagNone { // If g1 starts with a Token having a Flag.
switch g1[0].Flag() {
case FlagPlus:
return intersectPlus(g1, g2)
case FlagStar:
return intersectStar(g1, g2)
}
} else { // If g2 starts with a Token having a Flag.
switch g2[0].Flag() {... | [
"func",
"intersectSpecial",
"(",
"g1",
",",
"g2",
"Glob",
")",
"bool",
"{",
"if",
"g1",
"[",
"0",
"]",
".",
"Flag",
"(",
")",
"!=",
"FlagNone",
"{",
"// If g1 starts with a Token having a Flag.",
"switch",
"g1",
"[",
"0",
"]",
".",
"Flag",
"(",
")",
"{... | // intersectSpecial accepts two globs such that at least one starts with a flagged Token.
// It returns a boolean describing whether their intersection exists.
// It hands flow of control to intersectPlus or intersectStar correctly. | [
"intersectSpecial",
"accepts",
"two",
"globs",
"such",
"that",
"at",
"least",
"one",
"starts",
"with",
"a",
"flagged",
"Token",
".",
"It",
"returns",
"a",
"boolean",
"describing",
"whether",
"their",
"intersection",
"exists",
".",
"It",
"hands",
"flow",
"of",
... | 5c77d914dd0ba7bedca923f97232d37137e038f3 | https://github.com/yashtewari/glob-intersection/blob/5c77d914dd0ba7bedca923f97232d37137e038f3/non_empty.go#L83-L101 |
147,777 | yashtewari/glob-intersection | glob.go | NewGlob | func NewGlob(input string) (Glob, error) {
tokens, err := Tokenize([]rune(input))
if err != nil {
return nil, err
}
tokens = Simplify(tokens)
return Glob(tokens), nil
} | go | func NewGlob(input string) (Glob, error) {
tokens, err := Tokenize([]rune(input))
if err != nil {
return nil, err
}
tokens = Simplify(tokens)
return Glob(tokens), nil
} | [
"func",
"NewGlob",
"(",
"input",
"string",
")",
"(",
"Glob",
",",
"error",
")",
"{",
"tokens",
",",
"err",
":=",
"Tokenize",
"(",
"[",
"]",
"rune",
"(",
"input",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
... | // NewGlob constructs a Glob from the given string by tokenizing and then simplifying it, or reports errors if any. | [
"NewGlob",
"constructs",
"a",
"Glob",
"from",
"the",
"given",
"string",
"by",
"tokenizing",
"and",
"then",
"simplifying",
"it",
"or",
"reports",
"errors",
"if",
"any",
"."
] | 5c77d914dd0ba7bedca923f97232d37137e038f3 | https://github.com/yashtewari/glob-intersection/blob/5c77d914dd0ba7bedca923f97232d37137e038f3/glob.go#L13-L22 |
147,778 | yashtewari/glob-intersection | tokenize.go | Tokenize | func Tokenize(input []rune) ([]Token, error) {
tokens := []Token{}
for i, t, err := nextToken(0, input); err != errEndOfInput; i, t, err = nextToken(i, input) {
if err != nil {
return nil, err
}
tokens = append(tokens, t)
}
return tokens, nil
} | go | func Tokenize(input []rune) ([]Token, error) {
tokens := []Token{}
for i, t, err := nextToken(0, input); err != errEndOfInput; i, t, err = nextToken(i, input) {
if err != nil {
return nil, err
}
tokens = append(tokens, t)
}
return tokens, nil
} | [
"func",
"Tokenize",
"(",
"input",
"[",
"]",
"rune",
")",
"(",
"[",
"]",
"Token",
",",
"error",
")",
"{",
"tokens",
":=",
"[",
"]",
"Token",
"{",
"}",
"\n",
"for",
"i",
",",
"t",
",",
"err",
":=",
"nextToken",
"(",
"0",
",",
"input",
")",
";",... | // Tokenize converts a rune slice into a Token slice. | [
"Tokenize",
"converts",
"a",
"rune",
"slice",
"into",
"a",
"Token",
"slice",
"."
] | 5c77d914dd0ba7bedca923f97232d37137e038f3 | https://github.com/yashtewari/glob-intersection/blob/5c77d914dd0ba7bedca923f97232d37137e038f3/tokenize.go#L37-L48 |
147,779 | yashtewari/glob-intersection | tokenize.go | nextToken | func nextToken(index int, input []rune) (newIndex int, token Token, err error) {
var r rune
var escaped bool
newIndex, r, escaped, err = nextRune(index, input)
if err != nil {
return
}
if !escaped {
if ttype, ok := tokenTypeRunes[r]; ok {
switch ttype {
case TTDot:
token = NewDot()
case TTSet:... | go | func nextToken(index int, input []rune) (newIndex int, token Token, err error) {
var r rune
var escaped bool
newIndex, r, escaped, err = nextRune(index, input)
if err != nil {
return
}
if !escaped {
if ttype, ok := tokenTypeRunes[r]; ok {
switch ttype {
case TTDot:
token = NewDot()
case TTSet:... | [
"func",
"nextToken",
"(",
"index",
"int",
",",
"input",
"[",
"]",
"rune",
")",
"(",
"newIndex",
"int",
",",
"token",
"Token",
",",
"err",
"error",
")",
"{",
"var",
"r",
"rune",
"\n",
"var",
"escaped",
"bool",
"\n\n",
"newIndex",
",",
"r",
",",
"esc... | // nextToken yields the Token starting at the given index of input, and newIndex at which the next Token should start. | [
"nextToken",
"yields",
"the",
"Token",
"starting",
"at",
"the",
"given",
"index",
"of",
"input",
"and",
"newIndex",
"at",
"which",
"the",
"next",
"Token",
"should",
"start",
"."
] | 5c77d914dd0ba7bedca923f97232d37137e038f3 | https://github.com/yashtewari/glob-intersection/blob/5c77d914dd0ba7bedca923f97232d37137e038f3/tokenize.go#L51-L108 |
147,780 | yashtewari/glob-intersection | tokenize.go | nextFlag | func nextFlag(index int, input []rune) (newIndex int, f Flag, err error) {
var escaped, ok bool
var r rune
f = FlagNone
newIndex, r, escaped, err = nextRune(index, input)
if err != nil {
return
}
if !escaped {
// Revert back to index for later consumption.
if f, ok = flagRunes[r]; !ok {
newIndex = in... | go | func nextFlag(index int, input []rune) (newIndex int, f Flag, err error) {
var escaped, ok bool
var r rune
f = FlagNone
newIndex, r, escaped, err = nextRune(index, input)
if err != nil {
return
}
if !escaped {
// Revert back to index for later consumption.
if f, ok = flagRunes[r]; !ok {
newIndex = in... | [
"func",
"nextFlag",
"(",
"index",
"int",
",",
"input",
"[",
"]",
"rune",
")",
"(",
"newIndex",
"int",
",",
"f",
"Flag",
",",
"err",
"error",
")",
"{",
"var",
"escaped",
",",
"ok",
"bool",
"\n",
"var",
"r",
"rune",
"\n\n",
"f",
"=",
"FlagNone",
"\... | // nextFlag yields the Flag starting at the given index of input, if any.
// The next Token should start at newIndex. | [
"nextFlag",
"yields",
"the",
"Flag",
"starting",
"at",
"the",
"given",
"index",
"of",
"input",
"if",
"any",
".",
"The",
"next",
"Token",
"should",
"start",
"at",
"newIndex",
"."
] | 5c77d914dd0ba7bedca923f97232d37137e038f3 | https://github.com/yashtewari/glob-intersection/blob/5c77d914dd0ba7bedca923f97232d37137e038f3/tokenize.go#L196-L218 |
147,781 | yashtewari/glob-intersection | tokenize.go | invalidInputMessage | func invalidInputMessage(input []rune, index int, message string, args ...interface{}) string {
return fmt.Sprintf("input:%s, pos:%d, %s", string(input), index, fmt.Sprintf(message, args...))
} | go | func invalidInputMessage(input []rune, index int, message string, args ...interface{}) string {
return fmt.Sprintf("input:%s, pos:%d, %s", string(input), index, fmt.Sprintf(message, args...))
} | [
"func",
"invalidInputMessage",
"(",
"input",
"[",
"]",
"rune",
",",
"index",
"int",
",",
"message",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"string",
"(",
"input",
... | // invalidInputMessage wraps the message describing invalid input with the input itself and index at which it is invalid. | [
"invalidInputMessage",
"wraps",
"the",
"message",
"describing",
"invalid",
"input",
"with",
"the",
"input",
"itself",
"and",
"index",
"at",
"which",
"it",
"is",
"invalid",
"."
] | 5c77d914dd0ba7bedca923f97232d37137e038f3 | https://github.com/yashtewari/glob-intersection/blob/5c77d914dd0ba7bedca923f97232d37137e038f3/tokenize.go#L249-L251 |
147,782 | crossdock/crossdock-go | combinations.go | Combinations | func Combinations(axes map[string][]string) []map[string]string {
// sort the names to get deterministic ordering
names := make([]string, 0, len(axes))
for name := range axes {
names = append(names, name)
}
sort.Strings(names)
var xs []axis
for _, name := range names {
xs = append(xs, axis{name, axes[name]}... | go | func Combinations(axes map[string][]string) []map[string]string {
// sort the names to get deterministic ordering
names := make([]string, 0, len(axes))
for name := range axes {
names = append(names, name)
}
sort.Strings(names)
var xs []axis
for _, name := range names {
xs = append(xs, axis{name, axes[name]}... | [
"func",
"Combinations",
"(",
"axes",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"[",
"]",
"map",
"[",
"string",
"]",
"string",
"{",
"// sort the names to get deterministic ordering",
"names",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
... | // Combinations takes a map from axis name to list of values for that axis and
// returns a collection of entries which contain all combinations of each axis
// value with every other axis' values. | [
"Combinations",
"takes",
"a",
"map",
"from",
"axis",
"name",
"to",
"list",
"of",
"values",
"for",
"that",
"axis",
"and",
"returns",
"a",
"collection",
"of",
"entries",
"which",
"contain",
"all",
"combinations",
"of",
"each",
"axis",
"value",
"with",
"every",... | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/combinations.go#L28-L41 |
147,783 | crossdock/crossdock-go | t.go | Skipf | func (t *entryT) Skipf(format string, args ...interface{}) {
t.Put(Skipped, fmt.Sprintf(format, args...))
} | go | func (t *entryT) Skipf(format string, args ...interface{}) {
t.Put(Skipped, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"t",
"*",
"entryT",
")",
"Skipf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"t",
".",
"Put",
"(",
"Skipped",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}"
] | // Skipf records a skipped test.
//
// This may be called multiple times if multiple tests inside a behavior were
// skipped. | [
"Skipf",
"records",
"a",
"skipped",
"test",
".",
"This",
"may",
"be",
"called",
"multiple",
"times",
"if",
"multiple",
"tests",
"inside",
"a",
"behavior",
"were",
"skipped",
"."
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/t.go#L121-L123 |
147,784 | crossdock/crossdock-go | t.go | Errorf | func (t *entryT) Errorf(format string, args ...interface{}) {
t.Put(Failed, fmt.Sprintf(format, args...))
} | go | func (t *entryT) Errorf(format string, args ...interface{}) {
t.Put(Failed, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"t",
"*",
"entryT",
")",
"Errorf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"t",
".",
"Put",
"(",
"Failed",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}"
] | // Errorf records a failed test.
//
// This may be called multiple times if multiple tests inside a behavior
// failed. | [
"Errorf",
"records",
"a",
"failed",
"test",
".",
"This",
"may",
"be",
"called",
"multiple",
"times",
"if",
"multiple",
"tests",
"inside",
"a",
"behavior",
"failed",
"."
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/t.go#L129-L131 |
147,785 | crossdock/crossdock-go | t.go | Successf | func (t *entryT) Successf(format string, args ...interface{}) {
t.Put(Passed, fmt.Sprintf(format, args...))
} | go | func (t *entryT) Successf(format string, args ...interface{}) {
t.Put(Passed, fmt.Sprintf(format, args...))
} | [
"func",
"(",
"t",
"*",
"entryT",
")",
"Successf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"t",
".",
"Put",
"(",
"Passed",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}"
] | // Successf records a successful test.
//
// This may be called multiple times for multiple successful tests inside a
// behavior. | [
"Successf",
"records",
"a",
"successful",
"test",
".",
"This",
"may",
"be",
"called",
"multiple",
"times",
"for",
"multiple",
"successful",
"tests",
"inside",
"a",
"behavior",
"."
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/t.go#L137-L139 |
147,786 | crossdock/crossdock-go | t.go | Fatalf | func (t *entryT) Fatalf(format string, args ...interface{}) {
t.Errorf(format, args...)
t.FailNow()
} | go | func (t *entryT) Fatalf(format string, args ...interface{}) {
t.Errorf(format, args...)
t.FailNow()
} | [
"func",
"(",
"t",
"*",
"entryT",
")",
"Fatalf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"t",
".",
"Errorf",
"(",
"format",
",",
"args",
"...",
")",
"\n",
"t",
".",
"FailNow",
"(",
")",
"\n",
"}"
] | // Fatalf records a failed test and fails immediately | [
"Fatalf",
"records",
"a",
"failed",
"test",
"and",
"fails",
"immediately"
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/t.go#L142-L145 |
147,787 | crossdock/crossdock-go | entry.go | Status | func (e Entry) Status() Status {
switch v := e[statusKey].(type) {
case string:
return Status(v)
case Status:
return v
default:
panic(fmt.Sprintf("invalid status: %v", v))
}
} | go | func (e Entry) Status() Status {
switch v := e[statusKey].(type) {
case string:
return Status(v)
case Status:
return v
default:
panic(fmt.Sprintf("invalid status: %v", v))
}
} | [
"func",
"(",
"e",
"Entry",
")",
"Status",
"(",
")",
"Status",
"{",
"switch",
"v",
":=",
"e",
"[",
"statusKey",
"]",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"return",
"Status",
"(",
"v",
")",
"\n",
"case",
"Status",
":",
"return",
"v",
... | // Status returns the Status stored in the Entry. | [
"Status",
"returns",
"the",
"Status",
"stored",
"in",
"the",
"Entry",
"."
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/entry.go#L44-L53 |
147,788 | crossdock/crossdock-go | entry.go | Output | func (e Entry) Output() string {
s, ok := e[outputKey].(string)
if ok {
return s
}
return ""
} | go | func (e Entry) Output() string {
s, ok := e[outputKey].(string)
if ok {
return s
}
return ""
} | [
"func",
"(",
"e",
"Entry",
")",
"Output",
"(",
")",
"string",
"{",
"s",
",",
"ok",
":=",
"e",
"[",
"outputKey",
"]",
".",
"(",
"string",
")",
"\n",
"if",
"ok",
"{",
"return",
"s",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // Output returns the output attached to the entry. | [
"Output",
"returns",
"the",
"output",
"attached",
"to",
"the",
"entry",
"."
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/entry.go#L56-L62 |
147,789 | crossdock/crossdock-go | client.go | Handler | func Handler(behaviors Behaviors, failOnUnknown bool) http.Handler {
return requestHandler{behaviors: behaviors, failOnUnknown: failOnUnknown}
} | go | func Handler(behaviors Behaviors, failOnUnknown bool) http.Handler {
return requestHandler{behaviors: behaviors, failOnUnknown: failOnUnknown}
} | [
"func",
"Handler",
"(",
"behaviors",
"Behaviors",
",",
"failOnUnknown",
"bool",
")",
"http",
".",
"Handler",
"{",
"return",
"requestHandler",
"{",
"behaviors",
":",
"behaviors",
",",
"failOnUnknown",
":",
"failOnUnknown",
"}",
"\n",
"}"
] | // Handler returns an http.Handler that dispatches to functions defined in behaviors map.
// If failOnUnknown is true, a behavior that is not in the behaviors map will cause the
// handler to return an error status. Otherwise, the handler returns skipped status. | [
"Handler",
"returns",
"an",
"http",
".",
"Handler",
"that",
"dispatches",
"to",
"functions",
"defined",
"in",
"behaviors",
"map",
".",
"If",
"failOnUnknown",
"is",
"true",
"a",
"behavior",
"that",
"is",
"not",
"in",
"the",
"behaviors",
"map",
"will",
"cause"... | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/client.go#L48-L50 |
147,790 | crossdock/crossdock-go | client.go | extractParams | func extractParams(p url.Values) Params {
params := Params{}
for k, l := range p {
for _, v := range l {
params[k] = v
}
}
return params
} | go | func extractParams(p url.Values) Params {
params := Params{}
for k, l := range p {
for _, v := range l {
params[k] = v
}
}
return params
} | [
"func",
"extractParams",
"(",
"p",
"url",
".",
"Values",
")",
"Params",
"{",
"params",
":=",
"Params",
"{",
"}",
"\n",
"for",
"k",
",",
"l",
":=",
"range",
"p",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"l",
"{",
"params",
"[",
"k",
"]",
"=",
... | // extractParams returns a map of params from url values | [
"extractParams",
"returns",
"a",
"map",
"of",
"params",
"from",
"url",
"values"
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/client.go#L83-L91 |
147,791 | crossdock/crossdock-go | run.go | Run | func Run(params Params, f func(T)) []Entry {
behavior := params[BehaviorParam]
delete(params, BehaviorParam)
t := entryT{
params: params,
behavior: behavior,
}
done := make(chan struct{})
// We run the function inside a goroutine so that Fatalf can simply call
// runtime.Goexit to stop execution.
go fun... | go | func Run(params Params, f func(T)) []Entry {
behavior := params[BehaviorParam]
delete(params, BehaviorParam)
t := entryT{
params: params,
behavior: behavior,
}
done := make(chan struct{})
// We run the function inside a goroutine so that Fatalf can simply call
// runtime.Goexit to stop execution.
go fun... | [
"func",
"Run",
"(",
"params",
"Params",
",",
"f",
"func",
"(",
"T",
")",
")",
"[",
"]",
"Entry",
"{",
"behavior",
":=",
"params",
"[",
"BehaviorParam",
"]",
"\n",
"delete",
"(",
"params",
",",
"BehaviorParam",
")",
"\n",
"t",
":=",
"entryT",
"{",
"... | // Run the given function inside a behavior context and return the entries
// logged by it.
//
// Functions like Fatalf won't work if the behavior is not executed inside a
// Run context. | [
"Run",
"the",
"given",
"function",
"inside",
"a",
"behavior",
"context",
"and",
"return",
"the",
"entries",
"logged",
"by",
"it",
".",
"Functions",
"like",
"Fatalf",
"won",
"t",
"work",
"if",
"the",
"behavior",
"is",
"not",
"executed",
"inside",
"a",
"Run"... | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/run.go#L33-L76 |
147,792 | crossdock/crossdock-go | assert/assertions.go | getWhitespaceString | func getWhitespaceString() string {
_, file, line, ok := runtime.Caller(1)
if !ok {
return ""
}
parts := strings.Split(file, "/")
file = parts[len(parts)-1]
return strings.Repeat(" ", len(fmt.Sprintf("%s:%d: ", file, line)))
} | go | func getWhitespaceString() string {
_, file, line, ok := runtime.Caller(1)
if !ok {
return ""
}
parts := strings.Split(file, "/")
file = parts[len(parts)-1]
return strings.Repeat(" ", len(fmt.Sprintf("%s:%d: ", file, line)))
} | [
"func",
"getWhitespaceString",
"(",
")",
"string",
"{",
"_",
",",
"file",
",",
"line",
",",
"ok",
":=",
"runtime",
".",
"Caller",
"(",
"1",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"parts",
":=",
"strings",
".",
"Sp... | // getWhitespaceString returns a string that is long enough to overwrite the default
// output from the go testing framework. | [
"getWhitespaceString",
"returns",
"a",
"string",
"that",
"is",
"long",
"enough",
"to",
"overwrite",
"the",
"default",
"output",
"from",
"the",
"go",
"testing",
"framework",
"."
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/assert/assertions.go#L200-L211 |
147,793 | crossdock/crossdock-go | assert/assertions.go | InEpsilonSlice | func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
if expected == nil || actual == nil ||
reflect.TypeOf(actual).Kind() != reflect.Slice ||
reflect.TypeOf(expected).Kind() != reflect.Slice {
return Fail(t, fmt.Sprintf("Parameters must be slice"), msgA... | go | func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
if expected == nil || actual == nil ||
reflect.TypeOf(actual).Kind() != reflect.Slice ||
reflect.TypeOf(expected).Kind() != reflect.Slice {
return Fail(t, fmt.Sprintf("Parameters must be slice"), msgA... | [
"func",
"InEpsilonSlice",
"(",
"t",
"TestingT",
",",
"expected",
",",
"actual",
"interface",
"{",
"}",
",",
"epsilon",
"float64",
",",
"msgAndArgs",
"...",
"interface",
"{",
"}",
")",
"bool",
"{",
"if",
"expected",
"==",
"nil",
"||",
"actual",
"==",
"nil... | // InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. | [
"InEpsilonSlice",
"is",
"the",
"same",
"as",
"InEpsilon",
"except",
"it",
"compares",
"each",
"value",
"from",
"two",
"slices",
"."
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/assert/assertions.go#L867-L885 |
147,794 | crossdock/crossdock-go | assert/assertions.go | diff | func diff(expected interface{}, actual interface{}) string {
if expected == nil || actual == nil {
return ""
}
et, ek := typeAndKind(expected)
at, _ := typeAndKind(actual)
if et != at {
return ""
}
if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array {
return ""
}
... | go | func diff(expected interface{}, actual interface{}) string {
if expected == nil || actual == nil {
return ""
}
et, ek := typeAndKind(expected)
at, _ := typeAndKind(actual)
if et != at {
return ""
}
if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array {
return ""
}
... | [
"func",
"diff",
"(",
"expected",
"interface",
"{",
"}",
",",
"actual",
"interface",
"{",
"}",
")",
"string",
"{",
"if",
"expected",
"==",
"nil",
"||",
"actual",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"et",
",",
"ek",
":=",
"type... | // diff returns a diff of both values as long as both are of the same type and
// are a struct, map, slice or array. Otherwise it returns an empty string. | [
"diff",
"returns",
"a",
"diff",
"of",
"both",
"values",
"as",
"long",
"as",
"both",
"are",
"of",
"the",
"same",
"type",
"and",
"are",
"a",
"struct",
"map",
"slice",
"or",
"array",
".",
"Otherwise",
"it",
"returns",
"an",
"empty",
"string",
"."
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/assert/assertions.go#L1041-L1072 |
147,795 | crossdock/crossdock-go | call.go | Call | func Call(t *testing.T, clientURL string, behavior string, args url.Values) {
args.Set("behavior", behavior)
u, err := url.Parse(clientURL)
require.NoError(t, err, "failed to parse URL")
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
u.RawQuery = args.Encode()
log.Printl... | go | func Call(t *testing.T, clientURL string, behavior string, args url.Values) {
args.Set("behavior", behavior)
u, err := url.Parse(clientURL)
require.NoError(t, err, "failed to parse URL")
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
u.RawQuery = args.Encode()
log.Printl... | [
"func",
"Call",
"(",
"t",
"*",
"testing",
".",
"T",
",",
"clientURL",
"string",
",",
"behavior",
"string",
",",
"args",
"url",
".",
"Values",
")",
"{",
"args",
".",
"Set",
"(",
"\"",
"\"",
",",
"behavior",
")",
"\n",
"u",
",",
"err",
":=",
"url",... | // Call makes a GET request to the client | [
"Call",
"makes",
"a",
"GET",
"request",
"to",
"the",
"client"
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/call.go#L36-L65 |
147,796 | crossdock/crossdock-go | wait.go | Wait | func Wait(t *testing.T, url string, attempts int) {
ctx := context.Background()
for a := 0; a < attempts; a++ {
ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
log.Println("HEAD", url)
_, err := ctxhttp.Head(ctx, nil, url)
if err == nil {
log.Println("Client is ready, beginning test... | go | func Wait(t *testing.T, url string, attempts int) {
ctx := context.Background()
for a := 0; a < attempts; a++ {
ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
log.Println("HEAD", url)
_, err := ctxhttp.Head(ctx, nil, url)
if err == nil {
log.Println("Client is ready, beginning test... | [
"func",
"Wait",
"(",
"t",
"*",
"testing",
".",
"T",
",",
"url",
"string",
",",
"attempts",
"int",
")",
"{",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n\n",
"for",
"a",
":=",
"0",
";",
"a",
"<",
"attempts",
";",
"a",
"++",
"{",
"ctx... | // Wait sends attempts HEAD requests to url | [
"Wait",
"sends",
"attempts",
"HEAD",
"requests",
"to",
"url"
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/wait.go#L33-L53 |
147,797 | crossdock/crossdock-go | _codegen/main.go | analyzeCode | func analyzeCode(scope *types.Scope, docs *doc.Package) (imports.Importer, []testFunc, error) {
testingT := scope.Lookup("TestingT").Type().Underlying().(*types.Interface)
importer := imports.New(*outputPkg)
var funcs []testFunc
// Go through all the top level functions
for _, fdocs := range docs.Funcs {
// Fin... | go | func analyzeCode(scope *types.Scope, docs *doc.Package) (imports.Importer, []testFunc, error) {
testingT := scope.Lookup("TestingT").Type().Underlying().(*types.Interface)
importer := imports.New(*outputPkg)
var funcs []testFunc
// Go through all the top level functions
for _, fdocs := range docs.Funcs {
// Fin... | [
"func",
"analyzeCode",
"(",
"scope",
"*",
"types",
".",
"Scope",
",",
"docs",
"*",
"doc",
".",
"Package",
")",
"(",
"imports",
".",
"Importer",
",",
"[",
"]",
"testFunc",
",",
"error",
")",
"{",
"testingT",
":=",
"scope",
".",
"Lookup",
"(",
"\"",
... | // analyzeCode takes the types scope and the docs and returns the import
// information and information about all the assertion functions. | [
"analyzeCode",
"takes",
"the",
"types",
"scope",
"and",
"the",
"docs",
"and",
"returns",
"the",
"import",
"information",
"and",
"information",
"about",
"all",
"the",
"assertion",
"functions",
"."
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/_codegen/main.go#L145-L181 |
147,798 | crossdock/crossdock-go | assert/http_assertions.go | httpCode | func httpCode(handler http.HandlerFunc, method, url string, values url.Values) int {
w := httptest.NewRecorder()
req, err := http.NewRequest(method, url+"?"+values.Encode(), nil)
if err != nil {
return -1
}
handler(w, req)
return w.Code
} | go | func httpCode(handler http.HandlerFunc, method, url string, values url.Values) int {
w := httptest.NewRecorder()
req, err := http.NewRequest(method, url+"?"+values.Encode(), nil)
if err != nil {
return -1
}
handler(w, req)
return w.Code
} | [
"func",
"httpCode",
"(",
"handler",
"http",
".",
"HandlerFunc",
",",
"method",
",",
"url",
"string",
",",
"values",
"url",
".",
"Values",
")",
"int",
"{",
"w",
":=",
"httptest",
".",
"NewRecorder",
"(",
")",
"\n",
"req",
",",
"err",
":=",
"http",
"."... | // httpCode is a helper that returns HTTP code of the response. It returns -1
// if building a new request fails. | [
"httpCode",
"is",
"a",
"helper",
"that",
"returns",
"HTTP",
"code",
"of",
"the",
"response",
".",
"It",
"returns",
"-",
"1",
"if",
"building",
"a",
"new",
"request",
"fails",
"."
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/assert/http_assertions.go#L36-L44 |
147,799 | crossdock/crossdock-go | assert/assertion_forward.go | NotZero | func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
return NotZero(a.t, i, msgAndArgs...)
} | go | func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
return NotZero(a.t, i, msgAndArgs...)
} | [
"func",
"(",
"a",
"*",
"Assertions",
")",
"NotZero",
"(",
"i",
"interface",
"{",
"}",
",",
"msgAndArgs",
"...",
"interface",
"{",
"}",
")",
"bool",
"{",
"return",
"NotZero",
"(",
"a",
".",
"t",
",",
"i",
",",
"msgAndArgs",
"...",
")",
"\n",
"}"
] | // NotZero asserts that i is not the zero value for its type and returns the truth. | [
"NotZero",
"asserts",
"that",
"i",
"is",
"not",
"the",
"zero",
"value",
"for",
"its",
"type",
"and",
"returns",
"the",
"truth",
"."
] | 049aabb0122b03bc9bd30cab8f3f91fb60166361 | https://github.com/crossdock/crossdock-go/blob/049aabb0122b03bc9bd30cab8f3f91fb60166361/assert/assertion_forward.go#L336-L338 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.