id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
listlengths 1
418
| pl_tokens
listlengths 22
4.98k
|
---|---|---|---|
20,900 | all-20901 | [
"newWatcherBatch",
"maps",
"watchers",
"to",
"their",
"matched",
"events",
".",
"It",
"enables",
"quick",
"events",
"look",
"up",
"by",
"watcher",
"."
] | [
"func",
"newWatcherBatch",
"(",
"wg",
"*",
"watcherGroup",
",",
"evs",
"[",
"]",
"mvccpb",
".",
"<mask>",
")",
"watcherBatch",
"{",
"if",
"len",
"(",
"wg",
".",
"watchers",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"wb",
":=",
"make",
"(",
"watcherBatch",
")",
"\n",
"for",
"_",
",",
"ev",
":=",
"range",
"evs",
"{",
"for",
"w",
":=",
"range",
"wg",
".",
"watcherSetByKey",
"(",
"string",
"(",
"ev",
".",
"Kv",
".",
"Key",
")",
")",
"{",
"if",
"ev",
".",
"Kv",
".",
"ModRevision",
">=",
"w",
".",
"minRev",
"{",
"// don't double notify",
"wb",
".",
"add",
"(",
"w",
",",
"ev",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"wb",
"\n",
"}"
] |
20,901 | all-20902 | [
"VolumeSnapshotLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | [
"func",
"(",
"api",
"*",
"API",
")",
"VolumeSnapshotLocator",
"(",
"href",
"<mask>",
")",
"*",
"VolumeSnapshotLocator",
"{",
"return",
"&",
"VolumeSnapshotLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] |
20,902 | all-20903 | [
"ToOption",
"converts",
"this",
"Options",
"to",
"a",
"single",
"Option",
"."
] | [
"func",
"(",
"opts",
"*",
"Options",
")",
"ToOption",
"(",
")",
"Option",
"{",
"return",
"func",
"(",
"nopts",
"*",
"Options",
")",
"error",
"{",
"*",
"nopts",
"=",
"*",
"opts",
"\n",
"if",
"opts",
".",
"Other",
"!=",
"nil",
"{",
"nopts",
".",
"Other",
"=",
"make",
"(",
"map",
"[",
"<mask>",
"{",
"}",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"opts",
".",
"Other",
")",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"opts",
".",
"Other",
"{",
"nopts",
".",
"Other",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] |
20,903 | all-20904 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"AddInspectedHeapObjectParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoHeapprofiler23",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
20,904 | all-20905 | [
"KebabUpper",
"returns",
"a",
"KEBAB",
"-",
"CASED",
"string",
"with",
"all",
"upper",
"case",
"letters",
"."
] | [
"func",
"(",
"k",
"*",
"Kace",
")",
"KebabUpper",
"(",
"s",
"string",
")",
"string",
"{",
"return",
"delimitedCase",
"(",
"s",
",",
"kebabDelim",
",",
"<mask>",
")",
"\n",
"}"
] |
20,905 | all-20906 | [
"Routes",
"creates",
"a",
"REST",
"router",
"for",
"the",
"todos",
"resource"
] | [
"func",
"(",
"rs",
"todosResource",
")",
"Routes",
"(",
")",
"chi",
".",
"Router",
"{",
"r",
":=",
"chi",
".",
"NewRouter",
"(",
")",
"\n",
"// r.Use() // some middleware..",
"r",
".",
"Get",
"(",
"\"",
"\"",
",",
"rs",
".",
"List",
")",
"// GET /todos - read a list of todos",
"\n",
"r",
".",
"Post",
"(",
"\"",
"\"",
",",
"rs",
".",
"Create",
")",
"// POST /todos - create a new todo and persist it",
"\n",
"r",
".",
"Put",
"(",
"\"",
"\"",
",",
"rs",
".",
"Delete",
")",
"\n\n",
"r",
".",
"Route",
"(",
"\"",
"\"",
",",
"func",
"(",
"r",
"chi",
".",
"Router",
")",
"{",
"// r.Use(rs.TodoCtx) // lets have a todos map, and lets actually load/manipulate",
"r",
".",
"Get",
"(",
"\"",
"\"",
",",
"rs",
".",
"Get",
")",
"// GET /todos/{id} - read a single todo by :id",
"\n",
"r",
".",
"Put",
"(",
"\"",
"\"",
",",
"<mask>",
".",
"Update",
")",
"// PUT /todos/{id} - update a single todo by :id",
"\n",
"r",
".",
"Delete",
"(",
"\"",
"\"",
",",
"rs",
".",
"Delete",
")",
"// DELETE /todos/{id} - delete a single todo by :id",
"\n",
"r",
".",
"Get",
"(",
"\"",
"\"",
",",
"rs",
".",
"Sync",
")",
"\n",
"}",
")",
"\n\n",
"return",
"r",
"\n",
"}"
] |
20,906 | all-20907 | [
"GetVizOk",
"returns",
"a",
"tuple",
"with",
"the",
"Viz",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"g",
"*",
"GraphDefinition",
")",
"GetVizOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"g",
"==",
"nil",
"||",
"g",
".",
"Viz",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"g",
".",
"Viz",
",",
"<mask>",
"\n",
"}"
] |
20,907 | all-20908 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"EventReportHeapSnapshotProgress",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoHeapprofiler16",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
20,908 | all-20909 | [
"NextElement",
"parses",
"and",
"returns",
"the",
"next",
"string",
"element"
] | [
"func",
"(",
"p",
"*",
"ColorParser",
")",
"NextElement",
"(",
")",
"TextElement",
"{",
"if",
"p",
".",
"index",
">=",
"len",
"(",
"p",
".",
"text",
")",
"{",
"return",
"TextElement",
"{",
"Type",
":",
"ElemEndOfText",
"}",
"\n",
"}",
"\n\n",
"if",
"p",
".",
"text",
"[",
"p",
".",
"index",
"]",
"==",
"'\\n'",
"{",
"p",
".",
"index",
"++",
"\n",
"return",
"TextElement",
"{",
"Type",
":",
"ElemLineBreak",
"}",
"\n",
"}",
"\n\n",
"if",
"p",
".",
"text",
"[",
"p",
".",
"index",
"]",
"!=",
"'<'",
"{",
"p",
".",
"index",
"++",
"\n",
"return",
"TextElement",
"{",
"Type",
":",
"ElemPrintable",
",",
"Ch",
":",
"p",
".",
"text",
"[",
"p",
".",
"index",
"-",
"1",
"]",
",",
"Fg",
":",
"p",
".",
"currText",
",",
"Bg",
":",
"p",
".",
"currBack",
"}",
"\n",
"}",
"\n\n",
"attr",
",",
"atype",
",",
"ok",
":=",
"p",
".",
"parseColor",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"p",
".",
"index",
"++",
"\n",
"return",
"TextElement",
"{",
"<mask>",
":",
"ElemPrintable",
",",
"Ch",
":",
"p",
".",
"text",
"[",
"p",
".",
"index",
"-",
"1",
"]",
",",
"Fg",
":",
"p",
".",
"currText",
",",
"Bg",
":",
"p",
".",
"currBack",
"}",
"\n",
"}",
"\n\n",
"if",
"atype",
"==",
"ElemBackColor",
"{",
"if",
"attr",
"==",
"ColorDefault",
"{",
"p",
".",
"currBack",
"=",
"p",
".",
"defBack",
"\n",
"}",
"else",
"{",
"p",
".",
"currBack",
"=",
"attr",
"\n",
"}",
"\n",
"}",
"else",
"if",
"atype",
"==",
"ElemTextColor",
"{",
"if",
"attr",
"==",
"ColorDefault",
"{",
"p",
".",
"currText",
"=",
"p",
".",
"defText",
"\n",
"}",
"else",
"{",
"p",
".",
"currText",
"=",
"attr",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"TextElement",
"{",
"Type",
":",
"atype",
",",
"Fg",
":",
"p",
".",
"currText",
",",
"Bg",
":",
"p",
".",
"currBack",
"}",
"\n",
"}"
] |
20,909 | all-20910 | [
"ListZone",
":",
"Method",
"returns",
"the",
"details",
"of",
"a",
"specific",
"zone",
"from",
"PowerDNS",
"ref",
":",
"https",
":",
"//",
"doc",
".",
"powerdns",
".",
"com",
"/",
"authoritative",
"/",
"http",
"-",
"api",
"/",
"zone",
".",
"html#get",
"--",
"servers",
"-",
"server_id",
"-",
"zones",
"-",
"zone_id"
] | [
"func",
"(",
"c",
"*",
"PDNSAPIClient",
")",
"ListZone",
"(",
"zoneID",
"string",
")",
"(",
"zone",
"pgo",
".",
"Zone",
",",
"resp",
"*",
"http",
".",
"Response",
",",
"err",
"error",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"retryLimit",
";",
"i",
"++",
"{",
"zone",
",",
"resp",
",",
"err",
"=",
"c",
".",
"client",
".",
"ZonesApi",
".",
"ListZone",
"(",
"c",
".",
"authCtx",
",",
"defaultServerID",
",",
"zoneID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"i",
")",
"\n",
"time",
".",
"Sleep",
"(",
"retryAfterTime",
"*",
"(",
"1",
"<<",
"uint",
"(",
"i",
")",
")",
")",
"\n",
"continue",
"\n\n",
"}",
"\n",
"return",
"<mask>",
",",
"resp",
",",
"err",
"\n",
"}",
"\n\n",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"zone",
",",
"resp",
",",
"err",
"\n\n",
"}"
] |
20,910 | all-20911 | [
"Validate",
"ensures",
"that",
"the",
"configuration",
"options",
"are",
"valid"
] | [
"func",
"(",
"o",
"*",
"Options",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"o",
".",
"SrcRoot",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"o",
".",
"Log",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"o",
".",
"GitRefs",
")",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"seen",
":=",
"map",
"[",
"string",
"]",
"sets",
".",
"String",
"{",
"}",
"\n",
"for",
"_",
",",
"ref",
":=",
"range",
"o",
".",
"GitRefs",
"{",
"if",
"_",
",",
"seenOrg",
":=",
"seen",
"[",
"ref",
".",
"Org",
"]",
";",
"seenOrg",
"{",
"if",
"seen",
"[",
"<mask>",
".",
"Org",
"]",
".",
"Has",
"(",
"ref",
".",
"Repo",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"seen",
"[",
"ref",
".",
"Org",
"]",
".",
"Insert",
"(",
"ref",
".",
"Repo",
")",
"\n",
"}",
"else",
"{",
"seen",
"[",
"ref",
".",
"Org",
"]",
"=",
"sets",
".",
"NewString",
"(",
"ref",
".",
"Repo",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
20,911 | all-20912 | [
"ListContainers",
"returns",
"a",
"slice",
"of",
"container",
"IDs",
"."
] | [
"func",
"(",
"dg",
"*",
"dockerGoClient",
")",
"ListContainers",
"(",
"ctx",
"context",
".",
"Context",
",",
"all",
"bool",
",",
"timeout",
"time",
".",
"Duration",
")",
"ListContainersResponse",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"ctx",
",",
"timeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n\n",
"// Buffered channel so in the case of timeout it takes one write, never gets",
"// read, and can still be GC'd",
"response",
":=",
"make",
"(",
"chan",
"ListContainersResponse",
",",
"1",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"response",
"<-",
"dg",
".",
"listContainers",
"(",
"ctx",
",",
"all",
")",
"}",
"(",
")",
"\n",
"<mask>",
"{",
"case",
"resp",
":=",
"<-",
"response",
":",
"return",
"resp",
"\n",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"// Context has either expired or canceled. If it has timed out,",
"// send back the DockerTimeoutError",
"err",
":=",
"ctx",
".",
"Err",
"(",
")",
"\n",
"if",
"err",
"==",
"context",
".",
"DeadlineExceeded",
"{",
"return",
"ListContainersResponse",
"{",
"Error",
":",
"&",
"DockerTimeoutError",
"{",
"timeout",
",",
"\"",
"\"",
"}",
"}",
"\n",
"}",
"\n",
"return",
"ListContainersResponse",
"{",
"Error",
":",
"&",
"CannotListContainersError",
"{",
"err",
"}",
"}",
"\n",
"}",
"\n",
"}"
] |
20,912 | all-20913 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"SamplingHeapProfileNode",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoHeapprofiler7",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
20,913 | all-20914 | [
"ResetPasswordForDatabaseServer",
"requests",
"a",
"snapshot",
"of",
"an",
"existing",
"database",
"server",
"."
] | [
"func",
"(",
"c",
"*",
"<mask>",
")",
"ResetPasswordForDatabaseServer",
"(",
"identifier",
"string",
")",
"(",
"*",
"DatabaseServer",
",",
"error",
")",
"{",
"dbs",
":=",
"new",
"(",
"DatabaseServer",
")",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"MakeApiRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"identifier",
"+",
"\"",
"\"",
",",
"nil",
",",
"&",
"dbs",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"dbs",
",",
"nil",
"\n",
"}"
] |
20,914 | all-20915 | [
"generate",
"a",
"contiguous",
"set",
"of",
"empty",
"display",
"lists"
] | [
"func",
"GenLists",
"(",
"xrange",
"int32",
")",
"uint32",
"{",
"<mask>",
":=",
"C",
".",
"glowGenLists",
"(",
"gpGenLists",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"xrange",
")",
")",
"\n",
"return",
"(",
"uint32",
")",
"(",
"ret",
")",
"\n",
"}"
] |
20,915 | all-20916 | [
"Bytes",
"encodes",
"the",
"builder",
"s",
"underlying",
"envelope",
"to",
"XDR"
] | [
"func",
"(",
"b",
"*",
"TransactionEnvelopeBuilder",
")",
"Bytes",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"b",
".",
"Err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"b",
".",
"Err",
"\n",
"}",
"\n\n",
"var",
"txBytes",
"bytes",
".",
"<mask>",
"\n",
"_",
",",
"err",
":=",
"xdr",
".",
"Marshal",
"(",
"&",
"txBytes",
",",
"b",
".",
"E",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"txBytes",
".",
"Bytes",
"(",
")",
",",
"nil",
"\n",
"}"
] |
20,916 | all-20917 | [
"Manifest",
"is",
"like",
"ImageSource",
".",
"GetManifest",
"but",
"the",
"result",
"is",
"cached",
";",
"it",
"is",
"OK",
"to",
"call",
"this",
"however",
"often",
"you",
"need",
"."
] | [
"func",
"(",
"i",
"*",
"memoryImage",
")",
"Manifest",
"(",
"ctx",
"context",
".",
"<mask>",
")",
"(",
"[",
"]",
"byte",
",",
"string",
",",
"error",
")",
"{",
"if",
"i",
".",
"serializedManifest",
"==",
"nil",
"{",
"m",
",",
"err",
":=",
"i",
".",
"genericManifest",
".",
"serialize",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"i",
".",
"serializedManifest",
"=",
"m",
"\n",
"}",
"\n",
"return",
"i",
".",
"serializedManifest",
",",
"i",
".",
"genericManifest",
".",
"manifestMIMEType",
"(",
")",
",",
"nil",
"\n",
"}"
] |
20,917 | all-20918 | [
"Helper",
"function",
"to",
"submit",
"changes",
".",
"Changes",
"are",
"submitted",
"by",
"change",
"type",
"."
] | [
"func",
"(",
"p",
"*",
"RcodeZeroProvider",
")",
"submitChanges",
"(",
"changes",
"[",
"]",
"*",
"rc0",
".",
"RRSetChange",
")",
"error",
"{",
"if",
"len",
"(",
"changes",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"zones",
",",
"err",
":=",
"p",
".",
"Zones",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// separate into per-zone change sets to be passed to the API.",
"changesByZone",
":=",
"rcodezeroChangesByZone",
"(",
"zones",
",",
"changes",
")",
"\n\n",
"for",
"zoneName",
",",
"changes",
":=",
"<mask>",
"changesByZone",
"{",
"for",
"_",
",",
"change",
":=",
"range",
"changes",
"{",
"logFields",
":=",
"log",
".",
"Fields",
"{",
"\"",
"\"",
":",
"change",
".",
"Name",
",",
"\"",
"\"",
":",
"change",
".",
"Records",
"[",
"0",
"]",
".",
"Content",
",",
"\"",
"\"",
":",
"change",
".",
"Type",
",",
"\"",
"\"",
":",
"change",
".",
"ChangeType",
",",
"\"",
"\"",
":",
"zoneName",
",",
"}",
"\n\n",
"log",
".",
"WithFields",
"(",
"logFields",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"p",
".",
"DryRun",
"{",
"continue",
"\n",
"}",
"\n\n",
"// to avoid accidentally adding extra dot if already present",
"change",
".",
"Name",
"=",
"strings",
".",
"TrimSuffix",
"(",
"change",
".",
"Name",
",",
"\"",
"\"",
")",
"+",
"\"",
"\"",
"\n\n",
"switch",
"change",
".",
"ChangeType",
"{",
"case",
"rc0",
".",
"ChangeTypeADD",
":",
"sr",
",",
"err",
":=",
"p",
".",
"Client",
".",
"RRSet",
".",
"Create",
"(",
"zoneName",
",",
"[",
"]",
"*",
"rc0",
".",
"RRSetChange",
"{",
"change",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"sr",
".",
"HasError",
"(",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"sr",
".",
"Message",
")",
"\n",
"}",
"\n\n",
"case",
"rc0",
".",
"ChangeTypeUPDATE",
":",
"sr",
",",
"err",
":=",
"p",
".",
"Client",
".",
"RRSet",
".",
"Edit",
"(",
"zoneName",
",",
"[",
"]",
"*",
"rc0",
".",
"RRSetChange",
"{",
"change",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"sr",
".",
"HasError",
"(",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"sr",
".",
"Message",
")",
"\n",
"}",
"\n\n",
"case",
"rc0",
".",
"ChangeTypeDELETE",
":",
"sr",
",",
"err",
":=",
"p",
".",
"Client",
".",
"RRSet",
".",
"Delete",
"(",
"zoneName",
",",
"[",
"]",
"*",
"rc0",
".",
"RRSetChange",
"{",
"change",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"sr",
".",
"HasError",
"(",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"sr",
".",
"Message",
")",
"\n",
"}",
"\n\n",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"change",
".",
"ChangeType",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
20,918 | all-20919 | [
"GetChange",
"gets",
"the",
"old",
"and",
"new",
"values",
"for",
"the",
"value",
"specified",
"by",
"key",
"."
] | [
"func",
"(",
"r",
"*",
"Subresource",
")",
"GetChange",
"(",
"key",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"<mask>",
"{",
"}",
")",
"{",
"new",
":=",
"r",
".",
"data",
"[",
"key",
"]",
"\n",
"// No old data means no change, so we use the new value as a placeholder.",
"old",
":=",
"r",
".",
"data",
"[",
"key",
"]",
"\n",
"if",
"r",
".",
"olddata",
"!=",
"nil",
"{",
"old",
"=",
"r",
".",
"olddata",
"[",
"key",
"]",
"\n",
"}",
"\n",
"return",
"old",
",",
"new",
"\n",
"}"
] |
20,919 | all-20920 | [
"/",
"*",
"Application",
"security",
"is",
"very",
"important",
"so",
"Pusher",
"provides",
"a",
"mechanism",
"for",
"authenticating",
"a",
"user’s",
"access",
"to",
"a",
"channel",
"at",
"the",
"point",
"of",
"subscription",
"."
] | [
"func",
"(",
"c",
"*",
"<mask>",
")",
"AuthenticatePrivateChannel",
"(",
"params",
"[",
"]",
"byte",
")",
"(",
"response",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"return",
"c",
".",
"authenticateChannel",
"(",
"params",
",",
"nil",
")",
"\n",
"}"
] |
20,920 | all-20921 | [
"orgsInConfig",
"gets",
"all",
"the",
"org",
"strings",
"(",
"not",
"org",
"/",
"repo",
")",
"in",
"config",
".",
"Plugins",
"and",
"config",
".",
"ExternalPlugins",
"."
] | [
"func",
"orgsInConfig",
"(",
"config",
"*",
"plugins",
".",
"<mask>",
")",
"sets",
".",
"String",
"{",
"orgs",
":=",
"sets",
".",
"NewString",
"(",
")",
"\n",
"for",
"repo",
":=",
"range",
"config",
".",
"Plugins",
"{",
"if",
"!",
"strings",
".",
"Contains",
"(",
"repo",
",",
"\"",
"\"",
")",
"{",
"orgs",
".",
"Insert",
"(",
"repo",
")",
"\n",
"}",
"\n",
"}",
"\n",
"for",
"repo",
":=",
"range",
"config",
".",
"ExternalPlugins",
"{",
"if",
"!",
"strings",
".",
"Contains",
"(",
"repo",
",",
"\"",
"\"",
")",
"{",
"orgs",
".",
"Insert",
"(",
"repo",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"orgs",
"\n",
"}"
] |
20,921 | all-20922 | [
"CreateCloudIP",
"creates",
"a",
"new",
"Cloud",
"IP",
".",
"It",
"takes",
"a",
"CloudIPOptions",
"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",
"*",
"<mask>",
")",
"CreateCloudIP",
"(",
"newCloudIP",
"*",
"CloudIPOptions",
")",
"(",
"*",
"CloudIP",
",",
"error",
")",
"{",
"cloudip",
":=",
"new",
"(",
"CloudIP",
")",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"MakeApiRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"newCloudIP",
",",
"&",
"cloudip",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"cloudip",
",",
"nil",
"\n",
"}"
] |
20,922 | all-20923 | [
"Locator",
"returns",
"a",
"locator",
"for",
"the",
"given",
"resource"
] | [
"func",
"(",
"r",
"*",
"<mask>",
")",
"Locator",
"(",
"api",
"*",
"API",
")",
"*",
"TemplateLocator",
"{",
"return",
"api",
".",
"TemplateLocator",
"(",
"r",
".",
"Href",
")",
"\n",
"}"
] |
20,923 | all-20924 | [
"Print",
"prints",
"version",
"and",
"completes",
"the",
"program",
"."
] | [
"func",
"Print",
"(",
"run",
"bool",
",",
"commit",
",",
"version",
"string",
")",
"{",
"if",
"run",
"{",
"fmt",
".",
"Println",
"(",
"Message",
"(",
"commit",
",",
"<mask>",
")",
")",
"\n",
"os",
".",
"Exit",
"(",
"0",
")",
"\n",
"}",
"\n",
"}"
] |
20,924 | all-20925 | [
"Specify",
"the",
"value",
"of",
"a",
"uniform",
"variable",
"for",
"a",
"specified",
"program",
"object"
] | [
"func",
"ProgramUniformMatrix2x3fv",
"(",
"program",
"uint32",
",",
"<mask>",
"int32",
",",
"count",
"int32",
",",
"transpose",
"bool",
",",
"value",
"*",
"float32",
")",
"{",
"syscall",
".",
"Syscall6",
"(",
"gpProgramUniformMatrix2x3fv",
",",
"5",
",",
"uintptr",
"(",
"program",
")",
",",
"uintptr",
"(",
"location",
")",
",",
"uintptr",
"(",
"count",
")",
",",
"boolToUintptr",
"(",
"transpose",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"value",
")",
")",
",",
"0",
")",
"\n",
"}"
] |
20,925 | all-20926 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"RemoveDOMBreakpointParams",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoDomdebugger7",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
20,926 | all-20927 | [
"KeyWrap",
"encrypts",
"provided",
"key",
"(",
"CEK",
")",
"with",
"KEK",
"key",
"using",
"AES",
"Key",
"Wrap",
"(",
"rfc",
"3394",
")",
"algorithm"
] | [
"func",
"KeyWrap",
"(",
"cek",
",",
"kek",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"// 1) Initialize variables",
"a",
":=",
"defaultIV",
"// Set A = IV, an initial value",
"\n",
"r",
":=",
"arrays",
".",
"Slice",
"(",
"cek",
",",
"8",
")",
"// For i = 1 to n",
"\n",
"// R[0][i] = P[i]",
"n",
":=",
"uint64",
"(",
"len",
"(",
"r",
")",
")",
"\n",
"// 2) Calculate intermediate values.",
"var",
"j",
",",
"i",
",",
"t",
"uint64",
"\n",
"for",
"j",
"=",
"0",
";",
"j",
"<",
"6",
";",
"j",
"++",
"{",
"// For j = 0 to 5",
"for",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"// For i=1 to n",
"t",
"=",
"n",
"*",
"j",
"+",
"i",
"+",
"1",
";",
"b",
",",
"e",
":=",
"aesEnc",
"(",
"kek",
",",
"arrays",
".",
"Concat",
"(",
"a",
",",
"r",
"[",
"i",
"]",
")",
")",
"// B=AES(K, A | R[i])",
"\n",
"if",
"e",
"!=",
"nil",
"{",
"return",
"nil",
",",
"e",
"}",
"\n",
"a",
"=",
"b",
"[",
":",
"len",
"(",
"b",
")",
"/",
"2",
"]",
"// A=MSB(64,B) ^ t where t = (n*j)+i",
"\n",
"r",
"[",
"i",
"]",
"=",
"b",
"[",
"len",
"(",
"b",
")",
"/",
"2",
":",
"]",
"// R[i] = LSB(64, B)",
"\n",
"a",
"=",
"arrays",
".",
"Xor",
"(",
"a",
",",
"arrays",
".",
"UInt64ToBytes",
"(",
"t",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// 3) Output the results",
"c",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"n",
"+",
"1",
",",
"n",
"+",
"1",
")",
"\n",
"c",
"[",
"0",
"]",
"=",
"a",
";",
"// Set C[0] = A",
"for",
"i",
"=",
"1",
";",
"i",
"<=",
"n",
";",
"i",
"++",
"{",
"// For i = 1 to n",
"c",
"[",
"i",
"]",
"=",
"r",
"[",
"i",
"-",
"1",
"]",
"// C[i] = R[i]",
"\n",
"}",
"\n\n",
"return",
"arrays",
".",
"Unwrap",
"(",
"c",
")",
",",
"nil",
"\n",
"}"
] |
20,927 | all-20928 | [
"initialize",
"initializes",
"ExtractedV1Compatibility",
"and",
"verifies",
"invariants",
"so",
"that",
"the",
"rest",
"of",
"this",
"code",
"can",
"assume",
"a",
"minimally",
"healthy",
"manifest",
"."
] | [
"func",
"(",
"m",
"*",
"Schema1",
")",
"initialize",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"m",
".",
"FSLayers",
")",
"!=",
"len",
"(",
"m",
".",
"History",
")",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"m",
".",
"FSLayers",
")",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"m",
".",
"ExtractedV1Compatibility",
"=",
"make",
"(",
"[",
"]",
"Schema1V1Compatibility",
",",
"len",
"(",
"m",
".",
"History",
")",
")",
"\n",
"for",
"i",
",",
"h",
":=",
"<mask>",
"m",
".",
"History",
"{",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"h",
".",
"V1Compatibility",
")",
",",
"&",
"m",
".",
"ExtractedV1Compatibility",
"[",
"i",
"]",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"i",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
20,928 | all-20929 | [
"Kill",
"terminates",
"a",
"process",
"in",
"the",
"guest",
"operating",
"system",
".",
"Parameters",
":",
"pid",
":",
"The",
"ID",
"of",
"the",
"process",
"to",
"be",
"killed",
".",
"Remarks",
":",
"*",
"Depending",
"on",
"the",
"behavior",
"of",
"the",
"guest",
"operating",
"system",
"there",
"may",
"be",
"a",
"short",
"delay",
"after",
"the",
"job",
"completes",
"before",
"the",
"process",
"truly",
"disappears",
".",
"*",
"Because",
"of",
"differences",
"in",
"how",
"various",
"Operating",
"Systems",
"handle",
"process",
"IDs",
"Vix",
"may",
"return",
"either",
"VIX_E_INVALID_ARG",
"or",
"VIX_E_NO_SUCH_PROCESS",
"for",
"invalid",
"process",
"IDs",
".",
"Since",
"VMware",
"Workstation",
"6",
".",
"0",
"Minimum",
"Supported",
"Guest",
"OS",
":",
"Microsoft",
"Windows",
"NT",
"Series",
"Linux"
] | [
"func",
"(",
"g",
"*",
"Guest",
")",
"Kill",
"(",
"pid",
"uint64",
")",
"error",
"{",
"var",
"jobHandle",
"C",
".",
"VixHandle",
"=",
"C",
".",
"VIX_INVALID_HANDLE",
"\n",
"<mask>",
"err",
"C",
".",
"VixError",
"=",
"C",
".",
"VIX_OK",
"\n\n",
"jobHandle",
"=",
"C",
".",
"VixVM_KillProcessInGuest",
"(",
"g",
".",
"handle",
",",
"C",
".",
"uint64",
"(",
"pid",
")",
",",
"// file path name",
"0",
",",
"// options",
"nil",
",",
"// callbackProc",
"nil",
")",
"// clientData",
"\n\n",
"defer",
"C",
".",
"Vix_ReleaseHandle",
"(",
"jobHandle",
")",
"\n\n",
"err",
"=",
"C",
".",
"vix_job_wait",
"(",
"jobHandle",
")",
"\n",
"if",
"C",
".",
"VIX_OK",
"!=",
"err",
"{",
"return",
"&",
"Error",
"{",
"Operation",
":",
"\"",
"\"",
",",
"Code",
":",
"int",
"(",
"err",
"&",
"0xFFFF",
")",
",",
"Text",
":",
"C",
".",
"GoString",
"(",
"C",
".",
"Vix_GetErrorText",
"(",
"err",
",",
"nil",
")",
")",
",",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
20,929 | all-20930 | [
"WatchOne",
"watches",
"a",
"given",
"item",
".",
"The",
"first",
"value",
"returned",
"from",
"the",
"watch",
"will",
"be",
"the",
"current",
"value",
"of",
"the",
"item",
"."
] | [
"func",
"(",
"c",
"*",
"readonlyCollection",
")",
"WatchOne",
"(",
"key",
"string",
")",
"(",
"watch",
".",
"Watcher",
",",
"error",
")",
"{",
"return",
"<mask>",
".",
"NewWatcher",
"(",
"c",
".",
"ctx",
",",
"c",
".",
"etcdClient",
",",
"c",
".",
"prefix",
",",
"c",
".",
"Path",
"(",
"key",
")",
",",
"c",
".",
"template",
")",
"\n",
"}"
] |
20,930 | all-20931 | [
"HasColor",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"f",
"*",
"FreeTextDefinition",
")",
"HasColor",
"(",
")",
"bool",
"{",
"if",
"f",
"!=",
"nil",
"&&",
"f",
".",
"<mask>",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
20,931 | all-20932 | [
"CheckButtonNewWithLabel",
"is",
"a",
"wrapper",
"around",
"gtk_check_button_new_with_label",
"()",
"."
] | [
"func",
"CheckButtonNewWithLabel",
"(",
"label",
"string",
")",
"(",
"*",
"CheckButton",
",",
"error",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"label",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"c",
":=",
"C",
".",
"gtk_check_button_new_with_label",
"(",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"return",
"wrapCheckButton",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
",",
"nil",
"\n",
"}"
] |
20,932 | all-20933 | [
"WaitForText",
"is",
"a",
"wrapper",
"around",
"gtk_clipboard_wait_for_text"
] | [
"func",
"(",
"v",
"*",
"Clipboard",
")",
"WaitForText",
"(",
")",
"(",
"string",
",",
"<mask>",
")",
"{",
"c",
":=",
"C",
".",
"gtk_clipboard_wait_for_text",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"defer",
"C",
".",
"g_free",
"(",
"C",
".",
"gpointer",
"(",
"c",
")",
")",
"\n",
"return",
"goString",
"(",
"c",
")",
",",
"nil",
"\n",
"}"
] |
20,933 | all-20934 | [
"UnmarshalJSON",
"implements",
"the",
"json",
".",
"Unmarshaler",
"interface",
"."
] | [
"func",
"(",
"p",
"*",
"Policy",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"*",
"p",
"=",
"Policy",
"{",
"}",
"\n",
"transports",
":=",
"policyTransportsMap",
"{",
"}",
"\n",
"if",
"err",
":=",
"paranoidUnmarshalJSONObject",
"(",
"data",
",",
"func",
"(",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"switch",
"key",
"{",
"<mask>",
"\"",
"\"",
":",
"return",
"&",
"p",
".",
"Default",
"\n",
"case",
"\"",
"\"",
":",
"return",
"&",
"transports",
"\n",
"default",
":",
"return",
"nil",
"\n",
"}",
"\n",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"p",
".",
"Default",
"==",
"nil",
"{",
"return",
"InvalidPolicyFormatError",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"p",
".",
"Transports",
"=",
"map",
"[",
"string",
"]",
"PolicyTransportScopes",
"(",
"transports",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
20,934 | all-20935 | [
"CloseWindow",
"closes",
"the",
"active",
"window",
"."
] | [
"func",
"(",
"p",
"*",
"Page",
")",
"CloseWindow",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"p",
".",
"<mask>",
".",
"DeleteWindow",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
20,935 | all-20936 | [
"ValueCopy",
"returns",
"a",
"copy",
"of",
"the",
"value",
"of",
"the",
"item",
"from",
"the",
"value",
"log",
"writing",
"it",
"to",
"dst",
"slice",
".",
"If",
"nil",
"is",
"passed",
"or",
"capacity",
"of",
"dst",
"isn",
"t",
"sufficient",
"a",
"new",
"slice",
"would",
"be",
"allocated",
"and",
"returned",
".",
"Tip",
":",
"It",
"might",
"make",
"sense",
"to",
"reuse",
"the",
"returned",
"slice",
"as",
"dst",
"argument",
"for",
"the",
"next",
"call",
".",
"This",
"function",
"is",
"useful",
"in",
"long",
"running",
"iterate",
"/",
"update",
"transactions",
"to",
"avoid",
"a",
"write",
"deadlock",
".",
"See",
"Github",
"issue",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"dgraph",
"-",
"io",
"/",
"badger",
"/",
"issues",
"/",
"315"
] | [
"func",
"(",
"item",
"*",
"Item",
")",
"ValueCopy",
"(",
"dst",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"item",
".",
"wg",
".",
"Wait",
"(",
")",
"\n",
"if",
"item",
".",
"status",
"==",
"prefetched",
"{",
"return",
"y",
".",
"SafeCopy",
"(",
"dst",
",",
"item",
".",
"val",
")",
",",
"<mask>",
".",
"err",
"\n",
"}",
"\n",
"buf",
",",
"cb",
",",
"err",
":=",
"item",
".",
"yieldItemValue",
"(",
")",
"\n",
"defer",
"runCallback",
"(",
"cb",
")",
"\n",
"return",
"y",
".",
"SafeCopy",
"(",
"dst",
",",
"buf",
")",
",",
"err",
"\n",
"}"
] |
20,936 | all-20937 | [
"compressBlock",
"compresses",
"a",
"block",
"."
] | [
"func",
"(",
"z",
"*",
"Writer",
")",
"compressBlock",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"!",
"z",
".",
"NoChecksum",
"{",
"z",
".",
"checksum",
".",
"Write",
"(",
"data",
")",
"\n",
"}",
"\n\n",
"// The compressed block size cannot exceed the input's.",
"var",
"zn",
"int",
"\n",
"var",
"err",
"error",
"\n\n",
"if",
"level",
":=",
"z",
".",
"Header",
".",
"CompressionLevel",
";",
"level",
"!=",
"0",
"{",
"zn",
",",
"err",
"=",
"CompressBlockHC",
"(",
"<mask>",
",",
"z",
".",
"zdata",
",",
"level",
")",
"\n",
"}",
"else",
"{",
"zn",
",",
"err",
"=",
"CompressBlock",
"(",
"data",
",",
"z",
".",
"zdata",
",",
"z",
".",
"hashtable",
"[",
":",
"]",
")",
"\n",
"}",
"\n\n",
"var",
"zdata",
"[",
"]",
"byte",
"\n",
"var",
"bLen",
"uint32",
"\n",
"if",
"debugFlag",
"{",
"debug",
"(",
"\"",
"\"",
",",
"len",
"(",
"data",
")",
",",
"zn",
")",
"\n",
"}",
"\n",
"if",
"err",
"==",
"nil",
"&&",
"zn",
">",
"0",
"&&",
"zn",
"<",
"len",
"(",
"data",
")",
"{",
"// Compressible and compressed size smaller than uncompressed: ok!",
"bLen",
"=",
"uint32",
"(",
"zn",
")",
"\n",
"zdata",
"=",
"z",
".",
"zdata",
"[",
":",
"zn",
"]",
"\n",
"}",
"else",
"{",
"// Uncompressed block.",
"bLen",
"=",
"uint32",
"(",
"len",
"(",
"data",
")",
")",
"|",
"compressedBlockFlag",
"\n",
"zdata",
"=",
"data",
"\n",
"}",
"\n",
"if",
"debugFlag",
"{",
"debug",
"(",
"\"",
"\"",
",",
"bLen",
",",
"len",
"(",
"zdata",
")",
")",
"\n",
"}",
"\n\n",
"// Write the block.",
"if",
"err",
":=",
"z",
".",
"writeUint32",
"(",
"bLen",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"written",
",",
"err",
":=",
"z",
".",
"dst",
".",
"Write",
"(",
"zdata",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"h",
":=",
"z",
".",
"OnBlockDone",
";",
"h",
"!=",
"nil",
"{",
"h",
"(",
"written",
")",
"\n",
"}",
"\n\n",
"if",
"z",
".",
"BlockChecksum",
"{",
"checksum",
":=",
"xxh32",
".",
"ChecksumZero",
"(",
"zdata",
")",
"\n",
"if",
"debugFlag",
"{",
"debug",
"(",
"\"",
"\"",
",",
"checksum",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"z",
".",
"writeUint32",
"(",
"checksum",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"debugFlag",
"{",
"debug",
"(",
"\"",
"\"",
",",
"z",
".",
"checksum",
".",
"Sum32",
"(",
")",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
20,937 | all-20938 | [
"GenerateSelfSignedCert",
"generates",
"a",
"self",
"-",
"signed",
"TLS",
"cert",
"for",
"the",
"domain",
"name",
"address",
"with",
"a",
"private",
"key",
".",
"Other",
"attributes",
"of",
"the",
"subject",
"can",
"be",
"set",
"in",
"name",
"and",
"ip",
"addresses",
"can",
"be",
"set",
"in",
"ipAddresses"
] | [
"func",
"GenerateSelfSignedCert",
"(",
"address",
"string",
",",
"<mask>",
"*",
"pkix",
".",
"Name",
",",
"ipAddresses",
"...",
"string",
")",
"(",
"*",
"tls",
".",
"Certificate",
",",
"error",
")",
"{",
"// Generate Subject Distinguished Name",
"if",
"name",
"==",
"nil",
"{",
"name",
"=",
"&",
"pkix",
".",
"Name",
"{",
"}",
"\n",
"}",
"\n",
"switch",
"{",
"case",
"address",
"==",
"\"",
"\"",
"&&",
"name",
".",
"CommonName",
"==",
"\"",
"\"",
":",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"case",
"address",
"!=",
"\"",
"\"",
"&&",
"name",
".",
"CommonName",
"==",
"\"",
"\"",
":",
"name",
".",
"CommonName",
"=",
"address",
"\n",
"case",
"address",
"!=",
"\"",
"\"",
"&&",
"name",
".",
"CommonName",
"!=",
"\"",
"\"",
"&&",
"name",
".",
"CommonName",
"!=",
"address",
":",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\"",
",",
"address",
",",
"name",
".",
"CommonName",
")",
"\n",
"default",
":",
"// name.CommonName is already valid--nothing to do",
"}",
"\n\n",
"// Parse IPs in ipAddresses",
"parsedIPs",
":=",
"[",
"]",
"net",
".",
"IP",
"{",
"}",
"\n",
"for",
"_",
",",
"strIP",
":=",
"range",
"ipAddresses",
"{",
"nextParsedIP",
":=",
"net",
".",
"ParseIP",
"(",
"strIP",
")",
"\n",
"if",
"nextParsedIP",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"strIP",
")",
"\n",
"}",
"\n",
"parsedIPs",
"=",
"append",
"(",
"parsedIPs",
",",
"nextParsedIP",
")",
"\n",
"}",
"\n",
"// Generate key pair. According to",
"// https://security.stackexchange.com/questions/5096/rsa-vs-dsa-for-ssh-authentication-keys",
"// RSA is likely to be faster and more secure in practice than DSA/ECDSA, so",
"// this only generates RSA keys",
"key",
",",
"err",
":=",
"rsa",
".",
"GenerateKey",
"(",
"rand",
".",
"Reader",
",",
"rsaKeySize",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"// Generate unsigned cert",
"cert",
":=",
"x509",
".",
"Certificate",
"{",
"// the x509 spec requires every x509 cert must have a serial number that is",
"// unique for the signing CA. All of the certs generated by this package",
"// are self-signed, so this just starts at 1 and counts up",
"SerialNumber",
":",
"big",
".",
"NewInt",
"(",
"atomic",
".",
"AddInt64",
"(",
"&",
"serialNumber",
",",
"1",
")",
")",
",",
"Subject",
":",
"*",
"name",
",",
"NotBefore",
":",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"-",
"1",
"*",
"time",
".",
"Second",
")",
",",
"NotAfter",
":",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"validDur",
")",
",",
"KeyUsage",
":",
"x509",
".",
"KeyUsageCertSign",
"|",
"// can sign certs (need for self-signing)",
"x509",
".",
"KeyUsageKeyEncipherment",
"|",
"// can encrypt other keys (need for TLS in symmetric mode)",
"x509",
".",
"KeyUsageKeyAgreement",
",",
"// can establish keys (need for TLS in Diffie-Hellman mode)",
"ExtKeyUsage",
":",
"[",
"]",
"x509",
".",
"ExtKeyUsage",
"{",
"x509",
".",
"ExtKeyUsageServerAuth",
"}",
",",
"// can authenticate server (for TLS)",
"IsCA",
":",
"true",
",",
"// must be set b/c KeyUsageCertSign is set",
"BasicConstraintsValid",
":",
"true",
",",
"// mark \"Basic Constraints\" extn critical(?)",
"MaxPathLenZero",
":",
"true",
",",
"// must directly sign all end entity certs",
"IPAddresses",
":",
"parsedIPs",
",",
"DNSNames",
":",
"[",
"]",
"string",
"{",
"address",
"}",
",",
"}",
"\n\n",
"// Sign 'cert' (cert is both 'template' and 'parent' b/c it's self-signed)",
"signedCertDER",
",",
"err",
":=",
"x509",
".",
"CreateCertificate",
"(",
"rand",
".",
"Reader",
",",
"&",
"cert",
",",
"&",
"cert",
",",
"&",
"key",
".",
"PublicKey",
",",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"signedCert",
",",
"err",
":=",
"x509",
".",
"ParseCertificate",
"(",
"signedCertDER",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"&",
"tls",
".",
"Certificate",
"{",
"Certificate",
":",
"[",
"]",
"[",
"]",
"byte",
"{",
"signedCertDER",
"}",
",",
"Leaf",
":",
"signedCert",
",",
"PrivateKey",
":",
"key",
",",
"}",
",",
"nil",
"\n",
"}"
] |
20,938 | all-20939 | [
"GetRenotifyInterval",
"returns",
"the",
"RenotifyInterval",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"o",
"*",
"<mask>",
")",
"GetRenotifyInterval",
"(",
")",
"int",
"{",
"if",
"o",
"==",
"nil",
"||",
"o",
".",
"RenotifyInterval",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"*",
"o",
".",
"RenotifyInterval",
"\n",
"}"
] |
20,939 | all-20940 | [
"ReplaceN",
"replaces",
"a",
"number",
"of",
"regular",
"expressions",
"mathed",
"in",
"r",
"for",
"the",
"named",
"file",
"."
] | [
"func",
"ReplaceN",
"(",
"<mask>",
"string",
",",
"r",
"[",
"]",
"Replacer",
",",
"n",
"int",
")",
"error",
"{",
"e",
",",
"err",
":=",
"NewEdit",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"e",
".",
"genReplace",
"(",
"r",
",",
"n",
")",
"\n",
"err2",
":=",
"e",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"err2",
"\n",
"}"
] |
20,940 | all-20941 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"VisualViewport",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage1",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
20,941 | all-20942 | [
"ExoscaleWithLogging",
"injects",
"logging",
"when",
"ApplyChanges",
"is",
"called"
] | [
"func",
"ExoscaleWithLogging",
"(",
")",
"ExoscaleOption",
"{",
"return",
"func",
"(",
"p",
"*",
"ExoscaleProvider",
")",
"{",
"p",
".",
"OnApplyChanges",
"=",
"func",
"(",
"changes",
"*",
"<mask>",
".",
"Changes",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"changes",
".",
"Create",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"changes",
".",
"UpdateOld",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"changes",
".",
"UpdateNew",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"changes",
".",
"Delete",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
20,942 | all-20943 | [
"FindFiles",
"-"
] | [
"func",
"FindFiles",
"(",
"configDir",
",",
"pattern",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"foundFiles",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"err",
":=",
"filepath",
".",
"Walk",
"(",
"configDir",
",",
"func",
"(",
"path",
"string",
",",
"info",
"os",
".",
"FileInfo",
",",
"e",
"error",
")",
"error",
"{",
"if",
"strings",
".",
"Contains",
"(",
"path",
",",
"pattern",
")",
"{",
"foundFiles",
"=",
"<mask>",
"(",
"foundFiles",
",",
"path",
")",
"\n",
"}",
"\n",
"return",
"e",
"\n",
"}",
")",
"\n",
"return",
"foundFiles",
",",
"err",
"\n",
"}"
] |
20,943 | all-20944 | [
"UseProject",
"returns",
"a",
"client",
"that",
"will",
"use",
"a",
"specific",
"project",
"."
] | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"UseProject",
"(",
"name",
"string",
")",
"ContainerServer",
"{",
"return",
"&",
"ProtocolLXD",
"{",
"server",
":",
"r",
".",
"server",
",",
"http",
":",
"r",
".",
"http",
",",
"httpCertificate",
":",
"r",
".",
"httpCertificate",
",",
"httpHost",
":",
"r",
".",
"httpHost",
",",
"httpProtocol",
":",
"r",
".",
"httpProtocol",
",",
"httpUserAgent",
":",
"r",
".",
"httpUserAgent",
",",
"bakeryClient",
":",
"r",
".",
"bakeryClient",
",",
"bakeryInteractor",
":",
"r",
".",
"bakeryInteractor",
",",
"requireAuthenticated",
":",
"r",
".",
"requireAuthenticated",
",",
"clusterTarget",
":",
"r",
".",
"clusterTarget",
",",
"project",
":",
"<mask>",
",",
"}",
"\n",
"}"
] |
20,944 | all-20945 | [
"Set",
"a",
"counter",
"to",
"specific",
"value"
] | [
"func",
"(",
"m",
"*",
"CirconusMetrics",
")",
"<mask>",
"(",
"metric",
"string",
",",
"val",
"uint64",
")",
"{",
"m",
".",
"cm",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"cm",
".",
"Unlock",
"(",
")",
"\n",
"m",
".",
"counters",
"[",
"metric",
"]",
"=",
"val",
"\n",
"}"
] |
20,945 | all-20946 | [
"GenScheme",
"returns",
"a",
"func",
"that",
"generates",
"a",
"scheme",
":",
"//",
"style",
"DSN",
"from",
"the",
"passed",
"URL",
"."
] | [
"func",
"GenScheme",
"(",
"scheme",
"string",
")",
"func",
"(",
"*",
"URL",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"func",
"(",
"u",
"*",
"URL",
")",
"(",
"string",
",",
"error",
")",
"{",
"z",
":=",
"&",
"url",
".",
"URL",
"{",
"Scheme",
":",
"scheme",
",",
"Opaque",
":",
"u",
".",
"Opaque",
",",
"<mask>",
":",
"u",
".",
"User",
",",
"Host",
":",
"u",
".",
"Host",
",",
"Path",
":",
"u",
".",
"Path",
",",
"RawPath",
":",
"u",
".",
"RawPath",
",",
"RawQuery",
":",
"u",
".",
"RawQuery",
",",
"Fragment",
":",
"u",
".",
"Fragment",
",",
"}",
"\n\n",
"return",
"z",
".",
"String",
"(",
")",
",",
"nil",
"\n",
"}",
"\n",
"}"
] |
20,946 | all-20947 | [
"Value",
"returns",
"the",
"value",
"of",
"the",
"node",
"with",
"the",
"given",
"id",
".",
"It",
"will",
"return",
"ErrNoValue",
"if",
"the",
"node",
"does",
"not",
"have",
"a",
"value",
"."
] | [
"func",
"(",
"da",
"*",
"Cedar",
")",
"Value",
"(",
"id",
"int",
")",
"(",
"value",
"int",
",",
"err",
"error",
")",
"{",
"value",
"=",
"da",
".",
"<mask>",
"[",
"id",
"]",
".",
"Value",
"\n",
"if",
"value",
">=",
"0",
"{",
"return",
"value",
",",
"nil",
"\n",
"}",
"\n",
"to",
":=",
"da",
".",
"Array",
"[",
"id",
"]",
".",
"base",
"(",
")",
"\n",
"if",
"da",
".",
"Array",
"[",
"to",
"]",
".",
"Check",
"==",
"id",
"&&",
"da",
".",
"Array",
"[",
"to",
"]",
".",
"Value",
">=",
"0",
"{",
"return",
"da",
".",
"Array",
"[",
"to",
"]",
".",
"Value",
",",
"nil",
"\n",
"}",
"\n",
"return",
"0",
",",
"ErrNoValue",
"\n",
"}"
] |
20,947 | all-20948 | [
"WithCaseSensitive",
"if",
"true",
"search",
"is",
"case",
"sensitive",
"."
] | [
"func",
"(",
"p",
"SearchInResourceParams",
")",
"WithCaseSensitive",
"(",
"caseSensitive",
"bool",
")",
"*",
"SearchInResourceParams",
"{",
"p",
".",
"CaseSensitive",
"=",
"caseSensitive",
"\n",
"<mask>",
"&",
"p",
"\n",
"}"
] |
20,948 | all-20949 | [
"GetMessageOk",
"returns",
"a",
"tuple",
"with",
"the",
"Message",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"s",
"*",
"SyntheticsTest",
")",
"GetMessageOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"Message",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"s",
".",
"Message",
",",
"true",
"\n",
"}"
] |
20,949 | all-20950 | [
"Update",
"updates",
"the",
"uint16",
"in",
"the",
"buffer"
] | [
"func",
"(",
"ref",
"Uint16Ref",
")",
"Update",
"(",
"n",
"uint16",
")",
"{",
"if",
"<mask>",
"!=",
"nil",
"{",
"binary",
".",
"BigEndian",
".",
"PutUint16",
"(",
"ref",
",",
"n",
")",
"\n",
"}",
"\n",
"}"
] |
20,950 | all-20951 | [
"returns",
"the",
"call",
"price",
"by",
"country"
] | [
"func",
"(",
"cvps",
"*",
"CountryVoicePriceService",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"isoCountry",
"string",
")",
"(",
"*",
"VoicePrice",
",",
"error",
")",
"{",
"voicePrice",
":=",
"new",
"(",
"VoicePrice",
")",
"\n",
"err",
":=",
"cvps",
".",
"<mask>",
".",
"GetResource",
"(",
"ctx",
",",
"voicePathPart",
"+",
"\"",
"\"",
",",
"isoCountry",
",",
"voicePrice",
")",
"\n",
"return",
"voicePrice",
",",
"err",
"\n",
"}"
] |
20,951 | all-20952 | [
"GetEvaluationDuration",
"returns",
"the",
"time",
"in",
"seconds",
"it",
"took",
"to",
"evaluate",
"the",
"recording",
"rule",
"."
] | [
"func",
"(",
"rule",
"*",
"RecordingRule",
")",
"GetEvaluationDuration",
"(",
")",
"time",
".",
"Duration",
"{",
"rule",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"rule",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"<mask>",
".",
"evaluationDuration",
"\n",
"}"
] |
20,952 | all-20953 | [
"TODO",
":",
"add",
"checksum"
] | [
"func",
"(",
"c",
"*",
"WordCodec",
")",
"BytesToWords",
"(",
"raw",
"[",
"]",
"byte",
")",
"(",
"words",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"// always add a checksum to the data",
"data",
":=",
"c",
".",
"check",
".",
"AddECC",
"(",
"raw",
")",
"\n",
"numWords",
":=",
"wordlenFromBytes",
"(",
"len",
"(",
"data",
")",
")",
"\n\n",
"n2048",
":=",
"big",
".",
"NewInt",
"(",
"2048",
")",
"\n",
"nData",
":=",
"big",
".",
"NewInt",
"(",
"0",
")",
".",
"SetBytes",
"(",
"data",
")",
"\n",
"nRem",
":=",
"big",
".",
"NewInt",
"(",
"0",
")",
"\n",
"// Alternative, use condition \"nData.BitLen() > 0\"",
"// to allow for shorter words when data has leading 0's",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"numWords",
";",
"i",
"++",
"{",
"nData",
".",
"DivMod",
"(",
"nData",
",",
"n2048",
",",
"nRem",
")",
"\n",
"rem",
":=",
"nRem",
".",
"Int64",
"(",
")",
"\n",
"w",
":=",
"c",
".",
"<mask>",
"[",
"rem",
"]",
"\n",
"// double-check bank on generation...",
"_",
",",
"err",
":=",
"c",
".",
"GetIndex",
"(",
"w",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"words",
"=",
"append",
"(",
"words",
",",
"w",
")",
"\n",
"}",
"\n",
"return",
"words",
",",
"nil",
"\n",
"}"
] |
20,953 | all-20954 | [
"FileCopy",
"copies",
"a",
"file",
"overwriting",
"the",
"target",
"if",
"it",
"exists",
"."
] | [
"func",
"FileCopy",
"(",
"source",
"string",
",",
"dest",
"string",
")",
"error",
"{",
"s",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"source",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"s",
".",
"Close",
"(",
")",
"\n\n",
"fi",
",",
"err",
":=",
"s",
".",
"Stat",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"d",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"dest",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"os",
".",
"IsExist",
"(",
"err",
")",
"{",
"d",
",",
"err",
"=",
"os",
".",
"OpenFile",
"(",
"dest",
",",
"<mask>",
".",
"O_WRONLY",
",",
"fi",
".",
"Mode",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"defer",
"d",
".",
"Close",
"(",
")",
"\n\n",
"_",
",",
"err",
"=",
"io",
".",
"Copy",
"(",
"d",
",",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"/* chown not supported on windows */",
"if",
"runtime",
".",
"GOOS",
"!=",
"\"",
"\"",
"{",
"_",
",",
"uid",
",",
"gid",
":=",
"GetOwnerMode",
"(",
"fi",
")",
"\n",
"return",
"d",
".",
"Chown",
"(",
"uid",
",",
"gid",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
20,954 | all-20955 | [
"title",
":",
"service",
"instance",
"info",
"path",
":",
"/",
"services",
"/",
"{",
"service",
"}",
"/",
"instances",
"/",
"{",
"instance",
"}",
"method",
":",
"GET",
"produce",
":",
"application",
"/",
"json",
"responses",
":",
"200",
":",
"OK",
"401",
":",
"Unauthorized",
"404",
":",
"Service",
"instance",
"not",
"found"
] | [
"func",
"serviceInstance",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"t",
"auth",
".",
"Token",
")",
"error",
"{",
"instanceName",
":=",
"r",
".",
"<mask>",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"serviceName",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"svc",
",",
"err",
":=",
"getService",
"(",
"serviceName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"serviceInstance",
",",
"err",
":=",
"getServiceInstanceOrError",
"(",
"serviceName",
",",
"instanceName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"allowed",
":=",
"permission",
".",
"Check",
"(",
"t",
",",
"permission",
".",
"PermServiceInstanceRead",
",",
"contextsForServiceInstance",
"(",
"serviceInstance",
",",
"serviceName",
")",
"...",
",",
")",
"\n",
"if",
"!",
"allowed",
"{",
"return",
"permission",
".",
"ErrUnauthorized",
"\n",
"}",
"\n",
"requestID",
":=",
"requestIDHeader",
"(",
"r",
")",
"\n",
"info",
",",
"err",
":=",
"serviceInstance",
".",
"Info",
"(",
"requestID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"plan",
",",
"err",
":=",
"service",
".",
"GetPlanByServiceAndPlanName",
"(",
"svc",
",",
"serviceInstance",
".",
"PlanName",
",",
"requestID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"sInfo",
":=",
"serviceInstanceInfo",
"{",
"Apps",
":",
"serviceInstance",
".",
"Apps",
",",
"Teams",
":",
"serviceInstance",
".",
"Teams",
",",
"TeamOwner",
":",
"serviceInstance",
".",
"TeamOwner",
",",
"Description",
":",
"serviceInstance",
".",
"Description",
",",
"PlanName",
":",
"plan",
".",
"Name",
",",
"PlanDescription",
":",
"plan",
".",
"Description",
",",
"CustomInfo",
":",
"info",
",",
"Tags",
":",
"serviceInstance",
".",
"Tags",
",",
"}",
"\n",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"json",
".",
"NewEncoder",
"(",
"w",
")",
".",
"Encode",
"(",
"sInfo",
")",
"\n",
"}"
] |
20,955 | all-20956 | [
"ClearRect",
"fills",
"the",
"specified",
"rectangle",
"with",
"a",
"default",
"transparent",
"color"
] | [
"func",
"(",
"gc",
"*",
"GraphicContext",
")",
"ClearRect",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"int",
")",
"{",
"mask",
":=",
"gc",
".",
"newMask",
"(",
"x1",
",",
"y1",
",",
"x2",
"-",
"x1",
",",
"y2",
"-",
"y1",
")",
"\n\n",
"newGroup",
":=",
"&",
"Group",
"{",
"Groups",
":",
"gc",
".",
"svg",
".",
"Groups",
",",
"Mask",
":",
"\"",
"\"",
"+",
"mask",
".",
"Id",
"+",
"\"",
"\"",
",",
"}",
"\n\n",
"// replace groups with new masked group",
"gc",
".",
"svg",
".",
"Groups",
"=",
"[",
"]",
"*",
"<mask>",
"{",
"newGroup",
"}",
"\n",
"}"
] |
20,956 | all-20957 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"ErrorMessage",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoServiceworker13",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
20,957 | all-20958 | [
"specify",
"the",
"line",
"stipple",
"pattern"
] | [
"func",
"LineStipple",
"(",
"factor",
"int32",
",",
"pattern",
"uint16",
")",
"{",
"syscall",
".",
"Syscall",
"(",
"gpLineStipple",
",",
"2",
",",
"uintptr",
"(",
"<mask>",
")",
",",
"uintptr",
"(",
"pattern",
")",
",",
"0",
")",
"\n",
"}"
] |
20,958 | all-20959 | [
"render",
"primitives",
"using",
"a",
"count",
"derived",
"from",
"a",
"specifed",
"stream",
"of",
"a",
"transform",
"feedback",
"object"
] | [
"func",
"DrawTransformFeedbackStream",
"(",
"mode",
"uint32",
",",
"id",
"uint32",
",",
"stream",
"uint32",
")",
"{",
"syscall",
".",
"Syscall",
"(",
"gpDrawTransformFeedbackStream",
",",
"3",
",",
"uintptr",
"(",
"mode",
")",
",",
"uintptr",
"(",
"id",
")",
",",
"uintptr",
"(",
"<mask>",
")",
")",
"\n",
"}"
] |
20,959 | all-20960 | [
"resolve",
"sym",
"links",
"into",
"the",
"actual",
"log",
"directory",
"for",
"a",
"particular",
"test",
"run"
] | [
"func",
"(",
"bucket",
"gcsBucket",
")",
"resolveSymLink",
"(",
"symLink",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"<mask>",
",",
"err",
":=",
"bucket",
".",
"readObject",
"(",
"symLink",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"symLink",
",",
"err",
")",
"\n",
"}",
"\n",
"// strip gs://<bucket-name> from global address `u`",
"u",
":=",
"string",
"(",
"data",
")",
"\n",
"return",
"prefixRe",
".",
"ReplaceAllString",
"(",
"u",
",",
"\"",
"\"",
")",
",",
"nil",
"\n",
"}"
] |
20,960 | all-20961 | [
"TextFromUTF16",
"returns",
"v",
"s",
"string",
"value",
"interpreted",
"as",
"big",
"-",
"endian",
"UTF",
"-",
"16",
"and",
"then",
"converted",
"to",
"UTF",
"-",
"8",
".",
"If",
"v",
".",
"Kind",
"()",
"!",
"=",
"String",
"or",
"if",
"the",
"data",
"is",
"not",
"valid",
"UTF",
"-",
"16",
"TextFromUTF16",
"returns",
"the",
"empty",
"string",
"."
] | [
"func",
"(",
"v",
"<mask>",
")",
"TextFromUTF16",
"(",
")",
"string",
"{",
"x",
",",
"ok",
":=",
"v",
".",
"data",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"len",
"(",
"x",
")",
"%",
"2",
"==",
"1",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"x",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"utf16Decode",
"(",
"x",
")",
"\n",
"}"
] |
20,961 | all-20962 | [
"startDrainEventsTicker",
"starts",
"a",
"ticker",
"that",
"periodically",
"drains",
"the",
"events",
"queue",
"by",
"submitting",
"state",
"change",
"events",
"to",
"the",
"ECS",
"backend"
] | [
"func",
"(",
"handler",
"*",
"TaskHandler",
")",
"startDrainEventsTicker",
"(",
")",
"{",
"derivedCtx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"<mask>",
".",
"ctx",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"ticker",
":=",
"utils",
".",
"NewJitteredTicker",
"(",
"derivedCtx",
",",
"handler",
".",
"minDrainEventsFrequency",
",",
"handler",
".",
"maxDrainEventsFrequency",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"handler",
".",
"ctx",
".",
"Done",
"(",
")",
":",
"seelog",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"case",
"<-",
"ticker",
":",
"// Gather a list of task state changes to send. This list is",
"// constructed from the tasksToEvents map based on the task",
"// arns of containers that haven't been sent to ECS yet.",
"for",
"_",
",",
"taskEvent",
":=",
"range",
"handler",
".",
"taskStateChangesToSend",
"(",
")",
"{",
"seelog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"taskEvent",
".",
"String",
"(",
")",
")",
"\n",
"// Force start the the task state change submission",
"// workflow by calling AddStateChangeEvent method.",
"handler",
".",
"AddStateChangeEvent",
"(",
"taskEvent",
",",
"handler",
".",
"client",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
20,962 | all-20963 | [
"Tagging",
"parseTagAndLength",
"parses",
"an",
"ASN",
".",
"1",
"tag",
"and",
"length",
"pair",
"from",
"the",
"given",
"offset",
"into",
"a",
"byte",
"slice",
".",
"It",
"returns",
"the",
"parsed",
"data",
"and",
"the",
"new",
"offset",
".",
"SET",
"and",
"SET",
"OF",
"(",
"tag",
"17",
")",
"are",
"mapped",
"to",
"SEQUENCE",
"and",
"SEQUENCE",
"OF",
"(",
"tag",
"16",
")",
"since",
"we",
"don",
"t",
"distinguish",
"between",
"ordered",
"and",
"unordered",
"objects",
"in",
"this",
"code",
"."
] | [
"func",
"parseTagAndLength",
"(",
"bytes",
"[",
"]",
"byte",
",",
"initOffset",
"int",
")",
"(",
"ret",
"tagAndLength",
",",
"offset",
"int",
",",
"err",
"error",
")",
"{",
"offset",
"=",
"initOffset",
"\n",
"// parseTagAndLength should not be called without at least a single",
"// byte to read. Thus this check is for robustness:",
"if",
"<mask>",
">=",
"len",
"(",
"bytes",
")",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"b",
":=",
"bytes",
"[",
"offset",
"]",
"\n",
"offset",
"++",
"\n",
"ret",
".",
"class",
"=",
"int",
"(",
"b",
">>",
"6",
")",
"\n",
"ret",
".",
"isCompound",
"=",
"b",
"&",
"0x20",
"==",
"0x20",
"\n",
"ret",
".",
"tag",
"=",
"int",
"(",
"b",
"&",
"0x1f",
")",
"\n\n",
"// If the bottom five bits are set, then the tag number is actually base 128",
"// encoded afterwards",
"if",
"ret",
".",
"tag",
"==",
"0x1f",
"{",
"ret",
".",
"tag",
",",
"offset",
",",
"err",
"=",
"parseBase128Int",
"(",
"bytes",
",",
"offset",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"// Tags should be encoded in minimal form.",
"if",
"ret",
".",
"tag",
"<",
"0x1f",
"{",
"err",
"=",
"asn1",
".",
"SyntaxError",
"{",
"Msg",
":",
"\"",
"\"",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"offset",
">=",
"len",
"(",
"bytes",
")",
"{",
"err",
"=",
"asn1",
".",
"SyntaxError",
"{",
"Msg",
":",
"\"",
"\"",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"b",
"=",
"bytes",
"[",
"offset",
"]",
"\n",
"offset",
"++",
"\n",
"if",
"b",
"&",
"0x80",
"==",
"0",
"{",
"// The length is encoded in the bottom 7 bits.",
"ret",
".",
"length",
"=",
"int",
"(",
"b",
"&",
"0x7f",
")",
"\n",
"}",
"else",
"{",
"// Bottom 7 bits give the number of length bytes to follow.",
"numBytes",
":=",
"int",
"(",
"b",
"&",
"0x7f",
")",
"\n",
"if",
"numBytes",
"==",
"0",
"{",
"// TODO: Fix this for BER as it should be allowed. Not seen this in",
"// the wild with SNMP devices though.",
"err",
"=",
"asn1",
".",
"SyntaxError",
"{",
"Msg",
":",
"\"",
"\"",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"ret",
".",
"length",
"=",
"0",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"numBytes",
";",
"i",
"++",
"{",
"if",
"offset",
">=",
"len",
"(",
"bytes",
")",
"{",
"err",
"=",
"asn1",
".",
"SyntaxError",
"{",
"Msg",
":",
"\"",
"\"",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"b",
"=",
"bytes",
"[",
"offset",
"]",
"\n",
"offset",
"++",
"\n",
"if",
"ret",
".",
"length",
">=",
"1",
"<<",
"23",
"{",
"// We can't shift ret.length up without",
"// overflowing.",
"err",
"=",
"asn1",
".",
"StructuralError",
"{",
"Msg",
":",
"\"",
"\"",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"ret",
".",
"length",
"<<=",
"8",
"\n",
"ret",
".",
"length",
"|=",
"int",
"(",
"b",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] |
20,963 | all-20964 | [
"TCPDialCheck",
"returns",
"a",
"Check",
"that",
"checks",
"TCP",
"connectivity",
"to",
"the",
"provided",
"endpoint",
"."
] | [
"func",
"TCPDialCheck",
"(",
"addr",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"Check",
"{",
"return",
"func",
"(",
")",
"error",
"{",
"conn",
",",
"err",
":=",
"net",
".",
"DialTimeout",
"(",
"\"",
"\"",
",",
"addr",
",",
"timeout",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"<mask>",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
20,964 | all-20965 | [
"problemsInFiles",
"runs",
"buildifier",
"on",
"the",
"files",
".",
"It",
"returns",
"a",
"map",
"from",
"the",
"file",
"to",
"a",
"list",
"of",
"problems",
"with",
"that",
"file",
"."
] | [
"func",
"problemsInFiles",
"(",
"r",
"*",
"git",
".",
"Repo",
",",
"files",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"error",
")",
"{",
"problems",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"\n",
"for",
"f",
":=",
"range",
"files",
"{",
"src",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filepath",
".",
"Join",
"(",
"r",
".",
"Dir",
",",
"f",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"// This is modeled after the logic from buildifier:",
"// https://github.com/bazelbuild/buildtools/blob/8818289/buildifier/buildifier.go#L261",
"content",
",",
"err",
":=",
"build",
".",
"Parse",
"(",
"f",
",",
"src",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"beforeRewrite",
":=",
"build",
".",
"Format",
"(",
"content",
")",
"\n",
"<mask>",
"info",
"build",
".",
"RewriteInfo",
"\n",
"build",
".",
"Rewrite",
"(",
"content",
",",
"&",
"info",
")",
"\n",
"ndata",
":=",
"build",
".",
"Format",
"(",
"content",
")",
"\n",
"if",
"!",
"bytes",
".",
"Equal",
"(",
"src",
",",
"ndata",
")",
"&&",
"!",
"bytes",
".",
"Equal",
"(",
"src",
",",
"beforeRewrite",
")",
"{",
"// TODO(mattmoor): This always seems to be empty?",
"problems",
"[",
"f",
"]",
"=",
"uniqProblems",
"(",
"info",
".",
"Log",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"problems",
",",
"nil",
"\n",
"}"
] |
20,965 | all-20966 | [
"/",
"*",
"Warningm",
"uses",
"msg",
"as",
"a",
"format",
"string",
"with",
"subsequent",
"parameters",
"as",
"values",
"and",
"logs",
"the",
"resulting",
"message",
"to",
"all",
"added",
"loggers",
"at",
"LogLevel",
".",
"LevelWarning",
".",
"It",
"will",
"also",
"merge",
"all",
"attributes",
"passed",
"in",
"m",
"with",
"any",
"attributes",
"added",
"to",
"Base",
"and",
"include",
"them",
"with",
"the",
"message",
"if",
"the",
"Logger",
"supports",
"it",
"."
] | [
"func",
"(",
"b",
"*",
"Base",
")",
"Warningm",
"(",
"m",
"*",
"Attrs",
",",
"msg",
"string",
",",
"a",
"...",
"<mask>",
"{",
"}",
")",
"error",
"{",
"return",
"b",
".",
"Log",
"(",
"LevelWarning",
",",
"m",
",",
"msg",
",",
"a",
"...",
")",
"\n",
"}"
] |
20,966 | all-20967 | [
"GetInputPurpose",
"is",
"a",
"wrapper",
"around",
"gtk_text_view_get_input_purpose",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"TextView",
")",
"GetInputPurpose",
"(",
")",
"InputPurpose",
"{",
"c",
":=",
"C",
".",
"gtk_text_view_get_input_purpose",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"<mask>",
"InputPurpose",
"(",
"c",
")",
"\n",
"}"
] |
20,967 | all-20968 | [
"Patch",
"registers",
"handlers",
"with",
"the",
"given",
"pattern",
"for",
"PATCH",
"method"
] | [
"func",
"(",
"r",
"*",
"<mask>",
")",
"Patch",
"(",
"pat",
"string",
",",
"f",
"...",
"HandlerFunc",
")",
"{",
"r",
".",
"HandleMethod",
"(",
"pat",
",",
"\"",
"\"",
",",
"f",
"...",
")",
"\n",
"}"
] |
20,968 | all-20969 | [
"/",
"*",
"ProcessEvent",
"processes",
"all",
"events",
"come",
"from",
"the",
"control",
"parent",
".",
"If",
"a",
"control",
"processes",
"an",
"event",
"it",
"should",
"return",
"true",
".",
"If",
"the",
"method",
"returns",
"false",
"it",
"means",
"that",
"the",
"control",
"do",
"not",
"want",
"or",
"cannot",
"process",
"the",
"event",
"and",
"the",
"caller",
"sends",
"the",
"event",
"to",
"the",
"control",
"parent"
] | [
"func",
"(",
"l",
"*",
"ListBox",
")",
"ProcessEvent",
"(",
"event",
"Event",
")",
"bool",
"{",
"if",
"!",
"l",
".",
"Active",
"(",
")",
"||",
"!",
"l",
".",
"Enabled",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"switch",
"event",
".",
"Type",
"{",
"case",
"EventKey",
":",
"if",
"l",
".",
"onKeyPress",
"!=",
"nil",
"{",
"res",
":=",
"l",
".",
"onKeyPress",
"(",
"event",
".",
"Key",
")",
"\n",
"if",
"res",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"switch",
"event",
".",
"Key",
"{",
"case",
"term",
".",
"KeyHome",
":",
"l",
".",
"home",
"(",
")",
"\n",
"return",
"true",
"\n",
"case",
"term",
".",
"KeyEnd",
":",
"l",
".",
"end",
"(",
")",
"\n",
"return",
"true",
"\n",
"case",
"term",
".",
"KeyArrowUp",
":",
"l",
".",
"moveUp",
"(",
"1",
")",
"\n",
"return",
"true",
"\n",
"case",
"term",
".",
"KeyArrowDown",
":",
"l",
".",
"moveDown",
"(",
"1",
")",
"\n",
"return",
"true",
"\n",
"case",
"term",
".",
"KeyPgdn",
":",
"l",
".",
"moveDown",
"(",
"l",
".",
"height",
")",
"\n",
"return",
"true",
"\n",
"case",
"<mask>",
".",
"KeyPgup",
":",
"l",
".",
"moveUp",
"(",
"l",
".",
"height",
")",
"\n",
"return",
"true",
"\n",
"case",
"term",
".",
"KeyCtrlM",
":",
"if",
"l",
".",
"currSelection",
"!=",
"-",
"1",
"&&",
"l",
".",
"onSelectItem",
"!=",
"nil",
"{",
"ev",
":=",
"Event",
"{",
"Y",
":",
"l",
".",
"currSelection",
",",
"Msg",
":",
"l",
".",
"SelectedItemText",
"(",
")",
"}",
"\n",
"l",
".",
"onSelectItem",
"(",
"ev",
")",
"\n",
"}",
"\n",
"default",
":",
"return",
"false",
"\n",
"}",
"\n",
"case",
"EventMouse",
":",
"return",
"l",
".",
"processMouseClick",
"(",
"event",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
20,969 | all-20970 | [
"ConnectEntry",
"is",
"a",
"wrapper",
"around",
"gtk_search_bar_connect_entry",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"SearchBar",
")",
"ConnectEntry",
"(",
"entry",
"IEntry",
")",
"{",
"C",
".",
"gtk_search_bar_connect_entry",
"(",
"v",
".",
"native",
"(",
")",
",",
"<mask>",
".",
"toEntry",
"(",
")",
")",
"\n",
"}"
] |
20,970 | all-20971 | [
"Fprintm",
"writes",
"formatted",
"string",
"to",
"provided",
"writer",
".",
"This",
"is",
"same",
"as",
"fmt",
".",
"Fprintf",
"but",
"uses",
"gstring",
"formatting",
"."
] | [
"func",
"Fprintm",
"(",
"w",
"io",
".",
"Writer",
",",
"format",
"string",
",",
"args",
"<mask>",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"f",
",",
"a",
":=",
"gformat",
"(",
"format",
",",
"args",
")",
"\n",
"return",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"f",
",",
"a",
"...",
")",
"\n",
"}"
] |
20,971 | all-20972 | [
"Create",
"a",
"network",
"raft",
"transport",
"that",
"will",
"handle",
"connections",
"using",
"a",
"rafthttp",
".",
"Handler",
"."
] | [
"func",
"raftNetworkTransport",
"(",
"db",
"*",
"db",
".",
"Node",
",",
"<mask>",
"string",
",",
"logger",
"*",
"log",
".",
"Logger",
",",
"timeout",
"time",
".",
"Duration",
",",
"dial",
"rafthttp",
".",
"Dial",
")",
"(",
"raft",
".",
"Transport",
",",
"*",
"rafthttp",
".",
"Handler",
",",
"*",
"rafthttp",
".",
"Layer",
",",
"error",
")",
"{",
"handler",
":=",
"rafthttp",
".",
"NewHandlerWithLogger",
"(",
"logger",
")",
"\n",
"addr",
",",
"err",
":=",
"net",
".",
"ResolveTCPAddr",
"(",
"\"",
"\"",
",",
"address",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"nil",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"layer",
":=",
"rafthttp",
".",
"NewLayer",
"(",
"raftEndpoint",
",",
"addr",
",",
"handler",
",",
"dial",
")",
"\n",
"config",
":=",
"&",
"raft",
".",
"NetworkTransportConfig",
"{",
"Logger",
":",
"logger",
",",
"Stream",
":",
"layer",
",",
"MaxPool",
":",
"2",
",",
"Timeout",
":",
"timeout",
",",
"ServerAddressProvider",
":",
"&",
"raftAddressProvider",
"{",
"db",
":",
"db",
"}",
",",
"}",
"\n",
"transport",
":=",
"raft",
".",
"NewNetworkTransportWithConfig",
"(",
"config",
")",
"\n\n",
"return",
"transport",
",",
"handler",
",",
"layer",
",",
"nil",
"\n",
"}"
] |
20,972 | all-20973 | [
"GetDefaultInterfaces",
"fetches",
"the",
"device",
"name",
"of",
"default",
"routable",
"interface",
"."
] | [
"func",
"GetDefaultInterfaces",
"(",
")",
"(",
"<mask>",
"[",
"string",
"]",
"uint8",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"runtime",
".",
"GOOS",
",",
"runtime",
".",
"GOARCH",
")",
"\n",
"}"
] |
20,973 | all-20974 | [
"DumpMetrics",
"returns",
"the",
"metrics",
"prometheus",
"would",
"return",
"when",
"collected",
"as",
"a",
"string",
"for",
"fun",
"and",
"testing"
] | [
"func",
"DumpMetrics",
"(",
"ctx",
"context",
".",
"Context",
",",
"<mask>",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"gatherer",
":=",
"prometheus",
".",
"DefaultGatherer",
"\n",
"mfs",
",",
"err",
":=",
"gatherer",
".",
"Gather",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"enc",
":=",
"expfmt",
".",
"NewEncoder",
"(",
"buf",
",",
"expfmt",
".",
"FmtText",
")",
"\n\n",
"for",
"_",
",",
"mf",
":=",
"range",
"mfs",
"{",
"if",
"err",
":=",
"enc",
".",
"Encode",
"(",
"mf",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"buf",
".",
"String",
"(",
")",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"buf",
".",
"String",
"(",
")",
",",
"nil",
"\n",
"}"
] |
20,974 | all-20975 | [
"HasX",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"w",
"*",
"Widget",
")",
"HasX",
"(",
")",
"bool",
"{",
"if",
"w",
"!=",
"nil",
"&&",
"w",
".",
"X",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
20,975 | all-20976 | [
"GetIconActivatable",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_entry_get_icon_activatable",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"GetIconActivatable",
"(",
"iconPos",
"EntryIconPosition",
")",
"bool",
"{",
"c",
":=",
"C",
".",
"gtk_entry_get_icon_activatable",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"GtkEntryIconPosition",
"(",
"iconPos",
")",
")",
"\n",
"return",
"gobool",
"(",
"c",
")",
"\n",
"}"
] |
20,976 | all-20977 | [
"Specify",
"the",
"value",
"of",
"a",
"uniform",
"variable",
"for",
"a",
"specified",
"program",
"object"
] | [
"func",
"ProgramUniformMatrix3x4fv",
"(",
"program",
"uint32",
",",
"<mask>",
"int32",
",",
"count",
"int32",
",",
"transpose",
"bool",
",",
"value",
"*",
"float32",
")",
"{",
"syscall",
".",
"Syscall6",
"(",
"gpProgramUniformMatrix3x4fv",
",",
"5",
",",
"uintptr",
"(",
"program",
")",
",",
"uintptr",
"(",
"location",
")",
",",
"uintptr",
"(",
"count",
")",
",",
"boolToUintptr",
"(",
"transpose",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"value",
")",
")",
",",
"0",
")",
"\n",
"}"
] |
20,977 | all-20978 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"SetSkipAllPausesParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger4",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
] |
20,978 | all-20979 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"TypeProfileEntry",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoProfiler",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
20,979 | all-20980 | [
"RemoveAllCDDVDDrives",
"deletes",
"all",
"the",
"CD",
"/",
"DVD",
"drives",
"from",
"the",
"VM",
"s",
"VMX",
"file",
"."
] | [
"func",
"(",
"v",
"*",
"VM",
")",
"RemoveAllCDDVDDrives",
"(",
")",
"error",
"{",
"drives",
",",
"err",
":=",
"v",
".",
"CDDVDs",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"&",
"Error",
"{",
"Operation",
":",
"\"",
"\"",
",",
"Code",
":",
"200004",
",",
"Text",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
",",
"}",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"d",
":=",
"<mask>",
"drives",
"{",
"err",
":=",
"v",
".",
"DetachCDDVD",
"(",
"d",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"&",
"Error",
"{",
"Operation",
":",
"\"",
"\"",
",",
"Code",
":",
"200004",
",",
"Text",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"d",
",",
"err",
")",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
20,980 | all-20981 | [
"bind",
"one",
"or",
"more",
"named",
"textures",
"to",
"a",
"sequence",
"of",
"consecutive",
"texture",
"units"
] | [
"func",
"BindTextures",
"(",
"<mask>",
"uint32",
",",
"count",
"int32",
",",
"textures",
"*",
"uint32",
")",
"{",
"syscall",
".",
"Syscall",
"(",
"gpBindTextures",
",",
"3",
",",
"uintptr",
"(",
"first",
")",
",",
"uintptr",
"(",
"count",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"textures",
")",
")",
")",
"\n",
"}"
] |
20,981 | all-20982 | [
"GetSSHPort",
"returns",
"port",
"for",
"use",
"with",
"ssh"
] | [
"func",
"(",
"d",
"*",
"SerialDriver",
")",
"GetSSHPort",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"d",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"Unlock",
"(",
")",
"\n",
"<mask>",
"d",
".",
"Driver",
".",
"GetSSHPort",
"(",
")",
"\n",
"}"
] |
20,982 | all-20983 | [
"DrawRawText",
"draws",
"the",
"part",
"of",
"text",
"that",
"is",
"inside",
"the",
"current",
"clipping",
"rectangle",
".",
"DrawRawText",
"always",
"paints",
"string",
"as",
"is",
"-",
"no",
"color",
"changes",
".",
"If",
"you",
"want",
"to",
"draw",
"string",
"with",
"color",
"changing",
"commands",
"included",
"then",
"use",
"DrawText",
"function"
] | [
"func",
"DrawRawText",
"(",
"x",
",",
"y",
"int",
",",
"text",
"string",
")",
"{",
"cx",
",",
"cy",
",",
"cw",
",",
"ch",
":=",
"ClipRect",
"(",
")",
"\n",
"if",
"x",
">=",
"cx",
"+",
"cw",
"||",
"y",
"<",
"cy",
"||",
"y",
">=",
"cy",
"+",
"ch",
"{",
"return",
"\n",
"}",
"\n\n",
"length",
":=",
"xs",
".",
"Len",
"(",
"text",
")",
"\n",
"if",
"x",
"+",
"length",
"<",
"cx",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"x",
"<",
"cx",
"{",
"<mask>",
"=",
"xs",
".",
"Slice",
"(",
"text",
",",
"cx",
"-",
"x",
",",
"-",
"1",
")",
"\n",
"length",
"=",
"length",
"-",
"(",
"cx",
"-",
"x",
")",
"\n",
"x",
"=",
"cx",
"\n",
"}",
"\n",
"text",
"=",
"CutText",
"(",
"text",
",",
"cw",
")",
"\n\n",
"dx",
":=",
"0",
"\n",
"for",
"_",
",",
"ch",
":=",
"range",
"text",
"{",
"putCharUnsafe",
"(",
"x",
"+",
"dx",
",",
"y",
",",
"ch",
")",
"\n",
"dx",
"++",
"\n",
"}",
"\n",
"}"
] |
20,983 | all-20984 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"EventAttachedToTarget",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoTarget19",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
20,984 | all-20985 | [
"Create",
"creates",
"a",
"VirtualApp",
"."
] | [
"func",
"Create",
"(",
"rp",
"*",
"<mask>",
".",
"ResourcePool",
",",
"name",
"string",
",",
"resSpec",
"*",
"types",
".",
"ResourceConfigSpec",
",",
"vSpec",
"*",
"types",
".",
"VAppConfigSpec",
",",
"folder",
"*",
"object",
".",
"Folder",
")",
"(",
"*",
"object",
".",
"VirtualApp",
",",
"error",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"rp",
".",
"InventoryPath",
",",
"name",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"provider",
".",
"DefaultAPITimeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"nva",
",",
"err",
":=",
"rp",
".",
"CreateVApp",
"(",
"ctx",
",",
"name",
",",
"*",
"resSpec",
",",
"*",
"vSpec",
",",
"folder",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"nva",
",",
"nil",
"\n",
"}"
] |
20,985 | all-20986 | [
"ServeTaskHTTPEndpoint",
"serves",
"task",
"/",
"container",
"metadata",
"task",
"/",
"container",
"stats",
"and",
"IAM",
"Role",
"Credentials",
"for",
"tasks",
"being",
"managed",
"by",
"the",
"agent",
"."
] | [
"func",
"ServeTaskHTTPEndpoint",
"(",
"credentialsManager",
"credentials",
".",
"<mask>",
",",
"state",
"dockerstate",
".",
"TaskEngineState",
",",
"ecsClient",
"api",
".",
"ECSClient",
",",
"containerInstanceArn",
"string",
",",
"cfg",
"*",
"config",
".",
"Config",
",",
"statsEngine",
"stats",
".",
"Engine",
",",
"availabilityZone",
"string",
")",
"{",
"// Create and initialize the audit log",
"// TODO Use seelog's programmatic configuration instead of xml.",
"logger",
",",
"err",
":=",
"seelog",
".",
"LoggerFromConfigAsString",
"(",
"audit",
".",
"AuditLoggerConfig",
"(",
"cfg",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"// If the logger cannot be initialized, use the provided dummy seelog.LoggerInterface, seelog.Disabled.",
"logger",
"=",
"seelog",
".",
"Disabled",
"\n",
"}",
"\n\n",
"auditLogger",
":=",
"audit",
".",
"NewAuditLog",
"(",
"containerInstanceArn",
",",
"cfg",
",",
"logger",
")",
"\n\n",
"server",
":=",
"taskServerSetup",
"(",
"credentialsManager",
",",
"auditLogger",
",",
"state",
",",
"ecsClient",
",",
"cfg",
".",
"Cluster",
",",
"statsEngine",
",",
"cfg",
".",
"TaskMetadataSteadyStateRate",
",",
"cfg",
".",
"TaskMetadataBurstRate",
",",
"availabilityZone",
",",
"containerInstanceArn",
")",
"\n\n",
"for",
"{",
"retry",
".",
"RetryWithBackoff",
"(",
"retry",
".",
"NewExponentialBackoff",
"(",
"time",
".",
"Second",
",",
"time",
".",
"Minute",
",",
"0.2",
",",
"2",
")",
",",
"func",
"(",
")",
"error",
"{",
"// TODO, make this cancellable and use the passed in context;",
"err",
":=",
"server",
".",
"ListenAndServe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
")",
"\n",
"}",
"\n",
"}"
] |
20,986 | all-20987 | [
"sizeFromTag",
"returns",
"a",
"size",
"from",
"tag",
".",
"If",
"size",
"tag",
"specified",
"to",
"struct",
"field",
"it",
"will",
"converted",
"to",
"uint64",
"and",
"returns",
"it",
".",
"If",
"it",
"doesn",
"t",
"specify",
"it",
"returns",
"0",
".",
"If",
"value",
"of",
"size",
"tag",
"cannot",
"convert",
"to",
"uint64",
"it",
"returns",
"0",
"and",
"error",
"."
] | [
"func",
"(",
"<mask>",
"*",
"DB",
")",
"sizeFromTag",
"(",
"field",
"*",
"reflect",
".",
"StructField",
")",
"(",
"size",
"uint64",
",",
"err",
"error",
")",
"{",
"if",
"s",
":=",
"field",
".",
"Tag",
".",
"Get",
"(",
"dbSizeTag",
")",
";",
"s",
"!=",
"\"",
"\"",
"{",
"size",
",",
"err",
"=",
"strconv",
".",
"ParseUint",
"(",
"s",
",",
"10",
",",
"64",
")",
"\n",
"}",
"\n",
"return",
"size",
",",
"err",
"\n",
"}"
] |
20,987 | all-20988 | [
"GetIconName",
"is",
"a",
"wrapper",
"around",
"gtk_status_icon_get_icon_name",
"()"
] | [
"func",
"(",
"v",
"*",
"StatusIcon",
")",
"GetIconName",
"(",
")",
"string",
"{",
"c",
":=",
"C",
".",
"gtk_status_icon_get_icon_name",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"<mask>",
")",
"(",
"c",
")",
")",
"\n",
"}"
] |
20,988 | all-20989 | [
"String",
"returns",
"the",
"canonical",
"representation",
"of",
"a",
"LintStatus",
"as",
"a",
"string",
"."
] | [
"func",
"(",
"e",
"LintStatus",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"e",
"{",
"case",
"NA",
":",
"return",
"\"",
"\"",
"\n",
"case",
"NE",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Pass",
":",
"return",
"\"",
"\"",
"\n",
"<mask>",
"Notice",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Warn",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Error",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Fatal",
":",
"return",
"\"",
"\"",
"\n",
"default",
":",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"}"
] |
20,989 | all-20990 | [
"Creates",
"a",
"snapshot",
"on",
"the",
"given",
"block",
"volume",
".",
"volumeId",
":",
"The",
"id",
"of",
"the",
"volume",
"notes",
":",
"The",
"notes",
"or",
"name",
"to",
"assign",
"the",
"snapshot"
] | [
"func",
"(",
"c",
"*",
"ClientManager",
")",
"CreateSnapshot",
"(",
"volumeId",
"int",
",",
"notes",
"string",
")",
"(",
"datatypes",
".",
"Network_Storage",
",",
"error",
")",
"{",
"for",
"{",
"networkStorage",
",",
"err",
":=",
"c",
".",
"StorageService",
".",
"Id",
"(",
"volumeId",
")",
".",
"CreateSnapshot",
"(",
"sl",
".",
"String",
"(",
"(",
"notes",
")",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"apiErr",
":=",
"err",
".",
"(",
"sl",
".",
"Error",
")",
"\n",
"if",
"apiErr",
".",
"Exception",
"==",
"SOFTLAYER_PUBLIC_EXCEPTION",
"&&",
"strings",
".",
"Contains",
"(",
"apiErr",
".",
"<mask>",
",",
"\"",
"\"",
")",
"{",
"continue",
"\n",
"}",
"\n\n",
"return",
"datatypes",
".",
"Network_Storage",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"networkStorage",
",",
"nil",
"\n",
"}",
"\n",
"}"
] |
20,990 | all-20991 | [
"New",
"creates",
"a",
"new",
"CA",
"."
] | [
"func",
"New",
"(",
"opts",
"...",
"Option",
")",
"*",
"Identity",
"{",
"c",
":=",
"&",
"configuration",
"{",
"}",
"\n\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"<mask>",
"(",
"opt",
")",
"(",
"c",
")",
"\n",
"}",
"\n\n",
"return",
"c",
".",
"generate",
"(",
")",
"\n",
"}"
] |
20,991 | all-20992 | [
"CleanupSubnetIfExists",
"removes",
"a",
"subnet",
"if",
"there",
"are",
"no",
"IP",
"configurations",
"(",
"through",
"NICs",
")",
"are",
"attached",
"to",
"it",
".",
"Note",
"that",
"this",
"method",
"is",
"not",
"safe",
"for",
"multiple",
"concurrent",
"writers",
"in",
"case",
"of",
"races",
"deployment",
"of",
"a",
"machine",
"could",
"fail",
"or",
"resource",
"might",
"not",
"be",
"cleaned",
"up",
"."
] | [
"func",
"(",
"a",
"AzureClient",
")",
"CleanupSubnetIfExists",
"(",
"resourceGroup",
",",
"virtualNetwork",
",",
"name",
"string",
")",
"error",
"{",
"return",
"a",
".",
"cleanupResourceIfExists",
"(",
"&",
"subnetCleanup",
"{",
"rg",
":",
"resourceGroup",
",",
"vnet",
":",
"virtualNetwork",
",",
"<mask>",
":",
"name",
",",
"}",
")",
"\n",
"}"
] |
20,992 | all-20993 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"LayoutTreeNode",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoDomsnapshot7",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
20,993 | all-20994 | [
"export",
"FrameSet_InvertedFrameRange"
] | [
"func",
"FrameSet_InvertedFrameRange",
"(",
"id",
"FrameSetId",
",",
"pad",
"int",
")",
"(",
"ret",
"*",
"C",
".",
"<mask>",
")",
"{",
"fs",
",",
"ok",
":=",
"sFrameSets",
".",
"Get",
"(",
"id",
")",
"\n",
"if",
"!",
"ok",
"{",
"ret",
"=",
"C",
".",
"CString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"ret",
"=",
"C",
".",
"CString",
"(",
"fs",
".",
"InvertedFrameRange",
"(",
"pad",
")",
")",
"\n",
"}",
"\n",
"// caller must free the string",
"return",
"ret",
"\n",
"}"
] |
20,994 | all-20995 | [
"FSHandler",
"returns",
"request",
"handler",
"serving",
"static",
"files",
"from",
"the",
"given",
"root",
"folder",
".",
"stripSlashes",
"indicates",
"how",
"many",
"leading",
"slashes",
"must",
"be",
"stripped",
"from",
"requested",
"path",
"before",
"searching",
"requested",
"file",
"in",
"the",
"root",
"folder",
".",
"Examples",
":",
"*",
"stripSlashes",
"=",
"0",
"original",
"path",
":",
"/",
"foo",
"/",
"bar",
"result",
":",
"/",
"foo",
"/",
"bar",
"*",
"stripSlashes",
"=",
"1",
"original",
"path",
":",
"/",
"foo",
"/",
"bar",
"result",
":",
"/",
"bar",
"*",
"stripSlashes",
"=",
"2",
"original",
"path",
":",
"/",
"foo",
"/",
"bar",
"result",
":",
"The",
"returned",
"request",
"handler",
"automatically",
"generates",
"index",
"pages",
"for",
"directories",
"without",
"index",
".",
"html",
".",
"The",
"returned",
"handler",
"caches",
"requested",
"file",
"handles",
"for",
"FSHandlerCacheDuration",
".",
"Make",
"sure",
"your",
"program",
"has",
"enough",
"max",
"open",
"files",
"limit",
"aka",
"ulimit",
"-",
"n",
"if",
"root",
"folder",
"contains",
"many",
"files",
".",
"Do",
"not",
"create",
"multiple",
"request",
"handler",
"instances",
"for",
"the",
"same",
"(",
"root",
"stripSlashes",
")",
"arguments",
"-",
"just",
"reuse",
"a",
"single",
"instance",
".",
"Otherwise",
"goroutine",
"leak",
"will",
"occur",
"."
] | [
"func",
"FSHandler",
"(",
"root",
"string",
",",
"stripSlashes",
"int",
")",
"RequestHandler",
"{",
"fs",
":=",
"&",
"FS",
"{",
"Root",
":",
"<mask>",
",",
"IndexNames",
":",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"GenerateIndexPages",
":",
"true",
",",
"AcceptByteRange",
":",
"true",
",",
"}",
"\n",
"if",
"stripSlashes",
">",
"0",
"{",
"fs",
".",
"PathRewrite",
"=",
"NewPathSlashesStripper",
"(",
"stripSlashes",
")",
"\n",
"}",
"\n",
"return",
"fs",
".",
"NewRequestHandler",
"(",
")",
"\n",
"}"
] |
20,995 | all-20996 | [
"RemoveText",
"removes",
"a",
"text",
"metric"
] | [
"func",
"(",
"m",
"*",
"CirconusMetrics",
")",
"RemoveText",
"(",
"metric",
"string",
")",
"{",
"m",
".",
"tm",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"tm",
".",
"Unlock",
"(",
")",
"\n",
"<mask>",
"(",
"m",
".",
"text",
",",
"metric",
")",
"\n",
"}"
] |
20,996 | all-20997 | [
"Handle",
"writes",
"message",
"from",
"log",
"record",
"into",
"file",
"."
] | [
"func",
"(",
"handler",
"*",
"RotatingFileHandler",
")",
"Handle",
"(",
"record",
"*",
"Record",
")",
"error",
"{",
"handler",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"handler",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"msg",
":=",
"handler",
".",
"Formatter",
".",
"Format",
"(",
"record",
")",
"+",
"\"",
"\\n",
"\"",
"\n\n",
"if",
"handler",
".",
"needsRotation",
"(",
"msg",
")",
"{",
"if",
"err",
":=",
"handler",
".",
"rotate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"handler",
".",
"open",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"<mask>",
".",
"writer",
"==",
"nil",
"{",
"if",
"err",
":=",
"handler",
".",
"open",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"_",
",",
"err",
":=",
"handler",
".",
"writer",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"msg",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"handler",
".",
"writer",
".",
"Flush",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
20,997 | all-20998 | [
"pipelineReplicate",
"is",
"used",
"when",
"we",
"have",
"synchronized",
"our",
"state",
"with",
"the",
"follower",
"and",
"want",
"to",
"switch",
"to",
"a",
"higher",
"performance",
"pipeline",
"mode",
"of",
"replication",
".",
"We",
"only",
"pipeline",
"AppendEntries",
"commands",
"and",
"if",
"we",
"ever",
"hit",
"an",
"error",
"we",
"fall",
"back",
"to",
"the",
"standard",
"replication",
"which",
"can",
"handle",
"more",
"complex",
"situations",
"."
] | [
"func",
"(",
"r",
"*",
"Raft",
")",
"pipelineReplicate",
"(",
"s",
"*",
"followerReplication",
")",
"error",
"{",
"// Create a new pipeline",
"pipeline",
",",
"err",
":=",
"r",
".",
"trans",
".",
"AppendEntriesPipeline",
"(",
"s",
".",
"peer",
".",
"<mask>",
",",
"s",
".",
"peer",
".",
"Address",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"pipeline",
".",
"Close",
"(",
")",
"\n\n",
"// Log start and stop of pipeline",
"r",
".",
"logger",
".",
"Info",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"peer",
")",
")",
"\n",
"defer",
"r",
".",
"logger",
".",
"Info",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"peer",
")",
")",
"\n\n",
"// Create a shutdown and finish channel",
"stopCh",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"finishCh",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n\n",
"// Start a dedicated decoder",
"r",
".",
"goFunc",
"(",
"func",
"(",
")",
"{",
"r",
".",
"pipelineDecode",
"(",
"s",
",",
"pipeline",
",",
"stopCh",
",",
"finishCh",
")",
"}",
")",
"\n\n",
"// Start pipeline sends at the last good nextIndex",
"nextIndex",
":=",
"s",
".",
"nextIndex",
"\n\n",
"shouldStop",
":=",
"false",
"\n",
"SEND",
":",
"for",
"!",
"shouldStop",
"{",
"select",
"{",
"case",
"<-",
"finishCh",
":",
"break",
"SEND",
"\n",
"case",
"maxIndex",
":=",
"<-",
"s",
".",
"stopCh",
":",
"// Make a best effort to replicate up to this index",
"if",
"maxIndex",
">",
"0",
"{",
"r",
".",
"pipelineSend",
"(",
"s",
",",
"pipeline",
",",
"&",
"nextIndex",
",",
"maxIndex",
")",
"\n",
"}",
"\n",
"break",
"SEND",
"\n",
"case",
"<-",
"s",
".",
"triggerCh",
":",
"lastLogIdx",
",",
"_",
":=",
"r",
".",
"getLastLog",
"(",
")",
"\n",
"shouldStop",
"=",
"r",
".",
"pipelineSend",
"(",
"s",
",",
"pipeline",
",",
"&",
"nextIndex",
",",
"lastLogIdx",
")",
"\n",
"case",
"<-",
"randomTimeout",
"(",
"r",
".",
"conf",
".",
"CommitTimeout",
")",
":",
"lastLogIdx",
",",
"_",
":=",
"r",
".",
"getLastLog",
"(",
")",
"\n",
"shouldStop",
"=",
"r",
".",
"pipelineSend",
"(",
"s",
",",
"pipeline",
",",
"&",
"nextIndex",
",",
"lastLogIdx",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Stop our decoder, and wait for it to finish",
"close",
"(",
"stopCh",
")",
"\n",
"select",
"{",
"case",
"<-",
"finishCh",
":",
"case",
"<-",
"r",
".",
"shutdownCh",
":",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
20,998 | all-20999 | [
"From",
"public",
"API",
"method",
"to",
"proposalc",
"."
] | [
"func",
"(",
"s",
"*",
"etcdStore",
")",
"proposeInternalRaftRequest",
"(",
"req",
"etcdserverpb",
".",
"InternalRaftRequest",
")",
"(",
"<-",
"chan",
"proto",
".",
"Message",
",",
"<-",
"chan",
"error",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"req",
".",
"Marshal",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"<mask>",
")",
">",
"maxRequestBytes",
"{",
"return",
"nil",
",",
"nil",
",",
"errTooBig",
"\n",
"}",
"\n",
"msgc",
",",
"errc",
",",
"err",
":=",
"s",
".",
"registerPending",
"(",
"req",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"s",
".",
"proposalc",
"<-",
"data",
"\n",
"return",
"msgc",
",",
"errc",
",",
"nil",
"\n",
"}"
] |
20,999 | all-21000 | [
"FlushCommitAll",
"returns",
"commits",
"that",
"have",
"the",
"specified",
"commits",
"as",
"provenance",
".",
"Note",
"that",
"it",
"can",
"block",
"if",
"jobs",
"have",
"not",
"successfully",
"completed",
".",
"This",
"in",
"effect",
"waits",
"for",
"all",
"of",
"the",
"jobs",
"that",
"are",
"triggered",
"by",
"a",
"set",
"of",
"commits",
"to",
"complete",
".",
"If",
"toRepos",
"is",
"not",
"nil",
"then",
"only",
"the",
"commits",
"up",
"to",
"and",
"including",
"those",
"repos",
"will",
"be",
"considered",
"otherwise",
"all",
"repos",
"are",
"considered",
".",
"Note",
"that",
"it",
"s",
"never",
"necessary",
"to",
"call",
"FlushCommit",
"to",
"run",
"jobs",
"they",
"ll",
"run",
"no",
"matter",
"what",
"FlushCommitAll",
"just",
"allows",
"you",
"to",
"wait",
"for",
"them",
"to",
"complete",
"and",
"see",
"their",
"output",
"once",
"they",
"do",
"."
] | [
"func",
"(",
"c",
"APIClient",
")",
"FlushCommitAll",
"(",
"commits",
"[",
"]",
"*",
"pfs",
".",
"Commit",
",",
"toRepos",
"[",
"]",
"*",
"pfs",
".",
"Repo",
")",
"(",
"[",
"]",
"*",
"pfs",
".",
"CommitInfo",
",",
"error",
")",
"{",
"var",
"result",
"[",
"]",
"*",
"pfs",
".",
"CommitInfo",
"\n",
"if",
"err",
":=",
"c",
".",
"FlushCommitF",
"(",
"commits",
",",
"toRepos",
",",
"func",
"(",
"ci",
"*",
"pfs",
".",
"CommitInfo",
")",
"error",
"{",
"result",
"=",
"append",
"(",
"<mask>",
",",
"ci",
")",
"\n",
"return",
"nil",
"\n",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n",
"}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.