id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
listlengths 1
418
| pl_tokens
listlengths 22
4.98k
|
---|---|---|---|
17,500 | all-17501 | [
"See",
"also",
"feature",
"request",
"for",
"golang",
"reflect",
"pkg",
"at"
]
| [
"func",
"isEmptyValue",
"(",
"i",
"interface",
"{",
"}",
")",
"bool",
"{",
"<mask>",
"v",
":=",
"i",
".",
"(",
"type",
")",
"{",
"case",
"[",
"]",
"interface",
"{",
"}",
":",
"return",
"len",
"(",
"v",
")",
"==",
"0",
"\n",
"case",
"[",
"]",
"string",
":",
"return",
"len",
"(",
"v",
")",
"==",
"0",
"\n",
"case",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
":",
"return",
"len",
"(",
"v",
")",
"==",
"0",
"\n",
"case",
"bool",
":",
"return",
"!",
"v",
"\n",
"case",
"float64",
":",
"return",
"v",
"==",
"0",
"\n",
"case",
"int64",
":",
"return",
"v",
"==",
"0",
"\n",
"case",
"string",
":",
"return",
"v",
"==",
"\"",
"\"",
"\n",
"case",
"nil",
":",
"return",
"true",
"\n",
"default",
":",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
",",
"i",
")",
")",
"\n",
"}",
"\n",
"}"
]
|
17,501 | all-17502 | [
"Fill",
"fills",
"the",
"image",
"with",
"a",
"solid",
"color",
".",
"When",
"the",
"image",
"is",
"disposed",
"Fill",
"does",
"nothing",
".",
"Fill",
"always",
"returns",
"nil",
"as",
"of",
"1",
".",
"5",
".",
"0",
"-",
"alpha",
"."
]
| [
"func",
"(",
"i",
"*",
"<mask>",
")",
"Fill",
"(",
"clr",
"color",
".",
"Color",
")",
"error",
"{",
"i",
".",
"copyCheck",
"(",
")",
"\n",
"if",
"i",
".",
"isDisposed",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// TODO: Implement this.",
"if",
"i",
".",
"isSubImage",
"(",
")",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"i",
".",
"resolvePendingPixels",
"(",
"false",
")",
"\n\n",
"r16",
",",
"g16",
",",
"b16",
",",
"a16",
":=",
"clr",
".",
"RGBA",
"(",
")",
"\n",
"r",
",",
"g",
",",
"b",
",",
"a",
":=",
"uint8",
"(",
"r16",
">>",
"8",
")",
",",
"uint8",
"(",
"g16",
">>",
"8",
")",
",",
"uint8",
"(",
"b16",
">>",
"8",
")",
",",
"uint8",
"(",
"a16",
">>",
"8",
")",
"\n",
"i",
".",
"mipmap",
".",
"original",
"(",
")",
".",
"Fill",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
")",
"\n",
"i",
".",
"disposeMipmaps",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,502 | all-17503 | [
"Do",
"executes",
"ServiceWorker",
".",
"stopAllWorkers",
"against",
"the",
"provided",
"context",
"."
]
| [
"func",
"(",
"p",
"*",
"StopAllWorkersParams",
")",
"Do",
"(",
"ctx",
"context",
".",
"<mask>",
")",
"(",
"err",
"error",
")",
"{",
"return",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandStopAllWorkers",
",",
"nil",
",",
"nil",
")",
"\n",
"}"
]
|
17,503 | all-17504 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"FailRequestParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoFetch7",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
]
|
17,504 | all-17505 | [
"SliceInterfacesToManagedObjectReferences",
"converts",
"an",
"interface",
"slice",
"into",
"a",
"slice",
"of",
"ManagedObjectReferences",
"with",
"the",
"type",
"of",
"t",
"."
]
| [
"func",
"SliceInterfacesToManagedObjectReferences",
"(",
"s",
"[",
"]",
"interface",
"{",
"}",
",",
"t",
"string",
")",
"[",
"]",
"types",
".",
"ManagedObjectReference",
"{",
"var",
"d",
"[",
"]",
"types",
".",
"ManagedObjectReference",
"\n",
"for",
"_",
",",
"v",
":=",
"<mask>",
"s",
"{",
"d",
"=",
"append",
"(",
"d",
",",
"types",
".",
"ManagedObjectReference",
"{",
"Type",
":",
"t",
",",
"Value",
":",
"v",
".",
"(",
"string",
")",
",",
"}",
")",
"\n",
"}",
"\n",
"return",
"d",
"\n",
"}"
]
|
17,505 | all-17506 | [
"WriteLocalAssets",
"writes",
"assets",
"to",
"a",
"local",
"backend",
"."
]
| [
"func",
"WriteLocalAssets",
"(",
"encoder",
"Encoder",
",",
"opts",
"*",
"AssetOpts",
",",
"hostPath",
"string",
")",
"<mask>",
"{",
"if",
"err",
":=",
"WriteAssets",
"(",
"encoder",
",",
"opts",
",",
"localBackend",
",",
"localBackend",
",",
"1",
"/* = volume size (gb) */",
",",
"hostPath",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"secretErr",
":=",
"WriteSecret",
"(",
"encoder",
",",
"LocalSecret",
"(",
")",
",",
"opts",
")",
";",
"secretErr",
"!=",
"nil",
"{",
"return",
"secretErr",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,506 | all-17507 | [
"PushMetrics",
"sends",
"the",
"metrics",
"collected",
"to",
"the",
"prometheus",
"push",
"gateway",
"at",
"the",
"url",
"in",
"gatewayURL",
"with",
"the",
"job",
"name",
"of",
"task",
"Should",
"be",
"called",
"in",
"a",
"defer",
"in",
"main",
"()",
"of",
"a",
"cli",
"application",
".",
"For",
"long",
"-",
"running",
"services",
"use",
"ServeMetrics",
"instead"
]
| [
"func",
"PushMetrics",
"(",
"ctx",
"context",
".",
"Context",
",",
"task",
"string",
",",
"gatewayURL",
"string",
")",
"{",
"if",
"err",
":=",
"<mask>",
".",
"Collectors",
"(",
"task",
",",
"push",
".",
"HostnameGroupingKey",
"(",
")",
",",
"gatewayURL",
",",
"histograms",
",",
"counts",
",",
"errcounts",
",",
")",
";",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}"
]
|
17,507 | all-17508 | [
"ResolveContainer",
"indicates",
"an",
"expected",
"call",
"of",
"ResolveContainer"
]
| [
"func",
"(",
"mr",
"*",
"MockContainerMetadataResolverMockRecorder",
")",
"ResolveContainer",
"(",
"arg0",
"<mask>",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
"TypeOf",
"(",
"(",
"*",
"MockContainerMetadataResolver",
")",
"(",
"nil",
")",
".",
"ResolveContainer",
")",
",",
"arg0",
")",
"\n",
"}"
]
|
17,508 | all-17509 | [
"Take",
"retreives",
"just",
"the",
"first",
"n",
"elements",
"from",
"an",
"Enumerator",
"."
]
| [
"func",
"(",
"iter",
"Enumerator",
")",
"Take",
"(",
"n",
"uint",
")",
"Enumerator",
"{",
"results",
":=",
"make",
"(",
"chan",
"interface",
"{",
"}",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"defer",
"close",
"(",
"results",
")",
"\n",
"i",
":=",
"uint",
"(",
"0",
")",
"\n",
"for",
"entry",
":=",
"range",
"iter",
"{",
"if",
"i",
">=",
"n",
"{",
"return",
"\n",
"}",
"\n",
"i",
"++",
"\n",
"results",
"<-",
"entry",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"return",
"<mask>",
"\n",
"}"
]
|
17,509 | all-17510 | [
"prepare",
"injects",
"t",
"s",
"id",
"onto",
"txn",
"-",
"queue",
"for",
"all",
"affected",
"documents",
"and",
"collects",
"the",
"current",
"txn",
"-",
"queue",
"and",
"txn",
"-",
"revno",
"values",
"during",
"the",
"process",
".",
"If",
"the",
"prepared",
"txn",
"-",
"queue",
"indicates",
"that",
"there",
"are",
"pre",
"-",
"requisite",
"transactions",
"to",
"be",
"applied",
"and",
"the",
"force",
"parameter",
"is",
"false",
"errPreReqs",
"will",
"be",
"returned",
".",
"Otherwise",
"the",
"current",
"tip",
"revision",
"numbers",
"for",
"all",
"the",
"documents",
"are",
"returned",
"."
]
| [
"func",
"(",
"f",
"*",
"flusher",
")",
"prepare",
"(",
"t",
"*",
"transaction",
",",
"force",
"bool",
")",
"(",
"revnos",
"[",
"]",
"int64",
",",
"err",
"error",
")",
"{",
"if",
"t",
".",
"State",
"!=",
"tpreparing",
"{",
"return",
"f",
".",
"rescan",
"(",
"t",
",",
"force",
")",
"\n",
"}",
"\n",
"f",
".",
"debugf",
"(",
"\"",
"\"",
",",
"t",
")",
"\n\n",
"// dkeys being sorted means stable iteration across all runners. This",
"// isn't strictly required, but reduces the chances of cycles.",
"dkeys",
":=",
"t",
".",
"docKeys",
"(",
")",
"\n\n",
"revno",
":=",
"make",
"(",
"map",
"[",
"docKey",
"]",
"int64",
")",
"\n",
"<mask>",
":=",
"txnInfo",
"{",
"}",
"\n",
"tt",
":=",
"tokenFor",
"(",
"t",
")",
"\n",
"NextDoc",
":",
"for",
"_",
",",
"dkey",
":=",
"range",
"dkeys",
"{",
"change",
":=",
"mgo",
".",
"Change",
"{",
"Update",
":",
"bson",
".",
"D",
"{",
"{",
"\"",
"\"",
",",
"bson",
".",
"D",
"{",
"{",
"\"",
"\"",
",",
"tt",
"}",
"}",
"}",
"}",
",",
"ReturnNew",
":",
"true",
",",
"}",
"\n",
"c",
":=",
"f",
".",
"tc",
".",
"Database",
".",
"C",
"(",
"dkey",
".",
"C",
")",
"\n",
"cquery",
":=",
"c",
".",
"FindId",
"(",
"dkey",
".",
"Id",
")",
".",
"Select",
"(",
"txnFields",
")",
"\n\n",
"RetryDoc",
":",
"change",
".",
"Upsert",
"=",
"false",
"\n",
"chaos",
"(",
"\"",
"\"",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"cquery",
".",
"Apply",
"(",
"change",
",",
"&",
"info",
")",
";",
"err",
"==",
"nil",
"{",
"if",
"info",
".",
"Remove",
"==",
"\"",
"\"",
"{",
"// Fast path, unless workload is insert/remove heavy.",
"revno",
"[",
"dkey",
"]",
"=",
"info",
".",
"Revno",
"\n",
"f",
".",
"queue",
"[",
"dkey",
"]",
"=",
"info",
".",
"Queue",
"\n",
"f",
".",
"debugf",
"(",
"\"",
"\"",
",",
"dkey",
",",
"info",
".",
"Revno",
",",
"info",
".",
"Queue",
")",
"\n",
"continue",
"NextDoc",
"\n",
"}",
"else",
"{",
"// Handle remove in progress before preparing it.",
"if",
"err",
":=",
"f",
".",
"loadAndApply",
"(",
"info",
".",
"Remove",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"goto",
"RetryDoc",
"\n",
"}",
"\n",
"}",
"else",
"if",
"err",
"!=",
"mgo",
".",
"ErrNotFound",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Document missing. Use stash collection.",
"change",
".",
"Upsert",
"=",
"true",
"\n",
"chaos",
"(",
"\"",
"\"",
")",
"\n",
"_",
",",
"err",
":=",
"f",
".",
"sc",
".",
"FindId",
"(",
"dkey",
")",
".",
"Apply",
"(",
"change",
",",
"&",
"info",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"info",
".",
"Insert",
"!=",
"\"",
"\"",
"{",
"// Handle insert in progress before preparing it.",
"if",
"err",
":=",
"f",
".",
"loadAndApply",
"(",
"info",
".",
"Insert",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"goto",
"RetryDoc",
"\n",
"}",
"\n\n",
"// Must confirm stash is still in use and is the same one",
"// prepared, since applying a remove overwrites the stash.",
"docFound",
":=",
"false",
"\n",
"stashFound",
":=",
"false",
"\n",
"if",
"err",
"=",
"c",
".",
"FindId",
"(",
"dkey",
".",
"Id",
")",
".",
"Select",
"(",
"txnFields",
")",
".",
"One",
"(",
"&",
"info",
")",
";",
"err",
"==",
"nil",
"{",
"docFound",
"=",
"true",
"\n",
"}",
"else",
"if",
"err",
"!=",
"mgo",
".",
"ErrNotFound",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"else",
"if",
"err",
"=",
"f",
".",
"sc",
".",
"FindId",
"(",
"dkey",
")",
".",
"One",
"(",
"&",
"info",
")",
";",
"err",
"==",
"nil",
"{",
"stashFound",
"=",
"true",
"\n",
"if",
"info",
".",
"Revno",
"==",
"0",
"{",
"// Missing revno in the stash only happens when it",
"// has been upserted, in which case it defaults to -1.",
"// Txn-inserted documents get revno -1 while in the stash",
"// for the first time, and -revno-1 == 2 when they go live.",
"info",
".",
"Revno",
"=",
"-",
"1",
"\n",
"}",
"\n",
"}",
"else",
"if",
"err",
"!=",
"mgo",
".",
"ErrNotFound",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"docFound",
"&&",
"info",
".",
"Remove",
"==",
"\"",
"\"",
"||",
"stashFound",
"&&",
"info",
".",
"Insert",
"==",
"\"",
"\"",
"{",
"for",
"_",
",",
"dtt",
":=",
"range",
"info",
".",
"Queue",
"{",
"if",
"dtt",
"!=",
"tt",
"{",
"continue",
"\n",
"}",
"\n",
"// Found tt properly prepared.",
"if",
"stashFound",
"{",
"f",
".",
"debugf",
"(",
"\"",
"\"",
",",
"dkey",
",",
"info",
".",
"Revno",
",",
"info",
".",
"Queue",
")",
"\n",
"}",
"else",
"{",
"f",
".",
"debugf",
"(",
"\"",
"\"",
",",
"dkey",
",",
"info",
".",
"Revno",
",",
"info",
".",
"Queue",
")",
"\n",
"}",
"\n",
"revno",
"[",
"dkey",
"]",
"=",
"info",
".",
"Revno",
"\n",
"f",
".",
"queue",
"[",
"dkey",
"]",
"=",
"info",
".",
"Queue",
"\n",
"continue",
"NextDoc",
"\n",
"}",
"\n",
"}",
"\n\n",
"// The stash wasn't valid and tt got overwriten. Try again.",
"f",
".",
"unstashToken",
"(",
"tt",
",",
"dkey",
")",
"\n",
"goto",
"RetryDoc",
"\n",
"}",
"\n\n",
"// Save the prepared nonce onto t.",
"nonce",
":=",
"tt",
".",
"nonce",
"(",
")",
"\n",
"qdoc",
":=",
"bson",
".",
"D",
"{",
"{",
"\"",
"\"",
",",
"t",
".",
"Id",
"}",
",",
"{",
"\"",
"\"",
",",
"tpreparing",
"}",
"}",
"\n",
"udoc",
":=",
"bson",
".",
"D",
"{",
"{",
"\"",
"\"",
",",
"bson",
".",
"D",
"{",
"{",
"\"",
"\"",
",",
"tprepared",
"}",
",",
"{",
"\"",
"\"",
",",
"nonce",
"}",
"}",
"}",
"}",
"\n",
"chaos",
"(",
"\"",
"\"",
")",
"\n",
"err",
"=",
"f",
".",
"tc",
".",
"Update",
"(",
"qdoc",
",",
"udoc",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"t",
".",
"State",
"=",
"tprepared",
"\n",
"t",
".",
"Nonce",
"=",
"nonce",
"\n",
"}",
"else",
"if",
"err",
"==",
"mgo",
".",
"ErrNotFound",
"{",
"f",
".",
"debugf",
"(",
"\"",
"\"",
",",
"tt",
")",
"\n",
"if",
"err",
":=",
"f",
".",
"reload",
"(",
"t",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"else",
"if",
"t",
".",
"State",
"==",
"tpreparing",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"if",
"t",
".",
"State",
"!=",
"tprepared",
"{",
"return",
"t",
".",
"Revnos",
",",
"nil",
"\n",
"}",
"\n",
"tt",
"=",
"t",
".",
"token",
"(",
")",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"prereqs",
",",
"found",
":=",
"f",
".",
"hasPreReqs",
"(",
"tt",
",",
"dkeys",
")",
"\n",
"if",
"!",
"found",
"{",
"// Must only happen when reloading above.",
"return",
"f",
".",
"rescan",
"(",
"t",
",",
"force",
")",
"\n",
"}",
"else",
"if",
"prereqs",
"&&",
"!",
"force",
"{",
"f",
".",
"debugf",
"(",
"\"",
"\"",
",",
"tt",
")",
"\n",
"return",
"nil",
",",
"errPreReqs",
"\n",
"}",
"\n",
"revnos",
"=",
"assembledRevnos",
"(",
"t",
".",
"Ops",
",",
"revno",
")",
"\n",
"if",
"!",
"prereqs",
"{",
"f",
".",
"debugf",
"(",
"\"",
"\"",
",",
"tt",
",",
"revnos",
")",
"\n",
"}",
"else",
"{",
"f",
".",
"debugf",
"(",
"\"",
"\"",
",",
"tt",
",",
"revnos",
")",
"\n",
"}",
"\n",
"return",
"revnos",
",",
"nil",
"\n",
"}"
]
|
17,510 | all-17511 | [
"/",
"*",
"Convenience",
"PangoContext",
"*",
"pango_cairo_create_context",
"(",
"cairo_t",
"*",
"cr",
")",
";"
]
| [
"func",
"CairoCreateContext",
"(",
"cr",
"*",
"cairo",
".",
"Context",
")",
"*",
"Context",
"{",
"c",
":=",
"C",
".",
"pango_cairo_create_context",
"(",
"cairo_context",
"(",
"cr",
")",
")",
"\n",
"context",
":=",
"new",
"(",
"Context",
")",
"\n",
"<mask>",
".",
"pangoContext",
"=",
"(",
"*",
"C",
".",
"PangoContext",
")",
"(",
"c",
")",
"\n",
"return",
"context",
"\n",
"}"
]
|
17,511 | all-17512 | [
"Draw",
"all",
"figures",
"in",
"a",
"nice",
"4x3",
"grid",
"."
]
| [
"func",
"Draw",
"(",
"gc",
"draw2d",
".",
"GraphicContext",
",",
"width",
",",
"height",
"float64",
")",
"{",
"mx",
",",
"my",
":=",
"width",
"*",
"0.025",
",",
"height",
"*",
"0.025",
"// margin",
"\n",
"dx",
",",
"dy",
":=",
"(",
"<mask>",
"-",
"2",
"*",
"mx",
")",
"/",
"4",
",",
"(",
"height",
"-",
"2",
"*",
"my",
")",
"/",
"3",
"\n",
"w",
",",
"h",
":=",
"dx",
"-",
"2",
"*",
"mx",
",",
"dy",
"-",
"2",
"*",
"my",
"\n",
"x0",
",",
"y",
":=",
"2",
"*",
"mx",
",",
"2",
"*",
"my",
"\n",
"x",
":=",
"x0",
"\n",
"Bubble",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
"\n",
"x",
"+=",
"dx",
"\n",
"CurveRectangle",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
",",
"color",
".",
"NRGBA",
"{",
"0x80",
",",
"0",
",",
"0",
",",
"0x80",
"}",
",",
"color",
".",
"NRGBA",
"{",
"0x80",
",",
"0x80",
",",
"0xFF",
",",
"0xFF",
"}",
")",
"\n",
"x",
"+=",
"dx",
"\n",
"Dash",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
"\n",
"x",
"+=",
"dx",
"\n",
"Arc",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
"\n",
"x",
"=",
"x0",
"\n",
"y",
"+=",
"dy",
"\n",
"ArcNegative",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
"\n",
"x",
"+=",
"dx",
"\n",
"CubicCurve",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
"\n",
"x",
"+=",
"dx",
"\n",
"FillString",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
"\n",
"x",
"+=",
"dx",
"\n",
"FillStroke",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
"\n",
"x",
"=",
"x0",
"\n",
"y",
"+=",
"dy",
"\n",
"FillStyle",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
"\n",
"x",
"+=",
"dx",
"\n",
"PathTransform",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
"\n",
"x",
"+=",
"dx",
"\n",
"Star",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
")",
"\n",
"x",
"+=",
"dx",
"\n",
"gopher2",
".",
"Draw",
"(",
"gc",
",",
"x",
",",
"y",
",",
"w",
",",
"h",
"/",
"2",
")",
"\n",
"}"
]
|
17,512 | all-17513 | [
"NextBackOff",
"calculates",
"the",
"next",
"backoff",
"interval",
"using",
"the",
"formula",
":",
"Randomized",
"interval",
"=",
"RetryInterval",
"+",
"/",
"-",
"(",
"RandomizationFactor",
"*",
"RetryInterval",
")"
]
| [
"func",
"(",
"b",
"*",
"ExponentialBackOff",
")",
"NextBackOff",
"(",
")",
"time",
".",
"Duration",
"{",
"// Make sure we have not gone over the maximum elapsed time.",
"if",
"b",
".",
"MaxElapsedTime",
"!=",
"0",
"&&",
"b",
".",
"GetElapsedTime",
"(",
")",
">",
"b",
".",
"MaxElapsedTime",
"{",
"return",
"Stop",
"\n",
"}",
"\n",
"defer",
"b",
".",
"incrementCurrentInterval",
"(",
")",
"\n",
"return",
"getRandomValueFromInterval",
"(",
"b",
".",
"RandomizationFactor",
",",
"<mask>",
".",
"Float64",
"(",
")",
",",
"b",
".",
"currentInterval",
")",
"\n",
"}"
]
|
17,513 | all-17514 | [
"Branch",
"returns",
"the",
"name",
"of",
"the",
"branch",
"to",
"which",
"the",
"user",
"pushed",
"."
]
| [
"func",
"(",
"pe",
"PushEvent",
")",
"Branch",
"(",
")",
"string",
"{",
"ref",
":=",
"strings",
".",
"TrimPrefix",
"(",
"pe",
".",
"Ref",
",",
"\"",
"\"",
")",
"// if Ref is a branch",
"\n",
"<mask>",
"=",
"strings",
".",
"TrimPrefix",
"(",
"ref",
",",
"\"",
"\"",
")",
"// if Ref is a tag",
"\n",
"return",
"ref",
"\n",
"}"
]
|
17,514 | all-17515 | [
"Specify",
"the",
"value",
"of",
"a",
"uniform",
"variable",
"for",
"the",
"current",
"program",
"object"
]
| [
"func",
"Uniform1fv",
"(",
"location",
"int32",
",",
"count",
"int32",
",",
"<mask>",
"*",
"float32",
")",
"{",
"syscall",
".",
"Syscall",
"(",
"gpUniform1fv",
",",
"3",
",",
"uintptr",
"(",
"location",
")",
",",
"uintptr",
"(",
"count",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"value",
")",
")",
")",
"\n",
"}"
]
|
17,515 | all-17516 | [
"Fill",
"fills",
"the",
"paths",
"with",
"the",
"color",
"specified",
"by",
"SetFillColor"
]
| [
"func",
"(",
"gc",
"*",
"GraphicContext",
")",
"Fill",
"(",
"paths",
"...",
"*",
"draw2d",
".",
"Path",
")",
"{",
"paths",
"=",
"<mask>",
"(",
"paths",
",",
"gc",
".",
"Current",
".",
"Path",
")",
"\n",
"gc",
".",
"fillRasterizer",
".",
"UseNonZeroWinding",
"=",
"gc",
".",
"Current",
".",
"FillRule",
"==",
"draw2d",
".",
"FillRuleWinding",
"\n\n",
"/**** first method ****/",
"flattener",
":=",
"draw2dbase",
".",
"Transformer",
"{",
"Tr",
":",
"gc",
".",
"Current",
".",
"Tr",
",",
"Flattener",
":",
"FtLineBuilder",
"{",
"Adder",
":",
"gc",
".",
"fillRasterizer",
"}",
"}",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"paths",
"{",
"draw2dbase",
".",
"Flatten",
"(",
"p",
",",
"flattener",
",",
"gc",
".",
"Current",
".",
"Tr",
".",
"GetScale",
"(",
")",
")",
"\n",
"}",
"\n\n",
"gc",
".",
"paint",
"(",
"gc",
".",
"fillRasterizer",
",",
"gc",
".",
"Current",
".",
"FillColor",
")",
"\n",
"}"
]
|
17,516 | all-17517 | [
"GetFromTsOk",
"returns",
"a",
"tuple",
"with",
"the",
"FromTs",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"t",
"*",
"TriggeringValue",
")",
"GetFromTsOk",
"(",
")",
"(",
"int",
",",
"bool",
")",
"{",
"if",
"t",
"==",
"nil",
"||",
"t",
".",
"FromTs",
"==",
"nil",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"t",
".",
"FromTs",
",",
"<mask>",
"\n",
"}"
]
|
17,517 | all-17518 | [
"Generic",
"Replace",
":",
"replaces",
"a",
"number",
"of",
"regular",
"expressions",
"matched",
"in",
"r",
"."
]
| [
"func",
"(",
"e",
"*",
"edit",
")",
"genReplace",
"(",
"r",
"[",
"]",
"Replacer",
",",
"n",
"int",
")",
"error",
"{",
"if",
"n",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"e",
".",
"file",
".",
"Seek",
"(",
"0",
",",
"os",
".",
"SEEK_SET",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"content",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"e",
".",
"buf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"isNew",
":=",
"false",
"\n\n",
"for",
"_",
",",
"v",
":=",
"<mask>",
"r",
"{",
"reSearch",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"v",
".",
"Search",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"i",
":=",
"n",
"\n",
"repl",
":=",
"[",
"]",
"byte",
"(",
"v",
".",
"Replace",
")",
"\n\n",
"content",
"=",
"reSearch",
".",
"ReplaceAllFunc",
"(",
"content",
",",
"func",
"(",
"s",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"if",
"!",
"isNew",
"{",
"isNew",
"=",
"true",
"\n",
"}",
"\n\n",
"if",
"i",
"!=",
"0",
"{",
"i",
"--",
"\n",
"return",
"repl",
"\n",
"}",
"\n",
"return",
"s",
"\n",
"}",
")",
"\n",
"}",
"\n\n",
"if",
"isNew",
"{",
"return",
"e",
".",
"rewrite",
"(",
"content",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,518 | all-17519 | [
"Endpoints",
"returns",
"endpoint",
"objects",
"for",
"each",
"host",
"-",
"target",
"combination",
"that",
"should",
"be",
"processed",
".",
"Retrieves",
"all",
"gateway",
"resources",
"in",
"the",
"source",
"s",
"namespace",
"(",
"s",
")",
"."
]
| [
"func",
"(",
"sc",
"*",
"gatewaySource",
")",
"Endpoints",
"(",
")",
"(",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
",",
"error",
")",
"{",
"configs",
",",
"err",
":=",
"sc",
".",
"istioClient",
".",
"List",
"(",
"istiomodel",
".",
"Gateway",
".",
"<mask>",
",",
"sc",
".",
"namespace",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"configs",
",",
"err",
"=",
"sc",
".",
"filterByAnnotations",
"(",
"configs",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"endpoints",
":=",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
"{",
"}",
"\n\n",
"for",
"_",
",",
"config",
":=",
"range",
"configs",
"{",
"// Check controller annotation to see if we are responsible.",
"controller",
",",
"ok",
":=",
"config",
".",
"Annotations",
"[",
"controllerAnnotationKey",
"]",
"\n",
"if",
"ok",
"&&",
"controller",
"!=",
"controllerAnnotationValue",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"config",
".",
"Namespace",
",",
"config",
".",
"Name",
",",
"controller",
",",
"controllerAnnotationValue",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"gwEndpoints",
",",
"err",
":=",
"sc",
".",
"endpointsFromGatewayConfig",
"(",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// apply template if host is missing on gateway",
"if",
"(",
"sc",
".",
"combineFQDNAnnotation",
"||",
"len",
"(",
"gwEndpoints",
")",
"==",
"0",
")",
"&&",
"sc",
".",
"fqdnTemplate",
"!=",
"nil",
"{",
"iEndpoints",
",",
"err",
":=",
"sc",
".",
"endpointsFromTemplate",
"(",
"&",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"sc",
".",
"combineFQDNAnnotation",
"{",
"gwEndpoints",
"=",
"append",
"(",
"gwEndpoints",
",",
"iEndpoints",
"...",
")",
"\n",
"}",
"else",
"{",
"gwEndpoints",
"=",
"iEndpoints",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"gwEndpoints",
")",
"==",
"0",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"config",
".",
"Namespace",
",",
"config",
".",
"Name",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"config",
".",
"Namespace",
",",
"config",
".",
"Name",
",",
"gwEndpoints",
")",
"\n",
"sc",
".",
"setResourceLabel",
"(",
"config",
",",
"gwEndpoints",
")",
"\n",
"endpoints",
"=",
"append",
"(",
"endpoints",
",",
"gwEndpoints",
"...",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"ep",
":=",
"range",
"endpoints",
"{",
"sort",
".",
"Sort",
"(",
"ep",
".",
"Targets",
")",
"\n",
"}",
"\n\n",
"return",
"endpoints",
",",
"nil",
"\n",
"}"
]
|
17,519 | all-17520 | [
"RunFilter",
"implements",
"the",
"Filter",
"interface",
":",
"it",
"reads",
"a",
"sequence",
"of",
"items",
"from",
"arg",
".",
"In",
"and",
"passes",
"them",
"as",
"arguments",
"to",
"command",
"args",
"...",
"."
]
| [
"func",
"(",
"x",
"*",
"XargsFilter",
")",
"RunFilter",
"(",
"arg",
"Arg",
")",
"error",
"{",
"items",
":=",
"append",
"(",
"[",
"]",
"string",
"(",
"nil",
")",
",",
"x",
".",
"args",
"...",
")",
"\n",
"added",
":=",
"0",
"// Bytes added to items since last execution.",
"\n",
"for",
"s",
":=",
"range",
"arg",
".",
"In",
"{",
"if",
"len",
"(",
"items",
")",
">",
"len",
"(",
"x",
".",
"args",
")",
"{",
"// See if we have hit a byte or arg limit.",
"if",
"len",
"(",
"items",
")",
"-",
"len",
"(",
"x",
".",
"args",
")",
">=",
"x",
".",
"limitArgs",
"||",
"added",
"+",
"1",
"+",
"len",
"(",
"s",
")",
">=",
"x",
".",
"limitBytes",
"{",
"err",
":=",
"runCommand",
"(",
"arg",
",",
"x",
".",
"command",
",",
"items",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"items",
"=",
"items",
"[",
"0",
":",
"len",
"(",
"x",
".",
"args",
")",
"]",
"\n",
"added",
"=",
"0",
"\n",
"}",
"\n",
"}",
"\n",
"items",
"=",
"append",
"(",
"items",
",",
"s",
")",
"\n",
"added",
"+=",
"1",
"+",
"len",
"(",
"s",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"<mask>",
")",
">",
"len",
"(",
"x",
".",
"args",
")",
"{",
"return",
"runCommand",
"(",
"arg",
",",
"x",
".",
"command",
",",
"items",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,520 | all-17521 | [
"Clear",
"clears",
"all",
"previous",
"lines",
"and",
"the",
"output",
"starts",
"from",
"the",
"top",
"."
]
| [
"func",
"(",
"s",
"*",
"ScreenBuf",
")",
"Clear",
"(",
")",
"error",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"s",
".",
"height",
";",
"i",
"++",
"{",
"_",
",",
"err",
":=",
"s",
".",
"buf",
".",
"Write",
"(",
"moveUp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"s",
".",
"buf",
".",
"Write",
"(",
"clearLine",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"s",
".",
"cursor",
"=",
"0",
"\n",
"s",
".",
"height",
"=",
"0",
"\n",
"s",
".",
"<mask>",
"=",
"false",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,521 | all-17522 | [
"Stability",
":",
"***",
"EXPERIMENTAL",
"***",
"Send",
"an",
"email",
"to",
"address",
".",
"The",
"content",
"is",
"markdown",
"and",
"will",
"be",
"rendered",
"to",
"HTML",
"but",
"both",
"the",
"HTML",
"and",
"raw",
"markdown",
"text",
"will",
"be",
"sent",
"in",
"the",
"email",
".",
"If",
"a",
"link",
"is",
"included",
"it",
"will",
"be",
"rendered",
"to",
"a",
"nice",
"button",
"in",
"the",
"HTML",
"version",
"of",
"the",
"email",
"Required",
"scopes",
":",
"notify",
":",
"email",
":",
"<address",
">",
"See",
"#email"
]
| [
"func",
"(",
"notify",
"*",
"Notify",
")",
"Email",
"(",
"payload",
"*",
"SendEmailRequest",
")",
"error",
"{",
"cd",
":=",
"tcclient",
".",
"Client",
"(",
"*",
"notify",
")",
"\n",
"_",
",",
"_",
",",
"err",
":=",
"(",
"&",
"<mask>",
")",
".",
"APICall",
"(",
"payload",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"nil",
")",
"\n",
"return",
"err",
"\n",
"}"
]
|
17,522 | all-17523 | [
"Add",
"a",
"device",
"to",
"a",
"profile"
]
| [
"func",
"profileDeviceAdd",
"(",
"client",
"lxd",
".",
"ContainerServer",
",",
"name",
"string",
",",
"devName",
"string",
",",
"dev",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"// Get the profile entry",
"profile",
",",
"profileEtag",
",",
"err",
":=",
"client",
".",
"GetProfile",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Check if the device already exists",
"_",
",",
"ok",
":=",
"profile",
".",
"Devices",
"[",
"devName",
"]",
"\n",
"if",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"i18n",
".",
"G",
"(",
"\"",
"\"",
")",
",",
"devName",
")",
"\n",
"}",
"\n\n",
"// Add the device to the container",
"profile",
".",
"Devices",
"[",
"devName",
"]",
"=",
"dev",
"\n\n",
"err",
"=",
"client",
".",
"UpdateProfile",
"(",
"name",
",",
"<mask>",
".",
"Writable",
"(",
")",
",",
"profileEtag",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
17,523 | all-17524 | [
"Warnln",
"logging"
]
| [
"func",
"(",
"l",
"*",
"StdLevelLogger",
")",
"Warnln",
"(",
"args",
"...",
"<mask>",
"{",
"}",
")",
"{",
"l",
".",
"loglnFunc",
"(",
"WarnLevel",
",",
"l",
".",
"context",
",",
"args",
"...",
")",
"\n",
"}"
]
|
17,524 | all-17525 | [
"AddHeader",
"appends",
"given",
"header",
"value",
"to",
"header",
"name",
"without",
"changing",
"existing",
"values",
".",
"If",
"the",
"header",
"does",
"not",
"exist",
"already",
"it",
"will",
"be",
"created",
"."
]
| [
"func",
"(",
"e",
"*",
"Envelope",
")",
"AddHeader",
"(",
"name",
"string",
",",
"value",
"string",
")",
"error",
"{",
"if",
"<mask>",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"e",
".",
"header",
".",
"Add",
"(",
"name",
",",
"mime",
".",
"BEncoding",
".",
"Encode",
"(",
"\"",
"\"",
",",
"value",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,525 | all-17526 | [
"Get",
"gets",
"a",
"point",
"from",
"the",
"index",
"given",
"an",
"id",
"."
]
| [
"func",
"(",
"points",
"*",
"PointsIndex",
")",
"Get",
"(",
"id",
"string",
")",
"Point",
"{",
"if",
"point",
",",
"ok",
":=",
"points",
".",
"currentPosition",
"[",
"id",
"]",
";",
"ok",
"{",
"// first it gets the set of the currentPosition and then gets the point from the set",
"// this is done so it triggers expiration on expiringSet, and returns nil if a point has expired",
"if",
"result",
",",
"resultOk",
":=",
"points",
".",
"index",
".",
"GetEntryAt",
"(",
"<mask>",
")",
".",
"(",
"set",
")",
".",
"Get",
"(",
"id",
")",
";",
"resultOk",
"{",
"return",
"result",
".",
"(",
"Point",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,526 | all-17527 | [
"title",
":",
"deploy",
"list",
"path",
":",
"/",
"deploys",
"method",
":",
"GET",
"produce",
":",
"application",
"/",
"json",
"responses",
":",
"200",
":",
"OK",
"204",
":",
"No",
"content"
]
| [
"func",
"deploysList",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"t",
"auth",
".",
"Token",
")",
"error",
"{",
"contexts",
":=",
"permission",
".",
"ContextsForPermission",
"(",
"t",
",",
"permission",
".",
"PermAppReadDeploy",
")",
"\n",
"if",
"len",
"(",
"contexts",
")",
"==",
"0",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusNoContent",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"filter",
":=",
"appFilterByContext",
"(",
"contexts",
",",
"nil",
")",
"\n",
"<mask>",
".",
"Name",
"=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"skip",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"limit",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"skipInt",
",",
"_",
":=",
"strconv",
".",
"Atoi",
"(",
"skip",
")",
"\n",
"limitInt",
",",
"_",
":=",
"strconv",
".",
"Atoi",
"(",
"limit",
")",
"\n",
"deploys",
",",
"err",
":=",
"app",
".",
"ListDeploys",
"(",
"filter",
",",
"skipInt",
",",
"limitInt",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"deploys",
")",
"==",
"0",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusNoContent",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"w",
".",
"Header",
"(",
")",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"json",
".",
"NewEncoder",
"(",
"w",
")",
".",
"Encode",
"(",
"deploys",
")",
"\n",
"}"
]
|
17,527 | all-17528 | [
"Title",
"returns",
"the",
"page",
"title",
"."
]
| [
"func",
"(",
"p",
"*",
"Page",
")",
"Title",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"<mask>",
",",
"err",
":=",
"p",
".",
"session",
".",
"GetTitle",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"title",
",",
"nil",
"\n",
"}"
]
|
17,528 | all-17529 | [
"getEC2InstanceID",
"gets",
"the",
"EC2",
"instance",
"ID",
"from",
"the",
"metadata",
"service"
]
| [
"func",
"(",
"<mask>",
"*",
"ecsAgent",
")",
"getEC2InstanceID",
"(",
")",
"string",
"{",
"instanceID",
",",
"err",
":=",
"agent",
".",
"ec2MetadataClient",
".",
"InstanceID",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"instanceID",
"\n",
"}"
]
|
17,529 | all-17530 | [
"CompareAndSwapMulti",
"is",
"a",
"batch",
"version",
"of",
"CompareAndSwap",
".",
"appengine",
".",
"MultiError",
"may",
"be",
"returned",
"."
]
| [
"func",
"CompareAndSwapMulti",
"(",
"c",
"context",
".",
"Context",
",",
"item",
"[",
"]",
"*",
"Item",
")",
"error",
"{",
"return",
"<mask>",
"(",
"c",
",",
"item",
",",
"nil",
",",
"pb",
".",
"MemcacheSetRequest_CAS",
")",
"\n",
"}"
]
|
17,530 | all-17531 | [
"Log",
"will",
"construct",
"an",
"audit",
"log",
"entry",
"log",
"and",
"log",
"that",
"entry",
"to",
"the",
"audit",
"log",
"using",
"the",
"underlying",
"logger",
"(",
"which",
"implements",
"the",
"audit",
".",
"InfoLogger",
"interface",
")",
"."
]
| [
"func",
"(",
"a",
"*",
"auditLog",
")",
"<mask>",
"(",
"r",
"request",
".",
"LogRequest",
",",
"httpResponseCode",
"int",
",",
"eventType",
"string",
")",
"{",
"if",
"!",
"a",
".",
"cfg",
".",
"CredentialsAuditLogDisabled",
"{",
"auditLogEntry",
":=",
"constructAuditLogEntry",
"(",
"r",
",",
"httpResponseCode",
",",
"eventType",
",",
"a",
".",
"GetCluster",
"(",
")",
",",
"a",
".",
"GetContainerInstanceArn",
"(",
")",
")",
"\n\n",
"a",
".",
"logger",
".",
"Info",
"(",
"auditLogEntry",
")",
"\n",
"}",
"\n",
"}"
]
|
17,531 | all-17532 | [
"PrintTable",
"-",
"Prints",
"table",
"."
]
| [
"func",
"PrintTable",
"(",
"fields",
"[",
"]",
"string",
",",
"rows",
"[",
"]",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"table",
":=",
"New",
"(",
"fields",
")",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"<mask>",
"{",
"table",
".",
"AddRow",
"(",
"r",
")",
"\n",
"}",
"\n",
"table",
".",
"Print",
"(",
")",
"\n",
"}"
]
|
17,532 | all-17533 | [
"SetCopyFunc",
"is",
"a",
"file",
"setting",
"to",
"replace",
"the",
"function",
"that",
"runs",
"when",
"the",
"message",
"is",
"sent",
".",
"It",
"should",
"copy",
"the",
"content",
"of",
"the",
"file",
"to",
"the",
"io",
".",
"Writer",
".",
"The",
"default",
"copy",
"function",
"opens",
"the",
"file",
"with",
"the",
"given",
"filename",
"and",
"copy",
"its",
"content",
"to",
"the",
"io",
".",
"Writer",
"."
]
| [
"func",
"SetCopyFunc",
"(",
"f",
"func",
"(",
"io",
".",
"Writer",
")",
"error",
")",
"FileSetting",
"{",
"return",
"func",
"(",
"fi",
"*",
"<mask>",
")",
"{",
"fi",
".",
"CopyFunc",
"=",
"f",
"\n",
"}",
"\n",
"}"
]
|
17,533 | all-17534 | [
"DependencyOrder",
"is",
"a",
"sort",
".",
"Interface",
"that",
"*",
"best",
"-",
"effort",
"*",
"sorts",
"the",
"objects",
"so",
"that",
"known",
"dependencies",
"appear",
"earlier",
"in",
"the",
"list",
".",
"The",
"idea",
"is",
"to",
"prevent",
"*",
"some",
"*",
"of",
"the",
"crash",
"-",
"restart",
"loops",
"when",
"creating",
"inter",
"-",
"dependent",
"resources",
"."
]
| [
"func",
"DependencyOrder",
"(",
"disco",
"discovery",
".",
"OpenAPISchemaInterface",
",",
"mapper",
"meta",
".",
"RESTMapper",
",",
"list",
"[",
"]",
"*",
"unstructured",
".",
"Unstructured",
")",
"(",
"sort",
".",
"Interface",
",",
"error",
")",
"{",
"sortKeys",
":=",
"<mask>",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"list",
")",
")",
"\n",
"for",
"i",
",",
"item",
":=",
"range",
"list",
"{",
"var",
"err",
"error",
"\n",
"sortKeys",
"[",
"i",
"]",
",",
"err",
"=",
"depTier",
"(",
"disco",
",",
"mapper",
",",
"item",
".",
"GetObjectKind",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"sortKeys",
")",
"\n",
"return",
"&",
"mappedSort",
"{",
"sortKeys",
":",
"sortKeys",
",",
"items",
":",
"list",
"}",
",",
"nil",
"\n",
"}"
]
|
17,534 | all-17535 | [
"Fatalf",
"records",
"the",
"log",
"with",
"fatal",
"level",
"and",
"exits"
]
| [
"func",
"Fatalf",
"(",
"format",
"string",
",",
"args",
"...",
"<mask>",
"{",
"}",
")",
"{",
"logger",
".",
"Output",
"(",
"2",
",",
"LevelFatal",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}"
]
|
17,535 | all-17536 | [
"Print",
"an",
"AST",
"."
]
| [
"func",
"(",
"ps",
"*",
"printState",
")",
"print",
"(",
"a",
"AST",
")",
"{",
"c",
":=",
"0",
"\n",
"for",
"_",
",",
"v",
":=",
"<mask>",
"ps",
".",
"printing",
"{",
"if",
"v",
"==",
"a",
"{",
"// We permit the type to appear once, and",
"// return without printing anything if we see",
"// it twice. This is for a case like",
"// _Z6outer2IsEPFilES1_, where the",
"// substitution is printed differently the",
"// second time because the set of inner types",
"// is different.",
"c",
"++",
"\n",
"if",
"c",
">",
"1",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"ps",
".",
"printing",
"=",
"append",
"(",
"ps",
".",
"printing",
",",
"a",
")",
"\n\n",
"a",
".",
"print",
"(",
"ps",
")",
"\n\n",
"ps",
".",
"printing",
"=",
"ps",
".",
"printing",
"[",
":",
"len",
"(",
"ps",
".",
"printing",
")",
"-",
"1",
"]",
"\n",
"}"
]
|
17,536 | all-17537 | [
"NewClusterV3",
"returns",
"a",
"launched",
"cluster",
"with",
"a",
"grpc",
"client",
"connection",
"for",
"each",
"cluster",
"member",
"."
]
| [
"func",
"NewClusterV3",
"(",
"t",
"testing",
".",
"TB",
",",
"cfg",
"*",
"ClusterConfig",
")",
"*",
"ClusterV3",
"{",
"cfg",
".",
"UseGRPC",
"=",
"true",
"\n",
"if",
"<mask>",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"!=",
"\"",
"\"",
"{",
"clientv3",
".",
"SetLogger",
"(",
"grpclog",
".",
"NewLoggerV2WithVerbosity",
"(",
"os",
".",
"Stderr",
",",
"os",
".",
"Stderr",
",",
"os",
".",
"Stderr",
",",
"4",
")",
")",
"\n",
"}",
"\n",
"clus",
":=",
"&",
"ClusterV3",
"{",
"cluster",
":",
"NewClusterByConfig",
"(",
"t",
",",
"cfg",
")",
",",
"}",
"\n",
"clus",
".",
"Launch",
"(",
"t",
")",
"\n\n",
"if",
"!",
"cfg",
".",
"SkipCreatingClient",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"clus",
".",
"Members",
"{",
"client",
",",
"err",
":=",
"NewClientV3",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"t",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"clus",
".",
"clients",
"=",
"append",
"(",
"clus",
".",
"clients",
",",
"client",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"clus",
"\n",
"}"
]
|
17,537 | all-17538 | [
"Register",
"is",
"a",
"sentinel",
"option",
"to",
"register",
"a",
"server",
"its",
"shutdown",
"listener",
"and",
"ignore",
"error",
"handlers",
".",
"Both",
"server",
"and",
"shutdown",
"can",
"have",
"a",
"type",
"of",
"func",
"()",
"func",
"()",
"error",
"or",
"func",
"(",
"context",
".",
"Context",
")",
"error",
"."
]
| [
"func",
"Register",
"(",
"server",
",",
"shutdown",
"interface",
"{",
"}",
",",
"ignore",
"...",
"func",
"(",
"error",
")",
"bool",
")",
"Option",
"{",
"return",
"func",
"(",
"s",
"*",
"Sentinel",
")",
"error",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"s",
".",
"<mask>",
"{",
"return",
"ErrAlreadyStarted",
"\n",
"}",
"\n\n",
"return",
"s",
".",
"Register",
"(",
"server",
",",
"shutdown",
",",
"ignore",
"...",
")",
"\n",
"}",
"\n",
"}"
]
|
17,538 | all-17539 | [
"NewDockerTaskEngine",
"returns",
"a",
"created",
"but",
"uninitialized",
"DockerTaskEngine",
".",
"The",
"distinction",
"between",
"created",
"and",
"initialized",
"is",
"that",
"when",
"created",
"it",
"may",
"be",
"serialized",
"/",
"deserialized",
"but",
"it",
"will",
"not",
"communicate",
"with",
"docker",
"until",
"it",
"is",
"also",
"initialized",
"."
]
| [
"func",
"NewDockerTaskEngine",
"(",
"cfg",
"*",
"config",
".",
"Config",
",",
"client",
"dockerapi",
".",
"DockerClient",
",",
"credentialsManager",
"credentials",
".",
"Manager",
",",
"containerChangeEventStream",
"*",
"eventstream",
".",
"EventStream",
",",
"imageManager",
"ImageManager",
",",
"state",
"dockerstate",
".",
"TaskEngineState",
",",
"metadataManager",
"containermetadata",
".",
"Manager",
",",
"resourceFields",
"*",
"taskresource",
".",
"ResourceFields",
")",
"*",
"DockerTaskEngine",
"{",
"dockerTaskEngine",
":=",
"&",
"DockerTaskEngine",
"{",
"cfg",
":",
"cfg",
",",
"client",
":",
"<mask>",
",",
"saver",
":",
"statemanager",
".",
"NewNoopStateManager",
"(",
")",
",",
"state",
":",
"state",
",",
"managedTasks",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"managedTask",
")",
",",
"taskStopGroup",
":",
"utilsync",
".",
"NewSequentialWaitGroup",
"(",
")",
",",
"stateChangeEvents",
":",
"make",
"(",
"chan",
"statechange",
".",
"Event",
")",
",",
"credentialsManager",
":",
"credentialsManager",
",",
"containerChangeEventStream",
":",
"containerChangeEventStream",
",",
"imageManager",
":",
"imageManager",
",",
"cniClient",
":",
"ecscni",
".",
"NewClient",
"(",
"&",
"ecscni",
".",
"Config",
"{",
"PluginsPath",
":",
"cfg",
".",
"CNIPluginsPath",
",",
"MinSupportedCNIVersion",
":",
"config",
".",
"DefaultMinSupportedCNIVersion",
",",
"}",
")",
",",
"metadataManager",
":",
"metadataManager",
",",
"taskSteadyStatePollInterval",
":",
"defaultTaskSteadyStatePollInterval",
",",
"resourceFields",
":",
"resourceFields",
",",
"}",
"\n\n",
"dockerTaskEngine",
".",
"initializeContainerStatusToTransitionFunction",
"(",
")",
"\n\n",
"return",
"dockerTaskEngine",
"\n",
"}"
]
|
17,539 | all-17540 | [
"Debug",
"logs",
"a",
"message",
"(",
"with",
"optional",
"context",
")",
"at",
"the",
"DEBUG",
"log",
"level"
]
| [
"func",
"Debug",
"(",
"msg",
"string",
",",
"ctx",
"...",
"<mask>",
"{",
"}",
")",
"{",
"if",
"Log",
"!=",
"nil",
"{",
"Log",
".",
"Debug",
"(",
"msg",
",",
"ctx",
"...",
")",
"\n",
"}",
"\n",
"}"
]
|
17,540 | all-17541 | [
"DeleteAnnotationByCID",
"deletes",
"annotation",
"with",
"passed",
"cid",
"."
]
| [
"func",
"(",
"a",
"*",
"API",
")",
"DeleteAnnotationByCID",
"(",
"cid",
"CIDType",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"cid",
"==",
"nil",
"||",
"*",
"cid",
"==",
"\"",
"\"",
"{",
"return",
"false",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"annotationCID",
":=",
"string",
"(",
"*",
"cid",
")",
"\n\n",
"matched",
",",
"err",
":=",
"regexp",
".",
"MatchString",
"(",
"config",
".",
"AnnotationCIDRegex",
",",
"annotationCID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"if",
"!",
"matched",
"{",
"return",
"<mask>",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"annotationCID",
")",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"a",
".",
"Delete",
"(",
"annotationCID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"true",
",",
"nil",
"\n",
"}"
]
|
17,541 | all-17542 | [
"SortRecent",
"sorts",
"a",
"slice",
"of",
"LogMessages",
"by",
"timestamp",
".",
"The",
"sort",
"is",
"stable",
"so",
"messages",
"with",
"the",
"same",
"timestamp",
"are",
"sorted",
"in",
"the",
"order",
"that",
"they",
"are",
"received",
".",
"The",
"input",
"slice",
"is",
"sorted",
";",
"the",
"return",
"value",
"is",
"simply",
"a",
"pointer",
"to",
"the",
"same",
"slice",
"."
]
| [
"func",
"SortRecent",
"(",
"messages",
"[",
"]",
"*",
"<mask>",
".",
"LogMessage",
")",
"[",
"]",
"*",
"events",
".",
"LogMessage",
"{",
"sort",
".",
"Stable",
"(",
"logMessageSlice",
"(",
"messages",
")",
")",
"\n",
"return",
"messages",
"\n",
"}"
]
|
17,542 | all-17543 | [
"WatchOneF",
"watches",
"a",
"given",
"item",
"and",
"executes",
"a",
"callback",
"function",
"each",
"time",
"an",
"event",
"occurs",
".",
"The",
"first",
"value",
"returned",
"from",
"the",
"watch",
"will",
"be",
"the",
"current",
"value",
"of",
"the",
"item",
"."
]
| [
"func",
"(",
"c",
"*",
"readonlyCollection",
")",
"WatchOneF",
"(",
"key",
"string",
",",
"f",
"func",
"(",
"e",
"*",
"watch",
".",
"Event",
")",
"error",
")",
"error",
"{",
"watcher",
",",
"err",
":=",
"watch",
".",
"NewWatcher",
"(",
"c",
".",
"ctx",
",",
"c",
".",
"etcdClient",
",",
"c",
".",
"prefix",
",",
"c",
".",
"Path",
"(",
"key",
")",
",",
"c",
".",
"template",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"watcher",
".",
"Close",
"(",
")",
"\n",
"for",
"{",
"select",
"{",
"<mask>",
"e",
":=",
"<-",
"watcher",
".",
"Watch",
"(",
")",
":",
"if",
"err",
":=",
"f",
"(",
"e",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"errutil",
".",
"ErrBreak",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"case",
"<-",
"c",
".",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"c",
".",
"ctx",
".",
"Err",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
]
|
17,543 | all-17544 | [
"DeleteNic",
"deletes",
"the",
"nic",
"where",
"id",
"=",
"nicid",
"and",
"returns",
"a",
"Resp",
"struct"
]
| [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteNic",
"(",
"dcid",
",",
"srvid",
",",
"nicid",
"string",
")",
"(",
"*",
"http",
".",
"Header",
",",
"error",
")",
"{",
"url",
":=",
"nicPath",
"(",
"dcid",
",",
"srvid",
",",
"nicid",
")",
"\n",
"ret",
":=",
"&",
"http",
".",
"Header",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"client",
".",
"Delete",
"(",
"<mask>",
",",
"ret",
",",
"http",
".",
"StatusAccepted",
")",
"\n",
"return",
"ret",
",",
"err",
"\n",
"}"
]
|
17,544 | all-17545 | [
"unsuccessfulContexts",
"determines",
"which",
"contexts",
"from",
"the",
"list",
"that",
"we",
"care",
"about",
"are",
"failed",
".",
"For",
"instance",
"we",
"do",
"not",
"care",
"about",
"our",
"own",
"context",
".",
"If",
"the",
"branchProtection",
"is",
"set",
"to",
"only",
"check",
"for",
"required",
"checks",
"we",
"will",
"skip",
"all",
"non",
"-",
"required",
"tests",
".",
"If",
"required",
"tests",
"are",
"missing",
"from",
"the",
"list",
"they",
"will",
"be",
"added",
"to",
"the",
"list",
"of",
"failed",
"contexts",
"."
]
| [
"func",
"unsuccessfulContexts",
"(",
"contexts",
"[",
"]",
"Context",
",",
"cc",
"contextChecker",
",",
"log",
"*",
"logrus",
".",
"Entry",
")",
"[",
"]",
"Context",
"{",
"var",
"failed",
"[",
"]",
"Context",
"\n",
"for",
"_",
",",
"ctx",
":=",
"range",
"contexts",
"{",
"if",
"string",
"(",
"ctx",
".",
"Context",
")",
"==",
"statusContext",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"cc",
".",
"IsOptional",
"(",
"string",
"(",
"ctx",
".",
"Context",
")",
")",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"ctx",
".",
"State",
"!=",
"githubql",
".",
"StatusStateSuccess",
"{",
"failed",
"=",
"append",
"(",
"failed",
",",
"ctx",
")",
"\n",
"}",
"\n",
"}",
"\n",
"for",
"_",
",",
"c",
":=",
"<mask>",
"cc",
".",
"MissingRequiredContexts",
"(",
"contextsToStrings",
"(",
"contexts",
")",
")",
"{",
"failed",
"=",
"append",
"(",
"failed",
",",
"newExpectedContext",
"(",
"c",
")",
")",
"\n",
"}",
"\n\n",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"len",
"(",
"contexts",
")",
",",
"contextsToStrings",
"(",
"contexts",
")",
",",
"len",
"(",
"failed",
")",
",",
"contextsToStrings",
"(",
"failed",
")",
")",
"\n",
"return",
"failed",
"\n",
"}"
]
|
17,545 | all-17546 | [
"Do",
"executes",
"DOM",
".",
"querySelector",
"against",
"the",
"provided",
"context",
".",
"returns",
":",
"nodeID",
"-",
"Query",
"selector",
"result",
"."
]
| [
"func",
"(",
"p",
"*",
"QuerySelectorParams",
")",
"Do",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"nodeID",
"cdp",
".",
"NodeID",
",",
"err",
"error",
")",
"{",
"// execute",
"<mask>",
"res",
"QuerySelectorReturns",
"\n",
"err",
"=",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandQuerySelector",
",",
"p",
",",
"&",
"res",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
".",
"NodeID",
",",
"nil",
"\n",
"}"
]
|
17,546 | all-17547 | [
"Entries",
"implements",
"the",
"Storage",
"interface",
"."
]
| [
"func",
"(",
"ms",
"*",
"MemoryStorage",
")",
"Entries",
"(",
"lo",
",",
"hi",
",",
"maxSize",
"uint64",
")",
"(",
"[",
"]",
"pb",
".",
"Entry",
",",
"error",
")",
"{",
"ms",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ms",
".",
"Unlock",
"(",
")",
"\n",
"offset",
":=",
"ms",
".",
"ents",
"[",
"0",
"]",
".",
"Index",
"\n",
"if",
"lo",
"<=",
"offset",
"{",
"return",
"nil",
",",
"ErrCompacted",
"\n",
"}",
"\n",
"if",
"hi",
">",
"ms",
".",
"lastIndex",
"(",
")",
"+",
"1",
"{",
"raftLogger",
".",
"Panicf",
"(",
"\"",
"\"",
",",
"hi",
",",
"ms",
".",
"lastIndex",
"(",
")",
")",
"\n",
"}",
"\n",
"// only contains dummy entries.",
"if",
"len",
"(",
"ms",
".",
"ents",
")",
"==",
"1",
"{",
"return",
"nil",
",",
"ErrUnavailable",
"\n",
"}",
"\n\n",
"ents",
":=",
"ms",
".",
"ents",
"[",
"lo",
"-",
"offset",
":",
"hi",
"-",
"<mask>",
"]",
"\n",
"return",
"limitSize",
"(",
"ents",
",",
"maxSize",
")",
",",
"nil",
"\n",
"}"
]
|
17,547 | all-17548 | [
"Connections",
"returns",
"all",
"the",
"connections",
"that",
"the",
"local",
"peer",
"is",
"aware",
"of",
"."
]
| [
"func",
"(",
"peer",
"*",
"localPeer",
")",
"getConnections",
"(",
")",
"connectionSet",
"{",
"connections",
":=",
"<mask>",
"(",
"connectionSet",
")",
"\n",
"peer",
".",
"RLock",
"(",
")",
"\n",
"defer",
"peer",
".",
"RUnlock",
"(",
")",
"\n",
"for",
"_",
",",
"conn",
":=",
"range",
"peer",
".",
"connections",
"{",
"connections",
"[",
"conn",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"}",
"\n",
"return",
"connections",
"\n",
"}"
]
|
17,548 | all-17549 | [
"MarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Marshaler",
"."
]
| [
"func",
"(",
"t",
"State",
")",
"MarshalEasyJSON",
"(",
"out",
"*",
"jwriter",
".",
"Writer",
")",
"{",
"<mask>",
".",
"String",
"(",
"string",
"(",
"t",
")",
")",
"\n",
"}"
]
|
17,549 | all-17550 | [
"<nested",
"-",
"name",
">",
"::",
"=",
"N",
"[",
"<CV",
"-",
"qualifiers",
">",
"]",
"[",
"<ref",
"-",
"qualifier",
">",
"]",
"<prefix",
">",
"<unqualified",
"-",
"name",
">",
"E",
"::",
"=",
"N",
"[",
"<CV",
"-",
"qualifiers",
">",
"]",
"[",
"<ref",
"-",
"qualifier",
">",
"]",
"<template",
"-",
"prefix",
">",
"<template",
"-",
"args",
">",
"E"
]
| [
"func",
"(",
"st",
"*",
"state",
")",
"nestedName",
"(",
")",
"AST",
"{",
"st",
".",
"checkChar",
"(",
"'N'",
")",
"\n",
"q",
":=",
"st",
".",
"cvQualifiers",
"(",
")",
"\n",
"r",
":=",
"st",
".",
"refQualifier",
"(",
")",
"\n",
"a",
":=",
"st",
".",
"<mask>",
"(",
")",
"\n",
"if",
"len",
"(",
"q",
")",
">",
"0",
"||",
"r",
"!=",
"\"",
"\"",
"{",
"a",
"=",
"&",
"MethodWithQualifiers",
"{",
"Method",
":",
"a",
",",
"Qualifiers",
":",
"q",
",",
"RefQualifier",
":",
"r",
"}",
"\n",
"}",
"\n",
"if",
"len",
"(",
"st",
".",
"str",
")",
"==",
"0",
"||",
"st",
".",
"str",
"[",
"0",
"]",
"!=",
"'E'",
"{",
"st",
".",
"fail",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"st",
".",
"advance",
"(",
"1",
")",
"\n",
"return",
"a",
"\n",
"}"
]
|
17,550 | all-17551 | [
"Create",
"logfile",
"for",
"systemd",
"service",
"in",
"outputDir",
"with",
"the",
"given",
"journalctl",
"outputMode",
"."
]
| [
"func",
"createSystemdLogfile",
"(",
"service",
"string",
",",
"outputMode",
"string",
",",
"outputDir",
"string",
")",
"error",
"{",
"// Generate the journalctl command.",
"journalCmdArgs",
":=",
"[",
"]",
"string",
"{",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"outputMode",
")",
",",
"\"",
"\"",
",",
"*",
"journalPath",
"}",
"\n",
"if",
"service",
"==",
"\"",
"\"",
"{",
"journalCmdArgs",
"=",
"append",
"(",
"journalCmdArgs",
",",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"journalCmdArgs",
"=",
"append",
"(",
"journalCmdArgs",
",",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"service",
")",
")",
"\n",
"}",
"\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"journalCmdArgs",
"...",
")",
"\n\n",
"// Run the command and record the output to a file.",
"output",
",",
"err",
":=",
"cmd",
".",
"Output",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"<mask>",
",",
"err",
")",
"\n",
"}",
"\n",
"logfile",
":=",
"filepath",
".",
"Join",
"(",
"outputDir",
",",
"service",
"+",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"ioutil",
".",
"WriteFile",
"(",
"logfile",
",",
"output",
",",
"0444",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"service",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,551 | all-17552 | [
"DefaultCredentials",
"mocks",
"base",
"method"
]
| [
"func",
"(",
"m",
"*",
"MockEC2MetadataClient",
")",
"DefaultCredentials",
"(",
")",
"(",
"*",
"ec2",
".",
"RoleCredentials",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"*",
"ec2",
".",
"RoleCredentials",
")",
"\n",
"ret1",
",",
"_",
":=",
"<mask>",
"[",
"1",
"]",
".",
"(",
"error",
")",
"\n",
"return",
"ret0",
",",
"ret1",
"\n",
"}"
]
|
17,552 | all-17553 | [
"resourceVSphereDatastoreClusterApplyNameChange",
"applies",
"any",
"changes",
"to",
"a",
"StoragePod",
"s",
"name",
"."
]
| [
"func",
"resourceVSphereDatastoreClusterApplyNameChange",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"meta",
"interface",
"{",
"}",
",",
"pod",
"*",
"object",
".",
"StoragePod",
",",
")",
"(",
"*",
"object",
".",
"StoragePod",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"resourceVSphereDatastoreClusterIDString",
"(",
"d",
")",
",",
"pod",
".",
"InventoryPath",
",",
")",
"\n\n",
"var",
"changed",
"bool",
"\n",
"var",
"err",
"error",
"\n\n",
"if",
"d",
".",
"HasChange",
"(",
"\"",
"\"",
")",
"{",
"if",
"err",
"=",
"storagepod",
".",
"Rename",
"(",
"pod",
",",
"d",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"string",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"changed",
"=",
"true",
"\n",
"}",
"\n\n",
"if",
"<mask>",
"{",
"// Update the pod so that we have the new inventory path for logging and",
"// other things",
"pod",
",",
"err",
"=",
"resourceVSphereDatastoreClusterGetPod",
"(",
"d",
",",
"meta",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"resourceVSphereDatastoreClusterIDString",
"(",
"d",
")",
",",
"pod",
".",
"InventoryPath",
",",
")",
"\n",
"}",
"\n\n",
"return",
"pod",
",",
"nil",
"\n",
"}"
]
|
17,553 | all-17554 | [
"CleanUp",
"cleans",
"up",
"blocked",
"syscalls",
"for",
"pipes",
"that",
"were",
"never",
"opened",
".",
"And",
"returns",
"the",
"total",
"number",
"of",
"bytes",
"that",
"have",
"been",
"pulled",
"/",
"pushed",
".",
"It",
"also",
"returns",
"any",
"errors",
"that",
"might",
"have",
"been",
"encountered",
"while",
"trying",
"to",
"read",
"data",
"for",
"the",
"pipes",
".",
"CleanUp",
"should",
"be",
"called",
"after",
"all",
"code",
"that",
"might",
"access",
"pipes",
"has",
"completed",
"running",
"it",
"should",
"not",
"be",
"called",
"concurrently",
"."
]
| [
"func",
"(",
"p",
"*",
"Puller",
")",
"CleanUp",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"result",
"error",
"\n",
"select",
"{",
"case",
"result",
"=",
"<-",
"p",
".",
"errCh",
":",
"default",
":",
"}",
"\n\n",
"// Open all the pipes to unblock the goros",
"var",
"pipes",
"[",
"]",
"io",
".",
"Closer",
"\n",
"func",
"(",
")",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n",
"p",
".",
"cleaned",
"=",
"true",
"\n",
"for",
"path",
":=",
"range",
"p",
".",
"pipes",
"{",
"f",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"path",
",",
"syscall",
".",
"O_NONBLOCK",
"+",
"os",
".",
"O_RDONLY",
",",
"os",
".",
"ModeNamedPipe",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"result",
"==",
"nil",
"{",
"result",
"=",
"err",
"\n",
"}",
"\n",
"pipes",
"=",
"append",
"(",
"pipes",
",",
"f",
")",
"\n",
"}",
"\n",
"p",
".",
"pipes",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n",
"}",
"(",
")",
"\n\n",
"// Wait for all goros to exit",
"p",
".",
"wg",
".",
"Wait",
"(",
")",
"\n\n",
"// Close the pipes",
"for",
"_",
",",
"pipe",
":=",
"range",
"pipes",
"{",
"if",
"err",
":=",
"pipe",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"&&",
"result",
"==",
"nil",
"{",
"result",
"=",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"size",
":=",
"p",
".",
"size",
"\n",
"p",
".",
"<mask>",
"=",
"0",
"\n",
"return",
"size",
",",
"result",
"\n",
"}"
]
|
17,554 | all-17555 | [
"CalcHash160",
"returns",
"the",
"ripemd160",
"(",
"sha256",
"(",
"data",
"))",
"."
]
| [
"func",
"CalcHash160",
"(",
"data",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"return",
"CalcHash",
"(",
"CalcHash",
"(",
"<mask>",
",",
"sha256",
".",
"New",
"(",
")",
")",
",",
"ripemd160",
".",
"New",
"(",
")",
")",
"\n",
"}"
]
|
17,555 | all-17556 | [
"StopContainer",
"mocks",
"base",
"method"
]
| [
"func",
"(",
"m",
"*",
"MockDockerClient",
")",
"StopContainer",
"(",
"arg0",
"context",
".",
"Context",
",",
"arg1",
"string",
",",
"arg2",
"time",
".",
"Duration",
")",
"dockerapi",
".",
"DockerContainerMetadata",
"{",
"<mask>",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
",",
"arg1",
",",
"arg2",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"dockerapi",
".",
"DockerContainerMetadata",
")",
"\n",
"return",
"ret0",
"\n",
"}"
]
|
17,556 | all-17557 | [
"Do",
"executes",
"Database",
".",
"executeSQL",
"against",
"the",
"provided",
"context",
".",
"returns",
":",
"columnNames",
"values",
"sqlError"
]
| [
"func",
"(",
"p",
"*",
"ExecuteSQLParams",
")",
"Do",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"columnNames",
"[",
"]",
"string",
",",
"values",
"[",
"]",
"easyjson",
".",
"RawMessage",
",",
"sqlError",
"*",
"Error",
",",
"err",
"error",
")",
"{",
"// execute",
"<mask>",
"res",
"ExecuteSQLReturns",
"\n",
"err",
"=",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandExecuteSQL",
",",
"p",
",",
"&",
"res",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
".",
"ColumnNames",
",",
"res",
".",
"Values",
",",
"res",
".",
"SQLError",
",",
"nil",
"\n",
"}"
]
|
17,557 | all-17558 | [
"getPubKey",
"reads",
"the",
"pubkey",
"the",
"ledger",
"itself",
"since",
"this",
"involves",
"IO",
"it",
"may",
"return",
"an",
"error",
"which",
"is",
"not",
"exposed",
"in",
"the",
"PubKey",
"interface",
"so",
"this",
"function",
"allows",
"better",
"error",
"handling"
]
| [
"func",
"(",
"pk",
"PrivKeyLedgerSecp256k1",
")",
"getPubKey",
"(",
")",
"(",
"key",
"PubKey",
",",
"err",
"error",
")",
"{",
"dev",
",",
"err",
":=",
"getLedger",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"key",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"key",
",",
"err",
"=",
"pubkeyLedgerSecp256k1",
"(",
"dev",
",",
"pk",
".",
"Path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"<mask>",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"key",
",",
"err",
"\n",
"}"
]
|
17,558 | all-17559 | [
"AddRule",
"adds",
"a",
"new",
"rule",
"into",
"the",
"context",
"."
]
| [
"func",
"(",
"s",
"*",
"Seekret",
")",
"AddRule",
"(",
"rule",
"models",
".",
"Rule",
",",
"enabled",
"bool",
")",
"{",
"if",
"enabled",
"{",
"rule",
".",
"Enable",
"(",
")",
"\n",
"}",
"\n",
"s",
".",
"ruleList",
"=",
"<mask>",
"(",
"s",
".",
"ruleList",
",",
"rule",
")",
"\n",
"}"
]
|
17,559 | all-17560 | [
"Put",
"puts",
"a",
"key",
"/",
"value",
"pair",
"in",
"the",
"cache",
"and",
"reads",
"the",
"value",
"from",
"an",
"io",
".",
"Reader",
"."
]
| [
"func",
"(",
"c",
"*",
"Cache",
")",
"Put",
"(",
"key",
"string",
",",
"value",
"io",
".",
"Reader",
")",
"(",
"retErr",
"error",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"f",
",",
"err",
":=",
"<mask>",
".",
"Create",
"(",
"filepath",
".",
"Join",
"(",
"c",
".",
"root",
",",
"key",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
":=",
"f",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"&&",
"retErr",
"==",
"nil",
"{",
"retErr",
"=",
"err",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"buf",
":=",
"grpcutil",
".",
"GetBuffer",
"(",
")",
"\n",
"defer",
"grpcutil",
".",
"PutBuffer",
"(",
"buf",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"io",
".",
"CopyBuffer",
"(",
"f",
",",
"value",
",",
"buf",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"c",
".",
"keys",
"[",
"key",
"]",
"=",
"true",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,560 | all-17561 | [
"ItemsChanged",
"is",
"a",
"wrapper",
"around",
"g_menu_model_items_changed",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"MenuModel",
")",
"ItemsChanged",
"(",
"position",
",",
"removed",
",",
"<mask>",
"int",
")",
"{",
"C",
".",
"g_menu_model_items_changed",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"gint",
"(",
"position",
")",
",",
"C",
".",
"gint",
"(",
"removed",
")",
",",
"C",
".",
"gint",
"(",
"added",
")",
")",
"\n",
"}"
]
|
17,561 | all-17562 | [
"getJobName",
"generates",
"the",
"correct",
"job",
"name",
"for",
"this",
"job",
"type"
]
| [
"func",
"getJobName",
"(",
"spec",
"*",
"prowapi",
".",
"ProwJobSpec",
")",
"string",
"{",
"if",
"spec",
".",
"JenkinsSpec",
"!=",
"nil",
"&&",
"spec",
".",
"JenkinsSpec",
".",
"GitHubBranchSourceJob",
"&&",
"<mask>",
".",
"Refs",
"!=",
"nil",
"{",
"if",
"len",
"(",
"spec",
".",
"Refs",
".",
"Pulls",
")",
">",
"0",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"spec",
".",
"Job",
",",
"spec",
".",
"Refs",
".",
"Pulls",
"[",
"0",
"]",
".",
"Number",
")",
"\n",
"}",
"\n\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"spec",
".",
"Job",
",",
"spec",
".",
"Refs",
".",
"BaseRef",
")",
"\n",
"}",
"\n\n",
"return",
"spec",
".",
"Job",
"\n",
"}"
]
|
17,562 | all-17563 | [
"New",
"creates",
"a",
"new",
"instance",
"of",
"Handler",
".",
"The",
"first",
"argument",
"is",
"the",
"handler",
"that",
"will",
"be",
"executed",
"when",
"maintenance",
"mode",
"is",
"off",
"."
]
| [
"func",
"New",
"(",
"options",
"...",
"Option",
")",
"(",
"s",
"*",
"Service",
")",
"{",
"s",
"=",
"&",
"Service",
"{",
"logger",
":",
"stdLogger",
"{",
"}",
",",
"}",
"\n",
"for",
"_",
",",
"option",
":=",
"<mask>",
"options",
"{",
"option",
"(",
"s",
")",
"\n",
"}",
"\n",
"if",
"s",
".",
"store",
"==",
"nil",
"{",
"s",
".",
"store",
"=",
"NewMemoryStore",
"(",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
]
|
17,563 | all-17564 | [
"EncodeReadResponse",
"writes",
"a",
"remote",
".",
"Response",
"to",
"a",
"http",
".",
"ResponseWriter",
"."
]
| [
"func",
"EncodeReadResponse",
"(",
"resp",
"*",
"prompb",
".",
"ReadResponse",
",",
"w",
"http",
".",
"ResponseWriter",
")",
"error",
"{",
"data",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"resp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"w",
".",
"<mask>",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"compressed",
":=",
"snappy",
".",
"Encode",
"(",
"nil",
",",
"data",
")",
"\n",
"_",
",",
"err",
"=",
"w",
".",
"Write",
"(",
"compressed",
")",
"\n",
"return",
"err",
"\n",
"}"
]
|
17,564 | all-17565 | [
"PprofUpdateAddress",
"updates",
"the",
"address",
"for",
"the",
"pprof",
"endpoint",
"shutting",
"it",
"down",
"and",
"restarting",
"it",
"."
]
| [
"func",
"(",
"e",
"*",
"Endpoints",
")",
"PprofUpdateAddress",
"(",
"address",
"string",
")",
"error",
"{",
"if",
"address",
"!=",
"\"",
"\"",
"{",
"address",
"=",
"util",
".",
"CanonicalNetworkAddress",
"(",
"address",
")",
"\n",
"}",
"\n\n",
"oldAddress",
":=",
"e",
".",
"NetworkAddress",
"(",
")",
"\n",
"if",
"address",
"==",
"oldAddress",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"logger",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n\n",
"e",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// Close the previous socket",
"e",
".",
"closeListener",
"(",
"pprof",
")",
"\n\n",
"// If turning off listening, we're done",
"if",
"address",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Attempt to setup the new listening socket",
"getListener",
":=",
"func",
"(",
"address",
"string",
")",
"(",
"*",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"listener",
"net",
".",
"Listener",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
"{",
"// Ten retries over a second seems reasonable.",
"listener",
",",
"err",
"=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"address",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"<mask>",
"\n",
"}",
"\n\n",
"time",
".",
"Sleep",
"(",
"100",
"*",
"time",
".",
"Millisecond",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"listener",
",",
"nil",
"\n",
"}",
"\n\n",
"// If setting a new address, setup the listener",
"if",
"address",
"!=",
"\"",
"\"",
"{",
"listener",
",",
"err",
":=",
"getListener",
"(",
"address",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Attempt to revert to the previous address",
"listener",
",",
"err1",
":=",
"getListener",
"(",
"oldAddress",
")",
"\n",
"if",
"err1",
"==",
"nil",
"{",
"e",
".",
"listeners",
"[",
"pprof",
"]",
"=",
"*",
"listener",
"\n",
"e",
".",
"serveHTTP",
"(",
"pprof",
")",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}",
"\n\n",
"e",
".",
"listeners",
"[",
"pprof",
"]",
"=",
"*",
"listener",
"\n",
"e",
".",
"serveHTTP",
"(",
"pprof",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
17,565 | all-17566 | [
"WriteToRequest",
"writes",
"these",
"params",
"to",
"a",
"swagger",
"request"
]
| [
"func",
"(",
"o",
"*",
"UpdateVMWithStateParams",
")",
"WriteToRequest",
"(",
"r",
"runtime",
".",
"ClientRequest",
",",
"reg",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"if",
"err",
":=",
"r",
".",
"SetTimeout",
"(",
"o",
".",
"timeout",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"o",
".",
"<mask>",
"==",
"nil",
"{",
"o",
".",
"Body",
"=",
"new",
"(",
"models",
".",
"VMState",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"r",
".",
"SetBodyParam",
"(",
"o",
".",
"Body",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// path param cid",
"if",
"err",
":=",
"r",
".",
"SetPathParam",
"(",
"\"",
"\"",
",",
"swag",
".",
"FormatInt32",
"(",
"o",
".",
"Cid",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,566 | all-17567 | [
"NewConn",
"creates",
"a",
"new",
"JSON",
"-",
"RPC",
"client",
"/",
"server",
"connection",
"using",
"the",
"given",
"ReadWriteCloser",
"(",
"typically",
"a",
"TCP",
"connection",
"or",
"stdio",
")",
".",
"The",
"JSON",
"-",
"RPC",
"protocol",
"is",
"symmetric",
"so",
"a",
"Conn",
"runs",
"on",
"both",
"ends",
"of",
"a",
"client",
"-",
"server",
"connection",
".",
"NewClient",
"consumes",
"conn",
"so",
"you",
"should",
"call",
"Close",
"on",
"the",
"returned",
"client",
"not",
"on",
"the",
"given",
"conn",
"."
]
| [
"func",
"NewConn",
"(",
"ctx",
"context",
".",
"<mask>",
",",
"stream",
"ObjectStream",
",",
"h",
"Handler",
",",
"opts",
"...",
"ConnOpt",
")",
"*",
"Conn",
"{",
"c",
":=",
"&",
"Conn",
"{",
"stream",
":",
"stream",
",",
"h",
":",
"h",
",",
"pending",
":",
"map",
"[",
"ID",
"]",
"*",
"call",
"{",
"}",
",",
"disconnect",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"if",
"opt",
"==",
"nil",
"{",
"continue",
"\n",
"}",
"\n",
"opt",
"(",
"c",
")",
"\n",
"}",
"\n",
"go",
"c",
".",
"readMessages",
"(",
"ctx",
")",
"\n",
"return",
"c",
"\n",
"}"
]
|
17,567 | all-17568 | [
"NewCompressor",
"creates",
"a",
"new",
"Compressor",
"that",
"will",
"handle",
"encoding",
"responses",
".",
"The",
"level",
"should",
"be",
"one",
"of",
"the",
"ones",
"defined",
"in",
"the",
"flate",
"package",
".",
"The",
"types",
"are",
"the",
"content",
"types",
"that",
"are",
"allowed",
"to",
"be",
"compressed",
"."
]
| [
"func",
"NewCompressor",
"(",
"level",
"int",
",",
"types",
"...",
"string",
")",
"*",
"Compressor",
"{",
"// If types are provided, set those as the allowed types. If none are",
"// provided, use the default list.",
"allowedTypes",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n",
"if",
"len",
"(",
"types",
")",
">",
"0",
"{",
"for",
"_",
",",
"t",
":=",
"range",
"types",
"{",
"allowedTypes",
"[",
"t",
"]",
"=",
"true",
"\n",
"}",
"\n",
"}",
"else",
"{",
"for",
"_",
",",
"t",
":=",
"range",
"defaultCompressibleContentTypes",
"{",
"allowedTypes",
"[",
"t",
"]",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"c",
":=",
"&",
"Compressor",
"{",
"level",
":",
"level",
",",
"encoders",
":",
"<mask>",
"(",
"map",
"[",
"string",
"]",
"EncoderFunc",
")",
",",
"pooledEncoders",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"sync",
".",
"Pool",
")",
",",
"allowedTypes",
":",
"allowedTypes",
",",
"}",
"\n",
"// Set the default encoders. The precedence order uses the reverse",
"// ordering that the encoders were added. This means adding new encoders",
"// will move them to the front of the order.",
"//",
"// TODO:",
"// lzma: Opera.",
"// sdch: Chrome, Android. Gzip output + dictionary header.",
"// br: Brotli, see https://github.com/go-chi/chi/pull/326",
"// HTTP 1.1 \"deflate\" (RFC 2616) stands for DEFLATE data (RFC 1951)",
"// wrapped with zlib (RFC 1950). The zlib wrapper uses Adler-32",
"// checksum compared to CRC-32 used in \"gzip\" and thus is faster.",
"//",
"// But.. some old browsers (MSIE, Safari 5.1) incorrectly expect",
"// raw DEFLATE data only, without the mentioned zlib wrapper.",
"// Because of this major confusion, most modern browsers try it",
"// both ways, first looking for zlib headers.",
"// Quote by Mark Adler: http://stackoverflow.com/a/9186091/385548",
"//",
"// The list of browsers having problems is quite big, see:",
"// http://zoompf.com/blog/2012/02/lose-the-wait-http-compression",
"// https://web.archive.org/web/20120321182910/http://www.vervestudios.co/projects/compression-tests/results",
"//",
"// That's why we prefer gzip over deflate. It's just more reliable",
"// and not significantly slower than gzip.",
"c",
".",
"SetEncoder",
"(",
"\"",
"\"",
",",
"encoderDeflate",
")",
"\n\n",
"// TODO: Exception for old MSIE browsers that can't handle non-HTML?",
"// https://zoompf.com/blog/2012/02/lose-the-wait-http-compression",
"c",
".",
"SetEncoder",
"(",
"\"",
"\"",
",",
"encoderGzip",
")",
"\n\n",
"// NOTE: Not implemented, intentionally:",
"// case \"compress\": // LZW. Deprecated.",
"// case \"bzip2\": // Too slow on-the-fly.",
"// case \"zopfli\": // Too slow on-the-fly.",
"// case \"xz\": // Too slow on-the-fly.",
"return",
"c",
"\n",
"}"
]
|
17,568 | all-17569 | [
"EndSegment",
"ends",
"the",
"segment",
"at",
"the",
"top",
"of",
"the",
"stack",
"."
]
| [
"func",
"(",
"t",
"*",
"tx",
")",
"EndSegment",
"(",
")",
"error",
"{",
"t",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"id",
",",
"ok",
":=",
"t",
".",
"<mask>",
".",
"Pop",
"(",
")",
";",
"ok",
"{",
"return",
"t",
".",
"Tracer",
".",
"EndSegment",
"(",
"t",
".",
"id",
",",
"id",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,569 | all-17570 | [
"NewCLI",
"creates",
"a",
"new",
"CLI",
"object",
"with",
"the",
"given",
"stdout",
"and",
"stderr",
"streams",
"."
]
| [
"func",
"NewCLI",
"(",
"<mask>",
",",
"err",
"io",
".",
"Writer",
")",
"*",
"CLI",
"{",
"return",
"&",
"CLI",
"{",
"outStream",
":",
"out",
",",
"errStream",
":",
"err",
",",
"signalCh",
":",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
")",
",",
"stopCh",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"}"
]
|
17,570 | all-17571 | [
"GetResource",
"returns",
"the",
"Resource",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
]
| [
"func",
"(",
"s",
"*",
"ScreenboardLite",
")",
"GetResource",
"(",
")",
"string",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"<mask>",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"s",
".",
"Resource",
"\n",
"}"
]
|
17,571 | all-17572 | [
"EnableSvcEventHandler",
"creates",
"a",
"new",
"ENABLE_SVC_EVENT_HANDLER",
"Nagios",
"command",
".",
"Enables",
"the",
"event",
"handler",
"for",
"the",
"specified",
"service",
"."
]
| [
"func",
"EnableSvcEventHandler",
"(",
"host_name",
"string",
",",
"service_description",
"<mask>",
",",
")",
"*",
"livestatus",
".",
"Command",
"{",
"return",
"livestatus",
".",
"NewCommand",
"(",
"\"",
"\"",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"host_name",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"service_description",
")",
",",
")",
"\n",
"}"
]
|
17,572 | all-17573 | [
"ApplyChanges",
"simply",
"modifies",
"records",
"in",
"memory",
"error",
"checking",
"occurs",
"before",
"any",
"modifications",
"are",
"made",
"i",
".",
"e",
".",
"batch",
"processing",
"create",
"record",
"-",
"record",
"should",
"not",
"exist",
"update",
"/",
"delete",
"record",
"-",
"record",
"should",
"exist",
"create",
"/",
"update",
"/",
"delete",
"lists",
"should",
"not",
"have",
"overlapping",
"records"
]
| [
"func",
"(",
"im",
"*",
"InMemoryProvider",
")",
"ApplyChanges",
"(",
"changes",
"*",
"plan",
".",
"Changes",
")",
"error",
"{",
"defer",
"im",
".",
"OnApplyChanges",
"(",
"changes",
")",
"\n\n",
"perZoneChanges",
":=",
"map",
"[",
"string",
"]",
"*",
"plan",
".",
"Changes",
"{",
"}",
"\n\n",
"zones",
":=",
"im",
".",
"Zones",
"(",
")",
"\n",
"for",
"zoneID",
":=",
"range",
"zones",
"{",
"perZoneChanges",
"[",
"zoneID",
"]",
"=",
"&",
"plan",
".",
"Changes",
"{",
"}",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"ep",
":=",
"<mask>",
"changes",
".",
"Create",
"{",
"zoneID",
":=",
"im",
".",
"filter",
".",
"EndpointZoneID",
"(",
"ep",
",",
"zones",
")",
"\n",
"if",
"zoneID",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"Create",
"=",
"append",
"(",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"Create",
",",
"ep",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"ep",
":=",
"range",
"changes",
".",
"UpdateNew",
"{",
"zoneID",
":=",
"im",
".",
"filter",
".",
"EndpointZoneID",
"(",
"ep",
",",
"zones",
")",
"\n",
"if",
"zoneID",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"UpdateNew",
"=",
"append",
"(",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"UpdateNew",
",",
"ep",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"ep",
":=",
"range",
"changes",
".",
"UpdateOld",
"{",
"zoneID",
":=",
"im",
".",
"filter",
".",
"EndpointZoneID",
"(",
"ep",
",",
"zones",
")",
"\n",
"if",
"zoneID",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"UpdateOld",
"=",
"append",
"(",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"UpdateOld",
",",
"ep",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"ep",
":=",
"range",
"changes",
".",
"Delete",
"{",
"zoneID",
":=",
"im",
".",
"filter",
".",
"EndpointZoneID",
"(",
"ep",
",",
"zones",
")",
"\n",
"if",
"zoneID",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"Delete",
"=",
"append",
"(",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"Delete",
",",
"ep",
")",
"\n",
"}",
"\n\n",
"for",
"zoneID",
":=",
"range",
"perZoneChanges",
"{",
"change",
":=",
"&",
"inMemoryChange",
"{",
"Create",
":",
"convertToInMemoryRecord",
"(",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"Create",
")",
",",
"UpdateNew",
":",
"convertToInMemoryRecord",
"(",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"UpdateNew",
")",
",",
"UpdateOld",
":",
"convertToInMemoryRecord",
"(",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"UpdateOld",
")",
",",
"Delete",
":",
"convertToInMemoryRecord",
"(",
"perZoneChanges",
"[",
"zoneID",
"]",
".",
"Delete",
")",
",",
"}",
"\n",
"err",
":=",
"im",
".",
"client",
".",
"ApplyChanges",
"(",
"zoneID",
",",
"change",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
17,573 | all-17574 | [
"New",
"parses",
"the",
"given",
"template",
"using",
"the",
"given",
"startTag",
"and",
"endTag",
"as",
"tag",
"start",
"and",
"tag",
"end",
".",
"The",
"returned",
"template",
"can",
"be",
"executed",
"by",
"concurrently",
"running",
"goroutines",
"using",
"Execute",
"*",
"methods",
".",
"New",
"panics",
"if",
"the",
"given",
"template",
"cannot",
"be",
"parsed",
".",
"Use",
"NewTemplate",
"instead",
"if",
"template",
"may",
"contain",
"errors",
"."
]
| [
"func",
"New",
"(",
"template",
",",
"startTag",
",",
"endTag",
"string",
")",
"*",
"Template",
"{",
"t",
",",
"err",
":=",
"NewTemplate",
"(",
"<mask>",
",",
"startTag",
",",
"endTag",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"t",
"\n",
"}"
]
|
17,574 | all-17575 | [
"ZoomTo",
"zooms",
"to",
"the",
"given",
"bounding",
"box",
"."
]
| [
"func",
"(",
"m",
"*",
"<mask>",
")",
"ZoomTo",
"(",
"minx",
",",
"miny",
",",
"maxx",
",",
"maxy",
"float64",
")",
"{",
"bbox",
":=",
"C",
".",
"mapnik_bbox",
"(",
"C",
".",
"double",
"(",
"minx",
")",
",",
"C",
".",
"double",
"(",
"miny",
")",
",",
"C",
".",
"double",
"(",
"maxx",
")",
",",
"C",
".",
"double",
"(",
"maxy",
")",
")",
"\n",
"defer",
"C",
".",
"mapnik_bbox_free",
"(",
"bbox",
")",
"\n",
"C",
".",
"mapnik_map_zoom_to_box",
"(",
"m",
".",
"m",
",",
"bbox",
")",
"\n",
"}"
]
|
17,575 | all-17576 | [
"fieldName",
"returns",
"the",
"name",
"of",
"the",
"field",
"at",
"offset",
"off",
"in",
"x",
"."
]
| [
"func",
"fieldName",
"(",
"c",
"*",
"gocore",
".",
"<mask>",
",",
"x",
"gocore",
".",
"Object",
",",
"off",
"int64",
")",
"string",
"{",
"size",
":=",
"c",
".",
"Size",
"(",
"x",
")",
"\n",
"typ",
",",
"repeat",
":=",
"c",
".",
"Type",
"(",
"x",
")",
"\n",
"if",
"typ",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"off",
")",
"\n",
"}",
"\n",
"n",
":=",
"size",
"/",
"typ",
".",
"Size",
"\n",
"i",
":=",
"off",
"/",
"typ",
".",
"Size",
"\n",
"if",
"i",
"==",
"0",
"&&",
"repeat",
"==",
"1",
"{",
"// Probably a singleton object, no need for array notation.",
"return",
"typeFieldName",
"(",
"typ",
",",
"off",
")",
"\n",
"}",
"\n",
"if",
"i",
">=",
"n",
"{",
"// Partial space at the end of the object - the type can't be complete.",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"off",
")",
"\n",
"}",
"\n",
"q",
":=",
"\"",
"\"",
"\n",
"if",
"i",
">=",
"repeat",
"{",
"// Past the known repeat section, add a ? because we're not sure about the type.",
"q",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"i",
",",
"typeFieldName",
"(",
"typ",
",",
"off",
"-",
"i",
"*",
"typ",
".",
"Size",
")",
",",
"q",
")",
"\n",
"}"
]
|
17,576 | all-17577 | [
"This",
"helper",
"makes",
"sure",
"that",
"when",
"clustered",
"we",
"re",
"not",
"changing",
"node",
"-",
"specific",
"values",
".",
"POSSIBLY",
"TODO",
":",
"for",
"now",
"we",
"don",
"t",
"have",
"any",
"node",
"-",
"specific",
"values",
"that",
"can",
"be",
"modified",
".",
"If",
"we",
"ever",
"get",
"some",
"we",
"ll",
"need",
"to",
"extend",
"the",
"PUT",
"/",
"PATCH",
"APIs",
"to",
"accept",
"a",
"targetNode",
"query",
"parameter",
"."
]
| [
"func",
"storagePoolValidateClusterConfig",
"(",
"reqConfig",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"for",
"key",
":=",
"<mask>",
"reqConfig",
"{",
"if",
"shared",
".",
"StringInSlice",
"(",
"key",
",",
"db",
".",
"StoragePoolNodeConfigKeys",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,577 | all-17578 | [
"NewManageOfferResult",
"creates",
"a",
"new",
"ManageOfferResult",
"."
]
| [
"func",
"NewManageOfferResult",
"(",
"code",
"ManageOfferResultCode",
",",
"value",
"<mask>",
"{",
"}",
")",
"(",
"result",
"ManageOfferResult",
",",
"err",
"error",
")",
"{",
"result",
".",
"Code",
"=",
"code",
"\n",
"switch",
"ManageOfferResultCode",
"(",
"code",
")",
"{",
"case",
"ManageOfferResultCodeManageOfferSuccess",
":",
"tv",
",",
"ok",
":=",
"value",
".",
"(",
"ManageOfferSuccessResult",
")",
"\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"result",
".",
"Success",
"=",
"&",
"tv",
"\n",
"default",
":",
"// void",
"}",
"\n",
"return",
"\n",
"}"
]
|
17,578 | all-17579 | [
"shutdownFinished",
"closes",
"the",
"shutdownComplete",
"channel",
"10",
"miliseconds",
"after",
"being",
"invoked",
"(",
"to",
"give",
"a",
"cmd",
"ctrl",
"client",
"a",
"chance",
"to",
"return",
"."
]
| [
"func",
"(",
"o",
"*",
"Server",
")",
"shutdownFinished",
"(",
")",
"{",
"<mask>",
".",
"Sleep",
"(",
"10",
"*",
"time",
".",
"Millisecond",
")",
"\n",
"close",
"(",
"o",
".",
"ShutdownComplete",
")",
"\n",
"}"
]
|
17,579 | all-17580 | [
"TaskARNByV3EndpointID",
"returns",
"a",
"taskARN",
"for",
"a",
"given",
"v3",
"endpoint",
"ID"
]
| [
"func",
"(",
"state",
"*",
"DockerTaskEngineState",
")",
"TaskARNByV3EndpointID",
"(",
"v3EndpointID",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"state",
".",
"<mask>",
".",
"RLock",
"(",
")",
"\n",
"defer",
"state",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"taskArn",
",",
"ok",
":=",
"state",
".",
"v3EndpointIDToTask",
"[",
"v3EndpointID",
"]",
"\n",
"return",
"taskArn",
",",
"ok",
"\n",
"}"
]
|
17,580 | all-17581 | [
"/",
"*",
"LoadConfigurationFromReader",
"takes",
"a",
"reader",
"and",
"scans",
"it",
"for",
"an",
"ini",
"configuration",
".",
"The",
"caller",
"should",
"close",
"the",
"reader",
"."
]
| [
"func",
"LoadConfigurationFromReader",
"(",
"<mask>",
"io",
".",
"Reader",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"config",
":=",
"new",
"(",
"Config",
")",
"\n",
"err",
":=",
"config",
".",
"InitializeFromReader",
"(",
"input",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"config",
",",
"nil",
"\n",
"}"
]
|
17,581 | all-17582 | [
"lookUp",
"is",
"a",
"generic",
"parser",
"to",
"looking",
"for",
"a",
"value",
".",
"The",
"count",
"determines",
"the",
"number",
"of",
"fields",
"to",
"return",
":",
"n",
">",
"0",
":",
"at",
"most",
"n",
"fields",
"n",
"==",
"0",
":",
"the",
"result",
"is",
"nil",
"(",
"zero",
"fields",
")",
"n",
"<",
"0",
":",
"all",
"fields"
]
| [
"func",
"lookUp",
"(",
"_row",
"row",
",",
"_field",
"field",
",",
"value",
"interface",
"{",
"}",
",",
"n",
"int",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"n",
"==",
"0",
"{",
"return",
"nil",
",",
"errSearch",
"\n",
"}",
"\n\n",
"dbf",
",",
"err",
":=",
"openDBFile",
"(",
"_row",
".",
"filename",
"(",
")",
",",
"os",
".",
"O_RDONLY",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"dbf",
".",
"close",
"(",
")",
"\n\n",
"// Lines where a field is matched.",
"entries",
":=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"0",
",",
"0",
")",
"\n\n",
"for",
"{",
"<mask>",
",",
"_",
",",
"err",
":=",
"dbf",
".",
"rd",
".",
"ReadLine",
"(",
")",
"\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"break",
"\n",
"}",
"\n\n",
"entry",
":=",
"_row",
".",
"lookUp",
"(",
"string",
"(",
"line",
")",
",",
"_field",
",",
"value",
")",
"\n",
"if",
"entry",
"!=",
"nil",
"{",
"entries",
"=",
"append",
"(",
"entries",
",",
"entry",
")",
"\n",
"}",
"\n\n",
"if",
"n",
"<",
"0",
"{",
"continue",
"\n",
"}",
"else",
"if",
"n",
"==",
"len",
"(",
"entries",
")",
"{",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"entries",
")",
"!=",
"0",
"{",
"return",
"entries",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"NoFoundError",
"{",
"_row",
".",
"filename",
"(",
")",
",",
"_field",
".",
"String",
"(",
")",
",",
"value",
"}",
"\n",
"}"
]
|
17,582 | all-17583 | [
"Errorf",
"logs",
"an",
"ERROR",
"log",
"message",
"to",
"the",
"logger",
"specified",
"in",
"opts",
"or",
"to",
"the",
"global",
"logger",
"if",
"no",
"logger",
"is",
"specified",
"in",
"opts",
"."
]
| [
"func",
"(",
"opt",
"*",
"Options",
")",
"Errorf",
"(",
"format",
"string",
",",
"v",
"...",
"<mask>",
"{",
"}",
")",
"{",
"if",
"opt",
".",
"Logger",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"opt",
".",
"Logger",
".",
"Errorf",
"(",
"format",
",",
"v",
"...",
")",
"\n",
"}"
]
|
17,583 | all-17584 | [
"Done",
"should",
"be",
"called",
"by",
"workers",
"when",
"they",
"finish",
"working",
".",
"They",
"can",
"also",
"pass",
"the",
"error",
"status",
"of",
"work",
"done",
"."
]
| [
"func",
"(",
"t",
"*",
"Throttle",
")",
"Done",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"t",
".",
"errCh",
"<-",
"err",
"\n",
"}",
"\n",
"select",
"{",
"<mask>",
"<-",
"t",
".",
"ch",
":",
"default",
":",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"t",
".",
"wg",
".",
"Done",
"(",
")",
"\n",
"}"
]
|
17,584 | all-17585 | [
"PhantomJS",
"returns",
"an",
"instance",
"of",
"a",
"PhantomJS",
"WebDriver",
".",
"Provided",
"Options",
"will",
"apply",
"as",
"default",
"arguments",
"for",
"new",
"pages",
".",
"New",
"pages",
"will",
"accept",
"invalid",
"SSL",
"certificates",
"by",
"default",
".",
"This",
"may",
"be",
"disabled",
"using",
"the",
"RejectInvalidSSL",
"Option",
".",
"The",
"RejectInvalidSSL",
"Option",
"must",
"be",
"provided",
"to",
"the",
"PhantomJS",
"function",
"(",
"and",
"not",
"the",
"NewPage",
"method",
")",
"for",
"this",
"Option",
"to",
"take",
"effect",
"on",
"any",
"PhantomJS",
"page",
"."
]
| [
"func",
"PhantomJS",
"(",
"options",
"...",
"Option",
")",
"*",
"WebDriver",
"{",
"command",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"\n",
"defaultOptions",
":=",
"config",
"{",
"}",
".",
"Merge",
"(",
"options",
")",
"\n",
"if",
"!",
"defaultOptions",
".",
"RejectInvalidSSL",
"{",
"command",
"=",
"append",
"(",
"command",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"NewWebDriver",
"(",
"\"",
"\"",
",",
"<mask>",
",",
"options",
"...",
")",
"\n",
"}"
]
|
17,585 | all-17586 | [
"CreateDowntime",
"adds",
"a",
"new",
"downtme",
"to",
"the",
"system",
".",
"This",
"returns",
"a",
"pointer",
"to",
"a",
"Downtime",
"so",
"you",
"can",
"pass",
"that",
"to",
"UpdateDowntime",
"or",
"CancelDowntime",
"later",
"if",
"needed",
"."
]
| [
"func",
"(",
"client",
"*",
"Client",
")",
"CreateDowntime",
"(",
"downtime",
"*",
"Downtime",
")",
"(",
"*",
"Downtime",
",",
"error",
")",
"{",
"var",
"out",
"Downtime",
"\n",
"if",
"err",
":=",
"<mask>",
".",
"doJsonRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"downtime",
",",
"&",
"out",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"out",
",",
"nil",
"\n",
"}"
]
|
17,586 | all-17587 | [
"CreateTemporaryCredentials",
"is",
"an",
"alias",
"for",
"CreateNamedTemporaryCredentials",
"with",
"an",
"empty",
"name",
"."
]
| [
"func",
"(",
"permaCreds",
"*",
"Credentials",
")",
"CreateTemporaryCredentials",
"(",
"duration",
"time",
".",
"Duration",
",",
"scopes",
"...",
"string",
")",
"(",
"tempCreds",
"*",
"Credentials",
",",
"err",
"error",
")",
"{",
"return",
"permaCreds",
".",
"CreateNamedTemporaryCredentials",
"(",
"\"",
"\"",
",",
"<mask>",
",",
"scopes",
"...",
")",
"\n",
"}"
]
|
17,587 | all-17588 | [
"===",
"log2",
"(",
"Vector",
"ValueTypeVector",
")",
"Vector",
"==="
]
| [
"func",
"funcLog2",
"(",
"vals",
"[",
"]",
"<mask>",
",",
"args",
"Expressions",
",",
"enh",
"*",
"EvalNodeHelper",
")",
"Vector",
"{",
"return",
"simpleFunc",
"(",
"vals",
",",
"enh",
",",
"math",
".",
"Log2",
")",
"\n",
"}"
]
|
17,588 | all-17589 | [
"openReadOnly",
"assumes",
"that",
"we",
"have",
"a",
"write",
"lock",
"on",
"logFile",
"."
]
| [
"func",
"(",
"lf",
"*",
"logFile",
")",
"openReadOnly",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"lf",
".",
"fd",
",",
"err",
"=",
"os",
".",
"OpenFile",
"(",
"lf",
".",
"<mask>",
",",
"os",
".",
"O_RDONLY",
",",
"0666",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"lf",
".",
"path",
")",
"\n",
"}",
"\n\n",
"fi",
",",
"err",
":=",
"lf",
".",
"fd",
".",
"Stat",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"lf",
".",
"path",
")",
"\n",
"}",
"\n",
"y",
".",
"AssertTrue",
"(",
"fi",
".",
"Size",
"(",
")",
"<=",
"math",
".",
"MaxUint32",
")",
"\n",
"lf",
".",
"size",
"=",
"uint32",
"(",
"fi",
".",
"Size",
"(",
")",
")",
"\n\n",
"if",
"err",
"=",
"lf",
".",
"mmap",
"(",
"fi",
".",
"Size",
"(",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"_",
"=",
"lf",
".",
"fd",
".",
"Close",
"(",
")",
"\n",
"return",
"y",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
17,589 | all-17590 | [
"Open",
"returns",
"the",
"most",
"recently",
"uploaded",
"file",
"with",
"the",
"provided",
"name",
"for",
"reading",
".",
"If",
"the",
"file",
"isn",
"t",
"found",
"err",
"will",
"be",
"set",
"to",
"mgo",
".",
"ErrNotFound",
".",
"It",
"s",
"important",
"to",
"Close",
"files",
"whether",
"they",
"are",
"being",
"written",
"to",
"or",
"read",
"from",
"and",
"to",
"check",
"the",
"err",
"result",
"to",
"ensure",
"the",
"operation",
"completed",
"successfully",
".",
"The",
"following",
"example",
"will",
"print",
"the",
"first",
"8192",
"bytes",
"from",
"the",
"file",
":",
"file",
"err",
":",
"=",
"db",
".",
"GridFS",
"(",
"fs",
")",
".",
"Open",
"(",
"myfile",
".",
"txt",
")",
"check",
"(",
"err",
")",
"b",
":",
"=",
"make",
"(",
"[]",
"byte",
"8192",
")",
"n",
"err",
":",
"=",
"file",
".",
"Read",
"(",
"b",
")",
"check",
"(",
"err",
")",
"fmt",
".",
"Println",
"(",
"string",
"(",
"b",
"))",
"check",
"(",
"err",
")",
"err",
"=",
"file",
".",
"Close",
"()",
"check",
"(",
"err",
")",
"fmt",
".",
"Printf",
"(",
"%d",
"bytes",
"read",
"\\",
"n",
"n",
")",
"The",
"io",
".",
"Reader",
"interface",
"is",
"implemented",
"by",
"*",
"GridFile",
"and",
"may",
"be",
"used",
"to",
"deal",
"with",
"it",
".",
"As",
"an",
"example",
"the",
"following",
"snippet",
"will",
"dump",
"the",
"whole",
"file",
"into",
"the",
"standard",
"output",
":",
"file",
"err",
":",
"=",
"db",
".",
"GridFS",
"(",
"fs",
")",
".",
"Open",
"(",
"myfile",
".",
"txt",
")",
"check",
"(",
"err",
")",
"err",
"=",
"io",
".",
"Copy",
"(",
"os",
".",
"Stdout",
"file",
")",
"check",
"(",
"err",
")",
"err",
"=",
"file",
".",
"Close",
"()",
"check",
"(",
"err",
")"
]
| [
"func",
"(",
"gfs",
"*",
"GridFS",
")",
"Open",
"(",
"<mask>",
"string",
")",
"(",
"file",
"*",
"GridFile",
",",
"err",
"error",
")",
"{",
"var",
"doc",
"gfsFile",
"\n",
"err",
"=",
"gfs",
".",
"Files",
".",
"Find",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"name",
"}",
")",
".",
"Sort",
"(",
"\"",
"\"",
")",
".",
"One",
"(",
"&",
"doc",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"file",
"=",
"gfs",
".",
"newFile",
"(",
")",
"\n",
"file",
".",
"mode",
"=",
"gfsReading",
"\n",
"file",
".",
"doc",
"=",
"doc",
"\n",
"return",
"\n",
"}"
]
|
17,590 | all-17591 | [
"SetAppliedStatus",
"sets",
"the",
"applied",
"status",
"of",
"resource",
"and",
"returns",
"whether",
"the",
"resource",
"is",
"already",
"in",
"a",
"transition"
]
| [
"func",
"(",
"secret",
"*",
"ASMSecretResource",
")",
"SetAppliedStatus",
"(",
"status",
"resourcestatus",
".",
"ResourceStatus",
")",
"bool",
"{",
"secret",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"<mask>",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"secret",
".",
"appliedStatus",
"!=",
"resourcestatus",
".",
"ResourceStatus",
"(",
"ASMSecretStatusNone",
")",
"{",
"// return false to indicate the set operation failed",
"return",
"false",
"\n",
"}",
"\n\n",
"secret",
".",
"appliedStatus",
"=",
"status",
"\n",
"return",
"true",
"\n",
"}"
]
|
17,591 | all-17592 | [
"Process",
"-",
"go_googleapis",
"case"
]
| [
"func",
"generateFromPath",
"(",
"w",
"io",
".",
"Writer",
",",
"rootPath",
"string",
")",
"error",
"{",
"return",
"filepath",
".",
"Walk",
"(",
"rootPath",
",",
"func",
"(",
"path",
"string",
",",
"info",
"os",
".",
"FileInfo",
",",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"!",
"strings",
".",
"HasSuffix",
"(",
"path",
",",
"\"",
"\"",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"relPath",
",",
"err",
":=",
"filepath",
".",
"Rel",
"(",
"rootPath",
",",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"strings",
".",
"HasPrefix",
"(",
"relPath",
",",
"\"",
"\"",
")",
"{",
"log",
".",
"Panicf",
"(",
"\"",
"\"",
",",
"<mask>",
",",
"rootPath",
")",
"\n",
"}",
"\n",
"relPath",
"=",
"filepath",
".",
"ToSlash",
"(",
"relPath",
")",
"\n\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"relPath",
",",
"\"",
"\"",
")",
"{",
"// Special case: these protos need to be built together with protos in",
"// google/api. They have the same 'option go_package'. The proto_library",
"// rule requires them to be in the same Bazel package, so we don't",
"// create a build file in experimental.",
"packagePath",
":=",
"\"",
"\"",
"\n",
"protoLabel",
",",
"goLabel",
":=",
"protoLabels",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\n",
"\"",
",",
"relPath",
",",
"protoLabel",
",",
"packagePath",
",",
"goLabel",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"packagePath",
",",
"packageName",
",",
"err",
":=",
"loadGoPackage",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Print",
"(",
"err",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"protoLabel",
",",
"goLabel",
":=",
"protoLabels",
"(",
"relPath",
",",
"packageName",
")",
"\n\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\n",
"\"",
",",
"relPath",
",",
"protoLabel",
",",
"packagePath",
",",
"goLabel",
")",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"}"
]
|
17,592 | all-17593 | [
"Advertise",
"advertises",
"the",
"service",
"with",
"Hyperbahn",
"and",
"returns",
"any",
"errors",
"on",
"initial",
"advertisement",
".",
"Advertise",
"can",
"register",
"multiple",
"services",
"hosted",
"on",
"the",
"same",
"endpoint",
".",
"If",
"the",
"advertisement",
"succeeds",
"a",
"goroutine",
"is",
"started",
"to",
"re",
"-",
"advertise",
"periodically",
"."
]
| [
"func",
"(",
"c",
"*",
"<mask>",
")",
"Advertise",
"(",
"otherServices",
"...",
"tchannel",
".",
"Registrar",
")",
"error",
"{",
"c",
".",
"getServiceNames",
"(",
"otherServices",
")",
"\n\n",
"if",
"err",
":=",
"c",
".",
"initialAdvertise",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"c",
".",
"opts",
".",
"Handler",
".",
"On",
"(",
"Advertised",
")",
"\n",
"go",
"c",
".",
"advertiseLoop",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,593 | all-17594 | [
"HasManageStatusShowTitle",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"w",
"*",
"Widget",
")",
"HasManageStatusShowTitle",
"(",
")",
"bool",
"{",
"if",
"w",
"!=",
"nil",
"&&",
"w",
".",
"ManageStatusShowTitle",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
|
17,594 | all-17595 | [
"WithRootCAs",
"instructs",
"the",
"New",
"*",
"functions",
"to",
"create",
"client",
"that",
"uses",
"the",
"given",
"signed",
"x509",
"certificates",
"as",
"the",
"trusted",
"root",
"certificates",
"(",
"instead",
"of",
"the",
"system",
"certs",
")",
".",
"Introduced",
"to",
"pass",
"certs",
"provided",
"via",
"command",
"-",
"line",
"flags"
]
| [
"func",
"WithRootCAs",
"(",
"<mask>",
"string",
")",
"Option",
"{",
"return",
"func",
"(",
"settings",
"*",
"clientSettings",
")",
"error",
"{",
"settings",
".",
"caCerts",
"=",
"x509",
".",
"NewCertPool",
"(",
")",
"\n",
"return",
"addCertFromFile",
"(",
"settings",
".",
"caCerts",
",",
"path",
")",
"\n",
"}",
"\n",
"}"
]
|
17,595 | all-17596 | [
"SignBytes",
"creates",
"a",
"signature",
"for",
"buf",
"."
]
| [
"func",
"(",
"<mask>",
"*",
"RSASigner",
")",
"SignBytes",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// check rs.priv",
"if",
"rs",
".",
"priv",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrMissingPrivateKey",
"\n",
"}",
"\n\n",
"// hash",
"h",
":=",
"rs",
".",
"hash",
".",
"New",
"(",
")",
"\n",
"_",
",",
"err",
"=",
"h",
".",
"Write",
"(",
"buf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// sign",
"return",
"rs",
".",
"method",
".",
"Sign",
"(",
"rand",
".",
"Reader",
",",
"rs",
".",
"priv",
",",
"rs",
".",
"hash",
",",
"h",
".",
"Sum",
"(",
"nil",
")",
")",
"\n",
"}"
]
|
17,596 | all-17597 | [
"SetRequiredVersion",
"is",
"a",
"wrapper",
"around",
"gtk_gl_area_set_required_version",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"GLArea",
")",
"SetRequiredVersion",
"(",
"major",
",",
"minor",
"int",
")",
"{",
"C",
".",
"gtk_gl_area_set_required_version",
"(",
"v",
".",
"native",
"(",
")",
",",
"(",
"C",
".",
"int",
")",
"(",
"<mask>",
")",
",",
"(",
"C",
".",
"int",
")",
"(",
"minor",
")",
")",
"\n",
"}"
]
|
17,597 | all-17598 | [
"PangoAttrList",
"*",
"pango_layout_get_attributes",
"(",
"PangoLayout",
"*",
"layout",
")",
";"
]
| [
"func",
"(",
"v",
"*",
"Layout",
")",
"GetAttributes",
"(",
")",
"*",
"AttrList",
"{",
"c",
":=",
"C",
".",
"pango_layout_get_attributes",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n\n",
"attrList",
":=",
"<mask>",
"(",
"AttrList",
")",
"\n",
"attrList",
".",
"pangoAttrList",
"=",
"(",
"*",
"C",
".",
"PangoAttrList",
")",
"(",
"c",
")",
"\n\n",
"return",
"attrList",
"\n",
"}"
]
|
17,598 | all-17599 | [
"Save",
"writes",
"the",
"build",
"file",
"to",
"disk",
".",
"This",
"method",
"calls",
"Sync",
"internally",
"."
]
| [
"func",
"(",
"f",
"*",
"File",
")",
"Save",
"(",
"path",
"string",
")",
"error",
"{",
"f",
".",
"Sync",
"(",
")",
"\n",
"data",
":=",
"bzl",
".",
"Format",
"(",
"f",
".",
"File",
")",
"\n",
"return",
"ioutil",
".",
"WriteFile",
"(",
"<mask>",
",",
"data",
",",
"0666",
")",
"\n",
"}"
]
|
17,599 | all-17600 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"SetDocumentCookieDisabledParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoEmulation11",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.