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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
145,200 | tj/go-elastic | elastic.go | Aliases | func (c *Client) Aliases() (v aliases.Indexes, err error) {
err = c.Request("GET", "/_aliases", nil, &v)
return
} | go | func (c *Client) Aliases() (v aliases.Indexes, err error) {
err = c.Request("GET", "/_aliases", nil, &v)
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Aliases",
"(",
")",
"(",
"v",
"aliases",
".",
"Indexes",
",",
"err",
"error",
")",
"{",
"err",
"=",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"&",
"v",
")",
"\n",
"return",
... | // Aliases returns indexes and their aliases. | [
"Aliases",
"returns",
"indexes",
"and",
"their",
"aliases",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/elastic.go#L111-L114 |
145,201 | tj/go-elastic | elastic.go | SearchIndex | func (c *Client) SearchIndex(index string, query interface{}, v interface{}) error {
b, err := json.Marshal(query)
if err != nil {
return err
}
return c.Request("POST", fmt.Sprintf("/%s/_search", index), bytes.NewReader(b), v)
} | go | func (c *Client) SearchIndex(index string, query interface{}, v interface{}) error {
b, err := json.Marshal(query)
if err != nil {
return err
}
return c.Request("POST", fmt.Sprintf("/%s/_search", index), bytes.NewReader(b), v)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SearchIndex",
"(",
"index",
"string",
",",
"query",
"interface",
"{",
"}",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"query",
")",
"\n",
"if",
"e... | // SearchIndex queries `index` and stores the results of `query` in `v`. | [
"SearchIndex",
"queries",
"index",
"and",
"stores",
"the",
"results",
"of",
"query",
"in",
"v",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/elastic.go#L155-L162 |
145,202 | tj/go-elastic | elastic.go | SearchIndexString | func (c *Client) SearchIndexString(index, query string, v interface{}) error {
return c.Request("POST", fmt.Sprintf("/%s/_search", index), strings.NewReader(query), v)
} | go | func (c *Client) SearchIndexString(index, query string, v interface{}) error {
return c.Request("POST", fmt.Sprintf("/%s/_search", index), strings.NewReader(query), v)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SearchIndexString",
"(",
"index",
",",
"query",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
... | // SearchIndexString queries `index` and stores the results of `query` in `v`. | [
"SearchIndexString",
"queries",
"index",
"and",
"stores",
"the",
"results",
"of",
"query",
"in",
"v",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/elastic.go#L165-L167 |
145,203 | tj/go-elastic | elastic.go | SearchIndexTemplate | func (c *Client) SearchIndexTemplate(index, tmpl string, data interface{}, v interface{}) error {
var buf bytes.Buffer
t, err := template.New("main").Parse(tmpl)
if err != nil {
return err
}
if err := t.Execute(&buf, data); err != nil {
return err
}
return c.SearchIndexString(index, buf.String(), v)
} | go | func (c *Client) SearchIndexTemplate(index, tmpl string, data interface{}, v interface{}) error {
var buf bytes.Buffer
t, err := template.New("main").Parse(tmpl)
if err != nil {
return err
}
if err := t.Execute(&buf, data); err != nil {
return err
}
return c.SearchIndexString(index, buf.String(), v)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SearchIndexTemplate",
"(",
"index",
",",
"tmpl",
"string",
",",
"data",
"interface",
"{",
"}",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n\n",
"t",
",",
"err",
... | // SearchIndexTemplate queries `index` with `tmpl` string and stores the results in `v`. | [
"SearchIndexTemplate",
"queries",
"index",
"with",
"tmpl",
"string",
"and",
"stores",
"the",
"results",
"in",
"v",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/elastic.go#L170-L183 |
145,204 | tj/go-elastic | elastic.go | Request | func (c *Client) Request(method, path string, body io.Reader, v interface{}) error {
req, err := http.NewRequest(method, c.URL+path, body)
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
if c.authCredentials != nil {
credentials := fmt.Sprintf("%s:%s", c.authCredentials.userna... | go | func (c *Client) Request(method, path string, body io.Reader, v interface{}) error {
req, err := http.NewRequest(method, c.URL+path, body)
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
if c.authCredentials != nil {
credentials := fmt.Sprintf("%s:%s", c.authCredentials.userna... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Request",
"(",
"method",
",",
"path",
"string",
",",
"body",
"io",
".",
"Reader",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"method",
",",
"... | // Request performs a request against `url` storing the results as `v` when non-nil. | [
"Request",
"performs",
"a",
"request",
"against",
"url",
"storing",
"the",
"results",
"as",
"v",
"when",
"non",
"-",
"nil",
"."
] | 36157cbbebc210c55c1c8a82c8655ccbb9f41aa0 | https://github.com/tj/go-elastic/blob/36157cbbebc210c55c1c8a82c8655ccbb9f41aa0/elastic.go#L196-L235 |
145,205 | approvals/go-approval-tests | reporters/diff_reporter.go | NewDiffReporter | func NewDiffReporter() *Reporter {
tmp := NewFirstWorkingReporter(
NewBeyondCompareReporter(),
NewIntelliJReporter(),
NewFileMergeReporter(),
NewVSCodeReporter(),
NewGoGlandReporter(),
NewPrintSupportedDiffProgramsReporter(),
NewQuietReporter(),
)
return &tmp
} | go | func NewDiffReporter() *Reporter {
tmp := NewFirstWorkingReporter(
NewBeyondCompareReporter(),
NewIntelliJReporter(),
NewFileMergeReporter(),
NewVSCodeReporter(),
NewGoGlandReporter(),
NewPrintSupportedDiffProgramsReporter(),
NewQuietReporter(),
)
return &tmp
} | [
"func",
"NewDiffReporter",
"(",
")",
"*",
"Reporter",
"{",
"tmp",
":=",
"NewFirstWorkingReporter",
"(",
"NewBeyondCompareReporter",
"(",
")",
",",
"NewIntelliJReporter",
"(",
")",
",",
"NewFileMergeReporter",
"(",
")",
",",
"NewVSCodeReporter",
"(",
")",
",",
"N... | // NewDiffReporter creates the default diff reporter. | [
"NewDiffReporter",
"creates",
"the",
"default",
"diff",
"reporter",
"."
] | 6ae1ec6230a2f5eb200541972fb8510f71db4707 | https://github.com/approvals/go-approval-tests/blob/6ae1ec6230a2f5eb200541972fb8510f71db4707/reporters/diff_reporter.go#L19-L31 |
145,206 | approvals/go-approval-tests | utils/collection_utils.go | PrintMap | func PrintMap(m interface{}) string {
var outputText string
v := reflect.ValueOf(m)
if v.Kind() != reflect.Map {
outputText = fmt.Sprintf("error while printing map\nreceived a %T\n %s\n", m, m)
} else {
keys := v.MapKeys()
var xs []string
for _, k := range keys {
xs = append(xs, fmt.Sprintf("[%s]=%s"... | go | func PrintMap(m interface{}) string {
var outputText string
v := reflect.ValueOf(m)
if v.Kind() != reflect.Map {
outputText = fmt.Sprintf("error while printing map\nreceived a %T\n %s\n", m, m)
} else {
keys := v.MapKeys()
var xs []string
for _, k := range keys {
xs = append(xs, fmt.Sprintf("[%s]=%s"... | [
"func",
"PrintMap",
"(",
"m",
"interface",
"{",
"}",
")",
"string",
"{",
"var",
"outputText",
"string",
"\n\n",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"m",
")",
"\n",
"if",
"v",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Map",
"{",
"outputTe... | // PrintMap prints a map | [
"PrintMap",
"prints",
"a",
"map"
] | 6ae1ec6230a2f5eb200541972fb8510f71db4707 | https://github.com/approvals/go-approval-tests/blob/6ae1ec6230a2f5eb200541972fb8510f71db4707/utils/collection_utils.go#L11-L35 |
145,207 | approvals/go-approval-tests | utils/collection_utils.go | PrintArray | func PrintArray(m interface{}) string {
var outputText string
switch reflect.TypeOf(m).Kind() {
case reflect.Slice:
var xs []string
slice := reflect.ValueOf(m)
for i := 0; i < slice.Len(); i++ {
xs = append(xs, fmt.Sprintf("[%d]=%s", i, slice.Index(i)))
}
if len(xs) == 0 {
outputText = "len(array)... | go | func PrintArray(m interface{}) string {
var outputText string
switch reflect.TypeOf(m).Kind() {
case reflect.Slice:
var xs []string
slice := reflect.ValueOf(m)
for i := 0; i < slice.Len(); i++ {
xs = append(xs, fmt.Sprintf("[%d]=%s", i, slice.Index(i)))
}
if len(xs) == 0 {
outputText = "len(array)... | [
"func",
"PrintArray",
"(",
"m",
"interface",
"{",
"}",
")",
"string",
"{",
"var",
"outputText",
"string",
"\n\n",
"switch",
"reflect",
".",
"TypeOf",
"(",
"m",
")",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Slice",
":",
"var",
"xs",
"[",
... | // PrintArray prints an array | [
"PrintArray",
"prints",
"an",
"array"
] | 6ae1ec6230a2f5eb200541972fb8510f71db4707 | https://github.com/approvals/go-approval-tests/blob/6ae1ec6230a2f5eb200541972fb8510f71db4707/utils/collection_utils.go#L38-L60 |
145,208 | approvals/go-approval-tests | utils/collection_utils.go | MapToString | func MapToString(collection interface{}, transform func(x interface{}) string) []string {
switch reflect.TypeOf(collection).Kind() {
case reflect.Slice:
var xs []string
slice := reflect.ValueOf(collection)
for i := 0; i < slice.Len(); i++ {
xs = append(xs, transform(slice.Index(i).Interface()))
}
retur... | go | func MapToString(collection interface{}, transform func(x interface{}) string) []string {
switch reflect.TypeOf(collection).Kind() {
case reflect.Slice:
var xs []string
slice := reflect.ValueOf(collection)
for i := 0; i < slice.Len(); i++ {
xs = append(xs, transform(slice.Index(i).Interface()))
}
retur... | [
"func",
"MapToString",
"(",
"collection",
"interface",
"{",
"}",
",",
"transform",
"func",
"(",
"x",
"interface",
"{",
"}",
")",
"string",
")",
"[",
"]",
"string",
"{",
"switch",
"reflect",
".",
"TypeOf",
"(",
"collection",
")",
".",
"Kind",
"(",
")",
... | // MapToString maps a collection to a string collection | [
"MapToString",
"maps",
"a",
"collection",
"to",
"a",
"string",
"collection"
] | 6ae1ec6230a2f5eb200541972fb8510f71db4707 | https://github.com/approvals/go-approval-tests/blob/6ae1ec6230a2f5eb200541972fb8510f71db4707/utils/collection_utils.go#L63-L77 |
145,209 | approvals/go-approval-tests | utils/file_utils.go | DoesFileExist | func DoesFileExist(fileName string) bool {
_, err := os.Stat(fileName)
if os.IsNotExist(err) {
return false
}
return true
} | go | func DoesFileExist(fileName string) bool {
_, err := os.Stat(fileName)
if os.IsNotExist(err) {
return false
}
return true
} | [
"func",
"DoesFileExist",
"(",
"fileName",
"string",
")",
"bool",
"{",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"fileName",
")",
"\n",
"if",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"true",
"... | // DoesFileExist checks if a file exists. | [
"DoesFileExist",
"checks",
"if",
"a",
"file",
"exists",
"."
] | 6ae1ec6230a2f5eb200541972fb8510f71db4707 | https://github.com/approvals/go-approval-tests/blob/6ae1ec6230a2f5eb200541972fb8510f71db4707/utils/file_utils.go#L9-L15 |
145,210 | approvals/go-approval-tests | approvals.go | VerifyString | func VerifyString(t Failable, s string) error {
reader := strings.NewReader(s)
return Verify(t, reader)
} | go | func VerifyString(t Failable, s string) error {
reader := strings.NewReader(s)
return Verify(t, reader)
} | [
"func",
"VerifyString",
"(",
"t",
"Failable",
",",
"s",
"string",
")",
"error",
"{",
"reader",
":=",
"strings",
".",
"NewReader",
"(",
"s",
")",
"\n",
"return",
"Verify",
"(",
"t",
",",
"reader",
")",
"\n",
"}"
] | // VerifyString stores the passed string into the received file and confirms
// that it matches the approved local file. On failure, it will launch a reporter. | [
"VerifyString",
"stores",
"the",
"passed",
"string",
"into",
"the",
"received",
"file",
"and",
"confirms",
"that",
"it",
"matches",
"the",
"approved",
"local",
"file",
".",
"On",
"failure",
"it",
"will",
"launch",
"a",
"reporter",
"."
] | 6ae1ec6230a2f5eb200541972fb8510f71db4707 | https://github.com/approvals/go-approval-tests/blob/6ae1ec6230a2f5eb200541972fb8510f71db4707/approvals.go#L56-L59 |
145,211 | approvals/go-approval-tests | approvals.go | UseFrontLoadedReporter | func UseFrontLoadedReporter(reporter reporters.Reporter) io.Closer {
closer := &frontLoadedReporterCloser{
reporter: defaultFrontLoadedReporter,
}
defaultFrontLoadedReporter = &reporter
return closer
} | go | func UseFrontLoadedReporter(reporter reporters.Reporter) io.Closer {
closer := &frontLoadedReporterCloser{
reporter: defaultFrontLoadedReporter,
}
defaultFrontLoadedReporter = &reporter
return closer
} | [
"func",
"UseFrontLoadedReporter",
"(",
"reporter",
"reporters",
".",
"Reporter",
")",
"io",
".",
"Closer",
"{",
"closer",
":=",
"&",
"frontLoadedReporterCloser",
"{",
"reporter",
":",
"defaultFrontLoadedReporter",
",",
"}",
"\n\n",
"defaultFrontLoadedReporter",
"=",
... | // UseFrontLoadedReporter configures reporters ahead of all other reporters to
// handle situations like CI. These reporters usually prevent reporting in
// scenarios that are headless. | [
"UseFrontLoadedReporter",
"configures",
"reporters",
"ahead",
"of",
"all",
"other",
"reporters",
"to",
"handle",
"situations",
"like",
"CI",
".",
"These",
"reporters",
"usually",
"prevent",
"reporting",
"in",
"scenarios",
"that",
"are",
"headless",
"."
] | 6ae1ec6230a2f5eb200541972fb8510f71db4707 | https://github.com/approvals/go-approval-tests/blob/6ae1ec6230a2f5eb200541972fb8510f71db4707/approvals.go#L191-L198 |
145,212 | approvals/go-approval-tests | combination_approvals.go | VerifyAllCombinationsFor3 | func VerifyAllCombinationsFor3(
t Failable,
header string,
transform func(p1, p2, p3 interface{}) string,
collection1, collection2, collection3 interface{}) error {
kerning := func(p1, p2, p3, p4, p5, p6, p7, p8, p9 interface{}) string {
return transform(p1, p2, p3)
}
return VerifyAllCombinationsFor9(t, head... | go | func VerifyAllCombinationsFor3(
t Failable,
header string,
transform func(p1, p2, p3 interface{}) string,
collection1, collection2, collection3 interface{}) error {
kerning := func(p1, p2, p3, p4, p5, p6, p7, p8, p9 interface{}) string {
return transform(p1, p2, p3)
}
return VerifyAllCombinationsFor9(t, head... | [
"func",
"VerifyAllCombinationsFor3",
"(",
"t",
"Failable",
",",
"header",
"string",
",",
"transform",
"func",
"(",
"p1",
",",
"p2",
",",
"p3",
"interface",
"{",
"}",
")",
"string",
",",
"collection1",
",",
"collection2",
",",
"collection3",
"interface",
"{",... | // VerifyAllCombinationsFor3 is for combinations of 3. | [
"VerifyAllCombinationsFor3",
"is",
"for",
"combinations",
"of",
"3",
"."
] | 6ae1ec6230a2f5eb200541972fb8510f71db4707 | https://github.com/approvals/go-approval-tests/blob/6ae1ec6230a2f5eb200541972fb8510f71db4707/combination_approvals.go#L60-L80 |
145,213 | approvals/go-approval-tests | combination_approvals.go | VerifyAllCombinationsFor9 | func VerifyAllCombinationsFor9(
t Failable,
header string,
transform func(a, b, c, d, e, f, g, h, i interface{}) string,
collection1,
collection2,
collection3,
collection4,
collection5,
collection6,
collection7,
collection8,
collection9 interface{}) error {
if len(header) != 0 {
header = fmt.Sprintf("%s... | go | func VerifyAllCombinationsFor9(
t Failable,
header string,
transform func(a, b, c, d, e, f, g, h, i interface{}) string,
collection1,
collection2,
collection3,
collection4,
collection5,
collection6,
collection7,
collection8,
collection9 interface{}) error {
if len(header) != 0 {
header = fmt.Sprintf("%s... | [
"func",
"VerifyAllCombinationsFor9",
"(",
"t",
"Failable",
",",
"header",
"string",
",",
"transform",
"func",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
",",
"f",
",",
"g",
",",
"h",
",",
"i",
"interface",
"{",
"}",
")",
"string",
",",
"co... | // VerifyAllCombinationsFor9 is for combinations of 9. | [
"VerifyAllCombinationsFor9",
"is",
"for",
"combinations",
"of",
"9",
"."
] | 6ae1ec6230a2f5eb200541972fb8510f71db4707 | https://github.com/approvals/go-approval-tests/blob/6ae1ec6230a2f5eb200541972fb8510f71db4707/combination_approvals.go#L198-L264 |
145,214 | reiver/go-oi | longwritebyte.go | LongWriteByte | func LongWriteByte(w io.Writer, b byte) error {
var buffer [1]byte
p := buffer[:]
buffer[0] = b
numWritten, err := LongWrite(w, p)
if 1 != numWritten {
return io.ErrShortWrite
}
return err
} | go | func LongWriteByte(w io.Writer, b byte) error {
var buffer [1]byte
p := buffer[:]
buffer[0] = b
numWritten, err := LongWrite(w, p)
if 1 != numWritten {
return io.ErrShortWrite
}
return err
} | [
"func",
"LongWriteByte",
"(",
"w",
"io",
".",
"Writer",
",",
"b",
"byte",
")",
"error",
"{",
"var",
"buffer",
"[",
"1",
"]",
"byte",
"\n",
"p",
":=",
"buffer",
"[",
":",
"]",
"\n\n",
"buffer",
"[",
"0",
"]",
"=",
"b",
"\n\n",
"numWritten",
",",
... | // LongWriteByte trys to write the byte from 'b' to the writer 'w', such that it deals
// with "short writes" where w.Write would return an error of io.ErrShortWrite and
// n < 1.
//
// Note that LongWriteByte still could return the error io.ErrShortWrite; but this
// would only be after trying to handle the io.ErrShor... | [
"LongWriteByte",
"trys",
"to",
"write",
"the",
"byte",
"from",
"b",
"to",
"the",
"writer",
"w",
"such",
"that",
"it",
"deals",
"with",
"short",
"writes",
"where",
"w",
".",
"Write",
"would",
"return",
"an",
"error",
"of",
"io",
".",
"ErrShortWrite",
"and... | 431c83978379297f04f85f6eb94f129f25ab741d | https://github.com/reiver/go-oi/blob/431c83978379297f04f85f6eb94f129f25ab741d/longwritebyte.go#L16-L28 |
145,215 | manifoldco/go-base64 | base64.go | NewFromString | func NewFromString(encoded string) (*Value, error) {
out, err := base64.RawURLEncoding.DecodeString(encoded)
if err != nil {
return nil, err
}
return New(out), nil
} | go | func NewFromString(encoded string) (*Value, error) {
out, err := base64.RawURLEncoding.DecodeString(encoded)
if err != nil {
return nil, err
}
return New(out), nil
} | [
"func",
"NewFromString",
"(",
"encoded",
"string",
")",
"(",
"*",
"Value",
",",
"error",
")",
"{",
"out",
",",
"err",
":=",
"base64",
".",
"RawURLEncoding",
".",
"DecodeString",
"(",
"encoded",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",... | // NewFromString returns a Value containing the decoded data in encoded. | [
"NewFromString",
"returns",
"a",
"Value",
"containing",
"the",
"decoded",
"data",
"in",
"encoded",
"."
] | d8a3bc878677ec951dce1a0065759d2e3a0f4142 | https://github.com/manifoldco/go-base64/blob/d8a3bc878677ec951dce1a0065759d2e3a0f4142/base64.go#L23-L30 |
145,216 | manifoldco/go-base64 | base64.go | MarshalJSON | func (bv *Value) MarshalJSON() ([]byte, error) {
return []byte("\"" + base64.RawURLEncoding.EncodeToString(*bv) + "\""), nil
} | go | func (bv *Value) MarshalJSON() ([]byte, error) {
return []byte("\"" + base64.RawURLEncoding.EncodeToString(*bv) + "\""), nil
} | [
"func",
"(",
"bv",
"*",
"Value",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"[",
"]",
"byte",
"(",
"\"",
"\\\"",
"\"",
"+",
"base64",
".",
"RawURLEncoding",
".",
"EncodeToString",
"(",
"*",
"bv",
")",
"... | // MarshalJSON returns the ba64url encoding of bv for JSON representation. | [
"MarshalJSON",
"returns",
"the",
"ba64url",
"encoding",
"of",
"bv",
"for",
"JSON",
"representation",
"."
] | d8a3bc878677ec951dce1a0065759d2e3a0f4142 | https://github.com/manifoldco/go-base64/blob/d8a3bc878677ec951dce1a0065759d2e3a0f4142/base64.go#L33-L35 |
145,217 | manifoldco/go-base64 | base64.go | UnmarshalJSON | func (bv *Value) UnmarshalJSON(b []byte) error {
if len(b) < 2 || b[0] != byte('"') || b[len(b)-1] != byte('"') {
return errors.New("value is not a string")
}
out := make([]byte, base64.RawURLEncoding.DecodedLen(len(b)-2))
n, err := base64.RawURLEncoding.Decode(out, b[1:len(b)-1])
if err != nil {
return err
... | go | func (bv *Value) UnmarshalJSON(b []byte) error {
if len(b) < 2 || b[0] != byte('"') || b[len(b)-1] != byte('"') {
return errors.New("value is not a string")
}
out := make([]byte, base64.RawURLEncoding.DecodedLen(len(b)-2))
n, err := base64.RawURLEncoding.Decode(out, b[1:len(b)-1])
if err != nil {
return err
... | [
"func",
"(",
"bv",
"*",
"Value",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"b",
")",
"<",
"2",
"||",
"b",
"[",
"0",
"]",
"!=",
"byte",
"(",
"'\"'",
")",
"||",
"b",
"[",
"len",
"(",
"b",
")",
"-... | // UnmarshalJSON sets bv to the bytes represented in the base64url encoding b. | [
"UnmarshalJSON",
"sets",
"bv",
"to",
"the",
"bytes",
"represented",
"in",
"the",
"base64url",
"encoding",
"b",
"."
] | d8a3bc878677ec951dce1a0065759d2e3a0f4142 | https://github.com/manifoldco/go-base64/blob/d8a3bc878677ec951dce1a0065759d2e3a0f4142/base64.go#L42-L56 |
145,218 | danielkov/gin-helmet | helmet.go | NoSniff | func NoSniff() gin.HandlerFunc {
return func(c *gin.Context) {
c.Writer.Header().Set("X-Content-Type-Options", "nosniff")
}
} | go | func NoSniff() gin.HandlerFunc {
return func(c *gin.Context) {
c.Writer.Header().Set("X-Content-Type-Options", "nosniff")
}
} | [
"func",
"NoSniff",
"(",
")",
"gin",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"{",
"c",
".",
"Writer",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}... | // NoSniff applies header to protect your server from MimeType Sniffing | [
"NoSniff",
"applies",
"header",
"to",
"protect",
"your",
"server",
"from",
"MimeType",
"Sniffing"
] | 1387e224435edcb84dfc4bfc81fe56fc807ca98b | https://github.com/danielkov/gin-helmet/blob/1387e224435edcb84dfc4bfc81fe56fc807ca98b/helmet.go#L12-L16 |
145,219 | danielkov/gin-helmet | helmet.go | DNSPrefetchControl | func DNSPrefetchControl() gin.HandlerFunc {
return func(c *gin.Context) {
c.Writer.Header().Set("X-DNS-Prefetch-Control", "off")
}
} | go | func DNSPrefetchControl() gin.HandlerFunc {
return func(c *gin.Context) {
c.Writer.Header().Set("X-DNS-Prefetch-Control", "off")
}
} | [
"func",
"DNSPrefetchControl",
"(",
")",
"gin",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"{",
"c",
".",
"Writer",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
... | // DNSPrefetchControl sets Prefetch Control header to prevent browser from prefetching DNS | [
"DNSPrefetchControl",
"sets",
"Prefetch",
"Control",
"header",
"to",
"prevent",
"browser",
"from",
"prefetching",
"DNS"
] | 1387e224435edcb84dfc4bfc81fe56fc807ca98b | https://github.com/danielkov/gin-helmet/blob/1387e224435edcb84dfc4bfc81fe56fc807ca98b/helmet.go#L19-L23 |
145,220 | danielkov/gin-helmet | helmet.go | SetHSTS | func SetHSTS(sub bool, opt ...int) gin.HandlerFunc {
var o int
if len(opt) > 0 {
o = opt[0]
} else {
o = 5184000
}
op := "max-age=" + strconv.Itoa(o)
if sub {
op += "; includeSubDomains"
}
return func(c *gin.Context) {
c.Writer.Header().Set("Strict-Transport-Security", op)
}
} | go | func SetHSTS(sub bool, opt ...int) gin.HandlerFunc {
var o int
if len(opt) > 0 {
o = opt[0]
} else {
o = 5184000
}
op := "max-age=" + strconv.Itoa(o)
if sub {
op += "; includeSubDomains"
}
return func(c *gin.Context) {
c.Writer.Header().Set("Strict-Transport-Security", op)
}
} | [
"func",
"SetHSTS",
"(",
"sub",
"bool",
",",
"opt",
"...",
"int",
")",
"gin",
".",
"HandlerFunc",
"{",
"var",
"o",
"int",
"\n",
"if",
"len",
"(",
"opt",
")",
">",
"0",
"{",
"o",
"=",
"opt",
"[",
"0",
"]",
"\n",
"}",
"else",
"{",
"o",
"=",
"5... | // SetHSTS Sets Strict Transport Security header to the default of 60 days
// an optional integer may be added as a parameter to set the amount in seconds | [
"SetHSTS",
"Sets",
"Strict",
"Transport",
"Security",
"header",
"to",
"the",
"default",
"of",
"60",
"days",
"an",
"optional",
"integer",
"may",
"be",
"added",
"as",
"a",
"parameter",
"to",
"set",
"the",
"amount",
"in",
"seconds"
] | 1387e224435edcb84dfc4bfc81fe56fc807ca98b | https://github.com/danielkov/gin-helmet/blob/1387e224435edcb84dfc4bfc81fe56fc807ca98b/helmet.go#L40-L54 |
145,221 | danielkov/gin-helmet | helmet.go | IENoOpen | func IENoOpen() gin.HandlerFunc {
return func(c *gin.Context) {
c.Writer.Header().Set("X-Download-Options", "noopen")
}
} | go | func IENoOpen() gin.HandlerFunc {
return func(c *gin.Context) {
c.Writer.Header().Set("X-Download-Options", "noopen")
}
} | [
"func",
"IENoOpen",
"(",
")",
"gin",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"{",
"c",
".",
"Writer",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"... | // IENoOpen sets Download Options header for Internet Explorer to prevent it from executing downloads in the site's context | [
"IENoOpen",
"sets",
"Download",
"Options",
"header",
"for",
"Internet",
"Explorer",
"to",
"prevent",
"it",
"from",
"executing",
"downloads",
"in",
"the",
"site",
"s",
"context"
] | 1387e224435edcb84dfc4bfc81fe56fc807ca98b | https://github.com/danielkov/gin-helmet/blob/1387e224435edcb84dfc4bfc81fe56fc807ca98b/helmet.go#L57-L61 |
145,222 | danielkov/gin-helmet | helmet.go | XSSFilter | func XSSFilter() gin.HandlerFunc {
return func(c *gin.Context) {
c.Writer.Header().Set("X-XSS-Protection", "1; mode=block")
}
} | go | func XSSFilter() gin.HandlerFunc {
return func(c *gin.Context) {
c.Writer.Header().Set("X-XSS-Protection", "1; mode=block")
}
} | [
"func",
"XSSFilter",
"(",
")",
"gin",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"{",
"c",
".",
"Writer",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
... | // XSSFilter applies very minimal XSS protection via setting the XSS Protection header on | [
"XSSFilter",
"applies",
"very",
"minimal",
"XSS",
"protection",
"via",
"setting",
"the",
"XSS",
"Protection",
"header",
"on"
] | 1387e224435edcb84dfc4bfc81fe56fc807ca98b | https://github.com/danielkov/gin-helmet/blob/1387e224435edcb84dfc4bfc81fe56fc807ca98b/helmet.go#L64-L68 |
145,223 | danielkov/gin-helmet | helmet.go | Referrer | func Referrer(opt ...string) gin.HandlerFunc {
var o string
if len(opt) > 0 {
o = opt[0]
} else {
o = "no-referrer"
}
return func(c *gin.Context) {
c.Writer.Header().Set("Referrer-Policy", o)
}
} | go | func Referrer(opt ...string) gin.HandlerFunc {
var o string
if len(opt) > 0 {
o = opt[0]
} else {
o = "no-referrer"
}
return func(c *gin.Context) {
c.Writer.Header().Set("Referrer-Policy", o)
}
} | [
"func",
"Referrer",
"(",
"opt",
"...",
"string",
")",
"gin",
".",
"HandlerFunc",
"{",
"var",
"o",
"string",
"\n",
"if",
"len",
"(",
"opt",
")",
">",
"0",
"{",
"o",
"=",
"opt",
"[",
"0",
"]",
"\n",
"}",
"else",
"{",
"o",
"=",
"\"",
"\"",
"\n",... | // Referrer sets the Referrer Policy header to prevent the browser from sending data from your website to another one upon navigation
// an optional string can be provided to set the policy to something else other than "no-referrer". | [
"Referrer",
"sets",
"the",
"Referrer",
"Policy",
"header",
"to",
"prevent",
"the",
"browser",
"from",
"sending",
"data",
"from",
"your",
"website",
"to",
"another",
"one",
"upon",
"navigation",
"an",
"optional",
"string",
"can",
"be",
"provided",
"to",
"set",
... | 1387e224435edcb84dfc4bfc81fe56fc807ca98b | https://github.com/danielkov/gin-helmet/blob/1387e224435edcb84dfc4bfc81fe56fc807ca98b/helmet.go#L77-L87 |
145,224 | danielkov/gin-helmet | helmet.go | NoCache | func NoCache() gin.HandlerFunc {
return func(c *gin.Context) {
c.Writer.Header().Set("Surrogate-Control", "no-store")
c.Writer.Header().Set("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate")
c.Writer.Header().Set("Pragma", "no-cache")
c.Writer.Header().Set("Expires", "0")
}
} | go | func NoCache() gin.HandlerFunc {
return func(c *gin.Context) {
c.Writer.Header().Set("Surrogate-Control", "no-store")
c.Writer.Header().Set("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate")
c.Writer.Header().Set("Pragma", "no-cache")
c.Writer.Header().Set("Expires", "0")
}
} | [
"func",
"NoCache",
"(",
")",
"gin",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"{",
"c",
".",
"Writer",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"c",
".",
"Wr... | // NoCache obliterates cache options by setting a number of headers. This prevents the browser from storing your assets in cache | [
"NoCache",
"obliterates",
"cache",
"options",
"by",
"setting",
"a",
"number",
"of",
"headers",
".",
"This",
"prevents",
"the",
"browser",
"from",
"storing",
"your",
"assets",
"in",
"cache"
] | 1387e224435edcb84dfc4bfc81fe56fc807ca98b | https://github.com/danielkov/gin-helmet/blob/1387e224435edcb84dfc4bfc81fe56fc807ca98b/helmet.go#L90-L97 |
145,225 | andygrunwald/megos | http.go | GetHTTPResponseFromCluster | func (c *Client) GetHTTPResponseFromCluster(f func(url.URL) url.URL) (*http.Response, error) {
for _, instance := range c.Master {
u := f(*instance)
resp, err := c.GetHTTPResponse(&u)
// If there is no error, we hit an instance / master that is online
if err == nil {
return resp, nil
}
}
return nil, e... | go | func (c *Client) GetHTTPResponseFromCluster(f func(url.URL) url.URL) (*http.Response, error) {
for _, instance := range c.Master {
u := f(*instance)
resp, err := c.GetHTTPResponse(&u)
// If there is no error, we hit an instance / master that is online
if err == nil {
return resp, nil
}
}
return nil, e... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetHTTPResponseFromCluster",
"(",
"f",
"func",
"(",
"url",
".",
"URL",
")",
"url",
".",
"URL",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"for",
"_",
",",
"instance",
":=",
"range",
"c",
... | // GetHTTPResponseFromCluster will return a http.Response from one of the Mesos master nodes.
// In a cluster the master nodes can be online or offline.
// With GetHTTPResponseFromCluster you will receive a response from one of the nodes. | [
"GetHTTPResponseFromCluster",
"will",
"return",
"a",
"http",
".",
"Response",
"from",
"one",
"of",
"the",
"Mesos",
"master",
"nodes",
".",
"In",
"a",
"cluster",
"the",
"master",
"nodes",
"can",
"be",
"online",
"or",
"offline",
".",
"With",
"GetHTTPResponseFrom... | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/http.go#L13-L25 |
145,226 | andygrunwald/megos | http.go | GetHTTPResponseFromLeader | func (c *Client) GetHTTPResponseFromLeader(f func(Pid) url.URL) (*http.Response, error) {
if c.Leader == nil {
return nil, errors.New("No leader set.")
}
u := f(*c.Leader)
return c.GetHTTPResponse(&u)
} | go | func (c *Client) GetHTTPResponseFromLeader(f func(Pid) url.URL) (*http.Response, error) {
if c.Leader == nil {
return nil, errors.New("No leader set.")
}
u := f(*c.Leader)
return c.GetHTTPResponse(&u)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetHTTPResponseFromLeader",
"(",
"f",
"func",
"(",
"Pid",
")",
"url",
".",
"URL",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"if",
"c",
".",
"Leader",
"==",
"nil",
"{",
"return",
"nil",
... | // GetHTTPResponseFromLeader will return a http.Response from the determined leader
// of the master nodes. | [
"GetHTTPResponseFromLeader",
"will",
"return",
"a",
"http",
".",
"Response",
"from",
"the",
"determined",
"leader",
"of",
"the",
"master",
"nodes",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/http.go#L29-L35 |
145,227 | andygrunwald/megos | http.go | GetHTTPResponse | func (c *Client) GetHTTPResponse(u *url.URL) (*http.Response, error) {
resp, err := c.HTTP.Get(u.String())
if err != nil {
return nil, err
}
return resp, nil
} | go | func (c *Client) GetHTTPResponse(u *url.URL) (*http.Response, error) {
resp, err := c.HTTP.Get(u.String())
if err != nil {
return nil, err
}
return resp, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetHTTPResponse",
"(",
"u",
"*",
"url",
".",
"URL",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"HTTP",
".",
"Get",
"(",
"u",
".",
"String",
"(",
"... | // GetHTTPResponse will return a http.Response from a URL | [
"GetHTTPResponse",
"will",
"return",
"a",
"http",
".",
"Response",
"from",
"a",
"URL"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/http.go#L38-L46 |
145,228 | andygrunwald/megos | http.go | GetBodyOfHTTPResponse | func (c *Client) GetBodyOfHTTPResponse(u *url.URL) ([]byte, error) {
resp, err := c.GetHTTPResponse(u)
if err != nil {
return []byte{}, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
return body, err
} | go | func (c *Client) GetBodyOfHTTPResponse(u *url.URL) ([]byte, error) {
resp, err := c.GetHTTPResponse(u)
if err != nil {
return []byte{}, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
return body, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetBodyOfHTTPResponse",
"(",
"u",
"*",
"url",
".",
"URL",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"GetHTTPResponse",
"(",
"u",
")",
"\n",
"if",
"err",
"!=",
... | // GetBodyOfHTTPResponse will return the request body of the requested url u. | [
"GetBodyOfHTTPResponse",
"will",
"return",
"the",
"request",
"body",
"of",
"the",
"requested",
"url",
"u",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/http.go#L49-L59 |
145,229 | andygrunwald/megos | executors.go | GetExecutorByID | func (c *Client) GetExecutorByID(executor []Executor, executorID string) (*Executor, error) {
for _, e := range executor {
if e.ID == executorID {
return &e, nil
}
}
return nil, fmt.Errorf("No executor found with id \"%s\"", executorID)
} | go | func (c *Client) GetExecutorByID(executor []Executor, executorID string) (*Executor, error) {
for _, e := range executor {
if e.ID == executorID {
return &e, nil
}
}
return nil, fmt.Errorf("No executor found with id \"%s\"", executorID)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetExecutorByID",
"(",
"executor",
"[",
"]",
"Executor",
",",
"executorID",
"string",
")",
"(",
"*",
"Executor",
",",
"error",
")",
"{",
"for",
"_",
",",
"e",
":=",
"range",
"executor",
"{",
"if",
"e",
".",
"I... | // GetExecutorByID will return an Executor by its unique ID.
//
// The list of executors are provided by a framework. | [
"GetExecutorByID",
"will",
"return",
"an",
"Executor",
"by",
"its",
"unique",
"ID",
".",
"The",
"list",
"of",
"executors",
"are",
"provided",
"by",
"a",
"framework",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/executors.go#L10-L18 |
145,230 | andygrunwald/megos | logs.go | GetStdOutOfTask | func (c *Client) GetStdOutOfTask(pid *Pid, directory string) ([]byte, error) {
u := c.getBaseURLForLogs("stdout", pid, directory)
body, err := c.GetBodyOfHTTPResponse(&u)
return body, err
} | go | func (c *Client) GetStdOutOfTask(pid *Pid, directory string) ([]byte, error) {
u := c.getBaseURLForLogs("stdout", pid, directory)
body, err := c.GetBodyOfHTTPResponse(&u)
return body, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetStdOutOfTask",
"(",
"pid",
"*",
"Pid",
",",
"directory",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"u",
":=",
"c",
".",
"getBaseURLForLogs",
"(",
"\"",
"\"",
",",
"pid",
",",
"directory"... | // GetStdOutOfTask will return Stdout of a task.
//
// pid is a single mesos slave node.
// directory is the directory of a single executor, | [
"GetStdOutOfTask",
"will",
"return",
"Stdout",
"of",
"a",
"task",
".",
"pid",
"is",
"a",
"single",
"mesos",
"slave",
"node",
".",
"directory",
"is",
"the",
"directory",
"of",
"a",
"single",
"executor"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/logs.go#L12-L16 |
145,231 | andygrunwald/megos | logs.go | getBaseURLForLogs | func (c *Client) getBaseURLForLogs(mode string, pid *Pid, directory string) url.URL {
u := url.URL{
// TODO How to support https cluster?
Scheme: "http",
Host: pid.Host + ":" + strconv.Itoa(pid.Port),
Path: "files/download.json",
RawQuery: "path=" + directory + "/" + mode,
}
return u
} | go | func (c *Client) getBaseURLForLogs(mode string, pid *Pid, directory string) url.URL {
u := url.URL{
// TODO How to support https cluster?
Scheme: "http",
Host: pid.Host + ":" + strconv.Itoa(pid.Port),
Path: "files/download.json",
RawQuery: "path=" + directory + "/" + mode,
}
return u
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"getBaseURLForLogs",
"(",
"mode",
"string",
",",
"pid",
"*",
"Pid",
",",
"directory",
"string",
")",
"url",
".",
"URL",
"{",
"u",
":=",
"url",
".",
"URL",
"{",
"// TODO How to support https cluster?",
"Scheme",
":",
... | // getBaseURLForLogs will build the URL to get Stdout or Stderr. | [
"getBaseURLForLogs",
"will",
"build",
"the",
"URL",
"to",
"get",
"Stdout",
"or",
"Stderr",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/logs.go#L29-L39 |
145,232 | andygrunwald/megos | states.go | GetStateFromCluster | func (c *Client) GetStateFromCluster() (*State, error) {
resp, err := c.GetHTTPResponseFromCluster(c.GetURLForStateFile)
return c.parseStateResponse(resp, err)
} | go | func (c *Client) GetStateFromCluster() (*State, error) {
resp, err := c.GetHTTPResponseFromCluster(c.GetURLForStateFile)
return c.parseStateResponse(resp, err)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetStateFromCluster",
"(",
")",
"(",
"*",
"State",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"GetHTTPResponseFromCluster",
"(",
"c",
".",
"GetURLForStateFile",
")",
"\n",
"return",
"c",
".",
"par... | // GetStateFromCluster will return the current state of one of the cluster nodes. | [
"GetStateFromCluster",
"will",
"return",
"the",
"current",
"state",
"of",
"one",
"of",
"the",
"cluster",
"nodes",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L12-L15 |
145,233 | andygrunwald/megos | states.go | GetStateFromLeader | func (c *Client) GetStateFromLeader() (*State, error) {
resp, err := c.GetHTTPResponseFromLeader(c.GetURLForStateFilePid)
return c.parseStateResponse(resp, err)
} | go | func (c *Client) GetStateFromLeader() (*State, error) {
resp, err := c.GetHTTPResponseFromLeader(c.GetURLForStateFilePid)
return c.parseStateResponse(resp, err)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetStateFromLeader",
"(",
")",
"(",
"*",
"State",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"GetHTTPResponseFromLeader",
"(",
"c",
".",
"GetURLForStateFilePid",
")",
"\n",
"return",
"c",
".",
"pa... | // GetStateFromLeader will return the current state of the leader node of the cluster. | [
"GetStateFromLeader",
"will",
"return",
"the",
"current",
"state",
"of",
"the",
"leader",
"node",
"of",
"the",
"cluster",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L18-L21 |
145,234 | andygrunwald/megos | states.go | GetStateSummaryFromCluster | func (c *Client) GetStateSummaryFromCluster() (*State, error) {
resp, err := c.GetHTTPResponseFromCluster(c.GetURLForStateSummaryFile)
return c.parseStateResponse(resp, err)
} | go | func (c *Client) GetStateSummaryFromCluster() (*State, error) {
resp, err := c.GetHTTPResponseFromCluster(c.GetURLForStateSummaryFile)
return c.parseStateResponse(resp, err)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetStateSummaryFromCluster",
"(",
")",
"(",
"*",
"State",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"GetHTTPResponseFromCluster",
"(",
"c",
".",
"GetURLForStateSummaryFile",
")",
"\n",
"return",
"c",... | // GetStateSummaryFromCluster will return the current state summary of one of the cluster nodes. | [
"GetStateSummaryFromCluster",
"will",
"return",
"the",
"current",
"state",
"summary",
"of",
"one",
"of",
"the",
"cluster",
"nodes",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L31-L34 |
145,235 | andygrunwald/megos | states.go | GetStateSummaryFromLeader | func (c *Client) GetStateSummaryFromLeader() (*State, error) {
resp, err := c.GetHTTPResponseFromLeader(c.GetURLForStateSummaryFilePid)
return c.parseStateResponse(resp, err)
} | go | func (c *Client) GetStateSummaryFromLeader() (*State, error) {
resp, err := c.GetHTTPResponseFromLeader(c.GetURLForStateSummaryFilePid)
return c.parseStateResponse(resp, err)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetStateSummaryFromLeader",
"(",
")",
"(",
"*",
"State",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"GetHTTPResponseFromLeader",
"(",
"c",
".",
"GetURLForStateSummaryFilePid",
")",
"\n",
"return",
"c"... | // GetStateSummaryFromLeader will return the current state summary of the leader node of the cluster. | [
"GetStateSummaryFromLeader",
"will",
"return",
"the",
"current",
"state",
"summary",
"of",
"the",
"leader",
"node",
"of",
"the",
"cluster",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L37-L40 |
145,236 | andygrunwald/megos | states.go | GetSlavesFromCluster | func (c *Client) GetSlavesFromCluster() (*State, error) {
resp, err := c.GetHTTPResponseFromCluster(c.GetURLForSlavesFile)
return c.parseStateResponse(resp, err)
} | go | func (c *Client) GetSlavesFromCluster() (*State, error) {
resp, err := c.GetHTTPResponseFromCluster(c.GetURLForSlavesFile)
return c.parseStateResponse(resp, err)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetSlavesFromCluster",
"(",
")",
"(",
"*",
"State",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"GetHTTPResponseFromCluster",
"(",
"c",
".",
"GetURLForSlavesFile",
")",
"\n",
"return",
"c",
".",
"p... | // GetSlavesFromCluster will return the current slaves of one of the cluster nodes. | [
"GetSlavesFromCluster",
"will",
"return",
"the",
"current",
"slaves",
"of",
"one",
"of",
"the",
"cluster",
"nodes",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L50-L53 |
145,237 | andygrunwald/megos | states.go | GetSlavesFromLeader | func (c *Client) GetSlavesFromLeader() (*State, error) {
resp, err := c.GetHTTPResponseFromLeader(c.GetURLForSlavesFilePid)
return c.parseStateResponse(resp, err)
} | go | func (c *Client) GetSlavesFromLeader() (*State, error) {
resp, err := c.GetHTTPResponseFromLeader(c.GetURLForSlavesFilePid)
return c.parseStateResponse(resp, err)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetSlavesFromLeader",
"(",
")",
"(",
"*",
"State",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"GetHTTPResponseFromLeader",
"(",
"c",
".",
"GetURLForSlavesFilePid",
")",
"\n",
"return",
"c",
".",
"... | // GetSlavesFromLeader will return the current slaves of the leader node of the cluster. | [
"GetSlavesFromLeader",
"will",
"return",
"the",
"current",
"slaves",
"of",
"the",
"leader",
"node",
"of",
"the",
"cluster",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L56-L59 |
145,238 | andygrunwald/megos | states.go | parseStateResponse | func (c *Client) parseStateResponse(resp *http.Response, err error) (*State, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var state State
err = json.Unmarshal(body, &state)
if err != nil {
return nil, err
}
c.Lock()
c.State = &state
c.Unlock... | go | func (c *Client) parseStateResponse(resp *http.Response, err error) (*State, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var state State
err = json.Unmarshal(body, &state)
if err != nil {
return nil, err
}
c.Lock()
c.State = &state
c.Unlock... | [
"func",
"(",
"c",
"*",
"Client",
")",
"parseStateResponse",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"err",
"error",
")",
"(",
"*",
"State",
",",
"error",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n... | // parseStateResponse will transform a http.Response into a State object | [
"parseStateResponse",
"will",
"transform",
"a",
"http",
".",
"Response",
"into",
"a",
"State",
"object"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L69-L88 |
145,239 | andygrunwald/megos | states.go | GetURLForStateFile | func (c *Client) GetURLForStateFile(instance url.URL) url.URL {
return AppendPath(instance, "master/state")
} | go | func (c *Client) GetURLForStateFile(instance url.URL) url.URL {
return AppendPath(instance, "master/state")
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetURLForStateFile",
"(",
"instance",
"url",
".",
"URL",
")",
"url",
".",
"URL",
"{",
"return",
"AppendPath",
"(",
"instance",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // GetURLForStateFile will return the URL for the state file of a node | [
"GetURLForStateFile",
"will",
"return",
"the",
"URL",
"for",
"the",
"state",
"file",
"of",
"a",
"node"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L91-L93 |
145,240 | andygrunwald/megos | states.go | GetURLForStateFilePid | func (c *Client) GetURLForStateFilePid(pid Pid) url.URL {
return c.getURLForFilePid(pid, "state")
} | go | func (c *Client) GetURLForStateFilePid(pid Pid) url.URL {
return c.getURLForFilePid(pid, "state")
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetURLForStateFilePid",
"(",
"pid",
"Pid",
")",
"url",
".",
"URL",
"{",
"return",
"c",
".",
"getURLForFilePid",
"(",
"pid",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // GetURLForStateFilePid will return the URL for the state file of a node
// based on a PID | [
"GetURLForStateFilePid",
"will",
"return",
"the",
"URL",
"for",
"the",
"state",
"file",
"of",
"a",
"node",
"based",
"on",
"a",
"PID"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L97-L99 |
145,241 | andygrunwald/megos | states.go | GetURLForStateSummaryFile | func (c *Client) GetURLForStateSummaryFile(instance url.URL) url.URL {
return AppendPath(instance, "master/state-summary")
} | go | func (c *Client) GetURLForStateSummaryFile(instance url.URL) url.URL {
return AppendPath(instance, "master/state-summary")
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetURLForStateSummaryFile",
"(",
"instance",
"url",
".",
"URL",
")",
"url",
".",
"URL",
"{",
"return",
"AppendPath",
"(",
"instance",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // GetURLForStateSummaryFile will return the URL for the state-summary file of a node | [
"GetURLForStateSummaryFile",
"will",
"return",
"the",
"URL",
"for",
"the",
"state",
"-",
"summary",
"file",
"of",
"a",
"node"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L102-L104 |
145,242 | andygrunwald/megos | states.go | GetURLForStateSummaryFilePid | func (c *Client) GetURLForStateSummaryFilePid(pid Pid) url.URL {
return c.getURLForFilePid(pid, "state-summary")
} | go | func (c *Client) GetURLForStateSummaryFilePid(pid Pid) url.URL {
return c.getURLForFilePid(pid, "state-summary")
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetURLForStateSummaryFilePid",
"(",
"pid",
"Pid",
")",
"url",
".",
"URL",
"{",
"return",
"c",
".",
"getURLForFilePid",
"(",
"pid",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // GetURLForStateSummaryFilePid will return the URL for the state-summary file of a node
// based on a PID | [
"GetURLForStateSummaryFilePid",
"will",
"return",
"the",
"URL",
"for",
"the",
"state",
"-",
"summary",
"file",
"of",
"a",
"node",
"based",
"on",
"a",
"PID"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L108-L110 |
145,243 | andygrunwald/megos | states.go | GetURLForSlavesFile | func (c *Client) GetURLForSlavesFile(instance url.URL) url.URL {
return AppendPath(instance, "master/slaves")
} | go | func (c *Client) GetURLForSlavesFile(instance url.URL) url.URL {
return AppendPath(instance, "master/slaves")
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetURLForSlavesFile",
"(",
"instance",
"url",
".",
"URL",
")",
"url",
".",
"URL",
"{",
"return",
"AppendPath",
"(",
"instance",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // GetURLForSlavesFile will return the URL for the slaves file of a node | [
"GetURLForSlavesFile",
"will",
"return",
"the",
"URL",
"for",
"the",
"slaves",
"file",
"of",
"a",
"node"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L113-L115 |
145,244 | andygrunwald/megos | states.go | GetURLForSlavesFilePid | func (c *Client) GetURLForSlavesFilePid(pid Pid) url.URL {
return c.getURLForFilePid(pid, "slaves")
} | go | func (c *Client) GetURLForSlavesFilePid(pid Pid) url.URL {
return c.getURLForFilePid(pid, "slaves")
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetURLForSlavesFilePid",
"(",
"pid",
"Pid",
")",
"url",
".",
"URL",
"{",
"return",
"c",
".",
"getURLForFilePid",
"(",
"pid",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // GetURLForSlavesFilePid will return the URL for the slaves file of a node
// based on a PID | [
"GetURLForSlavesFilePid",
"will",
"return",
"the",
"URL",
"for",
"the",
"slaves",
"file",
"of",
"a",
"node",
"based",
"on",
"a",
"PID"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/states.go#L119-L121 |
145,245 | andygrunwald/megos | snapshot.go | GetMetricsSnapshot | func (c *Client) GetMetricsSnapshot(pid *Pid) (*MetricsSnapshot, error) {
u := c.GetURLForMetricsSnapshotPid(*pid)
resp, err := c.GetHTTPResponse(&u)
return c.parseMetricsSnapshotResponse(resp, err)
} | go | func (c *Client) GetMetricsSnapshot(pid *Pid) (*MetricsSnapshot, error) {
u := c.GetURLForMetricsSnapshotPid(*pid)
resp, err := c.GetHTTPResponse(&u)
return c.parseMetricsSnapshotResponse(resp, err)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetMetricsSnapshot",
"(",
"pid",
"*",
"Pid",
")",
"(",
"*",
"MetricsSnapshot",
",",
"error",
")",
"{",
"u",
":=",
"c",
".",
"GetURLForMetricsSnapshotPid",
"(",
"*",
"pid",
")",
"\n",
"resp",
",",
"err",
":=",
"c... | // GetMetricsSnapshot will return the snapshot of pid | [
"GetMetricsSnapshot",
"will",
"return",
"the",
"snapshot",
"of",
"pid"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/snapshot.go#L11-L15 |
145,246 | andygrunwald/megos | snapshot.go | GetURLForMetricsSnapshotPid | func (c *Client) GetURLForMetricsSnapshotPid(pid Pid) url.URL {
return c.getBaseURLForFilePid(pid, "metrics/snapshot")
} | go | func (c *Client) GetURLForMetricsSnapshotPid(pid Pid) url.URL {
return c.getBaseURLForFilePid(pid, "metrics/snapshot")
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetURLForMetricsSnapshotPid",
"(",
"pid",
"Pid",
")",
"url",
".",
"URL",
"{",
"return",
"c",
".",
"getBaseURLForFilePid",
"(",
"pid",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // GetURLForMetricsSnapshotPid will return the URL for the snapshot
// based on a PID | [
"GetURLForMetricsSnapshotPid",
"will",
"return",
"the",
"URL",
"for",
"the",
"snapshot",
"based",
"on",
"a",
"PID"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/snapshot.go#L19-L21 |
145,247 | andygrunwald/megos | snapshot.go | parseMetricsSnapshotResponse | func (c *Client) parseMetricsSnapshotResponse(resp *http.Response, err error) (*MetricsSnapshot, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var snapshot MetricsSnapshot
err = json.Unmarshal(body, &snapshot)
if err != nil {
return nil, err
}
... | go | func (c *Client) parseMetricsSnapshotResponse(resp *http.Response, err error) (*MetricsSnapshot, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var snapshot MetricsSnapshot
err = json.Unmarshal(body, &snapshot)
if err != nil {
return nil, err
}
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"parseMetricsSnapshotResponse",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"err",
"error",
")",
"(",
"*",
"MetricsSnapshot",
",",
"error",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // parseMetricsSnapshotResponse will transform a http.Response to snapshot map | [
"parseMetricsSnapshotResponse",
"will",
"transform",
"a",
"http",
".",
"Response",
"to",
"snapshot",
"map"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/snapshot.go#L24-L43 |
145,248 | andygrunwald/megos | megos.go | DetermineLeader | func (c *Client) DetermineLeader() (*Pid, error) {
state, err := c.GetStateFromCluster()
if err != nil {
return nil, err
}
pid, err := c.ParsePidInformation(state.Leader)
if err != nil {
return nil, err
}
c.Lock()
c.Leader = pid
c.Unlock()
return c.Leader, nil
} | go | func (c *Client) DetermineLeader() (*Pid, error) {
state, err := c.GetStateFromCluster()
if err != nil {
return nil, err
}
pid, err := c.ParsePidInformation(state.Leader)
if err != nil {
return nil, err
}
c.Lock()
c.Leader = pid
c.Unlock()
return c.Leader, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DetermineLeader",
"(",
")",
"(",
"*",
"Pid",
",",
"error",
")",
"{",
"state",
",",
"err",
":=",
"c",
".",
"GetStateFromCluster",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\... | // DetermineLeader will return the leader of several master nodes of
// the Mesos cluster. Only one leader is chosen per time.
// This leader will be returned. | [
"DetermineLeader",
"will",
"return",
"the",
"leader",
"of",
"several",
"master",
"nodes",
"of",
"the",
"Mesos",
"cluster",
".",
"Only",
"one",
"leader",
"is",
"chosen",
"per",
"time",
".",
"This",
"leader",
"will",
"be",
"returned",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/megos.go#L63-L79 |
145,249 | andygrunwald/megos | megos.go | ParsePidInformation | func (c *Client) ParsePidInformation(pid string) (*Pid, error) {
firstPart := strings.Split(pid, "@")
if len(firstPart) != 2 {
return nil, errors.New("Invalid master pid.")
}
secondPart := strings.Split(firstPart[1], ":")
var port int
var err error
if len(secondPart) == 2 {
port, err = strconv.Atoi(secondPa... | go | func (c *Client) ParsePidInformation(pid string) (*Pid, error) {
firstPart := strings.Split(pid, "@")
if len(firstPart) != 2 {
return nil, errors.New("Invalid master pid.")
}
secondPart := strings.Split(firstPart[1], ":")
var port int
var err error
if len(secondPart) == 2 {
port, err = strconv.Atoi(secondPa... | [
"func",
"(",
"c",
"*",
"Client",
")",
"ParsePidInformation",
"(",
"pid",
"string",
")",
"(",
"*",
"Pid",
",",
"error",
")",
"{",
"firstPart",
":=",
"strings",
".",
"Split",
"(",
"pid",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"firstPart",
")",... | // ParsePidInformation will split up a single PID of format node@ip:port
// into a Pid structure to access single parts of the PID on its own.
//
// Example pid: master@10.1.1.12:5050 | [
"ParsePidInformation",
"will",
"split",
"up",
"a",
"single",
"PID",
"of",
"format",
"node"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/megos.go#L85-L108 |
145,250 | andygrunwald/megos | megos.go | String | func (p *Pid) String() string {
s := p.Role + "@" + p.Host + ":" + strconv.Itoa(p.Port)
return s
} | go | func (p *Pid) String() string {
s := p.Role + "@" + p.Host + ":" + strconv.Itoa(p.Port)
return s
} | [
"func",
"(",
"p",
"*",
"Pid",
")",
"String",
"(",
")",
"string",
"{",
"s",
":=",
"p",
".",
"Role",
"+",
"\"",
"\"",
"+",
"p",
".",
"Host",
"+",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa",
"(",
"p",
".",
"Port",
")",
"\n",
"return",
"s",
"\n",
... | // String implements the Stringer interface for PID.
// It can be named as the opposite of Client.ParsePidInformation,
// because it transfers a single Pid structure into its original form
// with format node@ip:port. | [
"String",
"implements",
"the",
"Stringer",
"interface",
"for",
"PID",
".",
"It",
"can",
"be",
"named",
"as",
"the",
"opposite",
"of",
"Client",
".",
"ParsePidInformation",
"because",
"it",
"transfers",
"a",
"single",
"Pid",
"structure",
"into",
"its",
"origina... | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/megos.go#L114-L117 |
145,251 | andygrunwald/megos | tasks.go | GetTaskByID | func (c *Client) GetTaskByID(tasks []Task, taskID string) (*Task, error) {
for _, task := range tasks {
if taskID == task.ID {
return &task, nil
}
}
return nil, fmt.Errorf("No task with id \"%s\" found", taskID)
} | go | func (c *Client) GetTaskByID(tasks []Task, taskID string) (*Task, error) {
for _, task := range tasks {
if taskID == task.ID {
return &task, nil
}
}
return nil, fmt.Errorf("No task with id \"%s\" found", taskID)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetTaskByID",
"(",
"tasks",
"[",
"]",
"Task",
",",
"taskID",
"string",
")",
"(",
"*",
"Task",
",",
"error",
")",
"{",
"for",
"_",
",",
"task",
":=",
"range",
"tasks",
"{",
"if",
"taskID",
"==",
"task",
".",
... | // GetTaskByID will return a Task by its unique ID.
//
// The list of tasks are provided by a framework. | [
"GetTaskByID",
"will",
"return",
"a",
"Task",
"by",
"its",
"unique",
"ID",
".",
"The",
"list",
"of",
"tasks",
"are",
"provided",
"by",
"a",
"framework",
"."
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/tasks.go#L10-L18 |
145,252 | andygrunwald/megos | system.go | GetSystemFromPid | func (c *Client) GetSystemFromPid(pid *Pid) (*System, error) {
u := c.GetURLForSystemFilePid(*pid)
resp, err := c.GetHTTPResponse(&u)
return c.parseSystemResponse(resp, err)
} | go | func (c *Client) GetSystemFromPid(pid *Pid) (*System, error) {
u := c.GetURLForSystemFilePid(*pid)
resp, err := c.GetHTTPResponse(&u)
return c.parseSystemResponse(resp, err)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetSystemFromPid",
"(",
"pid",
"*",
"Pid",
")",
"(",
"*",
"System",
",",
"error",
")",
"{",
"u",
":=",
"c",
".",
"GetURLForSystemFilePid",
"(",
"*",
"pid",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"Get... | // GetSystemFromPid will return the system stats of node | [
"GetSystemFromPid",
"will",
"return",
"the",
"system",
"stats",
"of",
"node"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/system.go#L12-L16 |
145,253 | andygrunwald/megos | system.go | GetURLForSystemFilePid | func (c *Client) GetURLForSystemFilePid(pid Pid) url.URL {
return c.getBaseURLForFilePid(pid, "system/stats.json")
} | go | func (c *Client) GetURLForSystemFilePid(pid Pid) url.URL {
return c.getBaseURLForFilePid(pid, "system/stats.json")
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetURLForSystemFilePid",
"(",
"pid",
"Pid",
")",
"url",
".",
"URL",
"{",
"return",
"c",
".",
"getBaseURLForFilePid",
"(",
"pid",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // GetURLForSystemFilePid will return the URL for the system stats of a node
// based on a PID | [
"GetURLForSystemFilePid",
"will",
"return",
"the",
"URL",
"for",
"the",
"system",
"stats",
"of",
"a",
"node",
"based",
"on",
"a",
"PID"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/system.go#L20-L22 |
145,254 | andygrunwald/megos | system.go | parseSystemResponse | func (c *Client) parseSystemResponse(resp *http.Response, err error) (*System, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var system System
err = json.Unmarshal(body, &system)
if err != nil {
return nil, err
}
c.Lock()
c.System = &system
c... | go | func (c *Client) parseSystemResponse(resp *http.Response, err error) (*System, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var system System
err = json.Unmarshal(body, &system)
if err != nil {
return nil, err
}
c.Lock()
c.System = &system
c... | [
"func",
"(",
"c",
"*",
"Client",
")",
"parseSystemResponse",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"err",
"error",
")",
"(",
"*",
"System",
",",
"error",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"... | // parseSystemResponse will transform a http.Response into a System object | [
"parseSystemResponse",
"will",
"transform",
"a",
"http",
".",
"Response",
"into",
"a",
"System",
"object"
] | 0fccaea93714004464321640d15889da7e8c293b | https://github.com/andygrunwald/megos/blob/0fccaea93714004464321640d15889da7e8c293b/system.go#L25-L44 |
145,255 | marstr/guid | guid.go | NewGUID | func NewGUID() GUID {
result, err := version4()
if err != nil {
panic(err) //Version 4 (pseudo-random GUID) doesn't use anything that could fail.
}
return result
} | go | func NewGUID() GUID {
result, err := version4()
if err != nil {
panic(err) //Version 4 (pseudo-random GUID) doesn't use anything that could fail.
}
return result
} | [
"func",
"NewGUID",
"(",
")",
"GUID",
"{",
"result",
",",
"err",
":=",
"version4",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"//Version 4 (pseudo-random GUID) doesn't use anything that could fail.",
"\n",
"}",
"\n",
"return",
"res... | // NewGUID generates and returns a new globally unique identifier | [
"NewGUID",
"generates",
"and",
"returns",
"a",
"new",
"globally",
"unique",
"identifier"
] | 8bdf7d1a087ccc975cf37dd6507da50698fd19ca | https://github.com/marstr/guid/blob/8bdf7d1a087ccc975cf37dd6507da50698fd19ca/guid.go#L53-L59 |
145,256 | marstr/guid | guid.go | NewGUIDs | func NewGUIDs(strategy CreationStrategy) (GUID, error) {
if creator, present := knownStrategies[strategy]; present {
result, err := creator()
return result, err
}
return emptyGUID, errors.New("Unsupported CreationStrategy")
} | go | func NewGUIDs(strategy CreationStrategy) (GUID, error) {
if creator, present := knownStrategies[strategy]; present {
result, err := creator()
return result, err
}
return emptyGUID, errors.New("Unsupported CreationStrategy")
} | [
"func",
"NewGUIDs",
"(",
"strategy",
"CreationStrategy",
")",
"(",
"GUID",
",",
"error",
")",
"{",
"if",
"creator",
",",
"present",
":=",
"knownStrategies",
"[",
"strategy",
"]",
";",
"present",
"{",
"result",
",",
"err",
":=",
"creator",
"(",
")",
"\n",... | // NewGUIDs generates and returns a new globally unique identifier that conforms to the given strategy. | [
"NewGUIDs",
"generates",
"and",
"returns",
"a",
"new",
"globally",
"unique",
"identifier",
"that",
"conforms",
"to",
"the",
"given",
"strategy",
"."
] | 8bdf7d1a087ccc975cf37dd6507da50698fd19ca | https://github.com/marstr/guid/blob/8bdf7d1a087ccc975cf37dd6507da50698fd19ca/guid.go#L67-L73 |
145,257 | marstr/guid | guid.go | MarshalJSON | func (guid GUID) MarshalJSON() (marshaled []byte, err error) {
buf := bytes.Buffer{}
_, err = buf.WriteRune('"')
buf.WriteString(guid.String())
buf.WriteRune('"')
marshaled = buf.Bytes()
return
} | go | func (guid GUID) MarshalJSON() (marshaled []byte, err error) {
buf := bytes.Buffer{}
_, err = buf.WriteRune('"')
buf.WriteString(guid.String())
buf.WriteRune('"')
marshaled = buf.Bytes()
return
} | [
"func",
"(",
"guid",
"GUID",
")",
"MarshalJSON",
"(",
")",
"(",
"marshaled",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"buf",
":=",
"bytes",
".",
"Buffer",
"{",
"}",
"\n\n",
"_",
",",
"err",
"=",
"buf",
".",
"WriteRune",
"(",
"'\"'",
")",
... | // MarshalJSON writes a GUID as a JSON string. | [
"MarshalJSON",
"writes",
"a",
"GUID",
"as",
"a",
"JSON",
"string",
"."
] | 8bdf7d1a087ccc975cf37dd6507da50698fd19ca | https://github.com/marstr/guid/blob/8bdf7d1a087ccc975cf37dd6507da50698fd19ca/guid.go#L89-L98 |
145,258 | marstr/guid | guid.go | Stringf | func (guid GUID) Stringf(format Format) string {
if format == "" {
format = FormatDefault
}
fullFormat, present := knownFormats[format]
if !present {
return ""
}
return fmt.Sprintf(
fullFormat,
guid.timeLow,
guid.timeMid,
guid.timeHighAndVersion,
guid.clockSeqHighAndReserved,
guid.clockSeqLow,
g... | go | func (guid GUID) Stringf(format Format) string {
if format == "" {
format = FormatDefault
}
fullFormat, present := knownFormats[format]
if !present {
return ""
}
return fmt.Sprintf(
fullFormat,
guid.timeLow,
guid.timeMid,
guid.timeHighAndVersion,
guid.clockSeqHighAndReserved,
guid.clockSeqLow,
g... | [
"func",
"(",
"guid",
"GUID",
")",
"Stringf",
"(",
"format",
"Format",
")",
"string",
"{",
"if",
"format",
"==",
"\"",
"\"",
"{",
"format",
"=",
"FormatDefault",
"\n",
"}",
"\n",
"fullFormat",
",",
"present",
":=",
"knownFormats",
"[",
"format",
"]",
"\... | // Stringf returns a text representation of a GUID that conforms to the specified format.
// If an unrecognized format is provided, the empty string is returned. | [
"Stringf",
"returns",
"a",
"text",
"representation",
"of",
"a",
"GUID",
"that",
"conforms",
"to",
"the",
"specified",
"format",
".",
"If",
"an",
"unrecognized",
"format",
"is",
"provided",
"the",
"empty",
"string",
"is",
"returned",
"."
] | 8bdf7d1a087ccc975cf37dd6507da50698fd19ca | https://github.com/marstr/guid/blob/8bdf7d1a087ccc975cf37dd6507da50698fd19ca/guid.go#L133-L154 |
145,259 | marstr/guid | guid.go | UnmarshalJSON | func (guid *GUID) UnmarshalJSON(marshaled []byte) (err error) {
if len(marshaled) < 2 {
err = errors.New("JSON GUID must be surrounded by quotes")
return
}
stripped := marshaled[1 : len(marshaled)-1]
*guid, err = Parse(string(stripped))
return
} | go | func (guid *GUID) UnmarshalJSON(marshaled []byte) (err error) {
if len(marshaled) < 2 {
err = errors.New("JSON GUID must be surrounded by quotes")
return
}
stripped := marshaled[1 : len(marshaled)-1]
*guid, err = Parse(string(stripped))
return
} | [
"func",
"(",
"guid",
"*",
"GUID",
")",
"UnmarshalJSON",
"(",
"marshaled",
"[",
"]",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"marshaled",
")",
"<",
"2",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"re... | // UnmarshalJSON parses a GUID from a JSON string token. | [
"UnmarshalJSON",
"parses",
"a",
"GUID",
"from",
"a",
"JSON",
"string",
"token",
"."
] | 8bdf7d1a087ccc975cf37dd6507da50698fd19ca | https://github.com/marstr/guid/blob/8bdf7d1a087ccc975cf37dd6507da50698fd19ca/guid.go#L157-L165 |
145,260 | tildeleb/hashland | murmur3/murmur32.go | bmix | func (d *digest32) bmix(p []byte) (tail []byte) {
h1 := d.h1
nblocks := len(p) / 4
for i := 0; i < nblocks; i++ {
k1 := *(*uint32)(unsafe.Pointer(&p[i*4]))
k1 *= c1_32
k1 = (k1 << 15) | (k1 >> 17) // rotl32(k1, 15)
k1 *= c2_32
h1 ^= k1
h1 = (h1 << 13) | (h1 >> 19) // rotl32(h1, 13)
h1 = h1*5 + 0xe65... | go | func (d *digest32) bmix(p []byte) (tail []byte) {
h1 := d.h1
nblocks := len(p) / 4
for i := 0; i < nblocks; i++ {
k1 := *(*uint32)(unsafe.Pointer(&p[i*4]))
k1 *= c1_32
k1 = (k1 << 15) | (k1 >> 17) // rotl32(k1, 15)
k1 *= c2_32
h1 ^= k1
h1 = (h1 << 13) | (h1 >> 19) // rotl32(h1, 13)
h1 = h1*5 + 0xe65... | [
"func",
"(",
"d",
"*",
"digest32",
")",
"bmix",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"tail",
"[",
"]",
"byte",
")",
"{",
"h1",
":=",
"d",
".",
"h1",
"\n\n",
"nblocks",
":=",
"len",
"(",
"p",
")",
"/",
"4",
"\n",
"for",
"i",
":=",
"0",
";... | // Digest as many blocks as possible. | [
"Digest",
"as",
"many",
"blocks",
"as",
"possible",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/murmur3/murmur32.go#L44-L61 |
145,261 | tildeleb/hashland | smhasher/smhasher.go | setbits | func setbits(h *HashSet, b []byte, i int, k int) {
h.addB(b)
if k == 0 {
return
}
for j := i; j < len(b)*8; j++ {
b[j/8] |= byte(1 << uint(j&7))
setbits(h, b, j+1, k-1)
b[j/8] &= byte(^(1 << uint(j&7)))
}
} | go | func setbits(h *HashSet, b []byte, i int, k int) {
h.addB(b)
if k == 0 {
return
}
for j := i; j < len(b)*8; j++ {
b[j/8] |= byte(1 << uint(j&7))
setbits(h, b, j+1, k-1)
b[j/8] &= byte(^(1 << uint(j&7)))
}
} | [
"func",
"setbits",
"(",
"h",
"*",
"HashSet",
",",
"b",
"[",
"]",
"byte",
",",
"i",
"int",
",",
"k",
"int",
")",
"{",
"h",
".",
"addB",
"(",
"b",
")",
"\n",
"if",
"k",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"for",
"j",
":=",
"i",
";",
... | // set up to k bits at index i and greater | [
"set",
"up",
"to",
"k",
"bits",
"at",
"index",
"i",
"and",
"greater"
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/smhasher/smhasher.go#L347-L357 |
145,262 | tildeleb/hashland | threefish/threefish.go | NewSize | func NewSize(size int) (*Cipher, error) {
var err error
var internal cipherInternal
switch size {
case 256:
internal, err = newThreefish256(nil, nil)
case 512:
internal, err = newThreefish512(nil, nil)
case 1024:
internal, err = newThreefish1024(nil, nil)
default:
... | go | func NewSize(size int) (*Cipher, error) {
var err error
var internal cipherInternal
switch size {
case 256:
internal, err = newThreefish256(nil, nil)
case 512:
internal, err = newThreefish512(nil, nil)
case 1024:
internal, err = newThreefish1024(nil, nil)
default:
... | [
"func",
"NewSize",
"(",
"size",
"int",
")",
"(",
"*",
"Cipher",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"internal",
"cipherInternal",
"\n\n",
"switch",
"size",
"{",
"case",
"256",
":",
"internal",
",",
"err",
"=",
"newThreefish256",
... | // NewSize creates and returns a Cipher.
//
// The size argument is the requested Threefish state size
// which is also the key and block size. Supported sizes see constants section.
// | [
"NewSize",
"creates",
"and",
"returns",
"a",
"Cipher",
".",
"The",
"size",
"argument",
"is",
"the",
"requested",
"Threefish",
"state",
"size",
"which",
"is",
"also",
"the",
"key",
"and",
"block",
"size",
".",
"Supported",
"sizes",
"see",
"constants",
"sectio... | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/threefish/threefish.go#L143-L158 |
145,263 | tildeleb/hashland | skein/skein.go | New | func New(stateSize, outputSize int) (*Skein, error) {
if stateSize != 256 && stateSize != 512 && stateSize != 1024 {
return nil, stateSizeError(stateSize)
}
if outputSize <= 0 {
return nil, outputSizeError(outputSize)
}
s := new(Skein)
s.setup(stateSize, outputSize)
s.config = newSkeinConfiguration(s)
s.con... | go | func New(stateSize, outputSize int) (*Skein, error) {
if stateSize != 256 && stateSize != 512 && stateSize != 1024 {
return nil, stateSizeError(stateSize)
}
if outputSize <= 0 {
return nil, outputSizeError(outputSize)
}
s := new(Skein)
s.setup(stateSize, outputSize)
s.config = newSkeinConfiguration(s)
s.con... | [
"func",
"New",
"(",
"stateSize",
",",
"outputSize",
"int",
")",
"(",
"*",
"Skein",
",",
"error",
")",
"{",
"if",
"stateSize",
"!=",
"256",
"&&",
"stateSize",
"!=",
"512",
"&&",
"stateSize",
"!=",
"1024",
"{",
"return",
"nil",
",",
"stateSizeError",
"("... | // Initializes the Skein hash instance.
//
// stateSize
// The Skein state size of the hash in bits. Supported values
// are 256, 512, and 1024
// outputSize
// The output size of the hash in bits. Output size must greater
// than zero.
// | [
"Initializes",
"the",
"Skein",
"hash",
"instance",
".",
"stateSize",
"The",
"Skein",
"state",
"size",
"of",
"the",
"hash",
"in",
"bits",
".",
"Supported",
"values",
"are",
"256",
"512",
"and",
"1024",
"outputSize",
"The",
"output",
"size",
"of",
"the",
"ha... | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/skein.go#L153-L168 |
145,264 | tildeleb/hashland | skein/skein.go | setup | func (s *Skein) setup(stateSize, outputSize int) {
s.cipherStateWords = stateSize / 64
s.hashSize = outputSize
s.outputBytes = (outputSize + 7) / 8
// Figure out which cipher we need based on
// the state size
s.cipher, _ = threefish.NewSize(stateSize)
// Allocate buffers
s.inputBuffer = make([]byte, s.ciphe... | go | func (s *Skein) setup(stateSize, outputSize int) {
s.cipherStateWords = stateSize / 64
s.hashSize = outputSize
s.outputBytes = (outputSize + 7) / 8
// Figure out which cipher we need based on
// the state size
s.cipher, _ = threefish.NewSize(stateSize)
// Allocate buffers
s.inputBuffer = make([]byte, s.ciphe... | [
"func",
"(",
"s",
"*",
"Skein",
")",
"setup",
"(",
"stateSize",
",",
"outputSize",
"int",
")",
"{",
"s",
".",
"cipherStateWords",
"=",
"stateSize",
"/",
"64",
"\n\n",
"s",
".",
"hashSize",
"=",
"outputSize",
"\n",
"s",
".",
"outputBytes",
"=",
"(",
"... | // Initialize the internal variables
// | [
"Initialize",
"the",
"internal",
"variables"
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/skein.go#L210-L227 |
145,265 | tildeleb/hashland | skein/skein.go | initialize | func (s *Skein) initialize() {
// Copy the configuration value to the state
for i := 0; i < len(s.state); i++ {
s.state[i] = s.config.configValue[i]
}
// Set up tweak for message block
s.ubiParameters.startNewBlockType(uint64(Message))
s.bytesFilled = 0
} | go | func (s *Skein) initialize() {
// Copy the configuration value to the state
for i := 0; i < len(s.state); i++ {
s.state[i] = s.config.configValue[i]
}
// Set up tweak for message block
s.ubiParameters.startNewBlockType(uint64(Message))
s.bytesFilled = 0
} | [
"func",
"(",
"s",
"*",
"Skein",
")",
"initialize",
"(",
")",
"{",
"// Copy the configuration value to the state",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"s",
".",
"state",
")",
";",
"i",
"++",
"{",
"s",
".",
"state",
"[",
"i",
"]",
"=",
... | // Standard internal initialize function.
// | [
"Standard",
"internal",
"initialize",
"function",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/skein.go#L255-L263 |
145,266 | tildeleb/hashland | skein/skein.go | initializeConf | func (s *Skein) initializeConf(initializationType int) {
switch initializationType {
case normal:
s.initialize() // Normal initialization
case zeroedState:
copy(s.state, nullStateWords[:]) // Start with a all zero state
case chainedState:
// Keep the state as it is and do nothing
case chainedConfig:
// Gen... | go | func (s *Skein) initializeConf(initializationType int) {
switch initializationType {
case normal:
s.initialize() // Normal initialization
case zeroedState:
copy(s.state, nullStateWords[:]) // Start with a all zero state
case chainedState:
// Keep the state as it is and do nothing
case chainedConfig:
// Gen... | [
"func",
"(",
"s",
"*",
"Skein",
")",
"initializeConf",
"(",
"initializationType",
"int",
")",
"{",
"switch",
"initializationType",
"{",
"case",
"normal",
":",
"s",
".",
"initialize",
"(",
")",
"// Normal initialization",
"\n",
"case",
"zeroedState",
":",
"copy... | // Internal initialization function that sets up the state variables
// in several ways. Used during set-up of MAC key hash for example.
// | [
"Internal",
"initialization",
"function",
"that",
"sets",
"up",
"the",
"state",
"variables",
"in",
"several",
"ways",
".",
"Used",
"during",
"set",
"-",
"up",
"of",
"MAC",
"key",
"hash",
"for",
"example",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/skein.go#L268-L282 |
145,267 | tildeleb/hashland | skein/skein.go | Update | func (s *Skein) Update(input []byte) {
// Fill input buffer
for i := 0; i < len(input); i++ {
// Do a transform if the input buffer is filled
if s.bytesFilled == s.cipherStateWords*8 {
// Copy input buffer to cipher input buffer
for i := 0; i < s.cipherStateWords; i++ {
s.cipherInput[i] = binary.Little... | go | func (s *Skein) Update(input []byte) {
// Fill input buffer
for i := 0; i < len(input); i++ {
// Do a transform if the input buffer is filled
if s.bytesFilled == s.cipherStateWords*8 {
// Copy input buffer to cipher input buffer
for i := 0; i < s.cipherStateWords; i++ {
s.cipherInput[i] = binary.Little... | [
"func",
"(",
"s",
"*",
"Skein",
")",
"Update",
"(",
"input",
"[",
"]",
"byte",
")",
"{",
"// Fill input buffer",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"input",
")",
";",
"i",
"++",
"{",
"// Do a transform if the input buffer is filled",
"if",... | // Update Skein digest with the next part of the message.
//
// input
// Byte slice that contains data to hash.
// | [
"Update",
"Skein",
"digest",
"with",
"the",
"next",
"part",
"of",
"the",
"message",
".",
"input",
"Byte",
"slice",
"that",
"contains",
"data",
"to",
"hash",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/skein.go#L349-L372 |
145,268 | tildeleb/hashland | skein/skein.go | DoFinal | func (s *Skein) DoFinal() (hash []byte) {
hash = s.finalIntern()
s.Reset()
return
} | go | func (s *Skein) DoFinal() (hash []byte) {
hash = s.finalIntern()
s.Reset()
return
} | [
"func",
"(",
"s",
"*",
"Skein",
")",
"DoFinal",
"(",
")",
"(",
"hash",
"[",
"]",
"byte",
")",
"{",
"hash",
"=",
"s",
".",
"finalIntern",
"(",
")",
"\n",
"s",
".",
"Reset",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // Finalize Skein digest and return the hash.
//
// This method resets the Skein digest after it computed the digest. An
// application may reuse this Skein context to compute another digest.
// | [
"Finalize",
"Skein",
"digest",
"and",
"return",
"the",
"hash",
".",
"This",
"method",
"resets",
"the",
"Skein",
"digest",
"after",
"it",
"computed",
"the",
"digest",
".",
"An",
"application",
"may",
"reuse",
"this",
"Skein",
"context",
"to",
"compute",
"anot... | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/skein.go#L379-L383 |
145,269 | tildeleb/hashland | skein/skein.go | finalPad | func (s *Skein) finalPad() {
// Pad left over space in input buffer with zeros
// and copy to cipher input buffer
for i := s.bytesFilled; i < len(s.inputBuffer); i++ {
s.inputBuffer[i] = 0
}
for i := 0; i < s.cipherStateWords; i++ {
s.cipherInput[i] = binary.LittleEndian.Uint64(s.inputBuffer[i*8 : i*8+8])
}
... | go | func (s *Skein) finalPad() {
// Pad left over space in input buffer with zeros
// and copy to cipher input buffer
for i := s.bytesFilled; i < len(s.inputBuffer); i++ {
s.inputBuffer[i] = 0
}
for i := 0; i < s.cipherStateWords; i++ {
s.cipherInput[i] = binary.LittleEndian.Uint64(s.inputBuffer[i*8 : i*8+8])
}
... | [
"func",
"(",
"s",
"*",
"Skein",
")",
"finalPad",
"(",
")",
"{",
"// Pad left over space in input buffer with zeros",
"// and copy to cipher input buffer",
"for",
"i",
":=",
"s",
".",
"bytesFilled",
";",
"i",
"<",
"len",
"(",
"s",
".",
"inputBuffer",
")",
";",
... | // Internal function that performs a final block processing
// and returns the resulting data. Used during set-up of
// MAC key hash.
// | [
"Internal",
"function",
"that",
"performs",
"a",
"final",
"block",
"processing",
"and",
"returns",
"the",
"resulting",
"data",
".",
"Used",
"during",
"set",
"-",
"up",
"of",
"MAC",
"key",
"hash",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/skein.go#L446-L459 |
145,270 | tildeleb/hashland | skein/skein.go | putBytes | func (s *Skein) putBytes(input []uint64, output []byte) {
var j uint
for i := 0; i < len(output); i++ {
output[i] = byte(input[i/8] >> j)
j = (j + 8) & 63
}
} | go | func (s *Skein) putBytes(input []uint64, output []byte) {
var j uint
for i := 0; i < len(output); i++ {
output[i] = byte(input[i/8] >> j)
j = (j + 8) & 63
}
} | [
"func",
"(",
"s",
"*",
"Skein",
")",
"putBytes",
"(",
"input",
"[",
"]",
"uint64",
",",
"output",
"[",
"]",
"byte",
")",
"{",
"var",
"j",
"uint",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"output",
")",
";",
"i",
"++",
"{",
"o... | // Disassmble an array of words into a byte array.
//
// input
// The input array.
// output
// The byte output array.
// byteCount
// The number of bytes to disassemble, arbitrary length.
// | [
"Disassmble",
"an",
"array",
"of",
"words",
"into",
"a",
"byte",
"array",
".",
"input",
"The",
"input",
"array",
".",
"output",
"The",
"byte",
"output",
"array",
".",
"byteCount",
"The",
"number",
"of",
"bytes",
"to",
"disassemble",
"arbitrary",
"length",
... | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/skein.go#L470-L476 |
145,271 | tildeleb/hashland | hashtable/hashtable.go | NextLog2 | func NextLog2(x uint32) uint32 {
if x <= 1 {
return x
}
x--
n := uint32(0)
y := uint32(0)
y = x >> 16
if y != 0 {
n += 16
x = y
}
y = x >> 8
if y != 0 {
n += 8
x = y
}
y = x >> 4
if y != 0 {
n += 4
x = y
}
y = x >> 2
if y != 0 {
n += 2
x = y
}
y = x >> 1
if y != 0 {
return n + 2
... | go | func NextLog2(x uint32) uint32 {
if x <= 1 {
return x
}
x--
n := uint32(0)
y := uint32(0)
y = x >> 16
if y != 0 {
n += 16
x = y
}
y = x >> 8
if y != 0 {
n += 8
x = y
}
y = x >> 4
if y != 0 {
n += 4
x = y
}
y = x >> 2
if y != 0 {
n += 2
x = y
}
y = x >> 1
if y != 0 {
return n + 2
... | [
"func",
"NextLog2",
"(",
"x",
"uint32",
")",
"uint32",
"{",
"if",
"x",
"<=",
"1",
"{",
"return",
"x",
"\n",
"}",
"\n",
"x",
"--",
"\n",
"n",
":=",
"uint32",
"(",
"0",
")",
"\n",
"y",
":=",
"uint32",
"(",
"0",
")",
"\n",
"y",
"=",
"x",
">>",... | // Henry Warren, "Hacker's Delight", ch. 5.3 | [
"Henry",
"Warren",
"Hacker",
"s",
"Delight",
"ch",
".",
"5",
".",
"3"
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/hashtable/hashtable.go#L57-L89 |
145,272 | tildeleb/hashland | sbox/sbox.go | New | func New(seed uint32) nhash.HashF32 {
s := new(State)
s.seed = seed
return s
} | go | func New(seed uint32) nhash.HashF32 {
s := new(State)
s.seed = seed
return s
} | [
"func",
"New",
"(",
"seed",
"uint32",
")",
"nhash",
".",
"HashF32",
"{",
"s",
":=",
"new",
"(",
"State",
")",
"\n",
"s",
".",
"seed",
"=",
"seed",
"\n",
"return",
"s",
"\n",
"}"
] | // New returns a new hash.HashF32 interface that computes a 32 bit CrapWow hash. | [
"New",
"returns",
"a",
"new",
"hash",
".",
"HashF32",
"interface",
"that",
"computes",
"a",
"32",
"bit",
"CrapWow",
"hash",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/sbox/sbox.go#L62-L66 |
145,273 | tildeleb/hashland | jenkins/jenkins.go | mix64 | func mix64(a, b, c uint64) (uint64, uint64, uint64) {
a = a - b
a = a - c
a = a ^ (c >> 43)
b = b - c
b = b - a
b = b ^ (a << 9)
c = c - a
c = c - b
c = c ^ (b >> 8)
a = a - b
a = a - c
a = a ^ (c >> 38)
b = b - c
b = b - a
b = b ^ (a << 23)
c = c - a
c = c - b
c = c ^ (b >> 5)
a = a - b
a = a - c
... | go | func mix64(a, b, c uint64) (uint64, uint64, uint64) {
a = a - b
a = a - c
a = a ^ (c >> 43)
b = b - c
b = b - a
b = b ^ (a << 9)
c = c - a
c = c - b
c = c ^ (b >> 8)
a = a - b
a = a - c
a = a ^ (c >> 38)
b = b - c
b = b - a
b = b ^ (a << 23)
c = c - a
c = c - b
c = c ^ (b >> 5)
a = a - b
a = a - c
... | [
"func",
"mix64",
"(",
"a",
",",
"b",
",",
"c",
"uint64",
")",
"(",
"uint64",
",",
"uint64",
",",
"uint64",
")",
"{",
"a",
"=",
"a",
"-",
"b",
"\n",
"a",
"=",
"a",
"-",
"c",
"\n",
"a",
"=",
"a",
"^",
"(",
"c",
">>",
"43",
")",
"\n",
"b",... | // original mix function | [
"original",
"mix",
"function"
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/jenkins/jenkins.go#L194-L232 |
145,274 | tildeleb/hashland | jenkins/jenkins.go | mix64alt | func mix64alt(a, b, c uint64) (uint64, uint64, uint64) {
a -= b - c ^ (c >> 43)
b -= c - a ^ (a << 9)
c -= a - b ^ (b >> 8)
a -= b - c ^ (c >> 38)
b -= c - a ^ (a << 23)
c -= a - b ^ (b >> 5)
a -= b - c ^ (c >> 35)
b -= c - a ^ (a << 49)
c -= a - b ^ (b >> 11)
a -= b - c ^ (c >> 12)
b -= c - a ^ (a << 18)
c... | go | func mix64alt(a, b, c uint64) (uint64, uint64, uint64) {
a -= b - c ^ (c >> 43)
b -= c - a ^ (a << 9)
c -= a - b ^ (b >> 8)
a -= b - c ^ (c >> 38)
b -= c - a ^ (a << 23)
c -= a - b ^ (b >> 5)
a -= b - c ^ (c >> 35)
b -= c - a ^ (a << 49)
c -= a - b ^ (b >> 11)
a -= b - c ^ (c >> 12)
b -= c - a ^ (a << 18)
c... | [
"func",
"mix64alt",
"(",
"a",
",",
"b",
",",
"c",
"uint64",
")",
"(",
"uint64",
",",
"uint64",
",",
"uint64",
")",
"{",
"a",
"-=",
"b",
"-",
"c",
"^",
"(",
"c",
">>",
"43",
")",
"\n",
"b",
"-=",
"c",
"-",
"a",
"^",
"(",
"a",
"<<",
"9",
... | // restated mix function better for gofmt | [
"restated",
"mix",
"function",
"better",
"for",
"gofmt"
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/jenkins/jenkins.go#L235-L249 |
145,275 | tildeleb/hashland | jenkins/jenkins.go | mix64a | func mix64a(a, b, c uint64) (uint64, uint64, uint64) {
a -= b - c ^ (c >> 43)
b -= c - a ^ (a << 9)
return a, b, c
} | go | func mix64a(a, b, c uint64) (uint64, uint64, uint64) {
a -= b - c ^ (c >> 43)
b -= c - a ^ (a << 9)
return a, b, c
} | [
"func",
"mix64a",
"(",
"a",
",",
"b",
",",
"c",
"uint64",
")",
"(",
"uint64",
",",
"uint64",
",",
"uint64",
")",
"{",
"a",
"-=",
"b",
"-",
"c",
"^",
"(",
"c",
">>",
"43",
")",
"\n",
"b",
"-=",
"c",
"-",
"a",
"^",
"(",
"a",
"<<",
"9",
")... | // the following functions can be inlined | [
"the",
"following",
"functions",
"can",
"be",
"inlined"
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/jenkins/jenkins.go#L252-L256 |
145,276 | tildeleb/hashland | jenkins/jenkins.go | mix1 | func mix1(a, b, c uint32) (uint32, uint32, uint32) {
a -= c
a ^= rot(c, 4)
c += b
b -= a
b ^= rot(a, 6)
a += c
c -= b
c ^= rot(b, 8)
b += a
//a -= c; a ^= c << 4 | c >> (32 - 4); c += b;
//b -= a; b ^= a << 6 | a >> (32 - 6); a += c;
return a, b, c
} | go | func mix1(a, b, c uint32) (uint32, uint32, uint32) {
a -= c
a ^= rot(c, 4)
c += b
b -= a
b ^= rot(a, 6)
a += c
c -= b
c ^= rot(b, 8)
b += a
//a -= c; a ^= c << 4 | c >> (32 - 4); c += b;
//b -= a; b ^= a << 6 | a >> (32 - 6); a += c;
return a, b, c
} | [
"func",
"mix1",
"(",
"a",
",",
"b",
",",
"c",
"uint32",
")",
"(",
"uint32",
",",
"uint32",
",",
"uint32",
")",
"{",
"a",
"-=",
"c",
"\n",
"a",
"^=",
"rot",
"(",
"c",
",",
"4",
")",
"\n",
"c",
"+=",
"b",
"\n",
"b",
"-=",
"a",
"\n",
"b",
... | // current gc compilers can't inline long functions so we have to split mix into 2 | [
"current",
"gc",
"compilers",
"can",
"t",
"inline",
"long",
"functions",
"so",
"we",
"have",
"to",
"split",
"mix",
"into",
"2"
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/jenkins/jenkins.go#L474-L487 |
145,277 | tildeleb/hashland | jenkins/jenkins.go | XHashWords | func XHashWords(k []uint32, length int, seed uint32) uint32 {
var a, b, c uint32
var rot = func(x, k uint32) uint32 {
return x<<k | x>>(32-k)
}
var mix = func() {
a -= c
a ^= rot(c, 4)
c += b
b -= a
b ^= rot(a, 6)
a += c
c -= b
c ^= rot(b, 8)
b += a
a -= c
a ^= rot(c, 16)
c += b
b -= a
... | go | func XHashWords(k []uint32, length int, seed uint32) uint32 {
var a, b, c uint32
var rot = func(x, k uint32) uint32 {
return x<<k | x>>(32-k)
}
var mix = func() {
a -= c
a ^= rot(c, 4)
c += b
b -= a
b ^= rot(a, 6)
a += c
c -= b
c ^= rot(b, 8)
b += a
a -= c
a ^= rot(c, 16)
c += b
b -= a
... | [
"func",
"XHashWords",
"(",
"k",
"[",
"]",
"uint32",
",",
"length",
"int",
",",
"seed",
"uint32",
")",
"uint32",
"{",
"var",
"a",
",",
"b",
",",
"c",
"uint32",
"\n",
"var",
"rot",
"=",
"func",
"(",
"x",
",",
"k",
"uint32",
")",
"uint32",
"{",
"r... | // This is an example of how I could like to code hash functions like this.
// Using closures over the state and expecting thme to be inlined | [
"This",
"is",
"an",
"example",
"of",
"how",
"I",
"could",
"like",
"to",
"code",
"hash",
"functions",
"like",
"this",
".",
"Using",
"closures",
"over",
"the",
"state",
"and",
"expecting",
"thme",
"to",
"be",
"inlined"
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/jenkins/jenkins.go#L622-L691 |
145,278 | tildeleb/hashland | jenkins/jenkins.go | Sum32 | func Sum32(data []byte, seed uint32) uint32 {
rpc, _ := Jenkins364(data, len(data), seed, seed)
return rpc
} | go | func Sum32(data []byte, seed uint32) uint32 {
rpc, _ := Jenkins364(data, len(data), seed, seed)
return rpc
} | [
"func",
"Sum32",
"(",
"data",
"[",
"]",
"byte",
",",
"seed",
"uint32",
")",
"uint32",
"{",
"rpc",
",",
"_",
":=",
"Jenkins364",
"(",
"data",
",",
"len",
"(",
"data",
")",
",",
"seed",
",",
"seed",
")",
"\n",
"return",
"rpc",
"\n",
"}"
] | // const Size = 4
// Sum32 returns the 32 bit hash of data given the seed.
// This is code is what I started with before I added the hash.Hash and hash.Hash32 interfaces. | [
"const",
"Size",
"=",
"4",
"Sum32",
"returns",
"the",
"32",
"bit",
"hash",
"of",
"data",
"given",
"the",
"seed",
".",
"This",
"is",
"code",
"is",
"what",
"I",
"started",
"with",
"before",
"I",
"added",
"the",
"hash",
".",
"Hash",
"and",
"hash",
".",
... | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/jenkins/jenkins.go#L868-L871 |
145,279 | tildeleb/hashland | jenkins/jenkins.go | New | func New(seed uint32) hash.Hash32 {
s := new(State332c)
s.seed = seed
s.Reset()
return s
} | go | func New(seed uint32) hash.Hash32 {
s := new(State332c)
s.seed = seed
s.Reset()
return s
} | [
"func",
"New",
"(",
"seed",
"uint32",
")",
"hash",
".",
"Hash32",
"{",
"s",
":=",
"new",
"(",
"State332c",
")",
"\n",
"s",
".",
"seed",
"=",
"seed",
"\n",
"s",
".",
"Reset",
"(",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // New returns a new hash.Hash32 interface that computes a 32 bit jenkins lookup3 hash. | [
"New",
"returns",
"a",
"new",
"hash",
".",
"Hash32",
"interface",
"that",
"computes",
"a",
"32",
"bit",
"jenkins",
"lookup3",
"hash",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/jenkins/jenkins.go#L874-L879 |
145,280 | tildeleb/hashland | jenkins/jenkins.go | New332c | func New332c(seed uint32) nhash.HashF32 {
s := new(State332c)
s.seed = seed
s.Reset()
return s
} | go | func New332c(seed uint32) nhash.HashF32 {
s := new(State332c)
s.seed = seed
s.Reset()
return s
} | [
"func",
"New332c",
"(",
"seed",
"uint32",
")",
"nhash",
".",
"HashF32",
"{",
"s",
":=",
"new",
"(",
"State332c",
")",
"\n",
"s",
".",
"seed",
"=",
"seed",
"\n",
"s",
".",
"Reset",
"(",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // New returns a new nhash.HashF32 interface that computes a 32 bit jenkins lookup3 hash. | [
"New",
"returns",
"a",
"new",
"nhash",
".",
"HashF32",
"interface",
"that",
"computes",
"a",
"32",
"bit",
"jenkins",
"lookup3",
"hash",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/jenkins/jenkins.go#L882-L887 |
145,281 | tildeleb/hashland | jenkins/jenkins.go | Sum32 | func (d *State332c) Sum32() uint32 {
d.pc, d.pb = Jenkins364(d.tail, len(d.tail), d.pc, d.pb)
d.hash = d.pc
return d.hash
} | go | func (d *State332c) Sum32() uint32 {
d.pc, d.pb = Jenkins364(d.tail, len(d.tail), d.pc, d.pb)
d.hash = d.pc
return d.hash
} | [
"func",
"(",
"d",
"*",
"State332c",
")",
"Sum32",
"(",
")",
"uint32",
"{",
"d",
".",
"pc",
",",
"d",
".",
"pb",
"=",
"Jenkins364",
"(",
"d",
".",
"tail",
",",
"len",
"(",
"d",
".",
"tail",
")",
",",
"d",
".",
"pc",
",",
"d",
".",
"pb",
")... | // Return the current hash as a 32 bit unsigned type. | [
"Return",
"the",
"current",
"hash",
"as",
"a",
"32",
"bit",
"unsigned",
"type",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/jenkins/jenkins.go#L939-L943 |
145,282 | tildeleb/hashland | jenkins/jenkins.go | Hash32 | func (d *State332c) Hash32(b []byte, seeds ...uint32) uint32 {
//fmt.Printf("len(b)=%d, b=%x\n", len(b), b)
/*
switch len(seeds) {
case 2:
d.pb = seeds[1]
fallthrough
case 1:
d.pc = seeds[0]
default:
d.pc, d.pb = 0, 0
}
*/
d.pc, d.pb = 0, 0
d.pc, d.pb = Jenkins364(b, len(b), d.pc, d.pb)
d.h... | go | func (d *State332c) Hash32(b []byte, seeds ...uint32) uint32 {
//fmt.Printf("len(b)=%d, b=%x\n", len(b), b)
/*
switch len(seeds) {
case 2:
d.pb = seeds[1]
fallthrough
case 1:
d.pc = seeds[0]
default:
d.pc, d.pb = 0, 0
}
*/
d.pc, d.pb = 0, 0
d.pc, d.pb = Jenkins364(b, len(b), d.pc, d.pb)
d.h... | [
"func",
"(",
"d",
"*",
"State332c",
")",
"Hash32",
"(",
"b",
"[",
"]",
"byte",
",",
"seeds",
"...",
"uint32",
")",
"uint32",
"{",
"//fmt.Printf(\"len(b)=%d, b=%x\\n\", len(b), b)",
"/*\n\t\tswitch len(seeds) {\n\t\tcase 2:\n\t\t\td.pb = seeds[1]\n\t\t\tfallthrough\n\t\tcase 1... | // Given b as input and an optional 32 bit seed return the Jenkins lookup3 hash c bits. | [
"Given",
"b",
"as",
"input",
"and",
"an",
"optional",
"32",
"bit",
"seed",
"return",
"the",
"Jenkins",
"lookup3",
"hash",
"c",
"bits",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/jenkins/jenkins.go#L946-L964 |
145,283 | tildeleb/hashland | spooky/spooky.go | Mix | func Mix(data []uint64, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 uint64) (uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64) {
s0 += data[0]; s2 ^= s10; s11 ^= s0; s0 = Rot64(s0,11); s11 += s1;
s1 += data[1]; s3 ^= s11; s0 ^= s1; s... | go | func Mix(data []uint64, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 uint64) (uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64, uint64) {
s0 += data[0]; s2 ^= s10; s11 ^= s0; s0 = Rot64(s0,11); s11 += s1;
s1 += data[1]; s3 ^= s11; s0 ^= s1; s... | [
"func",
"Mix",
"(",
"data",
"[",
"]",
"uint64",
",",
"s0",
",",
"s1",
",",
"s2",
",",
"s3",
",",
"s4",
",",
"s5",
",",
"s6",
",",
"s7",
",",
"s8",
",",
"s9",
",",
"s10",
",",
"s11",
"uint64",
")",
"(",
"uint64",
",",
"uint64",
",",
"uint64"... | //
// This is used if the input is 96 bytes long or longer.
//
// The internal state is fully overwritten every 96 bytes.
// Every input bit appears to cause at least 128 bits of entropy
// before 96 other bytes are combined, when run forward or backward
// For every input bit,
// Two inputs differing in just that ... | [
"This",
"is",
"used",
"if",
"the",
"input",
"is",
"96",
"bytes",
"long",
"or",
"longer",
".",
"The",
"internal",
"state",
"is",
"fully",
"overwritten",
"every",
"96",
"bytes",
".",
"Every",
"input",
"bit",
"appears",
"to",
"cause",
"at",
"least",
"128",
... | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/spooky/spooky.go#L76-L90 |
145,284 | tildeleb/hashland | spooky/spooky.go | SpookyHash128 | func SpookyHash128(in []byte, hash1, hash2 uint64) (uint64, uint64) {
b := make([]byte, 96, 96)
length := len(in)
if (length < sc_bufSize) {
h1, h2 := SpookyHashShort(in, hash1, hash2)
return h1, h2
}
//fmt.Printf("SpookyHash128: len(in)=%d, hash1=0x%08x, hash2=0x%08x, in=%x\n", len(... | go | func SpookyHash128(in []byte, hash1, hash2 uint64) (uint64, uint64) {
b := make([]byte, 96, 96)
length := len(in)
if (length < sc_bufSize) {
h1, h2 := SpookyHashShort(in, hash1, hash2)
return h1, h2
}
//fmt.Printf("SpookyHash128: len(in)=%d, hash1=0x%08x, hash2=0x%08x, in=%x\n", len(... | [
"func",
"SpookyHash128",
"(",
"in",
"[",
"]",
"byte",
",",
"hash1",
",",
"hash2",
"uint64",
")",
"(",
"uint64",
",",
"uint64",
")",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"96",
",",
"96",
")",
"\n",
"length",
":=",
"len",
"(",
"in"... | // do the whole hash in one call | [
"do",
"the",
"whole",
"hash",
"in",
"one",
"call"
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/spooky/spooky.go#L137-L183 |
145,285 | tildeleb/hashland | skein/ubiTweak.go | setFirstBlock | func (u *ubiTweak) setFirstBlock(value bool) {
if value {
u.tweak[1] |= t1FlagFirst
} else {
u.tweak[1] &^= t1FlagFirst
}
} | go | func (u *ubiTweak) setFirstBlock(value bool) {
if value {
u.tweak[1] |= t1FlagFirst
} else {
u.tweak[1] &^= t1FlagFirst
}
} | [
"func",
"(",
"u",
"*",
"ubiTweak",
")",
"setFirstBlock",
"(",
"value",
"bool",
")",
"{",
"if",
"value",
"{",
"u",
".",
"tweak",
"[",
"1",
"]",
"|=",
"t1FlagFirst",
"\n",
"}",
"else",
"{",
"u",
".",
"tweak",
"[",
"1",
"]",
"&^=",
"t1FlagFirst",
"\... | /**
* Sets status of the first block flag.
*/ | [
"Sets",
"status",
"of",
"the",
"first",
"block",
"flag",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/ubiTweak.go#L53-L59 |
145,286 | tildeleb/hashland | skein/ubiTweak.go | setTreeLevel | func (u *ubiTweak) setTreeLevel(value int) {
u.tweak[1] &^= uint64(0x7f) << 48
u.tweak[1] |= uint64(value) << 48
} | go | func (u *ubiTweak) setTreeLevel(value int) {
u.tweak[1] &^= uint64(0x7f) << 48
u.tweak[1] |= uint64(value) << 48
} | [
"func",
"(",
"u",
"*",
"ubiTweak",
")",
"setTreeLevel",
"(",
"value",
"int",
")",
"{",
"u",
".",
"tweak",
"[",
"1",
"]",
"&^=",
"uint64",
"(",
"0x7f",
")",
"<<",
"48",
"\n",
"u",
".",
"tweak",
"[",
"1",
"]",
"|=",
"uint64",
"(",
"value",
")",
... | /**
* Set the current tree level.
*
* @param value
* the tree level
*/ | [
"Set",
"the",
"current",
"tree",
"level",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/ubiTweak.go#L110-L113 |
145,287 | tildeleb/hashland | skein/ubiTweak.go | getBitsProcessed | func (u *ubiTweak) getBitsProcessed() (low, high uint64) {
low = u.tweak[0]
high = u.tweak[1] & 0xffffffff
return
} | go | func (u *ubiTweak) getBitsProcessed() (low, high uint64) {
low = u.tweak[0]
high = u.tweak[1] & 0xffffffff
return
} | [
"func",
"(",
"u",
"*",
"ubiTweak",
")",
"getBitsProcessed",
"(",
")",
"(",
"low",
",",
"high",
"uint64",
")",
"{",
"low",
"=",
"u",
".",
"tweak",
"[",
"0",
"]",
"\n",
"high",
"=",
"u",
".",
"tweak",
"[",
"1",
"]",
"&",
"0xffffffff",
"\n",
"retu... | /**
* Gets the number of bytes processed so far, inclusive.
*
* @return
* Number of processed bytes.
*/ | [
"Gets",
"the",
"number",
"of",
"bytes",
"processed",
"so",
"far",
"inclusive",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/ubiTweak.go#L121-L125 |
145,288 | tildeleb/hashland | skein/ubiTweak.go | setBitsProcessed | func (u *ubiTweak) setBitsProcessed(value uint64) {
u.tweak[0] = value
u.tweak[1] &= 0xffffffff00000000
} | go | func (u *ubiTweak) setBitsProcessed(value uint64) {
u.tweak[0] = value
u.tweak[1] &= 0xffffffff00000000
} | [
"func",
"(",
"u",
"*",
"ubiTweak",
")",
"setBitsProcessed",
"(",
"value",
"uint64",
")",
"{",
"u",
".",
"tweak",
"[",
"0",
"]",
"=",
"value",
"\n",
"u",
".",
"tweak",
"[",
"1",
"]",
"&=",
"0xffffffff00000000",
"\n",
"}"
] | /**
* Set the number of bytes processed so far
*
* @param value
* The number of bits to set - low 64 bits
*/ | [
"Set",
"the",
"number",
"of",
"bytes",
"processed",
"so",
"far"
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/ubiTweak.go#L133-L136 |
145,289 | tildeleb/hashland | skein/ubiTweak.go | addBytesProcessed | func (u *ubiTweak) addBytesProcessed(value int) {
const len = 3
carry := uint64(value)
var words [len]uint64
words[0] = u.tweak[0] & 0xffffffff
words[1] = (u.tweak[0] >> 32) & 0xffffffff
words[2] = u.tweak[1] & 0xffffffff
for i := 0; i < len; i++ {
carry += words[i]
words[... | go | func (u *ubiTweak) addBytesProcessed(value int) {
const len = 3
carry := uint64(value)
var words [len]uint64
words[0] = u.tweak[0] & 0xffffffff
words[1] = (u.tweak[0] >> 32) & 0xffffffff
words[2] = u.tweak[1] & 0xffffffff
for i := 0; i < len; i++ {
carry += words[i]
words[... | [
"func",
"(",
"u",
"*",
"ubiTweak",
")",
"addBytesProcessed",
"(",
"value",
"int",
")",
"{",
"const",
"len",
"=",
"3",
"\n",
"carry",
":=",
"uint64",
"(",
"value",
")",
"\n\n",
"var",
"words",
"[",
"len",
"]",
"uint64",
"\n\n",
"words",
"[",
"0",
"]... | /**
* Add number of processed bytes.
*
* Adds the integer value to the 96-bit field of processed
* bytes.
*
* @param value
* Number of processed bytes.
*/ | [
"Add",
"number",
"of",
"processed",
"bytes",
".",
"Adds",
"the",
"integer",
"value",
"to",
"the",
"96",
"-",
"bit",
"field",
"of",
"processed",
"bytes",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/ubiTweak.go#L147-L165 |
145,290 | tildeleb/hashland | skein/ubiTweak.go | startNewBlockType | func (u *ubiTweak) startNewBlockType(t uint64) {
u.setBitsProcessed(0)
u.setBlockType(t)
u.setFirstBlock(true)
} | go | func (u *ubiTweak) startNewBlockType(t uint64) {
u.setBitsProcessed(0)
u.setBlockType(t)
u.setFirstBlock(true)
} | [
"func",
"(",
"u",
"*",
"ubiTweak",
")",
"startNewBlockType",
"(",
"t",
"uint64",
")",
"{",
"u",
".",
"setBitsProcessed",
"(",
"0",
")",
"\n",
"u",
".",
"setBlockType",
"(",
"t",
")",
"\n",
"u",
".",
"setFirstBlock",
"(",
"true",
")",
"\n",
"}"
] | /**
* Starts a new UBI block type by setting BitsProcessed to zero, setting
* the first flag, and setting the block type.
*
* @param type
* The UBI block type of the new block
*/ | [
"Starts",
"a",
"new",
"UBI",
"block",
"type",
"by",
"setting",
"BitsProcessed",
"to",
"zero",
"setting",
"the",
"first",
"flag",
"and",
"setting",
"the",
"block",
"type",
"."
] | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/ubiTweak.go#L191-L195 |
145,291 | tildeleb/hashland | skein/skeinMac.go | NewMac | func NewMac(stateSize, outputSize int, key []byte) (s *SkeinMac, err error) {
s = new(SkeinMac)
s.skein, err = NewExtended(stateSize, outputSize, 0, key)
if err != nil {
return nil, err
}
s.stateSave = make([]uint64, s.skein.cipherStateWords)
copy(s.stateSave, s.skein.state)
return s... | go | func NewMac(stateSize, outputSize int, key []byte) (s *SkeinMac, err error) {
s = new(SkeinMac)
s.skein, err = NewExtended(stateSize, outputSize, 0, key)
if err != nil {
return nil, err
}
s.stateSave = make([]uint64, s.skein.cipherStateWords)
copy(s.stateSave, s.skein.state)
return s... | [
"func",
"NewMac",
"(",
"stateSize",
",",
"outputSize",
"int",
",",
"key",
"[",
"]",
"byte",
")",
"(",
"s",
"*",
"SkeinMac",
",",
"err",
"error",
")",
"{",
"s",
"=",
"new",
"(",
"SkeinMac",
")",
"\n",
"s",
".",
"skein",
",",
"err",
"=",
"NewExtend... | // Initializes a Skein MAC context.
//
// Initializes the context with this data and saves the resulting Skein
// state variables for further use.
//
// Applications call the normal Skein functions to update the MAC and
// get the final result.
//
// stateSize
// Which Skein state size to use. Supported values
/... | [
"Initializes",
"a",
"Skein",
"MAC",
"context",
".",
"Initializes",
"the",
"context",
"with",
"this",
"data",
"and",
"saves",
"the",
"resulting",
"Skein",
"state",
"variables",
"for",
"further",
"use",
".",
"Applications",
"call",
"the",
"normal",
"Skein",
"fun... | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/skeinMac.go#L41-L50 |
145,292 | tildeleb/hashland | skein/skeinMac.go | DoFinal | func (s *SkeinMac) DoFinal() (hash []byte) {
hash = s.skein.DoFinal()
s.Reset()
return
} | go | func (s *SkeinMac) DoFinal() (hash []byte) {
hash = s.skein.DoFinal()
s.Reset()
return
} | [
"func",
"(",
"s",
"*",
"SkeinMac",
")",
"DoFinal",
"(",
")",
"(",
"hash",
"[",
"]",
"byte",
")",
"{",
"hash",
"=",
"s",
".",
"skein",
".",
"DoFinal",
"(",
")",
"\n",
"s",
".",
"Reset",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // Finalize Skein MAC and return the hash.
//
// This method resets the Skein MAC after it computed the MAC. An
// application may reuse this Skein MAC context to compute another
// MAC with the same key and sizes.
// | [
"Finalize",
"Skein",
"MAC",
"and",
"return",
"the",
"hash",
".",
"This",
"method",
"resets",
"the",
"Skein",
"MAC",
"after",
"it",
"computed",
"the",
"MAC",
".",
"An",
"application",
"may",
"reuse",
"this",
"Skein",
"MAC",
"context",
"to",
"compute",
"anot... | 07375b562deaa8d6891f9618a04e94a0b98e2ee7 | https://github.com/tildeleb/hashland/blob/07375b562deaa8d6891f9618a04e94a0b98e2ee7/skein/skeinMac.go#L82-L86 |
145,293 | auroratechnologies/vangoh | vangoh.go | New | func New() *Vangoh {
return &Vangoh{
singleProvider: nil,
providersByOrg: make(map[string]secretProvider),
algorithm: crypto.SHA256.New,
includedHeaders: make(map[string]*regexp.Regexp),
maxTimeSkew: time.Minute * 15,
debug: false,
}
} | go | func New() *Vangoh {
return &Vangoh{
singleProvider: nil,
providersByOrg: make(map[string]secretProvider),
algorithm: crypto.SHA256.New,
includedHeaders: make(map[string]*regexp.Regexp),
maxTimeSkew: time.Minute * 15,
debug: false,
}
} | [
"func",
"New",
"(",
")",
"*",
"Vangoh",
"{",
"return",
"&",
"Vangoh",
"{",
"singleProvider",
":",
"nil",
",",
"providersByOrg",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"secretProvider",
")",
",",
"algorithm",
":",
"crypto",
".",
"SHA256",
".",
"Ne... | // Creates a new Vangoh instance with no secret providers. | [
"Creates",
"a",
"new",
"Vangoh",
"instance",
"with",
"no",
"secret",
"providers",
"."
] | 560b87421380eb62d09a5ea840231d10b085e103 | https://github.com/auroratechnologies/vangoh/blob/560b87421380eb62d09a5ea840231d10b085e103/vangoh.go#L101-L110 |
145,294 | auroratechnologies/vangoh | vangoh.go | NewSingleProvider | func NewSingleProvider(provider secretProvider) *Vangoh {
vg := New()
vg.singleProvider = &provider
return vg
} | go | func NewSingleProvider(provider secretProvider) *Vangoh {
vg := New()
vg.singleProvider = &provider
return vg
} | [
"func",
"NewSingleProvider",
"(",
"provider",
"secretProvider",
")",
"*",
"Vangoh",
"{",
"vg",
":=",
"New",
"(",
")",
"\n",
"vg",
".",
"singleProvider",
"=",
"&",
"provider",
"\n",
"return",
"vg",
"\n",
"}"
] | // Creates a new Vangoh instance that supports a single
// secretProvider. Attempting to add providers with AddProvider will fail with an
// error. | [
"Creates",
"a",
"new",
"Vangoh",
"instance",
"that",
"supports",
"a",
"single",
"secretProvider",
".",
"Attempting",
"to",
"add",
"providers",
"with",
"AddProvider",
"will",
"fail",
"with",
"an",
"error",
"."
] | 560b87421380eb62d09a5ea840231d10b085e103 | https://github.com/auroratechnologies/vangoh/blob/560b87421380eb62d09a5ea840231d10b085e103/vangoh.go#L115-L119 |
145,295 | auroratechnologies/vangoh | vangoh.go | AuthenticateRequest | func (vg *Vangoh) AuthenticateRequest(r *http.Request) *AuthenticationError {
// Parse the ORG, KEY, and SIGNATURE out of the Authorization header.
authHeader := strings.TrimSpace(r.Header.Get("Authorization"))
if authHeader == "" {
return ErrorAuthHeaderMissing
}
match, err := regexp.Match(AuthRegex, []byte(aut... | go | func (vg *Vangoh) AuthenticateRequest(r *http.Request) *AuthenticationError {
// Parse the ORG, KEY, and SIGNATURE out of the Authorization header.
authHeader := strings.TrimSpace(r.Header.Get("Authorization"))
if authHeader == "" {
return ErrorAuthHeaderMissing
}
match, err := regexp.Match(AuthRegex, []byte(aut... | [
"func",
"(",
"vg",
"*",
"Vangoh",
")",
"AuthenticateRequest",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"*",
"AuthenticationError",
"{",
"// Parse the ORG, KEY, and SIGNATURE out of the Authorization header.",
"authHeader",
":=",
"strings",
".",
"TrimSpace",
"(",
"r... | // Checks a request for proper authentication details, returning the relevent
// error if the request fails this check or nil if the request passes. | [
"Checks",
"a",
"request",
"for",
"proper",
"authentication",
"details",
"returning",
"the",
"relevent",
"error",
"if",
"the",
"request",
"fails",
"this",
"check",
"or",
"nil",
"if",
"the",
"request",
"passes",
"."
] | 560b87421380eb62d09a5ea840231d10b085e103 | https://github.com/auroratechnologies/vangoh/blob/560b87421380eb62d09a5ea840231d10b085e103/vangoh.go#L253-L325 |
145,296 | auroratechnologies/vangoh | vangoh.go | createHeadersString | func (vg *Vangoh) createHeadersString(r *http.Request) string {
if len(vg.includedHeaders) == 0 {
return ""
}
// For each defined regex, determine the set of headers that match. Repeat
// for all regexes, without duplication, to get the final set of custom
// headers to use.
var sanitizedHeaders = make(map[str... | go | func (vg *Vangoh) createHeadersString(r *http.Request) string {
if len(vg.includedHeaders) == 0 {
return ""
}
// For each defined regex, determine the set of headers that match. Repeat
// for all regexes, without duplication, to get the final set of custom
// headers to use.
var sanitizedHeaders = make(map[str... | [
"func",
"(",
"vg",
"*",
"Vangoh",
")",
"createHeadersString",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"if",
"len",
"(",
"vg",
".",
"includedHeaders",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"// For each defined ... | // Create the canonicalized header string part of a request's signature body. | [
"Create",
"the",
"canonicalized",
"header",
"string",
"part",
"of",
"a",
"request",
"s",
"signature",
"body",
"."
] | 560b87421380eb62d09a5ea840231d10b085e103 | https://github.com/auroratechnologies/vangoh/blob/560b87421380eb62d09a5ea840231d10b085e103/vangoh.go#L374-L433 |
145,297 | jimstudt/http-authentication | digest/htdigest-user-store.go | Reload | func (us *HtdigestUserStore) Reload(onbad BadLineHandler) error {
f, err := os.Open(us.filename)
if err != nil {
return err
}
defer f.Close()
c := csv.NewReader(f)
c.Comma = ':'
c.Comment = '#'
c.TrimLeadingSpace = true
c.FieldsPerRecord = -1 // don't check
n := map[string]string{}
for {
r, err := c.Re... | go | func (us *HtdigestUserStore) Reload(onbad BadLineHandler) error {
f, err := os.Open(us.filename)
if err != nil {
return err
}
defer f.Close()
c := csv.NewReader(f)
c.Comma = ':'
c.Comment = '#'
c.TrimLeadingSpace = true
c.FieldsPerRecord = -1 // don't check
n := map[string]string{}
for {
r, err := c.Re... | [
"func",
"(",
"us",
"*",
"HtdigestUserStore",
")",
"Reload",
"(",
"onbad",
"BadLineHandler",
")",
"error",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"us",
".",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}... | // Reload the htdigest's file. If there is an error, the old data will be kept instead.
// This function is thread safe. | [
"Reload",
"the",
"htdigest",
"s",
"file",
".",
"If",
"there",
"is",
"an",
"error",
"the",
"old",
"data",
"will",
"be",
"kept",
"instead",
".",
"This",
"function",
"is",
"thread",
"safe",
"."
] | 3eca13d6893afd7ecabe15f4445f5d2872a1b012 | https://github.com/jimstudt/http-authentication/blob/3eca13d6893afd7ecabe15f4445f5d2872a1b012/digest/htdigest-user-store.go#L27-L68 |
145,298 | jimstudt/http-authentication | digest/htdigest-user-store.go | ReloadOn | func (us *HtdigestUserStore) ReloadOn(when os.Signal, onbad BadLineHandler) {
// this is rather common with code in htpasswd, but I don't have a common area...
c := make(chan os.Signal, 1)
signal.Notify(c, when)
go func() {
for {
_ = <-c
log.Printf("Reloading!")
us.Reload(onbad)
}
}()
} | go | func (us *HtdigestUserStore) ReloadOn(when os.Signal, onbad BadLineHandler) {
// this is rather common with code in htpasswd, but I don't have a common area...
c := make(chan os.Signal, 1)
signal.Notify(c, when)
go func() {
for {
_ = <-c
log.Printf("Reloading!")
us.Reload(onbad)
}
}()
} | [
"func",
"(",
"us",
"*",
"HtdigestUserStore",
")",
"ReloadOn",
"(",
"when",
"os",
".",
"Signal",
",",
"onbad",
"BadLineHandler",
")",
"{",
"// this is rather common with code in htpasswd, but I don't have a common area...",
"c",
":=",
"make",
"(",
"chan",
"os",
".",
... | // Reload the htdigest's file on a signal. If there is an error, the old data will be kept instead.
// Typically you would use syscall.SIGHUP for the value of "when" | [
"Reload",
"the",
"htdigest",
"s",
"file",
"on",
"a",
"signal",
".",
"If",
"there",
"is",
"an",
"error",
"the",
"old",
"data",
"will",
"be",
"kept",
"instead",
".",
"Typically",
"you",
"would",
"use",
"syscall",
".",
"SIGHUP",
"for",
"the",
"value",
"of... | 3eca13d6893afd7ecabe15f4445f5d2872a1b012 | https://github.com/jimstudt/http-authentication/blob/3eca13d6893afd7ecabe15f4445f5d2872a1b012/digest/htdigest-user-store.go#L72-L84 |
145,299 | jimstudt/http-authentication | digest/htdigest-user-store.go | NewHtdigestUserStore | func NewHtdigestUserStore(filename string, onbad BadLineHandler) (*HtdigestUserStore, error) {
us := HtdigestUserStore{
simpleUserStore: simpleUserStore{userToHA1: map[string]string{}},
filename: filename,
}
if err := us.Reload(onbad); err != nil {
return nil, err
} else {
return &us, nil
}
} | go | func NewHtdigestUserStore(filename string, onbad BadLineHandler) (*HtdigestUserStore, error) {
us := HtdigestUserStore{
simpleUserStore: simpleUserStore{userToHA1: map[string]string{}},
filename: filename,
}
if err := us.Reload(onbad); err != nil {
return nil, err
} else {
return &us, nil
}
} | [
"func",
"NewHtdigestUserStore",
"(",
"filename",
"string",
",",
"onbad",
"BadLineHandler",
")",
"(",
"*",
"HtdigestUserStore",
",",
"error",
")",
"{",
"us",
":=",
"HtdigestUserStore",
"{",
"simpleUserStore",
":",
"simpleUserStore",
"{",
"userToHA1",
":",
"map",
... | // Create a new UserStore loaded from an Apache style htdigest file. | [
"Create",
"a",
"new",
"UserStore",
"loaded",
"from",
"an",
"Apache",
"style",
"htdigest",
"file",
"."
] | 3eca13d6893afd7ecabe15f4445f5d2872a1b012 | https://github.com/jimstudt/http-authentication/blob/3eca13d6893afd7ecabe15f4445f5d2872a1b012/digest/htdigest-user-store.go#L87-L97 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.