id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
8,300 | all-8301 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"ComputedProperty",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss60",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
8,301 | all-8302 | [
"initializeTaskENIDependencies",
"initializes",
"all",
"of",
"the",
"dependencies",
"required",
"by",
"the",
"Agent",
"to",
"support",
"the",
"awsvpc",
"networking",
"mode",
".",
"A",
"non",
"nil",
"error",
"is",
"returned",
"if",
"an",
"error",
"is",
"encountered",
"during",
"this",
"process",
".",
"An",
"additional",
"boolean",
"flag",
"to",
"indicate",
"if",
"this",
"error",
"is",
"considered",
"terminal",
"is",
"also",
"returned"
] | [
"func",
"(",
"agent",
"*",
"ecsAgent",
")",
"initializeTaskENIDependencies",
"(",
"state",
"dockerstate",
".",
"TaskEngineState",
",",
"taskEngine",
"engine",
".",
"TaskEngine",
")",
"(",
"error",
",",
"bool",
")",
"{",
"// Check if the Agent process's pid == 1, which means it's running without an init system",
"if",
"agent",
".",
"os",
".",
"Getpid",
"(",
")",
"==",
"initPID",
"{",
"// This is a terminal error. Bad things happen with invoking the",
"// the ENI plugin when there's no init process in the pid namesapce.",
"// Specifically, the DHClient processes that are started as children",
"// of the Agent will not be reaped leading to the ENI device",
"// disappearing until the Agent is killed.",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
",",
"true",
"\n",
"}",
"\n\n",
"// Set VPC and Subnet IDs for the instance",
"if",
"err",
",",
"ok",
":=",
"agent",
".",
"setVPCSubnet",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
",",
"ok",
"\n",
"}",
"\n\n",
"// Validate that the CNI plugins exist in the expected path and that",
"// they possess the right capabilities",
"if",
"err",
":=",
"agent",
".",
"verifyCNIPluginsCapabilities",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"// An error here is terminal as it means that the plugins",
"// do not support the ENI capability",
"return",
"err",
",",
"true",
"\n",
"}",
"\n\n",
"// Load the pause container's image from the 'disk'",
"if",
"_",
",",
"err",
":=",
"agent",
".",
"pauseLoader",
".",
"LoadImage",
"(",
"agent",
".",
"ctx",
",",
"agent",
".",
"cfg",
",",
"agent",
".",
"dockerClient",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"pause",
".",
"IsNoSuchFileError",
"(",
"err",
")",
"||",
"pause",
".",
"UnsupportedPlatform",
"(",
"err",
")",
"{",
"// If the pause container's image tarball doesn't exist or if the",
"// invocation is done for an unsupported platform, we cannot recover.",
"// Return the error as terminal for these cases",
"return",
"err",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"err",
",",
"false",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"agent",
".",
"startUdevWatcher",
"(",
"state",
",",
"taskEngine",
".",
"StateChangeEvents",
"(",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"// If udev watcher was not initialized in this run because of the udev socket",
"// file not being available etc, the Agent might be able to retry and succeed",
"// on the next run. Hence, returning a false here for terminal bool",
"return",
"err",
",",
"false",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"false",
"\n",
"}"
] |
8,302 | all-8303 | [
"Validate",
"that",
"options",
"are",
"usuable"
] | [
"func",
"(",
"opts",
"*",
"<mask>",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"opts",
".",
"App",
".",
"IsZero",
"(",
")",
"{",
"opts",
".",
"App",
"=",
"meta",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"opts",
".",
"Out",
".",
"Writer",
"==",
"nil",
"{",
"opts",
".",
"Out",
"=",
"rx",
".",
"NewWriter",
"(",
"os",
".",
"Stdout",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
8,303 | all-8304 | [
"NewDriverNotSupported",
"creates",
"a",
"placeholder",
"Driver",
"that",
"replaces",
"a",
"driver",
"that",
"is",
"not",
"supported",
"on",
"a",
"given",
"platform",
".",
"eg",
"fusion",
"on",
"linux",
"."
] | [
"func",
"NewDriverNotSupported",
"(",
"driverName",
",",
"hostName",
",",
"storePath",
"string",
")",
"Driver",
"{",
"return",
"&",
"DriverNotSupported",
"{",
"BaseDriver",
":",
"&",
"BaseDriver",
"{",
"MachineName",
":",
"hostName",
",",
"StorePath",
":",
"storePath",
",",
"}",
",",
"<mask>",
":",
"driverName",
",",
"}",
"\n",
"}"
] |
8,304 | all-8305 | [
"AddPattern",
"is",
"a",
"wrapper",
"around",
"gtk_file_filter_add_pattern",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"FileFilter",
")",
"AddPattern",
"(",
"pattern",
"string",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"pattern",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"C",
".",
"gtk_file_filter_add_pattern",
"(",
"v",
".",
"native",
"(",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
] |
8,305 | all-8306 | [
"Description",
"return",
"a",
"human",
"-",
"readable",
"description",
"of",
"the",
"operation",
"type",
"."
] | [
"func",
"(",
"t",
"OperationType",
")",
"Description",
"(",
")",
"string",
"{",
"switch",
"t",
"{",
"case",
"OperationClusterBootstrap",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationClusterJoin",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationBackupCreate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationBackupRename",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationBackupRestore",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationBackupRemove",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationConsoleShow",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationContainerCreate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationContainerUpdate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationContainerRename",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationContainerMigrate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationContainerLiveMigrate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationContainerFreeze",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationContainerUnfreeze",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationContainerDelete",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationContainerStart",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationContainerStop",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationContainerRestart",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationCommandExec",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationSnapshotCreate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationSnapshotRename",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationSnapshotRestore",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationSnapshotTransfer",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationSnapshotUpdate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationSnapshotDelete",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationImageDownload",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationImageDelete",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationImageToken",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationImageRefresh",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationVolumeCopy",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationVolumeCreate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationVolumeMigrate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationVolumeMove",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationVolumeSnapshotCreate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationVolumeSnapshotDelete",
":",
"return",
"\"",
"\"",
"\n",
"<mask>",
"OperationVolumeSnapshotUpdate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationProjectRename",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationImagesExpire",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationImagesPruneLeftover",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationImagesUpdate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationImagesSynchronize",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationLogsExpire",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationInstanceTypesUpdate",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationBackupsExpire",
":",
"return",
"\"",
"\"",
"\n",
"case",
"OperationSnapshotsExpire",
":",
"return",
"\"",
"\"",
"\n",
"default",
":",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"}"
] |
8,306 | all-8307 | [
"NextToken",
"from",
"the",
"source",
"input"
] | [
"func",
"(",
"l",
"*",
"Lexer",
")",
"NextToken",
"(",
")",
"token",
".",
"Token",
"{",
"if",
"l",
".",
"inside",
"{",
"return",
"l",
".",
"nextInsideToken",
"(",
")",
"\n",
"}",
"\n",
"var",
"tok",
"token",
".",
"Token",
"\n\n",
"// l.skipWhitespace()",
"if",
"l",
".",
"ch",
"==",
"0",
"{",
"tok",
".",
"Literal",
"=",
"\"",
"\"",
"\n",
"tok",
".",
"Type",
"=",
"token",
".",
"EOF",
"\n",
"tok",
".",
"LineNumber",
"=",
"l",
".",
"curLine",
"\n",
"return",
"tok",
"\n",
"}",
"\n\n",
"if",
"l",
".",
"ch",
"==",
"'<'",
"&&",
"l",
".",
"peekChar",
"(",
")",
"==",
"'%'",
"{",
"l",
".",
"inside",
"=",
"true",
"\n",
"return",
"l",
".",
"nextInsideToken",
"(",
")",
"\n",
"}",
"\n\n",
"tok",
".",
"Type",
"=",
"token",
".",
"<mask>",
"\n",
"tok",
".",
"Literal",
"=",
"l",
".",
"readHTML",
"(",
")",
"\n",
"tok",
".",
"LineNumber",
"=",
"l",
".",
"curLine",
"\n",
"return",
"tok",
"\n",
"}"
] |
8,307 | all-8308 | [
"isCDtorConversion",
"returns",
"when",
"an",
"AST",
"is",
"a",
"constructor",
"a",
"destructor",
"or",
"a",
"conversion",
"operator",
"."
] | [
"func",
"isCDtorConversion",
"(",
"a",
"AST",
")",
"bool",
"{",
"switch",
"a",
":=",
"a",
".",
"(",
"type",
")",
"{",
"case",
"*",
"Qualified",
":",
"return",
"isCDtorConversion",
"(",
"a",
".",
"<mask>",
")",
"\n",
"case",
"*",
"Constructor",
",",
"*",
"Destructor",
",",
"*",
"Cast",
":",
"return",
"true",
"\n",
"default",
":",
"return",
"false",
"\n",
"}",
"\n",
"}"
] |
8,308 | all-8309 | [
"Signal",
"sends",
"a",
"signal",
"to",
"the",
"child",
"process",
"if",
"it",
"exists",
".",
"Any",
"errors",
"that",
"occur",
"are",
"returned",
"."
] | [
"func",
"(",
"r",
"*",
"Runner",
")",
"Signal",
"(",
"s",
"<mask>",
".",
"Signal",
")",
"error",
"{",
"r",
".",
"childLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"r",
".",
"childLock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"r",
".",
"child",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"r",
".",
"child",
".",
"Signal",
"(",
"s",
")",
"\n",
"}"
] |
8,309 | all-8310 | [
"Start",
"starts",
"and",
"begins",
"execution",
"of",
"the",
"child",
"process",
".",
"A",
"buffered",
"channel",
"is",
"returned",
"which",
"is",
"where",
"the",
"command",
"s",
"exit",
"code",
"will",
"be",
"returned",
"upon",
"exit",
".",
"Any",
"errors",
"that",
"occur",
"prior",
"to",
"starting",
"the",
"command",
"will",
"be",
"returned",
"as",
"the",
"second",
"error",
"argument",
"but",
"any",
"errors",
"returned",
"by",
"the",
"command",
"after",
"execution",
"will",
"be",
"returned",
"as",
"a",
"non",
"-",
"zero",
"value",
"over",
"the",
"exit",
"code",
"channel",
"."
] | [
"func",
"(",
"c",
"*",
"Child",
")",
"Start",
"(",
")",
"error",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"c",
".",
"Command",
"(",
")",
")",
"\n",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n",
"return",
"c",
".",
"<mask>",
"(",
")",
"\n",
"}"
] |
8,310 | all-8311 | [
"UpdateSession",
"updates",
"and",
"optionally",
"stops",
"the",
"current",
"client",
"session",
"."
] | [
"func",
"(",
"h",
"*",
"Handler",
")",
"UpdateSession",
"(",
"product",
",",
"productPassword",
",",
"clientKey",
"string",
",",
"units",
"uint64",
",",
"stopSession",
"bool",
")",
"error",
"{",
"logger",
":=",
"h",
".",
"logger",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"product",
",",
"\"",
"\"",
",",
"clientKey",
",",
"\"",
"\"",
",",
"units",
",",
"\"",
"\"",
",",
"stopSession",
")",
"\n\n",
"if",
"stopSession",
"{",
"logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"prod",
",",
"err",
":=",
"h",
".",
"checkProductPassword",
"(",
"logger",
",",
"product",
",",
"productPassword",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"ch",
",",
"err",
":=",
"h",
".",
"findClientChannel",
"(",
"logger",
",",
"prod",
",",
"clientKey",
",",
"true",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Make the server adapter to kill the session for non-active channel.",
"if",
"prod",
".",
"IsServer",
"&&",
"ch",
".",
"ServiceStatus",
"!=",
"data",
".",
"ServiceActive",
"{",
"logger",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
"ErrNonActiveChannel",
"\n",
"}",
"\n\n",
"clientStop",
":=",
"!",
"prod",
".",
"IsServer",
"&&",
"stopSession",
"\n\n",
"if",
"clientStop",
"{",
"if",
"ch",
".",
"ServiceStatus",
"==",
"data",
".",
"ServiceTerminated",
"{",
"logger",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"status",
":=",
"data",
".",
"ServiceSuspended",
"\n",
"if",
"ch",
".",
"ServiceStatus",
"==",
"data",
".",
"ServiceTerminating",
"{",
"status",
"=",
"data",
".",
"ServiceTerminated",
"\n",
"}",
"\n\n",
"err",
":=",
"job",
".",
"AddWithData",
"(",
"h",
".",
"queue",
",",
"nil",
",",
"data",
".",
"JobClientCompleteServiceTransition",
",",
"data",
".",
"JobChannel",
",",
"ch",
".",
"ID",
",",
"data",
".",
"JobSessionServer",
",",
"status",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"job",
".",
"ErrDuplicatedJob",
"{",
"logger",
".",
"Error",
"(",
"err",
".",
"<mask>",
"(",
")",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"sess",
",",
"err",
":=",
"h",
".",
"findCurrentSession",
"(",
"logger",
",",
"ch",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Client adapter can signal failure immediately, when no",
"// session is yet created.",
"if",
"err",
"==",
"ErrSessionNotFound",
"&&",
"clientStop",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"logger",
"=",
"logger",
".",
"Add",
"(",
"\"",
"\"",
",",
"sess",
")",
"\n\n",
"if",
"units",
"!=",
"0",
"{",
"// TODO: Use unit size instead of this hardcode.",
"units",
"/=",
"1024",
"*",
"1024",
"\n\n",
"switch",
"prod",
".",
"UsageRepType",
"{",
"case",
"data",
".",
"ProductUsageIncremental",
":",
"sess",
".",
"UnitsUsed",
"+=",
"units",
"\n",
"case",
"data",
".",
"ProductUsageTotal",
":",
"sess",
".",
"UnitsUsed",
"=",
"units",
"\n",
"default",
":",
"logger",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"sess",
".",
"LastUsageTime",
"=",
"time",
".",
"Now",
"(",
")",
"\n",
"if",
"stopSession",
"{",
"sess",
".",
"Stopped",
"=",
"pointer",
".",
"ToTime",
"(",
"sess",
".",
"LastUsageTime",
")",
"\n",
"}",
"\n\n",
"logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"err",
":=",
"h",
".",
"db",
".",
"Save",
"(",
"sess",
")",
";",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Error",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"ErrInternal",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
8,311 | all-8312 | [
"Inspect",
"traverses",
"an",
"AST",
"in",
"depth",
"-",
"first",
"order",
":",
"It",
"starts",
"by",
"calling",
"f",
"(",
"node",
"path",
")",
";",
"node",
"must",
"not",
"be",
"nil",
".",
"If",
"f",
"returns",
"a",
"nil",
"error",
"Inspect",
"invokes",
"f",
"for",
"all",
"the",
"non",
"-",
"nil",
"children",
"of",
"node",
"recursively",
"."
] | [
"func",
"Inspect",
"(",
"<mask>",
"Node",
",",
"f",
"inspector",
")",
"{",
"Walk",
"(",
"inspector",
"(",
"f",
")",
",",
"node",
",",
"nil",
")",
"\n",
"}"
] |
8,312 | all-8313 | [
"NewStore",
"returns",
"a",
"new",
"store",
".",
"It",
"is",
"useful",
"to",
"create",
"a",
"store",
"inside",
"mvcc",
"pkg",
".",
"It",
"should",
"only",
"be",
"used",
"for",
"testing",
"externally",
"."
] | [
"func",
"NewStore",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"b",
"backend",
".",
"Backend",
",",
"le",
"lease",
".",
"Lessor",
",",
"ig",
"ConsistentIndexGetter",
")",
"*",
"store",
"{",
"s",
":=",
"&",
"store",
"{",
"b",
":",
"b",
",",
"ig",
":",
"ig",
",",
"kvindex",
":",
"newTreeIndex",
"(",
"lg",
")",
",",
"le",
":",
"le",
",",
"currentRev",
":",
"1",
",",
"compactMainRev",
":",
"-",
"1",
",",
"bytesBuf8",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"8",
")",
",",
"fifoSched",
":",
"schedule",
".",
"NewFIFOScheduler",
"(",
")",
",",
"stopc",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"lg",
":",
"lg",
",",
"}",
"\n",
"s",
".",
"ReadView",
"=",
"&",
"readView",
"{",
"s",
"}",
"\n",
"s",
".",
"WriteView",
"=",
"&",
"writeView",
"{",
"s",
"}",
"\n",
"if",
"s",
".",
"le",
"!=",
"nil",
"{",
"s",
".",
"le",
".",
"SetRangeDeleter",
"(",
"func",
"(",
")",
"lease",
".",
"TxnDelete",
"{",
"return",
"s",
".",
"Write",
"(",
")",
"}",
")",
"\n",
"}",
"\n\n",
"<mask>",
":=",
"s",
".",
"b",
".",
"BatchTx",
"(",
")",
"\n",
"tx",
".",
"Lock",
"(",
")",
"\n",
"tx",
".",
"UnsafeCreateBucket",
"(",
"keyBucketName",
")",
"\n",
"tx",
".",
"UnsafeCreateBucket",
"(",
"metaBucketName",
")",
"\n",
"tx",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"b",
".",
"ForceCommit",
"(",
")",
"\n\n",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"err",
":=",
"s",
".",
"restore",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"// TODO: return the error instead of panic here?",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"s",
"\n",
"}"
] |
8,313 | all-8314 | [
"readTarComponent",
"returns",
"full",
"contents",
"of",
"componentPath",
"."
] | [
"func",
"(",
"s",
"*",
"Source",
")",
"readTarComponent",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"file",
",",
"err",
":=",
"s",
".",
"openTarComponent",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"<mask>",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"path",
")",
"\n",
"}",
"\n",
"defer",
"file",
".",
"Close",
"(",
")",
"\n",
"bytes",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"bytes",
",",
"nil",
"\n",
"}"
] |
8,314 | all-8315 | [
"reply",
"||",
"error"
] | [
"func",
"(",
"h",
"*",
"segmentHeader",
")",
"read",
"(",
"rd",
"*",
"bufio",
".",
"Reader",
")",
"error",
"{",
"h",
".",
"segmentLength",
"=",
"rd",
".",
"ReadInt32",
"(",
")",
"\n",
"h",
".",
"segmentOfs",
"=",
"rd",
".",
"ReadInt32",
"(",
")",
"\n",
"h",
".",
"noOfParts",
"=",
"rd",
".",
"ReadInt16",
"(",
")",
"\n",
"h",
".",
"segmentNo",
"=",
"rd",
".",
"ReadInt16",
"(",
")",
"\n",
"h",
".",
"segmentKind",
"=",
"segmentKind",
"(",
"rd",
".",
"ReadInt8",
"(",
")",
")",
"\n\n",
"switch",
"h",
".",
"segmentKind",
"{",
"default",
":",
"//error",
"rd",
".",
"Skip",
"(",
"11",
")",
"//segmentHeaderLength",
"\n\n",
"case",
"skRequest",
":",
"h",
".",
"messageType",
"=",
"messageType",
"(",
"rd",
".",
"ReadInt8",
"(",
")",
")",
"\n",
"h",
".",
"<mask>",
"=",
"rd",
".",
"ReadBool",
"(",
")",
"\n",
"h",
".",
"commandOptions",
"=",
"commandOptions",
"(",
"rd",
".",
"ReadInt8",
"(",
")",
")",
"\n",
"rd",
".",
"Skip",
"(",
"8",
")",
"//segmentHeaderLength",
"\n\n",
"case",
"skReply",
":",
"rd",
".",
"Skip",
"(",
"1",
")",
"//reserved",
"\n",
"h",
".",
"functionCode",
"=",
"functionCode",
"(",
"rd",
".",
"ReadInt16",
"(",
")",
")",
"\n",
"rd",
".",
"Skip",
"(",
"8",
")",
"//segmentHeaderLength",
"\n\n",
"}",
"\n\n",
"if",
"trace",
"{",
"outLogger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"h",
")",
"\n",
"}",
"\n\n",
"return",
"rd",
".",
"GetError",
"(",
")",
"\n",
"}"
] |
8,315 | all-8316 | [
"Uname",
"returns",
"Utsname",
"as",
"strings"
] | [
"func",
"Uname",
"(",
")",
"(",
"*",
"Utsname",
",",
"error",
")",
"{",
"/*\n\t * Based on: https://groups.google.com/forum/#!topic/golang-nuts/Jel8Bb-YwX8\n\t * there is really no better way to do this, which is\n\t * unfortunate. Also, we ditch the more accepted CharsToString\n\t * version in that thread, since it doesn't seem as portable,\n\t * viz. github issue #206.\n\t */",
"uname",
":=",
"syscall",
".",
"Utsname",
"{",
"}",
"\n",
"err",
":=",
"syscall",
".",
"Uname",
"(",
"&",
"uname",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"Utsname",
"{",
"Sysname",
":",
"intArrayToString",
"(",
"uname",
".",
"Sysname",
")",
",",
"Nodename",
":",
"intArrayToString",
"(",
"uname",
".",
"Nodename",
")",
",",
"Release",
":",
"intArrayToString",
"(",
"uname",
".",
"Release",
")",
",",
"<mask>",
":",
"intArrayToString",
"(",
"uname",
".",
"Version",
")",
",",
"Machine",
":",
"intArrayToString",
"(",
"uname",
".",
"Machine",
")",
",",
"Domainname",
":",
"intArrayToString",
"(",
"uname",
".",
"Domainname",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] |
8,316 | all-8317 | [
"SetUploadDate",
"changes",
"the",
"file",
"upload",
"time",
".",
"It",
"is",
"a",
"runtime",
"error",
"to",
"call",
"this",
"function",
"when",
"the",
"file",
"is",
"not",
"open",
"for",
"writing",
"."
] | [
"func",
"(",
"file",
"*",
"GridFile",
")",
"SetUploadDate",
"(",
"t",
"time",
".",
"Time",
")",
"{",
"file",
".",
"assertMode",
"(",
"gfsWriting",
")",
"\n",
"file",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"<mask>",
".",
"doc",
".",
"UploadDate",
"=",
"t",
"\n",
"file",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"}"
] |
8,317 | all-8318 | [
"compareMajorMinorVersion",
"returns",
"an",
"integer",
"comparing",
"two",
"versions",
"based",
"on",
"their",
"major",
"and",
"minor",
"version",
".",
"The",
"result",
"will",
"be",
"0",
"if",
"a",
"==",
"b",
"-",
"1",
"if",
"a",
"<",
"b",
"and",
"1",
"if",
"a",
">",
"b",
"."
] | [
"func",
"compareMajorMinorVersion",
"(",
"a",
",",
"b",
"*",
"semver",
".",
"Version",
")",
"int",
"{",
"na",
":=",
"&",
"semver",
".",
"Version",
"{",
"Major",
":",
"a",
".",
"Major",
",",
"Minor",
":",
"a",
".",
"Minor",
"}",
"\n",
"nb",
":=",
"&",
"semver",
".",
"Version",
"{",
"Major",
":",
"b",
".",
"Major",
",",
"Minor",
":",
"b",
".",
"Minor",
"}",
"\n",
"switch",
"{",
"case",
"na",
".",
"LessThan",
"(",
"*",
"nb",
")",
":",
"return",
"-",
"1",
"\n",
"<mask>",
"nb",
".",
"LessThan",
"(",
"*",
"na",
")",
":",
"return",
"1",
"\n",
"default",
":",
"return",
"0",
"\n",
"}",
"\n",
"}"
] |
8,318 | all-8319 | [
"GetActiveWindow",
"is",
"a",
"wrapper",
"around",
"gtk_application_get_active_window",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"GetActiveWindow",
"(",
")",
"*",
"Window",
"{",
"c",
":=",
"C",
".",
"gtk_application_get_active_window",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"wrapWindow",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
"\n",
"}"
] |
8,319 | all-8320 | [
"createInstance",
"creates",
"a",
"GCE",
"VM",
"instance",
"."
] | [
"func",
"(",
"c",
"*",
"ComputeUtil",
")",
"createInstance",
"(",
"d",
"*",
"Driver",
")",
"error",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n\n",
"var",
"net",
"string",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"d",
".",
"Network",
",",
"\"",
"\"",
")",
"{",
"net",
"=",
"d",
".",
"Network",
"\n",
"}",
"else",
"{",
"net",
"=",
"c",
".",
"globalURL",
"+",
"\"",
"\"",
"+",
"d",
".",
"Network",
"\n",
"}",
"\n\n",
"instance",
":=",
"&",
"raw",
".",
"Instance",
"{",
"Name",
":",
"c",
".",
"instanceName",
",",
"<mask>",
":",
"\"",
"\"",
",",
"MachineType",
":",
"c",
".",
"zoneURL",
"+",
"\"",
"\"",
"+",
"d",
".",
"MachineType",
",",
"Disks",
":",
"[",
"]",
"*",
"raw",
".",
"AttachedDisk",
"{",
"{",
"Boot",
":",
"true",
",",
"AutoDelete",
":",
"true",
",",
"Type",
":",
"\"",
"\"",
",",
"Mode",
":",
"\"",
"\"",
",",
"}",
",",
"}",
",",
"NetworkInterfaces",
":",
"[",
"]",
"*",
"raw",
".",
"NetworkInterface",
"{",
"{",
"Network",
":",
"net",
",",
"}",
",",
"}",
",",
"Tags",
":",
"&",
"raw",
".",
"Tags",
"{",
"Items",
":",
"parseTags",
"(",
"d",
")",
",",
"}",
",",
"ServiceAccounts",
":",
"[",
"]",
"*",
"raw",
".",
"ServiceAccount",
"{",
"{",
"Email",
":",
"d",
".",
"ServiceAccount",
",",
"Scopes",
":",
"strings",
".",
"Split",
"(",
"d",
".",
"Scopes",
",",
"\"",
"\"",
")",
",",
"}",
",",
"}",
",",
"Scheduling",
":",
"&",
"raw",
".",
"Scheduling",
"{",
"Preemptible",
":",
"c",
".",
"preemptible",
",",
"}",
",",
"}",
"\n\n",
"if",
"strings",
".",
"Contains",
"(",
"c",
".",
"subnetwork",
",",
"\"",
"\"",
")",
"{",
"instance",
".",
"NetworkInterfaces",
"[",
"0",
"]",
".",
"Subnetwork",
"=",
"c",
".",
"subnetwork",
"\n",
"}",
"else",
"if",
"c",
".",
"subnetwork",
"!=",
"\"",
"\"",
"{",
"instance",
".",
"NetworkInterfaces",
"[",
"0",
"]",
".",
"Subnetwork",
"=",
"\"",
"\"",
"+",
"c",
".",
"project",
"+",
"\"",
"\"",
"+",
"c",
".",
"region",
"(",
")",
"+",
"\"",
"\"",
"+",
"c",
".",
"subnetwork",
"\n",
"}",
"\n\n",
"if",
"!",
"c",
".",
"useInternalIPOnly",
"{",
"cfg",
":=",
"&",
"raw",
".",
"AccessConfig",
"{",
"Type",
":",
"\"",
"\"",
",",
"}",
"\n",
"instance",
".",
"NetworkInterfaces",
"[",
"0",
"]",
".",
"AccessConfigs",
"=",
"append",
"(",
"instance",
".",
"NetworkInterfaces",
"[",
"0",
"]",
".",
"AccessConfigs",
",",
"cfg",
")",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"address",
"!=",
"\"",
"\"",
"{",
"staticAddress",
",",
"err",
":=",
"c",
".",
"staticAddress",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"instance",
".",
"NetworkInterfaces",
"[",
"0",
"]",
".",
"AccessConfigs",
"[",
"0",
"]",
".",
"NatIP",
"=",
"staticAddress",
"\n",
"}",
"\n\n",
"disk",
",",
"err",
":=",
"c",
".",
"disk",
"(",
")",
"\n",
"if",
"disk",
"==",
"nil",
"||",
"err",
"!=",
"nil",
"{",
"instance",
".",
"Disks",
"[",
"0",
"]",
".",
"InitializeParams",
"=",
"&",
"raw",
".",
"AttachedDiskInitializeParams",
"{",
"DiskName",
":",
"c",
".",
"diskName",
"(",
")",
",",
"SourceImage",
":",
"\"",
"\"",
"+",
"d",
".",
"MachineImage",
",",
"// The maximum supported disk size is 1000GB, the cast should be fine.",
"DiskSizeGb",
":",
"int64",
"(",
"d",
".",
"DiskSize",
")",
",",
"DiskType",
":",
"c",
".",
"diskType",
"(",
")",
",",
"}",
"\n",
"}",
"else",
"{",
"instance",
".",
"Disks",
"[",
"0",
"]",
".",
"Source",
"=",
"c",
".",
"zoneURL",
"+",
"\"",
"\"",
"+",
"c",
".",
"instanceName",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"op",
",",
"err",
":=",
"c",
".",
"service",
".",
"Instances",
".",
"Insert",
"(",
"c",
".",
"project",
",",
"c",
".",
"zone",
",",
"instance",
")",
".",
"Do",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"=",
"c",
".",
"waitForRegionalOp",
"(",
"op",
".",
"Name",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"instance",
",",
"err",
"=",
"c",
".",
"instance",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"c",
".",
"uploadSSHKey",
"(",
"instance",
",",
"d",
".",
"GetSSHKeyPath",
"(",
")",
")",
"\n",
"}"
] |
8,320 | all-8321 | [
"connectionCreated",
"registers",
"the",
"passed",
"connection",
"and",
"marks",
"the",
"target",
"identified",
"by",
"conn",
".",
"RemoteTCPAddr",
"()",
"as",
"established",
"and",
"puts",
"it",
"in",
"the",
"TargetConnected",
"state",
"."
] | [
"func",
"(",
"cm",
"*",
"connectionMaker",
")",
"connectionCreated",
"(",
"conn",
"Connection",
")",
"{",
"cm",
".",
"actionChan",
"<-",
"func",
"(",
")",
"bool",
"{",
"cm",
".",
"connections",
"[",
"<mask>",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"if",
"conn",
".",
"isOutbound",
"(",
")",
"{",
"target",
":=",
"cm",
".",
"targets",
"[",
"conn",
".",
"remoteTCPAddress",
"(",
")",
"]",
"\n",
"target",
".",
"state",
"=",
"targetConnected",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}",
"\n",
"}"
] |
8,321 | all-8322 | [
"Request",
"adds",
"a",
"new",
"request",
"route",
"registry",
"."
] | [
"func",
"(",
"r",
"*",
"Router",
")",
"<mask>",
"(",
"route",
"string",
",",
"handler",
"func",
"(",
"ctx",
"*",
"neptulon",
".",
"ReqCtx",
")",
"error",
")",
"{",
"r",
".",
"routes",
"[",
"route",
"]",
"=",
"handler",
"\n",
"}"
] |
8,322 | all-8323 | [
"Load",
"reads",
"current",
"content",
"of",
"the",
"filename",
"and",
"loads",
"records",
"."
] | [
"func",
"(",
"r",
"*",
"CSVReport",
")",
"Load",
"(",
")",
"error",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"r",
".",
"Filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"file",
".",
"Close",
"(",
")",
"\n\n",
"<mask>",
":=",
"csv",
".",
"NewReader",
"(",
"file",
")",
"\n",
"for",
"line",
":=",
"1",
";",
"err",
"!=",
"io",
".",
"EOF",
";",
"line",
"++",
"{",
"record",
",",
"err",
":=",
"reader",
".",
"Read",
"(",
")",
"\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"break",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"r",
".",
"addRecord",
"(",
"record",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"logf",
"(",
"\"",
"\"",
",",
"r",
".",
"Filename",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
8,323 | all-8324 | [
"Error",
"implements",
"the",
"error",
"interface",
".",
"The",
"string",
"returned",
"prints",
"the",
"error",
"text",
"of",
"this",
"error",
"any",
"any",
"wrapped",
"errors",
"each",
"separated",
"by",
"a",
"colon",
"and",
"a",
"space",
"(",
":",
")",
".",
"After",
"the",
"error",
"message",
"(",
"or",
"messages",
")",
"comes",
"the",
"key",
"/",
"value",
"pairs",
".",
"The",
"resulting",
"string",
"can",
"be",
"parsed",
"with",
"the",
"Parse",
"function",
"."
] | [
"func",
"(",
"e",
"*",
"errorT",
")",
"Error",
"(",
")",
"string",
"{",
"var",
"(",
"text",
"=",
"strings",
".",
"TrimSpace",
"(",
"e",
".",
"text",
")",
"\n",
"prevText",
"[",
"]",
"byte",
"\n",
"prevList",
"List",
"\n",
")",
"\n",
"if",
"e",
".",
"err",
"!=",
"nil",
"{",
"input",
":=",
"[",
"]",
"byte",
"(",
"e",
".",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"prevText",
",",
"prevList",
"=",
"Parse",
"(",
"input",
")",
"\n",
"if",
"len",
"(",
"prevText",
")",
"==",
"0",
"&&",
"len",
"(",
"prevList",
")",
">",
"0",
"{",
"// The previous message consists only of key/value",
"// pairs. Search for a key indicating the message.",
"i",
":=",
"0",
"\n",
"newLen",
":=",
"len",
"(",
"prevList",
")",
"\n",
"for",
";",
"i",
"<",
"len",
"(",
"prevList",
")",
";",
"i",
"+=",
"2",
"{",
"key",
",",
"_",
":=",
"prevList",
"[",
"i",
"]",
".",
"(",
"string",
")",
"\n",
"if",
"key",
"==",
"\"",
"\"",
"{",
"if",
"value",
",",
"ok",
":=",
"prevList",
"[",
"i",
"+",
"1",
"]",
".",
"(",
"string",
")",
";",
"ok",
"{",
"prevText",
"=",
"[",
"]",
"byte",
"(",
"value",
")",
"\n",
"newLen",
"-=",
"2",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"for",
";",
"i",
"<",
"len",
"(",
"prevList",
")",
"-",
"2",
";",
"i",
"+=",
"2",
"{",
"prevList",
"[",
"i",
"]",
"=",
"prevList",
"[",
"i",
"+",
"2",
"]",
"\n",
"prevList",
"[",
"i",
"+",
"1",
"]",
"=",
"prevList",
"[",
"i",
"+",
"3",
"]",
"\n",
"}",
"\n",
"prevList",
"=",
"prevList",
"[",
":",
"newLen",
"]",
"\n",
"}",
"\n",
"}",
"\n\n",
"buf",
":=",
"pool",
".",
"AllocBuffer",
"(",
")",
"\n",
"defer",
"pool",
".",
"ReleaseBuffer",
"(",
"buf",
")",
"\n\n",
"if",
"len",
"(",
"text",
")",
">",
"0",
"{",
"buf",
".",
"WriteString",
"(",
"text",
")",
"\n",
"if",
"len",
"(",
"prevText",
")",
">",
"0",
"{",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"buf",
".",
"Write",
"(",
"prevText",
")",
"\n\n",
"list",
":=",
"dedup",
"(",
"e",
".",
"list",
",",
"prevList",
",",
"e",
".",
"ctxlist",
")",
"\n",
"if",
"len",
"(",
"<mask>",
")",
">",
"0",
"{",
"if",
"buf",
".",
"Len",
"(",
")",
">",
"0",
"{",
"buf",
".",
"WriteRune",
"(",
"' '",
")",
"\n",
"}",
"\n",
"list",
".",
"writeToBuffer",
"(",
"buf",
")",
"\n",
"}",
"\n\n",
"return",
"buf",
".",
"String",
"(",
")",
"\n",
"}"
] |
8,324 | all-8325 | [
"NewWriterLogger",
"creates",
"a",
"new",
"io",
".",
"Writer",
"based",
"logger",
"."
] | [
"func",
"NewWriterLogger",
"(",
"conf",
"*",
"WriterConfig",
",",
"out",
"io",
".",
"Writer",
")",
"(",
"Logger",
",",
"error",
")",
"{",
"l",
":=",
"&",
"writerLogger",
"{",
"}",
"\n\n",
"base",
",",
"err",
":=",
"NewLoggerBase",
"(",
"conf",
".",
"BaseConfig",
",",
"l",
".",
"log",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"flags",
":=",
"log",
".",
"LstdFlags",
"\n",
"if",
"conf",
".",
"UTC",
"{",
"flags",
"|=",
"log",
".",
"LUTC",
"\n",
"}",
"\n\n",
"l",
".",
"logger",
"=",
"<mask>",
".",
"New",
"(",
"out",
",",
"conf",
".",
"Prefix",
",",
"flags",
")",
"\n",
"l",
".",
"LoggerBase",
"=",
"base",
"\n\n",
"return",
"l",
",",
"nil",
"\n",
"}"
] |
8,325 | all-8326 | [
"UntagResource",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockSecretsManagerAPI",
")",
"UntagResource",
"(",
"arg0",
"*",
"secretsmanager",
".",
"UntagResourceInput",
")",
"(",
"*",
"secretsmanager",
".",
"UntagResourceOutput",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"*",
"secretsmanager",
".",
"UntagResourceOutput",
")",
"\n",
"ret1",
",",
"_",
":=",
"<mask>",
"[",
"1",
"]",
".",
"(",
"error",
")",
"\n",
"return",
"ret0",
",",
"ret1",
"\n",
"}"
] |
8,326 | all-8327 | [
"writeKeyEvent",
"trims",
"the",
"prefix",
"of",
"key",
"path",
"in",
"a",
"single",
"Event",
"under",
"StoreKeysPrefix",
"serializes",
"it",
"and",
"writes",
"the",
"resulting",
"JSON",
"to",
"the",
"given",
"ResponseWriter",
"along",
"with",
"the",
"appropriate",
"headers",
"."
] | [
"func",
"writeKeyEvent",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"resp",
"etcdserver",
".",
"Response",
",",
"noValueOnSuccess",
"bool",
")",
"error",
"{",
"ev",
":=",
"resp",
".",
"Event",
"\n",
"if",
"ev",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprint",
"(",
"ev",
".",
"EtcdIndex",
")",
")",
"\n",
"w",
".",
"<mask>",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprint",
"(",
"resp",
".",
"Index",
")",
")",
"\n",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprint",
"(",
"resp",
".",
"Term",
")",
")",
"\n\n",
"if",
"ev",
".",
"IsCreated",
"(",
")",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusCreated",
")",
"\n",
"}",
"\n\n",
"ev",
"=",
"trimEventPrefix",
"(",
"ev",
",",
"etcdserver",
".",
"StoreKeysPrefix",
")",
"\n",
"if",
"noValueOnSuccess",
"&&",
"(",
"ev",
".",
"Action",
"==",
"v2store",
".",
"Set",
"||",
"ev",
".",
"Action",
"==",
"v2store",
".",
"CompareAndSwap",
"||",
"ev",
".",
"Action",
"==",
"v2store",
".",
"Create",
"||",
"ev",
".",
"Action",
"==",
"v2store",
".",
"Update",
")",
"{",
"ev",
".",
"Node",
"=",
"nil",
"\n",
"ev",
".",
"PrevNode",
"=",
"nil",
"\n",
"}",
"\n",
"return",
"json",
".",
"NewEncoder",
"(",
"w",
")",
".",
"Encode",
"(",
"ev",
")",
"\n",
"}"
] |
8,327 | all-8328 | [
"SwitchMode",
"is",
"handle",
"to",
"store",
"switch",
"status",
"in",
"cookie"
] | [
"func",
"(",
"controller",
")",
"SwitchMode",
"(",
"context",
"*",
"admin",
".",
"Context",
")",
"{",
"utils",
".",
"SetCookie",
"(",
"http",
".",
"Cookie",
"{",
"Name",
":",
"\"",
"\"",
",",
"<mask>",
":",
"context",
".",
"Request",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"}",
",",
"context",
".",
"Context",
")",
"\n\n",
"referrer",
":=",
"context",
".",
"Request",
".",
"Referer",
"(",
")",
"\n",
"if",
"referrer",
"==",
"\"",
"\"",
"{",
"referrer",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"http",
".",
"Redirect",
"(",
"context",
".",
"Writer",
",",
"context",
".",
"Request",
",",
"referrer",
",",
"http",
".",
"StatusFound",
")",
"\n",
"}"
] |
8,328 | all-8329 | [
"SetCurrentTheme",
"changes",
"the",
"current",
"theme",
".",
"Returns",
"false",
"if",
"changing",
"failed",
"-",
"e",
".",
"g",
"theme",
"does",
"not",
"exist"
] | [
"func",
"SetCurrentTheme",
"(",
"name",
"string",
")",
"bool",
"{",
"thememtx",
".",
"RLock",
"(",
")",
"\n",
"_",
",",
"ok",
":=",
"themeManager",
".",
"themes",
"[",
"name",
"]",
"\n",
"thememtx",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"!",
"ok",
"{",
"tnames",
":=",
"ThemeNames",
"(",
")",
"\n",
"for",
"_",
",",
"theme",
":=",
"range",
"tnames",
"{",
"if",
"theme",
"==",
"name",
"{",
"themeManager",
".",
"loadTheme",
"(",
"theme",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"thememtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"thememtx",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"themeManager",
".",
"themes",
"[",
"name",
"]",
";",
"<mask>",
"{",
"themeManager",
".",
"current",
"=",
"name",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] |
8,329 | all-8330 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"AddRuleParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss64",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
8,330 | all-8331 | [
"CreateAndSync",
"is",
"the",
"main",
"workhorse",
"function",
"of",
"IssueCreator",
".",
"It",
"initializes",
"the",
"IssueCreator",
"asks",
"each",
"source",
"for",
"its",
"issues",
"to",
"sync",
"and",
"syncs",
"the",
"issues",
"."
] | [
"func",
"(",
"c",
"*",
"IssueCreator",
")",
"CreateAndSync",
"(",
")",
"{",
"var",
"err",
"error",
"\n",
"if",
"err",
"=",
"c",
".",
"initialize",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"glog",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"glog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"for",
"srcName",
",",
"src",
":=",
"range",
"sources",
"{",
"glog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"srcName",
")",
"\n",
"var",
"issues",
"[",
"]",
"Issue",
"\n",
"if",
"issues",
",",
"err",
"=",
"src",
".",
"Issues",
"(",
"c",
")",
";",
"err",
"!=",
"nil",
"{",
"glog",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"srcName",
",",
"err",
")",
"\n",
"<mask>",
"\n",
"}",
"\n\n",
"// Note: We assume that no issues made by this bot with ID's matching issues generated by",
"// sources will be created while this code is creating issues. If this is a possibility then",
"// this loop should be updated to fetch recently changed issues from github after every issue",
"// sync that results in an issue being created.",
"glog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"srcName",
")",
"\n",
"created",
":=",
"0",
"\n",
"for",
"_",
",",
"issue",
":=",
"range",
"issues",
"{",
"if",
"c",
".",
"sync",
"(",
"issue",
")",
"{",
"created",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"glog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"created",
",",
"len",
"(",
"issues",
")",
",",
"srcName",
",",
")",
"\n",
"}",
"\n",
"}"
] |
8,331 | all-8332 | [
"ParallelSelect",
"creates",
"an",
"Enumerable",
"which",
"will",
"use",
"all",
"logically",
"available",
"CPUs",
"to",
"execute",
"a",
"Transform",
"."
] | [
"func",
"ParallelSelect",
"(",
"original",
"Enumerable",
",",
"operation",
"Transform",
")",
"Enumerable",
"{",
"return",
"parallelSelecter",
"{",
"<mask>",
":",
"original",
",",
"operation",
":",
"operation",
",",
"}",
"\n",
"}"
] |
8,332 | all-8333 | [
"matrixIterSlice",
"populates",
"a",
"matrix",
"vector",
"covering",
"the",
"requested",
"range",
"for",
"a",
"single",
"time",
"series",
"with",
"points",
"retrieved",
"from",
"an",
"iterator",
".",
"As",
"an",
"optimization",
"the",
"matrix",
"vector",
"may",
"already",
"contain",
"points",
"of",
"the",
"same",
"time",
"series",
"from",
"the",
"evaluation",
"of",
"an",
"earlier",
"step",
"(",
"with",
"lower",
"mint",
"and",
"maxt",
"values",
")",
".",
"Any",
"such",
"points",
"falling",
"before",
"mint",
"are",
"discarded",
";",
"points",
"that",
"fall",
"into",
"the",
"[",
"mint",
"maxt",
"]",
"range",
"are",
"retained",
";",
"only",
"points",
"with",
"later",
"timestamps",
"are",
"populated",
"from",
"the",
"iterator",
"."
] | [
"func",
"(",
"ev",
"*",
"evaluator",
")",
"matrixIterSlice",
"(",
"it",
"*",
"storage",
".",
"BufferedSeriesIterator",
",",
"mint",
",",
"maxt",
"int64",
",",
"out",
"[",
"]",
"Point",
")",
"[",
"]",
"Point",
"{",
"if",
"len",
"(",
"out",
")",
">",
"0",
"&&",
"out",
"[",
"len",
"(",
"out",
")",
"-",
"1",
"]",
".",
"T",
">=",
"mint",
"{",
"// There is an overlap between previous and current ranges, retain common",
"// points. In most such cases:",
"// (a) the overlap is significantly larger than the eval step; and/or",
"// (b) the number of samples is relatively small.",
"// so a linear search will be as fast as a binary search.",
"var",
"drop",
"int",
"\n",
"for",
"drop",
"=",
"0",
";",
"out",
"[",
"<mask>",
"]",
".",
"T",
"<",
"mint",
";",
"drop",
"++",
"{",
"}",
"\n",
"copy",
"(",
"out",
",",
"out",
"[",
"drop",
":",
"]",
")",
"\n",
"out",
"=",
"out",
"[",
":",
"len",
"(",
"out",
")",
"-",
"drop",
"]",
"\n",
"// Only append points with timestamps after the last timestamp we have.",
"mint",
"=",
"out",
"[",
"len",
"(",
"out",
")",
"-",
"1",
"]",
".",
"T",
"+",
"1",
"\n",
"}",
"else",
"{",
"out",
"=",
"out",
"[",
":",
"0",
"]",
"\n",
"}",
"\n\n",
"ok",
":=",
"it",
".",
"Seek",
"(",
"maxt",
")",
"\n",
"if",
"!",
"ok",
"{",
"if",
"it",
".",
"Err",
"(",
")",
"!=",
"nil",
"{",
"ev",
".",
"error",
"(",
"it",
".",
"Err",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"buf",
":=",
"it",
".",
"Buffer",
"(",
")",
"\n",
"for",
"buf",
".",
"Next",
"(",
")",
"{",
"t",
",",
"v",
":=",
"buf",
".",
"At",
"(",
")",
"\n",
"if",
"value",
".",
"IsStaleNaN",
"(",
"v",
")",
"{",
"continue",
"\n",
"}",
"\n",
"// Values in the buffer are guaranteed to be smaller than maxt.",
"if",
"t",
">=",
"mint",
"{",
"if",
"ev",
".",
"currentSamples",
">=",
"ev",
".",
"maxSamples",
"{",
"ev",
".",
"error",
"(",
"ErrTooManySamples",
"(",
"env",
")",
")",
"\n",
"}",
"\n",
"out",
"=",
"append",
"(",
"out",
",",
"Point",
"{",
"T",
":",
"t",
",",
"V",
":",
"v",
"}",
")",
"\n",
"ev",
".",
"currentSamples",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"// The seeked sample might also be in the range.",
"if",
"ok",
"{",
"t",
",",
"v",
":=",
"it",
".",
"Values",
"(",
")",
"\n",
"if",
"t",
"==",
"maxt",
"&&",
"!",
"value",
".",
"IsStaleNaN",
"(",
"v",
")",
"{",
"if",
"ev",
".",
"currentSamples",
">=",
"ev",
".",
"maxSamples",
"{",
"ev",
".",
"error",
"(",
"ErrTooManySamples",
"(",
"env",
")",
")",
"\n",
"}",
"\n",
"out",
"=",
"append",
"(",
"out",
",",
"Point",
"{",
"T",
":",
"t",
",",
"V",
":",
"v",
"}",
")",
"\n",
"ev",
".",
"currentSamples",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"out",
"\n",
"}"
] |
8,333 | all-8334 | [
"NewNodeId",
"creates",
"a",
"new",
"NodeId",
"."
] | [
"func",
"NewNodeId",
"(",
"aType",
"CryptoKeyType",
",",
"value",
"interface",
"{",
"}",
")",
"(",
"result",
"NodeId",
",",
"err",
"error",
")",
"{",
"u",
",",
"err",
":=",
"NewPublicKey",
"(",
"aType",
",",
"value",
")",
"\n",
"<mask>",
"=",
"NodeId",
"(",
"u",
")",
"\n",
"return",
"\n",
"}"
] |
8,334 | all-8335 | [
"SetHTML",
"sets",
"or",
"resets",
"whether",
"the",
"message",
"should",
"be",
"parsed",
"as",
"HTML",
"or",
"plain",
"text",
"(",
"optional",
")",
"."
] | [
"func",
"(",
"om",
"*",
"OutgoingMessage",
")",
"SetHTML",
"(",
"to",
"bool",
")",
"*",
"OutgoingMessage",
"{",
"if",
"to",
"{",
"om",
".",
"ParseMode",
"=",
"ModeHTML",
"\n",
"}",
"else",
"{",
"om",
".",
"ParseMode",
"=",
"ModeDefault",
"\n",
"}",
"\n",
"<mask>",
"om",
"\n",
"}"
] |
8,335 | all-8336 | [
"GetHAdjustment",
"is",
"a",
"wrapper",
"around",
"gtk_scrollable_get_hadjustment",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Scrollable",
")",
"GetHAdjustment",
"(",
")",
"(",
"*",
"Adjustment",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gtk_scrollable_get_hadjustment",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"<mask>",
"wrapAdjustment",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
",",
"nil",
"\n",
"}"
] |
8,336 | all-8337 | [
"export",
"FrameSet_Start"
] | [
"func",
"FrameSet_Start",
"(",
"id",
"FrameSetId",
")",
"C",
".",
"int",
"{",
"fs",
",",
"<mask>",
":=",
"sFrameSets",
".",
"Get",
"(",
"id",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"C",
".",
"int",
"(",
"0",
")",
"\n",
"}",
"\n",
"return",
"C",
".",
"int",
"(",
"fs",
".",
"Start",
"(",
")",
")",
"\n",
"}"
] |
8,337 | all-8338 | [
"the",
"caller",
"of",
"this",
"function",
"must",
"have",
"the",
"peers",
"mutex",
"."
] | [
"func",
"(",
"t",
"*",
"Transport",
")",
"removePeer",
"(",
"id",
"types",
".",
"ID",
")",
"{",
"if",
"<mask>",
",",
"ok",
":=",
"t",
".",
"peers",
"[",
"id",
"]",
";",
"ok",
"{",
"peer",
".",
"stop",
"(",
")",
"\n",
"}",
"else",
"{",
"if",
"t",
".",
"Logger",
"!=",
"nil",
"{",
"t",
".",
"Logger",
".",
"Panic",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"id",
".",
"String",
"(",
")",
")",
")",
"\n",
"}",
"else",
"{",
"plog",
".",
"Panicf",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"}",
"\n",
"}",
"\n",
"delete",
"(",
"t",
".",
"peers",
",",
"id",
")",
"\n",
"delete",
"(",
"t",
".",
"LeaderStats",
".",
"Followers",
",",
"id",
".",
"String",
"(",
")",
")",
"\n",
"t",
".",
"pipelineProber",
".",
"Remove",
"(",
"id",
".",
"String",
"(",
")",
")",
"\n",
"t",
".",
"streamProber",
".",
"Remove",
"(",
"id",
".",
"String",
"(",
")",
")",
"\n\n",
"if",
"t",
".",
"Logger",
"!=",
"nil",
"{",
"t",
".",
"Logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"t",
".",
"ID",
".",
"String",
"(",
")",
")",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"id",
".",
"String",
"(",
")",
")",
",",
")",
"\n",
"}",
"else",
"{",
"plog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"}",
"\n",
"}"
] |
8,338 | all-8339 | [
"GenMyMySQL",
"generates",
"a",
"MyMySQL",
"MySQL",
"DSN",
"from",
"the",
"passed",
"URL",
"."
] | [
"func",
"GenMyMySQL",
"(",
"u",
"*",
"URL",
")",
"(",
"string",
",",
"error",
")",
"{",
"host",
",",
"port",
",",
"dbname",
":=",
"hostname",
"(",
"u",
".",
"Host",
")",
",",
"hostport",
"(",
"u",
".",
"Host",
")",
",",
"strings",
".",
"TrimPrefix",
"(",
"u",
".",
"Path",
",",
"\"",
"\"",
")",
"\n\n",
"// resolve path",
"if",
"u",
".",
"Proto",
"==",
"\"",
"\"",
"{",
"if",
"host",
"==",
"\"",
"\"",
"{",
"dbname",
"=",
"\"",
"\"",
"+",
"dbname",
"\n",
"}",
"\n",
"host",
",",
"dbname",
"=",
"resolveSocket",
"(",
"stdpath",
".",
"Join",
"(",
"host",
",",
"dbname",
")",
")",
"\n",
"port",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"// save host, port, dbname",
"if",
"u",
".",
"hostPortDB",
"==",
"nil",
"{",
"u",
".",
"hostPortDB",
"=",
"[",
"]",
"string",
"{",
"host",
",",
"port",
",",
"dbname",
"}",
"\n",
"}",
"\n\n",
"// if host or proto is not empty",
"if",
"u",
".",
"Proto",
"!=",
"\"",
"\"",
"{",
"if",
"host",
"==",
"\"",
"\"",
"{",
"host",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"port",
"==",
"\"",
"\"",
"{",
"port",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"port",
"!=",
"\"",
"\"",
"{",
"port",
"=",
"\"",
"\"",
"+",
"<mask>",
"\n",
"}",
"\n\n",
"dsn",
":=",
"u",
".",
"Proto",
"+",
"\"",
"\"",
"+",
"host",
"+",
"port",
"\n\n",
"// add opts",
"dsn",
"+=",
"genOptions",
"(",
"convertOptions",
"(",
"u",
".",
"Query",
"(",
")",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"false",
",",
")",
"\n\n",
"// add dbname",
"dsn",
"+=",
"\"",
"\"",
"+",
"dbname",
"\n\n",
"// add user/pass",
"if",
"u",
".",
"User",
"!=",
"nil",
"{",
"pass",
",",
"_",
":=",
"u",
".",
"User",
".",
"Password",
"(",
")",
"\n",
"dsn",
"+=",
"\"",
"\"",
"+",
"u",
".",
"User",
".",
"Username",
"(",
")",
"+",
"\"",
"\"",
"+",
"pass",
"\n",
"}",
"else",
"if",
"strings",
".",
"HasSuffix",
"(",
"dsn",
",",
"\"",
"\"",
")",
"{",
"dsn",
"+=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"dsn",
",",
"nil",
"\n",
"}"
] |
8,339 | all-8340 | [
"GetTags",
"returns",
"a",
"map",
"of",
"tags",
"."
] | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetTags",
"(",
"source",
"string",
")",
"(",
"TagMap",
",",
"error",
")",
"{",
"var",
"out",
"reqGetTags",
"\n",
"uri",
":=",
"\"",
"\"",
"\n",
"if",
"source",
"!=",
"\"",
"\"",
"{",
"uri",
"+=",
"\"",
"\"",
"+",
"<mask>",
"\n",
"}",
"\n",
"if",
"err",
":=",
"client",
".",
"doJsonRequest",
"(",
"\"",
"\"",
",",
"uri",
",",
"nil",
",",
"&",
"out",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"*",
"out",
".",
"Tags",
",",
"nil",
"\n",
"}"
] |
8,340 | all-8341 | [
"Procurement",
"-",
"method",
"to",
"issue",
"a",
"procurement",
"request",
"for",
"the",
"given",
"lease",
"item",
"."
] | [
"func",
"(",
"s",
"*",
"Lease",
")",
"Procurement",
"(",
")",
"(",
"skuTask",
"*",
"taskmanager",
".",
"Task",
")",
"{",
"if",
"skuConstructor",
",",
"ok",
":=",
"s",
".",
"availableSkus",
"[",
"s",
".",
"Sku",
"]",
";",
"ok",
"{",
"leaseMap",
":=",
"structs",
".",
"Map",
"(",
"s",
")",
"\n",
"sku",
":=",
"skuConstructor",
".",
"New",
"(",
"s",
".",
"taskManager",
",",
"leaseMap",
")",
"\n",
"GLogger",
".",
"Println",
"(",
"\"",
"\"",
",",
"sku",
")",
"\n",
"skuTask",
"=",
"sku",
".",
"Procurement",
"(",
")",
"\n",
"tt",
":=",
"skuTask",
".",
"Read",
"(",
"func",
"(",
"t",
"*",
"taskmanager",
".",
"Task",
")",
"interface",
"{",
"}",
"{",
"tt",
":=",
"*",
"t",
"\n",
"return",
"tt",
"\n",
"}",
")",
"\n",
"GLogger",
".",
"Println",
"(",
"\"",
"\"",
",",
"tt",
")",
"\n",
"s",
".",
"Task",
"=",
"skuTask",
".",
"GetRedactedVersion",
"(",
")",
"\n\n",
"}",
"else",
"{",
"GLogger",
".",
"Println",
"(",
"\"",
"\"",
",",
"s",
".",
"Sku",
",",
"s",
".",
"availableSkus",
")",
"\n",
"s",
".",
"Task",
".",
"<mask>",
"=",
"TaskStatusUnavailable",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
8,341 | all-8342 | [
"CloseStreams",
"closes",
"the",
"current",
"streams",
"."
] | [
"func",
"(",
"n",
"*",
"NetworkTransport",
")",
"CloseStreams",
"(",
")",
"{",
"n",
".",
"connPoolLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"n",
".",
"connPoolLock",
".",
"Unlock",
"(",
")",
"\n\n",
"// Close all the connections in the connection pool and then remove their",
"// entry.",
"for",
"k",
",",
"e",
":=",
"range",
"n",
".",
"connPool",
"{",
"for",
"_",
",",
"<mask>",
":=",
"range",
"e",
"{",
"conn",
".",
"Release",
"(",
")",
"\n",
"}",
"\n\n",
"delete",
"(",
"n",
".",
"connPool",
",",
"k",
")",
"\n",
"}",
"\n\n",
"// Cancel the existing connections and create a new context. Both these",
"// operations must always be done with the lock held otherwise we can create",
"// connection handlers that are holding a context that will never be",
"// cancelable.",
"n",
".",
"streamCtxLock",
".",
"Lock",
"(",
")",
"\n",
"n",
".",
"streamCancel",
"(",
")",
"\n",
"n",
".",
"setupStreamContext",
"(",
")",
"\n",
"n",
".",
"streamCtxLock",
".",
"Unlock",
"(",
")",
"\n",
"}"
] |
8,342 | all-8343 | [
"remountReadonly",
"will",
"bind",
"over",
"the",
"top",
"of",
"an",
"existing",
"path",
"and",
"ensure",
"that",
"it",
"is",
"read",
"-",
"only",
"."
] | [
"func",
"remountReadonly",
"(",
"<mask>",
"string",
")",
"error",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"5",
";",
"i",
"++",
"{",
"if",
"err",
":=",
"syscall",
".",
"Mount",
"(",
"\"",
"\"",
",",
"path",
",",
"\"",
"\"",
",",
"syscall",
".",
"MS_REMOUNT",
"|",
"syscall",
".",
"MS_RDONLY",
",",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"&&",
"!",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"switch",
"err",
"{",
"case",
"syscall",
".",
"EINVAL",
":",
"// Probably not a mountpoint, use bind-mount",
"if",
"err",
":=",
"syscall",
".",
"Mount",
"(",
"path",
",",
"path",
",",
"\"",
"\"",
",",
"syscall",
".",
"MS_BIND",
",",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"syscall",
".",
"Mount",
"(",
"path",
",",
"path",
",",
"\"",
"\"",
",",
"syscall",
".",
"MS_BIND",
"|",
"syscall",
".",
"MS_REMOUNT",
"|",
"syscall",
".",
"MS_RDONLY",
"|",
"syscall",
".",
"MS_REC",
"|",
"defaultMountFlags",
",",
"\"",
"\"",
")",
"\n",
"case",
"syscall",
".",
"EBUSY",
":",
"time",
".",
"Sleep",
"(",
"100",
"*",
"time",
".",
"Millisecond",
")",
"\n",
"continue",
"\n",
"default",
":",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
"}"
] |
8,343 | all-8344 | [
"NewOwners",
"consturcts",
"a",
"new",
"Owners",
"instance",
".",
"filenames",
"is",
"the",
"slice",
"of",
"files",
"changed",
"."
] | [
"func",
"NewOwners",
"(",
"log",
"*",
"logrus",
".",
"Entry",
",",
"filenames",
"[",
"]",
"string",
",",
"r",
"Repo",
",",
"s",
"int64",
")",
"Owners",
"{",
"return",
"Owners",
"{",
"filenames",
":",
"filenames",
",",
"repo",
":",
"r",
",",
"seed",
":",
"s",
",",
"log",
":",
"<mask>",
"}",
"\n",
"}"
] |
8,344 | all-8345 | [
"processConversion",
"marks",
"fields",
"as",
"used",
"if",
"they",
"re",
"part",
"of",
"a",
"type",
"conversion",
"."
] | [
"func",
"(",
"c",
"*",
"Checker",
")",
"processConversion",
"(",
"pkg",
"*",
"lint",
".",
"Pkg",
",",
"node",
"ast",
".",
"Node",
")",
"{",
"if",
"node",
",",
"ok",
":=",
"node",
".",
"(",
"*",
"ast",
".",
"CallExpr",
")",
";",
"ok",
"{",
"callTyp",
":=",
"pkg",
".",
"TypesInfo",
".",
"TypeOf",
"(",
"node",
".",
"Fun",
")",
"\n",
"var",
"typDst",
"*",
"types",
".",
"Struct",
"\n",
"var",
"ok",
"bool",
"\n",
"switch",
"typ",
":=",
"callTyp",
".",
"(",
"<mask>",
")",
"{",
"case",
"*",
"types",
".",
"Named",
":",
"typDst",
",",
"ok",
"=",
"typ",
".",
"Underlying",
"(",
")",
".",
"(",
"*",
"types",
".",
"Struct",
")",
"\n",
"case",
"*",
"types",
".",
"Pointer",
":",
"typDst",
",",
"ok",
"=",
"typ",
".",
"Elem",
"(",
")",
".",
"Underlying",
"(",
")",
".",
"(",
"*",
"types",
".",
"Struct",
")",
"\n",
"default",
":",
"return",
"\n",
"}",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"typ",
",",
"ok",
":=",
"pkg",
".",
"TypesInfo",
".",
"TypeOf",
"(",
"node",
".",
"Args",
"[",
"0",
"]",
")",
".",
"(",
"*",
"types",
".",
"Basic",
")",
";",
"ok",
"&&",
"typ",
".",
"Kind",
"(",
")",
"==",
"types",
".",
"UnsafePointer",
"{",
"// This is an unsafe conversion. Assume that all the",
"// fields are relevant (they are, because of memory",
"// layout)",
"n",
":=",
"typDst",
".",
"NumFields",
"(",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"c",
".",
"graph",
".",
"markUsedBy",
"(",
"typDst",
".",
"Field",
"(",
"i",
")",
",",
"typDst",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n\n",
"typSrc",
",",
"ok",
":=",
"dereferenceType",
"(",
"pkg",
".",
"TypesInfo",
".",
"TypeOf",
"(",
"node",
".",
"Args",
"[",
"0",
"]",
")",
")",
".",
"Underlying",
"(",
")",
".",
"(",
"*",
"types",
".",
"Struct",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
"}",
"\n\n",
"// When we convert from type t1 to t2, were t1 and t2 are",
"// structs, all fields are relevant, as otherwise the",
"// conversion would fail.",
"//",
"// We mark t2's fields as used by t1's fields, and vice",
"// versa. That way, if no code actually refers to a field",
"// in either type, it's still correctly marked as unused.",
"// If a field is used in either struct, it's implicitly",
"// relevant in the other one, too.",
"//",
"// It works in a similar way for conversions between types",
"// of two packages, only that the extra information in the",
"// graph is redundant unless we're in whole program mode.",
"n",
":=",
"typDst",
".",
"NumFields",
"(",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"fDst",
":=",
"typDst",
".",
"Field",
"(",
"i",
")",
"\n",
"fSrc",
":=",
"typSrc",
".",
"Field",
"(",
"i",
")",
"\n",
"c",
".",
"graph",
".",
"markUsedBy",
"(",
"fDst",
",",
"fSrc",
")",
"\n",
"c",
".",
"graph",
".",
"markUsedBy",
"(",
"fSrc",
",",
"fDst",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
8,345 | all-8346 | [
"Index",
"returns",
"the",
"path",
"to",
"the",
"file",
"at",
"the",
"given",
"index",
"in",
"the",
"sequence",
".",
"If",
"a",
"frame",
"range",
"was",
"not",
"parsed",
"from",
"the",
"sequence",
"this",
"will",
"always",
"returns",
"the",
"original",
"path",
".",
"If",
"the",
"index",
"is",
"not",
"valid",
"this",
"will",
"return",
"an",
"empty",
"string",
"."
] | [
"func",
"(",
"s",
"*",
"FileSequence",
")",
"Index",
"(",
"idx",
"int",
")",
"string",
"{",
"if",
"s",
".",
"frameSet",
"==",
"nil",
"{",
"return",
"s",
".",
"String",
"(",
")",
"\n",
"}",
"\n",
"<mask>",
",",
"err",
":=",
"s",
".",
"frameSet",
".",
"Frame",
"(",
"idx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"path",
",",
"err",
":=",
"s",
".",
"Frame",
"(",
"frame",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"path",
"\n",
"}"
] |
8,346 | all-8347 | [
"GuestOS",
"returns",
"the",
"guest",
"os",
"."
] | [
"func",
"(",
"v",
"*",
"VM",
")",
"GuestOS",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"<mask>",
"err",
"C",
".",
"VixError",
"=",
"C",
".",
"VIX_OK",
"\n",
"var",
"os",
"*",
"C",
".",
"char",
"\n\n",
"err",
"=",
"C",
".",
"get_property",
"(",
"v",
".",
"handle",
",",
"C",
".",
"VIX_PROPERTY_VM_GUESTOS",
",",
"unsafe",
".",
"Pointer",
"(",
"&",
"os",
")",
")",
"\n\n",
"defer",
"C",
".",
"Vix_FreeBuffer",
"(",
"unsafe",
".",
"Pointer",
"(",
"os",
")",
")",
"\n\n",
"if",
"C",
".",
"VIX_OK",
"!=",
"err",
"{",
"return",
"\"",
"\"",
",",
"&",
"Error",
"{",
"Operation",
":",
"\"",
"\"",
",",
"Code",
":",
"int",
"(",
"err",
"&",
"0xFFFF",
")",
",",
"Text",
":",
"C",
".",
"GoString",
"(",
"C",
".",
"Vix_GetErrorText",
"(",
"err",
",",
"nil",
")",
")",
",",
"}",
"\n",
"}",
"\n\n",
"return",
"C",
".",
"GoString",
"(",
"os",
")",
",",
"nil",
"\n",
"}"
] |
8,347 | all-8348 | [
"<array",
"-",
"type",
">",
"::",
"=",
"A",
"<",
"(",
"positive",
"dimension",
")",
"number",
">",
"_",
"<",
"(",
"element",
")",
"type",
">",
"::",
"=",
"A",
"[",
"<",
"(",
"dimension",
")",
"expression",
">",
"]",
"_",
"<",
"(",
"element",
")",
"type",
">"
] | [
"func",
"(",
"st",
"*",
"<mask>",
")",
"arrayType",
"(",
"isCast",
"bool",
")",
"AST",
"{",
"st",
".",
"checkChar",
"(",
"'A'",
")",
"\n\n",
"if",
"len",
"(",
"st",
".",
"str",
")",
"==",
"0",
"{",
"st",
".",
"fail",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"dim",
"AST",
"\n",
"if",
"st",
".",
"str",
"[",
"0",
"]",
"==",
"'_'",
"{",
"dim",
"=",
"&",
"Name",
"{",
"Name",
":",
"\"",
"\"",
"}",
"\n",
"}",
"else",
"if",
"isDigit",
"(",
"st",
".",
"str",
"[",
"0",
"]",
")",
"{",
"i",
":=",
"1",
"\n",
"for",
"len",
"(",
"st",
".",
"str",
")",
">",
"i",
"&&",
"isDigit",
"(",
"st",
".",
"str",
"[",
"i",
"]",
")",
"{",
"i",
"++",
"\n",
"}",
"\n",
"dim",
"=",
"&",
"Name",
"{",
"Name",
":",
"st",
".",
"str",
"[",
":",
"i",
"]",
"}",
"\n",
"st",
".",
"advance",
"(",
"i",
")",
"\n",
"}",
"else",
"{",
"dim",
"=",
"st",
".",
"expression",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"st",
".",
"str",
")",
"==",
"0",
"||",
"st",
".",
"str",
"[",
"0",
"]",
"!=",
"'_'",
"{",
"st",
".",
"fail",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"st",
".",
"advance",
"(",
"1",
")",
"\n\n",
"t",
":=",
"st",
".",
"demangleType",
"(",
"isCast",
")",
"\n\n",
"arr",
":=",
"&",
"ArrayType",
"{",
"Dimension",
":",
"dim",
",",
"Element",
":",
"t",
"}",
"\n\n",
"// Qualifiers on the element of an array type go on the whole",
"// array type.",
"if",
"q",
",",
"ok",
":=",
"arr",
".",
"Element",
".",
"(",
"*",
"TypeWithQualifiers",
")",
";",
"ok",
"{",
"return",
"&",
"TypeWithQualifiers",
"{",
"Base",
":",
"&",
"ArrayType",
"{",
"Dimension",
":",
"dim",
",",
"Element",
":",
"q",
".",
"Base",
"}",
",",
"Qualifiers",
":",
"q",
".",
"Qualifiers",
"}",
"\n",
"}",
"\n\n",
"return",
"arr",
"\n",
"}"
] |
8,348 | all-8349 | [
"get",
"the",
"initial",
"RPC",
"containing",
"all",
"of",
"our",
"subscriptions",
"to",
"send",
"to",
"new",
"peers"
] | [
"func",
"(",
"p",
"*",
"PubSub",
")",
"getHelloPacket",
"(",
")",
"*",
"RPC",
"{",
"var",
"rpc",
"RPC",
"\n",
"for",
"t",
":=",
"range",
"p",
".",
"myTopics",
"{",
"<mask>",
":=",
"&",
"pb",
".",
"RPC_SubOpts",
"{",
"Topicid",
":",
"proto",
".",
"String",
"(",
"t",
")",
",",
"Subscribe",
":",
"proto",
".",
"Bool",
"(",
"true",
")",
",",
"}",
"\n",
"rpc",
".",
"Subscriptions",
"=",
"append",
"(",
"rpc",
".",
"Subscriptions",
",",
"as",
")",
"\n",
"}",
"\n",
"return",
"&",
"rpc",
"\n",
"}"
] |
8,349 | all-8350 | [
"Level",
"implements",
"the",
"driver",
".",
"Error",
"interface",
"."
] | [
"func",
"(",
"e",
"*",
"hdbErrors",
")",
"Level",
"(",
")",
"int",
"{",
"return",
"int",
"(",
"e",
".",
"<mask>",
"[",
"e",
".",
"idx",
"]",
".",
"errorLevel",
")",
"\n",
"}"
] |
8,350 | all-8351 | [
"RegisterCacheStats",
"creates",
"a",
"new",
"wrapper",
"for",
"groupcache",
"stats",
"that",
"implements",
"the",
"prometheus",
".",
"Collector",
"interface",
"and",
"registers",
"it"
] | [
"func",
"RegisterCacheStats",
"(",
"cacheName",
"string",
",",
"groupCacheStats",
"*",
"groupcache",
".",
"Stats",
")",
"{",
"c",
":=",
"&",
"cacheStats",
"{",
"cacheName",
":",
"cacheName",
",",
"descriptions",
":",
"make",
"(",
"<mask>",
"[",
"string",
"]",
"*",
"prometheus",
".",
"Desc",
")",
",",
"stats",
":",
"groupCacheStats",
",",
"}",
"\n",
"if",
"err",
":=",
"prometheus",
".",
"Register",
"(",
"c",
")",
";",
"err",
"!=",
"nil",
"{",
"// metrics may be redundantly registered; ignore these errors",
"if",
"_",
",",
"ok",
":=",
"err",
".",
"(",
"prometheus",
".",
"AlreadyRegisteredError",
")",
";",
"!",
"ok",
"{",
"logrus",
".",
"Infof",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
8,351 | all-8352 | [
"Bzip2Decompressor",
"is",
"a",
"DecompressorFunc",
"for",
"the",
"bzip2",
"compression",
"algorithm",
"."
] | [
"func",
"Bzip2Decompressor",
"(",
"r",
"<mask>",
".",
"Reader",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"return",
"ioutil",
".",
"NopCloser",
"(",
"bzip2",
".",
"NewReader",
"(",
"r",
")",
")",
",",
"nil",
"\n",
"}"
] |
8,352 | all-8353 | [
"resourceVSphereComputeClusterVMAffinityRuleObjects",
"handles",
"the",
"fetching",
"of",
"the",
"cluster",
"and",
"rule",
"key",
"depending",
"on",
"what",
"attributes",
"are",
"available",
":",
"*",
"If",
"the",
"resource",
"ID",
"is",
"available",
"the",
"data",
"is",
"derived",
"from",
"the",
"ID",
".",
"*",
"If",
"not",
"only",
"the",
"cluster",
"is",
"retrieved",
"from",
"compute_cluster_id",
".",
"-",
"1",
"is",
"returned",
"for",
"the",
"key",
"."
] | [
"func",
"resourceVSphereComputeClusterVMAffinityRuleObjects",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"meta",
"<mask>",
"{",
"}",
",",
")",
"(",
"*",
"object",
".",
"ClusterComputeResource",
",",
"int32",
",",
"error",
")",
"{",
"if",
"d",
".",
"Id",
"(",
")",
"!=",
"\"",
"\"",
"{",
"return",
"resourceVSphereComputeClusterVMAffinityRuleObjectsFromID",
"(",
"d",
",",
"meta",
")",
"\n",
"}",
"\n",
"return",
"resourceVSphereComputeClusterVMAffinityRuleObjectsFromAttributes",
"(",
"d",
",",
"meta",
")",
"\n",
"}"
] |
8,353 | all-8354 | [
"FetchCheckBySubmissionURL",
"fetch",
"a",
"check",
"configuration",
"by",
"submission_url"
] | [
"func",
"(",
"cm",
"*",
"CheckManager",
")",
"fetchCheckBySubmissionURL",
"(",
"submissionURL",
"api",
".",
"URLType",
")",
"(",
"*",
"api",
".",
"Check",
",",
"error",
")",
"{",
"if",
"string",
"(",
"submissionURL",
")",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"string",
"(",
"submissionURL",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// valid trap url: scheme://host[:port]/module/httptrap/UUID/secret",
"// does it smell like a valid trap url path",
"if",
"!",
"strings",
".",
"Contains",
"(",
"u",
".",
"Path",
",",
"\"",
"\"",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"submissionURL",
")",
"\n",
"}",
"\n\n",
"// extract uuid",
"pathParts",
":=",
"strings",
".",
"Split",
"(",
"strings",
".",
"Replace",
"(",
"u",
".",
"Path",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"1",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"pathParts",
")",
"!=",
"2",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"submissionURL",
")",
"\n",
"}",
"\n",
"uuid",
":=",
"pathParts",
"[",
"0",
"]",
"\n\n",
"filter",
":=",
"api",
".",
"SearchFilterType",
"{",
"\"",
"\"",
":",
"[",
"]",
"string",
"{",
"uuid",
"}",
"}",
"\n\n",
"checks",
",",
"err",
":=",
"cm",
".",
"apih",
".",
"SearchChecks",
"(",
"nil",
",",
"&",
"filter",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"*",
"checks",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"uuid",
")",
"\n",
"}",
"\n\n",
"numActive",
":=",
"0",
"\n",
"checkID",
":=",
"-",
"1",
"\n\n",
"for",
"idx",
",",
"check",
":=",
"range",
"*",
"checks",
"{",
"if",
"check",
".",
"Active",
"{",
"numActive",
"++",
"\n",
"checkID",
"=",
"idx",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"numActive",
">",
"1",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"uuid",
")",
"\n",
"}",
"\n\n",
"check",
":=",
"(",
"*",
"checks",
")",
"[",
"checkID",
"]",
"\n\n",
"return",
"&",
"<mask>",
",",
"nil",
"\n\n",
"}"
] |
8,354 | all-8355 | [
"GenerateSalt",
"génère",
"le",
"salage"
] | [
"func",
"GenerateSalt",
"(",
")",
"(",
"salt",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"salt",
"=",
"make",
"(",
"[",
"]",
"<mask>",
",",
"S",
")",
"\n",
"_",
",",
"err",
"=",
"rand",
".",
"Read",
"(",
"salt",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
8,355 | all-8356 | [
"NodeOfflineThreshold",
"returns",
"the",
"amount",
"of",
"time",
"that",
"needs",
"to",
"elapse",
"after",
"which",
"a",
"series",
"of",
"unsuccessful",
"heartbeat",
"will",
"make",
"the",
"node",
"be",
"considered",
"offline",
"."
] | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"NodeOfflineThreshold",
"(",
")",
"(",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"threshold",
":=",
"<mask>",
".",
"Duration",
"(",
"DefaultOfflineThreshold",
")",
"*",
"time",
".",
"Second",
"\n",
"values",
",",
"err",
":=",
"query",
".",
"SelectStrings",
"(",
"c",
".",
"tx",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"values",
")",
">",
"0",
"{",
"seconds",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"values",
"[",
"0",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"threshold",
"=",
"time",
".",
"Duration",
"(",
"seconds",
")",
"*",
"time",
".",
"Second",
"\n",
"}",
"\n",
"return",
"threshold",
",",
"nil",
"\n",
"}"
] |
8,356 | all-8357 | [
"GetIncludeUnitsOk",
"returns",
"a",
"tuple",
"with",
"the",
"IncludeUnits",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"y",
"*",
"Yaxis",
")",
"GetIncludeUnitsOk",
"(",
")",
"(",
"bool",
",",
"bool",
")",
"{",
"if",
"y",
"==",
"nil",
"||",
"y",
".",
"IncludeUnits",
"==",
"nil",
"{",
"return",
"false",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"y",
".",
"IncludeUnits",
",",
"<mask>",
"\n",
"}"
] |
8,357 | all-8358 | [
"Status",
"checks",
"the",
"status",
"of",
"an",
"existing",
"GDPR",
"request",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"Status",
"(",
"<mask>",
"string",
")",
"(",
"*",
"StatusResponse",
",",
"error",
")",
"{",
"statResp",
":=",
"&",
"StatusResponse",
"{",
"}",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"caller",
".",
"Call",
"(",
"\"",
"\"",
",",
"c",
".",
"endpoint",
"+",
"\"",
"\"",
"+",
"id",
",",
"nil",
")",
"\n",
"return",
"statResp",
",",
"c",
".",
"json",
"(",
"resp",
",",
"err",
",",
"true",
",",
"statResp",
")",
"\n",
"}"
] |
8,358 | all-8359 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"StartParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoProfiler12",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
8,359 | all-8360 | [
"getGTLDData",
"fetches",
"the",
"ICANN_GTLD_JSON",
"and",
"parses",
"it",
"into",
"a",
"list",
"of",
"util",
".",
"GTLDPeriod",
"objects",
"or",
"returns",
"an",
"error",
".",
"The",
"gTLDEntries",
"are",
"returned",
"as",
"-",
"is",
"and",
"may",
"contain",
"entries",
"that",
"were",
"never",
"delegated",
"from",
"the",
"root",
"DNS",
"."
] | [
"func",
"getGTLDData",
"(",
")",
"(",
"[",
"]",
"util",
".",
"GTLDPeriod",
",",
"error",
")",
"{",
"respBody",
",",
"err",
":=",
"getData",
"(",
"ICANN_GTLD_JSON",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"<mask>",
"results",
"struct",
"{",
"GTLDs",
"[",
"]",
"util",
".",
"GTLDPeriod",
"\n",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"respBody",
",",
"&",
"results",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"ICANN_GTLD_JSON",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"results",
".",
"GTLDs",
",",
"nil",
"\n",
"}"
] |
8,360 | all-8361 | [
"Validate",
"flag",
"value",
"using",
"validation",
"criteria",
"provided",
"in",
"metadata"
] | [
"func",
"validateFlagValue",
"(",
"<mask>",
"string",
",",
"param",
"*",
"metadata",
".",
"ActionParam",
")",
"error",
"{",
"if",
"param",
".",
"Regexp",
"!=",
"nil",
"{",
"if",
"!",
"param",
".",
"Regexp",
".",
"MatchString",
"(",
"value",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"value",
",",
"param",
".",
"Name",
",",
"param",
".",
"Regexp",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"param",
".",
"NonBlank",
"&&",
"value",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"param",
".",
"Name",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"param",
".",
"ValidValues",
")",
">",
"0",
"&&",
"param",
".",
"Name",
"!=",
"\"",
"\"",
"{",
"// filter[] is special: it has values just so --help can list them",
"found",
":=",
"false",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"param",
".",
"ValidValues",
"{",
"if",
"v",
"==",
"value",
"{",
"found",
"=",
"true",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"found",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"param",
".",
"Name",
",",
"strings",
".",
"Join",
"(",
"param",
".",
"ValidValues",
",",
"\"",
"\"",
")",
",",
"value",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
8,361 | all-8362 | [
"Profiler",
"is",
"a",
"convenient",
"subrouter",
"used",
"for",
"mounting",
"net",
"/",
"http",
"/",
"pprof",
".",
"ie",
".",
"func",
"MyService",
"()",
"http",
".",
"Handler",
"{",
"r",
":",
"=",
"chi",
".",
"NewRouter",
"()",
"//",
"..",
"middlewares",
"r",
".",
"Mount",
"(",
"/",
"debug",
"middleware",
".",
"Profiler",
"()",
")",
"//",
"..",
"routes",
"return",
"r",
"}"
] | [
"func",
"Profiler",
"(",
")",
"http",
".",
"Handler",
"{",
"r",
":=",
"chi",
".",
"NewRouter",
"(",
")",
"\n",
"r",
".",
"Use",
"(",
"NoCache",
")",
"\n\n",
"r",
".",
"Get",
"(",
"\"",
"\"",
",",
"func",
"(",
"w",
"<mask>",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"http",
".",
"Redirect",
"(",
"w",
",",
"r",
",",
"r",
".",
"RequestURI",
"+",
"\"",
"\"",
",",
"301",
")",
"\n",
"}",
")",
"\n",
"r",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"http",
".",
"Redirect",
"(",
"w",
",",
"r",
",",
"r",
".",
"RequestURI",
"+",
"\"",
"\"",
",",
"301",
")",
"\n",
"}",
")",
"\n\n",
"r",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"pprof",
".",
"Index",
")",
"\n",
"r",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"pprof",
".",
"Cmdline",
")",
"\n",
"r",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"pprof",
".",
"Profile",
")",
"\n",
"r",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"pprof",
".",
"Symbol",
")",
"\n",
"r",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"pprof",
".",
"Trace",
")",
"\n",
"r",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"expVars",
")",
"\n\n",
"return",
"r",
"\n",
"}"
] |
8,362 | all-8363 | [
"Reset",
"indicates",
"an",
"expected",
"call",
"of",
"Reset"
] | [
"func",
"(",
"mr",
"*",
"MockTimerMockRecorder",
")",
"Reset",
"(",
"arg0",
"<mask>",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
"TypeOf",
"(",
"(",
"*",
"MockTimer",
")",
"(",
"nil",
")",
".",
"Reset",
")",
",",
"arg0",
")",
"\n",
"}"
] |
8,363 | all-8364 | [
"newAgent",
"returns",
"a",
"new",
"ecsAgent",
"object",
"but",
"does",
"not",
"start",
"anything"
] | [
"func",
"newAgent",
"(",
"ctx",
"context",
".",
"Context",
",",
"blackholeEC2Metadata",
"bool",
",",
"acceptInsecureCert",
"*",
"bool",
")",
"(",
"<mask>",
",",
"error",
")",
"{",
"ec2MetadataClient",
":=",
"ec2",
".",
"NewEC2MetadataClient",
"(",
"nil",
")",
"\n",
"if",
"blackholeEC2Metadata",
"{",
"ec2MetadataClient",
"=",
"ec2",
".",
"NewBlackholeEC2MetadataClient",
"(",
")",
"\n",
"}",
"\n\n",
"seelog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"cfg",
",",
"err",
":=",
"config",
".",
"NewConfig",
"(",
"ec2MetadataClient",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// All required config values can be inferred from EC2 Metadata,",
"// so this error could be transient.",
"seelog",
".",
"Criticalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"cfg",
".",
"AcceptInsecureCert",
"=",
"aws",
".",
"BoolValue",
"(",
"acceptInsecureCert",
")",
"\n",
"if",
"cfg",
".",
"AcceptInsecureCert",
"{",
"seelog",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"seelog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"version",
".",
"Version",
",",
"version",
".",
"GitShortHash",
")",
"\n",
"seelog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"cfg",
".",
"String",
"(",
")",
")",
"\n\n",
"ec2Client",
":=",
"ec2",
".",
"NewClientImpl",
"(",
"cfg",
".",
"AWSRegion",
")",
"\n",
"dockerClient",
",",
"err",
":=",
"dockerapi",
".",
"NewDockerGoClient",
"(",
"sdkclientfactory",
".",
"NewFactory",
"(",
"ctx",
",",
"cfg",
".",
"DockerEndpoint",
")",
",",
"cfg",
",",
"ctx",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"// This is also non terminal in the current config",
"seelog",
".",
"Criticalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"metadataManager",
"containermetadata",
".",
"Manager",
"\n",
"if",
"cfg",
".",
"ContainerMetadataEnabled",
"{",
"// We use the default API client for the metadata inspect call. This version has some information",
"// missing which means if we need those fields later we will need to change this client to",
"// the appropriate version",
"metadataManager",
"=",
"containermetadata",
".",
"NewManager",
"(",
"dockerClient",
",",
"cfg",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"ecsAgent",
"{",
"ctx",
":",
"ctx",
",",
"ec2MetadataClient",
":",
"ec2MetadataClient",
",",
"ec2Client",
":",
"ec2Client",
",",
"cfg",
":",
"cfg",
",",
"dockerClient",
":",
"dockerClient",
",",
"// We instantiate our own credentialProvider for use in acs/tcs. This tries",
"// to mimic roughly the way it's instantiated by the SDK for a default",
"// session.",
"credentialProvider",
":",
"defaults",
".",
"CredChain",
"(",
"defaults",
".",
"Config",
"(",
")",
",",
"defaults",
".",
"Handlers",
"(",
")",
")",
",",
"stateManagerFactory",
":",
"factory",
".",
"NewStateManager",
"(",
")",
",",
"saveableOptionFactory",
":",
"factory",
".",
"NewSaveableOption",
"(",
")",
",",
"pauseLoader",
":",
"pause",
".",
"New",
"(",
")",
",",
"cniClient",
":",
"ecscni",
".",
"NewClient",
"(",
"&",
"ecscni",
".",
"Config",
"{",
"PluginsPath",
":",
"cfg",
".",
"CNIPluginsPath",
",",
"MinSupportedCNIVersion",
":",
"config",
".",
"DefaultMinSupportedCNIVersion",
",",
"}",
")",
",",
"os",
":",
"oswrapper",
".",
"New",
"(",
")",
",",
"metadataManager",
":",
"metadataManager",
",",
"terminationHandler",
":",
"sighandlers",
".",
"StartDefaultTerminationHandler",
",",
"mobyPlugins",
":",
"mobypkgwrapper",
".",
"NewPlugins",
"(",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] |
8,364 | all-8365 | [
"Retry",
"on",
"transport",
"failures",
".",
"Retries",
"on",
"500s",
"retries",
"after",
"sleep",
"on",
"ratelimit",
"exceeded",
"and",
"retries",
"404s",
"a",
"couple",
"times",
".",
"This",
"function",
"closes",
"the",
"response",
"body",
"iff",
"it",
"also",
"returns",
"an",
"error",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"requestRetry",
"(",
"method",
",",
"path",
",",
"accept",
"string",
",",
"body",
"<mask>",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"var",
"hostIndex",
"int",
"\n",
"var",
"resp",
"*",
"http",
".",
"Response",
"\n",
"var",
"err",
"error",
"\n",
"backoff",
":=",
"initialDelay",
"\n",
"for",
"retries",
":=",
"0",
";",
"retries",
"<",
"maxRetries",
";",
"retries",
"++",
"{",
"if",
"retries",
">",
"0",
"&&",
"resp",
"!=",
"nil",
"{",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"resp",
",",
"err",
"=",
"c",
".",
"doRequest",
"(",
"method",
",",
"c",
".",
"bases",
"[",
"hostIndex",
"]",
"+",
"path",
",",
"accept",
",",
"body",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"if",
"resp",
".",
"StatusCode",
"==",
"404",
"&&",
"retries",
"<",
"max404Retries",
"{",
"// Retry 404s a couple times. Sometimes GitHub is inconsistent in",
"// the sense that they send us an event such as \"PR opened\" but an",
"// immediate request to GET the PR returns 404. We don't want to",
"// retry more than a couple times in this case, because a 404 may",
"// be caused by a bad API call and we'll just burn through API",
"// tokens.",
"c",
".",
"time",
".",
"Sleep",
"(",
"backoff",
")",
"\n",
"backoff",
"*=",
"2",
"\n",
"}",
"else",
"if",
"resp",
".",
"StatusCode",
"==",
"403",
"{",
"if",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"{",
"// If we are out of API tokens, sleep first. The X-RateLimit-Reset",
"// header tells us the time at which we can request again.",
"var",
"t",
"int",
"\n",
"if",
"t",
",",
"err",
"=",
"strconv",
".",
"Atoi",
"(",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
")",
";",
"err",
"==",
"nil",
"{",
"// Sleep an extra second plus how long GitHub wants us to",
"// sleep. If it's going to take too long, then break.",
"sleepTime",
":=",
"c",
".",
"time",
".",
"Until",
"(",
"time",
".",
"Unix",
"(",
"int64",
"(",
"t",
")",
",",
"0",
")",
")",
"+",
"time",
".",
"Second",
"\n",
"if",
"sleepTime",
"<",
"maxSleepTime",
"{",
"c",
".",
"time",
".",
"Sleep",
"(",
"sleepTime",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"sleepTime",
",",
"maxSleepTime",
")",
"\n",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"else",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
",",
"err",
")",
"\n",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"else",
"if",
"rawTime",
":=",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
";",
"rawTime",
"!=",
"\"",
"\"",
"&&",
"rawTime",
"!=",
"\"",
"\"",
"{",
"// If we are getting abuse rate limited, we need to wait or",
"// else we risk continuing to make the situation worse",
"var",
"t",
"int",
"\n",
"if",
"t",
",",
"err",
"=",
"strconv",
".",
"Atoi",
"(",
"rawTime",
")",
";",
"err",
"==",
"nil",
"{",
"// Sleep an extra second plus how long GitHub wants us to",
"// sleep. If it's going to take too long, then break.",
"sleepTime",
":=",
"time",
".",
"Duration",
"(",
"t",
"+",
"1",
")",
"*",
"time",
".",
"Second",
"\n",
"if",
"sleepTime",
"<",
"maxSleepTime",
"{",
"c",
".",
"time",
".",
"Sleep",
"(",
"sleepTime",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"sleepTime",
",",
"maxSleepTime",
")",
"\n",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"else",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"rawTime",
",",
"err",
")",
"\n",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"else",
"if",
"oauthScopes",
":=",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
";",
"len",
"(",
"oauthScopes",
")",
">",
"0",
"{",
"authorizedScopes",
":=",
"resp",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"authorizedScopes",
"==",
"\"",
"\"",
"{",
"authorizedScopes",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"authorizedScopes",
",",
"oauthScopes",
")",
"\n",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"else",
"if",
"resp",
".",
"StatusCode",
"<",
"500",
"{",
"// Normal, happy case.",
"break",
"\n",
"}",
"else",
"{",
"// Retry 500 after a break.",
"c",
".",
"time",
".",
"Sleep",
"(",
"backoff",
")",
"\n",
"backoff",
"*=",
"2",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// Connection problem. Try a different host.",
"hostIndex",
"=",
"(",
"hostIndex",
"+",
"1",
")",
"%",
"len",
"(",
"c",
".",
"bases",
")",
"\n",
"c",
".",
"time",
".",
"Sleep",
"(",
"backoff",
")",
"\n",
"backoff",
"*=",
"2",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"resp",
",",
"err",
"\n",
"}"
] |
8,365 | all-8366 | [
"SeekToLast",
"seeks",
"position",
"at",
"the",
"last",
"entry",
"in",
"list",
".",
"Final",
"state",
"of",
"iterator",
"is",
"Valid",
"()",
"iff",
"list",
"is",
"not",
"empty",
"."
] | [
"func",
"(",
"it",
"*",
"Iterator",
")",
"SeekToLast",
"(",
")",
"{",
"it",
".",
"setNode",
"(",
"it",
".",
"list",
".",
"getPrev",
"(",
"it",
".",
"list",
".",
"tail",
",",
"0",
")",
",",
"<mask>",
")",
"\n",
"}"
] |
8,366 | all-8367 | [
"specify",
"a",
"two",
"-",
"dimensional",
"texture",
"image",
"in",
"a",
"compressed",
"format"
] | [
"func",
"CompressedTexImage2D",
"(",
"target",
"uint32",
",",
"<mask>",
"int32",
",",
"internalformat",
"uint32",
",",
"width",
"int32",
",",
"height",
"int32",
",",
"border",
"int32",
",",
"imageSize",
"int32",
",",
"data",
"unsafe",
".",
"Pointer",
")",
"{",
"syscall",
".",
"Syscall9",
"(",
"gpCompressedTexImage2D",
",",
"8",
",",
"uintptr",
"(",
"target",
")",
",",
"uintptr",
"(",
"level",
")",
",",
"uintptr",
"(",
"internalformat",
")",
",",
"uintptr",
"(",
"width",
")",
",",
"uintptr",
"(",
"height",
")",
",",
"uintptr",
"(",
"border",
")",
",",
"uintptr",
"(",
"imageSize",
")",
",",
"uintptr",
"(",
"data",
")",
",",
"0",
")",
"\n",
"}"
] |
8,367 | all-8368 | [
"Get",
"subchannel",
"if",
"we",
"have",
"one"
] | [
"func",
"(",
"subChMap",
"*",
"subChannelMap",
")",
"get",
"(",
"serviceName",
"string",
")",
"(",
"*",
"SubChannel",
",",
"bool",
")",
"{",
"subChMap",
".",
"RLock",
"(",
")",
"\n",
"sc",
",",
"<mask>",
":=",
"subChMap",
".",
"subchannels",
"[",
"serviceName",
"]",
"\n",
"subChMap",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"sc",
",",
"ok",
"\n",
"}"
] |
8,368 | all-8369 | [
"NewCompactionCommand",
"returns",
"the",
"cobra",
"command",
"for",
"compaction",
"."
] | [
"func",
"NewCompactionCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"compactionCommandFunc",
",",
"}",
"\n",
"cmd",
".",
"Flags",
"(",
")",
".",
"BoolVar",
"(",
"&",
"compactPhysical",
",",
"\"",
"\"",
",",
"<mask>",
",",
"\"",
"\"",
")",
"\n",
"return",
"cmd",
"\n",
"}"
] |
8,369 | all-8370 | [
"Loads",
"the",
"registry",
"configuration",
"file",
"from",
"the",
"filesystem",
"and",
"then",
"unmarshals",
"it",
".",
"Returns",
"the",
"unmarshalled",
"object",
"."
] | [
"func",
"loadRegistryConf",
"(",
"sys",
"*",
"<mask>",
".",
"SystemContext",
")",
"(",
"*",
"tomlConfig",
",",
"error",
")",
"{",
"config",
":=",
"&",
"tomlConfig",
"{",
"}",
"\n\n",
"configBytes",
",",
"err",
":=",
"readConf",
"(",
"sys",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"toml",
".",
"Unmarshal",
"(",
"configBytes",
",",
"&",
"config",
")",
"\n",
"normalizeRegistries",
"(",
"&",
"config",
".",
"Registries",
".",
"Search",
")",
"\n",
"normalizeRegistries",
"(",
"&",
"config",
".",
"Registries",
".",
"Insecure",
")",
"\n",
"normalizeRegistries",
"(",
"&",
"config",
".",
"Registries",
".",
"Block",
")",
"\n",
"return",
"config",
",",
"err",
"\n",
"}"
] |
8,370 | all-8371 | [
"refType",
"returns",
"the",
"Go",
"code",
"required",
"to",
"declare",
"a",
"variable",
"of",
"the",
"given",
"resource",
"type",
".",
"i",
".",
"e",
".",
"var",
"foo",
"*",
"ResourceName"
] | [
"func",
"refType",
"(",
"resName",
"string",
")",
"string",
"{",
"res",
":=",
"resourceType",
"(",
"resName",
")",
"\n",
"if",
"res",
"!=",
"\"",
"\"",
"{",
"res",
"=",
"\"",
"\"",
"+",
"res",
"\n",
"}",
"\n",
"return",
"<mask>",
"\n",
"}"
] |
8,371 | all-8372 | [
"Canon",
"returns",
"the",
"canonical",
"version",
"of",
"r",
".",
"The",
"returned",
"rectangle",
"has",
"minimum",
"and",
"maximum",
"coordinates",
"swapped",
"if",
"necessary",
"so",
"that",
"it",
"is",
"well",
"-",
"formed",
"."
] | [
"func",
"(",
"r",
"Rectangle",
")",
"Canon",
"(",
")",
"Rectangle",
"{",
"if",
"r",
".",
"Max",
".",
"X",
"<",
"r",
".",
"Min",
".",
"X",
"{",
"r",
".",
"Min",
".",
"X",
",",
"r",
".",
"Max",
".",
"X",
"=",
"r",
".",
"Max",
".",
"X",
",",
"r",
".",
"Min",
".",
"X",
"\n",
"}",
"\n",
"if",
"r",
".",
"Max",
".",
"Y",
"<",
"r",
".",
"Min",
".",
"Y",
"{",
"r",
".",
"Min",
".",
"Y",
",",
"r",
".",
"Max",
".",
"Y",
"=",
"r",
".",
"Max",
".",
"Y",
",",
"r",
".",
"Min",
".",
"Y",
"\n",
"}",
"\n",
"<mask>",
"r",
"\n",
"}"
] |
8,372 | all-8373 | [
"Left",
"left",
"-",
"pads",
"the",
"string",
"with",
"pad",
"up",
"to",
"len",
"runes",
"len",
"may",
"be",
"exceeded",
"if"
] | [
"func",
"Left",
"(",
"str",
"string",
",",
"<mask>",
"int",
",",
"pad",
"string",
")",
"string",
"{",
"return",
"times",
"(",
"pad",
",",
"length",
"-",
"len",
"(",
"str",
")",
")",
"+",
"str",
"\n",
"}"
] |
8,373 | all-8374 | [
"NewDefaultServer",
"is",
"like",
"NewServer",
"but",
"we",
"take",
"care",
"of",
"creating",
"a",
"mesh",
".",
"Router",
"and",
"meshconn",
".",
"Peer",
"for",
"you",
"with",
"sane",
"defaults",
".",
"If",
"you",
"need",
"more",
"fine",
"-",
"grained",
"control",
"create",
"the",
"components",
"yourself",
"and",
"use",
"NewServer",
"."
] | [
"func",
"NewDefaultServer",
"(",
"minPeerCount",
"int",
",",
"terminatec",
"<-",
"chan",
"struct",
"{",
"}",
",",
"terminatedc",
"chan",
"<-",
"error",
",",
"logger",
"mesh",
".",
"Logger",
",",
")",
"Server",
"{",
"var",
"(",
"peerName",
"=",
"mustPeerName",
"(",
")",
"\n",
"nickName",
"=",
"mustHostname",
"(",
")",
"\n",
"host",
"=",
"\"",
"\"",
"\n",
"port",
"=",
"6379",
"\n",
"password",
"=",
"\"",
"\"",
"\n",
"channel",
"=",
"\"",
"\"",
"\n",
")",
"\n",
"router",
":=",
"mesh",
".",
"NewRouter",
"(",
"mesh",
".",
"Config",
"{",
"Host",
":",
"host",
",",
"Port",
":",
"port",
",",
"ProtocolMinVersion",
":",
"mesh",
".",
"ProtocolMinVersion",
",",
"Password",
":",
"[",
"]",
"byte",
"(",
"password",
")",
",",
"ConnLimit",
":",
"64",
",",
"PeerDiscovery",
":",
"true",
",",
"TrustedSubnets",
":",
"[",
"]",
"*",
"net",
".",
"IPNet",
"{",
"}",
",",
"}",
",",
"peerName",
",",
"nickName",
",",
"mesh",
".",
"NullOverlay",
"{",
"}",
",",
"logger",
")",
"\n\n",
"// Create a meshconn.Peer and connect it to a channel.",
"peer",
":=",
"meshconn",
".",
"NewPeer",
"(",
"router",
".",
"Ourself",
".",
"Peer",
".",
"Name",
",",
"router",
".",
"Ourself",
".",
"UID",
",",
"logger",
")",
"\n",
"gossip",
":=",
"router",
".",
"NewGossip",
"(",
"channel",
",",
"peer",
")",
"\n",
"<mask>",
".",
"Register",
"(",
"gossip",
")",
"\n\n",
"// Start the router and join the mesh.",
"// Note that we don't ever stop the router.",
"// This may or may not be a problem.",
"// TODO(pb): determine if this is a super huge problem",
"router",
".",
"Start",
"(",
")",
"\n\n",
"return",
"NewServer",
"(",
"router",
",",
"peer",
",",
"minPeerCount",
",",
"terminatec",
",",
"terminatedc",
",",
"logger",
")",
"\n",
"}"
] |
8,374 | all-8375 | [
"GetChangeTrustResult",
"retrieves",
"the",
"ChangeTrustResult",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | [
"func",
"(",
"u",
"OperationResultTr",
")",
"GetChangeTrustResult",
"(",
")",
"(",
"result",
"ChangeTrustResult",
",",
"<mask>",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n\n",
"if",
"armName",
"==",
"\"",
"\"",
"{",
"result",
"=",
"*",
"u",
".",
"ChangeTrustResult",
"\n",
"ok",
"=",
"true",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] |
8,375 | all-8376 | [
"Read",
"reads",
"the",
"packed",
"data",
"for",
"the",
"current",
"file",
"into",
"p",
"."
] | [
"func",
"(",
"f",
"*",
"packedFileReader",
")",
"Read",
"(",
"p",
"[",
"]",
"<mask>",
")",
"(",
"int",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"f",
".",
"r",
".",
"Read",
"(",
"p",
")",
"// read current block data",
"\n",
"for",
"err",
"==",
"io",
".",
"EOF",
"{",
"// current block empty",
"if",
"n",
">",
"0",
"{",
"return",
"n",
",",
"nil",
"\n",
"}",
"\n",
"if",
"f",
".",
"h",
"==",
"nil",
"||",
"f",
".",
"h",
".",
"last",
"{",
"return",
"0",
",",
"io",
".",
"EOF",
"// last block so end of file",
"\n",
"}",
"\n",
"if",
"err",
":=",
"f",
".",
"nextBlockInFile",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"n",
",",
"err",
"=",
"f",
".",
"r",
".",
"Read",
"(",
"p",
")",
"// read new block data",
"\n",
"}",
"\n",
"return",
"n",
",",
"err",
"\n",
"}"
] |
8,376 | all-8377 | [
"assumes",
"a",
"to",
"be",
"sorted",
"in",
"descending",
"order",
"returns",
"a",
"subslice",
"of",
"a",
"along",
"with",
"its",
"indices",
"(",
"inclusive",
")"
] | [
"func",
"cropResults",
"(",
"a",
"[",
"]",
"int64",
",",
"max",
"int64",
")",
"(",
"[",
"]",
"int64",
",",
"int",
",",
"int",
")",
"{",
"res",
":=",
"[",
"]",
"int64",
"{",
"}",
"\n",
"firstIndex",
":=",
"-",
"1",
"\n",
"lastIndex",
":=",
"0",
"\n",
"for",
"i",
",",
"v",
":=",
"range",
"a",
"{",
"if",
"v",
"<=",
"max",
"{",
"res",
"=",
"<mask>",
"(",
"res",
",",
"v",
")",
"\n",
"if",
"firstIndex",
"==",
"-",
"1",
"{",
"firstIndex",
"=",
"i",
"\n",
"}",
"\n",
"lastIndex",
"=",
"i",
"\n",
"if",
"len",
"(",
"res",
")",
">=",
"resultsPerPage",
"{",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"res",
",",
"firstIndex",
",",
"lastIndex",
"\n",
"}"
] |
8,377 | all-8378 | [
"Map",
"maps",
"an",
"array",
"s",
"iitem",
"through",
"an",
"iterator",
"."
] | [
"func",
"<mask>",
"(",
"arr",
"[",
"]",
"string",
",",
"iterator",
"func",
"(",
"string",
")",
"string",
")",
"[",
"]",
"string",
"{",
"r",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"item",
":=",
"range",
"arr",
"{",
"r",
"=",
"append",
"(",
"r",
",",
"iterator",
"(",
"item",
")",
")",
"\n",
"}",
"\n",
"return",
"r",
"\n",
"}"
] |
8,378 | all-8379 | [
"MustPrepare",
"retrieves",
"the",
"Prepare",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | [
"func",
"(",
"u",
"ScpStatementPledges",
")",
"MustPrepare",
"(",
")",
"ScpStatementPrepare",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetPrepare",
"(",
")",
"\n\n",
"if",
"!",
"<mask>",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"val",
"\n",
"}"
] |
8,379 | all-8380 | [
"getASMSecretsResource",
"retrieves",
"asmsecret",
"resource",
"from",
"resource",
"map"
] | [
"func",
"(",
"task",
"*",
"Task",
")",
"getASMSecretsResource",
"(",
")",
"(",
"[",
"]",
"taskresource",
".",
"TaskResource",
",",
"bool",
")",
"{",
"task",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"task",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"res",
",",
"ok",
":=",
"task",
".",
"ResourcesMapUnsafe",
"[",
"asmsecret",
".",
"ResourceName",
"]",
"\n",
"return",
"res",
",",
"<mask>",
"\n",
"}"
] |
8,380 | all-8381 | [
"ImageNewFromPixbuf",
"is",
"a",
"wrapper",
"around",
"gtk_image_new_from_pixbuf",
"()",
"."
] | [
"func",
"ImageNewFromPixbuf",
"(",
"pixbuf",
"*",
"gdk",
".",
"Pixbuf",
")",
"(",
"*",
"<mask>",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gtk_image_new_from_pixbuf",
"(",
"(",
"*",
"C",
".",
"GdkPixbuf",
")",
"(",
"pixbuf",
".",
"NativePrivate",
"(",
")",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"obj",
":=",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
"\n",
"return",
"wrapImage",
"(",
"obj",
")",
",",
"nil",
"\n",
"}"
] |
8,381 | all-8382 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"ClearBrowserCookiesParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork64",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
8,382 | all-8383 | [
"GetTitle",
"returns",
"the",
"Title",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"e",
"*",
"EventTimelineDefinition",
")",
"GetTitle",
"(",
")",
"string",
"{",
"if",
"e",
"==",
"nil",
"||",
"e",
".",
"Title",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"<mask>",
"*",
"e",
".",
"Title",
"\n",
"}"
] |
8,383 | all-8384 | [
"NewKTrie",
"..."
] | [
"func",
"NewKTrie",
"(",
"data",
"map",
"[",
"string",
"]",
"bool",
")",
"(",
"*",
"KTrie",
",",
"error",
")",
"{",
"n",
":=",
"NewKNode",
"(",
"0",
")",
"\n\n",
"maxDepth",
":=",
"0",
"\n",
"minDepth",
":=",
"9001",
"\n\n",
"for",
"k",
":=",
"range",
"data",
"{",
"<mask>",
":=",
"[",
"]",
"rune",
"(",
"k",
")",
"\n",
"l",
":=",
"len",
"(",
"rs",
")",
"\n\n",
"n",
".",
"Add",
"(",
"rs",
")",
"\n\n",
"if",
"l",
">",
"maxDepth",
"{",
"maxDepth",
"=",
"l",
"\n",
"}",
"\n",
"if",
"l",
"<",
"minDepth",
"{",
"minDepth",
"=",
"l",
"\n",
"}",
"\n",
"}",
"\n\n",
"t",
":=",
"&",
"KTrie",
"{",
"maxDepth",
":",
"maxDepth",
",",
"minDepth",
":",
"minDepth",
",",
"KNode",
":",
"n",
",",
"}",
"\n\n",
"return",
"t",
",",
"nil",
"\n",
"}"
] |
8,384 | all-8385 | [
"UnmarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Unmarshaler",
"."
] | [
"func",
"(",
"t",
"*",
"ClientNavigationReason",
")",
"UnmarshalEasyJSON",
"(",
"in",
"*",
"jlexer",
".",
"Lexer",
")",
"{",
"switch",
"ClientNavigationReason",
"(",
"in",
".",
"String",
"(",
")",
")",
"{",
"<mask>",
"ClientNavigationReasonFormSubmissionGet",
":",
"*",
"t",
"=",
"ClientNavigationReasonFormSubmissionGet",
"\n",
"case",
"ClientNavigationReasonFormSubmissionPost",
":",
"*",
"t",
"=",
"ClientNavigationReasonFormSubmissionPost",
"\n",
"case",
"ClientNavigationReasonHTTPHeaderRefresh",
":",
"*",
"t",
"=",
"ClientNavigationReasonHTTPHeaderRefresh",
"\n",
"case",
"ClientNavigationReasonScriptInitiated",
":",
"*",
"t",
"=",
"ClientNavigationReasonScriptInitiated",
"\n",
"case",
"ClientNavigationReasonMetaTagRefresh",
":",
"*",
"t",
"=",
"ClientNavigationReasonMetaTagRefresh",
"\n",
"case",
"ClientNavigationReasonPageBlockInterstitial",
":",
"*",
"t",
"=",
"ClientNavigationReasonPageBlockInterstitial",
"\n",
"case",
"ClientNavigationReasonReload",
":",
"*",
"t",
"=",
"ClientNavigationReasonReload",
"\n\n",
"default",
":",
"in",
".",
"AddError",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"}"
] |
8,385 | all-8386 | [
"SeekToFirst",
"seeks",
"position",
"at",
"the",
"first",
"entry",
"in",
"list",
".",
"Final",
"state",
"of",
"iterator",
"is",
"Valid",
"()",
"iff",
"list",
"is",
"not",
"empty",
"."
] | [
"func",
"(",
"s",
"*",
"Iterator",
")",
"SeekToFirst",
"(",
")",
"{",
"s",
".",
"n",
"=",
"s",
".",
"list",
".",
"getNext",
"(",
"s",
".",
"<mask>",
".",
"head",
",",
"0",
")",
"\n",
"}"
] |
8,386 | all-8387 | [
"BeginCall",
"starts",
"a",
"new",
"call",
"to",
"this",
"specific",
"peer",
"returning",
"an",
"OutboundCall",
"that",
"can",
"be",
"used",
"to",
"write",
"the",
"arguments",
"of",
"the",
"call",
"."
] | [
"func",
"(",
"p",
"*",
"Peer",
")",
"BeginCall",
"(",
"ctx",
"context",
".",
"Context",
",",
"serviceName",
",",
"methodName",
"string",
",",
"callOptions",
"*",
"CallOptions",
")",
"(",
"*",
"OutboundCall",
",",
"error",
")",
"{",
"if",
"callOptions",
"==",
"nil",
"{",
"callOptions",
"=",
"defaultCallOptions",
"\n",
"}",
"\n",
"callOptions",
".",
"RequestState",
".",
"AddSelectedPeer",
"(",
"p",
".",
"HostPort",
"(",
")",
")",
"\n\n",
"if",
"err",
":=",
"validateCall",
"(",
"ctx",
",",
"serviceName",
",",
"methodName",
",",
"callOptions",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"conn",
",",
"err",
":=",
"p",
".",
"GetConnection",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"call",
",",
"err",
":=",
"conn",
".",
"beginCall",
"(",
"ctx",
",",
"serviceName",
",",
"methodName",
",",
"callOptions",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"<mask>",
",",
"err",
"\n",
"}"
] |
8,387 | all-8388 | [
"DecodeKey",
"decodes",
"a",
"key",
"from",
"the",
"opaque",
"representation",
"returned",
"by",
"Encode",
"."
] | [
"func",
"DecodeKey",
"(",
"encoded",
"string",
")",
"(",
"*",
"Key",
",",
"error",
")",
"{",
"// Re-add padding.",
"if",
"m",
":=",
"len",
"(",
"encoded",
")",
"%",
"4",
";",
"m",
"!=",
"0",
"{",
"encoded",
"+=",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"4",
"-",
"m",
")",
"\n",
"}",
"\n\n",
"b",
",",
"err",
":=",
"base64",
".",
"URLEncoding",
".",
"DecodeString",
"(",
"encoded",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"ref",
":=",
"new",
"(",
"pb",
".",
"Reference",
")",
"\n",
"if",
"err",
":=",
"proto",
".",
"Unmarshal",
"(",
"b",
",",
"<mask>",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"protoToKey",
"(",
"ref",
")",
"\n",
"}"
] |
8,388 | all-8389 | [
"UnmarshalJSON",
"unmarshals",
"ResourcesMap",
"object"
] | [
"func",
"(",
"rm",
"*",
"ResourcesMap",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"resources",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"json",
".",
"RawMessage",
")",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"resources",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"result",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"taskresource",
".",
"TaskResource",
")",
"\n",
"for",
"key",
",",
"value",
":=",
"range",
"resources",
"{",
"switch",
"key",
"{",
"case",
"CgroupKey",
":",
"if",
"unmarshlCgroup",
"(",
"key",
",",
"value",
",",
"result",
")",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"case",
"DockerVolumeKey",
":",
"if",
"unmarshalDockerVolume",
"(",
"key",
",",
"value",
",",
"<mask>",
")",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"case",
"ASMAuthKey",
":",
"if",
"unmarshalASMAuthKey",
"(",
"key",
",",
"value",
",",
"result",
")",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"case",
"SSMSecretKey",
":",
"if",
"unmarshalSSMSecretKey",
"(",
"key",
",",
"value",
",",
"result",
")",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"case",
"ASMSecretKey",
":",
"if",
"unmarshalASMSecretKey",
"(",
"key",
",",
"value",
",",
"result",
")",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"default",
":",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"*",
"rm",
"=",
"result",
"\n",
"return",
"nil",
"\n",
"}"
] |
8,389 | all-8390 | [
"CheckMenuItemNew",
"is",
"a",
"wrapper",
"around",
"gtk_check_menu_item_new",
"()",
"."
] | [
"func",
"CheckMenuItemNew",
"(",
")",
"(",
"*",
"CheckMenuItem",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gtk_check_menu_item_new",
"(",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"<mask>",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"obj",
":=",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
"\n",
"return",
"wrapCheckMenuItem",
"(",
"obj",
")",
",",
"nil",
"\n",
"}"
] |
8,390 | all-8391 | [
"NewSnapshotCommand",
"returns",
"the",
"cobra",
"command",
"for",
"snapshot",
"."
] | [
"func",
"NewSnapshotCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"}",
"\n",
"cmd",
".",
"AddCommand",
"(",
"NewSnapshotSaveCommand",
"(",
")",
")",
"\n",
"cmd",
".",
"AddCommand",
"(",
"NewSnapshotRestoreCommand",
"(",
")",
")",
"\n",
"cmd",
".",
"AddCommand",
"(",
"newSnapshotStatusCommand",
"(",
")",
")",
"\n",
"<mask>",
"cmd",
"\n",
"}"
] |
8,391 | all-8392 | [
"PixbufNewFromFile",
"is",
"a",
"wrapper",
"around",
"gdk_pixbuf_new_from_file",
"()",
"."
] | [
"func",
"PixbufNewFromFile",
"(",
"filename",
"string",
")",
"(",
"*",
"Pixbuf",
",",
"error",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"filename",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n\n",
"var",
"err",
"*",
"C",
".",
"GError",
"\n",
"c",
":=",
"C",
".",
"gdk_pixbuf_new_from_file",
"(",
"(",
"*",
"C",
".",
"char",
")",
"(",
"cstr",
")",
",",
"&",
"err",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"defer",
"C",
".",
"g_error_free",
"(",
"err",
")",
"\n",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"char",
")",
"(",
"err",
".",
"message",
")",
")",
")",
"\n",
"}",
"\n\n",
"obj",
":=",
"&",
"glib",
".",
"<mask>",
"{",
"glib",
".",
"ToGObject",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
"}",
"\n",
"p",
":=",
"&",
"Pixbuf",
"{",
"obj",
"}",
"\n",
"//obj.Ref()",
"runtime",
".",
"SetFinalizer",
"(",
"p",
",",
"func",
"(",
"_",
"interface",
"{",
"}",
")",
"{",
"obj",
".",
"Unref",
"(",
")",
"}",
")",
"\n",
"return",
"p",
",",
"nil",
"\n",
"}"
] |
8,392 | all-8393 | [
"SeekPathConflict",
"seeks",
"an",
"entry",
"which",
"conflicts",
"with",
"path",
"and",
"returns",
"the",
"first",
"encountered",
"or",
"nil",
"nil",
"if",
"none",
"is",
"found",
"."
] | [
"func",
"SeekPathConflict",
"(",
"c",
"*",
"bolt",
".",
"Cursor",
",",
"path",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"[",
"]",
"byte",
")",
"{",
"// Validation",
"if",
"len",
"(",
"path",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"if",
"path",
"[",
"0",
"]",
"!=",
"'/'",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"// Fast-path for exact and prefix match.",
"if",
"k",
",",
"v",
":=",
"c",
".",
"Seek",
"(",
"path",
")",
";",
"bytes",
".",
"Equal",
"(",
"k",
",",
"path",
")",
"{",
"return",
"k",
",",
"v",
"\n",
"}",
"else",
"if",
"bytes",
".",
"HasPrefix",
"(",
"k",
",",
"path",
")",
"{",
"// Any prefixed k is good enough when path ends in '/'.",
"if",
"path",
"[",
"len",
"(",
"path",
")",
"-",
"1",
"]",
"==",
"'/'",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"// If k's last element is longer it could be a conflict.",
"if",
"k",
"[",
"len",
"(",
"path",
")",
"]",
"==",
"'/'",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Prefix scan.",
"i",
":=",
"0",
"\n",
"for",
"{",
"i",
"++",
"\n\n",
"// Match slash.",
"prefix",
":=",
"path",
"[",
":",
"i",
"]",
"\n",
"k",
",",
"v",
":=",
"c",
".",
"Seek",
"(",
"prefix",
")",
"\n",
"if",
"!",
"bytes",
".",
"HasPrefix",
"(",
"k",
",",
"<mask>",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"// Exact match is a conflict for trailing slash.",
"if",
"i",
"==",
"len",
"(",
"path",
")",
"{",
"if",
"len",
"(",
"k",
")",
"==",
"len",
"(",
"path",
")",
"{",
"return",
"k",
",",
"v",
"\n",
"}",
"\n",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"// Advance cursor past exact match to first prefix match.",
"if",
"len",
"(",
"k",
")",
"==",
"len",
"(",
"prefix",
")",
"{",
"k",
",",
"v",
"=",
"c",
".",
"Next",
"(",
")",
"\n",
"if",
"!",
"bytes",
".",
"HasPrefix",
"(",
"k",
",",
"prefix",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Find end of element.",
"offset",
":=",
"bytes",
".",
"IndexByte",
"(",
"path",
"[",
"i",
":",
"]",
",",
"'/'",
")",
"\n",
"last",
":=",
"offset",
"<",
"0",
"\n",
"if",
"last",
"{",
"i",
"=",
"len",
"(",
"path",
")",
"\n",
"}",
"else",
"{",
"i",
"+=",
"offset",
"\n",
"}",
"\n\n",
"switch",
"k",
"[",
"len",
"(",
"prefix",
")",
"]",
"{",
"case",
"'*'",
":",
"return",
"k",
",",
"v",
"\n\n",
"case",
"':'",
":",
"// Find end of element.",
"kPrefix",
":=",
"k",
"\n",
"offset",
":=",
"bytes",
".",
"IndexByte",
"(",
"k",
"[",
"len",
"(",
"prefix",
")",
":",
"]",
",",
"'/'",
")",
"\n",
"if",
"offset",
">",
"0",
"{",
"kPrefix",
"=",
"k",
"[",
":",
"len",
"(",
"prefix",
")",
"+",
"offset",
"]",
"\n",
"}",
"\n\n",
"// Exact match required through variable element.",
"prefix",
"=",
"path",
"[",
":",
"i",
"]",
"\n",
"if",
"!",
"bytes",
".",
"Equal",
"(",
"prefix",
",",
"kPrefix",
")",
"{",
"return",
"k",
",",
"v",
"\n",
"}",
"\n\n",
"if",
"last",
"{",
"// Exact match is a conflict for the last element.",
"if",
"k",
",",
"v",
"=",
"c",
".",
"Seek",
"(",
"prefix",
")",
";",
"bytes",
".",
"Equal",
"(",
"k",
",",
"prefix",
")",
"{",
"return",
"k",
",",
"v",
"\n",
"}",
"\n",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"default",
":",
"// Static (non-variable) element required.",
"next",
":=",
"path",
"[",
"len",
"(",
"prefix",
")",
"]",
"\n",
"if",
"next",
"==",
"':'",
"||",
"next",
"==",
"'*'",
"{",
"return",
"k",
",",
"v",
"\n",
"}",
"\n\n",
"prefix",
"=",
"path",
"[",
":",
"i",
"]",
"\n",
"k",
",",
"v",
"=",
"c",
".",
"Seek",
"(",
"prefix",
")",
"\n\n",
"if",
"last",
"{",
"// Exact match is a conflict for the last element.",
"if",
"bytes",
".",
"Equal",
"(",
"k",
",",
"prefix",
")",
"{",
"return",
"k",
",",
"v",
"\n",
"}",
"\n",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"if",
"!",
"bytes",
".",
"HasPrefix",
"(",
"k",
",",
"prefix",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
8,393 | all-8394 | [
"difference",
"returns",
"a",
"new",
"orgRepoConfig",
"that",
"represents",
"the",
"set",
"difference",
"of",
"the",
"repos",
"specified",
"by",
"the",
"receiver",
"and",
"the",
"parameter",
"orgRepoConfigs",
"."
] | [
"func",
"(",
"c",
"*",
"orgRepoConfig",
")",
"difference",
"(",
"c2",
"*",
"orgRepoConfig",
")",
"*",
"orgRepoConfig",
"{",
"res",
":=",
"&",
"orgRepoConfig",
"{",
"orgExceptions",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"sets",
".",
"String",
")",
",",
"repos",
":",
"sets",
".",
"NewString",
"(",
")",
".",
"Union",
"(",
"c",
".",
"repos",
")",
",",
"}",
"\n",
"for",
"org",
",",
"excepts1",
":=",
"range",
"c",
".",
"orgExceptions",
"{",
"if",
"excepts2",
",",
"ok",
":=",
"c2",
".",
"orgExceptions",
"[",
"org",
"]",
";",
"<mask>",
"{",
"res",
".",
"repos",
".",
"Insert",
"(",
"excepts2",
".",
"Difference",
"(",
"excepts1",
")",
".",
"UnsortedList",
"(",
")",
"...",
")",
"\n",
"}",
"else",
"{",
"excepts",
":=",
"sets",
".",
"NewString",
"(",
")",
".",
"Union",
"(",
"excepts1",
")",
"\n",
"// Add any applicable repos in repos2 to excepts",
"for",
"_",
",",
"repo",
":=",
"range",
"c2",
".",
"repos",
".",
"UnsortedList",
"(",
")",
"{",
"if",
"parts",
":=",
"strings",
".",
"SplitN",
"(",
"repo",
",",
"\"",
"\"",
",",
"2",
")",
";",
"len",
"(",
"parts",
")",
"==",
"2",
"&&",
"parts",
"[",
"0",
"]",
"==",
"org",
"{",
"excepts",
".",
"Insert",
"(",
"repo",
")",
"\n",
"}",
"\n",
"}",
"\n",
"res",
".",
"orgExceptions",
"[",
"org",
"]",
"=",
"excepts",
"\n",
"}",
"\n",
"}",
"\n\n",
"res",
".",
"repos",
"=",
"res",
".",
"repos",
".",
"Difference",
"(",
"c2",
".",
"repos",
")",
"\n\n",
"for",
"_",
",",
"repo",
":=",
"range",
"res",
".",
"repos",
".",
"UnsortedList",
"(",
")",
"{",
"if",
"parts",
":=",
"strings",
".",
"SplitN",
"(",
"repo",
",",
"\"",
"\"",
",",
"2",
")",
";",
"len",
"(",
"parts",
")",
"==",
"2",
"{",
"if",
"excepts2",
",",
"ok",
":=",
"c2",
".",
"orgExceptions",
"[",
"parts",
"[",
"0",
"]",
"]",
";",
"ok",
"&&",
"!",
"excepts2",
".",
"Has",
"(",
"repo",
")",
"{",
"res",
".",
"repos",
".",
"Delete",
"(",
"repo",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"res",
"\n",
"}"
] |
8,394 | all-8395 | [
"ImportAccountFromJSON",
"imports",
"private",
"key",
"from",
"JSON",
"blob",
"with",
"password",
"creates",
"account",
"and",
"initiates",
"JobAccountUpdateBalances",
"job",
"."
] | [
"func",
"(",
"h",
"*",
"Handler",
")",
"ImportAccountFromJSON",
"(",
"tkn",
"string",
",",
"params",
"*",
"AccountParams",
",",
"jsonBlob",
"json",
".",
"RawMessage",
",",
"jsonKeyStorePassword",
"string",
")",
"(",
"*",
"string",
",",
"error",
")",
"{",
"logger",
":=",
"h",
".",
"logger",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"!",
"h",
".",
"token",
".",
"Check",
"(",
"tkn",
")",
"{",
"logger",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"ErrAccessDenied",
"\n",
"}",
"\n\n",
"account",
":=",
"params",
".",
"prefilledAccount",
"(",
")",
"\n\n",
"makeECDSAFunc",
":=",
"h",
".",
"jsonPrivateKeyToECDSA",
"(",
"jsonBlob",
",",
"jsonKeyStorePassword",
")",
"\n\n",
"<mask>",
",",
"err",
":=",
"h",
".",
"fillAndSaveAccount",
"(",
"logger",
",",
"account",
",",
"makeECDSAFunc",
",",
"true",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"id",
",",
"nil",
"\n",
"}"
] |
8,395 | all-8396 | [
"Deletes",
"a",
"host",
".",
"Note",
"that",
"this",
"is",
"not",
"the",
"FQDN",
"but",
"a",
"hostname",
"."
] | [
"func",
"(",
"ds",
"*",
"DNSServer",
")",
"DeleteA",
"(",
"<mask>",
"string",
")",
"{",
"ds",
".",
"aMutex",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"ds",
".",
"aRecords",
",",
"ds",
".",
"qualifyHost",
"(",
"host",
")",
")",
"\n",
"ds",
".",
"aMutex",
".",
"Unlock",
"(",
")",
"\n",
"}"
] |
8,396 | all-8397 | [
"World",
"is",
"a",
"handler"
] | [
"func",
"(",
"h",
"*",
"Hello",
")",
"World",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"<mask>",
")",
"{",
"w",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
")",
"\n",
"}"
] |
8,397 | all-8398 | [
"delete",
"named",
"query",
"objects"
] | [
"func",
"DeleteQueries",
"(",
"n",
"int32",
",",
"ids",
"*",
"uint32",
")",
"{",
"C",
".",
"glowDeleteQueries",
"(",
"gpDeleteQueries",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"n",
")",
",",
"(",
"*",
"C",
".",
"GLuint",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"<mask>",
")",
")",
")",
"\n",
"}"
] |
8,398 | all-8399 | [
"AddFlags",
"parses",
"options",
"for",
"database",
"configuration"
] | [
"func",
"(",
"config",
"*",
"MySQLConfig",
")",
"AddFlags",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
")",
"{",
"cmd",
".",
"PersistentFlags",
"(",
")",
".",
"StringVar",
"(",
"&",
"config",
".",
"<mask>",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"cmd",
".",
"PersistentFlags",
"(",
")",
".",
"StringVar",
"(",
"&",
"config",
".",
"Password",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"cmd",
".",
"PersistentFlags",
"(",
")",
".",
"StringVar",
"(",
"&",
"config",
".",
"Host",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"cmd",
".",
"PersistentFlags",
"(",
")",
".",
"IntVar",
"(",
"&",
"config",
".",
"Port",
",",
"\"",
"\"",
",",
"3306",
",",
"\"",
"\"",
")",
"\n",
"cmd",
".",
"PersistentFlags",
"(",
")",
".",
"StringVar",
"(",
"&",
"config",
".",
"Db",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
8,399 | all-8400 | [
"flattenClusterAffinityRuleSpec",
"saves",
"a",
"ClusterAffinityRuleSpec",
"into",
"the",
"supplied",
"ResourceData",
"."
] | [
"func",
"flattenClusterAffinityRuleSpec",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"meta",
"interface",
"{",
"}",
",",
"obj",
"*",
"types",
".",
"ClusterAffinityRuleSpec",
")",
"error",
"{",
"client",
",",
"err",
":=",
"resourceVSphereComputeClusterVMGroupClient",
"(",
"meta",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"results",
",",
"err",
":=",
"virtualmachine",
".",
"UUIDsForManagedObjectReferences",
"(",
"client",
",",
"obj",
".",
"Vm",
",",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"structure",
".",
"SetBatch",
"(",
"d",
",",
"<mask>",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"obj",
".",
"Enabled",
",",
"\"",
"\"",
":",
"obj",
".",
"Mandatory",
",",
"\"",
"\"",
":",
"obj",
".",
"Name",
",",
"\"",
"\"",
":",
"results",
".",
"UUIDs",
"(",
")",
",",
"}",
")",
"\n",
"}"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.