id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
10,300 | all-10301 | [
"AddFunction",
"adds",
"a",
"validation",
"Func",
"to",
"a",
"Validate",
"s",
"map",
"of",
"validators",
"denoted",
"by",
"the",
"key",
"NOTE",
":",
"if",
"the",
"key",
"already",
"exists",
"it",
"will",
"get",
"replaced",
".",
"NOTE",
":",
"this",
"method",
"is",
"not",
"thread",
"-",
"safe"
] | [
"func",
"(",
"v",
"*",
"Validate",
")",
"AddFunction",
"(",
"key",
"string",
",",
"f",
"Func",
")",
"error",
"{",
"if",
"len",
"(",
"key",
")",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"f",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"v",
".",
"validationFuncs",
"[",
"<mask>",
"]",
"=",
"f",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
10,301 | all-10302 | [
"Map",
"sets",
"fields",
"values",
"in",
"dst",
"from",
"src",
".",
"src",
"can",
"be",
"a",
"map",
"with",
"string",
"keys",
"or",
"a",
"struct",
".",
"dst",
"must",
"be",
"the",
"opposite",
":",
"if",
"src",
"is",
"a",
"map",
"dst",
"must",
"be",
"a",
"valid",
"pointer",
"to",
"struct",
".",
"If",
"src",
"is",
"a",
"struct",
"dst",
"must",
"be",
"map",
"[",
"string",
"]",
"interface",
"{}",
".",
"It",
"won",
"t",
"merge",
"unexported",
"(",
"private",
")",
"fields",
"and",
"will",
"do",
"recursively",
"any",
"exported",
"field",
".",
"If",
"dst",
"is",
"a",
"map",
"keys",
"will",
"be",
"src",
"fields",
"names",
"in",
"lower",
"camel",
"case",
".",
"Missing",
"key",
"in",
"src",
"that",
"doesn",
"t",
"match",
"a",
"field",
"in",
"dst",
"will",
"be",
"skipped",
".",
"This",
"doesn",
"t",
"apply",
"if",
"dst",
"is",
"a",
"map",
".",
"This",
"is",
"separated",
"method",
"from",
"Merge",
"because",
"it",
"is",
"cleaner",
"and",
"it",
"keeps",
"sane",
"semantics",
":",
"merging",
"equal",
"types",
"mapping",
"different",
"(",
"restricted",
")",
"types",
"."
] | [
"func",
"Map",
"(",
"dst",
",",
"src",
"<mask>",
"{",
"}",
",",
"opts",
"...",
"func",
"(",
"*",
"Config",
")",
")",
"error",
"{",
"return",
"_map",
"(",
"dst",
",",
"src",
",",
"opts",
"...",
")",
"\n",
"}"
] |
10,302 | all-10303 | [
"genOptions",
"takes",
"URL",
"values",
"and",
"generates",
"options",
"joining",
"together",
"with",
"joiner",
"and",
"separated",
"by",
"sep",
"with",
"any",
"multi",
"URL",
"values",
"joined",
"by",
"valSep",
"ignoring",
"any",
"values",
"with",
"keys",
"in",
"ignore",
".",
"For",
"example",
"to",
"build",
"a",
"ODBC",
"style",
"connection",
"string",
"use",
"like",
"the",
"following",
":",
"genOptions",
"(",
"u",
".",
"Query",
"()",
"=",
";",
")"
] | [
"func",
"genOptions",
"(",
"q",
"url",
".",
"Values",
",",
"joiner",
",",
"assign",
",",
"sep",
",",
"valSep",
"string",
",",
"skipWhenEmpty",
"bool",
",",
"ignore",
"...",
"string",
")",
"string",
"{",
"qlen",
":=",
"len",
"(",
"q",
")",
"\n",
"if",
"qlen",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"// make ignore map",
"ig",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
",",
"len",
"(",
"ignore",
")",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"ignore",
"{",
"ig",
"[",
"strings",
".",
"ToLower",
"(",
"v",
")",
"]",
"=",
"true",
"\n",
"}",
"\n\n",
"// sort keys",
"s",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"q",
")",
")",
"\n",
"var",
"i",
"int",
"\n",
"for",
"k",
":=",
"range",
"q",
"{",
"s",
"[",
"i",
"]",
"=",
"k",
"\n",
"i",
"++",
"\n",
"}",
"\n",
"<mask>",
".",
"Strings",
"(",
"s",
")",
"\n\n",
"var",
"opts",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"k",
":=",
"range",
"s",
"{",
"if",
"!",
"ig",
"[",
"strings",
".",
"ToLower",
"(",
"k",
")",
"]",
"{",
"val",
":=",
"strings",
".",
"Join",
"(",
"q",
"[",
"k",
"]",
",",
"valSep",
")",
"\n",
"if",
"!",
"skipWhenEmpty",
"||",
"val",
"!=",
"\"",
"\"",
"{",
"if",
"val",
"!=",
"\"",
"\"",
"{",
"val",
"=",
"assign",
"+",
"val",
"\n",
"}",
"\n",
"opts",
"=",
"append",
"(",
"opts",
",",
"k",
"+",
"val",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"opts",
")",
"!=",
"0",
"{",
"return",
"joiner",
"+",
"strings",
".",
"Join",
"(",
"opts",
",",
"sep",
")",
"\n",
"}",
"\n\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
10,303 | all-10304 | [
"NewURLsValue",
"implements",
"url",
".",
"URL",
"slice",
"as",
"flag",
".",
"Value",
"interface",
".",
"Given",
"value",
"is",
"to",
"be",
"separated",
"by",
"comma",
"."
] | [
"func",
"NewURLsValue",
"(",
"s",
"string",
")",
"*",
"URLsValue",
"{",
"if",
"s",
"==",
"\"",
"\"",
"{",
"return",
"&",
"URLsValue",
"{",
"}",
"\n",
"}",
"\n",
"v",
":=",
"&",
"URLsValue",
"{",
"}",
"\n",
"if",
"err",
":=",
"v",
".",
"<mask>",
"(",
"s",
")",
";",
"err",
"!=",
"nil",
"{",
"plog",
".",
"Panicf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"v",
"\n",
"}"
] |
10,304 | all-10305 | [
"/",
"*",
"Pretty",
"prints",
"the",
"passed",
"in",
"object",
"at",
"the",
"passed",
"in",
"indentation",
"level",
"."
] | [
"func",
"Object",
"(",
"object",
"interface",
"{",
"}",
",",
"indentation",
"uint",
")",
"string",
"{",
"indent",
":=",
"strings",
".",
"Repeat",
"(",
"Indent",
",",
"int",
"(",
"indentation",
")",
")",
"\n",
"<mask>",
":=",
"reflect",
".",
"ValueOf",
"(",
"object",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"indent",
",",
"formatType",
"(",
"object",
")",
",",
"formatValue",
"(",
"value",
",",
"indentation",
")",
")",
"\n",
"}"
] |
10,305 | all-10306 | [
"simplifyContentType",
"drops",
"parameters",
"from",
"a",
"HTTP",
"media",
"type",
"(",
"see",
"https",
":",
"//",
"tools",
".",
"ietf",
".",
"org",
"/",
"html",
"/",
"rfc7231#section",
"-",
"3",
".",
"1",
".",
"1",
".",
"1",
")",
"Alternatively",
"an",
"empty",
"string",
"is",
"returned",
"unchanged",
"and",
"invalid",
"values",
"are",
"simplified",
"to",
"an",
"empty",
"string",
"."
] | [
"func",
"simplifyContentType",
"(",
"contentType",
"<mask>",
")",
"string",
"{",
"if",
"contentType",
"==",
"\"",
"\"",
"{",
"return",
"contentType",
"\n",
"}",
"\n",
"mimeType",
",",
"_",
",",
"err",
":=",
"mime",
".",
"ParseMediaType",
"(",
"contentType",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"mimeType",
"\n",
"}"
] |
10,306 | all-10307 | [
"Do",
"executes",
"Debugger",
".",
"pauseOnAsyncCall",
"against",
"the",
"provided",
"context",
"."
] | [
"func",
"(",
"p",
"*",
"PauseOnAsyncCallParams",
")",
"Do",
"(",
"ctx",
"context",
".",
"<mask>",
")",
"(",
"err",
"error",
")",
"{",
"return",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandPauseOnAsyncCall",
",",
"p",
",",
"nil",
")",
"\n",
"}"
] |
10,307 | all-10308 | [
"FinishCommit",
"ends",
"the",
"process",
"of",
"committing",
"data",
"to",
"a",
"Repo",
"and",
"persists",
"the",
"Commit",
".",
"Once",
"a",
"Commit",
"is",
"finished",
"the",
"data",
"becomes",
"immutable",
"and",
"future",
"attempts",
"to",
"write",
"to",
"it",
"with",
"PutFile",
"will",
"error",
"."
] | [
"func",
"(",
"c",
"APIClient",
")",
"FinishCommit",
"(",
"repoName",
"string",
",",
"commitID",
"string",
")",
"<mask>",
"{",
"_",
",",
"err",
":=",
"c",
".",
"PfsAPIClient",
".",
"FinishCommit",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"&",
"pfs",
".",
"FinishCommitRequest",
"{",
"Commit",
":",
"NewCommit",
"(",
"repoName",
",",
"commitID",
")",
",",
"}",
",",
")",
"\n",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}"
] |
10,308 | all-10309 | [
"TODO",
"(",
"jrick",
")",
"GIcon",
"/",
"*",
"func",
"(",
"v",
"*",
"Image",
")",
"SetFromGIcon",
"()",
"{",
"}",
"SetPixelSize",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_image_set_pixel_size",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"SetPixelSize",
"(",
"pixelSize",
"int",
")",
"{",
"C",
".",
"gtk_image_set_pixel_size",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"gint",
"(",
"pixelSize",
")",
")",
"\n",
"}"
] |
10,309 | all-10310 | [
"FetchRuleSet",
"retrieves",
"rule",
"set",
"with",
"passed",
"cid",
"."
] | [
"func",
"(",
"a",
"*",
"API",
")",
"FetchRuleSet",
"(",
"cid",
"CIDType",
")",
"(",
"*",
"RuleSet",
",",
"error",
")",
"{",
"if",
"cid",
"==",
"nil",
"||",
"*",
"cid",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"rulesetCID",
":=",
"string",
"(",
"*",
"cid",
")",
"\n\n",
"matched",
",",
"err",
":=",
"regexp",
".",
"MatchString",
"(",
"config",
".",
"RuleSetCIDRegex",
",",
"rulesetCID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"!",
"matched",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"rulesetCID",
")",
"\n",
"}",
"\n\n",
"result",
",",
"err",
":=",
"a",
".",
"Get",
"(",
"rulesetCID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"a",
".",
"Debug",
"{",
"a",
".",
"Log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"string",
"(",
"result",
")",
")",
"\n",
"}",
"\n\n",
"ruleset",
":=",
"&",
"RuleSet",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"<mask>",
",",
"ruleset",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"ruleset",
",",
"nil",
"\n",
"}"
] |
10,310 | all-10311 | [
"ImportRepoRules",
"reads",
"the",
"lock",
"file",
"of",
"a",
"vendoring",
"tool",
"and",
"returns",
"a",
"list",
"of",
"equivalent",
"repository",
"rules",
"that",
"can",
"be",
"merged",
"into",
"a",
"WORKSPACE",
"file",
".",
"The",
"format",
"of",
"the",
"file",
"is",
"inferred",
"from",
"its",
"basename",
"."
] | [
"func",
"ImportRepoRules",
"(",
"filename",
"string",
",",
"repoCache",
"*",
"RemoteCache",
")",
"(",
"[",
"]",
"*",
"rule",
".",
"Rule",
",",
"error",
")",
"{",
"format",
":=",
"getLockFileFormat",
"(",
"filename",
")",
"\n",
"if",
"format",
"==",
"unknownFormat",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"`%s: unrecognized lock file format. Expected \"Gopkg.lock\", \"go.mod\", or \"Godeps.json\"`",
",",
"filename",
")",
"\n",
"}",
"\n",
"parser",
":=",
"lockFileParsers",
"[",
"format",
"]",
"\n",
"repos",
",",
"err",
":=",
"parser",
"(",
"filename",
",",
"repoCache",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"filename",
",",
"err",
")",
"\n",
"}",
"\n",
"sort",
".",
"Stable",
"(",
"byName",
"(",
"repos",
")",
")",
"\n\n",
"<mask>",
":=",
"make",
"(",
"[",
"]",
"*",
"rule",
".",
"Rule",
",",
"0",
",",
"len",
"(",
"repos",
")",
")",
"\n",
"for",
"_",
",",
"repo",
":=",
"range",
"repos",
"{",
"rules",
"=",
"append",
"(",
"rules",
",",
"GenerateRule",
"(",
"repo",
")",
")",
"\n",
"}",
"\n",
"return",
"rules",
",",
"nil",
"\n",
"}"
] |
10,311 | all-10312 | [
"writeUint32",
"writes",
"a",
"uint32",
"to",
"the",
"underlying",
"writer",
"."
] | [
"func",
"(",
"z",
"*",
"Writer",
")",
"writeUint32",
"(",
"x",
"uint32",
")",
"error",
"{",
"buf",
":=",
"z",
".",
"buf",
"[",
":",
"4",
"]",
"\n",
"<mask>",
".",
"LittleEndian",
".",
"PutUint32",
"(",
"buf",
",",
"x",
")",
"\n",
"_",
",",
"err",
":=",
"z",
".",
"dst",
".",
"Write",
"(",
"buf",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
10,312 | all-10313 | [
"AddCommit",
"adds",
"the",
"files",
"to",
"a",
"new",
"commit",
"in",
"the",
"repo",
"."
] | [
"func",
"(",
"lg",
"*",
"LocalGit",
")",
"AddCommit",
"(",
"org",
",",
"repo",
"string",
",",
"files",
"map",
"[",
"string",
"]",
"[",
"]",
"byte",
")",
"error",
"{",
"rdir",
":=",
"filepath",
".",
"Join",
"(",
"lg",
".",
"Dir",
",",
"org",
",",
"repo",
")",
"\n",
"for",
"f",
",",
"b",
":=",
"range",
"files",
"{",
"path",
":=",
"filepath",
".",
"Join",
"(",
"rdir",
",",
"f",
")",
"\n",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"filepath",
".",
"Dir",
"(",
"<mask>",
")",
",",
"os",
".",
"ModePerm",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
":=",
"ioutil",
".",
"WriteFile",
"(",
"path",
",",
"b",
",",
"os",
".",
"ModePerm",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
":=",
"runCmd",
"(",
"lg",
".",
"Git",
",",
"rdir",
",",
"\"",
"\"",
",",
"f",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"runCmd",
"(",
"lg",
".",
"Git",
",",
"rdir",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
10,313 | all-10314 | [
"handle",
"interacts",
"with",
"GitHub",
"to",
"drive",
"the",
"pull",
"request",
"to",
"the",
"proper",
"state",
"by",
"adding",
"and",
"removing",
"comments",
"and",
"labels",
".",
"If",
"a",
"PR",
"has",
"a",
"WIP",
"prefix",
"it",
"needs",
"an",
"explanatory",
"comment",
"and",
"label",
".",
"Otherwise",
"neither",
"should",
"be",
"present",
"."
] | [
"func",
"handle",
"(",
"gc",
"githubClient",
",",
"le",
"*",
"logrus",
".",
"<mask>",
",",
"e",
"*",
"event",
")",
"error",
"{",
"needsLabel",
":=",
"e",
".",
"draft",
"||",
"titleRegex",
".",
"MatchString",
"(",
"e",
".",
"title",
")",
"\n\n",
"if",
"needsLabel",
"&&",
"!",
"e",
".",
"hasLabel",
"{",
"if",
"err",
":=",
"gc",
".",
"AddLabel",
"(",
"e",
".",
"org",
",",
"e",
".",
"repo",
",",
"e",
".",
"number",
",",
"labels",
".",
"WorkInProgress",
")",
";",
"err",
"!=",
"nil",
"{",
"le",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"labels",
".",
"WorkInProgress",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"if",
"!",
"needsLabel",
"&&",
"e",
".",
"hasLabel",
"{",
"if",
"err",
":=",
"gc",
".",
"RemoveLabel",
"(",
"e",
".",
"org",
",",
"e",
".",
"repo",
",",
"e",
".",
"number",
",",
"labels",
".",
"WorkInProgress",
")",
";",
"err",
"!=",
"nil",
"{",
"le",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"labels",
".",
"WorkInProgress",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,314 | all-10315 | [
"handle",
"is",
"the",
"generic",
"handler",
"for",
"the",
"assign",
"plugin",
".",
"It",
"uses",
"the",
"handler",
"s",
"regexp",
"and",
"affectedLogins",
"functions",
"to",
"identify",
"the",
"users",
"to",
"add",
"and",
"/",
"or",
"remove",
"and",
"then",
"passes",
"the",
"appropriate",
"users",
"to",
"the",
"handler",
"s",
"add",
"and",
"remove",
"functions",
".",
"If",
"add",
"fails",
"to",
"add",
"some",
"of",
"the",
"users",
"a",
"response",
"comment",
"is",
"created",
"where",
"the",
"body",
"of",
"the",
"response",
"is",
"generated",
"by",
"the",
"handler",
"s",
"addFailureResponse",
"function",
"."
] | [
"func",
"handle",
"(",
"h",
"*",
"handler",
")",
"error",
"{",
"e",
":=",
"h",
".",
"event",
"\n",
"org",
":=",
"e",
".",
"Repo",
".",
"Owner",
".",
"Login",
"\n",
"repo",
":=",
"e",
".",
"Repo",
".",
"Name",
"\n",
"matches",
":=",
"h",
".",
"regexp",
".",
"FindAllStringSubmatch",
"(",
"e",
".",
"Body",
",",
"-",
"1",
")",
"\n",
"if",
"matches",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"users",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n",
"for",
"_",
",",
"re",
":=",
"range",
"matches",
"{",
"add",
":=",
"re",
"[",
"1",
"]",
"!=",
"\"",
"\"",
"// un<cmd> == !add",
"\n",
"if",
"re",
"[",
"2",
"]",
"==",
"\"",
"\"",
"{",
"users",
"[",
"e",
".",
"User",
".",
"Login",
"]",
"=",
"add",
"\n",
"}",
"else",
"{",
"for",
"_",
",",
"login",
":=",
"range",
"parseLogins",
"(",
"re",
"[",
"2",
"]",
")",
"{",
"<mask>",
"[",
"login",
"]",
"=",
"add",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"var",
"toAdd",
",",
"toRemove",
"[",
"]",
"string",
"\n",
"for",
"login",
",",
"add",
":=",
"range",
"users",
"{",
"if",
"add",
"{",
"toAdd",
"=",
"append",
"(",
"toAdd",
",",
"login",
")",
"\n",
"}",
"else",
"{",
"toRemove",
"=",
"append",
"(",
"toRemove",
",",
"login",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"toRemove",
")",
">",
"0",
"{",
"h",
".",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"h",
".",
"userType",
",",
"org",
",",
"repo",
",",
"e",
".",
"Number",
",",
"toRemove",
")",
"\n",
"if",
"err",
":=",
"h",
".",
"remove",
"(",
"org",
",",
"repo",
",",
"e",
".",
"Number",
",",
"toRemove",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"len",
"(",
"toAdd",
")",
">",
"0",
"{",
"h",
".",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"h",
".",
"userType",
",",
"org",
",",
"repo",
",",
"e",
".",
"Number",
",",
"toAdd",
")",
"\n",
"if",
"err",
":=",
"h",
".",
"add",
"(",
"org",
",",
"repo",
",",
"e",
".",
"Number",
",",
"toAdd",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"mu",
",",
"ok",
":=",
"err",
".",
"(",
"github",
".",
"MissingUsers",
")",
";",
"ok",
"{",
"msg",
":=",
"h",
".",
"addFailureResponse",
"(",
"mu",
")",
"\n",
"if",
"len",
"(",
"msg",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"err",
":=",
"h",
".",
"gc",
".",
"CreateComment",
"(",
"org",
",",
"repo",
",",
"e",
".",
"Number",
",",
"plugins",
".",
"FormatResponseRaw",
"(",
"e",
".",
"Body",
",",
"e",
".",
"HTMLURL",
",",
"e",
".",
"User",
".",
"Login",
",",
"msg",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,315 | all-10316 | [
"Tries",
"to",
"find",
"the",
"best",
"fit",
"for",
"the",
"given",
"path",
".",
"It",
"goes",
"up",
"until",
"it",
"gets",
"into",
"the",
"existing",
"directory",
".",
"If",
"all",
"fails",
"it",
"returns",
"working",
"directory",
"."
] | [
"func",
"(",
"d",
"*",
"FileSelectDialog",
")",
"detectPath",
"(",
")",
"{",
"p",
":=",
"d",
".",
"currPath",
"\n",
"if",
"p",
"==",
"\"",
"\"",
"{",
"d",
".",
"currPath",
",",
"_",
"=",
"os",
".",
"Getwd",
"(",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"p",
"=",
"filepath",
".",
"Clean",
"(",
"p",
")",
"\n",
"for",
"{",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"p",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"break",
"\n",
"}",
"\n\n",
"dirUp",
":=",
"filepath",
".",
"Dir",
"(",
"p",
")",
"\n",
"if",
"dirUp",
"==",
"p",
"{",
"p",
",",
"_",
"=",
"<mask>",
".",
"Getwd",
"(",
")",
"\n",
"break",
"\n",
"}",
"\n\n",
"p",
"=",
"dirUp",
"\n",
"}",
"\n",
"d",
".",
"currPath",
"=",
"p",
"\n",
"}"
] |
10,316 | all-10317 | [
"regexMatch",
"returns",
"true",
"or",
"false",
"if",
"the",
"string",
"matches",
"the",
"given",
"regular",
"expression"
] | [
"func",
"regexMatch",
"(",
"re",
",",
"s",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"compiled",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"<mask>",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"compiled",
".",
"MatchString",
"(",
"s",
")",
",",
"nil",
"\n",
"}"
] |
10,317 | all-10318 | [
"specify",
"a",
"two",
"-",
"dimensional",
"texture",
"subimage"
] | [
"func",
"TextureSubImage2D",
"(",
"texture",
"uint32",
",",
"level",
"int32",
",",
"xoffset",
"int32",
",",
"yoffset",
"int32",
",",
"width",
"int32",
",",
"height",
"int32",
",",
"format",
"uint32",
",",
"xtype",
"uint32",
",",
"pixels",
"unsafe",
".",
"Pointer",
")",
"{",
"syscall",
".",
"Syscall9",
"(",
"gpTextureSubImage2D",
",",
"9",
",",
"uintptr",
"(",
"texture",
")",
",",
"uintptr",
"(",
"<mask>",
")",
",",
"uintptr",
"(",
"xoffset",
")",
",",
"uintptr",
"(",
"yoffset",
")",
",",
"uintptr",
"(",
"width",
")",
",",
"uintptr",
"(",
"height",
")",
",",
"uintptr",
"(",
"format",
")",
",",
"uintptr",
"(",
"xtype",
")",
",",
"uintptr",
"(",
"pixels",
")",
")",
"\n",
"}"
] |
10,318 | all-10319 | [
"SetDefaultTimeout",
"sets",
"the",
"default",
"go",
"-",
"dqlite",
"driver",
"timeout",
"."
] | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"SetDefaultTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"{",
"<mask>",
":=",
"c",
".",
"db",
".",
"Driver",
"(",
")",
".",
"(",
"*",
"dqlite",
".",
"Driver",
")",
"\n",
"driver",
".",
"SetContextTimeout",
"(",
"timeout",
")",
"\n",
"}"
] |
10,319 | all-10320 | [
"GetMessageOk",
"returns",
"a",
"tuple",
"with",
"the",
"Message",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"c",
"*",
"Comment",
")",
"GetMessageOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"c",
"==",
"nil",
"||",
"c",
".",
"Message",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"c",
".",
"<mask>",
",",
"true",
"\n",
"}"
] |
10,320 | all-10321 | [
"helperMethodJavascript",
"creates",
"and",
"returns",
"a",
"helper",
"method",
"javascript",
"."
] | [
"func",
"newHelperMethodJavascript",
"(",
"ln",
"*",
"line",
",",
"rslt",
"*",
"result",
",",
"src",
"*",
"source",
",",
"<mask>",
"element",
",",
"opts",
"*",
"Options",
")",
"*",
"helperMethodJavascript",
"{",
"return",
"&",
"helperMethodJavascript",
"{",
"elementBase",
":",
"newElementBase",
"(",
"ln",
",",
"rslt",
",",
"src",
",",
"parent",
",",
"opts",
")",
",",
"}",
"\n",
"}"
] |
10,321 | all-10322 | [
"CurrentFrame",
"returns",
"the",
"frame",
"currently",
"at",
"the",
"top",
"of",
"the",
"frame",
"stack"
] | [
"func",
"(",
"st",
"*",
"State",
")",
"CurrentFrame",
"(",
")",
"*",
"<mask>",
".",
"Frame",
"{",
"x",
",",
"err",
":=",
"st",
".",
"frames",
".",
"Top",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"x",
".",
"(",
"*",
"frame",
".",
"Frame",
")",
"\n",
"}"
] |
10,322 | all-10323 | [
"GobEncode",
"gob",
"-",
"encodes",
"each",
"item",
"and",
"returns",
"the",
"resulting",
"byte",
"slice",
"."
] | [
"func",
"gobEncode",
"(",
"items",
"...",
"interface",
"{",
"}",
")",
"[",
"]",
"byte",
"{",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"enc",
":=",
"gob",
".",
"NewEncoder",
"(",
"buf",
")",
"\n",
"for",
"_",
",",
"i",
":=",
"<mask>",
"items",
"{",
"if",
"err",
":=",
"enc",
".",
"Encode",
"(",
"i",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"buf",
".",
"Bytes",
"(",
")",
"\n",
"}"
] |
10,323 | all-10324 | [
"NewMockTimer",
"creates",
"a",
"new",
"mock",
"instance"
] | [
"func",
"NewMockTimer",
"(",
"ctrl",
"*",
"gomock",
".",
"<mask>",
")",
"*",
"MockTimer",
"{",
"mock",
":=",
"&",
"MockTimer",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockTimerMockRecorder",
"{",
"mock",
"}",
"\n",
"return",
"mock",
"\n",
"}"
] |
10,324 | all-10325 | [
"SequenceEntropy",
"calculates",
"the",
"entropy",
"for",
"sequences",
"such",
"as",
"4567",
"or",
"cdef"
] | [
"func",
"SequenceEntropy",
"(",
"<mask>",
"match",
".",
"Match",
",",
"dictionaryLength",
"int",
",",
"ascending",
"bool",
")",
"float64",
"{",
"firstChar",
":=",
"match",
".",
"Token",
"[",
"0",
"]",
"\n",
"baseEntropy",
":=",
"float64",
"(",
"0",
")",
"\n",
"if",
"string",
"(",
"firstChar",
")",
"==",
"\"",
"\"",
"||",
"string",
"(",
"firstChar",
")",
"==",
"\"",
"\"",
"{",
"baseEntropy",
"=",
"float64",
"(",
"0",
")",
"\n",
"}",
"else",
"{",
"baseEntropy",
"=",
"math",
".",
"Log2",
"(",
"float64",
"(",
"dictionaryLength",
")",
")",
"\n",
"//TODO: should this be just the first or any char?",
"if",
"unicode",
".",
"IsUpper",
"(",
"rune",
"(",
"firstChar",
")",
")",
"{",
"baseEntropy",
"++",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"!",
"ascending",
"{",
"baseEntropy",
"++",
"\n",
"}",
"\n",
"return",
"baseEntropy",
"+",
"math",
".",
"Log2",
"(",
"float64",
"(",
"len",
"(",
"match",
".",
"Token",
")",
")",
")",
"\n",
"}"
] |
10,325 | all-10326 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"GetWindowBoundsParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoBrowser8",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
10,326 | all-10327 | [
"ReapSnapshots",
"reaps",
"any",
"snapshots",
"beyond",
"the",
"retain",
"count",
"."
] | [
"func",
"(",
"f",
"*",
"FileSnapshotStore",
")",
"ReapSnapshots",
"(",
")",
"error",
"{",
"snapshots",
",",
"err",
":=",
"f",
".",
"getSnapshots",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"f",
".",
"logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"f",
".",
"retain",
";",
"i",
"<",
"len",
"(",
"snapshots",
")",
";",
"i",
"++",
"{",
"path",
":=",
"filepath",
".",
"Join",
"(",
"f",
".",
"path",
",",
"snapshots",
"[",
"i",
"]",
".",
"<mask>",
")",
"\n",
"f",
".",
"logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
"if",
"err",
":=",
"os",
".",
"RemoveAll",
"(",
"path",
")",
";",
"err",
"!=",
"nil",
"{",
"f",
".",
"logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"path",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,327 | all-10328 | [
"LastContact",
"returns",
"the",
"time",
"of",
"last",
"contact",
"."
] | [
"func",
"(",
"s",
"*",
"followerReplication",
")",
"LastContact",
"(",
")",
"time",
".",
"Time",
"{",
"s",
".",
"lastContactLock",
".",
"RLock",
"(",
")",
"\n",
"<mask>",
":=",
"s",
".",
"lastContact",
"\n",
"s",
".",
"lastContactLock",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"last",
"\n",
"}"
] |
10,328 | all-10329 | [
"NextGID",
"returns",
"the",
"next",
"free",
"group",
"id",
"to",
"use",
"."
] | [
"func",
"NextGID",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"db",
",",
"gid",
",",
"err",
":=",
"nextGUID",
"(",
"false",
")",
"\n",
"<mask>",
".",
"close",
"(",
")",
"\n",
"return",
"gid",
",",
"err",
"\n",
"}"
] |
10,329 | all-10330 | [
"LastUseTime",
"returns",
"time",
"the",
"client",
"was",
"last",
"used"
] | [
"func",
"(",
"c",
"*",
"HostClient",
")",
"LastUseTime",
"(",
")",
"<mask>",
".",
"Time",
"{",
"n",
":=",
"atomic",
".",
"LoadUint32",
"(",
"&",
"c",
".",
"lastUseTime",
")",
"\n",
"return",
"time",
".",
"Unix",
"(",
"startTimeUnix",
"+",
"int64",
"(",
"n",
")",
",",
"0",
")",
"\n",
"}"
] |
10,330 | all-10331 | [
"Clone",
"makes",
"a",
"deep",
"copy",
"of",
"a",
"configurations",
"object",
"."
] | [
"func",
"(",
"c",
"*",
"configurations",
")",
"Clone",
"(",
")",
"(",
"copy",
"configurations",
")",
"{",
"copy",
".",
"committed",
"=",
"c",
".",
"committed",
".",
"Clone",
"(",
")",
"\n",
"copy",
".",
"committedIndex",
"=",
"c",
".",
"committedIndex",
"\n",
"<mask>",
".",
"latest",
"=",
"c",
".",
"latest",
".",
"Clone",
"(",
")",
"\n",
"copy",
".",
"latestIndex",
"=",
"c",
".",
"latestIndex",
"\n",
"return",
"\n",
"}"
] |
10,331 | all-10332 | [
"these",
"are",
"unnecessary",
"and",
"make",
"the",
"config",
"larger",
"so",
"we",
"strip",
"them",
"out"
] | [
"func",
"yamlBytesStripNulls",
"(",
"yamlBytes",
"[",
"]",
"byte",
")",
"[",
"]",
"<mask>",
"{",
"nullRE",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\\n",
"\\n",
"\"",
")",
"\n",
"return",
"nullRE",
".",
"ReplaceAll",
"(",
"yamlBytes",
",",
"[",
"]",
"byte",
"{",
"}",
")",
"\n",
"}"
] |
10,332 | all-10333 | [
"NewQueue",
"creates",
"a",
"queue",
"."
] | [
"func",
"NewQueue",
"(",
"maxSize",
"int",
")",
"*",
"Queue",
"{",
"return",
"&",
"Queue",
"{",
"buffer",
":",
"<mask>",
"(",
"[",
"]",
"UsageStats",
",",
"0",
",",
"maxSize",
")",
",",
"maxSize",
":",
"maxSize",
",",
"}",
"\n",
"}"
] |
10,333 | all-10334 | [
"KnownCreated",
"returns",
"true",
"if",
"the",
"secret",
"s",
"known",
"status",
"is",
"CREATED"
] | [
"func",
"(",
"<mask>",
"*",
"SSMSecretResource",
")",
"KnownCreated",
"(",
")",
"bool",
"{",
"secret",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"secret",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"secret",
".",
"knownStatusUnsafe",
"==",
"resourcestatus",
".",
"ResourceStatus",
"(",
"SSMSecretCreated",
")",
"\n",
"}"
] |
10,334 | all-10335 | [
"Stdout",
"logging",
"apex",
"/",
"log"
] | [
"func",
"Stdout",
"(",
")",
"*",
"apexInterfaceWrapper",
"{",
"return",
"Wrap",
"(",
"&",
"apex",
".",
"Logger",
"{",
"Level",
":",
"apex",
".",
"InfoLevel",
",",
"<mask>",
":",
"cli",
".",
"New",
"(",
"os",
".",
"Stdout",
")",
",",
"}",
")",
"\n",
"}"
] |
10,335 | all-10336 | [
"UnmarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Unmarshaler",
"."
] | [
"func",
"(",
"t",
"*",
"SetWebLifecycleStateState",
")",
"UnmarshalEasyJSON",
"(",
"in",
"*",
"jlexer",
".",
"Lexer",
")",
"{",
"switch",
"SetWebLifecycleStateState",
"(",
"in",
".",
"String",
"(",
")",
")",
"{",
"case",
"SetWebLifecycleStateStateFrozen",
":",
"*",
"t",
"=",
"SetWebLifecycleStateStateFrozen",
"\n",
"case",
"SetWebLifecycleStateStateActive",
":",
"*",
"t",
"=",
"SetWebLifecycleStateStateActive",
"\n\n",
"default",
":",
"<mask>",
".",
"AddError",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"}"
] |
10,336 | all-10337 | [
"title",
":",
"pool",
"constraints",
"list",
"path",
":",
"/",
"constraints",
"method",
":",
"GET",
"produce",
":",
"application",
"/",
"json",
"responses",
":",
"200",
":",
"OK",
"204",
":",
"No",
"content",
"401",
":",
"Unauthorized"
] | [
"func",
"poolConstraintList",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"t",
"auth",
".",
"<mask>",
")",
"error",
"{",
"if",
"!",
"permission",
".",
"Check",
"(",
"t",
",",
"permission",
".",
"PermPoolReadConstraints",
")",
"{",
"return",
"permission",
".",
"ErrUnauthorized",
"\n",
"}",
"\n",
"constraints",
",",
"err",
":=",
"pool",
".",
"ListPoolsConstraints",
"(",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"constraints",
")",
"==",
"0",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusNoContent",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"json",
".",
"NewEncoder",
"(",
"w",
")",
".",
"Encode",
"(",
"constraints",
")",
"\n",
"}"
] |
10,337 | all-10338 | [
"/",
"*",
"Checks",
"the",
"balance",
"of",
"tokens",
"which",
"have",
"multiple",
"parts",
"such",
"as",
"parenthesis",
"."
] | [
"func",
"checkBalance",
"(",
"tokens",
"[",
"]",
"ExpressionToken",
")",
"error",
"{",
"var",
"stream",
"*",
"tokenStream",
"\n",
"var",
"token",
"ExpressionToken",
"\n",
"var",
"parens",
"int",
"\n\n",
"stream",
"=",
"newTokenStream",
"(",
"tokens",
")",
"\n\n",
"for",
"stream",
".",
"hasNext",
"(",
")",
"{",
"<mask>",
"=",
"stream",
".",
"next",
"(",
")",
"\n",
"if",
"token",
".",
"Kind",
"==",
"CLAUSE",
"{",
"parens",
"++",
"\n",
"continue",
"\n",
"}",
"\n",
"if",
"token",
".",
"Kind",
"==",
"CLAUSE_CLOSE",
"{",
"parens",
"--",
"\n",
"continue",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"parens",
"!=",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,338 | all-10339 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"BringToFrontParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage81",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
10,339 | all-10340 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"SamplingHeapProfileSample",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoHeapprofiler6",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
10,340 | all-10341 | [
"LogOnPanic",
"logs",
"the",
"given",
"panic",
"and",
"its",
"stacktrace",
"prefixing",
"each",
"line",
"with",
"the",
"panic",
"ID",
"."
] | [
"func",
"LogOnPanic",
"(",
"id",
"int64",
",",
"err",
"interface",
"{",
"}",
",",
"stacktrace",
"[",
"]",
"string",
",",
"_",
"*",
"http",
".",
"Request",
")",
"{",
"logMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"logMutex",
".",
"Unlock",
"(",
")",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"<mask>",
",",
"err",
")",
"\n",
"for",
"_",
",",
"line",
":=",
"range",
"stacktrace",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"id",
",",
"line",
")",
"\n",
"}",
"\n",
"}"
] |
10,341 | all-10342 | [
"writeChildren",
"writes",
"the",
"children",
"s",
"HTML",
"."
] | [
"func",
"(",
"e",
"*",
"elementBase",
")",
"writeChildren",
"(",
"bf",
"*",
"bytes",
".",
"Buffer",
")",
"(",
"int64",
",",
"error",
")",
"{",
"l",
":=",
"len",
"(",
"e",
".",
"children",
")",
"\n",
"for",
"index",
",",
"child",
":=",
"range",
"e",
".",
"children",
"{",
"if",
"index",
"==",
"l",
"-",
"1",
"{",
"child",
".",
"SetLastChild",
"(",
"true",
")",
"\n",
"}",
"\n\n",
"if",
"e",
".",
"opts",
".",
"formatter",
"!=",
"nil",
"{",
"if",
"i",
",",
"err",
":=",
"e",
".",
"opts",
".",
"formatter",
".",
"OpeningElement",
"(",
"bf",
",",
"child",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"int64",
"(",
"i",
")",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"i",
",",
"err",
":=",
"<mask>",
".",
"WriteTo",
"(",
"bf",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"int64",
"(",
"i",
")",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"0",
",",
"nil",
"\n",
"}"
] |
10,342 | all-10343 | [
"UCount",
"iterates",
"over",
"a",
"list",
"and",
"keeps",
"a",
"running",
"tally",
"of",
"the",
"number",
"of",
"elements",
"satisfy",
"a",
"predicate",
"."
] | [
"func",
"(",
"iter",
"Enumerator",
")",
"UCount",
"(",
"p",
"Predicate",
")",
"uint",
"{",
"tally",
":=",
"uint",
"(",
"0",
")",
"\n",
"for",
"<mask>",
":=",
"range",
"iter",
"{",
"if",
"p",
"(",
"entry",
")",
"{",
"tally",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"tally",
"\n",
"}"
] |
10,343 | all-10344 | [
"LastError",
"provides",
"a",
"mock",
"function",
"with",
"given",
"fields",
":"
] | [
"func",
"(",
"_m",
"*",
"ObjectRows",
")",
"LastError",
"(",
")",
"error",
"{",
"<mask>",
":=",
"_m",
".",
"Called",
"(",
")",
"\n\n",
"var",
"r0",
"error",
"\n",
"if",
"rf",
",",
"ok",
":=",
"ret",
".",
"Get",
"(",
"0",
")",
".",
"(",
"func",
"(",
")",
"error",
")",
";",
"ok",
"{",
"r0",
"=",
"rf",
"(",
")",
"\n",
"}",
"else",
"{",
"r0",
"=",
"ret",
".",
"Error",
"(",
"0",
")",
"\n",
"}",
"\n\n",
"return",
"r0",
"\n",
"}"
] |
10,344 | all-10345 | [
"push",
"a",
"named",
"debug",
"group",
"into",
"the",
"command",
"stream"
] | [
"func",
"PushDebugGroup",
"(",
"source",
"uint32",
",",
"<mask>",
"uint32",
",",
"length",
"int32",
",",
"message",
"*",
"uint8",
")",
"{",
"C",
".",
"glowPushDebugGroup",
"(",
"gpPushDebugGroup",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"source",
")",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"id",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"length",
")",
",",
"(",
"*",
"C",
".",
"GLchar",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"message",
")",
")",
")",
"\n",
"}"
] |
10,345 | all-10346 | [
"String",
"returns",
"the",
"human",
"-",
"friendly",
"version",
"of",
"this",
"dependency",
"."
] | [
"func",
"(",
"d",
"*",
"CatalogServicesQuery",
")",
"<mask>",
"(",
")",
"string",
"{",
"if",
"d",
".",
"dc",
"!=",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"d",
".",
"dc",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
10,346 | all-10347 | [
"DecodeCookie",
"verifies",
"the",
"signature",
"and",
"decodes",
"the",
"value",
"into",
"the",
"cookie"
] | [
"func",
"(",
"c",
"CookieSigner",
")",
"DecodeCookie",
"(",
"cookie",
"*",
"http",
".",
"Cookie",
")",
"error",
"{",
"data",
",",
"err",
":=",
"c",
".",
"DecodeValue",
"(",
"cookie",
".",
"Value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"cookie",
".",
"<mask>",
"=",
"data",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
10,347 | all-10348 | [
"Get",
"implements",
"ClientInterface"
] | [
"func",
"(",
"c",
"*",
"<mask>",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"Object",
",",
"error",
")",
"{",
"result",
":=",
"c",
".",
"NewObject",
"(",
")",
"\n",
"err",
":=",
"c",
".",
"cl",
".",
"Get",
"(",
")",
".",
"Namespace",
"(",
"c",
".",
"ns",
")",
".",
"Resource",
"(",
"c",
".",
"t",
".",
"Plural",
")",
".",
"Name",
"(",
"name",
")",
".",
"Do",
"(",
")",
".",
"Into",
"(",
"result",
")",
"\n",
"return",
"result",
",",
"err",
"\n",
"}"
] |
10,348 | all-10349 | [
"Load",
"is",
"used",
"to",
"load",
"the",
"cgroup",
"hierarchy",
"based",
"off",
"the",
"cgroup",
"path"
] | [
"func",
"(",
"c",
"*",
"GlobalCgroupFactory",
")",
"Load",
"(",
"hierarchy",
"cgroups",
".",
"Hierarchy",
",",
"<mask>",
"cgroups",
".",
"Path",
")",
"(",
"cgroups",
".",
"Cgroup",
",",
"error",
")",
"{",
"return",
"cgroups",
".",
"Load",
"(",
"hierarchy",
",",
"path",
")",
"\n",
"}"
] |
10,349 | all-10350 | [
"PixbufGetFileInfo",
"is",
"a",
"wrapper",
"around",
"gdk_pixbuf_get_file_info",
"()",
".",
"TODO",
":",
"need",
"to",
"wrap",
"the",
"returned",
"format",
"to",
"GdkPixbufFormat",
"."
] | [
"func",
"PixbufGetFileInfo",
"(",
"filename",
"string",
")",
"(",
"<mask>",
"interface",
"{",
"}",
",",
"width",
",",
"height",
"int",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"filename",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"var",
"cw",
",",
"ch",
"C",
".",
"gint",
"\n",
"format",
"=",
"C",
".",
"gdk_pixbuf_get_file_info",
"(",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
",",
"&",
"cw",
",",
"&",
"ch",
")",
"\n",
"// TODO: need to wrap the returned format to GdkPixbufFormat.",
"return",
"format",
",",
"int",
"(",
"cw",
")",
",",
"int",
"(",
"ch",
")",
"\n",
"}"
] |
10,350 | all-10351 | [
"copyTree",
"copies",
"srcDir",
"to",
"tar",
"file",
"dstDir",
"ignoring",
"skipFiles",
"."
] | [
"func",
"copyTree",
"(",
"tw",
"*",
"tar",
".",
"Writer",
",",
"dstDir",
",",
"srcDir",
"string",
")",
"error",
"{",
"entries",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"srcDir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"srcDir",
",",
"err",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"entry",
":=",
"range",
"entries",
"{",
"n",
":=",
"entry",
".",
"Name",
"(",
")",
"\n",
"if",
"skipFiles",
"[",
"n",
"]",
"{",
"<mask>",
"\n",
"}",
"\n",
"s",
":=",
"filepath",
".",
"Join",
"(",
"srcDir",
",",
"n",
")",
"\n",
"d",
":=",
"filepath",
".",
"Join",
"(",
"dstDir",
",",
"n",
")",
"\n",
"if",
"entry",
".",
"IsDir",
"(",
")",
"{",
"if",
"err",
":=",
"copyTree",
"(",
"tw",
",",
"d",
",",
"s",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"s",
",",
"d",
",",
"err",
")",
"\n",
"}",
"\n",
"continue",
"\n",
"}",
"\n",
"if",
"err",
":=",
"copyFile",
"(",
"tw",
",",
"d",
",",
"s",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"s",
",",
"d",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,351 | all-10352 | [
"ChangeSvcNotificationTimeperiod",
"creates",
"a",
"new",
"CHANGE_SVC_NOTIFICATION_TIMEPERIOD",
"Nagios",
"command",
".",
"Changes",
"the",
"notification",
"timeperiod",
"for",
"a",
"particular",
"service",
"to",
"what",
"is",
"specified",
"by",
"the",
"notification_timeperiod",
"option",
".",
"The",
"notification_timeperiod",
"option",
"should",
"be",
"the",
"short",
"name",
"of",
"the",
"timeperiod",
"that",
"is",
"to",
"be",
"used",
"as",
"the",
"service",
"notification",
"timeperiod",
".",
"The",
"timeperiod",
"must",
"have",
"been",
"configured",
"in",
"Nagios",
"before",
"it",
"was",
"last",
"(",
"re",
")",
"started",
"."
] | [
"func",
"ChangeSvcNotificationTimeperiod",
"(",
"host_name",
"string",
",",
"service_description",
"<mask>",
",",
"notification_timeperiod",
"string",
",",
")",
"*",
"livestatus",
".",
"Command",
"{",
"return",
"livestatus",
".",
"NewCommand",
"(",
"\"",
"\"",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"host_name",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"service_description",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"notification_timeperiod",
")",
",",
")",
"\n",
"}"
] |
10,352 | all-10353 | [
"LayerInfos",
"returns",
"a",
"list",
"of",
"LayerInfos",
"of",
"layers",
"referenced",
"by",
"this",
"image",
"in",
"order",
"(",
"the",
"root",
"layer",
"first",
"and",
"then",
"successive",
"layered",
"layers",
")",
".",
"The",
"Digest",
"field",
"is",
"guaranteed",
"to",
"be",
"provided",
";",
"Size",
"may",
"be",
"-",
"1",
".",
"WARNING",
":",
"The",
"list",
"may",
"contain",
"duplicates",
"and",
"they",
"are",
"semantically",
"relevant",
"."
] | [
"func",
"(",
"m",
"*",
"Schema1",
")",
"LayerInfos",
"(",
")",
"[",
"]",
"LayerInfo",
"{",
"layers",
":=",
"<mask>",
"(",
"[",
"]",
"LayerInfo",
",",
"len",
"(",
"m",
".",
"FSLayers",
")",
")",
"\n",
"for",
"i",
",",
"layer",
":=",
"range",
"m",
".",
"FSLayers",
"{",
"// NOTE: This includes empty layers (where m.History.V1Compatibility->ThrowAway)",
"layers",
"[",
"(",
"len",
"(",
"m",
".",
"FSLayers",
")",
"-",
"1",
")",
"-",
"i",
"]",
"=",
"LayerInfo",
"{",
"BlobInfo",
":",
"types",
".",
"BlobInfo",
"{",
"Digest",
":",
"layer",
".",
"BlobSum",
",",
"Size",
":",
"-",
"1",
"}",
",",
"EmptyLayer",
":",
"m",
".",
"ExtractedV1Compatibility",
"[",
"i",
"]",
".",
"ThrowAway",
",",
"}",
"\n",
"}",
"\n",
"return",
"layers",
"\n",
"}"
] |
10,353 | all-10354 | [
"WriteStruct",
"writes",
"the",
"given",
"Thrift",
"struct",
"to",
"a",
"writer",
".",
"It",
"pools",
"TProtocols",
"."
] | [
"func",
"WriteStruct",
"(",
"writer",
"io",
".",
"Writer",
",",
"s",
"thrift",
".",
"TStruct",
")",
"error",
"{",
"wp",
":=",
"getProtocolWriter",
"(",
"<mask>",
")",
"\n",
"err",
":=",
"s",
".",
"Write",
"(",
"wp",
".",
"protocol",
")",
"\n",
"thriftProtocolPool",
".",
"Put",
"(",
"wp",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
10,354 | all-10355 | [
"AddFast",
"implements",
"storage",
".",
"Appender",
"."
] | [
"func",
"(",
"t",
"*",
"timestampTracker",
")",
"AddFast",
"(",
"l",
"labels",
".",
"Labels",
",",
"_",
"uint64",
",",
"ts",
"int64",
",",
"v",
"float64",
")",
"error",
"{",
"_",
",",
"err",
":=",
"t",
".",
"Add",
"(",
"l",
",",
"<mask>",
",",
"v",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
10,355 | all-10356 | [
"Apply",
"any",
"pending",
"update",
"that",
"was",
"not",
"yet",
"applied",
"."
] | [
"func",
"ensureUpdatesAreApplied",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"current",
"int",
",",
"updates",
"[",
"]",
"Update",
",",
"hook",
"Hook",
")",
"error",
"{",
"if",
"current",
">",
"len",
"(",
"updates",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"current",
",",
"len",
"(",
"updates",
")",
")",
"\n",
"}",
"\n\n",
"// If there are no updates, there's nothing to do.",
"if",
"len",
"(",
"updates",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Apply missing updates.",
"for",
"_",
",",
"update",
":=",
"range",
"updates",
"[",
"current",
":",
"]",
"{",
"if",
"hook",
"!=",
"nil",
"{",
"err",
":=",
"hook",
"(",
"current",
",",
"tx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"current",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"err",
":=",
"update",
"(",
"tx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"current",
",",
"err",
")",
"\n",
"}",
"\n",
"current",
"++",
"\n\n",
"err",
"=",
"insertSchemaVersion",
"(",
"tx",
",",
"current",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"<mask>",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
10,356 | all-10357 | [
"/",
"*",
"Checks",
"to",
"see",
"if",
"any",
"optimizations",
"can",
"be",
"performed",
"on",
"the",
"given",
"[",
"tokens",
"]",
"which",
"form",
"a",
"complete",
"valid",
"expression",
".",
"The",
"returns",
"slice",
"will",
"represent",
"the",
"optimized",
"(",
"or",
"unmodified",
")",
"list",
"of",
"tokens",
"to",
"use",
"."
] | [
"func",
"optimizeTokens",
"(",
"tokens",
"[",
"]",
"ExpressionToken",
")",
"(",
"[",
"]",
"ExpressionToken",
",",
"error",
")",
"{",
"var",
"token",
"ExpressionToken",
"\n",
"var",
"symbol",
"OperatorSymbol",
"\n",
"var",
"err",
"error",
"\n",
"var",
"index",
"int",
"\n\n",
"for",
"<mask>",
",",
"token",
"=",
"range",
"tokens",
"{",
"// if we find a regex operator, and the right-hand value is a constant, precompile and replace with a pattern.",
"if",
"token",
".",
"Kind",
"!=",
"COMPARATOR",
"{",
"continue",
"\n",
"}",
"\n\n",
"symbol",
"=",
"comparatorSymbols",
"[",
"token",
".",
"Value",
".",
"(",
"string",
")",
"]",
"\n",
"if",
"symbol",
"!=",
"REQ",
"&&",
"symbol",
"!=",
"NREQ",
"{",
"continue",
"\n",
"}",
"\n\n",
"index",
"++",
"\n",
"token",
"=",
"tokens",
"[",
"index",
"]",
"\n",
"if",
"token",
".",
"Kind",
"==",
"STRING",
"{",
"token",
".",
"Kind",
"=",
"PATTERN",
"\n",
"token",
".",
"Value",
",",
"err",
"=",
"regexp",
".",
"Compile",
"(",
"token",
".",
"Value",
".",
"(",
"string",
")",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"tokens",
",",
"err",
"\n",
"}",
"\n\n",
"tokens",
"[",
"index",
"]",
"=",
"token",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"tokens",
",",
"nil",
"\n",
"}"
] |
10,357 | all-10358 | [
"GetStrv",
"returns",
"a",
"slice",
"of",
"strings",
"from",
"this",
"variant",
".",
"It",
"wraps",
"g_variant_get_strv",
"but",
"returns",
"copies",
"of",
"the",
"strings",
"instead",
"."
] | [
"func",
"(",
"v",
"*",
"Variant",
")",
"GetStrv",
"(",
")",
"[",
"]",
"string",
"{",
"gstrv",
":=",
"C",
".",
"g_variant_get_strv",
"(",
"v",
".",
"native",
"(",
")",
",",
"nil",
")",
"\n",
"// we do not own the memory for these strings, so we must not use strfreev",
"// but we must free the actual pointer we receive.",
"c",
":=",
"gstrv",
"\n",
"defer",
"C",
".",
"g_free",
"(",
"C",
".",
"gpointer",
"(",
"gstrv",
")",
")",
"\n",
"var",
"strs",
"[",
"]",
"string",
"\n\n",
"for",
"*",
"c",
"!=",
"nil",
"{",
"strs",
"=",
"append",
"(",
"strs",
",",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"<mask>",
")",
"(",
"*",
"c",
")",
")",
")",
"\n",
"c",
"=",
"C",
".",
"next_gcharptr",
"(",
"c",
")",
"\n",
"}",
"\n",
"return",
"strs",
"\n",
"}"
] |
10,358 | all-10359 | [
"Check",
"if",
"location",
"of",
"config",
"or",
"properties",
"file",
"is",
"set",
"in",
"the",
"env",
"variable",
"if",
"no",
"path",
"is",
"specified",
"it",
"will",
"use",
"the",
"current",
"directory"
] | [
"func",
"loadPath",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"path",
":=",
"\"",
"\"",
"\n",
"if",
"len",
"(",
"*",
"cpath",
")",
"==",
"0",
"{",
"path",
"=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"path",
"=",
"*",
"cpath",
"\n",
"}",
"\n\n",
"//if empty, load default config path",
"if",
"len",
"(",
"path",
")",
"==",
"0",
"{",
"gp",
",",
"err",
":=",
"getGoPath",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"<mask>",
"=",
"gp",
"+",
"\"",
"\"",
"\n",
"}",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"path",
")",
"\n\n",
"return",
"path",
",",
"nil",
"\n",
"}"
] |
10,359 | all-10360 | [
"Next",
"returns",
"the",
"next",
"log",
"record"
] | [
"func",
"(",
"qr",
"*",
"<mask>",
")",
"Next",
"(",
")",
"(",
"*",
"Record",
",",
"error",
")",
"{",
"if",
"qr",
".",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"qr",
".",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"qr",
".",
"logs",
")",
">",
"0",
"{",
"lr",
":=",
"qr",
".",
"logs",
"[",
"0",
"]",
"\n",
"qr",
".",
"logs",
"=",
"qr",
".",
"logs",
"[",
"1",
":",
"]",
"\n",
"return",
"lr",
",",
"nil",
"\n",
"}",
"\n\n",
"if",
"qr",
".",
"request",
".",
"Offset",
"==",
"nil",
"&&",
"qr",
".",
"resultsSeen",
"{",
"return",
"nil",
",",
"Done",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"qr",
".",
"run",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"// Errors here may be retried, so don't store the error.",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"qr",
".",
"Next",
"(",
")",
"\n",
"}"
] |
10,360 | all-10361 | [
"Equals",
"compares",
"to",
"private",
"keys"
] | [
"func",
"(",
"ePriv",
"*",
"ECDSAPrivateKey",
")",
"Equals",
"(",
"o",
"Key",
")",
"bool",
"{",
"oPriv",
",",
"<mask>",
":=",
"o",
".",
"(",
"*",
"ECDSAPrivateKey",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"ePriv",
".",
"priv",
".",
"D",
".",
"Cmp",
"(",
"oPriv",
".",
"priv",
".",
"D",
")",
"==",
"0",
"\n",
"}"
] |
10,361 | all-10362 | [
"NewCache",
"creates",
"a",
"new",
"cache",
"."
] | [
"func",
"NewCache",
"(",
"root",
"string",
")",
"*",
"Cache",
"{",
"return",
"&",
"Cache",
"{",
"root",
":",
"root",
",",
"keys",
":",
"make",
"(",
"<mask>",
"[",
"string",
"]",
"bool",
")",
",",
"}",
"\n",
"}"
] |
10,362 | all-10363 | [
"MoveTo",
"starts",
"a",
"new",
"path",
"at",
"(",
"x",
"y",
")",
"position"
] | [
"func",
"(",
"p",
"*",
"<mask>",
")",
"MoveTo",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"p",
".",
"appendToPath",
"(",
"MoveToCmp",
",",
"x",
",",
"y",
")",
"\n",
"p",
".",
"x",
"=",
"x",
"\n",
"p",
".",
"y",
"=",
"y",
"\n",
"}"
] |
10,363 | all-10364 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"EventWorkerVersionUpdated",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoServiceworker10",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
10,364 | all-10365 | [
"/",
"*",
"For",
"the",
"land",
"of",
"Middle",
"-",
"ware",
"Earth",
":",
"One",
"func",
"to",
"rule",
"them",
"all",
"One",
"func",
"to",
"find",
"them",
"One",
"func",
"to",
"bring",
"them",
"all",
"And",
"in",
"this",
"package",
"BIND",
"them",
".",
"Bind",
"wraps",
"up",
"the",
"functionality",
"of",
"the",
"Form",
"and",
"Json",
"middleware",
"according",
"to",
"the",
"Content",
"-",
"Type",
"and",
"verb",
"of",
"the",
"request",
".",
"A",
"Content",
"-",
"Type",
"is",
"required",
"for",
"POST",
"PUT",
"and",
"PATCH",
"requests",
".",
"Bind",
"invokes",
"the",
"ErrorHandler",
"middleware",
"to",
"bail",
"out",
"if",
"errors",
"occurred",
".",
"If",
"you",
"want",
"to",
"perform",
"your",
"own",
"error",
"handling",
"use",
"Form",
"or",
"Json",
"middleware",
"directly",
".",
"An",
"interface",
"pointer",
"can",
"be",
"added",
"as",
"a",
"second",
"argument",
"in",
"order",
"to",
"map",
"the",
"struct",
"to",
"a",
"specific",
"interface",
"."
] | [
"func",
"Bind",
"(",
"obj",
"interface",
"{",
"}",
",",
"ifacePtr",
"...",
"interface",
"{",
"}",
")",
"martini",
".",
"Handler",
"{",
"return",
"func",
"(",
"context",
"martini",
".",
"Context",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"contentType",
":=",
"req",
".",
"<mask>",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"req",
".",
"Method",
"==",
"\"",
"\"",
"||",
"req",
".",
"Method",
"==",
"\"",
"\"",
"||",
"req",
".",
"Method",
"==",
"\"",
"\"",
"||",
"contentType",
"!=",
"\"",
"\"",
"{",
"if",
"strings",
".",
"Contains",
"(",
"contentType",
",",
"\"",
"\"",
")",
"{",
"context",
".",
"Invoke",
"(",
"Form",
"(",
"obj",
",",
"ifacePtr",
"...",
")",
")",
"\n",
"}",
"else",
"if",
"strings",
".",
"Contains",
"(",
"contentType",
",",
"\"",
"\"",
")",
"{",
"context",
".",
"Invoke",
"(",
"MultipartForm",
"(",
"obj",
",",
"ifacePtr",
"...",
")",
")",
"\n",
"}",
"else",
"if",
"strings",
".",
"Contains",
"(",
"contentType",
",",
"\"",
"\"",
")",
"{",
"context",
".",
"Invoke",
"(",
"Json",
"(",
"obj",
",",
"ifacePtr",
"...",
")",
")",
"\n",
"}",
"else",
"{",
"var",
"errors",
"Errors",
"\n",
"if",
"contentType",
"==",
"\"",
"\"",
"{",
"errors",
".",
"Add",
"(",
"[",
"]",
"string",
"{",
"}",
",",
"ContentTypeError",
",",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"errors",
".",
"Add",
"(",
"[",
"]",
"string",
"{",
"}",
",",
"ContentTypeError",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"context",
".",
"Map",
"(",
"errors",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"context",
".",
"Invoke",
"(",
"Form",
"(",
"obj",
",",
"ifacePtr",
"...",
")",
")",
"\n",
"}",
"\n\n",
"context",
".",
"Invoke",
"(",
"ErrorHandler",
")",
"\n",
"}",
"\n",
"}"
] |
10,365 | all-10366 | [
"Critical",
"formats",
"a",
"given",
"message",
"according",
"to",
"given",
"params",
"to",
"log",
"with",
"level",
"Critical",
"."
] | [
"func",
"(",
"dl",
"*",
"DefaultLogger",
")",
"Critical",
"(",
"<mask>",
"string",
",",
"params",
"...",
"interface",
"{",
"}",
")",
"{",
"dl",
".",
"logger",
".",
"Criticalf",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"caller",
"(",
")",
",",
"message",
")",
",",
"params",
"...",
")",
"\n",
"}"
] |
10,366 | all-10367 | [
"Index",
"returns",
"the",
"index",
"position",
"of",
"the",
"frame",
"value",
"within",
"the",
"frame",
"set",
".",
"If",
"the",
"given",
"frame",
"does",
"not",
"exist",
"then",
"return",
"-",
"1"
] | [
"func",
"(",
"s",
"*",
"FrameSet",
")",
"Index",
"(",
"frame",
"int",
")",
"int",
"{",
"return",
"s",
".",
"rangePtr",
".",
"Index",
"(",
"<mask>",
")",
"\n",
"}"
] |
10,367 | all-10368 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"AddInspectedHeapObjectParams",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoHeapprofiler23",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
10,368 | all-10369 | [
"determine",
"if",
"a",
"name",
"corresponds",
"to",
"a",
"display",
"list"
] | [
"func",
"IsList",
"(",
"list",
"uint32",
")",
"bool",
"{",
"ret",
",",
"_",
",",
"_",
":=",
"syscall",
".",
"Syscall",
"(",
"gpIsList",
",",
"1",
",",
"uintptr",
"(",
"list",
")",
",",
"0",
",",
"0",
")",
"\n",
"return",
"<mask>",
"!=",
"0",
"\n",
"}"
] |
10,369 | all-10370 | [
"GetEventTypeOk",
"returns",
"a",
"tuple",
"with",
"the",
"EventType",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"e",
"*",
"Event",
")",
"GetEventTypeOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"e",
"==",
"nil",
"||",
"e",
".",
"EventType",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"e",
".",
"EventType",
",",
"<mask>",
"\n",
"}"
] |
10,370 | all-10371 | [
"SaveStruct",
"returns",
"the",
"fields",
"from",
"src",
"as",
"a",
"slice",
"of",
"Field",
".",
"src",
"must",
"be",
"a",
"struct",
"pointer",
"."
] | [
"func",
"SaveStruct",
"(",
"src",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"f",
",",
"_",
",",
"err",
":=",
"saveStructWithMeta",
"(",
"src",
")",
"\n",
"return",
"f",
",",
"err",
"\n",
"}"
] |
10,371 | all-10372 | [
"UnmarshalBinary",
"unmarshals",
"a",
"byte",
"slice",
"into",
"an",
"ATAArg",
".",
"If",
"the",
"byte",
"slice",
"does",
"not",
"contain",
"enough",
"data",
"to",
"form",
"a",
"valid",
"ATAArg",
"io",
".",
"ErrUnexpectedEOF",
"is",
"returned",
".",
"If",
"bytes",
"10",
"and",
"11",
"are",
"not",
"zero",
"(",
"reserved",
"bytes",
")",
"ErrorBadArgumentParameter",
"is",
"returned",
"."
] | [
"func",
"(",
"a",
"*",
"ATAArg",
")",
"UnmarshalBinary",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"// Must contain minimum length for ATA argument",
"if",
"len",
"(",
"b",
")",
"<",
"ataArgLen",
"{",
"return",
"io",
".",
"ErrUnexpectedEOF",
"\n",
"}",
"\n\n",
"// 2 bytes reserved",
"if",
"b",
"[",
"10",
"]",
"!=",
"0",
"||",
"b",
"[",
"11",
"]",
"!=",
"0",
"{",
"return",
"ErrorBadArgumentParameter",
"\n",
"}",
"\n\n",
"// Read bit flags at appropriate positions:",
"//",
"// 0101 0011",
"// | | ||",
"// | | |+-- write flag",
"// | | +--- asynchronous flag",
"// | +------- device/head register flag",
"// +--------- extended LBA48 flag",
"a",
".",
"FlagLBA48Extended",
"=",
"(",
"b",
"[",
"0",
"]",
"&",
"0x40",
")",
"!=",
"0",
"\n",
"a",
".",
"FlagATADeviceHeadRegister",
"=",
"(",
"b",
"[",
"0",
"]",
"&",
"0x10",
")",
"!=",
"0",
"\n",
"a",
".",
"FlagAsynchronous",
"=",
"(",
"b",
"[",
"0",
"]",
"&",
"0x02",
")",
"!=",
"0",
"\n",
"a",
".",
"FlagWrite",
"=",
"(",
"b",
"[",
"0",
"]",
"&",
"0x01",
")",
"!=",
"0",
"\n\n",
"// Read ATA data",
"a",
".",
"ErrFeature",
"=",
"b",
"[",
"1",
"]",
"\n",
"a",
".",
"SectorCount",
"=",
"b",
"[",
"2",
"]",
"\n",
"a",
".",
"CmdStatus",
"=",
"ATACmdStatus",
"(",
"b",
"[",
"3",
"]",
")",
"\n",
"a",
".",
"LBA",
"[",
"0",
"]",
"=",
"b",
"[",
"4",
"]",
"\n",
"a",
".",
"LBA",
"[",
"1",
"]",
"=",
"b",
"[",
"5",
"]",
"\n",
"a",
".",
"LBA",
"[",
"2",
"]",
"=",
"b",
"[",
"6",
"]",
"\n",
"a",
".",
"LBA",
"[",
"3",
"]",
"=",
"b",
"[",
"7",
"]",
"\n",
"a",
".",
"LBA",
"[",
"4",
"]",
"=",
"b",
"[",
"8",
"]",
"\n",
"a",
".",
"LBA",
"[",
"5",
"]",
"=",
"b",
"[",
"9",
"]",
"\n\n",
"// Copy raw data from ATA argument",
"d",
":=",
"make",
"(",
"[",
"]",
"<mask>",
",",
"len",
"(",
"b",
"[",
"12",
":",
"]",
")",
")",
"\n",
"copy",
"(",
"d",
",",
"b",
"[",
"12",
":",
"]",
")",
"\n",
"a",
".",
"Data",
"=",
"d",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
10,372 | all-10373 | [
"OnSignal",
"calls",
"the",
"given",
"ProcessFunc",
"every",
"time",
"the",
"signal",
"fires",
"and",
"waits",
"for",
"it",
"to",
"exit",
".",
"This",
"is",
"sequentially",
"rate",
"limited",
"only",
"one",
"call",
"will",
"be",
"in",
"-",
"flight",
"at",
"a",
"time",
".",
"sig",
":",
"=",
"make",
"(",
"chan",
"struct",
"{}",
")",
"p",
":",
"=",
"periodicproc",
".",
"OnSignal",
"(",
"sig",
"func",
"(",
"proc",
"goprocess",
".",
"Process",
")",
"{",
"fmt",
".",
"Println",
"(",
"fire!",
")",
"<",
"-",
"time",
".",
"After",
"(",
"time",
".",
"Second",
")",
"//",
"delays",
"sequential",
"execution",
"by",
"1",
"second",
"}",
")",
"sig<",
"-",
"struct",
"{}",
"sig<",
"-",
"struct",
"{}",
"sig<",
"-",
"struct",
"{}",
"//",
"Output",
":",
"//",
"fire!",
"//",
"fire!",
"//",
"fire!"
] | [
"func",
"OnSignal",
"(",
"sig",
"<-",
"chan",
"struct",
"{",
"}",
",",
"procfunc",
"gp",
".",
"ProcessFunc",
")",
"gp",
".",
"Process",
"{",
"return",
"gp",
".",
"Go",
"(",
"func",
"(",
"proc",
"gp",
".",
"Process",
")",
"{",
"for",
"{",
"select",
"{",
"<mask>",
"<-",
"sig",
":",
"select",
"{",
"case",
"<-",
"proc",
".",
"Go",
"(",
"procfunc",
")",
".",
"Closed",
"(",
")",
":",
"// spin it out as a child, and wait till it's done.",
"case",
"<-",
"proc",
".",
"Closing",
"(",
")",
":",
"// we're told to close",
"return",
"\n",
"}",
"\n",
"case",
"<-",
"proc",
".",
"Closing",
"(",
")",
":",
"// we're told to close",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}",
")",
"\n",
"}"
] |
10,373 | all-10374 | [
"/",
"*",
"Performs",
"a",
"mirror",
"on",
"a",
"subtree",
"of",
"stages",
".",
"This",
"mirror",
"functionally",
"inverts",
"the",
"order",
"of",
"execution",
"for",
"all",
"members",
"of",
"the",
"[",
"stages",
"]",
"list",
".",
"That",
"list",
"is",
"assumed",
"to",
"be",
"a",
"root",
"-",
"to",
"-",
"leaf",
"(",
"ordered",
")",
"list",
"of",
"evaluation",
"stages",
"where",
"each",
"is",
"a",
"right",
"-",
"hand",
"stage",
"of",
"the",
"last",
"."
] | [
"func",
"mirrorStageSubtree",
"(",
"stages",
"[",
"]",
"*",
"evaluationStage",
")",
"{",
"<mask>",
"rootStage",
",",
"inverseStage",
",",
"carryStage",
",",
"frontStage",
"*",
"evaluationStage",
"\n\n",
"stagesLength",
":=",
"len",
"(",
"stages",
")",
"\n\n",
"// reverse all right/left",
"for",
"_",
",",
"frontStage",
"=",
"range",
"stages",
"{",
"carryStage",
"=",
"frontStage",
".",
"rightStage",
"\n",
"frontStage",
".",
"rightStage",
"=",
"frontStage",
".",
"leftStage",
"\n",
"frontStage",
".",
"leftStage",
"=",
"carryStage",
"\n",
"}",
"\n\n",
"// end left swaps with root right",
"rootStage",
"=",
"stages",
"[",
"0",
"]",
"\n",
"frontStage",
"=",
"stages",
"[",
"stagesLength",
"-",
"1",
"]",
"\n\n",
"carryStage",
"=",
"frontStage",
".",
"leftStage",
"\n",
"frontStage",
".",
"leftStage",
"=",
"rootStage",
".",
"rightStage",
"\n",
"rootStage",
".",
"rightStage",
"=",
"carryStage",
"\n\n",
"// for all non-root non-end stages, right is swapped with inverse stage right in list",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"(",
"stagesLength",
"-",
"2",
")",
"/",
"2",
"+",
"1",
";",
"i",
"++",
"{",
"frontStage",
"=",
"stages",
"[",
"i",
"+",
"1",
"]",
"\n",
"inverseStage",
"=",
"stages",
"[",
"stagesLength",
"-",
"i",
"-",
"1",
"]",
"\n\n",
"carryStage",
"=",
"frontStage",
".",
"rightStage",
"\n",
"frontStage",
".",
"rightStage",
"=",
"inverseStage",
".",
"rightStage",
"\n",
"inverseStage",
".",
"rightStage",
"=",
"carryStage",
"\n",
"}",
"\n\n",
"// swap all other information with inverse stages",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"stagesLength",
"/",
"2",
";",
"i",
"++",
"{",
"frontStage",
"=",
"stages",
"[",
"i",
"]",
"\n",
"inverseStage",
"=",
"stages",
"[",
"stagesLength",
"-",
"i",
"-",
"1",
"]",
"\n",
"frontStage",
".",
"swapWith",
"(",
"inverseStage",
")",
"\n",
"}",
"\n",
"}"
] |
10,374 | all-10375 | [
"RespondTemplate",
"executes",
"a",
"named",
"template",
"with",
"provided",
"data",
"into",
"buffer",
"then",
"writes",
"the",
"the",
"body",
"to",
"the",
"response",
"writer",
".",
"A",
"panic",
"will",
"be",
"raised",
"if",
"the",
"template",
"does",
"not",
"exist",
"or",
"fails",
"to",
"execute",
"."
] | [
"func",
"(",
"t",
"Templates",
")",
"RespondTemplate",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"name",
",",
"templateName",
"string",
",",
"<mask>",
"interface",
"{",
"}",
")",
"{",
"t",
".",
"RespondTemplateWithStatus",
"(",
"w",
",",
"name",
",",
"templateName",
",",
"data",
",",
"0",
")",
"\n",
"}"
] |
10,375 | all-10376 | [
"RevHash",
"fetches",
"current",
"revision",
"and",
"hash",
"on",
"this",
"member",
"."
] | [
"func",
"(",
"m",
"*",
"Member",
")",
"RevHash",
"(",
")",
"(",
"int64",
",",
"int64",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"m",
".",
"DialEtcdGRPCServer",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n\n",
"mt",
":=",
"pb",
".",
"NewMaintenanceClient",
"(",
"<mask>",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"5",
"*",
"time",
".",
"Second",
")",
"\n",
"resp",
",",
"err",
":=",
"mt",
".",
"Hash",
"(",
"ctx",
",",
"&",
"pb",
".",
"HashRequest",
"{",
"}",
",",
"grpc",
".",
"FailFast",
"(",
"false",
")",
")",
"\n",
"cancel",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"resp",
".",
"Header",
".",
"Revision",
",",
"int64",
"(",
"resp",
".",
"Hash",
")",
",",
"nil",
"\n",
"}"
] |
10,376 | all-10377 | [
"Value",
"converts",
"a",
"value",
"to",
"a",
"database",
"driver",
"value"
] | [
"func",
"(",
"b",
"Base64",
")",
"Value",
"(",
")",
"(",
"driver",
".",
"<mask>",
",",
"error",
")",
"{",
"return",
"driver",
".",
"Value",
"(",
"string",
"(",
"b",
")",
")",
",",
"nil",
"\n",
"}"
] |
10,377 | all-10378 | [
"moveVictims",
"tries",
"to",
"update",
"watches",
"with",
"already",
"pending",
"event",
"data"
] | [
"func",
"(",
"s",
"*",
"watchableStore",
")",
"moveVictims",
"(",
")",
"(",
"moved",
"int",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"victims",
":=",
"s",
".",
"victims",
"\n",
"s",
".",
"victims",
"=",
"nil",
"\n",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"var",
"newVictim",
"watcherBatch",
"\n",
"for",
"_",
",",
"wb",
":=",
"range",
"victims",
"{",
"// try to send responses again",
"for",
"w",
",",
"eb",
":=",
"range",
"wb",
"{",
"// watcher has observed the store up to, but not including, w.minRev",
"rev",
":=",
"w",
".",
"minRev",
"-",
"1",
"\n",
"if",
"w",
".",
"send",
"(",
"WatchResponse",
"{",
"WatchID",
":",
"w",
".",
"id",
",",
"Events",
":",
"eb",
".",
"evs",
",",
"Revision",
":",
"rev",
"}",
")",
"{",
"pendingEventsGauge",
".",
"Add",
"(",
"float64",
"(",
"len",
"(",
"eb",
".",
"evs",
")",
")",
")",
"\n",
"}",
"else",
"{",
"if",
"newVictim",
"==",
"nil",
"{",
"newVictim",
"=",
"make",
"(",
"watcherBatch",
")",
"\n",
"}",
"\n",
"newVictim",
"[",
"w",
"]",
"=",
"eb",
"\n",
"continue",
"\n",
"}",
"\n",
"moved",
"++",
"\n",
"}",
"\n\n",
"// assign completed victim watchers to unsync/sync",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"store",
".",
"revMu",
".",
"RLock",
"(",
")",
"\n",
"curRev",
":=",
"s",
".",
"store",
".",
"currentRev",
"\n",
"for",
"w",
",",
"eb",
":=",
"range",
"wb",
"{",
"if",
"newVictim",
"!=",
"nil",
"&&",
"newVictim",
"[",
"w",
"]",
"!=",
"nil",
"{",
"// couldn't send watch response; stays victim",
"continue",
"\n",
"}",
"\n",
"w",
".",
"victim",
"=",
"false",
"\n",
"if",
"eb",
".",
"moreRev",
"!=",
"0",
"{",
"w",
".",
"minRev",
"=",
"eb",
".",
"moreRev",
"\n",
"}",
"\n",
"if",
"w",
".",
"minRev",
"<=",
"curRev",
"{",
"s",
".",
"unsynced",
".",
"add",
"(",
"w",
")",
"\n",
"}",
"else",
"{",
"slowWatcherGauge",
".",
"Dec",
"(",
")",
"\n",
"s",
".",
"synced",
".",
"add",
"(",
"w",
")",
"\n",
"}",
"\n",
"}",
"\n",
"s",
".",
"<mask>",
".",
"revMu",
".",
"RUnlock",
"(",
")",
"\n",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"newVictim",
")",
">",
"0",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"victims",
"=",
"append",
"(",
"s",
".",
"victims",
",",
"newVictim",
")",
"\n",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"moved",
"\n",
"}"
] |
10,378 | all-10379 | [
"Combo",
"returns",
"a",
"combo",
"router",
"."
] | [
"func",
"(",
"r",
"*",
"Router",
")",
"Combo",
"(",
"pattern",
"string",
",",
"h",
"...",
"<mask>",
")",
"*",
"ComboRouter",
"{",
"return",
"&",
"ComboRouter",
"{",
"r",
",",
"pattern",
",",
"h",
",",
"map",
"[",
"string",
"]",
"bool",
"{",
"}",
",",
"nil",
"}",
"\n",
"}"
] |
10,379 | all-10380 | [
"AddCName",
"adds",
"a",
"CName",
"to",
"app",
".",
"It",
"updates",
"the",
"attribute",
"calls",
"the",
"SetCName",
"function",
"on",
"the",
"provisioner",
"and",
"saves",
"the",
"app",
"in",
"the",
"database",
"returning",
"an",
"error",
"when",
"it",
"cannot",
"save",
"the",
"change",
"in",
"the",
"database",
"or",
"add",
"the",
"CName",
"on",
"the",
"provisioner",
"."
] | [
"func",
"(",
"app",
"*",
"App",
")",
"AddCName",
"(",
"cnames",
"...",
"string",
")",
"error",
"{",
"actions",
":=",
"[",
"]",
"*",
"<mask>",
".",
"Action",
"{",
"&",
"validateNewCNames",
",",
"&",
"setNewCNamesToProvisioner",
",",
"&",
"saveCNames",
",",
"&",
"updateApp",
",",
"}",
"\n",
"err",
":=",
"action",
".",
"NewPipeline",
"(",
"actions",
"...",
")",
".",
"Execute",
"(",
"app",
",",
"cnames",
")",
"\n",
"rebuild",
".",
"RoutesRebuildOrEnqueue",
"(",
"app",
".",
"Name",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
10,380 | all-10381 | [
"ValidateOCIPath",
"takes",
"the",
"OCI",
"path",
"and",
"validates",
"it",
"."
] | [
"func",
"ValidateOCIPath",
"(",
"path",
"string",
")",
"error",
"{",
"if",
"runtime",
".",
"GOOS",
"==",
"\"",
"\"",
"{",
"// On Windows we must allow for a ':' as part of the path",
"if",
"strings",
".",
"Count",
"(",
"path",
",",
"\"",
"\"",
")",
">",
"1",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"if",
"strings",
".",
"Contains",
"(",
"path",
",",
"\"",
"\"",
")",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"<mask>",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,381 | all-10382 | [
"/",
"*",
"This",
"function",
"takes",
"a",
"container",
"or",
"snapshot",
"from",
"the",
"local",
"image",
"server",
"and",
"exports",
"it",
"as",
"an",
"image",
"."
] | [
"func",
"imgPostContInfo",
"(",
"d",
"*",
"Daemon",
",",
"r",
"*",
"http",
".",
"Request",
",",
"req",
"api",
".",
"ImagesPost",
",",
"op",
"*",
"<mask>",
",",
"builddir",
"string",
")",
"(",
"*",
"api",
".",
"Image",
",",
"error",
")",
"{",
"info",
":=",
"api",
".",
"Image",
"{",
"}",
"\n",
"info",
".",
"Properties",
"=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"project",
":=",
"projectParam",
"(",
"r",
")",
"\n",
"name",
":=",
"req",
".",
"Source",
".",
"Name",
"\n",
"ctype",
":=",
"req",
".",
"Source",
".",
"Type",
"\n",
"if",
"ctype",
"==",
"\"",
"\"",
"||",
"name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"switch",
"ctype",
"{",
"case",
"\"",
"\"",
":",
"if",
"!",
"shared",
".",
"IsSnapshot",
"(",
"name",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"case",
"\"",
"\"",
":",
"if",
"shared",
".",
"IsSnapshot",
"(",
"name",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"default",
":",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"info",
".",
"Filename",
"=",
"req",
".",
"Filename",
"\n",
"switch",
"req",
".",
"Public",
"{",
"case",
"true",
":",
"info",
".",
"Public",
"=",
"true",
"\n",
"case",
"false",
":",
"info",
".",
"Public",
"=",
"false",
"\n",
"}",
"\n\n",
"c",
",",
"err",
":=",
"containerLoadByProjectAndName",
"(",
"d",
".",
"State",
"(",
")",
",",
"project",
",",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Build the actual image file",
"imageFile",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"builddir",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"os",
".",
"Remove",
"(",
"imageFile",
".",
"Name",
"(",
")",
")",
"\n\n",
"// Calculate (close estimate of) total size of input to image",
"totalSize",
":=",
"int64",
"(",
"0",
")",
"\n",
"sumSize",
":=",
"func",
"(",
"path",
"string",
",",
"fi",
"os",
".",
"FileInfo",
",",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"==",
"nil",
"{",
"totalSize",
"+=",
"fi",
".",
"Size",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"err",
"=",
"filepath",
".",
"Walk",
"(",
"c",
".",
"RootfsPath",
"(",
")",
",",
"sumSize",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Track progress creating image.",
"metadata",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"imageProgressWriter",
":=",
"&",
"ioprogress",
".",
"ProgressWriter",
"{",
"Tracker",
":",
"&",
"ioprogress",
".",
"ProgressTracker",
"{",
"Handler",
":",
"func",
"(",
"value",
",",
"speed",
"int64",
")",
"{",
"percent",
":=",
"int64",
"(",
"0",
")",
"\n",
"processed",
":=",
"int64",
"(",
"0",
")",
"\n\n",
"if",
"totalSize",
">",
"0",
"{",
"percent",
"=",
"value",
"\n",
"processed",
"=",
"totalSize",
"*",
"(",
"percent",
"/",
"100.0",
")",
"\n",
"}",
"else",
"{",
"processed",
"=",
"value",
"\n",
"}",
"\n\n",
"shared",
".",
"SetProgressMetadata",
"(",
"metadata",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"percent",
",",
"processed",
",",
"speed",
")",
"\n",
"op",
".",
"UpdateMetadata",
"(",
"metadata",
")",
"\n",
"}",
",",
"Length",
":",
"totalSize",
",",
"}",
",",
"}",
"\n\n",
"sha256",
":=",
"sha256",
".",
"New",
"(",
")",
"\n",
"var",
"compress",
"string",
"\n",
"var",
"writer",
"io",
".",
"Writer",
"\n\n",
"if",
"req",
".",
"CompressionAlgorithm",
"!=",
"\"",
"\"",
"{",
"compress",
"=",
"req",
".",
"CompressionAlgorithm",
"\n",
"}",
"else",
"{",
"compress",
",",
"err",
"=",
"cluster",
".",
"ConfigGetString",
"(",
"d",
".",
"cluster",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Setup tar, optional compress and sha256 to happen in one pass.",
"wg",
":=",
"sync",
".",
"WaitGroup",
"{",
"}",
"\n",
"var",
"compressErr",
"error",
"\n",
"if",
"compress",
"!=",
"\"",
"\"",
"{",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"tarReader",
",",
"tarWriter",
":=",
"io",
".",
"Pipe",
"(",
")",
"\n",
"imageProgressWriter",
".",
"WriteCloser",
"=",
"tarWriter",
"\n",
"writer",
"=",
"imageProgressWriter",
"\n",
"compressWriter",
":=",
"io",
".",
"MultiWriter",
"(",
"imageFile",
",",
"sha256",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"defer",
"wg",
".",
"Done",
"(",
")",
"\n",
"compressErr",
"=",
"compressFile",
"(",
"compress",
",",
"tarReader",
",",
"compressWriter",
")",
"\n",
"}",
"(",
")",
"\n",
"}",
"else",
"{",
"imageProgressWriter",
".",
"WriteCloser",
"=",
"imageFile",
"\n",
"writer",
"=",
"io",
".",
"MultiWriter",
"(",
"imageProgressWriter",
",",
"sha256",
")",
"\n",
"}",
"\n\n",
"err",
"=",
"c",
".",
"Export",
"(",
"writer",
",",
"req",
".",
"Properties",
")",
"\n",
"// When compression is used, Close on imageProgressWriter/tarWriter",
"// is required for compressFile/gzip to know it is finished.",
"// Otherwise It is equivalent to imageFile.Close.",
"imageProgressWriter",
".",
"Close",
"(",
")",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"compressErr",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"imageFile",
".",
"Close",
"(",
")",
"\n\n",
"fi",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"imageFile",
".",
"Name",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"info",
".",
"Size",
"=",
"fi",
".",
"Size",
"(",
")",
"\n",
"info",
".",
"Fingerprint",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sha256",
".",
"Sum",
"(",
"nil",
")",
")",
"\n\n",
"_",
",",
"_",
",",
"err",
"=",
"d",
".",
"cluster",
".",
"ImageGet",
"(",
"project",
",",
"info",
".",
"Fingerprint",
",",
"false",
",",
"true",
")",
"\n",
"if",
"err",
"!=",
"db",
".",
"ErrNoSuchObject",
"{",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"info",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"info",
".",
"Fingerprint",
")",
"\n",
"}",
"\n\n",
"/* rename the the file to the expected name so our caller can use it */",
"finalName",
":=",
"shared",
".",
"VarPath",
"(",
"\"",
"\"",
",",
"info",
".",
"Fingerprint",
")",
"\n",
"err",
"=",
"shared",
".",
"FileMove",
"(",
"imageFile",
".",
"Name",
"(",
")",
",",
"finalName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"info",
".",
"Architecture",
",",
"_",
"=",
"osarch",
".",
"ArchitectureName",
"(",
"c",
".",
"Architecture",
"(",
")",
")",
"\n",
"info",
".",
"Properties",
"=",
"req",
".",
"Properties",
"\n\n",
"// Create the database entry",
"err",
"=",
"d",
".",
"cluster",
".",
"ImageInsert",
"(",
"c",
".",
"Project",
"(",
")",
",",
"info",
".",
"Fingerprint",
",",
"info",
".",
"Filename",
",",
"info",
".",
"Size",
",",
"info",
".",
"Public",
",",
"info",
".",
"AutoUpdate",
",",
"info",
".",
"Architecture",
",",
"info",
".",
"CreatedAt",
",",
"info",
".",
"ExpiresAt",
",",
"info",
".",
"Properties",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"info",
",",
"nil",
"\n",
"}"
] |
10,382 | all-10383 | [
"newTxnResp",
"allocates",
"a",
"txn",
"response",
"for",
"a",
"txn",
"request",
"given",
"a",
"path",
"."
] | [
"func",
"newTxnResp",
"(",
"rt",
"*",
"pb",
".",
"TxnRequest",
",",
"txnPath",
"[",
"]",
"bool",
")",
"(",
"txnResp",
"*",
"pb",
".",
"TxnResponse",
",",
"txnCount",
"int",
")",
"{",
"reqs",
":=",
"rt",
".",
"Success",
"\n",
"if",
"!",
"txnPath",
"[",
"0",
"]",
"{",
"reqs",
"=",
"rt",
".",
"Failure",
"\n",
"}",
"\n",
"resps",
":=",
"make",
"(",
"[",
"]",
"*",
"pb",
".",
"ResponseOp",
",",
"len",
"(",
"reqs",
")",
")",
"\n",
"txnResp",
"=",
"&",
"pb",
".",
"TxnResponse",
"{",
"Responses",
":",
"resps",
",",
"Succeeded",
":",
"txnPath",
"[",
"0",
"]",
",",
"Header",
":",
"&",
"pb",
".",
"ResponseHeader",
"{",
"}",
",",
"}",
"\n",
"for",
"i",
",",
"req",
":=",
"range",
"reqs",
"{",
"switch",
"tv",
":=",
"req",
".",
"Request",
".",
"(",
"type",
")",
"{",
"case",
"*",
"pb",
".",
"RequestOp_RequestRange",
":",
"resps",
"[",
"i",
"]",
"=",
"&",
"pb",
".",
"ResponseOp",
"{",
"Response",
":",
"&",
"pb",
".",
"ResponseOp_ResponseRange",
"{",
"}",
"}",
"\n",
"case",
"*",
"pb",
".",
"RequestOp_RequestPut",
":",
"resps",
"[",
"i",
"]",
"=",
"&",
"pb",
".",
"ResponseOp",
"{",
"Response",
":",
"&",
"pb",
".",
"ResponseOp_ResponsePut",
"{",
"}",
"}",
"\n",
"case",
"*",
"pb",
".",
"RequestOp_RequestDeleteRange",
":",
"resps",
"[",
"i",
"]",
"=",
"&",
"pb",
".",
"ResponseOp",
"{",
"Response",
":",
"&",
"pb",
".",
"ResponseOp_ResponseDeleteRange",
"{",
"}",
"}",
"\n",
"case",
"*",
"<mask>",
".",
"RequestOp_RequestTxn",
":",
"resp",
",",
"txns",
":=",
"newTxnResp",
"(",
"tv",
".",
"RequestTxn",
",",
"txnPath",
"[",
"1",
":",
"]",
")",
"\n",
"resps",
"[",
"i",
"]",
"=",
"&",
"pb",
".",
"ResponseOp",
"{",
"Response",
":",
"&",
"pb",
".",
"ResponseOp_ResponseTxn",
"{",
"ResponseTxn",
":",
"resp",
"}",
"}",
"\n",
"txnPath",
"=",
"txnPath",
"[",
"1",
"+",
"txns",
":",
"]",
"\n",
"txnCount",
"+=",
"txns",
"+",
"1",
"\n",
"default",
":",
"}",
"\n",
"}",
"\n",
"return",
"txnResp",
",",
"txnCount",
"\n",
"}"
] |
10,383 | all-10384 | [
"NewPipelineInput",
"creates",
"a",
"new",
"pps",
".",
"PipelineInput"
] | [
"func",
"NewPipelineInput",
"(",
"repoName",
"string",
",",
"glob",
"string",
")",
"*",
"pps",
".",
"PipelineInput",
"{",
"<mask>",
"&",
"pps",
".",
"PipelineInput",
"{",
"Repo",
":",
"NewRepo",
"(",
"repoName",
")",
",",
"Glob",
":",
"glob",
",",
"}",
"\n",
"}"
] |
10,384 | all-10385 | [
"Codecs",
"returns",
"a",
"map",
"of",
"all",
"codecs",
"registered",
"in",
"reg",
"."
] | [
"func",
"(",
"reg",
"*",
"Registry",
")",
"Codecs",
"(",
")",
"(",
"codecs",
"<mask>",
"[",
"string",
"]",
"Codec",
")",
"{",
"codecs",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"Codec",
")",
"\n",
"reg",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"for",
"mimetype",
",",
"codec",
":=",
"range",
"reg",
".",
"codecs",
"{",
"codecs",
"[",
"mimetype",
"]",
"=",
"codec",
"\n",
"}",
"\n",
"reg",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"\n",
"}"
] |
10,385 | all-10386 | [
"WithName",
"attribute",
"name",
"to",
"replace",
"with",
"new",
"attributes",
"derived",
"from",
"text",
"in",
"case",
"text",
"parsed",
"successfully",
"."
] | [
"func",
"(",
"p",
"SetAttributesAsTextParams",
")",
"WithName",
"(",
"<mask>",
"string",
")",
"*",
"SetAttributesAsTextParams",
"{",
"p",
".",
"Name",
"=",
"name",
"\n",
"return",
"&",
"p",
"\n",
"}"
] |
10,386 | all-10387 | [
"Enumerate",
"lists",
"the",
"items",
"in",
"a",
"Directory"
] | [
"func",
"(",
"d",
"Directory",
")",
"Enumerate",
"(",
"cancel",
"<-",
"chan",
"struct",
"{",
"}",
")",
"Enumerator",
"{",
"results",
":=",
"<mask>",
"(",
"chan",
"interface",
"{",
"}",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"defer",
"close",
"(",
"results",
")",
"\n\n",
"filepath",
".",
"Walk",
"(",
"d",
".",
"Location",
",",
"func",
"(",
"currentLocation",
"string",
",",
"info",
"os",
".",
"FileInfo",
",",
"openErr",
"error",
")",
"(",
"err",
"error",
")",
"{",
"if",
"openErr",
"!=",
"nil",
"{",
"err",
"=",
"openErr",
"\n",
"return",
"\n",
"}",
"\n\n",
"if",
"d",
".",
"Location",
"==",
"currentLocation",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"info",
".",
"IsDir",
"(",
")",
"&&",
"0",
"==",
"d",
".",
"Options",
"&",
"DirectoryOptionsRecursive",
"{",
"err",
"=",
"filepath",
".",
"SkipDir",
"\n",
"}",
"\n\n",
"if",
"d",
".",
"applyOptions",
"(",
"currentLocation",
",",
"info",
")",
"{",
"select",
"{",
"case",
"results",
"<-",
"currentLocation",
":",
"// Intentionally Left Blank",
"case",
"<-",
"cancel",
":",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"\n",
"}",
")",
"\n",
"}",
"(",
")",
"\n\n",
"return",
"results",
"\n",
"}"
] |
10,387 | all-10388 | [
"Shutdown",
"calls",
"h2quic",
".",
"Server",
".",
"Close",
"method",
"."
] | [
"func",
"(",
"s",
"*",
"Server",
")",
"Shutdown",
"(",
"_",
"<mask>",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"return",
"s",
".",
"Server",
".",
"Close",
"(",
")",
"\n",
"}"
] |
10,388 | all-10389 | [
"expandStorageDrsVMConfigInfo",
"reads",
"certain",
"ResourceData",
"keys",
"and",
"returns",
"a",
"StorageDrsVmConfigInfo",
"."
] | [
"func",
"expandStorageDrsVMConfigInfo",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"vm",
"*",
"object",
".",
"VirtualMachine",
")",
"(",
"*",
"types",
".",
"StorageDrsVmConfigInfo",
",",
"error",
")",
"{",
"<mask>",
",",
"err",
":=",
"structure",
".",
"GetBoolStringPtr",
"(",
"d",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"intraVMAffinity",
",",
"err",
":=",
"structure",
".",
"GetBoolStringPtr",
"(",
"d",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"obj",
":=",
"&",
"types",
".",
"StorageDrsVmConfigInfo",
"{",
"Behavior",
":",
"d",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"string",
")",
",",
"Enabled",
":",
"enabled",
",",
"IntraVmAffinity",
":",
"intraVMAffinity",
",",
"Vm",
":",
"types",
".",
"NewReference",
"(",
"vm",
".",
"Reference",
"(",
")",
")",
",",
"}",
"\n\n",
"return",
"obj",
",",
"nil",
"\n",
"}"
] |
10,389 | all-10390 | [
"RedirectRoute",
"returns",
"a",
"RedirectResponse",
"to",
"the",
"route"
] | [
"func",
"(",
"c",
"*",
"Controller",
")",
"RedirectRoute",
"(",
"routeName",
"string",
",",
"args",
"...",
"string",
")",
"*",
"RedirectResponse",
"{",
"return",
"NewRedirectResponse",
"(",
"c",
".",
"UrlFor",
"(",
"routeName",
",",
"args",
"...",
")",
".",
"<mask>",
"(",
")",
")",
"\n",
"}"
] |
10,390 | all-10391 | [
"SaveTask",
"--"
] | [
"func",
"(",
"s",
"*",
"FakeTaskManager",
")",
"SaveTask",
"(",
"t",
"*",
"taskmanager",
".",
"<mask>",
")",
"(",
"*",
"taskmanager",
".",
"Task",
",",
"error",
")",
"{",
"if",
"s",
".",
"ExpireEmitter",
"!=",
"nil",
"{",
"s",
".",
"ExpireEmitter",
"<-",
"t",
".",
"Expires",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"SpyTaskSaved",
"!=",
"nil",
"{",
"*",
"s",
".",
"SpyTaskSaved",
"=",
"*",
"t",
"\n",
"}",
"\n",
"return",
"t",
",",
"s",
".",
"ReturnedErr",
"\n",
"}"
] |
10,391 | all-10392 | [
"createDiskImage",
"makes",
"a",
"disk",
"image",
"at",
"dest",
"with",
"the",
"given",
"size",
"in",
"MB",
".",
"If",
"r",
"is",
"not",
"nil",
"it",
"will",
"be",
"read",
"as",
"a",
"raw",
"disk",
"image",
"to",
"convert",
"from",
"."
] | [
"func",
"createDiskImage",
"(",
"dest",
"string",
",",
"size",
"int",
",",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"// Convert a raw image from stdin to the dest VMDK image.",
"sizeBytes",
":=",
"int64",
"(",
"size",
")",
"<<",
"20",
"// usually won't fit in 32-bit int (max 2GB)",
"\n",
"// FIXME: why isn't this just using the vbm*() functions?",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"vboxManageCmd",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"dest",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sizeBytes",
")",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"log",
".",
"Debug",
"(",
"cmd",
")",
"\n\n",
"if",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"!=",
"\"",
"\"",
"{",
"cmd",
".",
"Stdout",
"=",
"<mask>",
".",
"Stdout",
"\n",
"cmd",
".",
"Stderr",
"=",
"os",
".",
"Stderr",
"\n",
"}",
"\n\n",
"stdin",
",",
"err",
":=",
"cmd",
".",
"StdinPipe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"err",
":=",
"cmd",
".",
"Start",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"n",
",",
"err",
":=",
"io",
".",
"Copy",
"(",
"stdin",
",",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"// The total number of bytes written to stdin must match sizeBytes, or",
"// VBoxManage.exe on Windows will fail. Fill remaining with zeros.",
"if",
"left",
":=",
"sizeBytes",
"-",
"n",
";",
"left",
">",
"0",
"{",
"if",
"err",
":=",
"zeroFill",
"(",
"stdin",
",",
"left",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"// cmd won't exit until the stdin is closed.",
"if",
"err",
":=",
"stdin",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"return",
"cmd",
".",
"Wait",
"(",
")",
"\n",
"}"
] |
10,392 | all-10393 | [
"GetHeight",
"is",
"a",
"wrapper",
"around",
"gdk_pixbuf_get_height",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Pixbuf",
")",
"GetHeight",
"(",
")",
"int",
"{",
"c",
":=",
"C",
".",
"gdk_pixbuf_get_height",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"<mask>",
"int",
"(",
"c",
")",
"\n",
"}"
] |
10,393 | all-10394 | [
"NewGetCommand",
"returns",
"the",
"CLI",
"command",
"for",
"get",
"."
] | [
"func",
"NewGetCommand",
"(",
")",
"<mask>",
".",
"Command",
"{",
"return",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"ArgsUsage",
":",
"\"",
"\"",
",",
"Flags",
":",
"[",
"]",
"cli",
".",
"Flag",
"{",
"cli",
".",
"BoolFlag",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
"}",
",",
"cli",
".",
"BoolFlag",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
"}",
",",
"}",
",",
"Action",
":",
"func",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"getCommandFunc",
"(",
"c",
",",
"mustNewKeyAPI",
"(",
"c",
")",
")",
"\n",
"return",
"nil",
"\n",
"}",
",",
"}",
"\n",
"}"
] |
10,394 | all-10395 | [
"createMergedSnapshotMessage",
"creates",
"a",
"snapshot",
"message",
"that",
"contains",
":",
"raft",
"status",
"(",
"term",
"conf",
")",
"a",
"snapshot",
"of",
"v2",
"store",
"inside",
"raft",
".",
"Snapshot",
"as",
"[]",
"byte",
"a",
"snapshot",
"of",
"v3",
"KV",
"in",
"the",
"top",
"level",
"message",
"as",
"ReadCloser",
"."
] | [
"func",
"(",
"s",
"*",
"EtcdServer",
")",
"createMergedSnapshotMessage",
"(",
"m",
"raftpb",
".",
"Message",
",",
"snapt",
",",
"snapi",
"uint64",
",",
"confState",
"raftpb",
".",
"ConfState",
")",
"snap",
".",
"Message",
"{",
"// get a snapshot of v2 store as []byte",
"clone",
":=",
"s",
".",
"v2store",
".",
"Clone",
"(",
")",
"\n",
"d",
",",
"err",
":=",
"clone",
".",
"SaveNoCopy",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"lg",
":=",
"s",
".",
"getLogger",
"(",
")",
";",
"lg",
"!=",
"nil",
"{",
"lg",
".",
"Panic",
"(",
"\"",
"\"",
",",
"zap",
".",
"<mask>",
"(",
"err",
")",
")",
"\n",
"}",
"else",
"{",
"plog",
".",
"Panicf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// commit kv to write metadata(for example: consistent index).",
"s",
".",
"KV",
"(",
")",
".",
"Commit",
"(",
")",
"\n",
"dbsnap",
":=",
"s",
".",
"be",
".",
"Snapshot",
"(",
")",
"\n",
"// get a snapshot of v3 KV as readCloser",
"rc",
":=",
"newSnapshotReaderCloser",
"(",
"s",
".",
"getLogger",
"(",
")",
",",
"dbsnap",
")",
"\n\n",
"// put the []byte snapshot of store into raft snapshot and return the merged snapshot with",
"// KV readCloser snapshot.",
"snapshot",
":=",
"raftpb",
".",
"Snapshot",
"{",
"Metadata",
":",
"raftpb",
".",
"SnapshotMetadata",
"{",
"Index",
":",
"snapi",
",",
"Term",
":",
"snapt",
",",
"ConfState",
":",
"confState",
",",
"}",
",",
"Data",
":",
"d",
",",
"}",
"\n",
"m",
".",
"Snapshot",
"=",
"snapshot",
"\n\n",
"return",
"*",
"snap",
".",
"NewMessage",
"(",
"m",
",",
"rc",
",",
"dbsnap",
".",
"Size",
"(",
")",
")",
"\n",
"}"
] |
10,395 | all-10396 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"SetDiscoverTargetsParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoTarget1",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
10,396 | all-10397 | [
"SetReadDeadline",
"sets",
"the",
"read",
"deadline",
"for",
"the",
"websocket",
"connection",
"A",
"read",
"timeout",
"results",
"in",
"an",
"io",
"error",
"if",
"there",
"are",
"any",
"outstanding",
"reads",
"that",
"exceed",
"the",
"deadline"
] | [
"func",
"(",
"cs",
"*",
"ClientServerImpl",
")",
"SetReadDeadline",
"(",
"t",
"time",
".",
"Time",
")",
"error",
"{",
"err",
":=",
"cs",
".",
"conn",
".",
"SetReadDeadline",
"(",
"t",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"seelog",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"err",
",",
"cs",
".",
"URL",
")",
"\n",
"// If we get connection closed error from SetReadDeadline, break out of the for loop and",
"// return an error",
"if",
"opErr",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"<mask>",
".",
"OpError",
")",
";",
"ok",
"&&",
"strings",
".",
"Contains",
"(",
"opErr",
".",
"Err",
".",
"Error",
"(",
")",
",",
"errClosed",
")",
"{",
"seelog",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"cs",
".",
"URL",
")",
"\n",
"return",
"opErr",
"\n",
"}",
"\n",
"// An unhandled error has occurred while trying to extend read deadline.",
"// Try asynchronously closing the connection. We don't want to be blocked on stale connections",
"// taking too long to close. The flip side is that we might start accumulating stale connections.",
"// But, that still seems more desirable than waiting for ever for the connection to close",
"cs",
".",
"forceCloseConnection",
"(",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
10,397 | all-10398 | [
"SetPaperSize",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_print_settings_set_paper_size",
"()",
"."
] | [
"func",
"(",
"ps",
"*",
"PrintSettings",
")",
"SetPaperSize",
"(",
"size",
"*",
"PaperSize",
")",
"{",
"C",
".",
"gtk_print_settings_set_paper_size",
"(",
"<mask>",
".",
"native",
"(",
")",
",",
"size",
".",
"native",
"(",
")",
")",
"\n",
"}"
] |
10,398 | all-10399 | [
"GetAccelGroup",
"is",
"a",
"wrapper",
"around",
"gtk_menu_get_accel_group",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"GetAccelGroup",
"(",
")",
"*",
"AccelGroup",
"{",
"c",
":=",
"C",
".",
"gtk_menu_get_accel_group",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"wrapAccelGroup",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
"\n",
"}"
] |
10,399 | all-10400 | [
"NewEncoder",
"returns",
"a",
"new",
"JSON",
"encoder",
"that",
"writes",
"to",
"w",
"."
] | [
"func",
"NewEncoder",
"(",
"w",
"io",
".",
"<mask>",
")",
"*",
"objconv",
".",
"Encoder",
"{",
"return",
"objconv",
".",
"NewEncoder",
"(",
"NewEmitter",
"(",
"w",
")",
")",
"\n",
"}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.