id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
2,700 | all-2701 | [
"Equal",
"returns",
"whether",
"two",
"keys",
"are",
"equal",
"."
] | [
"func",
"(",
"k",
"*",
"Key",
")",
"Equal",
"(",
"o",
"*",
"Key",
")",
"bool",
"{",
"for",
"k",
"!=",
"nil",
"&&",
"o",
"!=",
"nil",
"{",
"if",
"k",
".",
"kind",
"!=",
"o",
".",
"kind",
"||",
"k",
".",
"stringID",
"!=",
"o",
".",
"stringID",
"||",
"k",
".",
"intID",
"!=",
"o",
".",
"intID",
"||",
"k",
".",
"appID",
"!=",
"o",
".",
"appID",
"||",
"k",
".",
"namespace",
"!=",
"o",
".",
"namespace",
"{",
"return",
"false",
"\n",
"}",
"\n",
"k",
",",
"o",
"=",
"k",
".",
"parent",
",",
"o",
".",
"<mask>",
"\n",
"}",
"\n",
"return",
"k",
"==",
"o",
"\n",
"}"
] |
2,701 | all-2702 | [
"creates",
"and",
"initializes",
"a",
"buffer",
"object",
"s",
"immutable",
"data",
"store"
] | [
"func",
"NamedBufferStorage",
"(",
"<mask>",
"uint32",
",",
"size",
"int",
",",
"data",
"unsafe",
".",
"Pointer",
",",
"flags",
"uint32",
")",
"{",
"syscall",
".",
"Syscall6",
"(",
"gpNamedBufferStorage",
",",
"4",
",",
"uintptr",
"(",
"buffer",
")",
",",
"uintptr",
"(",
"size",
")",
",",
"uintptr",
"(",
"data",
")",
",",
"uintptr",
"(",
"flags",
")",
",",
"0",
",",
"0",
")",
"\n",
"}"
] |
2,702 | all-2703 | [
"List",
"all",
"articles"
] | [
"func",
"List",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"{",
"db",
":=",
"c",
".",
"MustGet",
"(",
"\"",
"\"",
")",
".",
"(",
"*",
"mgo",
".",
"<mask>",
")",
"\n",
"articles",
":=",
"[",
"]",
"models",
".",
"Article",
"{",
"}",
"\n",
"err",
":=",
"db",
".",
"C",
"(",
"models",
".",
"CollectionArticle",
")",
".",
"Find",
"(",
"nil",
")",
".",
"Sort",
"(",
"\"",
"\"",
")",
".",
"All",
"(",
"&",
"articles",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"Error",
"(",
"err",
")",
"\n",
"}",
"\n",
"c",
".",
"HTML",
"(",
"http",
".",
"StatusOK",
",",
"\"",
"\"",
",",
"gin",
".",
"H",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",
"articles",
",",
"}",
")",
"\n",
"}"
] |
2,703 | all-2704 | [
"Watch",
"returns",
"a",
"watch",
".",
"Interface",
"that",
"watches",
"the",
"requested",
"prowJobs",
"."
] | [
"func",
"(",
"c",
"*",
"FakeProwJobs",
")",
"Watch",
"(",
"opts",
"v1",
".",
"ListOptions",
")",
"(",
"<mask>",
".",
"Interface",
",",
"error",
")",
"{",
"return",
"c",
".",
"Fake",
".",
"InvokesWatch",
"(",
"testing",
".",
"NewWatchAction",
"(",
"prowjobsResource",
",",
"c",
".",
"ns",
",",
"opts",
")",
")",
"\n\n",
"}"
] |
2,704 | all-2705 | [
"TargetsActive",
"returns",
"the",
"active",
"targets",
"currently",
"being",
"scraped",
"."
] | [
"func",
"(",
"m",
"*",
"Manager",
")",
"TargetsActive",
"(",
")",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"Target",
"{",
"m",
".",
"mtxScrape",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtxScrape",
".",
"Unlock",
"(",
")",
"\n\n",
"targets",
":=",
"make",
"(",
"<mask>",
"[",
"string",
"]",
"[",
"]",
"*",
"Target",
",",
"len",
"(",
"m",
".",
"scrapePools",
")",
")",
"\n",
"for",
"tset",
",",
"sp",
":=",
"range",
"m",
".",
"scrapePools",
"{",
"targets",
"[",
"tset",
"]",
"=",
"sp",
".",
"ActiveTargets",
"(",
")",
"\n",
"}",
"\n",
"return",
"targets",
"\n",
"}"
] |
2,705 | all-2706 | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"Pull",
"."
] | [
"func",
"(",
"in",
"*",
"Pull",
")",
"DeepCopy",
"(",
")",
"*",
"Pull",
"{",
"if",
"<mask>",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"Pull",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] |
2,706 | all-2707 | [
"createCluster",
"causes",
"gcloud",
"to",
"create",
"a",
"cluster",
"in",
"project",
"returning",
"the",
"context",
"name"
] | [
"func",
"createCluster",
"(",
"proj",
",",
"choice",
"string",
")",
"(",
"*",
"cluster",
",",
"error",
")",
"{",
"const",
"def",
"=",
"\"",
"\"",
"\n",
"if",
"choice",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"def",
")",
"\n",
"fmt",
".",
"Scanln",
"(",
"&",
"choice",
")",
"\n",
"if",
"choice",
"==",
"\"",
"\"",
"{",
"choice",
"=",
"def",
"\n",
"}",
"\n",
"}",
"\n\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"choice",
")",
"\n",
"cmd",
".",
"Stdin",
"=",
"os",
".",
"Stdin",
"\n",
"cmd",
".",
"Stdout",
"=",
"os",
".",
"Stdout",
"\n",
"cmd",
".",
"Stderr",
"=",
"os",
".",
"Stderr",
"\n",
"if",
"err",
":=",
"cmd",
".",
"Run",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"out",
",",
"err",
":=",
"output",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"<mask>",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"parts",
":=",
"strings",
".",
"Split",
"(",
"out",
",",
"\"",
"\\t",
"\"",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"2",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"out",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"cluster",
"{",
"name",
":",
"parts",
"[",
"0",
"]",
",",
"zone",
":",
"parts",
"[",
"1",
"]",
",",
"project",
":",
"proj",
"}",
",",
"nil",
"\n",
"}"
] |
2,707 | all-2708 | [
"strings",
"with",
"one",
"byte",
"length"
] | [
"func",
"readShortUtf8",
"(",
"rd",
"*",
"bufio",
".",
"Reader",
")",
"(",
"[",
"]",
"byte",
",",
"int",
")",
"{",
"size",
":=",
"rd",
".",
"ReadB",
"(",
")",
"\n",
"b",
":=",
"rd",
".",
"ReadCesu8",
"(",
"int",
"(",
"<mask>",
")",
")",
"\n",
"return",
"b",
",",
"int",
"(",
"size",
")",
"\n",
"}"
] |
2,708 | all-2709 | [
"threadsafe",
"list",
"of",
"peers",
"."
] | [
"func",
"(",
"ps",
"*",
"PeerSet",
")",
"List",
"(",
")",
"[",
"]",
"*",
"Peer",
"{",
"ps",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ps",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"ps",
".",
"<mask>",
"\n",
"}"
] |
2,709 | all-2710 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"SetBlockedURLSParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork18",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
2,710 | all-2711 | [
"Declaration",
"returns",
"the",
"declaration",
"for",
"this",
"field",
"."
] | [
"func",
"(",
"a",
"*",
"<mask>",
")",
"Declaration",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"a",
".",
"Name",
"(",
")",
",",
"a",
".",
"ArgType",
"(",
")",
")",
"\n",
"}"
] |
2,711 | all-2712 | [
"LayerInfosForCopy",
"returns",
"an",
"updated",
"set",
"of",
"layer",
"blob",
"information",
"which",
"may",
"not",
"match",
"the",
"manifest",
".",
"The",
"Digest",
"field",
"is",
"guaranteed",
"to",
"be",
"provided",
";",
"Size",
"may",
"be",
"-",
"1",
".",
"WARNING",
":",
"The",
"list",
"may",
"contain",
"duplicates",
"and",
"they",
"are",
"semantically",
"relevant",
"."
] | [
"func",
"(",
"i",
"*",
"memoryImage",
")",
"LayerInfosForCopy",
"(",
"ctx",
"<mask>",
".",
"Context",
")",
"(",
"[",
"]",
"types",
".",
"BlobInfo",
",",
"error",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}"
] |
2,712 | all-2713 | [
"Disconnect",
"close",
"current",
"connection"
] | [
"func",
"(",
"c",
"*",
"<mask>",
")",
"Disconnect",
"(",
")",
"error",
"{",
"if",
"!",
"c",
".",
"connActive",
".",
"get",
"(",
")",
"{",
"return",
"ErrConnectionIsNotOpen",
"\n",
"}",
"\n\n",
"c",
".",
"userDisconnect",
".",
"Close",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
2,713 | all-2714 | [
"AddTaskIPAddress",
"adds",
"ip",
"adddress",
"for",
"a",
"task",
"arn",
"into",
"the",
"state"
] | [
"func",
"(",
"state",
"*",
"DockerTaskEngineState",
")",
"AddTaskIPAddress",
"(",
"addr",
"string",
",",
"taskARN",
"string",
")",
"{",
"<mask>",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"state",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"state",
".",
"ipToTask",
"[",
"addr",
"]",
"=",
"taskARN",
"\n",
"}"
] |
2,714 | all-2715 | [
"NewMockCNI",
"creates",
"a",
"new",
"mock",
"instance"
] | [
"func",
"NewMockCNI",
"(",
"ctrl",
"*",
"gomock",
".",
"<mask>",
")",
"*",
"MockCNI",
"{",
"mock",
":=",
"&",
"MockCNI",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockCNIMockRecorder",
"{",
"mock",
"}",
"\n",
"return",
"mock",
"\n",
"}"
] |
2,715 | all-2716 | [
"isLabel",
"reports",
"whether",
"the",
"string",
"can",
"be",
"used",
"as",
"label",
"."
] | [
"func",
"isLabel",
"(",
"s",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"s",
")",
"==",
"0",
"||",
"!",
"isAlpha",
"(",
"rune",
"(",
"s",
"[",
"0",
"]",
")",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"s",
"[",
"1",
":",
"]",
"{",
"if",
"!",
"isAlphaNumeric",
"(",
"c",
")",
"{",
"return",
"<mask>",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] |
2,716 | all-2717 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"GetMetricsReturns",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoPerformance2",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
2,717 | all-2718 | [
"Support",
"migrating",
"single",
"string",
"Driver",
"fields",
"to",
"slices",
"."
] | [
"func",
"migrateStringToSlice",
"(",
"value",
"string",
",",
"values",
"[",
"]",
"string",
")",
"(",
"<mask>",
"[",
"]",
"string",
")",
"{",
"if",
"value",
"!=",
"\"",
"\"",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"value",
")",
"\n",
"}",
"\n",
"result",
"=",
"append",
"(",
"result",
",",
"values",
"...",
")",
"\n",
"return",
"\n",
"}"
] |
2,718 | all-2719 | [
"Set",
"sets",
"the",
"value",
"by",
"key",
"and",
"associates",
"it",
"with",
"the",
"current",
"goroutine",
"."
] | [
"func",
"Set",
"(",
"key",
"string",
",",
"<mask>",
"interface",
"{",
"}",
")",
"{",
"gid",
":=",
"curGoroutineID",
"(",
")",
"\n",
"dataLock",
".",
"Lock",
"(",
")",
"\n",
"if",
"data",
"[",
"gid",
"]",
"==",
"nil",
"{",
"data",
"[",
"gid",
"]",
"=",
"Values",
"{",
"}",
"\n",
"}",
"\n",
"data",
"[",
"gid",
"]",
"[",
"key",
"]",
"=",
"value",
"\n",
"dataLock",
".",
"Unlock",
"(",
")",
"\n",
"}"
] |
2,719 | all-2720 | [
"UnmarshalJSON",
"deserialises",
"the",
"raw",
"JSON",
"to",
"a",
"ASMAuthResource",
"struct"
] | [
"func",
"(",
"auth",
"*",
"ASMAuthResource",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"temp",
":=",
"asmAuthResourceJSON",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"&",
"temp",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"temp",
".",
"DesiredStatus",
"!=",
"nil",
"{",
"auth",
".",
"SetDesiredStatus",
"(",
"resourcestatus",
".",
"ResourceStatus",
"(",
"*",
"temp",
".",
"DesiredStatus",
")",
")",
"\n",
"}",
"\n",
"if",
"temp",
".",
"KnownStatus",
"!=",
"nil",
"{",
"auth",
".",
"SetKnownStatus",
"(",
"resourcestatus",
".",
"ResourceStatus",
"(",
"*",
"temp",
".",
"KnownStatus",
")",
")",
"\n",
"}",
"\n",
"if",
"temp",
".",
"CreatedAt",
"!=",
"nil",
"&&",
"!",
"temp",
".",
"CreatedAt",
".",
"IsZero",
"(",
")",
"{",
"auth",
".",
"SetCreatedAt",
"(",
"*",
"temp",
".",
"CreatedAt",
")",
"\n",
"}",
"\n",
"if",
"temp",
".",
"RequiredASMResources",
"!=",
"nil",
"{",
"auth",
".",
"requiredASMResources",
"=",
"temp",
".",
"RequiredASMResources",
"\n",
"}",
"\n",
"auth",
".",
"taskARN",
"=",
"temp",
".",
"TaskARN",
"\n",
"auth",
".",
"executionCredentialsID",
"=",
"<mask>",
".",
"ExecutionCredentialsID",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
2,720 | all-2721 | [
"Log",
"calls",
"UI",
".",
"Log",
"to",
"write",
".",
"This",
"is",
"a",
"thread",
"safe",
"function",
"."
] | [
"func",
"(",
"ui",
"*",
"ConcurrentUI",
")",
"<mask>",
"(",
"message",
"string",
")",
"{",
"ui",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ui",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"ui",
".",
"UI",
".",
"Log",
"(",
"message",
")",
"\n",
"}"
] |
2,721 | all-2722 | [
"Get",
"provides",
"a",
"mock",
"function",
"with",
"given",
"fields",
":",
"_a0",
"_a1"
] | [
"func",
"(",
"_m",
"*",
"InstrumentedStorage",
")",
"Get",
"(",
"_a0",
"context",
".",
"Context",
",",
"_a1",
"string",
")",
"(",
"*",
"mnemosynerpc",
".",
"Session",
",",
"error",
")",
"{",
"ret",
":=",
"_m",
".",
"Called",
"(",
"_a0",
",",
"_a1",
")",
"\n\n",
"var",
"r0",
"*",
"mnemosynerpc",
".",
"Session",
"\n",
"if",
"rf",
",",
"ok",
":=",
"ret",
".",
"Get",
"(",
"0",
")",
".",
"(",
"func",
"(",
"context",
".",
"<mask>",
",",
"string",
")",
"*",
"mnemosynerpc",
".",
"Session",
")",
";",
"ok",
"{",
"r0",
"=",
"rf",
"(",
"_a0",
",",
"_a1",
")",
"\n",
"}",
"else",
"{",
"if",
"ret",
".",
"Get",
"(",
"0",
")",
"!=",
"nil",
"{",
"r0",
"=",
"ret",
".",
"Get",
"(",
"0",
")",
".",
"(",
"*",
"mnemosynerpc",
".",
"Session",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"var",
"r1",
"error",
"\n",
"if",
"rf",
",",
"ok",
":=",
"ret",
".",
"Get",
"(",
"1",
")",
".",
"(",
"func",
"(",
"context",
".",
"Context",
",",
"string",
")",
"error",
")",
";",
"ok",
"{",
"r1",
"=",
"rf",
"(",
"_a0",
",",
"_a1",
")",
"\n",
"}",
"else",
"{",
"r1",
"=",
"ret",
".",
"Error",
"(",
"1",
")",
"\n",
"}",
"\n\n",
"return",
"r0",
",",
"r1",
"\n",
"}"
] |
2,722 | all-2723 | [
"HaveURL",
"passes",
"when",
"the",
"expected",
"URL",
"is",
"equivalent",
"to",
"the",
"current",
"URL",
"of",
"the",
"provided",
"page",
"."
] | [
"func",
"HaveURL",
"(",
"url",
"string",
")",
"types",
".",
"GomegaMatcher",
"{",
"return",
"&",
"<mask>",
".",
"ValueMatcher",
"{",
"Method",
":",
"\"",
"\"",
",",
"Property",
":",
"\"",
"\"",
",",
"Expected",
":",
"url",
"}",
"\n",
"}"
] |
2,723 | all-2724 | [
"This",
"is",
"run",
"at",
"init",
"time",
"only",
"."
] | [
"func",
"escapedPathExp",
"(",
"pathExp",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"// PathExp validation",
"if",
"pathExp",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"pathExp",
"[",
"0",
"]",
"!=",
"'/'",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"pathExp",
",",
"\"",
"\"",
")",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Get the right escaping",
"// XXX a bit hacky",
"pathExp",
"=",
"preEscape",
".",
"Replace",
"(",
"pathExp",
")",
"\n\n",
"urlObj",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"pathExp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"// get the same escaping as find requests",
"pathExp",
"=",
"urlObj",
".",
"RequestURI",
"(",
")",
"\n\n",
"pathExp",
"=",
"postEscape",
".",
"Replace",
"(",
"pathExp",
")",
"\n\n",
"return",
"pathExp",
",",
"nil",
"\n",
"}"
] |
2,724 | all-2725 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"GetWindowBoundsParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoBrowser8",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
2,725 | all-2726 | [
"NewManager",
"creates",
"a",
"metadataManager",
"for",
"a",
"given",
"DockerTaskEngine",
"settings",
"."
] | [
"func",
"NewManager",
"(",
"<mask>",
"DockerMetadataClient",
",",
"cfg",
"*",
"config",
".",
"Config",
")",
"Manager",
"{",
"return",
"&",
"metadataManager",
"{",
"client",
":",
"client",
",",
"cluster",
":",
"cfg",
".",
"Cluster",
",",
"dataDir",
":",
"cfg",
".",
"DataDir",
",",
"dataDirOnHost",
":",
"cfg",
".",
"DataDirOnHost",
",",
"osWrap",
":",
"oswrapper",
".",
"NewOS",
"(",
")",
",",
"ioutilWrap",
":",
"ioutilwrapper",
".",
"NewIOUtil",
"(",
")",
",",
"}",
"\n",
"}"
] |
2,726 | all-2727 | [
"parse",
"takes",
"a",
"file",
"sequence",
"pattern",
"and",
"returns",
"the",
"parsed",
"data",
"as",
"a",
"Result"
] | [
"func",
"parse",
"(",
"pattern",
"string",
",",
"opts",
"*",
"OptionsType",
")",
"*",
"Result",
"{",
"res",
":=",
"&",
"Result",
"{",
"String",
":",
"pattern",
",",
"origString",
":",
"pattern",
"}",
"\n\n",
"padStyle",
":=",
"fileseq",
".",
"PadStyleHash4",
"\n",
"if",
"opts",
".",
"Hash1",
"{",
"padStyle",
"=",
"fileseq",
".",
"PadStyleHash1",
"\n",
"}",
"\n\n",
"fs",
",",
"err",
":=",
"fileseq",
".",
"NewFileSequencePad",
"(",
"<mask>",
",",
"padStyle",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"res",
".",
"Error",
"=",
"err",
".",
"Error",
"(",
")",
"\n",
"return",
"res",
"\n",
"}",
"\n\n",
"// Handle any of the optional modifications to the seq",
"if",
"opts",
".",
"Format",
"!=",
"\"",
"\"",
"{",
"refmt",
",",
"err",
":=",
"fs",
".",
"Format",
"(",
"opts",
".",
"Format",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"res",
".",
"Error",
"=",
"err",
".",
"Error",
"(",
")",
"\n",
"return",
"res",
"\n",
"}",
"\n",
"fs",
",",
"err",
"=",
"fileseq",
".",
"NewFileSequencePad",
"(",
"refmt",
",",
"padStyle",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"res",
".",
"Error",
"=",
"err",
".",
"Error",
"(",
")",
"\n",
"return",
"res",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"Dirname",
"!=",
"\"",
"\"",
"{",
"fs",
".",
"SetDirname",
"(",
"opts",
".",
"Dirname",
")",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"Basename",
"!=",
"\"",
"\"",
"{",
"fs",
".",
"SetBasename",
"(",
"opts",
".",
"Basename",
")",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"Ext",
"!=",
"\"",
"\"",
"{",
"fs",
".",
"SetExt",
"(",
"opts",
".",
"Ext",
")",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"Padding",
"!=",
"\"",
"\"",
"{",
"fs",
".",
"SetPadding",
"(",
"opts",
".",
"Padding",
")",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"Range",
"!=",
"\"",
"\"",
"{",
"if",
"err",
":=",
"fs",
".",
"SetFrameRange",
"(",
"opts",
".",
"Range",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
".",
"Error",
"=",
"err",
".",
"Error",
"(",
")",
"\n",
"return",
"res",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"Inverted",
"{",
"frange",
":=",
"fs",
".",
"InvertedFrameRange",
"(",
")",
"\n",
"if",
"frange",
"!=",
"\"",
"\"",
"{",
"_",
"=",
"fs",
".",
"SetFrameRange",
"(",
"frange",
")",
"\n",
"}",
"else",
"{",
"fs",
".",
"SetFrameSet",
"(",
"nil",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"Index",
"!=",
"nil",
"{",
"frame",
":=",
"fs",
".",
"Index",
"(",
"*",
"opts",
".",
"Index",
")",
"\n",
"if",
"frame",
"==",
"\"",
"\"",
"{",
"res",
".",
"Error",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"*",
"opts",
".",
"Index",
",",
"fs",
".",
"FrameRange",
"(",
")",
")",
"\n",
"return",
"res",
"\n",
"}",
"\n",
"fs",
",",
"_",
"=",
"fileseq",
".",
"NewFileSequencePad",
"(",
"frame",
",",
"padStyle",
")",
"\n",
"_",
"=",
"fs",
".",
"SetFrameRange",
"(",
"strconv",
".",
"Itoa",
"(",
"fs",
".",
"Start",
"(",
")",
")",
")",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"Frame",
"!=",
"nil",
"{",
"frame",
",",
"_",
":=",
"fs",
".",
"Frame",
"(",
"*",
"opts",
".",
"Frame",
")",
"\n",
"fs",
",",
"_",
"=",
"fileseq",
".",
"NewFileSequencePad",
"(",
"frame",
",",
"padStyle",
")",
"\n",
"_",
"=",
"fs",
".",
"SetFrameRange",
"(",
"strconv",
".",
"Itoa",
"(",
"fs",
".",
"Start",
"(",
")",
")",
")",
"\n",
"}",
"\n\n",
"// Final setting of results",
"res",
".",
"String",
"=",
"fs",
".",
"String",
"(",
")",
"\n",
"res",
".",
"Dirname",
"=",
"fs",
".",
"Dirname",
"(",
")",
"\n",
"res",
".",
"Basename",
"=",
"fs",
".",
"Basename",
"(",
")",
"\n",
"res",
".",
"Ext",
"=",
"fs",
".",
"Ext",
"(",
")",
"\n",
"res",
".",
"Start",
"=",
"fs",
".",
"Start",
"(",
")",
"\n",
"res",
".",
"End",
"=",
"fs",
".",
"End",
"(",
")",
"\n",
"res",
".",
"Len",
"=",
"fs",
".",
"Len",
"(",
")",
"\n",
"res",
".",
"Padding",
"=",
"fs",
".",
"Padding",
"(",
")",
"\n",
"res",
".",
"ZFill",
"=",
"fs",
".",
"ZFill",
"(",
")",
"\n",
"res",
".",
"Range",
"=",
"fs",
".",
"FrameRange",
"(",
")",
"\n",
"res",
".",
"HasRange",
"=",
"(",
"fs",
".",
"FrameSet",
"(",
")",
"!=",
"nil",
")",
"\n\n",
"return",
"res",
"\n",
"}"
] |
2,727 | all-2728 | [
"SetCursorVisible",
"is",
"a",
"wrapper",
"around",
"gtk_text_view_set_cursor_visible",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"TextView",
")",
"SetCursorVisible",
"(",
"<mask>",
"bool",
")",
"{",
"C",
".",
"gtk_text_view_set_cursor_visible",
"(",
"v",
".",
"native",
"(",
")",
",",
"gbool",
"(",
"visible",
")",
")",
"\n",
"}"
] |
2,728 | all-2729 | [
"decode",
"accepts",
"an",
"ogg",
"stream",
"and",
"returns",
"a",
"decorded",
"stream",
"."
] | [
"func",
"decode",
"(",
"in",
"audio",
".",
"ReadSeekCloser",
")",
"(",
"*",
"decoded",
",",
"int",
",",
"int",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"newDecoder",
"(",
"in",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"d",
":=",
"&",
"decoded",
"{",
"// TODO: r.Length() returns 0 when the format is unknown.",
"// Should we check that?",
"totalBytes",
":",
"int",
"(",
"r",
".",
"Length",
"(",
")",
")",
"*",
"r",
".",
"Channels",
"(",
")",
"*",
"2",
",",
"// 2 means 16bit per sample.",
"posInBytes",
":",
"0",
",",
"<mask>",
":",
"in",
",",
"decoder",
":",
"r",
",",
"}",
"\n",
"runtime",
".",
"SetFinalizer",
"(",
"d",
",",
"(",
"*",
"decoded",
")",
".",
"Close",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"d",
".",
"Read",
"(",
"make",
"(",
"[",
"]",
"byte",
",",
"65536",
")",
")",
";",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"io",
".",
"EOF",
"{",
"return",
"nil",
",",
"0",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"d",
".",
"Seek",
"(",
"0",
",",
"io",
".",
"SeekStart",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"return",
"d",
",",
"r",
".",
"Channels",
"(",
")",
",",
"r",
".",
"SampleRate",
"(",
")",
",",
"nil",
"\n",
"}"
] |
2,729 | all-2730 | [
"Uint16SliceToStringSlice",
"converts",
"a",
"slice",
"of",
"type",
"uint16",
"to",
"a",
"slice",
"of",
"type",
"*",
"string",
".",
"It",
"uses",
"strconv",
".",
"Itoa",
"on",
"each",
"element"
] | [
"func",
"Uint16SliceToStringSlice",
"(",
"slice",
"[",
"]",
"uint16",
")",
"[",
"]",
"*",
"string",
"{",
"stringSlice",
":=",
"make",
"(",
"[",
"]",
"*",
"string",
",",
"len",
"(",
"slice",
")",
")",
"\n",
"for",
"i",
",",
"el",
":=",
"<mask>",
"slice",
"{",
"str",
":=",
"strconv",
".",
"Itoa",
"(",
"int",
"(",
"el",
")",
")",
"\n",
"stringSlice",
"[",
"i",
"]",
"=",
"&",
"str",
"\n",
"}",
"\n",
"return",
"stringSlice",
"\n",
"}"
] |
2,730 | all-2731 | [
"HasName",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"HasName",
"(",
")",
"bool",
"{",
"if",
"m",
"!=",
"nil",
"&&",
"m",
".",
"Name",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
2,731 | all-2732 | [
"SaveVimClient",
"saves",
"a",
"client",
"to",
"the",
"supplied",
"path",
".",
"This",
"facilitates",
"re",
"-",
"use",
"of",
"the",
"session",
"at",
"a",
"later",
"date",
".",
"Note",
"the",
"logic",
"in",
"this",
"function",
"has",
"been",
"largely",
"adapted",
"from",
"govc",
"and",
"is",
"designed",
"to",
"be",
"compatible",
"with",
"it",
"."
] | [
"func",
"(",
"c",
"*",
"Config",
")",
"SaveVimClient",
"(",
"<mask>",
"*",
"govmomi",
".",
"Client",
")",
"error",
"{",
"if",
"!",
"c",
".",
"Persist",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"p",
",",
"err",
":=",
"c",
".",
"vimSessionFile",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"p",
")",
"\n",
"err",
"=",
"os",
".",
"MkdirAll",
"(",
"filepath",
".",
"Dir",
"(",
"p",
")",
",",
"0700",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"f",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"p",
",",
"os",
".",
"O_CREATE",
"|",
"os",
".",
"O_WRONLY",
",",
"0600",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
"=",
"f",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"p",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"err",
"=",
"json",
".",
"NewEncoder",
"(",
"f",
")",
".",
"Encode",
"(",
"client",
".",
"Client",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
2,732 | all-2733 | [
"cancel",
"indicates",
"that",
"an",
"error",
"has",
"occurred",
"which",
"will",
"prevent",
"any",
"further",
"calls",
"to",
"Write",
"it",
"causes",
"all",
"calls",
"to",
"wait",
"()",
"to",
"return"
] | [
"func",
"(",
"c",
"*",
"<mask>",
")",
"cancel",
"(",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"n",
"=",
"math",
".",
"MaxInt64",
"\n",
"}"
] |
2,733 | all-2734 | [
"RootSnapshot",
"returns",
"a",
"root",
"Snapshot",
"instance",
"belonging",
"to",
"the",
"current",
"virtual",
"machine",
".",
"Parameters",
":",
"index",
":",
"Identifies",
"a",
"root",
"snapshot",
".",
"See",
"below",
"for",
"range",
"of",
"values",
".",
"Remarks",
":",
"*",
"Snapshots",
"are",
"indexed",
"from",
"0",
"to",
"n",
"-",
"1",
"where",
"n",
"is",
"the",
"number",
"of",
"root",
"snapshots",
".",
"Use",
"the",
"function",
"VM",
".",
"TotalRootSnapshots",
"to",
"get",
"the",
"value",
"of",
"n",
".",
"*",
"VMware",
"Server",
"can",
"manage",
"only",
"a",
"single",
"snapshot",
"for",
"each",
"virtual",
"machine",
".",
"The",
"value",
"of",
"index",
"can",
"only",
"be",
"0",
".",
"*",
"This",
"function",
"is",
"not",
"supported",
"when",
"using",
"the",
"VMWARE_PLAYER",
"provider",
"Since",
"VMware",
"Server",
"1",
".",
"0"
] | [
"func",
"(",
"v",
"*",
"VM",
")",
"RootSnapshot",
"(",
"index",
"int",
")",
"(",
"*",
"Snapshot",
",",
"error",
")",
"{",
"var",
"snapshotHandle",
"C",
".",
"VixHandle",
"=",
"C",
".",
"VIX_INVALID_HANDLE",
"\n",
"<mask>",
"err",
"C",
".",
"VixError",
"=",
"C",
".",
"VIX_OK",
"\n\n",
"err",
"=",
"C",
".",
"VixVM_GetRootSnapshot",
"(",
"v",
".",
"handle",
",",
"C",
".",
"int",
"(",
"index",
")",
",",
"&",
"snapshotHandle",
")",
"\n\n",
"if",
"C",
".",
"VIX_OK",
"!=",
"err",
"{",
"return",
"nil",
",",
"&",
"Error",
"{",
"Operation",
":",
"\"",
"\"",
",",
"Code",
":",
"int",
"(",
"err",
"&",
"0xFFFF",
")",
",",
"Text",
":",
"C",
".",
"GoString",
"(",
"C",
".",
"Vix_GetErrorText",
"(",
"err",
",",
"nil",
")",
")",
",",
"}",
"\n",
"}",
"\n\n",
"snapshot",
":=",
"&",
"Snapshot",
"{",
"handle",
":",
"snapshotHandle",
"}",
"\n\n",
"runtime",
".",
"SetFinalizer",
"(",
"snapshot",
",",
"cleanupSnapshot",
")",
"\n\n",
"return",
"snapshot",
",",
"nil",
"\n",
"}"
] |
2,734 | all-2735 | [
"Open",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockFileSystem",
")",
"Open",
"(",
"arg0",
"string",
")",
"(",
"io",
".",
"ReadWriteCloser",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
":=",
"<mask>",
"[",
"0",
"]",
".",
"(",
"io",
".",
"ReadWriteCloser",
")",
"\n",
"ret1",
",",
"_",
":=",
"ret",
"[",
"1",
"]",
".",
"(",
"error",
")",
"\n",
"return",
"ret0",
",",
"ret1",
"\n",
"}"
] |
2,735 | all-2736 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"GetHistogramParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoBrowser14",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
2,736 | all-2737 | [
"Validate",
"validates",
"GitHub",
"options",
"."
] | [
"func",
"(",
"o",
"*",
"GitHubOptions",
")",
"Validate",
"(",
"dryRun",
"bool",
")",
"error",
"{",
"for",
"_",
",",
"uri",
":=",
"range",
"o",
".",
"endpoint",
".",
"Strings",
"(",
")",
"{",
"if",
"uri",
"==",
"\"",
"\"",
"{",
"uri",
"=",
"github",
".",
"DefaultAPIEndpoint",
"\n",
"}",
"else",
"if",
"_",
",",
"err",
":=",
"url",
".",
"ParseRequestURI",
"(",
"uri",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"uri",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"o",
".",
"graphqlEndpoint",
"==",
"\"",
"\"",
"{",
"o",
".",
"graphqlEndpoint",
"=",
"github",
".",
"DefaultGraphQLEndpoint",
"\n",
"}",
"else",
"if",
"_",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"o",
".",
"graphqlEndpoint",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"o",
".",
"graphqlEndpoint",
")",
"\n",
"}",
"\n\n",
"if",
"o",
".",
"deprecatedTokenFile",
"!=",
"\"",
"\"",
"{",
"o",
".",
"TokenPath",
"=",
"o",
".",
"deprecatedTokenFile",
"\n",
"logrus",
".",
"<mask>",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"o",
".",
"TokenPath",
"==",
"\"",
"\"",
"{",
"logrus",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
2,737 | all-2738 | [
"Retrieves",
"the",
"GObject",
"instance",
"used",
"as",
"the",
"target",
"of",
"the",
"binding",
"."
] | [
"func",
"(",
"v",
"*",
"Binding",
")",
"GetTarget",
"(",
")",
"*",
"<mask>",
"{",
"obj",
":=",
"C",
".",
"g_binding_get_target",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"if",
"obj",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"wrapObject",
"(",
"unsafe",
".",
"Pointer",
"(",
"obj",
")",
")",
"\n",
"}"
] |
2,738 | all-2739 | [
"Do",
"executes",
"DOMSnapshot",
".",
"captureSnapshot",
"against",
"the",
"provided",
"context",
".",
"returns",
":",
"documents",
"-",
"The",
"nodes",
"in",
"the",
"DOM",
"tree",
".",
"The",
"DOMNode",
"at",
"index",
"0",
"corresponds",
"to",
"the",
"root",
"document",
".",
"strings",
"-",
"Shared",
"string",
"table",
"that",
"all",
"string",
"properties",
"refer",
"to",
"with",
"indexes",
"."
] | [
"func",
"(",
"p",
"*",
"CaptureSnapshotParams",
")",
"Do",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"documents",
"[",
"]",
"*",
"DocumentSnapshot",
",",
"strings",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"// execute",
"var",
"<mask>",
"CaptureSnapshotReturns",
"\n",
"err",
"=",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandCaptureSnapshot",
",",
"p",
",",
"&",
"res",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
".",
"Documents",
",",
"res",
".",
"Strings",
",",
"nil",
"\n",
"}"
] |
2,739 | all-2740 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"GetCookiesReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork34",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
2,740 | all-2741 | [
"SetTitle",
"is",
"a",
"wrapper",
"around",
"gtk_status_icon_set_title",
"()"
] | [
"func",
"(",
"v",
"*",
"StatusIcon",
")",
"SetTitle",
"(",
"<mask>",
"string",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"title",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"C",
".",
"gtk_status_icon_set_title",
"(",
"v",
".",
"native",
"(",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
] |
2,741 | all-2742 | [
"parseMultiPartBody",
"parses",
"a",
"multipart",
"message",
"in",
"root",
".",
"The",
"result",
"is",
"placed",
"in",
"e",
"."
] | [
"func",
"parseMultiPartBody",
"(",
"root",
"*",
"Part",
",",
"e",
"*",
"Envelope",
")",
"error",
"{",
"// Parse top-level multipart",
"ctype",
":=",
"root",
".",
"Header",
".",
"Get",
"(",
"hnContentType",
")",
"\n",
"mediatype",
",",
"params",
",",
"_",
",",
"err",
":=",
"parseMediaType",
"(",
"ctype",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"mediatype",
",",
"ctMultipartPrefix",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"mediatype",
")",
"\n",
"}",
"\n",
"boundary",
":=",
"params",
"[",
"hpBoundary",
"]",
"\n",
"if",
"boundary",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Locate text body",
"if",
"mediatype",
"==",
"ctMultipartAltern",
"{",
"p",
":=",
"root",
".",
"BreadthMatchFirst",
"(",
"func",
"(",
"p",
"*",
"Part",
")",
"bool",
"{",
"return",
"p",
".",
"ContentType",
"==",
"ctTextPlain",
"&&",
"p",
".",
"Disposition",
"!=",
"cdAttachment",
"\n",
"}",
")",
"\n",
"if",
"p",
"!=",
"nil",
"{",
"e",
".",
"Text",
"=",
"string",
"(",
"p",
".",
"Content",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// multipart is of a mixed type",
"parts",
":=",
"root",
".",
"DepthMatchAll",
"(",
"func",
"(",
"p",
"*",
"Part",
")",
"bool",
"{",
"return",
"p",
".",
"ContentType",
"==",
"ctTextPlain",
"&&",
"p",
".",
"Disposition",
"!=",
"cdAttachment",
"\n",
"}",
")",
"\n",
"for",
"i",
",",
"p",
":=",
"<mask>",
"parts",
"{",
"if",
"i",
">",
"0",
"{",
"e",
".",
"Text",
"+=",
"\"",
"\\n",
"\\n",
"\"",
"\n",
"}",
"\n",
"e",
".",
"Text",
"+=",
"string",
"(",
"p",
".",
"Content",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Locate HTML body",
"p",
":=",
"root",
".",
"BreadthMatchFirst",
"(",
"matchHTMLBodyPart",
")",
"\n",
"if",
"p",
"!=",
"nil",
"{",
"e",
".",
"HTML",
"+=",
"string",
"(",
"p",
".",
"Content",
")",
"\n",
"}",
"\n\n",
"// Locate attachments",
"e",
".",
"Attachments",
"=",
"root",
".",
"BreadthMatchAll",
"(",
"func",
"(",
"p",
"*",
"Part",
")",
"bool",
"{",
"return",
"p",
".",
"Disposition",
"==",
"cdAttachment",
"||",
"p",
".",
"ContentType",
"==",
"ctAppOctetStream",
"\n",
"}",
")",
"\n\n",
"// Locate inlines",
"e",
".",
"Inlines",
"=",
"root",
".",
"BreadthMatchAll",
"(",
"func",
"(",
"p",
"*",
"Part",
")",
"bool",
"{",
"return",
"p",
".",
"Disposition",
"==",
"cdInline",
"&&",
"!",
"strings",
".",
"HasPrefix",
"(",
"p",
".",
"ContentType",
",",
"ctMultipartPrefix",
")",
"\n",
"}",
")",
"\n\n",
"// Locate others parts not considered in attachments or inlines",
"e",
".",
"OtherParts",
"=",
"root",
".",
"BreadthMatchAll",
"(",
"func",
"(",
"p",
"*",
"Part",
")",
"bool",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"p",
".",
"ContentType",
",",
"ctMultipartPrefix",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"p",
".",
"Disposition",
"!=",
"\"",
"\"",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"p",
".",
"ContentType",
"==",
"ctAppOctetStream",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"p",
".",
"ContentType",
"!=",
"ctTextPlain",
"&&",
"p",
".",
"ContentType",
"!=",
"ctTextHTML",
"\n",
"}",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
2,742 | all-2743 | [
"GetURI",
"is",
"a",
"wrapper",
"around",
"gtk_file_chooser_get_uri",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"FileChooser",
")",
"GetURI",
"(",
")",
"string",
"{",
"c",
":=",
"C",
".",
"gtk_file_chooser_get_uri",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"s",
":=",
"goString",
"(",
"c",
")",
"\n",
"defer",
"C",
".",
"g_free",
"(",
"(",
"C",
".",
"gpointer",
")",
"(",
"c",
")",
")",
"\n",
"<mask>",
"s",
"\n",
"}"
] |
2,743 | all-2744 | [
"Log",
"indicates",
"an",
"expected",
"call",
"of",
"Log"
] | [
"func",
"(",
"mr",
"*",
"MockAuditLoggerMockRecorder",
")",
"Log",
"(",
"arg0",
",",
"arg1",
",",
"arg2",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
"TypeOf",
"(",
"(",
"*",
"MockAuditLogger",
")",
"(",
"nil",
")",
".",
"<mask>",
")",
",",
"arg0",
",",
"arg1",
",",
"arg2",
")",
"\n",
"}"
] |
2,744 | all-2745 | [
"GetClientIDOk",
"returns",
"a",
"tuple",
"with",
"the",
"ClientID",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"i",
"*",
"IntegrationGCPCreateRequest",
")",
"GetClientIDOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"i",
"==",
"nil",
"||",
"i",
".",
"ClientID",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"i",
".",
"ClientID",
",",
"true",
"\n",
"}"
] |
2,745 | all-2746 | [
"MarshalJSON",
"calls",
"json",
".",
"RawMessage",
"method",
"of",
"the",
"same",
"name",
".",
"Required",
"since",
"LaunchInfo",
"is",
"of",
"type",
"json",
".",
"RawMessage",
"..."
] | [
"func",
"(",
"this",
"*",
"LaunchInfo",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"x",
":=",
"json",
".",
"RawMessage",
"(",
"*",
"this",
")",
"\n",
"return",
"(",
"&",
"x",
")",
".",
"MarshalJSON",
"(",
")",
"\n",
"}"
] |
2,746 | all-2747 | [
"Read",
"function",
"gets",
"the",
"value",
"of",
"the",
"node",
".",
"If",
"the",
"receiver",
"node",
"is",
"not",
"a",
"key",
"-",
"value",
"pair",
"a",
"Not",
"A",
"File",
"error",
"will",
"be",
"returned",
"."
] | [
"func",
"(",
"n",
"*",
"node",
")",
"Read",
"(",
")",
"(",
"string",
",",
"*",
"v2error",
".",
"Error",
")",
"{",
"if",
"n",
".",
"IsDir",
"(",
")",
"{",
"return",
"\"",
"\"",
",",
"v2error",
".",
"NewError",
"(",
"v2error",
".",
"EcodeNotFile",
",",
"\"",
"\"",
",",
"n",
".",
"store",
".",
"CurrentIndex",
")",
"\n",
"}",
"\n\n",
"return",
"n",
".",
"<mask>",
",",
"nil",
"\n",
"}"
] |
2,747 | all-2748 | [
"ApplyDefault",
"applies",
"the",
"defaults",
"for",
"the",
"UtilityImages",
"decorations",
".",
"If",
"a",
"field",
"has",
"a",
"zero",
"value",
"it",
"replaces",
"that",
"with",
"the",
"value",
"set",
"in",
"def",
"."
] | [
"func",
"(",
"u",
"*",
"UtilityImages",
")",
"ApplyDefault",
"(",
"def",
"*",
"UtilityImages",
")",
"*",
"UtilityImages",
"{",
"if",
"u",
"==",
"nil",
"{",
"return",
"def",
"\n",
"}",
"else",
"if",
"def",
"==",
"nil",
"{",
"<mask>",
"u",
"\n",
"}",
"\n\n",
"merged",
":=",
"*",
"u",
"\n",
"if",
"merged",
".",
"CloneRefs",
"==",
"\"",
"\"",
"{",
"merged",
".",
"CloneRefs",
"=",
"def",
".",
"CloneRefs",
"\n",
"}",
"\n",
"if",
"merged",
".",
"InitUpload",
"==",
"\"",
"\"",
"{",
"merged",
".",
"InitUpload",
"=",
"def",
".",
"InitUpload",
"\n",
"}",
"\n",
"if",
"merged",
".",
"Entrypoint",
"==",
"\"",
"\"",
"{",
"merged",
".",
"Entrypoint",
"=",
"def",
".",
"Entrypoint",
"\n",
"}",
"\n",
"if",
"merged",
".",
"Sidecar",
"==",
"\"",
"\"",
"{",
"merged",
".",
"Sidecar",
"=",
"def",
".",
"Sidecar",
"\n",
"}",
"\n",
"return",
"&",
"merged",
"\n",
"}"
] |
2,748 | all-2749 | [
"ResetSecretForApiClient",
"requests",
"a",
"snapshot",
"of",
"an",
"existing",
"api",
"client"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"ResetSecretForApiClient",
"(",
"identifier",
"string",
")",
"(",
"*",
"ApiClient",
",",
"error",
")",
"{",
"ac",
":=",
"<mask>",
"(",
"ApiClient",
")",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"MakeApiRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"identifier",
"+",
"\"",
"\"",
",",
"nil",
",",
"&",
"ac",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"ac",
",",
"nil",
"\n",
"}"
] |
2,749 | all-2750 | [
"BatchQuery",
"creates",
"a",
"batch",
"query",
"with",
"the",
"given",
"queries",
"."
] | [
"func",
"(",
"idx",
"*",
"Index",
")",
"BatchQuery",
"(",
"queries",
"...",
"PQLQuery",
")",
"*",
"PQLBatchQuery",
"{",
"stringQueries",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"queries",
")",
")",
"\n",
"hasKeys",
":=",
"false",
"\n",
"for",
"_",
",",
"query",
":=",
"<mask>",
"queries",
"{",
"serializedQuery",
":=",
"query",
".",
"Serialize",
"(",
")",
"\n",
"hasKeys",
"=",
"hasKeys",
"||",
"serializedQuery",
".",
"HasWriteKeys",
"(",
")",
"\n",
"stringQueries",
"=",
"append",
"(",
"stringQueries",
",",
"serializedQuery",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"&",
"PQLBatchQuery",
"{",
"index",
":",
"idx",
",",
"queries",
":",
"stringQueries",
",",
"hasKeys",
":",
"hasKeys",
",",
"}",
"\n",
"}"
] |
2,750 | all-2751 | [
"CloseNotify",
"implements",
"the",
"http",
".",
"CloseNotifier",
"interface"
] | [
"func",
"(",
"w",
"*",
"Response",
")",
"CloseNotify",
"(",
")",
"<-",
"chan",
"bool",
"{",
"if",
"cn",
",",
"<mask>",
":=",
"w",
".",
"ResponseWriter",
".",
"(",
"closeNotifier",
")",
";",
"ok",
"{",
"return",
"cn",
".",
"CloseNotify",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
2,751 | all-2752 | [
"fast",
"path",
"for",
"single",
"topic",
"validation",
"that",
"avoids",
"the",
"extra",
"goroutine"
] | [
"func",
"(",
"p",
"*",
"PubSub",
")",
"validateSingleTopic",
"(",
"val",
"*",
"topicVal",
",",
"src",
"peer",
".",
"ID",
",",
"msg",
"*",
"Message",
")",
"bool",
"{",
"select",
"{",
"case",
"val",
".",
"validateThrottle",
"<-",
"struct",
"{",
"}",
"{",
"}",
":",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"p",
".",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n\n",
"<mask>",
":=",
"val",
".",
"validateMsg",
"(",
"ctx",
",",
"src",
",",
"msg",
")",
"\n",
"<-",
"val",
".",
"validateThrottle",
"\n\n",
"return",
"res",
"\n\n",
"default",
":",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"val",
".",
"topic",
")",
"\n",
"return",
"false",
"\n",
"}",
"\n",
"}"
] |
2,752 | all-2753 | [
"GetKey",
"returns",
"the",
"key",
"associated",
"with",
"the",
"provided",
"ID",
"."
] | [
"func",
"(",
"j",
"*",
"JWKClient",
")",
"GetKey",
"(",
"ID",
"string",
")",
"(",
"jose",
".",
"JSONWebKey",
",",
"error",
")",
"{",
"j",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"j",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"searchedKey",
",",
"err",
":=",
"j",
".",
"keyCacher",
".",
"Get",
"(",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"<mask>",
",",
"err",
":=",
"j",
".",
"downloadKeys",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"jose",
".",
"JSONWebKey",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"addedKey",
",",
"err",
":=",
"j",
".",
"keyCacher",
".",
"Add",
"(",
"ID",
",",
"keys",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"jose",
".",
"JSONWebKey",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"return",
"*",
"addedKey",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"*",
"searchedKey",
",",
"nil",
"\n",
"}"
] |
2,753 | all-2754 | [
"GetIncludeTags",
"returns",
"the",
"IncludeTags",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"o",
"*",
"Options",
")",
"GetIncludeTags",
"(",
")",
"bool",
"{",
"if",
"o",
"==",
"nil",
"||",
"o",
".",
"IncludeTags",
"==",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"o",
".",
"IncludeTags",
"\n",
"}"
] |
2,754 | all-2755 | [
"NewConfig",
"creates",
"a",
"new",
"Config",
"populated",
"with",
"default",
"values",
"."
] | [
"func",
"NewConfig",
"(",
")",
"*",
"Config",
"{",
"lpurl",
",",
"_",
":=",
"url",
".",
"Parse",
"(",
"DefaultListenPeerURLs",
")",
"\n",
"apurl",
",",
"_",
":=",
"url",
".",
"Parse",
"(",
"DefaultInitialAdvertisePeerURLs",
")",
"\n",
"lcurl",
",",
"_",
":=",
"url",
".",
"Parse",
"(",
"DefaultListenClientURLs",
")",
"\n",
"acurl",
",",
"_",
":=",
"url",
".",
"Parse",
"(",
"DefaultAdvertiseClientURLs",
")",
"\n",
"cfg",
":=",
"&",
"Config",
"{",
"MaxSnapFiles",
":",
"DefaultMaxSnapshots",
",",
"MaxWalFiles",
":",
"DefaultMaxWALs",
",",
"Name",
":",
"DefaultName",
",",
"SnapshotCount",
":",
"etcdserver",
".",
"DefaultSnapshotCount",
",",
"SnapshotCatchUpEntries",
":",
"etcdserver",
".",
"DefaultSnapshotCatchUpEntries",
",",
"MaxTxnOps",
":",
"DefaultMaxTxnOps",
",",
"MaxRequestBytes",
":",
"DefaultMaxRequestBytes",
",",
"GRPCKeepAliveMinTime",
":",
"DefaultGRPCKeepAliveMinTime",
",",
"GRPCKeepAliveInterval",
":",
"DefaultGRPCKeepAliveInterval",
",",
"GRPCKeepAliveTimeout",
":",
"DefaultGRPCKeepAliveTimeout",
",",
"TickMs",
":",
"100",
",",
"ElectionMs",
":",
"1000",
",",
"InitialElectionTickAdvance",
":",
"true",
",",
"LPUrls",
":",
"[",
"]",
"url",
".",
"URL",
"{",
"*",
"lpurl",
"}",
",",
"LCUrls",
":",
"[",
"]",
"url",
".",
"URL",
"{",
"*",
"lcurl",
"}",
",",
"APUrls",
":",
"[",
"]",
"url",
".",
"URL",
"{",
"*",
"apurl",
"}",
",",
"ACUrls",
":",
"[",
"]",
"url",
".",
"URL",
"{",
"*",
"acurl",
"}",
",",
"ClusterState",
":",
"ClusterStateFlagNew",
",",
"InitialClusterToken",
":",
"\"",
"\"",
",",
"StrictReconfigCheck",
":",
"DefaultStrictReconfigCheck",
",",
"Metrics",
":",
"\"",
"\"",
",",
"EnableV2",
":",
"DefaultEnableV2",
",",
"CORS",
":",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
"{",
"\"",
"\"",
":",
"{",
"}",
"}",
",",
"HostWhitelist",
":",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
"{",
"\"",
"\"",
":",
"{",
"}",
"}",
",",
"AuthToken",
":",
"\"",
"\"",
",",
"BcryptCost",
":",
"uint",
"(",
"bcrypt",
".",
"DefaultCost",
")",
",",
"PreVote",
":",
"false",
",",
"// TODO: enable by default in v3.5",
"loggerMu",
":",
"<mask>",
"(",
"sync",
".",
"RWMutex",
")",
",",
"logger",
":",
"nil",
",",
"Logger",
":",
"\"",
"\"",
",",
"DeprecatedLogOutput",
":",
"[",
"]",
"string",
"{",
"DefaultLogOutput",
"}",
",",
"LogOutputs",
":",
"[",
"]",
"string",
"{",
"DefaultLogOutput",
"}",
",",
"Debug",
":",
"false",
",",
"LogPkgLevels",
":",
"\"",
"\"",
",",
"}",
"\n",
"cfg",
".",
"InitialCluster",
"=",
"cfg",
".",
"InitialClusterFromName",
"(",
"cfg",
".",
"Name",
")",
"\n",
"return",
"cfg",
"\n",
"}"
] |
2,755 | all-2756 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"GetMetadataReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoIndexeddb11",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
2,756 | all-2757 | [
"map",
"all",
"or",
"part",
"of",
"a",
"buffer",
"object",
"s",
"data",
"store",
"into",
"the",
"client",
"s",
"address",
"space"
] | [
"func",
"MapNamedBufferRange",
"(",
"buffer",
"uint32",
",",
"offset",
"int",
",",
"length",
"int",
",",
"access",
"uint32",
")",
"unsafe",
".",
"Pointer",
"{",
"ret",
":=",
"C",
".",
"glowMapNamedBufferRange",
"(",
"gpMapNamedBufferRange",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"buffer",
")",
",",
"(",
"C",
".",
"GLintptr",
")",
"(",
"offset",
")",
",",
"(",
"C",
".",
"GLsizeiptr",
")",
"(",
"length",
")",
",",
"(",
"C",
".",
"GLbitfield",
")",
"(",
"access",
")",
")",
"\n",
"return",
"(",
"unsafe",
".",
"Pointer",
")",
"(",
"<mask>",
")",
"\n",
"}"
] |
2,757 | all-2758 | [
"GiBToByte",
"returns",
"n",
"*",
"1024^3",
".",
"The",
"output",
"is",
"returned",
"as",
"int64",
"-",
"if",
"another",
"type",
"is",
"needed",
"it",
"needs",
"to",
"be",
"cast",
".",
"Remember",
"that",
"int32",
"overflows",
"at",
"around",
"2GiB",
"and",
"uint32",
"will",
"overflow",
"at",
"4GiB",
"."
] | [
"func",
"GiBToByte",
"(",
"n",
"interface",
"{",
"}",
")",
"int64",
"{",
"switch",
"v",
":=",
"n",
".",
"(",
"type",
")",
"{",
"<mask>",
"int",
":",
"return",
"int64",
"(",
"v",
"*",
"int",
"(",
"math",
".",
"Pow",
"(",
"1024",
",",
"3",
")",
")",
")",
"\n",
"case",
"int32",
":",
"return",
"int64",
"(",
"v",
"*",
"int32",
"(",
"math",
".",
"Pow",
"(",
"1024",
",",
"3",
")",
")",
")",
"\n",
"case",
"int64",
":",
"return",
"v",
"*",
"int64",
"(",
"math",
".",
"Pow",
"(",
"1024",
",",
"3",
")",
")",
"\n",
"}",
"\n",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"n",
")",
")",
"\n",
"}"
] |
2,758 | all-2759 | [
"Do",
"executes",
"BackgroundService",
".",
"startObserving",
"against",
"the",
"provided",
"context",
"."
] | [
"func",
"(",
"p",
"*",
"StartObservingParams",
")",
"Do",
"(",
"ctx",
"<mask>",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"return",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandStartObserving",
",",
"p",
",",
"nil",
")",
"\n",
"}"
] |
2,759 | all-2760 | [
"SetCaps",
"applies",
"the",
"caps",
"for",
"a",
"particular",
"root",
"uid"
] | [
"func",
"SetCaps",
"(",
"<mask>",
"string",
",",
"caps",
"[",
"]",
"byte",
",",
"uid",
"int64",
")",
"error",
"{",
"cpath",
":=",
"C",
".",
"CString",
"(",
"path",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cpath",
")",
")",
"\n\n",
"ccaps",
":=",
"C",
".",
"CString",
"(",
"string",
"(",
"caps",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"ccaps",
")",
")",
"\n\n",
"r",
":=",
"C",
".",
"set_vfs_ns_caps",
"(",
"cpath",
",",
"ccaps",
",",
"C",
".",
"ssize_t",
"(",
"len",
"(",
"caps",
")",
")",
",",
"C",
".",
"uint32_t",
"(",
"uid",
")",
")",
"\n",
"if",
"r",
"!=",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
2,760 | all-2761 | [
"Set",
"is",
"required",
"for",
"kingpin",
"interfaces",
"to",
"allow",
"command",
"line",
"params",
"to",
"be",
"set",
"to",
"our",
"map",
"datatype"
] | [
"func",
"(",
"o",
"*",
"MapUint32Option",
")",
"Set",
"(",
"value",
"string",
")",
"error",
"{",
"parts",
":=",
"stringMapRegex",
".",
"Split",
"(",
"<mask>",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"2",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"value",
")",
"\n",
"}",
"\n",
"val",
":=",
"Uint32Option",
"{",
"}",
"\n",
"val",
".",
"Set",
"(",
"parts",
"[",
"1",
"]",
")",
"\n",
"(",
"*",
"o",
")",
"[",
"parts",
"[",
"0",
"]",
"]",
"=",
"val",
"\n",
"return",
"nil",
"\n",
"}"
] |
2,761 | all-2762 | [
"HasRequireFullWindow",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"o",
"*",
"Options",
")",
"HasRequireFullWindow",
"(",
")",
"bool",
"{",
"if",
"o",
"!=",
"nil",
"&&",
"o",
".",
"RequireFullWindow",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
2,762 | all-2763 | [
"gitRevParse",
"returns",
"current",
"commit",
"from",
"HEAD",
"in",
"a",
"git",
"tree"
] | [
"func",
"(",
"g",
"*",
"gitCtx",
")",
"gitRevParse",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"gitRevParseCommand",
":=",
"g",
".",
"gitCommand",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"_",
",",
"commit",
",",
"err",
":=",
"gitRevParseCommand",
".",
"run",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logrus",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"strings",
".",
"TrimSpace",
"(",
"<mask>",
")",
",",
"nil",
"\n",
"}"
] |
2,763 | all-2764 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"GetDOMCountersParams",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoMemory11",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
2,764 | all-2765 | [
"FromURL",
"converts",
"the",
"given",
"URL",
"to",
"a",
"folder",
"name"
] | [
"func",
"FromURL",
"(",
"url",
"string",
")",
"string",
"{",
"result",
":=",
"url",
"\n",
"for",
"_",
",",
"<mask>",
":=",
"range",
"replaces",
"{",
"result",
"=",
"strings",
".",
"Replace",
"(",
"result",
",",
"replace",
".",
"a",
",",
"replace",
".",
"b",
",",
"-",
"1",
")",
"\n",
"}",
"\n",
"return",
"result",
"\n",
"}"
] |
2,765 | all-2766 | [
"expandHostVirtualSwitchBondBridge",
"reads",
"certain",
"ResourceData",
"keys",
"and",
"returns",
"a",
"HostVirtualSwitchBondBridge",
"."
] | [
"func",
"expandHostVirtualSwitchBondBridge",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
")",
"*",
"types",
".",
"HostVirtualSwitchBondBridge",
"{",
"obj",
":=",
"&",
"types",
".",
"HostVirtualSwitchBondBridge",
"{",
"NicDevice",
":",
"structure",
".",
"SliceInterfacesToStrings",
"(",
"d",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"[",
"]",
"<mask>",
"{",
"}",
")",
")",
",",
"}",
"\n",
"obj",
".",
"Beacon",
"=",
"expandHostVirtualSwitchBeaconConfig",
"(",
"d",
")",
"\n",
"obj",
".",
"LinkDiscoveryProtocolConfig",
"=",
"expandLinkDiscoveryProtocolConfig",
"(",
"d",
")",
"\n",
"return",
"obj",
"\n",
"}"
] |
2,766 | all-2767 | [
"addApprovers",
"iterates",
"through",
"the",
"list",
"of",
"comments",
"on",
"a",
"PR",
"and",
"identifies",
"all",
"of",
"the",
"people",
"that",
"have",
"said",
"/",
"approve",
"and",
"adds",
"them",
"to",
"the",
"Approvers",
".",
"The",
"function",
"uses",
"the",
"latest",
"approve",
"or",
"cancel",
"comment",
"to",
"determine",
"the",
"Users",
"intention",
".",
"A",
"review",
"in",
"requested",
"changes",
"state",
"is",
"considered",
"a",
"cancel",
"."
] | [
"func",
"addApprovers",
"(",
"approversHandler",
"*",
"approvers",
".",
"Approvers",
",",
"approveComments",
"[",
"]",
"*",
"comment",
",",
"author",
"string",
",",
"reviewActsAsApprove",
"bool",
")",
"{",
"for",
"_",
",",
"c",
":=",
"range",
"approveComments",
"{",
"if",
"c",
".",
"Author",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n\n",
"if",
"reviewActsAsApprove",
"&&",
"c",
".",
"ReviewState",
"==",
"github",
".",
"ReviewStateApproved",
"{",
"approversHandler",
".",
"AddApprover",
"(",
"c",
".",
"Author",
",",
"c",
".",
"HTMLURL",
",",
"false",
",",
")",
"\n",
"}",
"\n",
"if",
"reviewActsAsApprove",
"&&",
"c",
".",
"ReviewState",
"==",
"github",
".",
"ReviewStateChangesRequested",
"{",
"approversHandler",
".",
"RemoveApprover",
"(",
"c",
".",
"Author",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"match",
":=",
"range",
"commandRegex",
".",
"FindAllStringSubmatch",
"(",
"c",
".",
"Body",
",",
"-",
"1",
")",
"{",
"name",
":=",
"strings",
".",
"ToUpper",
"(",
"<mask>",
"[",
"1",
"]",
")",
"\n",
"if",
"name",
"!=",
"approveCommand",
"&&",
"name",
"!=",
"lgtmCommand",
"{",
"continue",
"\n",
"}",
"\n",
"args",
":=",
"strings",
".",
"ToLower",
"(",
"strings",
".",
"TrimSpace",
"(",
"match",
"[",
"2",
"]",
")",
")",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"args",
",",
"cancelArgument",
")",
"{",
"approversHandler",
".",
"RemoveApprover",
"(",
"c",
".",
"Author",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"Author",
"==",
"author",
"{",
"approversHandler",
".",
"AddAuthorSelfApprover",
"(",
"c",
".",
"Author",
",",
"c",
".",
"HTMLURL",
",",
"args",
"==",
"noIssueArgument",
",",
")",
"\n",
"}",
"\n\n",
"if",
"name",
"==",
"approveCommand",
"{",
"approversHandler",
".",
"AddApprover",
"(",
"c",
".",
"Author",
",",
"c",
".",
"HTMLURL",
",",
"args",
"==",
"noIssueArgument",
",",
")",
"\n",
"}",
"else",
"{",
"approversHandler",
".",
"AddLGTMer",
"(",
"c",
".",
"Author",
",",
"c",
".",
"HTMLURL",
",",
"args",
"==",
"noIssueArgument",
",",
")",
"\n",
"}",
"\n\n",
"}",
"\n",
"}",
"\n",
"}"
] |
2,767 | all-2768 | [
"DialTimeout",
"is",
"like",
"Dial",
"but",
"takes",
"a",
"timeout",
".",
"The",
"timeout",
"includes",
"name",
"resolution",
"if",
"required",
"."
] | [
"func",
"DialTimeout",
"(",
"ctx",
"context",
".",
"Context",
",",
"protocol",
",",
"addr",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"Conn",
",",
"error",
")",
"{",
"dialCtx",
":=",
"ctx",
"// Used for dialing and name resolution, but not stored in the *Conn.",
"\n",
"if",
"timeout",
">",
"0",
"{",
"var",
"cancel",
"context",
".",
"CancelFunc",
"\n",
"dialCtx",
",",
"cancel",
"=",
"context",
".",
"WithTimeout",
"(",
"ctx",
",",
"timeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"}",
"\n\n",
"host",
",",
"portStr",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"port",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"portStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"portStr",
",",
"err",
")",
"\n",
"}",
"\n\n",
"var",
"prot",
"pb",
".",
"CreateSocketRequest_SocketProtocol",
"\n",
"switch",
"protocol",
"{",
"case",
"\"",
"\"",
":",
"prot",
"=",
"pb",
".",
"CreateSocketRequest_TCP",
"\n",
"case",
"\"",
"\"",
":",
"prot",
"=",
"pb",
".",
"CreateSocketRequest_UDP",
"\n",
"default",
":",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"protocol",
")",
"\n",
"}",
"\n\n",
"packedAddrs",
",",
"resolved",
",",
"err",
":=",
"resolve",
"(",
"dialCtx",
",",
"ipFamilies",
",",
"host",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"host",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"packedAddrs",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"host",
")",
"\n",
"}",
"\n\n",
"packedAddr",
":=",
"packedAddrs",
"[",
"0",
"]",
"// use first address",
"\n",
"fam",
":=",
"pb",
".",
"CreateSocketRequest_IPv4",
"\n",
"if",
"len",
"(",
"packedAddr",
")",
"==",
"net",
".",
"IPv6len",
"{",
"fam",
"=",
"pb",
".",
"CreateSocketRequest_IPv6",
"\n",
"}",
"\n\n",
"req",
":=",
"&",
"pb",
".",
"CreateSocketRequest",
"{",
"Family",
":",
"fam",
".",
"Enum",
"(",
")",
",",
"Protocol",
":",
"prot",
".",
"Enum",
"(",
")",
",",
"RemoteIp",
":",
"&",
"pb",
".",
"AddressPort",
"{",
"Port",
":",
"proto",
".",
"Int32",
"(",
"int32",
"(",
"<mask>",
")",
")",
",",
"PackedAddress",
":",
"packedAddr",
",",
"}",
",",
"}",
"\n",
"if",
"resolved",
"{",
"req",
".",
"RemoteIp",
".",
"HostnameHint",
"=",
"&",
"host",
"\n",
"}",
"\n",
"res",
":=",
"&",
"pb",
".",
"CreateSocketReply",
"{",
"}",
"\n",
"if",
"err",
":=",
"internal",
".",
"Call",
"(",
"dialCtx",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"req",
",",
"res",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"Conn",
"{",
"ctx",
":",
"ctx",
",",
"desc",
":",
"res",
".",
"GetSocketDescriptor",
"(",
")",
",",
"prot",
":",
"prot",
",",
"local",
":",
"res",
".",
"ProxyExternalIp",
",",
"remote",
":",
"req",
".",
"RemoteIp",
",",
"}",
",",
"nil",
"\n",
"}"
] |
2,768 | all-2769 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"EventShadowRootPopped",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom56",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
2,769 | all-2770 | [
"RunForPFS",
"creates",
"a",
"port",
"forwarder",
"for",
"PFS",
"over",
"HTTP",
"."
] | [
"func",
"(",
"f",
"*",
"PortForwarder",
")",
"RunForPFS",
"(",
"localPort",
"uint16",
")",
"<mask>",
"{",
"if",
"localPort",
"==",
"0",
"{",
"localPort",
"=",
"pfsLocalPort",
"\n",
"}",
"\n",
"return",
"f",
".",
"Run",
"(",
"\"",
"\"",
",",
"localPort",
",",
"30652",
")",
"\n",
"}"
] |
2,770 | all-2771 | [
"Stack",
"logs",
"the",
"error",
"err",
"with",
"the",
"stack",
"trace",
"."
] | [
"func",
"Stack",
"(",
"err",
"interface",
"{",
"}",
")",
"{",
"stack",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"64",
"<<",
"10",
")",
"\n",
"<mask>",
"=",
"stack",
"[",
":",
"runtime",
".",
"Stack",
"(",
"stack",
",",
"false",
")",
"]",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
",",
"stack",
")",
"\n",
"}"
] |
2,771 | all-2772 | [
"HasOrderDir",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"c",
"*",
"ChangeRequest",
")",
"HasOrderDir",
"(",
")",
"bool",
"{",
"if",
"c",
"!=",
"nil",
"&&",
"c",
".",
"OrderDir",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
2,772 | all-2773 | [
"doCompact",
"picks",
"some",
"table",
"on",
"level",
"l",
"and",
"compacts",
"it",
"away",
"to",
"the",
"next",
"level",
"."
] | [
"func",
"(",
"s",
"*",
"levelsController",
")",
"doCompact",
"(",
"p",
"compactionPriority",
")",
"error",
"{",
"l",
":=",
"p",
".",
"level",
"\n",
"y",
".",
"AssertTrue",
"(",
"l",
"+",
"1",
"<",
"s",
".",
"kv",
".",
"opt",
".",
"MaxLevels",
")",
"// Sanity check.",
"\n\n",
"cd",
":=",
"compactDef",
"{",
"elog",
":",
"trace",
".",
"New",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
")",
",",
"\"",
"\"",
")",
",",
"thisLevel",
":",
"s",
".",
"levels",
"[",
"l",
"]",
",",
"nextLevel",
":",
"s",
".",
"levels",
"[",
"l",
"+",
"1",
"]",
",",
"dropPrefix",
":",
"p",
".",
"dropPrefix",
",",
"}",
"\n",
"cd",
".",
"elog",
".",
"SetMaxEvents",
"(",
"100",
")",
"\n",
"defer",
"cd",
".",
"elog",
".",
"Finish",
"(",
")",
"\n\n",
"s",
".",
"kv",
".",
"opt",
".",
"Infof",
"(",
"\"",
"\"",
",",
"p",
")",
"\n\n",
"// While picking tables to be compacted, both levels' tables are expected to",
"// remain unchanged.",
"if",
"l",
"==",
"0",
"{",
"if",
"!",
"s",
".",
"fillTablesL0",
"(",
"&",
"cd",
")",
"{",
"return",
"errFillTables",
"\n",
"}",
"\n\n",
"}",
"else",
"{",
"if",
"!",
"s",
".",
"fillTables",
"(",
"&",
"cd",
")",
"{",
"return",
"errFillTables",
"\n",
"}",
"\n",
"}",
"\n",
"defer",
"s",
".",
"cstatus",
".",
"delete",
"(",
"cd",
")",
"// Remove the ranges from compaction status.",
"\n\n",
"s",
".",
"kv",
".",
"opt",
".",
"Infof",
"(",
"\"",
"\\n",
"\"",
",",
"cd",
".",
"thisLevel",
".",
"level",
")",
"\n",
"s",
".",
"cstatus",
".",
"toLog",
"(",
"cd",
".",
"elog",
")",
"\n",
"if",
"err",
":=",
"s",
".",
"runCompactDef",
"(",
"l",
",",
"cd",
")",
";",
"err",
"!=",
"nil",
"{",
"// This compaction couldn't be done successfully.",
"s",
".",
"kv",
".",
"opt",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"err",
",",
"cd",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"s",
".",
"cstatus",
".",
"toLog",
"(",
"cd",
".",
"elog",
")",
"\n",
"s",
".",
"kv",
".",
"opt",
".",
"Infof",
"(",
"\"",
"\"",
",",
"<mask>",
".",
"thisLevel",
".",
"level",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
2,773 | all-2774 | [
"Gets",
"the",
"length",
"of",
"the",
"entry",
"block"
] | [
"func",
"(",
"f",
"HeaderExtension",
")",
"EntrySize",
"(",
")",
"int",
"{",
"// Length of the name includes a null terminator",
"// the 4 * 5 is 4 bytes (uint32) for the 5 fields",
"baseSize",
":=",
"f",
".",
"FileEntry",
".",
"EntrySize",
"(",
")",
"\n\n",
"for",
"key",
",",
"val",
":=",
"<mask>",
"f",
".",
"ExtendedFields",
"{",
"// + 2 for the null terminator for each key/val",
"baseSize",
"+=",
"len",
"(",
"key",
")",
"+",
"len",
"(",
"val",
")",
"+",
"2",
"\n",
"}",
"\n\n",
"// There's a null terminator at the end of the block",
"return",
"baseSize",
"+",
"1",
"\n",
"}"
] |
2,774 | all-2775 | [
"Fetch",
"queries",
"the",
"Vault",
"API"
] | [
"func",
"(",
"d",
"*",
"VaultListQuery",
")",
"Fetch",
"(",
"clients",
"*",
"ClientSet",
",",
"opts",
"*",
"QueryOptions",
")",
"(",
"interface",
"{",
"}",
",",
"*",
"ResponseMetadata",
",",
"error",
")",
"{",
"select",
"{",
"case",
"<-",
"d",
".",
"stopCh",
":",
"return",
"nil",
",",
"nil",
",",
"ErrStopped",
"\n",
"default",
":",
"}",
"\n\n",
"opts",
"=",
"opts",
".",
"Merge",
"(",
"&",
"QueryOptions",
"{",
"}",
")",
"\n\n",
"// If this is not the first query, poll to simulate blocking-queries.",
"if",
"opts",
".",
"WaitIndex",
"!=",
"0",
"{",
"dur",
":=",
"VaultDefaultLeaseDuration",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"d",
",",
"dur",
")",
"\n\n",
"select",
"{",
"case",
"<-",
"d",
".",
"stopCh",
":",
"return",
"nil",
",",
"nil",
",",
"ErrStopped",
"\n",
"case",
"<-",
"time",
".",
"After",
"(",
"dur",
")",
":",
"}",
"\n",
"}",
"\n\n",
"// If we got this far, we either didn't have a secret to renew, the secret was",
"// not renewable, or the renewal failed, so attempt a fresh list.",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"d",
",",
"&",
"url",
".",
"URL",
"{",
"Path",
":",
"\"",
"\"",
"+",
"d",
".",
"path",
",",
"RawQuery",
":",
"opts",
".",
"String",
"(",
")",
",",
"}",
")",
"\n",
"secret",
",",
"err",
":=",
"clients",
".",
"Vault",
"(",
")",
".",
"Logical",
"(",
")",
".",
"List",
"(",
"d",
".",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"d",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n\n",
"var",
"result",
"[",
"]",
"string",
"\n\n",
"// The secret could be nil if it does not exist.",
"if",
"secret",
"==",
"nil",
"||",
"secret",
".",
"Data",
"==",
"nil",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"d",
")",
"\n",
"return",
"respWithMetadata",
"(",
"result",
")",
"\n",
"}",
"\n\n",
"// This is a weird thing that happened once...",
"keys",
",",
"ok",
":=",
"secret",
".",
"Data",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"ok",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"d",
")",
"\n",
"return",
"respWithMetadata",
"(",
"result",
")",
"\n",
"}",
"\n\n",
"list",
",",
"ok",
":=",
"keys",
".",
"(",
"[",
"]",
"<mask>",
"{",
"}",
")",
"\n",
"if",
"!",
"ok",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"d",
")",
"\n",
"return",
"nil",
",",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"d",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"list",
"{",
"typed",
",",
"ok",
":=",
"v",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"d",
")",
"\n",
"}",
"\n",
"result",
"=",
"append",
"(",
"result",
",",
"typed",
")",
"\n",
"}",
"\n",
"sort",
".",
"Strings",
"(",
"result",
")",
"\n\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"d",
",",
"len",
"(",
"result",
")",
")",
"\n\n",
"return",
"respWithMetadata",
"(",
"result",
")",
"\n",
"}"
] |
2,775 | all-2776 | [
"Encode",
"serializes",
"the",
"JSON",
"marshalable",
"obj",
"data",
"as",
"a",
"JWT",
"."
] | [
"func",
"(",
"rs",
"*",
"RSASigner",
")",
"Encode",
"(",
"obj",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"<mask>",
".",
"alg",
".",
"Encode",
"(",
"rs",
",",
"obj",
")",
"\n",
"}"
] |
2,776 | all-2777 | [
"NewFromCache",
"creates",
"a",
"GitHub",
"cache",
"RoundTripper",
"that",
"is",
"backed",
"by",
"the",
"specified",
"httpcache",
".",
"Cache",
"implementation",
"."
] | [
"func",
"NewFromCache",
"(",
"delegate",
"http",
".",
"RoundTripper",
",",
"cache",
"httpcache",
".",
"Cache",
",",
"maxConcurrency",
"int",
")",
"http",
".",
"RoundTripper",
"{",
"cacheTransport",
":=",
"httpcache",
".",
"NewTransport",
"(",
"cache",
")",
"\n",
"cacheTransport",
".",
"Transport",
"=",
"newThrottlingTransport",
"(",
"maxConcurrency",
",",
"upstreamTransport",
"{",
"delegate",
":",
"delegate",
"}",
")",
"\n",
"return",
"&",
"requestCoalescer",
"{",
"keys",
":",
"<mask>",
"(",
"map",
"[",
"string",
"]",
"*",
"responseWaiter",
")",
",",
"delegate",
":",
"cacheTransport",
",",
"}",
"\n",
"}"
] |
2,777 | all-2778 | [
"Run",
"starts",
"threads",
"workers",
"returning",
"after",
"receiving",
"a",
"stop",
"signal",
"."
] | [
"func",
"(",
"c",
"*",
"controller",
")",
"Run",
"(",
"threads",
"int",
",",
"stop",
"<-",
"chan",
"struct",
"{",
"}",
")",
"error",
"{",
"defer",
"runtime",
".",
"HandleCrash",
"(",
")",
"\n",
"defer",
"c",
".",
"workqueue",
".",
"ShutDown",
"(",
")",
"\n\n",
"logrus",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"logrus",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"if",
"ok",
":=",
"cache",
".",
"WaitForCacheSync",
"(",
"stop",
",",
"c",
".",
"hasSynced",
")",
";",
"!",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"logrus",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"threads",
";",
"i",
"++",
"{",
"go",
"wait",
".",
"Until",
"(",
"c",
".",
"runWorker",
",",
"<mask>",
".",
"Second",
",",
"stop",
")",
"\n",
"}",
"\n\n",
"logrus",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"<-",
"stop",
"\n",
"logrus",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
2,778 | all-2779 | [
"Fingerprint",
"returns",
"the",
"fingerprint",
"of",
"the",
"public",
"key",
"."
] | [
"func",
"(",
"c",
"*",
"CertInfo",
")",
"Fingerprint",
"(",
")",
"<mask>",
"{",
"fingerprint",
",",
"err",
":=",
"CertFingerprintStr",
"(",
"string",
"(",
"c",
".",
"PublicKey",
"(",
")",
")",
")",
"\n",
"// Parsing should never fail, since we generated the cert ourselves,",
"// but let's check the error for good measure.",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"fingerprint",
"\n",
"}"
] |
2,779 | all-2780 | [
"NewValueIterator",
"creates",
"a",
"new",
"iterator",
"for",
"value",
"data",
"."
] | [
"func",
"NewValueIterator",
"(",
"format",
"Format",
",",
"reader",
"io",
".",
"Reader",
")",
"*",
"Iterator",
"{",
"return",
"NewIterator",
"(",
"reader",
",",
"FieldValueUnmarshaller",
"(",
"<mask>",
")",
")",
"\n",
"}"
] |
2,780 | all-2781 | [
"PushFile",
"makes",
"sure",
"that",
"pfsFile",
"has",
"the",
"same",
"content",
"as",
"osFile",
"."
] | [
"func",
"PushFile",
"(",
"c",
"*",
"pachclient",
".",
"APIClient",
",",
"pfc",
"pachclient",
".",
"PutFileClient",
",",
"pfsFile",
"*",
"pfs",
".",
"File",
",",
"osFile",
"io",
".",
"ReadSeeker",
")",
"error",
"{",
"fileInfo",
",",
"err",
":=",
"c",
".",
"InspectFile",
"(",
"pfsFile",
".",
"Commit",
".",
"Repo",
".",
"Name",
",",
"pfsFile",
".",
"Commit",
".",
"ID",
",",
"pfsFile",
".",
"Path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"!",
"isNotExist",
"(",
"err",
")",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"var",
"i",
"int",
"\n",
"var",
"object",
"*",
"pfs",
".",
"Object",
"\n",
"if",
"fileInfo",
"!=",
"nil",
"{",
"for",
"i",
",",
"object",
"=",
"range",
"fileInfo",
".",
"Objects",
"{",
"hash",
":=",
"pfs",
".",
"NewHash",
"(",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"io",
".",
"CopyN",
"(",
"hash",
",",
"osFile",
",",
"pfs",
".",
"ChunkSize",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"break",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"object",
".",
"Hash",
"!=",
"pfs",
".",
"EncodeHash",
"(",
"hash",
".",
"Sum",
"(",
"nil",
")",
")",
"{",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"err",
":=",
"osFile",
".",
"Seek",
"(",
"int64",
"(",
"i",
")",
"*",
"pfs",
".",
"ChunkSize",
",",
"0",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"pfc",
".",
"PutFileOverwrite",
"(",
"pfsFile",
".",
"Commit",
".",
"Repo",
".",
"Name",
",",
"pfsFile",
".",
"Commit",
".",
"<mask>",
",",
"pfsFile",
".",
"Path",
",",
"osFile",
",",
"int64",
"(",
"i",
")",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
2,781 | all-2782 | [
"/",
"*",
"Kill",
"sends",
"a",
"SIGKILL",
"signal",
"to",
"all",
"the",
"processes",
"started",
"by",
"Run",
"and",
"waits",
"for",
"them",
"to",
"exit",
".",
"The",
"timeout",
"specified",
"is",
"applied",
"to",
"each",
"process",
"killed",
"."
] | [
"func",
"KillAndWait",
"(",
"timeout",
"...",
"interface",
"{",
"}",
")",
"{",
"trackedSessionsMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"trackedSessionsMutex",
".",
"Unlock",
"(",
")",
"\n",
"for",
"_",
",",
"<mask>",
":=",
"range",
"trackedSessions",
"{",
"session",
".",
"Kill",
"(",
")",
".",
"Wait",
"(",
"timeout",
"...",
")",
"\n",
"}",
"\n",
"trackedSessions",
"=",
"[",
"]",
"*",
"Session",
"{",
"}",
"\n",
"}"
] |
2,782 | all-2783 | [
"Start",
"a",
"Service",
"and",
"log",
"its",
"output",
"."
] | [
"func",
"(",
"s",
"*",
"ServiceManager",
")",
"Start",
"(",
")",
"*",
"exec",
".",
"Cmd",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"s",
".",
"Cmd",
",",
"s",
".",
"Args",
"...",
")",
"\n",
"env",
":=",
"os",
".",
"Environ",
"(",
")",
"\n",
"env",
"=",
"append",
"(",
"env",
",",
"s",
".",
"Env",
"...",
")",
"\n",
"cmd",
".",
"Env",
"=",
"env",
"\n\n",
"cmdReader",
",",
"err",
":=",
"cmd",
".",
"StdoutPipe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n\n",
"cmdReaderErr",
",",
"err",
":=",
"cmd",
".",
"StderrPipe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n\n",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"cmdReader",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"for",
"scanner",
".",
"Scan",
"(",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"scanner",
".",
"Text",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"scanner2",
":=",
"bufio",
".",
"NewScanner",
"(",
"cmdReaderErr",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"for",
"scanner2",
".",
"Scan",
"(",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"scanner2",
".",
"<mask>",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"err",
"=",
"cmd",
".",
"Start",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n\n",
"// Add service to registry",
"s",
".",
"commandCreatedChan",
"<-",
"cmd",
"\n\n",
"return",
"cmd",
"\n",
"}"
] |
2,783 | all-2784 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"GetFramesWithManifestsReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoApplicationcache3",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
2,784 | all-2785 | [
"Setup",
"external",
"authentication"
] | [
"func",
"(",
"d",
"*",
"Daemon",
")",
"setupExternalAuthentication",
"(",
"authEndpoint",
"string",
",",
"authPubkey",
"string",
",",
"expiry",
"int64",
",",
"domains",
"string",
")",
"error",
"{",
"// Parse the list of domains",
"authDomains",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"domain",
":=",
"range",
"strings",
".",
"Split",
"(",
"domains",
",",
"\"",
"\"",
")",
"{",
"if",
"domain",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n\n",
"authDomains",
"=",
"<mask>",
"(",
"authDomains",
",",
"strings",
".",
"TrimSpace",
"(",
"domain",
")",
")",
"\n",
"}",
"\n\n",
"// Allow disable external authentication",
"if",
"authEndpoint",
"==",
"\"",
"\"",
"{",
"d",
".",
"externalAuth",
"=",
"nil",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Setup the candid client",
"idmClient",
",",
"err",
":=",
"candidclient",
".",
"New",
"(",
"candidclient",
".",
"NewParams",
"{",
"BaseURL",
":",
"authEndpoint",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"idmClientWrapper",
":=",
"&",
"IdentityClientWrapper",
"{",
"client",
":",
"idmClient",
",",
"ValidDomains",
":",
"authDomains",
",",
"}",
"\n\n",
"// Generate an internal private key",
"key",
",",
"err",
":=",
"bakery",
".",
"GenerateKey",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"pkCache",
":=",
"bakery",
".",
"NewThirdPartyStore",
"(",
")",
"\n",
"pkLocator",
":=",
"httpbakery",
".",
"NewThirdPartyLocator",
"(",
"nil",
",",
"pkCache",
")",
"\n",
"if",
"authPubkey",
"!=",
"\"",
"\"",
"{",
"// Parse the public key",
"pkKey",
":=",
"bakery",
".",
"Key",
"{",
"}",
"\n",
"err",
":=",
"pkKey",
".",
"UnmarshalText",
"(",
"[",
"]",
"byte",
"(",
"authPubkey",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Add the key information",
"pkCache",
".",
"AddInfo",
"(",
"authEndpoint",
",",
"bakery",
".",
"ThirdPartyInfo",
"{",
"PublicKey",
":",
"bakery",
".",
"PublicKey",
"{",
"Key",
":",
"pkKey",
"}",
",",
"Version",
":",
"3",
",",
"}",
")",
"\n\n",
"// Allow http URLs if we have a public key set",
"if",
"strings",
".",
"HasPrefix",
"(",
"authEndpoint",
",",
"\"",
"\"",
")",
"{",
"pkLocator",
".",
"AllowInsecure",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Setup the bakery",
"bakery",
":=",
"identchecker",
".",
"NewBakery",
"(",
"identchecker",
".",
"BakeryParams",
"{",
"Key",
":",
"key",
",",
"Location",
":",
"authEndpoint",
",",
"Locator",
":",
"pkLocator",
",",
"Checker",
":",
"httpbakery",
".",
"NewChecker",
"(",
")",
",",
"IdentityClient",
":",
"idmClientWrapper",
",",
"Authorizer",
":",
"identchecker",
".",
"ACLAuthorizer",
"{",
"GetACL",
":",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"op",
"bakery",
".",
"Op",
")",
"(",
"[",
"]",
"string",
",",
"bool",
",",
"error",
")",
"{",
"return",
"[",
"]",
"string",
"{",
"identchecker",
".",
"Everyone",
"}",
",",
"false",
",",
"nil",
"\n",
"}",
",",
"}",
",",
"}",
")",
"\n\n",
"// Store our settings",
"d",
".",
"externalAuth",
"=",
"&",
"externalAuth",
"{",
"endpoint",
":",
"authEndpoint",
",",
"expiry",
":",
"expiry",
",",
"bakery",
":",
"bakery",
",",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
2,785 | all-2786 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"SetEmulatedMediaParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoEmulation9",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
2,786 | all-2787 | [
"StdoutPipe",
"returns",
"a",
"pipe",
"that",
"will",
"be",
"connected",
"to",
"the",
"command",
"s",
"standard",
"output",
"when",
"the",
"command",
"starts",
".",
"Wait",
"will",
"close",
"the",
"pipe",
"after",
"seeing",
"the",
"command",
"exit",
"so",
"most",
"callers",
"need",
"not",
"close",
"the",
"pipe",
"themselves",
";",
"however",
"an",
"implication",
"is",
"that",
"it",
"is",
"incorrect",
"to",
"call",
"Wait",
"before",
"all",
"reads",
"from",
"the",
"pipe",
"have",
"completed",
".",
"For",
"the",
"same",
"reason",
"it",
"is",
"incorrect",
"to",
"call",
"Run",
"when",
"using",
"StdoutPipe",
".",
"See",
"the",
"example",
"for",
"idiomatic",
"usage",
"."
] | [
"func",
"(",
"c",
"*",
"Cmd",
")",
"StdoutPipe",
"(",
")",
"(",
"<mask>",
".",
"ReadCloser",
",",
"error",
")",
"{",
"if",
"c",
".",
"Stdout",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"c",
".",
"Process",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"pr",
",",
"pw",
",",
"err",
":=",
"os",
".",
"Pipe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"c",
".",
"Stdout",
"=",
"pw",
"\n",
"c",
".",
"closeAfterStart",
"=",
"append",
"(",
"c",
".",
"closeAfterStart",
",",
"pw",
")",
"\n",
"c",
".",
"closeAfterWait",
"=",
"append",
"(",
"c",
".",
"closeAfterWait",
",",
"pr",
")",
"\n",
"return",
"pr",
",",
"nil",
"\n",
"}"
] |
2,787 | all-2788 | [
"StartImageCleanupProcess",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockImageManager",
")",
"StartImageCleanupProcess",
"(",
"arg0",
"context",
".",
"<mask>",
")",
"{",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"}"
] |
2,788 | all-2789 | [
"NewNetworkBus",
"-",
"returns",
"a",
"new",
"network",
"bus",
"object",
"at",
"the",
"server",
"address",
"and",
"path"
] | [
"func",
"NewNetworkBus",
"(",
"address",
",",
"path",
"string",
")",
"*",
"NetworkBus",
"{",
"bus",
":=",
"<mask>",
"(",
"NetworkBus",
")",
"\n",
"bus",
".",
"sharedBus",
"=",
"New",
"(",
")",
"\n",
"bus",
".",
"Server",
"=",
"NewServer",
"(",
"address",
",",
"path",
",",
"bus",
".",
"sharedBus",
")",
"\n",
"bus",
".",
"Client",
"=",
"NewClient",
"(",
"address",
",",
"path",
",",
"bus",
".",
"sharedBus",
")",
"\n",
"bus",
".",
"service",
"=",
"&",
"NetworkBusService",
"{",
"&",
"sync",
".",
"WaitGroup",
"{",
"}",
",",
"false",
"}",
"\n",
"bus",
".",
"address",
"=",
"address",
"\n",
"bus",
".",
"path",
"=",
"path",
"\n",
"return",
"bus",
"\n",
"}"
] |
2,789 | all-2790 | [
"Create",
"a",
"raft",
"instance",
"and",
"all",
"its",
"dependencies",
"to",
"be",
"used",
"as",
"backend",
"for",
"the",
"dqlite",
"driver",
"running",
"on",
"this",
"LXD",
"node",
".",
"If",
"this",
"node",
"should",
"not",
"serve",
"as",
"dqlite",
"node",
"nil",
"is",
"returned",
".",
"The",
"raft",
"instance",
"will",
"use",
"an",
"in",
"-",
"memory",
"transport",
"if",
"clustering",
"is",
"not",
"enabled",
"on",
"this",
"node",
".",
"The",
"certInfo",
"parameter",
"should",
"contain",
"the",
"cluster",
"TLS",
"keypair",
"and",
"optional",
"CA",
"certificate",
".",
"The",
"latency",
"parameter",
"is",
"a",
"coarse",
"grain",
"measure",
"of",
"how",
"fast",
"/",
"reliable",
"network",
"links",
"are",
".",
"This",
"is",
"used",
"to",
"tweak",
"the",
"various",
"timeouts",
"parameters",
"of",
"the",
"raft",
"algorithm",
".",
"See",
"the",
"raft",
".",
"Config",
"structure",
"for",
"more",
"details",
".",
"A",
"value",
"of",
"1",
".",
"0",
"means",
"use",
"the",
"default",
"values",
"from",
"hashicorp",
"s",
"raft",
"package",
".",
"Values",
"closer",
"to",
"0",
"reduce",
"the",
"values",
"of",
"the",
"various",
"timeouts",
"(",
"useful",
"when",
"running",
"unit",
"tests",
"in",
"-",
"memory",
")",
"."
] | [
"func",
"newRaft",
"(",
"database",
"*",
"db",
".",
"Node",
",",
"cert",
"*",
"shared",
".",
"CertInfo",
",",
"latency",
"float64",
")",
"(",
"*",
"raftInstance",
",",
"error",
")",
"{",
"if",
"latency",
"<=",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Figure out if we actually need to act as dqlite node.",
"var",
"info",
"*",
"db",
".",
"RaftNode",
"\n",
"err",
":=",
"database",
".",
"<mask>",
"(",
"func",
"(",
"tx",
"*",
"db",
".",
"NodeTx",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"info",
",",
"err",
"=",
"node",
".",
"DetermineRaftNode",
"(",
"tx",
")",
"\n",
"return",
"err",
"\n",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// If we're not part of the dqlite cluster, there's nothing to do.",
"if",
"info",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"logger",
".",
"Debug",
"(",
"\"",
"\"",
",",
"log15",
".",
"Ctx",
"{",
"\"",
"\"",
":",
"info",
".",
"ID",
",",
"\"",
"\"",
":",
"info",
".",
"Address",
"}",
")",
"\n\n",
"// Initialize a raft instance along with all needed dependencies.",
"instance",
",",
"err",
":=",
"raftInstanceInit",
"(",
"database",
",",
"info",
",",
"cert",
",",
"latency",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"instance",
",",
"nil",
"\n",
"}"
] |
2,790 | all-2791 | [
"own",
"methods"
] | [
"func",
"(",
"l",
"*",
"TextView",
")",
"calculateVirtualSize",
"(",
")",
"{",
"w",
":=",
"l",
".",
"width",
"-",
"1",
"\n",
"l",
".",
"virtualWidth",
"=",
"l",
".",
"<mask>",
"-",
"1",
"\n",
"l",
".",
"virtualHeight",
"=",
"0",
"\n\n",
"l",
".",
"lengths",
"=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"l",
".",
"lines",
")",
")",
"\n",
"for",
"idx",
",",
"str",
":=",
"range",
"l",
".",
"lines",
"{",
"str",
"=",
"UnColorizeText",
"(",
"str",
")",
"\n\n",
"sz",
":=",
"xs",
".",
"Len",
"(",
"str",
")",
"\n",
"if",
"l",
".",
"wordWrap",
"{",
"n",
":=",
"sz",
"/",
"w",
"\n",
"r",
":=",
"sz",
"%",
"w",
"\n",
"l",
".",
"virtualHeight",
"+=",
"n",
"\n",
"if",
"r",
"!=",
"0",
"{",
"l",
".",
"virtualHeight",
"++",
"\n",
"}",
"\n",
"}",
"else",
"{",
"l",
".",
"virtualHeight",
"++",
"\n",
"if",
"sz",
">",
"l",
".",
"virtualWidth",
"{",
"l",
".",
"virtualWidth",
"=",
"sz",
"\n",
"}",
"\n",
"}",
"\n",
"l",
".",
"lengths",
"[",
"idx",
"]",
"=",
"sz",
"\n",
"}",
"\n",
"}"
] |
2,791 | all-2792 | [
"Close",
"flushes",
"all",
"pending",
"data",
"to",
"reporters",
"and",
"releases",
"resources",
"."
] | [
"func",
"(",
"r",
"*",
"Registry",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"r",
".",
"closing",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"close",
"(",
"r",
".",
"closing",
")",
"\n",
"return",
"<-",
"r",
".",
"<mask>",
"\n",
"}"
] |
2,792 | all-2793 | [
"registerContainerInstance",
"registers",
"the",
"container",
"instance",
"ID",
"for",
"the",
"ECS",
"Agent"
] | [
"func",
"(",
"agent",
"*",
"ecsAgent",
")",
"registerContainerInstance",
"(",
"stateManager",
"statemanager",
".",
"StateManager",
",",
"client",
"api",
".",
"ECSClient",
",",
"additionalAttributes",
"[",
"]",
"*",
"ecs",
".",
"Attribute",
")",
"error",
"{",
"// Preflight request to make sure they're good",
"if",
"preflightCreds",
",",
"err",
":=",
"agent",
".",
"credentialProvider",
".",
"Get",
"(",
")",
";",
"err",
"!=",
"nil",
"||",
"preflightCreds",
".",
"AccessKeyID",
"==",
"\"",
"\"",
"{",
"seelog",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"preflightCreds",
".",
"AccessKeyID",
",",
"err",
")",
"\n",
"}",
"\n\n",
"agentCapabilities",
",",
"err",
":=",
"agent",
".",
"capabilities",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"capabilities",
":=",
"append",
"(",
"agentCapabilities",
",",
"additionalAttributes",
"...",
")",
"\n\n",
"// Get the tags of this container instance defined in config file",
"tags",
":=",
"utils",
".",
"MapToTags",
"(",
"agent",
".",
"cfg",
".",
"ContainerInstanceTags",
")",
"\n",
"if",
"agent",
".",
"cfg",
".",
"ContainerInstancePropagateTagsFrom",
"==",
"config",
".",
"ContainerInstancePropagateTagsFromEC2InstanceType",
"{",
"ec2Tags",
",",
"err",
":=",
"agent",
".",
"getContainerInstanceTagsFromEC2API",
"(",
")",
"\n",
"// If we are unable to call the API, we should not treat it as a transient error,",
"// because we've already retried several times, we may throttle the API if we",
"// keep retrying.",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"seelog",
".",
"Infof",
"(",
"\"",
"\\n",
"\"",
",",
"ec2Tags",
")",
"\n",
"tags",
"=",
"mergeTags",
"(",
"tags",
",",
"ec2Tags",
")",
"\n",
"}",
"\n\n",
"platformDevices",
":=",
"agent",
".",
"getPlatformDevices",
"(",
")",
"\n\n",
"if",
"agent",
".",
"containerInstanceARN",
"!=",
"\"",
"\"",
"{",
"seelog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"agent",
".",
"containerInstanceARN",
",",
"agent",
".",
"cfg",
".",
"Cluster",
")",
"\n",
"return",
"<mask>",
".",
"reregisterContainerInstance",
"(",
"client",
",",
"capabilities",
",",
"tags",
",",
"uuid",
".",
"New",
"(",
")",
",",
"platformDevices",
")",
"\n",
"}",
"\n\n",
"seelog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"containerInstanceArn",
",",
"availabilityZone",
",",
"err",
":=",
"client",
".",
"RegisterContainerInstance",
"(",
"\"",
"\"",
",",
"capabilities",
",",
"tags",
",",
"uuid",
".",
"New",
"(",
")",
",",
"platformDevices",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"if",
"retriable",
",",
"ok",
":=",
"err",
".",
"(",
"apierrors",
".",
"Retriable",
")",
";",
"ok",
"&&",
"!",
"retriable",
".",
"Retry",
"(",
")",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"utils",
".",
"IsAWSErrorCodeEqual",
"(",
"err",
",",
"ecs",
".",
"ErrCodeInvalidParameterException",
")",
"{",
"seelog",
".",
"Critical",
"(",
"\"",
"\"",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"if",
"_",
",",
"ok",
":=",
"err",
".",
"(",
"apierrors",
".",
"AttributeError",
")",
";",
"ok",
"{",
"seelog",
".",
"Critical",
"(",
"\"",
"\"",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"return",
"transientError",
"{",
"err",
"}",
"\n",
"}",
"\n",
"seelog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"containerInstanceArn",
",",
"agent",
".",
"cfg",
".",
"Cluster",
")",
"\n",
"agent",
".",
"containerInstanceARN",
"=",
"containerInstanceArn",
"\n",
"agent",
".",
"availabilityZone",
"=",
"availabilityZone",
"\n",
"// Save our shiny new containerInstanceArn",
"stateManager",
".",
"Save",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
2,793 | all-2794 | [
"GetMaxWidthChars",
"is",
"a",
"wrapper",
"around",
"gtk_label_get_max_width_chars",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"GetMaxWidthChars",
"(",
")",
"int",
"{",
"c",
":=",
"C",
".",
"gtk_label_get_max_width_chars",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"return",
"int",
"(",
"c",
")",
"\n",
"}"
] |
2,794 | all-2795 | [
"GetCreatePassiveOfferOp",
"retrieves",
"the",
"CreatePassiveOfferOp",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
] | [
"func",
"(",
"u",
"OperationBody",
")",
"GetCreatePassiveOfferOp",
"(",
")",
"(",
"result",
"CreatePassiveOfferOp",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"<mask>",
")",
")",
"\n\n",
"if",
"armName",
"==",
"\"",
"\"",
"{",
"result",
"=",
"*",
"u",
".",
"CreatePassiveOfferOp",
"\n",
"ok",
"=",
"true",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] |
2,795 | all-2796 | [
"IsAnyNotFoundError",
"checks",
"to",
"see",
"if",
"the",
"fault",
"is",
"of",
"any",
"not",
"found",
"error",
"type",
"that",
"we",
"track",
"."
] | [
"func",
"IsAnyNotFoundError",
"(",
"err",
"error",
")",
"bool",
"{",
"switch",
"{",
"<mask>",
"IsManagedObjectNotFoundError",
"(",
"err",
")",
":",
"fallthrough",
"\n",
"case",
"isNotFoundError",
"(",
"err",
")",
":",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] |
2,796 | all-2797 | [
"checkMultiArg",
"checks",
"that",
"v",
"has",
"type",
"[]",
"S",
"[]",
"*",
"S",
"[]",
"I",
"or",
"[]",
"P",
"for",
"some",
"struct",
"type",
"S",
"for",
"some",
"interface",
"type",
"I",
"or",
"some",
"non",
"-",
"interface",
"non",
"-",
"pointer",
"type",
"P",
"such",
"that",
"P",
"or",
"*",
"P",
"implements",
"PropertyLoadSaver",
".",
"It",
"returns",
"what",
"category",
"the",
"slice",
"s",
"elements",
"are",
"and",
"the",
"reflect",
".",
"Type",
"that",
"represents",
"S",
"I",
"or",
"P",
".",
"As",
"a",
"special",
"case",
"PropertyList",
"is",
"an",
"invalid",
"type",
"for",
"v",
"."
] | [
"func",
"checkMultiArg",
"(",
"v",
"reflect",
".",
"Value",
")",
"(",
"m",
"multiArgType",
",",
"elemType",
"reflect",
".",
"Type",
")",
"{",
"if",
"v",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Slice",
"{",
"return",
"multiArgTypeInvalid",
",",
"nil",
"\n",
"}",
"\n",
"if",
"v",
".",
"<mask>",
"(",
")",
"==",
"typeOfPropertyList",
"{",
"return",
"multiArgTypeInvalid",
",",
"nil",
"\n",
"}",
"\n",
"elemType",
"=",
"v",
".",
"Type",
"(",
")",
".",
"Elem",
"(",
")",
"\n",
"if",
"reflect",
".",
"PtrTo",
"(",
"elemType",
")",
".",
"Implements",
"(",
"typeOfPropertyLoadSaver",
")",
"{",
"return",
"multiArgTypePropertyLoadSaver",
",",
"elemType",
"\n",
"}",
"\n",
"switch",
"elemType",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Struct",
":",
"return",
"multiArgTypeStruct",
",",
"elemType",
"\n",
"case",
"reflect",
".",
"Interface",
":",
"return",
"multiArgTypeInterface",
",",
"elemType",
"\n",
"case",
"reflect",
".",
"Ptr",
":",
"elemType",
"=",
"elemType",
".",
"Elem",
"(",
")",
"\n",
"if",
"elemType",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Struct",
"{",
"return",
"multiArgTypeStructPtr",
",",
"elemType",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"multiArgTypeInvalid",
",",
"nil",
"\n",
"}"
] |
2,797 | all-2798 | [
"GetKubernetesClient",
"retrieves",
"the",
"Kubernetes",
"cluster",
"client",
"from",
"within",
"the",
"cluster"
] | [
"func",
"GetKubernetesClient",
"(",
"masterURL",
",",
"kubeConfig",
"string",
")",
"(",
"kubernetes",
".",
"Interface",
",",
"error",
")",
"{",
"config",
",",
"err",
":=",
"loadClusterConfig",
"(",
"masterURL",
",",
"kubeConfig",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// generate the client based off of the config",
"<mask>",
",",
"err",
":=",
"kubernetes",
".",
"NewForConfig",
"(",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"logrus",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"return",
"client",
",",
"nil",
"\n",
"}"
] |
2,798 | all-2799 | [
"ReleaseIPResource",
"marks",
"the",
"ip",
"available",
"in",
"the",
"ipam",
"db"
] | [
"func",
"(",
"client",
"*",
"cniClient",
")",
"ReleaseIPResource",
"(",
"cfg",
"*",
"Config",
")",
"error",
"{",
"runtimeConfig",
":=",
"libcni",
".",
"RuntimeConf",
"{",
"ContainerID",
":",
"cfg",
".",
"ContainerID",
",",
"NetNS",
":",
"fmt",
".",
"Sprintf",
"(",
"netnsFormat",
",",
"cfg",
".",
"ContainerPID",
")",
",",
"}",
"\n\n",
"seelog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"cfg",
".",
"ID",
",",
"cfg",
".",
"IPAMV4Address",
")",
"\n",
"os",
".",
"Setenv",
"(",
"\"",
"\"",
",",
"logger",
".",
"GetLevel",
"(",
")",
")",
"\n",
"defer",
"os",
".",
"Unsetenv",
"(",
"\"",
"\"",
")",
"\n",
"return",
"client",
".",
"del",
"(",
"runtimeConfig",
",",
"cfg",
",",
"<mask>",
".",
"createIPAMNetworkConfig",
")",
"\n",
"}"
] |
2,799 | all-2800 | [
"newWatcher",
"is",
"the",
"internal",
"function",
"for",
"properly",
"setting",
"up",
"a",
"new",
"watcher",
"."
] | [
"func",
"newWatcher",
"(",
"dir_notify",
"bool",
",",
"initpaths",
"...",
"string",
")",
"(",
"w",
"*",
"Watcher",
")",
"{",
"w",
"=",
"new",
"(",
"Watcher",
")",
"\n",
"w",
".",
"auto_watch",
"=",
"dir_notify",
"\n",
"w",
".",
"paths",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"watchItem",
",",
"0",
")",
"\n\n",
"var",
"paths",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"<mask>",
":=",
"range",
"initpaths",
"{",
"matches",
",",
"err",
":=",
"filepath",
".",
"Glob",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"continue",
"\n",
"}",
"\n",
"paths",
"=",
"append",
"(",
"paths",
",",
"matches",
"...",
")",
"\n",
"}",
"\n",
"if",
"dir_notify",
"{",
"w",
".",
"syncAddPaths",
"(",
"paths",
"...",
")",
"\n",
"}",
"else",
"{",
"for",
"_",
",",
"path",
":=",
"range",
"paths",
"{",
"w",
".",
"paths",
"[",
"path",
"]",
"=",
"watchPath",
"(",
"path",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\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.