id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
23,300 | all-23301 | [
"Validate",
"is",
"middleware",
"to",
"enforce",
"required",
"fields",
".",
"If",
"the",
"struct",
"passed",
"in",
"is",
"a",
"Validator",
"then",
"the",
"user",
"-",
"defined",
"Validate",
"method",
"is",
"executed",
"and",
"its",
"errors",
"are",
"mapped",
"to",
"the",
"context",
".",
"This",
"middleware",
"performs",
"no",
"error",
"handling",
":",
"it",
"merely",
"detects",
"them",
"and",
"maps",
"them",
"."
] | [
"func",
"Validate",
"(",
"obj",
"interface",
"{",
"}",
")",
"martini",
".",
"Handler",
"{",
"return",
"func",
"(",
"context",
"martini",
".",
"Context",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"errors",
":=",
"newErrors",
"(",
")",
"\n",
"validateStruct",
"(",
"errors",
",",
"obj",
")",
"\n\n",
"if",
"validator",
",",
"ok",
":=",
"obj",
".",
"(",
"Validator",
")",
";",
"ok",
"{",
"validator",
".",
"Validate",
"(",
"errors",
",",
"req",
")",
"\n",
"}",
"\n",
"<mask>",
".",
"Map",
"(",
"*",
"errors",
")",
"\n\n",
"}",
"\n",
"}"
] |
23,301 | all-23302 | [
"Error",
"implements",
"the",
"Error",
"interface",
"."
] | [
"func",
"(",
"e",
"*",
"hdbError",
")",
"<mask>",
"(",
")",
"string",
"{",
"if",
"e",
".",
"stmtNo",
"!=",
"-",
"1",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"errorLevel",
",",
"e",
".",
"errorCode",
",",
"e",
".",
"errorText",
",",
"e",
".",
"stmtNo",
")",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"errorLevel",
",",
"e",
".",
"errorCode",
",",
"e",
".",
"errorText",
")",
"\n",
"}"
] |
23,302 | all-23303 | [
"Run",
"implements",
"the",
"Discoverer",
"interface",
"."
] | [
"func",
"(",
"d",
"*",
"Discovery",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"ch",
"chan",
"<-",
"[",
"]",
"*",
"targetgroup",
".",
"Group",
")",
"{",
"if",
"d",
".",
"finalizer",
"!=",
"nil",
"{",
"defer",
"d",
".",
"finalizer",
"(",
")",
"\n",
"}",
"\n",
"d",
".",
"initialize",
"(",
"ctx",
")",
"\n\n",
"if",
"len",
"(",
"d",
".",
"watchedServices",
")",
"==",
"0",
"||",
"len",
"(",
"d",
".",
"watchedTags",
")",
"!=",
"0",
"{",
"// We need to watch the catalog.",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"d",
".",
"refreshInterval",
")",
"\n\n",
"// Watched services and their cancellation functions.",
"services",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"func",
"(",
")",
")",
"\n",
"var",
"lastIndex",
"uint64",
"\n\n",
"for",
"{",
"select",
"{",
"<mask>",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"ticker",
".",
"Stop",
"(",
")",
"\n",
"return",
"\n",
"default",
":",
"d",
".",
"watchServices",
"(",
"ctx",
",",
"ch",
",",
"&",
"lastIndex",
",",
"services",
")",
"\n",
"<-",
"ticker",
".",
"C",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"else",
"{",
"// We only have fully defined services.",
"for",
"_",
",",
"name",
":=",
"range",
"d",
".",
"watchedServices",
"{",
"d",
".",
"watchService",
"(",
"ctx",
",",
"ch",
",",
"name",
")",
"\n",
"}",
"\n",
"<-",
"ctx",
".",
"Done",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
23,303 | all-23304 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"SetShowScrollBottleneckRectsParams",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"<mask>",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoOverlay1",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
23,304 | all-23305 | [
"After",
"some",
"interval",
"time",
"goto",
"check",
"the",
"current",
"fileLogger",
"s",
"size",
"or",
"date"
] | [
"func",
"(",
"f",
"*",
"FileLogger",
")",
"fileMonitor",
"(",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
":=",
"recover",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"f",
".",
"lg",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"//TODO load logScan interval from config file",
"logScan",
":=",
"DEFAULT_LOG_SCAN",
"\n\n",
"timer",
":=",
"time",
".",
"NewTicker",
"(",
"time",
".",
"Duration",
"(",
"logScan",
")",
"*",
"time",
".",
"Second",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"<mask>",
".",
"C",
":",
"f",
".",
"fileCheck",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
23,305 | all-23306 | [
"newProcess",
"constructs",
"and",
"returns",
"a",
"Process",
".",
"It",
"will",
"call",
"tf",
"TeardownFunc",
"exactly",
"once",
":",
"**",
"after",
"**",
"all",
"children",
"have",
"fully",
"Closed",
"**",
"after",
"**",
"entering",
"<",
"-",
"Closing",
"()",
"and",
"**",
"before",
"**",
"<",
"-",
"Closed",
"()",
"."
] | [
"func",
"newProcess",
"(",
"tf",
"TeardownFunc",
")",
"*",
"process",
"{",
"return",
"&",
"process",
"{",
"teardown",
":",
"tf",
",",
"closed",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"closing",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"waitfors",
":",
"<mask>",
"(",
"map",
"[",
"*",
"processLink",
"]",
"struct",
"{",
"}",
")",
",",
"children",
":",
"make",
"(",
"map",
"[",
"*",
"processLink",
"]",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"}"
] |
23,306 | all-23307 | [
"Cert",
"attempts",
"to",
"parse",
"the",
"certificate",
"string",
"to",
"return",
"it",
"as",
"an",
"object",
".",
"If",
"the",
"certificate",
"is",
"an",
"empty",
"string",
"(",
"e",
".",
"g",
".",
"in",
"the",
"case",
"of",
"permanent",
"credentials",
")",
"then",
"a",
"nil",
"pointer",
"is",
"returned",
"for",
"the",
"certificate",
".",
"If",
"a",
"certificate",
"has",
"been",
"specified",
"but",
"cannot",
"be",
"parsed",
"an",
"error",
"is",
"returned",
"and",
"cert",
"is",
"an",
"empty",
"certificate",
"(",
"rather",
"than",
"nil",
")",
"."
] | [
"func",
"(",
"creds",
"*",
"Credentials",
")",
"Cert",
"(",
")",
"(",
"cert",
"*",
"Certificate",
",",
"err",
"error",
")",
"{",
"if",
"creds",
".",
"Certificate",
"==",
"\"",
"\"",
"{",
"return",
"\n",
"}",
"\n",
"cert",
"=",
"new",
"(",
"Certificate",
")",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"<mask>",
"(",
"creds",
".",
"Certificate",
")",
",",
"cert",
")",
"\n",
"return",
"\n",
"}"
] |
23,307 | all-23308 | [
"InstanceCombinationLocator",
"builds",
"a",
"locator",
"from",
"the",
"given",
"href",
"."
] | [
"func",
"(",
"api",
"*",
"API",
")",
"InstanceCombinationLocator",
"(",
"href",
"string",
")",
"*",
"InstanceCombinationLocator",
"{",
"<mask>",
"&",
"InstanceCombinationLocator",
"{",
"Href",
"(",
"href",
")",
",",
"api",
"}",
"\n",
"}"
] |
23,308 | all-23309 | [
"CopyFileToHost",
"copies",
"a",
"file",
"or",
"directory",
"from",
"the",
"guest",
"operating",
"system",
"to",
"the",
"local",
"system",
"(",
"where",
"the",
"VIX",
"client",
"is",
"running",
")",
".",
"Parameters",
":",
"guestpath",
":",
"The",
"path",
"name",
"of",
"a",
"file",
"on",
"a",
"file",
"system",
"available",
"to",
"the",
"guest",
".",
"hostpath",
":",
"The",
"path",
"name",
"of",
"a",
"file",
"on",
"a",
"file",
"system",
"available",
"to",
"the",
"Vix",
"client",
"."
] | [
"func",
"(",
"g",
"*",
"Guest",
")",
"CopyFileToHost",
"(",
"guestpath",
",",
"hostpath",
"string",
")",
"error",
"{",
"var",
"jobHandle",
"C",
".",
"VixHandle",
"=",
"C",
".",
"VIX_INVALID_HANDLE",
"\n",
"var",
"err",
"C",
".",
"VixError",
"=",
"C",
".",
"VIX_OK",
"\n\n",
"gpath",
":=",
"C",
".",
"CString",
"(",
"guestpath",
")",
"\n",
"hpath",
":=",
"C",
".",
"CString",
"(",
"hostpath",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"gpath",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"hpath",
")",
")",
"\n\n",
"jobHandle",
"=",
"C",
".",
"VixVM_CopyFileFromGuestToHost",
"(",
"g",
".",
"<mask>",
",",
"gpath",
",",
"// src name",
"hpath",
",",
"// dest name",
"0",
",",
"// options",
"C",
".",
"VIX_INVALID_HANDLE",
",",
"// propertyListHandle",
"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",
"}"
] |
23,309 | all-23310 | [
"UnmarshalJSON",
"implements",
"the",
"json",
".",
"Unmarshaler",
"interface",
"."
] | [
"func",
"(",
"prm",
"*",
"prmMatchRepoDigestOrExact",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"<mask>",
")",
"error",
"{",
"*",
"prm",
"=",
"prmMatchRepoDigestOrExact",
"{",
"}",
"\n",
"var",
"tmp",
"prmMatchRepoDigestOrExact",
"\n",
"if",
"err",
":=",
"paranoidUnmarshalJSONObjectExactFields",
"(",
"data",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"&",
"tmp",
".",
"Type",
",",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"tmp",
".",
"Type",
"!=",
"prmTypeMatchRepoDigestOrExact",
"{",
"return",
"InvalidPolicyFormatError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"tmp",
".",
"Type",
")",
")",
"\n",
"}",
"\n",
"*",
"prm",
"=",
"*",
"newPRMMatchRepoDigestOrExact",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
23,310 | all-23311 | [
"TODO",
"(",
"jrick",
")",
"GetSource",
"(",
"depends",
"on",
"Pattern",
")",
"SetAntialias",
"is",
"a",
"wrapper",
"around",
"cairo_set_antialias",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"SetAntialias",
"(",
"antialias",
"Antialias",
")",
"{",
"C",
".",
"cairo_set_antialias",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"cairo_antialias_t",
"(",
"antialias",
")",
")",
"\n",
"}"
] |
23,311 | all-23312 | [
"NewCatalogDatacentersQuery",
"creates",
"a",
"new",
"datacenter",
"dependency",
"."
] | [
"func",
"NewCatalogDatacentersQuery",
"(",
"ignoreFailing",
"bool",
")",
"(",
"*",
"CatalogDatacentersQuery",
",",
"error",
")",
"{",
"return",
"&",
"CatalogDatacentersQuery",
"{",
"ignoreFailing",
":",
"ignoreFailing",
",",
"stopCh",
":",
"<mask>",
"(",
"chan",
"struct",
"{",
"}",
",",
"1",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] |
23,312 | all-23313 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"SignedExchangeError",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork8",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
23,313 | all-23314 | [
"NewNodeFilter",
"创建节点过滤器,实现敏感词的过滤",
"从切片中读取敏感词数据"
] | [
"func",
"NewNodeFilter",
"(",
"text",
"[",
"]",
"string",
")",
"DirtyFilter",
"{",
"nf",
":=",
"&",
"nodeFilter",
"{",
"<mask>",
":",
"newNode",
"(",
")",
",",
"}",
"\n",
"for",
"i",
",",
"l",
":=",
"0",
",",
"len",
"(",
"text",
")",
";",
"i",
"<",
"l",
";",
"i",
"++",
"{",
"nf",
".",
"addDirtyWords",
"(",
"text",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"return",
"nf",
"\n",
"}"
] |
23,314 | all-23315 | [
"Fetch",
"retrieves",
"all",
"types",
"of",
"events",
"and",
"push",
"them",
"to",
"output",
"channels"
] | [
"func",
"(",
"f",
"*",
"Fetcher",
")",
"Fetch",
"(",
"db",
"*",
"gorm",
".",
"DB",
")",
"error",
"{",
"if",
"err",
":=",
"f",
".",
"fetchRecentIssues",
"(",
"<mask>",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
":=",
"f",
".",
"fetchRecentEventsAndComments",
"(",
"db",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
23,315 | all-23316 | [
"Intersects",
"returns",
"true",
"if",
"there",
"is",
"some",
"tree",
"node",
"intersecting",
"the",
"given",
"interval",
"."
] | [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"Intersects",
"(",
"iv",
"Interval",
")",
"bool",
"{",
"x",
":=",
"ivt",
".",
"root",
"\n",
"for",
"x",
"!=",
"nil",
"&&",
"<mask>",
".",
"Compare",
"(",
"&",
"x",
".",
"iv",
".",
"Ivl",
")",
"!=",
"0",
"{",
"if",
"x",
".",
"left",
"!=",
"nil",
"&&",
"x",
".",
"left",
".",
"max",
".",
"Compare",
"(",
"iv",
".",
"Begin",
")",
">",
"0",
"{",
"x",
"=",
"x",
".",
"left",
"\n",
"}",
"else",
"{",
"x",
"=",
"x",
".",
"right",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"x",
"!=",
"nil",
"\n",
"}"
] |
23,316 | all-23317 | [
"GetManageStatusShowTitle",
"returns",
"the",
"ManageStatusShowTitle",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"w",
"*",
"Widget",
")",
"GetManageStatusShowTitle",
"(",
")",
"bool",
"{",
"if",
"w",
"==",
"nil",
"||",
"w",
".",
"ManageStatusShowTitle",
"==",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"w",
".",
"ManageStatusShowTitle",
"\n",
"}"
] |
23,317 | all-23318 | [
"LoadPackage",
"parses",
"a",
"text",
"string",
"."
] | [
"func",
"LoadPackage",
"(",
"parser",
"<mask>",
",",
"name",
",",
"text",
"string",
")",
"(",
"Package",
",",
"error",
")",
"{",
"return",
"parser",
".",
"Parse",
"(",
"name",
",",
"text",
")",
"\n",
"}"
] |
23,318 | all-23319 | [
"TriggerIncidentKey",
"triggers",
"an",
"incident",
"using",
"the",
"default",
"client",
"with",
"a",
"given",
"incident",
"key",
"only",
"if",
"that",
"incident",
"has",
"been",
"resolved",
"or",
"if",
"that",
"incident",
"doesn",
"t",
"exist",
"yet",
"."
] | [
"func",
"TriggerIncidentKey",
"(",
"description",
"string",
",",
"key",
"string",
")",
"(",
"incidentKey",
"string",
",",
"err",
"error",
")",
"{",
"return",
"trigger",
"(",
"description",
",",
"<mask>",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] |
23,319 | all-23320 | [
"NewPrivate",
"constructs",
"ecdsa",
".",
"PrivateKey",
"from",
"given",
"(",
"X",
"Y",
")",
"and",
"D"
] | [
"func",
"NewPrivate",
"(",
"x",
",",
"y",
",",
"d",
"[",
"]",
"<mask>",
")",
"(",
"*",
"ecdsa",
".",
"PrivateKey",
")",
"{",
"return",
"&",
"ecdsa",
".",
"PrivateKey",
"{",
"D",
":",
"new",
"(",
"big",
".",
"Int",
")",
".",
"SetBytes",
"(",
"d",
")",
",",
"PublicKey",
":",
"ecdsa",
".",
"PublicKey",
"{",
"Curve",
":",
"curve",
"(",
"len",
"(",
"x",
")",
")",
",",
"X",
":",
"new",
"(",
"big",
".",
"Int",
")",
".",
"SetBytes",
"(",
"x",
")",
",",
"Y",
":",
"new",
"(",
"big",
".",
"Int",
")",
".",
"SetBytes",
"(",
"y",
")",
"}",
"}",
"\n",
"}"
] |
23,320 | all-23321 | [
"SplitPort",
"splits",
"port",
"number",
"and",
"protocol",
"name",
"from",
"Ports",
"string",
"."
] | [
"func",
"(",
"s",
"NetworkSettings",
")",
"SplitPort",
"(",
"<mask>",
"int",
")",
"(",
"uint16",
",",
"string",
")",
"{",
"ptProt",
",",
"_",
":=",
"s",
".",
"PortAt",
"(",
"index",
")",
"\n",
"vect",
":=",
"strings",
".",
"Split",
"(",
"ptProt",
",",
"\"",
"\"",
")",
"\n",
"port",
",",
"_",
":=",
"strconv",
".",
"ParseUint",
"(",
"vect",
"[",
"0",
"]",
",",
"10",
",",
"16",
")",
"\n",
"return",
"uint16",
"(",
"port",
")",
",",
"vect",
"[",
"1",
"]",
"\n",
"}"
] |
23,321 | all-23322 | [
"Print",
"qualifiers",
"as",
"an",
"inner",
"type",
"by",
"just",
"printing",
"the",
"qualifiers",
"."
] | [
"func",
"(",
"twq",
"*",
"TypeWithQualifiers",
")",
"printInner",
"(",
"<mask>",
"*",
"printState",
")",
"{",
"ps",
".",
"writeByte",
"(",
"' '",
")",
"\n",
"ps",
".",
"writeString",
"(",
"strings",
".",
"Join",
"(",
"twq",
".",
"Qualifiers",
",",
"\"",
"\"",
")",
")",
"\n",
"}"
] |
23,322 | all-23323 | [
"----------------------------------------",
".",
"String",
"()"
] | [
"func",
"(",
"ti",
"TypeInfo",
")",
"String",
"(",
")",
"string",
"{",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
")",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ti",
".",
"Type",
")",
")",
")",
"\n",
"if",
"ti",
".",
"Type",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Interface",
"{",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ti",
".",
"Priority",
")",
")",
")",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
")",
"\n",
"for",
"pb",
",",
"cinfos",
":=",
"range",
"ti",
".",
"Implementers",
"{",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"pb",
")",
")",
")",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"cinfos",
")",
")",
")",
"\n",
"}",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"<mask>",
"(",
"\"",
"\"",
")",
")",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ti",
".",
"InterfaceOptions",
".",
"Priority",
")",
")",
")",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ti",
".",
"InterfaceOptions",
".",
"AlwaysDisambiguate",
")",
")",
")",
"\n",
"}",
"\n",
"if",
"ti",
".",
"Type",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Interface",
"{",
"if",
"ti",
".",
"ConcreteInfo",
".",
"Registered",
"{",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
")",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ti",
".",
"PointerPreferred",
")",
")",
")",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"ti",
".",
"Name",
")",
")",
")",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"ti",
".",
"Disamb",
")",
")",
")",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"ti",
".",
"Prefix",
")",
")",
")",
"\n",
"}",
"else",
"{",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"ti",
".",
"AminoMarshalReprType",
")",
")",
")",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"ti",
".",
"AminoUnmarshalReprType",
")",
")",
")",
"\n",
"if",
"ti",
".",
"Type",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Struct",
"{",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ti",
".",
"Fields",
")",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"buf",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
")",
"\n",
"return",
"buf",
".",
"String",
"(",
")",
"\n",
"}"
] |
23,323 | all-23324 | [
"getCWStatsSet",
"gets",
"the",
"stats",
"set",
"for",
"either",
"CPU",
"or",
"Memory",
"based",
"on",
"the",
"function",
"pointer",
"."
] | [
"func",
"(",
"<mask>",
"*",
"Queue",
")",
"getCWStatsSet",
"(",
"f",
"getUsageFunc",
")",
"(",
"*",
"ecstcs",
".",
"CWStatsSet",
",",
"error",
")",
"{",
"queue",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"queue",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"queueLength",
":=",
"len",
"(",
"queue",
".",
"buffer",
")",
"\n",
"if",
"queueLength",
"<",
"2",
"{",
"// Need at least 2 data points to calculate this.",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"min",
",",
"max",
",",
"sum",
"float64",
"\n",
"var",
"sampleCount",
"int64",
"\n",
"min",
"=",
"math",
".",
"MaxFloat64",
"\n",
"max",
"=",
"-",
"math",
".",
"MaxFloat64",
"\n",
"sum",
"=",
"0",
"\n",
"sampleCount",
"=",
"0",
"\n\n",
"for",
"_",
",",
"stat",
":=",
"range",
"queue",
".",
"buffer",
"{",
"perc",
":=",
"f",
"(",
"&",
"stat",
")",
"\n",
"if",
"math",
".",
"IsNaN",
"(",
"perc",
")",
"{",
"continue",
"\n",
"}",
"\n\n",
"min",
"=",
"math",
".",
"Min",
"(",
"min",
",",
"perc",
")",
"\n",
"max",
"=",
"math",
".",
"Max",
"(",
"max",
",",
"perc",
")",
"\n",
"sampleCount",
"++",
"\n",
"sum",
"+=",
"perc",
"\n",
"}",
"\n\n",
"return",
"&",
"ecstcs",
".",
"CWStatsSet",
"{",
"Max",
":",
"&",
"max",
",",
"Min",
":",
"&",
"min",
",",
"SampleCount",
":",
"&",
"sampleCount",
",",
"Sum",
":",
"&",
"sum",
",",
"}",
",",
"nil",
"\n",
"}"
] |
23,324 | all-23325 | [
"repackage",
"repackages",
"the",
"main",
"package",
"specified",
"in",
"the",
"provided",
"configuration",
"and",
"re",
"-",
"writes",
"them",
"into",
"the",
"provided",
"output",
"directory",
".",
"The",
"repackaged",
"files",
"are",
"placed",
"into",
"a",
"directory",
"called",
"vendor",
"that",
"is",
"created",
"in",
"the",
"provided",
"directory",
".",
"This",
"function",
"assumes",
"and",
"verifies",
"that",
"the",
"provided",
"outputDir",
"is",
"a",
"directory",
"that",
"exists",
".",
"The",
"provided",
"configuration",
"is",
"processed",
"based",
"on",
"the",
"natural",
"ordering",
"of",
"the",
"name",
"of",
"the",
"commands",
".",
"If",
"multiple",
"commands",
"specify",
"the",
"same",
"package",
"it",
"is",
"only",
"processed",
"for",
"the",
"first",
"command",
"."
] | [
"func",
"repackage",
"(",
"config",
"Config",
",",
"outputDir",
"string",
")",
"error",
"{",
"if",
"outputDirInfo",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"outputDir",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"<mask>",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"outputDir",
")",
"\n",
"}",
"else",
"if",
"!",
"outputDirInfo",
".",
"IsDir",
"(",
")",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"outputDir",
")",
"\n",
"}",
"\n\n",
"vendorDir",
":=",
"path",
".",
"Join",
"(",
"outputDir",
",",
"internalDir",
")",
"\n",
"// remove output directory if it already exists",
"if",
"err",
":=",
"os",
".",
"RemoveAll",
"(",
"vendorDir",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"vendorDir",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"os",
".",
"Mkdir",
"(",
"vendorDir",
",",
"0755",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"internalDir",
",",
"vendorDir",
")",
"\n",
"}",
"\n\n",
"processedPkgs",
":=",
"make",
"(",
"map",
"[",
"SrcPkg",
"]",
"bool",
",",
"len",
"(",
"config",
".",
"Pkgs",
")",
")",
"\n",
"for",
"_",
",",
"currName",
":=",
"range",
"sortedKeys",
"(",
"config",
".",
"Pkgs",
")",
"{",
"currPkg",
":=",
"config",
".",
"Pkgs",
"[",
"currName",
"]",
"\n\n",
"// if multiple keys specify the exact same source package, only process once",
"if",
"processedPkgs",
"[",
"currPkg",
"]",
"{",
"continue",
"\n",
"}",
"\n\n",
"mainPkg",
",",
"err",
":=",
"build",
".",
"Import",
"(",
"currPkg",
".",
"MainPkg",
",",
"outputDir",
",",
"build",
".",
"FindOnly",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"currPkg",
".",
"MainPkg",
",",
"outputDir",
")",
"\n",
"}",
"\n\n",
"// get location of main package on disk",
"mainDir",
":=",
"mainPkg",
".",
"Dir",
"\n\n",
"// get project import path and location of project package directory",
"projectRootDir",
":=",
"mainDir",
"\n",
"projectImportPath",
":=",
"currPkg",
".",
"MainPkg",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"currPkg",
".",
"DistanceToProjectPkg",
";",
"i",
"++",
"{",
"projectRootDir",
"=",
"path",
".",
"Dir",
"(",
"projectRootDir",
")",
"\n",
"projectImportPath",
"=",
"path",
".",
"Dir",
"(",
"projectImportPath",
")",
"\n",
"}",
"\n\n",
"// copy project package into vendor directory in output dir if it does not already exist",
"projectDstDir",
":=",
"path",
".",
"Join",
"(",
"vendorDir",
",",
"projectImportPath",
")",
"\n\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"projectDstDir",
")",
";",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"if",
"err",
":=",
"shutil",
".",
"CopyTree",
"(",
"projectRootDir",
",",
"projectDstDir",
",",
"vendorCopyOptions",
"(",
"currPkg",
".",
"OmitVendorDirs",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"projectRootDir",
",",
"projectDstDir",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"removeEmptyDirs",
"(",
"projectDstDir",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"projectDstDir",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"projectDstDir",
")",
"\n",
"}",
"\n\n",
"projectDstDirImport",
",",
"err",
":=",
"build",
".",
"ImportDir",
"(",
"projectDstDir",
",",
"build",
".",
"FindOnly",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"projectDstDir",
")",
"\n",
"}",
"\n",
"projectDstDirImportPath",
":=",
"projectDstDirImport",
".",
"ImportPath",
"\n\n",
"// rewrite imports for all files in copied directory",
"fileSet",
":=",
"token",
".",
"NewFileSet",
"(",
")",
"\n",
"foundMain",
":=",
"false",
"\n",
"goFiles",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"ast",
".",
"File",
")",
"\n\n",
"flagPkgImported",
":=",
"false",
"\n",
"if",
"err",
":=",
"filepath",
".",
"Walk",
"(",
"projectDstDir",
",",
"func",
"(",
"currPath",
"string",
",",
"currInfo",
"os",
".",
"FileInfo",
",",
"err",
"error",
")",
"error",
"{",
"if",
"!",
"currInfo",
".",
"IsDir",
"(",
")",
"&&",
"strings",
".",
"HasSuffix",
"(",
"currInfo",
".",
"Name",
"(",
")",
",",
"\"",
"\"",
")",
"{",
"fileNode",
",",
"err",
":=",
"parser",
".",
"ParseFile",
"(",
"fileSet",
",",
"currPath",
",",
"nil",
",",
"parser",
".",
"ParseComments",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"currPath",
")",
"\n",
"}",
"\n",
"goFiles",
"[",
"currPath",
"]",
"=",
"fileNode",
"\n\n",
"for",
"_",
",",
"currImport",
":=",
"range",
"fileNode",
".",
"Imports",
"{",
"currImportPathUnquoted",
",",
"err",
":=",
"strconv",
".",
"Unquote",
"(",
"currImport",
".",
"Path",
".",
"Value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"currImport",
".",
"Path",
".",
"Value",
")",
"\n",
"}",
"\n\n",
"updatedImport",
":=",
"\"",
"\"",
"\n",
"if",
"currImportPathUnquoted",
"==",
"\"",
"\"",
"{",
"flagPkgImported",
"=",
"true",
"\n",
"updatedImport",
"=",
"path",
".",
"Join",
"(",
"projectDstDirImportPath",
",",
"\"",
"\"",
")",
"\n",
"}",
"else",
"if",
"strings",
".",
"HasPrefix",
"(",
"currImportPathUnquoted",
",",
"projectImportPath",
")",
"{",
"updatedImport",
"=",
"strings",
".",
"Replace",
"(",
"currImportPathUnquoted",
",",
"projectImportPath",
",",
"projectDstDirImportPath",
",",
"-",
"1",
")",
"\n",
"}",
"\n\n",
"if",
"updatedImport",
"!=",
"\"",
"\"",
"{",
"if",
"!",
"astutil",
".",
"RewriteImport",
"(",
"fileSet",
",",
"fileNode",
",",
"currImportPathUnquoted",
",",
"updatedImport",
")",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"currImportPathUnquoted",
",",
"updatedImport",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"removeImportPathChecking",
"(",
"fileNode",
")",
"\n\n",
"// change package name for main packages",
"if",
"fileNode",
".",
"Name",
".",
"Name",
"==",
"\"",
"\"",
"{",
"fileNode",
".",
"Name",
"=",
"ast",
".",
"NewIdent",
"(",
"amalgomatedPackage",
")",
"\n\n",
"// find the main function",
"mainFunc",
":=",
"findFunction",
"(",
"fileNode",
",",
"\"",
"\"",
")",
"\n",
"if",
"mainFunc",
"!=",
"nil",
"{",
"err",
"=",
"renameFunction",
"(",
"fileNode",
",",
"\"",
"\"",
",",
"amalgomatedMain",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"currPath",
")",
"\n",
"}",
"\n",
"foundMain",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"!",
"foundMain",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"currPkg",
".",
"MainPkg",
")",
"\n",
"}",
"\n\n",
"if",
"flagPkgImported",
"{",
"// if \"flag\" package is imported, add \"flag\" as a rewritten vendored dependency. This is done",
"// because flag.CommandLine is a global variable that is often used by programs and problems can",
"// arise if multiple amalgomated programs use it. A custom rewritten import is used rather than",
"// vendoring so that the amalgomated program can itself be vendored.",
"goRoot",
",",
"err",
":=",
"dirs",
".",
"GoRoot",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"WithStack",
"(",
"err",
")",
"\n",
"}",
"\n",
"fmtSrcDir",
":=",
"path",
".",
"Join",
"(",
"goRoot",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"fmtDstDir",
":=",
"path",
".",
"Join",
"(",
"projectDstDir",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"shutil",
".",
"CopyTree",
"(",
"fmtSrcDir",
",",
"fmtDstDir",
",",
"vendorCopyOptions",
"(",
"currPkg",
".",
"OmitVendorDirs",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"fmtSrcDir",
",",
"fmtDstDir",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"removeEmptyDirs",
"(",
"fmtDstDir",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"fmtDstDir",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"currGoFile",
",",
"currNode",
":=",
"range",
"goFiles",
"{",
"if",
"err",
"=",
"writeAstToFile",
"(",
"currGoFile",
",",
"currNode",
",",
"fileSet",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"config",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"processedPkgs",
"[",
"currPkg",
"]",
"=",
"true",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
23,325 | all-23326 | [
"GetType",
"returns",
"the",
"Type",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"e",
"*",
"EventStreamDefinition",
")",
"GetType",
"(",
")",
"string",
"{",
"if",
"e",
"==",
"nil",
"||",
"e",
".",
"Type",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"e",
".",
"<mask>",
"\n",
"}"
] |
23,326 | all-23327 | [
"PopupAtStatusIcon",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_menu_popup",
"()",
"specific",
"to",
"usage",
"with",
"GtkStatusIcon",
".",
"gomenu_popup",
"()",
"is",
"defined",
"in",
"menu",
".",
"go",
".",
"h",
"this",
"is",
"a",
"workaround",
"to",
"pass",
"gtk_status_icon_position_menu",
"as",
"the",
"GtkMenuPositionFunc",
"."
] | [
"func",
"(",
"v",
"*",
"Menu",
")",
"PopupAtStatusIcon",
"(",
"statusIcon",
"*",
"StatusIcon",
",",
"button",
"uint",
",",
"activateTime",
"uint32",
")",
"{",
"C",
".",
"gotk_menu_popup_at_status_icon",
"(",
"v",
".",
"native",
"(",
")",
",",
"statusIcon",
".",
"native",
"(",
")",
",",
"C",
".",
"guint",
"(",
"<mask>",
")",
",",
"C",
".",
"guint32",
"(",
"activateTime",
")",
")",
"\n",
"}"
] |
23,327 | all-23328 | [
"Do",
"executes",
"Input",
".",
"insertText",
"against",
"the",
"provided",
"context",
"."
] | [
"func",
"(",
"p",
"*",
"InsertTextParams",
")",
"Do",
"(",
"ctx",
"<mask>",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"return",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandInsertText",
",",
"p",
",",
"nil",
")",
"\n",
"}"
] |
23,328 | all-23329 | [
"UrlFor",
"returns",
"the",
"avsolute",
"URL",
"for",
"the",
"route",
"name",
".",
"UrlBase",
"is",
"used",
"for",
"the",
"URL",
"Host",
"and",
"Scheme"
] | [
"func",
"AbsoluteUrlFor",
"(",
"name",
"string",
",",
"args",
"...",
"string",
")",
"*",
"url",
".",
"URL",
"{",
"u",
":=",
"UrlFor",
"(",
"<mask>",
",",
"args",
"...",
")",
"\n",
"u",
".",
"Host",
"=",
"UrlBase",
".",
"Host",
"\n",
"u",
".",
"Scheme",
"=",
"UrlBase",
".",
"Scheme",
"\n",
"return",
"u",
"\n",
"}"
] |
23,329 | all-23330 | [
"Wrap",
"is",
"used",
"to",
"create",
"a",
"new",
"instrumented",
"driver",
"it",
"takes",
"a",
"vendor",
"specific",
"driver",
"and",
"a",
"Hooks",
"instance",
"to",
"produce",
"a",
"new",
"driver",
"instance",
".",
"It",
"s",
"usually",
"used",
"inside",
"a",
"sql",
".",
"Register",
"()",
"statement"
] | [
"func",
"Wrap",
"(",
"driver",
"driver",
".",
"Driver",
",",
"hooks",
"Hooks",
")",
"driver",
".",
"Driver",
"{",
"return",
"&",
"Driver",
"{",
"<mask>",
",",
"hooks",
"}",
"\n",
"}"
] |
23,330 | all-23331 | [
"Print",
"is",
"a",
"dummy",
"method",
"."
] | [
"func",
"(",
"l",
"*",
"nullLogger",
")",
"Print",
"(",
"start",
"<mask>",
".",
"Time",
",",
"query",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] |
23,331 | all-23332 | [
"TreeRowReferenceNew",
"is",
"a",
"wrapper",
"around",
"gtk_tree_row_reference_new",
"()",
"."
] | [
"func",
"TreeRowReferenceNew",
"(",
"model",
"*",
"TreeModel",
",",
"path",
"*",
"TreePath",
")",
"(",
"*",
"TreeRowReference",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gtk_tree_row_reference_new",
"(",
"model",
".",
"native",
"(",
")",
",",
"path",
".",
"native",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"r",
":=",
"&",
"TreeRowReference",
"{",
"c",
"}",
"\n",
"runtime",
".",
"SetFinalizer",
"(",
"r",
",",
"(",
"*",
"TreeRowReference",
")",
".",
"<mask>",
")",
"\n",
"return",
"r",
",",
"nil",
"\n",
"}"
] |
23,332 | all-23333 | [
"A",
"factory",
"method",
"that",
"enables",
"various",
"MetricsClients",
"to",
"be",
"created",
"."
] | [
"func",
"NewMetricsClient",
"(",
"api",
"APIType",
",",
"registry",
"*",
"prometheus",
".",
"Registry",
")",
"MetricsClient",
"{",
"switch",
"api",
"{",
"case",
"DockerAPI",
":",
"return",
"NewGenericMetricsClient",
"(",
"DockerSubsystem",
",",
"registry",
")",
"\n",
"case",
"TaskEngine",
":",
"return",
"NewGenericMetricsClient",
"(",
"TaskEngineSubsystem",
",",
"registry",
")",
"\n",
"case",
"StateManager",
":",
"return",
"NewGenericMetricsClient",
"(",
"StateManagerSubsystem",
",",
"registry",
")",
"\n",
"case",
"ECSClient",
":",
"return",
"NewGenericMetricsClient",
"(",
"ECSClientSubsystem",
",",
"registry",
")",
"\n",
"default",
":",
"seelog",
".",
"<mask>",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] |
23,333 | all-23334 | [
"SetTransientFor",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_native_dialog_set_transient_for",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"NativeDialog",
")",
"SetTransientFor",
"(",
"parent",
"IWindow",
")",
"{",
"<mask>",
"pw",
"*",
"C",
".",
"GtkWindow",
"=",
"nil",
"\n",
"if",
"parent",
"!=",
"nil",
"{",
"pw",
"=",
"parent",
".",
"toWindow",
"(",
")",
"\n",
"}",
"\n",
"C",
".",
"gtk_native_dialog_set_transient_for",
"(",
"v",
".",
"native",
"(",
")",
",",
"pw",
")",
"\n",
"}"
] |
23,334 | all-23335 | [
"NewIssueEvent",
"creates",
"a",
"new",
"(",
"orm",
")",
"Issue",
"from",
"a",
"github",
"Issue"
] | [
"func",
"NewIssueEvent",
"(",
"gIssueEvent",
"*",
"github",
".",
"IssueEvent",
",",
"issueID",
"int",
",",
"repository",
"string",
")",
"(",
"*",
"sql",
".",
"IssueEvent",
",",
"error",
")",
"{",
"if",
"gIssueEvent",
".",
"ID",
"==",
"nil",
"||",
"gIssueEvent",
".",
"Event",
"==",
"nil",
"||",
"gIssueEvent",
".",
"CreatedAt",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"gIssueEvent",
")",
"\n",
"}",
"\n\n",
"var",
"label",
"*",
"string",
"\n",
"if",
"gIssueEvent",
".",
"Label",
"!=",
"nil",
"{",
"label",
"=",
"gIssueEvent",
".",
"Label",
".",
"Name",
"\n",
"}",
"\n",
"var",
"assignee",
"*",
"string",
"\n",
"if",
"gIssueEvent",
".",
"Assignee",
"!=",
"nil",
"{",
"assignee",
"=",
"gIssueEvent",
".",
"Assignee",
".",
"Login",
"\n",
"}",
"\n",
"var",
"actor",
"*",
"string",
"\n",
"if",
"gIssueEvent",
".",
"Actor",
"!=",
"nil",
"{",
"actor",
"=",
"gIssueEvent",
".",
"Actor",
".",
"Login",
"\n",
"}",
"\n\n",
"return",
"&",
"sql",
".",
"IssueEvent",
"{",
"ID",
":",
"itoa",
"(",
"*",
"gIssueEvent",
".",
"ID",
")",
",",
"Label",
":",
"<mask>",
",",
"Event",
":",
"*",
"gIssueEvent",
".",
"Event",
",",
"EventCreatedAt",
":",
"*",
"gIssueEvent",
".",
"CreatedAt",
",",
"IssueID",
":",
"strconv",
".",
"Itoa",
"(",
"issueID",
")",
",",
"Assignee",
":",
"assignee",
",",
"Actor",
":",
"actor",
",",
"Repository",
":",
"strings",
".",
"ToLower",
"(",
"repository",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] |
23,335 | all-23336 | [
"TrackAnonymous",
"sends",
"a",
"single",
"event",
"to",
"Customer",
".",
"io",
"for",
"the",
"anonymous",
"user"
] | [
"func",
"(",
"c",
"*",
"CustomerIO",
")",
"TrackAnonymous",
"(",
"eventName",
"string",
",",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"body",
":=",
"<mask>",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"eventName",
",",
"\"",
"\"",
":",
"data",
"}",
"\n",
"j",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"body",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"status",
",",
"responseBody",
",",
"err",
":=",
"c",
".",
"request",
"(",
"\"",
"\"",
",",
"c",
".",
"anonURL",
"(",
")",
",",
"j",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"else",
"if",
"status",
"!=",
"200",
"{",
"return",
"&",
"CustomerIOError",
"{",
"status",
",",
"c",
".",
"anonURL",
"(",
")",
",",
"responseBody",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
23,336 | all-23337 | [
"NewLease",
"wraps",
"a",
"Lease",
"interface",
"to",
"filter",
"for",
"only",
"keys",
"with",
"a",
"prefix",
"and",
"remove",
"that",
"prefix",
"when",
"fetching",
"attached",
"keys",
"through",
"TimeToLive",
"."
] | [
"func",
"NewLease",
"(",
"l",
"clientv3",
".",
"Lease",
",",
"prefix",
"string",
")",
"clientv3",
".",
"Lease",
"{",
"return",
"&",
"leasePrefix",
"{",
"l",
",",
"[",
"]",
"byte",
"(",
"<mask>",
")",
"}",
"\n",
"}"
] |
23,337 | all-23338 | [
"DeepCopyInto",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"writing",
"into",
"out",
".",
"in",
"must",
"be",
"non",
"-",
"nil",
"."
] | [
"func",
"(",
"in",
"*",
"Refs",
")",
"DeepCopyInto",
"(",
"out",
"*",
"Refs",
")",
"{",
"*",
"out",
"=",
"*",
"in",
"\n",
"if",
"in",
".",
"Pulls",
"!=",
"nil",
"{",
"in",
",",
"out",
":=",
"&",
"<mask>",
".",
"Pulls",
",",
"&",
"out",
".",
"Pulls",
"\n",
"*",
"out",
"=",
"make",
"(",
"[",
"]",
"Pull",
",",
"len",
"(",
"*",
"in",
")",
")",
"\n",
"copy",
"(",
"*",
"out",
",",
"*",
"in",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
23,338 | all-23339 | [
"Start",
"all",
"the",
"tasks",
"in",
"the",
"group",
"."
] | [
"func",
"(",
"g",
"*",
"Group",
")",
"Start",
"(",
")",
"{",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n",
"ctx",
",",
"g",
".",
"cancel",
"=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n",
"g",
".",
"wg",
".",
"Add",
"(",
"len",
"(",
"g",
".",
"tasks",
")",
")",
"\n\n",
"g",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"g",
".",
"running",
"==",
"nil",
"{",
"g",
".",
"running",
"=",
"make",
"(",
"map",
"[",
"int",
"]",
"bool",
")",
"\n",
"}",
"\n",
"g",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"i",
":=",
"range",
"g",
".",
"tasks",
"{",
"g",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"g",
".",
"running",
"[",
"i",
"]",
"{",
"g",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"g",
".",
"running",
"[",
"i",
"]",
"=",
"true",
"\n",
"task",
":=",
"g",
".",
"tasks",
"[",
"i",
"]",
"// Local variable for the closure below.",
"\n",
"g",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"<mask>",
"func",
"(",
"i",
"int",
")",
"{",
"task",
".",
"loop",
"(",
"ctx",
")",
"\n",
"g",
".",
"wg",
".",
"Done",
"(",
")",
"\n\n",
"g",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"g",
".",
"running",
"[",
"i",
"]",
"=",
"false",
"\n",
"g",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"}",
"(",
"i",
")",
"\n",
"}",
"\n",
"}"
] |
23,339 | all-23340 | [
"GetFacet",
"returns",
"the",
"Facet",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"a",
"*",
"ApmOrLogQueryGroupBy",
")",
"GetFacet",
"(",
")",
"<mask>",
"{",
"if",
"a",
"==",
"nil",
"||",
"a",
".",
"Facet",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"a",
".",
"Facet",
"\n",
"}"
] |
23,340 | all-23341 | [
"InsertBefore",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_list_store_insert_before",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"ListStore",
")",
"InsertBefore",
"(",
"sibling",
"*",
"TreeIter",
")",
"*",
"TreeIter",
"{",
"<mask>",
"ti",
"C",
".",
"GtkTreeIter",
"\n",
"C",
".",
"gtk_list_store_insert_before",
"(",
"v",
".",
"native",
"(",
")",
",",
"&",
"ti",
",",
"sibling",
".",
"native",
"(",
")",
")",
"\n",
"iter",
":=",
"&",
"TreeIter",
"{",
"ti",
"}",
"\n",
"return",
"iter",
"\n",
"}"
] |
23,341 | all-23342 | [
"RemoveSvcAcknowledgement",
"creates",
"a",
"new",
"REMOVE_SVC_ACKNOWLEDGEMENT",
"Nagios",
"command",
".",
"This",
"removes",
"the",
"problem",
"acknowledgement",
"for",
"a",
"particular",
"service",
".",
"Once",
"the",
"acknowledgement",
"has",
"been",
"removed",
"notifications",
"can",
"once",
"again",
"be",
"sent",
"out",
"for",
"the",
"given",
"service",
"."
] | [
"func",
"RemoveSvcAcknowledgement",
"(",
"host_name",
"<mask>",
",",
"service_description",
"string",
",",
")",
"*",
"livestatus",
".",
"Command",
"{",
"return",
"livestatus",
".",
"NewCommand",
"(",
"\"",
"\"",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"host_name",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"service_description",
")",
",",
")",
"\n",
"}"
] |
23,342 | all-23343 | [
"WriteString",
"writes",
"string",
"data",
"into",
"the",
"response",
"object",
"."
] | [
"func",
"(",
"ctx",
"*",
"Cotex",
")",
"WriteString",
"(",
"<mask>",
"string",
")",
"{",
"ctx",
".",
"ResponseWriter",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"content",
")",
")",
"\n",
"}"
] |
23,343 | all-23344 | [
"SetHeaders",
"sets",
"the",
"message",
"headers",
"."
] | [
"func",
"(",
"m",
"*",
"Message",
")",
"SetHeaders",
"(",
"h",
"<mask>",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"h",
"{",
"m",
".",
"SetHeader",
"(",
"k",
",",
"v",
"...",
")",
"\n",
"}",
"\n",
"}"
] |
23,344 | all-23345 | [
"Equals",
"returns",
"true",
"if",
"other",
"is",
"equivalent",
"to",
"aid"
] | [
"func",
"(",
"aid",
"*",
"AccountId",
")",
"Equals",
"(",
"other",
"AccountId",
")",
"bool",
"{",
"if",
"aid",
".",
"<mask>",
"!=",
"other",
".",
"Type",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"switch",
"aid",
".",
"Type",
"{",
"case",
"CryptoKeyTypeKeyTypeEd25519",
":",
"l",
":=",
"aid",
".",
"MustEd25519",
"(",
")",
"\n",
"r",
":=",
"other",
".",
"MustEd25519",
"(",
")",
"\n",
"return",
"l",
"==",
"r",
"\n",
"default",
":",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"aid",
".",
"Type",
")",
")",
"\n",
"}",
"\n",
"}"
] |
23,345 | all-23346 | [
"Encode",
"encodes",
"given",
"byte",
"array",
"to",
"base64url",
"string"
] | [
"func",
"Encode",
"(",
"data",
"[",
"]",
"byte",
")",
"string",
"{",
"result",
":=",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"data",
")",
"\n",
"<mask>",
"=",
"strings",
".",
"Replace",
"(",
"result",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"// 62nd char of encoding",
"\n",
"result",
"=",
"strings",
".",
"Replace",
"(",
"result",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"// 63rd char of encoding",
"\n",
"result",
"=",
"strings",
".",
"Replace",
"(",
"result",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"// Remove any trailing '='s",
"\n",
"return",
"result",
"\n",
"}"
] |
23,346 | all-23347 | [
"render",
"multiple",
"sets",
"of",
"primitives",
"from",
"array",
"data",
"taking",
"parameters",
"from",
"memory"
] | [
"func",
"MultiDrawArraysIndirect",
"(",
"mode",
"uint32",
",",
"indirect",
"unsafe",
".",
"Pointer",
",",
"drawcount",
"int32",
",",
"stride",
"int32",
")",
"{",
"C",
".",
"glowMultiDrawArraysIndirect",
"(",
"gpMultiDrawArraysIndirect",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"<mask>",
")",
",",
"indirect",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"drawcount",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"stride",
")",
")",
"\n",
"}"
] |
23,347 | all-23348 | [
"Encode",
"image",
".",
"Image",
"with",
"Mapniks",
"image",
"encoder",
".",
"This",
"is",
"optimized",
"for",
"*",
"image",
".",
"NRGBA",
"or",
"*",
"image",
".",
"RGBA",
"."
] | [
"func",
"Encode",
"(",
"img",
"image",
".",
"Image",
",",
"<mask>",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"tmp",
":=",
"toNRGBA",
"(",
"img",
")",
"\n",
"i",
":=",
"C",
".",
"mapnik_image_from_raw",
"(",
"(",
"*",
"C",
".",
"uint8_t",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"tmp",
".",
"Pix",
"[",
"0",
"]",
")",
")",
",",
"C",
".",
"int",
"(",
"tmp",
".",
"Bounds",
"(",
")",
".",
"Dx",
"(",
")",
")",
",",
"C",
".",
"int",
"(",
"tmp",
".",
"Bounds",
"(",
")",
".",
"Dy",
"(",
")",
")",
",",
")",
"\n",
"defer",
"C",
".",
"mapnik_image_free",
"(",
"i",
")",
"\n\n",
"cformat",
":=",
"C",
".",
"CString",
"(",
"format",
")",
"\n",
"b",
":=",
"C",
".",
"mapnik_image_to_blob",
"(",
"i",
",",
"cformat",
")",
"\n",
"if",
"b",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
"+",
"C",
".",
"GoString",
"(",
"C",
".",
"mapnik_image_last_error",
"(",
"i",
")",
")",
")",
"\n",
"}",
"\n",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cformat",
")",
")",
"\n",
"defer",
"C",
".",
"mapnik_image_blob_free",
"(",
"b",
")",
"\n",
"return",
"C",
".",
"GoBytes",
"(",
"unsafe",
".",
"Pointer",
"(",
"b",
".",
"ptr",
")",
",",
"C",
".",
"int",
"(",
"b",
".",
"len",
")",
")",
",",
"nil",
"\n",
"}"
] |
23,348 | all-23349 | [
"Do",
"executes",
"CSS",
".",
"setStyleTexts",
"against",
"the",
"provided",
"context",
".",
"returns",
":",
"styles",
"-",
"The",
"resulting",
"styles",
"after",
"modification",
"."
] | [
"func",
"(",
"p",
"*",
"SetStyleTextsParams",
")",
"Do",
"(",
"ctx",
"<mask>",
".",
"Context",
")",
"(",
"styles",
"[",
"]",
"*",
"Style",
",",
"err",
"error",
")",
"{",
"// execute",
"var",
"res",
"SetStyleTextsReturns",
"\n",
"err",
"=",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandSetStyleTexts",
",",
"p",
",",
"&",
"res",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"res",
".",
"Styles",
",",
"nil",
"\n",
"}"
] |
23,349 | all-23350 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"SetFileInputFilesParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoDom7",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
23,350 | all-23351 | [
"IssuingCertificateURL",
"is",
"an",
"Option",
"for",
"setting",
"the",
"identity",
"s",
"certificate",
"s",
"IssuingCertificateURL",
"."
] | [
"func",
"IssuingCertificateURL",
"(",
"<mask>",
"...",
"string",
")",
"Option",
"{",
"return",
"func",
"(",
"c",
"*",
"configuration",
")",
"{",
"c",
".",
"issuingCertificateURL",
"=",
"append",
"(",
"c",
".",
"issuingCertificateURL",
",",
"value",
"...",
")",
"\n",
"}",
"\n",
"}"
] |
23,351 | all-23352 | [
"NewLeaderStats",
"generates",
"a",
"new",
"LeaderStats",
"with",
"the",
"given",
"id",
"as",
"leader"
] | [
"func",
"NewLeaderStats",
"(",
"id",
"string",
")",
"*",
"LeaderStats",
"{",
"return",
"&",
"LeaderStats",
"{",
"leaderStats",
":",
"leaderStats",
"{",
"Leader",
":",
"<mask>",
",",
"Followers",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"FollowerStats",
")",
",",
"}",
",",
"}",
"\n",
"}"
] |
23,352 | all-23353 | [
"Template",
"renders",
"the",
"named",
"files",
"using",
"the",
"specified",
"content",
"type",
"and",
"the",
"github",
".",
"com",
"/",
"gobuffalo",
"/",
"plush",
"package",
"for",
"templating",
".",
"If",
"more",
"than",
"1",
"file",
"is",
"provided",
"the",
"second",
"file",
"will",
"be",
"considered",
"a",
"layout",
"file",
"and",
"the",
"first",
"file",
"will",
"be",
"the",
"content",
"file",
"which",
"will",
"be",
"placed",
"into",
"the",
"layout",
"using",
"{{",
"yield",
"}}",
"."
] | [
"func",
"Template",
"(",
"c",
"string",
",",
"<mask>",
"...",
"string",
")",
"Renderer",
"{",
"e",
":=",
"New",
"(",
"Options",
"{",
"}",
")",
"\n",
"return",
"e",
".",
"Template",
"(",
"c",
",",
"names",
"...",
")",
"\n",
"}"
] |
23,353 | all-23354 | [
"void",
"pango_cairo_show_layout",
"(",
"cairo_t",
"*",
"cr",
"PangoLayout",
"*",
"layout",
")",
";"
] | [
"func",
"CairoShowLayout",
"(",
"cr",
"*",
"cairo",
".",
"Context",
",",
"<mask>",
"*",
"Layout",
")",
"{",
"C",
".",
"pango_cairo_show_layout",
"(",
"cairo_context",
"(",
"cr",
")",
",",
"layout",
".",
"native",
"(",
")",
")",
"\n",
"}"
] |
23,354 | all-23355 | [
"title",
":",
"node",
"healing",
"info",
"path",
":",
"/",
"healing",
"/",
"node",
"method",
":",
"GET",
"produce",
":",
"application",
"/",
"json",
"responses",
":",
"200",
":",
"Ok",
"401",
":",
"Unauthorized"
] | [
"func",
"nodeHealingRead",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"t",
"auth",
".",
"Token",
")",
"error",
"{",
"pools",
",",
"err",
":=",
"permission",
".",
"ListContextValues",
"(",
"t",
",",
"permission",
".",
"PermHealingRead",
",",
"true",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"configMap",
",",
"err",
":=",
"healer",
".",
"GetConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"pools",
")",
">",
"0",
"{",
"allowedPoolSet",
":=",
"<mask>",
"[",
"string",
"]",
"struct",
"{",
"}",
"{",
"}",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"pools",
"{",
"allowedPoolSet",
"[",
"p",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"}",
"\n",
"for",
"k",
":=",
"range",
"configMap",
"{",
"if",
"k",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"_",
",",
"ok",
":=",
"allowedPoolSet",
"[",
"k",
"]",
";",
"!",
"ok",
"{",
"delete",
"(",
"configMap",
",",
"k",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"json",
".",
"NewEncoder",
"(",
"w",
")",
".",
"Encode",
"(",
"configMap",
")",
"\n",
"}"
] |
23,355 | all-23356 | [
"ServePProf",
"sets",
"up",
"a",
"handler",
"for",
"pprof",
"debug",
"endpoints",
"and",
"starts",
"a",
"server",
"for",
"them",
"asynchronously",
".",
"The",
"contents",
"of",
"this",
"function",
"are",
"identical",
"to",
"what",
"the",
"net",
"/",
"http",
"/",
"pprof",
"package",
"does",
"on",
"import",
"for",
"the",
"simple",
"case",
"where",
"the",
"default",
"mux",
"is",
"to",
"be",
"used",
"but",
"with",
"a",
"custom",
"mux",
"to",
"ensure",
"we",
"don",
"t",
"serve",
"this",
"data",
"from",
"an",
"exposed",
"port",
"."
] | [
"func",
"ServePProf",
"(",
")",
"{",
"pprofMux",
":=",
"<mask>",
".",
"NewServeMux",
"(",
")",
"\n",
"pprofMux",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"pprof",
".",
"Index",
")",
"\n",
"pprofMux",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"pprof",
".",
"Cmdline",
")",
"\n",
"pprofMux",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"pprof",
".",
"Profile",
")",
"\n",
"pprofMux",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"pprof",
".",
"Symbol",
")",
"\n",
"pprofMux",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"pprof",
".",
"Trace",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"logrus",
".",
"WithError",
"(",
"http",
".",
"ListenAndServe",
"(",
"\"",
"\"",
",",
"pprofMux",
")",
")",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"(",
")",
"\n",
"}"
] |
23,356 | all-23357 | [
"Set",
"is",
"required",
"for",
"kingpin",
"interfaces",
"to",
"allow",
"command",
"line",
"params",
"to",
"be",
"set",
"to",
"our",
"map",
"datatype"
] | [
"func",
"(",
"o",
"*",
"ListUint32Option",
")",
"<mask>",
"(",
"value",
"string",
")",
"error",
"{",
"val",
":=",
"Uint32Option",
"{",
"}",
"\n",
"val",
".",
"Set",
"(",
"value",
")",
"\n",
"*",
"o",
"=",
"append",
"(",
"*",
"o",
",",
"val",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
23,357 | all-23358 | [
"LoadRulesFromFile",
"loads",
"rules",
"from",
"a",
"YAML",
"file",
"."
] | [
"func",
"(",
"s",
"*",
"Seekret",
")",
"LoadRulesFromFile",
"(",
"file",
"string",
",",
"defaulEnabled",
"bool",
")",
"error",
"{",
"var",
"ruleYamlMap",
"map",
"[",
"string",
"]",
"ruleYaml",
"\n\n",
"if",
"file",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"filename",
",",
"_",
":=",
"filepath",
".",
"Abs",
"(",
"file",
")",
"\n\n",
"ruleBase",
":=",
"filepath",
".",
"<mask>",
"(",
"filename",
")",
"\n",
"if",
"filepath",
".",
"Ext",
"(",
"ruleBase",
")",
"==",
"\"",
"\"",
"{",
"ruleBase",
"=",
"ruleBase",
"[",
"0",
":",
"len",
"(",
"ruleBase",
")",
"-",
"5",
"]",
"\n",
"}",
"\n\n",
"yamlData",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"yaml",
".",
"Unmarshal",
"(",
"yamlData",
",",
"&",
"ruleYamlMap",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"ruleYamlMap",
"{",
"rule",
",",
"err",
":=",
"models",
".",
"NewRule",
"(",
"ruleBase",
"+",
"\"",
"\"",
"+",
"k",
",",
"v",
".",
"Match",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"e",
":=",
"range",
"v",
".",
"Unmatch",
"{",
"rule",
".",
"AddUnmatch",
"(",
"e",
")",
"\n",
"}",
"\n",
"s",
".",
"AddRule",
"(",
"*",
"rule",
",",
"defaulEnabled",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
23,358 | all-23359 | [
"GetTriggeringValueOk",
"returns",
"a",
"tuple",
"with",
"the",
"TriggeringValue",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"g",
"*",
"GroupData",
")",
"GetTriggeringValueOk",
"(",
")",
"(",
"TriggeringValue",
",",
"bool",
")",
"{",
"if",
"g",
"==",
"nil",
"||",
"g",
".",
"TriggeringValue",
"==",
"nil",
"{",
"return",
"TriggeringValue",
"{",
"}",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"g",
".",
"TriggeringValue",
",",
"true",
"\n",
"}"
] |
23,359 | all-23360 | [
"RestartNode",
"is",
"similar",
"to",
"StartNode",
"but",
"does",
"not",
"take",
"a",
"list",
"of",
"peers",
".",
"The",
"current",
"membership",
"of",
"the",
"cluster",
"will",
"be",
"restored",
"from",
"the",
"Storage",
".",
"If",
"the",
"caller",
"has",
"an",
"existing",
"state",
"machine",
"pass",
"in",
"the",
"last",
"log",
"index",
"that",
"has",
"been",
"applied",
"to",
"it",
";",
"otherwise",
"use",
"zero",
"."
] | [
"func",
"RestartNode",
"(",
"c",
"*",
"Config",
")",
"Node",
"{",
"r",
":=",
"newRaft",
"(",
"c",
")",
"\n\n",
"n",
":=",
"newNode",
"(",
")",
"\n",
"n",
".",
"logger",
"=",
"c",
".",
"Logger",
"\n",
"<mask>",
"n",
".",
"run",
"(",
"r",
")",
"\n",
"return",
"&",
"n",
"\n",
"}"
] |
23,360 | all-23361 | [
"MustTxSet",
"retrieves",
"the",
"TxSet",
"value",
"from",
"the",
"union",
"panicing",
"if",
"the",
"value",
"is",
"not",
"set",
"."
] | [
"func",
"(",
"u",
"StellarMessage",
")",
"MustTxSet",
"(",
")",
"TransactionSet",
"{",
"val",
",",
"ok",
":=",
"u",
".",
"GetTxSet",
"(",
")",
"\n\n",
"if",
"!",
"<mask>",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"val",
"\n",
"}"
] |
23,361 | all-23362 | [
"NewDialer",
"creates",
"a",
"new",
"Dialer",
"object",
".",
"Before",
"any",
"calls",
"to",
"Dial",
"are",
"made",
"underlying",
"dialers",
"must",
"be",
"added",
"with",
"AddDialer",
"and",
"Protector",
"(",
"if",
"any",
")",
"must",
"be",
"set",
"."
] | [
"func",
"NewDialer",
"(",
"p",
"peer",
".",
"ID",
",",
"pk",
"ci",
".",
"PrivKey",
",",
"wrap",
"ConnWrapper",
")",
"*",
"Dialer",
"{",
"return",
"&",
"Dialer",
"{",
"LocalPeer",
":",
"p",
",",
"PrivateKey",
":",
"pk",
",",
"Wrapper",
":",
"<mask>",
",",
"fallback",
":",
"new",
"(",
"transport",
".",
"FallbackDialer",
")",
",",
"}",
"\n",
"}"
] |
23,362 | all-23363 | [
"GetTextAlign",
"returns",
"the",
"TextAlign",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"a",
"*",
"AlertValueDefinition",
")",
"GetTextAlign",
"(",
")",
"<mask>",
"{",
"if",
"a",
"==",
"nil",
"||",
"a",
".",
"TextAlign",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"a",
".",
"TextAlign",
"\n",
"}"
] |
23,363 | all-23364 | [
"Implements",
"Err"
] | [
"func",
"(",
"e",
"*",
"err",
")",
"Info",
"(",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"if",
"e",
".",
"<mask>",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"e",
".",
"info",
"[",
"key",
"]",
"\n",
"}"
] |
23,364 | all-23365 | [
"flattenVMwareUplinkLacpPolicy",
"reads",
"various",
"fields",
"from",
"a",
"VMwareUplinkLacpPolicy",
"into",
"the",
"passed",
"in",
"ResourceData",
"."
] | [
"func",
"flattenVMwareUplinkLacpPolicy",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"obj",
"*",
"<mask>",
".",
"VMwareUplinkLacpPolicy",
")",
"error",
"{",
"if",
"obj",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"structure",
".",
"SetBoolPolicy",
"(",
"d",
",",
"\"",
"\"",
",",
"obj",
".",
"Enable",
")",
"\n",
"structure",
".",
"SetStringPolicy",
"(",
"d",
",",
"\"",
"\"",
",",
"obj",
".",
"Mode",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
23,365 | all-23366 | [
"GetCachedSecretValue",
"retrieves",
"the",
"secret",
"value",
"from",
"secretData",
"field"
] | [
"func",
"(",
"secret",
"*",
"SSMSecretResource",
")",
"GetCachedSecretValue",
"(",
"secretKey",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"secret",
".",
"<mask>",
".",
"RLock",
"(",
")",
"\n",
"defer",
"secret",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"s",
",",
"ok",
":=",
"secret",
".",
"secretData",
"[",
"secretKey",
"]",
"\n",
"return",
"s",
",",
"ok",
"\n",
"}"
] |
23,366 | all-23367 | [
"expandDiskSettings",
"sets",
"appropriate",
"fields",
"on",
"an",
"existing",
"disk",
"-",
"this",
"is",
"used",
"during",
"Create",
"and",
"Update",
"to",
"set",
"attributes",
"to",
"those",
"found",
"in",
"configuration",
"."
] | [
"func",
"(",
"r",
"*",
"DiskSubresource",
")",
"expandDiskSettings",
"(",
"disk",
"*",
"types",
".",
"VirtualDisk",
")",
"error",
"{",
"// Backing settings",
"b",
":=",
"disk",
".",
"Backing",
".",
"(",
"*",
"types",
".",
"VirtualDiskFlatVer2BackingInfo",
")",
"\n",
"b",
".",
"DiskMode",
"=",
"r",
".",
"GetWithRestart",
"(",
"\"",
"\"",
")",
".",
"(",
"string",
")",
"\n",
"b",
".",
"WriteThrough",
"=",
"structure",
".",
"BoolPtr",
"(",
"r",
".",
"GetWithRestart",
"(",
"\"",
"\"",
")",
".",
"(",
"bool",
")",
")",
"\n\n",
"// Only use disk_sharing if we are on vSphere 6.0 and higher",
"version",
":=",
"viapi",
".",
"ParseVersionFromClient",
"(",
"r",
".",
"client",
")",
"\n",
"if",
"version",
".",
"Newer",
"(",
"viapi",
".",
"VSphereVersion",
"{",
"Product",
":",
"version",
".",
"Product",
",",
"Major",
":",
"6",
"}",
")",
"{",
"b",
".",
"Sharing",
"=",
"r",
".",
"GetWithRestart",
"(",
"\"",
"\"",
")",
".",
"(",
"string",
")",
"\n",
"}",
"\n\n",
"// This settings are only set for internal disks",
"if",
"!",
"r",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"bool",
")",
"{",
"var",
"err",
"error",
"\n",
"var",
"v",
"interface",
"{",
"}",
"\n",
"if",
"v",
",",
"err",
"=",
"r",
".",
"GetWithVeto",
"(",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"b",
".",
"ThinProvisioned",
"=",
"structure",
".",
"BoolPtr",
"(",
"v",
".",
"(",
"bool",
")",
")",
"\n\n",
"if",
"v",
",",
"err",
"=",
"r",
".",
"GetWithVeto",
"(",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"b",
".",
"EagerlyScrub",
"=",
"structure",
".",
"BoolPtr",
"(",
"v",
".",
"(",
"bool",
")",
")",
"\n\n",
"// Disk settings",
"os",
",",
"ns",
":=",
"r",
".",
"GetChange",
"(",
"\"",
"\"",
")",
"\n",
"if",
"os",
".",
"(",
"int",
")",
">",
"ns",
".",
"(",
"int",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"disk",
".",
"CapacityInBytes",
"=",
"structure",
".",
"GiBToByte",
"(",
"ns",
".",
"(",
"int",
")",
")",
"\n",
"disk",
".",
"CapacityInKB",
"=",
"disk",
".",
"CapacityInBytes",
"/",
"1024",
"\n",
"}",
"\n\n",
"alloc",
":=",
"&",
"types",
".",
"StorageIOAllocationInfo",
"{",
"Limit",
":",
"structure",
".",
"Int64Ptr",
"(",
"int64",
"(",
"r",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"int",
")",
")",
")",
",",
"Reservation",
":",
"structure",
".",
"Int32Ptr",
"(",
"int32",
"(",
"r",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"int",
")",
")",
")",
",",
"Shares",
":",
"&",
"<mask>",
".",
"SharesInfo",
"{",
"Shares",
":",
"int32",
"(",
"r",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"int",
")",
")",
",",
"Level",
":",
"types",
".",
"SharesLevel",
"(",
"r",
".",
"Get",
"(",
"\"",
"\"",
")",
".",
"(",
"string",
")",
")",
",",
"}",
",",
"}",
"\n",
"disk",
".",
"StorageIOAllocation",
"=",
"alloc",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
23,367 | all-23368 | [
"SetTooltipText",
"is",
"a",
"wrapper",
"around",
"gtk_tool_item_set_tooltip_text",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"ToolItem",
")",
"SetTooltipText",
"(",
"text",
"string",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"text",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"C",
".",
"gtk_tool_item_set_tooltip_text",
"(",
"v",
".",
"native",
"(",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"}"
] |
23,368 | all-23369 | [
"Return",
"the",
"code",
"for",
"a",
"dest",
"function",
"to",
"be",
"passed",
"as",
"parameter",
"to",
"query",
".",
"SelectObjects",
"in",
"order",
"to",
"scan",
"a",
"single",
"row",
"."
] | [
"func",
"destFunc",
"(",
"slice",
"string",
",",
"typ",
"string",
",",
"fields",
"[",
"]",
"*",
"Field",
")",
"string",
"{",
"f",
":=",
"fmt",
".",
"Sprintf",
"(",
"`func(i int) []interface{} {\n %s = append(%s, %s{})\n return []interface{}{\n`",
",",
"slice",
",",
"slice",
",",
"typ",
")",
"\n\n",
"for",
"_",
",",
"<mask>",
":=",
"range",
"fields",
"{",
"f",
"+=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\"",
",",
"slice",
",",
"field",
".",
"Name",
")",
"\n",
"}",
"\n\n",
"f",
"+=",
"\"",
"\\n",
"\"",
"\n",
"f",
"+=",
"\"",
"\"",
"\n\n",
"return",
"f",
"\n",
"}"
] |
23,369 | all-23370 | [
"Set",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockCache",
")",
"<mask>",
"(",
"arg0",
"string",
",",
"arg1",
"async",
".",
"Value",
")",
"{",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
",",
"arg1",
")",
"\n",
"}"
] |
23,370 | all-23371 | [
"Header",
"sets",
"the",
"given",
"header",
"."
] | [
"func",
"(",
"r",
"*",
"RequestBuilder",
")",
"<mask>",
"(",
"name",
",",
"value",
"string",
")",
"*",
"RequestBuilder",
"{",
"if",
"r",
".",
"headers",
"==",
"nil",
"{",
"r",
".",
"headers",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"1",
")",
"\n",
"}",
"\n",
"r",
".",
"headers",
"[",
"name",
"]",
"=",
"value",
"\n",
"return",
"r",
"\n",
"}"
] |
23,371 | all-23372 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"SearchInResourceParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage16",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
23,372 | all-23373 | [
"offset",
"returns",
"the",
"time",
"until",
"the",
"next",
"scrape",
"cycle",
"for",
"the",
"target",
".",
"It",
"includes",
"the",
"global",
"server",
"jitterSeed",
"for",
"scrapes",
"from",
"multiple",
"Prometheus",
"to",
"try",
"to",
"be",
"at",
"different",
"times",
"."
] | [
"func",
"(",
"t",
"*",
"Target",
")",
"offset",
"(",
"interval",
"time",
".",
"Duration",
",",
"jitterSeed",
"uint64",
")",
"time",
".",
"Duration",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
"\n\n",
"// Base is a pinned to absolute time, no matter how often offset is called.",
"var",
"(",
"base",
"=",
"int64",
"(",
"interval",
")",
"-",
"now",
"%",
"int64",
"(",
"interval",
")",
"\n",
"offset",
"=",
"(",
"t",
".",
"hash",
"(",
")",
"^",
"jitterSeed",
")",
"%",
"uint64",
"(",
"interval",
")",
"\n",
"next",
"=",
"base",
"+",
"int64",
"(",
"offset",
")",
"\n",
")",
"\n\n",
"if",
"<mask>",
">",
"int64",
"(",
"interval",
")",
"{",
"next",
"-=",
"int64",
"(",
"interval",
")",
"\n",
"}",
"\n",
"return",
"time",
".",
"Duration",
"(",
"next",
")",
"\n",
"}"
] |
23,373 | all-23374 | [
"SetHash",
"sets",
"URI",
"hash",
"."
] | [
"func",
"(",
"u",
"*",
"URI",
")",
"SetHash",
"(",
"<mask>",
"string",
")",
"{",
"u",
".",
"hash",
"=",
"append",
"(",
"u",
".",
"hash",
"[",
":",
"0",
"]",
",",
"hash",
"...",
")",
"\n",
"}"
] |
23,374 | all-23375 | [
"CheckMenuItemNewWithLabel",
"is",
"a",
"wrapper",
"around",
"gtk_check_menu_item_new_with_label",
"()",
"."
] | [
"func",
"CheckMenuItemNewWithLabel",
"(",
"<mask>",
"string",
")",
"(",
"*",
"CheckMenuItem",
",",
"error",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"label",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"c",
":=",
"C",
".",
"gtk_check_menu_item_new_with_label",
"(",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"obj",
":=",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
"\n",
"return",
"wrapCheckMenuItem",
"(",
"obj",
")",
",",
"nil",
"\n",
"}"
] |
23,375 | all-23376 | [
"URL",
"returns",
"a",
"URL",
"to",
"the",
"action",
"given",
"a",
"set",
"of",
"values",
"that",
"can",
"be",
"used",
"to",
"substitute",
"the",
"action",
"paths",
"pattern",
"variables",
".",
"This",
"method",
"tries",
"to",
"use",
"a",
"many",
"variables",
"as",
"possible",
"so",
"that",
"the",
"longest",
"path",
"gets",
"used",
".",
"So",
"if",
"for",
"example",
"an",
"action",
"has",
"the",
"patterns",
"/",
"instances",
"/",
":",
"id",
"and",
"/",
"clouds",
"/",
":",
"cloud_id",
"/",
"instances",
"/",
":",
"id",
"and",
"both",
"the",
":",
"cloud_id",
"and",
":",
"id",
"variable",
"values",
"are",
"given",
"as",
"parameter",
"the",
"method",
"returns",
"a",
"URL",
"built",
"from",
"substituting",
"the",
"values",
"of",
"the",
"later",
"(",
"longer",
")",
"path",
".",
"The",
"method",
"returns",
"an",
"error",
"in",
"case",
"no",
"path",
"pattern",
"can",
"have",
"all",
"its",
"variables",
"subsituted",
"."
] | [
"func",
"(",
"a",
"*",
"Action",
")",
"URL",
"(",
"vars",
"[",
"]",
"*",
"PathVariable",
")",
"(",
"*",
"ActionPath",
",",
"error",
")",
"{",
"candidates",
":=",
"make",
"(",
"[",
"]",
"*",
"ActionPath",
",",
"len",
"(",
"a",
".",
"PathPatterns",
")",
")",
"\n",
"allMissing",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"j",
":=",
"0",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"a",
".",
"PathPatterns",
"{",
"path",
",",
"names",
":=",
"p",
".",
"Substitute",
"(",
"vars",
")",
"\n",
"if",
"path",
"==",
"\"",
"\"",
"{",
"allMissing",
"=",
"<mask>",
"(",
"allMissing",
",",
"names",
"...",
")",
"\n",
"}",
"else",
"{",
"candidates",
"[",
"j",
"]",
"=",
"&",
"ActionPath",
"{",
"path",
",",
"p",
".",
"HTTPMethod",
",",
"len",
"(",
"names",
")",
"}",
"\n",
"j",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"j",
"==",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"allMissing",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"candidates",
"=",
"candidates",
"[",
":",
"j",
"]",
"\n",
"sort",
".",
"Sort",
"(",
"ByWeight",
"(",
"candidates",
")",
")",
"\n",
"return",
"candidates",
"[",
"0",
"]",
",",
"nil",
"\n",
"}"
] |
23,376 | all-23377 | [
"handleUpdate",
":",
"Handler",
"for",
"/",
"update",
"Method",
":",
"POST",
"URLParams",
"Required",
":",
"name",
"=",
"[",
"string",
"]",
":",
"name",
"of",
"target",
"resource",
"Required",
":",
"owner",
"=",
"[",
"string",
"]",
":",
"owner",
"of",
"the",
"resource",
"Required",
":",
"state",
"=",
"[",
"string",
"]",
":",
"current",
"state",
"of",
"the",
"resource",
"Optional",
":",
"userData",
"=",
"[",
"common",
".",
"UserData",
"]",
":",
"user",
"data",
"id",
"to",
"update"
] | [
"func",
"handleUpdate",
"(",
"r",
"*",
"ranch",
".",
"Ranch",
")",
"http",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"res",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"logrus",
".",
"WithField",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Infof",
"(",
"\"",
"\"",
",",
"req",
".",
"RemoteAddr",
")",
"\n\n",
"if",
"req",
".",
"Method",
"!=",
"http",
".",
"MethodPost",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"req",
".",
"Method",
")",
"\n",
"logrus",
".",
"Warning",
"(",
"msg",
")",
"\n",
"http",
".",
"Error",
"(",
"res",
",",
"msg",
",",
"http",
".",
"StatusMethodNotAllowed",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"name",
":=",
"req",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"owner",
":=",
"req",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"state",
":=",
"req",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"name",
"==",
"\"",
"\"",
"||",
"owner",
"==",
"\"",
"\"",
"||",
"state",
"==",
"\"",
"\"",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"name",
",",
"owner",
",",
"state",
")",
"\n",
"logrus",
".",
"Warning",
"(",
"msg",
")",
"\n",
"http",
".",
"<mask>",
"(",
"res",
",",
"msg",
",",
"http",
".",
"StatusBadRequest",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"var",
"userData",
"common",
".",
"UserData",
"\n\n",
"if",
"req",
".",
"Body",
"!=",
"nil",
"{",
"err",
":=",
"json",
".",
"NewDecoder",
"(",
"req",
".",
"Body",
")",
".",
"Decode",
"(",
"&",
"userData",
")",
"\n",
"switch",
"{",
"case",
"err",
"==",
"io",
".",
"EOF",
":",
"// empty body",
"case",
"err",
"!=",
"nil",
":",
"logrus",
".",
"WithError",
"(",
"err",
")",
".",
"Warning",
"(",
"\"",
"\"",
")",
"\n",
"http",
".",
"Error",
"(",
"res",
",",
"err",
".",
"Error",
"(",
")",
",",
"http",
".",
"StatusBadRequest",
")",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"r",
".",
"Update",
"(",
"name",
",",
"owner",
",",
"state",
",",
"&",
"userData",
")",
";",
"err",
"!=",
"nil",
"{",
"logrus",
".",
"WithError",
"(",
"err",
")",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"name",
",",
"state",
",",
"owner",
")",
"\n",
"http",
".",
"Error",
"(",
"res",
",",
"err",
".",
"Error",
"(",
")",
",",
"ErrorToStatus",
"(",
"err",
")",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"logrus",
".",
"Infof",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"}",
"\n",
"}"
] |
23,377 | all-23378 | [
"DumpStop",
"implements",
"gracefully",
"stop",
":",
"*",
"Start",
"writing",
"all",
"new",
"data",
"to",
"xlogs",
"*",
"Stop",
"cache",
"worker",
"*",
"Dump",
"all",
"cache",
"to",
"file",
"*",
"Stop",
"listeners",
"*",
"Close",
"xlogs",
"*",
"Exit",
"application"
] | [
"func",
"(",
"app",
"*",
"App",
")",
"DumpStop",
"(",
")",
"error",
"{",
"app",
".",
"Lock",
"(",
")",
"\n",
"defer",
"app",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"!",
"app",
".",
"Config",
".",
"Dump",
".",
"Enabled",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"app",
".",
"Persister",
"!=",
"nil",
"{",
"app",
".",
"Persister",
".",
"Stop",
"(",
")",
"\n",
"app",
".",
"Persister",
"=",
"nil",
"\n",
"}",
"\n\n",
"logger",
":=",
"zapwriter",
".",
"Logger",
"(",
"\"",
"\"",
")",
"\n\n",
"logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"filenamePostfix",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"os",
".",
"Getpid",
"(",
")",
",",
"time",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
")",
"\n",
"dumpFilename",
":=",
"path",
".",
"Join",
"(",
"app",
".",
"Config",
".",
"Dump",
".",
"Path",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"filenamePostfix",
")",
")",
"\n",
"xlogFilename",
":=",
"path",
".",
"Join",
"(",
"app",
".",
"Config",
".",
"Dump",
".",
"Path",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"filenamePostfix",
")",
")",
"\n\n",
"// start dumpers",
"logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"dumpFilename",
")",
")",
"\n",
"logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"xlogFilename",
")",
")",
"\n\n",
"// open dump file",
"dump",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"dumpFilename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"dumpWriter",
":=",
"bufio",
".",
"NewWriterSize",
"(",
"dump",
",",
"1048576",
")",
"// 1Mb",
"\n\n",
"// start input dumper",
"xlog",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"xlogFilename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"xlogWriter",
":=",
"&",
"SyncWriter",
"{",
"w",
":",
"bufio",
".",
"NewWriterSize",
"(",
"xlog",
",",
"4096",
")",
"}",
"// 4kb",
"\n\n",
"app",
".",
"Cache",
".",
"DivertToXlog",
"(",
"xlogWriter",
")",
"\n\n",
"// stop cache",
"dumpStart",
":=",
"<mask>",
".",
"Now",
"(",
")",
"\n",
"cacheSize",
":=",
"app",
".",
"Cache",
".",
"Size",
"(",
")",
"\n\n",
"// dump cache",
"err",
"=",
"app",
".",
"Cache",
".",
"DumpBinary",
"(",
"dumpWriter",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"Error",
"(",
"err",
")",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"Int",
"(",
"\"",
"\"",
",",
"int",
"(",
"cacheSize",
")",
")",
",",
"zap",
".",
"Duration",
"(",
"\"",
"\"",
",",
"time",
".",
"Since",
"(",
"dumpStart",
")",
")",
",",
")",
"\n\n",
"if",
"err",
"=",
"dumpWriter",
".",
"Flush",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"Error",
"(",
"err",
")",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"dump",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"Error",
"(",
"err",
")",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"// cache dump finished",
"logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"stopped",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"app",
".",
"stopListeners",
"(",
")",
"\n\n",
"if",
"err",
":=",
"xlogWriter",
".",
"Flush",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"Error",
"(",
"err",
")",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"xlog",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"Error",
"(",
"err",
")",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"close",
"(",
"stopped",
")",
"\n",
"}",
"(",
")",
"\n\n",
"select",
"{",
"case",
"<-",
"time",
".",
"After",
"(",
"5",
"*",
"time",
".",
"Second",
")",
":",
"logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"case",
"<-",
"stopped",
":",
"logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// logger.Info(\"stop all\")",
"// app.stopAll()",
"return",
"nil",
"\n",
"}"
] |
23,378 | all-23379 | [
"Printf",
"implements",
"fmt",
".",
"Printf",
"for",
"markdown"
] | [
"func",
"(",
"<mask>",
"*",
"markdown",
")",
"Printf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"md",
",",
"format",
",",
"args",
"...",
")",
"\n",
"}"
] |
23,379 | all-23380 | [
"setVState",
"sets",
"a",
"consistent",
"state",
"for",
"V",
"logging",
".",
"A",
"nil",
"value",
"for",
"modules",
"or",
"filepaths",
"will",
"result",
"in",
"that",
"filter",
"not",
"being",
"changed",
".",
"l",
".",
"mu",
"is",
"held",
"."
] | [
"func",
"(",
"l",
"*",
"Log",
")",
"setVState",
"(",
"verbosity",
"Level",
",",
"<mask>",
"[",
"]",
"modulePat",
",",
"filepaths",
"[",
"]",
"filepathPat",
",",
"setFilter",
"bool",
")",
"{",
"// Turn verbosity off so V will not fire while we are in transition.",
"l",
".",
"verbosity",
".",
"set",
"(",
"0",
")",
"\n",
"// Ditto for filter length.",
"atomic",
".",
"StoreInt32",
"(",
"&",
"l",
".",
"filterLength",
",",
"0",
")",
"\n\n",
"// Set the new filters and wipe the pc->Level map if the filter has changed.",
"nfilters",
":=",
"0",
"\n",
"if",
"setFilter",
"{",
"if",
"modules",
"!=",
"nil",
"{",
"l",
".",
"vmodule",
".",
"filter",
"=",
"modules",
"\n",
"}",
"\n",
"if",
"filepaths",
"!=",
"nil",
"{",
"l",
".",
"vfilepath",
".",
"filter",
"=",
"filepaths",
"\n",
"}",
"\n",
"nfilters",
"=",
"len",
"(",
"l",
".",
"vmodule",
".",
"filter",
")",
"+",
"len",
"(",
"l",
".",
"vfilepath",
".",
"filter",
")",
"\n",
"l",
".",
"vmap",
"=",
"make",
"(",
"map",
"[",
"uintptr",
"]",
"Level",
")",
"\n",
"}",
"\n\n",
"// Things are consistent now, so enable filtering and verbosity.",
"// They are enabled in order opposite to that in V.",
"atomic",
".",
"StoreInt32",
"(",
"&",
"l",
".",
"filterLength",
",",
"int32",
"(",
"nfilters",
")",
")",
"\n",
"l",
".",
"verbosity",
".",
"set",
"(",
"verbosity",
")",
"\n",
"}"
] |
23,380 | all-23381 | [
"HasFacet",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"a",
"*",
"ApmOrLogQueryGroupBy",
")",
"HasFacet",
"(",
")",
"bool",
"{",
"if",
"a",
"!=",
"nil",
"&&",
"a",
".",
"Facet",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
23,381 | all-23382 | [
"FinishedSpans",
"returns",
"all",
"spans",
"that",
"have",
"been",
"Finish",
"()",
"ed",
"since",
"the",
"MockTracer",
"was",
"constructed",
"or",
"since",
"the",
"last",
"call",
"to",
"its",
"Reset",
"()",
"method",
"."
] | [
"func",
"(",
"t",
"*",
"MockTracer",
")",
"FinishedSpans",
"(",
")",
"[",
"]",
"*",
"MockSpan",
"{",
"t",
".",
"RLock",
"(",
")",
"\n",
"defer",
"t",
".",
"RUnlock",
"(",
")",
"\n",
"spans",
":=",
"<mask>",
"(",
"[",
"]",
"*",
"MockSpan",
",",
"len",
"(",
"t",
".",
"finishedSpans",
")",
")",
"\n",
"copy",
"(",
"spans",
",",
"t",
".",
"finishedSpans",
")",
"\n",
"return",
"spans",
"\n",
"}"
] |
23,382 | all-23383 | [
"SetChunkSize",
"sets",
"size",
"of",
"saved",
"chunks",
".",
"Once",
"the",
"file",
"is",
"written",
"to",
"it",
"will",
"be",
"split",
"in",
"blocks",
"of",
"that",
"size",
"and",
"each",
"block",
"saved",
"into",
"an",
"independent",
"chunk",
"document",
".",
"The",
"default",
"chunk",
"size",
"is",
"256kb",
".",
"It",
"is",
"a",
"runtime",
"error",
"to",
"call",
"this",
"function",
"once",
"the",
"file",
"has",
"started",
"being",
"written",
"to",
"."
] | [
"func",
"(",
"file",
"*",
"GridFile",
")",
"SetChunkSize",
"(",
"bytes",
"int",
")",
"{",
"file",
".",
"assertMode",
"(",
"gfsWriting",
")",
"\n",
"debugf",
"(",
"\"",
"\"",
",",
"file",
",",
"bytes",
")",
"\n",
"file",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"file",
".",
"<mask>",
".",
"ChunkSize",
"=",
"bytes",
"\n",
"file",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"}"
] |
23,383 | all-23384 | [
"Hijack",
"Satisfy",
"the",
"http",
".",
"ResponseWriter",
"interface"
] | [
"func",
"(",
"w",
"*",
"StatusResponseWriter",
")",
"Hijack",
"(",
")",
"(",
"net",
".",
"Conn",
",",
"*",
"bufio",
".",
"ReadWriter",
",",
"error",
")",
"{",
"if",
"hj",
",",
"<mask>",
":=",
"w",
".",
"ResponseWriter",
".",
"(",
"http",
".",
"Hijacker",
")",
";",
"ok",
"{",
"return",
"hj",
".",
"Hijack",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
",",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
23,384 | all-23385 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"SetWindowBoundsParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoBrowser",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
23,385 | all-23386 | [
"GetPathAtPos",
"is",
"a",
"wrapper",
"around",
"gtk_tree_view_get_path_at_pos",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"TreeView",
")",
"GetPathAtPos",
"(",
"x",
",",
"y",
"int",
",",
"<mask>",
"*",
"TreePath",
",",
"column",
"*",
"TreeViewColumn",
",",
"cellX",
",",
"cellY",
"*",
"int",
")",
"bool",
"{",
"var",
"ctp",
"*",
"*",
"C",
".",
"GtkTreePath",
"\n",
"if",
"path",
"!=",
"nil",
"{",
"ctp",
"=",
"(",
"*",
"*",
"C",
".",
"GtkTreePath",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"path",
".",
"GtkTreePath",
")",
")",
"\n",
"}",
"else",
"{",
"ctp",
"=",
"nil",
"\n",
"}",
"\n\n",
"var",
"pctvcol",
"*",
"*",
"C",
".",
"GtkTreeViewColumn",
"\n",
"if",
"column",
"!=",
"nil",
"{",
"ctvcol",
":=",
"column",
".",
"native",
"(",
")",
"\n",
"pctvcol",
"=",
"&",
"ctvcol",
"\n",
"}",
"else",
"{",
"pctvcol",
"=",
"nil",
"\n",
"}",
"\n\n",
"return",
"0",
"!=",
"C",
".",
"gtk_tree_view_get_path_at_pos",
"(",
"v",
".",
"native",
"(",
")",
",",
"(",
"C",
".",
"gint",
")",
"(",
"x",
")",
",",
"(",
"C",
".",
"gint",
")",
"(",
"y",
")",
",",
"ctp",
",",
"pctvcol",
",",
"(",
"*",
"C",
".",
"gint",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"cellX",
")",
")",
",",
"(",
"*",
"C",
".",
"gint",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"cellY",
")",
")",
")",
"\n",
"}"
] |
23,386 | all-23387 | [
"WriteTo",
"writes",
"request",
"to",
"w",
".",
"It",
"implements",
"io",
".",
"WriterTo",
"."
] | [
"func",
"(",
"req",
"*",
"Request",
")",
"WriteTo",
"(",
"w",
"<mask>",
".",
"Writer",
")",
"(",
"int64",
",",
"error",
")",
"{",
"return",
"writeBufio",
"(",
"req",
",",
"w",
")",
"\n",
"}"
] |
23,387 | all-23388 | [
"SubmitContainerStateChange",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockECSSubmitStateSDK",
")",
"SubmitContainerStateChange",
"(",
"arg0",
"*",
"ecs",
".",
"SubmitContainerStateChangeInput",
")",
"(",
"*",
"ecs",
".",
"SubmitContainerStateChangeOutput",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"*",
"ecs",
".",
"SubmitContainerStateChangeOutput",
")",
"\n",
"ret1",
",",
"_",
":=",
"<mask>",
"[",
"1",
"]",
".",
"(",
"error",
")",
"\n",
"return",
"ret0",
",",
"ret1",
"\n",
"}"
] |
23,388 | all-23389 | [
"Collection",
"..."
] | [
"func",
"(",
"c",
"*",
"Collection",
")",
"<mask>",
"(",
")",
"*",
"mgo",
".",
"Collection",
"{",
"return",
"c",
".",
"Connection",
".",
"Session",
".",
"DB",
"(",
"c",
".",
"Database",
")",
".",
"C",
"(",
"c",
".",
"Name",
")",
"\n",
"}"
] |
23,389 | all-23390 | [
"ServeATA",
"replies",
"to",
"an",
"AoE",
"ATA",
"request",
"after",
"performing",
"the",
"requested",
"ATA",
"operations",
"on",
"the",
"io",
".",
"ReadSeeker",
".",
"ServeATA",
"can",
"handle",
"a",
"variety",
"of",
"ATA",
"requests",
"including",
"reads",
"writes",
"and",
"identification",
".",
"ServeATA",
"returns",
"the",
"number",
"of",
"bytes",
"transmitted",
"to",
"a",
"client",
"and",
"any",
"errors",
"which",
"occurred",
"while",
"processing",
"a",
"request",
".",
"In",
"order",
"to",
"make",
"use",
"of",
"the",
"full",
"functionality",
"provided",
"by",
"ServeATA",
"passing",
"a",
"block",
"device",
"to",
"it",
"as",
"the",
"io",
".",
"ReadSeeker",
"is",
"recommended",
".",
"Package",
"block",
"can",
"handle",
"this",
"functionality",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"mdlayher",
"/",
"block",
".",
"If",
"r",
".",
"Command",
"is",
"not",
"CommandIssueATACommand",
"or",
"r",
".",
"Arg",
"is",
"not",
"a",
"*",
"ATAArg",
"ErrInvalidATARequest",
"is",
"returned",
".",
"If",
"ATA",
"identification",
"is",
"requested",
"but",
"rs",
"does",
"not",
"implement",
"Identifier",
"ErrNotImplemented",
"is",
"returned",
".",
"This",
"behavior",
"will",
"change",
"in",
"the",
"future",
"and",
"Identifier",
"implementations",
"will",
"be",
"optional",
".",
"If",
"an",
"ATA",
"write",
"is",
"requested",
"but",
"rs",
"does",
"not",
"implement",
"io",
".",
"Writer",
"the",
"ATA",
"request",
"will",
"be",
"aborted",
"but",
"no",
"error",
"will",
"be",
"returned",
"by",
"ServeATA",
"."
] | [
"func",
"ServeATA",
"(",
"w",
"ResponseSender",
",",
"r",
"*",
"Header",
",",
"rs",
"io",
".",
"ReadSeeker",
")",
"(",
"int",
",",
"error",
")",
"{",
"// Ensure request intends to issue an ATA command",
"if",
"r",
".",
"Command",
"!=",
"CommandIssueATACommand",
"{",
"return",
"0",
",",
"ErrInvalidATARequest",
"\n",
"}",
"\n",
"arg",
",",
"<mask>",
":=",
"r",
".",
"Arg",
".",
"(",
"*",
"ATAArg",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"0",
",",
"ErrInvalidATARequest",
"\n",
"}",
"\n\n",
"// Request to check device power mode or flush device writes",
"// TODO(mdlayher): determine if these need to be different cases, because",
"// they are no-op operations here",
"if",
"arg",
".",
"CmdStatus",
"==",
"ATACmdStatusCheckPower",
"||",
"arg",
".",
"CmdStatus",
"==",
"ATACmdStatusFlush",
"{",
"return",
"w",
".",
"Send",
"(",
"&",
"Header",
"{",
"Arg",
":",
"&",
"ATAArg",
"{",
"// Device is active or idle",
"SectorCount",
":",
"0xff",
",",
"// Device is ready",
"CmdStatus",
":",
"ATACmdStatusReadyStatus",
",",
"}",
",",
"}",
")",
"\n",
"}",
"\n\n",
"// Handle other request types",
"var",
"warg",
"*",
"ATAArg",
"\n",
"var",
"err",
"error",
"\n\n",
"switch",
"arg",
".",
"CmdStatus",
"{",
"// Request to identify ATA device",
"case",
"ATACmdStatusIdentify",
":",
"warg",
",",
"err",
"=",
"ataIdentify",
"(",
"arg",
",",
"rs",
")",
"\n",
"// Request for ATA read",
"case",
"ATACmdStatusRead28Bit",
",",
"ATACmdStatusRead48Bit",
":",
"warg",
",",
"err",
"=",
"ataRead",
"(",
"arg",
",",
"rs",
")",
"\n",
"// Request for ATA write",
"case",
"ATACmdStatusWrite28Bit",
",",
"ATACmdStatusWrite48Bit",
":",
"warg",
",",
"err",
"=",
"ataWrite",
"(",
"arg",
",",
"rs",
")",
"\n",
"// ATA device is ready",
"case",
"ATACmdStatusReadyStatus",
":",
"return",
"0",
",",
"nil",
"\n",
"// Unknown ATA command, abort",
"default",
":",
"// TODO(mdlayher): possibly expose SMART data when a *block.Device",
"// is passed for rs",
"err",
"=",
"errATAAbort",
"\n",
"}",
"\n\n",
"// Return non-abort errors",
"if",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"errATAAbort",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"// If aborted, an ATAArg is returned stating that the command",
"// was aborted",
"if",
"err",
"==",
"errATAAbort",
"{",
"warg",
"=",
"&",
"ATAArg",
"{",
"CmdStatus",
":",
"ATACmdStatusErrStatus",
",",
"ErrFeature",
":",
"ATAErrAbort",
",",
"}",
"\n",
"}",
"\n\n",
"// Reply to client; w handles Header field copying",
"return",
"w",
".",
"Send",
"(",
"&",
"Header",
"{",
"Arg",
":",
"warg",
",",
"}",
")",
"\n",
"}"
] |
23,390 | all-23391 | [
"Size",
"returns",
"the",
"size",
"of",
"lsm",
"and",
"value",
"log",
"files",
"in",
"bytes",
".",
"It",
"can",
"be",
"used",
"to",
"decide",
"how",
"often",
"to",
"call",
"RunValueLogGC",
"."
] | [
"func",
"(",
"db",
"*",
"DB",
")",
"Size",
"(",
")",
"(",
"lsm",
",",
"vlog",
"int64",
")",
"{",
"if",
"y",
".",
"LSMSize",
".",
"Get",
"(",
"db",
".",
"<mask>",
".",
"Dir",
")",
"==",
"nil",
"{",
"lsm",
",",
"vlog",
"=",
"0",
",",
"0",
"\n",
"return",
"\n",
"}",
"\n",
"lsm",
"=",
"y",
".",
"LSMSize",
".",
"Get",
"(",
"db",
".",
"opt",
".",
"Dir",
")",
".",
"(",
"*",
"expvar",
".",
"Int",
")",
".",
"Value",
"(",
")",
"\n",
"vlog",
"=",
"y",
".",
"VlogSize",
".",
"Get",
"(",
"db",
".",
"opt",
".",
"Dir",
")",
".",
"(",
"*",
"expvar",
".",
"Int",
")",
".",
"Value",
"(",
")",
"\n",
"return",
"\n",
"}"
] |
23,391 | all-23392 | [
"isAWSAlias",
"determines",
"if",
"a",
"given",
"hostname",
"belongs",
"to",
"an",
"AWS",
"Alias",
"record",
"by",
"doing",
"an",
"reverse",
"lookup",
"."
] | [
"func",
"isAWSAlias",
"(",
"ep",
"*",
"endpoint",
".",
"Endpoint",
",",
"addrs",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
")",
"string",
"{",
"if",
"<mask>",
",",
"exists",
":=",
"ep",
".",
"GetProviderSpecificProperty",
"(",
"\"",
"\"",
")",
";",
"ep",
".",
"RecordType",
"==",
"endpoint",
".",
"RecordTypeCNAME",
"&&",
"exists",
"&&",
"prop",
".",
"Value",
"==",
"\"",
"\"",
"{",
"for",
"_",
",",
"addr",
":=",
"range",
"addrs",
"{",
"if",
"addr",
".",
"DNSName",
"==",
"ep",
".",
"Targets",
"[",
"0",
"]",
"{",
"if",
"hostedZone",
":=",
"canonicalHostedZone",
"(",
"addr",
".",
"Targets",
"[",
"0",
"]",
")",
";",
"hostedZone",
"!=",
"\"",
"\"",
"{",
"return",
"hostedZone",
"\n",
"}",
"\n\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
23,392 | all-23393 | [
"CreateCertificate",
"adds",
"a",
"new",
"certificate",
"to",
"the",
"LXD",
"trust",
"store"
] | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"CreateCertificate",
"(",
"certificate",
"api",
".",
"CertificatesPost",
")",
"error",
"{",
"// Send the request",
"_",
",",
"_",
",",
"err",
":=",
"r",
".",
"<mask>",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"certificate",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
23,393 | all-23394 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"ViolationSetting",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoLog",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
23,394 | all-23395 | [
"UrlFor",
"returns",
"the",
"URL",
"object",
"from",
"UriBase",
"with",
"the",
"Path",
"set",
"to",
"path",
"and",
"the",
"query",
"string",
"built",
"with",
"queryParams",
"."
] | [
"func",
"(",
"r",
"*",
"Request",
")",
"UrlFor",
"(",
"path",
"string",
",",
"queryParams",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"*",
"url",
".",
"URL",
"{",
"baseUrl",
":=",
"r",
".",
"BaseUrl",
"(",
")",
"\n",
"baseUrl",
".",
"Path",
"=",
"path",
"\n",
"if",
"queryParams",
"!=",
"nil",
"{",
"query",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"queryParams",
"{",
"for",
"_",
",",
"vv",
":=",
"<mask>",
"v",
"{",
"query",
".",
"Add",
"(",
"k",
",",
"vv",
")",
"\n",
"}",
"\n",
"}",
"\n",
"baseUrl",
".",
"RawQuery",
"=",
"query",
".",
"Encode",
"(",
")",
"\n",
"}",
"\n",
"return",
"baseUrl",
"\n",
"}"
] |
23,395 | all-23396 | [
"GetMACAddress",
"retrieves",
"the",
"MAC",
"address",
"of",
"a",
"device",
"using",
"netlink"
] | [
"func",
"GetMACAddress",
"(",
"ctx",
"<mask>",
".",
"Context",
",",
"timeout",
"time",
".",
"Duration",
",",
"dev",
"string",
",",
"netlinkClient",
"netlinkwrapper",
".",
"NetLink",
")",
"(",
"string",
",",
"error",
")",
"{",
"retriever",
":=",
"&",
"macAddressRetriever",
"{",
"dev",
":",
"dev",
",",
"netlinkClient",
":",
"netlinkClient",
",",
"ctx",
":",
"ctx",
",",
"timeout",
":",
"timeout",
",",
"}",
"\n",
"return",
"retriever",
".",
"retrieve",
"(",
")",
"\n",
"}"
] |
23,396 | all-23397 | [
"nanosecond",
":",
"HDB",
"-",
"7",
"digits",
"precision",
"(",
"not",
"9",
"digits",
")"
] | [
"func",
"convertTimeToLongdate",
"(",
"t",
"<mask>",
".",
"Time",
")",
"int64",
"{",
"t",
"=",
"t",
".",
"UTC",
"(",
")",
"\n",
"return",
"(",
"(",
"(",
"(",
"(",
"(",
"(",
"int64",
"(",
"convertTimeToDayDate",
"(",
"t",
")",
")",
"-",
"1",
")",
"*",
"24",
")",
"+",
"int64",
"(",
"t",
".",
"Hour",
"(",
")",
")",
")",
"*",
"60",
")",
"+",
"int64",
"(",
"t",
".",
"Minute",
"(",
")",
")",
")",
"*",
"60",
")",
"+",
"int64",
"(",
"t",
".",
"Second",
"(",
")",
")",
")",
"*",
"10000000",
"+",
"int64",
"(",
"t",
".",
"Nanosecond",
"(",
")",
"/",
"100",
")",
"+",
"1",
"\n",
"}"
] |
23,397 | all-23398 | [
"We",
"will",
"only",
"wait",
"on",
"the",
"children",
"we",
"have",
"now",
".",
"We",
"will",
"not",
"wait",
"on",
"children",
"added",
"subsequently",
".",
"this",
"may",
"change",
"in",
"the",
"future",
"."
] | [
"func",
"(",
"p",
"*",
"process",
")",
"CloseAfterChildren",
"(",
")",
"error",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"select",
"{",
"case",
"<-",
"p",
".",
"Closed",
"(",
")",
":",
"p",
".",
"Unlock",
"(",
")",
"\n",
"return",
"p",
".",
"Close",
"(",
")",
"// get error. safe, after p.Closed()",
"\n",
"case",
"<-",
"p",
".",
"waiting",
":",
"// already called it.",
"p",
".",
"Unlock",
"(",
")",
"\n",
"<-",
"p",
".",
"Closed",
"(",
")",
"\n",
"return",
"p",
".",
"Close",
"(",
")",
"// get error. safe, after p.Closed()",
"\n",
"default",
":",
"}",
"\n",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"// here only from one goroutine.",
"nextToWaitFor",
":=",
"func",
"(",
")",
"Process",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n",
"for",
"e",
",",
"_",
":=",
"range",
"p",
".",
"waitfors",
"{",
"c",
":=",
"e",
".",
"Child",
"(",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"continue",
"\n",
"}",
"\n\n",
"select",
"{",
"case",
"<-",
"c",
".",
"Closed",
"(",
")",
":",
"default",
":",
"return",
"c",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"// wait for all processes we're waiting for are closed.",
"// the semantics here are simple: we will _only_ close",
"// if there are no processes currently waiting for.",
"for",
"<mask>",
":=",
"nextToWaitFor",
"(",
")",
";",
"next",
"!=",
"nil",
";",
"next",
"=",
"nextToWaitFor",
"(",
")",
"{",
"<-",
"next",
".",
"Closed",
"(",
")",
"\n",
"}",
"\n\n",
"// YAY! we're done. close",
"return",
"p",
".",
"Close",
"(",
")",
"\n",
"}"
] |
23,398 | all-23399 | [
"DesiredTerminal",
"returns",
"true",
"if",
"the",
"cgroup",
"s",
"desired",
"status",
"is",
"REMOVED"
] | [
"func",
"(",
"auth",
"*",
"ASMAuthResource",
")",
"DesiredTerminal",
"(",
")",
"bool",
"{",
"auth",
".",
"<mask>",
".",
"RLock",
"(",
")",
"\n",
"defer",
"auth",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"auth",
".",
"desiredStatusUnsafe",
"==",
"resourcestatus",
".",
"ResourceStatus",
"(",
"ASMAuthStatusRemoved",
")",
"\n",
"}"
] |
23,399 | all-23400 | [
"MoveServersToServerGroup",
"atomically",
"moves",
"servers",
"from",
"one",
"group",
"to",
"another",
".",
"The",
"src",
"parameter",
"specifies",
"the",
"group",
"to",
"which",
"the",
"servers",
"currently",
"belong",
"The",
"dst",
"parameter",
"specifies",
"the",
"group",
"to",
"which",
"you",
"want",
"to",
"move",
"the",
"servers",
".",
"The",
"serverIds",
"parameter",
"specifies",
"the",
"identifiers",
"of",
"the",
"servers",
"you",
"want",
"to",
"move",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"MoveServersToServerGroup",
"(",
"src",
"string",
",",
"dst",
"string",
",",
"serverIds",
"[",
"]",
"string",
")",
"(",
"*",
"ServerGroup",
",",
"error",
")",
"{",
"group",
":=",
"new",
"(",
"ServerGroup",
")",
"\n",
"opts",
":=",
"serverGroupMemberOptions",
"{",
"Destination",
":",
"dst",
"}",
"\n",
"for",
"_",
",",
"id",
":=",
"range",
"serverIds",
"{",
"opts",
".",
"Servers",
"=",
"append",
"(",
"opts",
".",
"Servers",
",",
"serverGroupMember",
"{",
"<mask>",
":",
"id",
"}",
")",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"MakeApiRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"src",
"+",
"\"",
"\"",
",",
"opts",
",",
"&",
"group",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"group",
",",
"nil",
"\n",
"}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.