id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
3,400
all-3401
[ "simultaneously", "specify", "storage", "for", "all", "levels", "of", "a", "two", "-", "dimensional", "or", "one", "-", "dimensional", "array", "texture" ]
[ "func", "TextureStorage2D", "(", "texture", "uint32", ",", "levels", "int32", ",", "internalformat", "uint32", ",", "<mask>", "int32", ",", "height", "int32", ")", "{", "syscall", ".", "Syscall6", "(", "gpTextureStorage2D", ",", "5", ",", "uintptr", "(", "texture", ")", ",", "uintptr", "(", "levels", ")", ",", "uintptr", "(", "internalformat", ")", ",", "uintptr", "(", "width", ")", ",", "uintptr", "(", "height", ")", ",", "0", ")", "\n", "}" ]
3,401
all-3402
[ "HasQuery", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "a", "*", "Alert", ")", "HasQuery", "(", ")", "bool", "{", "if", "a", "!=", "nil", "&&", "a", ".", "Query", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
3,402
all-3403
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventDetachedFromTarget", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoTarget18", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
3,403
all-3404
[ "UnmarshalEasyJSON", "satisfies", "easyjson", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "PausedReason", ")", "UnmarshalEasyJSON", "(", "in", "*", "jlexer", ".", "Lexer", ")", "{", "switch", "PausedReason", "(", "in", ".", "String", "(", ")", ")", "{", "case", "PausedReasonXHR", ":", "*", "t", "=", "PausedReasonXHR", "\n", "case", "PausedReasonDOM", ":", "*", "t", "=", "PausedReasonDOM", "\n", "case", "PausedReasonEventListener", ":", "*", "t", "=", "PausedReasonEventListener", "\n", "<mask>", "PausedReasonException", ":", "*", "t", "=", "PausedReasonException", "\n", "case", "PausedReasonAssert", ":", "*", "t", "=", "PausedReasonAssert", "\n", "case", "PausedReasonDebugCommand", ":", "*", "t", "=", "PausedReasonDebugCommand", "\n", "case", "PausedReasonPromiseRejection", ":", "*", "t", "=", "PausedReasonPromiseRejection", "\n", "case", "PausedReasonOOM", ":", "*", "t", "=", "PausedReasonOOM", "\n", "case", "PausedReasonOther", ":", "*", "t", "=", "PausedReasonOther", "\n", "case", "PausedReasonAmbiguous", ":", "*", "t", "=", "PausedReasonAmbiguous", "\n\n", "default", ":", "in", ".", "AddError", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}" ]
3,404
all-3405
[ "NewColorParser", "creates", "a", "new", "string", "parser", ".", "str", "is", "a", "string", "to", "parse", ".", "defText", "is", "a", "default", "text", "color", ".", "defBack", "is", "a", "default", "background", "color", ".", "Default", "colors", "are", "applied", "in", "case", "of", "reset", "color", "tag" ]
[ "func", "NewColorParser", "(", "str", "string", ",", "defText", ",", "defBack", "term", ".", "Attribute", ")", "*", "ColorParser", "{", "p", ":=", "new", "(", "ColorParser", ")", "\n", "p", ".", "<mask>", "=", "[", "]", "rune", "(", "str", ")", "\n", "p", ".", "defBack", ",", "p", ".", "defText", "=", "defBack", ",", "defText", "\n", "p", ".", "currBack", ",", "p", ".", "currText", "=", "defBack", ",", "defText", "\n", "return", "p", "\n", "}" ]
3,405
all-3406
[ "Receive", "implements", "TCPReceiver", "by", "making", "a", "length", "-", "limited", "read", "into", "a", "byte", "buffer", "." ]
[ "func", "(", "receiver", "*", "lengthPrefixTCPReceiver", ")", "Receive", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "lenPrefix", ":=", "make", "(", "[", "]", "byte", ",", "4", ")", "\n", "if", "_", ",", "err", ":=", "io", ".", "ReadFull", "(", "receiver", ".", "reader", ",", "lenPrefix", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "l", ":=", "<mask>", ".", "BigEndian", ".", "Uint32", "(", "lenPrefix", ")", "\n", "if", "l", ">", "maxTCPMsgSize", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "l", ",", "maxTCPMsgSize", ")", "\n", "}", "\n", "msg", ":=", "make", "(", "[", "]", "byte", ",", "l", ")", "\n", "_", ",", "err", ":=", "io", ".", "ReadFull", "(", "receiver", ".", "reader", ",", "msg", ")", "\n", "return", "msg", ",", "err", "\n", "}" ]
3,406
all-3407
[ "query", "the", "bindings", "of", "color", "indices", "to", "user", "-", "defined", "varying", "out", "variables" ]
[ "func", "GetFragDataIndex", "(", "program", "uint32", ",", "name", "*", "uint8", ")", "int32", "{", "ret", ",", "_", ",", "_", ":=", "syscall", ".", "Syscall", "(", "gpGetFragDataIndex", ",", "2", ",", "uintptr", "(", "program", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "<mask>", ")", ")", ",", "0", ")", "\n", "return", "(", "int32", ")", "(", "ret", ")", "\n", "}" ]
3,407
all-3408
[ "uncompressedDigestLocked", "implements", "types", ".", "BlobInfoCache", ".", "UncompressedDigest", "but", "must", "be", "called", "only", "with", "mem", ".", "mutex", "held", "." ]
[ "func", "(", "mem", "*", "<mask>", ")", "uncompressedDigestLocked", "(", "anyDigest", "digest", ".", "Digest", ")", "digest", ".", "Digest", "{", "if", "d", ",", "ok", ":=", "mem", ".", "uncompressedDigests", "[", "anyDigest", "]", ";", "ok", "{", "return", "d", "\n", "}", "\n", "// Presence in digestsByUncompressed implies that anyDigest must already refer to an uncompressed digest.", "// This way we don't have to waste storage space with trivial (uncompressed, uncompressed) mappings", "// when we already record a (compressed, uncompressed) pair.", "if", "m", ",", "ok", ":=", "mem", ".", "digestsByUncompressed", "[", "anyDigest", "]", ";", "ok", "&&", "len", "(", "m", ")", ">", "0", "{", "return", "anyDigest", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
3,408
all-3409
[ "NewSyslogBackend", "connects", "to", "the", "syslog", "daemon", "using", "UNIX", "sockets", "with", "the", "given", "prefix", ".", "If", "prefix", "is", "not", "given", "the", "prefix", "will", "be", "derived", "from", "the", "launched", "command", "." ]
[ "func", "NewSyslogBackend", "(", "<mask>", "string", ")", "(", "b", "*", "SyslogBackend", ",", "err", "error", ")", "{", "var", "w", "*", "syslog", ".", "Writer", "\n", "w", ",", "err", "=", "syslog", ".", "New", "(", "syslog", ".", "LOG_CRIT", ",", "prefix", ")", "\n", "return", "&", "SyslogBackend", "{", "w", "}", ",", "err", "\n", "}" ]
3,409
all-3410
[ "Set", "is", "required", "for", "kingpin", "interfaces", "to", "allow", "command", "line", "params", "to", "be", "set", "to", "our", "map", "datatype" ]
[ "func", "(", "o", "*", "MapFloat64Option", ")", "Set", "(", "value", "string", ")", "error", "{", "parts", ":=", "stringMapRegex", ".", "Split", "(", "value", ",", "2", ")", "\n", "if", "len", "(", "parts", ")", "!=", "2", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "value", ")", "\n", "}", "\n", "val", ":=", "Float64Option", "{", "}", "\n", "val", ".", "Set", "(", "<mask>", "[", "1", "]", ")", "\n", "(", "*", "o", ")", "[", "parts", "[", "0", "]", "]", "=", "val", "\n", "return", "nil", "\n", "}" ]
3,410
all-3411
[ "partialFeeder", "returns", "template", "string", "for", "the", "name", "from", "TemplateBox", ".", "It", "should", "be", "registered", "as", "helper", "named", "partialFeeder", "so", "plush", "can", "find", "it", "with", "the", "name", "." ]
[ "func", "(", "s", "templateRenderer", ")", "partialFeeder", "(", "name", "string", ")", "(", "string", ",", "error", ")", "{", "<mask>", ":=", "strings", ".", "ToLower", "(", "s", ".", "contentType", ")", "\n\n", "d", ",", "f", ":=", "filepath", ".", "Split", "(", "name", ")", "\n", "name", "=", "filepath", ".", "Join", "(", "d", ",", "\"", "\"", "+", "f", ")", "\n", "name", "=", "fixExtension", "(", "name", ",", "ct", ")", "\n\n", "return", "s", ".", "TemplatesBox", ".", "FindString", "(", "name", ")", "\n", "}" ]
3,411
all-3412
[ "NewECRAuthProvider", "returns", "a", "DockerAuthProvider", "that", "can", "handle", "retrieve", "credentials", "for", "pulling", "from", "Amazon", "EC2", "Container", "Registry" ]
[ "func", "NewECRAuthProvider", "(", "ecrFactory", "ecr", ".", "ECRFactory", ",", "cache", "async", ".", "Cache", ")", "DockerAuthProvider", "{", "return", "&", "ecrAuthProvider", "{", "tokenCache", ":", "<mask>", ",", "factory", ":", "ecrFactory", ",", "}", "\n", "}" ]
3,412
all-3413
[ "GetSortOk", "returns", "a", "tuple", "with", "the", "Sort", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "a", "*", "ApmOrLogQueryGroupBy", ")", "GetSortOk", "(", ")", "(", "ApmOrLogQueryGroupBySort", ",", "bool", ")", "{", "if", "a", "==", "nil", "||", "a", ".", "Sort", "==", "nil", "{", "return", "ApmOrLogQueryGroupBySort", "{", "}", ",", "false", "\n", "}", "\n", "return", "*", "a", ".", "Sort", ",", "<mask>", "\n", "}" ]
3,413
all-3414
[ "Remove", "removes", "a", "point", "from", "the", "index", "." ]
[ "func", "(", "<mask>", "*", "PointsIndex", ")", "Remove", "(", "id", "string", ")", "{", "if", "prevPoint", ",", "ok", ":=", "points", ".", "currentPosition", "[", "id", "]", ";", "ok", "{", "set", ":=", "points", ".", "index", ".", "GetEntryAt", "(", "prevPoint", ")", ".", "(", "set", ")", "\n", "set", ".", "Remove", "(", "prevPoint", ".", "Id", "(", ")", ")", "\n", "delete", "(", "points", ".", "currentPosition", ",", "prevPoint", ".", "Id", "(", ")", ")", "\n", "}", "\n", "}" ]
3,414
all-3415
[ "GetName", "is", "a", "wrapper", "around", "g_action_get_name" ]
[ "func", "(", "v", "*", "<mask>", ")", "GetName", "(", ")", "string", "{", "return", "C", ".", "GoString", "(", "(", "*", "C", ".", "char", ")", "(", "C", ".", "g_action_get_name", "(", "v", ".", "native", "(", ")", ")", ")", ")", "\n", "}" ]
3,415
all-3416
[ "zeroValueOf", "and", "the", "related", "cache", "is", "used", "to", "keep", "the", "zero", "values", "so", "they", "don", "t", "need", "to", "be", "reallocated", "every", "time", "they", "re", "used", "." ]
[ "func", "zeroValueOf", "(", "t", "reflect", ".", "<mask>", ")", "reflect", ".", "Value", "{", "zeroMutex", ".", "RLock", "(", ")", "\n", "v", ",", "ok", ":=", "zeroCache", "[", "t", "]", "\n", "zeroMutex", ".", "RUnlock", "(", ")", "\n\n", "if", "!", "ok", "{", "v", "=", "reflect", ".", "Zero", "(", "t", ")", "\n", "zeroMutex", ".", "Lock", "(", ")", "\n", "zeroCache", "[", "t", "]", "=", "v", "\n", "zeroMutex", ".", "Unlock", "(", ")", "\n", "}", "\n\n", "return", "v", "\n", "}" ]
3,416
all-3417
[ "Finalize", "ensures", "there", "no", "nil", "pointers", "." ]
[ "func", "(", "c", "*", "ConsulConfig", ")", "Finalize", "(", ")", "{", "if", "c", ".", "<mask>", "==", "nil", "{", "c", ".", "Address", "=", "stringFromEnv", "(", "[", "]", "string", "{", "\"", "\"", ",", "}", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "c", ".", "Auth", "==", "nil", "{", "c", ".", "Auth", "=", "DefaultAuthConfig", "(", ")", "\n", "}", "\n", "c", ".", "Auth", ".", "Finalize", "(", ")", "\n\n", "if", "c", ".", "Retry", "==", "nil", "{", "c", ".", "Retry", "=", "DefaultRetryConfig", "(", ")", "\n", "}", "\n", "c", ".", "Retry", ".", "Finalize", "(", ")", "\n\n", "if", "c", ".", "SSL", "==", "nil", "{", "c", ".", "SSL", "=", "DefaultSSLConfig", "(", ")", "\n", "}", "\n", "c", ".", "SSL", ".", "Finalize", "(", ")", "\n\n", "if", "c", ".", "Token", "==", "nil", "{", "c", ".", "Token", "=", "stringFromEnv", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "}", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "c", ".", "Transport", "==", "nil", "{", "c", ".", "Transport", "=", "DefaultTransportConfig", "(", ")", "\n", "}", "\n", "c", ".", "Transport", ".", "Finalize", "(", ")", "\n", "}" ]
3,417
all-3418
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "SelectorList", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss22", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
3,418
all-3419
[ "SetStr", "sets", "environment", "variable", "from", "key", "=", "val", "string", "format", "." ]
[ "func", "(", "e", "*", "EnvVar", ")", "SetStr", "(", "keyVal", "string", ")", "{", "s", ":=", "strings", ".", "SplitN", "(", "keyVal", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "s", ")", "==", "2", "{", "e", ".", "<mask>", "(", "s", "[", "0", "]", ",", "s", "[", "1", "]", ")", "\n", "}", "\n", "}" ]
3,419
all-3420
[ "Create", "a", "container", "struct", "without", "initializing", "it", "." ]
[ "func", "containerLXCInstantiate", "(", "s", "*", "state", ".", "State", ",", "args", "db", ".", "ContainerArgs", ")", "*", "containerLXC", "{", "return", "&", "containerLXC", "{", "state", ":", "s", ",", "id", ":", "args", ".", "ID", ",", "<mask>", ":", "args", ".", "Project", ",", "name", ":", "args", ".", "Name", ",", "description", ":", "args", ".", "Description", ",", "ephemeral", ":", "args", ".", "Ephemeral", ",", "architecture", ":", "args", ".", "Architecture", ",", "cType", ":", "args", ".", "Ctype", ",", "creationDate", ":", "args", ".", "CreationDate", ",", "lastUsedDate", ":", "args", ".", "LastUsedDate", ",", "profiles", ":", "args", ".", "Profiles", ",", "localConfig", ":", "args", ".", "Config", ",", "localDevices", ":", "args", ".", "Devices", ",", "stateful", ":", "args", ".", "Stateful", ",", "node", ":", "args", ".", "Node", ",", "expiryDate", ":", "args", ".", "ExpiryDate", ",", "}", "\n", "}" ]
3,420
all-3421
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "SetBlackboxPatternsParams", ")", "UnmarshalJSON", "(", "<mask>", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger17", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
3,421
all-3422
[ "Marshal", "serializes", "the", "sitemap", "URLSet", "to", "XML", "with", "the", "<urlset", ">", "xmlns", "added", "and", "the", "XML", "preamble", "prepended", "." ]
[ "func", "Marshal", "(", "urlset", "*", "URLSet", ")", "(", "sitemapXML", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "len", "(", "urlset", ".", "URLs", ")", ">", "MaxURLs", "{", "err", "=", "ErrExceededMaxURLs", "\n", "return", "\n", "}", "\n", "urlset", ".", "XMLNS", "=", "xmlns", "\n", "sitemapXML", "=", "[", "]", "byte", "(", "preamble", ")", "\n", "var", "urlsetXML", "[", "]", "<mask>", "\n", "urlsetXML", ",", "err", "=", "xml", ".", "Marshal", "(", "urlset", ")", "\n", "if", "err", "==", "nil", "{", "sitemapXML", "=", "append", "(", "sitemapXML", ",", "urlsetXML", "...", ")", "\n", "}", "\n", "if", "len", "(", "sitemapXML", ")", ">", "MaxFileSize", "{", "err", "=", "ErrExceededMaxFileSize", "\n", "}", "\n", "return", "\n", "}" ]
3,422
all-3423
[ "RemoveLabel", "removes", "a", "label" ]
[ "func", "(", "f", "*", "FakeClient", ")", "RemoveLabel", "(", "owner", ",", "repo", "string", ",", "number", "int", ",", "<mask>", "string", ")", "error", "{", "labelString", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "owner", ",", "repo", ",", "number", ",", "label", ")", "\n", "if", "!", "sets", ".", "NewString", "(", "f", ".", "IssueLabelsRemoved", "...", ")", ".", "Has", "(", "labelString", ")", "{", "f", ".", "IssueLabelsRemoved", "=", "append", "(", "f", ".", "IssueLabelsRemoved", ",", "labelString", ")", "\n", "return", "nil", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "label", ",", "owner", ",", "repo", ",", "number", ")", "\n", "}" ]
3,423
all-3424
[ "NewWindow", "creates", "a", "new", "window", "type", "." ]
[ "func", "NewWindow", "(", "manager", "Windower", ")", "*", "Window", "{", "wc", ":=", "make", "(", "chan", "*", "Window", ")", "\n", "Queue", "(", "func", "(", ")", "{", "w", ":=", "&", "Window", "{", "id", ":", "lastWindowID", ",", "mgr", ":", "manager", ",", "x", ":", "maxX", ",", "y", ":", "maxY", ",", "focus", ":", "-", "1", ",", "// no widget focused", "backingStore", ":", "make", "(", "[", "]", "Cell", ",", "maxX", "*", "maxY", ")", ",", "widgets", ":", "make", "(", "[", "]", "Widgeter", ",", "0", ",", "16", ")", ",", "}", "\n", "lastWindowID", "++", "\n", "windows", "[", "w", ".", "id", "]", "=", "w", "\n", "windower2window", "[", "<mask>", "]", "=", "w", "\n", "manager", ".", "Init", "(", "w", ")", "\n", "wc", "<-", "w", "\n", "}", ")", "\n", "return", "<-", "wc", "\n", "}" ]
3,424
all-3425
[ "configureOrgMeta", "will", "update", "github", "to", "have", "the", "non", "-", "nil", "wanted", "metadata", "values", "." ]
[ "func", "configureOrgMeta", "(", "client", "orgMetadataClient", ",", "orgName", "string", ",", "want", "org", ".", "Metadata", ")", "error", "{", "cur", ",", "err", ":=", "client", ".", "GetOrg", "(", "orgName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "orgName", ",", "err", ")", "\n", "}", "\n", "change", ":=", "false", "\n", "change", "=", "updateString", "(", "&", "cur", ".", "BillingEmail", ",", "want", ".", "BillingEmail", ")", "||", "change", "\n", "<mask>", "=", "updateString", "(", "&", "cur", ".", "Company", ",", "want", ".", "Company", ")", "||", "change", "\n", "change", "=", "updateString", "(", "&", "cur", ".", "Email", ",", "want", ".", "Email", ")", "||", "change", "\n", "change", "=", "updateString", "(", "&", "cur", ".", "Name", ",", "want", ".", "Name", ")", "||", "change", "\n", "change", "=", "updateString", "(", "&", "cur", ".", "Description", ",", "want", ".", "Description", ")", "||", "change", "\n", "change", "=", "updateString", "(", "&", "cur", ".", "Location", ",", "want", ".", "Location", ")", "||", "change", "\n", "if", "want", ".", "DefaultRepositoryPermission", "!=", "nil", "{", "w", ":=", "string", "(", "*", "want", ".", "DefaultRepositoryPermission", ")", "\n", "change", "=", "updateString", "(", "&", "cur", ".", "DefaultRepositoryPermission", ",", "&", "w", ")", "\n", "}", "\n", "change", "=", "updateBool", "(", "&", "cur", ".", "HasOrganizationProjects", ",", "want", ".", "HasOrganizationProjects", ")", "||", "change", "\n", "change", "=", "updateBool", "(", "&", "cur", ".", "HasRepositoryProjects", ",", "want", ".", "HasRepositoryProjects", ")", "||", "change", "\n", "change", "=", "updateBool", "(", "&", "cur", ".", "MembersCanCreateRepositories", ",", "want", ".", "MembersCanCreateRepositories", ")", "||", "change", "\n", "if", "change", "{", "if", "_", ",", "err", ":=", "client", ".", "EditOrg", "(", "orgName", ",", "*", "cur", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "orgName", ",", "err", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
3,425
all-3426
[ "NewRegistryResolver", "returns", "a", "resolver", "that", "looks", "up", "a", "docker", "registry", "to", "resolve", "digests" ]
[ "func", "NewRegistryResolver", "(", "opt", "registry", ".", "Opt", ")", "Resolver", "{", "return", "&", "registryResolver", "{", "opt", ":", "<mask>", ",", "cache", ":", "make", "(", "map", "[", "string", "]", "string", ")", ",", "}", "\n", "}" ]
3,426
all-3427
[ "ResponseWriter", "returns", "a", "http", ".", "ResponseWriter", "that", "will", "write", "to", "an", "underlying", "writer", ".", "It", "also", "returns", "a", "function", "that", "should", "be", "called", "once", "the", "handler", "has", "completed", "." ]
[ "func", "ResponseWriter", "(", "response", "tchannel", ".", "ArgWritable", ")", "(", "http", ".", "ResponseWriter", ",", "func", "(", ")", "error", ")", "{", "responseWriter", ":=", "newTChanResponseWriter", "(", "<mask>", ")", "\n", "return", "responseWriter", ",", "responseWriter", ".", "finish", "\n", "}" ]
3,427
all-3428
[ "Stop", "the", "announce", "." ]
[ "func", "(", "a", "*", "Announce", ")", "Close", "(", ")", "{", "a", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "mu", ".", "Unlock", "(", ")", "\n", "a", ".", "<mask>", "(", ")", "\n", "}" ]
3,428
all-3429
[ "MarshalLogObject", "implements", "zapcore", "ObjectMarshaler", "." ]
[ "func", "(", "sc", "ServiceContext", ")", "MarshalLogObject", "(", "enc", "zapcore", ".", "ObjectEncoder", ")", "error", "{", "if", "sc", ".", "<mask>", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "enc", ".", "AddString", "(", "\"", "\"", ",", "sc", ".", "Service", ")", "\n", "enc", ".", "AddString", "(", "\"", "\"", ",", "sc", ".", "Version", ")", "\n\n", "return", "nil", "\n", "}" ]
3,429
all-3430
[ "Locator", "returns", "a", "locator", "for", "the", "given", "resource" ]
[ "func", "(", "r", "*", "NetworkOptionGroup", ")", "Locator", "(", "api", "*", "API", ")", "*", "NetworkOptionGroupLocator", "{", "for", "_", ",", "l", ":=", "<mask>", "r", ".", "Links", "{", "if", "l", "[", "\"", "\"", "]", "==", "\"", "\"", "{", "return", "api", ".", "NetworkOptionGroupLocator", "(", "l", "[", "\"", "\"", "]", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
3,430
all-3431
[ "fill", "a", "buffer", "object", "s", "data", "store", "with", "a", "fixed", "value" ]
[ "func", "ClearNamedBufferData", "(", "buffer", "uint32", ",", "internalformat", "uint32", ",", "format", "uint32", ",", "xtype", "uint32", ",", "data", "unsafe", ".", "Pointer", ")", "{", "syscall", ".", "Syscall6", "(", "gpClearNamedBufferData", ",", "5", ",", "uintptr", "(", "<mask>", ")", ",", "uintptr", "(", "internalformat", ")", ",", "uintptr", "(", "format", ")", ",", "uintptr", "(", "xtype", ")", ",", "uintptr", "(", "data", ")", ",", "0", ")", "\n", "}" ]
3,431
all-3432
[ "Retrieves", "the", "name", "of", "the", "property", "of", "“target”", "used", "as", "the", "target", "of", "the", "binding", "." ]
[ "func", "(", "v", "*", "Binding", ")", "GetTargetProperty", "(", ")", "string", "{", "s", ":=", "C", ".", "g_binding_get_target_property", "(", "v", ".", "native", "(", ")", ")", "\n", "return", "C", ".", "GoString", "(", "(", "*", "C", ".", "<mask>", ")", "(", "s", ")", ")", "\n", "}" ]
3,432
all-3433
[ "TaskByID", "retrieves", "the", "task", "of", "a", "given", "docker", "container", "id" ]
[ "func", "(", "<mask>", "*", "DockerTaskEngineState", ")", "TaskByID", "(", "cid", "string", ")", "(", "*", "apitask", ".", "Task", ",", "bool", ")", "{", "state", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "state", ".", "lock", ".", "RUnlock", "(", ")", "\n\n", "arn", ",", "found", ":=", "state", ".", "idToTask", "[", "cid", "]", "\n", "if", "!", "found", "{", "return", "nil", ",", "false", "\n", "}", "\n", "return", "state", ".", "taskByArn", "(", "arn", ")", "\n", "}" ]
3,433
all-3434
[ "Fire", "writes", "the", "message", "to", "the", "Stackdriver", "entry", "service", "." ]
[ "func", "(", "sh", "*", "StackdriverHook", ")", "Fire", "(", "entry", "*", "logrus", ".", "Entry", ")", "error", "{", "sh", ".", "waitGroup", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", "entry", "*", "logrus", ".", "Entry", ")", "{", "defer", "sh", ".", "waitGroup", ".", "Done", "(", ")", "\n", "var", "httpReq", "*", "logging", ".", "HttpRequest", "\n\n", "// convert entry data to labels", "labels", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "entry", ".", "Data", ")", ")", "\n", "for", "k", ",", "v", ":=", "<mask>", "entry", ".", "Data", "{", "switch", "x", ":=", "v", ".", "(", "type", ")", "{", "case", "string", ":", "labels", "[", "k", "]", "=", "x", "\n\n", "case", "*", "http", ".", "Request", ":", "httpReq", "=", "&", "logging", ".", "HttpRequest", "{", "Referer", ":", "x", ".", "Referer", "(", ")", ",", "RemoteIp", ":", "x", ".", "RemoteAddr", ",", "RequestMethod", ":", "x", ".", "Method", ",", "RequestUrl", ":", "x", ".", "URL", ".", "String", "(", ")", ",", "UserAgent", ":", "x", ".", "UserAgent", "(", ")", ",", "}", "\n\n", "case", "*", "logging", ".", "HttpRequest", ":", "httpReq", "=", "x", "\n\n", "default", ":", "labels", "[", "k", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "v", ")", "\n", "}", "\n", "}", "\n\n", "// write log entry", "if", "sh", ".", "agentClient", "!=", "nil", "{", "sh", ".", "sendLogMessageViaAgent", "(", "entry", ",", "labels", ",", "httpReq", ")", "\n", "}", "else", "{", "sh", ".", "sendLogMessageViaAPI", "(", "entry", ",", "labels", ",", "httpReq", ")", "\n", "}", "\n", "}", "(", "sh", ".", "copyEntry", "(", "entry", ")", ")", "\n\n", "return", "nil", "\n", "}" ]
3,434
all-3435
[ "Running", "calls", "UI", ".", "Running", "to", "write", ".", "Useful", "when", "you", "want", "separate", "colors", "or", "prefixes", ".", "RunningFGColor", "and", "RunningBGColor", "are", "used", "for", "color", "." ]
[ "func", "(", "ui", "*", "ColorUI", ")", "Running", "(", "<mask>", "string", ")", "{", "ct", ".", "ChangeColor", "(", "ui", ".", "RunningFGColor", ".", "Code", ",", "ui", ".", "RunningFGColor", ".", "Bright", ",", "ui", ".", "RunningBGColor", ".", "Code", ",", "ui", ".", "RunningBGColor", ".", "Bright", ")", "\n", "ui", ".", "UI", ".", "Running", "(", "message", ")", "\n", "ct", ".", "ResetColor", "(", ")", "\n", "}" ]
3,435
all-3436
[ "SetColumnInfo", "replaces", "the", "existing", "column", "info" ]
[ "func", "(", "l", "*", "TableView", ")", "SetColumnInfo", "(", "id", "int", ",", "col", "<mask>", ")", "{", "if", "id", "<", "len", "(", "l", ".", "columns", ")", "{", "l", ".", "columns", "[", "id", "]", "=", "col", "\n", "}", "\n", "}" ]
3,436
all-3437
[ "/", "*", "Returns", "a", "Seq", "of", "countours", "in", "an", "image", "detected", "according", "to", "the", "parameters", ".", "Caller", "must", "Release", "()", "the", "Seq", "returned" ]
[ "func", "(", "<mask>", "*", "IplImage", ")", "FindContours", "(", "mode", ",", "method", "int", ",", "offset", "Point", ")", "*", "Seq", "{", "storage", ":=", "C", ".", "cvCreateMemStorage", "(", "0", ")", "\n", "header_size", ":=", "(", "C", ".", "size_t", ")", "(", "unsafe", ".", "Sizeof", "(", "C", ".", "CvContour", "{", "}", ")", ")", "\n", "var", "seq", "*", "C", ".", "CvSeq", "\n", "C", ".", "cvFindContours", "(", "unsafe", ".", "Pointer", "(", "image", ")", ",", "storage", ",", "&", "seq", ",", "C", ".", "int", "(", "header_size", ")", ",", "C", ".", "int", "(", "mode", ")", ",", "C", ".", "int", "(", "method", ")", ",", "C", ".", "cvPoint", "(", "C", ".", "int", "(", "offset", ".", "X", ")", ",", "C", ".", "int", "(", "offset", ".", "Y", ")", ")", ")", "\n\n", "return", "(", "*", "Seq", ")", "(", "seq", ")", "\n", "}" ]
3,437
all-3438
[ "SwitchToFrame", "focuses", "on", "the", "frame", "specified", "by", "the", "selection", ".", "All", "new", "and", "existing", "selections", "will", "refer", "to", "the", "new", "frame", ".", "All", "further", "Page", "methods", "will", "apply", "to", "this", "frame", "as", "well", "." ]
[ "func", "(", "s", "*", "Selection", ")", "SwitchToFrame", "(", ")", "error", "{", "selectedElement", ",", "err", ":=", "s", ".", "elements", ".", "GetExactlyOne", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ",", "err", ")", "\n", "}", "\n\n", "if", "err", ":=", "s", ".", "<mask>", ".", "Frame", "(", "selectedElement", ".", "(", "*", "api", ".", "Element", ")", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
3,438
all-3439
[ "ValidateCN", "checks", "the", "CN", "of", "a", "verified", "peer", "cert", "and", "raises", "a", "403", "if", "the", "CN", "doesn", "t", "match", "any", "CN", "in", "the", "AllowedCNs", "list", "." ]
[ "func", "(", "a", "*", "Auth", ")", "ValidateCN", "(", "verifiedCert", "*", "x509", ".", "Certificate", ")", "error", "{", "var", "failed", "[", "]", "string", "\n\n", "for", "_", ",", "cn", ":=", "range", "a", ".", "opt", ".", "AllowedCNs", "{", "if", "cn", "==", "verifiedCert", ".", "Subject", ".", "CommonName", "{", "return", "nil", "\n", "}", "\n", "failed", "=", "append", "(", "<mask>", ",", "verifiedCert", ".", "Subject", ".", "CommonName", ")", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "failed", ",", "a", ".", "opt", ".", "AllowedCNs", ")", "\n", "}" ]
3,439
all-3440
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "GetStyleSheetTextParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss36", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
3,440
all-3441
[ "NewEndpoints", "returns", "a", "new", "endpoints", "discovery", "." ]
[ "func", "NewEndpoints", "(", "l", "log", ".", "Logger", ",", "svc", ",", "eps", ",", "pod", "cache", ".", "SharedInformer", ")", "*", "Endpoints", "{", "if", "l", "==", "nil", "{", "l", "=", "log", ".", "NewNopLogger", "(", ")", "\n", "}", "\n", "e", ":=", "&", "Endpoints", "{", "logger", ":", "l", ",", "endpointsInf", ":", "eps", ",", "endpointsStore", ":", "eps", ".", "GetStore", "(", ")", ",", "serviceInf", ":", "svc", ",", "serviceStore", ":", "svc", ".", "GetStore", "(", ")", ",", "podInf", ":", "pod", ",", "podStore", ":", "pod", ".", "GetStore", "(", ")", ",", "queue", ":", "workqueue", ".", "NewNamed", "(", "\"", "\"", ")", ",", "}", "\n\n", "e", ".", "endpointsInf", ".", "AddEventHandler", "(", "cache", ".", "ResourceEventHandlerFuncs", "{", "AddFunc", ":", "func", "(", "o", "interface", "{", "}", ")", "{", "eventCount", ".", "WithLabelValues", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "Inc", "(", ")", "\n", "e", ".", "enqueue", "(", "o", ")", "\n", "}", ",", "UpdateFunc", ":", "func", "(", "_", ",", "o", "interface", "{", "}", ")", "{", "eventCount", ".", "WithLabelValues", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "Inc", "(", ")", "\n", "e", ".", "enqueue", "(", "o", ")", "\n", "}", ",", "DeleteFunc", ":", "func", "(", "o", "interface", "{", "}", ")", "{", "eventCount", ".", "WithLabelValues", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "Inc", "(", ")", "\n", "e", ".", "enqueue", "(", "o", ")", "\n", "}", ",", "}", ")", "\n\n", "serviceUpdate", ":=", "func", "(", "o", "interface", "{", "}", ")", "{", "svc", ",", "err", ":=", "convertToService", "(", "o", ")", "\n", "if", "err", "!=", "nil", "{", "level", ".", "Error", "(", "e", ".", "logger", ")", ".", "<mask>", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n\n", "ep", ":=", "&", "apiv1", ".", "Endpoints", "{", "}", "\n", "ep", ".", "Namespace", "=", "svc", ".", "Namespace", "\n", "ep", ".", "Name", "=", "svc", ".", "Name", "\n", "obj", ",", "exists", ",", "err", ":=", "e", ".", "endpointsStore", ".", "Get", "(", "ep", ")", "\n", "if", "exists", "&&", "err", "==", "nil", "{", "e", ".", "enqueue", "(", "obj", ".", "(", "*", "apiv1", ".", "Endpoints", ")", ")", "\n", "}", "\n\n", "if", "err", "!=", "nil", "{", "level", ".", "Error", "(", "e", ".", "logger", ")", ".", "Log", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n", "e", ".", "serviceInf", ".", "AddEventHandler", "(", "cache", ".", "ResourceEventHandlerFuncs", "{", "// TODO(fabxc): potentially remove add and delete event handlers. Those should", "// be triggered via the endpoint handlers already.", "AddFunc", ":", "func", "(", "o", "interface", "{", "}", ")", "{", "eventCount", ".", "WithLabelValues", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "Inc", "(", ")", "\n", "serviceUpdate", "(", "o", ")", "\n", "}", ",", "UpdateFunc", ":", "func", "(", "_", ",", "o", "interface", "{", "}", ")", "{", "eventCount", ".", "WithLabelValues", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "Inc", "(", ")", "\n", "serviceUpdate", "(", "o", ")", "\n", "}", ",", "DeleteFunc", ":", "func", "(", "o", "interface", "{", "}", ")", "{", "eventCount", ".", "WithLabelValues", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "Inc", "(", ")", "\n", "serviceUpdate", "(", "o", ")", "\n", "}", ",", "}", ")", "\n\n", "return", "e", "\n", "}" ]
3,441
all-3442
[ "Deprecated", ":", "Do", "not", "use", "." ]
[ "func", "(", "m", "*", "AppOverride", ")", "GetMemcachePoolHint", "(", ")", "<mask>", "{", "if", "m", "!=", "nil", "&&", "m", ".", "MemcachePoolHint", "!=", "nil", "{", "return", "*", "m", ".", "MemcachePoolHint", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
3,442
all-3443
[ "NotificationStatus", "returns", "status", "of", "a", "particular", "notification" ]
[ "func", "(", "p", "*", "Pushy", ")", "NotificationStatus", "(", "pushID", "string", ")", "(", "*", "NotificationStatus", ",", "*", "<mask>", ",", "error", ")", "{", "url", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "APIEndpoint", ",", "pushID", ",", "p", ".", "APIToken", ")", "\n", "var", "errResponse", "*", "Error", "\n", "var", "status", "*", "NotificationStatus", "\n", "err", ":=", "get", "(", "p", ".", "httpClient", ",", "url", ",", "&", "status", ",", "&", "errResponse", ")", "\n", "return", "status", ",", "errResponse", ",", "err", "\n", "}" ]
3,443
all-3444
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventDataReceived", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork56", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
3,444
all-3445
[ "NewWithConfig", "creates", "a", "new", "Nitro", "instance", "based", "on", "provided", "configuration", "." ]
[ "func", "NewWithConfig", "(", "cfg", "Config", ")", "*", "Nitro", "{", "m", ":=", "&", "Nitro", "{", "snapshots", ":", "skiplist", ".", "New", "(", ")", ",", "gcsnapshots", ":", "skiplist", ".", "New", "(", ")", ",", "currSn", ":", "1", ",", "Config", ":", "cfg", ",", "gcchan", ":", "make", "(", "chan", "*", "skiplist", ".", "<mask>", ",", "gcchanBufSize", ")", ",", "id", ":", "int", "(", "atomic", ".", "AddInt64", "(", "&", "dbInstancesCount", ",", "1", ")", ")", ",", "}", "\n\n", "m", ".", "freechan", "=", "make", "(", "chan", "*", "skiplist", ".", "Node", ",", "gcchanBufSize", ")", "\n", "m", ".", "store", "=", "skiplist", ".", "NewWithConfig", "(", "m", ".", "newStoreConfig", "(", ")", ")", "\n", "m", ".", "initSizeFuns", "(", ")", "\n\n", "buf", ":=", "dbInstances", ".", "MakeBuf", "(", ")", "\n", "defer", "dbInstances", ".", "FreeBuf", "(", "buf", ")", "\n", "dbInstances", ".", "Insert", "(", "unsafe", ".", "Pointer", "(", "m", ")", ",", "CompareNitro", ",", "buf", ",", "&", "dbInstances", ".", "Stats", ")", "\n\n", "return", "m", "\n\n", "}" ]
3,445
all-3446
[ "UpdateIssueEvents", "fetches", "all", "events", "until", "we", "find", "the", "most", "recent", "we", "have", "in", "db", "and", "saves", "everything", "in", "database" ]
[ "func", "UpdateIssueEvents", "(", "issueID", "int", ",", "<mask>", "*", "gorm", ".", "DB", ",", "client", "ClientInterface", ")", "{", "latest", ",", "err", ":=", "findLatestEvent", "(", "issueID", ",", "db", ",", "client", ".", "RepositoryName", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Error", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "c", ":=", "make", "(", "chan", "*", "github", ".", "IssueEvent", ",", "500", ")", "\n\n", "go", "client", ".", "FetchIssueEvents", "(", "issueID", ",", "latest", ",", "c", ")", "\n", "for", "event", ":=", "range", "c", "{", "eventOrm", ",", "err", ":=", "NewIssueEvent", "(", "event", ",", "issueID", ",", "client", ".", "RepositoryName", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Error", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "db", ".", "Create", "(", "eventOrm", ")", "\n", "}", "\n", "}" ]
3,446
all-3447
[ "PixbufLoaderNew", "()", "is", "a", "wrapper", "around", "gdk_pixbuf_loader_new", "()", "." ]
[ "func", "PixbufLoaderNew", "(", ")", "(", "*", "PixbufLoader", ",", "error", ")", "{", "c", ":=", "C", ".", "gdk_pixbuf_loader_new", "(", ")", "\n", "if", "c", "==", "nil", "{", "return", "nil", ",", "nilPtrErr", "\n", "}", "\n\n", "obj", ":=", "&", "glib", ".", "Object", "{", "glib", ".", "ToGObject", "(", "unsafe", ".", "Pointer", "(", "c", ")", ")", "}", "\n", "p", ":=", "&", "PixbufLoader", "{", "obj", "}", "\n", "obj", ".", "Ref", "(", ")", "\n", "runtime", ".", "SetFinalizer", "(", "p", ",", "func", "(", "_", "<mask>", "{", "}", ")", "{", "obj", ".", "Unref", "(", ")", "}", ")", "\n", "return", "p", ",", "nil", "\n", "}" ]
3,447
all-3448
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "AddCompilationCacheParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage85", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "<mask>", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
3,448
all-3449
[ "DecodeConfig", "returns", "the", "color", "model", "and", "dimensions", "of", "a", "PNG", "image", "without", "decoding", "the", "entire", "image", "." ]
[ "func", "DecodeConfig", "(", "r", "io", ".", "Reader", ")", "(", "image", ".", "Config", ",", "error", ")", "{", "d", ":=", "&", "decoder", "{", "r", ":", "r", ",", "crc", ":", "crc32", ".", "NewIEEE", "(", ")", ",", "}", "\n", "if", "err", ":=", "d", ".", "checkHeader", "(", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "io", ".", "EOF", "{", "err", "=", "io", ".", "ErrUnexpectedEOF", "\n", "}", "\n", "return", "image", ".", "Config", "{", "}", ",", "err", "\n", "}", "\n", "for", "{", "if", "err", ":=", "d", ".", "parseChunk", "(", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "io", ".", "EOF", "{", "err", "=", "io", ".", "ErrUnexpectedEOF", "\n", "}", "\n", "return", "image", ".", "Config", "{", "}", ",", "err", "\n", "}", "\n", "paletted", ":=", "cbPaletted", "(", "d", ".", "cb", ")", "\n", "if", "d", ".", "stage", "==", "dsSeenIHDR", "&&", "!", "paletted", "{", "break", "\n", "}", "\n", "if", "d", ".", "stage", "==", "dsSeenPLTE", "&&", "paletted", "{", "break", "\n", "}", "\n", "}", "\n", "var", "cm", "color", ".", "Model", "\n", "switch", "d", ".", "cb", "{", "case", "cbG1", ",", "cbG2", ",", "cbG4", ",", "cbG8", ":", "cm", "=", "color", ".", "GrayModel", "\n", "case", "cbGA8", ":", "cm", "=", "color", ".", "NRGBAModel", "\n", "case", "cbTC8", ":", "cm", "=", "color", ".", "RGBAModel", "\n", "case", "cbP1", ",", "cbP2", ",", "cbP4", ",", "cbP8", ":", "cm", "=", "d", ".", "palette", "\n", "case", "cbTCA8", ":", "cm", "=", "color", ".", "NRGBAModel", "\n", "case", "cbG16", ":", "cm", "=", "color", ".", "Gray16Model", "\n", "case", "cbGA16", ":", "cm", "=", "<mask>", ".", "NRGBA64Model", "\n", "case", "cbTC16", ":", "cm", "=", "color", ".", "RGBA64Model", "\n", "case", "cbTCA16", ":", "cm", "=", "color", ".", "NRGBA64Model", "\n", "}", "\n", "return", "image", ".", "Config", "{", "ColorModel", ":", "cm", ",", "Width", ":", "d", ".", "width", ",", "Height", ":", "d", ".", "height", ",", "}", ",", "nil", "\n", "}" ]
3,449
all-3450
[ "NewClientFromFile", "reads", "a", "Cluster", "object", "at", "clusterPath", "and", "returns", "an", "authenticated", "client", "using", "the", "keys", "within", "." ]
[ "func", "NewClientFromFile", "(", "clusterPath", ",", "namespace", "string", ")", "(", "*", "<mask>", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "clusterPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "c", "Cluster", "\n", "if", "err", ":=", "yaml", ".", "Unmarshal", "(", "data", ",", "&", "c", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "NewClient", "(", "&", "c", ",", "namespace", ")", "\n", "}" ]
3,450
all-3451
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventDownloadWillBegin", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage67", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
3,451
all-3452
[ "getValidators", "returns", "all", "validators", "that", "apply", "to", "a", "given", "message" ]
[ "func", "(", "p", "*", "PubSub", ")", "getValidators", "(", "msg", "*", "Message", ")", "[", "]", "*", "topicVal", "{", "var", "vals", "[", "]", "*", "topicVal", "\n\n", "for", "_", ",", "topic", ":=", "range", "msg", ".", "GetTopicIDs", "(", ")", "{", "val", ",", "ok", ":=", "p", ".", "topicVals", "[", "topic", "]", "\n", "if", "!", "ok", "{", "<mask>", "\n", "}", "\n\n", "vals", "=", "append", "(", "vals", ",", "val", ")", "\n", "}", "\n\n", "return", "vals", "\n", "}" ]
3,452
all-3453
[ "blobInfoCacheDir", "returns", "a", "path", "to", "a", "blob", "info", "cache", "appropripate", "for", "sys", "and", "euid", ".", "euid", "is", "used", "so", "that", "(", "sudo", "…", ")", "does", "not", "write", "root", "-", "owned", "files", "into", "the", "unprivileged", "users’", "home", "directory", "." ]
[ "func", "blobInfoCacheDir", "(", "sys", "*", "types", ".", "SystemContext", ",", "euid", "int", ")", "(", "string", ",", "error", ")", "{", "if", "sys", "!=", "nil", "&&", "sys", ".", "BlobInfoCacheDir", "!=", "\"", "\"", "{", "return", "sys", ".", "BlobInfoCacheDir", ",", "nil", "\n", "}", "\n\n", "// FIXME? On Windows, os.Geteuid() returns -1. What should we do? Right now we treat it as unprivileged", "// and fail (fall back to memory-only) if neither HOME nor XDG_DATA_HOME is set, which is, at least, safe.", "if", "euid", "==", "0", "{", "if", "sys", "!=", "nil", "&&", "sys", ".", "RootForImplicitAbsolutePaths", "!=", "\"", "\"", "{", "return", "filepath", ".", "Join", "(", "sys", ".", "RootForImplicitAbsolutePaths", ",", "systemBlobInfoCacheDir", ")", ",", "nil", "\n", "}", "\n", "return", "systemBlobInfoCacheDir", ",", "nil", "\n", "}", "\n\n", "// This is intended to mirror the GraphRoot determination in github.com/containers/libpod/pkg/util.GetRootlessStorageOpts.", "dataDir", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "dataDir", "==", "\"", "\"", "{", "<mask>", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "home", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "dataDir", "=", "filepath", ".", "Join", "(", "home", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "filepath", ".", "Join", "(", "dataDir", ",", "\"", "\"", ",", "\"", "\"", ")", ",", "nil", "\n", "}" ]
3,453
all-3454
[ "LogLevel", "returns", "the", "log", "level", "from", "a", "string", "representation", "." ]
[ "func", "LogLevel", "(", "level", "string", ")", "(", "Level", ",", "error", ")", "{", "for", "i", ",", "name", ":=", "range", "levelNames", "{", "if", "strings", ".", "EqualFold", "(", "name", ",", "<mask>", ")", "{", "return", "Level", "(", "i", ")", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "ERROR", ",", "ErrInvalidLogLevel", "\n", "}" ]
3,454
all-3455
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "Node", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoCdp1", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
3,455
all-3456
[ "New", "returns", "a", "sorted", "Labels", "from", "the", "given", "labels", ".", "The", "caller", "has", "to", "guarantee", "that", "all", "label", "names", "are", "unique", "." ]
[ "func", "New", "(", "ls", "...", "Label", ")", "Labels", "{", "set", ":=", "make", "(", "Labels", ",", "0", ",", "len", "(", "ls", ")", ")", "\n", "for", "_", ",", "l", ":=", "range", "ls", "{", "set", "=", "append", "(", "set", ",", "l", ")", "\n", "}", "\n", "sort", ".", "Sort", "(", "set", ")", "\n\n", "return", "<mask>", "\n", "}" ]
3,456
all-3457
[ "Get", "the", "local", "datacenter", "if", "not", "specified", "." ]
[ "func", "(", "d", "*", "Discovery", ")", "getDatacenter", "(", ")", "error", "{", "// If the datacenter was not set from clientConf, let's get it from the local Consul agent", "// (Consul default is to use local node's datacenter if one isn't given for a query).", "if", "d", ".", "clientDatacenter", "!=", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "info", ",", "err", ":=", "d", ".", "client", ".", "Agent", "(", ")", ".", "Self", "(", ")", "\n", "if", "err", "!=", "nil", "{", "level", ".", "Error", "(", "d", ".", "logger", ")", ".", "<mask>", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ")", "\n", "rpcFailuresCount", ".", "Inc", "(", ")", "\n", "return", "err", "\n", "}", "\n\n", "dc", ",", "ok", ":=", "info", "[", "\"", "\"", "]", "[", "\"", "\"", "]", ".", "(", "string", ")", "\n", "if", "!", "ok", "{", "err", ":=", "errors", ".", "Errorf", "(", "\"", "\"", ",", "info", "[", "\"", "\"", "]", "[", "\"", "\"", "]", ")", "\n", "level", ".", "Error", "(", "d", ".", "logger", ")", ".", "Log", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n\n", "d", ".", "clientDatacenter", "=", "dc", "\n", "return", "nil", "\n", "}" ]
3,457
all-3458
[ "ByUsername", "finds", "a", "user", "by", "their", "username", "." ]
[ "func", "(", "u", "*", "UserRepository", ")", "ByUsername", "(", "username", "string", ")", "(", "*", "User", ",", "error", ")", "{", "if", "<mask>", ",", "ok", ":=", "u", ".", "Users", "[", "username", "]", ";", "ok", "{", "return", "user", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "ErrNotFound", "\n", "}" ]
3,458
all-3459
[ "The", "delay", "at", "the", "nth", "retry", "is", "a", "random", "value", "in", "the", "range", "[", "i", "-", "i", "/", "2", "i", "+", "i", "/", "2", "]", "where", "i", "=", "InitialInterval", "*", "1", ".", "5^", "(", "n", "-", "1", ")", "." ]
[ "func", "(", "t", "*", "target", ")", "nextTryLater", "(", ")", "{", "t", ".", "tryAfter", "=", "time", ".", "Now", "(", ")", ".", "Add", "(", "t", ".", "tryInterval", "/", "2", "+", "time", ".", "Duration", "(", "<mask>", ".", "Int63n", "(", "int64", "(", "t", ".", "tryInterval", ")", ")", ")", ")", "\n", "t", ".", "tryInterval", "=", "t", ".", "tryInterval", "*", "3", "/", "2", "\n", "if", "t", ".", "tryInterval", ">", "maxInterval", "{", "t", ".", "tryInterval", "=", "maxInterval", "\n", "}", "\n", "}" ]
3,459
all-3460
[ "NewImage", "returns", "a", "types", ".", "ImageCloser", "for", "this", "reference", "possibly", "specialized", "for", "this", "ImageTransport", ".", "The", "caller", "must", "call", ".", "Close", "()", "on", "the", "returned", "ImageCloser", ".", "NOTE", ":", "If", "any", "kind", "of", "signature", "verification", "should", "happen", "build", "an", "UnparsedImage", "from", "the", "value", "returned", "by", "NewImageSource", "verify", "that", "UnparsedImage", "and", "convert", "it", "into", "a", "real", "Image", "via", "image", ".", "FromUnparsedImage", ".", "WARNING", ":", "This", "may", "not", "do", "the", "right", "thing", "for", "a", "manifest", "list", "see", "image", ".", "FromSource", "for", "details", "." ]
[ "func", "(", "s", "storageReference", ")", "NewImage", "(", "ctx", "context", ".", "<mask>", ",", "sys", "*", "types", ".", "SystemContext", ")", "(", "types", ".", "ImageCloser", ",", "error", ")", "{", "return", "newImage", "(", "ctx", ",", "sys", ",", "s", ")", "\n", "}" ]
3,460
all-3461
[ "Remove", "removes", "a", "peer", "from", "the", "peer", "list", ".", "It", "returns", "an", "error", "if", "the", "peer", "cannot", "be", "found", ".", "Remove", "does", "not", "affect", "connections", "to", "the", "peer", "in", "any", "way", "." ]
[ "func", "(", "l", "*", "PeerList", ")", "Remove", "(", "hostPort", "string", ")", "error", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n\n", "p", ",", "<mask>", ":=", "l", ".", "peersByHostPort", "[", "hostPort", "]", "\n", "if", "!", "ok", "{", "return", "ErrPeerNotFound", "\n", "}", "\n\n", "p", ".", "delSC", "(", ")", "\n", "delete", "(", "l", ".", "peersByHostPort", ",", "hostPort", ")", "\n", "l", ".", "peerHeap", ".", "removePeer", "(", "p", ")", "\n\n", "return", "nil", "\n", "}" ]
3,461
all-3462
[ "connectionStateChanged", "is", "called", "when", "one", "of", "the", "peers", "connections", "states", "changes", ".", "All", "non", "-", "active", "connections", "are", "removed", "from", "the", "peer", ".", "The", "connection", "will", "still", "be", "tracked", "by", "the", "channel", "until", "it", "s", "completely", "closed", "." ]
[ "func", "(", "p", "*", "Peer", ")", "connectionCloseStateChange", "(", "changed", "*", "Connection", ")", "{", "if", "changed", ".", "IsActive", "(", ")", "{", "return", "\n", "}", "\n\n", "p", ".", "Lock", "(", ")", "\n", "found", ":=", "p", ".", "removeConnection", "(", "&", "p", ".", "inboundConnections", ",", "changed", ")", "\n", "if", "!", "found", "{", "found", "=", "p", ".", "removeConnection", "(", "&", "p", ".", "outboundConnections", ",", "<mask>", ")", "\n", "}", "\n", "p", ".", "Unlock", "(", ")", "\n\n", "if", "found", "{", "p", ".", "onClosedConnRemoved", "(", "p", ")", "\n", "// Inform third parties that a peer lost a connection.", "p", ".", "onStatusChanged", "(", "p", ")", "\n", "}", "\n", "}" ]
3,462
all-3463
[ "newConn", "constructs", "a", "new", "connection" ]
[ "func", "newSingleConn", "(", "ctx", "context", ".", "Context", ",", "local", ",", "remote", "peer", ".", "<mask>", ",", "maconn", "tpt", ".", "Conn", ")", "iconn", ".", "Conn", "{", "ml", ":=", "lgbl", ".", "Dial", "(", "\"", "\"", ",", "local", ",", "remote", ",", "maconn", ".", "LocalMultiaddr", "(", ")", ",", "maconn", ".", "RemoteMultiaddr", "(", ")", ")", "\n\n", "conn", ":=", "&", "singleConn", "{", "local", ":", "local", ",", "remote", ":", "remote", ",", "maconn", ":", "maconn", ",", "event", ":", "log", ".", "EventBegin", "(", "ctx", ",", "\"", "\"", ",", "ml", ")", ",", "}", "\n\n", "log", ".", "Debugf", "(", "\"", "\"", ",", "conn", ",", "local", ",", "remote", ")", "\n", "return", "conn", "\n", "}" ]
3,463
all-3464
[ "expandBaseClusterDasAdmissionControlPolicy", "reads", "certain", "ResourceData", "keys", "and", "returns", "a", "BaseClusterDasAdmissionControlPolicy", "." ]
[ "func", "expandBaseClusterDasAdmissionControlPolicy", "(", "d", "*", "schema", ".", "ResourceData", ",", "policy", "string", ",", "version", "viapi", ".", "VSphereVersion", ",", ")", "types", ".", "BaseClusterDasAdmissionControlPolicy", "{", "var", "obj", "types", ".", "BaseClusterDasAdmissionControlPolicy", "\n\n", "switch", "policy", "{", "<mask>", "clusterAdmissionControlTypeResourcePercentage", ":", "obj", "=", "expandClusterFailoverResourcesAdmissionControlPolicy", "(", "d", ",", "version", ")", "\n", "case", "clusterAdmissionControlTypeSlotPolicy", ":", "obj", "=", "expandClusterFailoverLevelAdmissionControlPolicy", "(", "d", ")", "\n", "case", "clusterAdmissionControlTypeFailoverHosts", ":", "obj", "=", "expandClusterFailoverHostAdmissionControlPolicy", "(", "d", ",", "version", ")", "\n", "case", "clusterAdmissionControlTypeDisabled", ":", "return", "nil", "\n", "}", "\n\n", "if", "version", ".", "Newer", "(", "viapi", ".", "VSphereVersion", "{", "Product", ":", "version", ".", "Product", ",", "Major", ":", "6", ",", "Minor", ":", "5", "}", ")", "{", "obj", ".", "GetClusterDasAdmissionControlPolicy", "(", ")", ".", "ResourceReductionToToleratePercent", "=", "int32", "(", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "int", ")", ")", "\n", "}", "\n\n", "return", "obj", "\n", "}" ]
3,464
all-3465
[ "MustResults", "retrieves", "the", "Results", "value", "from", "the", "union", "panicing", "if", "the", "value", "is", "not", "set", "." ]
[ "func", "(", "u", "TransactionResultResult", ")", "MustResults", "(", ")", "[", "]", "OperationResult", "{", "val", ",", "<mask>", ":=", "u", ".", "GetResults", "(", ")", "\n\n", "if", "!", "ok", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "val", "\n", "}" ]
3,465
all-3466
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "TakeCoverageDeltaParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss2", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "<mask>", "(", ")", "\n", "}" ]
3,466
all-3467
[ "HasType", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "t", "*", "TraceServiceDefinition", ")", "HasType", "(", ")", "bool", "{", "if", "t", "!=", "nil", "&&", "t", ".", "<mask>", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
3,467
all-3468
[ "rangeChan", "emits", "to", "fn", "the", "header", "for", "a", "loop", "that", "receives", "from", "channel", "x", "until", "it", "fails", ".", "tk", "is", "the", "channel", "s", "element", "type", "or", "nil", "if", "the", "k", "result", "is", "not", "wanted", "pos", "is", "the", "position", "of", "the", "=", "or", ":", "=", "token", "." ]
[ "func", "(", "b", "*", "builder", ")", "rangeChan", "(", "fn", "*", "Function", ",", "x", "Value", ",", "tk", "types", ".", "Type", ",", "pos", "token", ".", "Pos", ")", "(", "k", "Value", ",", "loop", ",", "done", "*", "BasicBlock", ")", "{", "//", "// loop: (target of continue)", "// ko = <-x (key, ok)", "// ok = extract ko #1", "// if ok goto body else done", "// body:", "// k = extract ko #0", "// ...", "// goto loop", "// done: (target of break)", "loop", "=", "fn", ".", "newBasicBlock", "(", "\"", "\"", ")", "\n", "emitJump", "(", "fn", ",", "loop", ")", "\n", "fn", ".", "currentBlock", "=", "loop", "\n", "recv", ":=", "&", "UnOp", "{", "Op", ":", "token", ".", "ARROW", ",", "X", ":", "x", ",", "CommaOk", ":", "true", ",", "}", "\n", "recv", ".", "setPos", "(", "pos", ")", "\n", "recv", ".", "setType", "(", "types", ".", "NewTuple", "(", "newVar", "(", "\"", "\"", ",", "x", ".", "Type", "(", ")", ".", "Underlying", "(", ")", ".", "(", "*", "types", ".", "Chan", ")", ".", "Elem", "(", ")", ")", ",", "varOk", ",", ")", ")", "\n", "ko", ":=", "fn", ".", "emit", "(", "recv", ")", "\n", "body", ":=", "fn", ".", "newBasicBlock", "(", "\"", "\"", ")", "\n", "<mask>", "=", "fn", ".", "newBasicBlock", "(", "\"", "\"", ")", "\n", "emitIf", "(", "fn", ",", "emitExtract", "(", "fn", ",", "ko", ",", "1", ")", ",", "body", ",", "done", ")", "\n", "fn", ".", "currentBlock", "=", "body", "\n", "if", "tk", "!=", "nil", "{", "k", "=", "emitExtract", "(", "fn", ",", "ko", ",", "0", ")", "\n", "}", "\n", "return", "\n", "}" ]
3,468
all-3469
[ "The", "For", "method", "is", "obsolete", "and", "will", "be", "removed", "in", "a", "future", "release", ".", "See", "Iter", "as", "an", "elegant", "replacement", "." ]
[ "func", "(", "q", "*", "Query", ")", "For", "(", "result", "interface", "{", "}", ",", "f", "func", "(", ")", "error", ")", "error", "{", "return", "q", ".", "Iter", "(", ")", ".", "For", "(", "<mask>", ",", "f", ")", "\n", "}" ]
3,469
all-3470
[ "validate", "checks", "app", "pool", "and", "plan" ]
[ "func", "(", "app", "*", "App", ")", "validate", "(", ")", "error", "{", "err", ":=", "app", ".", "validatePool", "(", ")", "\n", "if", "<mask>", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "app", ".", "validatePlan", "(", ")", "\n", "}" ]
3,470
all-3471
[ "Get", "a", "session", "using", "a", "request", "and", "response", "." ]
[ "func", "(", "a", "*", "App", ")", "getSession", "(", "r", "*", "http", ".", "Request", ",", "w", "http", ".", "ResponseWriter", ")", "*", "Session", "{", "if", "a", ".", "root", "!=", "nil", "{", "return", "a", ".", "root", ".", "getSession", "(", "r", ",", "w", ")", "\n", "}", "\n", "session", ",", "_", ":=", "a", ".", "SessionStore", ".", "Get", "(", "r", ",", "a", ".", "SessionName", ")", "\n", "return", "&", "<mask>", "{", "Session", ":", "session", ",", "req", ":", "r", ",", "res", ":", "w", ",", "}", "\n", "}" ]
3,471
all-3472
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "LoadSnapshotReturns", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoLayertree12", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
3,472
all-3473
[ "Close", "closes", "the", "network", "listener", "and", "the", "active", "connections", "." ]
[ "func", "(", "s", "*", "Server", ")", "Close", "(", ")", "error", "{", "if", "!", "s", ".", "running", ".", "Load", "(", ")", ".", "(", "bool", ")", "{", "return", "nil", "\n", "}", "\n", "s", ".", "running", ".", "Store", "(", "false", ")", "\n", "err", ":=", "s", ".", "listener", ".", "Close", "(", ")", "\n\n", "// close all active connections discarding any read/writes that is going on currently", "s", ".", "conns", ".", "Range", "(", "func", "(", "c", "interface", "{", "}", ")", "{", "c", ".", "(", "*", "Conn", ")", ".", "Close", "(", ")", "\n", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "s", ".", "wg", ".", "Wait", "(", ")", "\n", "<mask>", ".", "Printf", "(", "\"", "\"", ",", "s", ".", "addr", ")", "\n", "return", "nil", "\n", "}" ]
3,473
all-3474
[ "MarshalEasyJSON", "writes", "the", "Date", "to", "a", "easyjson", ".", "Writer" ]
[ "func", "(", "d", "Date", ")", "MarshalEasyJSON", "(", "w", "*", "jwriter", ".", "Writer", ")", "{", "w", ".", "<mask>", "(", "time", ".", "Time", "(", "d", ")", ".", "Format", "(", "RFC3339FullDate", ")", ")", "\n", "}" ]
3,474
all-3475
[ "Put", "saves", "the", "entity", "src", "into", "the", "datastore", "with", "key", "k", ".", "src", "must", "be", "a", "struct", "pointer", "or", "implement", "PropertyLoadSaver", ";", "if", "a", "struct", "pointer", "then", "any", "unexported", "fields", "of", "that", "struct", "will", "be", "skipped", ".", "If", "k", "is", "an", "incomplete", "key", "the", "returned", "key", "will", "be", "a", "unique", "key", "generated", "by", "the", "datastore", "." ]
[ "func", "Put", "(", "c", "context", ".", "Context", ",", "key", "*", "Key", ",", "src", "interface", "{", "}", ")", "(", "*", "Key", ",", "error", ")", "{", "k", ",", "err", ":=", "PutMulti", "(", "c", ",", "[", "]", "*", "Key", "{", "key", "}", ",", "[", "]", "interface", "{", "}", "{", "src", "}", ")", "\n", "if", "err", "!=", "nil", "{", "if", "<mask>", ",", "ok", ":=", "err", ".", "(", "appengine", ".", "MultiError", ")", ";", "ok", "{", "return", "nil", ",", "me", "[", "0", "]", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "k", "[", "0", "]", ",", "nil", "\n", "}" ]
3,475
all-3476
[ "Depth", "is", "a", "wrapper", "around", "g_type_depth", "()", "." ]
[ "func", "(", "t", "<mask>", ")", "Depth", "(", ")", "uint", "{", "return", "uint", "(", "C", ".", "g_type_depth", "(", "C", ".", "GType", "(", "t", ")", ")", ")", "\n", "}" ]
3,476
all-3477
[ "NewDecoder", "returns", "a", "new", "JSON", "decoder", "that", "parses", "values", "from", "r", "." ]
[ "func", "NewDecoder", "(", "r", "<mask>", ".", "Reader", ")", "*", "objconv", ".", "Decoder", "{", "return", "objconv", ".", "NewDecoder", "(", "NewParser", "(", "r", ")", ")", "\n", "}" ]
3,477
all-3478
[ "NewPriorityQueue", "creates", "an", "etcd", "priority", "queue", "." ]
[ "func", "NewPriorityQueue", "(", "client", "*", "v3", ".", "Client", ",", "<mask>", "string", ")", "*", "PriorityQueue", "{", "return", "&", "PriorityQueue", "{", "client", ",", "context", ".", "TODO", "(", ")", ",", "key", "+", "\"", "\"", "}", "\n", "}" ]
3,478
all-3479
[ "UserToDevice", "is", "a", "wrapper", "around", "cairo_user_to_device", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "UserToDevice", "(", "x", ",", "y", "float64", ")", "(", "float64", ",", "float64", ")", "{", "C", ".", "cairo_user_to_device", "(", "v", ".", "native", "(", ")", ",", "(", "*", "C", ".", "double", ")", "(", "&", "x", ")", ",", "(", "*", "C", ".", "double", ")", "(", "&", "y", ")", ")", "\n", "return", "x", ",", "y", "\n", "}" ]
3,479
all-3480
[ "GetType", "returns", "the", "Type", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "s", "*", "SyntheticsAssertion", ")", "GetType", "(", ")", "string", "{", "if", "s", "==", "nil", "||", "s", ".", "<mask>", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "s", ".", "Type", "\n", "}" ]
3,480
all-3481
[ "Insert", "the", "route", "in", "the", "Trie", "following", "or", "creating", "the", "nodes", "corresponding", "to", "the", "path", "." ]
[ "func", "(", "t", "*", "Trie", ")", "AddRoute", "(", "httpMethod", ",", "pathExp", "string", ",", "route", "<mask>", "{", "}", ")", "error", "{", "return", "t", ".", "root", ".", "addRoute", "(", "httpMethod", ",", "pathExp", ",", "route", ",", "[", "]", "string", "{", "}", ")", "\n", "}" ]
3,481
all-3482
[ "addJob", "adds", "a", "cron", "entry", "for", "a", "job", "to", "cronAgent" ]
[ "func", "(", "c", "*", "Cron", ")", "addJob", "(", "name", ",", "cron", "string", ")", "error", "{", "id", ",", "err", ":=", "c", ".", "cronAgent", ".", "AddFunc", "(", "\"", "\"", "+", "cron", ",", "func", "(", ")", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "<mask>", ".", "Unlock", "(", ")", "\n\n", "c", ".", "jobs", "[", "name", "]", ".", "triggered", "=", "true", "\n", "c", ".", "logger", ".", "Infof", "(", "\"", "\"", ",", "name", ")", "\n", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "cron", ",", "err", ")", "\n", "}", "\n\n", "c", ".", "jobs", "[", "name", "]", "=", "&", "jobStatus", "{", "entryID", ":", "id", ",", "cronStr", ":", "cron", ",", "// try to kick of a periodic trigger right away", "triggered", ":", "strings", ".", "HasPrefix", "(", "cron", ",", "\"", "\"", ")", ",", "}", "\n\n", "c", ".", "logger", ".", "Infof", "(", "\"", "\"", ",", "name", ",", "cron", ")", "\n", "return", "nil", "\n", "}" ]
3,482
all-3483
[ "GetRemoteFile", "-", "get", "a", "file", "from", "a", "remote", "system", "and", "return", "a", "writecloser", "to", "it" ]
[ "func", "(", "s", "*", "RemoteOperations", ")", "GetRemoteFile", "(", ")", "(", "rfile", "io", ".", "WriteCloser", ",", "err", "error", ")", "{", "<mask>", "sftpclient", "SFTPClient", "\n", "sftpclient", ",", "err", "=", "s", ".", "getClient", "(", ")", "\n\n", "if", "err", "==", "nil", "{", "rfile", ",", "err", "=", "SafeCreateSSH", "(", "sftpclient", ",", "s", ".", "remotePath", ")", "\n", "}", "\n\n", "return", "\n", "}" ]
3,483
all-3484
[ "Registers", "a", "handler" ]
[ "func", "(", "hmap", "*", "handlerMap", ")", "register", "(", "h", "Handler", ",", "method", "string", ")", "{", "hmap", ".", "Lock", "(", ")", "\n", "defer", "hmap", ".", "Unlock", "(", ")", "\n\n", "if", "hmap", ".", "handlers", "==", "nil", "{", "hmap", ".", "handlers", "=", "<mask>", "(", "map", "[", "string", "]", "Handler", ")", "\n", "}", "\n\n", "hmap", ".", "handlers", "[", "method", "]", "=", "h", "\n", "}" ]
3,484
all-3485
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "SetBreakpointByURLParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger15", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
3,485
all-3486
[ "GetId", "returns", "the", "Id", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "a", "*", "Alert", ")", "GetId", "(", ")", "int", "{", "if", "a", "==", "nil", "||", "a", ".", "Id", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "a", ".", "<mask>", "\n", "}" ]
3,486
all-3487
[ "Read", "reads", "a", "vsphere_virtual_machine", "cdrom", "sub", "-", "resource", "." ]
[ "func", "(", "r", "*", "CdromSubresource", ")", "Read", "(", "l", "object", ".", "VirtualDeviceList", ")", "error", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ")", "\n", "d", ",", "err", ":=", "r", ".", "FindVirtualDevice", "(", "l", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "device", ",", "ok", ":=", "d", ".", "(", "*", "types", ".", "VirtualCdrom", ")", "\n", "if", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "l", ".", "Name", "(", "d", ")", ")", "\n", "}", "\n", "// Only read backing info if it's available.", "switch", "backing", ":=", "device", ".", "Backing", ".", "(", "type", ")", "{", "case", "*", "types", ".", "VirtualCdromRemoteAtapiBackingInfo", ":", "r", ".", "Set", "(", "\"", "\"", ",", "true", ")", "\n", "case", "*", "types", ".", "VirtualCdromIsoBackingInfo", ":", "dp", ":=", "&", "<mask>", ".", "DatastorePath", "{", "}", "\n", "if", "ok", ":=", "dp", ".", "FromString", "(", "backing", ".", "FileName", ")", ";", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "backing", ".", "FileName", ")", "\n", "}", "\n", "// If a vApp ISO was inserted, it will be removed if the VM is powered off", "// and cause backing.Datastore to be nil.", "if", "backing", ".", "Datastore", "!=", "nil", "{", "r", ".", "Set", "(", "\"", "\"", ",", "backing", ".", "Datastore", ".", "Value", ")", "\n", "}", "\n", "r", ".", "Set", "(", "\"", "\"", ",", "dp", ".", "Path", ")", "\n", "default", ":", "// This is an unsupported entry, so we clear all attributes in the", "// subresource (except for the device address and key, of course). In", "// addition to making sure correct diffs get created for these kinds of", "// devices, this ensures we don't fail on CDROM device types we don't", "// support right now, such as passthrough devices. We might support these", "// later.", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ",", "backing", ")", "\n", "r", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "r", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "r", ".", "Set", "(", "\"", "\"", ",", "false", ")", "\n", "}", "\n", "// Save the device key and address data", "ctlr", ",", "err", ":=", "findControllerForDevice", "(", "l", ",", "d", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "r", ".", "SaveDevIDs", "(", "d", ",", "ctlr", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ")", "\n", "return", "nil", "\n", "}" ]
3,487
all-3488
[ "Register", "registers", "the", "given", "TChanServer", "to", "be", "called", "on", "any", "incoming", "call", "for", "its", "services", ".", "TODO", "(", "prashant", ")", ":", "Replace", "Register", "call", "with", "this", "call", "." ]
[ "func", "(", "s", "*", "Server", ")", "Register", "(", "svr", "TChanServer", ",", "opts", "...", "RegisterOption", ")", "{", "service", ":=", "svr", ".", "<mask>", "(", ")", "\n", "handler", ":=", "&", "handler", "{", "server", ":", "svr", "}", "\n", "for", "_", ",", "opt", ":=", "range", "opts", "{", "opt", ".", "Apply", "(", "handler", ")", "\n", "}", "\n\n", "s", ".", "Lock", "(", ")", "\n", "s", ".", "handlers", "[", "service", "]", "=", "*", "handler", "\n", "s", ".", "Unlock", "(", ")", "\n\n", "for", "_", ",", "m", ":=", "range", "svr", ".", "Methods", "(", ")", "{", "s", ".", "ch", ".", "Register", "(", "s", ",", "service", "+", "\"", "\"", "+", "m", ")", "\n", "}", "\n", "}" ]
3,488
all-3489
[ "GetRunCheck", "returns", "the", "RunCheck", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "i", "*", "IntegrationPDRequest", ")", "GetRunCheck", "(", ")", "bool", "{", "if", "i", "==", "nil", "||", "i", ".", "RunCheck", "==", "nil", "{", "return", "<mask>", "\n", "}", "\n", "return", "*", "i", ".", "RunCheck", "\n", "}" ]
3,489
all-3490
[ "Reset", "removes", "all", "existing", "counters", "and", "gauges", "." ]
[ "func", "(", "m", "*", "CirconusMetrics", ")", "Reset", "(", ")", "{", "m", ".", "cm", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "cm", ".", "Unlock", "(", ")", "\n\n", "m", ".", "cfm", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "cfm", ".", "Unlock", "(", ")", "\n\n", "m", ".", "gm", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "gm", ".", "Unlock", "(", ")", "\n\n", "m", ".", "gfm", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "gfm", ".", "Unlock", "(", ")", "\n\n", "m", ".", "hm", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "hm", ".", "Unlock", "(", ")", "\n\n", "m", ".", "tm", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "tm", ".", "Unlock", "(", ")", "\n\n", "m", ".", "tfm", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "tfm", ".", "Unlock", "(", ")", "\n\n", "m", ".", "counters", "=", "make", "(", "map", "[", "string", "]", "uint64", ")", "\n", "m", ".", "counterFuncs", "=", "make", "(", "map", "[", "string", "]", "func", "(", ")", "uint64", ")", "\n", "m", ".", "gauges", "=", "make", "(", "map", "[", "string", "]", "<mask>", "{", "}", ")", "\n", "m", ".", "gaugeFuncs", "=", "make", "(", "map", "[", "string", "]", "func", "(", ")", "int64", ")", "\n", "m", ".", "histograms", "=", "make", "(", "map", "[", "string", "]", "*", "Histogram", ")", "\n", "m", ".", "text", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "m", ".", "textFuncs", "=", "make", "(", "map", "[", "string", "]", "func", "(", ")", "string", ")", "\n", "}" ]
3,490
all-3491
[ "InsertItem", "is", "a", "wrapper", "around", "g_menu_insert_item", "()", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "InsertItem", "(", "position", "int", ",", "item", "*", "MenuItem", ")", "{", "C", ".", "g_menu_insert_item", "(", "v", ".", "native", "(", ")", ",", "C", ".", "gint", "(", "position", ")", ",", "item", ".", "native", "(", ")", ")", "\n", "}" ]
3,491
all-3492
[ "GetType", "returns", "the", "Type", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "i", "*", "IframeDefinition", ")", "GetType", "(", ")", "string", "{", "if", "i", "==", "nil", "||", "i", ".", "Type", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "i", ".", "<mask>", "\n", "}" ]
3,492
all-3493
[ "RelBaseName", "returns", "the", "base", "name", "for", "rel", "a", "slash", "-", "separated", "path", "relative", "to", "the", "repository", "root", ".", "If", "rel", "is", "empty", "RelBaseName", "returns", "the", "base", "name", "of", "prefix", ".", "If", "prefix", "is", "empty", "RelBaseName", "returns", "the", "base", "name", "of", "root", "the", "absolute", "file", "path", "of", "the", "repository", "root", "directory", ".", "If", "that", "s", "empty", "to", "then", "RelBaseName", "returns", "root", "." ]
[ "func", "RelBaseName", "(", "rel", ",", "prefix", ",", "root", "string", ")", "string", "{", "base", ":=", "path", ".", "Base", "(", "rel", ")", "\n", "if", "base", "==", "\"", "\"", "||", "base", "==", "\"", "\"", "{", "base", "=", "path", ".", "Base", "(", "prefix", ")", "\n", "}", "\n", "if", "<mask>", "==", "\"", "\"", "||", "base", "==", "\"", "\"", "{", "base", "=", "filepath", ".", "Base", "(", "root", ")", "\n", "}", "\n", "if", "base", "==", "\"", "\"", "||", "base", "==", "\"", "\"", "{", "base", "=", "\"", "\"", "\n", "}", "\n", "return", "base", "\n", "}" ]
3,493
all-3494
[ "SetTooltipText", "is", "a", "wrapper", "around", "gtk_status_icon_set_tooltip_text", "()" ]
[ "func", "(", "v", "*", "StatusIcon", ")", "SetTooltipText", "(", "text", "string", ")", "{", "cstr", ":=", "C", ".", "CString", "(", "text", ")", "\n", "defer", "C", ".", "<mask>", "(", "unsafe", ".", "Pointer", "(", "cstr", ")", ")", "\n", "C", ".", "gtk_status_icon_set_tooltip_text", "(", "v", ".", "native", "(", ")", ",", "(", "*", "C", ".", "gchar", ")", "(", "cstr", ")", ")", "\n", "}" ]
3,494
all-3495
[ "recursiveWalk", "is", "used", "to", "do", "a", "pre", "-", "order", "walk", "of", "a", "node", "recursively", ".", "Returns", "true", "if", "the", "walk", "should", "be", "aborted" ]
[ "func", "recursiveWalk", "(", "n", "*", "node", ",", "fn", "WalkFn", ")", "bool", "{", "// Visit the leaf values if any", "if", "n", ".", "leaf", "!=", "nil", "&&", "fn", "(", "n", ".", "leaf", ".", "key", ",", "n", ".", "leaf", ".", "val", ")", "{", "return", "<mask>", "\n", "}", "\n\n", "// Recurse on the children", "for", "_", ",", "e", ":=", "range", "n", ".", "edges", "{", "if", "recursiveWalk", "(", "e", ".", "node", ",", "fn", ")", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
3,495
all-3496
[ "Given", "the", "path", "to", "a", "device", "and", "it", "s", "cgroup_permissions", "(", "which", "cannot", "be", "easily", "queried", ")", "look", "up", "the", "information", "about", "a", "linux", "device", "and", "return", "that", "information", "as", "a", "Device", "struct", "." ]
[ "func", "DeviceFromPath", "(", "path", ",", "permissions", "string", ")", "(", "*", "configs", ".", "Device", ",", "error", ")", "{", "fileInfo", ",", "err", ":=", "osLstat", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "(", "devType", "rune", "\n", "mode", "=", "fileInfo", ".", "Mode", "(", ")", "\n", "fileModePermissionBits", "=", "os", ".", "FileMode", ".", "Perm", "(", "mode", ")", "\n", ")", "\n", "<mask>", "{", "case", "mode", "&", "os", ".", "ModeDevice", "==", "0", ":", "return", "nil", ",", "ErrNotADevice", "\n", "case", "mode", "&", "os", ".", "ModeCharDevice", "!=", "0", ":", "fileModePermissionBits", "|=", "syscall", ".", "S_IFCHR", "\n", "devType", "=", "'c'", "\n", "default", ":", "fileModePermissionBits", "|=", "syscall", ".", "S_IFBLK", "\n", "devType", "=", "'b'", "\n", "}", "\n", "stat_t", ",", "ok", ":=", "fileInfo", ".", "Sys", "(", ")", ".", "(", "*", "syscall", ".", "Stat_t", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "path", ")", "\n", "}", "\n", "devNumber", ":=", "int", "(", "stat_t", ".", "Rdev", ")", "\n", "return", "&", "configs", ".", "Device", "{", "Type", ":", "devType", ",", "Path", ":", "path", ",", "Major", ":", "Major", "(", "devNumber", ")", ",", "Minor", ":", "Minor", "(", "devNumber", ")", ",", "Permissions", ":", "permissions", ",", "FileMode", ":", "fileModePermissionBits", ",", "Uid", ":", "stat_t", ".", "Uid", ",", "Gid", ":", "stat_t", ".", "Gid", ",", "}", ",", "nil", "\n", "}" ]
3,496
all-3497
[ "UpdateLayerInfos", "replaces", "the", "original", "layers", "with", "the", "specified", "BlobInfos", "(", "size", "+", "digest", "+", "urls", ")", "in", "order", "(", "the", "root", "layer", "first", "and", "then", "successive", "layered", "layers", ")" ]
[ "func", "(", "m", "*", "Schema1", ")", "UpdateLayerInfos", "(", "layerInfos", "[", "]", "types", ".", "BlobInfo", ")", "error", "{", "// Our LayerInfos includes empty layers (where m.ExtractedV1Compatibility[].ThrowAway), so expect them to be included here as well.", "if", "len", "(", "m", ".", "FSLayers", ")", "!=", "len", "(", "layerInfos", ")", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "m", ".", "FSLayers", ")", ",", "len", "(", "layerInfos", ")", ")", "\n", "}", "\n", "m", ".", "FSLayers", "=", "<mask>", "(", "[", "]", "Schema1FSLayers", ",", "len", "(", "layerInfos", ")", ")", "\n", "for", "i", ",", "info", ":=", "range", "layerInfos", "{", "// (docker push) sets up m.ExtractedV1Compatibility[].{Id,Parent} based on values of info.Digest,", "// but (docker pull) ignores them in favor of computing DiffIDs from uncompressed data, except verifying the child->parent links and uniqueness.", "// So, we don't bother recomputing the IDs in m.History.V1Compatibility.", "m", ".", "FSLayers", "[", "(", "len", "(", "layerInfos", ")", "-", "1", ")", "-", "i", "]", ".", "BlobSum", "=", "info", ".", "Digest", "\n", "}", "\n", "return", "nil", "\n", "}" ]
3,497
all-3498
[ "isFile", "returns", "true", "if", "the", "path", "is", "a", "valid", "file", "." ]
[ "func", "isFile", "(", "p", "string", ")", "bool", "{", "// TODO(maruel): Is it faster to open the file or to stat it? Worth a perf", "// test on Windows.", "i", ",", "err", ":=", "<mask>", ".", "Stat", "(", "p", ")", "\n", "return", "err", "==", "nil", "&&", "!", "i", ".", "IsDir", "(", ")", "\n", "}" ]
3,498
all-3499
[ "title", ":", "regenerate", "token", "path", ":", "/", "users", "/", "api", "-", "key", "method", ":", "POST", "produce", ":", "application", "/", "json", "responses", ":", "200", ":", "OK", "401", ":", "Unauthorized", "404", ":", "User", "not", "found" ]
[ "func", "regenerateAPIToken", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "t", "auth", ".", "Token", ")", "(", "err", "error", ")", "{", "email", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "<mask>", "==", "\"", "\"", "{", "email", "=", "t", ".", "GetUserName", "(", ")", "\n", "}", "\n", "allowed", ":=", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermUserUpdateToken", ",", "permission", ".", "Context", "(", "permTypes", ".", "CtxUser", ",", "email", ")", ",", ")", "\n", "if", "!", "allowed", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "evt", ",", "err", ":=", "event", ".", "New", "(", "&", "event", ".", "Opts", "{", "Target", ":", "userTarget", "(", "email", ")", ",", "Kind", ":", "permission", ".", "PermUserUpdateToken", ",", "Owner", ":", "t", ",", "CustomData", ":", "event", ".", "FormToCustomData", "(", "InputFields", "(", "r", ")", ")", ",", "Allowed", ":", "event", ".", "Allowed", "(", "permission", ".", "PermUserReadEvents", ",", "permission", ".", "Context", "(", "permTypes", ".", "CtxUser", ",", "email", ")", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "func", "(", ")", "{", "evt", ".", "Done", "(", "err", ")", "}", "(", ")", "\n", "u", ",", "err", ":=", "auth", ".", "GetUserByEmail", "(", "email", ")", "\n", "if", "err", "!=", "nil", "{", "return", "&", "errors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusNotFound", ",", "Message", ":", "err", ".", "Error", "(", ")", "}", "\n", "}", "\n", "apiKey", ",", "err", ":=", "u", ".", "RegenerateAPIKey", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "w", ".", "Header", "(", ")", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "return", "json", ".", "NewEncoder", "(", "w", ")", ".", "Encode", "(", "apiKey", ")", "\n", "}" ]
3,499
all-3500
[ "WriteCert", "writes", "the", "given", "material", "to", "the", "appropriate", "certificate", "files", "in", "the", "given", "LXD", "var", "directory", "." ]
[ "func", "WriteCert", "(", "dir", ",", "prefix", "string", ",", "cert", ",", "key", ",", "ca", "[", "]", "byte", ")", "error", "{", "err", ":=", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "dir", ",", "prefix", "+", "\"", "\"", ")", ",", "cert", ",", "0644", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "dir", ",", "prefix", "+", "\"", "\"", ")", ",", "key", ",", "0600", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "ca", "!=", "nil", "{", "err", "=", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "dir", ",", "prefix", "+", "\"", "\"", ")", ",", "<mask>", ",", "0644", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]