id
int32 0
25.3k
| idx
stringlengths 5
9
| nl_tokens
sequencelengths 1
418
| pl_tokens
sequencelengths 22
4.98k
|
---|---|---|---|
10,600 | all-10601 | [
"GetImageFile",
"downloads",
"an",
"image",
"from",
"the",
"server",
"returning",
"an",
"ImageFileResponse",
"struct"
] | [
"func",
"(",
"r",
"*",
"ProtocolSimpleStreams",
")",
"GetImageFile",
"(",
"fingerprint",
"string",
",",
"req",
"ImageFileRequest",
")",
"(",
"*",
"ImageFileResponse",
",",
"error",
")",
"{",
"// Sanity checks",
"if",
"req",
".",
"MetaFile",
"==",
"nil",
"&&",
"req",
".",
"RootfsFile",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Attempt to download from host",
"if",
"shared",
".",
"PathExists",
"(",
"\"",
"\"",
")",
"&&",
"<mask>",
".",
"Geteuid",
"(",
")",
"==",
"0",
"{",
"unixURI",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"url",
".",
"QueryEscape",
"(",
"fingerprint",
")",
")",
"\n\n",
"// Setup the HTTP client",
"devlxdHTTP",
",",
"err",
":=",
"unixHTTPClient",
"(",
"nil",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"resp",
",",
"err",
":=",
"lxdDownloadImage",
"(",
"fingerprint",
",",
"unixURI",
",",
"r",
".",
"httpUserAgent",
",",
"devlxdHTTP",
",",
"req",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"resp",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Get the file list",
"files",
",",
"err",
":=",
"r",
".",
"ssClient",
".",
"GetFiles",
"(",
"fingerprint",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Prepare the response",
"resp",
":=",
"ImageFileResponse",
"{",
"}",
"\n\n",
"// Download function",
"download",
":=",
"func",
"(",
"path",
"string",
",",
"filename",
"string",
",",
"hash",
"string",
",",
"target",
"io",
".",
"WriteSeeker",
")",
"(",
"int64",
",",
"error",
")",
"{",
"// Try over http",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"strings",
".",
"TrimPrefix",
"(",
"r",
".",
"httpHost",
",",
"\"",
"\"",
")",
",",
"path",
")",
"\n\n",
"size",
",",
"err",
":=",
"shared",
".",
"DownloadFileHash",
"(",
"r",
".",
"http",
",",
"r",
".",
"httpUserAgent",
",",
"req",
".",
"ProgressHandler",
",",
"req",
".",
"Canceler",
",",
"filename",
",",
"url",
",",
"hash",
",",
"sha256",
".",
"New",
"(",
")",
",",
"target",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// Handle cancelation",
"if",
"err",
".",
"Error",
"(",
")",
"==",
"\"",
"\"",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n\n",
"// Try over https",
"url",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r",
".",
"httpHost",
",",
"path",
")",
"\n",
"size",
",",
"err",
"=",
"shared",
".",
"DownloadFileHash",
"(",
"r",
".",
"http",
",",
"r",
".",
"httpUserAgent",
",",
"req",
".",
"ProgressHandler",
",",
"req",
".",
"Canceler",
",",
"filename",
",",
"url",
",",
"hash",
",",
"sha256",
".",
"New",
"(",
")",
",",
"target",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"size",
",",
"nil",
"\n",
"}",
"\n\n",
"// Download the LXD image file",
"meta",
",",
"ok",
":=",
"files",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"ok",
"&&",
"req",
".",
"MetaFile",
"!=",
"nil",
"{",
"size",
",",
"err",
":=",
"download",
"(",
"meta",
".",
"Path",
",",
"\"",
"\"",
",",
"meta",
".",
"Sha256",
",",
"req",
".",
"MetaFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"parts",
":=",
"strings",
".",
"Split",
"(",
"meta",
".",
"Path",
",",
"\"",
"\"",
")",
"\n",
"resp",
".",
"MetaName",
"=",
"parts",
"[",
"len",
"(",
"parts",
")",
"-",
"1",
"]",
"\n",
"resp",
".",
"MetaSize",
"=",
"size",
"\n",
"}",
"\n\n",
"// Download the rootfs",
"rootfs",
",",
"ok",
":=",
"files",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"ok",
"&&",
"req",
".",
"RootfsFile",
"!=",
"nil",
"{",
"// Look for deltas (requires xdelta3)",
"downloaded",
":=",
"false",
"\n",
"_",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"==",
"nil",
"&&",
"req",
".",
"DeltaSourceRetriever",
"!=",
"nil",
"{",
"for",
"filename",
",",
"file",
":=",
"range",
"files",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"filename",
",",
"\"",
"\"",
")",
"{",
"continue",
"\n",
"}",
"\n\n",
"// Check if we have the source file for the delta",
"srcFingerprint",
":=",
"strings",
".",
"Split",
"(",
"filename",
",",
"\"",
"\"",
")",
"[",
"1",
"]",
"\n",
"srcPath",
":=",
"req",
".",
"DeltaSourceRetriever",
"(",
"srcFingerprint",
",",
"\"",
"\"",
")",
"\n",
"if",
"srcPath",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n\n",
"// Create temporary file for the delta",
"deltaFile",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"deltaFile",
".",
"Close",
"(",
")",
"\n",
"defer",
"os",
".",
"Remove",
"(",
"deltaFile",
".",
"Name",
"(",
")",
")",
"\n\n",
"// Download the delta",
"_",
",",
"err",
"=",
"download",
"(",
"file",
".",
"Path",
",",
"\"",
"\"",
",",
"file",
".",
"Sha256",
",",
"deltaFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Create temporary file for the delta",
"patchedFile",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"patchedFile",
".",
"Close",
"(",
")",
"\n",
"defer",
"os",
".",
"Remove",
"(",
"patchedFile",
".",
"Name",
"(",
")",
")",
"\n\n",
"// Apply it",
"_",
",",
"err",
"=",
"shared",
".",
"RunCommand",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"srcPath",
",",
"deltaFile",
".",
"Name",
"(",
")",
",",
"patchedFile",
".",
"Name",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Copy to the target",
"size",
",",
"err",
":=",
"io",
".",
"Copy",
"(",
"req",
".",
"RootfsFile",
",",
"patchedFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"parts",
":=",
"strings",
".",
"Split",
"(",
"rootfs",
".",
"Path",
",",
"\"",
"\"",
")",
"\n",
"resp",
".",
"RootfsName",
"=",
"parts",
"[",
"len",
"(",
"parts",
")",
"-",
"1",
"]",
"\n",
"resp",
".",
"RootfsSize",
"=",
"size",
"\n",
"downloaded",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Download the whole file",
"if",
"!",
"downloaded",
"{",
"size",
",",
"err",
":=",
"download",
"(",
"rootfs",
".",
"Path",
",",
"\"",
"\"",
",",
"rootfs",
".",
"Sha256",
",",
"req",
".",
"RootfsFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"parts",
":=",
"strings",
".",
"Split",
"(",
"rootfs",
".",
"Path",
",",
"\"",
"\"",
")",
"\n",
"resp",
".",
"RootfsName",
"=",
"parts",
"[",
"len",
"(",
"parts",
")",
"-",
"1",
"]",
"\n",
"resp",
".",
"RootfsSize",
"=",
"size",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"&",
"resp",
",",
"nil",
"\n",
"}"
] |
10,601 | all-10602 | [
"NewASMSecretResource",
"creates",
"a",
"new",
"ASMSecretResource",
"object"
] | [
"func",
"NewASMSecretResource",
"(",
"taskARN",
"string",
",",
"asmSecrets",
"map",
"[",
"string",
"]",
"apicontainer",
".",
"Secret",
",",
"executionCredentialsID",
"string",
",",
"credentialsManager",
"credentials",
".",
"<mask>",
",",
"asmClientCreator",
"factory",
".",
"ClientCreator",
")",
"*",
"ASMSecretResource",
"{",
"s",
":=",
"&",
"ASMSecretResource",
"{",
"taskARN",
":",
"taskARN",
",",
"requiredSecrets",
":",
"asmSecrets",
",",
"credentialsManager",
":",
"credentialsManager",
",",
"executionCredentialsID",
":",
"executionCredentialsID",
",",
"asmClientCreator",
":",
"asmClientCreator",
",",
"}",
"\n\n",
"s",
".",
"initStatusToTransition",
"(",
")",
"\n",
"return",
"s",
"\n",
"}"
] |
10,602 | all-10603 | [
"WithContentColor",
"the",
"content",
"box",
"highlight",
"fill",
"color",
"(",
"default",
":",
"transparent",
")",
"."
] | [
"func",
"(",
"p",
"HighlightFrameParams",
")",
"WithContentColor",
"(",
"contentColor",
"*",
"cdp",
".",
"RGBA",
")",
"*",
"HighlightFrameParams",
"{",
"p",
".",
"ContentColor",
"=",
"contentColor",
"\n",
"<mask>",
"&",
"p",
"\n",
"}"
] |
10,603 | all-10604 | [
"Load",
"reads",
"in",
"a",
"Mapnik",
"map",
"XML",
"."
] | [
"func",
"(",
"m",
"*",
"Map",
")",
"Load",
"(",
"stylesheet",
"string",
")",
"error",
"{",
"<mask>",
":=",
"C",
".",
"CString",
"(",
"stylesheet",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cs",
")",
")",
"\n",
"if",
"C",
".",
"mapnik_map_load",
"(",
"m",
".",
"m",
",",
"cs",
")",
"!=",
"0",
"{",
"return",
"m",
".",
"lastError",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,604 | all-10605 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"SetPageScaleFactorParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoEmulation6",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
10,605 | all-10606 | [
"Set",
"updates",
"the",
"namespaces"
] | [
"func",
"(",
"n",
"*",
"ns",
")",
"<mask>",
"(",
"namespaces",
"[",
"]",
"string",
")",
"{",
"n",
".",
"Lock",
"(",
")",
"\n",
"defer",
"n",
".",
"Unlock",
"(",
")",
"\n",
"n",
".",
"namespaces",
"=",
"namespaces",
"\n",
"}"
] |
10,606 | all-10607 | [
"UpdateConfig",
"updates",
"the",
"given",
"LXD",
"cluster",
"configuration",
"keys",
"in",
"the",
"config",
"table",
".",
"Config",
"keys",
"set",
"to",
"empty",
"values",
"will",
"be",
"deleted",
"."
] | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"UpdateConfig",
"(",
"<mask>",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"return",
"query",
".",
"UpdateConfig",
"(",
"c",
".",
"tx",
",",
"\"",
"\"",
",",
"values",
")",
"\n",
"}"
] |
10,607 | all-10608 | [
"List",
"lists",
"all",
"Apps",
"in",
"the",
"indexer",
"for",
"a",
"given",
"namespace",
"."
] | [
"func",
"(",
"s",
"appNamespaceLister",
")",
"List",
"(",
"selector",
"labels",
".",
"Selector",
")",
"(",
"ret",
"[",
"]",
"*",
"v1",
".",
"App",
",",
"err",
"error",
")",
"{",
"err",
"=",
"cache",
".",
"ListAllByNamespace",
"(",
"s",
".",
"indexer",
",",
"s",
".",
"namespace",
",",
"selector",
",",
"func",
"(",
"m",
"interface",
"{",
"}",
")",
"{",
"<mask>",
"=",
"append",
"(",
"ret",
",",
"m",
".",
"(",
"*",
"v1",
".",
"App",
")",
")",
"\n",
"}",
")",
"\n",
"return",
"ret",
",",
"err",
"\n",
"}"
] |
10,608 | all-10609 | [
"Collection",
"returns",
"a",
"collection",
"by",
"its",
"name",
".",
"If",
"the",
"collection",
"does",
"not",
"exist",
"MongoDB",
"will",
"create",
"it",
"."
] | [
"func",
"(",
"s",
"*",
"Storage",
")",
"Collection",
"(",
"name",
"string",
")",
"*",
"Collection",
"{",
"return",
"&",
"Collection",
"{",
"Collection",
":",
"s",
".",
"<mask>",
".",
"DB",
"(",
"s",
".",
"dbname",
")",
".",
"C",
"(",
"name",
")",
"}",
"\n",
"}"
] |
10,609 | all-10610 | [
"NewBufferedStream",
"creates",
"a",
"buffered",
"stream",
"from",
"a",
"network",
"connection",
"(",
"or",
"other",
"similar",
"interface",
")",
".",
"The",
"underlying",
"objectStream",
"is",
"used",
"to",
"produce",
"the",
"bytes",
"to",
"write",
"to",
"the",
"stream",
"for",
"the",
"JSON",
"-",
"RPC",
"2",
".",
"0",
"objects",
"."
] | [
"func",
"NewBufferedStream",
"(",
"conn",
"io",
".",
"ReadWriteCloser",
",",
"codec",
"ObjectCodec",
")",
"ObjectStream",
"{",
"return",
"&",
"bufferedObjectStream",
"{",
"<mask>",
":",
"conn",
",",
"w",
":",
"bufio",
".",
"NewWriter",
"(",
"conn",
")",
",",
"r",
":",
"bufio",
".",
"NewReader",
"(",
"conn",
")",
",",
"codec",
":",
"codec",
",",
"}",
"\n",
"}"
] |
10,610 | all-10611 | [
"GetKnownPortBindings",
"gets",
"the",
"ports",
"for",
"a",
"container"
] | [
"func",
"(",
"c",
"*",
"Container",
")",
"GetKnownPortBindings",
"(",
")",
"[",
"]",
"PortBinding",
"{",
"c",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"<mask>",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"c",
".",
"KnownPortBindingsUnsafe",
"\n",
"}"
] |
10,611 | all-10612 | [
"Calculates",
"the",
"per",
"-",
"element",
"bit",
"-",
"wise",
"disjunction",
"of",
"an",
"array",
"and",
"a",
"scalar",
"with",
"a",
"mask",
"."
] | [
"func",
"OrScalarWithMask",
"(",
"src",
"*",
"IplImage",
",",
"value",
"Scalar",
",",
"dst",
",",
"mask",
"*",
"IplImage",
")",
"{",
"C",
".",
"cvOrS",
"(",
"unsafe",
".",
"Pointer",
"(",
"src",
")",
",",
"(",
"C",
".",
"CvScalar",
")",
"(",
"value",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"dst",
")",
",",
"unsafe",
".",
"Pointer",
"(",
"<mask>",
")",
",",
")",
"\n",
"}"
] |
10,612 | all-10613 | [
"ShareScreenboard",
"shares",
"an",
"existing",
"screenboard",
"it",
"takes",
"and",
"updates",
"ScreenShareResponse"
] | [
"func",
"(",
"client",
"*",
"Client",
")",
"ShareScreenboard",
"(",
"id",
"int",
",",
"<mask>",
"*",
"ScreenShareResponse",
")",
"error",
"{",
"return",
"client",
".",
"doJsonRequest",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"id",
")",
",",
"nil",
",",
"response",
")",
"\n",
"}"
] |
10,613 | all-10614 | [
"ContentCharset",
"generates",
"a",
"handler",
"that",
"writes",
"a",
"415",
"Unsupported",
"Media",
"Type",
"response",
"if",
"none",
"of",
"the",
"charsets",
"match",
".",
"An",
"empty",
"charset",
"will",
"allow",
"requests",
"with",
"no",
"Content",
"-",
"Type",
"header",
"or",
"no",
"specified",
"charset",
"."
] | [
"func",
"ContentCharset",
"(",
"charsets",
"...",
"string",
")",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"for",
"i",
",",
"c",
":=",
"range",
"charsets",
"{",
"charsets",
"[",
"i",
"]",
"=",
"strings",
".",
"ToLower",
"(",
"c",
")",
"\n",
"}",
"\n\n",
"return",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"<mask>",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"!",
"contentEncoding",
"(",
"r",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
",",
"charsets",
"...",
")",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusUnsupportedMediaType",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"next",
".",
"ServeHTTP",
"(",
"w",
",",
"r",
")",
"\n",
"}",
")",
"\n",
"}",
"\n",
"}"
] |
10,614 | all-10615 | [
"Do",
"executes",
"IndexedDB",
".",
"deleteObjectStoreEntries",
"against",
"the",
"provided",
"context",
"."
] | [
"func",
"(",
"p",
"*",
"DeleteObjectStoreEntriesParams",
")",
"Do",
"(",
"ctx",
"<mask>",
".",
"Context",
")",
"(",
"err",
"error",
")",
"{",
"return",
"cdp",
".",
"Execute",
"(",
"ctx",
",",
"CommandDeleteObjectStoreEntries",
",",
"p",
",",
"nil",
")",
"\n",
"}"
] |
10,615 | all-10616 | [
"getBuffer",
"returns",
"a",
"new",
"ready",
"-",
"to",
"-",
"use",
"buffer",
"."
] | [
"func",
"(",
"l",
"*",
"Log",
")",
"getBuffer",
"(",
")",
"*",
"<mask>",
"{",
"l",
".",
"freeListMu",
".",
"Lock",
"(",
")",
"\n",
"b",
":=",
"l",
".",
"freeList",
"\n",
"if",
"b",
"!=",
"nil",
"{",
"l",
".",
"freeList",
"=",
"b",
".",
"next",
"\n",
"}",
"\n",
"l",
".",
"freeListMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"b",
"==",
"nil",
"{",
"b",
"=",
"new",
"(",
"buffer",
")",
"\n",
"}",
"else",
"{",
"b",
".",
"next",
"=",
"nil",
"\n",
"b",
".",
"Reset",
"(",
")",
"\n",
"}",
"\n",
"return",
"b",
"\n",
"}"
] |
10,616 | all-10617 | [
"Load",
"loads",
"and",
"returns",
"an",
"HTML",
"template",
".",
"Each",
"Ace",
"templates",
"are",
"parsed",
"only",
"once",
"and",
"cached",
"if",
"the",
"DynamicReload",
"option",
"are",
"not",
"set",
"."
] | [
"func",
"Load",
"(",
"basePath",
",",
"innerPath",
"string",
",",
"opts",
"*",
"Options",
")",
"(",
"*",
"template",
".",
"Template",
",",
"error",
")",
"{",
"// Initialize the options.",
"opts",
"=",
"InitializeOptions",
"(",
"opts",
")",
"\n\n",
"name",
":=",
"basePath",
"+",
"colon",
"+",
"innerPath",
"\n\n",
"if",
"!",
"opts",
".",
"DynamicReload",
"{",
"if",
"tpl",
",",
"ok",
":=",
"getCache",
"(",
"name",
")",
";",
"ok",
"{",
"return",
"&",
"tpl",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Read files.",
"src",
",",
"err",
":=",
"readFiles",
"(",
"basePath",
",",
"innerPath",
",",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Parse the source.",
"rslt",
",",
"err",
":=",
"ParseSource",
"(",
"src",
",",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// Compile the parsed result.",
"tpl",
",",
"err",
":=",
"CompileResult",
"(",
"<mask>",
",",
"rslt",
",",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"!",
"opts",
".",
"DynamicReload",
"{",
"setCache",
"(",
"name",
",",
"*",
"tpl",
")",
"\n",
"}",
"\n\n",
"return",
"tpl",
",",
"nil",
"\n",
"}"
] |
10,617 | all-10618 | [
"logError",
"logs",
"an",
"error",
"message",
"and",
"then",
"returns",
"the",
"given",
"status",
"."
] | [
"func",
"logError",
"(",
"err",
"error",
",",
"<mask>",
"int",
")",
"int",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"status",
"\n",
"}"
] |
10,618 | all-10619 | [
"New",
"ServerError",
".",
"New"
] | [
"func",
"(",
"e",
"*",
"ServerError",
")",
"New",
"(",
"message",
"string",
")",
"*",
"ServerError",
"{",
"e",
".",
"HTTPCode",
"=",
"<mask>",
".",
"StatusInternalServerError",
"\n",
"e",
".",
"Errno",
"=",
"0",
"\n",
"e",
".",
"Message",
"=",
"message",
"\n",
"return",
"e",
"\n",
"}"
] |
10,619 | all-10620 | [
"ProfilesExpandDevices",
"expands",
"the",
"given",
"container",
"devices",
"with",
"the",
"devices",
"defined",
"in",
"the",
"given",
"profiles",
"."
] | [
"func",
"ProfilesExpandDevices",
"(",
"devices",
"<mask>",
".",
"Devices",
",",
"profiles",
"[",
"]",
"api",
".",
"Profile",
")",
"types",
".",
"Devices",
"{",
"expandedDevices",
":=",
"types",
".",
"Devices",
"{",
"}",
"\n\n",
"// Apply all the profiles",
"profileDevices",
":=",
"make",
"(",
"[",
"]",
"types",
".",
"Devices",
",",
"len",
"(",
"profiles",
")",
")",
"\n",
"for",
"i",
",",
"profile",
":=",
"range",
"profiles",
"{",
"profileDevices",
"[",
"i",
"]",
"=",
"profile",
".",
"Devices",
"\n",
"}",
"\n",
"for",
"i",
":=",
"range",
"profileDevices",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"profileDevices",
"[",
"i",
"]",
"{",
"expandedDevices",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Stick the given devices on top",
"for",
"k",
",",
"v",
":=",
"range",
"devices",
"{",
"expandedDevices",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n\n",
"return",
"expandedDevices",
"\n",
"}"
] |
10,620 | all-10621 | [
"BoundingBox",
"returns",
"the",
"region",
"encoded",
"by",
"the",
"given",
"string",
"geohash",
"."
] | [
"func",
"BoundingBox",
"(",
"hash",
"string",
")",
"Box",
"{",
"bits",
":=",
"uint",
"(",
"5",
"*",
"len",
"(",
"<mask>",
")",
")",
"\n",
"inthash",
":=",
"base32encoding",
".",
"Decode",
"(",
"hash",
")",
"\n",
"return",
"BoundingBoxIntWithPrecision",
"(",
"inthash",
",",
"bits",
")",
"\n",
"}"
] |
10,621 | all-10622 | [
"osDiskStorageBlobURL",
"gives",
"the",
"full",
"url",
"of",
"the",
"VHD",
"blob",
"where",
"the",
"OS",
"disk",
"for",
"the",
"given",
"VM",
"should",
"be",
"stored",
"."
] | [
"func",
"osDiskStorageBlobURL",
"(",
"account",
"*",
"storage",
".",
"AccountProperties",
",",
"vmName",
"string",
")",
"string",
"{",
"containerURL",
":=",
"osDiskStorageContainerURL",
"(",
"<mask>",
",",
"vmName",
")",
"// has trailing slash",
"\n",
"blobName",
":=",
"fmt",
".",
"Sprintf",
"(",
"fmtOSDiskBlobName",
",",
"vmName",
")",
"\n",
"return",
"containerURL",
"+",
"blobName",
"\n",
"}"
] |
10,622 | all-10623 | [
"mustInt64",
"panics",
"if",
"val",
"isn",
"t",
"an",
"int",
"or",
"int64",
".",
"It",
"returns",
"an",
"int64",
"otherwise",
"."
] | [
"func",
"mustInt64",
"(",
"val",
"interface",
"{",
"}",
")",
"int64",
"{",
"if",
"v",
",",
"ok",
":=",
"val",
".",
"(",
"int64",
")",
";",
"ok",
"{",
"return",
"v",
"\n",
"}",
"\n",
"if",
"v",
",",
"ok",
":=",
"val",
".",
"(",
"int",
")",
";",
"<mask>",
"{",
"return",
"int64",
"(",
"v",
")",
"\n",
"}",
"\n",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
10,623 | all-10624 | [
"respCode",
"maps",
"any",
"successful",
"request",
"with",
"a",
"specific",
"status",
"code",
"or",
"returns",
"200",
"."
] | [
"func",
"(",
"s",
"*",
"Server",
")",
"respCode",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"int",
"{",
"if",
"r",
".",
"URL",
".",
"<mask>",
"==",
"\"",
"\"",
"&&",
"r",
".",
"Method",
"==",
"\"",
"\"",
"{",
"return",
"http",
".",
"StatusCreated",
"\n",
"}",
"\n",
"return",
"http",
".",
"StatusOK",
"\n",
"}"
] |
10,624 | all-10625 | [
"UpdateMonitor",
"takes",
"a",
"monitor",
"that",
"was",
"previously",
"retrieved",
"through",
"some",
"method",
"and",
"sends",
"it",
"back",
"to",
"the",
"server"
] | [
"func",
"(",
"client",
"*",
"Client",
")",
"UpdateMonitor",
"(",
"monitor",
"*",
"Monitor",
")",
"error",
"{",
"return",
"client",
".",
"doJsonRequest",
"(",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"*",
"monitor",
".",
"<mask>",
")",
",",
"monitor",
",",
"nil",
")",
"\n",
"}"
] |
10,625 | all-10626 | [
"HasUnit",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"a",
"*",
"AlertValueDefinition",
")",
"HasUnit",
"(",
")",
"bool",
"{",
"if",
"a",
"!=",
"nil",
"&&",
"a",
".",
"Unit",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
10,626 | all-10627 | [
"UnmarshalXML",
"unmarshal",
"SOAPBody"
] | [
"func",
"(",
"b",
"*",
"Body",
")",
"UnmarshalXML",
"(",
"d",
"*",
"xml",
".",
"Decoder",
",",
"start",
"xml",
".",
"StartElement",
")",
"error",
"{",
"if",
"b",
".",
"Content",
"==",
"nil",
"{",
"return",
"xml",
".",
"UnmarshalError",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"var",
"(",
"token",
"xml",
".",
"Token",
"\n",
"err",
"error",
"\n",
"consumed",
"bool",
"\n",
")",
"\n",
"Loop",
":",
"for",
"{",
"if",
"token",
",",
"err",
"=",
"d",
".",
"Token",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"token",
"==",
"nil",
"{",
"<mask>",
"\n",
"}",
"\n",
"envelopeNameSpace",
":=",
"\"",
"\"",
"\n",
"switch",
"se",
":=",
"token",
".",
"(",
"type",
")",
"{",
"case",
"xml",
".",
"StartElement",
":",
"if",
"consumed",
"{",
"return",
"xml",
".",
"UnmarshalError",
"(",
"\"",
"\"",
")",
"\n",
"}",
"else",
"if",
"se",
".",
"Name",
".",
"Space",
"==",
"envelopeNameSpace",
"&&",
"se",
".",
"Name",
".",
"Local",
"==",
"\"",
"\"",
"{",
"b",
".",
"Fault",
"=",
"&",
"Fault",
"{",
"}",
"\n",
"b",
".",
"Content",
"=",
"nil",
"\n",
"err",
"=",
"d",
".",
"DecodeElement",
"(",
"b",
".",
"Fault",
",",
"&",
"se",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"consumed",
"=",
"true",
"\n",
"}",
"else",
"{",
"if",
"err",
"=",
"d",
".",
"DecodeElement",
"(",
"b",
".",
"Content",
",",
"&",
"se",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"consumed",
"=",
"true",
"\n",
"}",
"\n",
"case",
"xml",
".",
"EndElement",
":",
"break",
"Loop",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,627 | all-10628 | [
"Raw",
"private",
"key",
"bytes",
"."
] | [
"func",
"(",
"k",
"*",
"Ed25519PrivateKey",
")",
"Raw",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// The Ed25519 private key contains two 32-bytes curve points, the private",
"// key and the public key.",
"// It makes it more efficient to get the public key without re-computing an",
"// elliptic curve multiplication.",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"k",
".",
"k",
")",
")",
"\n",
"<mask>",
"(",
"buf",
",",
"k",
".",
"k",
")",
"\n\n",
"return",
"buf",
",",
"nil",
"\n",
"}"
] |
10,628 | all-10629 | [
"NewHealthServiceQuery",
"processes",
"the",
"strings",
"to",
"build",
"a",
"service",
"dependency",
"."
] | [
"func",
"NewHealthServiceQuery",
"(",
"s",
"string",
")",
"(",
"*",
"HealthServiceQuery",
",",
"error",
")",
"{",
"if",
"!",
"HealthServiceQueryRe",
".",
"MatchString",
"(",
"s",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"s",
")",
"\n",
"}",
"\n\n",
"m",
":=",
"regexpMatch",
"(",
"HealthServiceQueryRe",
",",
"s",
")",
"\n\n",
"var",
"filters",
"[",
"]",
"string",
"\n",
"if",
"<mask>",
":=",
"m",
"[",
"\"",
"\"",
"]",
";",
"filter",
"!=",
"\"",
"\"",
"{",
"split",
":=",
"strings",
".",
"Split",
"(",
"filter",
",",
"\"",
"\"",
")",
"\n",
"for",
"_",
",",
"f",
":=",
"range",
"split",
"{",
"f",
"=",
"strings",
".",
"TrimSpace",
"(",
"f",
")",
"\n",
"switch",
"f",
"{",
"case",
"HealthAny",
",",
"HealthPassing",
",",
"HealthWarning",
",",
"HealthCritical",
",",
"HealthMaint",
":",
"filters",
"=",
"append",
"(",
"filters",
",",
"f",
")",
"\n",
"case",
"\"",
"\"",
":",
"default",
":",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"f",
",",
"s",
")",
"\n",
"}",
"\n",
"}",
"\n",
"sort",
".",
"Strings",
"(",
"filters",
")",
"\n",
"}",
"else",
"{",
"filters",
"=",
"[",
"]",
"string",
"{",
"HealthPassing",
"}",
"\n",
"}",
"\n\n",
"return",
"&",
"HealthServiceQuery",
"{",
"stopCh",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
",",
"1",
")",
",",
"dc",
":",
"m",
"[",
"\"",
"\"",
"]",
",",
"filters",
":",
"filters",
",",
"name",
":",
"m",
"[",
"\"",
"\"",
"]",
",",
"near",
":",
"m",
"[",
"\"",
"\"",
"]",
",",
"tag",
":",
"m",
"[",
"\"",
"\"",
"]",
",",
"}",
",",
"nil",
"\n",
"}"
] |
10,629 | all-10630 | [
"BasePropertiesFromReference",
"combines",
"BaseFromReference",
"and",
"BaseProperties",
"to",
"get",
"a",
"base",
"-",
"level",
"ComputeResource",
"managed",
"object",
"for",
"a",
"specific",
"managed",
"object",
"reference",
"."
] | [
"func",
"BasePropertiesFromReference",
"(",
"client",
"*",
"govmomi",
".",
"Client",
",",
"ref",
"types",
".",
"ManagedObjectReference",
")",
"(",
"*",
"mo",
".",
"ComputeResource",
",",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"BaseFromReference",
"(",
"<mask>",
",",
"ref",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"BaseProperties",
"(",
"obj",
")",
"\n",
"}"
] |
10,630 | all-10631 | [
"createConnection",
"creates",
"a",
"new",
"connection",
"originating",
"from",
"localAddr",
"to",
"peerAddr",
".",
"If",
"acceptNewPeer",
"is",
"false",
"peerAddr",
"must",
"already",
"be",
"a",
"member",
"of",
"the",
"mesh",
"."
] | [
"func",
"(",
"peer",
"*",
"localPeer",
")",
"createConnection",
"(",
"localAddr",
"string",
",",
"peerAddr",
"string",
",",
"acceptNewPeer",
"bool",
",",
"logger",
"Logger",
")",
"error",
"{",
"if",
"err",
":=",
"peer",
".",
"checkConnectionLimit",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"localTCPAddr",
",",
"err",
":=",
"net",
".",
"ResolveTCPAddr",
"(",
"\"",
"\"",
",",
"localAddr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"remoteTCPAddr",
",",
"err",
":=",
"<mask>",
".",
"ResolveTCPAddr",
"(",
"\"",
"\"",
",",
"peerAddr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"tcpConn",
",",
"err",
":=",
"net",
".",
"DialTCP",
"(",
"\"",
"\"",
",",
"localTCPAddr",
",",
"remoteTCPAddr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"connRemote",
":=",
"newRemoteConnection",
"(",
"peer",
".",
"Peer",
",",
"nil",
",",
"peerAddr",
",",
"true",
",",
"false",
")",
"\n",
"startLocalConnection",
"(",
"connRemote",
",",
"tcpConn",
",",
"peer",
".",
"router",
",",
"acceptNewPeer",
",",
"logger",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,631 | all-10632 | [
"listenGRPC",
"starts",
"a",
"grpc",
"server",
"over",
"a",
"unix",
"domain",
"socket",
"on",
"the",
"member"
] | [
"func",
"(",
"m",
"*",
"member",
")",
"listenGRPC",
"(",
")",
"error",
"{",
"// prefix with localhost so cert has right domain",
"m",
".",
"grpcAddr",
"=",
"\"",
"\"",
"+",
"m",
".",
"<mask>",
"\n",
"if",
"m",
".",
"useIP",
"{",
"// for IP-only TLS certs",
"m",
".",
"grpcAddr",
"=",
"\"",
"\"",
"+",
"m",
".",
"Name",
"\n",
"}",
"\n",
"l",
",",
"err",
":=",
"transport",
".",
"NewUnixListener",
"(",
"m",
".",
"grpcAddr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
".",
"grpcAddr",
",",
"err",
")",
"\n",
"}",
"\n",
"m",
".",
"grpcBridge",
",",
"err",
"=",
"newBridge",
"(",
"m",
".",
"grpcAddr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"l",
".",
"Close",
"(",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"m",
".",
"grpcAddr",
"=",
"schemeFromTLSInfo",
"(",
"m",
".",
"ClientTLSInfo",
")",
"+",
"\"",
"\"",
"+",
"m",
".",
"grpcBridge",
".",
"inaddr",
"\n",
"m",
".",
"grpcListener",
"=",
"l",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,632 | all-10633 | [
"Add",
"assigns",
"the",
"name",
"to",
"the",
"template"
] | [
"func",
"(",
"r",
"*",
"Render",
")",
"Add",
"(",
"name",
"string",
",",
"tmpl",
"*",
"<mask>",
".",
"Template",
")",
"{",
"if",
"tmpl",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"name",
")",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"r",
".",
"Templates",
"[",
"name",
"]",
"=",
"tmpl",
"\n",
"}"
] |
10,633 | all-10634 | [
"NewByteCode",
"creates",
"an",
"empty",
"ByteCode",
"instance",
"."
] | [
"func",
"NewByteCode",
"(",
")",
"*",
"ByteCode",
"{",
"return",
"&",
"ByteCode",
"{",
"GeneratedOn",
":",
"time",
".",
"Now",
"(",
")",
",",
"<mask>",
":",
"\"",
"\"",
",",
"OpList",
":",
"nil",
",",
"Version",
":",
"1.0",
",",
"}",
"\n",
"}"
] |
10,634 | all-10635 | [
"GetCreatedByOk",
"returns",
"a",
"tuple",
"with",
"the",
"CreatedBy",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"a",
"*",
"APIKey",
")",
"GetCreatedByOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"a",
"==",
"nil",
"||",
"a",
".",
"CreatedBy",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"a",
".",
"CreatedBy",
",",
"<mask>",
"\n",
"}"
] |
10,635 | all-10636 | [
"GetJob",
"returns",
"the",
"full",
"job",
"details",
"of",
"the",
"job",
"with",
"the",
"given",
"id",
"."
] | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetJob",
"(",
"id",
"string",
")",
"(",
"*",
"JobDetail",
",",
"error",
")",
"{",
"jobList",
":=",
"&",
"jobDetailList",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"<mask>",
"}",
",",
"nil",
",",
"jobList",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"jobList",
".",
"Jobs",
"[",
"0",
"]",
",",
"nil",
"\n",
"}"
] |
10,636 | all-10637 | [
"JoinAddress",
"formats",
"a",
"slice",
"of",
"Address",
"structs",
"such",
"that",
"they",
"can",
"be",
"used",
"in",
"a",
"To",
"or",
"Cc",
"header",
"."
] | [
"func",
"JoinAddress",
"(",
"addrs",
"[",
"]",
"mail",
".",
"Address",
")",
"string",
"{",
"if",
"len",
"(",
"addrs",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"for",
"i",
",",
"a",
":=",
"<mask>",
"addrs",
"{",
"if",
"i",
">",
"0",
"{",
"_",
",",
"_",
"=",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"_",
",",
"_",
"=",
"buf",
".",
"WriteString",
"(",
"a",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"buf",
".",
"String",
"(",
")",
"\n",
"}"
] |
10,637 | all-10638 | [
"CreateType",
"is",
"a",
"helper",
"method",
"that",
"creates",
"or",
"retrieve",
"a",
"object",
"data",
"type",
"given",
"its",
"attributes",
"."
] | [
"func",
"(",
"a",
"*",
"APIAnalyzer",
")",
"CreateType",
"(",
"query",
"string",
",",
"attributes",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"*",
"gen",
".",
"ObjectDataType",
",",
"error",
")",
"{",
"name",
":=",
"inflect",
".",
"Camelize",
"(",
"bracketRegexp",
".",
"ReplaceAllLiteralString",
"(",
"query",
",",
"\"",
"\"",
")",
"+",
"\"",
"\"",
")",
"\n",
"obj",
":=",
"a",
".",
"Registry",
".",
"CreateInlineType",
"(",
"<mask>",
")",
"\n",
"obj",
".",
"Fields",
"=",
"make",
"(",
"[",
"]",
"*",
"gen",
".",
"ActionParam",
",",
"len",
"(",
"attributes",
")",
")",
"\n",
"for",
"idx",
",",
"an",
":=",
"range",
"sortedKeys",
"(",
"attributes",
")",
"{",
"at",
":=",
"attributes",
"[",
"an",
"]",
"\n",
"var",
"childQ",
"string",
"\n",
"if",
"query",
"==",
"\"",
"\"",
"{",
"childQ",
"=",
"an",
"\n",
"}",
"else",
"{",
"childQ",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"query",
",",
"an",
")",
"\n",
"}",
"\n",
"att",
",",
"err",
":=",
"a",
".",
"AnalyzeAttribute",
"(",
"an",
",",
"childQ",
",",
"at",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"an",
",",
"err",
")",
"\n",
"}",
"\n",
"obj",
".",
"Fields",
"[",
"idx",
"]",
"=",
"att",
"\n",
"}",
"\n",
"return",
"obj",
",",
"nil",
"\n",
"}"
] |
10,638 | all-10639 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"PauseOnAsyncCallParams",
")",
"UnmarshalJSON",
"(",
"<mask>",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger29",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
10,639 | all-10640 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"ResolveAnimationParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoAnimation5",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"<mask>",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
10,640 | all-10641 | [
"--",
"Utils",
"post",
"sends",
"a",
"POST",
"request",
"with",
"the",
"given",
"request",
"body",
"to",
"PagerDuty",
".",
"See",
"this",
"URL",
"for",
"details",
"about",
"PagerDuty",
"API",
"response",
"codes",
"etc",
":",
"https",
":",
"//",
"developer",
".",
"pagerduty",
".",
"com",
"/",
"documentation",
"/",
"integration",
"/",
"events"
] | [
"func",
"post",
"(",
"reqBody",
"[",
"]",
"byte",
")",
"(",
"respBody",
"map",
"[",
"string",
"]",
"string",
",",
"err",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"<mask>",
".",
"Post",
"(",
"endpoint",
",",
"\"",
"\"",
",",
"bytes",
".",
"NewReader",
"(",
"reqBody",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"bodyBytes",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"resp",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"resp",
".",
"StatusCode",
"!=",
"http",
".",
"StatusOK",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"resp",
".",
"Status",
",",
"string",
"(",
"bodyBytes",
")",
")",
"\n",
"}",
"\n\n",
"respBody",
"=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"bodyBytes",
",",
"&",
"respBody",
")",
"\n",
"return",
"respBody",
",",
"err",
"\n",
"}"
] |
10,641 | all-10642 | [
"GetRegionOk",
"returns",
"a",
"tuple",
"with",
"the",
"Region",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"s",
"*",
"SyntheticsLocation",
")",
"GetRegionOk",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"Region",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"return",
"*",
"s",
".",
"Region",
",",
"<mask>",
"\n",
"}"
] |
10,642 | all-10643 | [
"invalidate",
"a",
"region",
"of",
"a",
"buffer",
"object",
"s",
"data",
"store"
] | [
"func",
"InvalidateBufferSubData",
"(",
"buffer",
"uint32",
",",
"offset",
"int",
",",
"length",
"int",
")",
"{",
"syscall",
".",
"Syscall",
"(",
"gpInvalidateBufferSubData",
",",
"3",
",",
"uintptr",
"(",
"buffer",
")",
",",
"uintptr",
"(",
"<mask>",
")",
",",
"uintptr",
"(",
"length",
")",
")",
"\n",
"}"
] |
10,643 | all-10644 | [
"WrapHTTPHandlerFunc",
"wraps",
"http",
".",
"HandlerFunc",
"in",
"possum",
".",
"HandlerFunc",
".",
"See",
"pprof",
".",
"go",
"."
] | [
"func",
"WrapHTTPHandlerFunc",
"(",
"f",
"http",
".",
"HandlerFunc",
")",
"HandlerFunc",
"{",
"newF",
":=",
"func",
"(",
"ctx",
"*",
"Context",
")",
"error",
"{",
"f",
"(",
"ctx",
".",
"<mask>",
",",
"ctx",
".",
"Request",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"newF",
"\n",
"}"
] |
10,644 | all-10645 | [
"SetValid",
"changes",
"this",
"String",
"s",
"value",
"and",
"also",
"sets",
"it",
"to",
"be",
"non",
"-",
"null",
"."
] | [
"func",
"(",
"s",
"*",
"<mask>",
")",
"SetValid",
"(",
"v",
"string",
")",
"{",
"s",
".",
"String",
"=",
"v",
"\n",
"s",
".",
"Valid",
"=",
"true",
"\n",
"}"
] |
10,645 | all-10646 | [
"clear",
"empties",
"the",
"cache",
"."
] | [
"func",
"(",
"<mask>",
"*",
"structTypeCache",
")",
"clear",
"(",
")",
"{",
"cache",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"for",
"typ",
":=",
"range",
"cache",
".",
"store",
"{",
"delete",
"(",
"cache",
".",
"store",
",",
"typ",
")",
"\n",
"}",
"\n",
"cache",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"}"
] |
10,646 | all-10647 | [
"UnbindApp",
"makes",
"the",
"unbind",
"between",
"the",
"service",
"instance",
"and",
"an",
"app",
"."
] | [
"func",
"(",
"si",
"*",
"ServiceInstance",
")",
"UnbindApp",
"(",
"unbindArgs",
"UnbindAppArgs",
")",
"error",
"{",
"if",
"si",
".",
"FindApp",
"(",
"unbindArgs",
".",
"App",
".",
"GetName",
"(",
")",
")",
"==",
"-",
"1",
"{",
"return",
"ErrAppNotBound",
"\n",
"}",
"\n",
"args",
":=",
"bindPipelineArgs",
"{",
"serviceInstance",
":",
"si",
",",
"app",
":",
"unbindArgs",
".",
"App",
",",
"<mask>",
":",
"unbindArgs",
".",
"Event",
",",
"shouldRestart",
":",
"unbindArgs",
".",
"Restart",
",",
"event",
":",
"unbindArgs",
".",
"Event",
",",
"requestID",
":",
"unbindArgs",
".",
"RequestID",
",",
"forceRemove",
":",
"unbindArgs",
".",
"ForceRemove",
",",
"}",
"\n",
"actions",
":=",
"[",
"]",
"*",
"action",
".",
"Action",
"{",
"&",
"unbindUnits",
",",
"&",
"unbindAppDB",
",",
"&",
"unbindAppEndpoint",
",",
"&",
"removeBoundEnvs",
",",
"}",
"\n",
"pipeline",
":=",
"action",
".",
"NewPipeline",
"(",
"actions",
"...",
")",
"\n",
"return",
"pipeline",
".",
"Execute",
"(",
"&",
"args",
")",
"\n",
"}"
] |
10,647 | all-10648 | [
"eliptic",
"curve",
"pubkey",
"addition"
] | [
"func",
"addPoints",
"(",
"a",
"[",
"]",
"byte",
",",
"b",
"[",
"]",
"<mask>",
")",
"[",
"]",
"byte",
"{",
"ap",
",",
"err",
":=",
"btcec",
".",
"ParsePubKey",
"(",
"a",
",",
"btcec",
".",
"S256",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"bp",
",",
"err",
":=",
"btcec",
".",
"ParsePubKey",
"(",
"b",
",",
"btcec",
".",
"S256",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"sumX",
",",
"sumY",
":=",
"btcec",
".",
"S256",
"(",
")",
".",
"Add",
"(",
"ap",
".",
"X",
",",
"ap",
".",
"Y",
",",
"bp",
".",
"X",
",",
"bp",
".",
"Y",
")",
"\n",
"sum",
":=",
"&",
"btcec",
".",
"PublicKey",
"{",
"Curve",
":",
"btcec",
".",
"S256",
"(",
")",
",",
"X",
":",
"sumX",
",",
"Y",
":",
"sumY",
",",
"}",
"\n",
"return",
"sum",
".",
"SerializeCompressed",
"(",
")",
"\n",
"}"
] |
10,648 | all-10649 | [
"PickPeerURL",
"chooses",
"a",
"random",
"address",
"from",
"a",
"given",
"Member",
"s",
"PeerURLs",
".",
"It",
"will",
"panic",
"if",
"there",
"is",
"no",
"PeerURLs",
"available",
"in",
"Member",
"."
] | [
"func",
"(",
"m",
"*",
"Member",
")",
"PickPeerURL",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"m",
".",
"PeerURLs",
")",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"m",
".",
"PeerURLs",
"[",
"<mask>",
".",
"Intn",
"(",
"len",
"(",
"m",
".",
"PeerURLs",
")",
")",
"]",
"\n",
"}"
] |
10,649 | all-10650 | [
"MutateAllowTrust",
"for",
"Trustor",
"sets",
"the",
"AllowTrustOp",
"s",
"Trustor",
"field"
] | [
"func",
"(",
"m",
"Trustor",
")",
"MutateAllowTrust",
"(",
"o",
"*",
"xdr",
".",
"AllowTrustOp",
")",
"error",
"{",
"return",
"setAccountId",
"(",
"m",
".",
"<mask>",
",",
"&",
"o",
".",
"Trustor",
")",
"\n",
"}"
] |
10,650 | all-10651 | [
"Specify",
"the",
"value",
"of",
"a",
"uniform",
"variable",
"for",
"the",
"current",
"program",
"object"
] | [
"func",
"UniformMatrix4x2fv",
"(",
"location",
"int32",
",",
"count",
"int32",
",",
"transpose",
"bool",
",",
"<mask>",
"*",
"float32",
")",
"{",
"C",
".",
"glowUniformMatrix4x2fv",
"(",
"gpUniformMatrix4x2fv",
",",
"(",
"C",
".",
"GLint",
")",
"(",
"location",
")",
",",
"(",
"C",
".",
"GLsizei",
")",
"(",
"count",
")",
",",
"(",
"C",
".",
"GLboolean",
")",
"(",
"boolToInt",
"(",
"transpose",
")",
")",
",",
"(",
"*",
"C",
".",
"GLfloat",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"value",
")",
")",
")",
"\n",
"}"
] |
10,651 | all-10652 | [
"go",
"client",
"for",
"performance",
"testing"
] | [
"func",
"main",
"(",
")",
"{",
"req",
",",
"_",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
")",
"\n",
"req",
".",
"<mask>",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"resp",
",",
"err",
":=",
"http",
".",
"DefaultClient",
".",
"Do",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"r",
":=",
"resp",
".",
"Body",
"\n\n",
"i",
":=",
"0",
"\n",
"buff",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"32",
"*",
"1024",
")",
"\n",
"for",
"{",
"n",
",",
"err",
":=",
"r",
".",
"Read",
"(",
"buff",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n",
"i",
"++",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
",",
"i",
",",
"sizestr",
".",
"ToString",
"(",
"int64",
"(",
"n",
")",
")",
")",
"\n",
"}",
"\n\n",
"r",
".",
"Close",
"(",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
10,652 | all-10653 | [
"MustParse",
"must",
"parse",
"string",
"to",
"time",
"or",
"will",
"panic"
] | [
"func",
"MustParse",
"(",
"strs",
"...",
"string",
")",
"<mask>",
".",
"Time",
"{",
"return",
"New",
"(",
"time",
".",
"Now",
"(",
")",
")",
".",
"MustParse",
"(",
"strs",
"...",
")",
"\n",
"}"
] |
10,653 | all-10654 | [
"AllByLink",
"finds",
"zero",
"or",
"more",
"anchor",
"elements",
"by",
"their",
"text",
"content",
"."
] | [
"func",
"(",
"s",
"*",
"selectable",
")",
"AllByLink",
"(",
"text",
"string",
")",
"*",
"MultiSelection",
"{",
"return",
"newMultiSelection",
"(",
"s",
".",
"session",
",",
"s",
".",
"selectors",
".",
"Append",
"(",
"target",
".",
"Link",
",",
"<mask>",
")",
")",
"\n",
"}"
] |
10,654 | all-10655 | [
"InspectContainer",
"mocks",
"base",
"method"
] | [
"func",
"(",
"m",
"*",
"MockDockerClient",
")",
"InspectContainer",
"(",
"arg0",
"context",
".",
"<mask>",
",",
"arg1",
"string",
",",
"arg2",
"time",
".",
"Duration",
")",
"(",
"*",
"types",
".",
"ContainerJSON",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
",",
"arg1",
",",
"arg2",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"*",
"types",
".",
"ContainerJSON",
")",
"\n",
"ret1",
",",
"_",
":=",
"ret",
"[",
"1",
"]",
".",
"(",
"error",
")",
"\n",
"return",
"ret0",
",",
"ret1",
"\n",
"}"
] |
10,655 | all-10656 | [
"ThrottledWriter",
"ensures",
"that",
"writes",
"to",
"w",
"never",
"exceeds",
"a",
"specified",
"rate",
"of",
"bytes",
"per",
"second",
".",
"The",
"maxBurst",
"duration",
"changes",
"how",
"often",
"the",
"verification",
"is",
"done",
".",
"The",
"smaller",
"the",
"value",
"the",
"less",
"bursty",
"but",
"also",
"the",
"more",
"overhead",
"there",
"is",
"to",
"the",
"throttling",
"."
] | [
"func",
"ThrottledWriter",
"(",
"w",
"io",
".",
"Writer",
",",
"bytesPerSec",
"int",
",",
"maxBurst",
"<mask>",
".",
"Duration",
")",
"ThrottlerWriter",
"{",
"return",
"&",
"throttledWriter",
"{",
"wrap",
":",
"w",
",",
"limiter",
":",
"newRateLimiter",
"(",
"bytesPerSec",
",",
"maxBurst",
")",
",",
"}",
"\n",
"}"
] |
10,656 | all-10657 | [
"serverVersion",
"returns",
"the",
"server",
"version",
"from",
"the",
"given",
"header",
"."
] | [
"func",
"serverVersion",
"(",
"h",
"http",
".",
"Header",
")",
"*",
"semver",
".",
"<mask>",
"{",
"verStr",
":=",
"h",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"// backward compatibility with etcd 2.0",
"if",
"verStr",
"==",
"\"",
"\"",
"{",
"verStr",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"semver",
".",
"Must",
"(",
"semver",
".",
"NewVersion",
"(",
"verStr",
")",
")",
"\n",
"}"
] |
10,657 | all-10658 | [
"Helper",
"to",
"initialize",
"LXD",
"clustering",
".",
"Used",
"by",
"the",
"lxd",
"init",
"command",
"."
] | [
"func",
"initDataClusterApply",
"(",
"d",
"lxd",
".",
"ContainerServer",
",",
"config",
"*",
"initDataCluster",
")",
"error",
"{",
"if",
"config",
"==",
"nil",
"||",
"!",
"config",
".",
"Enabled",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Get the current cluster configuration",
"currentCluster",
",",
"etag",
",",
"err",
":=",
"d",
".",
"GetCluster",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Check if already enabled",
"if",
"!",
"currentCluster",
".",
"Enabled",
"{",
"// Configure the cluster",
"op",
",",
"err",
":=",
"d",
".",
"UpdateCluster",
"(",
"config",
".",
"ClusterPut",
",",
"etag",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"err",
"=",
"op",
".",
"Wait",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"<mask>",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
10,658 | all-10659 | [
"render",
"multiple",
"instances",
"of",
"a",
"set",
"of",
"primitives",
"from",
"array",
"data",
"with",
"a",
"per",
"-",
"element",
"offset"
] | [
"func",
"DrawElementsInstancedBaseVertexBaseInstance",
"(",
"<mask>",
"uint32",
",",
"count",
"int32",
",",
"xtype",
"uint32",
",",
"indices",
"unsafe",
".",
"Pointer",
",",
"instancecount",
"int32",
",",
"basevertex",
"int32",
",",
"baseinstance",
"uint32",
")",
"{",
"syscall",
".",
"Syscall9",
"(",
"gpDrawElementsInstancedBaseVertexBaseInstance",
",",
"7",
",",
"uintptr",
"(",
"mode",
")",
",",
"uintptr",
"(",
"count",
")",
",",
"uintptr",
"(",
"xtype",
")",
",",
"uintptr",
"(",
"indices",
")",
",",
"uintptr",
"(",
"instancecount",
")",
",",
"uintptr",
"(",
"basevertex",
")",
",",
"uintptr",
"(",
"baseinstance",
")",
",",
"0",
",",
"0",
")",
"\n",
"}"
] |
10,659 | all-10660 | [
"Stderr",
"sets",
"the",
"process",
"s",
"standard",
"output",
"."
] | [
"func",
"(",
"g",
"*",
"gitCmd",
")",
"Stderr",
"(",
"stderr",
"io",
".",
"<mask>",
")",
"{",
"g",
".",
"Cmd",
".",
"Stderr",
"=",
"stderr",
"\n",
"}"
] |
10,660 | all-10661 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"Error",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdproto2",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
10,661 | all-10662 | [
"SetResult",
"sets",
"r",
".",
"Result",
"to",
"the",
"JSON",
"representation",
"of",
"v",
".",
"If",
"JSON",
"marshaling",
"fails",
"it",
"returns",
"an",
"error",
"."
] | [
"func",
"(",
"r",
"*",
"Response",
")",
"SetResult",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"r",
".",
"<mask>",
"=",
"(",
"*",
"json",
".",
"RawMessage",
")",
"(",
"&",
"b",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
10,662 | all-10663 | [
"GetReadOnlyOk",
"returns",
"a",
"tuple",
"with",
"the",
"ReadOnly",
"field",
"if",
"it",
"s",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"and",
"a",
"boolean",
"to",
"check",
"if",
"the",
"value",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"d",
"*",
"Dashboard",
")",
"GetReadOnlyOk",
"(",
")",
"(",
"bool",
",",
"bool",
")",
"{",
"if",
"d",
"==",
"nil",
"||",
"d",
".",
"ReadOnly",
"==",
"nil",
"{",
"return",
"false",
",",
"<mask>",
"\n",
"}",
"\n",
"return",
"*",
"d",
".",
"ReadOnly",
",",
"true",
"\n",
"}"
] |
10,663 | all-10664 | [
"IsIgnored",
"returns",
"true",
"if",
"the",
"given",
"linter",
"issue",
"is",
"ignored",
"by",
"a",
"linter",
"directive",
"."
] | [
"func",
"(",
"d",
"*",
"directiveParser",
")",
"IsIgnored",
"(",
"issue",
"*",
"Issue",
")",
"bool",
"{",
"d",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"path",
":=",
"issue",
".",
"Path",
".",
"Relative",
"(",
")",
"\n",
"ranges",
",",
"ok",
":=",
"d",
".",
"files",
"[",
"path",
"]",
"\n",
"if",
"!",
"ok",
"{",
"ranges",
"=",
"d",
".",
"parseFile",
"(",
"path",
")",
"\n",
"sort",
".",
"Sort",
"(",
"ranges",
")",
"\n",
"d",
".",
"files",
"[",
"path",
"]",
"=",
"ranges",
"\n",
"}",
"\n",
"d",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"for",
"_",
",",
"r",
":=",
"<mask>",
"ranges",
"{",
"if",
"r",
".",
"matches",
"(",
"issue",
")",
"{",
"debug",
"(",
"\"",
"\"",
",",
"r",
",",
"issue",
")",
"\n",
"r",
".",
"matched",
"=",
"true",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] |
10,664 | all-10665 | [
"WriteDashboardAssets",
"writes",
"the",
"k8s",
"config",
"for",
"deploying",
"the",
"Pachyderm",
"dashboard",
"to",
"encoder"
] | [
"func",
"WriteDashboardAssets",
"(",
"encoder",
"Encoder",
",",
"opts",
"*",
"AssetOpts",
")",
"error",
"{",
"if",
"err",
":=",
"encoder",
".",
"Encode",
"(",
"DashService",
"(",
"opts",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n",
"return",
"encoder",
".",
"Encode",
"(",
"DashDeployment",
"(",
"opts",
")",
")",
"\n",
"}"
] |
10,665 | all-10666 | [
"ExportPrivateKey",
"returns",
"a",
"private",
"key",
"in",
"base64",
"encoding",
"by",
"account",
"id",
"."
] | [
"func",
"(",
"h",
"*",
"Handler",
")",
"ExportPrivateKey",
"(",
"tkn",
",",
"account",
"string",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"logger",
":=",
"h",
".",
"logger",
".",
"Add",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"account",
")",
"\n",
"if",
"!",
"h",
".",
"token",
".",
"Check",
"(",
"tkn",
")",
"{",
"logger",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"ErrAccessDenied",
"\n",
"}",
"\n\n",
"var",
"acc",
"data",
".",
"Account",
"\n",
"err",
":=",
"h",
".",
"db",
".",
"FindByPrimaryKeyTo",
"(",
"&",
"acc",
",",
"account",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Error",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"if",
"err",
"==",
"reform",
".",
"ErrNoRows",
"{",
"return",
"nil",
",",
"ErrAccountNotFound",
"\n",
"}",
"\n",
"return",
"nil",
",",
"ErrInternal",
"\n",
"}",
"\n",
"key",
",",
"err",
":=",
"data",
".",
"ToBytes",
"(",
"acc",
".",
"PrivateKey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Error",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"nil",
",",
"ErrInternal",
"\n",
"}",
"\n\n",
"return",
"key",
",",
"nil",
"\n",
"}"
] |
10,666 | all-10667 | [
"TrimRuntime",
"returns",
"a",
"slice",
"of",
"the",
"Trace",
"with",
"the",
"topmost",
"entries",
"from",
"the",
"go",
"runtime",
"removed",
".",
"It",
"considers",
"any",
"calls",
"originating",
"from",
"files",
"under",
"GOROOT",
"as",
"part",
"of",
"the",
"runtime",
"."
] | [
"func",
"(",
"pcs",
"Trace",
")",
"TrimRuntime",
"(",
")",
"Trace",
"{",
"for",
"len",
"(",
"pcs",
")",
">",
"0",
"&&",
"inGoroot",
"(",
"pcs",
"[",
"len",
"(",
"pcs",
")",
"-",
"1",
"]",
".",
"<mask>",
"(",
")",
")",
"{",
"pcs",
"=",
"pcs",
"[",
":",
"len",
"(",
"pcs",
")",
"-",
"1",
"]",
"\n",
"}",
"\n",
"return",
"pcs",
"\n",
"}"
] |
10,667 | all-10668 | [
"Equals",
"compares",
"two",
"private",
"keys"
] | [
"func",
"(",
"k",
"*",
"Secp256k1PrivateKey",
")",
"Equals",
"(",
"o",
"Key",
")",
"bool",
"{",
"sk",
",",
"<mask>",
":=",
"o",
".",
"(",
"*",
"Secp256k1PrivateKey",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"k",
".",
"D",
".",
"Cmp",
"(",
"sk",
".",
"D",
")",
"==",
"0",
"\n",
"}"
] |
10,668 | all-10669 | [
"SignDockerManifest",
"returns",
"a",
"signature",
"for",
"manifest",
"as",
"the",
"specified",
"dockerReference",
"using",
"mech",
"and",
"keyIdentity",
"."
] | [
"func",
"SignDockerManifest",
"(",
"m",
"[",
"]",
"byte",
",",
"dockerReference",
"string",
",",
"mech",
"SigningMechanism",
",",
"keyIdentity",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"manifestDigest",
",",
"err",
":=",
"manifest",
".",
"Digest",
"(",
"m",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"sig",
":=",
"newUntrustedSignature",
"(",
"manifestDigest",
",",
"dockerReference",
")",
"\n",
"return",
"sig",
".",
"<mask>",
"(",
"mech",
",",
"keyIdentity",
")",
"\n",
"}"
] |
10,669 | all-10670 | [
"Post",
"sends",
"POST",
"request",
"to",
"the",
"given",
"url",
"with",
"the",
"given",
"POST",
"arguments",
".",
"The",
"contents",
"of",
"dst",
"will",
"be",
"replaced",
"by",
"the",
"body",
"and",
"returned",
"if",
"the",
"dst",
"is",
"too",
"small",
"a",
"new",
"slice",
"will",
"be",
"allocated",
".",
"The",
"function",
"follows",
"redirects",
".",
"Use",
"Do",
"*",
"for",
"manually",
"handling",
"redirects",
".",
"Empty",
"POST",
"body",
"is",
"sent",
"if",
"postArgs",
"is",
"nil",
"."
] | [
"func",
"Post",
"(",
"dst",
"[",
"]",
"byte",
",",
"<mask>",
"string",
",",
"postArgs",
"*",
"Args",
")",
"(",
"statusCode",
"int",
",",
"body",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"return",
"defaultClient",
".",
"Post",
"(",
"dst",
",",
"url",
",",
"postArgs",
")",
"\n",
"}"
] |
10,670 | all-10671 | [
"Header",
"---------------------------------------------------------------------",
"NewHeader",
"returns",
"a",
"header",
"matcher",
"converting",
"keys",
"to",
"the",
"canonical",
"form",
"."
] | [
"func",
"NewHeader",
"(",
"m",
"map",
"[",
"string",
"]",
"string",
")",
"Header",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"m",
"{",
"delete",
"(",
"m",
",",
"k",
")",
"\n",
"m",
"[",
"http",
".",
"CanonicalHeaderKey",
"(",
"k",
")",
"]",
"=",
"v",
"\n",
"}",
"\n",
"return",
"<mask>",
"(",
"m",
")",
"\n",
"}"
] |
10,671 | all-10672 | [
"UnmarshalJSON",
"supports",
"json",
".",
"Unmarshaler",
"interface"
] | [
"func",
"(",
"v",
"*",
"<mask>",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger30",
"(",
"&",
"r",
",",
"v",
")",
"\n",
"return",
"r",
".",
"Error",
"(",
")",
"\n",
"}"
] |
10,672 | all-10673 | [
"ConnectPublicLXD",
"lets",
"you",
"connect",
"to",
"a",
"remote",
"public",
"LXD",
"daemon",
"over",
"HTTPs",
".",
"Unless",
"the",
"remote",
"server",
"is",
"trusted",
"by",
"the",
"system",
"CA",
"the",
"remote",
"certificate",
"must",
"be",
"provided",
"(",
"TLSServerCert",
")",
"."
] | [
"func",
"ConnectPublicLXD",
"(",
"url",
"string",
",",
"args",
"*",
"ConnectionArgs",
")",
"(",
"ImageServer",
",",
"error",
")",
"{",
"logger",
".",
"Debugf",
"(",
"\"",
"\"",
")",
"\n\n",
"// Cleanup URL",
"url",
"=",
"strings",
".",
"TrimSuffix",
"(",
"url",
",",
"\"",
"\"",
")",
"\n\n",
"return",
"httpsLXD",
"(",
"<mask>",
",",
"args",
")",
"\n",
"}"
] |
10,673 | all-10674 | [
"ref",
".",
"https",
":",
"//",
"github",
".",
"com",
"/",
"golang",
"/",
"go",
"/",
"blob",
"/",
"master",
"/",
"src",
"/",
"io",
"/",
"io",
".",
"go",
"copyBuffer"
] | [
"func",
"(",
"b",
"*",
"bridge",
")",
"ioCopy",
"(",
"dst",
"io",
".",
"<mask>",
",",
"src",
"io",
".",
"Reader",
")",
"(",
"err",
"error",
")",
"{",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"32",
"*",
"1024",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"b",
".",
"blackholec",
":",
"io",
".",
"Copy",
"(",
"ioutil",
".",
"Discard",
",",
"src",
")",
"\n",
"return",
"nil",
"\n",
"default",
":",
"}",
"\n",
"nr",
",",
"er",
":=",
"src",
".",
"Read",
"(",
"buf",
")",
"\n",
"if",
"nr",
">",
"0",
"{",
"nw",
",",
"ew",
":=",
"dst",
".",
"Write",
"(",
"buf",
"[",
"0",
":",
"nr",
"]",
")",
"\n",
"if",
"ew",
"!=",
"nil",
"{",
"return",
"ew",
"\n",
"}",
"\n",
"if",
"nr",
"!=",
"nw",
"{",
"return",
"io",
".",
"ErrShortWrite",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"er",
"!=",
"nil",
"{",
"err",
"=",
"er",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] |
10,674 | all-10675 | [
"===",
"year",
"(",
"v",
"Vector",
")",
"Scalar",
"==="
] | [
"func",
"funcYear",
"(",
"vals",
"[",
"]",
"Value",
",",
"args",
"Expressions",
",",
"enh",
"*",
"EvalNodeHelper",
")",
"Vector",
"{",
"return",
"dateWrapper",
"(",
"vals",
",",
"enh",
",",
"func",
"(",
"t",
"<mask>",
".",
"Time",
")",
"float64",
"{",
"return",
"float64",
"(",
"t",
".",
"Year",
"(",
")",
")",
"\n",
"}",
")",
"\n",
"}"
] |
10,675 | all-10676 | [
"BuilderNewFromFile",
"is",
"a",
"wrapper",
"around",
"gtk_builder_new_from_file",
"()",
"."
] | [
"func",
"BuilderNewFromFile",
"(",
"filePath",
"string",
")",
"(",
"*",
"Builder",
",",
"error",
")",
"{",
"cstr",
":=",
"C",
".",
"CString",
"(",
"filePath",
")",
"\n",
"defer",
"C",
".",
"<mask>",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",
")",
")",
"\n\n",
"c",
":=",
"C",
".",
"gtk_builder_new_from_file",
"(",
"(",
"*",
"C",
".",
"gchar",
")",
"(",
"cstr",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nilPtrErr",
"\n",
"}",
"\n\n",
"obj",
":=",
"glib",
".",
"Take",
"(",
"unsafe",
".",
"Pointer",
"(",
"c",
")",
")",
"\n",
"return",
"&",
"Builder",
"{",
"obj",
"}",
",",
"nil",
"\n",
"}"
] |
10,676 | all-10677 | [
"NewNetworkTransportWithConfig",
"creates",
"a",
"new",
"network",
"transport",
"with",
"the",
"given",
"config",
"struct"
] | [
"func",
"NewNetworkTransportWithConfig",
"(",
"config",
"*",
"NetworkTransportConfig",
",",
")",
"*",
"NetworkTransport",
"{",
"if",
"config",
".",
"Logger",
"==",
"nil",
"{",
"config",
".",
"Logger",
"=",
"log",
".",
"New",
"(",
"<mask>",
".",
"Stderr",
",",
"\"",
"\"",
",",
"log",
".",
"LstdFlags",
")",
"\n",
"}",
"\n",
"trans",
":=",
"&",
"NetworkTransport",
"{",
"connPool",
":",
"make",
"(",
"map",
"[",
"ServerAddress",
"]",
"[",
"]",
"*",
"netConn",
")",
",",
"consumeCh",
":",
"make",
"(",
"chan",
"RPC",
")",
",",
"logger",
":",
"config",
".",
"Logger",
",",
"maxPool",
":",
"config",
".",
"MaxPool",
",",
"shutdownCh",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"stream",
":",
"config",
".",
"Stream",
",",
"timeout",
":",
"config",
".",
"Timeout",
",",
"TimeoutScale",
":",
"DefaultTimeoutScale",
",",
"serverAddressProvider",
":",
"config",
".",
"ServerAddressProvider",
",",
"}",
"\n\n",
"// Create the connection context and then start our listener.",
"trans",
".",
"setupStreamContext",
"(",
")",
"\n",
"go",
"trans",
".",
"listen",
"(",
")",
"\n\n",
"return",
"trans",
"\n",
"}"
] |
10,677 | all-10678 | [
"NewPrettyStreamEncoder",
"returns",
"a",
"new",
"JSON",
"stream",
"encoder",
"that",
"writes",
"to",
"w",
"."
] | [
"func",
"NewPrettyStreamEncoder",
"(",
"w",
"<mask>",
".",
"Writer",
")",
"*",
"objconv",
".",
"StreamEncoder",
"{",
"return",
"objconv",
".",
"NewStreamEncoder",
"(",
"NewPrettyEmitter",
"(",
"w",
")",
")",
"\n",
"}"
] |
10,678 | all-10679 | [
"ensureCachedDataIsPresent",
"loads",
"data",
"necessary",
"for",
"any",
"of",
"the",
"public",
"accessors",
"."
] | [
"func",
"(",
"s",
"*",
"Source",
")",
"ensureCachedDataIsPresent",
"(",
")",
"error",
"{",
"s",
".",
"cacheDataLock",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"// Read and parse manifest.json",
"tarManifest",
",",
"err",
":=",
"s",
".",
"loadTarManifest",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"s",
".",
"cacheDataResult",
"=",
"err",
"\n",
"return",
"\n",
"}",
"\n\n",
"// Check to make sure length is 1",
"if",
"len",
"(",
"tarManifest",
")",
"!=",
"1",
"{",
"s",
".",
"cacheDataResult",
"=",
"<mask>",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"len",
"(",
"tarManifest",
")",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"// Read and parse config.",
"configBytes",
",",
"err",
":=",
"s",
".",
"readTarComponent",
"(",
"tarManifest",
"[",
"0",
"]",
".",
"Config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"s",
".",
"cacheDataResult",
"=",
"err",
"\n",
"return",
"\n",
"}",
"\n",
"var",
"parsedConfig",
"manifest",
".",
"Schema2Image",
"// There's a lot of info there, but we only really care about layer DiffIDs.",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"configBytes",
",",
"&",
"parsedConfig",
")",
";",
"err",
"!=",
"nil",
"{",
"s",
".",
"cacheDataResult",
"=",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"tarManifest",
"[",
"0",
"]",
".",
"Config",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"knownLayers",
",",
"err",
":=",
"s",
".",
"prepareLayerData",
"(",
"&",
"tarManifest",
"[",
"0",
"]",
",",
"&",
"parsedConfig",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"s",
".",
"cacheDataResult",
"=",
"err",
"\n",
"return",
"\n",
"}",
"\n\n",
"// Success; commit.",
"s",
".",
"tarManifest",
"=",
"&",
"tarManifest",
"[",
"0",
"]",
"\n",
"s",
".",
"configBytes",
"=",
"configBytes",
"\n",
"s",
".",
"configDigest",
"=",
"digest",
".",
"FromBytes",
"(",
"configBytes",
")",
"\n",
"s",
".",
"orderedDiffIDList",
"=",
"parsedConfig",
".",
"RootFS",
".",
"DiffIDs",
"\n",
"s",
".",
"knownLayers",
"=",
"knownLayers",
"\n",
"}",
")",
"\n",
"return",
"s",
".",
"cacheDataResult",
"\n",
"}"
] |
10,679 | all-10680 | [
"RegisterNativeFuncs",
"adds",
"kubecfg",
"s",
"native",
"jsonnet",
"functions",
"to",
"provided",
"VM"
] | [
"func",
"RegisterNativeFuncs",
"(",
"vm",
"*",
"jsonnet",
".",
"VM",
",",
"resolver",
"Resolver",
")",
"{",
"// TODO(mkm): go-jsonnet 0.12.x now contains native std.parseJson; deprecate and remove this one.",
"vm",
".",
"NativeFunction",
"(",
"&",
"jsonnet",
".",
"NativeFunction",
"{",
"Name",
":",
"\"",
"\"",
",",
"Params",
":",
"[",
"]",
"jsonnetAst",
".",
"Identifier",
"{",
"\"",
"\"",
"}",
",",
"Func",
":",
"func",
"(",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"(",
"res",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"<mask>",
":=",
"[",
"]",
"byte",
"(",
"args",
"[",
"0",
"]",
".",
"(",
"string",
")",
")",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"res",
")",
"\n",
"return",
"\n",
"}",
",",
"}",
")",
"\n\n",
"vm",
".",
"NativeFunction",
"(",
"&",
"jsonnet",
".",
"NativeFunction",
"{",
"Name",
":",
"\"",
"\"",
",",
"Params",
":",
"[",
"]",
"jsonnetAst",
".",
"Identifier",
"{",
"\"",
"\"",
"}",
",",
"Func",
":",
"func",
"(",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"(",
"res",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"ret",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"data",
":=",
"[",
"]",
"byte",
"(",
"args",
"[",
"0",
"]",
".",
"(",
"string",
")",
")",
"\n",
"d",
":=",
"yaml",
".",
"NewYAMLToJSONDecoder",
"(",
"bytes",
".",
"NewReader",
"(",
"data",
")",
")",
"\n",
"for",
"{",
"var",
"doc",
"interface",
"{",
"}",
"\n",
"if",
"err",
":=",
"d",
".",
"Decode",
"(",
"&",
"doc",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"io",
".",
"EOF",
"{",
"break",
"\n",
"}",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"ret",
"=",
"append",
"(",
"ret",
",",
"doc",
")",
"\n",
"}",
"\n",
"return",
"ret",
",",
"nil",
"\n",
"}",
",",
"}",
")",
"\n\n",
"vm",
".",
"NativeFunction",
"(",
"&",
"jsonnet",
".",
"NativeFunction",
"{",
"Name",
":",
"\"",
"\"",
",",
"Params",
":",
"[",
"]",
"jsonnetAst",
".",
"Identifier",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"Func",
":",
"func",
"(",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"(",
"res",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"value",
":=",
"args",
"[",
"0",
"]",
"\n",
"indent",
":=",
"int",
"(",
"args",
"[",
"1",
"]",
".",
"(",
"float64",
")",
")",
"\n",
"data",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"value",
",",
"\"",
"\"",
",",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"indent",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"data",
"=",
"append",
"(",
"data",
",",
"byte",
"(",
"'\\n'",
")",
")",
"\n",
"return",
"string",
"(",
"data",
")",
",",
"nil",
"\n",
"}",
",",
"}",
")",
"\n\n",
"vm",
".",
"NativeFunction",
"(",
"&",
"jsonnet",
".",
"NativeFunction",
"{",
"Name",
":",
"\"",
"\"",
",",
"Params",
":",
"[",
"]",
"jsonnetAst",
".",
"Identifier",
"{",
"\"",
"\"",
"}",
",",
"Func",
":",
"func",
"(",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"(",
"res",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"value",
":=",
"args",
"[",
"0",
"]",
"\n",
"output",
",",
"err",
":=",
"goyaml",
".",
"Marshal",
"(",
"value",
")",
"\n",
"return",
"string",
"(",
"output",
")",
",",
"err",
"\n",
"}",
",",
"}",
")",
"\n\n",
"vm",
".",
"NativeFunction",
"(",
"&",
"jsonnet",
".",
"NativeFunction",
"{",
"Name",
":",
"\"",
"\"",
",",
"Params",
":",
"[",
"]",
"jsonnetAst",
".",
"Identifier",
"{",
"\"",
"\"",
"}",
",",
"Func",
":",
"func",
"(",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"(",
"res",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"return",
"resolveImage",
"(",
"resolver",
",",
"args",
"[",
"0",
"]",
".",
"(",
"string",
")",
")",
"\n",
"}",
",",
"}",
")",
"\n\n",
"vm",
".",
"NativeFunction",
"(",
"&",
"jsonnet",
".",
"NativeFunction",
"{",
"Name",
":",
"\"",
"\"",
",",
"Params",
":",
"[",
"]",
"jsonnetAst",
".",
"Identifier",
"{",
"\"",
"\"",
"}",
",",
"Func",
":",
"func",
"(",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"(",
"res",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"return",
"regexp",
".",
"QuoteMeta",
"(",
"args",
"[",
"0",
"]",
".",
"(",
"string",
")",
")",
",",
"nil",
"\n",
"}",
",",
"}",
")",
"\n\n",
"vm",
".",
"NativeFunction",
"(",
"&",
"jsonnet",
".",
"NativeFunction",
"{",
"Name",
":",
"\"",
"\"",
",",
"Params",
":",
"[",
"]",
"jsonnetAst",
".",
"Identifier",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"Func",
":",
"func",
"(",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"(",
"res",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"return",
"regexp",
".",
"MatchString",
"(",
"args",
"[",
"0",
"]",
".",
"(",
"string",
")",
",",
"args",
"[",
"1",
"]",
".",
"(",
"string",
")",
")",
"\n",
"}",
",",
"}",
")",
"\n\n",
"vm",
".",
"NativeFunction",
"(",
"&",
"jsonnet",
".",
"NativeFunction",
"{",
"Name",
":",
"\"",
"\"",
",",
"Params",
":",
"[",
"]",
"jsonnetAst",
".",
"Identifier",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"Func",
":",
"func",
"(",
"args",
"[",
"]",
"interface",
"{",
"}",
")",
"(",
"res",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"regex",
":=",
"args",
"[",
"0",
"]",
".",
"(",
"string",
")",
"\n",
"src",
":=",
"args",
"[",
"1",
"]",
".",
"(",
"string",
")",
"\n",
"repl",
":=",
"args",
"[",
"2",
"]",
".",
"(",
"string",
")",
"\n\n",
"r",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"regex",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"r",
".",
"ReplaceAllString",
"(",
"src",
",",
"repl",
")",
",",
"nil",
"\n",
"}",
",",
"}",
")",
"\n",
"}"
] |
10,680 | all-10681 | [
"ReadResponse",
"reads",
"a",
"server",
"response",
"into",
"the",
"received",
"o",
"."
] | [
"func",
"(",
"o",
"*",
"PostAppsAppRoutesReader",
")",
"ReadResponse",
"(",
"response",
"runtime",
".",
"ClientResponse",
",",
"consumer",
"runtime",
".",
"Consumer",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"switch",
"response",
".",
"Code",
"(",
")",
"{",
"case",
"200",
":",
"result",
":=",
"NewPostAppsAppRoutesOK",
"(",
")",
"\n",
"if",
"err",
":=",
"result",
".",
"readResponse",
"(",
"response",
",",
"consumer",
",",
"o",
".",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"result",
",",
"nil",
"\n\n",
"case",
"400",
":",
"result",
":=",
"NewPostAppsAppRoutesBadRequest",
"(",
")",
"\n",
"if",
"err",
":=",
"result",
".",
"readResponse",
"(",
"response",
",",
"consumer",
",",
"o",
".",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"nil",
",",
"result",
"\n\n",
"case",
"409",
":",
"result",
":=",
"NewPostAppsAppRoutesConflict",
"(",
")",
"\n",
"if",
"err",
":=",
"result",
".",
"readResponse",
"(",
"<mask>",
",",
"consumer",
",",
"o",
".",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"nil",
",",
"result",
"\n\n",
"default",
":",
"result",
":=",
"NewPostAppsAppRoutesDefault",
"(",
"response",
".",
"Code",
"(",
")",
")",
"\n",
"if",
"err",
":=",
"result",
".",
"readResponse",
"(",
"response",
",",
"consumer",
",",
"o",
".",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"response",
".",
"Code",
"(",
")",
"/",
"100",
"==",
"2",
"{",
"return",
"result",
",",
"nil",
"\n",
"}",
"\n",
"return",
"nil",
",",
"result",
"\n",
"}",
"\n",
"}"
] |
10,681 | all-10682 | [
"Terminate",
"stops",
"the",
"member",
"and",
"removes",
"the",
"data",
"dir",
"."
] | [
"func",
"(",
"m",
"*",
"member",
")",
"Terminate",
"(",
"t",
"testing",
".",
"TB",
")",
"{",
"lg",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"m",
".",
"Name",
")",
",",
"zap",
".",
"Strings",
"(",
"\"",
"\"",
",",
"m",
".",
"PeerURLs",
".",
"StringSlice",
"(",
")",
")",
",",
"zap",
".",
"Strings",
"(",
"\"",
"\"",
",",
"m",
".",
"ClientURLs",
".",
"StringSlice",
"(",
")",
")",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"m",
".",
"grpcAddr",
")",
",",
")",
"\n",
"m",
".",
"Close",
"(",
")",
"\n",
"if",
"!",
"m",
".",
"keepDataDirTerminate",
"{",
"if",
"err",
":=",
"<mask>",
".",
"RemoveAll",
"(",
"m",
".",
"ServerConfig",
".",
"DataDir",
")",
";",
"err",
"!=",
"nil",
"{",
"t",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n",
"lg",
".",
"Info",
"(",
"\"",
"\"",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"m",
".",
"Name",
")",
",",
"zap",
".",
"Strings",
"(",
"\"",
"\"",
",",
"m",
".",
"PeerURLs",
".",
"StringSlice",
"(",
")",
")",
",",
"zap",
".",
"Strings",
"(",
"\"",
"\"",
",",
"m",
".",
"ClientURLs",
".",
"StringSlice",
"(",
")",
")",
",",
"zap",
".",
"String",
"(",
"\"",
"\"",
",",
"m",
".",
"grpcAddr",
")",
",",
")",
"\n",
"}"
] |
10,682 | all-10683 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"TakeTypeProfileParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"<mask>",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoProfiler3",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
10,683 | all-10684 | [
"NewCtxClient",
"creates",
"a",
"client",
"with",
"a",
"context",
"but",
"no",
"underlying",
"grpc",
"connection",
".",
"This",
"is",
"useful",
"for",
"embedded",
"cases",
"that",
"override",
"the",
"service",
"interface",
"implementations",
"and",
"do",
"not",
"need",
"connection",
"management",
"."
] | [
"func",
"NewCtxClient",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"<mask>",
"{",
"cctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n",
"return",
"&",
"Client",
"{",
"ctx",
":",
"cctx",
",",
"cancel",
":",
"cancel",
"}",
"\n",
"}"
] |
10,684 | all-10685 | [
"GetNewId",
"returns",
"the",
"NewId",
"field",
"if",
"non",
"-",
"nil",
"zero",
"value",
"otherwise",
"."
] | [
"func",
"(",
"s",
"*",
"Screenboard",
")",
"GetNewId",
"(",
")",
"<mask>",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"NewId",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"*",
"s",
".",
"NewId",
"\n",
"}"
] |
10,685 | all-10686 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"GetFrameTreeParams",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage41",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
10,686 | all-10687 | [
"Mkdir",
"calls",
"os",
".",
"Mkdir",
"."
] | [
"func",
"(",
"g",
"GitOS",
")",
"Mkdir",
"(",
"name",
"string",
",",
"perm",
"os",
".",
"FileMode",
")",
"error",
"{",
"return",
"os",
".",
"Mkdir",
"(",
"<mask>",
",",
"perm",
")",
"\n",
"}"
] |
10,687 | all-10688 | [
"SetHasResizeGrip",
"is",
"a",
"wrapper",
"around",
"gtk_window_set_has_resize_grip",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Window",
")",
"SetHasResizeGrip",
"(",
"setting",
"bool",
")",
"{",
"C",
".",
"gtk_window_set_has_resize_grip",
"(",
"v",
".",
"native",
"(",
")",
",",
"gbool",
"(",
"<mask>",
")",
")",
"\n",
"}"
] |
10,688 | all-10689 | [
"HasCustomUnit",
"returns",
"a",
"boolean",
"if",
"a",
"field",
"has",
"been",
"set",
"."
] | [
"func",
"(",
"g",
"*",
"GraphDefinition",
")",
"HasCustomUnit",
"(",
")",
"bool",
"{",
"if",
"g",
"!=",
"nil",
"&&",
"g",
".",
"CustomUnit",
"!=",
"nil",
"{",
"return",
"<mask>",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] |
10,689 | all-10690 | [
"C",
"is",
"a",
"short",
"-",
"hand",
"function",
"to",
"construct",
"a",
"callback",
".",
"It",
"will",
"also",
"add",
"tracing",
"code",
"around",
"the",
"execution",
"of",
"the",
"callback",
"."
] | [
"func",
"C",
"(",
"name",
"string",
",",
"m",
"Matcher",
",",
"h",
"Handler",
")",
"*",
"Callback",
"{",
"// panic if matcher or handler is not set",
"if",
"m",
"==",
"nil",
"||",
"h",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"Callback",
"{",
"Matcher",
":",
"m",
",",
"Handler",
":",
"func",
"(",
"ctx",
"*",
"Context",
")",
"error",
"{",
"// begin trace",
"ctx",
".",
"Tracer",
".",
"Push",
"(",
"<mask>",
")",
"\n\n",
"// call handler",
"err",
":=",
"h",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// finish trace",
"ctx",
".",
"Tracer",
".",
"Pop",
"(",
")",
"\n\n",
"return",
"nil",
"\n",
"}",
",",
"}",
"\n",
"}"
] |
10,690 | all-10691 | [
"NewImageFromURL",
"creates",
"a",
"new",
"ebiten",
".",
"Image",
"from",
"the",
"given",
"URL",
".",
"Image",
"decoders",
"must",
"be",
"imported",
"when",
"using",
"NewImageFromURL",
".",
"For",
"example",
"if",
"you",
"want",
"to",
"load",
"a",
"PNG",
"image",
"you",
"d",
"need",
"to",
"add",
"_",
"image",
"/",
"png",
"to",
"the",
"import",
"section",
".",
"FilterDefault",
"is",
"used",
"at",
"NewImgeFromImage",
"internally",
"."
] | [
"func",
"NewImageFromURL",
"(",
"url",
"string",
")",
"(",
"*",
"ebiten",
".",
"Image",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"http",
".",
"Get",
"(",
"url",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"<mask>",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"img",
",",
"_",
",",
"err",
":=",
"image",
".",
"Decode",
"(",
"res",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"eimg",
",",
"_",
":=",
"ebiten",
".",
"NewImageFromImage",
"(",
"img",
",",
"ebiten",
".",
"FilterDefault",
")",
"\n",
"return",
"eimg",
",",
"nil",
"\n",
"}"
] |
10,691 | all-10692 | [
"GetMenuLabelText",
"()",
"is",
"a",
"wrapper",
"around",
"gtk_notebook_get_menu_label_text",
"()",
"."
] | [
"func",
"(",
"v",
"*",
"Notebook",
")",
"GetMenuLabelText",
"(",
"child",
"IWidget",
")",
"(",
"string",
",",
"error",
")",
"{",
"c",
":=",
"C",
".",
"gtk_notebook_get_menu_label_text",
"(",
"v",
".",
"native",
"(",
")",
",",
"<mask>",
".",
"toWidget",
"(",
")",
")",
"\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"goString",
"(",
"c",
")",
",",
"nil",
"\n",
"}"
] |
10,692 | all-10693 | [
"MarshalJSON",
"supports",
"json",
".",
"Marshaler",
"interface"
] | [
"func",
"(",
"v",
"EventTracingComplete",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"<mask>",
"{",
"}",
"\n",
"easyjsonC5a4559bEncodeGithubComChromedpCdprotoTracing8",
"(",
"&",
"w",
",",
"v",
")",
"\n",
"return",
"w",
".",
"Buffer",
".",
"BuildBytes",
"(",
")",
",",
"w",
".",
"Error",
"\n",
"}"
] |
10,693 | all-10694 | [
"NewExpiringClusteringIndex",
"creates",
"index",
"that",
"clusters",
"the",
"points",
"at",
"three",
"levels",
"with",
"cell",
"size",
"0",
".",
"5",
"5",
"and",
"500km",
"and",
"expires",
"them",
"after",
"expiration",
"minutes",
"."
] | [
"func",
"NewExpiringClusteringIndex",
"(",
"expiration",
"Minutes",
")",
"*",
"ClusteringIndex",
"{",
"<mask>",
":=",
"&",
"ClusteringIndex",
"{",
"}",
"\n",
"index",
".",
"streetLevel",
"=",
"NewExpiringPointsIndex",
"(",
"Km",
"(",
"0.5",
")",
",",
"expiration",
")",
"\n",
"index",
".",
"cityLevel",
"=",
"NewExpiringCountIndex",
"(",
"Km",
"(",
"10",
")",
",",
"expiration",
")",
"\n",
"index",
".",
"worldLevel",
"=",
"NewExpiringCountIndex",
"(",
"Km",
"(",
"500",
")",
",",
"expiration",
")",
"\n\n",
"return",
"index",
"\n",
"}"
] |
10,694 | all-10695 | [
"SetEffectivePropertyValueForNode",
"find",
"a",
"rule",
"with",
"the",
"given",
"active",
"property",
"for",
"the",
"given",
"node",
"and",
"set",
"the",
"new",
"value",
"for",
"this",
"property",
".",
"See",
":",
"https",
":",
"//",
"chromedevtools",
".",
"github",
".",
"io",
"/",
"devtools",
"-",
"protocol",
"/",
"tot",
"/",
"CSS#method",
"-",
"setEffectivePropertyValueForNode",
"parameters",
":",
"nodeID",
"-",
"The",
"element",
"id",
"for",
"which",
"to",
"set",
"property",
".",
"propertyName",
"value"
] | [
"func",
"SetEffectivePropertyValueForNode",
"(",
"nodeID",
"cdp",
".",
"NodeID",
",",
"propertyName",
"string",
",",
"<mask>",
"string",
")",
"*",
"SetEffectivePropertyValueForNodeParams",
"{",
"return",
"&",
"SetEffectivePropertyValueForNodeParams",
"{",
"NodeID",
":",
"nodeID",
",",
"PropertyName",
":",
"propertyName",
",",
"Value",
":",
"value",
",",
"}",
"\n",
"}"
] |
10,695 | all-10696 | [
"AskPassword",
"asks",
"the",
"user",
"to",
"enter",
"a",
"password",
"."
] | [
"func",
"AskPassword",
"(",
"question",
"string",
")",
"string",
"{",
"for",
"{",
"fmt",
".",
"Printf",
"(",
"<mask>",
")",
"\n\n",
"pwd",
",",
"_",
":=",
"terminal",
".",
"ReadPassword",
"(",
"0",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"inFirst",
":=",
"string",
"(",
"pwd",
")",
"\n",
"inFirst",
"=",
"strings",
".",
"TrimSuffix",
"(",
"inFirst",
",",
"\"",
"\\n",
"\"",
")",
"\n\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"pwd",
",",
"_",
"=",
"terminal",
".",
"ReadPassword",
"(",
"0",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"inSecond",
":=",
"string",
"(",
"pwd",
")",
"\n",
"inSecond",
"=",
"strings",
".",
"TrimSuffix",
"(",
"inSecond",
",",
"\"",
"\\n",
"\"",
")",
"\n\n",
"if",
"inFirst",
"==",
"inSecond",
"{",
"return",
"inFirst",
"\n",
"}",
"\n\n",
"invalidInput",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
10,696 | all-10697 | [
"available",
"returns",
"true",
"if",
"at",
"least",
"one",
"of",
"N",
"units",
"is",
"started",
"or",
"unreachable",
"."
] | [
"func",
"(",
"app",
"*",
"App",
")",
"available",
"(",
")",
"bool",
"{",
"units",
",",
"err",
":=",
"app",
".",
"Units",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"unit",
":=",
"range",
"units",
"{",
"if",
"unit",
".",
"Available",
"(",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"<mask>",
"\n",
"}"
] |
10,697 | all-10698 | [
"Create",
"implements",
"Create",
"method",
"of",
"PlanService",
"interface"
] | [
"func",
"(",
"s",
"*",
"planService",
")",
"Create",
"(",
"plan",
"appTypes",
".",
"Plan",
")",
"error",
"{",
"if",
"plan",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"appTypes",
".",
"PlanValidationError",
"{",
"Field",
":",
"\"",
"\"",
"}",
"\n",
"}",
"\n",
"if",
"plan",
".",
"CpuShare",
"<",
"2",
"{",
"return",
"appTypes",
".",
"ErrLimitOfCpuShare",
"\n",
"}",
"\n",
"if",
"plan",
".",
"Memory",
">",
"0",
"&&",
"plan",
".",
"Memory",
"<",
"4194304",
"{",
"return",
"appTypes",
".",
"ErrLimitOfMemory",
"\n",
"}",
"\n",
"return",
"s",
".",
"<mask>",
".",
"Insert",
"(",
"plan",
")",
"\n",
"}"
] |
10,698 | all-10699 | [
"Records",
"returns",
"the",
"list",
"of",
"records",
"in",
"a",
"given",
"hosted",
"zone",
"."
] | [
"func",
"(",
"p",
"*",
"AWSProvider",
")",
"Records",
"(",
")",
"(",
"endpoints",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
",",
"_",
"<mask>",
")",
"{",
"zones",
",",
"err",
":=",
"p",
".",
"Zones",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"p",
".",
"records",
"(",
"zones",
")",
"\n",
"}"
] |
10,699 | all-10700 | [
"sanitizeValue",
"converts",
"nil",
"interfaces",
"of",
"type",
"T",
"to",
"those",
"of",
"type",
"R",
"assuming",
"that",
"T",
"is",
"assignable",
"to",
"R",
".",
"Otherwise",
"it",
"returns",
"the",
"input",
"value",
"as",
"is",
"."
] | [
"func",
"sanitizeValue",
"(",
"v",
"reflect",
".",
"Value",
",",
"t",
"reflect",
".",
"Type",
")",
"reflect",
".",
"<mask>",
"{",
"// TODO(dsnet): Workaround for reflect bug (https://golang.org/issue/22143).",
"if",
"!",
"flags",
".",
"AtLeastGo110",
"{",
"if",
"v",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Interface",
"&&",
"v",
".",
"IsNil",
"(",
")",
"&&",
"v",
".",
"Type",
"(",
")",
"!=",
"t",
"{",
"return",
"reflect",
".",
"New",
"(",
"t",
")",
".",
"Elem",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"v",
"\n",
"}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.