id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
13,400 | all-13401 | [
"Call",
"executes",
"a",
"stored",
"procedure",
"."
] | [
"func",
"(",
"s",
"*",
"Session",
")",
"Call",
"(",
"id",
"uint64",
",",
"prmFieldSet",
"*",
"ParameterFieldSet",
",",
"args",
"[",
"]",
"driver",
".",
"NamedValue",
")",
"(",
"*",
"FieldValues",
",",
"[",
"]",
"*",
"TableResult",
",",
"error",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"statementID",
".",
"<mask>",
"=",
"&",
"id",
"\n",
"if",
"err",
":=",
"s",
".",
"writeRequest",
"(",
"mtExecute",
",",
"false",
",",
"s",
".",
"statementID",
",",
"newInputParameters",
"(",
"prmFieldSet",
".",
"inputFields",
"(",
")",
",",
"args",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"prmFieldValues",
":=",
"newFieldValues",
"(",
")",
"\n",
"var",
"tableResults",
"[",
"]",
"*",
"TableResult",
"\n",
"var",
"tableResult",
"*",
"TableResult",
"\n\n",
"f",
":=",
"func",
"(",
"p",
"replyPart",
")",
"{",
"switch",
"p",
":=",
"p",
".",
"(",
"type",
")",
"{",
"case",
"*",
"outputParameters",
":",
"p",
".",
"s",
"=",
"s",
"\n",
"p",
".",
"outputFields",
"=",
"prmFieldSet",
".",
"outputFields",
"(",
")",
"\n",
"p",
".",
"fieldValues",
"=",
"prmFieldValues",
"\n\n",
"// table output parameters: meta, id, result (only first param?)",
"case",
"*",
"resultMetadata",
":",
"tableResult",
"=",
"newTableResult",
"(",
"s",
",",
"p",
".",
"numArg",
")",
"\n",
"tableResults",
"=",
"append",
"(",
"tableResults",
",",
"tableResult",
")",
"\n",
"p",
".",
"resultFieldSet",
"=",
"tableResult",
".",
"resultFieldSet",
"\n",
"case",
"*",
"resultsetID",
":",
"p",
".",
"id",
"=",
"&",
"(",
"tableResult",
".",
"id",
")",
"\n",
"case",
"*",
"resultset",
":",
"p",
".",
"s",
"=",
"s",
"\n",
"tableResult",
".",
"attrs",
"=",
"s",
".",
"ph",
".",
"partAttributes",
"\n",
"p",
".",
"resultFieldSet",
"=",
"tableResult",
".",
"resultFieldSet",
"\n",
"p",
".",
"fieldValues",
"=",
"tableResult",
".",
"fieldValues",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"s",
".",
"readReply",
"(",
"f",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"s",
".",
"writeLobStream",
"(",
"prmFieldSet",
",",
"prmFieldValues",
",",
"args",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"prmFieldValues",
",",
"tableResults",
",",
"nil",
"\n",
"}"
] |
13,401 | all-13402 | [
"Valid",
"returns",
"true",
"if",
"incoming",
"request",
"and",
"post",
"-",
"response",
"from",
"the",
"original",
"handler",
"is",
"valid",
"to",
"be",
"store",
"to",
"the",
"cache",
"if",
"not",
"(",
"false",
")",
"then",
"the",
"consumer",
"should",
"just",
"exit",
"otherwise",
"(",
"true",
")",
"the",
"consumer",
"should",
"store",
"the",
"cached",
"response"
] | [
"func",
"(",
"v",
"*",
"validatorRule",
")",
"Valid",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"bool",
"{",
"// check if it's a valid response, if it's not then just return.",
"for",
"_",
",",
"valid",
":=",
"<mask>",
"v",
".",
"postValidators",
"{",
"if",
"!",
"valid",
"(",
"w",
",",
"r",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] |
13,402 | all-13403 | [
"EncodedSize",
"is",
"the",
"size",
"of",
"the",
"ValueStruct",
"when",
"encoded"
] | [
"func",
"(",
"v",
"*",
"ValueStruct",
")",
"EncodedSize",
"(",
")",
"uint16",
"{",
"sz",
":=",
"len",
"(",
"v",
".",
"<mask>",
")",
"+",
"2",
"// meta, usermeta.",
"\n",
"if",
"v",
".",
"ExpiresAt",
"==",
"0",
"{",
"return",
"uint16",
"(",
"sz",
"+",
"1",
")",
"\n",
"}",
"\n\n",
"enc",
":=",
"sizeVarint",
"(",
"v",
".",
"ExpiresAt",
")",
"\n",
"return",
"uint16",
"(",
"sz",
"+",
"enc",
")",
"\n",
"}"
] |
13,403 | all-13404 | [
"HasType",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"a",
"*",
"AlertValueDefinition",
")",
"HasType",
"(",
")",
"bool",
"{",
"if",
"a",
"!=",
"nil",
"&&",
"a",
".",
"Type",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
13,404 | all-13405 | [
"NewGroupRouter",
"return",
"GroupRouter",
"which",
"is",
"a",
"helper",
"to",
"construct",
"a",
"group",
"of",
"endpoints",
"such",
"example",
"could",
"be",
"API",
"-",
"version",
"or",
"different",
"methods",
"for",
"an",
"endpoint",
"You",
"should",
"always",
"use",
"router",
".",
"Group",
"instead",
"of",
"using",
"this",
"directly"
] | [
"func",
"NewGroupRouter",
"(",
"r",
"*",
"Router",
",",
"<mask>",
"string",
")",
"*",
"GroupRouter",
"{",
"gr",
":=",
"&",
"GroupRouter",
"{",
"}",
"\n",
"gr",
".",
"router",
"=",
"r",
"\n",
"gr",
".",
"path",
"=",
"strings",
".",
"TrimRight",
"(",
"path",
",",
"\"",
"\"",
")",
"\n",
"return",
"gr",
"\n",
"}"
] |
13,405 | all-13406 | [
"UnmarshalBinary",
"unmarshals",
"a",
"byte",
"slice",
"into",
"a",
"ReserveReleaseArg",
".",
"If",
"the",
"byte",
"slice",
"does",
"not",
"contain",
"enough",
"bytes",
"to",
"form",
"a",
"valid",
"ReserveReleaseArg",
"or",
"a",
"hardware",
"address",
"is",
"malformed",
"io",
".",
"ErrUnexpectedEOF",
"is",
"returned",
"."
] | [
"func",
"(",
"r",
"*",
"ReserveReleaseArg",
")",
"UnmarshalBinary",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"// Must contain minimum length for argument",
"if",
"len",
"(",
"b",
")",
"<",
"reserveReleaseArgLen",
"{",
"return",
"<mask>",
".",
"ErrUnexpectedEOF",
"\n",
"}",
"\n\n",
"r",
".",
"Command",
"=",
"ReserveReleaseCommand",
"(",
"b",
"[",
"0",
"]",
")",
"\n",
"r",
".",
"NMACs",
"=",
"b",
"[",
"1",
"]",
"\n\n",
"// Must have exact number of bytes for hardware addresses with",
"// this count",
"if",
"len",
"(",
"b",
"[",
"2",
":",
"]",
")",
"!=",
"(",
"6",
"*",
"int",
"(",
"r",
".",
"NMACs",
")",
")",
"{",
"return",
"io",
".",
"ErrUnexpectedEOF",
"\n",
"}",
"\n\n",
"// Copy each hardware address into slice",
"r",
".",
"MACs",
"=",
"make",
"(",
"[",
"]",
"net",
".",
"HardwareAddr",
",",
"r",
".",
"NMACs",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"int",
"(",
"r",
".",
"NMACs",
")",
";",
"i",
"++",
"{",
"m",
":=",
"make",
"(",
"net",
".",
"HardwareAddr",
",",
"6",
")",
"\n",
"copy",
"(",
"m",
",",
"b",
"[",
"2",
"+",
"(",
"i",
"*",
"6",
")",
":",
"2",
"+",
"(",
"i",
"*",
"6",
")",
"+",
"6",
"]",
")",
"\n",
"r",
".",
"MACs",
"[",
"i",
"]",
"=",
"m",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
13,406 | all-13407 | [
"Add",
"adds",
"a",
"new",
"server",
"instance",
"by",
"a",
"custom",
"name",
"and",
"with",
"address",
"to",
"listen",
"to",
"."
] | [
"func",
"(",
"s",
"*",
"Servers",
")",
"Add",
"(",
"name",
",",
"address",
"string",
",",
"srv",
"Server",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"servers",
"=",
"append",
"(",
"s",
".",
"servers",
",",
"&",
"server",
"{",
"<mask>",
":",
"srv",
",",
"name",
":",
"name",
",",
"address",
":",
"address",
",",
"}",
")",
"\n",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"}"
] |
13,407 | all-13408 | [
"nextUID",
"returns",
"the",
"next",
"free",
"user",
"id",
"to",
"use",
"according",
"to",
"whether",
"it",
"is",
"a",
"system",
"s",
"user",
"."
] | [
"func",
"nextUID",
"(",
"isSystem",
"bool",
")",
"(",
"db",
"*",
"dbfile",
",",
"uid",
"int",
",",
"err",
"error",
")",
"{",
"loadConfig",
"(",
")",
"\n\n",
"db",
",",
"err",
"=",
"openDBFile",
"(",
"_USER_FILE",
",",
"os",
".",
"O_RDWR",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"// Seek to file half size.",
"info",
",",
"err",
":=",
"db",
".",
"file",
".",
"Stat",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"db",
".",
"close",
"(",
")",
"\n",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
"=",
"db",
".",
"<mask>",
".",
"Seek",
"(",
"info",
".",
"Size",
"(",
")",
"/",
"2",
",",
"os",
".",
"SEEK_SET",
")",
";",
"err",
"!=",
"nil",
"{",
"db",
".",
"close",
"(",
")",
"\n",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"// To starting to read from a new line",
"if",
"_",
",",
"_",
",",
"err",
"=",
"db",
".",
"rd",
".",
"ReadLine",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"db",
".",
"close",
"(",
")",
"\n",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"minUid",
",",
"maxUid",
"int",
"\n",
"if",
"isSystem",
"{",
"minUid",
",",
"maxUid",
"=",
"config",
".",
"login",
".",
"SYS_UID_MIN",
",",
"config",
".",
"login",
".",
"SYS_UID_MAX",
"\n",
"}",
"else",
"{",
"minUid",
",",
"maxUid",
"=",
"config",
".",
"login",
".",
"UID_MIN",
",",
"config",
".",
"login",
".",
"UID_MAX",
"\n",
"}",
"\n\n",
"for",
"{",
"line",
",",
"_",
",",
"err",
":=",
"db",
".",
"rd",
".",
"ReadLine",
"(",
")",
"\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"break",
"\n",
"}",
"\n\n",
"u",
",",
"err",
":=",
"parseUser",
"(",
"string",
"(",
"line",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"db",
".",
"close",
"(",
")",
"\n",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"if",
"u",
".",
"UID",
">=",
"minUid",
"&&",
"u",
".",
"UID",
"<=",
"maxUid",
"{",
"uid",
"=",
"u",
".",
"UID",
"\n",
"}",
"\n",
"}",
"\n\n",
"uid",
"++",
"\n",
"if",
"uid",
"==",
"maxUid",
"{",
"return",
"nil",
",",
"0",
",",
"&",
"IdRangeError",
"{",
"maxUid",
",",
"isSystem",
",",
"true",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
13,408 | all-13409 | [
"flattenLatencySensitivity",
"reads",
"various",
"fields",
"from",
"a",
"LatencySensitivity",
"and",
"sets",
"appropriate",
"keys",
"in",
"the",
"supplied",
"ResourceData",
"."
] | [
"func",
"flattenLatencySensitivity",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"obj",
"*",
"types",
".",
"LatencySensitivity",
")",
"error",
"{",
"if",
"obj",
"==",
"nil",
"{",
"<mask>",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"d",
".",
"Set",
"(",
"\"",
"\"",
",",
"obj",
".",
"Level",
")",
"\n",
"}"
] |
13,409 | all-13410 | [
"ProxyMethod",
"pushes",
"the",
"proxy",
"method",
"on",
"the",
"stack",
".",
"Argument",
":",
"proxy",
"Returns",
":",
"method",
"(",
"function",
")"
] | [
"func",
"ProxyMethod",
"(",
"L",
"*",
"lua",
".",
"State",
")",
"int",
"{",
"if",
"!",
"isValueProxy",
"(",
"L",
",",
"1",
")",
"{",
"L",
".",
"PushNil",
"(",
")",
"\n",
"return",
"1",
"\n",
"}",
"\n",
"v",
",",
"_",
":=",
"valueOfProxy",
"(",
"L",
",",
"1",
")",
"\n",
"<mask>",
":=",
"L",
".",
"ToString",
"(",
"2",
")",
"\n",
"pushGoMethod",
"(",
"L",
",",
"name",
",",
"v",
")",
"\n",
"return",
"1",
"\n",
"}"
] |
13,410 | all-13411 | [
"ErrorService",
"is",
"an",
"option",
"that",
"sets",
"the",
"Google",
"API",
"error",
"reporting",
"service",
"to",
"use",
"."
] | [
"func",
"ErrorService",
"(",
"errorService",
"*",
"errorReporting",
".",
"<mask>",
")",
"Option",
"{",
"return",
"func",
"(",
"sh",
"*",
"StackdriverHook",
")",
"error",
"{",
"sh",
".",
"errorService",
"=",
"errorService",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] |
13,411 | all-13412 | [
"CrumbRequest",
"requests",
"a",
"CSRF",
"protection",
"token",
"from",
"Jenkins",
"to",
"use",
"it",
"in",
"subsequent",
"requests",
".",
"Required",
"for",
"Jenkins",
"masters",
"that",
"prevent",
"cross",
"site",
"request",
"forgery",
"exploits",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"CrumbRequest",
"(",
")",
"error",
"{",
"if",
"c",
".",
"authConfig",
".",
"csrfToken",
"!=",
"\"",
"\"",
"&&",
"c",
".",
"authConfig",
".",
"csrfRequestField",
"!=",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"c",
".",
"logger",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"<mask>",
",",
"err",
":=",
"c",
".",
"GetSkipMetrics",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"crumbResp",
":=",
"struct",
"{",
"Crumb",
"string",
"`json:\"crumb\"`",
"\n",
"CrumbRequestField",
"string",
"`json:\"crumbRequestField\"`",
"\n",
"}",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"crumbResp",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"c",
".",
"authConfig",
".",
"csrfToken",
"=",
"crumbResp",
".",
"Crumb",
"\n",
"c",
".",
"authConfig",
".",
"csrfRequestField",
"=",
"crumbResp",
".",
"CrumbRequestField",
"\n",
"return",
"nil",
"\n",
"}"
] |
13,412 | all-13413 | [
"ClearData",
"removes",
"all",
"bar",
"from",
"chart"
] | [
"func",
"(",
"b",
"*",
"SparkChart",
")",
"ClearData",
"(",
")",
"{",
"b",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"b",
".",
"data",
"=",
"<mask>",
"(",
"[",
"]",
"float64",
",",
"0",
")",
"\n",
"}"
] |
13,413 | all-13414 | [
"GetFillMin",
"returns",
"the",
"FillMin",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"h",
"*",
"HostmapStyle",
")",
"GetFillMin",
"(",
")",
"<mask>",
"{",
"if",
"h",
"==",
"nil",
"||",
"h",
".",
"FillMin",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"h",
".",
"FillMin",
"\n",
"}"
] |
13,414 | all-13415 | [
"resourceVSphereDRSVMOverrideFindEntry",
"attempts",
"to",
"locate",
"an",
"existing",
"DRS",
"VM",
"config",
"in",
"a",
"cluster",
"s",
"configuration",
".",
"It",
"s",
"used",
"by",
"the",
"resource",
"s",
"read",
"functionality",
"and",
"tests",
".",
"nil",
"is",
"returned",
"if",
"the",
"entry",
"cannot",
"be",
"found",
"."
] | [
"func",
"resourceVSphereDRSVMOverrideFindEntry",
"(",
"cluster",
"*",
"object",
".",
"ClusterComputeResource",
",",
"vm",
"*",
"object",
".",
"VirtualMachine",
",",
")",
"(",
"*",
"types",
".",
"ClusterDrsVmConfigInfo",
",",
"error",
")",
"{",
"props",
",",
"err",
":=",
"clustercomputeresource",
".",
"Properties",
"(",
"cluster",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"info",
":=",
"range",
"props",
".",
"ConfigurationEx",
".",
"(",
"*",
"types",
".",
"ClusterConfigInfoEx",
")",
".",
"DrsVmConfig",
"{",
"if",
"info",
".",
"<mask>",
"==",
"vm",
".",
"Reference",
"(",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"vm",
".",
"Name",
"(",
")",
",",
"cluster",
".",
"Name",
"(",
")",
")",
"\n",
"return",
"&",
"info",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"vm",
".",
"Name",
"(",
")",
",",
"cluster",
".",
"Name",
"(",
")",
")",
"\n",
"return",
"nil",
",",
"nil",
"\n",
"}"
] |
13,415 | all-13416 | [
"LogfmtFormat",
"return",
"a",
"formatter",
"for",
"a",
"text",
"log",
"file"
] | [
"func",
"LogfmtFormat",
"(",
")",
"log",
".",
"Format",
"{",
"return",
"log",
".",
"FormatFunc",
"(",
"func",
"(",
"r",
"*",
"log",
".",
"Record",
")",
"[",
"]",
"byte",
"{",
"common",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"r",
".",
"KeyNames",
".",
"Time",
",",
"r",
".",
"Time",
",",
"r",
".",
"KeyNames",
".",
"Lvl",
",",
"r",
".",
"Lvl",
",",
"r",
".",
"KeyNames",
".",
"Msg",
",",
"r",
".",
"Msg",
"}",
"\n",
"buf",
":=",
"&",
"bytes",
".",
"<mask>",
"{",
"}",
"\n\n",
"logfmt",
"(",
"buf",
",",
"common",
",",
"0",
",",
"false",
")",
"\n",
"buf",
".",
"Truncate",
"(",
"buf",
".",
"Len",
"(",
")",
"-",
"1",
")",
"\n",
"buf",
".",
"WriteByte",
"(",
"' '",
")",
"\n",
"logfmt",
"(",
"buf",
",",
"r",
".",
"Ctx",
",",
"0",
",",
"true",
")",
"\n",
"return",
"buf",
".",
"Bytes",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] |
13,416 | all-13417 | [
"NewGame",
"generates",
"a",
"new",
"Game",
"object",
"."
] | [
"func",
"NewGame",
"(",
")",
"(",
"*",
"Game",
",",
"error",
")",
"{",
"g",
":=",
"&",
"Game",
"{",
"input",
":",
"NewInput",
"(",
")",
",",
"}",
"\n",
"var",
"err",
"error",
"\n",
"g",
".",
"<mask>",
",",
"err",
"=",
"NewBoard",
"(",
"boardSize",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"g",
",",
"nil",
"\n",
"}"
] |
13,417 | all-13418 | [
"native",
"returns",
"a",
"pointer",
"to",
"the",
"underlying",
"GdkScreen",
"."
] | [
"func",
"(",
"v",
"*",
"Screen",
")",
"native",
"(",
")",
"*",
"C",
".",
"GdkScreen",
"{",
"if",
"v",
"==",
"nil",
"||",
"v",
".",
"GObject",
"==",
"nil",
"{",
"<mask>",
"nil",
"\n",
"}",
"\n",
"p",
":=",
"unsafe",
".",
"Pointer",
"(",
"v",
".",
"GObject",
")",
"\n",
"return",
"C",
".",
"toGdkScreen",
"(",
"p",
")",
"\n",
"}"
] |
13,418 | all-13419 | [
"HMAC",
"is",
"JSON",
"Web",
"Token",
"authentication",
"using",
"HMAC",
".",
"If",
"successful",
"token",
"context",
"will",
"be",
"store",
"with",
"the",
"key",
"userid",
"in",
"session",
".",
"If",
"unsuccessful",
"connection",
"will",
"be",
"closed",
"right",
"away",
"."
] | [
"func",
"HMAC",
"(",
"password",
"string",
")",
"func",
"(",
"ctx",
"*",
"neptulon",
".",
"ReqCtx",
")",
"error",
"{",
"pass",
":=",
"[",
"]",
"byte",
"(",
"password",
")",
"\n\n",
"return",
"func",
"(",
"ctx",
"*",
"neptulon",
".",
"ReqCtx",
")",
"error",
"{",
"// if user is already authenticated",
"if",
"_",
",",
"ok",
":=",
"ctx",
".",
"Conn",
".",
"Session",
".",
"GetOk",
"(",
"\"",
"\"",
")",
";",
"ok",
"{",
"return",
"ctx",
".",
"Next",
"(",
")",
"\n",
"}",
"\n\n",
"// if user is not authenticated.. check the JWT token",
"var",
"t",
"token",
"\n",
"if",
"err",
":=",
"ctx",
".",
"Params",
"(",
"&",
"t",
")",
";",
"err",
"!=",
"nil",
"{",
"ctx",
".",
"Conn",
".",
"Close",
"(",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"jt",
",",
"err",
":=",
"jwt",
".",
"Parse",
"(",
"t",
".",
"<mask>",
",",
"func",
"(",
"token",
"*",
"jwt",
".",
"Token",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"token",
".",
"Method",
".",
"(",
"*",
"jwt",
".",
"SigningMethodHMAC",
")",
";",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"token",
".",
"Header",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"\n",
"return",
"pass",
",",
"nil",
"\n",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"||",
"!",
"jt",
".",
"Valid",
"{",
"ctx",
".",
"Conn",
".",
"Close",
"(",
")",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
",",
"ctx",
".",
"Conn",
".",
"RemoteAddr",
"(",
")",
",",
"t",
".",
"Token",
")",
"\n",
"}",
"\n\n",
"userID",
":=",
"jt",
".",
"Claims",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"ctx",
".",
"Conn",
".",
"Session",
".",
"Set",
"(",
"\"",
"\"",
",",
"userID",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"userID",
",",
"ctx",
".",
"Conn",
".",
"ID",
",",
"ctx",
".",
"Conn",
".",
"RemoteAddr",
"(",
")",
")",
"\n",
"return",
"ctx",
".",
"Next",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
13,419 | all-13420 | [
"diffAndUpdateDeps",
"iterates",
"through",
"the",
"current",
"map",
"of",
"dependencies",
"on",
"this",
"runner",
"and",
"stops",
"the",
"watcher",
"for",
"any",
"deps",
"that",
"are",
"no",
"longer",
"required",
".",
"At",
"the",
"end",
"of",
"this",
"function",
"the",
"given",
"depsMap",
"is",
"converted",
"to",
"a",
"slice",
"and",
"stored",
"on",
"the",
"runner",
"."
] | [
"func",
"(",
"r",
"*",
"Runner",
")",
"diffAndUpdateDeps",
"(",
"depsMap",
"map",
"[",
"string",
"]",
"dep",
".",
"Dependency",
")",
"{",
"r",
".",
"dependenciesLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"dependenciesLock",
".",
"Unlock",
"(",
")",
"\n\n",
"// Diff and up the list of dependencies, stopping any unneeded watchers.",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n\n",
"for",
"key",
",",
"d",
":=",
"range",
"r",
".",
"dependencies",
"{",
"if",
"_",
",",
"<mask>",
":=",
"depsMap",
"[",
"key",
"]",
";",
"!",
"ok",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"d",
")",
"\n",
"r",
".",
"watcher",
".",
"Remove",
"(",
"d",
")",
"\n",
"r",
".",
"brain",
".",
"Forget",
"(",
"d",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"d",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"r",
".",
"dependencies",
"=",
"depsMap",
"\n",
"}"
] |
13,420 | all-13421 | [
"Multi",
"value",
"counter",
"."
] | [
"func",
"newMultiValueCounter",
"(",
"point",
"Point",
")",
"accumulatingCounter",
"{",
"values",
":=",
"<mask>",
"(",
"map",
"[",
"string",
"]",
"int",
")",
"\n",
"values",
"[",
"point",
".",
"Id",
"(",
")",
"]",
"=",
"1",
"\n",
"return",
"&",
"multiValueAccumulatingCounter",
"{",
"newSingleValueAccumulatingCounter",
"(",
"point",
")",
".",
"(",
"*",
"singleValueAccumulatingCounter",
")",
",",
"values",
",",
"}",
"\n",
"}"
] |
13,421 | all-13422 | [
"Init",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockControl",
")",
"Init",
"(",
")",
"error",
"{",
"<mask>",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"error",
")",
"\n",
"return",
"ret0",
"\n",
"}"
] |
13,422 | all-13423 | [
"Destroy",
"removes",
"an",
"object",
"from",
"its",
"parental",
"chain"
] | [
"func",
"(",
"c",
"*",
"BaseControl",
")",
"Destroy",
"(",
")",
"{",
"c",
".",
"<mask>",
".",
"removeChild",
"(",
"c",
")",
"\n",
"c",
".",
"parent",
".",
"SetConstraints",
"(",
"0",
",",
"0",
")",
"\n",
"}"
] |
13,423 | all-13424 | [
"SuggestCompletion",
"returns",
"a",
"list",
"of",
"mini",
"-",
"venues",
"partially",
"matching",
"the",
"search",
"term",
"near",
"the",
"location",
".",
"https",
":",
"//",
"developer",
".",
"foursquare",
".",
"com",
"/",
"docs",
"/",
"api",
"/",
"venues",
"/",
"suggestcompletion"
] | [
"func",
"(",
"s",
"*",
"VenueService",
")",
"SuggestCompletion",
"(",
"params",
"*",
"VenueSuggestParams",
")",
"(",
"[",
"]",
"MiniVenue",
",",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"venues",
":=",
"new",
"(",
"venueSuggestResp",
")",
"\n",
"response",
":=",
"new",
"(",
"Response",
")",
"\n\n",
"resp",
",",
"err",
":=",
"s",
".",
"sling",
".",
"New",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"QueryStruct",
"(",
"params",
")",
".",
"Receive",
"(",
"response",
",",
"<mask>",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"json",
".",
"Unmarshal",
"(",
"response",
".",
"Response",
",",
"venues",
")",
"\n",
"}",
"\n\n",
"return",
"venues",
".",
"MiniVenues",
",",
"resp",
",",
"relevantError",
"(",
"err",
",",
"*",
"response",
")",
"\n",
"}"
] |
13,424 | all-13425 | [
"TimeoutAdd",
"adds",
"an",
"timeout",
"source",
"to",
"the",
"default",
"main",
"event",
"loop",
"context",
".",
"After",
"running",
"once",
"the",
"source",
"func",
"will",
"be",
"removed",
"from",
"the",
"main",
"event",
"loop",
"unless",
"f",
"returns",
"a",
"single",
"bool",
"true",
".",
"This",
"function",
"will",
"cause",
"a",
"panic",
"when",
"f",
"eventually",
"runs",
"if",
"the",
"types",
"of",
"args",
"do",
"not",
"match",
"those",
"of",
"f",
".",
"timeout",
"is",
"in",
"milliseconds"
] | [
"func",
"TimeoutAdd",
"(",
"timeout",
"uint",
",",
"f",
"interface",
"{",
"}",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"SourceHandle",
",",
"error",
")",
"{",
"// f must be a func with no parameters.",
"rf",
":=",
"reflect",
".",
"ValueOf",
"(",
"f",
")",
"\n",
"if",
"rf",
".",
"<mask>",
"(",
")",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Func",
"{",
"return",
"0",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Create a timeout source func to be added to the main loop context.",
"timeoutSrc",
":=",
"C",
".",
"g_timeout_source_new",
"(",
"C",
".",
"guint",
"(",
"timeout",
")",
")",
"\n",
"if",
"timeoutSrc",
"==",
"nil",
"{",
"return",
"0",
",",
"errNilPtr",
"\n",
"}",
"\n\n",
"return",
"sourceAttach",
"(",
"timeoutSrc",
",",
"rf",
",",
"args",
"...",
")",
"\n",
"}"
] |
13,425 | all-13426 | [
"GetCustomImageUrl",
"returns",
"the",
"CustomImageUrl",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"d",
"*",
"DashboardConditionalFormat",
")",
"GetCustomImageUrl",
"(",
")",
"<mask>",
"{",
"if",
"d",
"==",
"nil",
"||",
"d",
".",
"CustomImageUrl",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"d",
".",
"CustomImageUrl",
"\n",
"}"
] |
13,426 | all-13427 | [
"Status",
"returns",
"a",
"stats",
"instance",
"."
] | [
"func",
"(",
"pool",
"*",
"Pool",
")",
"Status",
"(",
")",
"stats",
"{",
"stats_pipe",
":=",
"<mask>",
"(",
"chan",
"stats",
")",
"\n",
"if",
"pool",
".",
"supervisor_started",
"{",
"pool",
".",
"stats_wanted_pipe",
"<-",
"stats_pipe",
"\n",
"return",
"<-",
"stats_pipe",
"\n",
"}",
"\n",
"// the supervisor wasn't started so we return a zeroed structure",
"return",
"stats",
"{",
"}",
"\n",
"}"
] |
13,427 | all-13428 | [
"NewMockSaveableOption",
"creates",
"a",
"new",
"mock",
"instance"
] | [
"func",
"NewMockSaveableOption",
"(",
"ctrl",
"*",
"gomock",
".",
"<mask>",
")",
"*",
"MockSaveableOption",
"{",
"mock",
":=",
"&",
"MockSaveableOption",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockSaveableOptionMockRecorder",
"{",
"mock",
"}",
"\n",
"return",
"mock",
"\n",
"}"
] |
13,428 | all-13429 | [
"Xargs",
"returns",
"a",
"filter",
"that",
"executes",
"command",
"args",
"...",
"items",
"...",
"where",
"items",
"are",
"the",
"input",
"to",
"the",
"filter",
".",
"The",
"handling",
"of",
"items",
"may",
"be",
"split",
"across",
"multiple",
"executions",
"of",
"command",
"(",
"typically",
"to",
"meet",
"command",
"line",
"length",
"restrictions",
")",
".",
"The",
"standard",
"output",
"of",
"the",
"execution",
"(",
"s",
")",
"is",
"split",
"into",
"lines",
"and",
"the",
"lines",
"form",
"the",
"output",
"of",
"the",
"filter",
"(",
"with",
"trailing",
"newlines",
"removed",
")",
"."
] | [
"func",
"Xargs",
"(",
"command",
"string",
",",
"args",
"...",
"string",
")",
"*",
"XargsFilter",
"{",
"// Compute length of command+args",
"base",
":=",
"len",
"(",
"command",
")",
"\n",
"for",
"_",
",",
"a",
":=",
"range",
"args",
"{",
"base",
"+=",
"1",
"+",
"len",
"(",
"a",
")",
"\n",
"}",
"\n",
"return",
"&",
"XargsFilter",
"{",
"command",
":",
"<mask>",
",",
"args",
":",
"args",
",",
"limitArgs",
":",
"4096",
",",
"limitBytes",
":",
"4096",
"-",
"100",
"-",
"base",
",",
"// Posix limit with slop",
"}",
"\n",
"}"
] |
13,429 | all-13430 | [
"DiscoveredLabels",
"returns",
"a",
"copy",
"of",
"the",
"target",
"s",
"labels",
"before",
"any",
"processing",
"."
] | [
"func",
"(",
"t",
"*",
"Target",
")",
"DiscoveredLabels",
"(",
")",
"labels",
".",
"Labels",
"{",
"t",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"lset",
":=",
"make",
"(",
"labels",
".",
"Labels",
",",
"len",
"(",
"t",
".",
"discoveredLabels",
")",
")",
"\n",
"<mask>",
"(",
"lset",
",",
"t",
".",
"discoveredLabels",
")",
"\n",
"return",
"lset",
"\n",
"}"
] |
13,430 | all-13431 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"CachedResponse",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoCachestorage10",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
13,431 | all-13432 | [
"hookName",
"returns",
"the",
"name",
"of",
"the",
"hookHanlder",
"h",
"."
] | [
"func",
"hookName",
"(",
"h",
"hookHandler",
")",
"string",
"{",
"for",
"name",
",",
"handler",
":=",
"range",
"handlers",
"{",
"if",
"handler",
"==",
"h",
"{",
"return",
"<mask>",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
13,432 | all-13433 | [
"CustomLogf",
"outputs",
"formatted",
"custom",
"level",
"log"
] | [
"func",
"CustomLogf",
"(",
"level",
"string",
",",
"format",
"string",
",",
"val",
"...",
"<mask>",
"{",
"}",
")",
"error",
"{",
"return",
"glg",
".",
"out",
"(",
"glg",
".",
"TagStringToLevel",
"(",
"level",
")",
",",
"format",
",",
"val",
"...",
")",
"\n",
"}"
] |
13,433 | all-13434 | [
"render",
"primitives",
"from",
"array",
"data",
"with",
"a",
"per",
"-",
"element",
"offset"
] | [
"func",
"DrawRangeElementsBaseVertex",
"(",
"mode",
"uint32",
",",
"start",
"uint32",
",",
"end",
"uint32",
",",
"<mask>",
"int32",
",",
"xtype",
"uint32",
",",
"indices",
"unsafe",
".",
"Pointer",
",",
"basevertex",
"int32",
")",
"{",
"C",
".",
"glowDrawRangeElementsBaseVertex",
"(",
"gpDrawRangeElementsBaseVertex",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"mode",
")",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"start",
")",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"end",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"count",
")",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"xtype",
")",
",",
"indices",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"basevertex",
")",
")",
"\n",
"}"
] |
13,434 | all-13435 | [
"Parse",
"parses",
"s",
"for",
"git",
"ancestry",
"references",
".",
"It",
"supports",
"special",
"characters",
"^",
"~",
"both",
"of",
"which",
"are",
"supported",
"by",
"git",
".",
"Note",
"in",
"git",
"^",
"and",
"~",
"have",
"different",
"meanings",
"on",
"commits",
"that",
"have",
"multiple",
"parent",
"commits",
".",
"In",
"Pachyderm",
"there",
"s",
"only",
"1",
"parent",
"possible",
"so",
"they",
"have",
"identical",
"meanings",
".",
"We",
"support",
"both",
"simply",
"for",
"familiarity",
"sake",
".",
"ParseAncestry",
"returns",
"the",
"base",
"reference",
"and",
"how",
"many",
"ancestors",
"back",
"to",
"go",
".",
"For",
"example",
":",
"foo^",
"-",
">",
"foo",
"1",
"foo^^",
"-",
">",
"foo",
"2",
"foo^3",
"-",
">",
"foo",
"3",
"(",
"all",
"examples",
"apply",
"with",
"~",
"in",
"place",
"of",
"^",
"as",
"well"
] | [
"func",
"Parse",
"(",
"s",
"string",
")",
"(",
"string",
",",
"int",
")",
"{",
"sepIndex",
":=",
"strings",
".",
"IndexAny",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"if",
"sepIndex",
"==",
"-",
"1",
"{",
"return",
"s",
",",
"0",
"\n",
"}",
"\n\n",
"// Find the separator, which is either \"^\" or \"~\"",
"sep",
":=",
"s",
"[",
"sepIndex",
"]",
"\n",
"strAfterSep",
":=",
"s",
"[",
"sepIndex",
"+",
"1",
":",
"]",
"\n\n",
"// Try convert the string after the separator to an int.",
"intAfterSep",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"strAfterSep",
")",
"\n",
"// If it works, return",
"if",
"err",
"==",
"nil",
"{",
"return",
"s",
"[",
":",
"sepIndex",
"]",
",",
"intAfterSep",
"\n",
"}",
"\n\n",
"// Otherwise, we check if there's a sequence of separators, as in",
"// \"master^^^^\" or \"master~~~~\"",
"for",
"i",
":=",
"sepIndex",
"+",
"1",
";",
"i",
"<",
"len",
"(",
"s",
")",
";",
"i",
"++",
"{",
"if",
"s",
"[",
"i",
"]",
"!=",
"sep",
"{",
"// If we find a character that's not the separator, as in",
"// \"master~whatever\", then we return.",
"return",
"s",
",",
"0",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Here we've confirmed that the commit ID ends with a sequence of",
"// (the same) separators and therefore uses the correct ancestry",
"// syntax.",
"<mask>",
"s",
"[",
":",
"sepIndex",
"]",
",",
"len",
"(",
"s",
")",
"-",
"sepIndex",
"\n",
"}"
] |
13,435 | all-13436 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"EventExceptionRevoked",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoRuntime34",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
13,436 | all-13437 | [
"ContainerMapByArn",
"returns",
"a",
"map",
"of",
"containers",
"belonging",
"to",
"a",
"particular",
"task",
"ARN"
] | [
"func",
"(",
"state",
"*",
"DockerTaskEngineState",
")",
"ContainerMapByArn",
"(",
"arn",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"apicontainer",
".",
"DockerContainer",
",",
"bool",
")",
"{",
"state",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"state",
".",
"<mask>",
".",
"RUnlock",
"(",
")",
"\n\n",
"ret",
",",
"ok",
":=",
"state",
".",
"taskToID",
"[",
"arn",
"]",
"\n\n",
"// Copy the map to avoid data race",
"if",
"ok",
"{",
"mc",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"apicontainer",
".",
"DockerContainer",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"ret",
"{",
"mc",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"return",
"mc",
",",
"ok",
"\n",
"}",
"\n\n",
"return",
"ret",
",",
"ok",
"\n",
"}"
] |
13,437 | all-13438 | [
"/",
"*",
"This",
"method",
"allow",
"you",
"to",
"exclude",
"a",
"recipient",
"whose",
"connection",
"has",
"that",
"socket_id",
"from",
"receiving",
"the",
"event",
".",
"You",
"can",
"read",
"more",
"here",
":",
"http",
":",
"//",
"pusher",
".",
"com",
"/",
"docs",
"/",
"duplicates",
"."
] | [
"func",
"(",
"c",
"*",
"<mask>",
")",
"TriggerExclusive",
"(",
"channel",
"string",
",",
"eventName",
"string",
",",
"data",
"interface",
"{",
"}",
",",
"socketID",
"string",
")",
"(",
"*",
"BufferedEvents",
",",
"error",
")",
"{",
"return",
"c",
".",
"trigger",
"(",
"[",
"]",
"string",
"{",
"channel",
"}",
",",
"eventName",
",",
"data",
",",
"&",
"socketID",
")",
"\n",
"}"
] |
13,438 | all-13439 | [
"FetchUsers",
"retrieves",
"all",
"users",
"available",
"to",
"API",
"Token",
"."
] | [
"func",
"(",
"a",
"*",
"API",
")",
"FetchUsers",
"(",
")",
"(",
"*",
"[",
"]",
"User",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"a",
".",
"Get",
"(",
"config",
".",
"UserPrefix",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"<mask>",
"[",
"]",
"User",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"result",
",",
"&",
"users",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"users",
",",
"nil",
"\n",
"}"
] |
13,439 | all-13440 | [
"Abort",
"aborts",
"the",
"provided",
"Jenkins",
"build",
"for",
"job",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"Abort",
"(",
"job",
"string",
",",
"build",
"*",
"Build",
")",
"error",
"{",
"c",
".",
"logger",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"job",
",",
"build",
".",
"Number",
")",
"\n",
"if",
"c",
".",
"dryRun",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"request",
"(",
"http",
".",
"MethodPost",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"<mask>",
",",
"build",
".",
"Number",
")",
",",
"nil",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"if",
"resp",
".",
"StatusCode",
"<",
"200",
"||",
"resp",
".",
"StatusCode",
">=",
"300",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"resp",
".",
"Status",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
13,440 | all-13441 | [
"Update",
"updates",
"the",
"board",
"state",
"."
] | [
"func",
"(",
"b",
"*",
"Board",
")",
"Update",
"(",
"input",
"*",
"Input",
")",
"error",
"{",
"for",
"t",
":=",
"range",
"b",
".",
"tiles",
"{",
"if",
"err",
":=",
"t",
".",
"Update",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"0",
"<",
"len",
"(",
"b",
".",
"tasks",
")",
"{",
"t",
":=",
"b",
".",
"tasks",
"[",
"0",
"]",
"\n",
"if",
"err",
":=",
"t",
"(",
")",
";",
"err",
"==",
"taskTerminated",
"{",
"b",
".",
"tasks",
"=",
"b",
".",
"tasks",
"[",
"1",
":",
"]",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"dir",
",",
"ok",
":=",
"<mask>",
".",
"Dir",
"(",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"b",
".",
"Move",
"(",
"dir",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
13,441 | all-13442 | [
"GetModel",
"is",
"a",
"wrapper",
"around",
"gtk_tree_row_reference_get_path",
"."
] | [
"func",
"(",
"v",
"*",
"TreeRowReference",
")",
"GetModel",
"(",
")",
"ITreeModel",
"{",
"c",
":=",
"C",
".",
"gtk_tree_row_reference_get_model",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"m",
":=",
"wrapTreeModel",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
"\n",
"<mask>",
"m",
"\n",
"}"
] |
13,442 | all-13443 | [
"SetValueWidth",
"changes",
"width",
"of",
"the",
"value",
"panel",
"on",
"the",
"left"
] | [
"func",
"(",
"b",
"*",
"BarChart",
")",
"SetValueWidth",
"(",
"<mask>",
"int32",
")",
"{",
"atomic",
".",
"StoreInt32",
"(",
"&",
"b",
".",
"valueWidth",
",",
"width",
")",
"\n",
"}"
] |
13,443 | all-13444 | [
"Slugify",
"converts",
"s",
"into",
"a",
"dasherized",
"string",
"suitable",
"for",
"URL",
"segment",
"."
] | [
"func",
"Slugify",
"(",
"s",
"string",
")",
"<mask>",
"{",
"sl",
":=",
"slugifyRe",
".",
"ReplaceAllString",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"sl",
"=",
"strings",
".",
"ToLower",
"(",
"sl",
")",
"\n",
"sl",
"=",
"Dasherize",
"(",
"sl",
")",
"\n",
"return",
"sl",
"\n",
"}"
] |
13,444 | all-13445 | [
"Do",
"executes",
"CSS",
".",
"getComputedStyleForNode",
"against",
"the",
"provided",
"context",
".",
"returns",
":",
"computedStyle",
"-",
"Computed",
"style",
"for",
"the",
"specified",
"DOM",
"node",
"."
] | [
"func",
"(",
"p",
"*",
"GetComputedStyleForNodeParams",
")",
"Do",
"(",
"ctx",
"context",
".",
"<mask>",
")",
"(",
"computedStyle",
"[",
"]",
"*",
"ComputedProperty",
",",
"err",
"error",
")",
"{",
"// execute",
"var",
"res",
"GetComputedStyleForNodeReturns",
"\n",
"err",
"=",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandGetComputedStyleForNode",
",",
"p",
",",
"&",
"res",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
".",
"ComputedStyle",
",",
"nil",
"\n",
"}"
] |
13,445 | all-13446 | [
"Convert",
"[]",
"interface",
"{}",
"into",
"[]",
"string"
] | [
"func",
"toStringArray",
"(",
"a",
"[",
"]",
"interface",
"{",
"}",
")",
"[",
"]",
"string",
"{",
"<mask>",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"a",
")",
")",
"\n",
"for",
"i",
",",
"v",
":=",
"range",
"a",
"{",
"res",
"[",
"i",
"]",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"return",
"res",
"\n",
"}"
] |
13,446 | all-13447 | [
"WaitForContext",
"makes",
"p",
"WaitFor",
"ctx",
".",
"When",
"Closing",
"p",
"waits",
"for",
"ctx",
".",
"Done",
"()",
"before",
"being",
"Closed",
"()",
".",
"It",
"is",
"simply",
":",
"p",
".",
"WaitFor",
"(",
"goprocess",
".",
"WithContext",
"(",
"ctx",
"))"
] | [
"func",
"WaitForContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"p",
"goprocess",
".",
"<mask>",
")",
"{",
"p",
".",
"WaitFor",
"(",
"WithContext",
"(",
"ctx",
")",
")",
"\n",
"}"
] |
13,447 | all-13448 | [
"Scan",
"read",
"a",
"value",
"from",
"a",
"database",
"driver"
] | [
"func",
"(",
"id",
"*",
"ObjectId",
")",
"Scan",
"(",
"<mask>",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"data",
"[",
"]",
"byte",
"\n",
"switch",
"v",
":=",
"raw",
".",
"(",
"type",
")",
"{",
"case",
"[",
"]",
"byte",
":",
"data",
"=",
"v",
"\n",
"case",
"string",
":",
"data",
"=",
"[",
"]",
"byte",
"(",
"v",
")",
"\n",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n\n",
"return",
"id",
".",
"UnmarshalText",
"(",
"data",
")",
"\n",
"}"
] |
13,448 | all-13449 | [
"HasEmail",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"u",
"*",
"User",
")",
"HasEmail",
"(",
")",
"bool",
"{",
"if",
"u",
"!=",
"nil",
"&&",
"u",
".",
"Email",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
13,449 | all-13450 | [
"setClusterInConfig",
"sets",
"the",
"cluster",
"name",
"in",
"the",
"config",
"object",
"based",
"on",
"previous",
"state",
".",
"It",
"returns",
"an",
"error",
"if",
"there",
"s",
"a",
"mismatch",
"between",
"the",
"the",
"current",
"cluster",
"name",
"with",
"what",
"s",
"restored",
"from",
"the",
"cluster",
"state"
] | [
"func",
"(",
"agent",
"*",
"ecsAgent",
")",
"setClusterInConfig",
"(",
"previousCluster",
"string",
")",
"error",
"{",
"// TODO Handle default cluster in a sane and unified way across the codebase",
"configuredCluster",
":=",
"agent",
".",
"cfg",
".",
"Cluster",
"\n",
"if",
"configuredCluster",
"==",
"\"",
"\"",
"{",
"seelog",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"configuredCluster",
"=",
"config",
".",
"DefaultClusterName",
"\n",
"}",
"\n",
"if",
"previousCluster",
"!=",
"configuredCluster",
"{",
"err",
":=",
"clusterMismatchError",
"{",
"fmt",
".",
"Errorf",
"(",
"clusterMismatchErrorFormat",
",",
"previousCluster",
",",
"configuredCluster",
")",
",",
"}",
"\n",
"seelog",
".",
"Criticalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"<mask>",
".",
"cfg",
".",
"Cluster",
"=",
"previousCluster",
"\n",
"seelog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"agent",
".",
"cfg",
".",
"Cluster",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
13,450 | all-13451 | [
"Walk",
"the",
"command",
"tree",
"wrap",
"any",
"examples",
"in",
"a",
"block",
"-",
"quote",
"with",
"shell",
"highlighting"
] | [
"func",
"recursiveBlockQuoteExamples",
"(",
"parent",
"*",
"cobra",
".",
"Command",
")",
"{",
"if",
"parent",
".",
"Example",
"!=",
"\"",
"\"",
"{",
"<mask>",
".",
"Example",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\\n",
"\"",
",",
"parent",
".",
"Example",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"cmd",
":=",
"range",
"parent",
".",
"Commands",
"(",
")",
"{",
"recursiveBlockQuoteExamples",
"(",
"cmd",
")",
"\n",
"}",
"\n",
"}"
] |
13,451 | all-13452 | [
"HasColor",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"r",
"*",
"Rule",
")",
"HasColor",
"(",
")",
"bool",
"{",
"if",
"r",
"!=",
"nil",
"&&",
"r",
".",
"Color",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
13,452 | all-13453 | [
"/",
"*",
"NewTextView",
"creates",
"a",
"new",
"frame",
".",
"view",
"-",
"is",
"a",
"View",
"that",
"manages",
"the",
"control",
"parent",
"-",
"is",
"container",
"that",
"keeps",
"the",
"control",
".",
"The",
"same",
"View",
"can",
"be",
"a",
"view",
"and",
"a",
"parent",
"at",
"the",
"same",
"time",
".",
"width",
"and",
"heigth",
"-",
"are",
"minimal",
"size",
"of",
"the",
"control",
".",
"scale",
"-",
"the",
"way",
"of",
"scaling",
"the",
"control",
"when",
"the",
"parent",
"is",
"resized",
".",
"Use",
"DoNotScale",
"constant",
"if",
"the",
"control",
"should",
"keep",
"its",
"original",
"size",
"."
] | [
"func",
"CreateTextView",
"(",
"parent",
"Control",
",",
"width",
",",
"height",
"int",
",",
"scale",
"int",
")",
"*",
"TextView",
"{",
"l",
":=",
"new",
"(",
"TextView",
")",
"\n",
"l",
".",
"BaseControl",
"=",
"NewBaseControl",
"(",
")",
"\n\n",
"if",
"height",
"==",
"AutoSize",
"{",
"height",
"=",
"3",
"\n",
"}",
"\n",
"if",
"width",
"==",
"AutoSize",
"{",
"width",
"=",
"5",
"\n",
"}",
"\n\n",
"l",
".",
"SetSize",
"(",
"width",
",",
"height",
")",
"\n",
"l",
".",
"SetConstraints",
"(",
"width",
",",
"height",
")",
"\n",
"l",
".",
"topLine",
"=",
"0",
"\n",
"l",
".",
"<mask>",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"l",
".",
"parent",
"=",
"parent",
"\n",
"l",
".",
"maxLines",
"=",
"0",
"\n\n",
"l",
".",
"SetTabStop",
"(",
"true",
")",
"\n",
"l",
".",
"SetScale",
"(",
"scale",
")",
"\n\n",
"if",
"parent",
"!=",
"nil",
"{",
"parent",
".",
"AddChild",
"(",
"l",
")",
"\n",
"}",
"\n\n",
"return",
"l",
"\n",
"}"
] |
13,453 | all-13454 | [
"New",
"creates",
"a",
"logger",
"with",
"specified",
"handler",
"and",
"flag"
] | [
"func",
"New",
"(",
"handler",
"Handler",
",",
"flag",
"int",
")",
"*",
"Logger",
"{",
"var",
"l",
"=",
"new",
"(",
"Logger",
")",
"\n\n",
"l",
".",
"level",
"=",
"LevelInfo",
"\n",
"l",
".",
"handler",
"=",
"handler",
"\n\n",
"l",
".",
"<mask>",
"=",
"flag",
"\n\n",
"l",
".",
"bufs",
"=",
"sync",
".",
"Pool",
"{",
"New",
":",
"func",
"(",
")",
"interface",
"{",
"}",
"{",
"return",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"1024",
")",
"\n",
"}",
",",
"}",
"\n\n",
"return",
"l",
"\n",
"}"
] |
13,454 | all-13455 | [
"Refresh",
"returns",
"a",
"new",
"access",
"token"
] | [
"func",
"(",
"c",
"*",
"OAuth2Controller",
")",
"Refresh",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"grantType",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"refreshToken",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"strings",
".",
"Compare",
"(",
"grantType",
",",
"\"",
"\"",
")",
"!=",
"0",
"{",
"http",
".",
"Error",
"(",
"w",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
".",
"Error",
"(",
")",
",",
"http",
".",
"StatusBadRequest",
")",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"strings",
".",
"Compare",
"(",
"refreshToken",
",",
"\"",
"\"",
")",
"==",
"0",
"{",
"http",
".",
"Error",
"(",
"w",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
".",
"Error",
"(",
")",
",",
"http",
".",
"StatusBadRequest",
")",
"\n",
"return",
"\n",
"}",
"\n",
"token",
",",
"err",
":=",
"jwt",
".",
"Parse",
"(",
"refreshToken",
",",
"func",
"(",
"token",
"*",
"jwt",
".",
"Token",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"token",
".",
"Method",
".",
"(",
"*",
"jwt",
".",
"SigningMethodHMAC",
")",
";",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"token",
".",
"Header",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"\n",
"return",
"[",
"]",
"byte",
"(",
"c",
".",
"cnf",
".",
"Jwt",
".",
"Key",
")",
",",
"nil",
"\n",
"}",
")",
"\n",
"if",
"err",
"==",
"nil",
"&&",
"token",
".",
"Valid",
"{",
"token",
":=",
"jwt",
".",
"New",
"(",
"jwt",
".",
"GetSigningMethod",
"(",
"\"",
"\"",
")",
")",
"\n",
"claims",
":=",
"token",
".",
"Claims",
".",
"(",
"jwt",
".",
"MapClaims",
")",
"\n",
"claims",
"[",
"\"",
"\"",
"]",
"=",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"time",
".",
"Hour",
"*",
"1",
")",
".",
"Unix",
"(",
")",
"\n",
"tokenString",
",",
"_",
":=",
"token",
".",
"SignedString",
"(",
"[",
"]",
"byte",
"(",
"c",
".",
"cnf",
".",
"Jwt",
".",
"Key",
")",
")",
"\n\n",
"data",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"tokenString",
",",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",
"\"",
"\"",
",",
"}",
"\n",
"js",
",",
"_",
":=",
"json",
".",
"Marshal",
"(",
"<mask>",
")",
"\n",
"w",
".",
"Write",
"(",
"js",
")",
"\n",
"}",
"\n",
"}"
] |
13,455 | all-13456 | [
"View",
"wraps",
"bolt",
".",
"DB",
".",
"View",
"."
] | [
"func",
"(",
"db",
"DB",
")",
"View",
"(",
"f",
"func",
"(",
"Tx",
")",
"error",
")",
"error",
"{",
"return",
"errorsp",
".",
"WithStacks",
"(",
"db",
".",
"DB",
".",
"View",
"(",
"func",
"(",
"tx",
"*",
"bolt",
".",
"Tx",
")",
"error",
"{",
"return",
"errorsp",
".",
"WithStacks",
"(",
"f",
"(",
"Tx",
"{",
"<mask>",
"}",
")",
")",
"\n",
"}",
")",
")",
"\n",
"}"
] |
13,456 | all-13457 | [
"ReapChildren",
"is",
"a",
"long",
"-",
"running",
"routine",
"that",
"blocks",
"waiting",
"for",
"child",
"processes",
"to",
"exit",
"and",
"reaps",
"them",
"reporting",
"reaped",
"process",
"IDs",
"to",
"the",
"optional",
"pids",
"channel",
"and",
"any",
"errors",
"to",
"the",
"optional",
"errors",
"channel",
".",
"The",
"optional",
"reapLock",
"will",
"be",
"used",
"to",
"prevent",
"reaping",
"during",
"periods",
"when",
"you",
"know",
"your",
"application",
"is",
"waiting",
"for",
"subprocesses",
"to",
"return",
".",
"You",
"need",
"to",
"use",
"care",
"in",
"order",
"to",
"prevent",
"the",
"reaper",
"from",
"stealing",
"your",
"return",
"values",
"from",
"uses",
"of",
"packages",
"like",
"Go",
"s",
"exec",
".",
"We",
"use",
"an",
"RWMutex",
"so",
"that",
"we",
"don",
"t",
"serialize",
"all",
"of",
"the",
"application",
"s",
"execution",
"of",
"sub",
"processes",
"with",
"each",
"other",
"but",
"we",
"do",
"serialize",
"them",
"with",
"reaping",
".",
"The",
"application",
"should",
"get",
"a",
"read",
"lock",
"when",
"it",
"wants",
"to",
"do",
"a",
"wait",
"."
] | [
"func",
"ReapChildren",
"(",
"pids",
"PidCh",
",",
"errors",
"ErrorCh",
",",
"done",
"chan",
"struct",
"{",
"}",
",",
"reapLock",
"*",
"sync",
".",
"RWMutex",
")",
"{",
"c",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
")",
"\n",
"signal",
".",
"Notify",
"(",
"c",
",",
"unix",
".",
"SIGCHLD",
")",
"\n\n",
"for",
"{",
"// Block for an incoming signal that a child has exited.",
"select",
"{",
"case",
"<-",
"c",
":",
"// Got a child signal, drop out and reap.",
"case",
"<-",
"done",
":",
"return",
"\n",
"}",
"\n\n",
"// Attempt to reap all abandoned child processes after getting",
"// the reap lock, which makes sure the application isn't doing",
"// any waiting of its own. Note that we do the full write lock",
"// here.",
"func",
"(",
")",
"{",
"if",
"reapLock",
"!=",
"nil",
"{",
"reapLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"reapLock",
".",
"Unlock",
"(",
")",
"\n",
"}",
"\n\n",
"POLL",
":",
"// Try to reap children until there aren't any more. We",
"// never block in here so that we are always responsive",
"// to signals, at the expense of possibly leaving a",
"// child behind if we get here too quickly. Any",
"// stragglers should get reaped the next time we see a",
"// signal, so we won't leak in the long run.",
"var",
"<mask>",
"unix",
".",
"WaitStatus",
"\n",
"pid",
",",
"err",
":=",
"unix",
".",
"Wait4",
"(",
"-",
"1",
",",
"&",
"status",
",",
"unix",
".",
"WNOHANG",
",",
"nil",
")",
"\n",
"switch",
"err",
"{",
"case",
"nil",
":",
"// Got a child, clean this up and poll again.",
"if",
"pid",
">",
"0",
"{",
"if",
"pids",
"!=",
"nil",
"{",
"pids",
"<-",
"pid",
"\n",
"}",
"\n",
"goto",
"POLL",
"\n",
"}",
"\n",
"return",
"\n\n",
"case",
"unix",
".",
"ECHILD",
":",
"// No more children, we are done.",
"return",
"\n\n",
"case",
"unix",
".",
"EINTR",
":",
"// We got interrupted, try again. This likely",
"// can't happen since we are calling Wait4 in a",
"// non-blocking fashion, but it's good to be",
"// complete and handle this case rather than",
"// fail.",
"goto",
"POLL",
"\n\n",
"default",
":",
"// We got some other error we didn't expect.",
"// Wait for another SIGCHLD so we don't",
"// potentially spam in here and chew up CPU.",
"if",
"errors",
"!=",
"nil",
"{",
"errors",
"<-",
"err",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
13,457 | all-13458 | [
"Loss",
"Functions"
] | [
"func",
"LinearLoss",
"(",
"x",
",",
"θ ",
"]",
"f",
"loat64,",
" ",
",",
" ",
" f",
"oat64) ",
"f",
"oat64 {",
"",
"// log((1/(2*pi*sigma**2))**0.5*exp(-1/(2*σ**2)*(y-w*x)**2))",
"σ2 ",
"= ",
"ath.",
"P",
"ow(",
"σ",
", ",
"2",
"",
"",
"\n",
"z",
":=",
"math",
".",
"Pow",
"(",
"1.0",
"/",
"(",
"2",
"*",
"math",
".",
"Pi",
"*",
"σ2)",
",",
" ",
".5)",
"",
"\n",
"yest",
":=",
"0.0",
"\n",
"for",
"i",
",",
"xi",
":=",
"<mask>",
"x",
"{",
"yest",
"+=",
"θ[",
"i",
"]",
" ",
" ",
"i",
"\n",
"}",
"\n",
"return",
"-",
"math",
".",
"Log",
"(",
"z",
"*",
"math",
".",
"Exp",
"(",
"-",
"1",
"/",
"(",
"2",
"*",
"σ2)",
"*",
"m",
"ath.",
"P",
"ow(",
"(",
"y",
"-",
"y",
"est)",
",",
" ",
")",
")",
")",
"",
"\n",
"}"
] |
13,458 | all-13459 | [
"problemsInFiles",
"runs",
"golint",
"on",
"the",
"files",
".",
"It",
"returns",
"a",
"map",
"from",
"the",
"file",
"to",
"a",
"map",
"from",
"the",
"line",
"in",
"the",
"patch",
"to",
"the",
"problem",
"."
] | [
"func",
"problemsInFiles",
"(",
"r",
"*",
"git",
".",
"Repo",
",",
"files",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"map",
"[",
"int",
"]",
"lint",
".",
"Problem",
",",
"[",
"]",
"github",
".",
"DraftReviewComment",
")",
"{",
"problems",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"map",
"[",
"int",
"]",
"lint",
".",
"Problem",
")",
"\n",
"var",
"lintErrorComments",
"[",
"]",
"github",
".",
"DraftReviewComment",
"\n",
"l",
":=",
"new",
"(",
"lint",
".",
"Linter",
")",
"\n",
"for",
"f",
",",
"patch",
":=",
"range",
"files",
"{",
"problems",
"[",
"f",
"]",
"=",
"make",
"(",
"map",
"[",
"int",
"]",
"lint",
".",
"Problem",
")",
"\n",
"src",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filepath",
".",
"Join",
"(",
"r",
".",
"Dir",
",",
"f",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"lintErrorComments",
"=",
"append",
"(",
"lintErrorComments",
",",
"github",
".",
"DraftReviewComment",
"{",
"Path",
":",
"f",
",",
"Body",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"err",
")",
",",
"}",
")",
"\n",
"}",
"\n",
"ps",
",",
"err",
":=",
"l",
".",
"Lint",
"(",
"f",
",",
"src",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Get error line by parsing the error message",
"errLineIndexStart",
":=",
"strings",
".",
"LastIndex",
"(",
"err",
".",
"Error",
"(",
")",
",",
"f",
")",
"+",
"len",
"(",
"f",
")",
"\n",
"reNumber",
":=",
"regexp",
".",
"MustCompile",
"(",
"`:([0-9]+):`",
")",
"\n",
"matches",
":=",
"reNumber",
".",
"FindStringSubmatch",
"(",
"err",
".",
"Error",
"(",
")",
"[",
"errLineIndexStart",
":",
"]",
")",
"\n",
"newComment",
":=",
"github",
".",
"DraftReviewComment",
"{",
"Path",
":",
"f",
",",
"Body",
":",
"err",
".",
"Error",
"(",
")",
",",
"}",
"\n",
"if",
"len",
"(",
"matches",
")",
">",
"1",
"{",
"errLineString",
":=",
"matches",
"[",
"1",
"]",
"\n",
"errLine",
",",
"errAtoi",
":=",
"strconv",
".",
"Atoi",
"(",
"errLineString",
")",
"\n",
"if",
"errAtoi",
"==",
"nil",
"{",
"newComment",
".",
"Position",
"=",
"errLine",
"\n",
"}",
"\n",
"// Trim error message to after the line and column numbers",
"reTrimError",
":=",
"regexp",
".",
"MustCompile",
"(",
"`(:[0-9]+:[0-9]+: )`",
")",
"\n",
"matches",
"=",
"reTrimError",
".",
"FindStringSubmatch",
"(",
"err",
".",
"<mask>",
"(",
")",
")",
"\n",
"if",
"len",
"(",
"matches",
")",
">",
"0",
"{",
"newComment",
".",
"Body",
"=",
"err",
".",
"Error",
"(",
")",
"[",
"len",
"(",
"matches",
"[",
"0",
"]",
")",
"+",
"errLineIndexStart",
":",
"]",
"\n",
"}",
"\n",
"}",
"\n",
"lintErrorComments",
"=",
"append",
"(",
"lintErrorComments",
",",
"newComment",
")",
"\n",
"}",
"\n",
"al",
",",
"err",
":=",
"AddedLines",
"(",
"patch",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"lintErrorComments",
"=",
"append",
"(",
"lintErrorComments",
",",
"github",
".",
"DraftReviewComment",
"{",
"Path",
":",
"f",
",",
"Body",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"f",
",",
"err",
")",
",",
"}",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"ps",
"{",
"if",
"pl",
",",
"ok",
":=",
"al",
"[",
"p",
".",
"Position",
".",
"Line",
"]",
";",
"ok",
"{",
"problems",
"[",
"f",
"]",
"[",
"pl",
"]",
"=",
"p",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"problems",
",",
"lintErrorComments",
"\n",
"}"
] |
13,459 | all-13460 | [
"SetMethod",
"sets",
"HTTP",
"request",
"method",
"."
] | [
"func",
"(",
"h",
"*",
"RequestHeader",
")",
"SetMethod",
"(",
"method",
"string",
")",
"{",
"h",
".",
"method",
"=",
"<mask>",
"(",
"h",
".",
"method",
"[",
":",
"0",
"]",
",",
"method",
"...",
")",
"\n",
"}"
] |
13,460 | all-13461 | [
"Convenience",
"method",
"which",
"just",
"delegates",
"to",
"mgo",
".",
"Note",
"that",
"hooks",
"are",
"NOT",
"run"
] | [
"func",
"(",
"c",
"*",
"Collection",
")",
"DeleteOne",
"(",
"query",
"bson",
".",
"M",
")",
"error",
"{",
"sess",
":=",
"c",
".",
"Connection",
".",
"Session",
".",
"Clone",
"(",
")",
"\n",
"defer",
"sess",
".",
"Close",
"(",
")",
"\n",
"<mask>",
":=",
"c",
".",
"collectionOnSession",
"(",
"sess",
")",
"\n",
"return",
"col",
".",
"Remove",
"(",
"query",
")",
"\n",
"}"
] |
13,461 | all-13462 | [
"makePeerStatusSlice",
"takes",
"a",
"snapshot",
"of",
"the",
"state",
"of",
"peers",
"."
] | [
"func",
"makePeerStatusSlice",
"(",
"peers",
"*",
"Peers",
")",
"[",
"]",
"PeerStatus",
"{",
"var",
"slice",
"[",
"]",
"PeerStatus",
"\n\n",
"peers",
".",
"forEach",
"(",
"func",
"(",
"<mask>",
"*",
"Peer",
")",
"{",
"var",
"connections",
"[",
"]",
"connectionStatus",
"\n",
"if",
"peer",
"==",
"peers",
".",
"ourself",
".",
"Peer",
"{",
"for",
"conn",
":=",
"range",
"peers",
".",
"ourself",
".",
"getConnections",
"(",
")",
"{",
"connections",
"=",
"append",
"(",
"connections",
",",
"makeConnectionStatus",
"(",
"conn",
")",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// Modifying peer.connections requires a write lock on",
"// Peers, and since we are holding a read lock (due to the",
"// ForEach), access without locking the peer is safe.",
"for",
"_",
",",
"conn",
":=",
"range",
"peer",
".",
"connections",
"{",
"connections",
"=",
"append",
"(",
"connections",
",",
"makeConnectionStatus",
"(",
"conn",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"slice",
"=",
"append",
"(",
"slice",
",",
"PeerStatus",
"{",
"peer",
".",
"Name",
".",
"String",
"(",
")",
",",
"peer",
".",
"NickName",
",",
"peer",
".",
"UID",
",",
"peer",
".",
"ShortID",
",",
"peer",
".",
"Version",
",",
"connections",
",",
"}",
")",
"\n",
"}",
")",
"\n\n",
"return",
"slice",
"\n",
"}"
] |
13,462 | all-13463 | [
"Sum",
"returns",
"the",
"result",
"of",
"Lyra2re2",
"hash",
"."
] | [
"func",
"Sum",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"blake",
":=",
"blake256",
".",
"New",
"(",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"blake",
".",
"Write",
"(",
"data",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"resultBlake",
":=",
"blake",
".",
"Sum",
"(",
"nil",
")",
"\n\n",
"keccak",
":=",
"sha3",
".",
"NewKeccak256",
"(",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"keccak",
".",
"Write",
"(",
"resultBlake",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"resultkeccak",
":=",
"keccak",
".",
"Sum",
"(",
"nil",
")",
"\n\n",
"resultcube",
":=",
"cubehash256",
"(",
"resultkeccak",
")",
"\n",
"lyra2result",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"32",
")",
"\n",
"lyra2",
"(",
"lyra2result",
",",
"resultcube",
",",
"resultcube",
",",
"1",
",",
"4",
",",
"4",
")",
"\n",
"var",
"skeinresult",
"[",
"32",
"]",
"byte",
"\n",
"skein",
".",
"Sum256",
"(",
"&",
"skeinresult",
",",
"lyra2result",
",",
"nil",
")",
"\n",
"resultcube2",
":=",
"cubehash256",
"(",
"skeinresult",
"[",
":",
"]",
")",
"\n",
"resultbmw",
":=",
"bmw256",
"(",
"resultcube2",
")",
"\n",
"return",
"resultbmw",
",",
"nil",
"\n",
"}"
] |
13,463 | all-13464 | [
"UpdateLayerInfos",
"replaces",
"the",
"original",
"layers",
"with",
"the",
"specified",
"BlobInfos",
"(",
"size",
"+",
"digest",
"+",
"urls",
")",
"in",
"order",
"(",
"the",
"root",
"layer",
"first",
"and",
"then",
"successive",
"layered",
"layers",
")"
] | [
"func",
"(",
"m",
"*",
"Schema2",
")",
"UpdateLayerInfos",
"(",
"layerInfos",
"[",
"]",
"types",
".",
"BlobInfo",
")",
"error",
"{",
"if",
"len",
"(",
"m",
".",
"LayersDescriptors",
")",
"!=",
"len",
"(",
"layerInfos",
")",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"m",
".",
"LayersDescriptors",
")",
",",
"len",
"(",
"layerInfos",
")",
")",
"\n",
"}",
"\n",
"original",
":=",
"m",
".",
"LayersDescriptors",
"\n",
"m",
".",
"LayersDescriptors",
"=",
"make",
"(",
"[",
"]",
"Schema2Descriptor",
",",
"len",
"(",
"layerInfos",
")",
")",
"\n",
"for",
"i",
",",
"info",
":=",
"range",
"layerInfos",
"{",
"m",
".",
"LayersDescriptors",
"[",
"i",
"]",
".",
"MediaType",
"=",
"original",
"[",
"i",
"]",
".",
"MediaType",
"\n",
"m",
".",
"LayersDescriptors",
"[",
"i",
"]",
".",
"Digest",
"=",
"info",
".",
"Digest",
"\n",
"m",
".",
"LayersDescriptors",
"[",
"i",
"]",
".",
"Size",
"=",
"<mask>",
".",
"Size",
"\n",
"m",
".",
"LayersDescriptors",
"[",
"i",
"]",
".",
"URLs",
"=",
"info",
".",
"URLs",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
13,464 | all-13465 | [
"SignalPresent",
"returns",
"a",
"boolean",
"indicating",
"if",
"the",
"pointer",
"is",
"nil",
"or",
"if",
"the",
"pointer",
"is",
"pointing",
"to",
"the",
"zero",
"value",
".."
] | [
"func",
"SignalPresent",
"(",
"s",
"*",
"<mask>",
".",
"Signal",
")",
"bool",
"{",
"if",
"s",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"*",
"s",
"!=",
"signals",
".",
"SIGNIL",
"\n",
"}"
] |
13,465 | all-13466 | [
"TTLDuration",
"returns",
"the",
"Node",
"s",
"TTL",
"as",
"a",
"time",
".",
"Duration",
"object"
] | [
"func",
"(",
"n",
"*",
"Node",
")",
"TTLDuration",
"(",
")",
"<mask>",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"n",
".",
"TTL",
")",
"*",
"time",
".",
"Second",
"\n",
"}"
] |
13,466 | all-13467 | [
"NewOperationResultTr",
"creates",
"a",
"new",
"OperationResultTr",
"."
] | [
"func",
"NewOperationResultTr",
"(",
"aType",
"OperationType",
",",
"value",
"interface",
"{",
"}",
")",
"(",
"result",
"OperationResultTr",
",",
"err",
"error",
")",
"{",
"result",
".",
"Type",
"=",
"aType",
"\n",
"switch",
"OperationType",
"(",
"aType",
")",
"{",
"case",
"OperationTypeCreateAccount",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"CreateAccountResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"CreateAccountResult",
"=",
"&",
"tv",
"\n",
"case",
"OperationTypePayment",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"PaymentResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"PaymentResult",
"=",
"&",
"tv",
"\n",
"case",
"OperationTypePathPayment",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"PathPaymentResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"PathPaymentResult",
"=",
"&",
"tv",
"\n",
"case",
"OperationTypeManageOffer",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"ManageOfferResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"ManageOfferResult",
"=",
"&",
"tv",
"\n",
"case",
"OperationTypeCreatePassiveOffer",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"ManageOfferResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"CreatePassiveOfferResult",
"=",
"&",
"<mask>",
"\n",
"case",
"OperationTypeSetOptions",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"SetOptionsResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"SetOptionsResult",
"=",
"&",
"tv",
"\n",
"case",
"OperationTypeChangeTrust",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"ChangeTrustResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"ChangeTrustResult",
"=",
"&",
"tv",
"\n",
"case",
"OperationTypeAllowTrust",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"AllowTrustResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"AllowTrustResult",
"=",
"&",
"tv",
"\n",
"case",
"OperationTypeAccountMerge",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"AccountMergeResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"AccountMergeResult",
"=",
"&",
"tv",
"\n",
"case",
"OperationTypeInflation",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"InflationResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"InflationResult",
"=",
"&",
"tv",
"\n",
"case",
"OperationTypeManageData",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"ManageDataResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"ManageDataResult",
"=",
"&",
"tv",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
13,467 | all-13468 | [
"Proclaim",
"lets",
"the",
"leader",
"announce",
"a",
"new",
"value",
"without",
"another",
"election",
"."
] | [
"func",
"(",
"e",
"*",
"Election",
")",
"Proclaim",
"(",
"ctx",
"context",
".",
"Context",
",",
"val",
"string",
")",
"error",
"{",
"if",
"e",
".",
"leaderSession",
"==",
"nil",
"{",
"return",
"ErrElectionNotLeader",
"\n",
"}",
"\n",
"client",
":=",
"e",
".",
"<mask>",
".",
"Client",
"(",
")",
"\n",
"cmp",
":=",
"v3",
".",
"Compare",
"(",
"v3",
".",
"CreateRevision",
"(",
"e",
".",
"leaderKey",
")",
",",
"\"",
"\"",
",",
"e",
".",
"leaderRev",
")",
"\n",
"txn",
":=",
"client",
".",
"Txn",
"(",
"ctx",
")",
".",
"If",
"(",
"cmp",
")",
"\n",
"txn",
"=",
"txn",
".",
"Then",
"(",
"v3",
".",
"OpPut",
"(",
"e",
".",
"leaderKey",
",",
"val",
",",
"v3",
".",
"WithLease",
"(",
"e",
".",
"leaderSession",
".",
"Lease",
"(",
")",
")",
")",
")",
"\n",
"tresp",
",",
"terr",
":=",
"txn",
".",
"Commit",
"(",
")",
"\n",
"if",
"terr",
"!=",
"nil",
"{",
"return",
"terr",
"\n",
"}",
"\n",
"if",
"!",
"tresp",
".",
"Succeeded",
"{",
"e",
".",
"leaderKey",
"=",
"\"",
"\"",
"\n",
"return",
"ErrElectionNotLeader",
"\n",
"}",
"\n\n",
"e",
".",
"hdr",
"=",
"tresp",
".",
"Header",
"\n",
"return",
"nil",
"\n",
"}"
] |
13,468 | all-13469 | [
"DeleteJob",
"deletes",
"a",
"job",
"."
] | [
"func",
"(",
"c",
"APIClient",
")",
"DeleteJob",
"(",
"jobID",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"PpsAPIClient",
".",
"DeleteJob",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"&",
"pps",
".",
"DeleteJobRequest",
"{",
"<mask>",
":",
"NewJob",
"(",
"jobID",
")",
",",
"}",
",",
")",
"\n",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}"
] |
13,469 | all-13470 | [
"GetGPUIDsUnsafe",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockGPUManager",
")",
"GetGPUIDsUnsafe",
"(",
")",
"[",
"]",
"string",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"<mask>",
"[",
"0",
"]",
".",
"(",
"[",
"]",
"string",
")",
"\n",
"return",
"ret0",
"\n",
"}"
] |
13,470 | all-13471 | [
"DeleteRecords",
"deletes",
"records",
"for",
"a",
"given",
"slice",
"of",
"endpoints"
] | [
"func",
"(",
"p",
"*",
"dnsimpleProvider",
")",
"DeleteRecords",
"(",
"endpoints",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
")",
"<mask>",
"{",
"return",
"p",
".",
"submitChanges",
"(",
"newDnsimpleChanges",
"(",
"dnsimpleDelete",
",",
"endpoints",
")",
")",
"\n",
"}"
] |
13,471 | all-13472 | [
"RESTClient",
"returns",
"a",
"RESTClient",
"that",
"is",
"used",
"to",
"communicate",
"with",
"API",
"server",
"by",
"this",
"client",
"implementation",
"."
] | [
"func",
"(",
"c",
"*",
"TsuruV1Client",
")",
"RESTClient",
"(",
")",
"<mask>",
".",
"Interface",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"c",
".",
"restClient",
"\n",
"}"
] |
13,472 | all-13473 | [
"steadyState",
"returns",
"if",
"the",
"task",
"is",
"in",
"a",
"steady",
"state",
".",
"Steady",
"state",
"is",
"when",
"task",
"s",
"desired",
"and",
"known",
"status",
"are",
"both",
"RUNNING"
] | [
"func",
"(",
"mtask",
"*",
"managedTask",
")",
"steadyState",
"(",
")",
"bool",
"{",
"select",
"{",
"case",
"<-",
"mtask",
".",
"ctx",
".",
"Done",
"(",
")",
":",
"seelog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"return",
"false",
"\n",
"<mask>",
":",
"taskKnownStatus",
":=",
"mtask",
".",
"GetKnownStatus",
"(",
")",
"\n",
"return",
"taskKnownStatus",
"==",
"apitaskstatus",
".",
"TaskRunning",
"&&",
"taskKnownStatus",
">=",
"mtask",
".",
"GetDesiredStatus",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
13,473 | all-13474 | [
"Locator",
"returns",
"a",
"locator",
"for",
"the",
"given",
"resource"
] | [
"func",
"(",
"r",
"*",
"SecurityGroup",
")",
"Locator",
"(",
"api",
"*",
"API",
")",
"*",
"SecurityGroupLocator",
"{",
"for",
"_",
",",
"l",
":=",
"<mask>",
"r",
".",
"Links",
"{",
"if",
"l",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"{",
"return",
"api",
".",
"SecurityGroupLocator",
"(",
"l",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
13,474 | all-13475 | [
"Header",
"returns",
"request",
"header",
"representation",
".",
"The",
"returned",
"representation",
"is",
"valid",
"until",
"the",
"next",
"call",
"to",
"RequestHeader",
"methods",
"."
] | [
"func",
"(",
"h",
"*",
"RequestHeader",
")",
"Header",
"(",
")",
"[",
"]",
"byte",
"{",
"h",
".",
"bufKV",
".",
"value",
"=",
"h",
".",
"AppendBytes",
"(",
"h",
".",
"bufKV",
".",
"<mask>",
"[",
":",
"0",
"]",
")",
"\n",
"return",
"h",
".",
"bufKV",
".",
"value",
"\n",
"}"
] |
13,475 | all-13476 | [
"CVAPI",
"(",
"void",
")",
"cvLaplace",
"(",
"const",
"CvArr",
"*",
"src",
"CvArr",
"*",
"dst",
"int",
"aperture_size",
"CV_DEFAULT",
"(",
"3",
")",
")",
";",
"/",
"*",
"ConvertScale",
"converts",
"one",
"image",
"to",
"another",
"with",
"optional",
"linear",
"transformation",
"."
] | [
"func",
"ConvertScale",
"(",
"a",
",",
"b",
"*",
"IplImage",
",",
"scale",
",",
"<mask>",
"float64",
")",
"{",
"C",
".",
"cvConvertScale",
"(",
"unsafe",
".",
"Pointer",
"(",
"a",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"b",
")",
",",
"C",
".",
"double",
"(",
"scale",
")",
",",
"C",
".",
"double",
"(",
"shift",
")",
")",
"\n",
"}"
] |
13,476 | all-13477 | [
"configureEnvironment",
"adds",
"all",
"bin",
"/",
"directories",
"from",
"$GOPATH",
"to",
"$PATH"
] | [
"func",
"configureEnvironment",
"(",
")",
"{",
"paths",
":=",
"addGoBinsToPath",
"(",
"getGoPathList",
"(",
")",
")",
"\n",
"setEnv",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"paths",
",",
"string",
"(",
"<mask>",
".",
"PathListSeparator",
")",
")",
")",
"\n",
"setEnv",
"(",
"\"",
"\"",
",",
"discoverGoRoot",
"(",
")",
")",
"\n",
"debugPrintEnv",
"(",
")",
"\n",
"}"
] |
13,477 | all-13478 | [
"Helper",
"to",
"concatenate",
"arguments",
"into",
"a",
"string",
"with",
"spaces",
"between",
"the",
"arguments"
] | [
"func",
"concatArgs",
"(",
"args",
"...",
"<mask>",
"{",
"}",
")",
"string",
"{",
"res",
":=",
"fmt",
".",
"Sprintln",
"(",
"args",
"...",
")",
"\n",
"return",
"res",
"[",
"0",
":",
"len",
"(",
"res",
")",
"-",
"1",
"]",
"// Remove newline at the end",
"\n",
"}"
] |
13,478 | all-13479 | [
"GetUntrustedSignatureInformationWithoutVerifying",
"extracts",
"information",
"available",
"in",
"an",
"untrusted",
"signature",
"WITHOUT",
"doing",
"any",
"cryptographic",
"verification",
".",
"This",
"may",
"be",
"useful",
"when",
"debugging",
"signature",
"verification",
"failures",
"or",
"when",
"managing",
"a",
"set",
"of",
"signatures",
"on",
"a",
"single",
"image",
".",
"WARNING",
":",
"Do",
"not",
"use",
"the",
"contents",
"of",
"this",
"for",
"ANY",
"security",
"decisions",
"and",
"be",
"VERY",
"CAREFUL",
"about",
"showing",
"this",
"information",
"to",
"humans",
"in",
"any",
"way",
"which",
"suggest",
"that",
"these",
"values",
"“are",
"probably”",
"reliable",
".",
"There",
"is",
"NO",
"REASON",
"to",
"expect",
"the",
"values",
"to",
"be",
"correct",
"or",
"not",
"intentionally",
"misleading",
"(",
"including",
"things",
"like",
"“✅",
"Verified",
"by",
"$authority”",
")"
] | [
"func",
"GetUntrustedSignatureInformationWithoutVerifying",
"(",
"untrustedSignatureBytes",
"[",
"]",
"<mask>",
")",
"(",
"*",
"UntrustedSignatureInformation",
",",
"error",
")",
"{",
"// NOTE: This should eventualy do format autodetection.",
"mech",
",",
"_",
",",
"err",
":=",
"NewEphemeralGPGSigningMechanism",
"(",
"[",
"]",
"byte",
"{",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"mech",
".",
"Close",
"(",
")",
"\n\n",
"untrustedContents",
",",
"shortKeyIdentifier",
",",
"err",
":=",
"mech",
".",
"UntrustedSignatureContents",
"(",
"untrustedSignatureBytes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"var",
"untrustedDecodedContents",
"untrustedSignature",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"untrustedContents",
",",
"&",
"untrustedDecodedContents",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"InvalidSignatureError",
"{",
"msg",
":",
"err",
".",
"Error",
"(",
")",
"}",
"\n",
"}",
"\n\n",
"var",
"timestamp",
"*",
"time",
".",
"Time",
"// = nil",
"\n",
"if",
"untrustedDecodedContents",
".",
"UntrustedTimestamp",
"!=",
"nil",
"{",
"ts",
":=",
"time",
".",
"Unix",
"(",
"*",
"untrustedDecodedContents",
".",
"UntrustedTimestamp",
",",
"0",
")",
"\n",
"timestamp",
"=",
"&",
"ts",
"\n",
"}",
"\n",
"return",
"&",
"UntrustedSignatureInformation",
"{",
"UntrustedDockerManifestDigest",
":",
"untrustedDecodedContents",
".",
"UntrustedDockerManifestDigest",
",",
"UntrustedDockerReference",
":",
"untrustedDecodedContents",
".",
"UntrustedDockerReference",
",",
"UntrustedCreatorID",
":",
"untrustedDecodedContents",
".",
"UntrustedCreatorID",
",",
"UntrustedTimestamp",
":",
"timestamp",
",",
"UntrustedShortKeyIdentifier",
":",
"shortKeyIdentifier",
",",
"}",
",",
"nil",
"\n",
"}"
] |
13,479 | all-13480 | [
"GenerateKeyPair",
"generates",
"a",
"private",
"and",
"public",
"key"
] | [
"func",
"GenerateKeyPair",
"(",
"typ",
",",
"bits",
"int",
")",
"(",
"PrivKey",
",",
"PubKey",
",",
"error",
")",
"{",
"return",
"GenerateKeyPairWithReader",
"(",
"typ",
",",
"<mask>",
",",
"rand",
".",
"Reader",
")",
"\n",
"}"
] |
13,480 | all-13481 | [
"Delete",
"deletes",
"the",
"records",
"from",
"database",
"table",
".",
"The",
"obj",
"must",
"be",
"pointer",
"to",
"struct",
"or",
"slice",
"of",
"struct",
"and",
"must",
"have",
"field",
"that",
"specified",
"pk",
"struct",
"tag",
".",
"Delete",
"will",
"try",
"to",
"delete",
"record",
"which",
"searched",
"by",
"value",
"of",
"primary",
"key",
"in",
"obj",
".",
"Delete",
"returns",
"teh",
"number",
"of",
"rows",
"affected",
"by",
"a",
"delete",
"."
] | [
"func",
"(",
"db",
"*",
"DB",
")",
"Delete",
"(",
"obj",
"interface",
"{",
"}",
")",
"(",
"affected",
"int64",
",",
"err",
"error",
")",
"{",
"objs",
",",
"rtype",
",",
"tableName",
",",
"err",
":=",
"db",
".",
"tableObjs",
"(",
"\"",
"\"",
",",
"obj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"objs",
")",
"<",
"1",
"{",
"return",
"0",
",",
"nil",
"\n",
"}",
"\n",
"for",
"_",
",",
"obj",
":=",
"range",
"objs",
"{",
"if",
"hook",
",",
"ok",
":=",
"obj",
".",
"(",
"BeforeDeleter",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"hook",
".",
"BeforeDelete",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"pkIdx",
":=",
"db",
".",
"findPKIndex",
"(",
"rtype",
",",
"nil",
")",
"\n",
"if",
"len",
"(",
"pkIdx",
")",
"<",
"1",
"{",
"return",
"-",
"1",
",",
"fmt",
".",
"Errorf",
"(",
"`Delete: fields of struct doesn't have primary key: \"pk\" struct tag must be specified for delete`",
")",
"\n",
"}",
"\n",
"var",
"args",
"[",
"]",
"interface",
"{",
"}",
"\n",
"for",
"_",
",",
"obj",
":=",
"range",
"objs",
"{",
"rv",
":=",
"reflect",
".",
"Indirect",
"(",
"reflect",
".",
"ValueOf",
"(",
"obj",
")",
")",
"\n",
"args",
"=",
"append",
"(",
"args",
",",
"rv",
".",
"FieldByIndex",
"(",
"pkIdx",
")",
".",
"Interface",
"(",
")",
")",
"\n",
"}",
"\n",
"holders",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"args",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"holders",
")",
";",
"i",
"++",
"{",
"holders",
"[",
"i",
"]",
"=",
"db",
".",
"dialect",
".",
"PlaceHolder",
"(",
"i",
")",
"\n",
"}",
"\n",
"query",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"db",
".",
"dialect",
".",
"Quote",
"(",
"tableName",
")",
",",
"db",
".",
"dialect",
".",
"Quote",
"(",
"db",
".",
"columnFromTag",
"(",
"rtype",
".",
"FieldByIndex",
"(",
"pkIdx",
")",
")",
")",
",",
"strings",
".",
"Join",
"(",
"holders",
",",
"\"",
"\"",
")",
")",
"\n",
"stmt",
",",
"err",
":=",
"db",
".",
"prepare",
"(",
"<mask>",
",",
"args",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"defer",
"stmt",
".",
"Close",
"(",
")",
"\n",
"result",
",",
"err",
":=",
"stmt",
".",
"Exec",
"(",
"args",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"affected",
",",
"_",
"=",
"result",
".",
"RowsAffected",
"(",
")",
"\n",
"for",
"_",
",",
"obj",
":=",
"range",
"objs",
"{",
"if",
"hook",
",",
"ok",
":=",
"obj",
".",
"(",
"AfterDeleter",
")",
";",
"ok",
"{",
"if",
"err",
":=",
"hook",
".",
"AfterDelete",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"affected",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"affected",
",",
"nil",
"\n",
"}"
] |
13,481 | all-13482 | [
"hostStorageSystemFromHostSystemID",
"locates",
"a",
"HostStorageSystem",
"from",
"a",
"specified",
"HostSystem",
"managed",
"object",
"ID",
"."
] | [
"func",
"hostStorageSystemFromHostSystemID",
"(",
"client",
"*",
"govmomi",
".",
"Client",
",",
"hsID",
"string",
")",
"(",
"*",
"object",
".",
"HostStorageSystem",
",",
"error",
")",
"{",
"hs",
",",
"err",
":=",
"hostsystem",
".",
"FromID",
"(",
"client",
",",
"hsID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ctx",
",",
"cancel",
":=",
"<mask>",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"defaultAPITimeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"return",
"hs",
".",
"ConfigManager",
"(",
")",
".",
"StorageSystem",
"(",
"ctx",
")",
"\n",
"}"
] |
13,482 | all-13483 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"EventBreakpointResolved",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger41",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
13,483 | all-13484 | [
"TimeoutReader",
"returns",
"an",
"io",
".",
"Reader",
"that",
"wraps",
"the",
"passed",
"-",
"in",
"io",
".",
"Reader",
".",
"If",
"the",
"underlying",
"Reader",
"fails",
"to",
"read",
"within",
"the",
"alloted",
"timeout",
"ErrTimeout",
"is",
"returned",
"."
] | [
"func",
"TimeoutReader",
"(",
"r",
"<mask>",
".",
"Reader",
",",
"timeout",
"time",
".",
"Duration",
")",
"io",
".",
"Reader",
"{",
"return",
"timeoutReaderWriterCloser",
"{",
"r",
":",
"r",
",",
"d",
":",
"timeout",
"}",
"\n",
"}"
] |
13,484 | all-13485 | [
"GetDefaultTaskImageResource",
"-",
"convenience",
"helper",
"to",
"output",
"default",
"object",
"for",
"task",
"images"
] | [
"func",
"(",
"s",
"*",
"ConcoursePipeline",
")",
"GetDefaultTaskImageResource",
"(",
")",
"atc",
".",
"ImageResource",
"{",
"return",
"atc",
".",
"ImageResource",
"{",
"<mask>",
":",
"s",
".",
"defaultImageType",
",",
"Source",
":",
"atc",
".",
"Source",
"{",
"\"",
"\"",
":",
"s",
".",
"defaultImageRepository",
",",
"}",
",",
"}",
"\n",
"}"
] |
13,485 | all-13486 | [
"newExpectedContext",
"creates",
"a",
"Context",
"with",
"Expected",
"state",
"."
] | [
"func",
"newExpectedContext",
"(",
"c",
"string",
")",
"Context",
"{",
"return",
"Context",
"{",
"Context",
":",
"githubql",
".",
"<mask>",
"(",
"c",
")",
",",
"State",
":",
"githubql",
".",
"StatusStateExpected",
",",
"Description",
":",
"githubql",
".",
"String",
"(",
"\"",
"\"",
")",
",",
"}",
"\n",
"}"
] |
13,486 | all-13487 | [
"Return",
"the",
"addresses",
"of",
"the",
"raft",
"nodes",
"as",
"stored",
"in",
"the",
"node",
"-",
"level",
"database",
".",
"These",
"values",
"might",
"leg",
"behind",
"the",
"actual",
"values",
"and",
"are",
"refreshed",
"periodically",
"during",
"heartbeats",
"."
] | [
"func",
"(",
"g",
"*",
"Gateway",
")",
"cachedRaftNodes",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"addresses",
"[",
"]",
"string",
"\n",
"err",
":=",
"g",
".",
"db",
".",
"Transaction",
"(",
"func",
"(",
"<mask>",
"*",
"db",
".",
"NodeTx",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"addresses",
",",
"err",
"=",
"tx",
".",
"RaftNodeAddresses",
"(",
")",
"\n",
"return",
"err",
"\n",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"addresses",
",",
"nil",
"\n",
"}"
] |
13,487 | all-13488 | [
"Create",
"a",
"Typed",
"helper",
"from",
"the",
"given",
"JSON",
"stream"
] | [
"func",
"JsonReader",
"(",
"reader",
"io",
".",
"Reader",
")",
"(",
"Typed",
",",
"error",
")",
"{",
"if",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"reader",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"else",
"{",
"return",
"Json",
"(",
"<mask>",
")",
"\n",
"}",
"\n",
"}"
] |
13,488 | all-13489 | [
"XXX_OneofFuncs",
"is",
"for",
"the",
"internal",
"use",
"of",
"the",
"proto",
"package",
"."
] | [
"func",
"(",
"*",
"ResponseOp",
")",
"XXX_OneofFuncs",
"(",
")",
"(",
"func",
"(",
"msg",
"proto",
".",
"<mask>",
",",
"b",
"*",
"proto",
".",
"Buffer",
")",
"error",
",",
"func",
"(",
"msg",
"proto",
".",
"Message",
",",
"tag",
",",
"wire",
"int",
",",
"b",
"*",
"proto",
".",
"Buffer",
")",
"(",
"bool",
",",
"error",
")",
",",
"func",
"(",
"msg",
"proto",
".",
"Message",
")",
"(",
"n",
"int",
")",
",",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"return",
"_ResponseOp_OneofMarshaler",
",",
"_ResponseOp_OneofUnmarshaler",
",",
"_ResponseOp_OneofSizer",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"(",
"*",
"ResponseOp_ResponseRange",
")",
"(",
"nil",
")",
",",
"(",
"*",
"ResponseOp_ResponsePut",
")",
"(",
"nil",
")",
",",
"(",
"*",
"ResponseOp_ResponseDeleteRange",
")",
"(",
"nil",
")",
",",
"(",
"*",
"ResponseOp_ResponseTxn",
")",
"(",
"nil",
")",
",",
"}",
"\n",
"}"
] |
13,489 | all-13490 | [
"BeginningOfWeek",
"beginning",
"of",
"week"
] | [
"func",
"(",
"now",
"*",
"Now",
")",
"BeginningOfWeek",
"(",
")",
"time",
".",
"Time",
"{",
"t",
":=",
"<mask>",
".",
"BeginningOfDay",
"(",
")",
"\n",
"weekday",
":=",
"int",
"(",
"t",
".",
"Weekday",
"(",
")",
")",
"\n\n",
"if",
"WeekStartDay",
"!=",
"time",
".",
"Sunday",
"{",
"weekStartDayInt",
":=",
"int",
"(",
"WeekStartDay",
")",
"\n\n",
"if",
"weekday",
"<",
"weekStartDayInt",
"{",
"weekday",
"=",
"weekday",
"+",
"7",
"-",
"weekStartDayInt",
"\n",
"}",
"else",
"{",
"weekday",
"=",
"weekday",
"-",
"weekStartDayInt",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"t",
".",
"AddDate",
"(",
"0",
",",
"0",
",",
"-",
"weekday",
")",
"\n",
"}"
] |
13,490 | all-13491 | [
"RootFromDatacenter",
"returns",
"the",
"root",
"path",
"for",
"the",
"particle",
"from",
"the",
"given",
"datacenter",
"s",
"inventory",
"path",
"."
] | [
"func",
"(",
"p",
"RootPathParticle",
")",
"RootFromDatacenter",
"(",
"dc",
"*",
"<mask>",
".",
"Datacenter",
")",
"string",
"{",
"return",
"dc",
".",
"InventoryPath",
"+",
"\"",
"\"",
"+",
"string",
"(",
"p",
")",
"\n",
"}"
] |
13,491 | all-13492 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"ScriptCoverage",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoProfiler15",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
13,492 | all-13493 | [
"GetDesiredStatus",
"gets",
"the",
"desired",
"status",
"of",
"the",
"task"
] | [
"func",
"(",
"task",
"*",
"Task",
")",
"GetDesiredStatus",
"(",
")",
"apitaskstatus",
".",
"TaskStatus",
"{",
"task",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"<mask>",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"task",
".",
"DesiredStatusUnsafe",
"\n",
"}"
] |
13,493 | all-13494 | [
"StorageDRSEnabled",
"checks",
"a",
"StoragePod",
"to",
"see",
"if",
"Storage",
"DRS",
"is",
"enabled",
"."
] | [
"func",
"StorageDRSEnabled",
"(",
"pod",
"*",
"object",
".",
"StoragePod",
")",
"(",
"bool",
",",
"error",
")",
"{",
"props",
",",
"err",
":=",
"Properties",
"(",
"pod",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"<mask>",
",",
"err",
"\n",
"}",
"\n",
"if",
"props",
".",
"PodStorageDrsEntry",
"==",
"nil",
"{",
"return",
"false",
",",
"nil",
"\n",
"}",
"\n",
"return",
"props",
".",
"PodStorageDrsEntry",
".",
"StorageDrsConfig",
".",
"PodConfig",
".",
"Enabled",
",",
"nil",
"\n",
"}"
] |
13,494 | all-13495 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"SetCustomObjectFormatterEnabledParams",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoRuntime4",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
13,495 | all-13496 | [
"DialEtcdGRPCServer",
"creates",
"a",
"raw",
"gRPC",
"connection",
"to",
"an",
"etcd",
"member",
"."
] | [
"func",
"(",
"m",
"*",
"Member",
")",
"DialEtcdGRPCServer",
"(",
"opts",
"...",
"grpc",
".",
"DialOption",
")",
"(",
"*",
"grpc",
".",
"ClientConn",
",",
"error",
")",
"{",
"dialOpts",
":=",
"[",
"]",
"grpc",
".",
"DialOption",
"{",
"grpc",
".",
"WithTimeout",
"(",
"5",
"*",
"time",
".",
"Second",
")",
",",
"grpc",
".",
"WithBlock",
"(",
")",
",",
"}",
"\n\n",
"secure",
":=",
"false",
"\n",
"for",
"_",
",",
"cu",
":=",
"range",
"m",
".",
"Etcd",
".",
"AdvertiseClientURLs",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"cu",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"u",
".",
"Scheme",
"==",
"\"",
"\"",
"{",
"// TODO: handle unix",
"secure",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"secure",
"{",
"// assume save TLS assets are already stord on disk",
"tlsInfo",
":=",
"transport",
".",
"TLSInfo",
"{",
"CertFile",
":",
"m",
".",
"ClientCertPath",
",",
"KeyFile",
":",
"m",
".",
"ClientKeyPath",
",",
"TrustedCAFile",
":",
"m",
".",
"ClientTrustedCAPath",
",",
"// TODO: remove this with generated certs",
"// only need it for auto TLS",
"InsecureSkipVerify",
":",
"true",
",",
"}",
"\n",
"tlsConfig",
",",
"err",
":=",
"tlsInfo",
".",
"ClientConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"creds",
":=",
"credentials",
".",
"NewTLS",
"(",
"tlsConfig",
")",
"\n",
"dialOpts",
"=",
"append",
"(",
"dialOpts",
",",
"grpc",
".",
"WithTransportCredentials",
"(",
"creds",
")",
")",
"\n",
"}",
"else",
"{",
"dialOpts",
"=",
"<mask>",
"(",
"dialOpts",
",",
"grpc",
".",
"WithInsecure",
"(",
")",
")",
"\n",
"}",
"\n",
"dialOpts",
"=",
"append",
"(",
"dialOpts",
",",
"opts",
"...",
")",
"\n",
"return",
"grpc",
".",
"Dial",
"(",
"m",
".",
"EtcdClientEndpoint",
",",
"dialOpts",
"...",
")",
"\n",
"}"
] |
13,496 | all-13497 | [
"newRoutes",
"returns",
"a",
"usable",
"Routes",
"based",
"on",
"the",
"LocalPeer",
"and",
"existing",
"Peers",
"."
] | [
"func",
"newRoutes",
"(",
"ourself",
"*",
"localPeer",
",",
"peers",
"*",
"Peers",
")",
"*",
"routes",
"{",
"recalculate",
":=",
"make",
"(",
"chan",
"*",
"struct",
"{",
"}",
",",
"1",
")",
"\n",
"wait",
":=",
"make",
"(",
"chan",
"chan",
"struct",
"{",
"}",
")",
"\n",
"action",
":=",
"make",
"(",
"chan",
"func",
"(",
")",
")",
"\n",
"r",
":=",
"&",
"routes",
"{",
"ourself",
":",
"ourself",
",",
"peers",
":",
"peers",
",",
"unicast",
":",
"unicastRoutes",
"{",
"ourself",
".",
"Name",
":",
"UnknownPeerName",
"}",
",",
"unicastAll",
":",
"unicastRoutes",
"{",
"ourself",
".",
"Name",
":",
"UnknownPeerName",
"}",
",",
"broadcast",
":",
"broadcastRoutes",
"{",
"ourself",
".",
"<mask>",
":",
"[",
"]",
"PeerName",
"{",
"}",
"}",
",",
"broadcastAll",
":",
"broadcastRoutes",
"{",
"ourself",
".",
"Name",
":",
"[",
"]",
"PeerName",
"{",
"}",
"}",
",",
"recalc",
":",
"recalculate",
",",
"wait",
":",
"wait",
",",
"action",
":",
"action",
",",
"}",
"\n",
"go",
"r",
".",
"run",
"(",
"recalculate",
",",
"wait",
",",
"action",
")",
"\n",
"return",
"r",
"\n",
"}"
] |
13,497 | all-13498 | [
"virtualMachineProperties",
"is",
"a",
"convenience",
"method",
"that",
"wraps",
"fetching",
"the",
"VirtualMachine",
"MO",
"from",
"its",
"higher",
"-",
"level",
"object",
".",
"It",
"takes",
"a",
"list",
"of",
"property",
"keys",
"to",
"fetch",
".",
"Keeping",
"the",
"property",
"set",
"small",
"can",
"sometimes",
"result",
"in",
"significant",
"performance",
"improvements",
"."
] | [
"func",
"virtualMachineProperties",
"(",
"ctx",
"context",
".",
"Context",
",",
"vm",
"*",
"object",
".",
"VirtualMachine",
",",
"keys",
"[",
"]",
"string",
")",
"(",
"*",
"mo",
".",
"VirtualMachine",
",",
"error",
")",
"{",
"logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"vm",
".",
"<mask>",
"(",
")",
")",
"\n",
"var",
"props",
"mo",
".",
"VirtualMachine",
"\n",
"if",
"err",
":=",
"vm",
".",
"Properties",
"(",
"ctx",
",",
"vm",
".",
"Reference",
"(",
")",
",",
"keys",
",",
"&",
"props",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"props",
",",
"nil",
"\n",
"}"
] |
13,498 | all-13499 | [
"Wrap",
"wraps",
"an",
"HTTP",
"handler",
"to",
"check",
"the",
"contents",
"of",
"client",
"certificates",
".",
"If",
"CheckCertificate",
"returns",
"true",
"the",
"request",
"will",
"be",
"passed",
"to",
"the",
"wrapped",
"handler",
".",
"If",
"CheckCertificate",
"returns",
"false",
"it",
"will",
"be",
"passed",
"to",
"the",
"InvalidHandler",
"or",
"if",
"no",
"InvalidHandler",
"is",
"specified",
"will",
"return",
"an",
"empty",
"403",
"response",
"and",
"log",
"the",
"rejected",
"DN",
"."
] | [
"func",
"(",
"v",
"*",
"X509NameVerifier",
")",
"Wrap",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"dn",
":=",
"r",
".",
"Header",
".",
"Get",
"(",
"v",
".",
"HeaderName",
")",
"\n\n",
"var",
"name",
"*",
"pkix",
".",
"<mask>",
"\n",
"if",
"dn",
"!=",
"\"",
"\"",
"{",
"name",
"=",
"parseDN",
"(",
"dn",
")",
"\n",
"}",
"\n\n",
"if",
"name",
"!=",
"nil",
"&&",
"v",
".",
"CheckCertificate",
"(",
"name",
")",
"{",
"h",
".",
"ServeHTTP",
"(",
"w",
",",
"r",
")",
"\n",
"}",
"else",
"if",
"v",
".",
"InvalidHandler",
"!=",
"nil",
"{",
"v",
".",
"InvalidHandler",
".",
"ServeHTTP",
"(",
"w",
",",
"r",
")",
"\n",
"}",
"else",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"dn",
")",
"\n",
"w",
".",
"WriteHeader",
"(",
"403",
")",
"\n",
"}",
"\n",
"}",
")",
"\n",
"}"
] |
13,499 | all-13500 | [
"Schema",
"returns",
"the",
"indexes",
"and",
"fields",
"on",
"the",
"server",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"Schema",
"(",
")",
"(",
"*",
"Schema",
",",
"error",
")",
"{",
"span",
":=",
"c",
".",
"tracer",
".",
"StartSpan",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"span",
".",
"Finish",
"(",
")",
"\n\n",
"var",
"indexes",
"[",
"]",
"SchemaIndex",
"\n",
"indexes",
",",
"err",
":=",
"c",
".",
"readSchema",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"schema",
":=",
"NewSchema",
"(",
")",
"\n",
"for",
"_",
",",
"indexInfo",
":=",
"range",
"indexes",
"{",
"index",
":=",
"schema",
".",
"indexWithOptions",
"(",
"indexInfo",
".",
"Name",
",",
"indexInfo",
".",
"ShardWidth",
",",
"indexInfo",
".",
"Options",
".",
"asIndexOptions",
"(",
")",
")",
"\n",
"for",
"_",
",",
"fieldInfo",
":=",
"range",
"indexInfo",
".",
"Fields",
"{",
"<mask>",
".",
"fieldWithOptions",
"(",
"fieldInfo",
".",
"Name",
",",
"fieldInfo",
".",
"Options",
".",
"asFieldOptions",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"schema",
",",
"nil",
"\n",
"}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.