id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
listlengths 1
418
| pl_tokens
listlengths 22
4.98k
|
---|---|---|---|
17,400 | all-17401 | [
"Send",
"sends",
"the",
"chat",
"action",
".",
"On",
"success",
"nil",
"is",
"returned",
"."
]
| [
"func",
"(",
"oc",
"*",
"OutgoingChatAction",
")",
"Send",
"(",
")",
"error",
"{",
"resp",
":=",
"&",
"baseResponse",
"{",
"}",
"\n",
"_",
",",
"err",
":=",
"oc",
".",
"api",
".",
"c",
".",
"postJSON",
"(",
"sendChatAction",
",",
"resp",
",",
"oc",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"(",
"resp",
")",
"\n",
"}"
]
|
17,401 | all-17402 | [
"RemoveAll",
"finds",
"all",
"documents",
"matching",
"the",
"provided",
"selector",
"document",
"and",
"removes",
"them",
"from",
"the",
"database",
".",
"In",
"case",
"the",
"session",
"is",
"in",
"safe",
"mode",
"(",
"see",
"the",
"SetSafe",
"method",
")",
"and",
"an",
"error",
"happens",
"when",
"attempting",
"the",
"change",
"the",
"returned",
"error",
"will",
"be",
"of",
"type",
"*",
"LastError",
".",
"Relevant",
"documentation",
":",
"http",
":",
"//",
"www",
".",
"mongodb",
".",
"org",
"/",
"display",
"/",
"DOCS",
"/",
"Removing"
]
| [
"func",
"(",
"c",
"*",
"Collection",
")",
"RemoveAll",
"(",
"selector",
"interface",
"{",
"}",
")",
"(",
"<mask>",
"*",
"ChangeInfo",
",",
"err",
"error",
")",
"{",
"lerr",
",",
"err",
":=",
"c",
".",
"writeQuery",
"(",
"&",
"deleteOp",
"{",
"c",
".",
"FullName",
",",
"selector",
",",
"0",
"}",
")",
"\n",
"if",
"err",
"==",
"nil",
"&&",
"lerr",
"!=",
"nil",
"{",
"info",
"=",
"&",
"ChangeInfo",
"{",
"Removed",
":",
"lerr",
".",
"N",
"}",
"\n",
"}",
"\n",
"return",
"info",
",",
"err",
"\n",
"}"
]
|
17,402 | all-17403 | [
"GetPaletteFlipOk",
"returns",
"a",
"tuple",
"with",
"the",
"PaletteFlip",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"s",
"*",
"Style",
")",
"GetPaletteFlipOk",
"(",
")",
"(",
"bool",
",",
"bool",
")",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"PaletteFlip",
"==",
"nil",
"{",
"return",
"<mask>",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"s",
".",
"PaletteFlip",
",",
"true",
"\n",
"}"
]
|
17,403 | all-17404 | [
"CookieValue",
"returns",
"the",
"value",
"of",
"the",
"named",
"cookie"
]
| [
"func",
"(",
"r",
"*",
"<mask>",
")",
"CookieValue",
"(",
"name",
"string",
")",
"string",
"{",
"c",
",",
"err",
":=",
"r",
".",
"Cookie",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"c",
".",
"Value",
"\n",
"}"
]
|
17,404 | all-17405 | [
"Returns",
"the",
"parsed",
"languages",
"in",
"a",
"human",
"readable",
"fashion",
"."
]
| [
"func",
"(",
"al",
"AcceptLanguages",
")",
"String",
"(",
")",
"string",
"{",
"output",
":=",
"bytes",
".",
"NewBufferString",
"(",
"\"",
"\"",
")",
"\n",
"for",
"i",
",",
"language",
":=",
"range",
"al",
"{",
"output",
".",
"WriteString",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"language",
".",
"Language",
",",
"language",
".",
"Quality",
")",
")",
"\n",
"if",
"i",
"!=",
"len",
"(",
"al",
")",
"-",
"1",
"{",
"<mask>",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"output",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"output",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"output",
".",
"String",
"(",
")",
"\n",
"}"
]
|
17,405 | all-17406 | [
"IsMetricActive",
"checks",
"whether",
"a",
"given",
"metric",
"name",
"is",
"currently",
"active",
"(",
"enabled",
")"
]
| [
"func",
"(",
"cm",
"*",
"CheckManager",
")",
"IsMetricActive",
"(",
"name",
"string",
")",
"bool",
"{",
"cm",
".",
"availableMetricsmu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cm",
".",
"availableMetricsmu",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"cm",
".",
"availableMetrics",
"[",
"<mask>",
"]",
"\n",
"}"
]
|
17,406 | all-17407 | [
"Next",
"returns",
"the",
"key",
"of",
"the",
"next",
"result",
".",
"When",
"there",
"are",
"no",
"more",
"results",
"Done",
"is",
"returned",
"as",
"the",
"error",
".",
"If",
"the",
"query",
"is",
"not",
"keys",
"only",
"and",
"dst",
"is",
"non",
"-",
"nil",
"it",
"also",
"loads",
"the",
"entity",
"stored",
"for",
"that",
"key",
"into",
"the",
"struct",
"pointer",
"or",
"PropertyLoadSaver",
"dst",
"with",
"the",
"same",
"semantics",
"and",
"possible",
"errors",
"as",
"for",
"the",
"Get",
"function",
"."
]
| [
"func",
"(",
"t",
"*",
"Iterator",
")",
"Next",
"(",
"dst",
"interface",
"{",
"}",
")",
"(",
"*",
"<mask>",
",",
"error",
")",
"{",
"k",
",",
"e",
",",
"err",
":=",
"t",
".",
"next",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"dst",
"!=",
"nil",
"&&",
"!",
"t",
".",
"q",
".",
"keysOnly",
"{",
"err",
"=",
"loadEntity",
"(",
"dst",
",",
"e",
")",
"\n",
"}",
"\n",
"return",
"k",
",",
"err",
"\n",
"}"
]
|
17,407 | all-17408 | [
"establish",
"data",
"storage",
"format",
"and",
"dimensions",
"of",
"a",
"renderbuffer",
"object",
"s",
"image"
]
| [
"func",
"RenderbufferStorage",
"(",
"target",
"uint32",
",",
"internalformat",
"uint32",
",",
"width",
"int32",
",",
"height",
"int32",
")",
"{",
"C",
".",
"glowRenderbufferStorage",
"(",
"gpRenderbufferStorage",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"target",
")",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"internalformat",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"width",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"<mask>",
")",
")",
"\n",
"}"
]
|
17,408 | all-17409 | [
"FillExtents",
"is",
"a",
"wrapper",
"around",
"cairo_fill_extents",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"Context",
")",
"FillExtents",
"(",
")",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"float64",
")",
"{",
"<mask>",
"cx1",
",",
"cy1",
",",
"cx2",
",",
"cy2",
"C",
".",
"double",
"\n",
"C",
".",
"cairo_fill_extents",
"(",
"v",
".",
"native",
"(",
")",
",",
"&",
"cx1",
",",
"&",
"cy1",
",",
"&",
"cx2",
",",
"&",
"cy2",
")",
"\n",
"return",
"float64",
"(",
"cx1",
")",
",",
"float64",
"(",
"cy1",
")",
",",
"float64",
"(",
"cx2",
")",
",",
"float64",
"(",
"cy2",
")",
"\n",
"}"
]
|
17,409 | all-17410 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"GetStyleSheetTextParams",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss36",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
17,410 | all-17411 | [
"GetSubtitle",
"is",
"a",
"wrapper",
"around",
"gtk_header_bar_get_subtitle",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"HeaderBar",
")",
"GetSubtitle",
"(",
")",
"string",
"{",
"cstr",
":=",
"C",
".",
"gtk_header_bar_get_subtitle",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"return",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"<mask>",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
]
|
17,411 | all-17412 | [
"There",
"is",
"no",
"directory",
".",
"ParseReference",
"because",
"it",
"is",
"rather",
"pointless",
".",
"Callers",
"who",
"need",
"a",
"transport",
"-",
"independent",
"interface",
"will",
"go",
"through",
"dirTransport",
".",
"ParseReference",
";",
"callers",
"who",
"intentionally",
"deal",
"with",
"directories",
"can",
"use",
"directory",
".",
"NewReference",
".",
"NewReference",
"returns",
"a",
"directory",
"reference",
"for",
"a",
"specified",
"path",
".",
"We",
"do",
"not",
"expose",
"an",
"API",
"supplying",
"the",
"resolvedPath",
";",
"we",
"could",
"but",
"recomputing",
"it",
"is",
"generally",
"cheap",
"enough",
"that",
"we",
"prefer",
"being",
"confident",
"about",
"the",
"properties",
"of",
"resolvedPath",
"."
]
| [
"func",
"NewReference",
"(",
"path",
"string",
")",
"(",
"types",
".",
"ImageReference",
",",
"error",
")",
"{",
"resolved",
",",
"err",
":=",
"explicitfilepath",
".",
"ResolvePathToFullyExplicit",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"dirReference",
"{",
"path",
":",
"<mask>",
",",
"resolvedPath",
":",
"resolved",
"}",
",",
"nil",
"\n",
"}"
]
|
17,412 | all-17413 | [
"DeregisterObserver",
"deregisters",
"an",
"observer",
"."
]
| [
"func",
"(",
"r",
"*",
"Raft",
")",
"DeregisterObserver",
"(",
"or",
"*",
"Observer",
")",
"{",
"r",
".",
"observersLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"observersLock",
".",
"Unlock",
"(",
")",
"\n",
"<mask>",
"(",
"r",
".",
"observers",
",",
"or",
".",
"id",
")",
"\n",
"}"
]
|
17,413 | all-17414 | [
"CreateFirewallPolicy",
"creates",
"a",
"new",
"firewall",
"policy",
".",
"It",
"takes",
"a",
"FirewallPolicyOptions",
"struct",
"for",
"specifying",
"name",
"and",
"other",
"attributes",
".",
"Not",
"all",
"attributes",
"can",
"be",
"specified",
"at",
"create",
"time",
"(",
"such",
"as",
"Id",
"which",
"is",
"allocated",
"for",
"you",
")"
]
| [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateFirewallPolicy",
"(",
"policyOptions",
"*",
"FirewallPolicyOptions",
")",
"(",
"*",
"FirewallPolicy",
",",
"error",
")",
"{",
"<mask>",
":=",
"new",
"(",
"FirewallPolicy",
")",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"MakeApiRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"policyOptions",
",",
"&",
"policy",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"policy",
",",
"nil",
"\n",
"}"
]
|
17,414 | all-17415 | [
"NewMigrateCommand",
"returns",
"the",
"cobra",
"command",
"for",
"migrate",
"."
]
| [
"func",
"NewMigrateCommand",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"mc",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"migrateCommandFunc",
",",
"}",
"\n\n",
"mc",
".",
"Flags",
"(",
")",
".",
"BoolVar",
"(",
"&",
"migrateExcludeTTLKey",
",",
"\"",
"\"",
",",
"<mask>",
",",
"\"",
"\"",
")",
"\n",
"mc",
".",
"Flags",
"(",
")",
".",
"StringVar",
"(",
"&",
"migrateDatadir",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"mc",
".",
"Flags",
"(",
")",
".",
"StringVar",
"(",
"&",
"migrateWALdir",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"mc",
".",
"Flags",
"(",
")",
".",
"StringVar",
"(",
"&",
"migrateTransformer",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"mc",
"\n",
"}"
]
|
17,415 | all-17416 | [
"native",
"returns",
"a",
"pointer",
"to",
"the",
"underlying",
"GtkRadioMenuItem",
"."
]
| [
"func",
"(",
"v",
"*",
"RadioMenuItem",
")",
"native",
"(",
")",
"*",
"C",
".",
"GtkRadioMenuItem",
"{",
"if",
"v",
"==",
"nil",
"||",
"v",
".",
"GObject",
"==",
"nil",
"{",
"<mask>",
"nil",
"\n",
"}",
"\n",
"p",
":=",
"unsafe",
".",
"Pointer",
"(",
"v",
".",
"GObject",
")",
"\n",
"return",
"C",
".",
"toGtkRadioMenuItem",
"(",
"p",
")",
"\n",
"}"
]
|
17,416 | all-17417 | [
"AddRule",
"inserts",
"a",
"new",
"rule",
"with",
"the",
"given",
"ruleText",
"in",
"a",
"stylesheet",
"with",
"given",
"styleSheetId",
"at",
"the",
"position",
"specified",
"by",
"location",
".",
"See",
":",
"https",
":",
"//",
"chromedevtools",
".",
"github",
".",
"io",
"/",
"devtools",
"-",
"protocol",
"/",
"tot",
"/",
"CSS#method",
"-",
"addRule",
"parameters",
":",
"styleSheetID",
"-",
"The",
"css",
"style",
"sheet",
"identifier",
"where",
"a",
"new",
"rule",
"should",
"be",
"inserted",
".",
"ruleText",
"-",
"The",
"text",
"of",
"a",
"new",
"rule",
".",
"location",
"-",
"Text",
"position",
"of",
"a",
"new",
"rule",
"in",
"the",
"target",
"style",
"sheet",
"."
]
| [
"func",
"AddRule",
"(",
"styleSheetID",
"StyleSheetID",
",",
"ruleText",
"string",
",",
"location",
"*",
"SourceRange",
")",
"*",
"AddRuleParams",
"{",
"return",
"&",
"AddRuleParams",
"{",
"StyleSheetID",
":",
"styleSheetID",
",",
"RuleText",
":",
"ruleText",
",",
"<mask>",
":",
"location",
",",
"}",
"\n",
"}"
]
|
17,417 | all-17418 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"AddScriptToEvaluateOnNewDocumentReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage83",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
17,418 | all-17419 | [
"Connect",
"connects",
"to",
"mongodb"
]
| [
"func",
"Connect",
"(",
")",
"{",
"uri",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"len",
"(",
"uri",
")",
"==",
"0",
"{",
"uri",
"=",
"MongoDBUrl",
"\n",
"}",
"\n\n",
"mongo",
",",
"err",
":=",
"mgo",
".",
"ParseURL",
"(",
"uri",
")",
"\n",
"s",
",",
"err",
":=",
"mgo",
".",
"Dial",
"(",
"uri",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"panic",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"s",
".",
"SetSafe",
"(",
"&",
"mgo",
".",
"Safe",
"{",
"}",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"uri",
")",
"\n",
"<mask>",
"=",
"s",
"\n",
"Mongo",
"=",
"mongo",
"\n",
"}"
]
|
17,419 | all-17420 | [
"FilterSensitive",
"creates",
"a",
"Filter",
"that",
"filters",
"most",
"sensitive",
"data",
"like",
"passwords",
"keys",
"access_tokens",
"etc",
".",
"and",
"replaces",
"them",
"with",
"the",
"elided",
"value"
]
| [
"func",
"FilterSensitive",
"(",
"sensitive",
"[",
"]",
"string",
",",
"elided",
"interface",
"{",
"}",
")",
"Filter",
"{",
"return",
"FilterFunc",
"(",
"func",
"(",
"key",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"<mask>",
"{",
"}",
"{",
"lower",
":=",
"strings",
".",
"ToLower",
"(",
"key",
")",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"sensitive",
"{",
"if",
"lower",
"==",
"s",
"{",
"return",
"elided",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"v",
"\n",
"}",
")",
"\n",
"}"
]
|
17,420 | all-17421 | [
"SetLogToStderr",
"sets",
"the",
"flag",
"that",
"if",
"true",
"logs",
"to",
"standard",
"error",
"instead",
"of",
"files"
]
| [
"func",
"(",
"l",
"*",
"<mask>",
")",
"SetLogToStderr",
"(",
"f",
"bool",
")",
"{",
"l",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"l",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"l",
".",
"toStderr",
"=",
"f",
"\n\n",
"}"
]
|
17,421 | all-17422 | [
"Get",
"the",
"arguments",
"(",
"i",
".",
"e",
".",
"domain",
"-",
"spec",
"ip4",
"-",
"network",
"ip6",
"-",
"network",
"dual",
"-",
"cidr",
"-",
"length",
"ip4",
"-",
"cidr",
"-",
"length",
"ip6",
"-",
"cidr",
"-",
"length",
")",
"See",
"TestDirective",
"-",
">",
"directive",
".",
"getArguments",
"()",
"for",
"possible",
"return",
"values"
]
| [
"func",
"(",
"d",
"*",
"Directive",
")",
"getArguments",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"arguments",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"index",
":=",
"-",
"1",
"\n",
"ip",
":=",
"false",
"\n\n",
"term",
":=",
"d",
".",
"term",
"\n",
"index",
"=",
"strings",
".",
"Index",
"(",
"term",
",",
"\"",
"\"",
")",
"\n",
"if",
"index",
"!=",
"-",
"1",
"{",
"// \"a\" [ \":\" domain-spec ]",
"// \"ip4\" \":\" ip4-network",
"// ...",
"term",
":=",
"term",
"[",
"index",
"+",
"1",
":",
"len",
"(",
"term",
")",
"]",
"\n",
"spec",
":=",
"\"",
"\"",
"\n",
"index",
"=",
"strings",
".",
"Index",
"(",
"term",
",",
"\"",
"\"",
")",
"\n",
"if",
"index",
"==",
"-",
"1",
"{",
"spec",
"=",
"term",
"\n",
"}",
"else",
"{",
"spec",
"=",
"term",
"[",
"0",
":",
"index",
"]",
"\n",
"term",
"=",
"term",
"[",
"index",
"+",
"1",
":",
"len",
"(",
"term",
")",
"]",
"\n",
"}",
"\n",
"if",
"net",
".",
"ParseIP",
"(",
"spec",
")",
"!=",
"nil",
"{",
"arguments",
"[",
"\"",
"\"",
"]",
"=",
"spec",
"\n",
"<mask>",
"=",
"true",
"\n",
"}",
"else",
"{",
"arguments",
"[",
"\"",
"\"",
"]",
"=",
"spec",
"\n",
"}",
"\n",
"}",
"\n\n",
"index",
"=",
"strings",
".",
"Index",
"(",
"term",
",",
"\"",
"\"",
")",
"\n",
"if",
"index",
"==",
"-",
"1",
"{",
"arguments",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
"\n",
"arguments",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
"\n",
"return",
"arguments",
"\n",
"}",
"\n",
"if",
"term",
"[",
"index",
":",
"index",
"+",
"2",
"]",
"!=",
"\"",
"\"",
"{",
"term",
"=",
"term",
"[",
"index",
"+",
"1",
":",
"len",
"(",
"term",
")",
"]",
"\n",
"}",
"else",
"{",
"term",
"=",
"term",
"[",
"index",
":",
"len",
"(",
"term",
")",
"]",
"\n",
"}",
"\n\n",
"cidrs",
":=",
"strings",
".",
"Split",
"(",
"term",
",",
"\"",
"\"",
")",
"\n",
"if",
"ip",
"{",
"if",
"!",
"strings",
".",
"Contains",
"(",
"arguments",
"[",
"\"",
"\"",
"]",
",",
"\"",
"\"",
")",
"{",
"arguments",
"[",
"\"",
"\"",
"]",
"=",
"cidrs",
"[",
"0",
"]",
"\n",
"}",
"else",
"{",
"arguments",
"[",
"\"",
"\"",
"]",
"=",
"cidrs",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"}",
"else",
"{",
"if",
"len",
"(",
"cidrs",
")",
"==",
"2",
"{",
"// ip4-cidr + \"/\" + ip6-cidr",
"arguments",
"[",
"\"",
"\"",
"]",
"=",
"cidrs",
"[",
"0",
"]",
"\n",
"arguments",
"[",
"\"",
"\"",
"]",
"=",
"cidrs",
"[",
"1",
"]",
"\n",
"}",
"\n",
"if",
"len",
"(",
"cidrs",
")",
"==",
"1",
"{",
"// ip4",
"arguments",
"[",
"\"",
"\"",
"]",
"=",
"cidrs",
"[",
"0",
"]",
"\n",
"arguments",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"arguments",
"\n",
"}"
]
|
17,422 | all-17423 | [
"Free",
"decreases",
"the",
"reference",
"count",
".",
"It",
"close",
"the",
"DB",
"if",
"the",
"count",
"reaches",
"zero",
"."
]
| [
"func",
"(",
"b",
"*",
"RefCountBox",
")",
"Free",
"(",
")",
"{",
"b",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"Unlock",
"(",
")",
"\n\n",
"b",
".",
"count",
"--",
"\n",
"if",
"b",
".",
"count",
"==",
"0",
"{",
"b",
".",
"db",
".",
"Close",
"(",
")",
"\n",
"b",
".",
"<mask>",
"=",
"DB",
"{",
"}",
"\n",
"}",
"\n",
"}"
]
|
17,423 | all-17424 | [
"returns",
"an",
"int64",
"from",
"a",
"crypto",
"random",
"source",
"can",
"be",
"used",
"to",
"seed",
"a",
"source",
"for",
"a",
"math",
"/",
"rand",
"."
]
| [
"func",
"newSeed",
"(",
")",
"int64",
"{",
"r",
",",
"err",
":=",
"crand",
".",
"Int",
"(",
"crand",
".",
"Reader",
",",
"big",
".",
"NewInt",
"(",
"math",
".",
"MaxInt64",
")",
")",
"\n",
"if",
"<mask>",
"!=",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
")",
"\n",
"}",
"\n",
"return",
"r",
".",
"Int64",
"(",
")",
"\n",
"}"
]
|
17,424 | all-17425 | [
"FromURL",
"downloads",
"the",
"specified",
"src",
"URL",
"to",
"w",
"writer",
"using",
"the",
"specified",
"Options",
"."
]
| [
"func",
"FromURL",
"(",
"src",
"*",
"url",
".",
"URL",
",",
"w",
"io",
".",
"Writer",
",",
"options",
"Options",
")",
"error",
"{",
"httpClient",
":=",
"getHTTPClient",
"(",
"options",
")",
"\n",
"var",
"(",
"err",
"error",
"\n",
"resp",
"*",
"http",
".",
"Response",
"\n",
")",
"\n",
"downloader",
":=",
"func",
"(",
")",
"error",
"{",
"resp",
",",
"err",
"=",
"httpClient",
".",
"Get",
"(",
"src",
".",
"String",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"&",
"retriableError",
"{",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"}",
"\n",
"}",
"\n",
"if",
"resp",
".",
"StatusCode",
"!=",
"http",
".",
"StatusOK",
"{",
"defer",
"func",
"(",
")",
"{",
"_",
"=",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"}",
"(",
")",
"// #nosec",
"\n",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"resp",
".",
"StatusCode",
",",
"http",
".",
"StatusOK",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"retries",
":=",
"options",
".",
"Retries",
"\n",
"if",
"retries",
"==",
"0",
"{",
"retries",
"=",
"5",
"\n",
"}",
"\n",
"if",
"err",
"=",
"retryAfter",
"(",
"retries",
",",
"downloader",
",",
"options",
".",
"RetryInterval",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"_",
"=",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"}",
"(",
")",
"// #nosec",
"\n\n",
"var",
"(",
"validator",
"checksumValidator",
"\n\n",
"reader",
"io",
".",
"Reader",
"=",
"resp",
".",
"Body",
"\n",
")",
"\n\n",
"if",
"<mask>",
".",
"ProgressBars",
"!=",
"nil",
"&&",
"resp",
".",
"ContentLength",
">",
"0",
"{",
"bar",
":=",
"newProgressBar",
"(",
"resp",
".",
"ContentLength",
",",
"options",
".",
"ProgressBars",
".",
"MaxWidth",
",",
"options",
".",
"ProgressBars",
".",
"Writer",
")",
"\n",
"bar",
".",
"Start",
"(",
")",
"\n",
"reader",
"=",
"bar",
".",
"NewProxyReader",
"(",
"reader",
")",
"\n",
"defer",
"func",
"(",
")",
"{",
"<-",
"time",
".",
"After",
"(",
"bar",
".",
"RefreshRate",
")",
"\n",
"fmt",
".",
"Println",
"(",
")",
"\n",
"}",
"(",
")",
"\n",
"}",
"\n\n",
"validator",
",",
"reader",
",",
"err",
"=",
"createValidatorReader",
"(",
"reader",
",",
"options",
".",
"ChecksumHash",
",",
"httpClient",
",",
"options",
".",
"Checksum",
",",
"path",
".",
"Base",
"(",
"src",
".",
"Path",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"err",
"=",
"io",
".",
"Copy",
"(",
"w",
",",
"reader",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"validator",
".",
"validate",
"(",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
17,425 | all-17426 | [
"Validate",
"checks",
"all",
"things",
"are",
"well",
"and",
"constructs",
"the",
"CLI",
"args",
"to",
"the",
"message",
"service"
]
| [
"func",
"(",
"m",
"*",
"PactMessageRequest",
")",
"Validate",
"(",
")",
"error",
"{",
"m",
".",
"Args",
"=",
"[",
"]",
"string",
"{",
"}",
"\n\n",
"body",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"m",
".",
"Message",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"m",
".",
"Args",
"=",
"append",
"(",
"m",
".",
"Args",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"string",
"(",
"body",
")",
",",
"\"",
"\"",
",",
"m",
".",
"<mask>",
",",
"\"",
"\"",
",",
"m",
".",
"Provider",
",",
"\"",
"\"",
",",
"m",
".",
"PactDir",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"}",
"...",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
17,426 | all-17427 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"EventLifecycleEvent",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage55",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
17,427 | all-17428 | [
"ReadDiskAttrsForDataSource",
"returns",
"select",
"attributes",
"from",
"the",
"list",
"of",
"disks",
"on",
"a",
"virtual",
"machine",
".",
"This",
"is",
"used",
"in",
"the",
"VM",
"data",
"source",
"to",
"discover",
"specific",
"options",
"of",
"all",
"of",
"the",
"disks",
"on",
"the",
"virtual",
"machine",
"sorted",
"by",
"the",
"order",
"that",
"they",
"would",
"be",
"added",
"in",
"if",
"a",
"clone",
"were",
"to",
"be",
"done",
"."
]
| [
"func",
"ReadDiskAttrsForDataSource",
"(",
"l",
"object",
".",
"VirtualDeviceList",
",",
"count",
"int",
")",
"(",
"[",
"]",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"count",
")",
"\n",
"devices",
":=",
"SelectDisks",
"(",
"l",
",",
"count",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"DeviceListString",
"(",
"devices",
")",
")",
"\n",
"// Sort the device list, in case it's not sorted already.",
"devSort",
":=",
"virtualDeviceListSorter",
"{",
"Sort",
":",
"devices",
",",
"DeviceList",
":",
"l",
",",
"}",
"\n",
"sort",
".",
"Sort",
"(",
"devSort",
")",
"\n",
"devices",
"=",
"devSort",
".",
"Sort",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"DeviceListString",
"(",
"devices",
")",
")",
"\n",
"<mask>",
"out",
"[",
"]",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"for",
"i",
",",
"device",
":=",
"range",
"devices",
"{",
"disk",
":=",
"device",
".",
"(",
"*",
"types",
".",
"VirtualDisk",
")",
"\n",
"backing",
",",
"ok",
":=",
"disk",
".",
"Backing",
".",
"(",
"*",
"types",
".",
"VirtualDiskFlatVer2BackingInfo",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"i",
",",
"disk",
".",
"Backing",
")",
"\n",
"}",
"\n",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"var",
"eager",
",",
"thin",
"bool",
"\n",
"if",
"backing",
".",
"EagerlyScrub",
"!=",
"nil",
"{",
"eager",
"=",
"*",
"backing",
".",
"EagerlyScrub",
"\n",
"}",
"\n",
"if",
"backing",
".",
"ThinProvisioned",
"!=",
"nil",
"{",
"thin",
"=",
"*",
"backing",
".",
"ThinProvisioned",
"\n",
"}",
"\n",
"m",
"[",
"\"",
"\"",
"]",
"=",
"diskCapacityInGiB",
"(",
"disk",
")",
"\n",
"m",
"[",
"\"",
"\"",
"]",
"=",
"eager",
"\n",
"m",
"[",
"\"",
"\"",
"]",
"=",
"thin",
"\n",
"out",
"=",
"append",
"(",
"out",
",",
"m",
")",
"\n",
"}",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"out",
")",
"\n",
"return",
"out",
",",
"nil",
"\n",
"}"
]
|
17,428 | all-17429 | [
"SetBSON",
"sets",
"the",
"DateTime",
"from",
"raw",
"bson",
"data"
]
| [
"func",
"(",
"t",
"*",
"DateTime",
")",
"SetBSON",
"(",
"raw",
"bson",
".",
"Raw",
")",
"error",
"{",
"var",
"m",
"bson",
".",
"M",
"\n",
"if",
"err",
":=",
"raw",
".",
"Unmarshal",
"(",
"&",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"data",
",",
"ok",
":=",
"m",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
";",
"<mask>",
"{",
"var",
"err",
"error",
"\n",
"*",
"t",
",",
"err",
"=",
"ParseDateTime",
"(",
"data",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
]
|
17,429 | all-17430 | [
"applyResourceState",
"moves",
"the",
"resource",
"to",
"the",
"given",
"state",
"by",
"calling",
"the",
"function",
"defined",
"in",
"the",
"transitionFunctionMap",
"for",
"the",
"state"
]
| [
"func",
"(",
"mtask",
"*",
"managedTask",
")",
"applyResourceState",
"(",
"resource",
"taskresource",
".",
"TaskResource",
",",
"nextState",
"resourcestatus",
".",
"ResourceStatus",
")",
"error",
"{",
"resName",
":=",
"<mask>",
".",
"GetName",
"(",
")",
"\n",
"resStatus",
":=",
"resource",
".",
"StatusString",
"(",
"nextState",
")",
"\n",
"err",
":=",
"resource",
".",
"ApplyTransition",
"(",
"nextState",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"mtask",
".",
"Arn",
",",
"resName",
",",
"resStatus",
",",
"err",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"seelog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"mtask",
".",
"Arn",
",",
"resName",
",",
"resStatus",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,430 | all-17431 | [
"IsRecursionRequest",
"checks",
"whether",
"the",
"given",
"HTTP",
"request",
"is",
"marked",
"with",
"the",
"recursion",
"flag",
"in",
"its",
"form",
"values",
"."
]
| [
"func",
"IsRecursionRequest",
"(",
"r",
"*",
"http",
".",
"<mask>",
")",
"bool",
"{",
"recursionStr",
":=",
"r",
".",
"FormValue",
"(",
"\"",
"\"",
")",
"\n\n",
"recursion",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"recursionStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"recursion",
"!=",
"0",
"\n",
"}"
]
|
17,431 | all-17432 | [
"listFiles",
"returns",
"a",
"list",
"of",
"all",
"files",
"that",
"match",
"the",
"configured",
"patterns",
"."
]
| [
"func",
"(",
"d",
"*",
"Discovery",
")",
"listFiles",
"(",
")",
"[",
"]",
"string",
"{",
"<mask>",
"paths",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"d",
".",
"paths",
"{",
"files",
",",
"err",
":=",
"filepath",
".",
"Glob",
"(",
"p",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"level",
".",
"Error",
"(",
"d",
".",
"logger",
")",
".",
"Log",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"p",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"paths",
"=",
"append",
"(",
"paths",
",",
"files",
"...",
")",
"\n",
"}",
"\n",
"return",
"paths",
"\n",
"}"
]
|
17,432 | all-17433 | [
"Add",
"an",
"item",
"to",
"the",
"cache",
"only",
"if",
"an",
"item",
"doesn",
"t",
"already",
"exist",
"for",
"the",
"given",
"key",
"or",
"if",
"the",
"existing",
"item",
"has",
"expired",
".",
"Returns",
"an",
"error",
"otherwise",
"."
]
| [
"func",
"(",
"c",
"*",
"cache",
")",
"Add",
"(",
"k",
"string",
",",
"x",
"interface",
"{",
"}",
",",
"d",
"time",
".",
"Duration",
")",
"error",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"_",
",",
"<mask>",
":=",
"c",
".",
"get",
"(",
"k",
")",
"\n",
"if",
"found",
"{",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"k",
")",
"\n",
"}",
"\n",
"c",
".",
"set",
"(",
"k",
",",
"x",
",",
"d",
")",
"\n",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,433 | all-17434 | [
"Mark",
"marks",
"a",
"particular",
"resource",
"as",
"currently",
"present",
"and",
"advises",
"on",
"whether",
"it",
"should",
"be",
"deleted",
".",
"If",
"Mark",
"(",
"r",
")",
"returns",
"true",
"the",
"TTL",
"has",
"expired",
"for",
"r",
"and",
"it",
"should",
"be",
"deleted",
"."
]
| [
"func",
"(",
"s",
"*",
"Set",
")",
"Mark",
"(",
"r",
"Interface",
")",
"bool",
"{",
"key",
":=",
"r",
".",
"ResourceKey",
"(",
")",
"\n",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"s",
".",
"marked",
"[",
"key",
"]",
"=",
"true",
"\n",
"if",
"t",
",",
"ok",
":=",
"s",
".",
"firstSeen",
"[",
"key",
"]",
";",
"ok",
"{",
"since",
":=",
"now",
".",
"Sub",
"(",
"t",
")",
"\n",
"if",
"since",
">",
"s",
".",
"ttl",
"{",
"s",
".",
"swept",
"=",
"<mask>",
"(",
"s",
".",
"swept",
",",
"key",
")",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"klog",
".",
"V",
"(",
"1",
")",
".",
"Infof",
"(",
"\"",
"\"",
",",
"key",
",",
"since",
")",
"\n",
"return",
"false",
"\n",
"}",
"\n\n",
"s",
".",
"firstSeen",
"[",
"key",
"]",
"=",
"now",
"\n",
"klog",
".",
"V",
"(",
"1",
")",
".",
"Infof",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"if",
"s",
".",
"ttl",
"==",
"0",
"{",
"// If the TTL is 0, it should be deleted now.",
"s",
".",
"swept",
"=",
"append",
"(",
"s",
".",
"swept",
",",
"key",
")",
"\n",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
|
17,434 | all-17435 | [
"ListVolumes",
"returns",
"a",
"Collection",
"struct",
"for",
"volumes",
"in",
"the",
"Datacenter"
]
| [
"func",
"(",
"c",
"*",
"Client",
")",
"ListVolumes",
"(",
"dcid",
"string",
")",
"(",
"*",
"Volumes",
",",
"error",
")",
"{",
"<mask>",
":=",
"volumeColPath",
"(",
"dcid",
")",
"+",
"`?depth=`",
"+",
"c",
".",
"client",
".",
"depth",
"\n",
"ret",
":=",
"&",
"Volumes",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"client",
".",
"Get",
"(",
"url",
",",
"ret",
",",
"http",
".",
"StatusOK",
")",
"\n",
"return",
"ret",
",",
"err",
"\n",
"}"
]
|
17,435 | all-17436 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"Message",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdproto1",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
]
|
17,436 | all-17437 | [
"ContainersListByNodeAddress",
"returns",
"the",
"names",
"of",
"all",
"containers",
"grouped",
"by",
"cluster",
"node",
"address",
".",
"The",
"node",
"address",
"of",
"containers",
"running",
"on",
"the",
"local",
"node",
"is",
"set",
"to",
"the",
"empty",
"string",
"to",
"distinguish",
"it",
"from",
"remote",
"nodes",
".",
"Containers",
"whose",
"node",
"is",
"down",
"are",
"addeded",
"to",
"the",
"special",
"address",
"0",
".",
"0",
".",
"0",
".",
"0",
"."
]
| [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainersListByNodeAddress",
"(",
"project",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"error",
")",
"{",
"offlineThreshold",
",",
"err",
":=",
"c",
".",
"NodeOfflineThreshold",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"stmt",
":=",
"`\nSELECT containers.name, nodes.id, nodes.address, nodes.heartbeat\n FROM containers\n JOIN nodes ON nodes.id = containers.node_id\n JOIN projects ON projects.id = containers.project_id\n WHERE containers.type=?\n AND projects.name = ?\n ORDER BY containers.id\n`",
"\n",
"rows",
",",
"err",
":=",
"c",
".",
"tx",
".",
"Query",
"(",
"stmt",
",",
"CTypeRegular",
",",
"project",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"rows",
".",
"Close",
"(",
")",
"\n\n",
"result",
":=",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
"{",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";",
"rows",
".",
"Next",
"(",
")",
";",
"i",
"++",
"{",
"var",
"name",
"string",
"\n",
"<mask>",
"nodeAddress",
"string",
"\n",
"var",
"nodeID",
"int64",
"\n",
"var",
"nodeHeartbeat",
"time",
".",
"Time",
"\n",
"err",
":=",
"rows",
".",
"Scan",
"(",
"&",
"name",
",",
"&",
"nodeID",
",",
"&",
"nodeAddress",
",",
"&",
"nodeHeartbeat",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"nodeID",
"==",
"c",
".",
"nodeID",
"{",
"nodeAddress",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"if",
"nodeIsOffline",
"(",
"offlineThreshold",
",",
"nodeHeartbeat",
")",
"{",
"nodeAddress",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"result",
"[",
"nodeAddress",
"]",
"=",
"append",
"(",
"result",
"[",
"nodeAddress",
"]",
",",
"name",
")",
"\n",
"}",
"\n\n",
"err",
"=",
"rows",
".",
"Err",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
]
|
17,437 | all-17438 | [
"UpdateImageState",
"updates",
"image",
"name",
"and",
"container",
"reference",
"in",
"image",
"state"
]
| [
"func",
"(",
"imageState",
"*",
"ImageState",
")",
"UpdateImageState",
"(",
"<mask>",
"*",
"apicontainer",
".",
"Container",
")",
"{",
"imageState",
".",
"AddImageName",
"(",
"container",
".",
"Image",
")",
"\n",
"imageState",
".",
"UpdateContainerReference",
"(",
"container",
")",
"\n",
"}"
]
|
17,438 | all-17439 | [
"process",
"copies",
"stdin",
"to",
"stdout",
"and",
"processes",
"any",
"panic",
":",
"line",
"found",
".",
"If",
"html",
"is",
"used",
"a",
"stack",
"trace",
"is",
"written",
"to",
"this",
"file",
"instead",
"."
]
| [
"func",
"process",
"(",
"in",
"io",
".",
"Reader",
",",
"out",
"io",
".",
"Writer",
",",
"p",
"*",
"Palette",
",",
"s",
"stack",
".",
"Similarity",
",",
"fullPath",
",",
"parse",
",",
"rebase",
"bool",
",",
"<mask>",
"string",
",",
"filter",
",",
"match",
"*",
"regexp",
".",
"Regexp",
")",
"error",
"{",
"c",
",",
"err",
":=",
"stack",
".",
"ParseDump",
"(",
"in",
",",
"out",
",",
"rebase",
")",
"\n",
"if",
"c",
"==",
"nil",
"||",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"rebase",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"c",
".",
"GOROOT",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"c",
".",
"GOPATHs",
")",
"\n",
"}",
"\n",
"needsEnv",
":=",
"len",
"(",
"c",
".",
"Goroutines",
")",
"==",
"1",
"&&",
"showBanner",
"(",
")",
"\n",
"if",
"parse",
"{",
"stack",
".",
"Augment",
"(",
"c",
".",
"Goroutines",
")",
"\n",
"}",
"\n",
"buckets",
":=",
"stack",
".",
"Aggregate",
"(",
"c",
".",
"Goroutines",
",",
"s",
")",
"\n",
"if",
"html",
"==",
"\"",
"\"",
"{",
"return",
"writeToConsole",
"(",
"out",
",",
"p",
",",
"buckets",
",",
"fullPath",
",",
"needsEnv",
",",
"filter",
",",
"match",
")",
"\n",
"}",
"\n",
"return",
"writeToHTML",
"(",
"html",
",",
"buckets",
",",
"needsEnv",
")",
"\n",
"}"
]
|
17,439 | all-17440 | [
"Last",
"returns",
"the",
"last",
"pushed",
"span",
"or",
"the",
"root",
"span",
"."
]
| [
"func",
"(",
"t",
"*",
"Tracer",
")",
"Last",
"(",
")",
"opentracing",
".",
"Span",
"{",
"// return root if empty",
"if",
"len",
"(",
"t",
".",
"spans",
")",
"==",
"0",
"{",
"return",
"t",
".",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"t",
".",
"spans",
"[",
"len",
"(",
"t",
".",
"spans",
")",
"-",
"1",
"]",
"\n",
"}"
]
|
17,440 | all-17441 | [
"specify",
"a",
"two",
"-",
"dimensional",
"texture",
"subimage",
"in",
"a",
"compressed",
"format"
]
| [
"func",
"CompressedTextureSubImage2D",
"(",
"texture",
"uint32",
",",
"level",
"int32",
",",
"xoffset",
"int32",
",",
"yoffset",
"int32",
",",
"width",
"int32",
",",
"height",
"int32",
",",
"format",
"uint32",
",",
"imageSize",
"int32",
",",
"data",
"unsafe",
".",
"Pointer",
")",
"{",
"C",
".",
"glowCompressedTextureSubImage2D",
"(",
"gpCompressedTextureSubImage2D",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"texture",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"level",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"xoffset",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"yoffset",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"width",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"height",
")",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"<mask>",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"imageSize",
")",
",",
"data",
")",
"\n",
"}"
]
|
17,441 | all-17442 | [
"MarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Marshaler",
"."
]
| [
"func",
"(",
"t",
"CertificateTransparencyCompliance",
")",
"MarshalEasyJSON",
"(",
"<mask>",
"*",
"jwriter",
".",
"Writer",
")",
"{",
"out",
".",
"String",
"(",
"string",
"(",
"t",
")",
")",
"\n",
"}"
]
|
17,442 | all-17443 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"GetStackTraceReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger31",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
]
|
17,443 | all-17444 | [
"restoreSnapshot",
"attempts",
"to",
"restore",
"the",
"latest",
"snapshots",
"and",
"fails",
"if",
"none",
"of",
"them",
"can",
"be",
"restored",
".",
"This",
"is",
"called",
"at",
"initialization",
"time",
"and",
"is",
"completely",
"unsafe",
"to",
"call",
"at",
"any",
"other",
"time",
"."
]
| [
"func",
"(",
"r",
"*",
"Raft",
")",
"restoreSnapshot",
"(",
")",
"error",
"{",
"snapshots",
",",
"err",
":=",
"r",
".",
"snapshots",
".",
"List",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r",
".",
"logger",
".",
"Error",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"err",
")",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"// Try to load in order of newest to oldest",
"for",
"_",
",",
"snapshot",
":=",
"range",
"snapshots",
"{",
"_",
",",
"source",
",",
"err",
":=",
"r",
".",
"snapshots",
".",
"Open",
"(",
"snapshot",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r",
".",
"logger",
".",
"Error",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"snapshot",
".",
"ID",
",",
"err",
")",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"defer",
"source",
".",
"Close",
"(",
")",
"\n\n",
"if",
"err",
":=",
"r",
".",
"fsm",
".",
"Restore",
"(",
"source",
")",
";",
"err",
"!=",
"nil",
"{",
"r",
".",
"logger",
".",
"Error",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"snapshot",
".",
"ID",
",",
"err",
")",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"// Log success",
"r",
".",
"logger",
".",
"Info",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"snapshot",
".",
"ID",
")",
")",
"\n\n",
"// Update the lastApplied so we don't replay old logs",
"r",
".",
"setLastApplied",
"(",
"snapshot",
".",
"Index",
")",
"\n\n",
"// Update the last stable snapshot info",
"r",
".",
"setLastSnapshot",
"(",
"snapshot",
".",
"Index",
",",
"snapshot",
".",
"Term",
")",
"\n\n",
"// Update the configuration",
"if",
"snapshot",
".",
"Version",
">",
"0",
"{",
"r",
".",
"configurations",
".",
"committed",
"=",
"snapshot",
".",
"<mask>",
"\n",
"r",
".",
"configurations",
".",
"committedIndex",
"=",
"snapshot",
".",
"ConfigurationIndex",
"\n",
"r",
".",
"configurations",
".",
"latest",
"=",
"snapshot",
".",
"Configuration",
"\n",
"r",
".",
"configurations",
".",
"latestIndex",
"=",
"snapshot",
".",
"ConfigurationIndex",
"\n",
"}",
"else",
"{",
"configuration",
":=",
"decodePeers",
"(",
"snapshot",
".",
"Peers",
",",
"r",
".",
"trans",
")",
"\n",
"r",
".",
"configurations",
".",
"committed",
"=",
"configuration",
"\n",
"r",
".",
"configurations",
".",
"committedIndex",
"=",
"snapshot",
".",
"Index",
"\n",
"r",
".",
"configurations",
".",
"latest",
"=",
"configuration",
"\n",
"r",
".",
"configurations",
".",
"latestIndex",
"=",
"snapshot",
".",
"Index",
"\n",
"}",
"\n\n",
"// Success!",
"return",
"nil",
"\n",
"}",
"\n\n",
"// If we had snapshots and failed to load them, its an error",
"if",
"len",
"(",
"snapshots",
")",
">",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,444 | all-17445 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"GetBoxModelReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoDom50",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
17,445 | all-17446 | [
"get",
"retrieves",
"a",
"value",
"associated",
"with",
"the",
"given",
"key",
"from",
"the",
"cache",
".",
"ok",
"will",
"be",
"true",
"if",
"the",
"key",
"exists",
"in",
"the",
"cache",
"even",
"if",
"it",
"s",
"in",
"the",
"process",
"of",
"being",
"fetched",
"."
]
| [
"func",
"(",
"m",
"*",
"remoteCacheMap",
")",
"get",
"(",
"key",
"string",
")",
"(",
"value",
"interface",
"{",
"}",
",",
"ok",
"bool",
",",
"err",
"error",
")",
"{",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"e",
",",
"ok",
":=",
"m",
".",
"cache",
"[",
"key",
"]",
"\n",
"m",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"<mask>",
",",
"nil",
"\n",
"}",
"\n",
"if",
"e",
".",
"ready",
"!=",
"nil",
"{",
"<-",
"e",
".",
"ready",
"\n",
"}",
"\n",
"return",
"e",
".",
"value",
",",
"ok",
",",
"e",
".",
"err",
"\n",
"}"
]
|
17,446 | all-17447 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"EnableReturns",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger44",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
17,447 | all-17448 | [
"GetConfirm",
"retrieves",
"the",
"Confirm",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
]
| [
"func",
"(",
"u",
"ScpStatementPledges",
")",
"GetConfirm",
"(",
")",
"(",
"result",
"ScpStatementConfirm",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n\n",
"if",
"armName",
"==",
"\"",
"\"",
"{",
"<mask>",
"=",
"*",
"u",
".",
"Confirm",
"\n",
"ok",
"=",
"true",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
]
|
17,448 | all-17449 | [
"SearchChecks",
"returns",
"checks",
"matching",
"the",
"specified",
"search",
"query",
"and",
"/",
"or",
"filter",
".",
"If",
"nil",
"is",
"passed",
"for",
"both",
"parameters",
"all",
"checks",
"will",
"be",
"returned",
"."
]
| [
"func",
"(",
"a",
"*",
"API",
")",
"SearchChecks",
"(",
"searchCriteria",
"*",
"SearchQueryType",
",",
"filterCriteria",
"*",
"SearchFilterType",
")",
"(",
"*",
"[",
"]",
"Check",
",",
"error",
")",
"{",
"q",
":=",
"url",
".",
"Values",
"{",
"}",
"\n\n",
"if",
"searchCriteria",
"!=",
"nil",
"&&",
"*",
"searchCriteria",
"!=",
"\"",
"\"",
"{",
"q",
".",
"Set",
"(",
"\"",
"\"",
",",
"string",
"(",
"*",
"searchCriteria",
")",
")",
"\n",
"}",
"\n\n",
"if",
"filterCriteria",
"!=",
"nil",
"&&",
"len",
"(",
"*",
"filterCriteria",
")",
">",
"0",
"{",
"for",
"filter",
",",
"criteria",
":=",
"range",
"*",
"filterCriteria",
"{",
"for",
"_",
",",
"val",
":=",
"<mask>",
"criteria",
"{",
"q",
".",
"Add",
"(",
"filter",
",",
"val",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"q",
".",
"Encode",
"(",
")",
"==",
"\"",
"\"",
"{",
"return",
"a",
".",
"FetchChecks",
"(",
")",
"\n",
"}",
"\n\n",
"reqURL",
":=",
"url",
".",
"URL",
"{",
"Path",
":",
"config",
".",
"CheckPrefix",
",",
"RawQuery",
":",
"q",
".",
"Encode",
"(",
")",
",",
"}",
"\n\n",
"result",
",",
"err",
":=",
"a",
".",
"Get",
"(",
"reqURL",
".",
"String",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"checks",
"[",
"]",
"Check",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"result",
",",
"&",
"checks",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"checks",
",",
"nil",
"\n",
"}"
]
|
17,449 | all-17450 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"GetFrameTreeReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage40",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
17,450 | all-17451 | [
"encodeTargets",
"determines",
"what",
"to",
"encode",
"."
]
| [
"func",
"encodeTargets",
"(",
"alg",
"Algorithm",
",",
"obj",
"interface",
"{",
"}",
")",
"(",
"<mask>",
"{",
"}",
",",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// determine what to encode",
"switch",
"val",
":=",
"obj",
".",
"(",
"type",
")",
"{",
"case",
"*",
"Token",
":",
"return",
"val",
".",
"Header",
",",
"val",
".",
"Payload",
",",
"nil",
"\n",
"}",
"\n\n",
"objVal",
":=",
"reflect",
".",
"ValueOf",
"(",
"obj",
")",
"\n",
"objKind",
":=",
"objVal",
".",
"Kind",
"(",
")",
"\n",
"if",
"objKind",
"==",
"reflect",
".",
"Struct",
"||",
"(",
"objKind",
"==",
"reflect",
".",
"Ptr",
"&&",
"objVal",
".",
"Elem",
"(",
")",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Struct",
")",
"{",
"return",
"grabEncodeTargets",
"(",
"alg",
",",
"obj",
")",
"\n",
"}",
"\n\n",
"return",
"alg",
".",
"Header",
"(",
")",
",",
"obj",
",",
"nil",
"\n",
"}"
]
|
17,451 | all-17452 | [
"InternalGet",
"gets",
"the",
"node",
"of",
"the",
"given",
"nodePath",
"."
]
| [
"func",
"(",
"s",
"*",
"store",
")",
"internalGet",
"(",
"nodePath",
"string",
")",
"(",
"*",
"node",
",",
"*",
"v2error",
".",
"Error",
")",
"{",
"nodePath",
"=",
"path",
".",
"Clean",
"(",
"path",
".",
"Join",
"(",
"\"",
"\"",
",",
"nodePath",
")",
")",
"\n\n",
"walkFunc",
":=",
"func",
"(",
"parent",
"*",
"node",
",",
"name",
"string",
")",
"(",
"*",
"<mask>",
",",
"*",
"v2error",
".",
"Error",
")",
"{",
"if",
"!",
"parent",
".",
"IsDir",
"(",
")",
"{",
"err",
":=",
"v2error",
".",
"NewError",
"(",
"v2error",
".",
"EcodeNotDir",
",",
"parent",
".",
"Path",
",",
"s",
".",
"CurrentIndex",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"child",
",",
"ok",
":=",
"parent",
".",
"Children",
"[",
"name",
"]",
"\n",
"if",
"ok",
"{",
"return",
"child",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"v2error",
".",
"NewError",
"(",
"v2error",
".",
"EcodeKeyNotFound",
",",
"path",
".",
"Join",
"(",
"parent",
".",
"Path",
",",
"name",
")",
",",
"s",
".",
"CurrentIndex",
")",
"\n",
"}",
"\n\n",
"f",
",",
"err",
":=",
"s",
".",
"walk",
"(",
"nodePath",
",",
"walkFunc",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"f",
",",
"nil",
"\n",
"}"
]
|
17,452 | all-17453 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"TakeResponseBodyAsStreamParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoFetch1",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
17,453 | all-17454 | [
"CanFormatDiffSlice",
"reports",
"whether",
"we",
"support",
"custom",
"formatting",
"for",
"nodes",
"that",
"are",
"slices",
"of",
"primitive",
"kinds",
"or",
"strings",
"."
]
| [
"func",
"(",
"opts",
"formatOptions",
")",
"CanFormatDiffSlice",
"(",
"v",
"*",
"valueNode",
")",
"bool",
"{",
"switch",
"{",
"case",
"opts",
".",
"DiffMode",
"!=",
"diffUnknown",
":",
"return",
"false",
"// Must be formatting in diff mode",
"\n",
"case",
"v",
".",
"NumDiff",
"==",
"0",
":",
"return",
"false",
"// No differences detected",
"\n",
"case",
"v",
".",
"NumIgnored",
"+",
"v",
".",
"NumCompared",
"+",
"v",
".",
"NumTransformed",
">",
"0",
":",
"// TODO: Handle the case where someone uses bytes.Equal on a large slice.",
"return",
"false",
"// Some custom option was used to determined equality",
"\n",
"case",
"!",
"v",
".",
"ValueX",
".",
"IsValid",
"(",
")",
"||",
"!",
"v",
".",
"ValueY",
".",
"IsValid",
"(",
")",
":",
"return",
"false",
"// Both values must be valid",
"\n",
"}",
"\n\n",
"switch",
"t",
":=",
"v",
".",
"Type",
";",
"t",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"String",
":",
"<mask>",
"reflect",
".",
"Array",
",",
"reflect",
".",
"Slice",
":",
"// Only slices of primitive types have specialized handling.",
"switch",
"t",
".",
"Elem",
"(",
")",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Int",
",",
"reflect",
".",
"Int8",
",",
"reflect",
".",
"Int16",
",",
"reflect",
".",
"Int32",
",",
"reflect",
".",
"Int64",
",",
"reflect",
".",
"Uint",
",",
"reflect",
".",
"Uint8",
",",
"reflect",
".",
"Uint16",
",",
"reflect",
".",
"Uint32",
",",
"reflect",
".",
"Uint64",
",",
"reflect",
".",
"Uintptr",
",",
"reflect",
".",
"Bool",
",",
"reflect",
".",
"Float32",
",",
"reflect",
".",
"Float64",
",",
"reflect",
".",
"Complex64",
",",
"reflect",
".",
"Complex128",
":",
"default",
":",
"return",
"false",
"\n",
"}",
"\n\n",
"// If a sufficient number of elements already differ,",
"// use specialized formatting even if length requirement is not met.",
"if",
"v",
".",
"NumDiff",
">",
"v",
".",
"NumSame",
"{",
"return",
"true",
"\n",
"}",
"\n",
"default",
":",
"return",
"false",
"\n",
"}",
"\n\n",
"// Use specialized string diffing for longer slices or strings.",
"const",
"minLength",
"=",
"64",
"\n",
"return",
"v",
".",
"ValueX",
".",
"Len",
"(",
")",
">=",
"minLength",
"&&",
"v",
".",
"ValueY",
".",
"Len",
"(",
")",
">=",
"minLength",
"\n",
"}"
]
|
17,454 | all-17455 | [
"GetTr",
"retrieves",
"the",
"Tr",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
]
| [
"func",
"(",
"u",
"OperationResult",
")",
"GetTr",
"(",
")",
"(",
"result",
"OperationResultTr",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Code",
")",
")",
"\n\n",
"if",
"armName",
"==",
"\"",
"\"",
"{",
"result",
"=",
"*",
"u",
".",
"Tr",
"\n",
"<mask>",
"=",
"true",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
]
|
17,455 | all-17456 | [
"getExtensionsSignatures",
"returns",
"signatures",
"from",
"the",
"X",
"-",
"Registry",
"-",
"Supports",
"-",
"Signatures",
"API",
"extension",
"using",
"the",
"original",
"data",
"structures",
"."
]
| [
"func",
"(",
"c",
"*",
"dockerClient",
")",
"getExtensionsSignatures",
"(",
"ctx",
"context",
".",
"Context",
",",
"ref",
"dockerReference",
",",
"manifestDigest",
"digest",
".",
"Digest",
")",
"(",
"*",
"extensionSignatureList",
",",
"error",
")",
"{",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"extensionsSignaturePath",
",",
"reference",
".",
"Path",
"(",
"<mask>",
".",
"ref",
")",
",",
"manifestDigest",
")",
"\n",
"res",
",",
"err",
":=",
"c",
".",
"makeRequest",
"(",
"ctx",
",",
"\"",
"\"",
",",
"path",
",",
"nil",
",",
"nil",
",",
"v2Auth",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"res",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"if",
"res",
".",
"StatusCode",
"!=",
"http",
".",
"StatusOK",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"client",
".",
"HandleErrorResponse",
"(",
"res",
")",
",",
"\"",
"\"",
",",
"manifestDigest",
",",
"ref",
".",
"ref",
".",
"Name",
"(",
")",
")",
"\n",
"}",
"\n",
"body",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"res",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"var",
"parsedBody",
"extensionSignatureList",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"body",
",",
"&",
"parsedBody",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"parsedBody",
",",
"nil",
"\n",
"}"
]
|
17,456 | all-17457 | [
"SupportsFeatureSet",
"reports",
"whether",
"device",
"d",
"supports",
"feature",
"set",
"fs",
".",
"Reference",
":",
"https",
":",
"//",
"developer",
".",
"apple",
".",
"com",
"/",
"documentation",
"/",
"metal",
"/",
"mtldevice",
"/",
"1433418",
"-",
"supportsfeatureset",
"."
]
| [
"func",
"(",
"d",
"Device",
")",
"SupportsFeatureSet",
"(",
"<mask>",
"FeatureSet",
")",
"bool",
"{",
"return",
"C",
".",
"Device_SupportsFeatureSet",
"(",
"d",
".",
"device",
",",
"C",
".",
"uint16_t",
"(",
"fs",
")",
")",
"!=",
"0",
"\n",
"}"
]
|
17,457 | all-17458 | [
"LookupGroup",
"looks",
"up",
"a",
"group",
"by",
"name",
"."
]
| [
"func",
"LookupGroup",
"(",
"<mask>",
"string",
")",
"(",
"*",
"Group",
",",
"error",
")",
"{",
"entries",
",",
"err",
":=",
"LookupInGroup",
"(",
"G_NAME",
",",
"name",
",",
"1",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"entries",
"[",
"0",
"]",
",",
"err",
"\n",
"}"
]
|
17,458 | all-17459 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"RequestDatabaseParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoIndexeddb1",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
17,459 | all-17460 | [
"Execute",
"-",
"updates",
"organizations",
"metadata"
]
| [
"func",
"(",
"c",
"*",
"UpdateOrgsMetadataCommand",
")",
"Execute",
"(",
"[",
"]",
"string",
")",
"error",
"{",
"var",
"cfMgmt",
"*",
"CFMgmt",
"\n",
"<mask>",
"err",
"error",
"\n",
"if",
"cfMgmt",
",",
"err",
"=",
"InitializePeekManagers",
"(",
"c",
".",
"BaseCFConfigCommand",
",",
"c",
".",
"Peek",
")",
";",
"err",
"==",
"nil",
"{",
"err",
"=",
"cfMgmt",
".",
"OrgManager",
".",
"UpdateOrgsMetadata",
"(",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
]
|
17,460 | all-17461 | [
"getContainerInstanceTagsFromEC2API",
"will",
"retrieve",
"the",
"tags",
"of",
"this",
"instance",
"remotely",
"."
]
| [
"func",
"(",
"agent",
"*",
"ecsAgent",
")",
"getContainerInstanceTagsFromEC2API",
"(",
")",
"(",
"[",
"]",
"*",
"ecs",
".",
"<mask>",
",",
"error",
")",
"{",
"// Get instance ID from ec2 metadata client.",
"instanceID",
",",
"err",
":=",
"agent",
".",
"ec2MetadataClient",
".",
"InstanceID",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"agent",
".",
"ec2Client",
".",
"DescribeECSTagsForInstance",
"(",
"instanceID",
")",
"\n",
"}"
]
|
17,461 | all-17462 | [
"RegisterMaintenanceHandler",
"registers",
"the",
"http",
"handlers",
"for",
"service",
"Maintenance",
"to",
"mux",
".",
"The",
"handlers",
"forward",
"requests",
"to",
"the",
"grpc",
"endpoint",
"over",
"conn",
"."
]
| [
"func",
"RegisterMaintenanceHandler",
"(",
"ctx",
"context",
".",
"Context",
",",
"mux",
"*",
"runtime",
".",
"ServeMux",
",",
"<mask>",
"*",
"grpc",
".",
"ClientConn",
")",
"error",
"{",
"return",
"RegisterMaintenanceHandlerClient",
"(",
"ctx",
",",
"mux",
",",
"etcdserverpb",
".",
"NewMaintenanceClient",
"(",
"conn",
")",
")",
"\n",
"}"
]
|
17,462 | all-17463 | [
"Add",
"is",
"deprecated",
"as",
"of",
"1",
".",
"5",
".",
"0",
"-",
"alpha",
".",
"Note",
"that",
"this",
"doesn",
"t",
"make",
"sense",
"as",
"an",
"operation",
"for",
"affine",
"matrices",
"."
]
| [
"func",
"(",
"g",
"*",
"GeoM",
")",
"Add",
"(",
"other",
"GeoM",
")",
"{",
"g",
".",
"a_1",
"+=",
"other",
".",
"a_1",
"\n",
"g",
".",
"b",
"+=",
"other",
".",
"b",
"\n",
"g",
".",
"c",
"+=",
"other",
".",
"c",
"\n",
"g",
".",
"d_1",
"+=",
"other",
".",
"d_1",
"\n",
"g",
".",
"tx",
"+=",
"other",
".",
"tx",
"\n",
"g",
".",
"ty",
"+=",
"<mask>",
".",
"ty",
"\n",
"}"
]
|
17,463 | all-17464 | [
"GetSecretFromSSM",
"makes",
"the",
"api",
"call",
"to",
"the",
"AWS",
"SSM",
"parameter",
"store",
"to",
"retrieve",
"secrets",
"value",
"in",
"batches"
]
| [
"func",
"GetSecretsFromSSM",
"(",
"names",
"[",
"]",
"string",
",",
"client",
"SSMClient",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"var",
"secretNames",
"[",
"]",
"*",
"string",
"\n",
"for",
"_",
",",
"name",
":=",
"range",
"names",
"{",
"secretNames",
"=",
"append",
"(",
"secretNames",
",",
"aws",
".",
"String",
"(",
"name",
")",
")",
"\n",
"}",
"\n\n",
"in",
":=",
"&",
"ssm",
".",
"GetParametersInput",
"{",
"Names",
":",
"secretNames",
",",
"WithDecryption",
":",
"aws",
".",
"Bool",
"(",
"true",
")",
",",
"}",
"\n\n",
"out",
",",
"err",
":=",
"<mask>",
".",
"GetParameters",
"(",
"in",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"extractSSMValues",
"(",
"out",
")",
"\n",
"}"
]
|
17,464 | all-17465 | [
"GetBlob",
"returns",
"a",
"stream",
"for",
"the",
"specified",
"blob",
"and",
"the",
"blob’s",
"size",
"(",
"or",
"-",
"1",
"if",
"unknown",
")",
".",
"The",
"Digest",
"field",
"in",
"BlobInfo",
"is",
"guaranteed",
"to",
"be",
"provided",
"Size",
"may",
"be",
"-",
"1",
"and",
"MediaType",
"may",
"be",
"optionally",
"provided",
".",
"May",
"update",
"BlobInfoCache",
"preferably",
"after",
"it",
"knows",
"for",
"certain",
"that",
"a",
"blob",
"truly",
"exists",
"at",
"a",
"specific",
"location",
"."
]
| [
"func",
"(",
"s",
"*",
"ociImageSource",
")",
"GetBlob",
"(",
"ctx",
"context",
".",
"Context",
",",
"info",
"types",
".",
"BlobInfo",
",",
"cache",
"types",
".",
"BlobInfoCache",
")",
"(",
"io",
".",
"ReadCloser",
",",
"int64",
",",
"error",
")",
"{",
"if",
"len",
"(",
"info",
".",
"URLs",
")",
"!=",
"0",
"{",
"return",
"s",
".",
"getExternalBlob",
"(",
"ctx",
",",
"info",
".",
"URLs",
")",
"\n",
"}",
"\n\n",
"path",
",",
"err",
":=",
"s",
".",
"ref",
".",
"blobPath",
"(",
"info",
".",
"Digest",
",",
"s",
".",
"sharedBlobDir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"r",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"<mask>",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"fi",
",",
"err",
":=",
"r",
".",
"Stat",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"0",
",",
"err",
"\n",
"}",
"\n",
"return",
"r",
",",
"fi",
".",
"Size",
"(",
")",
",",
"nil",
"\n",
"}"
]
|
17,465 | all-17466 | [
"Create",
"a",
"new",
"SnowballWord",
"struct"
]
| [
"func",
"New",
"(",
"in",
"string",
")",
"(",
"word",
"*",
"SnowballWord",
")",
"{",
"word",
"=",
"&",
"SnowballWord",
"{",
"RS",
":",
"[",
"]",
"rune",
"(",
"in",
")",
"}",
"\n",
"word",
".",
"R1start",
"=",
"len",
"(",
"word",
".",
"RS",
")",
"\n",
"<mask>",
".",
"R2start",
"=",
"len",
"(",
"word",
".",
"RS",
")",
"\n",
"word",
".",
"RVstart",
"=",
"len",
"(",
"word",
".",
"RS",
")",
"\n",
"return",
"\n",
"}"
]
|
17,466 | all-17467 | [
"Load",
"reads",
"a",
"protobuf",
"-",
"encoded",
"list",
"of",
"all",
"entries",
"from",
"a",
"reader",
"and",
"writes",
"them",
"to",
"the",
"database",
".",
"This",
"can",
"be",
"used",
"to",
"restore",
"the",
"database",
"from",
"a",
"backup",
"made",
"by",
"calling",
"DB",
".",
"Backup",
"()",
".",
"DB",
".",
"Load",
"()",
"should",
"be",
"called",
"on",
"a",
"database",
"that",
"is",
"not",
"running",
"any",
"other",
"concurrent",
"transactions",
"while",
"it",
"is",
"running",
"."
]
| [
"func",
"(",
"db",
"*",
"DB",
")",
"Load",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"br",
":=",
"bufio",
".",
"NewReaderSize",
"(",
"r",
",",
"16",
"<<",
"10",
")",
"\n",
"unmarshalBuf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1",
"<<",
"10",
")",
"\n",
"var",
"entries",
"[",
"]",
"*",
"Entry",
"\n",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"errChan",
":=",
"make",
"(",
"chan",
"error",
",",
"1",
")",
"\n\n",
"// func to check for pending error before sending off a batch for writing",
"batchSetAsyncIfNoErr",
":=",
"func",
"(",
"entries",
"[",
"]",
"*",
"Entry",
")",
"error",
"{",
"<mask>",
"{",
"case",
"err",
":=",
"<-",
"errChan",
":",
"return",
"err",
"\n",
"default",
":",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"return",
"db",
".",
"batchSetAsync",
"(",
"entries",
",",
"func",
"(",
"err",
"error",
")",
"{",
"defer",
"wg",
".",
"Done",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"select",
"{",
"case",
"errChan",
"<-",
"err",
":",
"default",
":",
"}",
"\n",
"}",
"\n",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"{",
"var",
"sz",
"uint64",
"\n",
"err",
":=",
"binary",
".",
"Read",
"(",
"br",
",",
"binary",
".",
"LittleEndian",
",",
"&",
"sz",
")",
"\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"break",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"cap",
"(",
"unmarshalBuf",
")",
"<",
"int",
"(",
"sz",
")",
"{",
"unmarshalBuf",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"sz",
")",
"\n",
"}",
"\n\n",
"e",
":=",
"&",
"pb",
".",
"KV",
"{",
"}",
"\n",
"if",
"_",
",",
"err",
"=",
"io",
".",
"ReadFull",
"(",
"br",
",",
"unmarshalBuf",
"[",
":",
"sz",
"]",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
"=",
"e",
".",
"Unmarshal",
"(",
"unmarshalBuf",
"[",
":",
"sz",
"]",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"var",
"userMeta",
"byte",
"\n",
"if",
"len",
"(",
"e",
".",
"UserMeta",
")",
">",
"0",
"{",
"userMeta",
"=",
"e",
".",
"UserMeta",
"[",
"0",
"]",
"\n",
"}",
"\n",
"entries",
"=",
"append",
"(",
"entries",
",",
"&",
"Entry",
"{",
"Key",
":",
"y",
".",
"KeyWithTs",
"(",
"e",
".",
"Key",
",",
"e",
".",
"Version",
")",
",",
"Value",
":",
"e",
".",
"Value",
",",
"UserMeta",
":",
"userMeta",
",",
"ExpiresAt",
":",
"e",
".",
"ExpiresAt",
",",
"meta",
":",
"e",
".",
"Meta",
"[",
"0",
"]",
",",
"}",
")",
"\n",
"// Update nextTxnTs, memtable stores this timestamp in badger head",
"// when flushed.",
"if",
"e",
".",
"Version",
">=",
"db",
".",
"orc",
".",
"nextTxnTs",
"{",
"db",
".",
"orc",
".",
"nextTxnTs",
"=",
"e",
".",
"Version",
"+",
"1",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"entries",
")",
"==",
"1000",
"{",
"if",
"err",
":=",
"batchSetAsyncIfNoErr",
"(",
"entries",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"entries",
"=",
"make",
"(",
"[",
"]",
"*",
"Entry",
",",
"0",
",",
"1000",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"entries",
")",
">",
"0",
"{",
"if",
"err",
":=",
"batchSetAsyncIfNoErr",
"(",
"entries",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"wg",
".",
"Wait",
"(",
")",
"\n\n",
"select",
"{",
"case",
"err",
":=",
"<-",
"errChan",
":",
"return",
"err",
"\n",
"default",
":",
"// Mark all versions done up until nextTxnTs.",
"db",
".",
"orc",
".",
"txnMark",
".",
"Done",
"(",
"db",
".",
"orc",
".",
"nextTxnTs",
"-",
"1",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
]
|
17,467 | all-17468 | [
"Extract",
"command",
"line",
"argument",
"with",
"given",
"name",
"and",
"return",
"remaining",
"arguments"
]
| [
"func",
"extractArg",
"(",
"name",
"string",
",",
"args",
"[",
"]",
"string",
")",
"(",
"string",
",",
"[",
"]",
"string",
")",
"{",
"var",
"val",
"string",
"\n",
"var",
"newArgs",
"[",
"]",
"string",
"\n",
"var",
"skip",
"bool",
"\n",
"for",
"i",
",",
"a",
":=",
"<mask>",
"args",
"{",
"if",
"skip",
"{",
"skip",
"=",
"false",
"\n",
"continue",
"\n",
"}",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"a",
",",
"\"",
"\"",
")",
"{",
"elems",
":=",
"strings",
".",
"SplitN",
"(",
"a",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
"elems",
"[",
"0",
"]",
"==",
"name",
"{",
"val",
"=",
"elems",
"[",
"1",
"]",
"\n",
"}",
"else",
"{",
"newArgs",
"=",
"append",
"(",
"newArgs",
",",
"a",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"a",
"==",
"name",
"&&",
"len",
"(",
"args",
")",
">",
"(",
"i",
"+",
"1",
")",
"{",
"val",
"=",
"args",
"[",
"i",
"+",
"1",
"]",
"\n",
"skip",
"=",
"true",
"\n",
"}",
"else",
"{",
"newArgs",
"=",
"append",
"(",
"newArgs",
",",
"a",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"val",
",",
"newArgs",
"\n",
"}"
]
|
17,468 | all-17469 | [
"newStructType",
"takes",
"a",
"Go",
"type",
"as",
"argument",
"and",
"extract",
"information",
"to",
"make",
"a",
"new",
"structType",
"value",
".",
"The",
"type",
"has",
"to",
"be",
"a",
"struct",
"type",
"or",
"a",
"panic",
"will",
"be",
"raised",
"."
]
| [
"func",
"newStructType",
"(",
"t",
"reflect",
".",
"Type",
",",
"c",
"map",
"[",
"reflect",
".",
"Type",
"]",
"*",
"structType",
")",
"*",
"structType",
"{",
"if",
"s",
":=",
"c",
"[",
"t",
"]",
";",
"s",
"!=",
"nil",
"{",
"return",
"s",
"\n",
"}",
"\n\n",
"n",
":=",
"t",
".",
"NumField",
"(",
")",
"\n",
"s",
":=",
"&",
"structType",
"{",
"fields",
":",
"make",
"(",
"[",
"]",
"structField",
",",
"0",
",",
"n",
")",
",",
"fieldsByName",
":",
"make",
"(",
"<mask>",
"[",
"string",
"]",
"*",
"structField",
")",
",",
"}",
"\n",
"c",
"[",
"t",
"]",
"=",
"s",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"!=",
"n",
";",
"i",
"++",
"{",
"ft",
":=",
"t",
".",
"Field",
"(",
"i",
")",
"\n\n",
"if",
"ft",
".",
"Anonymous",
"||",
"len",
"(",
"ft",
".",
"PkgPath",
")",
"!=",
"0",
"{",
"// anonymous or non-exported",
"continue",
"\n",
"}",
"\n\n",
"sf",
":=",
"makeStructField",
"(",
"ft",
",",
"c",
")",
"\n\n",
"if",
"sf",
".",
"name",
"==",
"\"",
"\"",
"{",
"// skip",
"continue",
"\n",
"}",
"\n\n",
"s",
".",
"fields",
"=",
"append",
"(",
"s",
".",
"fields",
",",
"sf",
")",
"\n",
"s",
".",
"fieldsByName",
"[",
"sf",
".",
"name",
"]",
"=",
"&",
"s",
".",
"fields",
"[",
"len",
"(",
"s",
".",
"fields",
")",
"-",
"1",
"]",
"\n",
"}",
"\n\n",
"return",
"s",
"\n",
"}"
]
|
17,469 | all-17470 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"EventConsoleAPICalled",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoRuntime35",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
17,470 | all-17471 | [
"export",
"FrameSet_Frames"
]
| [
"func",
"FrameSet_Frames",
"(",
"id",
"FrameSetId",
",",
"out",
"*",
"C",
".",
"int",
")",
"C",
".",
"int",
"{",
"<mask>",
",",
"ok",
":=",
"sFrameSets",
".",
"Get",
"(",
"id",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"C",
".",
"int",
"(",
"0",
")",
"\n",
"}",
"\n\n",
"goframes",
":=",
"fs",
".",
"Frames",
"(",
")",
"\n",
"size",
":=",
"len",
"(",
"goframes",
")",
"\n\n",
"if",
"size",
"==",
"0",
"{",
"return",
"C",
".",
"int",
"(",
"0",
")",
"\n",
"}",
"\n\n",
"intSize",
":=",
"int",
"(",
"unsafe",
".",
"Sizeof",
"(",
"C",
".",
"int",
"(",
"0",
")",
")",
")",
"\n",
"startPtr",
":=",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"out",
")",
")",
"\n",
"for",
"i",
",",
"frame",
":=",
"range",
"goframes",
"{",
"ptr",
":=",
"unsafe",
".",
"Pointer",
"(",
"startPtr",
"+",
"uintptr",
"(",
"intSize",
"*",
"i",
")",
")",
"\n",
"*",
"(",
"*",
"C",
".",
"int",
")",
"(",
"ptr",
")",
"=",
"C",
".",
"int",
"(",
"int32",
"(",
"frame",
")",
")",
"\n",
"}",
"\n\n",
"return",
"C",
".",
"int",
"(",
"size",
")",
"\n",
"}"
]
|
17,471 | all-17472 | [
"SetCancelLabel",
"is",
"a",
"wrapper",
"around",
"gtk_file_chooser_native_set_cancel_label",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"FileChooserNativeDialog",
")",
"SetCancelLabel",
"(",
"cancel_label",
"string",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"cancel_label",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"C",
".",
"gtk_file_chooser_native_set_cancel_label",
"(",
"v",
".",
"native",
"(",
")",
",",
"(",
"*",
"C",
".",
"<mask>",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
]
|
17,472 | all-17473 | [
"shouldWatch",
"returns",
"whether",
"the",
"service",
"of",
"the",
"given",
"name",
"should",
"be",
"watched",
"."
]
| [
"func",
"(",
"d",
"*",
"Discovery",
")",
"shouldWatch",
"(",
"name",
"string",
",",
"tags",
"[",
"]",
"string",
")",
"bool",
"{",
"return",
"d",
".",
"shouldWatchFromName",
"(",
"<mask>",
")",
"&&",
"d",
".",
"shouldWatchFromTags",
"(",
"tags",
")",
"\n",
"}"
]
|
17,473 | all-17474 | [
"CheckTrustState",
"checks",
"whether",
"the",
"given",
"client",
"certificate",
"is",
"trusted",
"(",
"i",
".",
"e",
".",
"it",
"has",
"a",
"valid",
"time",
"span",
"and",
"it",
"belongs",
"to",
"the",
"given",
"list",
"of",
"trusted",
"certificates",
")",
"."
]
| [
"func",
"CheckTrustState",
"(",
"cert",
"x509",
".",
"Certificate",
",",
"trustedCerts",
"map",
"[",
"string",
"]",
"x509",
".",
"Certificate",
")",
"(",
"bool",
",",
"string",
")",
"{",
"// Extra validity check (should have been caught by TLS stack)",
"if",
"time",
".",
"Now",
"(",
")",
".",
"Before",
"(",
"cert",
".",
"NotBefore",
")",
"||",
"time",
".",
"Now",
"(",
")",
".",
"After",
"(",
"cert",
".",
"NotAfter",
")",
"{",
"return",
"<mask>",
",",
"\"",
"\"",
"\n",
"}",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"trustedCerts",
"{",
"if",
"bytes",
".",
"Compare",
"(",
"cert",
".",
"Raw",
",",
"v",
".",
"Raw",
")",
"==",
"0",
"{",
"logger",
".",
"Debug",
"(",
"\"",
"\"",
",",
"log",
".",
"Ctx",
"{",
"\"",
"\"",
":",
"k",
"}",
")",
"\n",
"return",
"true",
",",
"k",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
",",
"\"",
"\"",
"\n",
"}"
]
|
17,474 | all-17475 | [
"_edit",
"is",
"a",
"generic",
"editor",
"for",
"the",
"given",
"user",
"/",
"group",
"name",
".",
"If",
"remove",
"is",
"true",
"it",
"removes",
"the",
"structure",
"of",
"the",
"user",
"/",
"group",
"name",
".",
"TODO",
":",
"get",
"better",
"performance",
"if",
"start",
"to",
"store",
"since",
"when",
"the",
"file",
"is",
"edited",
".",
"So",
"there",
"is",
"to",
"store",
"the",
"size",
"of",
"all",
"lines",
"read",
"until",
"that",
"point",
"to",
"seek",
"from",
"there",
"."
]
| [
"func",
"_edit",
"(",
"name",
"string",
",",
"_row",
"row",
",",
"remove",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"filename",
":=",
"_row",
".",
"filename",
"(",
")",
"\n\n",
"dbf",
",",
"err",
":=",
"openDBFile",
"(",
"filename",
",",
"os",
".",
"O_RDWR",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"e",
":=",
"dbf",
".",
"<mask>",
"(",
")",
"\n",
"if",
"e",
"!=",
"nil",
"&&",
"err",
"==",
"nil",
"{",
"err",
"=",
"e",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"name_b",
":=",
"[",
"]",
"byte",
"(",
"name",
")",
"\n",
"isFound",
":=",
"false",
"\n\n",
"for",
"{",
"line",
",",
"err2",
":=",
"dbf",
".",
"rd",
".",
"ReadBytes",
"(",
"'\\n'",
")",
"\n",
"if",
"err2",
"==",
"io",
".",
"EOF",
"{",
"break",
"\n",
"}",
"\n\n",
"if",
"!",
"isFound",
"&&",
"bytes",
".",
"HasPrefix",
"(",
"line",
",",
"name_b",
")",
"{",
"isFound",
"=",
"true",
"\n",
"if",
"remove",
"{",
"// skip user",
"continue",
"\n",
"}",
"\n\n",
"line",
"=",
"[",
"]",
"byte",
"(",
"_row",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
"=",
"buf",
".",
"Write",
"(",
"line",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"isFound",
"{",
"if",
"err",
"=",
"backup",
"(",
"filename",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"err",
"=",
"dbf",
".",
"file",
".",
"Seek",
"(",
"0",
",",
"os",
".",
"SEEK_SET",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"var",
"n",
"int",
"\n",
"n",
",",
"err",
"=",
"dbf",
".",
"file",
".",
"Write",
"(",
"buf",
".",
"Bytes",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"err",
"=",
"dbf",
".",
"file",
".",
"Truncate",
"(",
"int64",
"(",
"n",
")",
")",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
]
|
17,475 | all-17476 | [
"ForEach",
"calls",
"fn",
"(",
"s",
")",
"for",
"every",
"item",
"s",
"in",
"the",
"output",
"of",
"filter",
"and",
"returns",
"either",
"nil",
"or",
"any",
"error",
"reported",
"by",
"the",
"execution",
"of",
"the",
"filter",
"."
]
| [
"func",
"ForEach",
"(",
"filter",
"Filter",
",",
"fn",
"func",
"(",
"s",
"string",
")",
")",
"error",
"{",
"in",
":=",
"make",
"(",
"chan",
"string",
")",
"\n",
"close",
"(",
"in",
")",
"\n",
"out",
":=",
"make",
"(",
"chan",
"string",
",",
"channelBuffer",
")",
"\n",
"e",
":=",
"&",
"filterErrors",
"{",
"}",
"\n",
"go",
"runFilter",
"(",
"<mask>",
",",
"Arg",
"{",
"In",
":",
"in",
",",
"Out",
":",
"out",
"}",
",",
"e",
")",
"\n",
"for",
"s",
":=",
"range",
"out",
"{",
"fn",
"(",
"s",
")",
"\n",
"}",
"\n",
"return",
"e",
".",
"getError",
"(",
")",
"\n",
"}"
]
|
17,476 | all-17477 | [
"HasId",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"s",
"*",
"SyntheticsLocation",
")",
"HasId",
"(",
")",
"bool",
"{",
"if",
"s",
"!=",
"nil",
"&&",
"s",
".",
"Id",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
]
|
17,477 | all-17478 | [
"MarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Marshaler",
"."
]
| [
"func",
"(",
"t",
"InspectMode",
")",
"MarshalEasyJSON",
"(",
"out",
"*",
"jwriter",
".",
"<mask>",
")",
"{",
"out",
".",
"String",
"(",
"string",
"(",
"t",
")",
")",
"\n",
"}"
]
|
17,478 | all-17479 | [
"Errf",
"is",
"a",
"short",
"-",
"hand",
"version",
"of",
"Errorf"
]
| [
"func",
"(",
"la",
"*",
"LogAdapter",
")",
"Errf",
"(",
"msg",
"string",
",",
"a",
"...",
"<mask>",
"{",
"}",
")",
"error",
"{",
"return",
"la",
".",
"Errorf",
"(",
"msg",
",",
"a",
"...",
")",
"\n",
"}"
]
|
17,479 | all-17480 | [
"linkify",
"transforms",
"a",
"string",
"into",
"a",
"markdown",
"anchor",
"link",
"I",
"could",
"not",
"find",
"a",
"proper",
"doc",
"so",
"rules",
"here",
"a",
"mostly",
"empirical"
]
| [
"func",
"linkify",
"(",
"text",
"string",
")",
"string",
"{",
"// swap space with dash",
"link",
":=",
"strings",
".",
"Replace",
"(",
"<mask>",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"// discard some special characters",
"discard",
",",
"_",
":=",
"regexp",
".",
"Compile",
"(",
"\"",
"\"",
")",
"\n",
"link",
"=",
"discard",
".",
"ReplaceAllString",
"(",
"link",
",",
"\"",
"\"",
")",
"\n",
"// lowercase",
"return",
"strings",
".",
"ToLower",
"(",
"link",
")",
"\n",
"}"
]
|
17,480 | all-17481 | [
"resourceVSphereVirtualMachineUpdateLocationRelocateWithSDRS",
"runs",
"the",
"storage",
"vMotion",
"part",
"of",
"resourceVSphereVirtualMachineUpdateLocation",
"through",
"storage",
"DRS",
".",
"It",
"s",
"designed",
"to",
"be",
"run",
"when",
"a",
"storage",
"cluster",
"is",
"specified",
"versus",
"simply",
"specifying",
"datastores",
"."
]
| [
"func",
"resourceVSphereVirtualMachineUpdateLocationRelocateWithSDRS",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"meta",
"interface",
"{",
"}",
",",
"vm",
"*",
"object",
".",
"VirtualMachine",
",",
"spec",
"types",
".",
"VirtualMachineRelocateSpec",
",",
"timeout",
"int",
",",
")",
"error",
"{",
"client",
":=",
"meta",
".",
"(",
"*",
"VSphereClient",
")",
".",
"vimClient",
"\n",
"if",
"err",
":=",
"viapi",
".",
"ValidateVirtualCenter",
"(",
"client",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"<mask>",
".",
"Printf",
"(",
"\"",
"\"",
",",
"resourceVSphereVirtualMachineIDString",
"(",
"d",
")",
")",
"\n",
"pod",
",",
"err",
":=",
"storagepod",
".",
"FromID",
"(",
"client",
",",
"d",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"string",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"err",
"=",
"storagepod",
".",
"RelocateVM",
"(",
"client",
",",
"vm",
",",
"spec",
",",
"timeout",
",",
"pod",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"pod",
".",
"Name",
"(",
")",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
17,481 | all-17482 | [
"GetSHA256",
"calculates",
"a",
"file",
"s",
"sha256sum"
]
| [
"func",
"GetSHA256",
"(",
"<mask>",
"string",
")",
"string",
"{",
"dat",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"name",
")",
"\n",
"Assert",
"(",
"err",
")",
"\n\n",
"h256",
":=",
"sha256",
".",
"New",
"(",
")",
"\n",
"_",
",",
"err",
"=",
"h256",
".",
"Write",
"(",
"dat",
")",
"\n",
"Assert",
"(",
"err",
")",
"\n\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"h256",
".",
"Sum",
"(",
"nil",
")",
")",
"\n",
"}"
]
|
17,482 | all-17483 | [
"Draw",
"a",
"left",
"hand",
"and",
"ear",
"of",
"a",
"gopher",
"using",
"a",
"gc",
"thanks",
"to",
"https",
":",
"//",
"github",
".",
"com",
"/",
"golang",
"-",
"samples",
"/",
"gopher",
"-",
"vector",
"/"
]
| [
"func",
"Draw",
"(",
"gc",
"draw2d",
".",
"GraphicContext",
")",
"{",
"// Initialize Stroke Attribute",
"gc",
".",
"SetLineWidth",
"(",
"3",
")",
"\n",
"gc",
".",
"SetLineCap",
"(",
"draw2d",
".",
"RoundCap",
")",
"\n",
"gc",
".",
"SetStrokeColor",
"(",
"<mask>",
".",
"Black",
")",
"\n\n",
"// Left hand",
"// <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" fill=\"#F6D2A2\" stroke=\"#000000\" stroke-width=\"3\" stroke-linecap=\"round\" d=\"",
"// M10.634,300.493c0.764,15.751,16.499,8.463,23.626,3.539c6.765-4.675,8.743-0.789,9.337-10.015",
"// c0.389-6.064,1.088-12.128,0.744-18.216c-10.23-0.927-21.357,1.509-29.744,7.602C10.277,286.542,2.177,296.561,10.634,300.493\"/>",
"gc",
".",
"SetFillColor",
"(",
"color",
".",
"RGBA",
"{",
"0xF6",
",",
"0xD2",
",",
"0xA2",
",",
"0xff",
"}",
")",
"\n",
"gc",
".",
"MoveTo",
"(",
"10.634",
",",
"300.493",
")",
"\n",
"rCubicCurveTo",
"(",
"gc",
",",
"0.764",
",",
"15.751",
",",
"16.499",
",",
"8.463",
",",
"23.626",
",",
"3.539",
")",
"\n",
"rCubicCurveTo",
"(",
"gc",
",",
"6.765",
",",
"-",
"4.675",
",",
"8.743",
",",
"-",
"0.789",
",",
"9.337",
",",
"-",
"10.015",
")",
"\n",
"rCubicCurveTo",
"(",
"gc",
",",
"0.389",
",",
"-",
"6.064",
",",
"1.088",
",",
"-",
"12.128",
",",
"0.744",
",",
"-",
"18.216",
")",
"\n",
"rCubicCurveTo",
"(",
"gc",
",",
"-",
"10.23",
",",
"-",
"0.927",
",",
"-",
"21.357",
",",
"1.509",
",",
"-",
"29.744",
",",
"7.602",
")",
"\n",
"gc",
".",
"CubicCurveTo",
"(",
"10.277",
",",
"286.542",
",",
"2.177",
",",
"296.561",
",",
"10.634",
",",
"300.493",
")",
"\n",
"gc",
".",
"FillStroke",
"(",
")",
"\n\n",
"// <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" fill=\"#C6B198\" stroke=\"#000000\" stroke-width=\"3\" stroke-linecap=\"round\" d=\"",
"// M10.634,300.493c2.29-0.852,4.717-1.457,6.271-3.528\"/>",
"gc",
".",
"MoveTo",
"(",
"10.634",
",",
"300.493",
")",
"\n",
"rCubicCurveTo",
"(",
"gc",
",",
"2.29",
",",
"-",
"0.852",
",",
"4.717",
",",
"-",
"1.457",
",",
"6.271",
",",
"-",
"3.528",
")",
"\n",
"gc",
".",
"Stroke",
"(",
")",
"\n\n",
"// Left Ear",
"// <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" fill=\"#6AD7E5\" stroke=\"#000000\" stroke-width=\"3\" stroke-linecap=\"round\" d=\"",
"// M46.997,112.853C-13.3,95.897,31.536,19.189,79.956,50.74L46.997,112.853z\"/>",
"gc",
".",
"MoveTo",
"(",
"46.997",
",",
"112.853",
")",
"\n",
"gc",
".",
"CubicCurveTo",
"(",
"-",
"13.3",
",",
"95.897",
",",
"31.536",
",",
"19.189",
",",
"79.956",
",",
"50.74",
")",
"\n",
"gc",
".",
"LineTo",
"(",
"46.997",
",",
"112.853",
")",
"\n",
"gc",
".",
"Close",
"(",
")",
"\n",
"gc",
".",
"Stroke",
"(",
")",
"\n",
"}"
]
|
17,483 | all-17484 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"GetLayoutMetricsReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage36",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
17,484 | all-17485 | [
"Common",
"code",
"for",
"date",
"related",
"functions",
"."
]
| [
"func",
"dateWrapper",
"(",
"vals",
"[",
"]",
"<mask>",
",",
"enh",
"*",
"EvalNodeHelper",
",",
"f",
"func",
"(",
"time",
".",
"Time",
")",
"float64",
")",
"Vector",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"enh",
".",
"out",
",",
"Sample",
"{",
"Metric",
":",
"labels",
".",
"Labels",
"{",
"}",
",",
"Point",
":",
"Point",
"{",
"V",
":",
"f",
"(",
"time",
".",
"Unix",
"(",
"enh",
".",
"ts",
"/",
"1000",
",",
"0",
")",
".",
"UTC",
"(",
")",
")",
"}",
",",
"}",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"el",
":=",
"range",
"vals",
"[",
"0",
"]",
".",
"(",
"Vector",
")",
"{",
"t",
":=",
"time",
".",
"Unix",
"(",
"int64",
"(",
"el",
".",
"V",
")",
",",
"0",
")",
".",
"UTC",
"(",
")",
"\n",
"enh",
".",
"out",
"=",
"append",
"(",
"enh",
".",
"out",
",",
"Sample",
"{",
"Metric",
":",
"enh",
".",
"dropMetricName",
"(",
"el",
".",
"Metric",
")",
",",
"Point",
":",
"Point",
"{",
"V",
":",
"f",
"(",
"t",
")",
"}",
",",
"}",
")",
"\n",
"}",
"\n",
"return",
"enh",
".",
"out",
"\n",
"}"
]
|
17,485 | all-17486 | [
"HasGroup",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"w",
"*",
"Widget",
")",
"HasGroup",
"(",
")",
"bool",
"{",
"if",
"w",
"!=",
"nil",
"&&",
"w",
".",
"<mask>",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
]
|
17,486 | all-17487 | [
"WithProgress",
"is",
"a",
"helper",
"to",
"introspect",
"the",
"Progress",
"for",
"this",
"node",
"and",
"its",
"peers",
"."
]
| [
"func",
"(",
"rn",
"*",
"RawNode",
")",
"WithProgress",
"(",
"visitor",
"func",
"(",
"id",
"uint64",
",",
"typ",
"ProgressType",
",",
"pr",
"Progress",
")",
")",
"{",
"for",
"id",
",",
"pr",
":=",
"range",
"rn",
".",
"raft",
".",
"prs",
"{",
"pr",
":=",
"*",
"pr",
"\n",
"pr",
".",
"ins",
"=",
"nil",
"\n",
"visitor",
"(",
"id",
",",
"ProgressTypePeer",
",",
"pr",
")",
"\n",
"}",
"\n",
"for",
"id",
",",
"pr",
":=",
"range",
"rn",
".",
"raft",
".",
"learnerPrs",
"{",
"pr",
":=",
"*",
"pr",
"\n",
"pr",
".",
"<mask>",
"=",
"nil",
"\n",
"visitor",
"(",
"id",
",",
"ProgressTypeLearner",
",",
"pr",
")",
"\n",
"}",
"\n",
"}"
]
|
17,487 | all-17488 | [
"extractFuncFromPath",
"walks",
"up",
"the",
"path",
"and",
"searches",
"for",
"the",
"first",
"instance",
"of",
"a",
"function",
"or",
"aggregation",
"."
]
| [
"func",
"extractFuncFromPath",
"(",
"p",
"[",
"]",
"Node",
")",
"string",
"{",
"if",
"len",
"(",
"p",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"switch",
"n",
":=",
"p",
"[",
"len",
"(",
"p",
")",
"-",
"1",
"]",
".",
"(",
"type",
")",
"{",
"case",
"*",
"AggregateExpr",
":",
"return",
"n",
".",
"Op",
".",
"String",
"(",
")",
"\n",
"case",
"*",
"Call",
":",
"return",
"n",
".",
"Func",
".",
"Name",
"\n",
"<mask>",
"*",
"BinaryExpr",
":",
"// If we hit a binary expression we terminate since we only care about functions",
"// or aggregations over a single metric.",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"extractFuncFromPath",
"(",
"p",
"[",
":",
"len",
"(",
"p",
")",
"-",
"1",
"]",
")",
"\n",
"}"
]
|
17,488 | all-17489 | [
"attach",
"a",
"single",
"layer",
"of",
"a",
"texture",
"object",
"as",
"a",
"logical",
"buffer",
"of",
"a",
"framebuffer",
"object"
]
| [
"func",
"NamedFramebufferTextureLayer",
"(",
"framebuffer",
"uint32",
",",
"attachment",
"uint32",
",",
"texture",
"uint32",
",",
"<mask>",
"int32",
",",
"layer",
"int32",
")",
"{",
"C",
".",
"glowNamedFramebufferTextureLayer",
"(",
"gpNamedFramebufferTextureLayer",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"framebuffer",
")",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"attachment",
")",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"texture",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"level",
")",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"layer",
")",
")",
"\n",
"}"
]
|
17,489 | all-17490 | [
"exist",
"checks",
"if",
"the",
"file",
"exists",
"."
]
| [
"func",
"exist",
"(",
"file",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"<mask>",
".",
"Stat",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"os",
".",
"ErrNotExist",
"{",
"return",
"false",
",",
"nil",
"\n",
"}",
"\n",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"true",
",",
"nil",
"\n",
"}"
]
|
17,490 | all-17491 | [
"EnsurePrefixF",
"is",
"the",
"filter",
"form",
"of",
"EnsurePrefix",
"."
]
| [
"func",
"EnsurePrefixF",
"(",
"prefix",
"string",
")",
"func",
"(",
"string",
")",
"string",
"{",
"return",
"func",
"(",
"s",
"string",
")",
"string",
"{",
"return",
"EnsurePrefix",
"(",
"s",
",",
"<mask>",
")",
"\n",
"}",
"\n",
"}"
]
|
17,491 | all-17492 | [
"v2KeysURL",
"forms",
"a",
"URL",
"representing",
"the",
"location",
"of",
"a",
"key",
".",
"The",
"endpoint",
"argument",
"represents",
"the",
"base",
"URL",
"of",
"an",
"etcd",
"server",
".",
"The",
"prefix",
"is",
"the",
"path",
"needed",
"to",
"route",
"from",
"the",
"provided",
"endpoint",
"s",
"path",
"to",
"the",
"root",
"of",
"the",
"keys",
"API",
"(",
"typically",
"/",
"v2",
"/",
"keys",
")",
"."
]
| [
"func",
"v2KeysURL",
"(",
"ep",
"url",
".",
"URL",
",",
"prefix",
",",
"key",
"string",
")",
"*",
"url",
".",
"URL",
"{",
"// We concatenate all parts together manually. We cannot use",
"// path.Join because it does not reserve trailing slash.",
"// We call CanonicalURLPath to further cleanup the path.",
"if",
"prefix",
"!=",
"\"",
"\"",
"&&",
"prefix",
"[",
"0",
"]",
"!=",
"'/'",
"{",
"prefix",
"=",
"\"",
"\"",
"+",
"<mask>",
"\n",
"}",
"\n",
"if",
"key",
"!=",
"\"",
"\"",
"&&",
"key",
"[",
"0",
"]",
"!=",
"'/'",
"{",
"key",
"=",
"\"",
"\"",
"+",
"key",
"\n",
"}",
"\n",
"ep",
".",
"Path",
"=",
"pathutil",
".",
"CanonicalURLPath",
"(",
"ep",
".",
"Path",
"+",
"prefix",
"+",
"key",
")",
"\n",
"return",
"&",
"ep",
"\n",
"}"
]
|
17,492 | all-17493 | [
"NewAPIClient",
"creates",
"a",
"new",
"API",
"client",
".",
"Requires",
"a",
"userAgent",
"string",
"describing",
"your",
"application",
".",
"optionally",
"a",
"custom",
"http",
".",
"Client",
"to",
"allow",
"for",
"advanced",
"features",
"such",
"as",
"caching",
"."
]
| [
"func",
"NewAPIClient",
"(",
"cfg",
"*",
"Configuration",
")",
"*",
"APIClient",
"{",
"if",
"cfg",
".",
"HTTPClient",
"==",
"nil",
"{",
"cfg",
".",
"HTTPClient",
"=",
"http",
".",
"DefaultClient",
"\n",
"}",
"\n\n",
"c",
":=",
"&",
"APIClient",
"{",
"}",
"\n",
"c",
".",
"cfg",
"=",
"cfg",
"\n",
"c",
".",
"common",
".",
"client",
"=",
"c",
"\n\n",
"// API Services",
"c",
".",
"ServiceProviderConfigApi",
"=",
"(",
"*",
"ServiceProviderConfigApiService",
")",
"(",
"&",
"c",
".",
"common",
")",
"\n",
"c",
".",
"UserApi",
"=",
"(",
"*",
"UserApiService",
")",
"(",
"&",
"c",
".",
"<mask>",
")",
"\n\n",
"return",
"c",
"\n",
"}"
]
|
17,493 | all-17494 | [
"RegisterLeaseHandler",
"registers",
"the",
"http",
"handlers",
"for",
"service",
"Lease",
"to",
"mux",
".",
"The",
"handlers",
"forward",
"requests",
"to",
"the",
"grpc",
"endpoint",
"over",
"the",
"given",
"implementation",
"of",
"LeaseClient",
".",
"Note",
":",
"the",
"gRPC",
"framework",
"executes",
"interceptors",
"within",
"the",
"gRPC",
"handler",
".",
"If",
"the",
"passed",
"in",
"LeaseClient",
"doesn",
"t",
"go",
"through",
"the",
"normal",
"gRPC",
"flow",
"(",
"creating",
"a",
"gRPC",
"client",
"etc",
".",
")",
"then",
"it",
"will",
"be",
"up",
"to",
"the",
"passed",
"in",
"LeaseClient",
"to",
"call",
"the",
"correct",
"interceptors",
"."
]
| [
"func",
"RegisterLeaseHandlerClient",
"(",
"ctx",
"context",
".",
"Context",
",",
"mux",
"*",
"runtime",
".",
"ServeMux",
",",
"client",
"etcdserverpb",
".",
"LeaseClient",
")",
"error",
"{",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"pattern_Lease_LeaseGrant_0",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"pathParams",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"req",
".",
"Context",
"(",
")",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"if",
"cn",
",",
"ok",
":=",
"w",
".",
"(",
"http",
".",
"CloseNotifier",
")",
";",
"ok",
"{",
"go",
"func",
"(",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"closed",
"<-",
"chan",
"bool",
")",
"{",
"<mask>",
"{",
"case",
"<-",
"done",
":",
"case",
"<-",
"closed",
":",
"cancel",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
"ctx",
".",
"Done",
"(",
")",
",",
"cn",
".",
"CloseNotify",
"(",
")",
")",
"\n",
"}",
"\n",
"inboundMarshaler",
",",
"outboundMarshaler",
":=",
"runtime",
".",
"MarshalerForRequest",
"(",
"mux",
",",
"req",
")",
"\n",
"rctx",
",",
"err",
":=",
"runtime",
".",
"AnnotateContext",
"(",
"ctx",
",",
"mux",
",",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"resp",
",",
"md",
",",
"err",
":=",
"request_Lease_LeaseGrant_0",
"(",
"rctx",
",",
"inboundMarshaler",
",",
"client",
",",
"req",
",",
"pathParams",
")",
"\n",
"ctx",
"=",
"runtime",
".",
"NewServerMetadataContext",
"(",
"ctx",
",",
"md",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"forward_Lease_LeaseGrant_0",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"resp",
",",
"mux",
".",
"GetForwardResponseOptions",
"(",
")",
"...",
")",
"\n\n",
"}",
")",
"\n\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"pattern_Lease_LeaseRevoke_0",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"pathParams",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"req",
".",
"Context",
"(",
")",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"if",
"cn",
",",
"ok",
":=",
"w",
".",
"(",
"http",
".",
"CloseNotifier",
")",
";",
"ok",
"{",
"go",
"func",
"(",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"closed",
"<-",
"chan",
"bool",
")",
"{",
"select",
"{",
"case",
"<-",
"done",
":",
"case",
"<-",
"closed",
":",
"cancel",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
"ctx",
".",
"Done",
"(",
")",
",",
"cn",
".",
"CloseNotify",
"(",
")",
")",
"\n",
"}",
"\n",
"inboundMarshaler",
",",
"outboundMarshaler",
":=",
"runtime",
".",
"MarshalerForRequest",
"(",
"mux",
",",
"req",
")",
"\n",
"rctx",
",",
"err",
":=",
"runtime",
".",
"AnnotateContext",
"(",
"ctx",
",",
"mux",
",",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"resp",
",",
"md",
",",
"err",
":=",
"request_Lease_LeaseRevoke_0",
"(",
"rctx",
",",
"inboundMarshaler",
",",
"client",
",",
"req",
",",
"pathParams",
")",
"\n",
"ctx",
"=",
"runtime",
".",
"NewServerMetadataContext",
"(",
"ctx",
",",
"md",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"forward_Lease_LeaseRevoke_0",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"resp",
",",
"mux",
".",
"GetForwardResponseOptions",
"(",
")",
"...",
")",
"\n\n",
"}",
")",
"\n\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"pattern_Lease_LeaseRevoke_1",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"pathParams",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"req",
".",
"Context",
"(",
")",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"if",
"cn",
",",
"ok",
":=",
"w",
".",
"(",
"http",
".",
"CloseNotifier",
")",
";",
"ok",
"{",
"go",
"func",
"(",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"closed",
"<-",
"chan",
"bool",
")",
"{",
"select",
"{",
"case",
"<-",
"done",
":",
"case",
"<-",
"closed",
":",
"cancel",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
"ctx",
".",
"Done",
"(",
")",
",",
"cn",
".",
"CloseNotify",
"(",
")",
")",
"\n",
"}",
"\n",
"inboundMarshaler",
",",
"outboundMarshaler",
":=",
"runtime",
".",
"MarshalerForRequest",
"(",
"mux",
",",
"req",
")",
"\n",
"rctx",
",",
"err",
":=",
"runtime",
".",
"AnnotateContext",
"(",
"ctx",
",",
"mux",
",",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"resp",
",",
"md",
",",
"err",
":=",
"request_Lease_LeaseRevoke_1",
"(",
"rctx",
",",
"inboundMarshaler",
",",
"client",
",",
"req",
",",
"pathParams",
")",
"\n",
"ctx",
"=",
"runtime",
".",
"NewServerMetadataContext",
"(",
"ctx",
",",
"md",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"forward_Lease_LeaseRevoke_1",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"resp",
",",
"mux",
".",
"GetForwardResponseOptions",
"(",
")",
"...",
")",
"\n\n",
"}",
")",
"\n\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"pattern_Lease_LeaseKeepAlive_0",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"pathParams",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"req",
".",
"Context",
"(",
")",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"if",
"cn",
",",
"ok",
":=",
"w",
".",
"(",
"http",
".",
"CloseNotifier",
")",
";",
"ok",
"{",
"go",
"func",
"(",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"closed",
"<-",
"chan",
"bool",
")",
"{",
"select",
"{",
"case",
"<-",
"done",
":",
"case",
"<-",
"closed",
":",
"cancel",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
"ctx",
".",
"Done",
"(",
")",
",",
"cn",
".",
"CloseNotify",
"(",
")",
")",
"\n",
"}",
"\n",
"inboundMarshaler",
",",
"outboundMarshaler",
":=",
"runtime",
".",
"MarshalerForRequest",
"(",
"mux",
",",
"req",
")",
"\n",
"rctx",
",",
"err",
":=",
"runtime",
".",
"AnnotateContext",
"(",
"ctx",
",",
"mux",
",",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"resp",
",",
"md",
",",
"err",
":=",
"request_Lease_LeaseKeepAlive_0",
"(",
"rctx",
",",
"inboundMarshaler",
",",
"client",
",",
"req",
",",
"pathParams",
")",
"\n",
"ctx",
"=",
"runtime",
".",
"NewServerMetadataContext",
"(",
"ctx",
",",
"md",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"forward_Lease_LeaseKeepAlive_0",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"func",
"(",
")",
"(",
"proto",
".",
"Message",
",",
"error",
")",
"{",
"return",
"resp",
".",
"Recv",
"(",
")",
"}",
",",
"mux",
".",
"GetForwardResponseOptions",
"(",
")",
"...",
")",
"\n\n",
"}",
")",
"\n\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"pattern_Lease_LeaseTimeToLive_0",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"pathParams",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"req",
".",
"Context",
"(",
")",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"if",
"cn",
",",
"ok",
":=",
"w",
".",
"(",
"http",
".",
"CloseNotifier",
")",
";",
"ok",
"{",
"go",
"func",
"(",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"closed",
"<-",
"chan",
"bool",
")",
"{",
"select",
"{",
"case",
"<-",
"done",
":",
"case",
"<-",
"closed",
":",
"cancel",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
"ctx",
".",
"Done",
"(",
")",
",",
"cn",
".",
"CloseNotify",
"(",
")",
")",
"\n",
"}",
"\n",
"inboundMarshaler",
",",
"outboundMarshaler",
":=",
"runtime",
".",
"MarshalerForRequest",
"(",
"mux",
",",
"req",
")",
"\n",
"rctx",
",",
"err",
":=",
"runtime",
".",
"AnnotateContext",
"(",
"ctx",
",",
"mux",
",",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"resp",
",",
"md",
",",
"err",
":=",
"request_Lease_LeaseTimeToLive_0",
"(",
"rctx",
",",
"inboundMarshaler",
",",
"client",
",",
"req",
",",
"pathParams",
")",
"\n",
"ctx",
"=",
"runtime",
".",
"NewServerMetadataContext",
"(",
"ctx",
",",
"md",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"forward_Lease_LeaseTimeToLive_0",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"resp",
",",
"mux",
".",
"GetForwardResponseOptions",
"(",
")",
"...",
")",
"\n\n",
"}",
")",
"\n\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"pattern_Lease_LeaseTimeToLive_1",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"pathParams",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"req",
".",
"Context",
"(",
")",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"if",
"cn",
",",
"ok",
":=",
"w",
".",
"(",
"http",
".",
"CloseNotifier",
")",
";",
"ok",
"{",
"go",
"func",
"(",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"closed",
"<-",
"chan",
"bool",
")",
"{",
"select",
"{",
"case",
"<-",
"done",
":",
"case",
"<-",
"closed",
":",
"cancel",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
"ctx",
".",
"Done",
"(",
")",
",",
"cn",
".",
"CloseNotify",
"(",
")",
")",
"\n",
"}",
"\n",
"inboundMarshaler",
",",
"outboundMarshaler",
":=",
"runtime",
".",
"MarshalerForRequest",
"(",
"mux",
",",
"req",
")",
"\n",
"rctx",
",",
"err",
":=",
"runtime",
".",
"AnnotateContext",
"(",
"ctx",
",",
"mux",
",",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"resp",
",",
"md",
",",
"err",
":=",
"request_Lease_LeaseTimeToLive_1",
"(",
"rctx",
",",
"inboundMarshaler",
",",
"client",
",",
"req",
",",
"pathParams",
")",
"\n",
"ctx",
"=",
"runtime",
".",
"NewServerMetadataContext",
"(",
"ctx",
",",
"md",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"forward_Lease_LeaseTimeToLive_1",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"resp",
",",
"mux",
".",
"GetForwardResponseOptions",
"(",
")",
"...",
")",
"\n\n",
"}",
")",
"\n\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"pattern_Lease_LeaseLeases_0",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"pathParams",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"req",
".",
"Context",
"(",
")",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"if",
"cn",
",",
"ok",
":=",
"w",
".",
"(",
"http",
".",
"CloseNotifier",
")",
";",
"ok",
"{",
"go",
"func",
"(",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"closed",
"<-",
"chan",
"bool",
")",
"{",
"select",
"{",
"case",
"<-",
"done",
":",
"case",
"<-",
"closed",
":",
"cancel",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
"ctx",
".",
"Done",
"(",
")",
",",
"cn",
".",
"CloseNotify",
"(",
")",
")",
"\n",
"}",
"\n",
"inboundMarshaler",
",",
"outboundMarshaler",
":=",
"runtime",
".",
"MarshalerForRequest",
"(",
"mux",
",",
"req",
")",
"\n",
"rctx",
",",
"err",
":=",
"runtime",
".",
"AnnotateContext",
"(",
"ctx",
",",
"mux",
",",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"resp",
",",
"md",
",",
"err",
":=",
"request_Lease_LeaseLeases_0",
"(",
"rctx",
",",
"inboundMarshaler",
",",
"client",
",",
"req",
",",
"pathParams",
")",
"\n",
"ctx",
"=",
"runtime",
".",
"NewServerMetadataContext",
"(",
"ctx",
",",
"md",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"forward_Lease_LeaseLeases_0",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"resp",
",",
"mux",
".",
"GetForwardResponseOptions",
"(",
")",
"...",
")",
"\n\n",
"}",
")",
"\n\n",
"mux",
".",
"Handle",
"(",
"\"",
"\"",
",",
"pattern_Lease_LeaseLeases_1",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"pathParams",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"req",
".",
"Context",
"(",
")",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"if",
"cn",
",",
"ok",
":=",
"w",
".",
"(",
"http",
".",
"CloseNotifier",
")",
";",
"ok",
"{",
"go",
"func",
"(",
"done",
"<-",
"chan",
"struct",
"{",
"}",
",",
"closed",
"<-",
"chan",
"bool",
")",
"{",
"select",
"{",
"case",
"<-",
"done",
":",
"case",
"<-",
"closed",
":",
"cancel",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
"ctx",
".",
"Done",
"(",
")",
",",
"cn",
".",
"CloseNotify",
"(",
")",
")",
"\n",
"}",
"\n",
"inboundMarshaler",
",",
"outboundMarshaler",
":=",
"runtime",
".",
"MarshalerForRequest",
"(",
"mux",
",",
"req",
")",
"\n",
"rctx",
",",
"err",
":=",
"runtime",
".",
"AnnotateContext",
"(",
"ctx",
",",
"mux",
",",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"resp",
",",
"md",
",",
"err",
":=",
"request_Lease_LeaseLeases_1",
"(",
"rctx",
",",
"inboundMarshaler",
",",
"client",
",",
"req",
",",
"pathParams",
")",
"\n",
"ctx",
"=",
"runtime",
".",
"NewServerMetadataContext",
"(",
"ctx",
",",
"md",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"runtime",
".",
"HTTPError",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"forward_Lease_LeaseLeases_1",
"(",
"ctx",
",",
"mux",
",",
"outboundMarshaler",
",",
"w",
",",
"req",
",",
"resp",
",",
"mux",
".",
"GetForwardResponseOptions",
"(",
")",
"...",
")",
"\n\n",
"}",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
17,494 | all-17495 | [
"maybeCommit",
"attempts",
"to",
"advance",
"the",
"commit",
"index",
".",
"Returns",
"true",
"if",
"the",
"commit",
"index",
"changed",
"(",
"in",
"which",
"case",
"the",
"caller",
"should",
"call",
"r",
".",
"bcastAppend",
")",
"."
]
| [
"func",
"(",
"r",
"*",
"raft",
")",
"maybeCommit",
"(",
")",
"bool",
"{",
"// Preserving matchBuf across calls is an optimization",
"// used to avoid allocating a new slice on each call.",
"if",
"cap",
"(",
"r",
".",
"matchBuf",
")",
"<",
"len",
"(",
"r",
".",
"prs",
")",
"{",
"r",
".",
"matchBuf",
"=",
"make",
"(",
"uint64Slice",
",",
"len",
"(",
"r",
".",
"prs",
")",
")",
"\n",
"}",
"\n",
"r",
".",
"matchBuf",
"=",
"r",
".",
"matchBuf",
"[",
":",
"len",
"(",
"r",
".",
"prs",
")",
"]",
"\n",
"idx",
":=",
"0",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"r",
".",
"prs",
"{",
"r",
".",
"matchBuf",
"[",
"idx",
"]",
"=",
"p",
".",
"Match",
"\n",
"idx",
"++",
"\n",
"}",
"\n",
"<mask>",
".",
"Sort",
"(",
"&",
"r",
".",
"matchBuf",
")",
"\n",
"mci",
":=",
"r",
".",
"matchBuf",
"[",
"len",
"(",
"r",
".",
"matchBuf",
")",
"-",
"r",
".",
"quorum",
"(",
")",
"]",
"\n",
"return",
"r",
".",
"raftLog",
".",
"maybeCommit",
"(",
"mci",
",",
"r",
".",
"Term",
")",
"\n",
"}"
]
|
17,495 | all-17496 | [
"String",
"allows",
"printing",
"span",
"for",
"debugging"
]
| [
"func",
"(",
"s",
"*",
"MockSpan",
")",
"<mask>",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"SpanContext",
".",
"TraceID",
",",
"s",
".",
"SpanContext",
".",
"SpanID",
",",
"s",
".",
"ParentID",
",",
"s",
".",
"SpanContext",
".",
"Sampled",
",",
"s",
".",
"OperationName",
")",
"\n",
"}"
]
|
17,496 | all-17497 | [
"GetCheckoutKey",
"fetches",
"the",
"checkout",
"key",
"for",
"the",
"given",
"project",
"by",
"fingerprint"
]
| [
"func",
"(",
"c",
"*",
"<mask>",
")",
"GetCheckoutKey",
"(",
"account",
",",
"repo",
",",
"fingerprint",
"string",
")",
"(",
"*",
"CheckoutKey",
",",
"error",
")",
"{",
"checkoutKey",
":=",
"&",
"CheckoutKey",
"{",
"}",
"\n\n",
"err",
":=",
"c",
".",
"request",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"account",
",",
"repo",
",",
"fingerprint",
")",
",",
"&",
"checkoutKey",
",",
"nil",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"checkoutKey",
",",
"nil",
"\n",
"}"
]
|
17,497 | all-17498 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"DatabaseWithObjectStores",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoIndexeddb17",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
]
|
17,498 | all-17499 | [
"isPtrPkgDot",
"returns",
"true",
"if",
"f",
"is",
"the",
"expression",
"*",
"pkg",
".",
"name",
"where",
"pkg",
"is",
"an",
"imported",
"identifier",
"."
]
| [
"func",
"isPtrPkgDot",
"(",
"t",
"ast",
".",
"Expr",
",",
"pkg",
",",
"name",
"string",
")",
"bool",
"{",
"ptr",
",",
"<mask>",
":=",
"t",
".",
"(",
"*",
"ast",
".",
"StarExpr",
")",
"\n",
"return",
"ok",
"&&",
"isPkgDot",
"(",
"ptr",
".",
"X",
",",
"pkg",
",",
"name",
")",
"\n",
"}"
]
|
17,499 | all-17500 | [
"FilterChanges",
"determines",
"which",
"of",
"the",
"changes",
"are",
"relevant",
"for",
"config",
"updating",
"returning",
"mapping",
"of",
"config",
"map",
"to",
"key",
"to",
"filename",
"to",
"update",
"that",
"key",
"from",
"."
]
| [
"func",
"FilterChanges",
"(",
"cfg",
"plugins",
".",
"ConfigUpdater",
",",
"changes",
"[",
"]",
"github",
".",
"PullRequestChange",
",",
"log",
"*",
"logrus",
".",
"Entry",
")",
"map",
"[",
"ConfigMapID",
"]",
"[",
"]",
"ConfigMapUpdate",
"{",
"toUpdate",
":=",
"map",
"[",
"ConfigMapID",
"]",
"[",
"]",
"ConfigMapUpdate",
"{",
"}",
"\n",
"for",
"_",
",",
"change",
":=",
"range",
"changes",
"{",
"var",
"cm",
"plugins",
".",
"ConfigMapSpec",
"\n",
"found",
":=",
"false",
"\n\n",
"for",
"key",
",",
"configMap",
":=",
"range",
"cfg",
".",
"Maps",
"{",
"var",
"matchErr",
"error",
"\n",
"found",
",",
"matchErr",
"=",
"zglob",
".",
"Match",
"(",
"key",
",",
"change",
".",
"Filename",
")",
"\n",
"if",
"matchErr",
"!=",
"nil",
"{",
"// Should not happen, log matchErr and continue",
"log",
".",
"WithError",
"(",
"matchErr",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"<mask>",
"\n",
"}",
"\n\n",
"if",
"found",
"{",
"cm",
"=",
"configMap",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"!",
"found",
"{",
"continue",
"// This file does not define a configmap",
"\n",
"}",
"\n\n",
"// Yes, update the configmap with the contents of this file",
"for",
"_",
",",
"ns",
":=",
"range",
"append",
"(",
"cm",
".",
"Namespaces",
")",
"{",
"id",
":=",
"ConfigMapID",
"{",
"Name",
":",
"cm",
".",
"Name",
",",
"Namespace",
":",
"ns",
"}",
"\n",
"key",
":=",
"cm",
".",
"Key",
"\n",
"if",
"key",
"==",
"\"",
"\"",
"{",
"key",
"=",
"path",
".",
"Base",
"(",
"change",
".",
"Filename",
")",
"\n",
"// if the key changed, we need to remove the old key",
"if",
"change",
".",
"Status",
"==",
"github",
".",
"PullRequestFileRenamed",
"{",
"oldKey",
":=",
"path",
".",
"Base",
"(",
"change",
".",
"PreviousFilename",
")",
"\n",
"// not setting the filename field will cause the key to be",
"// deleted",
"toUpdate",
"[",
"id",
"]",
"=",
"append",
"(",
"toUpdate",
"[",
"id",
"]",
",",
"ConfigMapUpdate",
"{",
"Key",
":",
"oldKey",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"change",
".",
"Status",
"==",
"github",
".",
"PullRequestFileRemoved",
"{",
"toUpdate",
"[",
"id",
"]",
"=",
"append",
"(",
"toUpdate",
"[",
"id",
"]",
",",
"ConfigMapUpdate",
"{",
"Key",
":",
"key",
"}",
")",
"\n",
"}",
"else",
"{",
"gzip",
":=",
"cfg",
".",
"GZIP",
"\n",
"if",
"cm",
".",
"GZIP",
"!=",
"nil",
"{",
"gzip",
"=",
"*",
"cm",
".",
"GZIP",
"\n",
"}",
"\n",
"toUpdate",
"[",
"id",
"]",
"=",
"append",
"(",
"toUpdate",
"[",
"id",
"]",
",",
"ConfigMapUpdate",
"{",
"Key",
":",
"key",
",",
"Filename",
":",
"change",
".",
"Filename",
",",
"GZIP",
":",
"gzip",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"toUpdate",
"\n",
"}"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.