id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
4,700 | all-4701 | [
"helpers"
] | [
"func",
"(",
"peer",
"*",
"localPeer",
")",
"broadcastPeerUpdate",
"(",
"peers",
"...",
"*",
"Peer",
")",
"{",
"// Some tests run without a router. This should be fixed so",
"// that the relevant part of Router can be easily run in the",
"// context of a test, but that will involve significant",
"// reworking of tests.",
"if",
"peer",
".",
"router",
"!=",
"nil",
"{",
"peer",
".",
"router",
".",
"broadcastTopologyUpdate",
"(",
"append",
"(",
"peers",
",",
"<mask>",
".",
"Peer",
")",
")",
"\n",
"}",
"\n",
"}"
] |
4,701 | all-4702 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"CrashGpuProcessParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoBrowser18",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
4,702 | all-4703 | [
"HasTitleSize",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"c",
"*",
"ChangeDefinition",
")",
"HasTitleSize",
"(",
")",
"bool",
"{",
"if",
"c",
"!=",
"nil",
"&&",
"c",
".",
"TitleSize",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"<mask>",
"\n",
"}"
] |
4,703 | all-4704 | [
"NumInstances",
"returns",
"the",
"number",
"of",
"instances",
"of",
"the",
"given",
"module",
"/",
"version",
".",
"If",
"either",
"argument",
"is",
"the",
"empty",
"string",
"it",
"means",
"the",
"default",
"."
] | [
"func",
"NumInstances",
"(",
"c",
"context",
".",
"Context",
",",
"module",
",",
"version",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"req",
":=",
"&",
"pb",
".",
"GetNumInstancesRequest",
"{",
"}",
"\n",
"if",
"module",
"!=",
"\"",
"\"",
"{",
"req",
".",
"<mask>",
"=",
"&",
"module",
"\n",
"}",
"\n",
"if",
"version",
"!=",
"\"",
"\"",
"{",
"req",
".",
"Version",
"=",
"&",
"version",
"\n",
"}",
"\n",
"res",
":=",
"&",
"pb",
".",
"GetNumInstancesResponse",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"internal",
".",
"Call",
"(",
"c",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"req",
",",
"res",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n",
"return",
"int",
"(",
"*",
"res",
".",
"Instances",
")",
",",
"nil",
"\n",
"}"
] |
4,704 | all-4705 | [
"Token",
"returns",
"the",
"token",
"string",
"stored",
"in",
"the",
"request",
"context",
"or",
"an",
"empty",
"string",
"."
] | [
"func",
"Token",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"if",
"token",
",",
"ok",
":=",
"r",
".",
"<mask>",
"(",
")",
".",
"Value",
"(",
"TokenKey",
")",
".",
"(",
"string",
")",
";",
"ok",
"{",
"return",
"token",
"\n",
"}",
"\n\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
4,705 | all-4706 | [
"UpdateServer",
"partial",
"update",
"of",
"server",
"properties",
"passed",
"in",
"as",
"jason",
"[]",
"byte",
"Returns",
"Instance",
"struct"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateServer",
"(",
"dcid",
"string",
",",
"srvid",
"string",
",",
"props",
"ServerProperties",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"url",
":=",
"serverPath",
"(",
"dcid",
",",
"srvid",
")",
"+",
"`?depth=`",
"+",
"c",
".",
"client",
".",
"depth",
"+",
"`&pretty=`",
"+",
"strconv",
".",
"FormatBool",
"(",
"c",
".",
"client",
".",
"pretty",
")",
"\n",
"ret",
":=",
"&",
"Server",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"<mask>",
".",
"Patch",
"(",
"url",
",",
"props",
",",
"ret",
",",
"http",
".",
"StatusAccepted",
")",
"\n",
"return",
"ret",
",",
"err",
"\n",
"}"
] |
4,706 | all-4707 | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"delete",
"apps",
"app",
"params"
] | [
"func",
"(",
"o",
"*",
"DeleteAppsAppParams",
")",
"WithTimeout",
"(",
"timeout",
"<mask>",
".",
"Duration",
")",
"*",
"DeleteAppsAppParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] |
4,707 | all-4708 | [
"GetUrl",
"returns",
"the",
"Url",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"b",
"*",
"Board",
")",
"GetUrl",
"(",
")",
"<mask>",
"{",
"if",
"b",
"==",
"nil",
"||",
"b",
".",
"Url",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"b",
".",
"Url",
"\n",
"}"
] |
4,708 | all-4709 | [
"GetGroup",
"retrieves",
"a",
"group",
"from",
"a",
"domain",
"with",
"the",
"given",
"group",
"name"
] | [
"func",
"(",
"dom",
"*",
"Domain",
")",
"GetGroup",
"(",
"name",
"string",
")",
"(",
"*",
"Group",
",",
"error",
")",
"{",
"var",
"d",
"dictionary",
"\n",
"err",
":=",
"dom",
".",
"cgp",
".",
"<mask>",
"(",
"getGroup",
"{",
"Name",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"name",
",",
"dom",
".",
"Name",
")",
"}",
",",
"&",
"d",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"&",
"Group",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"memStr",
":=",
"d",
".",
"toMap",
"(",
")",
"[",
"\"",
"\"",
"]",
"\n",
"var",
"mems",
"[",
"]",
"*",
"Account",
"\n",
"dec",
":=",
"xml",
".",
"NewDecoder",
"(",
"bytes",
".",
"NewBufferString",
"(",
"memStr",
")",
")",
"\n",
"for",
"{",
"var",
"a",
"string",
"\n",
"err",
":=",
"dec",
".",
"Decode",
"(",
"&",
"a",
")",
"\n",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"break",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"dom",
".",
"Group",
"(",
"name",
",",
"mems",
")",
",",
"err",
"\n",
"}",
"\n",
"if",
"a",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n",
"mems",
"=",
"append",
"(",
"mems",
",",
"dom",
".",
"Account",
"(",
"a",
")",
")",
"\n",
"}",
"\n",
"return",
"dom",
".",
"Group",
"(",
"name",
",",
"mems",
")",
",",
"nil",
"\n",
"}"
] |
4,709 | all-4710 | [
"Stability",
":",
"***",
"EXPERIMENTAL",
"***",
"Get",
"a",
"list",
"of",
"all",
"active",
"workers",
"of",
"a",
"workerType",
".",
"listWorkers",
"allows",
"a",
"response",
"to",
"be",
"filtered",
"by",
"quarantined",
"and",
"non",
"quarantined",
"workers",
".",
"To",
"filter",
"the",
"query",
"you",
"should",
"call",
"the",
"end",
"-",
"point",
"with",
"quarantined",
"as",
"a",
"query",
"-",
"string",
"option",
"with",
"a",
"true",
"or",
"false",
"value",
".",
"The",
"response",
"is",
"paged",
".",
"If",
"this",
"end",
"-",
"point",
"returns",
"a",
"continuationToken",
"you",
"should",
"call",
"the",
"end",
"-",
"point",
"again",
"with",
"the",
"continuationToken",
"as",
"a",
"query",
"-",
"string",
"option",
".",
"By",
"default",
"this",
"end",
"-",
"point",
"will",
"list",
"up",
"to",
"1000",
"workers",
"in",
"a",
"single",
"page",
".",
"You",
"may",
"limit",
"this",
"with",
"the",
"query",
"-",
"string",
"parameter",
"limit",
".",
"See",
"#listWorkers"
] | [
"func",
"(",
"queue",
"*",
"Queue",
")",
"ListWorkers",
"(",
"provisionerId",
",",
"workerType",
",",
"continuationToken",
",",
"limit",
",",
"quarantined",
"string",
")",
"(",
"*",
"ListWorkersResponse",
",",
"error",
")",
"{",
"v",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"if",
"continuationToken",
"!=",
"\"",
"\"",
"{",
"v",
".",
"Add",
"(",
"\"",
"\"",
",",
"continuationToken",
")",
"\n",
"}",
"\n",
"if",
"limit",
"!=",
"\"",
"\"",
"{",
"v",
".",
"Add",
"(",
"\"",
"\"",
",",
"limit",
")",
"\n",
"}",
"\n",
"if",
"quarantined",
"!=",
"\"",
"\"",
"{",
"v",
".",
"Add",
"(",
"\"",
"\"",
",",
"quarantined",
")",
"\n",
"}",
"\n",
"cd",
":=",
"tcclient",
".",
"Client",
"(",
"*",
"queue",
")",
"\n",
"responseObject",
",",
"_",
",",
"err",
":=",
"(",
"&",
"<mask>",
")",
".",
"APICall",
"(",
"nil",
",",
"\"",
"\"",
",",
"\"",
"\"",
"+",
"url",
".",
"QueryEscape",
"(",
"provisionerId",
")",
"+",
"\"",
"\"",
"+",
"url",
".",
"QueryEscape",
"(",
"workerType",
")",
"+",
"\"",
"\"",
",",
"new",
"(",
"ListWorkersResponse",
")",
",",
"v",
")",
"\n",
"return",
"responseObject",
".",
"(",
"*",
"ListWorkersResponse",
")",
",",
"err",
"\n",
"}"
] |
4,710 | all-4711 | [
"draw",
"a",
"bitmap"
] | [
"func",
"Bitmap",
"(",
"<mask>",
"int32",
",",
"height",
"int32",
",",
"xorig",
"float32",
",",
"yorig",
"float32",
",",
"xmove",
"float32",
",",
"ymove",
"float32",
",",
"bitmap",
"*",
"uint8",
")",
"{",
"C",
".",
"glowBitmap",
"(",
"gpBitmap",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"width",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"height",
")",
",",
"(",
"C",
".",
"GLfloat",
")",
"(",
"xorig",
")",
",",
"(",
"C",
".",
"GLfloat",
")",
"(",
"yorig",
")",
",",
"(",
"C",
".",
"GLfloat",
")",
"(",
"xmove",
")",
",",
"(",
"C",
".",
"GLfloat",
")",
"(",
"ymove",
")",
",",
"(",
"*",
"C",
".",
"GLubyte",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"bitmap",
")",
")",
")",
"\n",
"}"
] |
4,711 | all-4712 | [
"ensureManifestIsLoaded",
"sets",
"s",
".",
"cachedManifest",
"and",
"s",
".",
"cachedManifestMIMEType",
"ImageSource",
"implementations",
"are",
"not",
"required",
"or",
"expected",
"to",
"do",
"any",
"caching",
"but",
"because",
"our",
"signatures",
"are",
"“attached”",
"to",
"the",
"manifest",
"digest",
"we",
"need",
"to",
"ensure",
"that",
"the",
"digest",
"of",
"the",
"manifest",
"returned",
"by",
"GetManifest",
"(",
"ctx",
"nil",
")",
"and",
"used",
"by",
"GetSignatures",
"(",
"ctx",
"nil",
")",
"are",
"consistent",
"otherwise",
"we",
"would",
"get",
"spurious",
"signature",
"verification",
"failures",
"when",
"pulling",
"while",
"a",
"tag",
"is",
"being",
"updated",
"."
] | [
"func",
"(",
"s",
"*",
"dockerImageSource",
")",
"ensureManifestIsLoaded",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"s",
".",
"cachedManifest",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"<mask>",
",",
"err",
":=",
"s",
".",
"ref",
".",
"tagOrDigest",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"manblob",
",",
"mt",
",",
"err",
":=",
"s",
".",
"fetchManifest",
"(",
"ctx",
",",
"reference",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"// We might validate manblob against the Docker-Content-Digest header here to protect against transport errors.",
"s",
".",
"cachedManifest",
"=",
"manblob",
"\n",
"s",
".",
"cachedManifestMIMEType",
"=",
"mt",
"\n",
"return",
"nil",
"\n",
"}"
] |
4,712 | all-4713 | [
"RemoveFront",
"returns",
"the",
"entry",
"logically",
"stored",
"at",
"the",
"front",
"of",
"this",
"list",
"and",
"removes",
"it",
"."
] | [
"func",
"(",
"list",
"*",
"LinkedList",
")",
"RemoveFront",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"bool",
")",
"{",
"list",
".",
"key",
".",
"Lock",
"(",
")",
"\n",
"defer",
"list",
".",
"key",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"list",
".",
"first",
"==",
"nil",
"{",
"return",
"nil",
",",
"false",
"\n",
"}",
"\n\n",
"retval",
":=",
"list",
".",
"first",
".",
"payload",
"\n\n",
"list",
".",
"first",
"=",
"list",
".",
"first",
".",
"next",
"\n",
"list",
".",
"length",
"--",
"\n\n",
"if",
"0",
"==",
"<mask>",
".",
"length",
"{",
"list",
".",
"last",
"=",
"nil",
"\n",
"}",
"\n\n",
"return",
"retval",
",",
"true",
"\n",
"}"
] |
4,713 | all-4714 | [
"OpenCommits",
"returns",
"a",
"collection",
"of",
"open",
"commits"
] | [
"func",
"OpenCommits",
"(",
"etcdClient",
"*",
"etcd",
".",
"Client",
",",
"etcdPrefix",
"string",
")",
"col",
".",
"Collection",
"{",
"return",
"<mask>",
".",
"NewCollection",
"(",
"etcdClient",
",",
"path",
".",
"Join",
"(",
"etcdPrefix",
",",
"openCommitsPrefix",
")",
",",
"nil",
",",
"&",
"pfs",
".",
"Commit",
"{",
"}",
",",
"nil",
",",
"nil",
",",
")",
"\n",
"}"
] |
4,714 | all-4715 | [
"GetCombinedStatus",
"returns",
"the",
"latest",
"statuses",
"for",
"a",
"given",
"ref",
".",
"See",
"https",
":",
"//",
"developer",
".",
"github",
".",
"com",
"/",
"v3",
"/",
"repos",
"/",
"statuses",
"/",
"#get",
"-",
"the",
"-",
"combined",
"-",
"status",
"-",
"for",
"-",
"a",
"-",
"specific",
"-",
"ref"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetCombinedStatus",
"(",
"org",
",",
"repo",
",",
"ref",
"string",
")",
"(",
"*",
"CombinedStatus",
",",
"error",
")",
"{",
"c",
".",
"log",
"(",
"\"",
"\"",
",",
"org",
",",
"repo",
",",
"ref",
")",
"\n",
"var",
"combinedStatus",
"CombinedStatus",
"\n",
"err",
":=",
"c",
".",
"readPaginatedResults",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"org",
",",
"repo",
",",
"ref",
")",
",",
"\"",
"\"",
",",
"func",
"(",
")",
"interface",
"{",
"}",
"{",
"return",
"&",
"CombinedStatus",
"{",
"}",
"\n",
"}",
",",
"func",
"(",
"obj",
"interface",
"{",
"}",
")",
"{",
"cs",
":=",
"*",
"(",
"obj",
".",
"(",
"*",
"CombinedStatus",
")",
")",
"\n",
"cs",
".",
"Statuses",
"=",
"append",
"(",
"combinedStatus",
".",
"Statuses",
",",
"<mask>",
".",
"Statuses",
"...",
")",
"\n",
"combinedStatus",
"=",
"cs",
"\n",
"}",
",",
")",
"\n",
"return",
"&",
"combinedStatus",
",",
"err",
"\n",
"}"
] |
4,715 | all-4716 | [
"buildLayerInfosForCopy",
"builds",
"a",
"LayerInfosForCopy",
"return",
"value",
"based",
"on",
"manifestInfos",
"from",
"the",
"original",
"manifest",
"but",
"using",
"layer",
"data",
"which",
"we",
"can",
"actually",
"produce",
"—",
"physicalInfos",
"for",
"non",
"-",
"empty",
"layers",
"and",
"image",
".",
"GzippedEmptyLayer",
"for",
"empty",
"ones",
".",
"(",
"This",
"is",
"split",
"basically",
"only",
"to",
"allow",
"easily",
"unit",
"-",
"testing",
"the",
"part",
"that",
"has",
"no",
"dependencies",
"on",
"the",
"external",
"environment",
".",
")"
] | [
"func",
"buildLayerInfosForCopy",
"(",
"manifestInfos",
"[",
"]",
"manifest",
".",
"LayerInfo",
",",
"physicalInfos",
"[",
"]",
"types",
".",
"BlobInfo",
")",
"(",
"[",
"]",
"types",
".",
"BlobInfo",
",",
"error",
")",
"{",
"nextPhysical",
":=",
"0",
"\n",
"res",
":=",
"make",
"(",
"[",
"]",
"types",
".",
"BlobInfo",
",",
"len",
"(",
"manifestInfos",
")",
")",
"\n",
"for",
"i",
",",
"mi",
":=",
"range",
"manifestInfos",
"{",
"if",
"mi",
".",
"EmptyLayer",
"{",
"res",
"[",
"i",
"]",
"=",
"types",
".",
"BlobInfo",
"{",
"Digest",
":",
"image",
".",
"GzippedEmptyLayerDigest",
",",
"Size",
":",
"int64",
"(",
"len",
"(",
"image",
".",
"GzippedEmptyLayer",
")",
")",
",",
"MediaType",
":",
"<mask>",
".",
"MediaType",
",",
"}",
"\n",
"}",
"else",
"{",
"if",
"nextPhysical",
">=",
"len",
"(",
"physicalInfos",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"physicalInfos",
")",
")",
"\n",
"}",
"\n",
"res",
"[",
"i",
"]",
"=",
"physicalInfos",
"[",
"nextPhysical",
"]",
"\n",
"nextPhysical",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"nextPhysical",
"!=",
"len",
"(",
"physicalInfos",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"nextPhysical",
",",
"len",
"(",
"physicalInfos",
")",
")",
"\n",
"}",
"\n",
"return",
"res",
",",
"nil",
"\n",
"}"
] |
4,716 | all-4717 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"GetVersionReturns",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"<mask>",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoBrowser9",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
4,717 | all-4718 | [
"ValidEnum",
"validates",
"a",
"proposed",
"value",
"for",
"this",
"enum",
".",
"Implements",
"the",
"Enum",
"interface",
"for",
"ThresholdIndexes"
] | [
"func",
"(",
"e",
"ThresholdIndexes",
")",
"ValidEnum",
"(",
"v",
"int32",
")",
"bool",
"{",
"_",
",",
"<mask>",
":=",
"thresholdIndexesMap",
"[",
"v",
"]",
"\n",
"return",
"ok",
"\n",
"}"
] |
4,718 | all-4719 | [
"GetContainerFile",
"retrieves",
"the",
"provided",
"path",
"from",
"the",
"container"
] | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"GetContainerFile",
"(",
"containerName",
"string",
",",
"path",
"string",
")",
"(",
"io",
".",
"ReadCloser",
",",
"*",
"ContainerFileResponse",
",",
"error",
")",
"{",
"// Prepare the HTTP request",
"requestURL",
",",
"err",
":=",
"shared",
".",
"URLEncode",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r",
".",
"httpHost",
",",
"url",
".",
"QueryEscape",
"(",
"containerName",
")",
")",
",",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"path",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"requestURL",
",",
"err",
"=",
"r",
".",
"setQueryAttributes",
"(",
"requestURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"requestURL",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Set the user agent",
"if",
"r",
".",
"httpUserAgent",
"!=",
"\"",
"\"",
"{",
"req",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"r",
".",
"httpUserAgent",
")",
"\n",
"}",
"\n\n",
"// Send the request",
"resp",
",",
"err",
":=",
"r",
".",
"do",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Check the return value for a cleaner error",
"if",
"resp",
".",
"StatusCode",
"!=",
"http",
".",
"StatusOK",
"{",
"_",
",",
"_",
",",
"err",
":=",
"lxdParseResponse",
"(",
"resp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Parse the headers",
"uid",
",",
"gid",
",",
"mode",
",",
"fileType",
",",
"_",
":=",
"shared",
".",
"ParseLXDFileHeaders",
"(",
"resp",
".",
"Header",
")",
"\n",
"fileResp",
":=",
"ContainerFileResponse",
"{",
"UID",
":",
"uid",
",",
"GID",
":",
"gid",
",",
"Mode",
":",
"mode",
",",
"<mask>",
":",
"fileType",
",",
"}",
"\n\n",
"if",
"fileResp",
".",
"Type",
"==",
"\"",
"\"",
"{",
"// Decode the response",
"response",
":=",
"api",
".",
"Response",
"{",
"}",
"\n",
"decoder",
":=",
"json",
".",
"NewDecoder",
"(",
"resp",
".",
"Body",
")",
"\n\n",
"err",
"=",
"decoder",
".",
"Decode",
"(",
"&",
"response",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Get the file list",
"entries",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"err",
"=",
"response",
".",
"MetadataAsStruct",
"(",
"&",
"entries",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"fileResp",
".",
"Entries",
"=",
"entries",
"\n\n",
"return",
"nil",
",",
"&",
"fileResp",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"resp",
".",
"Body",
",",
"&",
"fileResp",
",",
"err",
"\n",
"}"
] |
4,719 | all-4720 | [
"/",
"*",
"Peer",
"exchange",
"GetSelection",
"randomly",
"selects",
"some",
"addresses",
"(",
"old",
"&",
"new",
")",
".",
"Suitable",
"for",
"peer",
"-",
"exchange",
"protocols",
"."
] | [
"func",
"(",
"a",
"*",
"AddrBook",
")",
"GetSelection",
"(",
")",
"[",
"]",
"*",
"NetAddress",
"{",
"a",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"a",
".",
"size",
"(",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"allAddr",
":=",
"make",
"(",
"[",
"]",
"*",
"NetAddress",
",",
"a",
".",
"<mask>",
"(",
")",
")",
"\n",
"i",
":=",
"0",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"a",
".",
"addrLookup",
"{",
"allAddr",
"[",
"i",
"]",
"=",
"v",
".",
"Addr",
"\n",
"i",
"++",
"\n",
"}",
"\n\n",
"numAddresses",
":=",
"MaxInt",
"(",
"MinInt",
"(",
"minGetSelection",
",",
"len",
"(",
"allAddr",
")",
")",
",",
"len",
"(",
"allAddr",
")",
"*",
"getSelectionPercent",
"/",
"100",
")",
"\n",
"numAddresses",
"=",
"MinInt",
"(",
"maxGetSelection",
",",
"numAddresses",
")",
"\n\n",
"// Fisher-Yates shuffle the array. We only need to do the first",
"// `numAddresses' since we are throwing the rest.",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"numAddresses",
";",
"i",
"++",
"{",
"// pick a number between current index and the end",
"j",
":=",
"rand",
".",
"Intn",
"(",
"len",
"(",
"allAddr",
")",
"-",
"i",
")",
"+",
"i",
"\n",
"allAddr",
"[",
"i",
"]",
",",
"allAddr",
"[",
"j",
"]",
"=",
"allAddr",
"[",
"j",
"]",
",",
"allAddr",
"[",
"i",
"]",
"\n",
"}",
"\n\n",
"// slice off the limit we are willing to share.",
"return",
"allAddr",
"[",
":",
"numAddresses",
"]",
"\n",
"}"
] |
4,720 | all-4721 | [
"CanAuthenticate",
"makes",
"a",
"test",
"request",
"to",
"CM",
"1",
".",
"5",
"and",
"returns",
"nil",
"if",
"it",
"is",
"successful",
"."
] | [
"func",
"(",
"t",
"*",
"tokenAuthenticator",
")",
"CanAuthenticate",
"(",
"<mask>",
"string",
")",
"error",
"{",
"client",
":=",
"httpclient",
".",
"New",
"(",
")",
"\n",
"return",
"testAuth",
"(",
"t",
",",
"client",
",",
"host",
",",
"false",
")",
"\n",
"}"
] |
4,721 | all-4722 | [
"FromPath",
"takes",
"a",
"relative",
"folder",
"path",
"an",
"object",
"type",
"and",
"an",
"optional",
"supplied",
"datacenter",
"and",
"returns",
"the",
"respective",
"*",
"object",
".",
"Folder",
"if",
"it",
"exists",
".",
"The",
"datacenter",
"supplied",
"in",
"dc",
"cannot",
"be",
"nil",
"if",
"the",
"folder",
"type",
"supplied",
"by",
"ft",
"is",
"something",
"else",
"other",
"than",
"VSphereFolderTypeDatacenter",
"."
] | [
"func",
"FromPath",
"(",
"c",
"*",
"govmomi",
".",
"Client",
",",
"p",
"string",
",",
"ft",
"VSphereFolderType",
",",
"dc",
"*",
"object",
".",
"Datacenter",
")",
"(",
"*",
"object",
".",
"Folder",
",",
"error",
")",
"{",
"var",
"fp",
"string",
"\n",
"if",
"ft",
"==",
"VSphereFolderTypeDatacenter",
"{",
"fp",
"=",
"\"",
"\"",
"+",
"p",
"\n",
"}",
"else",
"{",
"<mask>",
":=",
"RootPathParticle",
"(",
"ft",
")",
"\n",
"fp",
"=",
"pt",
".",
"PathFromDatacenter",
"(",
"dc",
",",
"p",
")",
"\n",
"}",
"\n",
"return",
"FromAbsolutePath",
"(",
"c",
",",
"fp",
")",
"\n",
"}"
] |
4,722 | all-4723 | [
"PeerNameFromString",
"parses",
"PeerName",
"from",
"a",
"generic",
"string",
"."
] | [
"func",
"PeerNameFromString",
"(",
"nameStr",
"string",
")",
"(",
"PeerName",
",",
"error",
")",
"{",
"if",
"_",
",",
"err",
":=",
"<mask>",
".",
"DecodeString",
"(",
"nameStr",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"UnknownPeerName",
",",
"err",
"\n",
"}",
"\n",
"return",
"PeerName",
"(",
"nameStr",
")",
",",
"nil",
"\n",
"}"
] |
4,723 | all-4724 | [
"verifyTasksMetadata",
"verifies",
"the",
"number",
"of",
"tasks",
"in",
"tasks",
"metadata",
"."
] | [
"func",
"verifyTasksMetadata",
"(",
"tasksMetadataRawMsg",
"json",
".",
"RawMessage",
")",
"error",
"{",
"<mask>",
"tasksMetadataMap",
"map",
"[",
"string",
"]",
"json",
".",
"RawMessage",
"\n",
"json",
".",
"Unmarshal",
"(",
"tasksMetadataRawMsg",
",",
"&",
"tasksMetadataMap",
")",
"\n\n",
"if",
"tasksMetadataMap",
"[",
"\"",
"\"",
"]",
"==",
"nil",
"{",
"return",
"notEmptyErrMsg",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"tasksMetadataArray",
"[",
"]",
"json",
".",
"RawMessage",
"\n",
"json",
".",
"Unmarshal",
"(",
"tasksMetadataMap",
"[",
"\"",
"\"",
"]",
",",
"&",
"tasksMetadataArray",
")",
"\n\n",
"if",
"len",
"(",
"tasksMetadataArray",
")",
"!=",
"1",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"tasksMetadataArray",
")",
")",
"\n",
"}",
"\n\n",
"return",
"verifyTaskMetadata",
"(",
"tasksMetadataArray",
"[",
"0",
"]",
")",
"\n",
"}"
] |
4,724 | all-4725 | [
"nolint",
":",
"deadcode",
"used",
"from",
"unit",
"test"
] | [
"func",
"instanceToInstanceSummary",
"(",
"<mask>",
"*",
"sd",
".",
"Instance",
")",
"*",
"sd",
".",
"InstanceSummary",
"{",
"if",
"instance",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"&",
"sd",
".",
"InstanceSummary",
"{",
"Id",
":",
"instance",
".",
"Id",
",",
"Attributes",
":",
"instance",
".",
"Attributes",
",",
"}",
"\n",
"}"
] |
4,725 | all-4726 | [
"Stability",
":",
"***",
"EXPERIMENTAL",
"***",
"Return",
"a",
"list",
"of",
"recent",
"errors",
"encountered",
"See",
"https",
":",
"//",
"docs",
".",
"taskcluster",
".",
"net",
"/",
"reference",
"/",
"core",
"/",
"ec2",
"-",
"manager",
"/",
"api",
"-",
"docs#getRecentErrors"
] | [
"func",
"(",
"eC2Manager",
"*",
"EC2Manager",
")",
"GetRecentErrors",
"(",
")",
"(",
"*",
"Errors",
",",
"error",
")",
"{",
"<mask>",
":=",
"tcclient",
".",
"Client",
"(",
"*",
"eC2Manager",
")",
"\n",
"responseObject",
",",
"_",
",",
"err",
":=",
"(",
"&",
"cd",
")",
".",
"APICall",
"(",
"nil",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"new",
"(",
"Errors",
")",
",",
"nil",
")",
"\n",
"return",
"responseObject",
".",
"(",
"*",
"Errors",
")",
",",
"err",
"\n",
"}"
] |
4,726 | all-4727 | [
"Do",
"executes",
"Page",
".",
"waitForDebugger",
"against",
"the",
"provided",
"context",
"."
] | [
"func",
"(",
"p",
"*",
"WaitForDebuggerParams",
")",
"Do",
"(",
"ctx",
"<mask>",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"return",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandWaitForDebugger",
",",
"nil",
",",
"nil",
")",
"\n",
"}"
] |
4,727 | all-4728 | [
"Recover",
"converts",
"a",
"seedphrase",
"to",
"a",
"private",
"key",
"and",
"persists",
"it",
"encrypted",
"with",
"the",
"given",
"passphrase",
".",
"Functions",
"like",
"Create",
"but",
"seedphrase",
"is",
"input",
"not",
"output",
"."
] | [
"func",
"(",
"kb",
"dbKeybase",
")",
"Recover",
"(",
"name",
",",
"passphrase",
",",
"seedphrase",
"string",
")",
"(",
"Info",
",",
"error",
")",
"{",
"words",
":=",
"strings",
".",
"Split",
"(",
"strings",
".",
"TrimSpace",
"(",
"seedphrase",
")",
",",
"\"",
"\"",
")",
"\n",
"secret",
",",
"err",
":=",
"kb",
".",
"codec",
".",
"WordsToBytes",
"(",
"words",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// secret is comprised of the actual secret with the type",
"// appended.",
"// ie [secret] = [type] + [secret]",
"typ",
",",
"secret",
":=",
"secret",
"[",
"0",
"]",
",",
"secret",
"[",
"1",
":",
"]",
"\n",
"algo",
":=",
"byteToSignAlgo",
"(",
"typ",
")",
"\n",
"priv",
",",
"err",
":=",
"generate",
"(",
"algo",
",",
"secret",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// encrypt and persist key.",
"public",
":=",
"kb",
".",
"writeLocalKey",
"(",
"priv",
",",
"name",
",",
"passphrase",
")",
"\n",
"return",
"<mask>",
",",
"nil",
"\n",
"}"
] |
4,728 | all-4729 | [
"title",
":",
"webhook",
"info",
"path",
":",
"/",
"events",
"/",
"webhooks",
"/",
"{",
"name",
"}",
"method",
":",
"GET",
"produce",
":",
"application",
"/",
"json",
"responses",
":",
"200",
":",
"Get",
"webhook",
"404",
":",
"Not",
"found",
"401",
":",
"Unauthorized"
] | [
"func",
"webhookInfo",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"t",
"auth",
".",
"<mask>",
")",
"error",
"{",
"webhookName",
":=",
"r",
".",
"URL",
".",
"Query",
"(",
")",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"webhook",
",",
"err",
":=",
"servicemanager",
".",
"Webhook",
".",
"Find",
"(",
"webhookName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"eventTypes",
".",
"ErrWebhookNotFound",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusNotFound",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"ctx",
":=",
"permission",
".",
"Context",
"(",
"permTypes",
".",
"CtxTeam",
",",
"webhook",
".",
"TeamOwner",
")",
"\n",
"if",
"!",
"permission",
".",
"Check",
"(",
"t",
",",
"permission",
".",
"PermWebhookRead",
",",
"ctx",
")",
"{",
"return",
"permission",
".",
"ErrUnauthorized",
"\n",
"}",
"\n",
"w",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"json",
".",
"NewEncoder",
"(",
"w",
")",
".",
"Encode",
"(",
"webhook",
")",
"\n",
"}"
] |
4,729 | all-4730 | [
"ListenAndServe",
"serves",
"HTTP",
"requests",
"from",
"the",
"given",
"TCP4",
"addr",
".",
"Pass",
"custom",
"listener",
"to",
"Serve",
"if",
"you",
"need",
"listening",
"on",
"non",
"-",
"TCP4",
"media",
"such",
"as",
"IPv6",
".",
"Accepted",
"connections",
"are",
"configured",
"to",
"enable",
"TCP",
"keep",
"-",
"alives",
"."
] | [
"func",
"(",
"s",
"*",
"Server",
")",
"ListenAndServe",
"(",
"addr",
"string",
")",
"error",
"{",
"ln",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"s",
".",
"TCPKeepalive",
"{",
"if",
"tcpln",
",",
"ok",
":=",
"ln",
".",
"(",
"*",
"net",
".",
"TCPListener",
")",
";",
"<mask>",
"{",
"return",
"s",
".",
"Serve",
"(",
"tcpKeepaliveListener",
"{",
"TCPListener",
":",
"tcpln",
",",
"keepalivePeriod",
":",
"s",
".",
"TCPKeepalivePeriod",
",",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"s",
".",
"Serve",
"(",
"ln",
")",
"\n",
"}"
] |
4,730 | all-4731 | [
"CommitWith",
"acts",
"like",
"Commit",
"but",
"takes",
"a",
"callback",
"which",
"gets",
"run",
"via",
"a",
"goroutine",
"to",
"avoid",
"blocking",
"this",
"function",
".",
"The",
"callback",
"is",
"guaranteed",
"to",
"run",
"so",
"it",
"is",
"safe",
"to",
"increment",
"sync",
".",
"WaitGroup",
"before",
"calling",
"CommitWith",
"and",
"decrementing",
"it",
"in",
"the",
"callback",
";",
"to",
"block",
"until",
"all",
"callbacks",
"are",
"run",
"."
] | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"CommitWith",
"(",
"cb",
"func",
"(",
"error",
")",
")",
"{",
"txn",
".",
"commitPrecheck",
"(",
")",
"// Precheck before discarding txn.",
"\n",
"defer",
"txn",
".",
"Discard",
"(",
")",
"\n\n",
"if",
"cb",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"txn",
".",
"writes",
")",
"==",
"0",
"{",
"// Do not run these callbacks from here, because the CommitWith and the",
"// callback might be acquiring the same locks. Instead run the callback",
"// from another goroutine.",
"go",
"runTxnCallback",
"(",
"&",
"txnCb",
"{",
"user",
":",
"cb",
",",
"err",
":",
"nil",
"}",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"commitCb",
",",
"err",
":=",
"txn",
".",
"commitAndSend",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"go",
"runTxnCallback",
"(",
"&",
"txnCb",
"{",
"user",
":",
"cb",
",",
"err",
":",
"err",
"}",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"go",
"runTxnCallback",
"(",
"&",
"txnCb",
"{",
"<mask>",
":",
"cb",
",",
"commit",
":",
"commitCb",
"}",
")",
"\n",
"}"
] |
4,731 | all-4732 | [
"WriteIndented",
"indents",
"all",
"lines",
"four",
"spaces",
"."
] | [
"func",
"WriteIndented",
"(",
"w",
"io",
".",
"<mask>",
",",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"WriteIndentedN",
"(",
"w",
",",
"b",
",",
"4",
")",
"\n",
"}"
] |
4,732 | all-4733 | [
"GetTooltipText",
"is",
"a",
"wrapper",
"around",
"gtk_status_icon_get_tooltip_text",
"()"
] | [
"func",
"(",
"v",
"*",
"StatusIcon",
")",
"GetTooltipText",
"(",
")",
"string",
"{",
"c",
":=",
"C",
".",
"gtk_status_icon_get_tooltip_text",
"(",
"v",
".",
"native",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"<mask>",
")",
"(",
"c",
")",
")",
"\n",
"}"
] |
4,733 | all-4734 | [
"<tagged",
"-",
"name",
">",
"::",
"=",
"<name",
">",
"B",
"<source",
"-",
"name",
">"
] | [
"func",
"(",
"st",
"*",
"state",
")",
"taggedName",
"(",
"a",
"AST",
")",
"AST",
"{",
"for",
"len",
"(",
"st",
".",
"str",
")",
">",
"0",
"&&",
"st",
".",
"str",
"[",
"0",
"]",
"==",
"'B'",
"{",
"st",
".",
"advance",
"(",
"1",
")",
"\n",
"<mask>",
":=",
"st",
".",
"sourceName",
"(",
")",
"\n",
"a",
"=",
"&",
"TaggedName",
"{",
"Name",
":",
"a",
",",
"Tag",
":",
"tag",
"}",
"\n",
"}",
"\n",
"return",
"a",
"\n",
"}"
] |
4,734 | all-4735 | [
"MergePattern",
"add",
"entry",
"patterns",
"with",
"given",
"pattern",
"strings",
".",
"If",
"a",
"pattern",
"already",
"exists",
"on",
"the",
"entry",
"it",
"adds",
"remaining",
"patterns",
"to",
"the",
"existing",
"entry",
"."
] | [
"func",
"(",
"e",
"*",
"Entry",
")",
"MergePatterns",
"(",
"patterns",
"[",
"]",
"string",
")",
"*",
"Entry",
"{",
"pat",
",",
"<mask>",
":=",
"PeekNextPattern",
"(",
"patterns",
")",
"\n",
"if",
"child",
":=",
"e",
".",
"getChildEntry",
"(",
"pat",
")",
";",
"child",
"!=",
"nil",
"{",
"if",
"len",
"(",
"patterns",
")",
"==",
"size",
"{",
"return",
"child",
"\n",
"}",
"\n",
"return",
"child",
".",
"MergePatterns",
"(",
"patterns",
"[",
"size",
":",
"]",
")",
"\n",
"}",
"\n",
"return",
"e",
".",
"addPatterns",
"(",
"patterns",
")",
"\n",
"}"
] |
4,735 | all-4736 | [
"Execute",
"-",
"updates",
"space",
"configuration"
] | [
"func",
"(",
"c",
"*",
"UpdateSpaceConfigurationCommand",
")",
"Execute",
"(",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"c",
".",
"initConfig",
"(",
")",
"\n",
"spaceConfig",
",",
"err",
":=",
"c",
".",
"ConfigManager",
".",
"GetSpaceConfig",
"(",
"c",
".",
"OrgName",
",",
"c",
".",
"SpaceName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"asgConfigs",
",",
"err",
":=",
"c",
".",
"ConfigManager",
".",
"GetASGConfigs",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"Quota",
".",
"EnableSpaceQuota",
"==",
"\"",
"\"",
"&&",
"c",
".",
"NamedQuota",
"!=",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"errorString",
":=",
"\"",
"\"",
"\n\n",
"convertToBool",
"(",
"\"",
"\"",
",",
"&",
"spaceConfig",
".",
"RemoveUsers",
",",
"c",
".",
"EnableRemoveUsers",
",",
"&",
"errorString",
")",
"\n",
"convertToBool",
"(",
"\"",
"\"",
",",
"&",
"spaceConfig",
".",
"EnableSecurityGroup",
",",
"c",
".",
"EnableSecurityGroup",
",",
"&",
"errorString",
")",
"\n",
"convertToBool",
"(",
"\"",
"\"",
",",
"&",
"spaceConfig",
".",
"EnableUnassignSecurityGroup",
",",
"c",
".",
"EnableUnassignSecurityGroup",
",",
"&",
"errorString",
")",
"\n",
"if",
"c",
".",
"IsoSegment",
"!=",
"\"",
"\"",
"{",
"spaceConfig",
".",
"IsoSegment",
"=",
"c",
".",
"IsoSegment",
"\n",
"}",
"\n",
"if",
"c",
".",
"ClearIsolationSegment",
"{",
"spaceConfig",
".",
"IsoSegment",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"spaceConfig",
".",
"ASGs",
"=",
"removeFromSlice",
"(",
"addToSlice",
"(",
"spaceConfig",
".",
"ASGs",
",",
"c",
".",
"ASGs",
",",
"&",
"errorString",
")",
",",
"c",
".",
"ASGsToRemove",
")",
"\n",
"validateASGsExist",
"(",
"asgConfigs",
",",
"spaceConfig",
".",
"ASGs",
",",
"&",
"errorString",
")",
"\n",
"updateSpaceQuotaConfig",
"(",
"spaceConfig",
",",
"c",
".",
"Quota",
",",
"&",
"errorString",
")",
"\n\n",
"if",
"c",
".",
"NamedQuota",
"!=",
"\"",
"\"",
"{",
"spaceConfig",
".",
"NamedQuota",
"=",
"c",
".",
"NamedQuota",
"\n",
"}",
"\n",
"if",
"c",
".",
"ClearNamedQuota",
"{",
"spaceConfig",
".",
"NamedQuota",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"c",
".",
"updateUsers",
"(",
"spaceConfig",
",",
"&",
"errorString",
")",
"\n",
"c",
".",
"sshConfig",
"(",
"spaceConfig",
",",
"&",
"errorString",
")",
"\n\n",
"if",
"errorString",
"!=",
"\"",
"\"",
"{",
"return",
"<mask>",
".",
"New",
"(",
"errorString",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"c",
".",
"ConfigManager",
".",
"SaveSpaceConfig",
"(",
"spaceConfig",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"fmt",
".",
"Println",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"OrgName",
",",
"c",
".",
"SpaceName",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
4,736 | all-4737 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"Location",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger30",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
4,737 | all-4738 | [
"String",
"returns",
"a",
"human",
"readable",
"string",
"representation",
"of",
"this",
"object"
] | [
"func",
"(",
"c",
"*",
"ContainerStateChange",
")",
"String",
"(",
")",
"string",
"{",
"res",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"TaskArn",
",",
"c",
".",
"ContainerName",
",",
"c",
".",
"Status",
".",
"String",
"(",
")",
")",
"\n",
"if",
"c",
".",
"ExitCode",
"!=",
"nil",
"{",
"<mask>",
"+=",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa",
"(",
"*",
"c",
".",
"ExitCode",
")",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"c",
".",
"Reason",
"!=",
"\"",
"\"",
"{",
"res",
"+=",
"\"",
"\"",
"+",
"c",
".",
"Reason",
"\n",
"}",
"\n",
"if",
"len",
"(",
"c",
".",
"PortBindings",
")",
"!=",
"0",
"{",
"res",
"+=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"PortBindings",
")",
"\n",
"}",
"\n",
"if",
"c",
".",
"Container",
"!=",
"nil",
"{",
"res",
"+=",
"\"",
"\"",
"+",
"c",
".",
"Container",
".",
"GetSentStatus",
"(",
")",
".",
"String",
"(",
")",
"\n",
"}",
"\n",
"return",
"res",
"\n",
"}"
] |
4,738 | all-4739 | [
"TryReusingBlob",
"checks",
"whether",
"the",
"transport",
"already",
"contains",
"or",
"can",
"efficiently",
"reuse",
"a",
"blob",
"and",
"if",
"so",
"applies",
"it",
"to",
"the",
"current",
"destination",
"(",
"e",
".",
"g",
".",
"if",
"the",
"blob",
"is",
"a",
"filesystem",
"layer",
"this",
"signifies",
"that",
"the",
"changes",
"it",
"describes",
"need",
"to",
"be",
"applied",
"again",
"when",
"composing",
"a",
"filesystem",
"tree",
")",
".",
"info",
".",
"Digest",
"must",
"not",
"be",
"empty",
".",
"If",
"canSubstitute",
"TryReusingBlob",
"can",
"use",
"an",
"equivalent",
"equivalent",
"of",
"the",
"desired",
"blob",
";",
"in",
"that",
"case",
"the",
"returned",
"info",
"may",
"not",
"match",
"the",
"input",
".",
"If",
"the",
"blob",
"has",
"been",
"succesfully",
"reused",
"returns",
"(",
"true",
"info",
"nil",
")",
";",
"info",
"must",
"contain",
"at",
"least",
"a",
"digest",
"and",
"size",
".",
"If",
"the",
"transport",
"can",
"not",
"reuse",
"the",
"requested",
"blob",
"TryReusingBlob",
"returns",
"(",
"false",
"{}",
"nil",
")",
";",
"it",
"returns",
"a",
"non",
"-",
"nil",
"error",
"only",
"on",
"an",
"unexpected",
"failure",
".",
"May",
"use",
"and",
"/",
"or",
"update",
"cache",
"."
] | [
"func",
"(",
"d",
"*",
"ociArchiveImageDestination",
")",
"TryReusingBlob",
"(",
"ctx",
"context",
".",
"Context",
",",
"<mask>",
"types",
".",
"BlobInfo",
",",
"cache",
"types",
".",
"BlobInfoCache",
",",
"canSubstitute",
"bool",
")",
"(",
"bool",
",",
"types",
".",
"BlobInfo",
",",
"error",
")",
"{",
"return",
"d",
".",
"unpackedDest",
".",
"TryReusingBlob",
"(",
"ctx",
",",
"info",
",",
"cache",
",",
"canSubstitute",
")",
"\n",
"}"
] |
4,739 | all-4740 | [
"Iterator",
"returns",
"a",
"new",
"Iterator",
"to",
"iterate",
"through",
"values",
"in",
"the",
"set",
".",
"Each",
"call",
"to",
"this",
"method",
"creates",
"a",
"new",
"Iterator",
".",
"Therefore",
"the",
"returned",
"Iterator",
"should",
"be",
"assigned",
"to",
"a",
"variable",
"before",
"usage",
".",
"It",
"is",
"safe",
"to",
"create",
"and",
"use",
"multiple",
"Iterators",
"in",
"multiple",
"goroutines",
"."
] | [
"func",
"(",
"s",
"*",
"Set",
")",
"Iterator",
"(",
")",
"Iterator",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n",
"iterChan",
":=",
"make",
"(",
"chan",
"interface",
"{",
"}",
",",
"len",
"(",
"s",
".",
"m",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"s",
".",
"m",
"{",
"iterChan",
"<-",
"k",
"\n",
"}",
"\n",
"close",
"(",
"iterChan",
")",
"\n",
"return",
"IterFunc",
"(",
"func",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"bool",
")",
"{",
"value",
",",
"<mask>",
":=",
"<-",
"iterChan",
"\n",
"return",
"value",
",",
"ok",
"\n",
"}",
")",
"\n",
"}"
] |
4,740 | all-4741 | [
"CancelableWait",
"waits",
"for",
"an",
"operation",
"and",
"cancel",
"it",
"on",
"SIGINT",
"/",
"SIGTERM"
] | [
"func",
"CancelableWait",
"(",
"rawOp",
"interface",
"{",
"}",
",",
"progress",
"*",
"ProgressRenderer",
")",
"error",
"{",
"var",
"op",
"lxd",
".",
"Operation",
"\n",
"var",
"rop",
"lxd",
".",
"RemoteOperation",
"\n\n",
"// Check what type of operation we're dealing with",
"switch",
"v",
":=",
"rawOp",
".",
"(",
"type",
")",
"{",
"case",
"lxd",
".",
"Operation",
":",
"op",
"=",
"v",
"\n",
"case",
"lxd",
".",
"RemoteOperation",
":",
"rop",
"=",
"v",
"\n",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Signal handling",
"chSignal",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
")",
"\n",
"signal",
".",
"Notify",
"(",
"chSignal",
",",
"os",
".",
"Interrupt",
")",
"\n\n",
"// Operation handling",
"chOperation",
":=",
"make",
"(",
"chan",
"error",
")",
"\n",
"<mask>",
"func",
"(",
")",
"{",
"if",
"op",
"!=",
"nil",
"{",
"chOperation",
"<-",
"op",
".",
"Wait",
"(",
")",
"\n",
"}",
"else",
"{",
"chOperation",
"<-",
"rop",
".",
"Wait",
"(",
")",
"\n",
"}",
"\n",
"close",
"(",
"chOperation",
")",
"\n",
"}",
"(",
")",
"\n\n",
"count",
":=",
"0",
"\n",
"for",
"{",
"var",
"err",
"error",
"\n\n",
"select",
"{",
"case",
"err",
":=",
"<-",
"chOperation",
":",
"return",
"err",
"\n",
"case",
"<-",
"chSignal",
":",
"if",
"op",
"!=",
"nil",
"{",
"err",
"=",
"op",
".",
"Cancel",
"(",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"rop",
".",
"CancelTarget",
"(",
")",
"\n",
"}",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"i18n",
".",
"G",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n\n",
"count",
"++",
"\n\n",
"if",
"count",
"==",
"3",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"i18n",
".",
"G",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n\n",
"if",
"progress",
"!=",
"nil",
"{",
"progress",
".",
"Warn",
"(",
"fmt",
".",
"Sprintf",
"(",
"i18n",
".",
"G",
"(",
"\"",
"\"",
")",
",",
"err",
")",
",",
"time",
".",
"Second",
"*",
"5",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
4,741 | all-4742 | [
"NewBranch",
"creates",
"a",
"pfs",
".",
"Branch"
] | [
"func",
"NewBranch",
"(",
"repoName",
"string",
",",
"branchName",
"string",
")",
"*",
"pfs",
".",
"Branch",
"{",
"return",
"&",
"pfs",
".",
"Branch",
"{",
"Repo",
":",
"NewRepo",
"(",
"repoName",
")",
",",
"<mask>",
":",
"branchName",
",",
"}",
"\n",
"}"
] |
4,742 | all-4743 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"StopAllWorkersParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoServiceworker4",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
4,743 | all-4744 | [
"IconViewNewWithModel",
"is",
"a",
"wrapper",
"around",
"gtk_icon_view_new_with_model",
"()",
"."
] | [
"func",
"IconViewNewWithModel",
"(",
"<mask>",
"ITreeModel",
")",
"(",
"*",
"IconView",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gtk_icon_view_new_with_model",
"(",
"model",
".",
"toTreeModel",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n",
"obj",
":=",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
"\n",
"return",
"wrapIconView",
"(",
"obj",
")",
",",
"nil",
"\n",
"}"
] |
4,744 | all-4745 | [
"SuggestCodeChange",
"returns",
"code",
"suggestions",
"for",
"a",
"given",
"lint",
".",
"Problem",
"Returns",
"empty",
"string",
"if",
"no",
"suggestion",
"can",
"be",
"given"
] | [
"func",
"SuggestCodeChange",
"(",
"p",
"lint",
".",
"Problem",
")",
"string",
"{",
"var",
"suggestion",
"=",
"\"",
"\"",
"\n",
"for",
"regex",
",",
"handler",
":=",
"range",
"lintHandlersMap",
"{",
"matches",
":=",
"regex",
".",
"FindStringSubmatch",
"(",
"p",
".",
"Text",
")",
"\n",
"suggestion",
"=",
"<mask>",
"(",
"p",
",",
"matches",
")",
"\n",
"if",
"suggestion",
"!=",
"\"",
"\"",
"&&",
"suggestion",
"!=",
"p",
".",
"LineText",
"{",
"return",
"formatSuggestion",
"(",
"suggestion",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
4,745 | all-4746 | [
"DateFormat",
"is",
"used",
"to",
"format",
"the",
"timestamp",
"."
] | [
"func",
"DateFormat",
"(",
"f",
"string",
")",
"Option",
"{",
"return",
"Option",
"{",
"func",
"(",
"o",
"*",
"<mask>",
")",
"{",
"o",
".",
"dateFormat",
"=",
"f",
"\n",
"}",
"}",
"\n",
"}"
] |
4,746 | all-4747 | [
"Count",
"iterates",
"over",
"a",
"list",
"and",
"keeps",
"a",
"running",
"tally",
"of",
"the",
"number",
"of",
"elements",
"satisfy",
"a",
"predicate",
"."
] | [
"func",
"(",
"iter",
"Enumerator",
")",
"Count",
"(",
"p",
"Predicate",
")",
"int",
"{",
"tally",
":=",
"0",
"\n",
"for",
"entry",
":=",
"range",
"iter",
"{",
"if",
"p",
"(",
"<mask>",
")",
"{",
"tally",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"tally",
"\n",
"}"
] |
4,747 | all-4748 | [
"SetHashBytes",
"sets",
"URI",
"hash",
"."
] | [
"func",
"(",
"u",
"*",
"URI",
")",
"SetHashBytes",
"(",
"hash",
"[",
"]",
"byte",
")",
"{",
"u",
".",
"hash",
"=",
"append",
"(",
"u",
".",
"<mask>",
"[",
":",
"0",
"]",
",",
"hash",
"...",
")",
"\n",
"}"
] |
4,748 | all-4749 | [
"GetAll",
"returns",
"all",
"registered",
"error",
"descriptors"
] | [
"func",
"(",
"r",
"*",
"registry",
")",
"GetAll",
"(",
")",
"[",
"]",
"*",
"ErrDescriptor",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"defer",
"r",
".",
"RUnlock",
"(",
")",
"\n\n",
"res",
":=",
"make",
"(",
"[",
"]",
"*",
"ErrDescriptor",
",",
"0",
",",
"len",
"(",
"r",
".",
"byCode",
")",
")",
"\n",
"for",
"_",
",",
"d",
":=",
"range",
"r",
".",
"byCode",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"d",
")",
"\n",
"}",
"\n",
"return",
"<mask>",
"\n",
"}"
] |
4,749 | all-4750 | [
"OpCompact",
"wraps",
"slice",
"CompactOption",
"to",
"create",
"a",
"CompactOp",
"."
] | [
"func",
"OpCompact",
"(",
"rev",
"int64",
",",
"opts",
"...",
"CompactOption",
")",
"CompactOp",
"{",
"ret",
":=",
"CompactOp",
"{",
"revision",
":",
"rev",
"}",
"\n",
"<mask>",
".",
"applyCompactOpts",
"(",
"opts",
")",
"\n",
"return",
"ret",
"\n",
"}"
] |
4,750 | all-4751 | [
"DeleteComment",
"deletes",
"a",
"comment",
"."
] | [
"func",
"(",
"f",
"*",
"FakeClient",
")",
"DeleteComment",
"(",
"owner",
",",
"repo",
"string",
",",
"ID",
"int",
")",
"error",
"{",
"f",
".",
"IssueCommentsDeleted",
"=",
"append",
"(",
"f",
".",
"IssueCommentsDeleted",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"owner",
",",
"repo",
",",
"ID",
")",
")",
"\n",
"for",
"num",
",",
"ics",
":=",
"range",
"f",
".",
"IssueComments",
"{",
"for",
"i",
",",
"ic",
":=",
"range",
"ics",
"{",
"if",
"<mask>",
".",
"ID",
"==",
"ID",
"{",
"f",
".",
"IssueComments",
"[",
"num",
"]",
"=",
"append",
"(",
"ics",
"[",
":",
"i",
"]",
",",
"ics",
"[",
"i",
"+",
"1",
":",
"]",
"...",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ID",
")",
"\n",
"}"
] |
4,751 | all-4752 | [
"Using",
"the",
"classic",
"API",
"posts",
"a",
"count",
"to",
"a",
"stat",
"using",
"DefaultReporter",
"."
] | [
"func",
"PostCount",
"(",
"statKey",
",",
"userKey",
"string",
",",
"<mask>",
"int",
")",
"error",
"{",
"return",
"DefaultReporter",
".",
"PostCount",
"(",
"statKey",
",",
"userKey",
",",
"count",
")",
"\n",
"}"
] |
4,752 | all-4753 | [
"DecodeUnverifiedToken",
"decodes",
"a",
"token",
"into",
"the",
"provided",
"UnverifiedToken",
"."
] | [
"func",
"DecodeUnverifiedToken",
"(",
"buf",
"[",
"]",
"byte",
",",
"ut",
"*",
"UnverifiedToken",
")",
"error",
"{",
"b",
":=",
"bytes",
".",
"Split",
"(",
"buf",
",",
"tokenSep",
")",
"\n",
"if",
"len",
"(",
"b",
")",
"!=",
"3",
"{",
"return",
"ErrInvalidToken",
"\n",
"}",
"\n\n",
"ut",
".",
"<mask>",
"=",
"b",
"[",
"0",
"]",
"\n",
"ut",
".",
"Payload",
"=",
"b",
"[",
"1",
"]",
"\n",
"ut",
".",
"Signature",
"=",
"b",
"[",
"2",
"]",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
4,753 | all-4754 | [
"Initialize",
"the",
"gateway",
"creating",
"a",
"new",
"raft",
"factory",
"and",
"gRPC",
"server",
"(",
"if",
"this",
"node",
"is",
"a",
"database",
"node",
")",
"and",
"a",
"gRPC",
"dialer",
"."
] | [
"func",
"(",
"g",
"*",
"Gateway",
")",
"init",
"(",
")",
"error",
"{",
"logger",
".",
"Debugf",
"(",
"\"",
"\"",
")",
"\n",
"raft",
",",
"err",
":=",
"newRaft",
"(",
"g",
".",
"db",
",",
"g",
".",
"cert",
",",
"g",
".",
"options",
".",
"latency",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// If the resulting raft instance is not nil, it means that this node",
"// should serve as database node, so create a dqlite driver to be",
"// exposed it over gRPC.",
"if",
"raft",
"!=",
"nil",
"{",
"listener",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"raft",
".",
"HandlerFunc",
"(",
")",
"==",
"nil",
"{",
"g",
".",
"memoryDial",
"=",
"dqliteMemoryDial",
"(",
"listener",
")",
"\n",
"g",
".",
"store",
".",
"inMemory",
"=",
"dqlite",
".",
"NewInmemServerStore",
"(",
")",
"\n",
"g",
".",
"store",
".",
"Set",
"(",
"context",
".",
"Background",
"(",
")",
",",
"[",
"]",
"dqlite",
".",
"ServerInfo",
"{",
"{",
"Address",
":",
"\"",
"\"",
"}",
"}",
")",
"\n",
"}",
"else",
"{",
"go",
"runDqliteProxy",
"(",
"listener",
",",
"g",
".",
"acceptCh",
")",
"\n",
"g",
".",
"store",
".",
"inMemory",
"=",
"nil",
"\n",
"}",
"\n\n",
"provider",
":=",
"&",
"raftAddressProvider",
"{",
"<mask>",
":",
"g",
".",
"db",
"}",
"\n",
"server",
",",
"err",
":=",
"dqlite",
".",
"NewServer",
"(",
"raft",
".",
"Raft",
"(",
")",
",",
"raft",
".",
"Registry",
"(",
")",
",",
"listener",
",",
"dqlite",
".",
"WithServerAddressProvider",
"(",
"provider",
")",
",",
"dqlite",
".",
"WithServerLogFunc",
"(",
"DqliteLog",
")",
",",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"g",
".",
"server",
"=",
"server",
"\n",
"g",
".",
"raft",
"=",
"raft",
"\n",
"}",
"else",
"{",
"g",
".",
"server",
"=",
"nil",
"\n",
"g",
".",
"raft",
"=",
"nil",
"\n",
"g",
".",
"store",
".",
"inMemory",
"=",
"nil",
"\n",
"}",
"\n\n",
"g",
".",
"store",
".",
"onDisk",
"=",
"dqlite",
".",
"NewServerStore",
"(",
"g",
".",
"db",
".",
"DB",
"(",
")",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
4,754 | all-4755 | [
"Read",
"-",
"satisfies",
"reader",
"interface"
] | [
"func",
"(",
"r",
"*",
"MockReadWriteCloser",
")",
"Read",
"(",
"p",
"[",
"]",
"<mask>",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"r",
".",
"ReadErr",
";",
"err",
"==",
"nil",
"{",
"r",
".",
"BytesRead",
"=",
"p",
"\n",
"n",
"=",
"len",
"(",
"p",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
4,755 | all-4756 | [
"SetLink",
"is",
"a",
"wrapper",
"around",
"g_menu_item_Set_link",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"MenuItem",
")",
"SetLink",
"(",
"link",
"string",
",",
"<mask>",
"*",
"MenuModel",
")",
"{",
"cstr1",
":=",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"C",
".",
"CString",
"(",
"link",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr1",
")",
")",
"\n\n",
"C",
".",
"g_menu_item_set_link",
"(",
"v",
".",
"native",
"(",
")",
",",
"cstr1",
",",
"model",
".",
"native",
"(",
")",
")",
"\n",
"}"
] |
4,756 | all-4757 | [
"Set",
"is",
"required",
"for",
"kingpin",
"interfaces",
"to",
"allow",
"command",
"line",
"params",
"to",
"be",
"set",
"to",
"our",
"map",
"datatype"
] | [
"func",
"(",
"o",
"*",
"MapByteOption",
")",
"Set",
"(",
"value",
"string",
")",
"error",
"{",
"parts",
":=",
"stringMapRegex",
".",
"Split",
"(",
"<mask>",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"2",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"value",
")",
"\n",
"}",
"\n",
"val",
":=",
"ByteOption",
"{",
"}",
"\n",
"val",
".",
"Set",
"(",
"parts",
"[",
"1",
"]",
")",
"\n",
"(",
"*",
"o",
")",
"[",
"parts",
"[",
"0",
"]",
"]",
"=",
"val",
"\n",
"return",
"nil",
"\n",
"}"
] |
4,757 | all-4758 | [
"insert",
"the",
"cursor",
"rune",
"array",
"into",
"r",
"before",
"the",
"provided",
"index"
] | [
"func",
"format",
"(",
"a",
"[",
"]",
"rune",
",",
"c",
"*",
"Cursor",
")",
"string",
"{",
"i",
":=",
"c",
".",
"Position",
"\n",
"var",
"b",
"[",
"]",
"rune",
"\n\n",
"out",
":=",
"<mask>",
"(",
"[",
"]",
"rune",
",",
"0",
")",
"\n",
"if",
"i",
"<",
"len",
"(",
"a",
")",
"{",
"b",
"=",
"c",
".",
"Cursor",
"(",
"[",
"]",
"rune",
"(",
"a",
"[",
"i",
":",
"i",
"+",
"1",
"]",
")",
")",
"\n",
"out",
"=",
"append",
"(",
"out",
",",
"a",
"[",
":",
"i",
"]",
"...",
")",
"// does not include i",
"\n",
"out",
"=",
"append",
"(",
"out",
",",
"b",
"...",
")",
"// add the cursor",
"\n",
"out",
"=",
"append",
"(",
"out",
",",
"a",
"[",
"i",
"+",
"1",
":",
"]",
"...",
")",
"// add the rest after i",
"\n",
"}",
"else",
"{",
"b",
"=",
"c",
".",
"Cursor",
"(",
"[",
"]",
"rune",
"{",
"}",
")",
"\n",
"out",
"=",
"append",
"(",
"out",
",",
"a",
"...",
")",
"\n",
"out",
"=",
"append",
"(",
"out",
",",
"b",
"...",
")",
"\n",
"}",
"\n",
"return",
"string",
"(",
"out",
")",
"\n",
"}"
] |
4,758 | all-4759 | [
"CheckoutNewBranch",
"does",
"git",
"checkout",
"-",
"b",
"."
] | [
"func",
"(",
"lg",
"*",
"LocalGit",
")",
"CheckoutNewBranch",
"(",
"org",
",",
"repo",
",",
"branch",
"<mask>",
")",
"error",
"{",
"rdir",
":=",
"filepath",
".",
"Join",
"(",
"lg",
".",
"Dir",
",",
"org",
",",
"repo",
")",
"\n",
"return",
"runCmd",
"(",
"lg",
".",
"Git",
",",
"rdir",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"branch",
")",
"\n",
"}"
] |
4,759 | all-4760 | [
"Initialize",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockTaskResource",
")",
"Initialize",
"(",
"arg0",
"*",
"taskresource",
".",
"ResourceFields",
",",
"arg1",
",",
"arg2",
"<mask>",
".",
"TaskStatus",
")",
"{",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
",",
"arg1",
",",
"arg2",
")",
"\n",
"}"
] |
4,760 | all-4761 | [
"GetMetricOk",
"returns",
"a",
"tuple",
"with",
"the",
"Metric",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"w",
"*",
"WidgetProcessQuery",
")",
"GetMetricOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"w",
"==",
"nil",
"||",
"w",
".",
"Metric",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"w",
".",
"Metric",
",",
"true",
"\n",
"}"
] |
4,761 | all-4762 | [
"hash",
"returns",
"an",
"identifying",
"hash",
"for",
"the",
"target",
"."
] | [
"func",
"(",
"t",
"*",
"Target",
")",
"hash",
"(",
")",
"uint64",
"{",
"h",
":=",
"fnv",
".",
"New64a",
"(",
")",
"\n",
"h",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"t",
".",
"labels",
".",
"Hash",
"(",
")",
")",
")",
")",
"\n",
"h",
".",
"Write",
"(",
"[",
"]",
"<mask>",
"(",
"t",
".",
"URL",
"(",
")",
".",
"String",
"(",
")",
")",
")",
"\n\n",
"return",
"h",
".",
"Sum64",
"(",
")",
"\n",
"}"
] |
4,762 | all-4763 | [
"walk",
"walks",
"through",
"the",
"revisions",
"in",
"the",
"generation",
"in",
"descending",
"order",
".",
"It",
"passes",
"the",
"revision",
"to",
"the",
"given",
"function",
".",
"walk",
"returns",
"until",
":",
"1",
".",
"it",
"finishes",
"walking",
"all",
"pairs",
"2",
".",
"the",
"function",
"returns",
"false",
".",
"walk",
"returns",
"the",
"position",
"at",
"where",
"it",
"stopped",
".",
"If",
"it",
"stopped",
"after",
"finishing",
"walking",
"-",
"1",
"will",
"be",
"returned",
"."
] | [
"func",
"(",
"g",
"*",
"generation",
")",
"walk",
"(",
"f",
"func",
"(",
"rev",
"revision",
")",
"bool",
")",
"int",
"{",
"l",
":=",
"len",
"(",
"g",
".",
"revs",
")",
"\n",
"for",
"i",
":=",
"range",
"g",
".",
"revs",
"{",
"<mask>",
":=",
"f",
"(",
"g",
".",
"revs",
"[",
"l",
"-",
"i",
"-",
"1",
"]",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"l",
"-",
"i",
"-",
"1",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"-",
"1",
"\n",
"}"
] |
4,763 | all-4764 | [
"SettingsSchemaSourceNewFromDirectory",
"()",
"is",
"a",
"wrapper",
"around",
"g_settings_schema_source_new_from_directory",
"()",
"."
] | [
"func",
"SettingsSchemaSourceNewFromDirectory",
"(",
"dir",
"string",
",",
"parent",
"*",
"SettingsSchemaSource",
",",
"trusted",
"bool",
")",
"*",
"SettingsSchemaSource",
"{",
"cstr",
":=",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"C",
".",
"CString",
"(",
"dir",
")",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n\n",
"return",
"wrapSettingsSchemaSource",
"(",
"C",
".",
"g_settings_schema_source_new_from_directory",
"(",
"cstr",
",",
"parent",
".",
"native",
"(",
")",
",",
"gbool",
"(",
"trusted",
")",
",",
"nil",
")",
")",
"\n",
"}"
] |
4,764 | all-4765 | [
"buildFunction",
"builds",
"SSA",
"code",
"for",
"the",
"body",
"of",
"function",
"fn",
".",
"Idempotent",
"."
] | [
"func",
"(",
"b",
"*",
"builder",
")",
"buildFunction",
"(",
"fn",
"*",
"Function",
")",
"{",
"if",
"fn",
".",
"Blocks",
"!=",
"nil",
"{",
"return",
"// building already started",
"\n",
"}",
"\n\n",
"var",
"recvField",
"*",
"ast",
".",
"FieldList",
"\n",
"var",
"body",
"*",
"ast",
".",
"BlockStmt",
"\n",
"var",
"functype",
"*",
"ast",
".",
"FuncType",
"\n",
"switch",
"n",
":=",
"fn",
".",
"syntax",
".",
"(",
"type",
")",
"{",
"<mask>",
"nil",
":",
"return",
"// not a Go source function. (Synthetic, or from object file.)",
"\n",
"case",
"*",
"ast",
".",
"FuncDecl",
":",
"functype",
"=",
"n",
".",
"Type",
"\n",
"recvField",
"=",
"n",
".",
"Recv",
"\n",
"body",
"=",
"n",
".",
"Body",
"\n",
"case",
"*",
"ast",
".",
"FuncLit",
":",
"functype",
"=",
"n",
".",
"Type",
"\n",
"body",
"=",
"n",
".",
"Body",
"\n",
"default",
":",
"panic",
"(",
"n",
")",
"\n",
"}",
"\n\n",
"if",
"body",
"==",
"nil",
"{",
"// External function.",
"if",
"fn",
".",
"Params",
"==",
"nil",
"{",
"// This condition ensures we add a non-empty",
"// params list once only, but we may attempt",
"// the degenerate empty case repeatedly.",
"// TODO(adonovan): opt: don't do that.",
"// We set Function.Params even though there is no body",
"// code to reference them. This simplifies clients.",
"if",
"recv",
":=",
"fn",
".",
"Signature",
".",
"Recv",
"(",
")",
";",
"recv",
"!=",
"nil",
"{",
"fn",
".",
"addParamObj",
"(",
"recv",
")",
"\n",
"}",
"\n",
"params",
":=",
"fn",
".",
"Signature",
".",
"Params",
"(",
")",
"\n",
"for",
"i",
",",
"n",
":=",
"0",
",",
"params",
".",
"Len",
"(",
")",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"fn",
".",
"addParamObj",
"(",
"params",
".",
"At",
"(",
"i",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"fn",
".",
"Prog",
".",
"mode",
"&",
"LogSource",
"!=",
"0",
"{",
"defer",
"logStack",
"(",
"\"",
"\"",
",",
"fn",
",",
"fn",
".",
"Prog",
".",
"Fset",
".",
"Position",
"(",
"fn",
".",
"pos",
")",
")",
"(",
")",
"\n",
"}",
"\n",
"fn",
".",
"startBody",
"(",
")",
"\n",
"fn",
".",
"createSyntacticParams",
"(",
"recvField",
",",
"functype",
")",
"\n",
"b",
".",
"stmt",
"(",
"fn",
",",
"body",
")",
"\n",
"if",
"cb",
":=",
"fn",
".",
"currentBlock",
";",
"cb",
"!=",
"nil",
"&&",
"(",
"cb",
"==",
"fn",
".",
"Blocks",
"[",
"0",
"]",
"||",
"cb",
"==",
"fn",
".",
"Recover",
"||",
"cb",
".",
"Preds",
"!=",
"nil",
")",
"{",
"// Control fell off the end of the function's body block.",
"//",
"// Block optimizations eliminate the current block, if",
"// unreachable. It is a builder invariant that",
"// if this no-arg return is ill-typed for",
"// fn.Signature.Results, this block must be",
"// unreachable. The sanity checker checks this.",
"fn",
".",
"emit",
"(",
"new",
"(",
"RunDefers",
")",
")",
"\n",
"fn",
".",
"emit",
"(",
"new",
"(",
"Return",
")",
")",
"\n",
"}",
"\n",
"fn",
".",
"finishBody",
"(",
")",
"\n",
"}"
] |
4,765 | all-4766 | [
"Unzip",
"unzips",
"archive",
"to",
"target",
"location"
] | [
"func",
"Unzip",
"(",
"archive",
",",
"target",
"string",
")",
"error",
"{",
"// fmt.Println(\"Unzip archive \", target)",
"reader",
",",
"err",
":=",
"zip",
".",
"OpenReader",
"(",
"archive",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"reader",
".",
"Close",
"(",
")",
"\n\n",
"for",
"_",
",",
"file",
":=",
"range",
"reader",
".",
"File",
"{",
"filePath",
":=",
"filepath",
".",
"Join",
"(",
"target",
",",
"file",
".",
"Name",
")",
"\n\n",
"if",
"file",
".",
"FileInfo",
"(",
")",
".",
"IsDir",
"(",
")",
"{",
"os",
".",
"MkdirAll",
"(",
"filePath",
",",
"file",
".",
"Mode",
"(",
")",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"fileReader",
",",
"err",
":=",
"file",
".",
"Open",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"fileReader",
".",
"Close",
"(",
")",
"\n\n",
"targetFile",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"filePath",
",",
"os",
".",
"O_WRONLY",
"|",
"os",
".",
"O_CREATE",
"|",
"os",
".",
"O_TRUNC",
",",
"<mask>",
".",
"Mode",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"targetFile",
".",
"Close",
"(",
")",
"\n\n",
"if",
"_",
",",
"err",
":=",
"io",
".",
"Copy",
"(",
"targetFile",
",",
"fileReader",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
4,766 | all-4767 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"SetScriptExecutionDisabledParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoEmulation5",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
4,767 | all-4768 | [
"dudupe",
"removes",
"duplicate",
"characters",
"from",
"s",
"."
] | [
"func",
"dedupe",
"(",
"s",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"var",
"out",
"[",
"]",
"string",
"\n",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n\n",
"for",
"_",
",",
"char",
":=",
"range",
"s",
"{",
"if",
"_",
",",
"ok",
":=",
"m",
"[",
"char",
"]",
";",
"!",
"ok",
"{",
"m",
"[",
"<mask>",
"]",
"=",
"true",
"\n",
"out",
"=",
"append",
"(",
"out",
",",
"char",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"out",
"\n",
"}"
] |
4,768 | all-4769 | [
"OperationsUUIDs",
"returns",
"the",
"UUIDs",
"of",
"all",
"operations",
"associated",
"with",
"this",
"node",
"."
] | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"OperationsUUIDs",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"stmt",
":=",
"\"",
"\"",
"\n",
"return",
"query",
".",
"SelectStrings",
"(",
"c",
".",
"<mask>",
",",
"stmt",
",",
"c",
".",
"nodeID",
")",
"\n",
"}"
] |
4,769 | all-4770 | [
"NewIstioClient",
"returns",
"a",
"new",
"Istio",
"client",
"object",
".",
"It",
"uses",
"the",
"configured",
"KubeConfig",
"attribute",
"to",
"connect",
"to",
"the",
"cluster",
".",
"If",
"KubeConfig",
"isn",
"t",
"provided",
"it",
"defaults",
"to",
"using",
"the",
"recommended",
"default",
".",
"NB",
":",
"Istio",
"controls",
"the",
"creation",
"of",
"the",
"underlying",
"Kubernetes",
"client",
"so",
"we",
"have",
"no",
"ability",
"to",
"tack",
"on",
"transport",
"wrappers",
"(",
"e",
".",
"g",
".",
"Prometheus",
"request",
"wrappers",
")",
"to",
"the",
"client",
"s",
"config",
"at",
"this",
"level",
".",
"Furthermore",
"the",
"Istio",
"client",
"constructor",
"does",
"not",
"expose",
"the",
"ability",
"to",
"override",
"the",
"Kubernetes",
"master",
"so",
"the",
"Master",
"config",
"attribute",
"has",
"no",
"effect",
"."
] | [
"func",
"NewIstioClient",
"(",
"kubeConfig",
"string",
")",
"(",
"*",
"istiocrd",
".",
"Client",
",",
"error",
")",
"{",
"if",
"kubeConfig",
"==",
"\"",
"\"",
"{",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"clientcmd",
".",
"RecommendedHomeFile",
")",
";",
"err",
"==",
"nil",
"{",
"kubeConfig",
"=",
"clientcmd",
".",
"RecommendedHomeFile",
"\n",
"}",
"\n",
"}",
"\n\n",
"client",
",",
"err",
":=",
"istiocrd",
".",
"NewClient",
"(",
"kubeConfig",
",",
"\"",
"\"",
",",
"istiomodel",
".",
"ConfigDescriptor",
"{",
"istiomodel",
".",
"Gateway",
"}",
",",
"\"",
"\"",
",",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"<mask>",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"return",
"client",
",",
"nil",
"\n",
"}"
] |
4,770 | all-4771 | [
"ScaleSimple",
"is",
"a",
"wrapper",
"around",
"gdk_pixbuf_scale_simple",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Pixbuf",
")",
"ScaleSimple",
"(",
"destWidth",
",",
"destHeight",
"int",
",",
"interpType",
"InterpType",
")",
"(",
"*",
"Pixbuf",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gdk_pixbuf_scale_simple",
"(",
"v",
".",
"native",
"(",
")",
",",
"C",
".",
"int",
"(",
"destWidth",
")",
",",
"C",
".",
"int",
"(",
"destHeight",
")",
",",
"C",
".",
"GdkInterpType",
"(",
"interpType",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n\n",
"obj",
":=",
"&",
"glib",
".",
"Object",
"{",
"glib",
".",
"ToGObject",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
"}",
"\n",
"p",
":=",
"&",
"Pixbuf",
"{",
"obj",
"}",
"\n",
"//obj.Ref()",
"runtime",
".",
"SetFinalizer",
"(",
"p",
",",
"func",
"(",
"_",
"<mask>",
"{",
"}",
")",
"{",
"obj",
".",
"Unref",
"(",
")",
"}",
")",
"\n",
"return",
"p",
",",
"nil",
"\n",
"}"
] |
4,771 | all-4772 | [
"MacroName",
"returns",
"the",
"name",
"of",
"the",
"macro",
"function",
"that",
"this",
"file",
"is",
"editing",
"or",
"an",
"empty",
"string",
"if",
"a",
"macro",
"function",
"is",
"not",
"being",
"edited",
"."
] | [
"func",
"(",
"f",
"*",
"File",
")",
"MacroName",
"(",
")",
"string",
"{",
"if",
"f",
".",
"function",
"!=",
"nil",
"&&",
"f",
".",
"function",
".",
"stmt",
"!=",
"nil",
"{",
"return",
"f",
".",
"function",
".",
"stmt",
".",
"<mask>",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
4,772 | all-4773 | [
"PrintSettingsNewFromKeyFile",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_print_settings_new_from_key_file",
"()",
".",
"LoadFile",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_print_settings_load_file",
"()",
"."
] | [
"func",
"(",
"ps",
"*",
"PrintSettings",
")",
"LoadFile",
"(",
"name",
"string",
")",
"error",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"name",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n",
"var",
"err",
"*",
"C",
".",
"GError",
"=",
"nil",
"\n",
"c",
":=",
"C",
".",
"gtk_print_settings_load_file",
"(",
"ps",
".",
"native",
"(",
")",
",",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
",",
"&",
"err",
")",
"\n",
"if",
"gobool",
"(",
"c",
")",
"==",
"false",
"{",
"defer",
"C",
".",
"g_error_free",
"(",
"err",
")",
"\n",
"return",
"errors",
".",
"New",
"(",
"C",
".",
"GoString",
"(",
"(",
"*",
"C",
".",
"char",
")",
"(",
"err",
".",
"message",
")",
")",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
4,773 | all-4774 | [
"DockerStateToState",
"converts",
"the",
"container",
"status",
"from",
"docker",
"to",
"status",
"recognized",
"by",
"the",
"agent"
] | [
"func",
"DockerStateToState",
"(",
"state",
"*",
"types",
".",
"ContainerState",
")",
"apicontainerstatus",
".",
"ContainerStatus",
"{",
"if",
"state",
".",
"Running",
"{",
"return",
"apicontainerstatus",
".",
"ContainerRunning",
"\n",
"}",
"\n\n",
"if",
"state",
".",
"Dead",
"{",
"return",
"apicontainerstatus",
".",
"ContainerStopped",
"\n",
"}",
"\n\n",
"// StartAt field in ContainerState is a string and need to convert to compare to zero time instant",
"startTime",
",",
"_",
":=",
"time",
".",
"Parse",
"(",
"time",
".",
"RFC3339",
",",
"state",
".",
"StartedAt",
")",
"\n",
"if",
"startTime",
".",
"IsZero",
"(",
")",
"&&",
"state",
".",
"<mask>",
"==",
"\"",
"\"",
"{",
"return",
"apicontainerstatus",
".",
"ContainerCreated",
"\n",
"}",
"\n\n",
"return",
"apicontainerstatus",
".",
"ContainerStopped",
"\n",
"}"
] |
4,774 | all-4775 | [
"Endpoints",
"returns",
"endpoint",
"objects",
"for",
"each",
"host",
"-",
"target",
"combination",
"that",
"should",
"be",
"processed",
".",
"Retrieves",
"all",
"ingress",
"resources",
"on",
"all",
"namespaces"
] | [
"func",
"(",
"sc",
"*",
"ingressSource",
")",
"Endpoints",
"(",
")",
"(",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
",",
"error",
")",
"{",
"ingresses",
",",
"err",
":=",
"sc",
".",
"ingressInformer",
".",
"Lister",
"(",
")",
".",
"Ingresses",
"(",
"sc",
".",
"namespace",
")",
".",
"List",
"(",
"labels",
".",
"Everything",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ingresses",
",",
"err",
"=",
"sc",
".",
"filterByAnnotations",
"(",
"ingresses",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"endpoints",
":=",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
"{",
"}",
"\n\n",
"for",
"_",
",",
"ing",
":=",
"range",
"ingresses",
"{",
"// Check controller annotation to see if we are responsible.",
"controller",
",",
"ok",
":=",
"ing",
".",
"Annotations",
"[",
"controllerAnnotationKey",
"]",
"\n",
"if",
"ok",
"&&",
"controller",
"!=",
"controllerAnnotationValue",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"ing",
".",
"Namespace",
",",
"ing",
".",
"<mask>",
",",
"controller",
",",
"controllerAnnotationValue",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"ingEndpoints",
":=",
"endpointsFromIngress",
"(",
"ing",
",",
"sc",
".",
"ignoreHostnameAnnotation",
")",
"\n\n",
"// apply template if host is missing on ingress",
"if",
"(",
"sc",
".",
"combineFQDNAnnotation",
"||",
"len",
"(",
"ingEndpoints",
")",
"==",
"0",
")",
"&&",
"sc",
".",
"fqdnTemplate",
"!=",
"nil",
"{",
"iEndpoints",
",",
"err",
":=",
"sc",
".",
"endpointsFromTemplate",
"(",
"ing",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"sc",
".",
"combineFQDNAnnotation",
"{",
"ingEndpoints",
"=",
"append",
"(",
"ingEndpoints",
",",
"iEndpoints",
"...",
")",
"\n",
"}",
"else",
"{",
"ingEndpoints",
"=",
"iEndpoints",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"ingEndpoints",
")",
"==",
"0",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"ing",
".",
"Namespace",
",",
"ing",
".",
"Name",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"ing",
".",
"Namespace",
",",
"ing",
".",
"Name",
",",
"ingEndpoints",
")",
"\n",
"sc",
".",
"setResourceLabel",
"(",
"ing",
",",
"ingEndpoints",
")",
"\n",
"endpoints",
"=",
"append",
"(",
"endpoints",
",",
"ingEndpoints",
"...",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"ep",
":=",
"range",
"endpoints",
"{",
"sort",
".",
"Sort",
"(",
"ep",
".",
"Targets",
")",
"\n",
"}",
"\n\n",
"return",
"endpoints",
",",
"nil",
"\n",
"}"
] |
4,775 | all-4776 | [
"Errorf",
"outputs",
"formatted",
"Error",
"log"
] | [
"func",
"(",
"g",
"*",
"Glg",
")",
"Errorf",
"(",
"<mask>",
"string",
",",
"val",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"g",
".",
"out",
"(",
"ERR",
",",
"format",
",",
"val",
"...",
")",
"\n",
"}"
] |
4,776 | all-4777 | [
"ArgWriter",
"returns",
"an",
"ArgWriter",
"to",
"write",
"an",
"argument",
".",
"The",
"ArgWriter",
"will",
"handle",
"fragmentation",
"as",
"needed",
".",
"Once",
"the",
"argument",
"is",
"written",
"the",
"ArgWriter",
"must",
"be",
"closed",
"."
] | [
"func",
"(",
"w",
"*",
"fragmentingWriter",
")",
"ArgWriter",
"(",
"last",
"bool",
")",
"(",
"ArgWriter",
",",
"error",
")",
"{",
"if",
"err",
":=",
"w",
".",
"BeginArgument",
"(",
"<mask>",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"w",
",",
"nil",
"\n",
"}"
] |
4,777 | all-4778 | [
"NewUUID",
"returns",
"a",
"Version",
"1",
"UUID",
"based",
"on",
"the",
"current",
"NodeID",
"and",
"clock",
"sequence",
"and",
"the",
"current",
"time",
".",
"If",
"the",
"NodeID",
"has",
"not",
"been",
"set",
"by",
"SetNodeID",
"or",
"SetNodeInterface",
"then",
"it",
"will",
"be",
"set",
"automatically",
".",
"If",
"the",
"NodeID",
"cannot",
"be",
"set",
"NewUUID",
"returns",
"nil",
".",
"If",
"clock",
"sequence",
"has",
"not",
"been",
"set",
"by",
"SetClockSequence",
"then",
"it",
"will",
"be",
"set",
"automatically",
".",
"If",
"GetTime",
"fails",
"to",
"return",
"the",
"current",
"NewUUID",
"returns",
"nil",
"and",
"an",
"error",
".",
"In",
"most",
"cases",
"New",
"should",
"be",
"used",
"."
] | [
"func",
"NewUUID",
"(",
")",
"(",
"UUID",
",",
"error",
")",
"{",
"nodeMu",
".",
"Lock",
"(",
")",
"\n",
"if",
"nodeID",
"==",
"zeroID",
"{",
"setNodeInterface",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"nodeMu",
".",
"Unlock",
"(",
")",
"\n\n",
"var",
"uuid",
"UUID",
"\n",
"now",
",",
"seq",
",",
"err",
":=",
"GetTime",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"uuid",
",",
"err",
"\n",
"}",
"\n\n",
"timeLow",
":=",
"uint32",
"(",
"now",
"&",
"0xffffffff",
")",
"\n",
"timeMid",
":=",
"uint16",
"(",
"(",
"now",
">>",
"32",
")",
"&",
"0xffff",
")",
"\n",
"timeHi",
":=",
"uint16",
"(",
"(",
"now",
">>",
"48",
")",
"&",
"0x0fff",
")",
"\n",
"timeHi",
"|=",
"0x1000",
"// Version 1",
"\n\n",
"binary",
".",
"BigEndian",
".",
"PutUint32",
"(",
"uuid",
"[",
"0",
":",
"]",
",",
"timeLow",
")",
"\n",
"binary",
".",
"BigEndian",
".",
"PutUint16",
"(",
"uuid",
"[",
"4",
":",
"]",
",",
"timeMid",
")",
"\n",
"<mask>",
".",
"BigEndian",
".",
"PutUint16",
"(",
"uuid",
"[",
"6",
":",
"]",
",",
"timeHi",
")",
"\n",
"binary",
".",
"BigEndian",
".",
"PutUint16",
"(",
"uuid",
"[",
"8",
":",
"]",
",",
"seq",
")",
"\n",
"copy",
"(",
"uuid",
"[",
"10",
":",
"]",
",",
"nodeID",
"[",
":",
"]",
")",
"\n\n",
"return",
"uuid",
",",
"nil",
"\n",
"}"
] |
4,778 | all-4779 | [
"String",
"returns",
"the",
"name",
"of",
"e"
] | [
"func",
"(",
"e",
"AccountFlags",
")",
"<mask>",
"(",
")",
"string",
"{",
"name",
",",
"_",
":=",
"accountFlagsMap",
"[",
"int32",
"(",
"e",
")",
"]",
"\n",
"return",
"name",
"\n",
"}"
] |
4,779 | all-4780 | [
"httpRequest",
"makes",
"a",
"request",
"to",
"the",
"cluster",
"-",
"use",
"this",
"when",
"you",
"want",
"the",
"client",
"to",
"choose",
"a",
"host",
"and",
"it",
"doesn",
"t",
"matter",
"if",
"the",
"request",
"goes",
"to",
"a",
"specific",
"host"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"httpRequest",
"(",
"method",
"string",
",",
"path",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"headers",
"map",
"[",
"string",
"]",
"string",
",",
"useCoordinator",
"bool",
")",
"(",
"*",
"http",
".",
"Response",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"data",
"==",
"nil",
"{",
"data",
"=",
"[",
"]",
"byte",
"{",
"}",
"\n",
"}",
"\n\n",
"// try at most maxHosts non-failed hosts; protect against broken cluster.removeHost",
"var",
"response",
"*",
"http",
".",
"Response",
"\n",
"var",
"err",
"error",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"maxHosts",
";",
"i",
"++",
"{",
"host",
",",
"err",
":=",
"c",
".",
"host",
"(",
"useCoordinator",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"response",
",",
"err",
"=",
"c",
".",
"doRequest",
"(",
"host",
",",
"method",
",",
"path",
",",
"c",
".",
"augmentHeaders",
"(",
"headers",
")",
",",
"bytes",
".",
"NewReader",
"(",
"data",
")",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"break",
"\n",
"}",
"\n",
"if",
"c",
".",
"manualServerURI",
"==",
"nil",
"{",
"if",
"useCoordinator",
"{",
"c",
".",
"coordinatorLock",
".",
"Lock",
"(",
")",
"\n",
"c",
".",
"coordinatorURI",
"=",
"nil",
"\n",
"c",
".",
"coordinatorLock",
".",
"Unlock",
"(",
")",
"\n",
"}",
"else",
"{",
"c",
".",
"cluster",
".",
"RemoveHost",
"(",
"<mask>",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// TODO: exponential backoff",
"time",
".",
"Sleep",
"(",
"1",
"*",
"time",
".",
"Second",
")",
"\n",
"}",
"\n",
"if",
"response",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"ErrTriedMaxHosts",
"\n",
"}",
"\n",
"defer",
"response",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"warning",
":=",
"response",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"warning",
"!=",
"\"",
"\"",
"{",
"c",
".",
"logger",
".",
"Println",
"(",
"warning",
")",
"\n",
"}",
"\n",
"// TODO: Optimize buffer creation",
"buf",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"response",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"response",
".",
"StatusCode",
"<",
"200",
"||",
"response",
".",
"StatusCode",
">=",
"300",
"{",
"err",
":=",
"NewError",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"response",
".",
"StatusCode",
",",
"response",
".",
"Status",
",",
"string",
"(",
"buf",
")",
")",
")",
"\n",
"return",
"response",
",",
"buf",
",",
"err",
"\n",
"}",
"\n",
"return",
"response",
",",
"buf",
",",
"nil",
"\n",
"}"
] |
4,780 | all-4781 | [
"WithFunctions",
"adds",
"function",
"map",
"to",
"templates",
"."
] | [
"func",
"WithFunctions",
"(",
"fns",
"template",
".",
"FuncMap",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"<mask>",
")",
"{",
"for",
"name",
",",
"fn",
":=",
"range",
"fns",
"{",
"o",
".",
"functions",
"[",
"name",
"]",
"=",
"fn",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
4,781 | all-4782 | [
"LabelsForTarget",
"returns",
"labels",
"that",
"have",
"a",
"given",
"target"
] | [
"func",
"LabelsForTarget",
"(",
"labels",
"[",
"]",
"<mask>",
",",
"target",
"LabelTarget",
")",
"(",
"filteredLabels",
"[",
"]",
"Label",
")",
"{",
"for",
"_",
",",
"label",
":=",
"range",
"labels",
"{",
"if",
"target",
"==",
"label",
".",
"Target",
"{",
"filteredLabels",
"=",
"append",
"(",
"filteredLabels",
",",
"label",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// We also sort to make nice tables",
"sort",
".",
"Slice",
"(",
"filteredLabels",
",",
"func",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"filteredLabels",
"[",
"i",
"]",
".",
"Name",
"<",
"filteredLabels",
"[",
"j",
"]",
".",
"Name",
"}",
")",
"\n",
"return",
"\n",
"}"
] |
4,782 | all-4783 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"NameValue",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoDomsnapshot5",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
4,783 | all-4784 | [
"HasTitleSize",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"e",
"*",
"EventStreamDefinition",
")",
"HasTitleSize",
"(",
")",
"bool",
"{",
"if",
"e",
"!=",
"nil",
"&&",
"e",
".",
"TitleSize",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
4,784 | all-4785 | [
"note",
":",
"this",
"is",
"not",
"a",
"standard",
"s3",
"error"
] | [
"func",
"invalidDelimiterError",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"<mask>",
".",
"Request",
")",
"{",
"writeError",
"(",
"w",
",",
"r",
",",
"http",
".",
"StatusBadRequest",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
4,785 | all-4786 | [
"HasTitleSize",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"t",
"*",
"TraceServiceDefinition",
")",
"HasTitleSize",
"(",
")",
"bool",
"{",
"if",
"t",
"!=",
"nil",
"&&",
"t",
".",
"TitleSize",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
4,786 | all-4787 | [
"Stop",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockTimer",
")",
"Stop",
"(",
")",
"bool",
"{",
"<mask>",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"bool",
")",
"\n",
"return",
"ret0",
"\n",
"}"
] |
4,787 | all-4788 | [
"DeleteFirewallRule",
"deletes",
"a",
"firewall",
"rule"
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteFirewallRule",
"(",
"dcID",
"string",
",",
"serverID",
"string",
",",
"nicID",
"string",
",",
"fwID",
"string",
")",
"(",
"*",
"http",
".",
"Header",
",",
"error",
")",
"{",
"url",
":=",
"fwrulePath",
"(",
"dcID",
",",
"serverID",
",",
"nicID",
",",
"fwID",
")",
"+",
"`?depth=`",
"+",
"c",
".",
"<mask>",
".",
"depth",
"+",
"`&pretty=`",
"+",
"strconv",
".",
"FormatBool",
"(",
"c",
".",
"client",
".",
"pretty",
")",
"\n",
"ret",
":=",
"&",
"http",
".",
"Header",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"client",
".",
"Delete",
"(",
"url",
",",
"ret",
",",
"http",
".",
"StatusAccepted",
")",
"\n",
"return",
"ret",
",",
"err",
"\n",
"}"
] |
4,788 | all-4789 | [
"String",
"prints",
"a",
"humanly",
"-",
"readable",
"summary",
"of",
"coalesced",
"records",
".",
"Example",
":",
"diffStats",
"{",
"Name",
":",
"Field",
"NumIgnored",
":",
"5",
"}",
".",
"String",
"()",
"=",
">",
"5",
"ignored",
"fields"
] | [
"func",
"(",
"s",
"diffStats",
")",
"String",
"(",
")",
"string",
"{",
"var",
"ss",
"[",
"]",
"string",
"\n",
"var",
"sum",
"int",
"\n",
"labels",
":=",
"[",
"...",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"\n",
"counts",
":=",
"[",
"...",
"]",
"int",
"{",
"s",
".",
"NumIgnored",
",",
"s",
".",
"NumIdentical",
",",
"s",
".",
"NumRemoved",
",",
"s",
".",
"NumInserted",
",",
"s",
".",
"NumModified",
"}",
"\n",
"for",
"i",
",",
"n",
":=",
"range",
"counts",
"{",
"if",
"n",
">",
"0",
"{",
"<mask>",
"=",
"append",
"(",
"ss",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"n",
",",
"labels",
"[",
"i",
"]",
")",
")",
"\n",
"}",
"\n",
"sum",
"+=",
"n",
"\n",
"}",
"\n\n",
"// Pluralize the name (adjusting for some obscure English grammar rules).",
"name",
":=",
"s",
".",
"Name",
"\n",
"if",
"sum",
">",
"1",
"{",
"name",
"=",
"name",
"+",
"\"",
"\"",
"\n",
"if",
"strings",
".",
"HasSuffix",
"(",
"name",
",",
"\"",
"\"",
")",
"{",
"name",
"=",
"name",
"[",
":",
"len",
"(",
"name",
")",
"-",
"2",
"]",
"+",
"\"",
"\"",
"// e.g., \"entrys\" => \"entries\"",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Format the list according to English grammar (with Oxford comma).",
"switch",
"n",
":=",
"len",
"(",
"ss",
")",
";",
"n",
"{",
"case",
"0",
":",
"return",
"\"",
"\"",
"\n",
"case",
"1",
",",
"2",
":",
"return",
"strings",
".",
"Join",
"(",
"ss",
",",
"\"",
"\"",
")",
"+",
"\"",
"\"",
"+",
"name",
"\n",
"default",
":",
"return",
"strings",
".",
"Join",
"(",
"ss",
"[",
":",
"n",
"-",
"1",
"]",
",",
"\"",
"\"",
")",
"+",
"\"",
"\"",
"+",
"ss",
"[",
"n",
"-",
"1",
"]",
"+",
"\"",
"\"",
"+",
"name",
"\n",
"}",
"\n",
"}"
] |
4,789 | all-4790 | [
"WithProcessClosing",
"returns",
"a",
"context",
".",
"Context",
"derived",
"from",
"ctx",
"that",
"is",
"cancelled",
"as",
"p",
"is",
"Closing",
"(",
"after",
":",
"<",
"-",
"p",
".",
"Closing",
"()",
")",
".",
"It",
"is",
"simply",
":",
"func",
"WithProcessClosing",
"(",
"ctx",
"context",
".",
"Context",
"p",
"goprocess",
".",
"Process",
")",
"context",
".",
"Context",
"{",
"ctx",
"cancel",
":",
"=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"go",
"func",
"()",
"{",
"<",
"-",
"p",
".",
"Closing",
"()",
"cancel",
"()",
"}",
"()",
"return",
"ctx",
"}"
] | [
"func",
"WithProcessClosing",
"(",
"ctx",
"context",
".",
"Context",
",",
"p",
"goprocess",
".",
"Process",
")",
"<mask>",
".",
"Context",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"<-",
"p",
".",
"Closing",
"(",
")",
"\n",
"cancel",
"(",
")",
"\n",
"}",
"(",
")",
"\n",
"return",
"ctx",
"\n",
"}"
] |
4,790 | all-4791 | [
"Rename",
"renames",
"a",
"StoragePod",
"."
] | [
"func",
"Rename",
"(",
"pod",
"*",
"<mask>",
".",
"StoragePod",
",",
"name",
"string",
")",
"error",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"pod",
".",
"InventoryPath",
",",
"name",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"provider",
".",
"DefaultAPITimeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n",
"task",
",",
"err",
":=",
"pod",
".",
"Rename",
"(",
"ctx",
",",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"task",
".",
"Wait",
"(",
"ctx",
")",
"\n",
"}"
] |
4,791 | all-4792 | [
"Dbgf",
"is",
"a",
"short",
"-",
"hand",
"version",
"of",
"Debugf"
] | [
"func",
"(",
"b",
"*",
"Base",
")",
"Dbgf",
"(",
"msg",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"b",
".",
"Debugf",
"(",
"<mask>",
",",
"a",
"...",
")",
"\n",
"}"
] |
4,792 | all-4793 | [
"HostVolumeByName",
"returns",
"the",
"task",
"Volume",
"for",
"the",
"given",
"a",
"volume",
"name",
"in",
"that",
"task",
".",
"The",
"second",
"return",
"value",
"indicates",
"the",
"presence",
"of",
"that",
"volume"
] | [
"func",
"(",
"task",
"*",
"Task",
")",
"HostVolumeByName",
"(",
"name",
"string",
")",
"(",
"taskresourcevolume",
".",
"Volume",
",",
"bool",
")",
"{",
"for",
"_",
",",
"v",
":=",
"<mask>",
"task",
".",
"Volumes",
"{",
"if",
"v",
".",
"Name",
"==",
"name",
"{",
"return",
"v",
".",
"Volume",
",",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
",",
"false",
"\n",
"}"
] |
4,793 | all-4794 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"RuleMatch",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss24",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"<mask>",
"\n",
"}"
] |
4,794 | all-4795 | [
"===",
"sqrt",
"(",
"Vector",
"VectorNode",
")",
"Vector",
"==="
] | [
"func",
"funcSqrt",
"(",
"vals",
"[",
"]",
"<mask>",
",",
"args",
"Expressions",
",",
"enh",
"*",
"EvalNodeHelper",
")",
"Vector",
"{",
"return",
"simpleFunc",
"(",
"vals",
",",
"enh",
",",
"math",
".",
"Sqrt",
")",
"\n",
"}"
] |
4,795 | all-4796 | [
"List",
"takes",
"label",
"and",
"field",
"selectors",
"and",
"returns",
"the",
"list",
"of",
"ProwJobs",
"that",
"match",
"those",
"selectors",
"."
] | [
"func",
"(",
"c",
"*",
"FakeProwJobs",
")",
"List",
"(",
"opts",
"v1",
".",
"ListOptions",
")",
"(",
"result",
"*",
"prowjobsv1",
".",
"ProwJobList",
",",
"err",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"c",
".",
"Fake",
".",
"Invokes",
"(",
"testing",
".",
"NewListAction",
"(",
"prowjobsResource",
",",
"prowjobsKind",
",",
"c",
".",
"ns",
",",
"opts",
")",
",",
"&",
"prowjobsv1",
".",
"ProwJobList",
"{",
"}",
")",
"\n\n",
"if",
"obj",
"==",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"label",
",",
"_",
",",
"_",
":=",
"testing",
".",
"ExtractFromListOptions",
"(",
"opts",
")",
"\n",
"if",
"label",
"==",
"nil",
"{",
"label",
"=",
"labels",
".",
"Everything",
"(",
")",
"\n",
"}",
"\n",
"list",
":=",
"&",
"prowjobsv1",
".",
"ProwJobList",
"{",
"ListMeta",
":",
"obj",
".",
"(",
"*",
"prowjobsv1",
".",
"ProwJobList",
")",
".",
"ListMeta",
"}",
"\n",
"for",
"_",
",",
"item",
":=",
"<mask>",
"obj",
".",
"(",
"*",
"prowjobsv1",
".",
"ProwJobList",
")",
".",
"Items",
"{",
"if",
"label",
".",
"Matches",
"(",
"labels",
".",
"Set",
"(",
"item",
".",
"Labels",
")",
")",
"{",
"list",
".",
"Items",
"=",
"append",
"(",
"list",
".",
"Items",
",",
"item",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"list",
",",
"err",
"\n",
"}"
] |
4,796 | all-4797 | [
"retrieve",
"messages",
"from",
"the",
"debug",
"message",
"log"
] | [
"func",
"GetDebugMessageLog",
"(",
"count",
"uint32",
",",
"bufSize",
"int32",
",",
"sources",
"*",
"uint32",
",",
"types",
"*",
"uint32",
",",
"ids",
"*",
"uint32",
",",
"severities",
"*",
"uint32",
",",
"lengths",
"*",
"int32",
",",
"messageLog",
"*",
"uint8",
")",
"uint32",
"{",
"ret",
",",
"_",
",",
"_",
":=",
"syscall",
".",
"Syscall9",
"(",
"gpGetDebugMessageLog",
",",
"8",
",",
"uintptr",
"(",
"count",
")",
",",
"uintptr",
"(",
"bufSize",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"sources",
")",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"types",
")",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"ids",
")",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"severities",
")",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"lengths",
")",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"messageLog",
")",
")",
",",
"0",
")",
"\n",
"return",
"(",
"uint32",
")",
"(",
"<mask>",
")",
"\n",
"}"
] |
4,797 | all-4798 | [
"retrieve",
"the",
"label",
"of",
"a",
"sync",
"object",
"identified",
"by",
"a",
"pointer"
] | [
"func",
"GetObjectPtrLabel",
"(",
"ptr",
"unsafe",
".",
"Pointer",
",",
"bufSize",
"int32",
",",
"length",
"*",
"int32",
",",
"<mask>",
"*",
"uint8",
")",
"{",
"syscall",
".",
"Syscall6",
"(",
"gpGetObjectPtrLabel",
",",
"4",
",",
"uintptr",
"(",
"ptr",
")",
",",
"uintptr",
"(",
"bufSize",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"length",
")",
")",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"label",
")",
")",
",",
"0",
",",
"0",
")",
"\n",
"}"
] |
4,798 | all-4799 | [
"CopyImage",
"copies",
"an",
"image",
"from",
"a",
"remote",
"server",
".",
"Additional",
"options",
"can",
"be",
"passed",
"using",
"ImageCopyArgs"
] | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"CopyImage",
"(",
"source",
"ImageServer",
",",
"image",
"api",
".",
"Image",
",",
"args",
"*",
"ImageCopyArgs",
")",
"(",
"RemoteOperation",
",",
"error",
")",
"{",
"// Sanity checks",
"if",
"r",
"==",
"<mask>",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Get source server connection information",
"info",
",",
"err",
":=",
"source",
".",
"GetConnectionInfo",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Prepare the copy request",
"req",
":=",
"api",
".",
"ImagesPost",
"{",
"Source",
":",
"&",
"api",
".",
"ImagesPostSource",
"{",
"ImageSource",
":",
"api",
".",
"ImageSource",
"{",
"Certificate",
":",
"info",
".",
"Certificate",
",",
"Protocol",
":",
"info",
".",
"Protocol",
",",
"}",
",",
"Fingerprint",
":",
"image",
".",
"Fingerprint",
",",
"Mode",
":",
"\"",
"\"",
",",
"Type",
":",
"\"",
"\"",
",",
"}",
",",
"}",
"\n\n",
"// Generate secret token if needed",
"if",
"!",
"image",
".",
"Public",
"{",
"secret",
",",
"err",
":=",
"source",
".",
"GetImageSecret",
"(",
"image",
".",
"Fingerprint",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"req",
".",
"Source",
".",
"Secret",
"=",
"secret",
"\n",
"}",
"\n\n",
"// Process the arguments",
"if",
"args",
"!=",
"nil",
"{",
"req",
".",
"Aliases",
"=",
"args",
".",
"Aliases",
"\n",
"req",
".",
"AutoUpdate",
"=",
"args",
".",
"AutoUpdate",
"\n",
"req",
".",
"Public",
"=",
"args",
".",
"Public",
"\n\n",
"if",
"args",
".",
"CopyAliases",
"{",
"req",
".",
"Aliases",
"=",
"image",
".",
"Aliases",
"\n",
"if",
"args",
".",
"Aliases",
"!=",
"nil",
"{",
"req",
".",
"Aliases",
"=",
"append",
"(",
"req",
".",
"Aliases",
",",
"args",
".",
"Aliases",
"...",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"r",
".",
"tryCopyImage",
"(",
"req",
",",
"info",
".",
"Addresses",
")",
"\n",
"}"
] |
4,799 | all-4800 | [
"Run",
"implements",
"the",
"Discoverer",
"interface",
"."
] | [
"func",
"(",
"e",
"*",
"Endpoints",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"ch",
"chan",
"<-",
"[",
"]",
"*",
"targetgroup",
".",
"<mask>",
")",
"{",
"defer",
"e",
".",
"queue",
".",
"ShutDown",
"(",
")",
"\n\n",
"if",
"!",
"cache",
".",
"WaitForCacheSync",
"(",
"ctx",
".",
"Done",
"(",
")",
",",
"e",
".",
"endpointsInf",
".",
"HasSynced",
",",
"e",
".",
"serviceInf",
".",
"HasSynced",
",",
"e",
".",
"podInf",
".",
"HasSynced",
")",
"{",
"level",
".",
"Error",
"(",
"e",
".",
"logger",
")",
".",
"Log",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"go",
"func",
"(",
")",
"{",
"for",
"e",
".",
"process",
"(",
"ctx",
",",
"ch",
")",
"{",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"// Block until the target provider is explicitly canceled.",
"<-",
"ctx",
".",
"Done",
"(",
")",
"\n",
"}"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.