id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
12,900 | all-12901 | [
"Verify",
"parses",
"unverifiedSignature",
"and",
"returns",
"the",
"content",
"and",
"the",
"signer",
"s",
"identity"
] | [
"func",
"(",
"m",
"gpgmeSigningMechanism",
")",
"Verify",
"(",
"unverifiedSignature",
"[",
"]",
"<mask>",
")",
"(",
"contents",
"[",
"]",
"byte",
",",
"keyIdentity",
"string",
",",
"err",
"error",
")",
"{",
"signedBuffer",
":=",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"signedData",
",",
"err",
":=",
"gpgme",
".",
"NewDataWriter",
"(",
"&",
"signedBuffer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"unverifiedSignatureData",
",",
"err",
":=",
"gpgme",
".",
"NewDataBytes",
"(",
"unverifiedSignature",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"_",
",",
"sigs",
",",
"err",
":=",
"m",
".",
"ctx",
".",
"Verify",
"(",
"unverifiedSignatureData",
",",
"nil",
",",
"signedData",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"sigs",
")",
"!=",
"1",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"InvalidSignatureError",
"{",
"msg",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"len",
"(",
"sigs",
")",
")",
"}",
"\n",
"}",
"\n",
"sig",
":=",
"sigs",
"[",
"0",
"]",
"\n",
"// This is sig.Summary == gpgme.SigSumValid except for key trust, which we handle ourselves",
"if",
"sig",
".",
"Status",
"!=",
"nil",
"||",
"sig",
".",
"Validity",
"==",
"gpgme",
".",
"ValidityNever",
"||",
"sig",
".",
"ValidityReason",
"!=",
"nil",
"||",
"sig",
".",
"WrongKeyUsage",
"{",
"// FIXME: Better error reporting eventually",
"return",
"nil",
",",
"\"",
"\"",
",",
"InvalidSignatureError",
"{",
"msg",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sig",
")",
"}",
"\n",
"}",
"\n",
"return",
"signedBuffer",
".",
"Bytes",
"(",
")",
",",
"sig",
".",
"Fingerprint",
",",
"nil",
"\n",
"}"
] |
12,901 | all-12902 | [
"UnmarshalJSON",
"satisfies",
"json",
".",
"Unmarshaler",
"."
] | [
"func",
"(",
"t",
"*",
"RequestStage",
")",
"UnmarshalJSON",
"(",
"buf",
"[",
"]",
"<mask>",
")",
"error",
"{",
"return",
"easyjson",
".",
"Unmarshal",
"(",
"buf",
",",
"t",
")",
"\n",
"}"
] |
12,902 | all-12903 | [
"GenSnowflake",
"generates",
"a",
"snowflake",
"DSN",
"from",
"the",
"passed",
"URL",
"."
] | [
"func",
"GenSnowflake",
"(",
"u",
"*",
"URL",
")",
"(",
"string",
",",
"error",
")",
"{",
"host",
",",
"port",
",",
"dbname",
":=",
"hostname",
"(",
"u",
".",
"Host",
")",
",",
"hostport",
"(",
"u",
".",
"Host",
")",
",",
"strings",
".",
"TrimPrefix",
"(",
"u",
".",
"Path",
",",
"\"",
"\"",
")",
"\n",
"if",
"host",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"ErrMissingHost",
"\n",
"}",
"\n",
"if",
"dbname",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"ErrMissingPath",
"\n",
"}",
"\n",
"if",
"port",
"!=",
"\"",
"\"",
"{",
"port",
"=",
"\"",
"\"",
"+",
"<mask>",
"\n",
"}",
"\n\n",
"// add user/pass",
"var",
"user",
"string",
"\n",
"if",
"u",
".",
"User",
"!=",
"nil",
"{",
"user",
"=",
"u",
".",
"User",
".",
"Username",
"(",
")",
"\n",
"if",
"pass",
",",
"_",
":=",
"u",
".",
"User",
".",
"Password",
"(",
")",
";",
"pass",
"!=",
"\"",
"\"",
"{",
"user",
"+=",
"\"",
"\"",
"+",
"pass",
"\n",
"}",
"\n",
"user",
"+=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"user",
"+",
"host",
"+",
"port",
"+",
"\"",
"\"",
"+",
"dbname",
"+",
"genQueryOptions",
"(",
"u",
".",
"Query",
"(",
")",
")",
",",
"nil",
"\n",
"}"
] |
12,903 | all-12904 | [
"getTreeForFile",
"is",
"like",
"getTreeForCommit",
"except",
"that",
"it",
"can",
"handle",
"open",
"commits",
".",
"It",
"takes",
"a",
"file",
"instead",
"of",
"a",
"commit",
"so",
"that",
"it",
"can",
"apply",
"the",
"changes",
"for",
"that",
"path",
"to",
"the",
"tree",
"before",
"it",
"returns",
"it",
"."
] | [
"func",
"(",
"d",
"*",
"driver",
")",
"getTreeForFile",
"(",
"pachClient",
"*",
"client",
".",
"APIClient",
",",
"file",
"*",
"pfs",
".",
"File",
")",
"(",
"hashtree",
".",
"HashTree",
",",
"error",
")",
"{",
"if",
"file",
".",
"Commit",
"==",
"nil",
"{",
"t",
",",
"err",
":=",
"hashtree",
".",
"NewDBHashTree",
"(",
"d",
".",
"storageRoot",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"t",
",",
"nil",
"\n",
"}",
"\n",
"commitInfo",
",",
"err",
":=",
"d",
".",
"inspectCommit",
"(",
"pachClient",
",",
"file",
".",
"Commit",
",",
"pfs",
".",
"CommitState_STARTED",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"commitInfo",
".",
"Finished",
"!=",
"nil",
"{",
"tree",
",",
"err",
":=",
"d",
".",
"getTreeForCommit",
"(",
"pachClient",
",",
"file",
".",
"Commit",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"<mask>",
",",
"nil",
"\n",
"}",
"\n",
"parentTree",
",",
"err",
":=",
"d",
".",
"getTreeForCommit",
"(",
"pachClient",
",",
"commitInfo",
".",
"ParentCommit",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"d",
".",
"getTreeForOpenCommit",
"(",
"pachClient",
",",
"file",
",",
"parentTree",
")",
"\n",
"}"
] |
12,904 | all-12905 | [
"New",
"constructs",
"a",
"Spyglass",
"object",
"from",
"a",
"JobAgent",
"a",
"config",
".",
"Agent",
"and",
"a",
"storage",
"Client",
"."
] | [
"func",
"New",
"(",
"ja",
"*",
"jobs",
".",
"JobAgent",
",",
"cfg",
"config",
".",
"Getter",
",",
"c",
"*",
"storage",
".",
"<mask>",
",",
"ctx",
"context",
".",
"Context",
")",
"*",
"Spyglass",
"{",
"return",
"&",
"Spyglass",
"{",
"JobAgent",
":",
"ja",
",",
"config",
":",
"cfg",
",",
"PodLogArtifactFetcher",
":",
"NewPodLogArtifactFetcher",
"(",
"ja",
")",
",",
"GCSArtifactFetcher",
":",
"NewGCSArtifactFetcher",
"(",
"c",
")",
",",
"testgrid",
":",
"&",
"TestGrid",
"{",
"conf",
":",
"cfg",
",",
"client",
":",
"c",
",",
"ctx",
":",
"ctx",
",",
"}",
",",
"}",
"\n",
"}"
] |
12,905 | all-12906 | [
"DiscoverDNS",
"..."
] | [
"func",
"DiscoverDNS",
"(",
"address",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"_",
",",
"addresses",
",",
"err",
":=",
"net",
".",
"LookupSRV",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"address",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"addresses",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"var",
"(",
"tmp",
"[",
"]",
"service",
"\n",
"services",
"[",
"]",
"string",
"\n",
")",
"\n",
"for",
"_",
",",
"addr",
":=",
"range",
"addresses",
"{",
"tmp",
"=",
"append",
"(",
"tmp",
",",
"service",
"{",
"Address",
":",
"addr",
".",
"Target",
",",
"Port",
":",
"int",
"(",
"addr",
".",
"Port",
")",
"}",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"tmp",
"{",
"services",
"=",
"append",
"(",
"services",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"<mask>",
",",
"s",
".",
"Port",
")",
")",
"\n",
"}",
"\n",
"return",
"services",
",",
"nil",
"\n",
"}"
] |
12,906 | all-12907 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"GetInlineStylesForNodeParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss44",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
12,907 | all-12908 | [
"DataAndLastIndex",
"returns",
"the",
"most",
"-",
"recently",
"-",
"received",
"data",
"from",
"Consul",
"for",
"this",
"view",
"along",
"with",
"the",
"last",
"index",
".",
"This",
"is",
"atomic",
"so",
"you",
"will",
"get",
"the",
"index",
"that",
"goes",
"with",
"the",
"data",
"you",
"are",
"fetching",
"."
] | [
"func",
"(",
"v",
"*",
"View",
")",
"DataAndLastIndex",
"(",
")",
"(",
"<mask>",
"{",
"}",
",",
"uint64",
")",
"{",
"v",
".",
"dataLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"v",
".",
"dataLock",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"v",
".",
"data",
",",
"v",
".",
"lastIndex",
"\n",
"}"
] |
12,908 | all-12909 | [
"DisableSvcNotifications",
"creates",
"a",
"new",
"DISABLE_SVC_NOTIFICATIONS",
"Nagios",
"command",
".",
"Disables",
"notifications",
"for",
"a",
"particular",
"service",
"."
] | [
"func",
"DisableSvcNotifications",
"(",
"host_name",
"string",
",",
"service_description",
"string",
",",
")",
"*",
"livestatus",
".",
"Command",
"{",
"<mask>",
"livestatus",
".",
"NewCommand",
"(",
"\"",
"\"",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"host_name",
")",
",",
"stringifyArg",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"service_description",
")",
",",
")",
"\n",
"}"
] |
12,909 | all-12910 | [
"HasStart",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"d",
"*",
"Downtime",
")",
"HasStart",
"(",
")",
"bool",
"{",
"if",
"d",
"!=",
"nil",
"&&",
"d",
".",
"Start",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
12,910 | all-12911 | [
"Warnf",
"records",
"the",
"log",
"with",
"warn",
"level"
] | [
"func",
"Warnf",
"(",
"<mask>",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"logger",
".",
"Output",
"(",
"2",
",",
"LevelWarn",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}"
] |
12,911 | all-12912 | [
"export",
"FileSequence_SetPaddingStyle"
] | [
"func",
"FileSequence_SetPaddingStyle",
"(",
"id",
"FileSeqId",
",",
"padStyle",
"C",
".",
"int",
")",
"{",
"if",
"fs",
",",
"ok",
":=",
"sFileSeqs",
".",
"Get",
"(",
"id",
")",
";",
"ok",
"{",
"style",
":=",
"fileseq",
".",
"PadStyle",
"(",
"padStyle",
")",
"\n",
"<mask>",
".",
"SetPaddingStyle",
"(",
"style",
")",
"\n",
"}",
"\n",
"}"
] |
12,912 | all-12913 | [
"Styler",
"is",
"a",
"function",
"that",
"accepts",
"multiple",
"possible",
"styling",
"transforms",
"from",
"the",
"state",
"color",
"and",
"background",
"colors",
"constants",
"and",
"transforms",
"them",
"into",
"a",
"templated",
"string",
"to",
"apply",
"those",
"styles",
"in",
"the",
"CLI",
".",
"The",
"returned",
"styling",
"function",
"accepts",
"a",
"string",
"that",
"will",
"be",
"extended",
"with",
"the",
"wrapping",
"function",
"s",
"styling",
"attributes",
"."
] | [
"func",
"Styler",
"(",
"attrs",
"...",
"attribute",
")",
"func",
"(",
"interface",
"{",
"}",
")",
"string",
"{",
"attrstrs",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"attrs",
")",
")",
"\n",
"for",
"i",
",",
"v",
":=",
"range",
"attrs",
"{",
"attrstrs",
"[",
"i",
"]",
"=",
"strconv",
".",
"Itoa",
"(",
"int",
"(",
"v",
")",
")",
"\n",
"}",
"\n\n",
"seq",
":=",
"strings",
".",
"Join",
"(",
"attrstrs",
",",
"\"",
"\"",
")",
"\n\n",
"return",
"func",
"(",
"v",
"<mask>",
"{",
"}",
")",
"string",
"{",
"end",
":=",
"\"",
"\"",
"\n",
"s",
",",
"ok",
":=",
"v",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"||",
"!",
"strings",
".",
"HasSuffix",
"(",
"s",
",",
"ResetCode",
")",
"{",
"end",
"=",
"ResetCode",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"esc",
",",
"seq",
",",
"v",
",",
"end",
")",
"\n",
"}",
"\n",
"}"
] |
12,913 | all-12914 | [
"guessType",
"tries",
"to",
"guess",
"the",
"resource",
"name",
"based",
"on",
"the",
"definition",
"and",
"service",
".",
"This",
"info",
"is",
"not",
"stored",
"in",
"the",
"swagger",
".",
"TBD",
"manual",
"overrides",
"if",
"needed",
"."
] | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"guessType",
"(",
"ec",
"EvalCtx",
",",
"d",
"*",
"Definition",
",",
"refID",
"string",
")",
"string",
"{",
"// First get the type name and and view from the swagger reference definition",
"// name -- are a few cases where that's the only place that has the view",
"if",
"t",
",",
"ok",
":=",
"a",
".",
"TypeOverrides",
"[",
"refID",
"]",
";",
"ok",
"{",
"return",
"t",
"\n",
"}",
"\n",
"var",
"name",
",",
"view",
"string",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"refID",
",",
"\"",
"\"",
")",
"{",
"bits",
":=",
"strings",
".",
"Split",
"(",
"refID",
",",
"\"",
"\"",
")",
"\n",
"name",
"=",
"bits",
"[",
"0",
"]",
"\n",
"if",
"len",
"(",
"bits",
")",
">",
"1",
"{",
"view",
"=",
"strings",
".",
"ToLower",
"(",
"bits",
"[",
"1",
"]",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"strings",
".",
"Contains",
"(",
"refID",
",",
"\"",
"\"",
")",
"{",
"bits",
":=",
"strings",
".",
"Split",
"(",
"refID",
",",
"\"",
"\"",
")",
"\n",
"name",
"=",
"bits",
"[",
"0",
"]",
"\n",
"if",
"len",
"(",
"bits",
")",
">",
"1",
"{",
"view",
"=",
"strings",
".",
"ToLower",
"(",
"bits",
"[",
"1",
"]",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"name",
"=",
"refID",
"\n",
"}",
"\n\n",
"// Now try and get it from the media type -- this is preferred if its set.",
"if",
"mt",
":=",
"mediaType",
"(",
"d",
".",
"Title",
")",
";",
"mt",
"!=",
"\"",
"\"",
"{",
"if",
"strings",
".",
"Contains",
"(",
"mt",
",",
"\"",
"\"",
")",
"{",
"bits",
":=",
"strings",
".",
"Split",
"(",
"mt",
",",
"\"",
"\"",
")",
"\n",
"name",
":=",
"bits",
"[",
"len",
"(",
"bits",
")",
"-",
"1",
"]",
"\n",
"attrs",
":=",
"mediaTypeAttrs",
"(",
"d",
".",
"Title",
")",
"\n",
"if",
"attrs",
"[",
"\"",
"\"",
"]",
"!=",
"\"",
"\"",
"{",
"name",
"+=",
"\"",
"\"",
"+",
"attrs",
"[",
"\"",
"\"",
"]",
"\n",
"}",
"\n",
"if",
"attrs",
"[",
"\"",
"\"",
"]",
"!=",
"\"",
"\"",
"&&",
"attrs",
"[",
"\"",
"\"",
"]",
"!=",
"\"",
"\"",
"{",
"name",
"+=",
"\"",
"\"",
"+",
"attrs",
"[",
"\"",
"\"",
"]",
"\n",
"}",
"else",
"if",
"view",
"!=",
"\"",
"\"",
"{",
"name",
"+=",
"\"",
"\"",
"+",
"<mask>",
"\n",
"}",
"\n",
"dbg",
"(",
"\"",
"\\n",
"\"",
",",
"refID",
",",
"d",
".",
"Title",
",",
"name",
",",
"view",
",",
"name",
")",
"\n",
"return",
"toTypeName",
"(",
"name",
")",
"\n",
"}",
"else",
"if",
"strings",
".",
"Contains",
"(",
"mt",
",",
"\"",
"\"",
")",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"fail",
"(",
"\"",
"\"",
",",
"mt",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"view",
"!=",
"\"",
"\"",
"{",
"return",
"name",
"+",
"\"",
"\"",
"+",
"view",
"\n",
"}",
"\n\n",
"return",
"name",
"\n",
"}"
] |
12,914 | all-12915 | [
"newFileBuffer",
"creates",
"a",
"buffer",
"for",
"reading",
"from",
"the",
"specified",
"File",
"file"
] | [
"func",
"newFileBuffer",
"(",
"file",
"File",
")",
"fileBuffer",
"{",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"return",
"fileBuffer",
"{",
"Reader",
":",
"<mask>",
".",
"TeeReader",
"(",
"file",
".",
"Reader",
",",
"buf",
")",
",",
"File",
":",
"file",
",",
"cache",
":",
"buf",
",",
"}",
"\n",
"}"
] |
12,915 | all-12916 | [
"EmptyMacroFile",
"creates",
"a",
"bzl",
"file",
"at",
"the",
"given",
"path",
"and",
"within",
"the",
"file",
"creates",
"a",
"Starlark",
"function",
"with",
"the",
"provided",
"name",
".",
"The",
"function",
"can",
"then",
"be",
"modified",
"by",
"Sync",
"and",
"Save",
"calls",
"."
] | [
"func",
"EmptyMacroFile",
"(",
"<mask>",
",",
"pkg",
",",
"defName",
"string",
")",
"(",
"*",
"File",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"LoadMacroData",
"(",
"path",
",",
"pkg",
",",
"defName",
",",
"nil",
")",
"\n",
"}"
] |
12,916 | all-12917 | [
"Returns",
"a",
"random",
"value",
"from",
"the",
"following",
"interval",
":",
"[",
"randomizationFactor",
"*",
"currentInterval",
"randomizationFactor",
"*",
"currentInterval",
"]",
"."
] | [
"func",
"getRandomValueFromInterval",
"(",
"randomizationFactor",
",",
"<mask>",
"float64",
",",
"currentInterval",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"var",
"delta",
"=",
"randomizationFactor",
"*",
"float64",
"(",
"currentInterval",
")",
"\n",
"var",
"minInterval",
"=",
"float64",
"(",
"currentInterval",
")",
"-",
"delta",
"\n",
"var",
"maxInterval",
"=",
"float64",
"(",
"currentInterval",
")",
"+",
"delta",
"\n\n",
"// Get a random value from the range [minInterval, maxInterval].",
"// The formula used below has a +1 because if the minInterval is 1 and the maxInterval is 3 then",
"// we want a 33% chance for selecting either 1, 2 or 3.",
"return",
"time",
".",
"Duration",
"(",
"minInterval",
"+",
"(",
"random",
"*",
"(",
"maxInterval",
"-",
"minInterval",
"+",
"1",
")",
")",
")",
"\n",
"}"
] |
12,917 | all-12918 | [
"networkObjectFromHostSystem",
"locates",
"the",
"network",
"object",
"in",
"vCenter",
"for",
"a",
"specific",
"HostSystem",
"and",
"network",
"name",
".",
"It",
"does",
"this",
"by",
"searching",
"for",
"all",
"networks",
"in",
"the",
"folder",
"hierarchy",
"that",
"match",
"the",
"given",
"network",
"name",
"for",
"the",
"HostSystem",
"s",
"managed",
"object",
"reference",
"ID",
".",
"This",
"match",
"is",
"returned",
"-",
"if",
"nothing",
"is",
"found",
"an",
"error",
"is",
"given",
"."
] | [
"func",
"networkObjectFromHostSystem",
"(",
"client",
"*",
"govmomi",
".",
"Client",
",",
"hs",
"*",
"object",
".",
"HostSystem",
",",
"name",
"string",
")",
"(",
"*",
"object",
".",
"Network",
",",
"error",
")",
"{",
"// Validate vCenter as this function is only relevant there",
"if",
"err",
":=",
"viapi",
".",
"ValidateVirtualCenter",
"(",
"client",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"finder",
":=",
"find",
".",
"NewFinder",
"(",
"client",
".",
"Client",
",",
"false",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"defaultAPITimeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"nets",
",",
"err",
":=",
"finder",
".",
"NetworkList",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"<mask>",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"n",
":=",
"range",
"nets",
"{",
"net",
",",
"ok",
":=",
"n",
".",
"(",
"*",
"object",
".",
"Network",
")",
"\n",
"if",
"!",
"ok",
"{",
"// Not a standard port group (possibly DVS, etc), pass",
"continue",
"\n",
"}",
"\n",
"props",
",",
"err",
":=",
"network",
".",
"Properties",
"(",
"net",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"for",
"_",
",",
"hsRef",
":=",
"range",
"props",
".",
"Host",
"{",
"if",
"hsRef",
".",
"Value",
"==",
"hs",
".",
"Reference",
"(",
")",
".",
"Value",
"{",
"// This is our network",
"return",
"net",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"name",
",",
"hs",
".",
"Reference",
"(",
")",
".",
"Value",
")",
"\n",
"}"
] |
12,918 | all-12919 | [
"MatchingReferencesValidator",
"compares",
"the",
"model",
"with",
"one",
"related",
"model",
"or",
"all",
"related",
"models",
"and",
"checks",
"if",
"the",
"specified",
"references",
"are",
"shared",
"exactly",
".",
"The",
"target",
"is",
"defined",
"by",
"passing",
"the",
"reference",
"on",
"the",
"current",
"model",
"and",
"the",
"target",
"model",
".",
"The",
"matcher",
"is",
"defined",
"by",
"passing",
"pairs",
"of",
"fields",
"on",
"the",
"current",
"and",
"target",
"model",
":",
"fire",
".",
"MatchingReferencesValidator",
"(",
"Blog",
"&Blog",
"{}",
"map",
"[",
"string",
"]",
"string",
"{",
"Owner",
":",
"Owner",
"}",
")",
"To",
"-",
"many",
"optional",
"to",
"-",
"many",
"and",
"has",
"-",
"many",
"relationships",
"are",
"supported",
"both",
"for",
"the",
"initial",
"reference",
"and",
"in",
"the",
"matchers",
"."
] | [
"func",
"MatchingReferencesValidator",
"(",
"reference",
"string",
",",
"target",
"coal",
".",
"Model",
",",
"matcher",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"Callback",
"{",
"return",
"C",
"(",
"\"",
"\"",
",",
"Only",
"(",
"Create",
",",
"Update",
")",
",",
"func",
"(",
"ctx",
"*",
"Context",
")",
"error",
"{",
"// prepare ids",
"var",
"ids",
"[",
"]",
"bson",
".",
"ObjectId",
"\n\n",
"// get reference",
"ref",
":=",
"ctx",
".",
"Model",
".",
"MustGet",
"(",
"reference",
")",
"\n\n",
"// handle to-one reference",
"if",
"id",
",",
"ok",
":=",
"ref",
".",
"(",
"bson",
".",
"ObjectId",
")",
";",
"ok",
"{",
"ids",
"=",
"[",
"]",
"bson",
".",
"ObjectId",
"{",
"id",
"}",
"\n",
"}",
"\n\n",
"// handle optional to-one reference",
"if",
"oid",
",",
"ok",
":=",
"ref",
".",
"(",
"*",
"bson",
".",
"ObjectId",
")",
";",
"ok",
"{",
"// return immediately if not set",
"if",
"oid",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// set id",
"ids",
"=",
"[",
"]",
"bson",
".",
"ObjectId",
"{",
"*",
"oid",
"}",
"\n",
"}",
"\n\n",
"// handle to-many reference",
"if",
"list",
",",
"ok",
":=",
"ref",
".",
"(",
"[",
"]",
"bson",
".",
"ObjectId",
")",
";",
"ok",
"{",
"// return immediately if empty",
"if",
"len",
"(",
"list",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// set list",
"ids",
"=",
"list",
"\n",
"}",
"\n\n",
"// ensure list is unique",
"ids",
"=",
"coal",
".",
"Unique",
"(",
"ids",
")",
"\n\n",
"// prepare query",
"query",
":=",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"ids",
",",
"}",
",",
"}",
"\n\n",
"// add matchers",
"for",
"sourceField",
",",
"targetField",
":=",
"range",
"matcher",
"{",
"query",
"[",
"coal",
".",
"F",
"(",
"target",
",",
"targetField",
")",
"]",
"=",
"ctx",
".",
"Model",
".",
"MustGet",
"(",
"sourceField",
")",
"\n",
"}",
"\n\n",
"// find matching documents",
"ctx",
".",
"Tracer",
".",
"Push",
"(",
"\"",
"\"",
")",
"\n",
"ctx",
".",
"Tracer",
".",
"Tag",
"(",
"\"",
"\"",
",",
"query",
")",
"\n",
"n",
",",
"err",
":=",
"ctx",
".",
"<mask>",
".",
"DB",
"(",
")",
".",
"C",
"(",
"coal",
".",
"C",
"(",
"target",
")",
")",
".",
"Find",
"(",
"query",
")",
".",
"Count",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"ctx",
".",
"Tracer",
".",
"Pop",
"(",
")",
"\n\n",
"// return error if a document is missing (does not match)",
"if",
"n",
"!=",
"len",
"(",
"ids",
")",
"{",
"return",
"E",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"}"
] |
12,919 | all-12920 | [
"Full",
"type",
"hierarchy",
"is",
"returned",
"when",
"provided",
"either",
"the",
"concept",
"type",
"or",
"full",
"uri",
"of",
"the",
"most",
"specific",
"concept",
"type"
] | [
"func",
"FullTypeHierarchy",
"(",
"highestLevelType",
"string",
")",
"[",
"]",
"string",
"{",
"<mask>",
"typeHierarchy",
"[",
"]",
"string",
"\n",
"t",
":=",
"strings",
".",
"Split",
"(",
"highestLevelType",
",",
"\"",
"\"",
")",
"\n",
"typeToCheck",
":=",
"t",
"[",
"len",
"(",
"t",
")",
"-",
"1",
"]",
"\n",
"for",
"{",
"typeHierarchy",
"=",
"append",
"(",
"typeHierarchy",
",",
"typeToCheck",
")",
"\n",
"parentType",
":=",
"ParentType",
"(",
"typeToCheck",
")",
"\n",
"if",
"parentType",
"!=",
"\"",
"\"",
"{",
"typeToCheck",
"=",
"parentType",
"\n",
"}",
"else",
"{",
"return",
"TypeURIs",
"(",
"typeHierarchy",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"}"
] |
12,920 | all-12921 | [
"newMessageExchangeSet",
"creates",
"a",
"new",
"messageExchangeSet",
"with",
"a",
"given",
"name",
"."
] | [
"func",
"newMessageExchangeSet",
"(",
"<mask>",
"Logger",
",",
"name",
"string",
")",
"*",
"messageExchangeSet",
"{",
"return",
"&",
"messageExchangeSet",
"{",
"name",
":",
"name",
",",
"log",
":",
"log",
".",
"WithFields",
"(",
"LogField",
"{",
"\"",
"\"",
",",
"name",
"}",
")",
",",
"exchanges",
":",
"make",
"(",
"map",
"[",
"uint32",
"]",
"*",
"messageExchange",
")",
",",
"expiredExchanges",
":",
"make",
"(",
"map",
"[",
"uint32",
"]",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"}"
] |
12,921 | all-12922 | [
"buildLinuxMemorySpec",
"validates",
"and",
"builds",
"the",
"task",
"memory",
"spec"
] | [
"func",
"(",
"task",
"*",
"Task",
")",
"buildLinuxMemorySpec",
"(",
")",
"(",
"specs",
".",
"LinuxMemory",
",",
"error",
")",
"{",
"// If task memory limit is not present, cgroup parent memory is not set",
"// If task memory limit is set, ensure that no container",
"// of this task has a greater request",
"for",
"_",
",",
"container",
":=",
"<mask>",
"task",
".",
"Containers",
"{",
"containerMemoryLimit",
":=",
"int64",
"(",
"container",
".",
"Memory",
")",
"\n",
"if",
"containerMemoryLimit",
">",
"task",
".",
"Memory",
"{",
"return",
"specs",
".",
"LinuxMemory",
"{",
"}",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"containerMemoryLimit",
",",
"task",
".",
"Memory",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Kernel expects memory to be expressed in bytes",
"memoryBytes",
":=",
"task",
".",
"Memory",
"*",
"bytesPerMegabyte",
"\n",
"return",
"specs",
".",
"LinuxMemory",
"{",
"Limit",
":",
"&",
"memoryBytes",
",",
"}",
",",
"nil",
"\n",
"}"
] |
12,922 | all-12923 | [
"Must",
"returns",
"uuid",
"if",
"err",
"is",
"nil",
"and",
"panics",
"otherwise",
"."
] | [
"func",
"Must",
"(",
"uuid",
"UUID",
",",
"<mask>",
"error",
")",
"UUID",
"{",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"uuid",
"\n",
"}"
] |
12,923 | all-12924 | [
"resourceVSphereComputeClusterVMDependencyRuleObjects",
"handles",
"the",
"fetching",
"of",
"the",
"cluster",
"and",
"rule",
"key",
"depending",
"on",
"what",
"attributes",
"are",
"available",
":",
"*",
"If",
"the",
"resource",
"ID",
"is",
"available",
"the",
"data",
"is",
"derived",
"from",
"the",
"ID",
".",
"*",
"If",
"not",
"only",
"the",
"cluster",
"is",
"retrieved",
"from",
"compute_cluster_id",
".",
"-",
"1",
"is",
"returned",
"for",
"the",
"key",
"."
] | [
"func",
"resourceVSphereComputeClusterVMDependencyRuleObjects",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"meta",
"interface",
"{",
"}",
",",
")",
"(",
"*",
"object",
".",
"ClusterComputeResource",
",",
"int32",
",",
"error",
")",
"{",
"if",
"d",
".",
"<mask>",
"(",
")",
"!=",
"\"",
"\"",
"{",
"return",
"resourceVSphereComputeClusterVMDependencyRuleObjectsFromID",
"(",
"d",
",",
"meta",
")",
"\n",
"}",
"\n",
"return",
"resourceVSphereComputeClusterVMDependencyRuleObjectsFromAttributes",
"(",
"d",
",",
"meta",
")",
"\n",
"}"
] |
12,924 | all-12925 | [
"SubscribeCommitF",
"is",
"like",
"ListCommit",
"but",
"it",
"calls",
"a",
"callback",
"function",
"with",
"the",
"results",
"rather",
"than",
"returning",
"an",
"iterator",
"."
] | [
"func",
"(",
"c",
"APIClient",
")",
"SubscribeCommitF",
"(",
"repo",
",",
"branch",
",",
"from",
"string",
",",
"<mask>",
"pfs",
".",
"CommitState",
",",
"f",
"func",
"(",
"*",
"pfs",
".",
"CommitInfo",
")",
"error",
")",
"error",
"{",
"req",
":=",
"&",
"pfs",
".",
"SubscribeCommitRequest",
"{",
"Repo",
":",
"NewRepo",
"(",
"repo",
")",
",",
"Branch",
":",
"branch",
",",
"State",
":",
"state",
",",
"}",
"\n",
"if",
"from",
"!=",
"\"",
"\"",
"{",
"req",
".",
"From",
"=",
"NewCommit",
"(",
"repo",
",",
"from",
")",
"\n",
"}",
"\n",
"stream",
",",
"err",
":=",
"c",
".",
"PfsAPIClient",
".",
"SubscribeCommit",
"(",
"c",
".",
"Ctx",
"(",
")",
",",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"for",
"{",
"ci",
",",
"err",
":=",
"stream",
".",
"Recv",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"f",
"(",
"ci",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"grpcutil",
".",
"ScrubGRPC",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
12,925 | all-12926 | [
"NewReporter",
"returns",
"a",
"reporter",
"client"
] | [
"func",
"NewReporter",
"(",
"cookiefilePath",
"string",
",",
"projects",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"lister",
"pjlister",
".",
"ProwJobLister",
")",
"(",
"*",
"<mask>",
",",
"error",
")",
"{",
"gc",
",",
"err",
":=",
"client",
".",
"NewClient",
"(",
"projects",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"gc",
".",
"Start",
"(",
"cookiefilePath",
")",
"\n",
"return",
"&",
"Client",
"{",
"gc",
":",
"gc",
",",
"lister",
":",
"lister",
",",
"}",
",",
"nil",
"\n",
"}"
] |
12,926 | all-12927 | [
"WithIncludeCommandLineAPI",
"determines",
"whether",
"Command",
"Line",
"API",
"should",
"be",
"available",
"during",
"the",
"evaluation",
"."
] | [
"func",
"(",
"p",
"EvaluateParams",
")",
"WithIncludeCommandLineAPI",
"(",
"includeCommandLineAPI",
"bool",
")",
"*",
"EvaluateParams",
"{",
"p",
".",
"IncludeCommandLineAPI",
"=",
"includeCommandLineAPI",
"\n",
"<mask>",
"&",
"p",
"\n",
"}"
] |
12,927 | all-12928 | [
"Mutate",
"applies",
"the",
"provided",
"TransactionEnvelopeMutators",
"to",
"this",
"builder",
"s",
"envelope"
] | [
"func",
"(",
"b",
"*",
"TransactionEnvelopeBuilder",
")",
"Mutate",
"(",
"muts",
"...",
"TransactionEnvelopeMutator",
")",
"{",
"b",
".",
"Init",
"(",
")",
"\n\n",
"for",
"_",
",",
"m",
":=",
"<mask>",
"muts",
"{",
"err",
":=",
"m",
".",
"MutateTransactionEnvelope",
"(",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"b",
".",
"Err",
"=",
"err",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
12,928 | all-12929 | [
"Glob",
"executes",
"a",
"callback",
"for",
"each",
"path",
"that",
"matches",
"the",
"glob",
"pattern",
"."
] | [
"func",
"(",
"h",
"*",
"dbHashTree",
")",
"Glob",
"(",
"pattern",
"string",
",",
"f",
"func",
"(",
"string",
",",
"*",
"NodeProto",
")",
"error",
")",
"error",
"{",
"pattern",
"=",
"<mask>",
"(",
"pattern",
")",
"\n",
"return",
"h",
".",
"View",
"(",
"func",
"(",
"tx",
"*",
"bolt",
".",
"Tx",
")",
"error",
"{",
"return",
"glob",
"(",
"tx",
",",
"pattern",
",",
"f",
")",
"\n",
"}",
")",
"\n",
"}"
] |
12,929 | all-12930 | [
"Use",
"adds",
"a",
"handler",
"to",
"the",
"handlers",
"stack",
"."
] | [
"func",
"(",
"hs",
"*",
"HandlersStack",
")",
"Use",
"(",
"h",
"RouterHandler",
")",
"{",
"hs",
".",
"Handlers",
"=",
"<mask>",
"(",
"hs",
".",
"Handlers",
",",
"h",
")",
"\n",
"}"
] |
12,930 | all-12931 | [
"Value",
"converts",
"a",
"value",
"to",
"a",
"database",
"driver",
"value"
] | [
"func",
"(",
"u",
"URI",
")",
"Value",
"(",
")",
"(",
"driver",
".",
"<mask>",
",",
"error",
")",
"{",
"return",
"driver",
".",
"Value",
"(",
"string",
"(",
"u",
")",
")",
",",
"nil",
"\n",
"}"
] |
12,931 | all-12932 | [
"ParseFiles",
"converts",
"all",
"arguments",
"to",
"*",
"pfs",
".",
"Commit",
"structs",
"using",
"the",
"semantics",
"of",
"ParseFile"
] | [
"func",
"ParseFiles",
"(",
"args",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"pfs",
".",
"File",
",",
"error",
")",
"{",
"var",
"results",
"[",
"]",
"*",
"pfs",
".",
"File",
"\n",
"for",
"_",
",",
"arg",
":=",
"range",
"args",
"{",
"commit",
",",
"err",
":=",
"ParseFile",
"(",
"arg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"results",
"=",
"append",
"(",
"results",
",",
"commit",
")",
"\n",
"}",
"\n",
"return",
"<mask>",
",",
"nil",
"\n",
"}"
] |
12,932 | all-12933 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"CopyToReturns",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoDom74",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
12,933 | all-12934 | [
"Write",
"Write"
] | [
"func",
"(",
"ms",
"*",
"MongoStore",
")",
"Write",
"(",
"words",
"...",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"<mask>",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"var",
"err",
"error",
"\n",
"ms",
".",
"c",
"(",
"func",
"(",
"c",
"*",
"mgo",
".",
"Collection",
")",
"{",
"for",
"i",
",",
"l",
":=",
"0",
",",
"len",
"(",
"words",
")",
";",
"i",
"<",
"l",
";",
"i",
"++",
"{",
"_",
",",
"err",
"=",
"c",
".",
"Upsert",
"(",
"_Dirties",
"{",
"Value",
":",
"words",
"[",
"i",
"]",
"}",
",",
"_Dirties",
"{",
"Value",
":",
"words",
"[",
"i",
"]",
"}",
")",
"\n",
"}",
"\n",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"atomic",
".",
"AddUint64",
"(",
"&",
"ms",
".",
"version",
",",
"1",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,934 | all-12935 | [
"SetModel",
"is",
"a",
"wrapper",
"around",
"gtk_combo_box_set_model",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"ComboBox",
")",
"SetModel",
"(",
"model",
"ITreeModel",
")",
"{",
"var",
"mptr",
"*",
"C",
".",
"GtkTreeModel",
"\n",
"if",
"model",
"!=",
"nil",
"{",
"mptr",
"=",
"<mask>",
".",
"toTreeModel",
"(",
")",
"\n",
"}",
"\n",
"C",
".",
"gtk_combo_box_set_model",
"(",
"v",
".",
"native",
"(",
")",
",",
"mptr",
")",
"\n",
"}"
] |
12,935 | all-12936 | [
"filterField",
"returns",
"a",
"new",
"Option",
"where",
"opt",
"is",
"only",
"evaluated",
"on",
"paths",
"that",
"include",
"a",
"specific",
"exported",
"field",
"on",
"a",
"single",
"struct",
"type",
".",
"The",
"struct",
"type",
"is",
"specified",
"by",
"passing",
"in",
"a",
"value",
"of",
"that",
"type",
".",
"The",
"name",
"may",
"be",
"a",
"dot",
"-",
"delimited",
"string",
"(",
"e",
".",
"g",
".",
"Foo",
".",
"Bar",
")",
"to",
"select",
"a",
"specific",
"sub",
"-",
"field",
"that",
"is",
"embedded",
"or",
"nested",
"within",
"the",
"parent",
"struct",
"."
] | [
"func",
"filterField",
"(",
"typ",
"interface",
"{",
"}",
",",
"name",
"string",
",",
"opt",
"cmp",
".",
"Option",
")",
"cmp",
".",
"Option",
"{",
"// TODO: This is currently unexported over concerns of how helper filters",
"// can be composed together easily.",
"// TODO: Add tests for FilterField.",
"sf",
":=",
"newStructFilter",
"(",
"typ",
",",
"name",
")",
"\n",
"return",
"cmp",
".",
"FilterPath",
"(",
"sf",
".",
"<mask>",
",",
"opt",
")",
"\n",
"}"
] |
12,936 | all-12937 | [
"SearchArticles",
"searches",
"the",
"Articles",
"data",
"for",
"a",
"matching",
"article",
".",
"It",
"s",
"just",
"a",
"stub",
"but",
"you",
"get",
"the",
"idea",
"."
] | [
"func",
"SearchArticles",
"(",
"w",
"<mask>",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"render",
".",
"RenderList",
"(",
"w",
",",
"r",
",",
"NewArticleListResponse",
"(",
"articles",
")",
")",
"\n",
"}"
] |
12,937 | all-12938 | [
"equal",
"returns",
"true",
"only",
"if",
"both",
"calls",
"are",
"exactly",
"equal",
"."
] | [
"func",
"(",
"c",
"*",
"Call",
")",
"<mask>",
"(",
"r",
"*",
"Call",
")",
"bool",
"{",
"return",
"c",
".",
"SrcPath",
"==",
"r",
".",
"SrcPath",
"&&",
"c",
".",
"Line",
"==",
"r",
".",
"Line",
"&&",
"c",
".",
"Func",
"==",
"r",
".",
"Func",
"&&",
"c",
".",
"Args",
".",
"equal",
"(",
"&",
"r",
".",
"Args",
")",
"\n",
"}"
] |
12,938 | all-12939 | [
"try",
"to",
"convert",
"value",
"to",
"target",
"type",
"panic",
"if",
"fail"
] | [
"func",
"Convert",
"(",
"val",
"interface",
"{",
"}",
",",
"targetType",
"reflect",
".",
"Type",
")",
"reflect",
".",
"Value",
"{",
"<mask>",
":=",
"reflect",
".",
"ValueOf",
"(",
"val",
")",
"\n",
"if",
"!",
"value",
".",
"IsValid",
"(",
")",
"{",
"return",
"reflect",
".",
"Zero",
"(",
"targetType",
")",
"\n",
"}",
"\n\n",
"valType",
":=",
"value",
".",
"Type",
"(",
")",
"\n",
"if",
"valType",
".",
"ConvertibleTo",
"(",
"targetType",
")",
"{",
"return",
"value",
".",
"Convert",
"(",
"targetType",
")",
"\n",
"}",
"\n\n",
"//fmt.Printf(\"Value type is %v, emptyInterfaceType is %v, equals %v\\n\", valType, emptyInterfaceType, valType == emptyInterfaceType)",
"interfaceVal",
":=",
"value",
".",
"Interface",
"(",
")",
"\n\n",
"switch",
"realVal",
":=",
"interfaceVal",
".",
"(",
"type",
")",
"{",
"case",
"float64",
":",
"return",
"reflect",
".",
"ValueOf",
"(",
"realVal",
")",
".",
"Convert",
"(",
"targetType",
")",
"\n",
"case",
"[",
"]",
"interface",
"{",
"}",
":",
"// val is of type []interface{}, try to convert to typ",
"sliceSize",
":=",
"len",
"(",
"realVal",
")",
"\n",
"targetSlice",
":=",
"reflect",
".",
"MakeSlice",
"(",
"targetType",
",",
"0",
",",
"sliceSize",
")",
"\n",
"elemType",
":=",
"targetType",
".",
"Elem",
"(",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"sliceSize",
";",
"i",
"++",
"{",
"targetSlice",
"=",
"reflect",
".",
"Append",
"(",
"targetSlice",
",",
"Convert",
"(",
"value",
".",
"Index",
"(",
"i",
")",
",",
"elemType",
")",
")",
"\n",
"}",
"\n",
"return",
"targetSlice",
"\n",
"}",
"\n\n",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"valType",
",",
"targetType",
",",
"value",
")",
")",
"\n",
"}"
] |
12,939 | all-12940 | [
"Deprecated",
":",
"Do",
"not",
"use",
"."
] | [
"func",
"(",
"m",
"*",
"AppOverride",
")",
"GetIgnoreShardlock",
"(",
")",
"bool",
"{",
"if",
"m",
"!=",
"nil",
"&&",
"m",
".",
"IgnoreShardlock",
"!=",
"nil",
"{",
"return",
"*",
"m",
".",
"IgnoreShardlock",
"\n",
"}",
"\n",
"return",
"<mask>",
"\n",
"}"
] |
12,940 | all-12941 | [
"NewClient",
"returns",
"a",
"new",
"Client",
"that",
"can",
"make",
"calls",
"to",
"a",
"benchmark",
"server",
"."
] | [
"func",
"NewClient",
"(",
"hosts",
"[",
"]",
"string",
",",
"optFns",
"...",
"Option",
")",
"<mask>",
"{",
"opts",
":=",
"getOptions",
"(",
"optFns",
")",
"\n",
"if",
"opts",
".",
"external",
"{",
"return",
"newExternalClient",
"(",
"hosts",
",",
"opts",
")",
"\n",
"}",
"\n",
"if",
"opts",
".",
"numClients",
">",
"1",
"{",
"return",
"newInternalMultiClient",
"(",
"hosts",
",",
"opts",
")",
"\n",
"}",
"\n",
"return",
"newClient",
"(",
"hosts",
",",
"opts",
")",
"\n",
"}"
] |
12,941 | all-12942 | [
"EndOfQuarter",
"end",
"of",
"quarter"
] | [
"func",
"(",
"now",
"*",
"Now",
")",
"EndOfQuarter",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"now",
".",
"BeginningOfQuarter",
"(",
")",
".",
"AddDate",
"(",
"0",
",",
"3",
",",
"0",
")",
".",
"Add",
"(",
"-",
"<mask>",
".",
"Nanosecond",
")",
"\n",
"}"
] |
12,942 | all-12943 | [
"Converts",
"IDMap",
"to",
"SysProcIDMap",
"array",
"and",
"adds",
"it",
"to",
"SysProcAttr",
"."
] | [
"func",
"(",
"c",
"*",
"linuxContainer",
")",
"addUidGidMappings",
"(",
"sys",
"*",
"syscall",
".",
"SysProcAttr",
")",
"error",
"{",
"if",
"c",
".",
"config",
".",
"UidMappings",
"!=",
"nil",
"{",
"sys",
".",
"UidMappings",
"=",
"make",
"(",
"[",
"]",
"syscall",
".",
"SysProcIDMap",
",",
"len",
"(",
"c",
".",
"config",
".",
"UidMappings",
")",
")",
"\n",
"for",
"i",
",",
"um",
":=",
"range",
"c",
".",
"config",
".",
"UidMappings",
"{",
"sys",
".",
"UidMappings",
"[",
"i",
"]",
".",
"ContainerID",
"=",
"um",
".",
"ContainerID",
"\n",
"sys",
".",
"UidMappings",
"[",
"i",
"]",
".",
"HostID",
"=",
"um",
".",
"HostID",
"\n",
"sys",
".",
"UidMappings",
"[",
"i",
"]",
".",
"Size",
"=",
"um",
".",
"Size",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"c",
".",
"config",
".",
"GidMappings",
"!=",
"nil",
"{",
"sys",
".",
"GidMappings",
"=",
"make",
"(",
"[",
"]",
"syscall",
".",
"SysProcIDMap",
",",
"len",
"(",
"c",
".",
"config",
".",
"GidMappings",
")",
")",
"\n",
"for",
"i",
",",
"gm",
":=",
"<mask>",
"c",
".",
"config",
".",
"GidMappings",
"{",
"sys",
".",
"GidMappings",
"[",
"i",
"]",
".",
"ContainerID",
"=",
"gm",
".",
"ContainerID",
"\n",
"sys",
".",
"GidMappings",
"[",
"i",
"]",
".",
"HostID",
"=",
"gm",
".",
"HostID",
"\n",
"sys",
".",
"GidMappings",
"[",
"i",
"]",
".",
"Size",
"=",
"gm",
".",
"Size",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,943 | all-12944 | [
"Performs",
"required",
"field",
"checking",
"on",
"a",
"struct"
] | [
"func",
"validateStruct",
"(",
"errors",
"Errors",
",",
"obj",
"interface",
"{",
"}",
")",
"Errors",
"{",
"typ",
":=",
"reflect",
".",
"TypeOf",
"(",
"obj",
")",
"\n",
"val",
":=",
"reflect",
".",
"ValueOf",
"(",
"obj",
")",
"\n\n",
"if",
"typ",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Ptr",
"{",
"typ",
"=",
"typ",
".",
"Elem",
"(",
")",
"\n",
"val",
"=",
"val",
".",
"Elem",
"(",
")",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"typ",
".",
"NumField",
"(",
")",
";",
"i",
"++",
"{",
"field",
":=",
"typ",
".",
"Field",
"(",
"i",
")",
"\n\n",
"// Skip ignored and unexported fields in the struct",
"if",
"field",
".",
"Tag",
".",
"Get",
"(",
"\"",
"\"",
")",
"==",
"\"",
"\"",
"||",
"!",
"val",
".",
"Field",
"(",
"i",
")",
".",
"CanInterface",
"(",
")",
"{",
"continue",
"\n",
"}",
"\n\n",
"fieldValue",
":=",
"val",
".",
"Field",
"(",
"i",
")",
".",
"Interface",
"(",
")",
"\n",
"zero",
":=",
"reflect",
".",
"Zero",
"(",
"field",
".",
"Type",
")",
".",
"Interface",
"(",
")",
"\n\n",
"// Validate nested and embedded structs (if pointer, only do so if not nil)",
"if",
"<mask>",
".",
"Type",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Struct",
"||",
"(",
"field",
".",
"Type",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Ptr",
"&&",
"!",
"reflect",
".",
"DeepEqual",
"(",
"zero",
",",
"fieldValue",
")",
"&&",
"field",
".",
"Type",
".",
"Elem",
"(",
")",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Struct",
")",
"{",
"errors",
"=",
"validateStruct",
"(",
"errors",
",",
"fieldValue",
")",
"\n",
"}",
"\n\n",
"if",
"strings",
".",
"Index",
"(",
"field",
".",
"Tag",
".",
"Get",
"(",
"\"",
"\"",
")",
",",
"\"",
"\"",
")",
">",
"-",
"1",
"{",
"if",
"reflect",
".",
"DeepEqual",
"(",
"zero",
",",
"fieldValue",
")",
"{",
"name",
":=",
"field",
".",
"Name",
"\n",
"if",
"j",
":=",
"field",
".",
"Tag",
".",
"Get",
"(",
"\"",
"\"",
")",
";",
"j",
"!=",
"\"",
"\"",
"{",
"name",
"=",
"j",
"\n",
"}",
"else",
"if",
"f",
":=",
"field",
".",
"Tag",
".",
"Get",
"(",
"\"",
"\"",
")",
";",
"f",
"!=",
"\"",
"\"",
"{",
"name",
"=",
"f",
"\n",
"}",
"\n",
"errors",
".",
"Add",
"(",
"[",
"]",
"string",
"{",
"name",
"}",
",",
"RequiredError",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"errors",
"\n",
"}"
] |
12,944 | all-12945 | [
"NewExportManager",
"Creates",
"a",
"new",
"instance",
"of",
"the",
"ImportConfig",
"manager"
] | [
"func",
"NewExportManager",
"(",
"configDir",
"string",
",",
"uaaMgr",
"uaa",
".",
"Manager",
",",
"spaceManager",
"space",
".",
"<mask>",
",",
"userManager",
"user",
".",
"Manager",
",",
"orgManager",
"organization",
".",
"Manager",
",",
"securityGroupManager",
"securitygroup",
".",
"Manager",
",",
"isoSegmentMgr",
"isosegment",
".",
"Manager",
",",
"privateDomainMgr",
"privatedomain",
".",
"Manager",
",",
"sharedDomainMgr",
"*",
"shareddomain",
".",
"Manager",
",",
"serviceAccessMgr",
"*",
"serviceaccess",
".",
"Manager",
",",
"quotaMgr",
"*",
"quota",
".",
"Manager",
")",
"Manager",
"{",
"return",
"&",
"DefaultImportManager",
"{",
"ConfigDir",
":",
"configDir",
",",
"UAAMgr",
":",
"uaaMgr",
",",
"SpaceManager",
":",
"spaceManager",
",",
"UserManager",
":",
"userManager",
",",
"OrgManager",
":",
"orgManager",
",",
"SecurityGroupManager",
":",
"securityGroupManager",
",",
"IsoSegmentManager",
":",
"isoSegmentMgr",
",",
"PrivateDomainManager",
":",
"privateDomainMgr",
",",
"SharedDomainManager",
":",
"sharedDomainMgr",
",",
"ServiceAccessManager",
":",
"serviceAccessMgr",
",",
"QuotaManager",
":",
"quotaMgr",
",",
"}",
"\n",
"}"
] |
12,945 | all-12946 | [
"GetResourceOk",
"returns",
"a",
"tuple",
"with",
"the",
"Resource",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"c",
"*",
"Comment",
")",
"GetResourceOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"c",
"==",
"nil",
"||",
"c",
".",
"Resource",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"c",
".",
"Resource",
",",
"true",
"\n",
"}"
] |
12,946 | all-12947 | [
"setupHeaders",
"reads",
"the",
"header",
"then",
"populates",
"the",
"MIME",
"header",
"values",
"for",
"this",
"Part",
"."
] | [
"func",
"(",
"p",
"*",
"<mask>",
")",
"setupHeaders",
"(",
"r",
"*",
"bufio",
".",
"Reader",
",",
"defaultContentType",
"string",
")",
"error",
"{",
"header",
",",
"err",
":=",
"readHeader",
"(",
"r",
",",
"p",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"p",
".",
"Header",
"=",
"header",
"\n",
"ctype",
":=",
"header",
".",
"Get",
"(",
"hnContentType",
")",
"\n",
"if",
"ctype",
"==",
"\"",
"\"",
"{",
"if",
"defaultContentType",
"==",
"\"",
"\"",
"{",
"p",
".",
"addWarning",
"(",
"ErrorMissingContentType",
",",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"ctype",
"=",
"defaultContentType",
"\n",
"}",
"\n",
"// Parse Content-Type header.",
"mtype",
",",
"mparams",
",",
"minvalidParams",
",",
"err",
":=",
"parseMediaType",
"(",
"ctype",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"mtype",
"==",
"\"",
"\"",
"&&",
"len",
"(",
"mparams",
")",
">",
"0",
"{",
"p",
".",
"addWarning",
"(",
"ErrorMissingContentType",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"for",
"i",
":=",
"range",
"minvalidParams",
"{",
"p",
".",
"addWarning",
"(",
"ErrorMalformedHeader",
",",
"\"",
"\"",
",",
"minvalidParams",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"p",
".",
"ContentType",
"=",
"mtype",
"\n",
"// Set disposition, filename, charset if available.",
"p",
".",
"setupContentHeaders",
"(",
"mparams",
")",
"\n",
"p",
".",
"Boundary",
"=",
"mparams",
"[",
"hpBoundary",
"]",
"\n",
"p",
".",
"ContentID",
"=",
"coding",
".",
"FromIDHeader",
"(",
"header",
".",
"Get",
"(",
"hnContentID",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,947 | all-12948 | [
"WithObjectGroup",
"string",
"object",
"group",
"name",
"to",
"put",
"result",
"into",
"(",
"allows",
"rapid",
"releasing",
"resulting",
"object",
"handles",
"using",
"releaseObjectGroup",
")",
"."
] | [
"func",
"(",
"p",
"EvaluateOnCallFrameParams",
")",
"WithObjectGroup",
"(",
"objectGroup",
"string",
")",
"*",
"EvaluateOnCallFrameParams",
"{",
"p",
".",
"ObjectGroup",
"=",
"objectGroup",
"\n",
"<mask>",
"&",
"p",
"\n",
"}"
] |
12,948 | all-12949 | [
"ExecuteCommand",
"executes",
"commands",
"to",
"manage",
"database",
"db",
"-",
"create",
"-",
"command",
"to",
"create",
"database",
"db",
"-",
"migrate",
"-",
"command",
"to",
"execute",
"migration",
"scripts",
"db",
"-",
"init",
"-",
"data",
"-",
"command",
"to",
"initialize",
"database",
"by",
"default",
"values",
"db",
"-",
"version",
"-",
"command",
"to",
"print",
"the",
"version",
"of",
"the",
"database",
"schema",
"."
] | [
"func",
"ExecuteCommand",
"(",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"args",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"switch",
"args",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"f",
":=",
"readFlags",
"(",
"args",
")",
"\n",
"if",
"err",
":=",
"createDatabase",
"(",
"f",
".",
"connection",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"os",
".",
"Exit",
"(",
"0",
")",
"\n",
"case",
"\"",
"\"",
":",
"f",
":=",
"readFlags",
"(",
"args",
")",
"\n",
"err",
":=",
"migration",
".",
"Migrate",
"(",
"f",
".",
"connection",
",",
"f",
".",
"version",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"os",
".",
"Exit",
"(",
"0",
")",
"\n",
"case",
"\"",
"\"",
":",
"f",
":=",
"readFlags",
"(",
"args",
")",
"\n",
"if",
"err",
":=",
"initData",
"(",
"f",
".",
"<mask>",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"os",
".",
"Exit",
"(",
"0",
")",
"\n",
"case",
"\"",
"\"",
":",
"f",
":=",
"readFlags",
"(",
"args",
")",
"\n",
"version",
",",
"err",
":=",
"migration",
".",
"Version",
"(",
"f",
".",
"connection",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"msg",
":=",
"\"",
"\"",
"\n",
"panic",
"(",
"msg",
"+",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"version",
")",
"\n",
"os",
".",
"Exit",
"(",
"0",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,949 | all-12950 | [
"FinalizeTypeNames",
"makes",
"sure",
"type",
"names",
"are",
"unique",
"it",
"should",
"be",
"called",
"after",
"analysis",
"has",
"completed",
"."
] | [
"func",
"(",
"reg",
"*",
"TypeRegistry",
")",
"FinalizeTypeNames",
"(",
"d",
"*",
"gen",
".",
"APIDescriptor",
")",
"{",
"for",
"n",
",",
"named",
":=",
"range",
"reg",
".",
"NamedTypes",
"{",
"reg",
".",
"InlineTypes",
"[",
"n",
"]",
"=",
"<mask>",
"(",
"reg",
".",
"InlineTypes",
"[",
"n",
"]",
",",
"named",
")",
"\n",
"}",
"\n",
"d",
".",
"FinalizeTypeNames",
"(",
"reg",
".",
"InlineTypes",
")",
"\n",
"}"
] |
12,950 | all-12951 | [
"Running",
"calls",
"Output",
"to",
"write",
".",
"Useful",
"when",
"you",
"want",
"separate",
"colors",
"or",
"prefixes",
".",
"RunningPrefix",
"is",
"used",
"to",
"prefix",
"message",
"."
] | [
"func",
"(",
"ui",
"*",
"PrefixUI",
")",
"Running",
"(",
"message",
"string",
")",
"{",
"if",
"ui",
".",
"RunningPrefix",
"==",
"\"",
"\"",
"{",
"//Lets keep the space if they want one",
"<mask>",
"=",
"ui",
".",
"RunningPrefix",
"+",
"message",
"\n",
"}",
"else",
"if",
"ui",
".",
"RunningPrefix",
"!=",
"\"",
"\"",
"{",
"message",
"=",
"ui",
".",
"RunningPrefix",
"+",
"\"",
"\"",
"+",
"message",
"\n",
"}",
"\n",
"ui",
".",
"UI",
".",
"Running",
"(",
"message",
")",
"\n",
"}"
] |
12,951 | all-12952 | [
"Fatalf",
"records",
"the",
"log",
"with",
"fatal",
"level",
"and",
"exits"
] | [
"func",
"(",
"l",
"*",
"Logger",
")",
"Fatalf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"Output",
"(",
"2",
",",
"LevelFatal",
",",
"fmt",
".",
"Sprintf",
"(",
"<mask>",
",",
"args",
"...",
")",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}"
] |
12,952 | all-12953 | [
"GetWithVeto",
"returns",
"the",
"value",
"specified",
"by",
"key",
"but",
"returns",
"an",
"error",
"if",
"it",
"has",
"changed",
".",
"The",
"intention",
"here",
"is",
"to",
"block",
"changes",
"to",
"the",
"resource",
"in",
"a",
"fashion",
"that",
"would",
"otherwise",
"result",
"in",
"forcing",
"a",
"new",
"resource",
"."
] | [
"func",
"(",
"r",
"*",
"Subresource",
")",
"GetWithVeto",
"(",
"key",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"r",
".",
"HasChange",
"(",
"key",
")",
"{",
"old",
",",
"new",
":=",
"r",
".",
"GetChange",
"(",
"key",
")",
"\n",
"return",
"r",
".",
"Get",
"(",
"key",
")",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"key",
",",
"<mask>",
",",
"new",
")",
"\n",
"}",
"\n",
"return",
"r",
".",
"Get",
"(",
"key",
")",
",",
"nil",
"\n",
"}"
] |
12,953 | all-12954 | [
"GetOptions",
"returns",
"the",
"Options",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"s",
"*",
"SyntheticsTest",
")",
"GetOptions",
"(",
")",
"SyntheticsOptions",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"<mask>",
"==",
"nil",
"{",
"return",
"SyntheticsOptions",
"{",
"}",
"\n",
"}",
"\n",
"return",
"*",
"s",
".",
"Options",
"\n",
"}"
] |
12,954 | all-12955 | [
"LinkButtonNew",
"is",
"a",
"wrapper",
"around",
"gtk_link_button_new",
"()",
"."
] | [
"func",
"LinkButtonNew",
"(",
"label",
"string",
")",
"(",
"*",
"LinkButton",
",",
"error",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"<mask>",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"c",
":=",
"C",
".",
"gtk_link_button_new",
"(",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"return",
"wrapLinkButton",
"(",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
")",
",",
"nil",
"\n",
"}"
] |
12,955 | all-12956 | [
"delete",
"a",
"contiguous",
"group",
"of",
"display",
"lists"
] | [
"func",
"DeleteLists",
"(",
"list",
"uint32",
",",
"xrange",
"int32",
")",
"{",
"C",
".",
"glowDeleteLists",
"(",
"gpDeleteLists",
",",
"(",
"C",
".",
"GLuint",
")",
"(",
"<mask>",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"xrange",
")",
")",
"\n",
"}"
] |
12,956 | all-12957 | [
"Do",
"executes",
"DOM",
".",
"setNodeValue",
"against",
"the",
"provided",
"context",
"."
] | [
"func",
"(",
"p",
"*",
"SetNodeValueParams",
")",
"Do",
"(",
"ctx",
"<mask>",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"return",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandSetNodeValue",
",",
"p",
",",
"nil",
")",
"\n",
"}"
] |
12,957 | all-12958 | [
"ContainsAZName",
"-"
] | [
"func",
"(",
"s",
"*",
"CloudConfigManifest",
")",
"ContainsAZName",
"(",
"azName",
"string",
")",
"(",
"result",
"bool",
")",
"{",
"result",
"=",
"false",
"\n",
"for",
"_",
",",
"az",
":=",
"range",
"s",
".",
"AZs",
"{",
"if",
"az",
".",
"<mask>",
"==",
"azName",
"{",
"result",
"=",
"true",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
12,958 | all-12959 | [
"FindIssues",
"uses",
"the",
"GitHub",
"search",
"API",
"to",
"find",
"issues",
"which",
"match",
"a",
"particular",
"query",
".",
"Input",
"query",
"the",
"same",
"way",
"you",
"would",
"into",
"the",
"website",
".",
"Order",
"returned",
"results",
"with",
"sort",
"(",
"usually",
"updated",
")",
".",
"Control",
"whether",
"oldest",
"/",
"newest",
"is",
"first",
"with",
"asc",
".",
"See",
"https",
":",
"//",
"help",
".",
"github",
".",
"com",
"/",
"articles",
"/",
"searching",
"-",
"issues",
"-",
"and",
"-",
"pull",
"-",
"requests",
"/",
"for",
"details",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"FindIssues",
"(",
"query",
",",
"sort",
"string",
",",
"asc",
"bool",
")",
"(",
"[",
"]",
"Issue",
",",
"error",
")",
"{",
"c",
".",
"log",
"(",
"\"",
"\"",
",",
"query",
")",
"\n",
"path",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"url",
".",
"QueryEscape",
"(",
"query",
")",
")",
"\n",
"if",
"sort",
"!=",
"\"",
"\"",
"{",
"path",
"+=",
"\"",
"\"",
"+",
"url",
".",
"QueryEscape",
"(",
"sort",
")",
"\n",
"if",
"asc",
"{",
"path",
"+=",
"\"",
"\"",
"\n",
"}",
"\n",
"}",
"\n",
"var",
"issSearchResult",
"IssuesSearchResult",
"\n",
"_",
",",
"err",
":=",
"c",
".",
"request",
"(",
"&",
"request",
"{",
"method",
":",
"http",
".",
"MethodGet",
",",
"<mask>",
":",
"path",
",",
"exitCodes",
":",
"[",
"]",
"int",
"{",
"200",
"}",
",",
"}",
",",
"&",
"issSearchResult",
")",
"\n",
"return",
"issSearchResult",
".",
"Issues",
",",
"err",
"\n",
"}"
] |
12,959 | all-12960 | [
"OptFieldTypeTime",
"adds",
"a",
"time",
"field",
"."
] | [
"func",
"OptFieldTypeTime",
"(",
"quantum",
"TimeQuantum",
",",
"opts",
"...",
"bool",
")",
"FieldOption",
"{",
"return",
"func",
"(",
"options",
"*",
"FieldOptions",
")",
"{",
"options",
".",
"fieldType",
"=",
"FieldTypeTime",
"\n",
"options",
".",
"timeQuantum",
"=",
"quantum",
"\n",
"if",
"len",
"(",
"opts",
")",
">",
"0",
"&&",
"opts",
"[",
"0",
"]",
"{",
"<mask>",
".",
"noStandardView",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
12,960 | all-12961 | [
"Patches",
"returns",
"the",
"names",
"of",
"all",
"patches",
"currently",
"applied",
"on",
"this",
"node",
"."
] | [
"func",
"(",
"n",
"*",
"Node",
")",
"Patches",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"inargs",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"outfmt",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
"}",
"\n\n",
"query",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
")",
"\n",
"result",
",",
"err",
":=",
"queryScan",
"(",
"n",
".",
"db",
",",
"query",
",",
"inargs",
",",
"outfmt",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"err",
"\n",
"}",
"\n\n",
"response",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"result",
"{",
"response",
"=",
"append",
"(",
"<mask>",
",",
"r",
"[",
"0",
"]",
".",
"(",
"string",
")",
")",
"\n",
"}",
"\n\n",
"return",
"response",
",",
"nil",
"\n",
"}"
] |
12,961 | all-12962 | [
"TODO",
"(",
"jrick",
")",
"SetSource",
"(",
"depends",
"on",
"Pattern",
")",
"SetSourceSurface",
"is",
"a",
"wrapper",
"around",
"cairo_set_source_surface",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"SetSourceSurface",
"(",
"surface",
"*",
"Surface",
",",
"x",
",",
"y",
"float64",
")",
"{",
"C",
".",
"cairo_set_source_surface",
"(",
"v",
".",
"native",
"(",
")",
",",
"surface",
".",
"native",
"(",
")",
",",
"C",
".",
"double",
"(",
"x",
")",
",",
"C",
".",
"double",
"(",
"y",
")",
")",
"\n",
"}"
] |
12,962 | all-12963 | [
"NewContext",
"returns",
"a",
"new",
"context",
".",
"Context",
"and",
"Trace",
"with",
"the",
"given",
"family",
"and",
"title",
".",
"The",
"trace",
"will",
"be",
"stored",
"in",
"the",
"context",
"."
] | [
"func",
"NewContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"family",
",",
"title",
"string",
")",
"(",
"xtr",
".",
"Trace",
",",
"context",
".",
"Context",
")",
"{",
"sp",
":=",
"parentOrChildFromContext",
"(",
"ctx",
",",
"<mask>",
",",
"title",
")",
"\n",
"return",
"sp",
",",
"contextWithTrace",
"(",
"ctx",
",",
"sp",
")",
"\n",
"}"
] |
12,963 | all-12964 | [
"Parse",
"the",
"url",
"string",
"(",
"complete",
"or",
"just",
"the",
"path",
")",
"and",
"return",
"the",
"first",
"matching",
"Route",
"and",
"the",
"corresponding",
"parameters",
"."
] | [
"func",
"(",
"rt",
"*",
"router",
")",
"findRoute",
"(",
"httpMethod",
",",
"urlStr",
"string",
")",
"(",
"*",
"Route",
",",
"<mask>",
"[",
"string",
"]",
"string",
",",
"bool",
",",
"error",
")",
"{",
"// parse the url",
"urlObj",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"urlStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"false",
",",
"err",
"\n",
"}",
"\n\n",
"route",
",",
"params",
",",
"pathMatched",
":=",
"rt",
".",
"findRouteFromURL",
"(",
"httpMethod",
",",
"urlObj",
")",
"\n",
"return",
"route",
",",
"params",
",",
"pathMatched",
",",
"nil",
"\n",
"}"
] |
12,964 | all-12965 | [
"ParseHTTPDate",
"parses",
"HTTP",
"-",
"compliant",
"(",
"RFC1123",
")",
"date",
"."
] | [
"func",
"ParseHTTPDate",
"(",
"date",
"[",
"]",
"byte",
")",
"(",
"<mask>",
".",
"Time",
",",
"error",
")",
"{",
"return",
"time",
".",
"Parse",
"(",
"time",
".",
"RFC1123",
",",
"b2s",
"(",
"date",
")",
")",
"\n",
"}"
] |
12,965 | all-12966 | [
"UnmarshalEasyJSON",
"satisfies",
"easyjson",
".",
"Unmarshaler",
"."
] | [
"func",
"(",
"t",
"*",
"Type",
")",
"UnmarshalEasyJSON",
"(",
"in",
"*",
"jlexer",
".",
"Lexer",
")",
"{",
"switch",
"Type",
"(",
"in",
".",
"String",
"(",
")",
")",
"{",
"case",
"TypeObject",
":",
"*",
"t",
"=",
"TypeObject",
"\n",
"case",
"TypeFunction",
":",
"*",
"t",
"=",
"TypeFunction",
"\n",
"<mask>",
"TypeUndefined",
":",
"*",
"t",
"=",
"TypeUndefined",
"\n",
"case",
"TypeString",
":",
"*",
"t",
"=",
"TypeString",
"\n",
"case",
"TypeNumber",
":",
"*",
"t",
"=",
"TypeNumber",
"\n",
"case",
"TypeBoolean",
":",
"*",
"t",
"=",
"TypeBoolean",
"\n",
"case",
"TypeSymbol",
":",
"*",
"t",
"=",
"TypeSymbol",
"\n",
"case",
"TypeBigint",
":",
"*",
"t",
"=",
"TypeBigint",
"\n",
"case",
"TypeAccessor",
":",
"*",
"t",
"=",
"TypeAccessor",
"\n\n",
"default",
":",
"in",
".",
"AddError",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"}"
] |
12,966 | all-12967 | [
"Format",
"formats",
"the",
"node",
"."
] | [
"func",
"(",
"node",
"*",
"Show",
")",
"Format",
"(",
"buf",
"*",
"TrackedBuffer",
")",
"{",
"if",
"node",
".",
"Type",
"==",
"\"",
"\"",
"&&",
"node",
".",
"ShowTablesOpt",
"!=",
"nil",
"{",
"opt",
":=",
"node",
".",
"ShowTablesOpt",
"\n",
"if",
"opt",
".",
"DbName",
"!=",
"\"",
"\"",
"{",
"if",
"opt",
".",
"Filter",
"!=",
"nil",
"{",
"buf",
".",
"Myprintf",
"(",
"\"",
"\"",
",",
"opt",
".",
"Extended",
",",
"opt",
".",
"Full",
",",
"opt",
".",
"DbName",
",",
"<mask>",
".",
"Filter",
")",
"\n",
"}",
"else",
"{",
"buf",
".",
"Myprintf",
"(",
"\"",
"\"",
",",
"opt",
".",
"Extended",
",",
"opt",
".",
"Full",
",",
"opt",
".",
"DbName",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"if",
"opt",
".",
"Filter",
"!=",
"nil",
"{",
"buf",
".",
"Myprintf",
"(",
"\"",
"\"",
",",
"opt",
".",
"Extended",
",",
"opt",
".",
"Full",
",",
"opt",
".",
"Filter",
")",
"\n",
"}",
"else",
"{",
"buf",
".",
"Myprintf",
"(",
"\"",
"\"",
",",
"opt",
".",
"Extended",
",",
"opt",
".",
"Full",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"node",
".",
"Scope",
"==",
"\"",
"\"",
"{",
"buf",
".",
"Myprintf",
"(",
"\"",
"\"",
",",
"node",
".",
"Type",
")",
"\n",
"}",
"else",
"{",
"buf",
".",
"Myprintf",
"(",
"\"",
"\"",
",",
"node",
".",
"Scope",
",",
"node",
".",
"Type",
")",
"\n",
"}",
"\n",
"if",
"node",
".",
"HasOnTable",
"(",
")",
"{",
"buf",
".",
"Myprintf",
"(",
"\"",
"\"",
",",
"node",
".",
"OnTable",
")",
"\n",
"}",
"\n",
"}"
] |
12,967 | all-12968 | [
"WithIsKeypad",
"whether",
"the",
"event",
"was",
"generated",
"from",
"the",
"keypad",
"(",
"default",
":",
"false",
")",
"."
] | [
"func",
"(",
"p",
"DispatchKeyEventParams",
")",
"WithIsKeypad",
"(",
"isKeypad",
"bool",
")",
"*",
"DispatchKeyEventParams",
"{",
"p",
".",
"IsKeypad",
"=",
"isKeypad",
"\n",
"<mask>",
"&",
"p",
"\n",
"}"
] |
12,968 | all-12969 | [
"decimal"
] | [
"func",
"convertNvDecimal",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"driver",
".",
"Value",
",",
"error",
")",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"if",
"v",
",",
"<mask>",
":=",
"v",
".",
"(",
"[",
"]",
"byte",
")",
";",
"ok",
"{",
"return",
"v",
",",
"nil",
"\n",
"}",
"\n\n",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"v",
")",
"\n",
"}"
] |
12,969 | all-12970 | [
"NewFile",
"returns",
"a",
"new",
"File",
"with",
"the",
"given",
"URL",
"and",
"config",
".",
"Set",
"rawurl",
"to",
"a",
"directory",
"on",
"S3",
"such",
"as",
"https",
":",
"//",
"mybucket",
".",
"s3",
".",
"amazonaws",
".",
"com",
"/",
"myfolder",
".",
"The",
"URL",
"cannot",
"have",
"query",
"parameters",
"or",
"a",
"fragment",
".",
"If",
"c",
"is",
"nil",
"DefaultConfig",
"will",
"be",
"used",
"."
] | [
"func",
"NewFile",
"(",
"rawurl",
"string",
",",
"c",
"*",
"Config",
")",
"(",
"*",
"File",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"rawurl",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"u",
".",
"RawQuery",
"!=",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"u",
".",
"Fragment",
"!=",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"prefix",
":=",
"strings",
".",
"TrimLeft",
"(",
"u",
".",
"Path",
",",
"\"",
"\"",
")",
"\n",
"if",
"prefix",
"!=",
"\"",
"\"",
"&&",
"!",
"strings",
".",
"HasSuffix",
"(",
"prefix",
",",
"\"",
"\"",
")",
"{",
"prefix",
"+=",
"\"",
"\"",
"\n",
"}",
"\n",
"u",
".",
"Path",
"=",
"\"",
"\"",
"\n",
"return",
"&",
"File",
"{",
"u",
".",
"String",
"(",
")",
",",
"<mask>",
",",
"c",
",",
"nil",
"}",
",",
"nil",
"\n",
"}"
] |
12,970 | all-12971 | [
"resolveSocket",
"tries",
"to",
"resolve",
"a",
"path",
"to",
"a",
"Unix",
"domain",
"socket",
"based",
"on",
"the",
"form",
"/",
"path",
"/",
"to",
"/",
"socket",
"/",
"dbname",
"returning",
"either",
"the",
"original",
"path",
"and",
"the",
"empty",
"string",
"or",
"the",
"components",
"/",
"path",
"/",
"to",
"/",
"socket",
"and",
"dbname",
"when",
"/",
"path",
"/",
"to",
"/",
"socket",
"/",
"dbname",
"is",
"reported",
"by",
"os",
".",
"Stat",
"as",
"a",
"socket",
".",
"Used",
"for",
"MySQL",
"DSNs",
"."
] | [
"func",
"resolveSocket",
"(",
"path",
"string",
")",
"(",
"string",
",",
"string",
")",
"{",
"dir",
",",
"dbname",
":=",
"path",
",",
"\"",
"\"",
"\n",
"for",
"dir",
"!=",
"\"",
"\"",
"&&",
"dir",
"!=",
"\"",
"\"",
"&&",
"dir",
"!=",
"\"",
"\"",
"{",
"if",
"m",
":=",
"mode",
"(",
"dir",
")",
";",
"m",
"&",
"os",
".",
"ModeSocket",
"!=",
"0",
"{",
"return",
"dir",
",",
"dbname",
"\n",
"}",
"\n",
"dir",
",",
"dbname",
"=",
"stdpath",
".",
"Dir",
"(",
"dir",
")",
",",
"stdpath",
".",
"<mask>",
"(",
"dir",
")",
"\n",
"}",
"\n\n",
"return",
"path",
",",
"\"",
"\"",
"\n",
"}"
] |
12,971 | all-12972 | [
"SetGreetingText",
"sets",
"a",
"greeting",
"text",
"which",
"is",
"only",
"rendered",
"the",
"first",
"time",
"user",
"interacts",
"with",
"the",
"Page",
"on",
"Messenger",
"https",
":",
"//",
"developers",
".",
"facebook",
".",
"com",
"/",
"docs",
"/",
"messenger",
"-",
"platform",
"/",
"thread",
"-",
"settings",
"/",
"greeting",
"-",
"text",
"text",
"must",
"be",
"UTF",
"-",
"8",
"and",
"have",
"a",
"160",
"character",
"limit"
] | [
"func",
"(",
"m",
"*",
"Messenger",
")",
"SetGreetingText",
"(",
"text",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"text",
")",
">",
"160",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"result",
",",
"err",
":=",
"m",
".",
"changeThreadSettings",
"(",
"http",
".",
"MethodPost",
",",
"&",
"threadSettings",
"{",
"Type",
":",
"settingTypeGreeting",
",",
"Greeting",
":",
"&",
"greeting",
"{",
"<mask>",
":",
"text",
"}",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"result",
".",
"Result",
"!=",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"result",
".",
"Result",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,972 | all-12973 | [
"Set",
"is",
"required",
"for",
"kingpin",
"interfaces",
"to",
"allow",
"command",
"line",
"params",
"to",
"be",
"set",
"to",
"our",
"map",
"datatype"
] | [
"func",
"(",
"o",
"*",
"ListUintOption",
")",
"Set",
"(",
"value",
"string",
")",
"error",
"{",
"val",
":=",
"UintOption",
"{",
"}",
"\n",
"val",
".",
"Set",
"(",
"<mask>",
")",
"\n",
"*",
"o",
"=",
"append",
"(",
"*",
"o",
",",
"val",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,973 | all-12974 | [
"String",
"returns",
"the",
"name",
"of",
"e"
] | [
"func",
"(",
"e",
"OperationType",
")",
"String",
"(",
")",
"string",
"{",
"name",
",",
"_",
":=",
"operationTypeMap",
"[",
"int32",
"(",
"e",
")",
"]",
"\n",
"return",
"<mask>",
"\n",
"}"
] |
12,974 | all-12975 | [
"ReflectSort",
"will",
"sort",
"slice",
"according",
"to",
"compareFunc",
"using",
"reflection",
".",
"slice",
"can",
"be",
"a",
"slice",
"of",
"any",
"element",
"type",
"including",
"interface",
"{}",
".",
"compareFunc",
"must",
"have",
"two",
"arguments",
"that",
"are",
"assignable",
"from",
"the",
"slice",
"element",
"type",
"or",
"pointers",
"to",
"such",
"a",
"type",
".",
"The",
"result",
"of",
"compareFunc",
"must",
"be",
"a",
"bool",
"indicating",
"if",
"the",
"first",
"argument",
"is",
"less",
"than",
"the",
"second",
".",
"If",
"the",
"element",
"type",
"of",
"slice",
"is",
"interface",
"{}",
"then",
"the",
"type",
"of",
"the",
"compareFunc",
"arguments",
"can",
"be",
"any",
"type",
"and",
"dynamic",
"casting",
"from",
"the",
"interface",
"value",
"or",
"its",
"address",
"will",
"be",
"attempted",
"."
] | [
"func",
"ReflectSort",
"(",
"slice",
",",
"compareFunc",
"<mask>",
"{",
"}",
")",
"{",
"sortable",
",",
"err",
":=",
"newReflectSortable",
"(",
"slice",
",",
"compareFunc",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"sort",
".",
"Sort",
"(",
"sortable",
")",
"\n",
"}"
] |
12,975 | all-12976 | [
"NewVerifier",
"creates",
"a",
"new",
"RSA",
"backed",
"Verifier"
] | [
"func",
"NewVerifier",
"(",
"opts",
"*",
"KeyOptions",
")",
"(",
"Verifier",
",",
"error",
")",
"{",
"publicKey",
":=",
"opts",
".",
"KeyBytes",
"\n",
"if",
"opts",
".",
"KeyPath",
"!=",
"\"",
"\"",
"{",
"raw",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"opts",
".",
"KeyPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"publicKey",
"=",
"raw",
"\n",
"}",
"\n",
"block",
",",
"_",
":=",
"pem",
".",
"Decode",
"(",
"publicKey",
")",
"\n",
"<mask>",
",",
"err",
":=",
"x509",
".",
"ParseCertificate",
"(",
"block",
".",
"Bytes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"// TODO",
"// Currently only support RSA keys",
"// Need to consider DSA/ECDSA",
"if",
"cert",
".",
"PublicKeyAlgorithm",
"!=",
"x509",
".",
"RSA",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"rsaVerifier",
"{",
"publicKey",
":",
"cert",
".",
"PublicKey",
".",
"(",
"*",
"rsa",
".",
"PublicKey",
")",
",",
"cert",
":",
"cert",
"}",
",",
"nil",
"\n",
"}"
] |
12,976 | all-12977 | [
"Next",
"()",
"returns",
"the",
"current",
"value",
"in",
"the",
"iteration",
"and",
"advances",
"the",
"interator",
".",
"Next",
"()",
"will",
"produce",
"a",
"valid",
"result",
"as",
"long",
"as",
"a",
"call",
"to",
"isDone",
"()",
"returns",
"false",
"."
] | [
"func",
"(",
"it",
"*",
"inclusiveRangesIt",
")",
"Next",
"(",
")",
"int",
"{",
"if",
"!",
"it",
".",
"init",
"(",
")",
"{",
"return",
"it",
".",
"ptr",
".",
"End",
"(",
")",
"\n",
"}",
"\n\n",
"val",
":=",
"it",
".",
"current",
".",
"Next",
"(",
")",
"\n\n",
"if",
"<mask>",
".",
"current",
".",
"IsDone",
"(",
")",
"{",
"// Get the next available range",
"it",
".",
"pos",
"++",
"\n",
"it",
".",
"current",
"=",
"nil",
"\n",
"}",
"\n\n",
"return",
"val",
"\n",
"}"
] |
12,977 | all-12978 | [
"HasManageStatusTitleSize",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"w",
"*",
"Widget",
")",
"HasManageStatusTitleSize",
"(",
")",
"bool",
"{",
"if",
"w",
"!=",
"nil",
"&&",
"w",
".",
"ManageStatusTitleSize",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
12,978 | all-12979 | [
"Dial",
"connects",
"to",
"the",
"address",
"addr",
"on",
"the",
"network",
"protocol",
".",
"The",
"address",
"format",
"is",
"host",
":",
"port",
"where",
"host",
"may",
"be",
"a",
"hostname",
"or",
"an",
"IP",
"address",
".",
"Known",
"protocols",
"are",
"tcp",
"and",
"udp",
".",
"The",
"returned",
"connection",
"satisfies",
"net",
".",
"Conn",
"and",
"is",
"valid",
"while",
"ctx",
"is",
"valid",
";",
"if",
"the",
"connection",
"is",
"to",
"be",
"used",
"after",
"ctx",
"becomes",
"invalid",
"invoke",
"SetContext",
"with",
"the",
"new",
"context",
"."
] | [
"func",
"Dial",
"(",
"ctx",
"context",
".",
"<mask>",
",",
"protocol",
",",
"addr",
"string",
")",
"(",
"*",
"Conn",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"net",
".",
"Dial",
"(",
"protocol",
",",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"Conn",
"{",
"conn",
"}",
",",
"nil",
"\n",
"}"
] |
12,979 | all-12980 | [
"AddActionWidget",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_dialog_add_action_widget",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Dialog",
")",
"AddActionWidget",
"(",
"child",
"IWidget",
",",
"id",
"ResponseType",
")",
"{",
"C",
".",
"gtk_dialog_add_action_widget",
"(",
"v",
".",
"native",
"(",
")",
",",
"<mask>",
".",
"toWidget",
"(",
")",
",",
"C",
".",
"gint",
"(",
"id",
")",
")",
"\n",
"}"
] |
12,980 | all-12981 | [
"Resolve",
"the",
"reference",
"s",
"name",
"to",
"an",
"image",
"ID",
"in",
"the",
"store",
"if",
"there",
"s",
"already",
"one",
"present",
"with",
"the",
"same",
"name",
"or",
"ID",
"and",
"return",
"the",
"image",
"."
] | [
"func",
"(",
"s",
"*",
"storageReference",
")",
"resolveImage",
"(",
")",
"(",
"*",
"storage",
".",
"Image",
",",
"error",
")",
"{",
"var",
"loadedImage",
"*",
"storage",
".",
"Image",
"\n",
"if",
"s",
".",
"id",
"==",
"\"",
"\"",
"&&",
"s",
".",
"named",
"!=",
"nil",
"{",
"// Look for an image that has the expanded reference name as an explicit Name value.",
"image",
",",
"err",
":=",
"s",
".",
"transport",
".",
"store",
".",
"Image",
"(",
"s",
".",
"named",
".",
"String",
"(",
")",
")",
"\n",
"if",
"image",
"!=",
"nil",
"&&",
"err",
"==",
"nil",
"{",
"loadedImage",
"=",
"image",
"\n",
"s",
".",
"id",
"=",
"image",
".",
"ID",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"s",
".",
"id",
"==",
"\"",
"\"",
"&&",
"s",
".",
"named",
"!=",
"nil",
"{",
"if",
"digested",
",",
"ok",
":=",
"s",
".",
"named",
".",
"(",
"reference",
".",
"Digested",
")",
";",
"ok",
"{",
"// Look for an image with the specified digest that has the same name,",
"// though possibly with a different tag or digest, as a Name value, so",
"// that the canonical reference can be implicitly resolved to the image.",
"images",
",",
"err",
":=",
"s",
".",
"transport",
".",
"store",
".",
"ImagesByDigest",
"(",
"digested",
".",
"Digest",
"(",
")",
")",
"\n",
"if",
"err",
"==",
"nil",
"&&",
"len",
"(",
"images",
")",
">",
"0",
"{",
"for",
"_",
",",
"<mask>",
":=",
"range",
"images",
"{",
"if",
"imageMatchesRepo",
"(",
"image",
",",
"s",
".",
"named",
")",
"{",
"loadedImage",
"=",
"image",
"\n",
"s",
".",
"id",
"=",
"image",
".",
"ID",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"s",
".",
"id",
"==",
"\"",
"\"",
"{",
"logrus",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"s",
".",
"StringWithinTransport",
"(",
")",
")",
"\n",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"ErrNoSuchImage",
",",
"\"",
"\"",
",",
"s",
".",
"StringWithinTransport",
"(",
")",
")",
"\n",
"}",
"\n",
"if",
"loadedImage",
"==",
"nil",
"{",
"img",
",",
"err",
":=",
"s",
".",
"transport",
".",
"store",
".",
"Image",
"(",
"s",
".",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"s",
".",
"id",
")",
"\n",
"}",
"\n",
"loadedImage",
"=",
"img",
"\n",
"}",
"\n",
"if",
"s",
".",
"named",
"!=",
"nil",
"{",
"if",
"!",
"imageMatchesRepo",
"(",
"loadedImage",
",",
"s",
".",
"named",
")",
"{",
"logrus",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"s",
".",
"StringWithinTransport",
"(",
")",
")",
"\n",
"return",
"nil",
",",
"ErrNoSuchImage",
"\n",
"}",
"\n",
"}",
"\n",
"// Default to having the image digest that we hand back match the most recently",
"// added manifest...",
"if",
"digest",
",",
"ok",
":=",
"loadedImage",
".",
"BigDataDigests",
"[",
"storage",
".",
"ImageDigestBigDataKey",
"]",
";",
"ok",
"{",
"loadedImage",
".",
"Digest",
"=",
"digest",
"\n",
"}",
"\n",
"// ... unless the named reference says otherwise, and it matches one of the digests",
"// in the image. For those cases, set the Digest field to that value, for the",
"// sake of older consumers that don't know there's a whole list in there now.",
"if",
"s",
".",
"named",
"!=",
"nil",
"{",
"if",
"digested",
",",
"ok",
":=",
"s",
".",
"named",
".",
"(",
"reference",
".",
"Digested",
")",
";",
"ok",
"{",
"for",
"_",
",",
"digest",
":=",
"range",
"loadedImage",
".",
"Digests",
"{",
"if",
"digest",
"==",
"digested",
".",
"Digest",
"(",
")",
"{",
"loadedImage",
".",
"Digest",
"=",
"digest",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"loadedImage",
",",
"nil",
"\n",
"}"
] |
12,981 | all-12982 | [
"Panic",
"returns",
"a",
"handler",
"that",
"invokes",
"the",
"passed",
"handler",
"h",
"catching",
"any",
"panics",
".",
"If",
"one",
"occurs",
"an",
"HTTP",
"500",
"response",
"is",
"produced",
".",
"By",
"default",
"all",
"messages",
"are",
"printed",
"out",
"to",
"os",
".",
"Stderr",
"."
] | [
"func",
"Panic",
"(",
"h",
"<mask>",
".",
"Handler",
",",
"opts",
"...",
"Option",
")",
"http",
".",
"Handler",
"{",
"o",
":=",
"options",
"{",
"logger",
":",
"handler",
".",
"ErrLogger",
"(",
")",
",",
"dateFormat",
":",
"PanicDateFormat",
"}",
"\n",
"o",
".",
"apply",
"(",
"opts",
")",
"\n\n",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"rec",
":=",
"recover",
"(",
")",
";",
"rec",
"!=",
"nil",
"{",
"stack",
":=",
"debug",
".",
"Stack",
"(",
")",
"\n",
"timestamp",
":=",
"time",
".",
"Now",
"(",
")",
".",
"Format",
"(",
"o",
".",
"dateFormat",
")",
"\n",
"message",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\\n",
"\"",
",",
"timestamp",
",",
"rec",
",",
"stack",
")",
"\n\n",
"o",
".",
"logger",
".",
"Print",
"(",
"message",
")",
"\n\n",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusInternalServerError",
")",
"\n\n",
"if",
"!",
"o",
".",
"showStack",
"{",
"message",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"w",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"message",
")",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"h",
".",
"ServeHTTP",
"(",
"w",
",",
"r",
")",
"\n",
"}",
")",
"\n",
"}"
] |
12,982 | all-12983 | [
"title",
":",
"remove",
"node",
"container",
"path",
":",
"/",
"docker",
"/",
"nodecontainers",
"/",
"{",
"name",
"}",
"method",
":",
"DELETE",
"responses",
":",
"200",
":",
"Ok",
"401",
":",
"Unauthorized",
"404",
":",
"Not",
"found"
] | [
"func",
"nodeContainerDelete",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"<mask>",
".",
"Request",
",",
"t",
"auth",
".",
"Token",
")",
"(",
"err",
"error",
")",
"{",
"name",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"poolName",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"kill",
",",
"_",
":=",
"strconv",
".",
"ParseBool",
"(",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
")",
"\n",
"var",
"ctxs",
"[",
"]",
"permTypes",
".",
"PermissionContext",
"\n",
"if",
"poolName",
"!=",
"\"",
"\"",
"{",
"ctxs",
"=",
"append",
"(",
"ctxs",
",",
"permission",
".",
"Context",
"(",
"permTypes",
".",
"CtxPool",
",",
"poolName",
")",
")",
"\n",
"}",
"\n",
"if",
"!",
"permission",
".",
"Check",
"(",
"t",
",",
"permission",
".",
"PermNodecontainerDelete",
",",
"ctxs",
"...",
")",
"{",
"return",
"permission",
".",
"ErrUnauthorized",
"\n",
"}",
"\n",
"evt",
",",
"err",
":=",
"event",
".",
"New",
"(",
"&",
"event",
".",
"Opts",
"{",
"Target",
":",
"event",
".",
"Target",
"{",
"Type",
":",
"event",
".",
"TargetTypeNodeContainer",
",",
"Value",
":",
"name",
"}",
",",
"Kind",
":",
"permission",
".",
"PermNodecontainerDelete",
",",
"Owner",
":",
"t",
",",
"CustomData",
":",
"event",
".",
"FormToCustomData",
"(",
"InputFields",
"(",
"r",
")",
")",
",",
"Allowed",
":",
"event",
".",
"Allowed",
"(",
"permission",
".",
"PermPoolReadEvents",
",",
"ctxs",
"...",
")",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"evt",
".",
"Done",
"(",
"err",
")",
"}",
"(",
")",
"\n",
"err",
"=",
"nodecontainer",
".",
"RemoveContainer",
"(",
"poolName",
",",
"name",
")",
"\n",
"if",
"err",
"==",
"nodecontainer",
".",
"ErrNodeContainerNotFound",
"{",
"return",
"&",
"tsuruErrors",
".",
"HTTP",
"{",
"Code",
":",
"http",
".",
"StatusNotFound",
",",
"Message",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"name",
",",
"poolName",
")",
",",
"}",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"!",
"kill",
"{",
"return",
"err",
"\n",
"}",
"\n",
"provs",
",",
"err",
":=",
"provision",
".",
"Registry",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"keepAliveWriter",
":=",
"tsuruIo",
".",
"NewKeepAliveWriter",
"(",
"w",
",",
"15",
"*",
"time",
".",
"Second",
",",
"\"",
"\"",
")",
"\n",
"defer",
"keepAliveWriter",
".",
"Stop",
"(",
")",
"\n",
"writer",
":=",
"&",
"tsuruIo",
".",
"SimpleJsonMessageEncoderWriter",
"{",
"Encoder",
":",
"json",
".",
"NewEncoder",
"(",
"keepAliveWriter",
")",
"}",
"\n",
"evt",
".",
"SetLogWriter",
"(",
"writer",
")",
"\n",
"var",
"allErrors",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"prov",
":=",
"range",
"provs",
"{",
"ncProv",
",",
"ok",
":=",
"prov",
".",
"(",
"provision",
".",
"NodeContainerProvisioner",
")",
"\n",
"if",
"!",
"ok",
"{",
"continue",
"\n",
"}",
"\n",
"err",
"=",
"ncProv",
".",
"RemoveNodeContainer",
"(",
"name",
",",
"poolName",
",",
"evt",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"allErrors",
"=",
"append",
"(",
"allErrors",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"len",
"(",
"allErrors",
")",
">",
"0",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"strings",
".",
"Join",
"(",
"allErrors",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,983 | all-12984 | [
"LogFields",
"adds",
"the",
"key",
"/",
"value",
"pairs",
"onto",
"the",
"Logger",
"to",
"be",
"printed",
"out",
"as",
"part",
"of",
"the",
"request",
"logging",
".",
"This",
"allows",
"you",
"to",
"easily",
"add",
"things",
"like",
"metrics",
"(",
"think",
"DB",
"times",
")",
"to",
"your",
"request",
"."
] | [
"func",
"(",
"d",
"*",
"DefaultContext",
")",
"LogFields",
"(",
"<mask>",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"d",
".",
"logger",
"=",
"d",
".",
"logger",
".",
"WithFields",
"(",
"values",
")",
"\n",
"}"
] |
12,984 | all-12985 | [
"Specify",
"the",
"value",
"of",
"a",
"uniform",
"variable",
"for",
"the",
"current",
"program",
"object"
] | [
"func",
"Uniform4i",
"(",
"location",
"int32",
",",
"v0",
"int32",
",",
"v1",
"int32",
",",
"v2",
"int32",
",",
"v3",
"int32",
")",
"{",
"syscall",
".",
"Syscall6",
"(",
"gpUniform4i",
",",
"5",
",",
"uintptr",
"(",
"<mask>",
")",
",",
"uintptr",
"(",
"v0",
")",
",",
"uintptr",
"(",
"v1",
")",
",",
"uintptr",
"(",
"v2",
")",
",",
"uintptr",
"(",
"v3",
")",
",",
"0",
")",
"\n",
"}"
] |
12,985 | all-12986 | [
"Validate",
"validates",
"this",
"vms",
"response"
] | [
"func",
"(",
"m",
"*",
"VmsResponse",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateVms",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"// prop",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"<mask>",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,986 | all-12987 | [
"HasTitle",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"e",
"*",
"Event",
")",
"HasTitle",
"(",
")",
"bool",
"{",
"if",
"e",
"!=",
"nil",
"&&",
"e",
".",
"Title",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
12,987 | all-12988 | [
"InsertText",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_entry_buffer_insert_text",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"EntryBuffer",
")",
"InsertText",
"(",
"position",
"uint",
",",
"text",
"string",
")",
"uint",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"text",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"c",
":=",
"C",
".",
"gtk_entry_buffer_insert_text",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"guint",
"(",
"<mask>",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
",",
"C",
".",
"gint",
"(",
"len",
"(",
"text",
")",
")",
")",
"\n",
"return",
"uint",
"(",
"c",
")",
"\n",
"}"
] |
12,988 | all-12989 | [
"GetSystemErrorMessage",
"returns",
"the",
"message",
"to",
"report",
"for",
"the",
"given",
"error",
".",
"If",
"the",
"error",
"is",
"a",
"SystemError",
"we",
"can",
"get",
"the",
"underlying",
"message",
".",
"Otherwise",
"use",
"the",
"Error",
"()",
"method",
"."
] | [
"func",
"GetSystemErrorMessage",
"(",
"err",
"error",
")",
"string",
"{",
"if",
"se",
",",
"ok",
":=",
"err",
".",
"(",
"SystemError",
")",
";",
"ok",
"{",
"return",
"se",
".",
"<mask>",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"err",
".",
"Error",
"(",
")",
"\n",
"}"
] |
12,989 | all-12990 | [
"==",
"Set",
"session",
"-",
"wide",
"variables",
"Set",
"sets",
"the",
"value",
"of",
"the",
"environment",
"variable",
"named",
"by",
"the",
"key",
"that",
"affects",
"the",
"current",
"user",
".",
"It",
"returns",
"an",
"error",
"if",
"any",
"."
] | [
"func",
"<mask>",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"err",
":=",
"_Set",
"(",
"_SETTINGS",
".",
"user",
",",
"key",
",",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"_SETTINGS",
".",
"useKDE",
"{",
"return",
"_Set",
"(",
"_SETTINGS",
".",
"kde",
",",
"key",
",",
"value",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,990 | all-12991 | [
"pipelineSend",
"is",
"used",
"to",
"send",
"data",
"over",
"a",
"pipeline",
".",
"It",
"is",
"a",
"helper",
"to",
"pipelineReplicate",
"."
] | [
"func",
"(",
"r",
"*",
"Raft",
")",
"pipelineSend",
"(",
"s",
"*",
"followerReplication",
",",
"p",
"AppendPipeline",
",",
"nextIdx",
"*",
"uint64",
",",
"lastIndex",
"uint64",
")",
"(",
"shouldStop",
"bool",
")",
"{",
"// Create a new append request",
"req",
":=",
"new",
"(",
"AppendEntriesRequest",
")",
"\n",
"if",
"err",
":=",
"r",
".",
"setupAppendEntries",
"(",
"s",
",",
"req",
",",
"*",
"nextIdx",
",",
"lastIndex",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"// Pipeline the append entries",
"if",
"_",
",",
"err",
":=",
"p",
".",
"AppendEntries",
"(",
"req",
",",
"new",
"(",
"AppendEntriesResponse",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"r",
".",
"logger",
".",
"Error",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"peer",
",",
"err",
")",
")",
"\n",
"return",
"true",
"\n",
"}",
"\n\n",
"// Increase the next send log to avoid re-sending old logs",
"if",
"n",
":=",
"len",
"(",
"req",
".",
"Entries",
")",
";",
"n",
">",
"0",
"{",
"last",
":=",
"req",
".",
"Entries",
"[",
"n",
"-",
"1",
"]",
"\n",
"*",
"nextIdx",
"=",
"last",
".",
"Index",
"+",
"1",
"\n",
"}",
"\n",
"return",
"<mask>",
"\n",
"}"
] |
12,991 | all-12992 | [
"Same",
"as",
"AcquireApplicationLock",
"but",
"it",
"keeps",
"trying",
"to",
"acquire",
"the",
"lock",
"until",
"timeout",
"is",
"reached",
"."
] | [
"func",
"AcquireApplicationLockWait",
"(",
"appName",
"string",
",",
"owner",
"string",
",",
"reason",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"bool",
",",
"error",
")",
"{",
"timeoutChan",
":=",
"time",
".",
"After",
"(",
"timeout",
")",
"\n",
"for",
"{",
"appLock",
":=",
"appTypes",
".",
"AppLock",
"{",
"Locked",
":",
"true",
",",
"Reason",
":",
"reason",
",",
"Owner",
":",
"owner",
",",
"AcquireDate",
":",
"time",
".",
"Now",
"(",
")",
".",
"In",
"(",
"time",
".",
"UTC",
")",
",",
"}",
"\n",
"conn",
",",
"err",
":=",
"db",
".",
"Conn",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"err",
"=",
"conn",
".",
"Apps",
"(",
")",
".",
"Update",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"appName",
",",
"\"",
"\"",
":",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"[",
"]",
"interface",
"{",
"}",
"{",
"false",
",",
"nil",
"}",
"}",
"}",
",",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"appLock",
"}",
"}",
")",
"\n",
"conn",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"true",
",",
"nil",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"mgo",
".",
"ErrNotFound",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"select",
"{",
"case",
"<-",
"timeoutChan",
":",
"return",
"false",
",",
"nil",
"\n",
"case",
"<-",
"<mask>",
".",
"After",
"(",
"300",
"*",
"time",
".",
"Millisecond",
")",
":",
"}",
"\n",
"}",
"\n",
"}"
] |
12,992 | all-12993 | [
"Generate",
"API",
"metadata",
"drives",
"the",
"metadata",
"writer",
"."
] | [
"func",
"GenerateAngular",
"(",
"descriptor",
"*",
"gen",
".",
"APIDescriptor",
",",
"pkgDir",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"files",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"name",
":=",
"range",
"descriptor",
".",
"ResourceNames",
"{",
"res",
":=",
"descriptor",
".",
"Resources",
"[",
"name",
"]",
"\n",
"codegen",
":=",
"filepath",
".",
"Join",
"(",
"pkgDir",
",",
"inflect",
".",
"Underscore",
"(",
"name",
")",
"+",
"\"",
"\"",
")",
"\n",
"f",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"codegen",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"files",
",",
"err",
"\n",
"}",
"\n",
"c",
",",
"err",
":=",
"NewAngularWriter",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"files",
",",
"err",
"\n",
"}",
"\n",
"kingpin",
".",
"FatalIfError",
"(",
"c",
".",
"WriteResource",
"(",
"res",
",",
"f",
")",
",",
"\"",
"\"",
")",
"\n",
"f",
".",
"Close",
"(",
")",
"\n",
"<mask>",
"=",
"append",
"(",
"files",
",",
"codegen",
")",
"\n",
"}",
"\n",
"return",
"files",
",",
"nil",
"\n",
"}"
] |
12,993 | all-12994 | [
"Same",
"compares",
"to",
"Targets",
"and",
"returns",
"true",
"if",
"they",
"are",
"completely",
"identical"
] | [
"func",
"(",
"t",
"Targets",
")",
"Same",
"(",
"o",
"Targets",
")",
"bool",
"{",
"if",
"len",
"(",
"t",
")",
"!=",
"len",
"(",
"o",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"<mask>",
".",
"Stable",
"(",
"t",
")",
"\n",
"sort",
".",
"Stable",
"(",
"o",
")",
"\n\n",
"for",
"i",
",",
"e",
":=",
"range",
"t",
"{",
"if",
"e",
"!=",
"o",
"[",
"i",
"]",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] |
12,994 | all-12995 | [
"GetLongPolicy",
"reads",
"a",
"ResourceData",
"and",
"returns",
"an",
"appropriate",
"LongPolicy",
"for",
"the",
"state",
"of",
"the",
"definition",
".",
"nil",
"is",
"returned",
"if",
"it",
"does",
"not",
"exist",
"."
] | [
"func",
"GetLongPolicy",
"(",
"d",
"*",
"schema",
".",
"ResourceData",
",",
"key",
"string",
")",
"*",
"<mask>",
".",
"LongPolicy",
"{",
"v",
",",
"e",
":=",
"d",
".",
"GetOkExists",
"(",
"key",
")",
"\n",
"if",
"e",
"{",
"return",
"LongPolicy",
"(",
"v",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
12,995 | all-12996 | [
"GetRoleOk",
"returns",
"a",
"tuple",
"with",
"the",
"Role",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"u",
"*",
"User",
")",
"GetRoleOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"u",
"==",
"nil",
"||",
"u",
".",
"Role",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"u",
".",
"<mask>",
",",
"true",
"\n",
"}"
] |
12,996 | all-12997 | [
"NewFile",
"is",
"a",
"convenience",
"function",
"which",
"creates",
"and",
"opens",
"a",
"file"
] | [
"func",
"NewFile",
"(",
"<mask>",
"string",
")",
"io",
".",
"Writer",
"{",
"if",
"err",
",",
"_",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
";",
"err",
"!=",
"nil",
"{",
"os",
".",
"Remove",
"(",
"filename",
")",
"\n",
"}",
"\n\n",
"file",
",",
"_",
":=",
"os",
".",
"Create",
"(",
"filename",
")",
"\n\n",
"return",
"file",
"\n",
"}"
] |
12,997 | all-12998 | [
"PruneComments",
"fetches",
"issue",
"comments",
"if",
"they",
"have",
"not",
"yet",
"been",
"fetched",
"for",
"this",
"webhook",
"event",
"and",
"then",
"deletes",
"any",
"bot",
"comments",
"indicated",
"by",
"the",
"func",
"shouldPrune",
"."
] | [
"func",
"(",
"c",
"*",
"EventClient",
")",
"PruneComments",
"(",
"shouldPrune",
"func",
"(",
"github",
".",
"IssueComment",
")",
"bool",
")",
"{",
"c",
".",
"once",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"botName",
",",
"err",
":=",
"c",
".",
"ghc",
".",
"BotName",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"comments",
",",
"err",
":=",
"c",
".",
"ghc",
".",
"ListIssueComments",
"(",
"c",
".",
"org",
",",
"c",
".",
"repo",
",",
"c",
".",
"number",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"c",
".",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"c",
".",
"org",
",",
"c",
".",
"repo",
",",
"c",
".",
"<mask>",
")",
"\n",
"}",
"\n",
"if",
"botName",
"!=",
"\"",
"\"",
"{",
"for",
"_",
",",
"comment",
":=",
"range",
"comments",
"{",
"if",
"comment",
".",
"User",
".",
"Login",
"==",
"botName",
"{",
"c",
".",
"comments",
"=",
"append",
"(",
"c",
".",
"comments",
",",
"comment",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
")",
"\n\n",
"c",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"var",
"remaining",
"[",
"]",
"github",
".",
"IssueComment",
"\n",
"for",
"_",
",",
"comment",
":=",
"range",
"c",
".",
"comments",
"{",
"removed",
":=",
"false",
"\n",
"if",
"shouldPrune",
"(",
"comment",
")",
"{",
"if",
"err",
":=",
"c",
".",
"ghc",
".",
"DeleteComment",
"(",
"c",
".",
"org",
",",
"c",
".",
"repo",
",",
"comment",
".",
"ID",
")",
";",
"err",
"!=",
"nil",
"{",
"c",
".",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"comment",
".",
"ID",
")",
"\n",
"}",
"else",
"{",
"removed",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"removed",
"{",
"remaining",
"=",
"append",
"(",
"remaining",
",",
"comment",
")",
"\n",
"}",
"\n",
"}",
"\n",
"c",
".",
"comments",
"=",
"remaining",
"\n",
"}"
] |
12,998 | all-12999 | [
"Invalidate",
"invalidates",
"the",
"cache",
"entries",
"that",
"intersecting",
"with",
"the",
"given",
"range",
"from",
"key",
"to",
"endkey",
"."
] | [
"func",
"(",
"c",
"*",
"cache",
")",
"Invalidate",
"(",
"key",
",",
"endkey",
"[",
"]",
"byte",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"var",
"(",
"ivs",
"[",
"]",
"*",
"adt",
".",
"IntervalValue",
"\n",
"ivl",
"adt",
".",
"Interval",
"\n",
")",
"\n",
"if",
"len",
"(",
"endkey",
")",
"==",
"0",
"{",
"ivl",
"=",
"adt",
".",
"NewStringAffinePoint",
"(",
"string",
"(",
"key",
")",
")",
"\n",
"}",
"else",
"{",
"ivl",
"=",
"adt",
".",
"NewStringAffineInterval",
"(",
"string",
"(",
"key",
")",
",",
"string",
"(",
"endkey",
")",
")",
"\n",
"}",
"\n\n",
"ivs",
"=",
"c",
".",
"cachedRanges",
".",
"Stab",
"(",
"ivl",
")",
"\n",
"for",
"_",
",",
"iv",
":=",
"range",
"ivs",
"{",
"keys",
":=",
"iv",
".",
"Val",
".",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
"\n",
"for",
"key",
":=",
"<mask>",
"keys",
"{",
"c",
".",
"lru",
".",
"Remove",
"(",
"key",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// delete after removing all keys since it is destructive to 'ivs'",
"c",
".",
"cachedRanges",
".",
"Delete",
"(",
"ivl",
")",
"\n",
"}"
] |
12,999 | all-13000 | [
"GetSerializableArgument",
"get",
"serializable",
"argument"
] | [
"func",
"(",
"serialize",
"*",
"SerializableMeta",
")",
"GetSerializableArgument",
"(",
"serializableMetaInterface",
"SerializableMetaInterface",
")",
"<mask>",
"{",
"}",
"{",
"if",
"serialize",
".",
"Value",
".",
"OriginalValue",
"!=",
"nil",
"{",
"return",
"serialize",
".",
"Value",
".",
"OriginalValue",
"\n",
"}",
"\n\n",
"if",
"res",
":=",
"serializableMetaInterface",
".",
"GetSerializableArgumentResource",
"(",
")",
";",
"res",
"!=",
"nil",
"{",
"value",
":=",
"res",
".",
"NewStruct",
"(",
")",
"\n",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"serialize",
".",
"Value",
".",
"SerializedValue",
")",
",",
"value",
")",
"\n",
"return",
"value",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.