id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
listlengths 1
418
| pl_tokens
listlengths 22
4.98k
|
---|---|---|---|
13,700 | all-13701 | [
"This",
"function",
"is",
"used",
"to",
"notify",
"the",
"leader",
"that",
"a",
"node",
"was",
"removed",
"it",
"will",
"decide",
"whether",
"to",
"promote",
"a",
"new",
"node",
"as",
"database",
"node",
"."
]
| [
"func",
"tryClusterRebalance",
"(",
"d",
"*",
"Daemon",
")",
"error",
"{",
"leader",
",",
"err",
":=",
"d",
".",
"gateway",
".",
"LeaderAddress",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// This is not a fatal error, so let's just log it.",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"cert",
":=",
"d",
".",
"endpoints",
".",
"NetworkCert",
"(",
")",
"\n",
"client",
",",
"err",
":=",
"cluster",
".",
"Connect",
"(",
"leader",
",",
"cert",
",",
"true",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"_",
",",
"_",
",",
"err",
"=",
"client",
".",
"RawQuery",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"<mask>",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
13,701 | all-13702 | [
"RedirectSlashes",
"is",
"a",
"middleware",
"that",
"will",
"match",
"request",
"paths",
"with",
"a",
"trailing",
"slash",
"and",
"redirect",
"to",
"the",
"same",
"path",
"less",
"the",
"trailing",
"slash",
".",
"NOTE",
":",
"RedirectSlashes",
"middleware",
"is",
"*",
"incompatible",
"*",
"with",
"http",
".",
"FileServer",
"see",
"https",
":",
"//",
"github",
".",
"com",
"/",
"go",
"-",
"chi",
"/",
"chi",
"/",
"issues",
"/",
"343"
]
| [
"func",
"RedirectSlashes",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"fn",
":=",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"var",
"path",
"string",
"\n",
"rctx",
":=",
"chi",
".",
"RouteContext",
"(",
"r",
".",
"Context",
"(",
")",
")",
"\n",
"if",
"rctx",
".",
"RoutePath",
"!=",
"\"",
"\"",
"{",
"path",
"=",
"rctx",
".",
"RoutePath",
"\n",
"}",
"else",
"{",
"path",
"=",
"r",
".",
"URL",
".",
"Path",
"\n",
"}",
"\n",
"if",
"len",
"(",
"path",
")",
">",
"1",
"&&",
"path",
"[",
"len",
"(",
"path",
")",
"-",
"1",
"]",
"==",
"'/'",
"{",
"if",
"r",
".",
"URL",
".",
"RawQuery",
"!=",
"\"",
"\"",
"{",
"path",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"path",
"[",
":",
"len",
"(",
"path",
")",
"-",
"1",
"]",
",",
"r",
".",
"URL",
".",
"RawQuery",
")",
"\n",
"}",
"else",
"{",
"path",
"=",
"<mask>",
"[",
":",
"len",
"(",
"path",
")",
"-",
"1",
"]",
"\n",
"}",
"\n",
"http",
".",
"Redirect",
"(",
"w",
",",
"r",
",",
"path",
",",
"301",
")",
"\n",
"return",
"\n",
"}",
"\n",
"next",
".",
"ServeHTTP",
"(",
"w",
",",
"r",
")",
"\n",
"}",
"\n",
"return",
"http",
".",
"HandlerFunc",
"(",
"fn",
")",
"\n",
"}"
]
|
13,702 | all-13703 | [
"Recv",
"waits",
"to",
"receive",
"the",
"next",
"XMPP",
"stanza",
".",
"Return",
"type",
"is",
"either",
"a",
"presence",
"notification",
"or",
"a",
"chat",
"message",
"."
]
| [
"func",
"(",
"c",
"*",
"Client",
")",
"Recv",
"(",
")",
"(",
"stanza",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"for",
"{",
"_",
",",
"val",
",",
"err",
":=",
"next",
"(",
"c",
".",
"p",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Chat",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"switch",
"v",
":=",
"val",
".",
"(",
"type",
")",
"{",
"case",
"*",
"clientMessage",
":",
"stamp",
",",
"_",
":=",
"time",
".",
"Parse",
"(",
"\"",
"\"",
",",
"v",
".",
"Delay",
".",
"Stamp",
",",
")",
"\n",
"chat",
":=",
"Chat",
"{",
"Remote",
":",
"v",
".",
"From",
",",
"Type",
":",
"v",
".",
"Type",
",",
"Text",
":",
"v",
".",
"Body",
",",
"Subject",
":",
"v",
".",
"Subject",
",",
"Thread",
":",
"v",
".",
"Thread",
",",
"Other",
":",
"v",
".",
"OtherStrings",
"(",
")",
",",
"OtherElem",
":",
"v",
".",
"Other",
",",
"Stamp",
":",
"stamp",
",",
"}",
"\n",
"return",
"chat",
",",
"nil",
"\n",
"case",
"*",
"clientQuery",
":",
"var",
"r",
"Roster",
"\n",
"for",
"_",
",",
"item",
":=",
"range",
"v",
".",
"Item",
"{",
"r",
"=",
"append",
"(",
"r",
",",
"Contact",
"{",
"item",
".",
"Jid",
",",
"item",
".",
"Name",
",",
"item",
".",
"Group",
"}",
")",
"\n",
"}",
"\n",
"return",
"Chat",
"{",
"<mask>",
":",
"\"",
"\"",
",",
"Roster",
":",
"r",
"}",
",",
"nil",
"\n",
"case",
"*",
"clientPresence",
":",
"return",
"Presence",
"{",
"v",
".",
"From",
",",
"v",
".",
"To",
",",
"v",
".",
"Type",
",",
"v",
".",
"Show",
",",
"v",
".",
"Status",
"}",
",",
"nil",
"\n",
"case",
"*",
"clientIQ",
":",
"// TODO check more strictly",
"if",
"bytes",
".",
"Equal",
"(",
"bytes",
".",
"TrimSpace",
"(",
"v",
".",
"Query",
")",
",",
"[",
"]",
"byte",
"(",
"`<ping xmlns='urn:xmpp:ping'/>`",
")",
")",
"||",
"bytes",
".",
"Equal",
"(",
"bytes",
".",
"TrimSpace",
"(",
"v",
".",
"Query",
")",
",",
"[",
"]",
"byte",
"(",
"`<ping xmlns=\"urn:xmpp:ping\"/>`",
")",
")",
"{",
"err",
":=",
"c",
".",
"SendResultPing",
"(",
"v",
".",
"ID",
",",
"v",
".",
"From",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Chat",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"IQ",
"{",
"ID",
":",
"v",
".",
"ID",
",",
"From",
":",
"v",
".",
"From",
",",
"To",
":",
"v",
".",
"To",
",",
"Type",
":",
"v",
".",
"Type",
",",
"Query",
":",
"v",
".",
"Query",
"}",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"}"
]
|
13,703 | all-13704 | [
"yamlToConfig",
"converts",
"a",
"yaml",
"file",
"into",
"a",
"Config",
"object"
]
| [
"func",
"yamlToConfig",
"(",
"path",
"string",
",",
"nc",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
",",
"err",
":=",
"ReadFileMaybeGZIP",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"<mask>",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"yaml",
".",
"Unmarshal",
"(",
"b",
",",
"nc",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"path",
",",
"err",
")",
"\n",
"}",
"\n",
"var",
"jc",
"*",
"JobConfig",
"\n",
"switch",
"v",
":=",
"nc",
".",
"(",
"type",
")",
"{",
"case",
"*",
"JobConfig",
":",
"jc",
"=",
"v",
"\n",
"case",
"*",
"Config",
":",
"jc",
"=",
"&",
"v",
".",
"JobConfig",
"\n",
"}",
"\n",
"for",
"rep",
":=",
"range",
"jc",
".",
"Presubmits",
"{",
"var",
"fix",
"func",
"(",
"*",
"Presubmit",
")",
"\n",
"fix",
"=",
"func",
"(",
"job",
"*",
"Presubmit",
")",
"{",
"job",
".",
"SourcePath",
"=",
"path",
"\n",
"}",
"\n",
"for",
"i",
":=",
"range",
"jc",
".",
"Presubmits",
"[",
"rep",
"]",
"{",
"fix",
"(",
"&",
"jc",
".",
"Presubmits",
"[",
"rep",
"]",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n",
"for",
"rep",
":=",
"range",
"jc",
".",
"Postsubmits",
"{",
"var",
"fix",
"func",
"(",
"*",
"Postsubmit",
")",
"\n",
"fix",
"=",
"func",
"(",
"job",
"*",
"Postsubmit",
")",
"{",
"job",
".",
"SourcePath",
"=",
"path",
"\n",
"}",
"\n",
"for",
"i",
":=",
"range",
"jc",
".",
"Postsubmits",
"[",
"rep",
"]",
"{",
"fix",
"(",
"&",
"jc",
".",
"Postsubmits",
"[",
"rep",
"]",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"var",
"fix",
"func",
"(",
"*",
"Periodic",
")",
"\n",
"fix",
"=",
"func",
"(",
"job",
"*",
"Periodic",
")",
"{",
"job",
".",
"SourcePath",
"=",
"path",
"\n",
"}",
"\n",
"for",
"i",
":=",
"range",
"jc",
".",
"Periodics",
"{",
"fix",
"(",
"&",
"jc",
".",
"Periodics",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
13,704 | all-13705 | [
"newTaskEngine",
"creates",
"a",
"new",
"docker",
"task",
"engine",
"object",
".",
"It",
"tries",
"to",
"load",
"the",
"local",
"state",
"if",
"needed",
"else",
"initializes",
"a",
"new",
"one"
]
| [
"func",
"(",
"agent",
"*",
"ecsAgent",
")",
"newTaskEngine",
"(",
"containerChangeEventStream",
"*",
"eventstream",
".",
"EventStream",
",",
"credentialsManager",
"credentials",
".",
"Manager",
",",
"state",
"dockerstate",
".",
"TaskEngineState",
",",
"imageManager",
"engine",
".",
"ImageManager",
")",
"(",
"engine",
".",
"TaskEngine",
",",
"string",
",",
"error",
")",
"{",
"containerChangeEventStream",
".",
"StartListening",
"(",
")",
"\n\n",
"if",
"!",
"agent",
".",
"cfg",
".",
"Checkpoint",
"{",
"seelog",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"return",
"engine",
".",
"NewTaskEngine",
"(",
"agent",
".",
"cfg",
",",
"agent",
".",
"dockerClient",
",",
"credentialsManager",
",",
"containerChangeEventStream",
",",
"imageManager",
",",
"state",
",",
"agent",
".",
"metadataManager",
",",
"<mask>",
".",
"resourceFields",
")",
",",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n\n",
"// We try to set these values by loading the existing state file first",
"var",
"previousCluster",
",",
"previousEC2InstanceID",
",",
"previousContainerInstanceArn",
",",
"previousAZ",
"string",
"\n",
"previousTaskEngine",
":=",
"engine",
".",
"NewTaskEngine",
"(",
"agent",
".",
"cfg",
",",
"agent",
".",
"dockerClient",
",",
"credentialsManager",
",",
"containerChangeEventStream",
",",
"imageManager",
",",
"state",
",",
"agent",
".",
"metadataManager",
",",
"agent",
".",
"resourceFields",
")",
"\n\n",
"// previousStateManager is used to verify that our current runtime configuration is",
"// compatible with our past configuration as reflected by our state-file",
"previousStateManager",
",",
"err",
":=",
"agent",
".",
"newStateManager",
"(",
"previousTaskEngine",
",",
"&",
"previousCluster",
",",
"&",
"previousContainerInstanceArn",
",",
"&",
"previousEC2InstanceID",
",",
"&",
"previousAZ",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Criticalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"previousStateManager",
".",
"Load",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Criticalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"agent",
".",
"checkCompatibility",
"(",
"previousTaskEngine",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"seelog",
".",
"Criticalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"currentEC2InstanceID",
":=",
"agent",
".",
"getEC2InstanceID",
"(",
")",
"\n",
"if",
"previousEC2InstanceID",
"!=",
"\"",
"\"",
"&&",
"previousEC2InstanceID",
"!=",
"currentEC2InstanceID",
"{",
"seelog",
".",
"Warnf",
"(",
"instanceIDMismatchErrorFormat",
",",
"previousEC2InstanceID",
",",
"currentEC2InstanceID",
")",
"\n\n",
"// Reset agent state as a new container instance",
"state",
".",
"Reset",
"(",
")",
"\n",
"// Reset taskEngine; all the other values are still default",
"return",
"engine",
".",
"NewTaskEngine",
"(",
"agent",
".",
"cfg",
",",
"agent",
".",
"dockerClient",
",",
"credentialsManager",
",",
"containerChangeEventStream",
",",
"imageManager",
",",
"state",
",",
"agent",
".",
"metadataManager",
",",
"agent",
".",
"resourceFields",
")",
",",
"currentEC2InstanceID",
",",
"nil",
"\n",
"}",
"\n\n",
"if",
"previousCluster",
"!=",
"\"",
"\"",
"{",
"if",
"err",
":=",
"agent",
".",
"setClusterInConfig",
"(",
"previousCluster",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Use the values we loaded if there's no issue",
"agent",
".",
"containerInstanceARN",
"=",
"previousContainerInstanceArn",
"\n\n",
"return",
"previousTaskEngine",
",",
"currentEC2InstanceID",
",",
"nil",
"\n",
"}"
]
|
13,705 | all-13706 | [
"newHelperMethodDoctype",
"creates",
"and",
"returns",
"a",
"helper",
"method",
"doctype",
"."
]
| [
"func",
"newHelperMethodDoctype",
"(",
"ln",
"*",
"line",
",",
"rslt",
"*",
"result",
",",
"src",
"*",
"source",
",",
"parent",
"element",
",",
"opts",
"*",
"Options",
")",
"(",
"*",
"helperMethodDoctype",
",",
"error",
")",
"{",
"if",
"len",
"(",
"ln",
".",
"tokens",
")",
"<",
"3",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ln",
".",
"fileName",
"(",
")",
",",
"ln",
".",
"no",
")",
"\n",
"}",
"\n\n",
"doctype",
":=",
"ln",
".",
"tokens",
"[",
"2",
"]",
"\n\n",
"if",
"_",
",",
"<mask>",
":=",
"doctypes",
"[",
"doctype",
"]",
";",
"!",
"ok",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ln",
".",
"fileName",
"(",
")",
",",
"ln",
".",
"no",
",",
"doctype",
")",
"\n",
"}",
"\n\n",
"e",
":=",
"&",
"helperMethodDoctype",
"{",
"elementBase",
":",
"newElementBase",
"(",
"ln",
",",
"rslt",
",",
"src",
",",
"parent",
",",
"opts",
")",
",",
"doctype",
":",
"doctype",
",",
"}",
"\n\n",
"return",
"e",
",",
"nil",
"\n",
"}"
]
|
13,706 | all-13707 | [
"GetDeploymentManifest",
"-"
]
| [
"func",
"(",
"director",
"*",
"BoshDirector",
")",
"GetDeploymentManifest",
"(",
"deploymentName",
"string",
")",
"(",
"manifest",
"io",
".",
"Reader",
",",
"err",
"error",
")",
"{",
"endpoint",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"director",
".",
"ip",
",",
"director",
".",
"port",
",",
"deploymentName",
")",
"\n",
"httpEntity",
":=",
"director",
".",
"getEntity",
"(",
"endpoint",
",",
"\"",
"\"",
")",
"\n",
"<mask>",
":=",
"director",
".",
"gateway",
".",
"Get",
"(",
"httpEntity",
")",
"\n",
"resp",
",",
"err",
":=",
"request",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"manifest",
",",
"err",
"=",
"retrieveManifest",
"(",
"resp",
")",
"\n",
"return",
"\n",
"}"
]
|
13,707 | all-13708 | [
"UnmarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Unmarshaler",
"."
]
| [
"func",
"(",
"t",
"*",
"RecordMode",
")",
"UnmarshalEasyJSON",
"(",
"in",
"*",
"jlexer",
".",
"Lexer",
")",
"{",
"switch",
"RecordMode",
"(",
"in",
".",
"String",
"(",
")",
")",
"{",
"case",
"RecordModeRecordUntilFull",
":",
"*",
"t",
"=",
"RecordModeRecordUntilFull",
"\n",
"case",
"RecordModeRecordContinuously",
":",
"*",
"t",
"=",
"RecordModeRecordContinuously",
"\n",
"case",
"RecordModeRecordAsMuchAsPossible",
":",
"*",
"t",
"=",
"RecordModeRecordAsMuchAsPossible",
"\n",
"case",
"RecordModeEchoToConsole",
":",
"*",
"t",
"=",
"RecordModeEchoToConsole",
"\n\n",
"default",
":",
"<mask>",
".",
"AddError",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"}"
]
|
13,708 | all-13709 | [
"Validate",
"that",
"options",
"are",
"usuable"
]
| [
"func",
"(",
"opts",
"*",
"Options",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"opts",
".",
"App",
".",
"IsZero",
"(",
")",
"{",
"opts",
".",
"App",
"=",
"meta",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"opts",
".",
"Name",
")",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"opts",
".",
"Model",
")",
"==",
"0",
"{",
"opts",
".",
"Model",
"=",
"opts",
".",
"Name",
"\n",
"}",
"\n\n",
"if",
"strings",
".",
"Contains",
"(",
"opts",
".",
"<mask>",
",",
"\"",
"\"",
")",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"opts",
".",
"Model",
",",
"\"",
"\"",
")",
"\n",
"opts",
".",
"Model",
"=",
"parts",
"[",
"len",
"(",
"parts",
")",
"-",
"1",
"]",
"\n",
"}",
"\n\n",
"if",
"opts",
".",
"App",
".",
"AsAPI",
"{",
"opts",
".",
"SkipTemplates",
"=",
"true",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
13,709 | all-13710 | [
"Chmod",
"mocks",
"base",
"method"
]
| [
"func",
"(",
"m",
"*",
"MockFile",
")",
"Chmod",
"(",
"arg0",
"<mask>",
".",
"FileMode",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"error",
")",
"\n",
"return",
"ret0",
"\n",
"}"
]
|
13,710 | all-13711 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"RelatedNode",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoAccessibility2",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
]
|
13,711 | all-13712 | [
"WithRange",
"sets",
"the",
"comparison",
"to",
"scan",
"the",
"range",
"[",
"key",
"end",
")",
"."
]
| [
"func",
"(",
"cmp",
"Cmp",
")",
"WithRange",
"(",
"end",
"string",
")",
"Cmp",
"{",
"cmp",
".",
"RangeEnd",
"=",
"[",
"]",
"<mask>",
"(",
"end",
")",
"\n",
"return",
"cmp",
"\n",
"}"
]
|
13,712 | all-13713 | [
"updateLease",
"extracts",
"the",
"duration",
"of",
"the",
"lease",
"governing",
"secret",
"(",
"an",
"AWS",
"secret",
")",
".",
"IIUC",
"because",
"the",
"AWS",
"backend",
"issues",
"dynamic",
"secrets",
"there",
"is",
"no",
"tokens",
"associated",
"with",
"them",
"and",
"vaultSecret",
".",
"TokenTTL",
"can",
"be",
"ignored"
]
| [
"func",
"(",
"v",
"*",
"vaultCredentialsProvider",
")",
"updateLease",
"(",
"secret",
"*",
"vault",
".",
"Secret",
")",
"{",
"v",
".",
"leaseMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"v",
".",
"leaseMu",
".",
"Unlock",
"(",
")",
"\n",
"v",
".",
"leaseID",
"=",
"<mask>",
".",
"LeaseID",
"\n",
"v",
".",
"leaseLastRenew",
"=",
"time",
".",
"Now",
"(",
")",
"\n",
"v",
".",
"leaseDuration",
"=",
"time",
".",
"Duration",
"(",
"secret",
".",
"LeaseDuration",
")",
"*",
"time",
".",
"Second",
"\n",
"}"
]
|
13,713 | all-13714 | [
"Put",
"serializes",
"x",
"into",
"the",
"buffer",
"(",
"big",
"endian",
")",
".",
"Behavior",
"is",
"undefined",
"when",
"x",
"does",
"not",
"fit",
"so",
"the",
"caller",
"must",
"ensure",
"c",
"is",
"large",
"enough",
"."
]
| [
"func",
"(",
"c",
"<mask>",
")",
"Put",
"(",
"x",
"uint64",
")",
"{",
"s",
":=",
"uint",
"(",
"8",
"*",
"(",
"len",
"(",
"c",
")",
"-",
"1",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"c",
"{",
"c",
"[",
"i",
"]",
"=",
"byte",
"(",
"x",
">>",
"s",
")",
"\n",
"s",
"-=",
"8",
"\n",
"}",
"\n",
"}"
]
|
13,714 | all-13715 | [
"Execute",
"substitutes",
"template",
"tags",
"(",
"placeholders",
")",
"with",
"the",
"corresponding",
"values",
"from",
"the",
"map",
"m",
"and",
"writes",
"the",
"result",
"to",
"the",
"given",
"writer",
"w",
".",
"Substitution",
"map",
"m",
"may",
"contain",
"values",
"with",
"the",
"following",
"types",
":",
"*",
"[]",
"byte",
"-",
"the",
"fastest",
"value",
"type",
"*",
"string",
"-",
"convenient",
"value",
"type",
"*",
"TagFunc",
"-",
"flexible",
"value",
"type",
"Returns",
"the",
"number",
"of",
"bytes",
"written",
"to",
"w",
"."
]
| [
"func",
"(",
"t",
"*",
"Template",
")",
"Execute",
"(",
"w",
"io",
".",
"Writer",
",",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"int64",
",",
"error",
")",
"{",
"return",
"t",
".",
"ExecuteFunc",
"(",
"w",
",",
"func",
"(",
"w",
"io",
".",
"Writer",
",",
"<mask>",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"stdTagFunc",
"(",
"w",
",",
"tag",
",",
"m",
")",
"}",
")",
"\n",
"}"
]
|
13,715 | all-13716 | [
"discoverErr",
"prints",
"out",
"a",
"friendly",
"error",
"heading",
"for",
"the",
"top",
"-",
"level",
"discovery",
"errors",
".",
"It",
"should",
"only",
"be",
"used",
"in",
"the",
"Addrs",
"method",
"."
]
| [
"func",
"discoverErr",
"(",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"s",
"string",
"\n",
"if",
"len",
"(",
"a",
")",
">",
"1",
"{",
"s",
"=",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"a",
"...",
")",
"\n",
"}",
"else",
"{",
"s",
"=",
"<mask>",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"s",
")",
"\n",
"}"
]
|
13,716 | all-13717 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"MemoryDumpConfig",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoTracing5",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"<mask>",
"(",
")",
"\n",
"}"
]
|
13,717 | all-13718 | [
"RoundTrip",
"coalesces",
"concurrent",
"GET",
"requests",
"for",
"the",
"same",
"URI",
"by",
"blocking",
"the",
"later",
"requests",
"until",
"the",
"first",
"request",
"returns",
"and",
"then",
"sharing",
"the",
"response",
"between",
"all",
"requests",
".",
"Notes",
":",
"Deadlock",
"shouldn",
"t",
"be",
"possible",
"because",
"the",
"map",
"lock",
"is",
"always",
"acquired",
"before",
"responseWaiter",
"lock",
"if",
"both",
"locks",
"are",
"to",
"be",
"held",
"and",
"we",
"never",
"hold",
"multiple",
"responseWaiter",
"locks",
"."
]
| [
"func",
"(",
"r",
"*",
"requestCoalescer",
")",
"RoundTrip",
"(",
"req",
"*",
"<mask>",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"// Only coalesce GET requests",
"if",
"req",
".",
"Method",
"!=",
"http",
".",
"MethodGet",
"{",
"return",
"r",
".",
"delegate",
".",
"RoundTrip",
"(",
"req",
")",
"\n",
"}",
"\n\n",
"var",
"cacheMode",
"=",
"ModeError",
"\n",
"resp",
",",
"err",
":=",
"func",
"(",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"key",
":=",
"req",
".",
"URL",
".",
"String",
"(",
")",
"\n",
"r",
".",
"Lock",
"(",
")",
"\n",
"waiter",
",",
"ok",
":=",
"r",
".",
"keys",
"[",
"key",
"]",
"\n",
"if",
"ok",
"{",
"// Earlier request in flight. Wait for it's response.",
"if",
"req",
".",
"Body",
"!=",
"nil",
"{",
"defer",
"req",
".",
"Body",
".",
"Close",
"(",
")",
"// Since we won't pass the request we must close it.",
"\n",
"}",
"\n",
"waiter",
".",
"L",
".",
"Lock",
"(",
")",
"\n",
"r",
".",
"Unlock",
"(",
")",
"\n",
"waiter",
".",
"waiting",
"=",
"true",
"\n",
"// The documentation for Wait() says:",
"// \"Because c.L is not locked when Wait first resumes, the caller typically",
"// cannot assume that the condition is true when Wait returns. Instead, the",
"// caller should Wait in a loop.\"",
"// This does not apply to this use of Wait() because the condition we are",
"// waiting for remains true once it becomes true. This lets us avoid the",
"// normal check to see if the condition has switched back to false between",
"// the signal being sent and this thread acquiring the lock.",
"waiter",
".",
"Wait",
"(",
")",
"\n",
"waiter",
".",
"L",
".",
"Unlock",
"(",
")",
"\n",
"// Earlier request completed.",
"if",
"waiter",
".",
"err",
"!=",
"nil",
"{",
"// Don't log the error, it will be logged by requester.",
"return",
"nil",
",",
"waiter",
".",
"err",
"\n",
"}",
"\n",
"resp",
",",
"err",
":=",
"http",
".",
"ReadResponse",
"(",
"bufio",
".",
"NewReader",
"(",
"bytes",
".",
"NewBuffer",
"(",
"waiter",
".",
"resp",
")",
")",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logrus",
".",
"WithField",
"(",
"\"",
"\"",
",",
"key",
")",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"cacheMode",
"=",
"ModeCoalesced",
"\n",
"return",
"resp",
",",
"nil",
"\n",
"}",
"\n",
"// No earlier request in flight (common case).",
"// Register a new responseWaiter and make the request ourself.",
"waiter",
"=",
"&",
"responseWaiter",
"{",
"Cond",
":",
"sync",
".",
"NewCond",
"(",
"&",
"sync",
".",
"Mutex",
"{",
"}",
")",
"}",
"\n",
"r",
".",
"keys",
"[",
"key",
"]",
"=",
"waiter",
"\n",
"r",
".",
"Unlock",
"(",
")",
"\n\n",
"resp",
",",
"err",
":=",
"r",
".",
"delegate",
".",
"RoundTrip",
"(",
"req",
")",
"\n",
"// Real response received. Remove this responseWaiter from the map THEN",
"// wake any requesters that were waiting on this response.",
"r",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"r",
".",
"keys",
",",
"key",
")",
"\n",
"r",
".",
"Unlock",
"(",
")",
"\n\n",
"waiter",
".",
"L",
".",
"Lock",
"(",
")",
"\n",
"if",
"waiter",
".",
"waiting",
"{",
"if",
"err",
"!=",
"nil",
"{",
"waiter",
".",
"resp",
",",
"waiter",
".",
"err",
"=",
"nil",
",",
"err",
"\n",
"}",
"else",
"{",
"// Copy the response before releasing to waiter(s).",
"waiter",
".",
"resp",
",",
"waiter",
".",
"err",
"=",
"httputil",
".",
"DumpResponse",
"(",
"resp",
",",
"true",
")",
"\n",
"}",
"\n",
"waiter",
".",
"Broadcast",
"(",
")",
"\n",
"}",
"\n",
"waiter",
".",
"L",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"logrus",
".",
"WithField",
"(",
"\"",
"\"",
",",
"key",
")",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"cacheMode",
"=",
"cacheResponseMode",
"(",
"resp",
".",
"Header",
")",
"\n",
"return",
"resp",
",",
"nil",
"\n",
"}",
"(",
")",
"\n\n",
"cacheCounter",
".",
"WithLabelValues",
"(",
"string",
"(",
"cacheMode",
")",
")",
".",
"Inc",
"(",
")",
"\n",
"if",
"resp",
"!=",
"nil",
"{",
"resp",
".",
"Header",
".",
"Set",
"(",
"CacheModeHeader",
",",
"string",
"(",
"cacheMode",
")",
")",
"\n",
"}",
"\n",
"return",
"resp",
",",
"err",
"\n",
"}"
]
|
13,718 | all-13719 | [
"equal",
"returns",
"true",
"only",
"if",
"both",
"arguments",
"are",
"exactly",
"equal",
"."
]
| [
"func",
"(",
"a",
"*",
"Args",
")",
"equal",
"(",
"r",
"*",
"Args",
")",
"bool",
"{",
"if",
"a",
".",
"Elided",
"!=",
"r",
".",
"Elided",
"||",
"len",
"(",
"a",
".",
"Values",
")",
"!=",
"len",
"(",
"r",
".",
"Values",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"i",
",",
"l",
":=",
"<mask>",
"a",
".",
"Values",
"{",
"if",
"l",
"!=",
"r",
".",
"Values",
"[",
"i",
"]",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
]
|
13,719 | all-13720 | [
"printcURL",
"prints",
"the",
"cURL",
"equivalent",
"request",
"to",
"stderr",
".",
"It",
"returns",
"an",
"error",
"if",
"the",
"body",
"of",
"the",
"request",
"cannot",
"be",
"read",
".",
"The",
"caller",
"MUST",
"cancel",
"the",
"request",
"if",
"there",
"is",
"an",
"error",
"."
]
| [
"func",
"printcURL",
"(",
"req",
"*",
"http",
".",
"<mask>",
")",
"error",
"{",
"if",
"!",
"cURLDebug",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"var",
"(",
"command",
"string",
"\n",
"b",
"[",
"]",
"byte",
"\n",
"err",
"error",
"\n",
")",
"\n\n",
"if",
"req",
".",
"URL",
"!=",
"nil",
"{",
"command",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"req",
".",
"Method",
",",
"req",
".",
"URL",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n\n",
"if",
"req",
".",
"Body",
"!=",
"nil",
"{",
"b",
",",
"err",
"=",
"ioutil",
".",
"ReadAll",
"(",
"req",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"command",
"+=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"string",
"(",
"b",
")",
")",
"\n",
"}",
"\n\n",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr",
",",
"\"",
"\\n",
"\"",
",",
"command",
")",
"\n\n",
"// reset body",
"body",
":=",
"bytes",
".",
"NewBuffer",
"(",
"b",
")",
"\n",
"req",
".",
"Body",
"=",
"ioutil",
".",
"NopCloser",
"(",
"body",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
13,720 | all-13721 | [
"Writes",
"encrypted",
"frames",
"of",
"sealedFrameSize",
"CONTRACT",
":",
"data",
"smaller",
"than",
"dataMaxSize",
"is",
"read",
"atomically",
"."
]
| [
"func",
"(",
"sc",
"*",
"SecretConnection",
")",
"Write",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"for",
"0",
"<",
"len",
"(",
"<mask>",
")",
"{",
"var",
"frame",
"[",
"]",
"byte",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"totalFrameSize",
")",
"\n",
"var",
"chunk",
"[",
"]",
"byte",
"\n",
"if",
"dataMaxSize",
"<",
"len",
"(",
"data",
")",
"{",
"chunk",
"=",
"data",
"[",
":",
"dataMaxSize",
"]",
"\n",
"data",
"=",
"data",
"[",
"dataMaxSize",
":",
"]",
"\n",
"}",
"else",
"{",
"chunk",
"=",
"data",
"\n",
"data",
"=",
"nil",
"\n",
"}",
"\n",
"chunkLength",
":=",
"len",
"(",
"chunk",
")",
"\n",
"binary",
".",
"BigEndian",
".",
"PutUint16",
"(",
"frame",
",",
"uint16",
"(",
"chunkLength",
")",
")",
"\n",
"copy",
"(",
"frame",
"[",
"dataLenSize",
":",
"]",
",",
"chunk",
")",
"\n\n",
"// encrypt the frame",
"var",
"sealedFrame",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"sealedFrameSize",
")",
"\n",
"secretbox",
".",
"Seal",
"(",
"sealedFrame",
"[",
":",
"0",
"]",
",",
"frame",
",",
"sc",
".",
"sendNonce",
",",
"sc",
".",
"shrSecret",
")",
"\n",
"// fmt.Printf(\"secretbox.Seal(sealed:%X,sendNonce:%X,shrSecret:%X\\n\", sealedFrame, sc.sendNonce, sc.shrSecret)",
"incr2Nonce",
"(",
"sc",
".",
"sendNonce",
")",
"\n",
"// end encryption",
"_",
",",
"err",
":=",
"sc",
".",
"conn",
".",
"Write",
"(",
"sealedFrame",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n",
",",
"err",
"\n",
"}",
"else",
"{",
"n",
"+=",
"len",
"(",
"chunk",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
]
|
13,721 | all-13722 | [
"Checksum64S",
"returns",
"the",
"64bit",
"xxhash",
"checksum",
"for",
"a",
"single",
"input"
]
| [
"func",
"Checksum64S",
"(",
"in",
"[",
"]",
"byte",
",",
"seed",
"uint64",
")",
"uint64",
"{",
"if",
"len",
"(",
"in",
")",
"==",
"0",
"&&",
"seed",
"==",
"0",
"{",
"return",
"0xef46db3751d8e999",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"<mask>",
")",
">",
"31",
"{",
"return",
"checksum64",
"(",
"in",
",",
"seed",
")",
"\n",
"}",
"\n\n",
"return",
"checksum64Short",
"(",
"in",
",",
"seed",
")",
"\n",
"}"
]
|
13,722 | all-13723 | [
"CreateRecords",
"creates",
"records",
"for",
"a",
"given",
"slice",
"of",
"endpoints"
]
| [
"func",
"(",
"p",
"*",
"dnsimpleProvider",
")",
"CreateRecords",
"(",
"endpoints",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
")",
"error",
"{",
"<mask>",
"p",
".",
"submitChanges",
"(",
"newDnsimpleChanges",
"(",
"dnsimpleCreate",
",",
"endpoints",
")",
")",
"\n",
"}"
]
|
13,723 | all-13724 | [
"PutUint64",
"sets",
"a",
"64",
"-",
"bit",
"unsigned",
"integer",
"for",
"the",
"given",
"field",
"name",
".",
"The",
"field",
"name",
"must",
"be",
"a",
"Uint64Field",
".",
"Otherwise",
"an",
"error",
"will",
"be",
"returned",
".",
"If",
"the",
"type",
"buffer",
"no",
"longer",
"has",
"enough",
"space",
"to",
"write",
"the",
"value",
"an",
"xbinary",
".",
"ErrOutOfRange",
"error",
"will",
"be",
"returned",
".",
"Upon",
"success",
"the",
"number",
"of",
"bytes",
"written",
"as",
"well",
"as",
"a",
"nil",
"error",
"will",
"be",
"returned",
".",
"The",
"type",
"code",
"will",
"be",
"written",
"first",
".",
"If",
"the",
"absolute",
"value",
"is",
"<",
"math",
".",
"MaxUint8",
"only",
"1",
"byte",
"will",
"be",
"written",
".",
"If",
"the",
"absolute",
"value",
"is",
"<",
"math",
".",
"MaxUint16",
"only",
"2",
"bytes",
"will",
"be",
"written",
".",
"If",
"the",
"absolute",
"value",
"is",
"<",
"math",
".",
"MaxUint32",
"only",
"4",
"bytes",
"will",
"be",
"written",
".",
"Otherwise",
"the",
"entire",
"64",
"-",
"bit",
"value",
"will",
"be",
"written",
"."
]
| [
"func",
"(",
"b",
"*",
"TupleBuilder",
")",
"PutUint64",
"(",
"field",
"string",
",",
"value",
"uint64",
")",
"(",
"wrote",
"uint64",
",",
"err",
"error",
")",
"{",
"// field type should be",
"if",
"err",
"=",
"b",
".",
"typeCheck",
"(",
"field",
",",
"Uint64Field",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"value",
"<",
"math",
".",
"MaxUint8",
"{",
"// minimum bytes is 2 (type code + value)",
"if",
"b",
".",
"available",
"(",
")",
"<",
"2",
"{",
"return",
"0",
",",
"xbinary",
".",
"ErrOutOfRange",
"\n",
"}",
"\n\n",
"// write type code",
"b",
".",
"buffer",
"[",
"b",
".",
"pos",
"]",
"=",
"byte",
"(",
"UnsignedLong8Code",
".",
"OpCode",
")",
"\n\n",
"// write value",
"b",
".",
"buffer",
"[",
"b",
".",
"pos",
"+",
"1",
"]",
"=",
"byte",
"(",
"value",
")",
"\n\n",
"// set field offset",
"b",
".",
"offsets",
"[",
"field",
"]",
"=",
"b",
".",
"pos",
"\n\n",
"// incr pos",
"b",
".",
"pos",
"+=",
"2",
"\n\n",
"return",
"2",
",",
"nil",
"\n",
"}",
"else",
"if",
"value",
"<",
"math",
".",
"MaxUint16",
"{",
"// write value",
"// length check performed by xbinary",
"wrote",
",",
"err",
"=",
"xbinary",
".",
"LittleEndian",
".",
"PutUint16",
"(",
"b",
".",
"buffer",
",",
"b",
".",
"<mask>",
"+",
"1",
",",
"uint16",
"(",
"value",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"// write type code",
"b",
".",
"buffer",
"[",
"b",
".",
"pos",
"]",
"=",
"byte",
"(",
"UnsignedLong16Code",
".",
"OpCode",
")",
"\n\n",
"// set field offset",
"b",
".",
"offsets",
"[",
"field",
"]",
"=",
"b",
".",
"pos",
"\n\n",
"// incr pos",
"b",
".",
"pos",
"+=",
"3",
"\n\n",
"// wrote 3 bytes",
"return",
"3",
",",
"nil",
"\n",
"}",
"else",
"if",
"value",
"<",
"math",
".",
"MaxUint32",
"{",
"// write value",
"// length check performed by xbinary",
"wrote",
",",
"err",
"=",
"xbinary",
".",
"LittleEndian",
".",
"PutUint32",
"(",
"b",
".",
"buffer",
",",
"b",
".",
"pos",
"+",
"1",
",",
"uint32",
"(",
"value",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"// write type code",
"b",
".",
"buffer",
"[",
"b",
".",
"pos",
"]",
"=",
"byte",
"(",
"UnsignedLong32Code",
".",
"OpCode",
")",
"\n\n",
"// set field offset",
"b",
".",
"offsets",
"[",
"field",
"]",
"=",
"b",
".",
"pos",
"\n\n",
"// incr pos",
"b",
".",
"pos",
"+=",
"5",
"\n\n",
"// wrote 5 bytes",
"return",
"5",
",",
"nil",
"\n",
"}",
"\n\n",
"// write value",
"// length check performed by xbinary",
"wrote",
",",
"err",
"=",
"xbinary",
".",
"LittleEndian",
".",
"PutUint64",
"(",
"b",
".",
"buffer",
",",
"b",
".",
"pos",
"+",
"1",
",",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"// write type code",
"b",
".",
"buffer",
"[",
"b",
".",
"pos",
"]",
"=",
"byte",
"(",
"UnsignedLong64Code",
".",
"OpCode",
")",
"\n\n",
"// set field offset",
"b",
".",
"offsets",
"[",
"field",
"]",
"=",
"b",
".",
"pos",
"\n\n",
"// incr pos",
"b",
".",
"pos",
"+=",
"9",
"\n\n",
"// wrote 9 bytes",
"return",
"9",
",",
"nil",
"\n\n",
"}"
]
|
13,724 | all-13725 | [
"Remove",
"duplicates",
"and",
"sort",
"it",
"to",
"ensure",
"reproducability",
"."
]
| [
"func",
"newAlphabet",
"(",
"s",
"string",
")",
"alphabet",
"{",
"abc",
":=",
"dedupe",
"(",
"strings",
".",
"Split",
"(",
"s",
",",
"\"",
"\"",
")",
")",
"\n\n",
"if",
"len",
"(",
"abc",
")",
"!=",
"57",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"sort",
".",
"Strings",
"(",
"abc",
")",
"\n",
"a",
":=",
"alphabet",
"{",
"len",
":",
"int64",
"(",
"len",
"(",
"abc",
")",
")",
",",
"}",
"\n",
"<mask>",
"(",
"a",
".",
"chars",
"[",
":",
"]",
",",
"abc",
")",
"\n",
"return",
"a",
"\n",
"}"
]
|
13,725 | all-13726 | [
"R",
"is",
"a",
"short",
"-",
"hand",
"function",
"to",
"extract",
"the",
"relationship",
"name",
"of",
"a",
"model",
"field",
".",
"Note",
":",
"R",
"will",
"panic",
"if",
"no",
"field",
"has",
"been",
"found",
"."
]
| [
"func",
"R",
"(",
"m",
"Model",
",",
"field",
"string",
")",
"string",
"{",
"// find field",
"f",
":=",
"Init",
"(",
"m",
")",
".",
"Meta",
"(",
")",
".",
"Fields",
"[",
"field",
"]",
"\n",
"if",
"f",
"==",
"nil",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"`coal: field \"%s\" not found on \"%s\"`",
",",
"<mask>",
",",
"m",
".",
"Meta",
"(",
")",
".",
"Name",
")",
")",
"\n",
"}",
"\n\n",
"return",
"f",
".",
"RelName",
"\n",
"}"
]
|
13,726 | all-13727 | [
"GetNetworkState",
"returns",
"metrics",
"and",
"information",
"on",
"the",
"running",
"network"
]
| [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"GetNetworkState",
"(",
"name",
"string",
")",
"(",
"*",
"api",
".",
"NetworkState",
",",
"error",
")",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"",
"\"",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"state",
":=",
"api",
".",
"NetworkState",
"{",
"}",
"\n\n",
"// Fetch the raw value",
"_",
",",
"err",
":=",
"r",
".",
"queryStruct",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"<mask>",
".",
"QueryEscape",
"(",
"name",
")",
")",
",",
"nil",
",",
"\"",
"\"",
",",
"&",
"state",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"&",
"state",
",",
"nil",
"\n",
"}"
]
|
13,727 | all-13728 | [
"addTimeout",
"adds",
"timeout",
"to",
"context",
"."
]
| [
"func",
"(",
"b",
"*",
"backendInstance",
")",
"addTimeout",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"context",
".",
"Context",
",",
"context",
".",
"CancelFunc",
")",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"ctx",
"=",
"context",
".",
"Background",
"(",
")",
"\n",
"}",
"\n",
"return",
"<mask>",
".",
"WithTimeout",
"(",
"ctx",
",",
"time",
".",
"Duration",
"(",
"b",
".",
"cfg",
".",
"Timeout",
")",
"*",
"time",
".",
"Millisecond",
")",
"\n",
"}"
]
|
13,728 | all-13729 | [
"ChangeContactModsattr",
"creates",
"a",
"new",
"CHANGE_CONTACT_MODSATTR",
"Nagios",
"command",
".",
"This",
"command",
"changes",
"the",
"modified",
"service",
"attributes",
"value",
"for",
"the",
"specified",
"contact",
".",
"Modified",
"attributes",
"values",
"are",
"used",
"by",
"Nagios",
"to",
"determine",
"which",
"object",
"properties",
"should",
"be",
"retained",
"across",
"program",
"restarts",
".",
"Thus",
"modifying",
"the",
"value",
"of",
"the",
"attributes",
"can",
"affect",
"data",
"retention",
".",
"This",
"is",
"an",
"advanced",
"option",
"and",
"should",
"only",
"be",
"used",
"by",
"people",
"who",
"are",
"intimately",
"familiar",
"with",
"the",
"data",
"retention",
"logic",
"in",
"Nagios",
"."
]
| [
"func",
"ChangeContactModsattr",
"(",
"contact_name",
"string",
",",
"value",
"string",
",",
")",
"*",
"livestatus",
".",
"Command",
"{",
"return",
"livestatus",
".",
"NewCommand",
"(",
"\"",
"\"",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"contact_name",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"<mask>",
")",
",",
")",
"\n",
"}"
]
|
13,729 | all-13730 | [
"expandVirtualMachineFlagInfo",
"reads",
"certain",
"ResourceData",
"keys",
"and",
"returns",
"a",
"VirtualMachineFlagInfo",
"."
]
| [
"func",
"expandVirtualMachineFlagInfo",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
")",
"*",
"types",
".",
"VirtualMachineFlagInfo",
"{",
"obj",
":=",
"&",
"<mask>",
".",
"VirtualMachineFlagInfo",
"{",
"DiskUuidEnabled",
":",
"getBoolWithRestart",
"(",
"d",
",",
"\"",
"\"",
")",
",",
"VirtualExecUsage",
":",
"getWithRestart",
"(",
"d",
",",
"\"",
"\"",
")",
".",
"(",
"string",
")",
",",
"VirtualMmuUsage",
":",
"getWithRestart",
"(",
"d",
",",
"\"",
"\"",
")",
".",
"(",
"string",
")",
",",
"EnableLogging",
":",
"getBoolWithRestart",
"(",
"d",
",",
"\"",
"\"",
")",
",",
"}",
"\n",
"return",
"obj",
"\n",
"}"
]
|
13,730 | all-13731 | [
"Scale",
"scales",
"the",
"matrix",
"by",
"(",
"r",
"g",
"b",
"a",
")",
"."
]
| [
"func",
"(",
"c",
"*",
"ColorM",
")",
"Scale",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
"float32",
")",
"*",
"ColorM",
"{",
"if",
"!",
"c",
".",
"isInited",
"(",
")",
"{",
"return",
"&",
"ColorM",
"{",
"body",
":",
"[",
"]",
"float32",
"{",
"r",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"g",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"b",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"a",
",",
"}",
",",
"}",
"\n",
"}",
"\n",
"eb",
":=",
"make",
"(",
"[",
"]",
"float32",
",",
"len",
"(",
"colorMIdentityBody",
")",
")",
"\n",
"if",
"c",
".",
"body",
"!=",
"nil",
"{",
"copy",
"(",
"eb",
",",
"c",
".",
"body",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"ColorMDim",
"-",
"1",
";",
"i",
"++",
"{",
"eb",
"[",
"i",
"*",
"(",
"ColorMDim",
"-",
"1",
")",
"]",
"*=",
"r",
"\n",
"eb",
"[",
"i",
"*",
"(",
"ColorMDim",
"-",
"1",
")",
"+",
"1",
"]",
"*=",
"g",
"\n",
"eb",
"[",
"i",
"*",
"(",
"ColorMDim",
"-",
"1",
")",
"+",
"2",
"]",
"*=",
"b",
"\n",
"eb",
"[",
"i",
"*",
"(",
"ColorMDim",
"-",
"1",
")",
"+",
"3",
"]",
"*=",
"a",
"\n",
"}",
"\n",
"}",
"else",
"{",
"eb",
"[",
"0",
"]",
"=",
"r",
"\n",
"eb",
"[",
"5",
"]",
"=",
"g",
"\n",
"eb",
"[",
"10",
"]",
"=",
"b",
"\n",
"eb",
"[",
"15",
"]",
"=",
"a",
"\n",
"}",
"\n\n",
"et",
":=",
"make",
"(",
"[",
"]",
"float32",
",",
"len",
"(",
"colorMIdentityTranslate",
")",
")",
"\n",
"if",
"c",
".",
"translate",
"!=",
"nil",
"{",
"et",
"[",
"0",
"]",
"=",
"c",
".",
"translate",
"[",
"0",
"]",
"*",
"r",
"\n",
"et",
"[",
"1",
"]",
"=",
"c",
".",
"translate",
"[",
"1",
"]",
"*",
"g",
"\n",
"et",
"[",
"2",
"]",
"=",
"c",
".",
"translate",
"[",
"2",
"]",
"*",
"b",
"\n",
"et",
"[",
"3",
"]",
"=",
"c",
".",
"translate",
"[",
"3",
"]",
"*",
"a",
"\n",
"}",
"\n\n",
"return",
"&",
"ColorM",
"{",
"<mask>",
":",
"eb",
",",
"translate",
":",
"et",
",",
"}",
"\n",
"}"
]
|
13,731 | all-13732 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"GetTargetInfoReturns",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoTarget8",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
13,732 | all-13733 | [
"FileCopyDir",
"recursively",
"copies",
"a",
"directory",
"tree",
"attempting",
"to",
"preserve",
"permissions",
".",
"Source",
"directory",
"must",
"exist",
"destination",
"directory",
"must",
"*",
"not",
"*",
"exist",
".",
"Based",
"on",
"Jaybill",
"McCarthy",
"s",
"code",
"which",
"can",
"be",
"found",
"at",
"http",
":",
"//",
"jayblog",
".",
"jaybill",
".",
"com",
"/",
"post",
"/",
"id",
"/",
"26"
]
| [
"func",
"FileCopyDir",
"(",
"source",
"string",
",",
"dest",
"string",
")",
"(",
"err",
"error",
")",
"{",
"// get properties of source dir\r",
"fileInfo",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"source",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"!",
"fileInfo",
".",
"IsDir",
"(",
")",
"{",
"return",
"&",
"FileCopyError",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"// ensure dest dir does not already exist\r",
"_",
",",
"err",
"=",
"os",
".",
"Open",
"(",
"dest",
")",
"\n",
"if",
"!",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"return",
"&",
"FileCopyError",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"// create dest dir\r",
"err",
"=",
"os",
".",
"MkdirAll",
"(",
"dest",
",",
"fileInfo",
".",
"Mode",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"entries",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"source",
")",
"\n",
"for",
"_",
",",
"<mask>",
":=",
"range",
"entries",
"{",
"sourcePath",
":=",
"filepath",
".",
"Join",
"(",
"source",
",",
"entry",
".",
"Name",
"(",
")",
")",
"\n",
"destinationPath",
":=",
"filepath",
".",
"Join",
"(",
"dest",
",",
"entry",
".",
"Name",
"(",
")",
")",
"\n",
"if",
"entry",
".",
"IsDir",
"(",
")",
"{",
"err",
"=",
"FileCopyDir",
"(",
"sourcePath",
",",
"destinationPath",
")",
"\n",
"}",
"else",
"{",
"// perform copy\r",
"err",
"=",
"FileCopy",
"(",
"sourcePath",
",",
"destinationPath",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
]
|
13,733 | all-13734 | [
"Return",
"the",
"highest",
"update",
"version",
"currently",
"applied",
".",
"Zero",
"means",
"that",
"no",
"updates",
"have",
"been",
"applied",
"yet",
"."
]
| [
"func",
"queryCurrentVersion",
"(",
"tx",
"*",
"sql",
".",
"Tx",
")",
"(",
"int",
",",
"error",
")",
"{",
"versions",
",",
"err",
":=",
"selectSchemaVersions",
"(",
"tx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"// Fix bad upgrade code between 30 and 32",
"hasVersion",
":=",
"func",
"(",
"v",
"int",
")",
"bool",
"{",
"return",
"shared",
".",
"IntInSlice",
"(",
"v",
",",
"versions",
")",
"}",
"\n",
"if",
"hasVersion",
"(",
"30",
")",
"&&",
"hasVersion",
"(",
"32",
")",
"&&",
"!",
"hasVersion",
"(",
"31",
")",
"{",
"err",
"=",
"insertSchemaVersion",
"(",
"tx",
",",
"31",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"versions",
",",
"err",
"=",
"selectSchemaVersions",
"(",
"tx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Fix broken schema version between 37 and 38",
"if",
"hasVersion",
"(",
"37",
")",
"&&",
"!",
"hasVersion",
"(",
"38",
")",
"{",
"count",
",",
"err",
":=",
"query",
".",
"Count",
"(",
"<mask>",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"count",
"==",
"1",
"{",
"// Insert the missing version.",
"err",
":=",
"insertSchemaVersion",
"(",
"tx",
",",
"38",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"versions",
"=",
"append",
"(",
"versions",
",",
"38",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"current",
":=",
"0",
"\n",
"if",
"len",
"(",
"versions",
")",
">",
"0",
"{",
"err",
"=",
"checkSchemaVersionsHaveNoHoles",
"(",
"versions",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"current",
"=",
"versions",
"[",
"len",
"(",
"versions",
")",
"-",
"1",
"]",
"// Highest recorded version",
"\n",
"}",
"\n\n",
"return",
"current",
",",
"nil",
"\n",
"}"
]
|
13,734 | all-13735 | [
"Append",
"a",
"code",
"snippet",
"to",
"a",
"file",
"."
]
| [
"func",
"Append",
"(",
"path",
"string",
",",
"snippet",
"Snippet",
")",
"error",
"{",
"buffer",
":=",
"newBuffer",
"(",
")",
"\n",
"buffer",
".",
"N",
"(",
")",
"\n\n",
"err",
":=",
"snippet",
".",
"Generate",
"(",
"buffer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"file",
"*",
"os",
".",
"File",
"\n\n",
"if",
"path",
"==",
"\"",
"\"",
"{",
"file",
"=",
"os",
".",
"Stdout",
"\n",
"}",
"else",
"{",
"file",
",",
"err",
"=",
"os",
".",
"OpenFile",
"(",
"path",
",",
"os",
".",
"O_APPEND",
"|",
"os",
".",
"O_WRONLY",
",",
"0644",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"path",
")",
"\n",
"}",
"\n",
"defer",
"file",
".",
"Close",
"(",
")",
"\n",
"}",
"\n\n",
"<mask>",
",",
"err",
":=",
"buffer",
".",
"code",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"file",
".",
"Write",
"(",
"bytes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"path",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
]
|
13,735 | all-13736 | [
"Perform",
"a",
"database",
"dump",
"."
]
| [
"func",
"internalSQLGet",
"(",
"d",
"*",
"Daemon",
",",
"r",
"*",
"http",
".",
"Request",
")",
"Response",
"{",
"database",
":=",
"r",
".",
"FormValue",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"!",
"shared",
".",
"StringInSlice",
"(",
"database",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
")",
"{",
"return",
"BadRequest",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n\n",
"schemaFormValue",
":=",
"r",
".",
"FormValue",
"(",
"\"",
"\"",
")",
"\n",
"schemaOnly",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"schemaFormValue",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"schemaOnly",
"=",
"0",
"\n",
"}",
"\n\n",
"var",
"schema",
"string",
"\n",
"var",
"db",
"*",
"sql",
".",
"DB",
"\n",
"if",
"<mask>",
"==",
"\"",
"\"",
"{",
"db",
"=",
"d",
".",
"cluster",
".",
"DB",
"(",
")",
"\n",
"schema",
"=",
"cluster",
".",
"FreshSchema",
"(",
")",
"\n",
"}",
"else",
"{",
"db",
"=",
"d",
".",
"db",
".",
"DB",
"(",
")",
"\n",
"schema",
"=",
"node",
".",
"FreshSchema",
"(",
")",
"\n",
"}",
"\n\n",
"tx",
",",
"err",
":=",
"db",
".",
"Begin",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SmartError",
"(",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"defer",
"tx",
".",
"Rollback",
"(",
")",
"\n",
"dump",
",",
"err",
":=",
"query",
".",
"Dump",
"(",
"tx",
",",
"schema",
",",
"schemaOnly",
"==",
"1",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"SmartError",
"(",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"database",
")",
")",
"\n",
"}",
"\n",
"return",
"SyncResponse",
"(",
"true",
",",
"internalSQLDump",
"{",
"Text",
":",
"dump",
"}",
")",
"\n",
"}"
]
|
13,736 | all-13737 | [
"NewController",
"creates",
"a",
"new",
"Controller",
"from",
"the",
"provided",
"clients",
"."
]
| [
"func",
"NewController",
"(",
"prowJobClient",
"prowv1",
".",
"ProwJobInterface",
",",
"jc",
"*",
"Client",
",",
"ghc",
"*",
"github",
".",
"Client",
",",
"logger",
"*",
"logrus",
".",
"<mask>",
",",
"cfg",
"config",
".",
"Getter",
",",
"totURL",
",",
"selector",
"string",
")",
"(",
"*",
"Controller",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"snowflake",
".",
"NewNode",
"(",
"1",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"logger",
"==",
"nil",
"{",
"logger",
"=",
"logrus",
".",
"NewEntry",
"(",
"logrus",
".",
"StandardLogger",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"&",
"Controller",
"{",
"prowJobClient",
":",
"prowJobClient",
",",
"jc",
":",
"jc",
",",
"ghc",
":",
"ghc",
",",
"log",
":",
"logger",
",",
"cfg",
":",
"cfg",
",",
"selector",
":",
"selector",
",",
"node",
":",
"n",
",",
"totURL",
":",
"totURL",
",",
"pendingJobs",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
")",
",",
"}",
",",
"nil",
"\n",
"}"
]
|
13,737 | all-13738 | [
"Render",
"will",
"return",
"the",
"HTML",
"of",
"the",
"bar",
"used",
"this",
"function",
"to",
"render",
"the",
"bar",
"in",
"frontend",
"page",
"s",
"template",
"or",
"layout"
]
| [
"func",
"(",
"bar",
"*",
"ActionBar",
")",
"Render",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"template",
".",
"HTML",
"{",
"var",
"(",
"actions",
",",
"inlineActions",
"[",
"]",
"ActionInterface",
"\n",
"context",
"=",
"bar",
".",
"Admin",
".",
"NewContext",
"(",
"w",
",",
"r",
")",
"\n",
")",
"\n",
"for",
"_",
",",
"<mask>",
":=",
"range",
"bar",
".",
"actions",
"{",
"if",
"action",
".",
"InlineAction",
"(",
")",
"{",
"inlineActions",
"=",
"append",
"(",
"inlineActions",
",",
"action",
")",
"\n",
"}",
"else",
"{",
"actions",
"=",
"append",
"(",
"actions",
",",
"action",
")",
"\n",
"}",
"\n",
"}",
"\n",
"context",
".",
"Context",
".",
"CurrentUser",
"=",
"bar",
".",
"Admin",
".",
"Auth",
".",
"GetCurrentUser",
"(",
"context",
")",
"\n",
"result",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"bar",
".",
"EditMode",
"(",
"w",
",",
"r",
")",
",",
"\"",
"\"",
":",
"bar",
".",
"Admin",
".",
"Auth",
",",
"\"",
"\"",
":",
"context",
".",
"Context",
".",
"CurrentUser",
",",
"\"",
"\"",
":",
"actions",
",",
"\"",
"\"",
":",
"inlineActions",
",",
"\"",
"\"",
":",
"bar",
".",
"Admin",
".",
"GetRouter",
"(",
")",
".",
"Prefix",
",",
"}",
"\n",
"return",
"context",
".",
"Render",
"(",
"\"",
"\"",
",",
"result",
")",
"\n",
"}"
]
|
13,738 | all-13739 | [
"Reverse",
"yields",
"items",
"in",
"the",
"reverse",
"of",
"the",
"order",
"it",
"received",
"them",
"."
]
| [
"func",
"Reverse",
"(",
")",
"Filter",
"{",
"return",
"FilterFunc",
"(",
"func",
"(",
"arg",
"Arg",
")",
"error",
"{",
"<mask>",
"data",
"[",
"]",
"string",
"\n",
"for",
"s",
":=",
"range",
"arg",
".",
"In",
"{",
"data",
"=",
"append",
"(",
"data",
",",
"s",
")",
"\n",
"}",
"\n",
"for",
"i",
":=",
"len",
"(",
"data",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"arg",
".",
"Out",
"<-",
"data",
"[",
"i",
"]",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"}"
]
|
13,739 | all-13740 | [
"GetPage",
"returns",
"a",
"single",
"Page",
"of",
"resources",
"filtered",
"by",
"data",
".",
"See",
"https",
":",
"//",
"www",
".",
"twilio",
".",
"com",
"/",
"docs",
"/",
"api",
"/",
"monitor",
"/",
"alerts#list",
"-",
"get",
"-",
"filters",
"."
]
| [
"func",
"(",
"a",
"*",
"AlertService",
")",
"GetPage",
"(",
"ctx",
"<mask>",
".",
"Context",
",",
"data",
"url",
".",
"Values",
")",
"(",
"*",
"AlertPage",
",",
"error",
")",
"{",
"return",
"a",
".",
"GetPageIterator",
"(",
"data",
")",
".",
"Next",
"(",
"ctx",
")",
"\n",
"}"
]
|
13,740 | all-13741 | [
"WithURL",
"if",
"set",
"the",
"request",
"url",
"will",
"be",
"modified",
"in",
"a",
"way",
"that",
"s",
"not",
"observable",
"by",
"page",
".",
"Must",
"not",
"be",
"set",
"in",
"response",
"to",
"an",
"authChallenge",
"."
]
| [
"func",
"(",
"p",
"ContinueInterceptedRequestParams",
")",
"WithURL",
"(",
"url",
"string",
")",
"*",
"ContinueInterceptedRequestParams",
"{",
"p",
".",
"URL",
"=",
"<mask>",
"\n",
"return",
"&",
"p",
"\n",
"}"
]
|
13,741 | all-13742 | [
"GetPaymentOp",
"retrieves",
"the",
"PaymentOp",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
]
| [
"func",
"(",
"u",
"OperationBody",
")",
"GetPaymentOp",
"(",
")",
"(",
"<mask>",
"PaymentOp",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Type",
")",
")",
"\n\n",
"if",
"armName",
"==",
"\"",
"\"",
"{",
"result",
"=",
"*",
"u",
".",
"PaymentOp",
"\n",
"ok",
"=",
"true",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
]
|
13,742 | all-13743 | [
"title",
":",
"node",
"info",
"path",
":",
"/",
"node",
"/",
"{",
"address",
"}",
"method",
":",
"GET",
"produce",
":",
"application",
"/",
"json",
"responses",
":",
"200",
":",
"Ok",
"401",
":",
"Unauthorized",
"404",
":",
"Not",
"found"
]
| [
"func",
"infoNodeHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"t",
"auth",
".",
"Token",
")",
"error",
"{",
"address",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"address",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"_",
",",
"node",
",",
"err",
":=",
"node",
".",
"FindNode",
"(",
"address",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"provision",
".",
"ErrNodeNotFound",
"{",
"return",
"&",
"tsuruErrors",
".",
"HTTP",
"{",
"Code",
":",
"http",
".",
"StatusNotFound",
",",
"Message",
":",
"err",
".",
"Error",
"(",
")",
",",
"}",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"hasAccess",
":=",
"permission",
".",
"Check",
"(",
"t",
",",
"permission",
".",
"PermNodeRead",
",",
"permission",
".",
"Context",
"(",
"permTypes",
".",
"CtxPool",
",",
"node",
".",
"Pool",
"(",
")",
")",
")",
"\n",
"if",
"!",
"hasAccess",
"{",
"return",
"permission",
".",
"ErrUnauthorized",
"\n",
"}",
"\n",
"spec",
":=",
"provision",
".",
"NodeToSpec",
"(",
"node",
")",
"\n",
"if",
"spec",
".",
"IaaSID",
"==",
"\"",
"\"",
"{",
"var",
"machine",
"iaas",
".",
"Machine",
"\n",
"machine",
",",
"err",
"=",
"iaas",
".",
"FindMachineByAddress",
"(",
"address",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"err",
"!=",
"iaas",
".",
"ErrMachineNotFound",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"else",
"{",
"<mask>",
".",
"IaaSID",
"=",
"machine",
".",
"Iaas",
"\n",
"}",
"\n",
"}",
"\n",
"nodeStatus",
",",
"err",
":=",
"healer",
".",
"HealerInstance",
".",
"GetNodeStatusData",
"(",
"node",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"provision",
".",
"ErrNodeNotFound",
"{",
"return",
"&",
"tsuruErrors",
".",
"HTTP",
"{",
"Code",
":",
"http",
".",
"StatusNotFound",
",",
"Message",
":",
"err",
".",
"Error",
"(",
")",
",",
"}",
"\n",
"}",
"\n",
"units",
",",
"err",
":=",
"node",
".",
"Units",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"&",
"tsuruErrors",
".",
"HTTP",
"{",
"Code",
":",
"http",
".",
"StatusNotFound",
",",
"Message",
":",
"err",
".",
"Error",
"(",
")",
",",
"}",
"\n",
"}",
"\n",
"response",
":=",
"apiTypes",
".",
"InfoNodeResponse",
"{",
"Node",
":",
"spec",
",",
"Status",
":",
"nodeStatus",
",",
"Units",
":",
"units",
",",
"}",
"\n",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"json",
".",
"NewEncoder",
"(",
"w",
")",
".",
"Encode",
"(",
"response",
")",
"\n",
"}"
]
|
13,743 | all-13744 | [
"GetInputHints",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_entry_get_input_hints",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"<mask>",
")",
"GetInputHints",
"(",
")",
"InputHints",
"{",
"c",
":=",
"C",
".",
"gtk_entry_get_input_hints",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"return",
"InputHints",
"(",
"c",
")",
"\n",
"}"
]
|
13,744 | all-13745 | [
"CompleteRequest",
"completes",
"a",
"money",
"request",
"referenced",
"by",
"id"
]
| [
"func",
"(",
"c",
"<mask>",
")",
"CompleteRequest",
"(",
"id",
"string",
")",
"(",
"*",
"transactionConfirmation",
",",
"error",
")",
"{",
"return",
"c",
".",
"transactionRequest",
"(",
"\"",
"\"",
",",
"id",
"+",
"\"",
"\"",
",",
"nil",
")",
"\n",
"}"
]
|
13,745 | all-13746 | [
"Create",
"a",
"Typed",
"helper",
"from",
"the",
"given",
"JSON",
"bytes",
"panics",
"on",
"error"
]
| [
"func",
"Must",
"(",
"data",
"[",
"]",
"byte",
")",
"Typed",
"{",
"<mask>",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"m",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"Typed",
"(",
"m",
")",
"\n",
"}"
]
|
13,746 | all-13747 | [
"getConfigBlob",
"exists",
"only",
"to",
"let",
"us",
"retrieve",
"the",
"configuration",
"blob",
"so",
"that",
"the",
"manifest",
"package",
"can",
"dig",
"information",
"out",
"of",
"it",
"for",
"Inspect",
"()",
"."
]
| [
"func",
"(",
"s",
"*",
"storageImageDestination",
")",
"getConfigBlob",
"(",
"info",
"types",
".",
"BlobInfo",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"info",
".",
"Digest",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"<mask>",
".",
"Errorf",
"(",
"`no digest supplied when reading blob`",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"info",
".",
"Digest",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"`invalid digest supplied when reading blob`",
")",
"\n",
"}",
"\n",
"// Assume it's a file, since we're only calling this from a place that expects to read files.",
"if",
"filename",
",",
"ok",
":=",
"s",
".",
"filenames",
"[",
"info",
".",
"Digest",
"]",
";",
"ok",
"{",
"contents",
",",
"err2",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filename",
")",
"\n",
"if",
"err2",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"err2",
",",
"`error reading blob from file %q`",
",",
"filename",
")",
"\n",
"}",
"\n",
"return",
"contents",
",",
"nil",
"\n",
"}",
"\n",
"// If it's not a file, it's a bug, because we're not expecting to be asked for a layer.",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
]
|
13,747 | all-13748 | [
"Registry",
"returns",
"the",
"list",
"of",
"registered",
"builders",
"."
]
| [
"func",
"Registry",
"(",
")",
"(",
"[",
"]",
"Builder",
",",
"error",
")",
"{",
"registry",
":=",
"make",
"(",
"[",
"]",
"Builder",
",",
"0",
",",
"len",
"(",
"builders",
")",
")",
"\n",
"for",
"_",
",",
"b",
":=",
"<mask>",
"builders",
"{",
"registry",
"=",
"append",
"(",
"registry",
",",
"b",
")",
"\n",
"}",
"\n",
"return",
"registry",
",",
"nil",
"\n",
"}"
]
|
13,748 | all-13749 | [
"determine",
"if",
"a",
"name",
"corresponds",
"to",
"a",
"renderbuffer",
"object"
]
| [
"func",
"IsRenderbuffer",
"(",
"renderbuffer",
"uint32",
")",
"bool",
"{",
"ret",
":=",
"C",
".",
"glowIsRenderbuffer",
"(",
"gpIsRenderbuffer",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"renderbuffer",
")",
")",
"\n",
"return",
"<mask>",
"==",
"TRUE",
"\n",
"}"
]
|
13,749 | all-13750 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"GetScriptSourceParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger34",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
13,750 | all-13751 | [
"String",
"returns",
"a",
"human",
"-",
"readable",
"representation",
"of",
"the",
"node",
"info",
"."
]
| [
"func",
"(",
"info",
"NodeInfo",
")",
"String",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"<mask>",
".",
"Hostname",
")",
"!=",
"0",
"{",
"return",
"info",
".",
"Hostname",
"\n",
"}",
"\n",
"return",
"httpBroadcastAddress",
"(",
"info",
")",
"\n",
"}"
]
|
13,751 | all-13752 | [
"/",
"*",
"Fatalf",
"uses",
"msg",
"as",
"a",
"format",
"string",
"with",
"subsequent",
"parameters",
"as",
"values",
"and",
"logs",
"the",
"resulting",
"message",
"to",
"all",
"added",
"loggers",
"at",
"LogLevel",
".",
"LevelFatal"
]
| [
"func",
"(",
"la",
"*",
"LogAdapter",
")",
"Fatalf",
"(",
"<mask>",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"la",
".",
"Log",
"(",
"LevelFatal",
",",
"nil",
",",
"msg",
",",
"a",
"...",
")",
"\n",
"}"
]
|
13,752 | all-13753 | [
"--------------------------------------------------------------------------",
"Marshaling",
"of",
"base",
"types",
"."
]
| [
"func",
"(",
"e",
"*",
"encoder",
")",
"addBinary",
"(",
"subtype",
"<mask>",
",",
"v",
"[",
"]",
"byte",
")",
"{",
"if",
"subtype",
"==",
"0x02",
"{",
"// Wonder how that brilliant idea came to life. Obsolete, luckily.",
"e",
".",
"addInt32",
"(",
"int32",
"(",
"len",
"(",
"v",
")",
"+",
"4",
")",
")",
"\n",
"e",
".",
"addBytes",
"(",
"subtype",
")",
"\n",
"e",
".",
"addInt32",
"(",
"int32",
"(",
"len",
"(",
"v",
")",
")",
")",
"\n",
"}",
"else",
"{",
"e",
".",
"addInt32",
"(",
"int32",
"(",
"len",
"(",
"v",
")",
")",
")",
"\n",
"e",
".",
"addBytes",
"(",
"subtype",
")",
"\n",
"}",
"\n",
"e",
".",
"addBytes",
"(",
"v",
"...",
")",
"\n",
"}"
]
|
13,753 | all-13754 | [
"Do",
"shutdowns",
"All",
"registered",
"Shutdownable",
"items"
]
| [
"func",
"Do",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"done",
":=",
"make",
"(",
"chan",
"bool",
")",
"\n",
"wg",
":=",
"sync",
".",
"WaitGroup",
"{",
"}",
"\n",
"for",
"_",
",",
"h",
":=",
"range",
"registered",
"{",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"func",
"(",
"h",
"Shutdownable",
")",
"{",
"defer",
"wg",
".",
"Done",
"(",
")",
"\n",
"<mask>",
"name",
"string",
"\n",
"if",
"_",
",",
"ok",
":=",
"h",
".",
"(",
"fmt",
".",
"Stringer",
")",
";",
"ok",
"{",
"name",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"h",
")",
"\n",
"}",
"else",
"{",
"name",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"h",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"err",
":=",
"h",
".",
"Shutdown",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\"",
",",
"name",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\n",
"\"",
",",
"name",
")",
"\n",
"}",
"(",
"h",
")",
"\n",
"}",
"\n",
"go",
"func",
"(",
")",
"{",
"wg",
".",
"Wait",
"(",
")",
"\n",
"close",
"(",
"done",
")",
"\n",
"}",
"(",
")",
"\n",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx",
".",
"Err",
"(",
")",
"\n",
"case",
"<-",
"done",
":",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
13,754 | all-13755 | [
"GetNoIssuer",
"retrieves",
"the",
"NoIssuer",
"value",
"from",
"the",
"union",
"returning",
"ok",
"if",
"the",
"union",
"s",
"switch",
"indicated",
"the",
"value",
"is",
"valid",
"."
]
| [
"func",
"(",
"u",
"PathPaymentResult",
")",
"GetNoIssuer",
"(",
")",
"(",
"result",
"Asset",
",",
"ok",
"bool",
")",
"{",
"armName",
",",
"_",
":=",
"u",
".",
"ArmForSwitch",
"(",
"int32",
"(",
"u",
".",
"Code",
")",
")",
"\n\n",
"if",
"armName",
"==",
"\"",
"\"",
"{",
"result",
"=",
"*",
"u",
".",
"NoIssuer",
"\n",
"ok",
"=",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
]
|
13,755 | all-13756 | [
"DesiredTerminal",
"returns",
"true",
"if",
"the",
"secret",
"s",
"desired",
"status",
"is",
"REMOVED"
]
| [
"func",
"(",
"secret",
"*",
"ASMSecretResource",
")",
"DesiredTerminal",
"(",
")",
"bool",
"{",
"secret",
".",
"<mask>",
".",
"RLock",
"(",
")",
"\n",
"defer",
"secret",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"secret",
".",
"desiredStatusUnsafe",
"==",
"resourcestatus",
".",
"ResourceStatus",
"(",
"ASMSecretRemoved",
")",
"\n",
"}"
]
|
13,756 | all-13757 | [
"ExecuteFunc",
"calls",
"f",
"on",
"each",
"template",
"tag",
"(",
"placeholder",
")",
"occurrence",
".",
"Returns",
"the",
"number",
"of",
"bytes",
"written",
"to",
"w",
".",
"This",
"function",
"is",
"optimized",
"for",
"frozen",
"templates",
".",
"Use",
"ExecuteFunc",
"for",
"constantly",
"changing",
"templates",
"."
]
| [
"func",
"(",
"t",
"*",
"Template",
")",
"ExecuteFunc",
"(",
"w",
"io",
".",
"Writer",
",",
"f",
"TagFunc",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"nn",
"int64",
"\n\n",
"n",
":=",
"len",
"(",
"t",
".",
"texts",
")",
"-",
"1",
"\n",
"if",
"n",
"==",
"-",
"1",
"{",
"ni",
",",
"err",
":=",
"w",
".",
"Write",
"(",
"unsafeString2Bytes",
"(",
"t",
".",
"<mask>",
")",
")",
"\n",
"return",
"int64",
"(",
"ni",
")",
",",
"err",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"ni",
",",
"err",
":=",
"w",
".",
"Write",
"(",
"t",
".",
"texts",
"[",
"i",
"]",
")",
"\n",
"nn",
"+=",
"int64",
"(",
"ni",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nn",
",",
"err",
"\n",
"}",
"\n\n",
"ni",
",",
"err",
"=",
"f",
"(",
"w",
",",
"t",
".",
"tags",
"[",
"i",
"]",
")",
"\n",
"nn",
"+=",
"int64",
"(",
"ni",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nn",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"ni",
",",
"err",
":=",
"w",
".",
"Write",
"(",
"t",
".",
"texts",
"[",
"n",
"]",
")",
"\n",
"nn",
"+=",
"int64",
"(",
"ni",
")",
"\n",
"return",
"nn",
",",
"err",
"\n",
"}"
]
|
13,757 | all-13758 | [
"UnmarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Unmarshaler",
"."
]
| [
"func",
"(",
"t",
"*",
"ValueNativeSourceType",
")",
"UnmarshalEasyJSON",
"(",
"in",
"*",
"jlexer",
".",
"Lexer",
")",
"{",
"switch",
"ValueNativeSourceType",
"(",
"in",
".",
"String",
"(",
")",
")",
"{",
"case",
"ValueNativeSourceTypeFigcaption",
":",
"*",
"t",
"=",
"ValueNativeSourceTypeFigcaption",
"\n",
"case",
"ValueNativeSourceTypeLabel",
":",
"*",
"t",
"=",
"ValueNativeSourceTypeLabel",
"\n",
"case",
"ValueNativeSourceTypeLabelfor",
":",
"*",
"t",
"=",
"ValueNativeSourceTypeLabelfor",
"\n",
"case",
"ValueNativeSourceTypeLabelwrapped",
":",
"*",
"t",
"=",
"ValueNativeSourceTypeLabelwrapped",
"\n",
"<mask>",
"ValueNativeSourceTypeLegend",
":",
"*",
"t",
"=",
"ValueNativeSourceTypeLegend",
"\n",
"case",
"ValueNativeSourceTypeTablecaption",
":",
"*",
"t",
"=",
"ValueNativeSourceTypeTablecaption",
"\n",
"case",
"ValueNativeSourceTypeTitle",
":",
"*",
"t",
"=",
"ValueNativeSourceTypeTitle",
"\n",
"case",
"ValueNativeSourceTypeOther",
":",
"*",
"t",
"=",
"ValueNativeSourceTypeOther",
"\n\n",
"default",
":",
"in",
".",
"AddError",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"}"
]
|
13,758 | all-13759 | [
"receiver",
"emits",
"to",
"fn",
"code",
"for",
"expression",
"e",
"in",
"the",
"receiver",
"position",
"of",
"selection",
"e",
".",
"f",
"(",
"where",
"f",
"may",
"be",
"a",
"field",
"or",
"a",
"method",
")",
"and",
"returns",
"the",
"effective",
"receiver",
"after",
"applying",
"the",
"implicit",
"field",
"selections",
"of",
"sel",
".",
"wantAddr",
"requests",
"that",
"the",
"result",
"is",
"an",
"an",
"address",
".",
"If",
"!sel",
".",
"Indirect",
"()",
"this",
"may",
"require",
"that",
"e",
"be",
"built",
"in",
"addr",
"()",
"mode",
";",
"it",
"must",
"thus",
"be",
"addressable",
".",
"escaping",
"is",
"defined",
"as",
"per",
"builder",
".",
"addr",
"()",
"."
]
| [
"func",
"(",
"b",
"*",
"builder",
")",
"receiver",
"(",
"fn",
"*",
"Function",
",",
"e",
"ast",
".",
"Expr",
",",
"wantAddr",
",",
"escaping",
"bool",
",",
"sel",
"*",
"<mask>",
".",
"Selection",
")",
"Value",
"{",
"var",
"v",
"Value",
"\n",
"if",
"wantAddr",
"&&",
"!",
"sel",
".",
"Indirect",
"(",
")",
"&&",
"!",
"isPointer",
"(",
"fn",
".",
"Pkg",
".",
"typeOf",
"(",
"e",
")",
")",
"{",
"v",
"=",
"b",
".",
"addr",
"(",
"fn",
",",
"e",
",",
"escaping",
")",
".",
"address",
"(",
"fn",
")",
"\n",
"}",
"else",
"{",
"v",
"=",
"b",
".",
"expr",
"(",
"fn",
",",
"e",
")",
"\n",
"}",
"\n\n",
"last",
":=",
"len",
"(",
"sel",
".",
"Index",
"(",
")",
")",
"-",
"1",
"\n",
"v",
"=",
"emitImplicitSelections",
"(",
"fn",
",",
"v",
",",
"sel",
".",
"Index",
"(",
")",
"[",
":",
"last",
"]",
")",
"\n",
"if",
"!",
"wantAddr",
"&&",
"isPointer",
"(",
"v",
".",
"Type",
"(",
")",
")",
"{",
"v",
"=",
"emitLoad",
"(",
"fn",
",",
"v",
")",
"\n",
"}",
"\n",
"return",
"v",
"\n",
"}"
]
|
13,759 | all-13760 | [
"NewFrame",
"allocates",
"a",
"new",
"frame",
"with",
"the",
"given",
"payload",
"capacity"
]
| [
"func",
"NewFrame",
"(",
"payloadCapacity",
"int",
")",
"*",
"Frame",
"{",
"f",
":=",
"&",
"Frame",
"{",
"}",
"\n",
"f",
".",
"buffer",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"payloadCapacity",
"+",
"FrameHeaderSize",
")",
"\n",
"f",
".",
"Payload",
"=",
"f",
".",
"buffer",
"[",
"FrameHeaderSize",
":",
"]",
"\n",
"f",
".",
"headerBuffer",
"=",
"f",
".",
"<mask>",
"[",
":",
"FrameHeaderSize",
"]",
"\n",
"return",
"f",
"\n",
"}"
]
|
13,760 | all-13761 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"TakeTypeProfileReturns",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"<mask>",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoProfiler2",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
13,761 | all-13762 | [
"FirstIndex",
"implements",
"the",
"Storage",
"interface",
"."
]
| [
"func",
"(",
"ms",
"*",
"MemoryStorage",
")",
"FirstIndex",
"(",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"ms",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ms",
".",
"Unlock",
"(",
")",
"\n",
"return",
"<mask>",
".",
"firstIndex",
"(",
")",
",",
"nil",
"\n",
"}"
]
|
13,762 | all-13763 | [
"GetLastResolvedTsOk",
"returns",
"a",
"tuple",
"with",
"the",
"LastResolvedTs",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"g",
"*",
"GroupData",
")",
"GetLastResolvedTsOk",
"(",
")",
"(",
"int",
",",
"bool",
")",
"{",
"if",
"g",
"==",
"nil",
"||",
"g",
".",
"LastResolvedTs",
"==",
"nil",
"{",
"return",
"0",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"g",
".",
"LastResolvedTs",
",",
"true",
"\n",
"}"
]
|
13,763 | all-13764 | [
"UnmarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Unmarshaler",
"."
]
| [
"func",
"(",
"t",
"*",
"ScreenshotParamsFormat",
")",
"UnmarshalEasyJSON",
"(",
"in",
"*",
"jlexer",
".",
"Lexer",
")",
"{",
"switch",
"ScreenshotParamsFormat",
"(",
"in",
".",
"String",
"(",
")",
")",
"{",
"case",
"ScreenshotParamsFormatJpeg",
":",
"*",
"t",
"=",
"ScreenshotParamsFormatJpeg",
"\n",
"<mask>",
"ScreenshotParamsFormatPng",
":",
"*",
"t",
"=",
"ScreenshotParamsFormatPng",
"\n\n",
"default",
":",
"in",
".",
"AddError",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"}"
]
|
13,764 | all-13765 | [
"DeleteProject",
"deletes",
"a",
"project",
"and",
"all",
"of",
"its",
"jobs",
"."
]
| [
"func",
"(",
"c",
"*",
"<mask>",
")",
"DeleteProject",
"(",
"name",
"string",
")",
"error",
"{",
"return",
"c",
".",
"delete",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"name",
"}",
")",
"\n",
"}"
]
|
13,765 | all-13766 | [
"HasTitleAlign",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"h",
"*",
"HostmapDefinition",
")",
"HasTitleAlign",
"(",
")",
"bool",
"{",
"if",
"h",
"!=",
"nil",
"&&",
"h",
".",
"TitleAlign",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
]
|
13,766 | all-13767 | [
"InviteUsers",
"takes",
"a",
"slice",
"of",
"email",
"addresses",
"and",
"sends",
"invitations",
"to",
"them",
"."
]
| [
"func",
"(",
"client",
"*",
"Client",
")",
"InviteUsers",
"(",
"emails",
"[",
"]",
"string",
")",
"error",
"{",
"return",
"<mask>",
".",
"doJsonRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"reqInviteUsers",
"{",
"Emails",
":",
"emails",
"}",
",",
"nil",
")",
"\n",
"}"
]
|
13,767 | all-13768 | [
"fetchApps",
"requests",
"a",
"list",
"of",
"applications",
"from",
"a",
"marathon",
"server",
"."
]
| [
"func",
"fetchApps",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"*",
"http",
".",
"Client",
",",
"url",
"string",
")",
"(",
"*",
"appList",
",",
"error",
")",
"{",
"request",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"url",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"request",
"=",
"request",
".",
"WithContext",
"(",
"ctx",
")",
"\n\n",
"resp",
",",
"err",
":=",
"<mask>",
".",
"Do",
"(",
"request",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"io",
".",
"Copy",
"(",
"ioutil",
".",
"Discard",
",",
"resp",
".",
"Body",
")",
"\n",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"}",
"(",
")",
"\n\n",
"if",
"(",
"resp",
".",
"StatusCode",
"<",
"200",
")",
"||",
"(",
"resp",
".",
"StatusCode",
">=",
"300",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"resp",
".",
"StatusCode",
")",
"\n",
"}",
"\n\n",
"var",
"apps",
"appList",
"\n",
"err",
"=",
"json",
".",
"NewDecoder",
"(",
"resp",
".",
"Body",
")",
".",
"Decode",
"(",
"&",
"apps",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"url",
")",
"\n",
"}",
"\n",
"return",
"&",
"apps",
",",
"nil",
"\n",
"}"
]
|
13,768 | all-13769 | [
"RequirementsMet",
"returns",
"a",
"bool",
"indicating",
"whether",
"the",
"PR",
"has",
"met",
"all",
"approval",
"requirements",
":",
"-",
"all",
"OWNERS",
"files",
"associated",
"with",
"the",
"PR",
"have",
"been",
"approved",
"AND",
"EITHER",
"-",
"the",
"munger",
"config",
"is",
"such",
"that",
"an",
"issue",
"is",
"not",
"required",
"to",
"be",
"associated",
"with",
"the",
"PR",
"-",
"that",
"there",
"is",
"an",
"associated",
"issue",
"with",
"the",
"PR",
"-",
"an",
"OWNER",
"has",
"indicated",
"that",
"the",
"PR",
"is",
"trivial",
"enough",
"that",
"an",
"issue",
"need",
"not",
"be",
"associated",
"with",
"the",
"PR"
]
| [
"func",
"(",
"ap",
"Approvers",
")",
"RequirementsMet",
"(",
")",
"bool",
"{",
"<mask>",
"ap",
".",
"AreFilesApproved",
"(",
")",
"&&",
"(",
"!",
"ap",
".",
"RequireIssue",
"||",
"ap",
".",
"AssociatedIssue",
"!=",
"0",
"||",
"len",
"(",
"ap",
".",
"NoIssueApprovers",
"(",
")",
")",
"!=",
"0",
")",
"\n",
"}"
]
|
13,769 | all-13770 | [
"rotateLeft",
"moves",
"x",
"so",
"it",
"is",
"left",
"of",
"its",
"right",
"child"
]
| [
"func",
"(",
"ivt",
"*",
"IntervalTree",
")",
"rotateLeft",
"(",
"x",
"*",
"intervalNode",
")",
"{",
"y",
":=",
"x",
".",
"right",
"\n",
"x",
".",
"right",
"=",
"y",
".",
"left",
"\n",
"if",
"y",
".",
"left",
"!=",
"nil",
"{",
"y",
".",
"left",
".",
"parent",
"=",
"x",
"\n",
"}",
"\n",
"x",
".",
"updateMax",
"(",
")",
"\n",
"ivt",
".",
"replaceParent",
"(",
"x",
",",
"y",
")",
"\n",
"y",
".",
"<mask>",
"=",
"x",
"\n",
"y",
".",
"updateMax",
"(",
")",
"\n",
"}"
]
|
13,770 | all-13771 | [
"SetHistogramValue",
"adds",
"a",
"value",
"to",
"a",
"histogram"
]
| [
"func",
"(",
"m",
"*",
"CirconusMetrics",
")",
"SetHistogramValue",
"(",
"metric",
"<mask>",
",",
"val",
"float64",
")",
"{",
"hist",
":=",
"m",
".",
"NewHistogram",
"(",
"metric",
")",
"\n\n",
"m",
".",
"hm",
".",
"Lock",
"(",
")",
"\n",
"hist",
".",
"rw",
".",
"Lock",
"(",
")",
"\n",
"hist",
".",
"hist",
".",
"RecordValue",
"(",
"val",
")",
"\n",
"hist",
".",
"rw",
".",
"Unlock",
"(",
")",
"\n",
"m",
".",
"hm",
".",
"Unlock",
"(",
")",
"\n",
"}"
]
|
13,771 | all-13772 | [
"GetDefaultSize",
"is",
"a",
"wrapper",
"around",
"gtk_window_get_default_size",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"Window",
")",
"GetDefaultSize",
"(",
")",
"(",
"width",
",",
"height",
"int",
")",
"{",
"<mask>",
"w",
",",
"h",
"C",
".",
"gint",
"\n",
"C",
".",
"gtk_window_get_default_size",
"(",
"v",
".",
"native",
"(",
")",
",",
"&",
"w",
",",
"&",
"h",
")",
"\n",
"return",
"int",
"(",
"w",
")",
",",
"int",
"(",
"h",
")",
"\n",
"}"
]
|
13,772 | all-13773 | [
"Server",
"retrieves",
"a",
"detailed",
"view",
"of",
"one",
"server"
]
| [
"func",
"(",
"c",
"*",
"Client",
")",
"Server",
"(",
"identifier",
"string",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"server",
":=",
"<mask>",
"(",
"Server",
")",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"MakeApiRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"identifier",
",",
"nil",
",",
"server",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"server",
",",
"err",
"\n",
"}"
]
|
13,773 | all-13774 | [
"simultaneously",
"specify",
"storage",
"for",
"all",
"levels",
"of",
"a",
"two",
"-",
"dimensional",
"or",
"one",
"-",
"dimensional",
"array",
"texture"
]
| [
"func",
"TextureStorage2D",
"(",
"texture",
"uint32",
",",
"levels",
"int32",
",",
"internalformat",
"uint32",
",",
"width",
"int32",
",",
"height",
"int32",
")",
"{",
"C",
".",
"glowTextureStorage2D",
"(",
"gpTextureStorage2D",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"texture",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"levels",
")",
",",
"(",
"C",
".",
"GLenum",
")",
"(",
"internalformat",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"width",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"<mask>",
")",
")",
"\n",
"}"
]
|
13,774 | all-13775 | [
"MenuBarNew",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_menu_bar_new",
"()",
"."
]
| [
"func",
"MenuBarNew",
"(",
")",
"(",
"*",
"MenuBar",
",",
"<mask>",
")",
"{",
"c",
":=",
"C",
".",
"gtk_menu_bar_new",
"(",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"return",
"wrapMenuBar",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
",",
"nil",
"\n",
"}"
]
|
13,775 | all-13776 | [
"GetAvailableInventory",
"-",
"this",
"should",
"return",
"available",
"inventory",
"and",
"start",
"a",
"long",
"task",
"poller"
]
| [
"func",
"GetAvailableInventory",
"(",
"taskCollection",
"integrations",
".",
"Collection",
")",
"(",
"inventory",
"<mask>",
"[",
"string",
"]",
"skurepo",
".",
"SkuBuilder",
")",
"{",
"inventory",
"=",
"skurepo",
".",
"GetRegistry",
"(",
")",
"\n\n",
"onceLoadInventoryPoller",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"startTaskPollingForRegisteredSkus",
"(",
"taskCollection",
")",
"\n",
"}",
")",
"\n",
"return",
"\n",
"}"
]
|
13,776 | all-13777 | [
"Clone",
"clones",
"a",
"ZFS",
"snapshot",
"and",
"returns",
"a",
"clone",
"dataset",
".",
"An",
"error",
"will",
"be",
"returned",
"if",
"the",
"input",
"dataset",
"is",
"not",
"of",
"snapshot",
"type",
"."
]
| [
"func",
"(",
"d",
"*",
"Dataset",
")",
"Clone",
"(",
"dest",
"string",
",",
"properties",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"Dataset",
",",
"error",
")",
"{",
"if",
"d",
".",
"Type",
"!=",
"DatasetSnapshot",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"args",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"2",
",",
"4",
")",
"\n",
"args",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"args",
"[",
"1",
"]",
"=",
"\"",
"\"",
"\n",
"if",
"<mask>",
"!=",
"nil",
"{",
"args",
"=",
"append",
"(",
"args",
",",
"propsSlice",
"(",
"properties",
")",
"...",
")",
"\n",
"}",
"\n",
"args",
"=",
"append",
"(",
"args",
",",
"[",
"]",
"string",
"{",
"d",
".",
"Name",
",",
"dest",
"}",
"...",
")",
"\n",
"_",
",",
"err",
":=",
"zfs",
"(",
"args",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"GetDataset",
"(",
"dest",
")",
"\n",
"}"
]
|
13,777 | all-13778 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
]
| [
"func",
"(",
"v",
"CreateIsolatedWorldReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage72",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
]
|
13,778 | all-13779 | [
"Remove",
"is",
"a",
"wrapper",
"around",
"gtk_combo_box_text_remove",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"ComboBoxText",
")",
"Remove",
"(",
"position",
"int",
")",
"{",
"C",
".",
"gtk_combo_box_text_remove",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"gint",
"(",
"<mask>",
")",
")",
"\n",
"}"
]
|
13,779 | all-13780 | [
"title",
":",
"service",
"instance",
"list",
"path",
":",
"/",
"services",
"/",
"instances",
"method",
":",
"GET",
"produce",
":",
"application",
"/",
"json",
"responses",
":",
"200",
":",
"List",
"services",
"instances",
"204",
":",
"No",
"content",
"401",
":",
"Unauthorized"
]
| [
"func",
"serviceInstances",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"t",
"auth",
".",
"Token",
")",
"error",
"{",
"appName",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"contexts",
":=",
"permission",
".",
"ContextsForPermission",
"(",
"t",
",",
"permission",
".",
"PermServiceInstanceRead",
")",
"\n",
"instances",
",",
"err",
":=",
"readableInstances",
"(",
"t",
",",
"contexts",
",",
"appName",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"contexts",
"=",
"permission",
".",
"ContextsForPermission",
"(",
"t",
",",
"permission",
".",
"PermServiceRead",
")",
"\n",
"services",
",",
"err",
":=",
"readableServices",
"(",
"t",
",",
"contexts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"servicesMap",
":=",
"map",
"[",
"string",
"]",
"*",
"service",
".",
"ServiceModel",
"{",
"}",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"services",
"{",
"if",
"_",
",",
"in",
":=",
"servicesMap",
"[",
"s",
".",
"Name",
"]",
";",
"!",
"in",
"{",
"servicesMap",
"[",
"s",
".",
"Name",
"]",
"=",
"&",
"service",
".",
"ServiceModel",
"{",
"Service",
":",
"s",
".",
"Name",
",",
"Instances",
":",
"[",
"]",
"string",
"{",
"}",
",",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"for",
"_",
",",
"instance",
":=",
"range",
"instances",
"{",
"entry",
":=",
"servicesMap",
"[",
"instance",
".",
"ServiceName",
"]",
"\n",
"if",
"entry",
"==",
"nil",
"{",
"continue",
"\n",
"}",
"\n",
"entry",
".",
"Instances",
"=",
"append",
"(",
"entry",
".",
"Instances",
",",
"instance",
".",
"Name",
")",
"\n",
"entry",
".",
"Plans",
"=",
"append",
"(",
"entry",
".",
"Plans",
",",
"instance",
".",
"PlanName",
")",
"\n",
"entry",
".",
"ServiceInstances",
"=",
"append",
"(",
"entry",
".",
"ServiceInstances",
",",
"instance",
")",
"\n",
"}",
"\n",
"<mask>",
":=",
"[",
"]",
"service",
".",
"ServiceModel",
"{",
"}",
"\n",
"for",
"_",
",",
"name",
":=",
"range",
"sortedServiceNames",
"(",
"servicesMap",
")",
"{",
"entry",
":=",
"servicesMap",
"[",
"name",
"]",
"\n",
"result",
"=",
"append",
"(",
"result",
",",
"*",
"entry",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"result",
")",
"==",
"0",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusNoContent",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"json",
".",
"NewEncoder",
"(",
"w",
")",
".",
"Encode",
"(",
"result",
")",
"\n",
"}"
]
|
13,780 | all-13781 | [
"Locator",
"returns",
"a",
"locator",
"for",
"the",
"given",
"resource"
]
| [
"func",
"(",
"r",
"*",
"VolumeSnapshot",
")",
"Locator",
"(",
"api",
"*",
"API",
")",
"*",
"VolumeSnapshotLocator",
"{",
"for",
"_",
",",
"l",
":=",
"<mask>",
"r",
".",
"Links",
"{",
"if",
"l",
"[",
"\"",
"\"",
"]",
"==",
"\"",
"\"",
"{",
"return",
"api",
".",
"VolumeSnapshotLocator",
"(",
"l",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
]
|
13,781 | all-13782 | [
"PageNum",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_notebook_page_num",
"()",
"."
]
| [
"func",
"(",
"v",
"*",
"Notebook",
")",
"PageNum",
"(",
"child",
"IWidget",
")",
"int",
"{",
"c",
":=",
"C",
".",
"gtk_notebook_page_num",
"(",
"v",
".",
"native",
"(",
")",
",",
"<mask>",
".",
"toWidget",
"(",
")",
")",
"\n",
"return",
"int",
"(",
"c",
")",
"\n",
"}"
]
|
13,782 | all-13783 | [
"Do",
"executes",
"DOMDebugger",
".",
"setXHRBreakpoint",
"against",
"the",
"provided",
"context",
"."
]
| [
"func",
"(",
"p",
"*",
"SetXHRBreakpointParams",
")",
"Do",
"(",
"ctx",
"<mask>",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"return",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandSetXHRBreakpoint",
",",
"p",
",",
"nil",
")",
"\n",
"}"
]
|
13,783 | all-13784 | [
"byteSlice",
"returns",
"byte",
"slice",
"of",
"id",
"from",
"start",
"to",
"end",
".",
"Calling",
"this",
"function",
"with",
"an",
"invalid",
"id",
"will",
"cause",
"a",
"runtime",
"panic",
"."
]
| [
"func",
"(",
"id",
"ObjectId",
")",
"byteSlice",
"(",
"start",
",",
"end",
"int",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"id",
")",
"!=",
"12",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"string",
"(",
"id",
")",
")",
")",
"\n",
"}",
"\n",
"return",
"[",
"]",
"byte",
"(",
"string",
"(",
"id",
")",
"[",
"<mask>",
":",
"end",
"]",
")",
"\n",
"}"
]
|
13,784 | all-13785 | [
"verifyStatusResolvable",
"validates",
"that",
"target",
"can",
"be",
"resolved",
"given",
"that",
"target",
"depends",
"on",
"dependencies",
"(",
"which",
"are",
"container",
"names",
")",
"and",
"there",
"are",
"existingContainers",
"(",
"map",
"from",
"name",
"to",
"container",
")",
".",
"The",
"resolves",
"function",
"passed",
"should",
"return",
"true",
"if",
"the",
"named",
"container",
"is",
"resolved",
"."
]
| [
"func",
"verifyStatusResolvable",
"(",
"target",
"*",
"apicontainer",
".",
"Container",
",",
"existingContainers",
"map",
"[",
"string",
"]",
"*",
"apicontainer",
".",
"Container",
",",
"dependencies",
"[",
"]",
"string",
",",
"resolves",
"func",
"(",
"*",
"apicontainer",
".",
"Container",
",",
"*",
"apicontainer",
".",
"<mask>",
")",
"bool",
")",
"bool",
"{",
"targetGoal",
":=",
"target",
".",
"GetDesiredStatus",
"(",
")",
"\n",
"if",
"targetGoal",
"!=",
"target",
".",
"GetSteadyStateStatus",
"(",
")",
"&&",
"targetGoal",
"!=",
"apicontainerstatus",
".",
"ContainerCreated",
"{",
"// A container can always stop, die, or reach whatever other state it",
"// wants regardless of what dependencies it has",
"return",
"true",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"dependency",
":=",
"range",
"dependencies",
"{",
"maybeResolves",
",",
"exists",
":=",
"existingContainers",
"[",
"dependency",
"]",
"\n",
"if",
"!",
"exists",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"!",
"resolves",
"(",
"target",
",",
"maybeResolves",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
]
|
13,785 | all-13786 | [
"DeleteIntegrationGCP",
"deletes",
"a",
"Google",
"Cloud",
"Platform",
"Integration",
"."
]
| [
"func",
"(",
"client",
"*",
"<mask>",
")",
"DeleteIntegrationGCP",
"(",
"cir",
"*",
"IntegrationGCPDeleteRequest",
")",
"error",
"{",
"return",
"client",
".",
"doJsonRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"cir",
",",
"nil",
")",
"\n",
"}"
]
|
13,786 | all-13787 | [
"GetSSHUsername",
"returns",
"username",
"for",
"use",
"with",
"ssh"
]
| [
"func",
"(",
"d",
"*",
"SerialDriver",
")",
"GetSSHUsername",
"(",
")",
"string",
"{",
"d",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"Unlock",
"(",
")",
"\n",
"<mask>",
"d",
".",
"Driver",
".",
"GetSSHUsername",
"(",
")",
"\n",
"}"
]
|
13,787 | all-13788 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"RequestEntriesReturns",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"<mask>",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoCachestorage",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
13,788 | all-13789 | [
"Do",
"executes",
"Page",
".",
"getNavigationHistory",
"against",
"the",
"provided",
"context",
".",
"returns",
":",
"currentIndex",
"-",
"Index",
"of",
"the",
"current",
"navigation",
"history",
"entry",
".",
"entries",
"-",
"Array",
"of",
"navigation",
"history",
"entries",
"."
]
| [
"func",
"(",
"p",
"*",
"GetNavigationHistoryParams",
")",
"Do",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"currentIndex",
"int64",
",",
"entries",
"[",
"]",
"*",
"NavigationEntry",
",",
"err",
"error",
")",
"{",
"// execute",
"var",
"res",
"GetNavigationHistoryReturns",
"\n",
"err",
"=",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandGetNavigationHistory",
",",
"nil",
",",
"&",
"res",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"<mask>",
".",
"CurrentIndex",
",",
"res",
".",
"Entries",
",",
"nil",
"\n",
"}"
]
|
13,789 | all-13790 | [
"AddWithDelay",
"is",
"convenience",
"method",
"to",
"add",
"a",
"job",
"with",
"given",
"data",
"delay",
"."
]
| [
"func",
"AddWithDelay",
"(",
"q",
"Queue",
",",
"tx",
"*",
"reform",
".",
"TX",
",",
"jobType",
",",
"relatedType",
",",
"relatedID",
",",
"<mask>",
"string",
",",
"delay",
"time",
".",
"Duration",
")",
"error",
"{",
"return",
"AddWithDataAndDelay",
"(",
"q",
",",
"tx",
",",
"jobType",
",",
"relatedType",
",",
"relatedID",
",",
"creator",
",",
"&",
"struct",
"{",
"}",
"{",
"}",
",",
"delay",
")",
"\n",
"}"
]
|
13,790 | all-13791 | [
"GetVolume",
"gets",
"a",
"volume"
]
| [
"func",
"(",
"c",
"*",
"Client",
")",
"GetVolume",
"(",
"dcid",
"string",
",",
"volumeID",
"string",
")",
"(",
"*",
"Volume",
",",
"error",
")",
"{",
"url",
":=",
"volumePath",
"(",
"dcid",
",",
"volumeID",
")",
"+",
"`?depth=`",
"+",
"c",
".",
"client",
".",
"depth",
"\n",
"ret",
":=",
"&",
"Volume",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"client",
".",
"Get",
"(",
"url",
",",
"ret",
",",
"<mask>",
".",
"StatusOK",
")",
"\n",
"return",
"ret",
",",
"err",
"\n",
"}"
]
|
13,791 | all-13792 | [
"NewSdk",
"constructs",
"a",
"new",
"Openstack",
"SDK",
"for",
"the",
"specified",
"region",
".",
"The",
"following",
"environment",
"variable",
"list",
"is",
"looked",
"up",
"in",
"the",
"user",
"environment",
"in",
"order",
"to",
"authenticate",
"to",
"the",
"cloud",
"operator",
":",
"OS_AUTH_URL",
"OS_USERNAME",
"OS_USERID",
"OS_PASSWORD",
"OS_TENANT_ID",
"OS_TENANT_NAME",
"OS_DOMAIN_ID",
"OS_DOMAIN_NAME",
".",
"Note",
"that",
"only",
"a",
"susbset",
"of",
"these",
"has",
"to",
"be",
"set",
"since",
"most",
"variables",
"derive",
"from",
"one",
"another",
"to",
"allow",
"using",
"either",
"names",
"or",
"ids",
"."
]
| [
"func",
"NewSdk",
"(",
"<mask>",
"string",
")",
"(",
"*",
"Sdk",
",",
"error",
")",
"{",
"sdk",
":=",
"&",
"Sdk",
"{",
"}",
"\n",
"authOpts",
",",
"err",
":=",
"openstack",
".",
"AuthOptionsFromEnv",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// By default, enable re-authenticating when the token expires. This may be",
"// useful when the operator policy enforces a short token validity period",
"// and you run into a long deployment.",
"authOpts",
".",
"AllowReauth",
"=",
"true",
"\n\n",
"client",
",",
"err",
":=",
"openstack",
".",
"AuthenticatedClient",
"(",
"authOpts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"//----------------------------",
"//",
"// Openstack Client Resources",
"//",
"//----------------------------",
"endpointOpts",
":=",
"gophercloud",
".",
"EndpointOpts",
"{",
"Region",
":",
"region",
",",
"}",
"\n",
"// Compute [Nova]",
"if",
"sdk",
".",
"Compute",
",",
"err",
"=",
"openstack",
".",
"NewComputeV2",
"(",
"client",
",",
"endpointOpts",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"// Network [Neutron]",
"if",
"sdk",
".",
"Network",
",",
"err",
"=",
"openstack",
".",
"NewNetworkV2",
"(",
"client",
",",
"endpointOpts",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"// Object Storage [Swift]",
"if",
"sdk",
".",
"ObjectStorage",
",",
"err",
"=",
"openstack",
".",
"NewObjectStorageV1",
"(",
"client",
",",
"endpointOpts",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"sdk",
",",
"nil",
"\n",
"}"
]
|
13,792 | all-13793 | [
"loadDoc",
"converts",
"from",
"protobufs",
"to",
"a",
"struct",
"pointer",
"or",
"FieldLoadSaver",
"/",
"FieldMetadataLoadSaver",
".",
"The",
"src",
"param",
"provides",
"the",
"document",
"s",
"stored",
"fields",
"and",
"facets",
"and",
"any",
"document",
"metadata",
".",
"An",
"additional",
"slice",
"of",
"fields",
"exprs",
"may",
"optionally",
"be",
"provided",
"to",
"contain",
"any",
"derived",
"expressions",
"requested",
"by",
"the",
"developer",
"."
]
| [
"func",
"loadDoc",
"(",
"dst",
"interface",
"{",
"}",
",",
"src",
"*",
"pb",
".",
"Document",
",",
"exprs",
"[",
"]",
"*",
"pb",
".",
"<mask>",
")",
"(",
"err",
"error",
")",
"{",
"fields",
",",
"err",
":=",
"protoToFields",
"(",
"src",
".",
"Field",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"facets",
",",
"err",
":=",
"protoToFacets",
"(",
"src",
".",
"Facet",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"exprs",
")",
">",
"0",
"{",
"exprFields",
",",
"err",
":=",
"protoToFields",
"(",
"exprs",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"// Mark each field as derived.",
"for",
"i",
":=",
"range",
"exprFields",
"{",
"exprFields",
"[",
"i",
"]",
".",
"Derived",
"=",
"true",
"\n",
"}",
"\n",
"fields",
"=",
"append",
"(",
"fields",
",",
"exprFields",
"...",
")",
"\n",
"}",
"\n",
"meta",
":=",
"&",
"DocumentMetadata",
"{",
"Rank",
":",
"int",
"(",
"src",
".",
"GetOrderId",
"(",
")",
")",
",",
"Facets",
":",
"facets",
",",
"}",
"\n",
"switch",
"x",
":=",
"dst",
".",
"(",
"type",
")",
"{",
"case",
"FieldLoadSaver",
":",
"return",
"x",
".",
"Load",
"(",
"fields",
",",
"meta",
")",
"\n",
"default",
":",
"return",
"loadStructWithMeta",
"(",
"dst",
",",
"fields",
",",
"meta",
")",
"\n",
"}",
"\n",
"}"
]
|
13,793 | all-13794 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
]
| [
"func",
"(",
"v",
"*",
"Page",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoHar6",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
]
|
13,794 | all-13795 | [
"SeekFirst",
"moves",
"cursor",
"to",
"the",
"first",
"item"
]
| [
"func",
"(",
"mit",
"*",
"MergeIterator",
")",
"SeekFirst",
"(",
")",
"{",
"for",
"_",
",",
"it",
":=",
"range",
"mit",
".",
"iters",
"{",
"it",
".",
"SeekFirst",
"(",
")",
"\n",
"if",
"it",
".",
"Valid",
"(",
")",
"{",
"n",
":=",
"it",
".",
"GetNode",
"(",
")",
"\n",
"mit",
".",
"h",
"=",
"append",
"(",
"mit",
".",
"h",
",",
"heapItem",
"{",
"iter",
":",
"<mask>",
",",
"n",
":",
"n",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"heap",
".",
"Init",
"(",
"&",
"mit",
".",
"h",
")",
"\n",
"mit",
".",
"Next",
"(",
")",
"\n",
"}"
]
|
13,795 | all-13796 | [
"Exit",
"application",
"but",
"deinit",
"first",
"so",
"that",
"the",
"terminal",
"will",
"not",
"be",
"corrupt",
"."
]
| [
"func",
"Exit",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"termbox",
".",
"Close",
"(",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr",
",",
"format",
"+",
"\"",
"\\n",
"\"",
",",
"args",
"...",
")",
"\n",
"<mask>",
".",
"Exit",
"(",
"1",
")",
"\n",
"}"
]
|
13,796 | all-13797 | [
"EnabledReposForExternalPlugin",
"returns",
"the",
"orgs",
"and",
"repos",
"that",
"have",
"enabled",
"the",
"passed",
"external",
"plugin",
"."
]
| [
"func",
"(",
"c",
"*",
"Configuration",
")",
"EnabledReposForExternalPlugin",
"(",
"plugin",
"string",
")",
"(",
"orgs",
",",
"repos",
"[",
"]",
"string",
")",
"{",
"for",
"repo",
",",
"plugins",
":=",
"range",
"c",
".",
"ExternalPlugins",
"{",
"found",
":=",
"false",
"\n",
"for",
"_",
",",
"candidate",
":=",
"range",
"plugins",
"{",
"if",
"candidate",
".",
"Name",
"==",
"plugin",
"{",
"found",
"=",
"<mask>",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"found",
"{",
"if",
"strings",
".",
"Contains",
"(",
"repo",
",",
"\"",
"\"",
")",
"{",
"repos",
"=",
"append",
"(",
"repos",
",",
"repo",
")",
"\n",
"}",
"else",
"{",
"orgs",
"=",
"append",
"(",
"orgs",
",",
"repo",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
]
|
13,797 | all-13798 | [
"/",
"*",
"Warningm",
"uses",
"msg",
"as",
"a",
"format",
"string",
"with",
"subsequent",
"parameters",
"as",
"values",
"and",
"logs",
"the",
"resulting",
"message",
"to",
"all",
"added",
"loggers",
"at",
"LogLevel",
".",
"LevelWarning",
".",
"It",
"will",
"also",
"merge",
"all",
"attributes",
"passed",
"in",
"m",
"with",
"any",
"attributes",
"added",
"to",
"Base",
"and",
"include",
"them",
"with",
"the",
"message",
"if",
"the",
"Logger",
"supports",
"it",
"."
]
| [
"func",
"(",
"la",
"*",
"LogAdapter",
")",
"Warningm",
"(",
"m",
"*",
"Attrs",
",",
"msg",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"la",
".",
"<mask>",
"(",
"LevelWarning",
",",
"m",
",",
"msg",
",",
"a",
"...",
")",
"\n",
"}"
]
|
13,798 | all-13799 | [
"creates",
"the",
"temporary",
"directory",
"and",
"copies",
"the",
"tarred",
"content",
"to",
"it"
]
| [
"func",
"createUntarTempDir",
"(",
"<mask>",
"ociArchiveReference",
")",
"(",
"tempDirOCIRef",
",",
"error",
")",
"{",
"tempDirRef",
",",
"err",
":=",
"createOCIRef",
"(",
"ref",
".",
"image",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"tempDirOCIRef",
"{",
"}",
",",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"src",
":=",
"ref",
".",
"resolvedFile",
"\n",
"dst",
":=",
"tempDirRef",
".",
"tempDirectory",
"\n",
"// TODO: This can take quite some time, and should ideally be cancellable using a context.Context.",
"if",
"err",
":=",
"archive",
".",
"UntarPath",
"(",
"src",
",",
"dst",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"err",
":=",
"tempDirRef",
".",
"deleteTempDir",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"tempDirOCIRef",
"{",
"}",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"tempDirRef",
".",
"tempDirectory",
")",
"\n",
"}",
"\n",
"return",
"tempDirOCIRef",
"{",
"}",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"tempDirRef",
".",
"tempDirectory",
")",
"\n",
"}",
"\n",
"return",
"tempDirRef",
",",
"nil",
"\n",
"}"
]
|
13,799 | all-13800 | [
"GetOverrideOk",
"returns",
"a",
"tuple",
"with",
"the",
"Override",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
]
| [
"func",
"(",
"h",
"*",
"HostActionMute",
")",
"GetOverrideOk",
"(",
")",
"(",
"bool",
",",
"bool",
")",
"{",
"if",
"h",
"==",
"nil",
"||",
"h",
".",
"Override",
"==",
"nil",
"{",
"return",
"<mask>",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"h",
".",
"Override",
",",
"true",
"\n",
"}"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.