id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
1,300 | all-1301 | [
"verifyContainerOrderingStatusResolvable",
"validates",
"that",
"target",
"can",
"be",
"resolved",
"given",
"that",
"the",
"dependsOn",
"containers",
"are",
"resolved",
"and",
"there",
"are",
"existingContainers",
"(",
"map",
"from",
"name",
"to",
"container",
")",
".",
"The",
"resolves",
"function",
"passed",
"should",
"return",
"true",
"if",
"the",
"named",
"container",
"is",
"resolved",
"."
] | [
"func",
"verifyContainerOrderingStatusResolvable",
"(",
"<mask>",
"*",
"apicontainer",
".",
"Container",
",",
"existingContainers",
"map",
"[",
"string",
"]",
"*",
"apicontainer",
".",
"Container",
",",
"resolves",
"func",
"(",
"*",
"apicontainer",
".",
"Container",
",",
"*",
"apicontainer",
".",
"Container",
",",
"string",
")",
"bool",
")",
"(",
"*",
"apicontainer",
".",
"DependsOn",
",",
"error",
")",
"{",
"targetGoal",
":=",
"target",
".",
"GetDesiredStatus",
"(",
")",
"\n",
"targetKnown",
":=",
"target",
".",
"GetKnownStatus",
"(",
")",
"\n",
"if",
"targetGoal",
"!=",
"target",
".",
"GetSteadyStateStatus",
"(",
")",
"&&",
"targetGoal",
"!=",
"apicontainerstatus",
".",
"ContainerCreated",
"{",
"// A container can always stop, die, or reach whatever other state it",
"// wants regardless of what dependencies it has",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"dependency",
":=",
"range",
"target",
".",
"DependsOn",
"{",
"dependencyContainer",
",",
"ok",
":=",
"existingContainers",
"[",
"dependency",
".",
"ContainerName",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"dependencyContainer",
",",
"target",
")",
"\n",
"}",
"\n\n",
"// We want to check whether the dependency container has timed out only if target has not been created yet.",
"// If the target is already created, then everything is normal and dependency can be and is resolved.",
"// However, if dependency container has already stopped, then it cannot time out.",
"if",
"targetKnown",
"<",
"apicontainerstatus",
".",
"ContainerCreated",
"&&",
"dependencyContainer",
".",
"GetKnownStatus",
"(",
")",
"!=",
"apicontainerstatus",
".",
"ContainerStopped",
"{",
"if",
"hasDependencyTimedOut",
"(",
"dependencyContainer",
",",
"dependency",
".",
"Condition",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"dependencyContainer",
",",
"target",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// We want to fail fast if the dependency container did not exit successfully' because target container",
"// can then never progress to its desired state when the dependency condition is 'SUCCESS'",
"if",
"dependency",
".",
"Condition",
"==",
"successCondition",
"&&",
"dependencyContainer",
".",
"GetKnownExitCode",
"(",
")",
"!=",
"nil",
"{",
"if",
"!",
"hasDependencyStoppedSuccessfully",
"(",
"dependencyContainer",
",",
"dependency",
".",
"Condition",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"dependencyContainer",
",",
"target",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"!",
"resolves",
"(",
"target",
",",
"dependencyContainer",
",",
"dependency",
".",
"Condition",
")",
"{",
"return",
"&",
"dependency",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"dependencyContainer",
",",
"target",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
",",
"nil",
"\n",
"}"
] |
1,301 | all-1302 | [
"StatusString",
"returns",
"the",
"string",
"of",
"the",
"cgroup",
"resource",
"status"
] | [
"func",
"(",
"secret",
"*",
"SSMSecretResource",
")",
"StatusString",
"(",
"<mask>",
"resourcestatus",
".",
"ResourceStatus",
")",
"string",
"{",
"return",
"SSMSecretStatus",
"(",
"status",
")",
".",
"String",
"(",
")",
"\n",
"}"
] |
1,302 | all-1303 | [
"RequestData",
"requests",
"data",
"from",
"object",
"store",
"or",
"index",
".",
"See",
":",
"https",
":",
"//",
"chromedevtools",
".",
"github",
".",
"io",
"/",
"devtools",
"-",
"protocol",
"/",
"tot",
"/",
"IndexedDB#method",
"-",
"requestData",
"parameters",
":",
"securityOrigin",
"-",
"Security",
"origin",
".",
"databaseName",
"-",
"Database",
"name",
".",
"objectStoreName",
"-",
"Object",
"store",
"name",
".",
"indexName",
"-",
"Index",
"name",
"empty",
"string",
"for",
"object",
"store",
"data",
"requests",
".",
"skipCount",
"-",
"Number",
"of",
"records",
"to",
"skip",
".",
"pageSize",
"-",
"Number",
"of",
"records",
"to",
"fetch",
"."
] | [
"func",
"RequestData",
"(",
"securityOrigin",
"string",
",",
"databaseName",
"string",
",",
"objectStoreName",
"<mask>",
",",
"indexName",
"string",
",",
"skipCount",
"int64",
",",
"pageSize",
"int64",
")",
"*",
"RequestDataParams",
"{",
"return",
"&",
"RequestDataParams",
"{",
"SecurityOrigin",
":",
"securityOrigin",
",",
"DatabaseName",
":",
"databaseName",
",",
"ObjectStoreName",
":",
"objectStoreName",
",",
"IndexName",
":",
"indexName",
",",
"SkipCount",
":",
"skipCount",
",",
"PageSize",
":",
"pageSize",
",",
"}",
"\n",
"}"
] |
1,303 | all-1304 | [
"SetPrefix",
"set",
"Print",
"logger",
"prefix"
] | [
"func",
"(",
"g",
"*",
"Glg",
")",
"SetPrefix",
"(",
"pref",
"string",
")",
"*",
"Glg",
"{",
"v",
",",
"ok",
":=",
"g",
".",
"logger",
".",
"Load",
"(",
"PRINT",
")",
"\n",
"if",
"ok",
"{",
"<mask>",
":=",
"v",
".",
"(",
"*",
"logger",
")",
"\n",
"value",
".",
"tag",
"=",
"pref",
"\n",
"g",
".",
"logger",
".",
"Store",
"(",
"PRINT",
",",
"value",
")",
"\n",
"}",
"\n",
"return",
"g",
"\n",
"}"
] |
1,304 | all-1305 | [
"sortExprLabels",
"sorts",
"lists",
"of",
"strings",
"using",
"the",
"same",
"order",
"as",
"buildifier",
".",
"Buildifier",
"also",
"sorts",
"string",
"lists",
"but",
"not",
"those",
"involved",
"with",
"select",
"expressions",
".",
"This",
"function",
"is",
"intended",
"to",
"be",
"used",
"with",
"bzl",
".",
"Walk",
"."
] | [
"func",
"sortExprLabels",
"(",
"e",
"bzl",
".",
"Expr",
",",
"_",
"[",
"]",
"bzl",
".",
"Expr",
")",
"{",
"list",
",",
"ok",
":=",
"e",
".",
"(",
"*",
"bzl",
".",
"ListExpr",
")",
"\n",
"if",
"!",
"ok",
"||",
"len",
"(",
"list",
".",
"List",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"keys",
":=",
"make",
"(",
"[",
"]",
"stringSortKey",
",",
"len",
"(",
"list",
".",
"<mask>",
")",
")",
"\n",
"for",
"i",
",",
"elem",
":=",
"range",
"list",
".",
"List",
"{",
"s",
",",
"ok",
":=",
"elem",
".",
"(",
"*",
"bzl",
".",
"StringExpr",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"// don't sort lists unless all elements are strings",
"\n",
"}",
"\n",
"keys",
"[",
"i",
"]",
"=",
"makeSortKey",
"(",
"i",
",",
"s",
")",
"\n",
"}",
"\n\n",
"before",
":=",
"keys",
"[",
"0",
"]",
".",
"x",
".",
"Comment",
"(",
")",
".",
"Before",
"\n",
"keys",
"[",
"0",
"]",
".",
"x",
".",
"Comment",
"(",
")",
".",
"Before",
"=",
"nil",
"\n",
"sort",
".",
"Sort",
"(",
"byStringExpr",
"(",
"keys",
")",
")",
"\n",
"keys",
"[",
"0",
"]",
".",
"x",
".",
"Comment",
"(",
")",
".",
"Before",
"=",
"append",
"(",
"before",
",",
"keys",
"[",
"0",
"]",
".",
"x",
".",
"Comment",
"(",
")",
".",
"Before",
"...",
")",
"\n",
"for",
"i",
",",
"k",
":=",
"range",
"keys",
"{",
"list",
".",
"List",
"[",
"i",
"]",
"=",
"k",
".",
"x",
"\n",
"}",
"\n",
"}"
] |
1,305 | all-1306 | [
"WaitIsTextAvailable",
"is",
"a",
"wrapper",
"around",
"gtk_clipboard_wait_is_text_available"
] | [
"func",
"(",
"v",
"*",
"Clipboard",
")",
"WaitIsTextAvailable",
"(",
")",
"bool",
"{",
"c",
":=",
"C",
".",
"gtk_clipboard_wait_is_text_available",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"<mask>",
"gobool",
"(",
"c",
")",
"\n",
"}"
] |
1,306 | all-1307 | [
"GetType",
"returns",
"the",
"Type",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"g",
"*",
"GraphDefinitionRequest",
")",
"GetType",
"(",
")",
"string",
"{",
"if",
"g",
"==",
"nil",
"||",
"g",
".",
"Type",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"g",
".",
"<mask>",
"\n",
"}"
] |
1,307 | all-1308 | [
"Write",
"writes",
"a",
"single",
"line",
"to",
"the",
"underlining",
"buffer",
".",
"If",
"the",
"ScreenBuf",
"was",
"previously",
"reset",
"all",
"previous",
"lines",
"are",
"cleared",
"and",
"the",
"output",
"starts",
"from",
"the",
"top",
".",
"Lines",
"with",
"\\",
"r",
"or",
"\\",
"n",
"will",
"cause",
"an",
"error",
"since",
"they",
"can",
"interfere",
"with",
"the",
"terminal",
"ability",
"to",
"move",
"between",
"lines",
"."
] | [
"func",
"(",
"s",
"*",
"ScreenBuf",
")",
"Write",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"bytes",
".",
"ContainsAny",
"(",
"b",
",",
"\"",
"\\r",
"\\n",
"\"",
")",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\\",
"\\\\",
"\"",
",",
"b",
")",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"reset",
"{",
"if",
"err",
":=",
"s",
".",
"Clear",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"switch",
"{",
"case",
"s",
".",
"cursor",
"==",
"s",
".",
"height",
":",
"n",
",",
"err",
":=",
"s",
".",
"buf",
".",
"Write",
"(",
"clearLine",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n",
",",
"err",
"\n",
"}",
"\n",
"line",
":=",
"append",
"(",
"b",
",",
"[",
"]",
"byte",
"(",
"\"",
"\\n",
"\"",
")",
"...",
")",
"\n",
"n",
",",
"err",
"=",
"s",
".",
"buf",
".",
"Write",
"(",
"line",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n",
",",
"err",
"\n",
"}",
"\n",
"s",
".",
"<mask>",
"++",
"\n",
"s",
".",
"cursor",
"++",
"\n",
"return",
"n",
",",
"nil",
"\n",
"case",
"s",
".",
"cursor",
"<",
"s",
".",
"height",
":",
"n",
",",
"err",
":=",
"s",
".",
"buf",
".",
"Write",
"(",
"clearLine",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n",
",",
"err",
"\n",
"}",
"\n",
"n",
",",
"err",
"=",
"s",
".",
"buf",
".",
"Write",
"(",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n",
",",
"err",
"\n",
"}",
"\n",
"n",
",",
"err",
"=",
"s",
".",
"buf",
".",
"Write",
"(",
"moveDown",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n",
",",
"err",
"\n",
"}",
"\n",
"s",
".",
"cursor",
"++",
"\n",
"return",
"n",
",",
"nil",
"\n",
"default",
":",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"s",
".",
"cursor",
",",
"s",
".",
"height",
")",
"\n",
"}",
"\n",
"}"
] |
1,308 | all-1309 | [
"GetPrefix",
"returns",
"the",
"Prefix",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"t",
"*",
"TemplateVariable",
")",
"GetPrefix",
"(",
")",
"string",
"{",
"if",
"t",
"==",
"nil",
"||",
"t",
".",
"Prefix",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"<mask>",
"*",
"t",
".",
"Prefix",
"\n",
"}"
] |
1,309 | all-1310 | [
"GetType",
"returns",
"the",
"Type",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"a",
"*",
"AlertValueDefinition",
")",
"GetType",
"(",
")",
"string",
"{",
"if",
"a",
"==",
"nil",
"||",
"a",
".",
"Type",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"a",
".",
"<mask>",
"\n",
"}"
] |
1,310 | all-1311 | [
"ValidEnum",
"validates",
"a",
"proposed",
"value",
"for",
"this",
"enum",
".",
"Implements",
"the",
"Enum",
"interface",
"for",
"ErrorCode"
] | [
"func",
"(",
"e",
"ErrorCode",
")",
"ValidEnum",
"(",
"v",
"int32",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"errorCodeMap",
"[",
"v",
"]",
"\n",
"return",
"<mask>",
"\n",
"}"
] |
1,311 | all-1312 | [
"NewSession",
"creates",
"a",
"new",
"database",
"session",
"."
] | [
"func",
"NewSession",
"(",
"ctx",
"context",
".",
"Context",
",",
"prm",
"sessionPrm",
")",
"(",
"*",
"Session",
",",
"error",
")",
"{",
"if",
"trace",
"{",
"outLogger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"prm",
")",
"\n",
"}",
"\n\n",
"<mask>",
",",
"err",
":=",
"newSessionConn",
"(",
"ctx",
",",
"prm",
".",
"Host",
"(",
")",
",",
"prm",
".",
"Timeout",
"(",
")",
",",
"prm",
".",
"TLSConfig",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"rd",
":=",
"bufio",
".",
"NewReader",
"(",
"conn",
")",
"\n",
"wr",
":=",
"bufio",
".",
"NewWriter",
"(",
"conn",
")",
"\n\n",
"s",
":=",
"&",
"Session",
"{",
"prm",
":",
"prm",
",",
"conn",
":",
"conn",
",",
"rd",
":",
"rd",
",",
"wr",
":",
"wr",
",",
"mh",
":",
"new",
"(",
"messageHeader",
")",
",",
"sh",
":",
"new",
"(",
"segmentHeader",
")",
",",
"ph",
":",
"new",
"(",
"partHeader",
")",
",",
"scramsha256InitialRequest",
":",
"new",
"(",
"scramsha256InitialRequest",
")",
",",
"scramsha256InitialReply",
":",
"new",
"(",
"scramsha256InitialReply",
")",
",",
"scramsha256FinalRequest",
":",
"new",
"(",
"scramsha256FinalRequest",
")",
",",
"scramsha256FinalReply",
":",
"new",
"(",
"scramsha256FinalReply",
")",
",",
"topologyInformation",
":",
"newTopologyInformation",
"(",
")",
",",
"connectOptions",
":",
"newConnectOptions",
"(",
")",
",",
"rowsAffected",
":",
"new",
"(",
"rowsAffected",
")",
",",
"statementID",
":",
"new",
"(",
"statementID",
")",
",",
"resultMetadata",
":",
"new",
"(",
"resultMetadata",
")",
",",
"resultsetID",
":",
"new",
"(",
"resultsetID",
")",
",",
"resultset",
":",
"new",
"(",
"resultset",
")",
",",
"parameterMetadata",
":",
"new",
"(",
"parameterMetadata",
")",
",",
"outputParameters",
":",
"new",
"(",
"outputParameters",
")",
",",
"writeLobRequest",
":",
"new",
"(",
"writeLobRequest",
")",
",",
"readLobRequest",
":",
"new",
"(",
"readLobRequest",
")",
",",
"writeLobReply",
":",
"new",
"(",
"writeLobReply",
")",
",",
"readLobReply",
":",
"new",
"(",
"readLobReply",
")",
",",
"stmtCtx",
":",
"newStatementContext",
"(",
")",
",",
"txFlags",
":",
"newTransactionFlags",
"(",
")",
",",
"lastError",
":",
"new",
"(",
"hdbErrors",
")",
",",
"}",
"\n\n",
"if",
"err",
"=",
"s",
".",
"init",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] |
1,312 | all-1313 | [
"Uptime",
"returns",
"the",
"uptime",
"of",
"the",
"bot"
] | [
"func",
"(",
"<mask>",
"*",
"Bot",
")",
"Uptime",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"bot",
".",
"started",
",",
"time",
".",
"Since",
"(",
"bot",
".",
"started",
")",
")",
"\n",
"}"
] |
1,313 | all-1314 | [
"copyWithoutSnapshotsFull",
"creates",
"a",
"sparse",
"copy",
"of",
"a",
"container",
"This",
"introduces",
"a",
"dependency",
"relation",
"between",
"the",
"source",
"RBD",
"storage",
"volume",
"and",
"the",
"target",
"RBD",
"storage",
"volume",
"."
] | [
"func",
"(",
"s",
"*",
"storageCeph",
")",
"copyWithoutSnapshotsSparse",
"(",
"<mask>",
"container",
",",
"source",
"container",
")",
"error",
"{",
"logger",
".",
"Debugf",
"(",
"`Creating sparse copy of RBD storage volume for container \"%s\" to \"%s\" without snapshots`",
",",
"source",
".",
"Name",
"(",
")",
",",
"target",
".",
"Name",
"(",
")",
")",
"\n\n",
"sourceIsSnapshot",
":=",
"source",
".",
"IsSnapshot",
"(",
")",
"\n",
"sourceContainerName",
":=",
"projectPrefix",
"(",
"source",
".",
"Project",
"(",
")",
",",
"source",
".",
"Name",
"(",
")",
")",
"\n",
"targetContainerName",
":=",
"projectPrefix",
"(",
"target",
".",
"Project",
"(",
")",
",",
"target",
".",
"Name",
"(",
")",
")",
"\n",
"sourceContainerOnlyName",
":=",
"sourceContainerName",
"\n",
"sourceSnapshotOnlyName",
":=",
"\"",
"\"",
"\n",
"snapshotName",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"uuid",
".",
"NewRandom",
"(",
")",
".",
"String",
"(",
")",
")",
"\n",
"if",
"sourceIsSnapshot",
"{",
"sourceContainerOnlyName",
",",
"sourceSnapshotOnlyName",
",",
"_",
"=",
"containerGetParentAndSnapshotName",
"(",
"sourceContainerName",
")",
"\n",
"snapshotName",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sourceSnapshotOnlyName",
")",
"\n",
"}",
"else",
"{",
"// create snapshot",
"err",
":=",
"cephRBDSnapshotCreate",
"(",
"s",
".",
"ClusterName",
",",
"s",
".",
"OSDPoolName",
",",
"sourceContainerName",
",",
"storagePoolVolumeTypeNameContainer",
",",
"snapshotName",
",",
"s",
".",
"UserName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Errorf",
"(",
"`Failed to create snapshot for RBD storage volume for image \"%s\" on storage pool \"%s\": %s`",
",",
"targetContainerName",
",",
"s",
".",
"pool",
".",
"Name",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// protect volume so we can create clones of it",
"err",
":=",
"cephRBDSnapshotProtect",
"(",
"s",
".",
"ClusterName",
",",
"s",
".",
"OSDPoolName",
",",
"sourceContainerOnlyName",
",",
"storagePoolVolumeTypeNameContainer",
",",
"snapshotName",
",",
"s",
".",
"UserName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Errorf",
"(",
"`Failed to protect snapshot for RBD storage volume for image \"%s\" on storage pool \"%s\": %s`",
",",
"snapshotName",
",",
"s",
".",
"pool",
".",
"Name",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"cephRBDCloneCreate",
"(",
"s",
".",
"ClusterName",
",",
"s",
".",
"OSDPoolName",
",",
"sourceContainerOnlyName",
",",
"storagePoolVolumeTypeNameContainer",
",",
"snapshotName",
",",
"s",
".",
"OSDPoolName",
",",
"targetContainerName",
",",
"storagePoolVolumeTypeNameContainer",
",",
"s",
".",
"UserName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Errorf",
"(",
"`Failed to clone new RBD storage volume for container \"%s\": %s`",
",",
"targetContainerName",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"// Re-generate the UUID",
"err",
"=",
"s",
".",
"cephRBDGenerateUUID",
"(",
"projectPrefix",
"(",
"target",
".",
"Project",
"(",
")",
",",
"target",
".",
"Name",
"(",
")",
")",
",",
"storagePoolVolumeTypeNameContainer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Create mountpoint",
"targetContainerMountPoint",
":=",
"getContainerMountPoint",
"(",
"target",
".",
"Project",
"(",
")",
",",
"s",
".",
"pool",
".",
"Name",
",",
"target",
".",
"Name",
"(",
")",
")",
"\n",
"err",
"=",
"createContainerMountpoint",
"(",
"targetContainerMountPoint",
",",
"target",
".",
"Path",
"(",
")",
",",
"target",
".",
"IsPrivileged",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"ourMount",
",",
"err",
":=",
"target",
".",
"StorageStart",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"ourMount",
"{",
"defer",
"target",
".",
"StorageStop",
"(",
")",
"\n",
"}",
"\n\n",
"err",
"=",
"target",
".",
"TemplateApply",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Errorf",
"(",
"`Failed to apply copy template for container \"%s\": %s`",
",",
"target",
".",
"Name",
"(",
")",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"logger",
".",
"Debugf",
"(",
"`Applied copy template for container \"%s\"`",
",",
"target",
".",
"Name",
"(",
")",
")",
"\n\n",
"logger",
".",
"Debugf",
"(",
"`Created sparse copy of RBD storage volume for container \"%s\" to \"%s\" without snapshots`",
",",
"source",
".",
"Name",
"(",
")",
",",
"target",
".",
"Name",
"(",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
1,314 | all-1315 | [
"MapWithOverwrite",
"will",
"do",
"the",
"same",
"as",
"Map",
"except",
"that",
"non",
"-",
"empty",
"dst",
"attributes",
"will",
"be",
"overridden",
"by",
"non",
"-",
"empty",
"src",
"attribute",
"values",
".",
"Deprecated",
":",
"Use",
"Map",
"(",
"…",
")",
"with",
"WithOverride"
] | [
"func",
"MapWithOverwrite",
"(",
"dst",
",",
"src",
"interface",
"{",
"}",
",",
"opts",
"...",
"func",
"(",
"*",
"Config",
")",
")",
"error",
"{",
"return",
"_map",
"(",
"dst",
",",
"src",
",",
"<mask>",
"(",
"opts",
",",
"WithOverride",
")",
"...",
")",
"\n",
"}"
] |
1,315 | all-1316 | [
"/",
"1",
".",
"0",
"/",
"storage",
"-",
"pools",
"/",
"{",
"name",
"}",
"/",
"volumes",
"List",
"all",
"storage",
"volumes",
"attached",
"to",
"a",
"given",
"storage",
"pool",
"."
] | [
"func",
"storagePoolVolumesGet",
"(",
"d",
"*",
"Daemon",
",",
"r",
"*",
"http",
".",
"Request",
")",
"Response",
"{",
"project",
":=",
"projectParam",
"(",
"r",
")",
"\n",
"poolName",
":=",
"mux",
".",
"Vars",
"(",
"r",
")",
"[",
"\"",
"\"",
"]",
"\n\n",
"recursion",
":=",
"util",
".",
"IsRecursionRequest",
"(",
"r",
")",
"\n\n",
"// Retrieve ID of the storage pool (and check if the storage pool",
"// exists).",
"poolID",
",",
"err",
":=",
"d",
".",
"cluster",
".",
"StoragePoolGetID",
"(",
"poolName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SmartError",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"// Get all volumes currently attached to the storage pool by ID of the",
"// pool and project.",
"//",
"// We exclude volumes of type image, since those are special: they are",
"// stored using the storage_volumes table, but are effectively a cache",
"// which is not tied to projects, so we always link the to the default",
"// project. This means that we want to filter image volumes and return",
"// only the ones that have fingerprints matching images actually in use",
"// by the project.",
"volumes",
",",
"err",
":=",
"d",
".",
"cluster",
".",
"StoragePoolVolumesGet",
"(",
"project",
",",
"poolID",
",",
"supportedVolumeTypesExceptImages",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"<mask>",
".",
"ErrNoSuchObject",
"{",
"return",
"SmartError",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"imageVolumes",
",",
"err",
":=",
"d",
".",
"cluster",
".",
"StoragePoolVolumesGet",
"(",
"\"",
"\"",
",",
"poolID",
",",
"[",
"]",
"int",
"{",
"storagePoolVolumeTypeImage",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"db",
".",
"ErrNoSuchObject",
"{",
"return",
"SmartError",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"projectImages",
",",
"err",
":=",
"d",
".",
"cluster",
".",
"ImagesGet",
"(",
"project",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SmartError",
"(",
"err",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"volume",
":=",
"range",
"imageVolumes",
"{",
"if",
"shared",
".",
"StringInSlice",
"(",
"volume",
".",
"Name",
",",
"projectImages",
")",
"{",
"volumes",
"=",
"append",
"(",
"volumes",
",",
"volume",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"resultString",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"volume",
":=",
"range",
"volumes",
"{",
"apiEndpoint",
",",
"err",
":=",
"storagePoolVolumeTypeNameToAPIEndpoint",
"(",
"volume",
".",
"Type",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"InternalError",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"apiEndpoint",
"==",
"storagePoolVolumeAPIEndpointContainers",
"{",
"apiEndpoint",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"if",
"apiEndpoint",
"==",
"storagePoolVolumeAPIEndpointImages",
"{",
"apiEndpoint",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"if",
"!",
"recursion",
"{",
"volName",
",",
"snapName",
",",
"ok",
":=",
"containerGetParentAndSnapshotName",
"(",
"volume",
".",
"Name",
")",
"\n",
"if",
"ok",
"{",
"resultString",
"=",
"append",
"(",
"resultString",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"version",
".",
"APIVersion",
",",
"poolName",
",",
"apiEndpoint",
",",
"volName",
",",
"snapName",
")",
")",
"\n",
"}",
"else",
"{",
"resultString",
"=",
"append",
"(",
"resultString",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"version",
".",
"APIVersion",
",",
"poolName",
",",
"apiEndpoint",
",",
"volume",
".",
"Name",
")",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"volumeUsedBy",
",",
"err",
":=",
"storagePoolVolumeUsedByGet",
"(",
"d",
".",
"State",
"(",
")",
",",
"project",
",",
"volume",
".",
"Name",
",",
"volume",
".",
"Type",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"InternalError",
"(",
"err",
")",
"\n",
"}",
"\n",
"volume",
".",
"UsedBy",
"=",
"volumeUsedBy",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"!",
"recursion",
"{",
"return",
"SyncResponse",
"(",
"true",
",",
"resultString",
")",
"\n",
"}",
"\n\n",
"return",
"SyncResponse",
"(",
"true",
",",
"volumes",
")",
"\n",
"}"
] |
1,316 | all-1317 | [
"StripSlashes",
"is",
"a",
"middleware",
"that",
"will",
"match",
"request",
"paths",
"with",
"a",
"trailing",
"slash",
"strip",
"it",
"from",
"the",
"path",
"and",
"continue",
"routing",
"through",
"the",
"mux",
"if",
"a",
"route",
"matches",
"then",
"it",
"will",
"serve",
"the",
"handler",
"."
] | [
"func",
"StripSlashes",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"fn",
":=",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"var",
"path",
"string",
"\n",
"rctx",
":=",
"chi",
".",
"RouteContext",
"(",
"r",
".",
"Context",
"(",
")",
")",
"\n",
"if",
"rctx",
".",
"RoutePath",
"!=",
"\"",
"\"",
"{",
"<mask>",
"=",
"rctx",
".",
"RoutePath",
"\n",
"}",
"else",
"{",
"path",
"=",
"r",
".",
"URL",
".",
"Path",
"\n",
"}",
"\n",
"if",
"len",
"(",
"path",
")",
">",
"1",
"&&",
"path",
"[",
"len",
"(",
"path",
")",
"-",
"1",
"]",
"==",
"'/'",
"{",
"rctx",
".",
"RoutePath",
"=",
"path",
"[",
":",
"len",
"(",
"path",
")",
"-",
"1",
"]",
"\n",
"}",
"\n",
"next",
".",
"ServeHTTP",
"(",
"w",
",",
"r",
")",
"\n",
"}",
"\n",
"return",
"http",
".",
"HandlerFunc",
"(",
"fn",
")",
"\n",
"}"
] |
1,317 | all-1318 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"GetPlatformFontsForNodeParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"<mask>",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss38",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
1,318 | all-1319 | [
"flattenSrcs",
"transforms",
"srcs",
"attributes",
"structured",
"as",
"concatenations",
"of",
"lists",
"and",
"selects",
"(",
"generated",
"from",
"PlatformStrings",
";",
"see",
"extractPlatformStringsExprs",
"for",
"matching",
"details",
")",
"into",
"a",
"sorted",
"de",
"-",
"duplicated",
"list",
".",
"Comments",
"are",
"accumulated",
"and",
"de",
"-",
"duplicated",
"across",
"duplicate",
"expressions",
"."
] | [
"func",
"flattenSrcs",
"(",
"c",
"*",
"config",
".",
"Config",
",",
"f",
"*",
"rule",
".",
"File",
")",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"f",
".",
"Rules",
"{",
"if",
"!",
"isGoRule",
"(",
"r",
".",
"Kind",
"(",
")",
")",
"{",
"continue",
"\n",
"}",
"\n",
"oldSrcs",
":=",
"r",
".",
"Attr",
"(",
"\"",
"\"",
")",
"\n",
"if",
"oldSrcs",
"==",
"nil",
"{",
"<mask>",
"\n",
"}",
"\n",
"flatSrcs",
":=",
"rule",
".",
"FlattenExpr",
"(",
"oldSrcs",
")",
"\n",
"if",
"flatSrcs",
"!=",
"oldSrcs",
"{",
"r",
".",
"SetAttr",
"(",
"\"",
"\"",
",",
"flatSrcs",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
1,319 | all-1320 | [
"GetEndIter",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_text_buffer_get_end_iter",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"TextBuffer",
")",
"GetEndIter",
"(",
")",
"*",
"TextIter",
"{",
"<mask>",
"iter",
"C",
".",
"GtkTextIter",
"\n",
"C",
".",
"gtk_text_buffer_get_end_iter",
"(",
"v",
".",
"native",
"(",
")",
",",
"&",
"iter",
")",
"\n",
"return",
"(",
"*",
"TextIter",
")",
"(",
"&",
"iter",
")",
"\n",
"}"
] |
1,320 | all-1321 | [
"newImageSource",
"returns",
"an",
"ImageSource",
"for",
"reading",
"from",
"an",
"existing",
"directory",
"."
] | [
"func",
"newImageSource",
"(",
"tmpDir",
"string",
",",
"<mask>",
"ostreeReference",
")",
"(",
"types",
".",
"ImageSource",
",",
"error",
")",
"{",
"return",
"&",
"ostreeImageSource",
"{",
"ref",
":",
"ref",
",",
"tmpDir",
":",
"tmpDir",
",",
"compressed",
":",
"nil",
"}",
",",
"nil",
"\n",
"}"
] |
1,321 | all-1322 | [
"InMemoryWithLogging",
"injects",
"logging",
"when",
"ApplyChanges",
"is",
"called"
] | [
"func",
"InMemoryWithLogging",
"(",
")",
"InMemoryOption",
"{",
"return",
"func",
"(",
"p",
"*",
"InMemoryProvider",
")",
"{",
"p",
".",
"OnApplyChanges",
"=",
"func",
"(",
"<mask>",
"*",
"plan",
".",
"Changes",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"changes",
".",
"Create",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"changes",
".",
"UpdateOld",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"changes",
".",
"UpdateNew",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"changes",
".",
"Delete",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
1,322 | all-1323 | [
"GetNewBaseFee",
"retrieves",
"the",
"NewBaseFee",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | [
"func",
"(",
"u",
"LedgerUpgrade",
")",
"GetNewBaseFee",
"(",
")",
"(",
"result",
"Uint32",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n\n",
"if",
"armName",
"==",
"\"",
"\"",
"{",
"<mask>",
"=",
"*",
"u",
".",
"NewBaseFee",
"\n",
"ok",
"=",
"true",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] |
1,323 | all-1324 | [
"DFS",
"does",
"depth",
"-",
"first",
"search",
"and",
"returns",
"the",
"list",
"of",
"vertices",
".",
"(",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Depth",
"-",
"first_search",
")",
"0",
".",
"DFS",
"(",
"G",
"v",
")",
":",
"1",
".",
"2",
".",
"let",
"S",
"be",
"a",
"stack",
"3",
".",
"S",
".",
"push",
"(",
"v",
")",
"4",
".",
"5",
".",
"while",
"S",
"is",
"not",
"empty",
":",
"6",
".",
"7",
".",
"u",
"=",
"S",
".",
"pop",
"()",
"8",
".",
"9",
".",
"if",
"u",
"is",
"not",
"visited",
"yet",
":",
"10",
".",
"11",
".",
"label",
"u",
"as",
"visited",
"12",
".",
"13",
".",
"for",
"each",
"vertex",
"w",
"adjacent",
"to",
"u",
":",
"14",
".",
"15",
".",
"if",
"w",
"is",
"not",
"visited",
"yet",
":",
"16",
".",
"S",
".",
"push",
"(",
"w",
")"
] | [
"func",
"DFS",
"(",
"g",
"Graph",
",",
"id",
"ID",
")",
"[",
"]",
"ID",
"{",
"if",
"_",
",",
"err",
":=",
"g",
".",
"GetNode",
"(",
"id",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"s",
":=",
"[",
"]",
"ID",
"{",
"id",
"}",
"\n",
"visited",
":=",
"make",
"(",
"map",
"[",
"ID",
"]",
"bool",
")",
"\n",
"rs",
":=",
"[",
"]",
"ID",
"{",
"}",
"\n\n",
"// while S is not empty:",
"for",
"len",
"(",
"s",
")",
"!=",
"0",
"{",
"u",
":=",
"s",
"[",
"len",
"(",
"s",
")",
"-",
"1",
"]",
"\n",
"s",
"=",
"s",
"[",
":",
"len",
"(",
"s",
")",
"-",
"1",
":",
"len",
"(",
"s",
")",
"-",
"1",
"]",
"\n\n",
"// if u is not visited yet:",
"if",
"_",
",",
"ok",
":=",
"visited",
"[",
"u",
"]",
";",
"!",
"ok",
"{",
"// label u as visited",
"visited",
"[",
"u",
"]",
"=",
"true",
"\n\n",
"rs",
"=",
"append",
"(",
"rs",
",",
"u",
")",
"\n\n",
"// for each vertex w adjacent to u:",
"cmap",
",",
"_",
":=",
"g",
".",
"GetTargets",
"(",
"u",
")",
"\n",
"for",
"_",
",",
"w",
":=",
"range",
"cmap",
"{",
"// if w is not visited yet:",
"if",
"_",
",",
"ok",
":=",
"visited",
"[",
"w",
".",
"ID",
"(",
")",
"]",
";",
"!",
"ok",
"{",
"s",
"=",
"append",
"(",
"s",
",",
"w",
".",
"ID",
"(",
")",
")",
"// S.push(w)",
"\n",
"}",
"\n",
"}",
"\n",
"pmap",
",",
"_",
":=",
"g",
".",
"GetSources",
"(",
"u",
")",
"\n",
"for",
"_",
",",
"w",
":=",
"range",
"pmap",
"{",
"// if w is not visited yet:",
"if",
"_",
",",
"ok",
":=",
"visited",
"[",
"w",
".",
"ID",
"(",
")",
"]",
";",
"!",
"ok",
"{",
"s",
"=",
"<mask>",
"(",
"s",
",",
"w",
".",
"ID",
"(",
")",
")",
"// S.push(w)",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"rs",
"\n",
"}"
] |
1,324 | all-1325 | [
"checkDir",
"will",
"check",
"whether",
"the",
"component",
"is",
"a",
"directory",
"under",
"parent",
"node",
".",
"If",
"it",
"is",
"a",
"directory",
"this",
"function",
"will",
"return",
"the",
"pointer",
"to",
"that",
"node",
".",
"If",
"it",
"does",
"not",
"exist",
"this",
"function",
"will",
"create",
"a",
"new",
"directory",
"and",
"return",
"the",
"pointer",
"to",
"that",
"node",
".",
"If",
"it",
"is",
"a",
"file",
"this",
"function",
"will",
"return",
"error",
"."
] | [
"func",
"(",
"s",
"*",
"store",
")",
"checkDir",
"(",
"parent",
"*",
"node",
",",
"dirName",
"string",
")",
"(",
"*",
"node",
",",
"*",
"v2error",
".",
"Error",
")",
"{",
"node",
",",
"ok",
":=",
"parent",
".",
"Children",
"[",
"dirName",
"]",
"\n\n",
"if",
"ok",
"{",
"if",
"node",
".",
"IsDir",
"(",
")",
"{",
"return",
"node",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"v2error",
".",
"NewError",
"(",
"v2error",
".",
"EcodeNotDir",
",",
"node",
".",
"Path",
",",
"s",
".",
"CurrentIndex",
")",
"\n",
"}",
"\n\n",
"n",
":=",
"newDir",
"(",
"s",
",",
"path",
".",
"Join",
"(",
"<mask>",
".",
"Path",
",",
"dirName",
")",
",",
"s",
".",
"CurrentIndex",
"+",
"1",
",",
"parent",
",",
"Permanent",
")",
"\n\n",
"parent",
".",
"Children",
"[",
"dirName",
"]",
"=",
"n",
"\n\n",
"return",
"n",
",",
"nil",
"\n",
"}"
] |
1,325 | all-1326 | [
"The",
"caller",
"MUST",
"NOT",
"hold",
"s",
".",
"Lock"
] | [
"func",
"(",
"s",
"*",
"MockSpan",
")",
"logFieldsWithTimestamp",
"(",
"ts",
"time",
".",
"Time",
",",
"fields",
"...",
"log",
".",
"Field",
")",
"{",
"lr",
":=",
"MockLogRecord",
"{",
"Timestamp",
":",
"ts",
",",
"Fields",
":",
"<mask>",
"(",
"[",
"]",
"MockKeyValue",
",",
"len",
"(",
"fields",
")",
")",
",",
"}",
"\n",
"for",
"i",
",",
"f",
":=",
"range",
"fields",
"{",
"outField",
":=",
"&",
"(",
"lr",
".",
"Fields",
"[",
"i",
"]",
")",
"\n",
"f",
".",
"Marshal",
"(",
"outField",
")",
"\n",
"}",
"\n\n",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"logs",
"=",
"append",
"(",
"s",
".",
"logs",
",",
"lr",
")",
"\n",
"}"
] |
1,326 | all-1327 | [
"MoveTo",
"is",
"a",
"wrapper",
"around",
"cairo_move_to",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"MoveTo",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"C",
".",
"cairo_move_to",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"double",
"(",
"x",
")",
",",
"C",
".",
"double",
"(",
"y",
")",
")",
"\n",
"}"
] |
1,327 | all-1328 | [
"DialTo",
"makes",
"a",
"(",
"un",
"-",
"secure",
")",
"TELNET",
"client",
"connection",
"to",
"the",
"the",
"address",
"specified",
"by",
"addr",
".",
"If",
"a",
"secure",
"connection",
"is",
"desired",
"use",
"DialToTLS",
"instead",
"."
] | [
"func",
"DialTo",
"(",
"addr",
"string",
")",
"(",
"*",
"Conn",
",",
"error",
")",
"{",
"const",
"network",
"=",
"\"",
"\"",
"\n\n",
"if",
"\"",
"\"",
"==",
"addr",
"{",
"addr",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"conn",
",",
"err",
":=",
"net",
".",
"Dial",
"(",
"network",
",",
"addr",
")",
"\n",
"if",
"nil",
"!=",
"err",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"dataReader",
":=",
"newDataReader",
"(",
"conn",
")",
"\n",
"dataWriter",
":=",
"newDataWriter",
"(",
"conn",
")",
"\n\n",
"clientConn",
":=",
"Conn",
"{",
"<mask>",
":",
"conn",
",",
"dataReader",
":",
"dataReader",
",",
"dataWriter",
":",
"dataWriter",
",",
"}",
"\n\n",
"return",
"&",
"clientConn",
",",
"nil",
"\n",
"}"
] |
1,328 | all-1329 | [
"Int",
"defines",
"an",
"int",
"flag",
"with",
"specified",
"name",
"default",
"value",
"and",
"usage",
"string",
".",
"The",
"return",
"value",
"is",
"the",
"address",
"of",
"an",
"int",
"variable",
"that",
"stores",
"the",
"value",
"of",
"the",
"flag",
"."
] | [
"func",
"Int",
"(",
"name",
"string",
",",
"value",
"int",
",",
"usage",
"string",
")",
"*",
"int",
"{",
"return",
"EnvironmentFlags",
".",
"Int",
"(",
"name",
",",
"value",
",",
"<mask>",
")",
"\n",
"}"
] |
1,329 | all-1330 | [
"NewAccountMergeResult",
"creates",
"a",
"new",
"AccountMergeResult",
"."
] | [
"func",
"NewAccountMergeResult",
"(",
"code",
"AccountMergeResultCode",
",",
"value",
"interface",
"{",
"}",
")",
"(",
"result",
"AccountMergeResult",
",",
"err",
"error",
")",
"{",
"<mask>",
".",
"Code",
"=",
"code",
"\n",
"switch",
"AccountMergeResultCode",
"(",
"code",
")",
"{",
"case",
"AccountMergeResultCodeAccountMergeSuccess",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"Int64",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"SourceAccountBalance",
"=",
"&",
"tv",
"\n",
"default",
":",
"// void",
"}",
"\n",
"return",
"\n",
"}"
] |
1,330 | all-1331 | [
"returns",
"the",
"plural",
"form",
"of",
"a",
"singular",
"word"
] | [
"func",
"(",
"rs",
"*",
"Ruleset",
")",
"Pluralize",
"(",
"word",
"string",
")",
"string",
"{",
"if",
"len",
"(",
"word",
")",
"==",
"0",
"{",
"return",
"word",
"\n",
"}",
"\n",
"if",
"rs",
".",
"isUncountable",
"(",
"word",
")",
"{",
"return",
"word",
"\n",
"}",
"\n",
"for",
"_",
",",
"rule",
":=",
"range",
"rs",
".",
"plurals",
"{",
"if",
"rule",
".",
"exact",
"{",
"if",
"word",
"==",
"rule",
".",
"suffix",
"{",
"return",
"rule",
".",
"replacement",
"\n",
"}",
"\n",
"}",
"else",
"{",
"if",
"strings",
".",
"HasSuffix",
"(",
"word",
",",
"rule",
".",
"suffix",
")",
"{",
"return",
"replaceLast",
"(",
"word",
",",
"<mask>",
".",
"suffix",
",",
"rule",
".",
"replacement",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"word",
"+",
"\"",
"\"",
"\n",
"}"
] |
1,331 | all-1332 | [
"Logger",
"returns",
"a",
"middleware",
"handler",
"that",
"logs",
"the",
"request",
"as",
"it",
"goes",
"in",
"and",
"the",
"response",
"as",
"it",
"goes",
"out",
"."
] | [
"func",
"Logger",
"(",
")",
"Handler",
"{",
"return",
"func",
"(",
"ctx",
"*",
"Context",
",",
"log",
"*",
"log",
".",
"Logger",
")",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"time",
".",
"Now",
"(",
")",
".",
"Format",
"(",
"LogTimeFormat",
")",
",",
"ctx",
".",
"Req",
".",
"Method",
",",
"ctx",
".",
"Req",
".",
"RequestURI",
",",
"ctx",
".",
"RemoteAddr",
"(",
")",
")",
"\n\n",
"rw",
":=",
"ctx",
".",
"Resp",
".",
"(",
"ResponseWriter",
")",
"\n",
"ctx",
".",
"Next",
"(",
")",
"\n\n",
"content",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"time",
".",
"Now",
"(",
")",
".",
"Format",
"(",
"LogTimeFormat",
")",
",",
"ctx",
".",
"Req",
".",
"Method",
",",
"ctx",
".",
"Req",
".",
"RequestURI",
",",
"rw",
".",
"Status",
"(",
")",
",",
"http",
".",
"StatusText",
"(",
"rw",
".",
"Status",
"(",
")",
")",
",",
"time",
".",
"Since",
"(",
"start",
")",
")",
"\n",
"if",
"ColorLog",
"{",
"switch",
"rw",
".",
"Status",
"(",
")",
"{",
"case",
"200",
",",
"201",
",",
"202",
":",
"content",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\033",
"\\033",
"\"",
",",
"content",
")",
"\n",
"case",
"301",
",",
"302",
":",
"content",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\033",
"\\033",
"\"",
",",
"<mask>",
")",
"\n",
"case",
"304",
":",
"content",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\033",
"\\033",
"\"",
",",
"content",
")",
"\n",
"case",
"401",
",",
"403",
":",
"content",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\033",
"\\033",
"\"",
",",
"content",
")",
"\n",
"case",
"404",
":",
"content",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\033",
"\\033",
"\"",
",",
"content",
")",
"\n",
"case",
"500",
":",
"content",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\033",
"\\033",
"\"",
",",
"content",
")",
"\n",
"}",
"\n",
"}",
"\n",
"log",
".",
"Println",
"(",
"content",
")",
"\n",
"}",
"\n",
"}"
] |
1,332 | all-1333 | [
"GetCursorLocations",
"is",
"a",
"wrapper",
"around",
"gtk_text_view_get_cursor_locations",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"TextView",
")",
"GetCursorLocations",
"(",
"iter",
"*",
"TextIter",
")",
"(",
"strong",
",",
"weak",
"*",
"gdk",
".",
"Rectangle",
")",
"{",
"<mask>",
"strongRect",
",",
"weakRect",
"C",
".",
"GdkRectangle",
"\n",
"C",
".",
"gtk_text_view_get_cursor_locations",
"(",
"v",
".",
"native",
"(",
")",
",",
"iter",
".",
"native",
"(",
")",
",",
"&",
"strongRect",
",",
"&",
"weakRect",
")",
"\n",
"return",
"gdk",
".",
"WrapRectangle",
"(",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"strongRect",
")",
")",
")",
",",
"gdk",
".",
"WrapRectangle",
"(",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"weakRect",
")",
")",
")",
"\n",
"}"
] |
1,333 | all-1334 | [
"GetResourceOk",
"returns",
"a",
"tuple",
"with",
"the",
"Resource",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"d",
"*",
"DashboardLite",
")",
"GetResourceOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"d",
"==",
"nil",
"||",
"d",
".",
"<mask>",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"d",
".",
"Resource",
",",
"true",
"\n",
"}"
] |
1,334 | all-1335 | [
"newCookieSigner",
"returns",
"a",
"cookie",
"signer",
"that",
"uses",
"the",
"given",
"builder",
"to",
"build",
"login",
"requests",
"."
] | [
"func",
"newCookieSigner",
"(",
"builder",
"loginRequestBuilder",
",",
"accountID",
"int",
")",
"Authenticator",
"{",
"return",
"&",
"cookieSigner",
"{",
"builder",
":",
"builder",
",",
"accountID",
":",
"accountID",
",",
"refreshAt",
":",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"-",
"2",
"*",
"<mask>",
".",
"Minute",
")",
",",
"client",
":",
"httpclient",
".",
"NewNoRedirect",
"(",
")",
",",
"}",
"\n",
"}"
] |
1,335 | all-1336 | [
"UTF8String",
"parseUTF8String",
"parses",
"a",
"ASN",
".",
"1",
"UTF8String",
"(",
"raw",
"UTF",
"-",
"8",
")",
"from",
"the",
"given",
"byte",
"array",
"and",
"returns",
"it",
"."
] | [
"func",
"parseUTF8String",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"ret",
"string",
",",
"err",
"error",
")",
"{",
"if",
"!",
"utf8",
".",
"Valid",
"(",
"bytes",
")",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"string",
"(",
"bytes",
")",
",",
"nil",
"\n",
"}"
] |
1,336 | all-1337 | [
"Return",
"information",
"about",
"the",
"cluster",
"."
] | [
"func",
"clusterGet",
"(",
"d",
"*",
"Daemon",
",",
"r",
"*",
"http",
".",
"Request",
")",
"Response",
"{",
"name",
":=",
"\"",
"\"",
"\n",
"err",
":=",
"d",
".",
"cluster",
".",
"<mask>",
"(",
"func",
"(",
"tx",
"*",
"db",
".",
"ClusterTx",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"name",
",",
"err",
"=",
"tx",
".",
"NodeName",
"(",
")",
"\n",
"return",
"err",
"\n",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SmartError",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"// If the name is set to the hard-coded default node name, then",
"// clustering is not enabled.",
"if",
"name",
"==",
"\"",
"\"",
"{",
"name",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"memberConfig",
",",
"err",
":=",
"clusterGetMemberConfig",
"(",
"d",
".",
"cluster",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SmartError",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"cluster",
":=",
"api",
".",
"Cluster",
"{",
"ServerName",
":",
"name",
",",
"Enabled",
":",
"name",
"!=",
"\"",
"\"",
",",
"MemberConfig",
":",
"memberConfig",
",",
"}",
"\n\n",
"return",
"SyncResponseETag",
"(",
"true",
",",
"cluster",
",",
"cluster",
")",
"\n",
"}"
] |
1,337 | all-1338 | [
"PeekBack",
"returns",
"the",
"element",
"at",
"the",
"back",
"of",
"the",
"queue",
"."
] | [
"func",
"(",
"queue",
"*",
"queue",
")",
"PeekBack",
"(",
")",
"<mask>",
"{",
"}",
"{",
"if",
"queue",
".",
"size",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"queue",
".",
"elements",
"[",
"(",
"queue",
".",
"end",
"-",
"1",
")",
"%",
"int64",
"(",
"queue",
".",
"cap",
")",
"]",
"\n",
"}"
] |
1,338 | all-1339 | [
"expandBaseVmwareDistributedVirtualSwitchVlanSpec",
"reads",
"certain",
"ResourceData",
"keys",
"and",
"returns",
"a",
"BaseVmwareDistributedVirtualSwitchVlanSpec",
"."
] | [
"func",
"expandBaseVmwareDistributedVirtualSwitchVlanSpec",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
")",
"types",
".",
"BaseVmwareDistributedVirtualSwitchVlanSpec",
"{",
"var",
"obj",
"types",
".",
"BaseVmwareDistributedVirtualSwitchVlanSpec",
"\n\n",
"_",
",",
"ide",
":=",
"d",
".",
"GetOkExists",
"(",
"\"",
"\"",
")",
"\n",
"_",
",",
"pvid",
":=",
"d",
".",
"GetOkExists",
"(",
"\"",
"\"",
")",
"\n",
"vteList",
",",
"vteOK",
":=",
"d",
".",
"GetOkExists",
"(",
"\"",
"\"",
")",
"\n",
"vte",
":=",
"vteOK",
"&&",
"len",
"(",
"vteList",
".",
"(",
"*",
"schema",
".",
"Set",
")",
".",
"List",
"(",
")",
")",
">",
"0",
"\n",
"switch",
"{",
"case",
"vte",
":",
"obj",
"=",
"expandVmwareDistributedVirtualSwitchTrunkVlanSpec",
"(",
"d",
")",
"\n",
"<mask>",
"pvid",
":",
"obj",
"=",
"expandVmwareDistributedVirtualSwitchPvlanSpec",
"(",
"d",
")",
"\n",
"case",
"ide",
":",
"obj",
"=",
"expandVmwareDistributedVirtualSwitchVlanIDSpec",
"(",
"d",
")",
"\n",
"}",
"\n\n",
"return",
"obj",
"\n",
"}"
] |
1,339 | all-1340 | [
"StoragePoolNodeJoin",
"adds",
"a",
"new",
"entry",
"in",
"the",
"storage_pools_nodes",
"table",
".",
"It",
"should",
"only",
"be",
"used",
"when",
"a",
"new",
"node",
"joins",
"the",
"cluster",
"when",
"it",
"s",
"safe",
"to",
"assume",
"that",
"the",
"relevant",
"pool",
"has",
"already",
"been",
"created",
"on",
"the",
"joining",
"node",
"and",
"we",
"just",
"need",
"to",
"track",
"it",
"."
] | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"StoragePoolNodeJoin",
"(",
"poolID",
",",
"nodeID",
"int64",
")",
"error",
"{",
"columns",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"\n",
"<mask>",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"poolID",
",",
"nodeID",
"}",
"\n",
"_",
",",
"err",
":=",
"query",
".",
"UpsertObject",
"(",
"c",
".",
"tx",
",",
"\"",
"\"",
",",
"columns",
",",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
1,340 | all-1341 | [
"Update",
"the",
"caller",
"ID",
"with",
"the",
"given",
"data",
".",
"Valid",
"parameters",
"may",
"be",
"found",
"here",
":",
"https",
":",
"//",
"www",
".",
"twilio",
".",
"com",
"/",
"docs",
"/",
"api",
"/",
"rest",
"/",
"outgoing",
"-",
"caller",
"-",
"ids#list"
] | [
"func",
"(",
"o",
"*",
"OutgoingCallerIDService",
")",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"sid",
"string",
",",
"data",
"url",
".",
"Values",
")",
"(",
"*",
"OutgoingCallerID",
",",
"error",
")",
"{",
"id",
":=",
"new",
"(",
"OutgoingCallerID",
")",
"\n",
"err",
":=",
"o",
".",
"client",
".",
"UpdateResource",
"(",
"ctx",
",",
"callerIDPathPart",
",",
"sid",
",",
"<mask>",
",",
"id",
")",
"\n",
"return",
"id",
",",
"err",
"\n",
"}"
] |
1,341 | all-1342 | [
"DependentResourcesValidator",
"counts",
"related",
"documents",
"and",
"returns",
"an",
"error",
"if",
"some",
"get",
"found",
".",
"This",
"callback",
"is",
"meant",
"to",
"protect",
"resources",
"from",
"breaking",
"relations",
"when",
"requested",
"to",
"be",
"deleted",
".",
"Dependent",
"resources",
"are",
"defined",
"by",
"passing",
"pairs",
"of",
"models",
"and",
"fields",
"that",
"reference",
"the",
"current",
"model",
".",
"fire",
".",
"DependentResourcesValidator",
"(",
"map",
"[",
"coal",
".",
"Model",
"]",
"string",
"{",
"&Post",
"{}",
":",
"Author",
"&Comment",
"{}",
":",
"Author",
"}",
")",
"The",
"callback",
"supports",
"models",
"that",
"use",
"the",
"soft",
"delete",
"mechanism",
"."
] | [
"func",
"DependentResourcesValidator",
"(",
"pairs",
"map",
"[",
"coal",
".",
"Model",
"]",
"string",
")",
"*",
"Callback",
"{",
"return",
"C",
"(",
"\"",
"\"",
",",
"Only",
"(",
"Delete",
")",
",",
"func",
"(",
"ctx",
"*",
"Context",
")",
"error",
"{",
"// check all relations",
"for",
"model",
",",
"field",
":=",
"range",
"pairs",
"{",
"// prepare query",
"query",
":=",
"bson",
".",
"M",
"{",
"coal",
".",
"F",
"(",
"<mask>",
",",
"field",
")",
":",
"ctx",
".",
"Model",
".",
"ID",
"(",
")",
"}",
"\n\n",
"// exclude soft deleted documents if supported",
"if",
"sdm",
":=",
"coal",
".",
"L",
"(",
"model",
",",
"\"",
"\"",
",",
"false",
")",
";",
"sdm",
"!=",
"\"",
"\"",
"{",
"query",
"[",
"coal",
".",
"F",
"(",
"model",
",",
"sdm",
")",
"]",
"=",
"nil",
"\n",
"}",
"\n\n",
"// count referencing documents",
"ctx",
".",
"Tracer",
".",
"Push",
"(",
"\"",
"\"",
")",
"\n",
"ctx",
".",
"Tracer",
".",
"Tag",
"(",
"\"",
"\"",
",",
"query",
")",
"\n",
"n",
",",
"err",
":=",
"ctx",
".",
"Store",
".",
"DB",
"(",
")",
".",
"C",
"(",
"coal",
".",
"C",
"(",
"model",
")",
")",
".",
"Find",
"(",
"query",
")",
".",
"Limit",
"(",
"1",
")",
".",
"Count",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"ctx",
".",
"Tracer",
".",
"Pop",
"(",
")",
"\n\n",
"// return err of documents are found",
"if",
"n",
"!=",
"0",
"{",
"return",
"E",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// pass validation",
"return",
"nil",
"\n",
"}",
")",
"\n",
"}"
] |
1,342 | all-1343 | [
"Callback",
"will",
"return",
"a",
"callback",
"that",
"authorizes",
"operations",
"using",
"the",
"strategy",
"."
] | [
"func",
"(",
"s",
"*",
"Strategy",
")",
"Callback",
"(",
")",
"*",
"fire",
".",
"Callback",
"{",
"// enforce defaults",
"if",
"s",
".",
"CollectionAction",
"==",
"nil",
"{",
"s",
".",
"CollectionAction",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"Authorizer",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"ResourceAction",
"==",
"nil",
"{",
"s",
".",
"ResourceAction",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"Authorizer",
")",
"\n",
"}",
"\n\n",
"// construct and return callback",
"return",
"fire",
".",
"C",
"(",
"\"",
"\"",
",",
"fire",
".",
"All",
"(",
")",
",",
"func",
"(",
"ctx",
"*",
"fire",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"switch",
"ctx",
".",
"Operation",
"{",
"case",
"fire",
".",
"List",
":",
"err",
"=",
"s",
".",
"call",
"(",
"ctx",
",",
"s",
".",
"List",
",",
"s",
".",
"Read",
",",
"s",
".",
"All",
")",
"\n",
"case",
"fire",
".",
"Find",
":",
"err",
"=",
"s",
".",
"call",
"(",
"ctx",
",",
"s",
".",
"Find",
",",
"s",
".",
"Read",
",",
"s",
".",
"All",
")",
"\n",
"<mask>",
"fire",
".",
"Create",
":",
"err",
"=",
"s",
".",
"call",
"(",
"ctx",
",",
"s",
".",
"Create",
",",
"s",
".",
"Write",
",",
"s",
".",
"All",
")",
"\n",
"case",
"fire",
".",
"Update",
":",
"err",
"=",
"s",
".",
"call",
"(",
"ctx",
",",
"s",
".",
"Update",
",",
"s",
".",
"Write",
",",
"s",
".",
"All",
")",
"\n",
"case",
"fire",
".",
"Delete",
":",
"err",
"=",
"s",
".",
"call",
"(",
"ctx",
",",
"s",
".",
"Delete",
",",
"s",
".",
"Write",
",",
"s",
".",
"All",
")",
"\n",
"case",
"fire",
".",
"CollectionAction",
":",
"err",
"=",
"s",
".",
"call",
"(",
"ctx",
",",
"s",
".",
"CollectionAction",
"[",
"ctx",
".",
"JSONAPIRequest",
".",
"CollectionAction",
"]",
",",
"s",
".",
"CollectionActions",
",",
"s",
".",
"Actions",
",",
"s",
".",
"All",
")",
"\n",
"case",
"fire",
".",
"ResourceAction",
":",
"err",
"=",
"s",
".",
"call",
"(",
"ctx",
",",
"s",
".",
"ResourceAction",
"[",
"ctx",
".",
"JSONAPIRequest",
".",
"ResourceAction",
"]",
",",
"s",
".",
"ResourceActions",
",",
"s",
".",
"Actions",
",",
"s",
".",
"All",
")",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}",
")",
"\n",
"}"
] |
1,343 | all-1344 | [
"openDBFile",
"opens",
"a",
"file",
"."
] | [
"func",
"openDBFile",
"(",
"filename",
"string",
",",
"<mask>",
"int",
")",
"(",
"*",
"dbfile",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"filename",
",",
"flag",
",",
"0",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"db",
":=",
"&",
"dbfile",
"{",
"file",
":",
"f",
",",
"rd",
":",
"bufio",
".",
"NewReader",
"(",
"f",
")",
"}",
"\n",
"db",
".",
"Lock",
"(",
")",
"\n",
"return",
"db",
",",
"nil",
"\n",
"}"
] |
1,344 | all-1345 | [
"GetUrl",
"returns",
"the",
"Url",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"r",
"*",
"reqGetDashboard",
")",
"GetUrl",
"(",
")",
"string",
"{",
"if",
"r",
"==",
"nil",
"||",
"r",
".",
"Url",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"<mask>",
"*",
"r",
".",
"Url",
"\n",
"}"
] |
1,345 | all-1346 | [
"/",
"*",
"Inializes",
"IplImage",
"header"
] | [
"func",
"(",
"img",
"*",
"IplImage",
")",
"InitHeader",
"(",
"w",
",",
"h",
",",
"<mask>",
",",
"channels",
",",
"origin",
",",
"align",
"int",
")",
"{",
"C",
".",
"cvInitImageHeader",
"(",
"(",
"*",
"C",
".",
"IplImage",
")",
"(",
"img",
")",
",",
"C",
".",
"cvSize",
"(",
"C",
".",
"int",
"(",
"w",
")",
",",
"C",
".",
"int",
"(",
"h",
")",
")",
",",
"C",
".",
"int",
"(",
"depth",
")",
",",
"C",
".",
"int",
"(",
"channels",
")",
",",
"C",
".",
"int",
"(",
"origin",
")",
",",
"C",
".",
"int",
"(",
"align",
")",
",",
")",
"\n",
"}"
] |
1,346 | all-1347 | [
"NewBufPool",
"creates",
"a",
"new",
"BufPool",
"that",
"returns",
"buffers",
"of",
"the",
"given",
"size",
"."
] | [
"func",
"NewBufPool",
"(",
"size",
"int",
")",
"*",
"BufPool",
"{",
"return",
"&",
"BufPool",
"{",
"<mask>",
".",
"Pool",
"{",
"New",
":",
"func",
"(",
")",
"interface",
"{",
"}",
"{",
"return",
"make",
"(",
"[",
"]",
"byte",
",",
"size",
")",
"}",
",",
"}",
"}",
"\n",
"}"
] |
1,347 | all-1348 | [
"RegisterHandler",
"inserts",
"a",
"handler",
"on",
"a",
"list",
"of",
"handlers",
"for",
"version",
"1",
".",
"0"
] | [
"func",
"RegisterHandler",
"(",
"path",
"string",
",",
"method",
"string",
",",
"h",
"<mask>",
".",
"Handler",
")",
"{",
"RegisterHandlerVersion",
"(",
"\"",
"\"",
",",
"path",
",",
"method",
",",
"h",
")",
"\n",
"}"
] |
1,348 | all-1349 | [
"FilterPath",
"returns",
"a",
"new",
"Option",
"where",
"opt",
"is",
"only",
"evaluated",
"if",
"filter",
"f",
"returns",
"true",
"for",
"the",
"current",
"Path",
"in",
"the",
"value",
"tree",
".",
"This",
"filter",
"is",
"called",
"even",
"if",
"a",
"slice",
"element",
"or",
"map",
"entry",
"is",
"missing",
"and",
"provides",
"an",
"opportunity",
"to",
"ignore",
"such",
"cases",
".",
"The",
"filter",
"function",
"must",
"be",
"symmetric",
"such",
"that",
"the",
"filter",
"result",
"is",
"identical",
"regardless",
"of",
"whether",
"the",
"missing",
"value",
"is",
"from",
"x",
"or",
"y",
".",
"The",
"option",
"passed",
"in",
"may",
"be",
"an",
"Ignore",
"Transformer",
"Comparer",
"Options",
"or",
"a",
"previously",
"filtered",
"Option",
"."
] | [
"func",
"FilterPath",
"(",
"f",
"func",
"(",
"Path",
")",
"bool",
",",
"<mask>",
"Option",
")",
"Option",
"{",
"if",
"f",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"opt",
":=",
"normalizeOption",
"(",
"opt",
")",
";",
"opt",
"!=",
"nil",
"{",
"return",
"&",
"pathFilter",
"{",
"fnc",
":",
"f",
",",
"opt",
":",
"opt",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
1,349 | all-1350 | [
"otherFileInfo",
"returns",
"information",
"about",
"a",
"non",
"-",
".",
"go",
"file",
".",
"It",
"will",
"parse",
"part",
"of",
"the",
"file",
"to",
"determine",
"build",
"tags",
".",
"If",
"the",
"file",
"can",
"t",
"be",
"read",
"an",
"error",
"will",
"be",
"logged",
"and",
"partial",
"information",
"will",
"be",
"returned",
"."
] | [
"func",
"otherFileInfo",
"(",
"<mask>",
"string",
")",
"fileInfo",
"{",
"info",
":=",
"fileNameInfo",
"(",
"path",
")",
"\n",
"if",
"info",
".",
"ext",
"==",
"unknownExt",
"{",
"return",
"info",
"\n",
"}",
"\n\n",
"tags",
",",
"err",
":=",
"readTags",
"(",
"info",
".",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"info",
".",
"path",
",",
"err",
")",
"\n",
"return",
"info",
"\n",
"}",
"\n",
"info",
".",
"tags",
"=",
"tags",
"\n",
"return",
"info",
"\n",
"}"
] |
1,350 | all-1351 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"Bounds",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoBrowser21",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
1,351 | all-1352 | [
"GetFocusVisible",
"is",
"a",
"wrapper",
"around",
"gtk_window_get_focus_visible",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Window",
")",
"GetFocusVisible",
"(",
")",
"bool",
"{",
"c",
":=",
"C",
".",
"gtk_window_get_focus_visible",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"<mask>",
"gobool",
"(",
"c",
")",
"\n",
"}"
] |
1,352 | all-1353 | [
"failResult",
"is",
"a",
"small",
"utility",
"function",
"for",
"creating",
"a",
"failed",
"lint",
"result",
"."
] | [
"func",
"failResult",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"*",
"LintResult",
"{",
"return",
"&",
"LintResult",
"{",
"<mask>",
":",
"Error",
",",
"Details",
":",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
",",
"}",
"\n",
"}"
] |
1,353 | all-1354 | [
"void",
"pango_font_description_set_size",
"(",
"PangoFontDescription",
"*",
"desc",
"gint",
"size",
")",
";"
] | [
"func",
"(",
"v",
"*",
"FontDescription",
")",
"SetSize",
"(",
"<mask>",
"int",
")",
"{",
"C",
".",
"pango_font_description_set_size",
"(",
"v",
".",
"native",
"(",
")",
",",
"(",
"C",
".",
"gint",
")",
"(",
"size",
")",
")",
"\n",
"}"
] |
1,354 | all-1355 | [
"SubmitContainerStateChange",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockECSClient",
")",
"SubmitContainerStateChange",
"(",
"arg0",
"api",
".",
"ContainerStateChange",
")",
"error",
"{",
"<mask>",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"error",
")",
"\n",
"return",
"ret0",
"\n",
"}"
] |
1,355 | all-1356 | [
"NextUID",
"returns",
"the",
"next",
"free",
"user",
"id",
"to",
"use",
"."
] | [
"func",
"NextUID",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"db",
",",
"uid",
",",
"err",
":=",
"nextUID",
"(",
"false",
")",
"\n",
"db",
".",
"<mask>",
"(",
")",
"\n",
"return",
"uid",
",",
"err",
"\n",
"}"
] |
1,356 | all-1357 | [
"SetPassword",
"sets",
"the",
"password",
"only",
"on",
"the",
"first",
"call",
".",
"Returns",
"error",
"if",
"password",
"already",
"exists",
"."
] | [
"func",
"(",
"h",
"*",
"<mask>",
")",
"SetPassword",
"(",
"password",
"string",
")",
"error",
"{",
"logger",
":=",
"h",
".",
"logger",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"logger",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"password",
"==",
"\"",
"\"",
"{",
"logger",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
"ErrEmptyPassword",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"h",
".",
"validatePasswordNotSet",
"(",
"logger",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"salt",
":=",
"util",
".",
"NewUUID",
"(",
")",
"\n\n",
"hashed",
",",
"err",
":=",
"hashedPassword",
"(",
"logger",
",",
"password",
",",
"salt",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"tx",
",",
"err",
":=",
"beginTX",
"(",
"logger",
",",
"h",
".",
"db",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"tx",
".",
"Rollback",
"(",
")",
"\n\n",
"if",
"err",
":=",
"insert",
"(",
"logger",
",",
"tx",
".",
"Querier",
",",
"saltSetting",
"(",
"salt",
")",
",",
"passwordHashSetting",
"(",
"hashed",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"commitTX",
"(",
"logger",
",",
"tx",
")",
"\n",
"}"
] |
1,357 | all-1358 | [
"Separator",
"returns",
"the",
"character",
"/",
"s",
"used",
"to",
"separate",
"the",
"key",
"from",
"the",
"value",
".",
"The",
"separator",
"is",
"got",
"in",
"the",
"first",
"call",
"to",
"Scan",
"()",
";",
"if",
"it",
"has",
"not",
"been",
"called",
"this",
"makes",
"it",
"explicitly",
"but",
"panics",
"when",
"there",
"is",
"any",
"error",
"."
] | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"Separator",
"(",
")",
"[",
"]",
"byte",
"{",
"if",
"s",
".",
"separator",
"==",
"nil",
"{",
"if",
"<mask>",
":=",
"s",
".",
"Scan",
"(",
")",
";",
"!",
"found",
"{",
"if",
"err",
":=",
"s",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"_DEF_SEPARATOR",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"s",
".",
"separator",
"\n",
"}"
] |
1,358 | all-1359 | [
"GetSizeFormatOk",
"returns",
"a",
"tuple",
"with",
"the",
"SizeFormat",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"t",
"*",
"TraceServiceDefinition",
")",
"GetSizeFormatOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"t",
"==",
"nil",
"||",
"t",
".",
"SizeFormat",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"t",
".",
"SizeFormat",
",",
"true",
"\n",
"}"
] |
1,359 | all-1360 | [
"Stdout",
"sets",
"the",
"process",
"s",
"standard",
"output",
"."
] | [
"func",
"(",
"g",
"*",
"gitCmd",
")",
"Stdout",
"(",
"stdout",
"<mask>",
".",
"Writer",
")",
"{",
"g",
".",
"Cmd",
".",
"Stdout",
"=",
"stdout",
"\n",
"}"
] |
1,360 | all-1361 | [
"AggregateProfiles",
"takes",
"multiple",
"coverage",
"profiles",
"and",
"produces",
"a",
"new",
"coverage",
"profile",
"that",
"counts",
"the",
"number",
"of",
"profiles",
"that",
"hit",
"a",
"block",
"at",
"least",
"once",
"."
] | [
"func",
"AggregateProfiles",
"(",
"profiles",
"[",
"]",
"[",
"]",
"*",
"cover",
".",
"Profile",
")",
"(",
"[",
"]",
"*",
"cover",
".",
"Profile",
",",
"error",
")",
"{",
"setProfiles",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"*",
"cover",
".",
"Profile",
",",
"0",
",",
"len",
"(",
"profiles",
")",
")",
"\n",
"for",
"_",
",",
"p",
":=",
"<mask>",
"profiles",
"{",
"c",
":=",
"countToBoolean",
"(",
"p",
")",
"\n",
"setProfiles",
"=",
"append",
"(",
"setProfiles",
",",
"c",
")",
"\n",
"}",
"\n",
"aggregateProfiles",
",",
"err",
":=",
"MergeMultipleProfiles",
"(",
"setProfiles",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"aggregateProfiles",
",",
"nil",
"\n",
"}"
] |
1,361 | all-1362 | [
"export",
"PaddingChars"
] | [
"func",
"PaddingChars",
"(",
"<mask>",
"int",
")",
"*",
"C",
".",
"char",
"{",
"// caller must free string",
"return",
"C",
".",
"CString",
"(",
"fileseq",
".",
"PaddingChars",
"(",
"pad",
")",
")",
"\n",
"}"
] |
1,362 | all-1363 | [
"attach",
"a",
"single",
"layer",
"of",
"a",
"texture",
"object",
"as",
"a",
"logical",
"buffer",
"of",
"a",
"framebuffer",
"object"
] | [
"func",
"FramebufferTextureLayer",
"(",
"<mask>",
"uint32",
",",
"attachment",
"uint32",
",",
"texture",
"uint32",
",",
"level",
"int32",
",",
"layer",
"int32",
")",
"{",
"syscall",
".",
"Syscall6",
"(",
"gpFramebufferTextureLayer",
",",
"5",
",",
"uintptr",
"(",
"target",
")",
",",
"uintptr",
"(",
"attachment",
")",
",",
"uintptr",
"(",
"texture",
")",
",",
"uintptr",
"(",
"level",
")",
",",
"uintptr",
"(",
"layer",
")",
",",
"0",
")",
"\n",
"}"
] |
1,363 | all-1364 | [
"getGCSDirsForPR",
"returns",
"a",
"map",
"from",
"bucket",
"names",
"-",
">",
"set",
"of",
"directories",
"containing",
"presubmit",
"data"
] | [
"func",
"getGCSDirsForPR",
"(",
"config",
"*",
"config",
".",
"Config",
",",
"org",
",",
"repo",
"string",
",",
"pr",
"int",
")",
"(",
"map",
"[",
"string",
"]",
"sets",
".",
"String",
",",
"error",
")",
"{",
"toSearch",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"sets",
".",
"String",
")",
"\n",
"fullRepo",
":=",
"org",
"+",
"\"",
"\"",
"+",
"repo",
"\n",
"presubmits",
",",
"ok",
":=",
"config",
".",
"Presubmits",
"[",
"fullRepo",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"toSearch",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fullRepo",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"presubmit",
":=",
"range",
"presubmits",
"{",
"var",
"gcsConfig",
"*",
"v1",
".",
"GCSConfiguration",
"\n",
"if",
"presubmit",
".",
"DecorationConfig",
"!=",
"nil",
"&&",
"presubmit",
".",
"DecorationConfig",
".",
"GCSConfiguration",
"!=",
"nil",
"{",
"gcsConfig",
"=",
"presubmit",
".",
"DecorationConfig",
".",
"GCSConfiguration",
"\n",
"}",
"else",
"{",
"// for undecorated jobs assume the default",
"gcsConfig",
"=",
"config",
".",
"Plank",
".",
"DefaultDecorationConfig",
".",
"GCSConfiguration",
"\n",
"}",
"\n\n",
"gcsPath",
",",
"_",
",",
"_",
":=",
"gcsupload",
".",
"PathsForJob",
"(",
"gcsConfig",
",",
"&",
"downwardapi",
".",
"JobSpec",
"{",
"Type",
":",
"v1",
".",
"PresubmitJob",
",",
"Job",
":",
"presubmit",
".",
"Name",
",",
"Refs",
":",
"&",
"v1",
".",
"Refs",
"{",
"Repo",
":",
"repo",
",",
"Org",
":",
"org",
",",
"Pulls",
":",
"[",
"]",
"v1",
".",
"Pull",
"{",
"{",
"Number",
":",
"pr",
"}",
",",
"}",
",",
"}",
",",
"}",
",",
"\"",
"\"",
")",
"\n",
"gcsPath",
",",
"_",
"=",
"path",
".",
"Split",
"(",
"<mask>",
".",
"Clean",
"(",
"gcsPath",
")",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"toSearch",
"[",
"gcsConfig",
".",
"Bucket",
"]",
";",
"!",
"ok",
"{",
"toSearch",
"[",
"gcsConfig",
".",
"Bucket",
"]",
"=",
"sets",
".",
"String",
"{",
"}",
"\n",
"}",
"\n",
"toSearch",
"[",
"gcsConfig",
".",
"Bucket",
"]",
".",
"Insert",
"(",
"gcsPath",
")",
"\n",
"}",
"\n",
"return",
"toSearch",
",",
"nil",
"\n",
"}"
] |
1,364 | all-1365 | [
"Job",
"writes",
"out",
"the",
"job",
"differences",
"between",
"the",
"specified",
"releases"
] | [
"func",
"(",
"s",
"*",
"DiffCmd",
")",
"Job",
"(",
"job",
"string",
",",
"w",
"io",
".",
"<mask>",
")",
"error",
"{",
"differ",
",",
"err",
":=",
"diff",
".",
"New",
"(",
"s",
".",
"releaseRepo",
",",
"s",
".",
"release1",
",",
"s",
".",
"release2",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"d",
",",
"err",
":=",
"differ",
".",
"DiffJob",
"(",
"job",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"s",
".",
"printDiffResult",
"(",
"w",
",",
"d",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
1,365 | all-1366 | [
"Helper",
"method",
"called",
"by",
"(",
"Start|Finish",
")",
"ReportAndFlushUserAction",
".",
"Like",
"those",
"functions",
"it",
"is",
"used",
"by",
"the",
"pachctl",
"binary",
"and",
"runs",
"on",
"users",
"machines",
"TODO",
"(",
"msteffen",
")",
":",
"Wrap",
"config",
"parsing",
"in",
"a",
"library"
] | [
"func",
"reportAndFlushUserAction",
"(",
"action",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"func",
"(",
")",
"{",
"metricsDone",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"client",
":=",
"newSegmentClient",
"(",
")",
"\n",
"defer",
"client",
".",
"Close",
"(",
")",
"\n",
"cfg",
",",
"err",
":=",
"config",
".",
"Read",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"cfg",
"==",
"nil",
"||",
"cfg",
".",
"UserID",
"==",
"\"",
"\"",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"// metrics errors are non fatal",
"return",
"\n",
"}",
"\n",
"reportUserMetricsToSegment",
"(",
"client",
",",
"cfg",
".",
"UserID",
",",
"\"",
"\"",
",",
"<mask>",
",",
"value",
",",
"\"",
"\"",
")",
"\n",
"close",
"(",
"metricsDone",
")",
"\n",
"}",
"(",
")",
"\n",
"return",
"func",
"(",
")",
"{",
"select",
"{",
"case",
"<-",
"metricsDone",
":",
"return",
"\n",
"case",
"<-",
"time",
".",
"After",
"(",
"time",
".",
"Second",
"*",
"5",
")",
":",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
1,366 | all-1367 | [
"converts",
"domain",
"name",
"to",
"FQDN"
] | [
"func",
"canonicalizeDomainName",
"(",
"d",
"string",
")",
"<mask>",
"{",
"if",
"!",
"strings",
".",
"HasSuffix",
"(",
"d",
",",
"\"",
"\"",
")",
"{",
"d",
"+=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"strings",
".",
"ToLower",
"(",
"d",
")",
"\n",
"}"
] |
1,367 | all-1368 | [
"MergeCommitTemplate",
"returns",
"a",
"struct",
"with",
"Go",
"template",
"string",
"(",
"s",
")",
"or",
"nil"
] | [
"func",
"(",
"t",
"*",
"Tide",
")",
"MergeCommitTemplate",
"(",
"org",
",",
"repo",
"string",
")",
"TideMergeCommitTemplate",
"{",
"name",
":=",
"org",
"+",
"\"",
"\"",
"+",
"repo",
"\n\n",
"v",
",",
"ok",
":=",
"t",
".",
"MergeTemplate",
"[",
"name",
"]",
"\n",
"if",
"!",
"<mask>",
"{",
"return",
"t",
".",
"MergeTemplate",
"[",
"org",
"]",
"\n",
"}",
"\n\n",
"return",
"v",
"\n",
"}"
] |
1,368 | all-1369 | [
"newFragment",
"creates",
"a",
"new",
"fragment",
"for",
"marshaling",
"into"
] | [
"func",
"(",
"w",
"*",
"reqResWriter",
")",
"newFragment",
"(",
"initial",
"bool",
",",
"checksum",
"Checksum",
")",
"(",
"*",
"writableFragment",
",",
"error",
")",
"{",
"if",
"err",
":=",
"w",
".",
"mex",
".",
"checkError",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"w",
".",
"failed",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"message",
":=",
"w",
".",
"messageForFragment",
"(",
"initial",
")",
"\n\n",
"// Create the frame",
"frame",
":=",
"w",
".",
"conn",
".",
"opts",
".",
"FramePool",
".",
"Get",
"(",
")",
"\n",
"frame",
".",
"Header",
".",
"ID",
"=",
"w",
".",
"mex",
".",
"msgID",
"\n",
"frame",
".",
"Header",
".",
"messageType",
"=",
"message",
".",
"messageType",
"(",
")",
"\n\n",
"// Write the message into the fragment, reserving flags and checksum bytes",
"wbuf",
":=",
"typed",
".",
"NewWriteBuffer",
"(",
"frame",
".",
"Payload",
"[",
":",
"]",
")",
"\n",
"fragment",
":=",
"<mask>",
"(",
"writableFragment",
")",
"\n",
"fragment",
".",
"frame",
"=",
"frame",
"\n",
"fragment",
".",
"flagsRef",
"=",
"wbuf",
".",
"DeferByte",
"(",
")",
"\n",
"if",
"err",
":=",
"message",
".",
"write",
"(",
"wbuf",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"wbuf",
".",
"WriteSingleByte",
"(",
"byte",
"(",
"checksum",
".",
"TypeCode",
"(",
")",
")",
")",
"\n",
"fragment",
".",
"checksumRef",
"=",
"wbuf",
".",
"DeferBytes",
"(",
"checksum",
".",
"Size",
"(",
")",
")",
"\n",
"fragment",
".",
"checksum",
"=",
"checksum",
"\n",
"fragment",
".",
"contents",
"=",
"wbuf",
"\n",
"return",
"fragment",
",",
"wbuf",
".",
"Err",
"(",
")",
"\n",
"}"
] |
1,369 | all-1370 | [
"ListCheckoutKeys",
"fetches",
"the",
"checkout",
"keys",
"associated",
"with",
"the",
"given",
"project"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListCheckoutKeys",
"(",
"account",
",",
"repo",
"string",
")",
"(",
"[",
"]",
"*",
"CheckoutKey",
",",
"error",
")",
"{",
"checkoutKeys",
":=",
"[",
"]",
"*",
"CheckoutKey",
"{",
"}",
"\n\n",
"err",
":=",
"c",
".",
"request",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"<mask>",
",",
"repo",
")",
",",
"&",
"checkoutKeys",
",",
"nil",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"checkoutKeys",
",",
"nil",
"\n",
"}"
] |
1,370 | all-1371 | [
"MemoryInUse",
"returns",
"memory",
"used",
"by",
"nodetable",
"instance"
] | [
"func",
"(",
"nt",
"*",
"NodeTable",
")",
"MemoryInUse",
"(",
")",
"int64",
"{",
"<mask>",
"int64",
"(",
"approxItemSize",
"*",
"(",
"nt",
".",
"fastHTCount",
"+",
"nt",
".",
"slowHTCount",
")",
")",
"\n",
"}"
] |
1,371 | all-1372 | [
"title",
":",
"saml",
"callback",
"path",
":",
"/",
"auth",
"/",
"saml",
"method",
":",
"POST",
"responses",
":",
"200",
":",
"Ok",
"400",
":",
"Invalid",
"data"
] | [
"func",
"samlCallbackLogin",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"if",
"app",
".",
"AuthScheme",
".",
"Name",
"(",
")",
"!=",
"\"",
"\"",
"{",
"return",
"&",
"errors",
".",
"HTTP",
"{",
"Code",
":",
"http",
".",
"StatusBadRequest",
",",
"Message",
":",
"\"",
"\"",
",",
"}",
"\n",
"}",
"\n",
"params",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"content",
":=",
"r",
".",
"PostFormValue",
"(",
"\"",
"\"",
")",
"\n",
"if",
"content",
"==",
"\"",
"\"",
"{",
"return",
"&",
"errors",
".",
"HTTP",
"{",
"Code",
":",
"http",
".",
"StatusBadRequest",
",",
"Message",
":",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"params",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
"\n",
"params",
"[",
"\"",
"\"",
"]",
"=",
"content",
"\n",
"//Get saml.SAMLAuthScheme, error already treated on first check",
"scheme",
",",
"_",
":=",
"auth",
".",
"GetScheme",
"(",
"\"",
"\"",
")",
"\n",
"_",
",",
"err",
":=",
"scheme",
".",
"Login",
"(",
"params",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"cmd",
".",
"SamlCallbackFailureMessage",
"(",
")",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"fmt",
".",
"Fprint",
"(",
"w",
",",
"<mask>",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Fprint",
"(",
"w",
",",
"cmd",
".",
"SamlCallbackSuccessMessage",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
1,372 | all-1373 | [
"OperationByUUID",
"returns",
"the",
"operation",
"with",
"the",
"given",
"UUID",
"."
] | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"OperationByUUID",
"(",
"uuid",
"string",
")",
"(",
"Operation",
",",
"error",
")",
"{",
"null",
":=",
"Operation",
"{",
"}",
"\n",
"operations",
",",
"err",
":=",
"c",
".",
"operations",
"(",
"\"",
"\"",
",",
"uuid",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"null",
",",
"err",
"\n",
"}",
"\n",
"switch",
"len",
"(",
"operations",
")",
"{",
"case",
"0",
":",
"return",
"null",
",",
"ErrNoSuchObject",
"\n",
"case",
"1",
":",
"return",
"operations",
"[",
"0",
"]",
",",
"nil",
"\n",
"<mask>",
":",
"return",
"null",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] |
1,373 | all-1374 | [
"WriteError",
"logs",
"and",
"writes",
"the",
"given",
"Error",
"to",
"the",
"ResponseWriter",
"If",
"Error",
"is",
"an",
"etcdErr",
"it",
"is",
"rendered",
"to",
"the",
"ResponseWriter",
"Otherwise",
"it",
"is",
"assumed",
"to",
"be",
"a",
"StatusInternalServerError"
] | [
"func",
"WriteError",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"err",
"error",
")",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"switch",
"e",
":=",
"err",
".",
"(",
"type",
")",
"{",
"case",
"*",
"v2error",
".",
"Error",
":",
"e",
".",
"WriteTo",
"(",
"w",
")",
"\n\n",
"case",
"*",
"httptypes",
".",
"HTTPError",
":",
"if",
"et",
":=",
"e",
".",
"WriteTo",
"(",
"w",
")",
";",
"et",
"!=",
"nil",
"{",
"if",
"lg",
"!=",
"nil",
"{",
"lg",
".",
"Debug",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"r",
".",
"RemoteAddr",
")",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"e",
".",
"Error",
"(",
")",
")",
",",
"zap",
".",
"Error",
"(",
"et",
")",
",",
")",
"\n",
"}",
"else",
"{",
"plog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"et",
",",
"r",
".",
"RemoteAddr",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"default",
":",
"switch",
"err",
"{",
"case",
"etcdserver",
".",
"ErrTimeoutDueToLeaderFail",
",",
"etcdserver",
".",
"ErrTimeoutDueToConnectionLost",
",",
"etcdserver",
".",
"ErrNotEnoughStartedMembers",
",",
"etcdserver",
".",
"ErrUnhealthy",
":",
"if",
"lg",
"!=",
"nil",
"{",
"lg",
".",
"Warn",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"r",
".",
"RemoteAddr",
")",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"err",
".",
"Error",
"(",
")",
")",
",",
")",
"\n",
"}",
"else",
"{",
"mlog",
".",
"MergeError",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"<mask>",
":",
"if",
"lg",
"!=",
"nil",
"{",
"lg",
".",
"Warn",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"r",
".",
"RemoteAddr",
")",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"err",
".",
"Error",
"(",
")",
")",
",",
")",
"\n",
"}",
"else",
"{",
"mlog",
".",
"MergeErrorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"herr",
":=",
"httptypes",
".",
"NewHTTPError",
"(",
"http",
".",
"StatusInternalServerError",
",",
"\"",
"\"",
")",
"\n",
"if",
"et",
":=",
"herr",
".",
"WriteTo",
"(",
"w",
")",
";",
"et",
"!=",
"nil",
"{",
"if",
"lg",
"!=",
"nil",
"{",
"lg",
".",
"Debug",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"r",
".",
"RemoteAddr",
")",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"err",
".",
"Error",
"(",
")",
")",
",",
"zap",
".",
"Error",
"(",
"et",
")",
",",
")",
"\n",
"}",
"else",
"{",
"plog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"et",
",",
"r",
".",
"RemoteAddr",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
1,374 | all-1375 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"StopTrackingHeapObjectsParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoHeapprofiler1",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
1,375 | all-1376 | [
"URLPart",
"returns",
"a",
"part",
"of",
"the",
"url",
"and",
"caches",
"it",
"in",
"the",
"context"
] | [
"func",
"URLPart",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"http",
".",
"Request",
",",
"i",
"int",
")",
"(",
"context",
".",
"Context",
",",
"string",
",",
"bool",
")",
"{",
"ctx",
",",
"parts",
":=",
"URLParts",
"(",
"ctx",
",",
"r",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
">",
"i",
"&&",
"i",
">=",
"0",
"{",
"return",
"ctx",
",",
"<mask>",
"[",
"i",
"]",
",",
"true",
"\n",
"}",
"\n",
"return",
"ctx",
",",
"\"",
"\"",
",",
"false",
"\n",
"}"
] |
1,376 | all-1377 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"Event",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoBackgroundservice6",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
1,377 | all-1378 | [
"GetLog",
"returns",
"the",
"log",
"of",
"the",
"default",
"container",
"in",
"the",
"specified",
"pod",
"in",
"the",
"client",
"s",
"specified",
"namespace",
".",
"Analogous",
"to",
"kubectl",
"logs",
"pod",
"--",
"namespace",
"=",
"client",
".",
"namespace"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetLog",
"(",
"pod",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"c",
".",
"<mask>",
"(",
"\"",
"\"",
",",
"pod",
")",
"\n",
"return",
"c",
".",
"requestRetry",
"(",
"&",
"request",
"{",
"path",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"namespace",
",",
"pod",
")",
",",
"}",
")",
"\n",
"}"
] |
1,378 | all-1379 | [
"DeleteImage",
"deletes",
"the",
"named",
"image",
"from",
"the",
"registry",
"if",
"supported",
"."
] | [
"func",
"(",
"ref",
"archiveReference",
")",
"DeleteImage",
"(",
"ctx",
"<mask>",
".",
"Context",
",",
"sys",
"*",
"types",
".",
"SystemContext",
")",
"error",
"{",
"// Not really supported, for safety reasons.",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
1,379 | all-1380 | [
"GetName",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_widget_get_name",
"()",
".",
"A",
"non",
"-",
"nil",
"error",
"is",
"returned",
"in",
"the",
"case",
"that",
"gtk_widget_get_name",
"returns",
"NULL",
"to",
"differentiate",
"between",
"NULL",
"and",
"an",
"empty",
"string",
"."
] | [
"func",
"(",
"v",
"*",
"Widget",
")",
"GetName",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gtk_widget_get_name",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"return",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"<mask>",
")",
"(",
"c",
")",
")",
",",
"nil",
"\n",
"}"
] |
1,380 | all-1381 | [
"reconcile",
"ensures",
"a",
"tekton",
"prowjob",
"has",
"a",
"corresponding",
"pipeline",
"updating",
"the",
"prowjob",
"s",
"status",
"as",
"the",
"pipeline",
"progresses",
"."
] | [
"func",
"reconcile",
"(",
"c",
"reconciler",
",",
"key",
"string",
")",
"error",
"{",
"logrus",
".",
"Debugf",
"(",
"\"",
"\\n",
"\"",
",",
"key",
")",
"\n\n",
"ctx",
",",
"namespace",
",",
"name",
",",
"err",
":=",
"fromKey",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HandleError",
"(",
"err",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"var",
"wantPipelineRun",
"bool",
"\n",
"pj",
",",
"err",
":=",
"c",
".",
"getProwJob",
"(",
"name",
")",
"\n",
"switch",
"{",
"case",
"apierrors",
".",
"IsNotFound",
"(",
"err",
")",
":",
"// Do not want pipeline",
"case",
"err",
"!=",
"nil",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"case",
"pj",
".",
"Spec",
".",
"Agent",
"!=",
"prowjobv1",
".",
"TektonAgent",
":",
"// Do not want a pipeline for this job",
"case",
"pjutil",
".",
"ClusterToCtx",
"(",
"pj",
".",
"Spec",
".",
"Cluster",
")",
"!=",
"ctx",
":",
"// Build is in wrong cluster, we do not want this build",
"logrus",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"key",
",",
"ctx",
",",
"pjutil",
".",
"ClusterToCtx",
"(",
"pj",
".",
"Spec",
".",
"Cluster",
")",
")",
"\n",
"case",
"pj",
".",
"DeletionTimestamp",
"==",
"nil",
":",
"wantPipelineRun",
"=",
"true",
"\n",
"}",
"\n\n",
"var",
"havePipelineRun",
"bool",
"\n",
"p",
",",
"err",
":=",
"c",
".",
"getPipelineRun",
"(",
"ctx",
",",
"namespace",
",",
"<mask>",
")",
"\n",
"switch",
"{",
"case",
"apierrors",
".",
"IsNotFound",
"(",
"err",
")",
":",
"// Do not have a pipeline",
"case",
"err",
"!=",
"nil",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"key",
",",
"err",
")",
"\n",
"case",
"p",
".",
"DeletionTimestamp",
"==",
"nil",
":",
"havePipelineRun",
"=",
"true",
"\n",
"}",
"\n\n",
"var",
"newPipelineRun",
"bool",
"\n",
"switch",
"{",
"case",
"!",
"wantPipelineRun",
":",
"if",
"!",
"havePipelineRun",
"{",
"if",
"pj",
"!=",
"nil",
"&&",
"pj",
".",
"Spec",
".",
"Agent",
"==",
"prowjobv1",
".",
"TektonAgent",
"{",
"logrus",
".",
"Infof",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Skip deleting if the pipeline run is not created by prow",
"switch",
"v",
",",
"ok",
":=",
"p",
".",
"Labels",
"[",
"kube",
".",
"CreatedByProw",
"]",
";",
"{",
"case",
"!",
"ok",
",",
"v",
"!=",
"\"",
"\"",
":",
"return",
"nil",
"\n",
"}",
"\n",
"logrus",
".",
"Infof",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"if",
"err",
"=",
"c",
".",
"deletePipelineRun",
"(",
"ctx",
",",
"namespace",
",",
"name",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"case",
"finalState",
"(",
"pj",
".",
"Status",
".",
"State",
")",
":",
"logrus",
".",
"Infof",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"return",
"nil",
"\n",
"case",
"wantPipelineRun",
"&&",
"pj",
".",
"Spec",
".",
"PipelineRunSpec",
"==",
"nil",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"case",
"wantPipelineRun",
"&&",
"!",
"havePipelineRun",
":",
"id",
",",
"url",
",",
"err",
":=",
"c",
".",
"pipelineID",
"(",
"*",
"pj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"pj",
".",
"Status",
".",
"BuildID",
"=",
"id",
"\n",
"pj",
".",
"Status",
".",
"URL",
"=",
"url",
"\n",
"newPipelineRun",
"=",
"true",
"\n",
"pr",
":=",
"makePipelineGitResource",
"(",
"*",
"pj",
")",
"\n",
"logrus",
".",
"Infof",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"if",
"pr",
",",
"err",
"=",
"c",
".",
"createPipelineResource",
"(",
"ctx",
",",
"namespace",
",",
"pr",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"key",
",",
"err",
")",
"\n",
"}",
"\n",
"newp",
",",
"err",
":=",
"makePipelineRun",
"(",
"*",
"pj",
",",
"pr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"key",
",",
"err",
")",
"\n",
"}",
"\n",
"logrus",
".",
"Infof",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"p",
",",
"err",
"=",
"c",
".",
"createPipelineRun",
"(",
"ctx",
",",
"namespace",
",",
"newp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"jerr",
":=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"// Set the prow job in error state to avoid an endless loop when",
"// the pipeline cannot be executed (e.g. referenced pipeline does not exist)",
"return",
"updateProwJobState",
"(",
"c",
",",
"key",
",",
"newPipelineRun",
",",
"pj",
",",
"prowjobv1",
".",
"ErrorState",
",",
"jerr",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"p",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"key",
",",
"wantPipelineRun",
")",
"\n",
"}",
"\n",
"wantState",
",",
"wantMsg",
":=",
"prowJobStatus",
"(",
"p",
".",
"Status",
")",
"\n",
"return",
"updateProwJobState",
"(",
"c",
",",
"key",
",",
"newPipelineRun",
",",
"pj",
",",
"wantState",
",",
"wantMsg",
")",
"\n",
"}"
] |
1,381 | all-1382 | [
"clientConn",
"returns",
"a",
"loggingConn",
"at",
"the",
"oposite",
"end",
"of",
"the",
"loggingPipe",
"as",
"serverConn",
".",
"There",
"is",
"no",
"fundamental",
"difference",
"between",
"the",
"clientConn",
"and",
"the",
"serverConn",
"as",
"communication",
"is",
"full",
"duplex",
"but",
"distinguishing",
"the",
"two",
"ends",
"of",
"the",
"pipe",
"as",
"client",
"and",
"server",
"rather",
"than",
"e",
".",
"g",
".",
"left",
"and",
"right",
"hopefully",
"makes",
"the",
"calling",
"code",
"easier",
"to",
"read"
] | [
"func",
"(",
"p",
"*",
"loggingPipe",
")",
"clientConn",
"(",
")",
"*",
"loggingConn",
"{",
"return",
"&",
"loggingConn",
"{",
"<mask>",
":",
"p",
",",
"r",
":",
"p",
".",
"clientReader",
",",
"w",
":",
"p",
".",
"serverWriter",
",",
"}",
"\n",
"}"
] |
1,382 | all-1383 | [
"HasCustomBgColor",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"d",
"*",
"DashboardConditionalFormat",
")",
"HasCustomBgColor",
"(",
")",
"bool",
"{",
"if",
"d",
"!=",
"nil",
"&&",
"d",
".",
"CustomBgColor",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
1,383 | all-1384 | [
"Token",
"generates",
"a",
"base",
"-",
"64",
"string",
"of",
"random",
"bytes",
"with",
"length",
"as",
"specified",
"by",
"size",
"parameter",
"."
] | [
"func",
"(",
"self",
"*",
"Salter",
")",
"Token",
"(",
"size",
"int",
")",
"string",
"{",
"return",
"base64",
".",
"URLEncoding",
".",
"EncodeToString",
"(",
"<mask>",
".",
"BToken",
"(",
"size",
")",
")",
"\n",
"}"
] |
1,384 | all-1385 | [
"hostVSwitchFromName",
"locates",
"a",
"virtual",
"switch",
"on",
"the",
"supplied",
"HostNetworkSystem",
"by",
"name",
"."
] | [
"func",
"hostVSwitchFromName",
"(",
"client",
"*",
"govmomi",
".",
"Client",
",",
"<mask>",
"*",
"object",
".",
"HostNetworkSystem",
",",
"name",
"string",
")",
"(",
"*",
"types",
".",
"HostVirtualSwitch",
",",
"error",
")",
"{",
"var",
"mns",
"mo",
".",
"HostNetworkSystem",
"\n",
"pc",
":=",
"client",
".",
"PropertyCollector",
"(",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"defaultAPITimeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"if",
"err",
":=",
"pc",
".",
"RetrieveOne",
"(",
"ctx",
",",
"ns",
".",
"Reference",
"(",
")",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"&",
"mns",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"sw",
":=",
"range",
"mns",
".",
"NetworkInfo",
".",
"Vswitch",
"{",
"if",
"sw",
".",
"Name",
"==",
"name",
"{",
"// Spec.Mtu is not set for vSwitches created directly",
"// in ESXi. TODO: Use sw.Mtu instead of sw.Spec.Mtu in",
"// flattenHostVirtualSwitchSpec.",
"sw",
".",
"Spec",
".",
"Mtu",
"=",
"sw",
".",
"Mtu",
"\n",
"return",
"&",
"sw",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"}"
] |
1,385 | all-1386 | [
"set",
"the",
"viewport"
] | [
"func",
"Viewport",
"(",
"x",
"int32",
",",
"y",
"int32",
",",
"width",
"int32",
",",
"height",
"int32",
")",
"{",
"C",
".",
"glowViewport",
"(",
"gpViewport",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"x",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"y",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"<mask>",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"height",
")",
")",
"\n",
"}"
] |
1,386 | all-1387 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"GetApplicationCacheForFrameParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoApplicationcache6",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
1,387 | all-1388 | [
"VerifyMessageConsumer",
"is",
"a",
"test",
"convience",
"function",
"for",
"VerifyMessageConsumerRaw",
"accepting",
"an",
"instance",
"of",
"*",
"testing",
".",
"T"
] | [
"func",
"(",
"p",
"*",
"Pact",
")",
"VerifyMessageConsumer",
"(",
"t",
"*",
"testing",
".",
"T",
",",
"message",
"*",
"<mask>",
",",
"handler",
"MessageConsumer",
")",
"error",
"{",
"err",
":=",
"p",
".",
"VerifyMessageConsumerRaw",
"(",
"message",
",",
"handler",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"t",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}"
] |
1,388 | all-1389 | [
"add",
"adds",
"new",
"route",
"to",
"route",
"tree",
"map",
"."
] | [
"func",
"(",
"rm",
"*",
"routeMap",
")",
"add",
"(",
"method",
",",
"pattern",
"string",
",",
"leaf",
"*",
"Leaf",
")",
"{",
"rm",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"rm",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"rm",
".",
"routes",
"[",
"<mask>",
"]",
"[",
"pattern",
"]",
"=",
"leaf",
"\n",
"}"
] |
1,389 | all-1390 | [
"NewNodeReaderFilter",
"创建节点过滤器,实现敏感词的过滤",
"从可读流中读取敏感词数据",
"(",
"以指定的分隔符读取数据",
")"
] | [
"func",
"NewNodeReaderFilter",
"(",
"rd",
"io",
".",
"Reader",
",",
"delim",
"<mask>",
")",
"DirtyFilter",
"{",
"nf",
":=",
"&",
"nodeFilter",
"{",
"root",
":",
"newNode",
"(",
")",
",",
"}",
"\n",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"io",
".",
"Copy",
"(",
"buf",
",",
"rd",
")",
"\n",
"buf",
".",
"WriteByte",
"(",
"delim",
")",
"\n",
"for",
"{",
"line",
",",
"err",
":=",
"buf",
".",
"ReadString",
"(",
"delim",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n",
"if",
"line",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n",
"nf",
".",
"addDirtyWords",
"(",
"line",
")",
"\n",
"}",
"\n",
"buf",
".",
"Reset",
"(",
")",
"\n",
"return",
"nf",
"\n",
"}"
] |
1,390 | all-1391 | [
"GetMustShowErrorsOk",
"returns",
"a",
"tuple",
"with",
"the",
"MustShowErrors",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"w",
"*",
"Widget",
")",
"GetMustShowErrorsOk",
"(",
")",
"(",
"bool",
",",
"bool",
")",
"{",
"if",
"w",
"==",
"nil",
"||",
"w",
".",
"MustShowErrors",
"==",
"nil",
"{",
"return",
"false",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"w",
".",
"MustShowErrors",
",",
"true",
"\n",
"}"
] |
1,391 | all-1392 | [
"MarshalEasyJSON",
"writes",
"the",
"UUID",
"to",
"a",
"easyjson",
".",
"Writer"
] | [
"func",
"(",
"u",
"UUID",
")",
"MarshalEasyJSON",
"(",
"w",
"*",
"jwriter",
".",
"Writer",
")",
"{",
"w",
".",
"<mask>",
"(",
"string",
"(",
"u",
")",
")",
"\n",
"}"
] |
1,392 | all-1393 | [
"StartUnixListener",
"starts",
"up",
"a",
"unix",
"domain",
"socket",
"listener",
"for",
"reconnects",
"to",
"be",
"sent",
"through"
] | [
"func",
"(",
"irc",
"*",
"Bot",
")",
"StartUnixListener",
"(",
")",
"{",
"unaddr",
",",
"err",
":=",
"net",
".",
"ResolveUnixAddr",
"(",
"\"",
"\"",
",",
"irc",
".",
"unixastr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"list",
",",
"err",
":=",
"net",
".",
"ListenUnix",
"(",
"\"",
"\"",
",",
"unaddr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"irc",
".",
"unixlist",
"=",
"list",
"\n",
"con",
",",
"err",
":=",
"list",
".",
"AcceptUnix",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"list",
".",
"Close",
"(",
")",
"\n\n",
"fi",
",",
"err",
":=",
"irc",
".",
"con",
".",
"(",
"*",
"net",
".",
"TCPConn",
")",
".",
"File",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"err",
"=",
"sendfd",
".",
"SendFD",
"(",
"con",
",",
"fi",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"<mask>",
"{",
"case",
"<-",
"irc",
".",
"Incoming",
":",
"default",
":",
"close",
"(",
"irc",
".",
"Incoming",
")",
"\n",
"}",
"\n",
"close",
"(",
"irc",
".",
"outgoing",
")",
"\n",
"}"
] |
1,393 | all-1394 | [
"platformHostConfigOverride",
"to",
"override",
"platform",
"specific",
"feature",
"sets"
] | [
"func",
"(",
"<mask>",
"*",
"Task",
")",
"platformHostConfigOverride",
"(",
"hostConfig",
"*",
"dockercontainer",
".",
"HostConfig",
")",
"error",
"{",
"// Override cgroup parent",
"return",
"task",
".",
"overrideCgroupParent",
"(",
"hostConfig",
")",
"\n",
"}"
] |
1,394 | all-1395 | [
"CandidServer",
"returns",
"all",
"the",
"Candid",
"settings",
"needed",
"to",
"connect",
"to",
"a",
"server",
"."
] | [
"func",
"(",
"c",
"*",
"Config",
")",
"CandidServer",
"(",
")",
"(",
"string",
",",
"<mask>",
",",
"int64",
",",
"string",
")",
"{",
"return",
"c",
".",
"m",
".",
"GetString",
"(",
"\"",
"\"",
")",
",",
"c",
".",
"m",
".",
"GetString",
"(",
"\"",
"\"",
")",
",",
"c",
".",
"m",
".",
"GetInt64",
"(",
"\"",
"\"",
")",
",",
"c",
".",
"m",
".",
"GetString",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
1,395 | all-1396 | [
"sendSymlink",
"sends",
"a",
"symlink",
"into",
"the",
"tar",
"stream",
"."
] | [
"func",
"(",
"d",
"*",
"Destination",
")",
"sendSymlink",
"(",
"path",
"string",
",",
"target",
"string",
")",
"error",
"{",
"hdr",
",",
"err",
":=",
"<mask>",
".",
"FileInfoHeader",
"(",
"&",
"tarFI",
"{",
"path",
":",
"path",
",",
"size",
":",
"0",
",",
"isSymlink",
":",
"true",
"}",
",",
"target",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"path",
",",
"target",
")",
"\n",
"return",
"d",
".",
"tar",
".",
"WriteHeader",
"(",
"hdr",
")",
"\n",
"}"
] |
1,396 | all-1397 | [
"WriteGzipLevel",
"writes",
"response",
"with",
"gzipped",
"body",
"to",
"w",
".",
"Level",
"is",
"the",
"desired",
"compression",
"level",
":",
"*",
"CompressNoCompression",
"*",
"CompressBestSpeed",
"*",
"CompressBestCompression",
"*",
"CompressDefaultCompression",
"*",
"CompressHuffmanOnly",
"The",
"method",
"gzips",
"response",
"body",
"and",
"sets",
"Content",
"-",
"Encoding",
":",
"gzip",
"header",
"before",
"writing",
"response",
"to",
"w",
".",
"WriteGzipLevel",
"doesn",
"t",
"flush",
"response",
"to",
"w",
"for",
"performance",
"reasons",
"."
] | [
"func",
"(",
"resp",
"*",
"Response",
")",
"WriteGzipLevel",
"(",
"w",
"*",
"bufio",
".",
"Writer",
",",
"<mask>",
"int",
")",
"error",
"{",
"if",
"err",
":=",
"resp",
".",
"gzipBody",
"(",
"level",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"resp",
".",
"Write",
"(",
"w",
")",
"\n",
"}"
] |
1,397 | all-1398 | [
"CopyTo",
"copies",
"resp",
"contents",
"to",
"dst",
"except",
"of",
"body",
"stream",
"."
] | [
"func",
"(",
"resp",
"*",
"Response",
")",
"CopyTo",
"(",
"dst",
"*",
"Response",
")",
"{",
"resp",
".",
"copyToSkipBody",
"(",
"dst",
")",
"\n",
"if",
"resp",
".",
"bodyRaw",
"!=",
"nil",
"{",
"dst",
".",
"bodyRaw",
"=",
"resp",
".",
"bodyRaw",
"\n",
"if",
"dst",
".",
"body",
"!=",
"nil",
"{",
"dst",
".",
"body",
".",
"Reset",
"(",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"resp",
".",
"<mask>",
"!=",
"nil",
"{",
"dst",
".",
"bodyBuffer",
"(",
")",
".",
"Set",
"(",
"resp",
".",
"body",
".",
"B",
")",
"\n",
"}",
"else",
"if",
"dst",
".",
"body",
"!=",
"nil",
"{",
"dst",
".",
"body",
".",
"Reset",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
1,398 | all-1399 | [
"Head",
"adds",
"the",
"route",
"pattern",
"that",
"matches",
"a",
"HEAD",
"http",
"method",
"to",
"execute",
"the",
"handlerFn",
"http",
".",
"HandlerFunc",
"."
] | [
"func",
"(",
"mx",
"*",
"Mux",
")",
"Head",
"(",
"<mask>",
"string",
",",
"handlerFn",
"http",
".",
"HandlerFunc",
")",
"{",
"mx",
".",
"handle",
"(",
"mHEAD",
",",
"pattern",
",",
"handlerFn",
")",
"\n",
"}"
] |
1,399 | all-1400 | [
"getAWSKeys",
"gets",
"the",
"AWS",
"Keys",
"from",
"environment",
"variables",
"or",
"the",
"instance",
"-",
"based",
"metadata",
"on",
"EC2",
"Environment",
"variables",
"are",
"attempted",
"first",
"followed",
"by",
"the",
"instance",
"-",
"based",
"credentials",
"."
] | [
"func",
"getAWSKeys",
"(",
")",
"(",
"<mask>",
"s3gof3r",
".",
"Keys",
",",
"err",
"error",
")",
"{",
"keys",
",",
"err",
"=",
"s3gof3r",
".",
"EnvKeys",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"keys",
",",
"err",
"=",
"s3gof3r",
".",
"InstanceKeys",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}"
] |
Subsets and Splits