id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
10,900 | all-10901 | [
"MarshalEasyJSON",
"writes",
"the",
"UUID5",
"to",
"a",
"easyjson",
".",
"Writer"
] | [
"func",
"(",
"u",
"UUID5",
")",
"MarshalEasyJSON",
"(",
"w",
"*",
"jwriter",
".",
"<mask>",
")",
"{",
"w",
".",
"String",
"(",
"string",
"(",
"u",
")",
")",
"\n",
"}"
] |
10,901 | all-10902 | [
"E",
"is",
"a",
"short",
"-",
"hand",
"function",
"to",
"construct",
"a",
"safe",
"error",
"."
] | [
"func",
"E",
"(",
"<mask>",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"Safe",
"(",
"fmt",
".",
"Errorf",
"(",
"format",
",",
"a",
"...",
")",
")",
"\n",
"}"
] |
10,902 | all-10903 | [
"SetIconName",
"is",
"a",
"wrapper",
"around",
"gtk_tool_button_set_icon_name",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"ToolButton",
")",
"SetIconName",
"(",
"iconName",
"string",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"iconName",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"C",
".",
"gtk_tool_button_set_icon_name",
"(",
"v",
".",
"native",
"(",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
] |
10,903 | all-10904 | [
"Set",
"is",
"required",
"for",
"kingpin",
"interfaces",
"to",
"allow",
"command",
"line",
"params",
"to",
"be",
"set",
"to",
"our",
"map",
"datatype"
] | [
"func",
"(",
"o",
"*",
"ListComplex128Option",
")",
"Set",
"(",
"value",
"string",
")",
"error",
"{",
"val",
":=",
"Complex128Option",
"{",
"}",
"\n",
"val",
".",
"<mask>",
"(",
"value",
")",
"\n",
"*",
"o",
"=",
"append",
"(",
"*",
"o",
",",
"val",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,904 | all-10905 | [
"Dump",
"request",
"if",
"needed",
".",
"Return",
"request",
"serialized",
"as",
"JSON",
"if",
"DumpFormat",
"is",
"JSON",
"nil",
"otherwise",
"."
] | [
"func",
"(",
"d",
"*",
"dumpClient",
")",
"dumpRequest",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"[",
"]",
"byte",
"{",
"df",
":=",
"d",
".",
"dumpFormat",
"(",
")",
"\n",
"if",
"df",
"==",
"NoDump",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"reqBody",
",",
"err",
":=",
"dumpReqBody",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Error",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"if",
"df",
".",
"IsDebug",
"(",
")",
"{",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n",
"<mask>",
".",
"WriteString",
"(",
"req",
".",
"Method",
"+",
"\"",
"\"",
"+",
"req",
".",
"URL",
".",
"String",
"(",
")",
"+",
"\"",
"\\n",
"\"",
")",
"\n",
"d",
".",
"writeHeaders",
"(",
"&",
"buffer",
",",
"req",
".",
"Header",
")",
"\n",
"if",
"reqBody",
"!=",
"nil",
"{",
"buffer",
".",
"WriteString",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"buffer",
".",
"Write",
"(",
"reqBody",
")",
"\n",
"buffer",
".",
"WriteString",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Fprint",
"(",
"OsStderr",
",",
"buffer",
".",
"String",
"(",
")",
")",
"\n",
"}",
"else",
"if",
"df",
".",
"IsJSON",
"(",
")",
"{",
"return",
"reqBody",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,905 | all-10906 | [
"NewLuaObjectFromValue",
"creates",
"a",
"new",
"LuaObject",
"from",
"a",
"Go",
"value",
".",
"Note",
"that",
"this",
"will",
"convert",
"any",
"slices",
"or",
"maps",
"into",
"Lua",
"tables",
"."
] | [
"func",
"NewLuaObjectFromValue",
"(",
"L",
"*",
"lua",
".",
"State",
",",
"val",
"<mask>",
"{",
"}",
")",
"*",
"LuaObject",
"{",
"GoToLua",
"(",
"L",
",",
"val",
")",
"\n",
"return",
"NewLuaObject",
"(",
"L",
",",
"-",
"1",
")",
"\n",
"}"
] |
10,906 | all-10907 | [
"NewFilteredProwJobInformer",
"constructs",
"a",
"new",
"informer",
"for",
"ProwJob",
"type",
".",
"Always",
"prefer",
"using",
"an",
"informer",
"factory",
"to",
"get",
"a",
"shared",
"informer",
"instead",
"of",
"getting",
"an",
"independent",
"one",
".",
"This",
"reduces",
"memory",
"footprint",
"and",
"number",
"of",
"connections",
"to",
"the",
"server",
"."
] | [
"func",
"NewFilteredProwJobInformer",
"(",
"client",
"versioned",
".",
"Interface",
",",
"namespace",
"string",
",",
"resyncPeriod",
"time",
".",
"Duration",
",",
"indexers",
"<mask>",
".",
"Indexers",
",",
"tweakListOptions",
"internalinterfaces",
".",
"TweakListOptionsFunc",
")",
"cache",
".",
"SharedIndexInformer",
"{",
"return",
"cache",
".",
"NewSharedIndexInformer",
"(",
"&",
"cache",
".",
"ListWatch",
"{",
"ListFunc",
":",
"func",
"(",
"options",
"metav1",
".",
"ListOptions",
")",
"(",
"runtime",
".",
"Object",
",",
"error",
")",
"{",
"if",
"tweakListOptions",
"!=",
"nil",
"{",
"tweakListOptions",
"(",
"&",
"options",
")",
"\n",
"}",
"\n",
"return",
"client",
".",
"ProwV1",
"(",
")",
".",
"ProwJobs",
"(",
"namespace",
")",
".",
"List",
"(",
"options",
")",
"\n",
"}",
",",
"WatchFunc",
":",
"func",
"(",
"options",
"metav1",
".",
"ListOptions",
")",
"(",
"watch",
".",
"Interface",
",",
"error",
")",
"{",
"if",
"tweakListOptions",
"!=",
"nil",
"{",
"tweakListOptions",
"(",
"&",
"options",
")",
"\n",
"}",
"\n",
"return",
"client",
".",
"ProwV1",
"(",
")",
".",
"ProwJobs",
"(",
"namespace",
")",
".",
"Watch",
"(",
"options",
")",
"\n",
"}",
",",
"}",
",",
"&",
"prowjobsv1",
".",
"ProwJob",
"{",
"}",
",",
"resyncPeriod",
",",
"indexers",
",",
")",
"\n",
"}"
] |
10,907 | all-10908 | [
"SetEmbedPageSetup",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_print_operation_set_embed_page_setup",
"()",
"."
] | [
"func",
"(",
"<mask>",
"*",
"PrintOperation",
")",
"SetEmbedPageSetup",
"(",
"embed",
"bool",
")",
"{",
"C",
".",
"gtk_print_operation_set_embed_page_setup",
"(",
"po",
".",
"native",
"(",
")",
",",
"gbool",
"(",
"embed",
")",
")",
"\n",
"}"
] |
10,908 | all-10909 | [
"WithReturnByValue",
"whether",
"the",
"result",
"is",
"expected",
"to",
"be",
"a",
"JSON",
"object",
"that",
"should",
"be",
"sent",
"by",
"value",
"."
] | [
"func",
"(",
"p",
"EvaluateParams",
")",
"WithReturnByValue",
"(",
"returnByValue",
"bool",
")",
"*",
"EvaluateParams",
"{",
"p",
".",
"ReturnByValue",
"=",
"returnByValue",
"\n",
"<mask>",
"&",
"p",
"\n",
"}"
] |
10,909 | all-10910 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"GetComputedStyleForNodeParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss46",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
10,910 | all-10911 | [
"Stop",
"stops",
"at",
"most",
"limit",
"running",
"services",
"pulling",
"from",
"git",
"repo",
"at",
"repoURL",
".",
"It",
"waits",
"until",
"the",
"service",
"is",
"terminated",
"before",
"returning",
".",
"If",
"limit",
"is",
"less",
"than",
"zero",
"it",
"is",
"ignored",
".",
"TODO",
"find",
"better",
"ways",
"to",
"identify",
"repos"
] | [
"func",
"(",
"s",
"*",
"services",
")",
"Stop",
"(",
"repoURL",
"string",
",",
"limit",
"int",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"// locate repos",
"for",
"i",
",",
"j",
":=",
"0",
",",
"0",
";",
"i",
"<",
"len",
"(",
"s",
".",
"services",
")",
"&&",
"(",
"(",
"limit",
">=",
"0",
"&&",
"j",
"<",
"limit",
")",
"||",
"limit",
"<",
"0",
")",
";",
"i",
"++",
"{",
"service",
":=",
"s",
".",
"<mask>",
"[",
"i",
"]",
"\n",
"if",
"string",
"(",
"service",
".",
"repo",
".",
"URL",
")",
"==",
"repoURL",
"{",
"// send halt signal",
"service",
".",
"halt",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"s",
".",
"services",
"[",
"i",
"]",
"=",
"nil",
"\n",
"j",
"++",
"\n",
"}",
"\n",
"}",
"\n\n",
"// remove them from repos list",
"services",
":=",
"s",
".",
"services",
"[",
":",
"0",
"]",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"s",
".",
"services",
"{",
"if",
"s",
"!=",
"nil",
"{",
"services",
"=",
"append",
"(",
"services",
",",
"s",
")",
"\n",
"}",
"\n",
"}",
"\n",
"s",
".",
"services",
"=",
"services",
"\n",
"}"
] |
10,911 | all-10912 | [
"MergeWithOverwrite",
"will",
"do",
"the",
"same",
"as",
"Merge",
"except",
"that",
"non",
"-",
"empty",
"dst",
"attributes",
"will",
"be",
"overriden",
"by",
"non",
"-",
"empty",
"src",
"attribute",
"values",
".",
"Deprecated",
":",
"use",
"Merge",
"(",
"…",
")",
"with",
"WithOverride"
] | [
"func",
"MergeWithOverwrite",
"(",
"dst",
",",
"src",
"interface",
"{",
"}",
",",
"opts",
"...",
"func",
"(",
"*",
"Config",
")",
")",
"error",
"{",
"return",
"merge",
"(",
"dst",
",",
"src",
",",
"<mask>",
"(",
"opts",
",",
"WithOverride",
")",
"...",
")",
"\n",
"}"
] |
10,912 | all-10913 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"SetShowDebugBordersParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"<mask>",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoOverlay5",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
10,913 | all-10914 | [
"SetWriter",
"sets",
"the",
"io",
".",
"Writer",
"destination",
"for",
"a",
"lob",
"field",
"to",
"be",
"read",
"from",
"database",
"and",
"return",
"*",
"Lob",
"to",
"enable",
"simple",
"call",
"chaining",
"."
] | [
"func",
"(",
"l",
"*",
"Lob",
")",
"SetWriter",
"(",
"wr",
"io",
".",
"<mask>",
")",
"*",
"Lob",
"{",
"l",
".",
"wr",
"=",
"wr",
"\n",
"return",
"l",
"\n",
"}"
] |
10,914 | all-10915 | [
"findFakeFunctionFor",
"returns",
"a",
"faker",
"function",
"for",
"a",
"fako",
"identifier"
] | [
"func",
"findFakeFunctionFor",
"(",
"fako",
"string",
")",
"func",
"(",
")",
"string",
"{",
"result",
":=",
"func",
"(",
")",
"string",
"{",
"return",
"\"",
"\"",
"}",
"\n\n",
"for",
"<mask>",
",",
"function",
":=",
"range",
"allGenerators",
"(",
")",
"{",
"if",
"fako",
"==",
"kind",
"{",
"result",
"=",
"function",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"}"
] |
10,915 | all-10916 | [
"compareDockerVersions",
"compares",
"two",
"docker",
"api",
"versions",
"lhs",
"and",
"rhs",
"and",
"returns",
"-",
"1",
"if",
"lhs",
"is",
"less",
"than",
"rhs",
"0",
"if",
"they",
"are",
"equal",
"and",
"1",
"if",
"lhs",
"is",
"greater",
"than",
"rhs"
] | [
"func",
"compareDockerVersions",
"(",
"lhs",
",",
"rhs",
"dockerVersion",
")",
"int",
"{",
"switch",
"{",
"case",
"lhs",
".",
"major",
"<",
"rhs",
".",
"major",
":",
"return",
"-",
"1",
"\n",
"<mask>",
"lhs",
".",
"major",
">",
"rhs",
".",
"major",
":",
"return",
"1",
"\n",
"case",
"lhs",
".",
"minor",
"<",
"rhs",
".",
"minor",
":",
"return",
"-",
"1",
"\n",
"case",
"lhs",
".",
"minor",
">",
"rhs",
".",
"minor",
":",
"return",
"1",
"\n",
"}",
"\n",
"return",
"0",
"\n",
"}"
] |
10,916 | all-10917 | [
"MustExec",
"is",
"like",
"Exec",
"but",
"panics",
"instead",
"of",
"returning",
"an",
"error",
"."
] | [
"func",
"(",
"xp",
"XPathExec",
")",
"MustExec",
"(",
"t",
"tree",
".",
"<mask>",
",",
"opts",
"...",
"FuncOpts",
")",
"tree",
".",
"Result",
"{",
"res",
",",
"err",
":=",
"xp",
".",
"Exec",
"(",
"t",
",",
"opts",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"res",
"\n",
"}"
] |
10,917 | all-10918 | [
"New",
"creates",
"a",
"Signer",
"using",
"the",
"supplied",
"keyset",
".",
"The",
"keyset",
"can",
"be",
"of",
"type",
"[]",
"byte",
"*",
"rsa",
".",
"{",
"PrivateKey",
"PublicKey",
"}",
"*",
"ecdsa",
".",
"{",
"PrivateKey",
"PublicKey",
"}",
"or",
"compatible",
"with",
"the",
"Store",
"interface",
".",
"If",
"a",
"private",
"key",
"is",
"not",
"provided",
"tokens",
"cannot",
"be",
"Encode",
"d",
".",
"Public",
"keys",
"will",
"be",
"automatically",
"generated",
"for",
"RSA",
"and",
"ECC",
"private",
"keys",
"if",
"none",
"were",
"provided",
"in",
"the",
"keyset",
"."
] | [
"func",
"(",
"alg",
"Algorithm",
")",
"New",
"(",
"keyset",
"interface",
"{",
"}",
")",
"(",
"Signer",
",",
"error",
")",
"{",
"a",
":=",
"algSet",
"[",
"alg",
"]",
"\n\n",
"// check hash",
"if",
"!",
"a",
".",
"hash",
".",
"Available",
"(",
")",
"{",
"return",
"nil",
",",
"ErrInvalidHash",
"\n",
"}",
"\n\n",
"var",
"s",
"Store",
"\n\n",
"// load the data",
"switch",
"p",
":=",
"keyset",
".",
"(",
"type",
")",
"{",
"// regular store",
"case",
"Store",
":",
"s",
"=",
"p",
"\n\n",
"// raw key",
"case",
"[",
"]",
"byte",
":",
"s",
"=",
"&",
"Keystore",
"{",
"<mask>",
":",
"p",
"}",
"\n\n",
"// rsa keys",
"case",
"*",
"rsa",
".",
"PrivateKey",
":",
"s",
"=",
"&",
"Keystore",
"{",
"Key",
":",
"p",
"}",
"\n",
"case",
"*",
"rsa",
".",
"PublicKey",
":",
"s",
"=",
"&",
"Keystore",
"{",
"PubKey",
":",
"p",
"}",
"\n\n",
"// ecc keys",
"case",
"*",
"ecdsa",
".",
"PrivateKey",
":",
"s",
"=",
"&",
"Keystore",
"{",
"Key",
":",
"p",
"}",
"\n",
"case",
"*",
"ecdsa",
".",
"PublicKey",
":",
"s",
"=",
"&",
"Keystore",
"{",
"PubKey",
":",
"p",
"}",
"\n\n",
"default",
":",
"return",
"nil",
",",
"ErrInvalidKeyset",
"\n",
"}",
"\n\n",
"return",
"a",
".",
"init",
"(",
"s",
",",
"a",
".",
"hash",
")",
"\n",
"}"
] |
10,918 | all-10919 | [
"MarshalEasyJSON",
"writes",
"the",
"SSN",
"to",
"a",
"easyjson",
".",
"Writer"
] | [
"func",
"(",
"u",
"SSN",
")",
"MarshalEasyJSON",
"(",
"w",
"*",
"jwriter",
".",
"Writer",
")",
"{",
"w",
".",
"<mask>",
"(",
"string",
"(",
"u",
")",
")",
"\n",
"}"
] |
10,919 | all-10920 | [
"Listen",
"for",
"DNS",
"requests",
".",
"listenSpec",
"is",
"a",
"dotted",
"-",
"quad",
"+",
"port",
"e",
".",
"g",
".",
"127",
".",
"0",
".",
"0",
".",
"1",
":",
"53",
".",
"This",
"function",
"blocks",
"and",
"only",
"returns",
"when",
"the",
"DNS",
"service",
"is",
"no",
"longer",
"functioning",
"."
] | [
"func",
"(",
"ds",
"*",
"DNSServer",
")",
"Listen",
"(",
"listenSpec",
"string",
")",
"error",
"{",
"return",
"dns",
".",
"ListenAndServe",
"(",
"listenSpec",
",",
"\"",
"\"",
",",
"<mask>",
")",
"\n",
"}"
] |
10,920 | all-10921 | [
"Push",
"a",
"point",
"to",
"the",
"database"
] | [
"func",
"(",
"i",
"*",
"InfluxDB",
")",
"Push",
"(",
"measurement",
"string",
",",
"tags",
"<mask>",
"[",
"string",
"]",
"string",
",",
"fields",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"date",
"time",
".",
"Time",
")",
"error",
"{",
"batch",
",",
"err",
":=",
"influxdb",
".",
"NewBatchPoints",
"(",
"influxdb",
".",
"BatchPointsConfig",
"{",
"Database",
":",
"i",
".",
"database",
",",
"Precision",
":",
"\"",
"\"",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"pt",
",",
"err",
":=",
"influxdb",
".",
"NewPoint",
"(",
"measurement",
",",
"tags",
",",
"fields",
",",
"date",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"batch",
".",
"AddPoint",
"(",
"pt",
")",
"\n\n",
"err",
"=",
"i",
".",
"client",
".",
"Write",
"(",
"batch",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"glog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"measurement",
",",
"tags",
",",
"fields",
",",
"date",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
10,921 | all-10922 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"SetXHRBreakpointParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoDomdebugger",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
] |
10,922 | all-10923 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"SetDefaultBackgroundColorOverrideParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoEmulation13",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
10,923 | all-10924 | [
"SubnetID",
"returns",
"the",
"subnet",
"id",
"for",
"the",
"network",
"interface",
"given",
"its",
"mac",
"address"
] | [
"func",
"(",
"c",
"*",
"ec2MetadataClientImpl",
")",
"SubnetID",
"(",
"<mask>",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"client",
".",
"GetMetadata",
"(",
"fmt",
".",
"Sprintf",
"(",
"SubnetIDResourceFormat",
",",
"mac",
")",
")",
"\n",
"}"
] |
10,924 | all-10925 | [
"TSSPluginLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | [
"func",
"(",
"api",
"*",
"API",
")",
"TSSPluginLocator",
"(",
"href",
"<mask>",
")",
"*",
"TSSPluginLocator",
"{",
"return",
"&",
"TSSPluginLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] |
10,925 | all-10926 | [
"FileExists",
"returns",
"a",
"flag",
"indicating",
"whether",
"a",
"provided",
"file",
"path",
"exists",
"."
] | [
"func",
"FileExists",
"(",
"filePath",
"string",
")",
"bool",
"{",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filePath",
")",
";",
"!",
"<mask>",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] |
10,926 | all-10927 | [
"----------------------------------------",
"Signed"
] | [
"func",
"EncodeInt8",
"(",
"w",
"io",
".",
"<mask>",
",",
"i",
"int8",
")",
"(",
"err",
"error",
")",
"{",
"return",
"EncodeVarint",
"(",
"w",
",",
"int64",
"(",
"i",
")",
")",
"\n",
"}"
] |
10,927 | all-10928 | [
"UnmarshalJSON",
"implements",
"the",
"json",
".",
"Unmarshaler",
"interface",
"."
] | [
"func",
"(",
"pr",
"*",
"prInsecureAcceptAnything",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"*",
"pr",
"=",
"prInsecureAcceptAnything",
"{",
"}",
"\n",
"<mask>",
"tmp",
"prInsecureAcceptAnything",
"\n",
"if",
"err",
":=",
"paranoidUnmarshalJSONObjectExactFields",
"(",
"data",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"&",
"tmp",
".",
"Type",
",",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"tmp",
".",
"Type",
"!=",
"prTypeInsecureAcceptAnything",
"{",
"return",
"InvalidPolicyFormatError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"tmp",
".",
"Type",
")",
")",
"\n",
"}",
"\n",
"*",
"pr",
"=",
"*",
"newPRInsecureAcceptAnything",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,928 | all-10929 | [
"NewServer",
"returns",
"a",
"new",
"agent",
"server",
"."
] | [
"func",
"NewServer",
"(",
"lg",
"*",
"zap",
".",
"Logger",
",",
"network",
"string",
",",
"address",
"string",
",",
")",
"*",
"Server",
"{",
"return",
"&",
"Server",
"{",
"lg",
":",
"lg",
",",
"network",
":",
"network",
",",
"address",
":",
"address",
",",
"last",
":",
"rpcpb",
".",
"Operation_NOT_STARTED",
",",
"advertiseClientPortToProxy",
":",
"make",
"(",
"map",
"[",
"int",
"]",
"proxy",
".",
"Server",
")",
",",
"advertisePeerPortToProxy",
":",
"make",
"(",
"map",
"[",
"int",
"]",
"<mask>",
".",
"Server",
")",
",",
"}",
"\n",
"}"
] |
10,929 | all-10930 | [
"DeleteInteractions",
"removes",
"any",
"previous",
"Mock",
"Service",
"Interactions",
"."
] | [
"func",
"(",
"m",
"*",
"MockService",
")",
"DeleteInteractions",
"(",
")",
"error",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"m",
".",
"BaseURL",
")",
"\n",
"return",
"m",
".",
"call",
"(",
"\"",
"\"",
",",
"<mask>",
",",
"nil",
")",
"\n",
"}"
] |
10,930 | all-10931 | [
"HasManageStatusTitleAlign",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"w",
"*",
"Widget",
")",
"HasManageStatusTitleAlign",
"(",
")",
"bool",
"{",
"if",
"w",
"!=",
"nil",
"&&",
"w",
".",
"ManageStatusTitleAlign",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
10,931 | all-10932 | [
"MarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Marshaler",
"."
] | [
"func",
"(",
"t",
"AuthChallengeResponseResponse",
")",
"MarshalEasyJSON",
"(",
"<mask>",
"*",
"jwriter",
".",
"Writer",
")",
"{",
"out",
".",
"String",
"(",
"string",
"(",
"t",
")",
")",
"\n",
"}"
] |
10,932 | all-10933 | [
"LoadRepoOwners",
"returns",
"an",
"up",
"-",
"to",
"-",
"date",
"RepoOwners",
"struct",
"for",
"the",
"specified",
"repo",
".",
"Note",
":",
"The",
"returned",
"*",
"RepoOwners",
"should",
"be",
"treated",
"as",
"read",
"only",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"LoadRepoOwners",
"(",
"org",
",",
"repo",
",",
"base",
"string",
")",
"(",
"RepoOwner",
",",
"error",
")",
"{",
"log",
":=",
"c",
".",
"logger",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"\"",
"\"",
":",
"org",
",",
"\"",
"\"",
":",
"repo",
",",
"\"",
"\"",
":",
"base",
"}",
")",
"\n",
"cloneRef",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"org",
",",
"repo",
")",
"\n",
"fullName",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"cloneRef",
",",
"base",
")",
"\n",
"mdYaml",
":=",
"c",
".",
"mdYAMLEnabled",
"(",
"org",
",",
"repo",
")",
"\n\n",
"sha",
",",
"err",
":=",
"c",
".",
"ghc",
".",
"GetRef",
"(",
"org",
",",
"repo",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"base",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fullName",
",",
"err",
")",
"\n",
"}",
"\n\n",
"c",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"entry",
",",
"ok",
":=",
"c",
".",
"cache",
"[",
"fullName",
"]",
"\n",
"if",
"!",
"ok",
"||",
"entry",
".",
"sha",
"!=",
"sha",
"||",
"entry",
".",
"owners",
"==",
"nil",
"||",
"!",
"entry",
".",
"matchesMDYAML",
"(",
"mdYaml",
")",
"{",
"gitRepo",
",",
"err",
":=",
"c",
".",
"git",
".",
"Clone",
"(",
"cloneRef",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"cloneRef",
",",
"err",
")",
"\n",
"}",
"\n",
"defer",
"gitRepo",
".",
"Clean",
"(",
")",
"\n\n",
"reusable",
":=",
"entry",
".",
"fullyLoaded",
"(",
")",
"&&",
"entry",
".",
"matchesMDYAML",
"(",
"mdYaml",
")",
"\n",
"// In most sha changed cases, the files associated with the owners are unchanged.",
"// The cached entry can continue to be used, so need do git diff",
"if",
"reusable",
"{",
"changes",
",",
"err",
":=",
"gitRepo",
".",
"Diff",
"(",
"sha",
",",
"entry",
".",
"sha",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"sha",
",",
"entry",
".",
"sha",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"change",
":=",
"<mask>",
"changes",
"{",
"if",
"mdYaml",
"&&",
"strings",
".",
"HasSuffix",
"(",
"change",
",",
"\"",
"\"",
")",
"||",
"strings",
".",
"HasSuffix",
"(",
"change",
",",
"aliasesFileName",
")",
"||",
"strings",
".",
"HasSuffix",
"(",
"change",
",",
"ownersFileName",
")",
"{",
"reusable",
"=",
"false",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"reusable",
"{",
"entry",
".",
"sha",
"=",
"sha",
"\n",
"}",
"else",
"{",
"if",
"err",
":=",
"gitRepo",
".",
"Checkout",
"(",
"base",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"entry",
".",
"aliases",
"==",
"nil",
"||",
"entry",
".",
"sha",
"!=",
"sha",
"{",
"// aliases must be loaded",
"entry",
".",
"aliases",
"=",
"loadAliasesFrom",
"(",
"gitRepo",
".",
"Dir",
",",
"log",
")",
"\n",
"}",
"\n\n",
"dirBlacklistPatterns",
":=",
"append",
"(",
"c",
".",
"ownersDirBlacklist",
"(",
")",
".",
"DirBlacklist",
"(",
"org",
",",
"repo",
")",
",",
"commonDirBlacklist",
"...",
")",
"\n",
"var",
"dirBlacklist",
"[",
"]",
"*",
"regexp",
".",
"Regexp",
"\n",
"for",
"_",
",",
"pattern",
":=",
"range",
"dirBlacklistPatterns",
"{",
"re",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"pattern",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"pattern",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"dirBlacklist",
"=",
"append",
"(",
"dirBlacklist",
",",
"re",
")",
"\n",
"}",
"\n\n",
"entry",
".",
"owners",
",",
"err",
"=",
"loadOwnersFrom",
"(",
"gitRepo",
".",
"Dir",
",",
"mdYaml",
",",
"entry",
".",
"aliases",
",",
"dirBlacklist",
",",
"log",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"fullName",
",",
"err",
")",
"\n",
"}",
"\n",
"entry",
".",
"sha",
"=",
"sha",
"\n",
"c",
".",
"cache",
"[",
"fullName",
"]",
"=",
"entry",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"skipCollaborators",
"(",
"org",
",",
"repo",
")",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"org",
",",
"repo",
")",
"\n",
"return",
"entry",
".",
"owners",
",",
"nil",
"\n",
"}",
"\n\n",
"var",
"owners",
"*",
"RepoOwners",
"\n",
"// Filter collaborators. We must filter the RepoOwners struct even if it came from the cache",
"// because the list of collaborators could have changed without the git SHA changing.",
"collaborators",
",",
"err",
":=",
"c",
".",
"ghc",
".",
"ListCollaborators",
"(",
"org",
",",
"repo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"owners",
"=",
"entry",
".",
"owners",
"\n",
"}",
"else",
"{",
"owners",
"=",
"entry",
".",
"owners",
".",
"filterCollaborators",
"(",
"collaborators",
")",
"\n",
"}",
"\n",
"return",
"owners",
",",
"nil",
"\n",
"}"
] |
10,933 | all-10934 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"ReleaseSnapshotParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoLayertree6",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
10,934 | all-10935 | [
"Execute",
"should",
"be",
"called",
"once",
"the",
"top",
"-",
"level",
"-",
"flags",
"on",
"a",
"Commander",
"have",
"been",
"initialized",
".",
"It",
"finds",
"the",
"correct",
"subcommand",
"and",
"executes",
"it",
"and",
"returns",
"an",
"ExitStatus",
"with",
"the",
"result",
".",
"On",
"a",
"usage",
"error",
"an",
"appropriate",
"message",
"is",
"printed",
"to",
"os",
".",
"Stderr",
"and",
"ExitUsageError",
"is",
"returned",
".",
"The",
"additional",
"args",
"are",
"provided",
"as",
"-",
"is",
"to",
"the",
"Execute",
"method",
"of",
"the",
"selected",
"Command",
"."
] | [
"func",
"(",
"cdr",
"*",
"Commander",
")",
"Execute",
"(",
"ctx",
"context",
".",
"Context",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"ExitStatus",
"{",
"if",
"cdr",
".",
"topFlags",
".",
"NArg",
"(",
")",
"<",
"1",
"{",
"cdr",
".",
"topFlags",
".",
"Usage",
"(",
")",
"\n",
"return",
"ExitUsageError",
"\n",
"}",
"\n\n",
"name",
":=",
"cdr",
".",
"topFlags",
".",
"Arg",
"(",
"0",
")",
"\n\n",
"for",
"_",
",",
"<mask>",
":=",
"range",
"cdr",
".",
"commands",
"{",
"for",
"_",
",",
"cmd",
":=",
"range",
"group",
".",
"commands",
"{",
"if",
"name",
"!=",
"cmd",
".",
"Name",
"(",
")",
"{",
"continue",
"\n",
"}",
"\n",
"f",
":=",
"flag",
".",
"NewFlagSet",
"(",
"name",
",",
"flag",
".",
"ContinueOnError",
")",
"\n",
"f",
".",
"Usage",
"=",
"func",
"(",
")",
"{",
"explain",
"(",
"cdr",
".",
"Error",
",",
"cmd",
")",
"}",
"\n",
"cmd",
".",
"SetFlags",
"(",
"f",
")",
"\n",
"if",
"f",
".",
"Parse",
"(",
"cdr",
".",
"topFlags",
".",
"Args",
"(",
")",
"[",
"1",
":",
"]",
")",
"!=",
"nil",
"{",
"return",
"ExitUsageError",
"\n",
"}",
"\n",
"return",
"cmd",
".",
"Execute",
"(",
"ctx",
",",
"f",
",",
"args",
"...",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Cannot find this command.",
"cdr",
".",
"topFlags",
".",
"Usage",
"(",
")",
"\n",
"return",
"ExitUsageError",
"\n",
"}"
] |
10,935 | all-10936 | [
"NewMockOS",
"creates",
"a",
"new",
"mock",
"instance"
] | [
"func",
"NewMockOS",
"(",
"ctrl",
"*",
"gomock",
".",
"<mask>",
")",
"*",
"MockOS",
"{",
"mock",
":=",
"&",
"MockOS",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockOSMockRecorder",
"{",
"mock",
"}",
"\n",
"return",
"mock",
"\n",
"}"
] |
10,936 | all-10937 | [
"PKI",
"management",
"."
] | [
"func",
"(",
"s",
"*",
"<mask>",
")",
"Delete",
"(",
"clusterID",
"string",
")",
"error",
"{",
"// Create a client for the system backend configured with the Vault token",
"// used for the current cluster's PKI backend.",
"sysBackend",
":=",
"s",
".",
"VaultClient",
".",
"Sys",
"(",
")",
"\n\n",
"// Unmount the PKI backend, if it exists.",
"mounted",
",",
"err",
":=",
"s",
".",
"IsMounted",
"(",
"clusterID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"microerror",
".",
"Mask",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"mounted",
"{",
"err",
"=",
"sysBackend",
".",
"Unmount",
"(",
"s",
".",
"MountPKIPath",
"(",
"clusterID",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"microerror",
".",
"Mask",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
10,937 | all-10938 | [
"Name",
"is",
"a",
"wrapper",
"around",
"g_type_name",
"()",
"."
] | [
"func",
"(",
"t",
"<mask>",
")",
"Name",
"(",
")",
"string",
"{",
"return",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"char",
")",
"(",
"C",
".",
"g_type_name",
"(",
"C",
".",
"GType",
"(",
"t",
")",
")",
")",
")",
"\n",
"}"
] |
10,938 | all-10939 | [
"/",
"*",
"Returns",
"an",
"array",
"representing",
"the",
"variables",
"contained",
"in",
"this",
"EvaluableExpression",
"."
] | [
"func",
"(",
"this",
"EvaluableExpression",
")",
"Vars",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"varlist",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"val",
":=",
"range",
"this",
".",
"Tokens",
"(",
")",
"{",
"if",
"val",
".",
"Kind",
"==",
"VARIABLE",
"{",
"varlist",
"=",
"<mask>",
"(",
"varlist",
",",
"val",
".",
"Value",
".",
"(",
"string",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"varlist",
"\n",
"}"
] |
10,939 | all-10940 | [
"LogsCollections",
"returns",
"logs",
"collections",
"for",
"all",
"apps",
"from",
"MongoDB",
"."
] | [
"func",
"(",
"s",
"*",
"LogStorage",
")",
"LogsCollections",
"(",
")",
"(",
"[",
"]",
"*",
"storage",
".",
"Collection",
",",
"error",
")",
"{",
"var",
"names",
"[",
"]",
"struct",
"{",
"Name",
"string",
"\n",
"}",
"\n",
"conn",
",",
"err",
":=",
"Conn",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n",
"err",
"=",
"conn",
".",
"Apps",
"(",
")",
".",
"Find",
"(",
"nil",
")",
".",
"All",
"(",
"&",
"<mask>",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"var",
"colls",
"[",
"]",
"*",
"storage",
".",
"Collection",
"\n",
"for",
"_",
",",
"name",
":=",
"range",
"names",
"{",
"colls",
"=",
"append",
"(",
"colls",
",",
"s",
".",
"Collection",
"(",
"\"",
"\"",
"+",
"name",
".",
"Name",
")",
")",
"\n",
"}",
"\n",
"return",
"colls",
",",
"nil",
"\n",
"}"
] |
10,940 | all-10941 | [
"RegisterPushEventHandler",
"registers",
"a",
"plugin",
"s",
"github",
".",
"PushEvent",
"handler",
"."
] | [
"func",
"RegisterPushEventHandler",
"(",
"<mask>",
"string",
",",
"fn",
"PushEventHandler",
",",
"help",
"HelpProvider",
")",
"{",
"pluginHelp",
"[",
"name",
"]",
"=",
"help",
"\n",
"pushEventHandlers",
"[",
"name",
"]",
"=",
"fn",
"\n",
"}"
] |
10,941 | all-10942 | [
"SelectServers",
"restricts",
"communication",
"to",
"servers",
"configured",
"with",
"the",
"given",
"tags",
".",
"For",
"example",
"the",
"following",
"statement",
"restricts",
"servers",
"used",
"for",
"reading",
"operations",
"to",
"those",
"with",
"both",
"tag",
"disk",
"set",
"to",
"ssd",
"and",
"tag",
"rack",
"set",
"to",
"1",
":",
"session",
".",
"SelectSlaves",
"(",
"bson",
".",
"D",
"{{",
"disk",
"ssd",
"}",
"{",
"rack",
"1",
"}}",
")",
"Multiple",
"sets",
"of",
"tags",
"may",
"be",
"provided",
"in",
"which",
"case",
"the",
"used",
"server",
"must",
"match",
"all",
"tags",
"within",
"any",
"one",
"set",
".",
"If",
"a",
"connection",
"was",
"previously",
"assigned",
"to",
"the",
"session",
"due",
"to",
"the",
"current",
"session",
"mode",
"(",
"see",
"Session",
".",
"SetMode",
")",
"the",
"tag",
"selection",
"will",
"only",
"be",
"enforced",
"after",
"the",
"session",
"is",
"refreshed",
".",
"Relevant",
"documentation",
":",
"http",
":",
"//",
"docs",
".",
"mongodb",
".",
"org",
"/",
"manual",
"/",
"tutorial",
"/",
"configure",
"-",
"replica",
"-",
"set",
"-",
"tag",
"-",
"sets"
] | [
"func",
"(",
"s",
"*",
"Session",
")",
"SelectServers",
"(",
"tags",
"...",
"bson",
".",
"D",
")",
"{",
"s",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"queryConfig",
".",
"op",
".",
"serverTags",
"=",
"<mask>",
"\n",
"s",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"}"
] |
10,942 | all-10943 | [
"PeekBytes",
"returns",
"query",
"arg",
"value",
"for",
"the",
"given",
"key",
".",
"Returned",
"value",
"is",
"valid",
"until",
"the",
"next",
"Args",
"call",
"."
] | [
"func",
"(",
"a",
"*",
"Args",
")",
"PeekBytes",
"(",
"key",
"[",
"]",
"byte",
")",
"[",
"]",
"<mask>",
"{",
"return",
"peekArgBytes",
"(",
"a",
".",
"args",
",",
"key",
")",
"\n",
"}"
] |
10,943 | all-10944 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"EventWebSocketCreated",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork45",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
10,944 | all-10945 | [
"serveSubstream",
"forwards",
"watch",
"responses",
"from",
"run",
"()",
"to",
"the",
"subscriber"
] | [
"func",
"(",
"w",
"*",
"watchGrpcStream",
")",
"serveSubstream",
"(",
"<mask>",
"*",
"watcherStream",
",",
"resumec",
"chan",
"struct",
"{",
"}",
")",
"{",
"if",
"ws",
".",
"closing",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// nextRev is the minimum expected next revision",
"nextRev",
":=",
"ws",
".",
"initReq",
".",
"rev",
"\n",
"resuming",
":=",
"false",
"\n",
"defer",
"func",
"(",
")",
"{",
"if",
"!",
"resuming",
"{",
"ws",
".",
"closing",
"=",
"true",
"\n",
"}",
"\n",
"close",
"(",
"ws",
".",
"donec",
")",
"\n",
"if",
"!",
"resuming",
"{",
"w",
".",
"closingc",
"<-",
"ws",
"\n",
"}",
"\n",
"w",
".",
"wg",
".",
"Done",
"(",
")",
"\n",
"}",
"(",
")",
"\n\n",
"emptyWr",
":=",
"&",
"WatchResponse",
"{",
"}",
"\n",
"for",
"{",
"curWr",
":=",
"emptyWr",
"\n",
"outc",
":=",
"ws",
".",
"outc",
"\n\n",
"if",
"len",
"(",
"ws",
".",
"buf",
")",
">",
"0",
"{",
"curWr",
"=",
"ws",
".",
"buf",
"[",
"0",
"]",
"\n",
"}",
"else",
"{",
"outc",
"=",
"nil",
"\n",
"}",
"\n",
"select",
"{",
"case",
"outc",
"<-",
"*",
"curWr",
":",
"if",
"ws",
".",
"buf",
"[",
"0",
"]",
".",
"Err",
"(",
")",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"ws",
".",
"buf",
"[",
"0",
"]",
"=",
"nil",
"\n",
"ws",
".",
"buf",
"=",
"ws",
".",
"buf",
"[",
"1",
":",
"]",
"\n",
"case",
"wr",
",",
"ok",
":=",
"<-",
"ws",
".",
"recvc",
":",
"if",
"!",
"ok",
"{",
"// shutdown from closeSubstream",
"return",
"\n",
"}",
"\n\n",
"if",
"wr",
".",
"Created",
"{",
"if",
"ws",
".",
"initReq",
".",
"retc",
"!=",
"nil",
"{",
"ws",
".",
"initReq",
".",
"retc",
"<-",
"ws",
".",
"outc",
"\n",
"// to prevent next write from taking the slot in buffered channel",
"// and posting duplicate create events",
"ws",
".",
"initReq",
".",
"retc",
"=",
"nil",
"\n\n",
"// send first creation event only if requested",
"if",
"ws",
".",
"initReq",
".",
"createdNotify",
"{",
"ws",
".",
"outc",
"<-",
"*",
"wr",
"\n",
"}",
"\n",
"// once the watch channel is returned, a current revision",
"// watch must resume at the store revision. This is necessary",
"// for the following case to work as expected:",
"//\twch := m1.Watch(\"a\")",
"//\tm2.Put(\"a\", \"b\")",
"//\t<-wch",
"// If the revision is only bound on the first observed event,",
"// if wch is disconnected before the Put is issued, then reconnects",
"// after it is committed, it'll miss the Put.",
"if",
"ws",
".",
"initReq",
".",
"rev",
"==",
"0",
"{",
"nextRev",
"=",
"wr",
".",
"Header",
".",
"Revision",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// current progress of watch; <= store revision",
"nextRev",
"=",
"wr",
".",
"Header",
".",
"Revision",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"wr",
".",
"Events",
")",
">",
"0",
"{",
"nextRev",
"=",
"wr",
".",
"Events",
"[",
"len",
"(",
"wr",
".",
"Events",
")",
"-",
"1",
"]",
".",
"Kv",
".",
"ModRevision",
"+",
"1",
"\n",
"}",
"\n",
"ws",
".",
"initReq",
".",
"rev",
"=",
"nextRev",
"\n\n",
"// created event is already sent above,",
"// watcher should not post duplicate events",
"if",
"wr",
".",
"Created",
"{",
"continue",
"\n",
"}",
"\n\n",
"// TODO pause channel if buffer gets too large",
"ws",
".",
"buf",
"=",
"append",
"(",
"ws",
".",
"buf",
",",
"wr",
")",
"\n",
"case",
"<-",
"w",
".",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"\n",
"case",
"<-",
"ws",
".",
"initReq",
".",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"\n",
"case",
"<-",
"resumec",
":",
"resuming",
"=",
"true",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"// lazily send cancel message if events on missing id",
"}"
] |
10,945 | all-10946 | [
"Apply",
"satisfies",
"the",
"StartSpanOption",
"interface",
"."
] | [
"func",
"(",
"t",
"StartTime",
")",
"Apply",
"(",
"o",
"*",
"StartSpanOptions",
")",
"{",
"o",
".",
"StartTime",
"=",
"<mask>",
".",
"Time",
"(",
"t",
")",
"\n",
"}"
] |
10,946 | all-10947 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"ReadReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoIo2",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
10,947 | all-10948 | [
"FirstIndex",
"implements",
"the",
"LogStore",
"interface",
"."
] | [
"func",
"(",
"i",
"*",
"InmemStore",
")",
"FirstIndex",
"(",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"i",
".",
"l",
".",
"RLock",
"(",
")",
"\n",
"defer",
"i",
".",
"l",
".",
"RUnlock",
"(",
")",
"\n",
"<mask>",
"i",
".",
"lowIndex",
",",
"nil",
"\n",
"}"
] |
10,948 | all-10949 | [
"errMissingField",
"returns",
"a",
"logical",
"response",
"error",
"that",
"prints",
"a",
"consistent",
"error",
"message",
"for",
"when",
"a",
"required",
"field",
"is",
"missing",
"."
] | [
"func",
"errMissingField",
"(",
"<mask>",
"string",
")",
"*",
"logical",
".",
"Response",
"{",
"return",
"logical",
".",
"ErrorResponse",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"field",
")",
")",
"\n",
"}"
] |
10,949 | all-10950 | [
"NextKnownState",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockTaskResource",
")",
"NextKnownState",
"(",
")",
"status0",
".",
"ResourceStatus",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"<mask>",
"[",
"0",
"]",
".",
"(",
"status0",
".",
"ResourceStatus",
")",
"\n",
"return",
"ret0",
"\n",
"}"
] |
10,950 | all-10951 | [
"GetProwJob",
"returns",
"the",
"prowjob",
"at",
"name",
"in",
"the",
"client",
"s",
"specified",
"namespace",
".",
"Analogous",
"to",
"kubectl",
"get",
"prowjob",
"/",
"NAME",
"--",
"namespace",
"=",
"client",
".",
"namespace"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetProwJob",
"(",
"name",
"string",
")",
"(",
"prowapi",
".",
"ProwJob",
",",
"error",
")",
"{",
"c",
".",
"log",
"(",
"\"",
"\"",
",",
"<mask>",
")",
"\n",
"var",
"pj",
"prowapi",
".",
"ProwJob",
"\n",
"err",
":=",
"c",
".",
"request",
"(",
"&",
"request",
"{",
"path",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"namespace",
",",
"name",
")",
",",
"}",
",",
"&",
"pj",
")",
"\n",
"return",
"pj",
",",
"err",
"\n",
"}"
] |
10,951 | all-10952 | [
"UpdateAlert",
"takes",
"an",
"alert",
"that",
"was",
"previously",
"retrieved",
"through",
"some",
"method",
"and",
"sends",
"it",
"back",
"to",
"the",
"server",
"."
] | [
"func",
"(",
"client",
"*",
"<mask>",
")",
"UpdateAlert",
"(",
"alert",
"*",
"Alert",
")",
"error",
"{",
"return",
"client",
".",
"doJsonRequest",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"alert",
".",
"Id",
")",
",",
"alert",
",",
"nil",
")",
"\n",
"}"
] |
10,952 | all-10953 | [
"Uninhibit",
"is",
"a",
"wrapper",
"around",
"gtk_application_uninhibit",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Application",
")",
"Uninhibit",
"(",
"cookie",
"uint",
")",
"{",
"C",
".",
"gtk_application_uninhibit",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"guint",
"(",
"<mask>",
")",
")",
"\n",
"}"
] |
10,953 | all-10954 | [
"GetDatumTotalTime",
"sums",
"the",
"timing",
"stats",
"from",
"a",
"DatumInfo"
] | [
"func",
"GetDatumTotalTime",
"(",
"s",
"*",
"pps",
".",
"ProcessStats",
")",
"time",
".",
"Duration",
"{",
"totalDuration",
":=",
"time",
".",
"Duration",
"(",
"0",
")",
"\n",
"duration",
",",
"_",
":=",
"<mask>",
".",
"DurationFromProto",
"(",
"s",
".",
"DownloadTime",
")",
"\n",
"totalDuration",
"+=",
"duration",
"\n",
"duration",
",",
"_",
"=",
"types",
".",
"DurationFromProto",
"(",
"s",
".",
"ProcessTime",
")",
"\n",
"totalDuration",
"+=",
"duration",
"\n",
"duration",
",",
"_",
"=",
"types",
".",
"DurationFromProto",
"(",
"s",
".",
"UploadTime",
")",
"\n",
"totalDuration",
"+=",
"duration",
"\n",
"return",
"totalDuration",
"\n",
"}"
] |
10,954 | all-10955 | [
"export",
"goPageSetupDone"
] | [
"func",
"goPageSetupDone",
"(",
"setup",
"*",
"C",
".",
"GtkPageSetup",
",",
"data",
"C",
".",
"gpointer",
")",
"{",
"<mask>",
":=",
"int",
"(",
"uintptr",
"(",
"data",
")",
")",
"\n\n",
"pageSetupDoneCallbackRegistry",
".",
"Lock",
"(",
")",
"\n",
"r",
":=",
"pageSetupDoneCallbackRegistry",
".",
"m",
"[",
"id",
"]",
"\n",
"delete",
"(",
"pageSetupDoneCallbackRegistry",
".",
"m",
",",
"id",
")",
"\n",
"pageSetupDoneCallbackRegistry",
".",
"Unlock",
"(",
")",
"\n\n",
"obj",
":=",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"setup",
")",
")",
"\n",
"r",
".",
"fn",
"(",
"wrapPageSetup",
"(",
"obj",
")",
",",
"r",
".",
"data",
")",
"\n\n",
"}"
] |
10,955 | all-10956 | [
"Decode",
"decodes",
"a",
"serialized",
"token",
"verifying",
"the",
"signature",
"storing",
"the",
"decoded",
"data",
"from",
"the",
"token",
"in",
"obj",
"."
] | [
"func",
"(",
"<mask>",
"*",
"EccSigner",
")",
"Decode",
"(",
"buf",
"[",
"]",
"byte",
",",
"obj",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"es",
".",
"alg",
".",
"Decode",
"(",
"es",
",",
"buf",
",",
"obj",
")",
"\n",
"}"
] |
10,956 | all-10957 | [
"MultipartForm",
"returns",
"requests",
"s",
"multipart",
"form",
".",
"Returns",
"ErrNoMultipartForm",
"if",
"request",
"s",
"Content",
"-",
"Type",
"isn",
"t",
"multipart",
"/",
"form",
"-",
"data",
".",
"RemoveMultipartFormFiles",
"must",
"be",
"called",
"after",
"returned",
"multipart",
"form",
"is",
"processed",
"."
] | [
"func",
"(",
"req",
"*",
"<mask>",
")",
"MultipartForm",
"(",
")",
"(",
"*",
"multipart",
".",
"Form",
",",
"error",
")",
"{",
"if",
"req",
".",
"multipartForm",
"!=",
"nil",
"{",
"return",
"req",
".",
"multipartForm",
",",
"nil",
"\n",
"}",
"\n\n",
"req",
".",
"multipartFormBoundary",
"=",
"string",
"(",
"req",
".",
"Header",
".",
"MultipartFormBoundary",
"(",
")",
")",
"\n",
"if",
"len",
"(",
"req",
".",
"multipartFormBoundary",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"ErrNoMultipartForm",
"\n",
"}",
"\n\n",
"ce",
":=",
"req",
".",
"Header",
".",
"peek",
"(",
"strContentEncoding",
")",
"\n",
"body",
":=",
"req",
".",
"bodyBytes",
"(",
")",
"\n",
"if",
"bytes",
".",
"Equal",
"(",
"ce",
",",
"strGzip",
")",
"{",
"// Do not care about memory usage here.",
"var",
"err",
"error",
"\n",
"if",
"body",
",",
"err",
"=",
"AppendGunzipBytes",
"(",
"nil",
",",
"body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"len",
"(",
"ce",
")",
">",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ce",
")",
"\n",
"}",
"\n\n",
"f",
",",
"err",
":=",
"readMultipartForm",
"(",
"bytes",
".",
"NewReader",
"(",
"body",
")",
",",
"req",
".",
"multipartFormBoundary",
",",
"len",
"(",
"body",
")",
",",
"len",
"(",
"body",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"req",
".",
"multipartForm",
"=",
"f",
"\n",
"return",
"f",
",",
"nil",
"\n",
"}"
] |
10,957 | all-10958 | [
"AddButton",
"is",
"a",
"wrapper",
"around",
"g_notification_add_button",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Notification",
")",
"AddButton",
"(",
"label",
",",
"detailedAction",
"string",
")",
"{",
"cstr1",
":=",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"C",
".",
"CString",
"(",
"label",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr1",
")",
")",
"\n\n",
"cstr2",
":=",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"C",
".",
"CString",
"(",
"detailedAction",
")",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr2",
")",
")",
"\n\n",
"C",
".",
"g_notification_add_button",
"(",
"v",
".",
"native",
"(",
")",
",",
"cstr1",
",",
"cstr2",
")",
"\n",
"}"
] |
10,958 | all-10959 | [
"Returns",
"an",
"map",
"[",
"string",
"]",
"string"
] | [
"func",
"(",
"t",
"Typed",
")",
"StringString",
"(",
"key",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"raw",
",",
"ok",
":=",
"t",
".",
"getmap",
"(",
"key",
")",
"\n",
"if",
"ok",
"==",
"false",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"len",
"(",
"raw",
")",
")",
"\n",
"for",
"k",
",",
"<mask>",
":=",
"range",
"raw",
"{",
"m",
"[",
"k",
"]",
"=",
"value",
".",
"(",
"string",
")",
"\n",
"}",
"\n",
"return",
"m",
"\n",
"}"
] |
10,959 | all-10960 | [
"NewFile",
"creates",
"a",
"pfs",
".",
"File",
"."
] | [
"func",
"NewFile",
"(",
"repoName",
"string",
",",
"commitID",
"string",
",",
"path",
"string",
")",
"*",
"pfs",
".",
"File",
"{",
"return",
"&",
"pfs",
".",
"File",
"{",
"Commit",
":",
"NewCommit",
"(",
"repoName",
",",
"commitID",
")",
",",
"Path",
":",
"<mask>",
",",
"}",
"\n",
"}"
] |
10,960 | all-10961 | [
"IsExpired",
"indicates",
"an",
"expected",
"call",
"of",
"IsExpired"
] | [
"func",
"(",
"mr",
"*",
"MockProviderMockRecorder",
")",
"IsExpired",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"<mask>",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
"TypeOf",
"(",
"(",
"*",
"MockProvider",
")",
"(",
"nil",
")",
".",
"IsExpired",
")",
")",
"\n",
"}"
] |
10,961 | all-10962 | [
"StrokeString",
"draws",
"the",
"contour",
"of",
"the",
"text",
"at",
"point",
"(",
"0",
"0",
")"
] | [
"func",
"(",
"gc",
"*",
"GraphicContext",
")",
"StrokeString",
"(",
"<mask>",
"string",
")",
"(",
"width",
"float64",
")",
"{",
"return",
"gc",
".",
"StrokeStringAt",
"(",
"text",
",",
"0",
",",
"0",
")",
"\n",
"}"
] |
10,962 | all-10963 | [
"Track",
"sends",
"a",
"single",
"event",
"to",
"Customer",
".",
"io",
"for",
"the",
"supplied",
"user"
] | [
"func",
"(",
"c",
"*",
"CustomerIO",
")",
"Track",
"(",
"customerID",
"string",
",",
"eventName",
"string",
",",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"body",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"eventName",
",",
"\"",
"\"",
":",
"data",
"}",
"\n",
"j",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"body",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"<mask>",
",",
"responseBody",
",",
"err",
":=",
"c",
".",
"request",
"(",
"\"",
"\"",
",",
"c",
".",
"eventURL",
"(",
"customerID",
")",
",",
"j",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"else",
"if",
"status",
"!=",
"200",
"{",
"return",
"&",
"CustomerIOError",
"{",
"status",
",",
"c",
".",
"eventURL",
"(",
"customerID",
")",
",",
"responseBody",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
10,963 | all-10964 | [
"destroy",
"is",
"a",
"wrapper",
"around",
"cairo_surface_destroy",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Surface",
")",
"<mask>",
"(",
")",
"{",
"if",
"v",
".",
"surface",
"!=",
"nil",
"{",
"C",
".",
"cairo_surface_destroy",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"v",
".",
"surface",
"=",
"nil",
"\n",
"}",
"\n",
"}"
] |
10,964 | all-10965 | [
"Schema1FromComponents",
"creates",
"an",
"Schema1",
"manifest",
"instance",
"from",
"the",
"supplied",
"data",
"."
] | [
"func",
"Schema1FromComponents",
"(",
"ref",
"reference",
".",
"Named",
",",
"fsLayers",
"[",
"]",
"Schema1FSLayers",
",",
"history",
"[",
"]",
"Schema1History",
",",
"architecture",
"string",
")",
"(",
"*",
"Schema1",
",",
"error",
")",
"{",
"var",
"name",
",",
"tag",
"string",
"\n",
"if",
"ref",
"!=",
"nil",
"{",
"// Well, what to do if it _is_ nil? Most consumers actually don't use these fields nowadays, so we might as well try not supplying them.",
"name",
"=",
"reference",
".",
"Path",
"(",
"ref",
")",
"\n",
"if",
"tagged",
",",
"ok",
":=",
"ref",
".",
"(",
"reference",
".",
"NamedTagged",
")",
";",
"ok",
"{",
"tag",
"=",
"tagged",
".",
"Tag",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"s1",
":=",
"Schema1",
"{",
"Name",
":",
"name",
",",
"Tag",
":",
"tag",
",",
"Architecture",
":",
"architecture",
",",
"FSLayers",
":",
"fsLayers",
",",
"History",
":",
"<mask>",
",",
"SchemaVersion",
":",
"1",
",",
"}",
"\n",
"if",
"err",
":=",
"s1",
".",
"initialize",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"s1",
",",
"nil",
"\n",
"}"
] |
10,965 | all-10966 | [
"DefaultConfig",
"returns",
"a",
"Config",
"with",
"usable",
"defaults",
"."
] | [
"func",
"DefaultConfig",
"(",
")",
"*",
"Config",
"{",
"return",
"&",
"Config",
"{",
"ProtocolVersion",
":",
"ProtocolVersionMax",
",",
"HeartbeatTimeout",
":",
"1000",
"*",
"time",
".",
"Millisecond",
",",
"ElectionTimeout",
":",
"1000",
"*",
"<mask>",
".",
"Millisecond",
",",
"CommitTimeout",
":",
"50",
"*",
"time",
".",
"Millisecond",
",",
"MaxAppendEntries",
":",
"64",
",",
"ShutdownOnRemove",
":",
"true",
",",
"TrailingLogs",
":",
"10240",
",",
"SnapshotInterval",
":",
"120",
"*",
"time",
".",
"Second",
",",
"SnapshotThreshold",
":",
"8192",
",",
"LeaderLeaseTimeout",
":",
"500",
"*",
"time",
".",
"Millisecond",
",",
"LogLevel",
":",
"\"",
"\"",
",",
"}",
"\n",
"}"
] |
10,966 | all-10967 | [
"checkConstraints",
"determines",
"whether",
"build",
"constraints",
"are",
"satisfied",
"on",
"a",
"given",
"platform",
".",
"The",
"first",
"few",
"arguments",
"describe",
"the",
"platform",
".",
"genericTags",
"is",
"the",
"set",
"of",
"build",
"tags",
"that",
"are",
"true",
"on",
"all",
"platforms",
".",
"os",
"and",
"arch",
"are",
"the",
"platform",
"GOOS",
"and",
"GOARCH",
"strings",
".",
"If",
"os",
"or",
"arch",
"is",
"empty",
"checkConstraints",
"will",
"return",
"false",
"in",
"the",
"presence",
"of",
"OS",
"and",
"architecture",
"constraints",
"even",
"if",
"they",
"are",
"negated",
".",
"The",
"remaining",
"arguments",
"describe",
"the",
"file",
"being",
"tested",
".",
"All",
"of",
"these",
"may",
"be",
"empty",
"or",
"nil",
".",
"osSuffix",
"and",
"archSuffix",
"are",
"filename",
"suffixes",
".",
"fileTags",
"is",
"a",
"list",
"tags",
"from",
"+",
"build",
"comments",
"found",
"near",
"the",
"top",
"of",
"the",
"file",
".",
"cgoTags",
"is",
"an",
"extra",
"set",
"of",
"tags",
"in",
"a",
"#cgo",
"directive",
"."
] | [
"func",
"checkConstraints",
"(",
"c",
"*",
"config",
".",
"Config",
",",
"<mask>",
",",
"arch",
",",
"osSuffix",
",",
"archSuffix",
"string",
",",
"fileTags",
"[",
"]",
"tagLine",
",",
"cgoTags",
"tagLine",
")",
"bool",
"{",
"if",
"osSuffix",
"!=",
"\"",
"\"",
"&&",
"osSuffix",
"!=",
"os",
"||",
"archSuffix",
"!=",
"\"",
"\"",
"&&",
"archSuffix",
"!=",
"arch",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"l",
":=",
"range",
"fileTags",
"{",
"if",
"!",
"l",
".",
"check",
"(",
"c",
",",
"os",
",",
"arch",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"len",
"(",
"cgoTags",
")",
">",
"0",
"&&",
"!",
"cgoTags",
".",
"check",
"(",
"c",
",",
"os",
",",
"arch",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] |
10,967 | all-10968 | [
"===",
"resets",
"(",
"Matrix",
"ValueTypeMatrix",
")",
"Vector",
"==="
] | [
"func",
"funcResets",
"(",
"vals",
"[",
"]",
"Value",
",",
"args",
"Expressions",
",",
"enh",
"*",
"EvalNodeHelper",
")",
"<mask>",
"{",
"in",
":=",
"vals",
"[",
"0",
"]",
".",
"(",
"Matrix",
")",
"\n\n",
"for",
"_",
",",
"samples",
":=",
"range",
"in",
"{",
"resets",
":=",
"0",
"\n",
"prev",
":=",
"samples",
".",
"Points",
"[",
"0",
"]",
".",
"V",
"\n",
"for",
"_",
",",
"sample",
":=",
"range",
"samples",
".",
"Points",
"[",
"1",
":",
"]",
"{",
"current",
":=",
"sample",
".",
"V",
"\n",
"if",
"current",
"<",
"prev",
"{",
"resets",
"++",
"\n",
"}",
"\n",
"prev",
"=",
"current",
"\n",
"}",
"\n\n",
"enh",
".",
"out",
"=",
"append",
"(",
"enh",
".",
"out",
",",
"Sample",
"{",
"Point",
":",
"Point",
"{",
"V",
":",
"float64",
"(",
"resets",
")",
"}",
",",
"}",
")",
"\n",
"}",
"\n",
"return",
"enh",
".",
"out",
"\n",
"}"
] |
10,968 | all-10969 | [
"GetType",
"gets",
"the",
"type",
"for",
"the",
"specified",
"name"
] | [
"func",
"(",
"f",
"*",
"defaultFormats",
")",
"GetType",
"(",
"name",
"string",
")",
"(",
"reflect",
".",
"Type",
",",
"bool",
")",
"{",
"f",
".",
"Lock",
"(",
")",
"\n",
"defer",
"f",
".",
"Unlock",
"(",
")",
"\n",
"nme",
":=",
"f",
".",
"normalizeName",
"(",
"name",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"f",
".",
"data",
"{",
"if",
"v",
".",
"Name",
"==",
"nme",
"{",
"return",
"v",
".",
"Type",
",",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
",",
"<mask>",
"\n",
"}"
] |
10,969 | all-10970 | [
"Start",
"starts",
"a",
"timer",
"with",
"the",
"given",
"duration",
"for",
"the",
"specified",
"ID",
"."
] | [
"func",
"(",
"rt",
"*",
"relayTimer",
")",
"Start",
"(",
"d",
"<mask>",
".",
"Duration",
",",
"items",
"*",
"relayItems",
",",
"id",
"uint32",
",",
"isOriginator",
"bool",
")",
"{",
"rt",
".",
"verifyNotReleased",
"(",
")",
"\n",
"if",
"rt",
".",
"active",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"rt",
".",
"active",
"=",
"true",
"\n",
"rt",
".",
"items",
"=",
"items",
"\n",
"rt",
".",
"id",
"=",
"id",
"\n",
"rt",
".",
"isOriginator",
"=",
"isOriginator",
"\n\n",
"if",
"wasActive",
":=",
"rt",
".",
"timer",
".",
"Reset",
"(",
"d",
")",
";",
"wasActive",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] |
10,970 | all-10971 | [
"WithMessage",
"the",
"message",
"to",
"display",
"also",
"triggers",
"resume",
"and",
"step",
"over",
"controls",
"."
] | [
"func",
"(",
"p",
"SetPausedInDebuggerMessageParams",
")",
"WithMessage",
"(",
"message",
"string",
")",
"*",
"SetPausedInDebuggerMessageParams",
"{",
"p",
".",
"<mask>",
"=",
"message",
"\n",
"return",
"&",
"p",
"\n",
"}"
] |
10,971 | all-10972 | [
"HasReadOnly",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"d",
"*",
"Dashboard",
")",
"HasReadOnly",
"(",
")",
"bool",
"{",
"if",
"d",
"!=",
"nil",
"&&",
"d",
".",
"ReadOnly",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
10,972 | all-10973 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"ScreenshotParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoHeadlessexperimental",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
] |
10,973 | all-10974 | [
"KeepUpdated",
"is",
"a",
"task",
"that",
"continuously",
"monitor",
"this",
"node",
"s",
"version",
"to",
"see",
"it",
"it",
"s",
"out",
"of",
"date",
"with",
"respect",
"to",
"other",
"nodes",
".",
"In",
"the",
"node",
"is",
"out",
"of",
"date",
"and",
"the",
"LXD_CLUSTER_UPDATE",
"environment",
"variable",
"is",
"set",
"then",
"the",
"task",
"executes",
"the",
"executable",
"that",
"the",
"variable",
"is",
"pointing",
"at",
"."
] | [
"func",
"KeepUpdated",
"(",
"<mask>",
"*",
"state",
".",
"State",
")",
"(",
"task",
".",
"Func",
",",
"task",
".",
"Schedule",
")",
"{",
"f",
":=",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"ch",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"maybeUpdate",
"(",
"state",
")",
"\n",
"close",
"(",
"ch",
")",
"\n",
"}",
"(",
")",
"\n",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"case",
"<-",
"ch",
":",
"}",
"\n",
"}",
"\n\n",
"schedule",
":=",
"task",
".",
"Every",
"(",
"5",
"*",
"time",
".",
"Minute",
")",
"\n\n",
"return",
"f",
",",
"schedule",
"\n",
"}"
] |
10,974 | all-10975 | [
"EndOfYear",
"end",
"of",
"year"
] | [
"func",
"(",
"now",
"*",
"Now",
")",
"EndOfYear",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"<mask>",
".",
"BeginningOfYear",
"(",
")",
".",
"AddDate",
"(",
"1",
",",
"0",
",",
"0",
")",
".",
"Add",
"(",
"-",
"time",
".",
"Nanosecond",
")",
"\n",
"}"
] |
10,975 | all-10976 | [
"ReadBinary",
"wraps",
"binary",
".",
"Read",
"with",
"a",
"CountingReader",
"and",
"returns",
"the",
"acutal",
"bytes",
"read",
"by",
"it",
"."
] | [
"func",
"ReadBinary",
"(",
"r",
"io",
".",
"Reader",
",",
"order",
"binary",
".",
"ByteOrder",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"countingReader",
":=",
"CountingReader",
"{",
"Reader",
":",
"r",
"}",
"\n",
"err",
"=",
"binary",
".",
"Read",
"(",
"&",
"countingReader",
",",
"<mask>",
",",
"data",
")",
"\n",
"return",
"countingReader",
".",
"BytesRead",
",",
"err",
"\n",
"}"
] |
10,976 | all-10977 | [
"MustGet",
"returns",
"the",
"value",
"of",
"the",
"given",
"field",
".",
"MustGet",
"will",
"panic",
"if",
"no",
"field",
"has",
"been",
"found",
"."
] | [
"func",
"(",
"b",
"*",
"Base",
")",
"MustGet",
"(",
"name",
"string",
")",
"interface",
"{",
"}",
"{",
"// find field",
"field",
":=",
"b",
".",
"meta",
".",
"Fields",
"[",
"name",
"]",
"\n",
"if",
"field",
"==",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"`coal: field \"%s\" not found on \"%s\"`",
",",
"name",
",",
"b",
".",
"meta",
".",
"<mask>",
")",
")",
"\n",
"}",
"\n\n",
"// read value from model struct",
"structField",
":=",
"reflect",
".",
"ValueOf",
"(",
"b",
".",
"model",
")",
".",
"Elem",
"(",
")",
".",
"Field",
"(",
"field",
".",
"index",
")",
"\n",
"return",
"structField",
".",
"Interface",
"(",
")",
"\n",
"}"
] |
10,977 | all-10978 | [
"SetKnownStatus",
"sets",
"the",
"known",
"status",
"of",
"the",
"container",
"and",
"update",
"the",
"container",
"applied",
"status"
] | [
"func",
"(",
"c",
"*",
"Container",
")",
"SetKnownStatus",
"(",
"status",
"apicontainerstatus",
".",
"ContainerStatus",
")",
"{",
"c",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"c",
".",
"KnownStatusUnsafe",
"=",
"status",
"\n",
"c",
".",
"updateAppliedStatusUnsafe",
"(",
"<mask>",
")",
"\n",
"}"
] |
10,978 | all-10979 | [
"Okln",
"logs",
"a",
"line",
"with",
"an",
"OK",
"prefix",
"."
] | [
"func",
"(",
"l",
"*",
"logger",
")",
"Okln",
"(",
"vals",
"...",
"<mask>",
"{",
"}",
")",
"{",
"l",
".",
"mut",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"mut",
".",
"Unlock",
"(",
")",
"\n",
"s",
":=",
"fmt",
".",
"Sprintln",
"(",
"vals",
"...",
")",
"\n",
"l",
".",
"logger",
".",
"Output",
"(",
"2",
",",
"\"",
"\"",
"+",
"s",
")",
"\n",
"l",
".",
"callHandlers",
"(",
"LevelOK",
",",
"s",
")",
"\n",
"}"
] |
10,979 | all-10980 | [
"GetName",
"returns",
"the",
"Name",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"d",
"*",
"DashboardList",
")",
"GetName",
"(",
")",
"string",
"{",
"if",
"d",
"==",
"nil",
"||",
"d",
".",
"<mask>",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"d",
".",
"Name",
"\n",
"}"
] |
10,980 | all-10981 | [
"SetActive",
"is",
"a",
"wrapper",
"around",
"gtk_cell_renderer_toggle_set_active",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"CellRendererToggle",
")",
"SetActive",
"(",
"active",
"bool",
")",
"{",
"C",
".",
"gtk_cell_renderer_toggle_set_active",
"(",
"v",
".",
"native",
"(",
")",
",",
"gbool",
"(",
"<mask>",
")",
")",
"\n",
"}"
] |
10,981 | all-10982 | [
"MergeRoutes",
"returns",
"a",
"slice",
"with",
"all",
"routes",
"returned",
"by",
"Routable",
"objects",
"."
] | [
"func",
"MergeRoutes",
"(",
"r",
"...",
"Routable",
")",
"Routes",
"{",
"routes",
":=",
"make",
"(",
"Routes",
",",
"0",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"<mask>",
"r",
"{",
"routes",
"=",
"append",
"(",
"routes",
",",
"v",
".",
"Routes",
"(",
")",
"...",
")",
"\n",
"}",
"\n",
"return",
"routes",
"\n",
"}"
] |
10,982 | all-10983 | [
"ShorthandInput",
"renders",
"a",
"pps",
".",
"Input",
"as",
"a",
"short",
"readable",
"string"
] | [
"func",
"ShorthandInput",
"(",
"input",
"*",
"ppsclient",
".",
"Input",
")",
"string",
"{",
"switch",
"{",
"case",
"input",
"==",
"nil",
":",
"return",
"\"",
"\"",
"\n",
"case",
"input",
".",
"Pfs",
"!=",
"nil",
":",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"input",
".",
"Pfs",
".",
"Repo",
",",
"input",
".",
"Pfs",
".",
"Glob",
")",
"\n",
"case",
"input",
".",
"Cross",
"!=",
"nil",
":",
"var",
"subInput",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"input",
":=",
"range",
"input",
".",
"Cross",
"{",
"subInput",
"=",
"append",
"(",
"subInput",
",",
"ShorthandInput",
"(",
"input",
")",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"+",
"strings",
".",
"Join",
"(",
"subInput",
",",
"\"",
" ",
"+",
"\"",
"\"",
"",
"\n",
"case",
"input",
".",
"Union",
"!=",
"nil",
":",
"var",
"subInput",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"input",
":=",
"range",
"input",
".",
"Union",
"{",
"subInput",
"=",
"append",
"(",
"subInput",
",",
"ShorthandInput",
"(",
"input",
")",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"+",
"strings",
".",
"Join",
"(",
"subInput",
",",
"\"",
" ",
"+",
"\"",
"\"",
"",
"\n",
"case",
"<mask>",
".",
"Cron",
"!=",
"nil",
":",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"input",
".",
"Cron",
".",
"Name",
",",
"input",
".",
"Cron",
".",
"Spec",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
10,983 | all-10984 | [
"StartNode",
"returns",
"a",
"new",
"Node",
"given",
"configuration",
"and",
"a",
"list",
"of",
"raft",
"peers",
".",
"It",
"appends",
"a",
"ConfChangeAddNode",
"entry",
"for",
"each",
"given",
"peer",
"to",
"the",
"initial",
"log",
"."
] | [
"func",
"StartNode",
"(",
"c",
"*",
"Config",
",",
"peers",
"[",
"]",
"Peer",
")",
"Node",
"{",
"r",
":=",
"newRaft",
"(",
"c",
")",
"\n",
"// become the follower at term 1 and apply initial configuration",
"// entries of term 1",
"r",
".",
"becomeFollower",
"(",
"1",
",",
"None",
")",
"\n",
"for",
"_",
",",
"peer",
":=",
"range",
"peers",
"{",
"cc",
":=",
"pb",
".",
"ConfChange",
"{",
"Type",
":",
"pb",
".",
"ConfChangeAddNode",
",",
"NodeID",
":",
"peer",
".",
"ID",
",",
"Context",
":",
"peer",
".",
"Context",
"}",
"\n",
"d",
",",
"err",
":=",
"cc",
".",
"Marshal",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"e",
":=",
"pb",
".",
"Entry",
"{",
"Type",
":",
"pb",
".",
"EntryConfChange",
",",
"Term",
":",
"1",
",",
"Index",
":",
"r",
".",
"raftLog",
".",
"lastIndex",
"(",
")",
"+",
"1",
",",
"Data",
":",
"d",
"}",
"\n",
"r",
".",
"raftLog",
".",
"append",
"(",
"e",
")",
"\n",
"}",
"\n",
"// Mark these initial entries as committed.",
"// TODO(bdarnell): These entries are still unstable; do we need to preserve",
"// the invariant that committed < unstable?",
"r",
".",
"raftLog",
".",
"committed",
"=",
"r",
".",
"raftLog",
".",
"lastIndex",
"(",
")",
"\n",
"// Now apply them, mainly so that the application can call Campaign",
"// immediately after StartNode in tests. Note that these nodes will",
"// be added to raft twice: here and when the application's Ready",
"// loop calls ApplyConfChange. The calls to addNode must come after",
"// all calls to raftLog.append so progress.next is set after these",
"// bootstrapping entries (it is an error if we try to append these",
"// entries since they have already been committed).",
"// We do not set raftLog.applied so the application will be able",
"// to observe all conf changes via Ready.CommittedEntries.",
"for",
"_",
",",
"peer",
":=",
"range",
"peers",
"{",
"r",
".",
"addNode",
"(",
"peer",
".",
"ID",
")",
"\n",
"}",
"\n\n",
"n",
":=",
"newNode",
"(",
")",
"\n",
"n",
".",
"logger",
"=",
"c",
".",
"Logger",
"\n",
"<mask>",
"n",
".",
"run",
"(",
"r",
")",
"\n",
"return",
"&",
"n",
"\n",
"}"
] |
10,984 | all-10985 | [
"RecordDigestUncompressedPair",
"records",
"that",
"the",
"uncompressed",
"version",
"of",
"anyDigest",
"is",
"uncompressed",
".",
"It’s",
"allowed",
"for",
"anyDigest",
"==",
"uncompressed",
".",
"WARNING",
":",
"Only",
"call",
"this",
"for",
"LOCALLY",
"VERIFIED",
"data",
";",
"don’t",
"record",
"a",
"digest",
"pair",
"just",
"because",
"some",
"remote",
"author",
"claims",
"so",
"(",
"e",
".",
"g",
".",
"because",
"a",
"manifest",
"/",
"config",
"pair",
"exists",
")",
";",
"otherwise",
"the",
"cache",
"could",
"be",
"poisoned",
"and",
"allow",
"substituting",
"unexpected",
"blobs",
".",
"(",
"Eventually",
"the",
"DiffIDs",
"in",
"image",
"config",
"could",
"detect",
"the",
"substitution",
"but",
"that",
"may",
"be",
"too",
"late",
"and",
"not",
"all",
"image",
"formats",
"contain",
"that",
"data",
".",
")"
] | [
"func",
"(",
"bdc",
"*",
"cache",
")",
"RecordDigestUncompressedPair",
"(",
"anyDigest",
"digest",
".",
"Digest",
",",
"uncompressed",
"digest",
".",
"Digest",
")",
"{",
"_",
"=",
"bdc",
".",
"update",
"(",
"func",
"(",
"tx",
"*",
"bolt",
".",
"Tx",
")",
"error",
"{",
"b",
",",
"err",
":=",
"tx",
".",
"CreateBucketIfNotExists",
"(",
"uncompressedDigestBucket",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"key",
":=",
"[",
"]",
"byte",
"(",
"anyDigest",
".",
"String",
"(",
")",
")",
"\n",
"if",
"previousBytes",
":=",
"b",
".",
"Get",
"(",
"key",
")",
";",
"previousBytes",
"!=",
"nil",
"{",
"previous",
",",
"err",
":=",
"digest",
".",
"Parse",
"(",
"string",
"(",
"previousBytes",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"previous",
"!=",
"uncompressed",
"{",
"logrus",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"anyDigest",
",",
"previous",
",",
"uncompressed",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"err",
":=",
"b",
".",
"Put",
"(",
"key",
",",
"[",
"]",
"byte",
"(",
"uncompressed",
".",
"String",
"(",
")",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"b",
",",
"err",
"=",
"tx",
".",
"CreateBucketIfNotExists",
"(",
"digestByUncompressedBucket",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"b",
",",
"err",
"=",
"b",
".",
"CreateBucketIfNotExists",
"(",
"[",
"]",
"byte",
"(",
"uncompressed",
".",
"String",
"(",
")",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
":=",
"b",
".",
"Put",
"(",
"[",
"]",
"byte",
"(",
"anyDigest",
".",
"<mask>",
"(",
")",
")",
",",
"[",
"]",
"byte",
"{",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"// Possibly writing the same []byte{} presence marker again.",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
")",
"// FIXME? Log error (but throttle the log volume on repeated accesses)?",
"\n",
"}"
] |
10,985 | all-10986 | [
"GetDashboardCountOk",
"returns",
"a",
"tuple",
"with",
"the",
"DashboardCount",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"d",
"*",
"DashboardList",
")",
"GetDashboardCountOk",
"(",
")",
"(",
"int",
",",
"bool",
")",
"{",
"if",
"d",
"==",
"nil",
"||",
"d",
".",
"DashboardCount",
"==",
"nil",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"d",
".",
"DashboardCount",
",",
"<mask>",
"\n",
"}"
] |
10,986 | all-10987 | [
"Adapter",
"return",
"an",
"adapter",
"as",
"storage",
".",
"Storage",
"."
] | [
"func",
"Adapter",
"(",
"db",
"*",
"tsdb",
".",
"DB",
",",
"startTimeMargin",
"int64",
")",
"storage",
".",
"<mask>",
"{",
"return",
"&",
"adapter",
"{",
"db",
":",
"db",
",",
"startTimeMargin",
":",
"startTimeMargin",
"}",
"\n",
"}"
] |
10,987 | all-10988 | [
"downcaseAllVolumePaths",
"forces",
"all",
"volume",
"paths",
"(",
"host",
"path",
"and",
"container",
"path",
")",
"to",
"be",
"lower",
"-",
"case",
".",
"This",
"is",
"to",
"account",
"for",
"Windows",
"case",
"-",
"insensitivity",
"and",
"the",
"case",
"-",
"sensitive",
"string",
"comparison",
"that",
"takes",
"place",
"elsewhere",
"in",
"the",
"code",
"."
] | [
"func",
"(",
"<mask>",
"*",
"Task",
")",
"downcaseAllVolumePaths",
"(",
")",
"{",
"for",
"_",
",",
"volume",
":=",
"range",
"task",
".",
"Volumes",
"{",
"if",
"hostVol",
",",
"ok",
":=",
"volume",
".",
"Volume",
".",
"(",
"*",
"taskresourcevolume",
".",
"FSHostVolume",
")",
";",
"ok",
"{",
"hostVol",
".",
"FSSourcePath",
"=",
"getCanonicalPath",
"(",
"hostVol",
".",
"FSSourcePath",
")",
"\n",
"}",
"\n",
"}",
"\n",
"for",
"_",
",",
"container",
":=",
"range",
"task",
".",
"Containers",
"{",
"for",
"i",
",",
"mountPoint",
":=",
"range",
"container",
".",
"MountPoints",
"{",
"// container.MountPoints is a slice of values, not a slice of pointers so",
"// we need to mutate the actual value instead of the copied value",
"container",
".",
"MountPoints",
"[",
"i",
"]",
".",
"ContainerPath",
"=",
"getCanonicalPath",
"(",
"mountPoint",
".",
"ContainerPath",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
10,988 | all-10989 | [
"ContainerConfigClear",
"removes",
"any",
"config",
"associated",
"with",
"the",
"container",
"with",
"the",
"given",
"ID",
"."
] | [
"func",
"ContainerConfigClear",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"id",
"int",
")",
"error",
"{",
"_",
",",
"err",
":=",
"tx",
".",
"Exec",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"tx",
".",
"Exec",
"(",
"\"",
"\"",
",",
"<mask>",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"tx",
".",
"Exec",
"(",
"`DELETE FROM containers_devices_config WHERE id IN\n\t\t(SELECT containers_devices_config.id\n\t\t FROM containers_devices_config JOIN containers_devices\n\t\t ON containers_devices_config.container_device_id=containers_devices.id\n\t\t WHERE containers_devices.container_id=?)`",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"tx",
".",
"Exec",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
10,989 | all-10990 | [
"NewMockECSSubmitStateSDK",
"creates",
"a",
"new",
"mock",
"instance"
] | [
"func",
"NewMockECSSubmitStateSDK",
"(",
"ctrl",
"*",
"gomock",
".",
"<mask>",
")",
"*",
"MockECSSubmitStateSDK",
"{",
"mock",
":=",
"&",
"MockECSSubmitStateSDK",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockECSSubmitStateSDKMockRecorder",
"{",
"mock",
"}",
"\n",
"return",
"mock",
"\n",
"}"
] |
10,990 | all-10991 | [
"findTenantID",
"figures",
"out",
"the",
"AAD",
"tenant",
"ID",
"of",
"the",
"subscription",
"by",
"making",
"an",
"unauthenticated",
"request",
"to",
"the",
"Get",
"Subscription",
"Details",
"endpoint",
"and",
"parses",
"the",
"value",
"from",
"WWW",
"-",
"Authenticate",
"header",
"."
] | [
"func",
"findTenantID",
"(",
"env",
"azure",
".",
"Environment",
",",
"subscriptionID",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"const",
"hdrKey",
"=",
"\"",
"\"",
"\n",
"c",
":=",
"subscriptionsClient",
"(",
"env",
".",
"ResourceManagerEndpoint",
")",
"\n\n",
"// we expect this request to fail (err != nil), but we are only interested",
"// in headers, so surface the error if the Response is not present (i.e.",
"// network error etc)",
"subs",
",",
"err",
":=",
"c",
".",
"Get",
"(",
"subscriptionID",
")",
"\n",
"if",
"subs",
".",
"Response",
".",
"<mask>",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"// Expecting 401 StatusUnauthorized here, just read the header",
"if",
"subs",
".",
"StatusCode",
"!=",
"http",
".",
"StatusUnauthorized",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"hdr",
":=",
"subs",
".",
"Header",
".",
"Get",
"(",
"hdrKey",
")",
"\n",
"if",
"hdr",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"hdrKey",
")",
"\n",
"}",
"\n\n",
"// Example value for hdr:",
"// Bearer authorization_uri=\"https://login.windows.net/996fe9d1-6171-40aa-945b-4c64b63bf655\", error=\"invalid_token\", error_description=\"The authentication failed because of missing 'Authorization' header.\"",
"r",
":=",
"regexp",
".",
"MustCompile",
"(",
"`authorization_uri=\".*/([0-9a-f\\-]+)\"`",
")",
"\n",
"m",
":=",
"r",
".",
"FindStringSubmatch",
"(",
"hdr",
")",
"\n",
"if",
"m",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"hdrKey",
",",
"hdr",
")",
"\n",
"}",
"\n",
"return",
"m",
"[",
"1",
"]",
",",
"nil",
"\n",
"}"
] |
10,991 | all-10992 | [
"StripTags",
"strips",
"all",
"of",
"the",
"html",
"tags",
"or",
"tags",
"specified",
"by",
"the",
"parameters"
] | [
"func",
"StripTags",
"(",
"s",
"string",
",",
"tags",
"...",
"string",
")",
"string",
"{",
"if",
"len",
"(",
"tags",
")",
"==",
"0",
"{",
"tags",
"=",
"append",
"(",
"tags",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"<mask>",
":=",
"range",
"tags",
"{",
"stripTagsRe",
":=",
"regexp",
".",
"MustCompile",
"(",
"`(?i)<\\/?`",
"+",
"tag",
"+",
"`[^<>]*>`",
")",
"\n",
"s",
"=",
"stripTagsRe",
".",
"ReplaceAllString",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"s",
"\n",
"}"
] |
10,992 | all-10993 | [
"SetValue",
"is",
"a",
"wrapper",
"around",
"gtk_list_store_set_value",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"ListStore",
")",
"SetValue",
"(",
"iter",
"*",
"TreeIter",
",",
"column",
"int",
",",
"<mask>",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"value",
".",
"(",
"type",
")",
"{",
"case",
"*",
"gdk",
".",
"Pixbuf",
":",
"pix",
":=",
"value",
".",
"(",
"*",
"gdk",
".",
"Pixbuf",
")",
"\n",
"C",
".",
"_gtk_list_store_set",
"(",
"v",
".",
"native",
"(",
")",
",",
"iter",
".",
"native",
"(",
")",
",",
"C",
".",
"gint",
"(",
"column",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"pix",
".",
"Native",
"(",
")",
")",
")",
"\n\n",
"default",
":",
"gv",
",",
"err",
":=",
"glib",
".",
"GValue",
"(",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"C",
".",
"gtk_list_store_set_value",
"(",
"v",
".",
"native",
"(",
")",
",",
"iter",
".",
"native",
"(",
")",
",",
"C",
".",
"gint",
"(",
"column",
")",
",",
"(",
"*",
"C",
".",
"GValue",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"gv",
".",
"Native",
"(",
")",
")",
")",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
10,993 | all-10994 | [
"CalcHash256",
"returns",
"the",
"sha256",
"(",
"sha256",
"(",
"data",
"))",
"."
] | [
"func",
"CalcHash256",
"(",
"data",
"[",
"]",
"byte",
")",
"[",
"]",
"<mask>",
"{",
"return",
"CalcHash",
"(",
"CalcHash",
"(",
"data",
",",
"sha256",
".",
"New",
"(",
")",
")",
",",
"sha256",
".",
"New",
"(",
")",
")",
"\n",
"}"
] |
10,994 | all-10995 | [
"Locator",
"returns",
"a",
"locator",
"for",
"the",
"given",
"resource"
] | [
"func",
"(",
"r",
"*",
"AuditEntry",
")",
"Locator",
"(",
"api",
"*",
"API",
")",
"*",
"AuditEntryLocator",
"{",
"for",
"_",
",",
"l",
":=",
"<mask>",
"r",
".",
"Links",
"{",
"if",
"l",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"{",
"return",
"api",
".",
"AuditEntryLocator",
"(",
"l",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,995 | all-10996 | [
"StringStripHTMLTags",
"strips",
"HTML",
"/",
"XML",
"tags",
"from",
"text",
"."
] | [
"func",
"StringStripHTMLTags",
"(",
"text",
"string",
")",
"(",
"plainText",
"string",
")",
"{",
"var",
"buf",
"*",
"bytes",
".",
"Buffer",
"\n",
"tagClose",
":=",
"-",
"1",
"\n",
"tagStart",
":=",
"-",
"1",
"\n",
"for",
"i",
",",
"char",
":=",
"range",
"text",
"{",
"if",
"char",
"==",
"'<'",
"{",
"if",
"buf",
"==",
"nil",
"{",
"buf",
"=",
"bytes",
".",
"NewBufferString",
"(",
"text",
")",
"\n",
"buf",
".",
"Reset",
"(",
")",
"\n",
"}",
"\n",
"buf",
".",
"WriteString",
"(",
"text",
"[",
"tagClose",
"+",
"1",
":",
"i",
"]",
")",
"\n",
"tagStart",
"=",
"i",
"\n",
"}",
"else",
"if",
"char",
"==",
"'>'",
"&&",
"tagStart",
"!=",
"-",
"1",
"{",
"tagClose",
"=",
"i",
"\n",
"tagStart",
"=",
"-",
"1",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"buf",
"==",
"nil",
"{",
"return",
"text",
"\n",
"}",
"\n",
"buf",
".",
"WriteString",
"(",
"<mask>",
"[",
"tagClose",
"+",
"1",
":",
"]",
")",
"\n",
"return",
"buf",
".",
"String",
"(",
")",
"\n",
"}"
] |
10,996 | all-10997 | [
"SessionInit",
"初始化并加载session中间件"
] | [
"func",
"SessionInit",
"(",
"expire",
"time",
".",
"Duration",
",",
"pool",
"*",
"conn",
".",
"RedisPool",
",",
"<mask>",
"http",
".",
"Cookie",
")",
"{",
"sessExpire",
"=",
"expire",
"\n",
"redisPool",
"=",
"pool",
"\n",
"httpCookie",
"=",
"cookie",
"\n",
"httpCookie",
".",
"MaxAge",
"=",
"int",
"(",
"sessExpire",
".",
"Seconds",
"(",
")",
")",
"\n",
"Use",
"(",
"session",
")",
"\n",
"}"
] |
10,997 | all-10998 | [
"GetStoragePoolVolume",
"returns",
"a",
"StorageVolume",
"entry",
"for",
"the",
"provided",
"pool",
"and",
"volume",
"name"
] | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"GetStoragePoolVolume",
"(",
"pool",
"string",
",",
"volType",
"string",
",",
"name",
"string",
")",
"(",
"*",
"api",
".",
"StorageVolume",
",",
"string",
",",
"error",
")",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"",
"\"",
")",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"volume",
":=",
"api",
".",
"StorageVolume",
"{",
"}",
"\n\n",
"// Fetch the raw value",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"<mask>",
".",
"QueryEscape",
"(",
"pool",
")",
",",
"url",
".",
"QueryEscape",
"(",
"volType",
")",
",",
"url",
".",
"QueryEscape",
"(",
"name",
")",
")",
"\n",
"etag",
",",
"err",
":=",
"r",
".",
"queryStruct",
"(",
"\"",
"\"",
",",
"path",
",",
"nil",
",",
"\"",
"\"",
",",
"&",
"volume",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"volume",
",",
"etag",
",",
"nil",
"\n",
"}"
] |
10,998 | all-10999 | [
"After",
"is",
"for",
"adding",
"middleware",
"for",
"running",
"after",
"routing"
] | [
"func",
"(",
"c4",
"*",
"Seefor",
")",
"After",
"(",
"middleware",
"...",
"After",
")",
"{",
"c4",
".",
"afters",
"=",
"<mask>",
"(",
"c4",
".",
"afters",
",",
"middleware",
"...",
")",
"\n",
"}"
] |
10,999 | all-11000 | [
"NewPipeConns",
"returns",
"new",
"bi",
"-",
"directional",
"connection",
"pipe",
"."
] | [
"func",
"NewPipeConns",
"(",
")",
"*",
"PipeConns",
"{",
"ch1",
":=",
"make",
"(",
"chan",
"*",
"byteBuffer",
",",
"4",
")",
"\n",
"ch2",
":=",
"make",
"(",
"chan",
"*",
"byteBuffer",
",",
"4",
")",
"\n\n",
"pc",
":=",
"&",
"PipeConns",
"{",
"stopCh",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"pc",
".",
"c1",
".",
"rCh",
"=",
"ch1",
"\n",
"pc",
".",
"c1",
".",
"wCh",
"=",
"ch2",
"\n",
"pc",
".",
"c2",
".",
"rCh",
"=",
"ch2",
"\n",
"<mask>",
".",
"c2",
".",
"wCh",
"=",
"ch1",
"\n",
"pc",
".",
"c1",
".",
"pc",
"=",
"pc",
"\n",
"pc",
".",
"c2",
".",
"pc",
"=",
"pc",
"\n",
"return",
"pc",
"\n",
"}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.