id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
listlengths
1
418
pl_tokens
listlengths
22
4.98k
16,100
all-16101
[ "GetUseColor", "()", "is", "a", "wrapper", "around", "gtk_print_settings_get_use_color", "()", "." ]
[ "func", "(", "<mask>", "*", "PrintSettings", ")", "GetUseColor", "(", ")", "bool", "{", "c", ":=", "C", ".", "gtk_print_settings_get_use_color", "(", "ps", ".", "native", "(", ")", ")", "\n", "return", "gobool", "(", "c", ")", "\n", "}" ]
16,101
all-16102
[ "create", "a", "new", "sync", "object", "and", "insert", "it", "into", "the", "GL", "command", "stream" ]
[ "func", "FenceSync", "(", "condition", "uint32", ",", "flags", "uint32", ")", "uintptr", "{", "<mask>", ",", "_", ",", "_", ":=", "syscall", ".", "Syscall", "(", "gpFenceSync", ",", "2", ",", "uintptr", "(", "condition", ")", ",", "uintptr", "(", "flags", ")", ",", "0", ")", "\n", "return", "(", "uintptr", ")", "(", "ret", ")", "\n", "}" ]
16,102
all-16103
[ "End", "returns", "a", "derivative", "query", "with", "the", "given", "end", "point", "." ]
[ "func", "(", "q", "*", "Query", ")", "End", "(", "c", "Cursor", ")", "*", "Query", "{", "q", "=", "q", ".", "clone", "(", ")", "\n", "if", "c", ".", "cc", "==", "nil", "{", "q", ".", "err", "=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "return", "q", "\n", "}", "\n", "q", ".", "end", "=", "c", ".", "<mask>", "\n", "return", "q", "\n", "}" ]
16,103
all-16104
[ "GetSecretFromASM", "makes", "the", "api", "call", "to", "the", "AWS", "Secrets", "Manager", "service", "to", "retrieve", "the", "secret", "value" ]
[ "func", "GetSecretFromASM", "(", "secretID", "string", ",", "client", "secretsmanageriface", ".", "SecretsManagerAPI", ")", "(", "string", ",", "error", ")", "{", "in", ":=", "&", "secretsmanager", ".", "GetSecretValueInput", "{", "SecretId", ":", "aws", ".", "String", "(", "secretID", ")", ",", "}", "\n\n", "out", ",", "err", ":=", "client", ".", "GetSecretValue", "(", "in", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "<mask>", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "secretID", ")", "\n", "}", "\n\n", "return", "aws", ".", "StringValue", "(", "out", ".", "SecretString", ")", ",", "nil", "\n", "}" ]
16,104
all-16105
[ "read", "a", "block", "of", "pixels", "from", "the", "frame", "buffer" ]
[ "func", "ReadnPixels", "(", "x", "int32", ",", "y", "int32", ",", "width", "int32", ",", "<mask>", "int32", ",", "format", "uint32", ",", "xtype", "uint32", ",", "bufSize", "int32", ",", "data", "unsafe", ".", "Pointer", ")", "{", "syscall", ".", "Syscall9", "(", "gpReadnPixels", ",", "8", ",", "uintptr", "(", "x", ")", ",", "uintptr", "(", "y", ")", ",", "uintptr", "(", "width", ")", ",", "uintptr", "(", "height", ")", ",", "uintptr", "(", "format", ")", ",", "uintptr", "(", "xtype", ")", ",", "uintptr", "(", "bufSize", ")", ",", "uintptr", "(", "data", ")", ",", "0", ")", "\n", "}" ]
16,105
all-16106
[ "Locator", "returns", "a", "locator", "for", "the", "given", "resource" ]
[ "func", "(", "r", "*", "AccountGroup", ")", "Locator", "(", "api", "*", "API", ")", "*", "AccountGroupLocator", "{", "for", "_", ",", "l", ":=", "<mask>", "r", ".", "Links", "{", "if", "l", "[", "\"", "\"", "]", "==", "\"", "\"", "{", "return", "api", ".", "AccountGroupLocator", "(", "l", "[", "\"", "\"", "]", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
16,106
all-16107
[ "UnmarshalText", "hydrates", "this", "instance", "from", "text" ]
[ "func", "(", "<mask>", "*", "ObjectId", ")", "UnmarshalText", "(", "data", "[", "]", "byte", ")", "error", "{", "// validation is performed later on", "*", "id", "=", "ObjectId", "(", "bson", ".", "ObjectIdHex", "(", "string", "(", "data", ")", ")", ")", "\n", "return", "nil", "\n", "}" ]
16,107
all-16108
[ "ContainerConfigRef", "returns", "entities", "used", "by", "containers", "." ]
[ "func", "(", "c", "*", "ClusterTx", ")", "ContainerConfigRef", "(", "filter", "ContainerFilter", ")", "(", "map", "[", "string", "]", "map", "[", "string", "]", "map", "[", "string", "]", "string", ",", "error", ")", "{", "// Result slice.", "objects", ":=", "make", "(", "[", "]", "struct", "{", "Project", "string", "\n", "<mask>", "string", "\n", "Key", "string", "\n", "Value", "string", "\n", "}", ",", "0", ")", "\n\n", "// Check which filter criteria are active.", "criteria", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "}", "\n", "if", "filter", ".", "Project", "!=", "\"", "\"", "{", "criteria", "[", "\"", "\"", "]", "=", "filter", ".", "Project", "\n", "}", "\n", "if", "filter", ".", "Name", "!=", "\"", "\"", "{", "criteria", "[", "\"", "\"", "]", "=", "filter", ".", "Name", "\n", "}", "\n", "if", "filter", ".", "Parent", "!=", "\"", "\"", "{", "criteria", "[", "\"", "\"", "]", "=", "filter", ".", "Parent", "\n", "}", "\n\n", "// Pick the prepared statement and arguments to use based on active criteria.", "var", "stmt", "*", "sql", ".", "Stmt", "\n", "var", "args", "[", "]", "interface", "{", "}", "\n\n", "if", "criteria", "[", "\"", "\"", "]", "!=", "nil", "&&", "criteria", "[", "\"", "\"", "]", "!=", "nil", "{", "stmt", "=", "c", ".", "stmt", "(", "containerConfigRefByProjectAndName", ")", "\n", "args", "=", "[", "]", "interface", "{", "}", "{", "filter", ".", "Project", ",", "filter", ".", "Name", ",", "}", "\n", "}", "else", "if", "criteria", "[", "\"", "\"", "]", "!=", "nil", "&&", "criteria", "[", "\"", "\"", "]", "!=", "nil", "{", "stmt", "=", "c", ".", "stmt", "(", "containerConfigRefByProjectAndNode", ")", "\n", "args", "=", "[", "]", "interface", "{", "}", "{", "filter", ".", "Project", ",", "filter", ".", "Node", ",", "}", "\n", "}", "else", "if", "criteria", "[", "\"", "\"", "]", "!=", "nil", "{", "stmt", "=", "c", ".", "stmt", "(", "containerConfigRefByNode", ")", "\n", "args", "=", "[", "]", "interface", "{", "}", "{", "filter", ".", "Node", ",", "}", "\n", "}", "else", "if", "criteria", "[", "\"", "\"", "]", "!=", "nil", "{", "stmt", "=", "c", ".", "stmt", "(", "containerConfigRefByProject", ")", "\n", "args", "=", "[", "]", "interface", "{", "}", "{", "filter", ".", "Project", ",", "}", "\n", "}", "else", "{", "stmt", "=", "c", ".", "stmt", "(", "containerConfigRef", ")", "\n", "args", "=", "[", "]", "interface", "{", "}", "{", "}", "\n", "}", "\n\n", "// Dest function for scanning a row.", "dest", ":=", "func", "(", "i", "int", ")", "[", "]", "interface", "{", "}", "{", "objects", "=", "append", "(", "objects", ",", "struct", "{", "Project", "string", "\n", "Name", "string", "\n", "Key", "string", "\n", "Value", "string", "\n", "}", "{", "}", ")", "\n", "return", "[", "]", "interface", "{", "}", "{", "&", "objects", "[", "i", "]", ".", "Project", ",", "&", "objects", "[", "i", "]", ".", "Name", ",", "&", "objects", "[", "i", "]", ".", "Key", ",", "&", "objects", "[", "i", "]", ".", "Value", ",", "}", "\n", "}", "\n\n", "// Select.", "err", ":=", "query", ".", "SelectObjects", "(", "stmt", ",", "dest", ",", "args", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Build index by primary name.", "index", ":=", "map", "[", "string", "]", "map", "[", "string", "]", "map", "[", "string", "]", "string", "{", "}", "\n\n", "for", "_", ",", "object", ":=", "range", "objects", "{", "_", ",", "ok", ":=", "index", "[", "object", ".", "Project", "]", "\n", "if", "!", "ok", "{", "subIndex", ":=", "map", "[", "string", "]", "map", "[", "string", "]", "string", "{", "}", "\n", "index", "[", "object", ".", "Project", "]", "=", "subIndex", "\n", "}", "\n\n", "item", ",", "ok", ":=", "index", "[", "object", ".", "Project", "]", "[", "object", ".", "Name", "]", "\n", "if", "!", "ok", "{", "item", "=", "map", "[", "string", "]", "string", "{", "}", "\n", "}", "\n\n", "index", "[", "object", ".", "Project", "]", "[", "object", ".", "Name", "]", "=", "item", "\n", "item", "[", "object", ".", "Key", "]", "=", "object", ".", "Value", "\n", "}", "\n\n", "return", "index", ",", "nil", "\n", "}" ]
16,108
all-16109
[ "initLastProcessedBlock", "calculates", "last", "processed", "block", ".", "If", "user", "role", "is", "client", "and", "value", "of", "eth", ".", "event", ".", "lastProcessedBlock", "setting", "is", "0", "then", "value", "of", "eth", ".", "event", ".", "lastProcessedBlock", "setting", "is", "equal", "the", "difference", "between", "the", "last", "Ethereum", "block", "and", "a", "InitialBlocks", "value", ".", "If", "InitialBlocks", "value", "is", "0", "then", "this", "parameter", "is", "ignored", "." ]
[ "func", "(", "m", "*", "Monitor", ")", "initLastProcessedBlock", "(", "role", "string", ",", "initialBlocks", "uint64", ")", "{", "logger", ":=", "m", ".", "logger", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "role", ",", "\"", "\"", ",", "initialBlocks", ")", "\n\n", "block", ",", "err", ":=", "m", ".", "getLastProcessedBlockNumber", "(", ")", "\n", "if", "block", ">", "0", "||", "err", "!=", "nil", "||", "role", "!=", "data", ".", "RoleClient", "||", "initialBlocks", "==", "0", "{", "return", "\n", "}", "\n\n", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "m", ".", "ethCallTimeout", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "lastBlock", ",", "err", ":=", "m", ".", "eth", ".", "HeaderByNumber", "(", "ctx", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "err", ".", "Error", "(", ")", ")", "\n", "return", "\n", "}", "\n\n", "lastEthBlockNum", ":=", "lastBlock", ".", "Number", ".", "Uint64", "(", ")", "\n", "logger", "=", "logger", ".", "Add", "(", "\"", "\"", ",", "lastEthBlockNum", ")", "\n\n", "if", "initialBlocks", ">", "lastEthBlockNum", "{", "logger", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "lastProcessedBlock", ":=", "lastEthBlockNum", "-", "initialBlocks", "\n\n", "_", ",", "err", "=", "m", ".", "db", ".", "Exec", "(", "`UPDATE settings SET value=$1 WHERE key=$2`", ",", "lastProcessedBlock", ",", "<mask>", ".", "SettingLastProcessedBlock", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "logger", ".", "Debug", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "lastProcessedBlock", ")", ")", "\n", "}" ]
16,109
all-16110
[ "NewValueParser", "creates", "a", "new", "parser", "that", "exposes", "the", "value", "v", "." ]
[ "func", "NewValueParser", "(", "v", "interface", "{", "}", ")", "*", "ValueParser", "{", "return", "&", "ValueParser", "{", "stack", ":", "[", "]", "reflect", ".", "<mask>", "{", "reflect", ".", "ValueOf", "(", "v", ")", "}", ",", "}", "\n", "}" ]
16,110
all-16111
[ "title", ":", "unbind", "service", "instance", "path", ":", "/", "services", "/", "{", "service", "}", "/", "instances", "/", "{", "instance", "}", "/", "{", "app", "}", "method", ":", "DELETE", "produce", ":", "application", "/", "x", "-", "json", "-", "stream", "responses", ":", "200", ":", "Ok", "400", ":", "Invalid", "data", "401", ":", "Unauthorized", "404", ":", "App", "not", "found" ]
[ "func", "unbindServiceInstance", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "t", "auth", ".", "<mask>", ")", "error", "{", "instanceName", ",", "appName", ",", "serviceName", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", ",", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", ",", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "noRestart", ",", "_", ":=", "strconv", ".", "ParseBool", "(", "InputValue", "(", "r", ",", "\"", "\"", ")", ")", "\n", "force", ",", "_", ":=", "strconv", ".", "ParseBool", "(", "InputValue", "(", "r", ",", "\"", "\"", ")", ")", "\n", "instance", ",", "a", ",", "err", ":=", "getServiceInstance", "(", "serviceName", ",", "instanceName", ",", "appName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "allowed", ":=", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermServiceInstanceUpdateUnbind", ",", "append", "(", "permission", ".", "Contexts", "(", "permTypes", ".", "CtxTeam", ",", "instance", ".", "Teams", ")", ",", "permission", ".", "Context", "(", "permTypes", ".", "CtxServiceInstance", ",", "instance", ".", "Name", ")", ",", ")", "...", ",", ")", "\n", "if", "!", "allowed", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "allowed", "=", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermAppUpdateUnbind", ",", "contextsForApp", "(", "a", ")", "...", ",", ")", "\n", "if", "!", "allowed", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "if", "force", "{", "s", ",", "errGet", ":=", "service", ".", "Get", "(", "instance", ".", "ServiceName", ")", "\n", "if", "errGet", "!=", "nil", "{", "return", "errGet", "\n", "}", "\n", "allowed", "=", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermServiceUpdate", ",", "contextsForServiceProvision", "(", "&", "s", ")", "...", ",", ")", "\n", "if", "!", "allowed", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "}", "\n", "evt", ",", "err", ":=", "event", ".", "New", "(", "&", "event", ".", "Opts", "{", "Target", ":", "appTarget", "(", "appName", ")", ",", "Kind", ":", "permission", ".", "PermAppUpdateUnbind", ",", "Owner", ":", "t", ",", "CustomData", ":", "event", ".", "FormToCustomData", "(", "InputFields", "(", "r", ")", ")", ",", "Allowed", ":", "event", ".", "Allowed", "(", "permission", ".", "PermAppReadEvents", ",", "contextsForApp", "(", "a", ")", "...", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "func", "(", ")", "{", "evt", ".", "Done", "(", "err", ")", "}", "(", ")", "\n", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "keepAliveWriter", ":=", "tsuruIo", ".", "NewKeepAliveWriter", "(", "w", ",", "30", "*", "time", ".", "Second", ",", "\"", "\"", ")", "\n", "defer", "keepAliveWriter", ".", "Stop", "(", ")", "\n", "writer", ":=", "&", "tsuruIo", ".", "SimpleJsonMessageEncoderWriter", "{", "Encoder", ":", "json", ".", "NewEncoder", "(", "keepAliveWriter", ")", "}", "\n", "evt", ".", "SetLogWriter", "(", "writer", ")", "\n", "err", "=", "instance", ".", "UnbindApp", "(", "service", ".", "UnbindAppArgs", "{", "App", ":", "a", ",", "Restart", ":", "!", "noRestart", ",", "ForceRemove", ":", "force", ",", "Event", ":", "evt", ",", "RequestID", ":", "requestIDHeader", "(", "r", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "fmt", ".", "Fprintf", "(", "evt", ",", "\"", "\\n", "\\n", "\"", ",", "instanceName", ",", "appName", ")", "\n", "return", "nil", "\n", "}" ]
16,111
all-16112
[ "title", ":", "app", "info", "path", ":", "/", "apps", "/", "{", "name", "}", "method", ":", "GET", "produce", ":", "application", "/", "json", "responses", ":", "200", ":", "OK", "401", ":", "Unauthorized", "404", ":", "Not", "found" ]
[ "func", "appInfo", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "<mask>", ".", "Request", ",", "t", "auth", ".", "Token", ")", "error", "{", "a", ",", "err", ":=", "getAppFromContext", "(", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", ",", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "canRead", ":=", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermAppRead", ",", "contextsForApp", "(", "&", "a", ")", "...", ",", ")", "\n", "if", "!", "canRead", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n\n", "err", "=", "a", ".", "FillInternalAddresses", "(", "r", ".", "Context", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "return", "json", ".", "NewEncoder", "(", "w", ")", ".", "Encode", "(", "&", "a", ")", "\n", "}" ]
16,112
all-16113
[ "ExecAndWait", "will", "execute", "the", "command", "using", "the", "given", "executor", "and", "wait", "until", "completion" ]
[ "func", "(", "e", "*", "execStreamer", ")", "ExecAndWait", "(", ")", "error", "{", "cmd", ",", "err", ":=", "e", ".", "StartExec", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "e", ".", "stdOutAndErrWaitGroup", ".", "Wait", "(", ")", "\n\n", "err", "=", "cmd", ".", "Wait", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
16,113
all-16114
[ "ParseReference", "converts", "a", "string", "which", "should", "not", "start", "with", "the", "ImageTransport", ".", "Name", "prefix", "into", "an", "ImageReference", "." ]
[ "func", "(", "t", "dirTransport", ")", "ParseReference", "(", "<mask>", "string", ")", "(", "types", ".", "ImageReference", ",", "error", ")", "{", "return", "NewReference", "(", "reference", ")", "\n", "}" ]
16,114
all-16115
[ "registerAlias", "registers", "a", "alias", "for", "an", "already", "registered", "Scheme", "." ]
[ "func", "registerAlias", "(", "name", ",", "alias", "string", ",", "doSort", "bool", ")", "{", "scheme", ",", "ok", ":=", "schemeMap", "[", "name", "]", "\n", "if", "!", "ok", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ")", ")", "\n", "}", "\n\n", "if", "doSort", "&&", "has", "(", "scheme", ".", "Aliases", ",", "alias", ")", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ",", "alias", ")", ")", "\n", "}", "\n\n", "if", "_", ",", "ok", ":=", "schemeMap", "[", "alias", "]", ";", "ok", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "alias", ")", ")", "\n", "}", "\n\n", "scheme", ".", "Aliases", "=", "<mask>", "(", "scheme", ".", "Aliases", ",", "alias", ")", "\n", "if", "doSort", "{", "sort", ".", "Sort", "(", "ss", "(", "scheme", ".", "Aliases", ")", ")", "\n", "}", "\n\n", "schemeMap", "[", "alias", "]", "=", "scheme", "\n", "}" ]
16,115
all-16116
[ "Create", "takes", "the", "representation", "of", "a", "app", "and", "creates", "it", ".", "Returns", "the", "server", "s", "representation", "of", "the", "app", "and", "an", "error", "if", "there", "is", "any", "." ]
[ "func", "(", "c", "*", "FakeApps", ")", "Create", "(", "app", "*", "tsuru_v1", ".", "App", ")", "(", "result", "*", "tsuru_v1", ".", "App", ",", "err", "error", ")", "{", "obj", ",", "err", ":=", "c", ".", "Fake", ".", "Invokes", "(", "testing", ".", "NewCreateAction", "(", "appsResource", ",", "c", ".", "<mask>", ",", "app", ")", ",", "&", "tsuru_v1", ".", "App", "{", "}", ")", "\n\n", "if", "obj", "==", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "obj", ".", "(", "*", "tsuru_v1", ".", "App", ")", ",", "err", "\n", "}" ]
16,116
all-16117
[ "LoadFile", "loads", "a", "text", "from", "file", "and", "replace", "the", "control", "text", "with", "the", "file", "one", ".", "Function", "returns", "false", "if", "loading", "text", "from", "file", "fails" ]
[ "func", "(", "l", "*", "TextView", ")", "LoadFile", "(", "filename", "string", ")", "bool", "{", "l", ".", "lines", "=", "make", "(", "[", "]", "string", ",", "0", ")", "\n\n", "file", ",", "err", ":=", "os", ".", "Open", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n\n", "defer", "file", ".", "Close", "(", ")", "\n\n", "scanner", ":=", "bufio", ".", "NewScanner", "(", "file", ")", "\n", "for", "scanner", ".", "Scan", "(", ")", "{", "line", ":=", "scanner", ".", "Text", "(", ")", "\n", "line", "=", "strings", ".", "TrimSpace", "(", "line", ")", "\n", "l", ".", "lines", "=", "append", "(", "l", ".", "lines", ",", "<mask>", ")", "\n", "}", "\n\n", "l", ".", "applyLimit", "(", ")", "\n", "l", ".", "calculateVirtualSize", "(", ")", "\n\n", "if", "l", ".", "autoscroll", "{", "l", ".", "end", "(", ")", "\n", "}", "\n\n", "return", "true", "\n", "}" ]
16,117
all-16118
[ "void", "pango_font_description_set_family_static", "(", "PangoFontDescription", "*", "desc", "const", "char", "*", "family", ")", ";" ]
[ "func", "(", "v", "*", "FontDescription", ")", "SetFamilyStatic", "(", "family", "string", ")", "{", "cstr", ":=", "C", ".", "CString", "(", "family", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cstr", ")", ")", "\n", "C", ".", "pango_font_description_set_family_static", "(", "v", ".", "native", "(", ")", ",", "(", "*", "C", ".", "<mask>", ")", "(", "cstr", ")", ")", "\n", "}" ]
16,118
all-16119
[ "InstallSnapshot", "is", "used", "to", "push", "a", "snapshot", "down", "to", "a", "follower", ".", "The", "data", "is", "read", "from", "the", "ReadCloser", "and", "streamed", "to", "the", "client", "." ]
[ "func", "(", "t", "*", "transport", ")", "InstallSnapshot", "(", "id", "raft", ".", "ServerID", ",", "target", "raft", ".", "ServerAddress", ",", "args", "*", "raft", ".", "InstallSnapshotRequest", ",", "resp", "*", "raft", ".", "InstallSnapshotResponse", ",", "data", "<mask>", ".", "Reader", ")", "error", "{", "t", ".", "log", ".", "Printf", "(", "\"", "\"", ")", "\n", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
16,119
all-16120
[ "Scan", "scans", "a", "Date", "value", "from", "database", "driver", "type", "." ]
[ "func", "(", "d", "*", "Date", ")", "Scan", "(", "raw", "interface", "{", "}", ")", "error", "{", "<mask>", "v", ":=", "raw", ".", "(", "type", ")", "{", "case", "[", "]", "byte", ":", "return", "d", ".", "UnmarshalText", "(", "v", ")", "\n", "case", "string", ":", "return", "d", ".", "UnmarshalText", "(", "[", "]", "byte", "(", "v", ")", ")", "\n", "case", "time", ".", "Time", ":", "*", "d", "=", "Date", "(", "v", ")", "\n", "return", "nil", "\n", "case", "nil", ":", "*", "d", "=", "Date", "{", "}", "\n", "return", "nil", "\n", "default", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "v", ")", "\n", "}", "\n", "}" ]
16,120
all-16121
[ "AskChoice", "asks", "the", "user", "to", "select", "one", "of", "multiple", "options" ]
[ "func", "AskChoice", "(", "question", "string", ",", "choices", "[", "]", "string", ",", "defaultAnswer", "string", ")", "string", "{", "for", "{", "<mask>", ":=", "askQuestion", "(", "question", ",", "defaultAnswer", ")", "\n\n", "if", "shared", ".", "StringInSlice", "(", "answer", ",", "choices", ")", "{", "return", "answer", "\n", "}", "\n\n", "invalidInput", "(", ")", "\n", "}", "\n", "}" ]
16,121
all-16122
[ "Validate", "a", "password", "against", "the", "given", "requirements", "Returns", "a", "boolean", "indicating", "whether", "the", "password", "meets", "the", "requirements", ".", "The", "second", "argument", "is", "a", "string", "explaining", "why", "it", "doesn", "t", "meet", "the", "requirements", "if", "it", "doesn", "t", ".", "It", "is", "empty", "if", "the", "requirements", "are", "met", "." ]
[ "func", "(", "p", "*", "PasswordStrengthRequirements", ")", "Validate", "(", "<mask>", "string", ")", "(", "bool", ",", "string", ")", "{", "reqs", ":=", "MakeRequirements", "(", "password", ")", "\n", "if", "p", ".", "MaximumTotalLength", ">", "0", "&&", "reqs", ".", "MaximumTotalLength", ">", "p", ".", "MaximumTotalLength", "{", "return", "false", ",", "\"", "\"", "\n", "}", "\n", "if", "reqs", ".", "MinimumTotalLength", "<", "p", ".", "MinimumTotalLength", "{", "return", "false", ",", "\"", "\"", "\n", "}", "\n", "if", "reqs", ".", "Digits", "<", "p", ".", "Digits", "{", "return", "false", ",", "\"", "\"", "\n", "}", "\n", "if", "reqs", ".", "Punctuation", "<", "p", ".", "Punctuation", "{", "return", "false", ",", "\"", "\"", "\n", "}", "\n", "if", "reqs", ".", "Uppercase", "<", "p", ".", "Uppercase", "{", "return", "false", ",", "\"", "\"", "\n", "}", "\n", "return", "true", ",", "\"", "\"", "\n", "}" ]
16,122
all-16123
[ "BusTypeFromID", "gets", "BusType", "from", "device", "ID", "." ]
[ "func", "BusTypeFromID", "(", "ID", "string", ")", "vmx", ".", "BusType", "{", "var", "bus", "vmx", ".", "BusType", "\n", "switch", "{", "<mask>", "strings", ".", "HasPrefix", "(", "ID", ",", "string", "(", "vmx", ".", "IDE", ")", ")", ":", "bus", "=", "vmx", ".", "IDE", "\n", "case", "strings", ".", "HasPrefix", "(", "ID", ",", "string", "(", "vmx", ".", "SCSI", ")", ")", ":", "bus", "=", "vmx", ".", "SCSI", "\n", "case", "strings", ".", "HasPrefix", "(", "ID", ",", "string", "(", "vmx", ".", "SATA", ")", ")", ":", "bus", "=", "vmx", ".", "SATA", "\n", "}", "\n\n", "return", "bus", "\n", "}" ]
16,123
all-16124
[ "nodeToFileInfoHeaderFooter", "is", "like", "nodeToFileInfo", "but", "handles", "the", "case", "(", "which", "currently", "only", "occurs", "in", "input", "commits", ")", "where", "files", "have", "a", "header", "that", "is", "stored", "in", "their", "parent", "directory" ]
[ "func", "nodeToFileInfoHeaderFooter", "(", "ci", "*", "pfs", ".", "CommitInfo", ",", "filePath", "string", ",", "node", "*", "hashtree", ".", "NodeProto", ",", "tree", "hashtree", ".", "HashTree", ",", "full", "bool", ")", "(", "*", "pfs", ".", "FileInfo", ",", "error", ")", "{", "if", "<mask>", ".", "FileNode", "==", "nil", "||", "!", "node", ".", "FileNode", ".", "HasHeaderFooter", "{", "return", "nodeToFileInfo", "(", "ci", ",", "filePath", ",", "node", ",", "full", ")", ",", "nil", "\n", "}", "\n", "node", "=", "proto", ".", "Clone", "(", "node", ")", ".", "(", "*", "hashtree", ".", "NodeProto", ")", "\n", "// validate baseFileInfo for logic below--if input hashtrees start using", "// blockrefs instead of objects, this logic will need to be adjusted", "if", "node", ".", "FileNode", ".", "Objects", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// 'file' includes header from parent—construct synthetic file info that", "// includes header in list of objects & hash", "parentPath", ":=", "path", ".", "Dir", "(", "filePath", ")", "\n", "parentNode", ",", "err", ":=", "tree", ".", "Get", "(", "parentPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", "+", "\"", "\"", ",", "filePath", ",", "parentPath", ",", "err", ")", "\n", "}", "\n", "if", "parentNode", ".", "DirNode", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", "+", "\"", "\"", ",", "filePath", ")", "\n", "}", "\n", "if", "parentNode", ".", "DirNode", ".", "Shared", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", "+", "\"", "\"", ",", "filePath", ")", "\n", "}", "\n\n", "s", ":=", "parentNode", ".", "DirNode", ".", "Shared", "\n", "var", "newObjects", "[", "]", "*", "pfs", ".", "Object", "\n", "if", "s", ".", "Header", "!=", "nil", "{", "// cap := len+1 => newObjects is right whether or not we append() a footer", "newL", ":=", "len", "(", "node", ".", "FileNode", ".", "Objects", ")", "+", "1", "\n", "newObjects", "=", "make", "(", "[", "]", "*", "pfs", ".", "Object", ",", "newL", ",", "newL", "+", "1", ")", "\n\n", "newObjects", "[", "0", "]", "=", "s", ".", "Header", "\n", "copy", "(", "newObjects", "[", "1", ":", "]", ",", "node", ".", "FileNode", ".", "Objects", ")", "\n", "}", "else", "{", "newObjects", "=", "node", ".", "FileNode", ".", "Objects", "\n", "}", "\n", "if", "s", ".", "Footer", "!=", "nil", "{", "newObjects", "=", "append", "(", "newObjects", ",", "s", ".", "Footer", ")", "\n", "}", "\n", "node", ".", "FileNode", ".", "Objects", "=", "newObjects", "\n", "node", ".", "SubtreeSize", "+=", "s", ".", "HeaderSize", "+", "s", ".", "FooterSize", "\n", "node", ".", "Hash", "=", "hashtree", ".", "HashFileNode", "(", "node", ".", "FileNode", ")", "\n", "return", "nodeToFileInfo", "(", "ci", ",", "filePath", ",", "node", ",", "full", ")", ",", "nil", "\n", "}" ]
16,124
all-16125
[ "GetGroup", "returns", "the", "Group", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "c", "*", "CheckStatusDefinition", ")", "GetGroup", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "<mask>", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "Group", "\n", "}" ]
16,125
all-16126
[ "dividePool", "splits", "up", "the", "list", "of", "pull", "requests", "and", "prow", "jobs", "into", "a", "group", "per", "repo", "and", "branch", ".", "It", "only", "keeps", "ProwJobs", "that", "match", "the", "latest", "branch", "." ]
[ "func", "(", "c", "*", "Controller", ")", "dividePool", "(", "pool", "map", "[", "string", "]", "PullRequest", ",", "pjs", "[", "]", "prowapi", ".", "ProwJob", ")", "(", "map", "[", "string", "]", "*", "subpool", ",", "error", ")", "{", "sps", ":=", "make", "(", "map", "[", "string", "]", "*", "subpool", ")", "\n", "for", "_", ",", "pr", ":=", "range", "pool", "{", "org", ":=", "string", "(", "pr", ".", "Repository", ".", "Owner", ".", "Login", ")", "\n", "repo", ":=", "string", "(", "pr", ".", "Repository", ".", "Name", ")", "\n", "branch", ":=", "string", "(", "pr", ".", "BaseRef", ".", "Name", ")", "\n", "branchRef", ":=", "string", "(", "pr", ".", "BaseRef", ".", "Prefix", ")", "+", "string", "(", "pr", ".", "BaseRef", ".", "Name", ")", "\n", "fn", ":=", "poolKey", "(", "org", ",", "repo", ",", "branch", ")", "\n", "if", "sps", "[", "fn", "]", "==", "nil", "{", "sha", ",", "err", ":=", "c", ".", "ghc", ".", "GetRef", "(", "org", ",", "repo", ",", "strings", ".", "TrimPrefix", "(", "branchRef", ",", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "sps", "[", "fn", "]", "=", "&", "subpool", "{", "log", ":", "c", ".", "logger", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\"", ":", "org", ",", "\"", "\"", ":", "repo", ",", "\"", "\"", ":", "branch", ",", "\"", "\"", ":", "sha", ",", "}", ")", ",", "org", ":", "org", ",", "repo", ":", "repo", ",", "branch", ":", "branch", ",", "sha", ":", "sha", ",", "}", "\n", "}", "\n", "sps", "[", "fn", "]", ".", "prs", "=", "<mask>", "(", "sps", "[", "fn", "]", ".", "prs", ",", "pr", ")", "\n", "}", "\n", "for", "_", ",", "pj", ":=", "range", "pjs", "{", "if", "pj", ".", "Spec", ".", "Type", "!=", "prowapi", ".", "PresubmitJob", "&&", "pj", ".", "Spec", ".", "Type", "!=", "prowapi", ".", "BatchJob", "{", "continue", "\n", "}", "\n", "fn", ":=", "poolKey", "(", "pj", ".", "Spec", ".", "Refs", ".", "Org", ",", "pj", ".", "Spec", ".", "Refs", ".", "Repo", ",", "pj", ".", "Spec", ".", "Refs", ".", "BaseRef", ")", "\n", "if", "sps", "[", "fn", "]", "==", "nil", "||", "pj", ".", "Spec", ".", "Refs", ".", "BaseSHA", "!=", "sps", "[", "fn", "]", ".", "sha", "{", "continue", "\n", "}", "\n", "sps", "[", "fn", "]", ".", "pjs", "=", "append", "(", "sps", "[", "fn", "]", ".", "pjs", ",", "pj", ")", "\n", "}", "\n", "return", "sps", ",", "nil", "\n", "}" ]
16,126
all-16127
[ "GetTitleAlign", "returns", "the", "TitleAlign", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "a", "*", "AlertValueDefinition", ")", "GetTitleAlign", "(", ")", "string", "{", "if", "a", "==", "nil", "||", "a", ".", "TitleAlign", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "<mask>", "*", "a", ".", "TitleAlign", "\n", "}" ]
16,127
all-16128
[ "parseTags", "computes", "the", "tags", "for", "the", "instance", "." ]
[ "func", "parseTags", "(", "d", "*", "Driver", ")", "[", "]", "string", "{", "tags", ":=", "[", "]", "string", "{", "firewallTargetTag", "}", "\n\n", "if", "d", ".", "Tags", "!=", "\"", "\"", "{", "<mask>", "=", "append", "(", "tags", ",", "strings", ".", "Split", "(", "d", ".", "Tags", ",", "\"", "\"", ")", "...", ")", "\n", "}", "\n\n", "return", "tags", "\n", "}" ]
16,128
all-16129
[ "UnmarshalEasyJSON", "satisfies", "easyjson", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "CertificateTransparencyCompliance", ")", "UnmarshalEasyJSON", "(", "in", "*", "jlexer", ".", "Lexer", ")", "{", "switch", "CertificateTransparencyCompliance", "(", "in", ".", "String", "(", ")", ")", "{", "case", "CertificateTransparencyComplianceUnknown", ":", "*", "t", "=", "CertificateTransparencyComplianceUnknown", "\n", "case", "CertificateTransparencyComplianceNotCompliant", ":", "*", "t", "=", "CertificateTransparencyComplianceNotCompliant", "\n", "<mask>", "CertificateTransparencyComplianceCompliant", ":", "*", "t", "=", "CertificateTransparencyComplianceCompliant", "\n\n", "default", ":", "in", ".", "AddError", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}" ]
16,129
all-16130
[ "RawOperation", "allows", "direct", "querying", "of", "a", "LXD", "API", "endpoint", "returning", "background", "operations", "." ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "RawOperation", "(", "method", "string", ",", "path", "string", ",", "data", "interface", "{", "}", ",", "ETag", "string", ")", "(", "Operation", ",", "string", ",", "error", ")", "{", "return", "r", ".", "queryOperation", "(", "method", ",", "path", ",", "<mask>", ",", "ETag", ")", "\n", "}" ]
16,130
all-16131
[ "Locator", "returns", "a", "locator", "for", "the", "given", "resource" ]
[ "func", "(", "r", "*", "Server", ")", "Locator", "(", "api", "*", "API", ")", "*", "ServerLocator", "{", "for", "_", ",", "l", ":=", "<mask>", "r", ".", "Links", "{", "if", "l", "[", "\"", "\"", "]", "==", "\"", "\"", "{", "return", "api", ".", "ServerLocator", "(", "l", "[", "\"", "\"", "]", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
16,131
all-16132
[ "WriteTo", "saves", "a", "index", "table", "." ]
[ "func", "(", "idx", "IndexTable", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "n", "int64", ",", "err", "error", ")", "{", "n", ",", "err", "=", "idx", ".", "Da", ".", "WriteTo", "(", "w", ")", "\n", "<mask>", "b", "bytes", ".", "Buffer", "\n", "enc", ":=", "gob", ".", "NewEncoder", "(", "&", "b", ")", "\n", "if", "err", "=", "enc", ".", "Encode", "(", "idx", ".", "Dup", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "x", ",", "err", ":=", "b", ".", "WriteTo", "(", "w", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "n", "+=", "x", "\n", "return", "\n", "}" ]
16,132
all-16133
[ "GetOrAdd", "returns", "a", "peer", "for", "the", "given", "hostPort", "creating", "one", "if", "it", "doesn", "t", "yet", "exist", "." ]
[ "func", "(", "l", "*", "PeerList", ")", "GetOrAdd", "(", "hostPort", "string", ")", "*", "Peer", "{", "if", "ps", ",", "<mask>", ":=", "l", ".", "exists", "(", "hostPort", ")", ";", "ok", "{", "return", "ps", ".", "Peer", "\n", "}", "\n", "return", "l", ".", "Add", "(", "hostPort", ")", "\n", "}" ]
16,133
all-16134
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "SamplingHeapProfile", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoHeapprofiler8", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
16,134
all-16135
[ "continuedFraction", "calculates", "and", "returns", "the", "best", "rational", "approximation", "of", "the", "given", "real", "number", "." ]
[ "func", "continuedFraction", "(", "<mask>", "string", ")", "(", "xdrPrice", "xdr", ".", "Price", ",", "err", "error", ")", "{", "number", ":=", "&", "big", ".", "Rat", "{", "}", "\n", "maxInt32", ":=", "&", "big", ".", "Rat", "{", "}", "\n", "zero", ":=", "&", "big", ".", "Rat", "{", "}", "\n", "one", ":=", "&", "big", ".", "Rat", "{", "}", "\n\n", "_", ",", "ok", ":=", "number", ".", "SetString", "(", "price", ")", "\n", "if", "!", "ok", "{", "return", "xdrPrice", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "price", ")", "\n", "}", "\n\n", "maxInt32", ".", "SetInt64", "(", "int64", "(", "math", ".", "MaxInt32", ")", ")", "\n", "zero", ".", "SetInt64", "(", "int64", "(", "0", ")", ")", "\n", "one", ".", "SetInt64", "(", "int64", "(", "1", ")", ")", "\n\n", "fractions", ":=", "[", "]", "[", "2", "]", "*", "big", ".", "Rat", "{", "{", "zero", ",", "one", "}", ",", "{", "one", ",", "zero", "}", ",", "}", "\n\n", "i", ":=", "2", "\n", "for", "{", "if", "number", ".", "Cmp", "(", "maxInt32", ")", "==", "1", "{", "break", "\n", "}", "\n\n", "f", ":=", "&", "big", ".", "Rat", "{", "}", "\n", "h", ":=", "&", "big", ".", "Rat", "{", "}", "\n", "k", ":=", "&", "big", ".", "Rat", "{", "}", "\n\n", "a", ":=", "floor", "(", "number", ")", "\n", "f", ".", "Sub", "(", "number", ",", "a", ")", "\n", "h", ".", "Mul", "(", "a", ",", "fractions", "[", "i", "-", "1", "]", "[", "0", "]", ")", "\n", "h", ".", "Add", "(", "h", ",", "fractions", "[", "i", "-", "2", "]", "[", "0", "]", ")", "\n", "k", ".", "Mul", "(", "a", ",", "fractions", "[", "i", "-", "1", "]", "[", "1", "]", ")", "\n", "k", ".", "Add", "(", "k", ",", "fractions", "[", "i", "-", "2", "]", "[", "1", "]", ")", "\n\n", "if", "h", ".", "Cmp", "(", "maxInt32", ")", "==", "1", "||", "k", ".", "Cmp", "(", "maxInt32", ")", "==", "1", "{", "break", "\n", "}", "\n\n", "fractions", "=", "append", "(", "fractions", ",", "[", "2", "]", "*", "big", ".", "Rat", "{", "h", ",", "k", "}", ")", "\n", "if", "f", ".", "Cmp", "(", "zero", ")", "==", "0", "{", "break", "\n", "}", "\n", "number", ".", "Quo", "(", "one", ",", "f", ")", "\n", "i", "++", "\n", "}", "\n\n", "n", ",", "d", ":=", "fractions", "[", "len", "(", "fractions", ")", "-", "1", "]", "[", "0", "]", ",", "fractions", "[", "len", "(", "fractions", ")", "-", "1", "]", "[", "1", "]", "\n\n", "if", "n", ".", "Cmp", "(", "zero", ")", "==", "0", "||", "d", ".", "Cmp", "(", "zero", ")", "==", "0", "{", "return", "xdrPrice", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "xdr", ".", "Price", "{", "N", ":", "xdr", ".", "Int32", "(", "n", ".", "Num", "(", ")", ".", "Int64", "(", ")", ")", ",", "D", ":", "xdr", ".", "Int32", "(", "d", ".", "Num", "(", ")", ".", "Int64", "(", ")", ")", ",", "}", ",", "nil", "\n", "}" ]
16,135
all-16136
[ "Dash", "draws", "a", "line", "with", "a", "dash", "pattern" ]
[ "func", "Dash", "(", "gc", "draw2d", ".", "GraphicContext", ",", "x", ",", "y", ",", "width", ",", "height", "float64", ")", "{", "sx", ",", "sy", ":=", "width", "/", "162", ",", "height", "/", "205", "\n", "gc", ".", "SetStrokeColor", "(", "image", ".", "Black", ")", "\n", "gc", ".", "SetLineDash", "(", "[", "]", "float64", "{", "<mask>", "/", "10", ",", "height", "/", "50", ",", "height", "/", "50", ",", "height", "/", "50", "}", ",", "-", "50.0", ")", "\n", "gc", ".", "SetLineCap", "(", "draw2d", ".", "ButtCap", ")", "\n", "gc", ".", "SetLineJoin", "(", "draw2d", ".", "RoundJoin", ")", "\n", "gc", ".", "SetLineWidth", "(", "height", "/", "50", ")", "\n\n", "gc", ".", "MoveTo", "(", "x", "+", "sx", "*", "60.0", ",", "y", ")", "\n", "gc", ".", "LineTo", "(", "x", "+", "sx", "*", "60.0", ",", "y", ")", "\n", "gc", ".", "LineTo", "(", "x", "+", "sx", "*", "162", ",", "y", "+", "sy", "*", "205", ")", "\n", "rLineTo", "(", "gc", ",", "sx", "*", "-", "102.4", ",", "0", ")", "\n", "gc", ".", "CubicCurveTo", "(", "x", "+", "sx", "*", "-", "17", ",", "y", "+", "sy", "*", "205", ",", "x", "+", "sx", "*", "-", "17", ",", "y", "+", "sy", "*", "103", ",", "x", "+", "sx", "*", "60.0", ",", "y", "+", "sy", "*", "103.0", ")", "\n", "gc", ".", "Stroke", "(", ")", "\n", "gc", ".", "SetLineDash", "(", "nil", ",", "0.0", ")", "\n", "}" ]
16,136
all-16137
[ "ParseMetric", "parses", "the", "input", "into", "a", "metric" ]
[ "func", "ParseMetric", "(", "input", "string", ")", "(", "m", "labels", ".", "Labels", ",", "err", "error", ")", "{", "p", ":=", "newParser", "(", "input", ")", "\n", "defer", "p", ".", "recover", "(", "&", "err", ")", "\n\n", "m", "=", "p", ".", "metric", "(", ")", "\n", "if", "p", ".", "peek", "(", ")", ".", "typ", "!=", "ItemEOF", "{", "p", ".", "errorf", "(", "\"", "\"", ",", "p", ".", "lex", ".", "<mask>", "[", "p", ".", "lex", ".", "lastPos", ":", "]", ")", "\n", "}", "\n", "return", "m", ",", "nil", "\n", "}" ]
16,137
all-16138
[ "Enters", "the", "directory" ]
[ "func", "(", "d", "*", "FileSelectDialog", ")", "pathDown", "(", "dir", "<mask>", ")", "{", "d", ".", "currPath", "=", "filepath", ".", "Join", "(", "d", ".", "currPath", ",", "dir", ")", "\n", "d", ".", "populateFiles", "(", ")", "\n", "d", ".", "selectFirst", "(", ")", "\n", "}" ]
16,138
all-16139
[ "Load", ".", "env", "files", ".", "Files", "will", "be", "loaded", "in", "the", "same", "order", "that", "are", "received", ".", "Redefined", "vars", "will", "override", "previously", "existing", "values", ".", "IE", ":", "envy", ".", "Load", "(", ".", "env", "test_env", "/", ".", "env", ")", "will", "result", "in", "DIR", "=", "test_env", "If", "no", "arg", "passed", "it", "will", "try", "to", "load", "a", ".", "env", "file", "." ]
[ "func", "Load", "(", "files", "...", "string", ")", "error", "{", "// If no files received, load the default one", "if", "len", "(", "files", ")", "==", "0", "{", "err", ":=", "godotenv", ".", "Overload", "(", ")", "\n", "if", "err", "==", "nil", "{", "Reload", "(", ")", "\n", "}", "\n", "return", "err", "\n", "}", "\n\n", "// We received a list of files", "for", "_", ",", "file", ":=", "range", "<mask>", "{", "// Check if it exists or we can access", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "file", ")", ";", "err", "!=", "nil", "{", "// It does not exist or we can not access.", "// Return and stop loading", "return", "err", "\n", "}", "\n\n", "// It exists and we have permission. Load it", "if", "err", ":=", "godotenv", ".", "Overload", "(", "file", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Reload the env so all new changes are noticed", "Reload", "(", ")", "\n\n", "}", "\n", "return", "nil", "\n", "}" ]
16,139
all-16140
[ "SetAuthentication", "stores", "the", "username", "and", "password", "in", "the", "auth", ".", "json", "file" ]
[ "func", "SetAuthentication", "(", "sys", "*", "<mask>", ".", "SystemContext", ",", "registry", ",", "username", ",", "password", "string", ")", "error", "{", "return", "modifyJSON", "(", "sys", ",", "func", "(", "auths", "*", "dockerConfigFile", ")", "(", "bool", ",", "error", ")", "{", "if", "ch", ",", "exists", ":=", "auths", ".", "CredHelpers", "[", "registry", "]", ";", "exists", "{", "return", "false", ",", "setAuthToCredHelper", "(", "ch", ",", "registry", ",", "username", ",", "password", ")", "\n", "}", "\n\n", "creds", ":=", "base64", ".", "StdEncoding", ".", "EncodeToString", "(", "[", "]", "byte", "(", "username", "+", "\"", "\"", "+", "password", ")", ")", "\n", "newCreds", ":=", "dockerAuthConfig", "{", "Auth", ":", "creds", "}", "\n", "auths", ".", "AuthConfigs", "[", "registry", "]", "=", "newCreds", "\n", "return", "true", ",", "nil", "\n", "}", ")", "\n", "}" ]
16,140
all-16141
[ "GetService", "returns", "the", "Service", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "t", "*", "TraceServiceDefinition", ")", "GetService", "(", ")", "string", "{", "if", "t", "==", "nil", "||", "t", ".", "<mask>", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "t", ".", "Service", "\n", "}" ]
16,141
all-16142
[ "ActivateCmd", "returns", "a", "cobra", ".", "Command", "to", "activate", "the", "enterprise", "features", "of", "Pachyderm", "within", "a", "Pachyderm", "cluster", ".", "All", "repos", "will", "go", "from", "publicly", "-", "accessible", "to", "accessible", "only", "by", "the", "owner", "who", "can", "subsequently", "add", "users" ]
[ "func", "ActivateCmd", "(", "noMetrics", ",", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "<mask>", "expires", "string", "\n", "activate", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"", "\"", ",", "Short", ":", "\"", "\"", "+", "\"", "\"", ",", "Long", ":", "\"", "\"", "+", "\"", "\"", ",", "Run", ":", "cmdutil", ".", "RunFixedArgs", "(", "1", ",", "func", "(", "args", "[", "]", "string", ")", "error", "{", "c", ",", "err", ":=", "client", ".", "NewOnUserMachine", "(", "!", "*", "noMetrics", ",", "!", "*", "noPortForwarding", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "defer", "c", ".", "Close", "(", ")", "\n", "req", ":=", "&", "enterprise", ".", "ActivateRequest", "{", "}", "\n", "req", ".", "ActivationCode", "=", "args", "[", "0", "]", "\n", "if", "expires", "!=", "\"", "\"", "{", "t", ",", "err", ":=", "parseISO8601", "(", "expires", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ",", "expires", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "req", ".", "Expires", ",", "err", "=", "types", ".", "TimestampProto", "(", "t", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ",", "t", ".", "String", "(", ")", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "}", "\n", "resp", ",", "err", ":=", "c", ".", "Enterprise", ".", "Activate", "(", "c", ".", "Ctx", "(", ")", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "ts", ",", "err", ":=", "types", ".", "TimestampFromProto", "(", "resp", ".", "Info", ".", "Expires", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", "+", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"", "\"", "+", "\"", "\\n", "\"", ",", "ts", ".", "String", "(", ")", ")", "\n", "return", "nil", "\n", "}", ")", ",", "}", "\n", "activate", ".", "PersistentFlags", "(", ")", ".", "StringVar", "(", "&", "expires", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "+", "\"", "\"", "+", "\"", "\"", "+", "\"", "\"", "+", "\"", "\"", ")", "\n\n", "return", "cmdutil", ".", "CreateAlias", "(", "activate", ",", "\"", "\"", ")", "\n", "}" ]
16,142
all-16143
[ "Import", "a", "tarball", "of", "the", "images", "needed", "by", "a", "deployment", "such", "as", "the", "one", "created", "by", "Export", "and", "push", "those", "images", "to", "the", "registry", "specific", "in", "opts", "." ]
[ "func", "Import", "(", "opts", "*", "assets", ".", "AssetOpts", ",", "in", "io", ".", "Reader", ")", "error", "{", "client", ",", "err", ":=", "docker", ".", "NewClientFromEnv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "authConfigs", ",", "err", ":=", "docker", ".", "NewAuthConfigurationsFromDockerCfg", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "if", "len", "(", "authConfigs", ".", "Configs", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "err", ":=", "client", ".", "LoadImage", "(", "docker", ".", "LoadImageOptions", "{", "InputStream", ":", "in", ",", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "registry", ":=", "opts", ".", "Registry", "\n", "opts", ".", "Registry", "=", "\"", "\"", "// pretend we're using default images so we can get targets to tag", "\n", "images", ":=", "assets", ".", "Images", "(", "opts", ")", "\n", "opts", ".", "Registry", "=", "registry", "\n", "for", "_", ",", "image", ":=", "range", "images", "{", "repository", ",", "tag", ":=", "docker", ".", "ParseRepositoryTag", "(", "<mask>", ")", "\n", "registryRepo", ":=", "assets", ".", "AddRegistry", "(", "opts", ".", "Registry", ",", "repository", ")", "\n", "if", "err", ":=", "client", ".", "TagImage", "(", "image", ",", "docker", ".", "TagImageOptions", "{", "Repo", ":", "registryRepo", ",", "Tag", ":", "tag", ",", "}", ",", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "pushed", ":=", "false", "\n", "var", "loopErr", "[", "]", "error", "\n", "for", "registry", ",", "authConfig", ":=", "range", "authConfigs", ".", "Configs", "{", "if", "err", ":=", "client", ".", "PushImage", "(", "docker", ".", "PushImageOptions", "{", "Name", ":", "registryRepo", ",", "Tag", ":", "tag", ",", "Registry", ":", "opts", ".", "Registry", ",", "InactivityTimeout", ":", "5", "*", "time", ".", "Second", ",", "}", ",", "authConfig", ",", ")", ";", "err", "!=", "nil", "{", "loopErr", "=", "append", "(", "loopErr", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "registry", ",", "err", ")", ")", "\n", "continue", "\n", "}", "\n", "pushed", "=", "true", "\n", "break", "\n", "}", "\n", "if", "!", "pushed", "{", "errStr", ":=", "\"", "\"", "\n", "for", "_", ",", "err", ":=", "range", "loopErr", "{", "errStr", "+=", "err", ".", "Error", "(", ")", "+", "\"", "\\n", "\"", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "registryRepo", ",", "tag", ",", "errStr", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
16,143
all-16144
[ "Returns", "the", "number", "of", "distinct", "remote", "addresses", "the", "announce", "has", "queried", "." ]
[ "func", "(", "a", "*", "Announce", ")", "NumContacted", "(", ")", "int", "{", "a", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "mu", ".", "Unlock", "(", ")", "\n", "<mask>", "a", ".", "numContacted", "\n", "}" ]
16,144
all-16145
[ "Process", "a", "rangePattern", "match", "group" ]
[ "func", "(", "s", "*", "FrameSet", ")", "handleMatch", "(", "match", "[", "]", "string", ")", "error", "{", "switch", "len", "(", "match", ")", "{", "// Single frame match", "case", "1", ":", "f", ",", "err", ":=", "parseInt", "(", "match", "[", "0", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "s", ".", "rangePtr", ".", "AppendUnique", "(", "f", ",", "f", ",", "1", ")", "\n\n", "// Simple frame range", "case", "2", ":", "start", ",", "err", ":=", "parseInt", "(", "match", "[", "0", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "end", ",", "err", ":=", "parseInt", "(", "match", "[", "1", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Handle descending frame ranges, like 10-1", "var", "inc", "int", "\n", "if", "start", ">", "end", "{", "inc", "=", "-", "1", "\n", "}", "else", "{", "inc", "=", "1", "\n", "}", "\n\n", "s", ".", "rangePtr", ".", "AppendUnique", "(", "start", ",", "end", ",", "inc", ")", "\n\n", "// Complex frame range", "case", "4", ":", "var", "(", "err", "error", "\n", "mod", "string", "\n", "start", ",", "end", ",", "chunk", "int", "\n", ")", "\n", "chunk", ",", "err", "=", "parseInt", "(", "<mask>", "[", "3", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "chunk", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", "+", "\"", "\"", ",", "match", "[", "3", "]", ")", "\n", "}", "\n", "if", "start", ",", "err", "=", "parseInt", "(", "match", "[", "0", "]", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "end", ",", "err", "=", "parseInt", "(", "match", "[", "1", "]", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "mod", "=", "match", "[", "2", "]", ";", "!", "isModifier", "(", "mod", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "mod", ")", "\n", "}", "\n\n", "switch", "mod", "{", "case", "`x`", ":", "s", ".", "rangePtr", ".", "AppendUnique", "(", "start", ",", "end", ",", "chunk", ")", "\n\n", "case", "`y`", ":", "// TODO: Add proper support for adding inverse of range.", "// This approach will add excessive amounts of singe", "// range elements. They could be compressed into chunks", "skip", ":=", "start", "\n", "aRange", ":=", "ranges", ".", "NewInclusiveRange", "(", "start", ",", "end", ",", "1", ")", "\n", "var", "val", "int", "\n", "for", "it", ":=", "aRange", ".", "IterValues", "(", ")", ";", "!", "it", ".", "IsDone", "(", ")", ";", "{", "val", "=", "it", ".", "Next", "(", ")", "\n", "if", "val", "==", "skip", "{", "skip", "+=", "chunk", "\n", "continue", "\n", "}", "\n", "s", ".", "rangePtr", ".", "AppendUnique", "(", "val", ",", "val", ",", "1", ")", "\n", "}", "\n\n", "case", "`:`", ":", "for", ";", "chunk", ">", "0", ";", "chunk", "--", "{", "s", ".", "rangePtr", ".", "AppendUnique", "(", "start", ",", "end", ",", "chunk", ")", "\n", "}", "\n", "}", "\n\n", "default", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "match", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
16,145
all-16146
[ "GetSSHHostname", "returns", "hostname", "for", "use", "with", "ssh" ]
[ "func", "(", "d", "*", "SerialDriver", ")", "GetSSHHostname", "(", ")", "(", "<mask>", ",", "error", ")", "{", "d", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "Unlock", "(", ")", "\n", "return", "d", ".", "Driver", ".", "GetSSHHostname", "(", ")", "\n", "}" ]
16,146
all-16147
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventSignedExchangeReceived", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork47", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
16,147
all-16148
[ "inspectCommit", "takes", "a", "Commit", "and", "returns", "the", "corresponding", "CommitInfo", ".", "As", "a", "side", "effect", "this", "function", "also", "replaces", "the", "ID", "in", "the", "given", "commit", "with", "a", "real", "commit", "ID", "." ]
[ "func", "(", "d", "*", "driver", ")", "inspectCommit", "(", "pachClient", "*", "client", ".", "APIClient", ",", "commit", "*", "pfs", ".", "Commit", ",", "blockState", "pfs", ".", "CommitState", ")", "(", "*", "pfs", ".", "CommitInfo", ",", "error", ")", "{", "ctx", ":=", "pachClient", ".", "Ctx", "(", ")", "\n", "if", "commit", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "err", ":=", "d", ".", "checkIsAuthorized", "(", "pachClient", ",", "commit", ".", "Repo", ",", "auth", ".", "Scope_READER", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Check if the commitID is a branch name", "var", "commitInfo", "*", "pfs", ".", "CommitInfo", "\n", "if", "_", ",", "err", ":=", "col", ".", "NewSTM", "(", "ctx", ",", "d", ".", "etcdClient", ",", "func", "(", "stm", "col", ".", "STM", ")", "error", "{", "<mask>", "err", "error", "\n", "commitInfo", ",", "err", "=", "d", ".", "resolveCommit", "(", "stm", ",", "commit", ")", "\n", "return", "err", "\n", "}", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "commits", ":=", "d", ".", "commits", "(", "commit", ".", "Repo", ".", "Name", ")", ".", "ReadOnly", "(", "ctx", ")", "\n", "if", "blockState", "==", "pfs", ".", "CommitState_READY", "{", "// Wait for each provenant commit to be finished", "for", "_", ",", "p", ":=", "range", "commitInfo", ".", "Provenance", "{", "d", ".", "inspectCommit", "(", "pachClient", ",", "p", ".", "Commit", ",", "pfs", ".", "CommitState_FINISHED", ")", "\n", "}", "\n", "}", "\n", "if", "blockState", "==", "pfs", ".", "CommitState_FINISHED", "{", "// Watch the CommitInfo until the commit has been finished", "if", "err", ":=", "func", "(", ")", "error", "{", "commitInfoWatcher", ",", "err", ":=", "commits", ".", "WatchOne", "(", "commit", ".", "ID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "commitInfoWatcher", ".", "Close", "(", ")", "\n", "for", "{", "var", "commitID", "string", "\n", "_commitInfo", ":=", "new", "(", "pfs", ".", "CommitInfo", ")", "\n", "event", ":=", "<-", "commitInfoWatcher", ".", "Watch", "(", ")", "\n", "switch", "event", ".", "Type", "{", "case", "watch", ".", "EventError", ":", "return", "event", ".", "Err", "\n", "case", "watch", ".", "EventPut", ":", "if", "err", ":=", "event", ".", "Unmarshal", "(", "&", "commitID", ",", "_commitInfo", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "case", "watch", ".", "EventDelete", ":", "return", "pfsserver", ".", "ErrCommitDeleted", "{", "commit", "}", "\n", "}", "\n", "if", "_commitInfo", ".", "Finished", "!=", "nil", "{", "commitInfo", "=", "_commitInfo", "\n", "break", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "return", "commitInfo", ",", "nil", "\n", "}" ]
16,148
all-16149
[ "NOTE", "following", "two", "functions", "and", "soe", "other", "further", "below", "copied", "from", "dwra2d", "{", "img|gl", "}", "TODO", "move", "them", "all", "to", "common", "draw2dbase?", "CreateStringPath", "creates", "a", "path", "from", "the", "string", "s", "at", "x", "y", "and", "returns", "the", "string", "width", ".", "The", "text", "is", "placed", "so", "that", "the", "left", "edge", "of", "the", "em", "square", "of", "the", "first", "character", "of", "s", "and", "the", "baseline", "intersect", "at", "x", "y", ".", "The", "majority", "of", "the", "affected", "pixels", "will", "be", "above", "and", "to", "the", "right", "of", "the", "point", "but", "some", "may", "be", "below", "or", "to", "the", "left", ".", "For", "example", "drawing", "a", "string", "that", "starts", "with", "a", "J", "in", "an", "italic", "font", "may", "affect", "pixels", "below", "and", "left", "of", "the", "point", "." ]
[ "func", "(", "gc", "*", "GraphicContext", ")", "CreateStringPath", "(", "s", "string", ",", "x", ",", "y", "float64", ")", "(", "cursor", "float64", ")", "{", "f", ",", "err", ":=", "gc", ".", "loadCurrentFont", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Println", "(", "err", ")", "\n", "return", "0.0", "\n", "}", "\n", "startx", ":=", "x", "\n", "prev", ",", "hasPrev", ":=", "truetype", ".", "Index", "(", "0", ")", ",", "false", "\n", "for", "_", ",", "rune", ":=", "range", "s", "{", "index", ":=", "f", ".", "<mask>", "(", "rune", ")", "\n", "if", "hasPrev", "{", "x", "+=", "fUnitsToFloat64", "(", "f", ".", "Kern", "(", "fixed", ".", "Int26_6", "(", "gc", ".", "Current", ".", "Scale", ")", ",", "prev", ",", "index", ")", ")", "\n", "}", "\n", "err", ":=", "gc", ".", "drawGlyph", "(", "index", ",", "x", ",", "y", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Println", "(", "err", ")", "\n", "return", "startx", "-", "x", "\n", "}", "\n", "x", "+=", "fUnitsToFloat64", "(", "f", ".", "HMetric", "(", "fixed", ".", "Int26_6", "(", "gc", ".", "Current", ".", "Scale", ")", ",", "index", ")", ".", "AdvanceWidth", ")", "\n", "prev", ",", "hasPrev", "=", "index", ",", "true", "\n", "}", "\n\n", "return", "x", "-", "startx", "\n", "}" ]
16,149
all-16150
[ "ExecBool", "is", "like", "Exec", "except", "it", "will", "attempt", "to", "convert", "the", "result", "to", "its", "boolean", "value", "." ]
[ "func", "(", "xp", "XPathExec", ")", "ExecBool", "(", "t", "tree", ".", "Node", ",", "opts", "...", "FuncOpts", ")", "(", "bool", ",", "error", ")", "{", "<mask>", ",", "err", ":=", "xp", ".", "Exec", "(", "t", ",", "opts", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n\n", "b", ",", "ok", ":=", "res", ".", "(", "tree", ".", "IsBool", ")", "\n", "if", "!", "ok", "{", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "bool", "(", "b", ".", "Bool", "(", ")", ")", ",", "nil", "\n", "}" ]
16,150
all-16151
[ "cephRBDSnapshotDelete", "deletes", "an", "RBD", "snapshot", "This", "requires", "that", "the", "snapshot", "does", "not", "have", "any", "clones", "and", "is", "unmapped", "and", "unprotected", "." ]
[ "func", "cephRBDSnapshotDelete", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeName", "string", ",", "volumeType", "string", ",", "snapshotName", "string", ",", "userName", "string", ")", "error", "{", "_", ",", "err", ":=", "<mask>", ".", "RunCommand", "(", "\"", "\"", ",", "\"", "\"", ",", "userName", ",", "\"", "\"", ",", "clusterName", ",", "\"", "\"", ",", "poolName", ",", "\"", "\"", ",", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "volumeType", ",", "volumeName", ",", "snapshotName", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
16,151
all-16152
[ "WrapPrefix", "makes", "an", "Error", "from", "the", "given", "value", ".", "If", "that", "value", "is", "already", "an", "error", "then", "it", "will", "be", "used", "directly", "if", "not", "it", "will", "be", "passed", "to", "fmt", ".", "Errorf", "(", "%v", ")", ".", "The", "prefix", "parameter", "is", "used", "to", "add", "a", "prefix", "to", "the", "error", "message", "when", "calling", "Error", "()", ".", "The", "skip", "parameter", "indicates", "how", "far", "up", "the", "stack", "to", "start", "the", "stacktrace", ".", "0", "is", "from", "the", "current", "call", "1", "from", "its", "caller", "etc", "." ]
[ "func", "WrapPrefix", "(", "e", "interface", "{", "}", ",", "prefix", "string", ",", "skip", "int", ")", "*", "Error", "{", "if", "e", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "err", ":=", "Wrap", "(", "e", ",", "1", "+", "skip", ")", "\n\n", "if", "err", ".", "<mask>", "!=", "\"", "\"", "{", "prefix", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "prefix", ",", "err", ".", "prefix", ")", "\n", "}", "\n\n", "return", "&", "Error", "{", "Err", ":", "err", ".", "Err", ",", "stack", ":", "err", ".", "stack", ",", "prefix", ":", "prefix", ",", "}", "\n\n", "}" ]
16,152
all-16153
[ "GetSubdomain", "returns", "the", "Subdomain", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "i", "*", "IntegrationPDRequest", ")", "GetSubdomain", "(", ")", "string", "{", "if", "i", "==", "nil", "||", "i", ".", "Subdomain", "==", "nil", "{", "<mask>", "\"", "\"", "\n", "}", "\n", "return", "*", "i", ".", "Subdomain", "\n", "}" ]
16,153
all-16154
[ "Validate", "implements", "the", "coal", ".", "ValidatableModel", "interface", "." ]
[ "func", "(", "a", "*", "Application", ")", "Validate", "(", ")", "error", "{", "// hash password if available", "err", ":=", "a", ".", "HashSecret", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// check id", "if", "!", "a", ".", "ID", "(", ")", ".", "Valid", "(", ")", "{", "return", "fire", ".", "E", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// check name", "if", "a", ".", "<mask>", "==", "\"", "\"", "{", "return", "fire", ".", "E", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// check key", "if", "a", ".", "Key", "==", "\"", "\"", "{", "return", "fire", ".", "E", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// check secret hash", "if", "len", "(", "a", ".", "SecretHash", ")", "==", "0", "{", "return", "fire", ".", "E", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// check redirect uri", "if", "a", ".", "RedirectURL", "!=", "\"", "\"", "&&", "!", "govalidator", ".", "IsURL", "(", "a", ".", "RedirectURL", ")", "{", "return", "fire", ".", "E", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
16,154
all-16155
[ "Same", "as", "FindRoutes", "but", "return", "in", "addition", "a", "boolean", "indicating", "if", "the", "path", "was", "matched", ".", "Useful", "to", "return", "405" ]
[ "func", "(", "t", "*", "Trie", ")", "FindRoutesAndPathMatched", "(", "httpMethod", ",", "path", "string", ")", "(", "[", "]", "*", "Match", ",", "bool", ")", "{", "context", ":=", "newFindContext", "(", ")", "\n", "pathMatched", ":=", "false", "\n", "matches", ":=", "[", "]", "*", "Match", "{", "}", "\n", "context", ".", "matchFunc", "=", "func", "(", "httpMethod", ",", "path", "string", ",", "node", "*", "node", ")", "{", "pathMatched", "=", "true", "\n", "if", "<mask>", ".", "HttpMethodToRoute", "[", "httpMethod", "]", "!=", "nil", "{", "// path and method match, found a route !", "matches", "=", "append", "(", "matches", ",", "&", "Match", "{", "Route", ":", "node", ".", "HttpMethodToRoute", "[", "httpMethod", "]", ",", "Params", ":", "context", ".", "paramsAsMap", "(", ")", ",", "}", ",", ")", "\n", "}", "\n", "}", "\n", "t", ".", "root", ".", "find", "(", "httpMethod", ",", "path", ",", "context", ")", "\n", "return", "matches", ",", "pathMatched", "\n", "}" ]
16,155
all-16156
[ "fieldIndexByName", "returns", "the", "nested", "field", "corresponding", "to", "the", "index", "sequence", "." ]
[ "func", "(", "db", "*", "DB", ")", "fieldIndexByName", "(", "t", "reflect", ".", "Type", ",", "name", "string", ",", "index", "[", "]", "int", ")", "[", "]", "int", "{", "for", "i", ":=", "0", ";", "i", "<", "t", ".", "NumField", "(", ")", ";", "i", "++", "{", "field", ":=", "t", ".", "Field", "(", "i", ")", "\n", "if", "candidate", ":=", "db", ".", "columnFromTag", "(", "field", ")", ";", "candidate", "==", "name", "{", "return", "append", "(", "index", ",", "i", ")", "\n", "}", "\n", "if", "field", ".", "Anonymous", "{", "if", "idx", ":=", "db", ".", "fieldIndexByName", "(", "field", ".", "Type", ",", "name", ",", "<mask>", "(", "index", ",", "i", ")", ")", ";", "len", "(", "idx", ")", ">", "0", "{", "return", "append", "(", "index", ",", "idx", "...", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
16,156
all-16157
[ "newArena", "returns", "a", "new", "arena", "." ]
[ "func", "newArena", "(", "n", "int64", ")", "*", "Arena", "{", "// Don't store data at position 0 in order to reserve offset=0 as a kind", "// of nil pointer.", "out", ":=", "&", "Arena", "{", "n", ":", "1", ",", "buf", ":", "make", "(", "[", "]", "byte", ",", "n", ")", ",", "}", "\n", "return", "<mask>", "\n", "}" ]
16,157
all-16158
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "EventMetrics", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoPerformance4", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
16,158
all-16159
[ "MissingRequiredContexts", "discard", "the", "optional", "contexts", "and", "only", "look", "of", "extra", "required", "contexts", "that", "are", "not", "provided", "." ]
[ "func", "(", "cp", "*", "TideContextPolicy", ")", "MissingRequiredContexts", "(", "contexts", "[", "]", "string", ")", "[", "]", "string", "{", "if", "len", "(", "cp", ".", "RequiredContexts", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "existingContexts", ":=", "sets", ".", "NewString", "(", ")", "\n", "for", "_", ",", "c", ":=", "range", "contexts", "{", "existingContexts", ".", "Insert", "(", "c", ")", "\n", "}", "\n", "var", "missingContexts", "[", "]", "string", "\n", "for", "c", ":=", "<mask>", "sets", ".", "NewString", "(", "cp", ".", "RequiredContexts", "...", ")", ".", "Difference", "(", "existingContexts", ")", "{", "missingContexts", "=", "append", "(", "missingContexts", ",", "c", ")", "\n", "}", "\n", "return", "missingContexts", "\n", "}" ]
16,159
all-16160
[ "HasTime", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "e", "*", "EventStreamDefinition", ")", "HasTime", "(", ")", "bool", "{", "if", "e", "!=", "nil", "&&", "e", ".", "Time", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
16,160
all-16161
[ "IsLess", "should", "fulfill", "the", "requirement", "to", "compare", "two", "targets", "and", "chosse", "the", "lesser", "one", ".", "In", "the", "past", "target", "was", "a", "simple", "string", "so", "simple", "string", "comparison", "could", "be", "used", ".", "Now", "we", "define", "less", "as", "either", "being", "the", "shorter", "list", "of", "targets", "or", "where", "the", "first", "entry", "is", "less", ".", "FIXME", "We", "really", "need", "to", "define", "under", "which", "circumstances", "a", "list", "Targets", "is", "considered", "less", "than", "another", "." ]
[ "func", "(", "t", "Targets", ")", "IsLess", "(", "o", "Targets", ")", "bool", "{", "if", "len", "(", "t", ")", "<", "len", "(", "o", ")", "{", "return", "<mask>", "\n", "}", "\n", "if", "len", "(", "t", ")", ">", "len", "(", "o", ")", "{", "return", "false", "\n", "}", "\n\n", "sort", ".", "Sort", "(", "t", ")", "\n", "sort", ".", "Sort", "(", "o", ")", "\n\n", "for", "i", ",", "e", ":=", "range", "t", "{", "if", "e", "!=", "o", "[", "i", "]", "{", "return", "e", "<", "o", "[", "i", "]", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
16,161
all-16162
[ "tokenFor", "returns", "a", "unique", "transaction", "token", "that", "is", "composed", "by", "t", "s", "id", "and", "a", "nonce", ".", "If", "t", "already", "has", "a", "nonce", "assigned", "to", "it", "it", "will", "be", "used", "otherwise", "a", "new", "nonce", "will", "be", "generated", "." ]
[ "func", "tokenFor", "(", "t", "*", "transaction", ")", "token", "{", "nonce", ":=", "t", ".", "Nonce", "\n", "if", "nonce", "==", "\"", "\"", "{", "nonce", "=", "newNonce", "(", ")", "\n", "}", "\n", "return", "<mask>", "(", "t", ".", "Id", ".", "Hex", "(", ")", "+", "\"", "\"", "+", "nonce", ")", "\n", "}" ]
16,162
all-16163
[ "IsAborted", "means", "something", "stopped", "the", "job", "before", "it", "could", "finish", "." ]
[ "func", "(", "jb", "*", "Build", ")", "IsAborted", "(", ")", "bool", "{", "return", "jb", ".", "Result", "!=", "nil", "&&", "*", "jb", ".", "<mask>", "==", "aborted", "\n", "}" ]
16,163
all-16164
[ "DeleteArticle", "removes", "an", "existing", "Article", "from", "our", "persistent", "store", "." ]
[ "func", "DeleteArticle", "(", "w", "<mask>", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "err", "error", "\n\n", "// Assume if we've reach this far, we can access the article", "// context because this handler is a child of the ArticleCtx", "// middleware. The worst case, the recoverer middleware will save us.", "article", ":=", "r", ".", "Context", "(", ")", ".", "Value", "(", "\"", "\"", ")", ".", "(", "*", "Article", ")", "\n\n", "article", ",", "err", "=", "dbRemoveArticle", "(", "article", ".", "ID", ")", "\n", "if", "err", "!=", "nil", "{", "render", ".", "Render", "(", "w", ",", "r", ",", "ErrInvalidRequest", "(", "err", ")", ")", "\n", "return", "\n", "}", "\n\n", "render", ".", "Render", "(", "w", ",", "r", ",", "NewArticleResponse", "(", "article", ")", ")", "\n", "}" ]
16,164
all-16165
[ "SetImageDefaults", "setter" ]
[ "func", "(", "s", "*", "ConcoursePipeline", ")", "SetImageDefaults", "(", "platform", ",", "imagetype", ",", "repo", "string", ")", "{", "s", ".", "defaultPlatform", "=", "<mask>", "\n", "s", ".", "defaultImageType", "=", "imagetype", "\n", "s", ".", "defaultImageRepository", "=", "repo", "\n", "}" ]
16,165
all-16166
[ "localOnlyMain", "contains", "logic", "used", "only", "when", "running", "locally", "and", "is", "mutually", "exclusive", "with", "prodOnlyMain", "." ]
[ "func", "localOnlyMain", "(", "cfg", "config", ".", "Getter", ",", "o", "<mask>", ",", "mux", "*", "http", ".", "ServeMux", ")", "*", "http", ".", "ServeMux", "{", "mux", ".", "Handle", "(", "\"", "\"", ",", "gziphandler", ".", "GzipHandler", "(", "handleSimpleTemplate", "(", "o", ",", "cfg", ",", "\"", "\"", ",", "nil", ")", ")", ")", "\n\n", "if", "o", ".", "spyglass", "{", "initSpyglass", "(", "cfg", ",", "o", ",", "mux", ",", "nil", ")", "\n", "}", "\n\n", "return", "mux", "\n", "}" ]
16,166
all-16167
[ "deleteImport", "deletes", "the", "import", "path", "from", "the", "file", "f", "if", "present", "." ]
[ "func", "deleteImport", "(", "f", "*", "ast", ".", "File", ",", "path", "string", ")", "(", "deleted", "bool", ")", "{", "oldImport", ":=", "importSpec", "(", "f", ",", "path", ")", "\n\n", "// Find the import node that imports path, if any.", "for", "i", ",", "decl", ":=", "range", "f", ".", "Decls", "{", "gen", ",", "ok", ":=", "decl", ".", "(", "*", "ast", ".", "GenDecl", ")", "\n", "if", "!", "ok", "||", "gen", ".", "Tok", "!=", "token", ".", "IMPORT", "{", "continue", "\n", "}", "\n", "for", "j", ",", "spec", ":=", "range", "gen", ".", "Specs", "{", "impspec", ":=", "spec", ".", "(", "*", "ast", ".", "ImportSpec", ")", "\n", "if", "oldImport", "!=", "impspec", "{", "continue", "\n", "}", "\n\n", "// We found an import spec that imports path.", "// Delete it.", "deleted", "=", "true", "\n", "copy", "(", "gen", ".", "Specs", "[", "j", ":", "]", ",", "gen", ".", "Specs", "[", "j", "+", "1", ":", "]", ")", "\n", "gen", ".", "Specs", "=", "<mask>", ".", "Specs", "[", ":", "len", "(", "gen", ".", "Specs", ")", "-", "1", "]", "\n\n", "// If this was the last import spec in this decl,", "// delete the decl, too.", "if", "len", "(", "gen", ".", "Specs", ")", "==", "0", "{", "copy", "(", "f", ".", "Decls", "[", "i", ":", "]", ",", "f", ".", "Decls", "[", "i", "+", "1", ":", "]", ")", "\n", "f", ".", "Decls", "=", "f", ".", "Decls", "[", ":", "len", "(", "f", ".", "Decls", ")", "-", "1", "]", "\n", "}", "else", "if", "len", "(", "gen", ".", "Specs", ")", "==", "1", "{", "gen", ".", "Lparen", "=", "token", ".", "NoPos", "// drop parens", "\n", "}", "\n", "if", "j", ">", "0", "{", "// We deleted an entry but now there will be", "// a blank line-sized hole where the import was.", "// Close the hole by making the previous", "// import appear to \"end\" where this one did.", "gen", ".", "Specs", "[", "j", "-", "1", "]", ".", "(", "*", "ast", ".", "ImportSpec", ")", ".", "EndPos", "=", "impspec", ".", "End", "(", ")", "\n", "}", "\n", "break", "\n", "}", "\n", "}", "\n\n", "// Delete it from f.Imports.", "for", "i", ",", "imp", ":=", "range", "f", ".", "Imports", "{", "if", "imp", "==", "oldImport", "{", "copy", "(", "f", ".", "Imports", "[", "i", ":", "]", ",", "f", ".", "Imports", "[", "i", "+", "1", ":", "]", ")", "\n", "f", ".", "Imports", "=", "f", ".", "Imports", "[", ":", "len", "(", "f", ".", "Imports", ")", "-", "1", "]", "\n", "break", "\n", "}", "\n", "}", "\n\n", "return", "\n", "}" ]
16,167
all-16168
[ "HasPaletteFlip", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "h", "*", "HostmapStyle", ")", "HasPaletteFlip", "(", ")", "bool", "{", "if", "h", "!=", "nil", "&&", "h", ".", "PaletteFlip", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
16,168
all-16169
[ "Decode", "expects", "v", "to", "be", "a", "pointer", "to", "a", "value", "in", "which", "the", "decoder", "will", "load", "the", "next", "parsed", "data", ".", "The", "method", "panics", "if", "v", "is", "neither", "a", "pointer", "type", "nor", "implements", "the", "ValueDecoder", "interface", "or", "if", "v", "is", "a", "nil", "pointer", "." ]
[ "func", "(", "d", "Decoder", ")", "Decode", "(", "v", "interface", "{", "}", ")", "error", "{", "to", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n\n", "if", "d", ".", "off", "!=", "0", "{", "var", "err", "error", "\n", "if", "d", ".", "off", ",", "err", "=", "0", ",", "d", ".", "<mask>", ".", "ParseMapValue", "(", "d", ".", "off", "-", "1", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "if", "!", "to", ".", "IsValid", "(", ")", "{", "// This special case for a nil value is used to make it possible to", "// discard decoded values.", "_", ",", "err", ":=", "d", ".", "decodeInterface", "(", "to", ")", "\n", "return", "err", "\n", "}", "\n\n", "// Optimization for ValueDecoder, in practice tho it's also handled in the", "// methods that are based on reflection.", "switch", "x", ":=", "v", ".", "(", "type", ")", "{", "case", "ValueDecoder", ":", "return", "x", ".", "DecodeValue", "(", "d", ")", "\n", "}", "\n\n", "if", "to", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "// In most cases the method receives a pointer, but we may also have to", "// support types that aren't pointers but implement ValueDecoder, or", "// types that have got adapters set.", "// If we're not in either of those cases the code will likely panic when", "// the value is set because it won't be addressable.", "to", "=", "to", ".", "Elem", "(", ")", "\n", "}", "\n\n", "_", ",", "err", ":=", "d", ".", "decode", "(", "to", ")", "\n", "return", "err", "\n", "}" ]
16,169
all-16170
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "GetPlatformFontsForNodeReturns", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss37", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
16,170
all-16171
[ "ParseBytes", "is", "like", "Parse", "except", "it", "parses", "a", "byte", "slice", "instead", "of", "a", "string", "." ]
[ "func", "ParseBytes", "(", "b", "[", "]", "byte", ")", "(", "UUID", ",", "error", ")", "{", "var", "uuid", "UUID", "\n", "switch", "len", "(", "b", ")", "{", "case", "36", ":", "// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "case", "36", "+", "9", ":", "// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "if", "!", "bytes", ".", "Equal", "(", "bytes", ".", "ToLower", "(", "b", "[", ":", "9", "]", ")", ",", "[", "]", "byte", "(", "\"", "\"", ")", ")", "{", "return", "uuid", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "b", "[", ":", "9", "]", ")", "\n", "}", "\n", "b", "=", "b", "[", "9", ":", "]", "\n", "case", "36", "+", "2", ":", "// {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}", "b", "=", "b", "[", "1", ":", "]", "\n", "case", "32", ":", "// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "var", "ok", "bool", "\n", "for", "i", ":=", "0", ";", "i", "<", "32", ";", "i", "+=", "2", "{", "uuid", "[", "i", "/", "2", "]", ",", "ok", "=", "xtob", "(", "b", "[", "i", "]", ",", "b", "[", "i", "+", "1", "]", ")", "\n", "if", "!", "ok", "{", "return", "uuid", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "return", "uuid", ",", "nil", "\n", "default", ":", "return", "uuid", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "b", ")", ")", "\n", "}", "\n", "// s is now at least 36 bytes long", "// it must be of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "if", "b", "[", "8", "]", "!=", "'-'", "||", "b", "[", "13", "]", "!=", "'-'", "||", "b", "[", "18", "]", "!=", "'-'", "||", "b", "[", "23", "]", "!=", "'-'", "{", "return", "uuid", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "for", "i", ",", "x", ":=", "<mask>", "[", "16", "]", "int", "{", "0", ",", "2", ",", "4", ",", "6", ",", "9", ",", "11", ",", "14", ",", "16", ",", "19", ",", "21", ",", "24", ",", "26", ",", "28", ",", "30", ",", "32", ",", "34", "}", "{", "v", ",", "ok", ":=", "xtob", "(", "b", "[", "x", "]", ",", "b", "[", "x", "+", "1", "]", ")", "\n", "if", "!", "ok", "{", "return", "uuid", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "uuid", "[", "i", "]", "=", "v", "\n", "}", "\n", "return", "uuid", ",", "nil", "\n", "}" ]
16,171
all-16172
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "Scope", ")", "UnmarshalJSON", "(", "<mask>", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger23", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
16,172
all-16173
[ "SetEndpoints", "updates", "the", "endpoints", "for", "ResolverGroup", ".", "All", "registered", "resolver", "are", "updated", "immediately", "with", "the", "new", "endpoints", "." ]
[ "func", "(", "e", "*", "ResolverGroup", ")", "SetEndpoints", "(", "endpoints", "[", "]", "string", ")", "{", "addrs", ":=", "epsToAddrs", "(", "endpoints", "...", ")", "\n", "e", ".", "mu", ".", "Lock", "(", ")", "\n", "e", ".", "endpoints", "=", "endpoints", "\n", "for", "_", ",", "r", ":=", "<mask>", "e", ".", "resolvers", "{", "r", ".", "cc", ".", "NewAddress", "(", "addrs", ")", "\n", "}", "\n", "e", ".", "mu", ".", "Unlock", "(", ")", "\n", "}" ]
16,173
all-16174
[ "Devices", "returns", "the", "devices", "matching", "the", "given", "filters", "." ]
[ "func", "(", "c", "*", "Cluster", ")", "Devices", "(", "project", ",", "qName", "string", ",", "isprofile", "bool", ")", "(", "types", ".", "Devices", ",", "error", ")", "{", "err", ":=", "c", ".", "Transaction", "(", "func", "(", "tx", "*", "ClusterTx", ")", "error", "{", "enabled", ",", "err", ":=", "tx", ".", "ProjectHasProfiles", "(", "project", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "!", "enabled", "{", "project", "=", "\"", "\"", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "q", "string", "\n", "if", "isprofile", "{", "q", "=", "`SELECT profiles_devices.id, profiles_devices.name, profiles_devices.type\n\t\t\tFROM profiles_devices\n JOIN profiles ON profiles_devices.profile_id = profiles.id\n JOIN projects ON projects.id=profiles.project_id\n \t\tWHERE projects.name=? AND profiles.name=?`", "\n", "}", "else", "{", "q", "=", "`SELECT containers_devices.id, containers_devices.name, containers_devices.type\n\t\t\tFROM containers_devices\n JOIN containers\tON containers_devices.container_id = containers.id\n JOIN projects ON projects.id=containers.project_id\n\t\t\tWHERE projects.name=? AND containers.name=?`", "\n", "}", "\n", "var", "id", ",", "dtype", "int", "\n", "var", "name", ",", "stype", "string", "\n", "inargs", ":=", "[", "]", "interface", "{", "}", "{", "project", ",", "qName", "}", "\n", "outfmt", ":=", "[", "]", "interface", "{", "}", "{", "id", ",", "name", ",", "dtype", "}", "\n", "results", ",", "err", ":=", "queryScan", "(", "c", ".", "db", ",", "q", ",", "inargs", ",", "outfmt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "devices", ":=", "types", ".", "Devices", "{", "}", "\n", "for", "_", ",", "r", ":=", "range", "results", "{", "id", "=", "r", "[", "0", "]", ".", "(", "int", ")", "\n", "<mask>", "=", "r", "[", "1", "]", ".", "(", "string", ")", "\n", "stype", ",", "err", "=", "dbDeviceTypeToString", "(", "r", "[", "2", "]", ".", "(", "int", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "newdev", ",", "err", ":=", "dbDeviceConfig", "(", "c", ".", "db", ",", "id", ",", "isprofile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "newdev", "[", "\"", "\"", "]", "=", "stype", "\n", "devices", "[", "name", "]", "=", "newdev", "\n", "}", "\n\n", "return", "devices", ",", "nil", "\n", "}" ]
16,174
all-16175
[ "SetBSON", "sets", "the", "Hostname", "from", "raw", "bson", "data" ]
[ "func", "(", "h", "*", "Hostname", ")", "SetBSON", "(", "raw", "bson", ".", "Raw", ")", "error", "{", "var", "m", "bson", ".", "M", "\n", "if", "err", ":=", "raw", ".", "Unmarshal", "(", "&", "m", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "data", ",", "ok", ":=", "m", "[", "\"", "\"", "]", ".", "(", "string", ")", ";", "<mask>", "{", "*", "h", "=", "Hostname", "(", "data", ")", "\n", "return", "nil", "\n", "}", "\n\n", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
16,175
all-16176
[ "FindPortInRange", "Iterate", "through", "CSV", "or", "Range", "of", "ports", "to", "find", "open", "port", "Valid", "inputs", "are", "8081", "8081", "8085", "8081", "-", "8085", ".", "Do", "not", "combine", "list", "and", "range" ]
[ "func", "FindPortInRange", "(", "s", "string", ")", "(", "int", ",", "error", ")", "{", "// Take care of csv and single value", "if", "!", "strings", ".", "Contains", "(", "s", ",", "\"", "\"", ")", "{", "ports", ":=", "strings", ".", "Split", "(", "strings", ".", "TrimSpace", "(", "s", ")", ",", "\"", "\"", ")", "\n", "for", "_", ",", "p", ":=", "range", "ports", "{", "i", ",", "err", ":=", "strconv", ".", "Atoi", "(", "p", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "err", "=", "checkPort", "(", "i", ")", "\n", "if", "err", "!=", "nil", "{", "continue", "\n", "}", "\n", "return", "i", ",", "nil", "\n", "}", "\n", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "// Now take care of ranges", "ports", ":=", "strings", ".", "Split", "(", "strings", ".", "TrimSpace", "(", "s", ")", ",", "\"", "\"", ")", "\n", "if", "len", "(", "ports", ")", "!=", "2", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "lower", ",", "err", ":=", "strconv", ".", "Atoi", "(", "ports", "[", "0", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "upper", ",", "err", ":=", "strconv", ".", "Atoi", "(", "ports", "[", "1", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "if", "upper", "<", "lower", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "for", "i", ":=", "<mask>", ";", "i", "<=", "upper", ";", "i", "++", "{", "err", "=", "checkPort", "(", "i", ")", "\n", "if", "err", "!=", "nil", "{", "continue", "\n", "}", "\n", "return", "i", ",", "nil", "\n", "}", "\n", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
16,176
all-16177
[ "Do", "executes", "Debugger", ".", "setBreakpointByUrl", "against", "the", "provided", "context", ".", "returns", ":", "breakpointID", "-", "Id", "of", "the", "created", "breakpoint", "for", "further", "reference", ".", "locations", "-", "List", "of", "the", "locations", "this", "breakpoint", "resolved", "into", "upon", "addition", "." ]
[ "func", "(", "p", "*", "SetBreakpointByURLParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "breakpointID", "BreakpointID", ",", "locations", "[", "]", "*", "Location", ",", "err", "error", ")", "{", "// execute", "var", "res", "SetBreakpointByURLReturns", "\n", "err", "=", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetBreakpointByURL", ",", "p", ",", "&", "res", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "nil", ",", "err", "\n", "}", "\n\n", "return", "<mask>", ".", "BreakpointID", ",", "res", ".", "Locations", ",", "nil", "\n", "}" ]
16,177
all-16178
[ "MakeTexture", "creates", "a", "texture", "object", "with", "privately", "owned", "storage", "that", "contains", "texture", "state", ".", "Reference", ":", "https", ":", "//", "developer", ".", "apple", ".", "com", "/", "documentation", "/", "metal", "/", "mtldevice", "/", "1433425", "-", "maketexture", "." ]
[ "func", "(", "d", "<mask>", ")", "MakeTexture", "(", "td", "TextureDescriptor", ")", "Texture", "{", "descriptor", ":=", "C", ".", "struct_TextureDescriptor", "{", "PixelFormat", ":", "C", ".", "uint16_t", "(", "td", ".", "PixelFormat", ")", ",", "Width", ":", "C", ".", "uint_t", "(", "td", ".", "Width", ")", ",", "Height", ":", "C", ".", "uint_t", "(", "td", ".", "Height", ")", ",", "StorageMode", ":", "C", ".", "uint8_t", "(", "td", ".", "StorageMode", ")", ",", "Usage", ":", "C", ".", "uint8_t", "(", "td", ".", "Usage", ")", ",", "}", "\n", "return", "Texture", "{", "texture", ":", "C", ".", "Device_MakeTexture", "(", "d", ".", "device", ",", "descriptor", ")", ",", "Width", ":", "td", ".", "Width", ",", "// TODO: Fetch dimensions of actually created texture.", "Height", ":", "td", ".", "Height", ",", "// TODO: Fetch dimensions of actually created texture.", "}", "\n", "}" ]
16,178
all-16179
[ "Collect", "implements", "prometheus", "Collector", "interface", "." ]
[ "func", "(", "c", "*", "Cache", ")", "Collect", "(", "in", "chan", "<-", "prometheus", ".", "Metric", ")", "{", "c", ".", "hitsTotal", ".", "Collect", "(", "in", ")", "\n", "c", ".", "refreshTotal", ".", "Collect", "(", "<mask>", ")", "\n", "c", ".", "missesTotal", ".", "Collect", "(", "in", ")", "\n", "}" ]
16,179
all-16180
[ "Adds", "ka", "to", "old", "bucket", ".", "Returns", "false", "if", "it", "couldn", "t", "do", "it", "cuz", "buckets", "full", "." ]
[ "func", "(", "a", "*", "AddrBook", ")", "addToOldBucket", "(", "ka", "*", "knownAddress", ",", "bucketIdx", "int", ")", "bool", "{", "// Sanity check", "if", "ka", ".", "isNew", "(", ")", "{", "log", ".", "Warn", "(", "Fmt", "(", "\"", "\"", ",", "ka", ")", ")", "\n", "return", "false", "\n", "}", "\n", "if", "len", "(", "ka", ".", "Buckets", ")", "!=", "0", "{", "log", ".", "Warn", "(", "Fmt", "(", "\"", "\"", ",", "ka", ")", ")", "\n", "return", "<mask>", "\n", "}", "\n\n", "addrStr", ":=", "ka", ".", "Addr", ".", "String", "(", ")", "\n", "bucket", ":=", "a", ".", "getBucket", "(", "bucketTypeNew", ",", "bucketIdx", ")", "\n\n", "// Already exists?", "if", "_", ",", "ok", ":=", "bucket", "[", "addrStr", "]", ";", "ok", "{", "return", "true", "\n", "}", "\n\n", "// Enforce max addresses.", "if", "len", "(", "bucket", ")", ">", "oldBucketSize", "{", "return", "false", "\n", "}", "\n\n", "// Add to bucket.", "bucket", "[", "addrStr", "]", "=", "ka", "\n", "if", "ka", ".", "addBucketRef", "(", "bucketIdx", ")", "==", "1", "{", "a", ".", "nOld", "++", "\n", "}", "\n\n", "// Ensure in addrLookup", "a", ".", "addrLookup", "[", "addrStr", "]", "=", "ka", "\n\n", "return", "true", "\n", "}" ]
16,180
all-16181
[ "NewVolumeResource", "returns", "a", "docker", "volume", "wrapper", "object" ]
[ "func", "NewVolumeResource", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "dockerVolumeName", "string", ",", "scope", "string", ",", "autoprovision", "bool", ",", "driver", "string", ",", "driverOptions", "map", "[", "string", "]", "string", ",", "labels", "map", "[", "string", "]", "string", ",", "<mask>", "dockerapi", ".", "DockerClient", ")", "(", "*", "VolumeResource", ",", "error", ")", "{", "if", "scope", "==", "TaskScope", "&&", "autoprovision", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n\n", "v", ":=", "&", "VolumeResource", "{", "Name", ":", "name", ",", "VolumeConfig", ":", "DockerVolumeConfig", "{", "Scope", ":", "scope", ",", "Autoprovision", ":", "autoprovision", ",", "Driver", ":", "driver", ",", "DriverOpts", ":", "driverOptions", ",", "Labels", ":", "labels", ",", "DockerVolumeName", ":", "dockerVolumeName", ",", "}", ",", "client", ":", "client", ",", "ctx", ":", "ctx", ",", "}", "\n", "v", ".", "initStatusToTransitions", "(", ")", "\n", "return", "v", ",", "nil", "\n", "}" ]
16,181
all-16182
[ "GetStringId", "is", "a", "helper", "routine", "that", "allows", "screenboards", "and", "timeboards", "to", "be", "retrieved", "by", "either", "the", "legacy", "numerical", "format", "or", "the", "new", "string", "format", ".", "It", "returns", "the", "id", "as", "is", "if", "it", "is", "a", "string", "converts", "it", "to", "a", "string", "if", "it", "is", "an", "integer", ".", "It", "return", "an", "error", "if", "the", "type", "is", "neither", "string", "or", "an", "integer" ]
[ "func", "GetStringId", "(", "id", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "switch", "v", ":=", "<mask>", ".", "(", "type", ")", "{", "case", "int", ":", "return", "strconv", ".", "Itoa", "(", "v", ")", ",", "nil", "\n", "case", "string", ":", "return", "v", ",", "nil", "\n", "default", ":", "return", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
16,182
all-16183
[ "GetHTTPClient", "returns", "the", "http", "client", "used", "for", "the", "connection", ".", "This", "can", "be", "used", "to", "set", "custom", "http", "options", "." ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetHTTPClient", "(", ")", "(", "*", "http", ".", "<mask>", ",", "error", ")", "{", "if", "r", ".", "http", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "r", ".", "http", ",", "nil", "\n", "}" ]
16,183
all-16184
[ "Helper", "functions", "Returns", "the", "parent", "container", "name", "snapshot", "name", "and", "whether", "it", "actually", "was", "a", "snapshot", "name", "." ]
[ "func", "containerGetParentAndSnapshotName", "(", "name", "string", ")", "(", "string", ",", "string", ",", "bool", ")", "{", "fields", ":=", "strings", ".", "SplitN", "(", "name", ",", "<mask>", ".", "SnapshotDelimiter", ",", "2", ")", "\n", "if", "len", "(", "fields", ")", "==", "1", "{", "return", "name", ",", "\"", "\"", ",", "false", "\n", "}", "\n\n", "return", "fields", "[", "0", "]", ",", "fields", "[", "1", "]", ",", "true", "\n", "}" ]
16,184
all-16185
[ "Per", "http", ":", "//", "www", ".", "libtorrent", ".", "org", "/", "dht_sec", ".", "html#enforcement", "the", "IP", "is", "considered", "a", "local", "network", "address", "and", "should", "be", "exempted", "from", "node", "ID", "verification", "." ]
[ "func", "isLocalNetwork", "(", "ip", "net", ".", "IP", ")", "bool", "{", "if", "classA", ".", "Contains", "(", "ip", ")", "{", "return", "true", "\n", "}", "\n", "if", "classB", ".", "Contains", "(", "ip", ")", "{", "return", "true", "\n", "}", "\n", "if", "classC", ".", "Contains", "(", "<mask>", ")", "{", "return", "true", "\n", "}", "\n", "if", "ip", ".", "IsLinkLocalUnicast", "(", ")", "{", "return", "true", "\n", "}", "\n", "if", "ip", ".", "IsLoopback", "(", ")", "{", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
16,185
all-16186
[ "PprofHandler", "serves", "server", "runtime", "profiling", "data", "in", "the", "format", "expected", "by", "the", "pprof", "visualization", "tool", ".", "See", "https", ":", "//", "golang", ".", "org", "/", "pkg", "/", "net", "/", "http", "/", "pprof", "/", "for", "details", "." ]
[ "func", "PprofHandler", "(", "ctx", "*", "fasthttp", ".", "RequestCtx", ")", "{", "ctx", ".", "Response", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "strings", ".", "HasPrefix", "(", "string", "(", "ctx", ".", "Path", "(", ")", ")", ",", "\"", "\"", ")", "{", "cmdline", "(", "ctx", ")", "\n", "}", "else", "if", "strings", ".", "HasPrefix", "(", "string", "(", "ctx", ".", "<mask>", "(", ")", ")", ",", "\"", "\"", ")", "{", "profile", "(", "ctx", ")", "\n", "}", "else", "if", "strings", ".", "HasPrefix", "(", "string", "(", "ctx", ".", "Path", "(", ")", ")", ",", "\"", "\"", ")", "{", "symbol", "(", "ctx", ")", "\n", "}", "else", "if", "strings", ".", "HasPrefix", "(", "string", "(", "ctx", ".", "Path", "(", ")", ")", ",", "\"", "\"", ")", "{", "trace", "(", "ctx", ")", "\n", "}", "else", "{", "for", "_", ",", "v", ":=", "range", "rtp", ".", "Profiles", "(", ")", "{", "ppName", ":=", "v", ".", "Name", "(", ")", "\n", "if", "strings", ".", "HasPrefix", "(", "string", "(", "ctx", ".", "Path", "(", ")", ")", ",", "\"", "\"", "+", "ppName", ")", "{", "namedHandler", ":=", "fasthttpadaptor", ".", "NewFastHTTPHandlerFunc", "(", "pprof", ".", "Handler", "(", "ppName", ")", ".", "ServeHTTP", ")", "\n", "namedHandler", "(", "ctx", ")", "\n", "return", "\n", "}", "\n", "}", "\n", "index", "(", "ctx", ")", "\n", "}", "\n", "}" ]
16,186
all-16187
[ "Functions", "dealing", "with", "container", "storage", "." ]
[ "func", "(", "s", "*", "storageBtrfs", ")", "ContainerStorageReady", "(", "<mask>", "container", ")", "bool", "{", "containerMntPoint", ":=", "getContainerMountPoint", "(", "container", ".", "Project", "(", ")", ",", "s", ".", "pool", ".", "Name", ",", "container", ".", "Name", "(", ")", ")", "\n", "return", "isBtrfsSubVolume", "(", "containerMntPoint", ")", "\n", "}" ]
16,187
all-16188
[ "Size", "returns", "the", "amount", "of", "bytes", "needed", "to", "encode", "an", "UTF", "-", "8", "byte", "slice", "to", "CESU", "-", "8", "." ]
[ "func", "Size", "(", "p", "[", "]", "byte", ")", "int", "{", "n", ":=", "0", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "p", ")", ";", "{", "r", ",", "<mask>", ",", "_", ":=", "decodeRune", "(", "p", "[", "i", ":", "]", ")", "\n", "i", "+=", "size", "\n", "n", "+=", "RuneLen", "(", "r", ")", "\n", "}", "\n", "return", "n", "\n", "}" ]
16,188
all-16189
[ "Create", "fetches", "secret", "value", "from", "SSM", "in", "batches", ".", "It", "spins", "up", "multiple", "goroutines", "in", "order", "to", "retrieve", "values", "in", "parallel", "." ]
[ "func", "(", "secret", "*", "SSMSecretResource", ")", "Create", "(", ")", "error", "{", "// To fail fast, check execution role first", "executionCredentials", ",", "ok", ":=", "secret", ".", "credentialsManager", ".", "GetTaskCredentials", "(", "secret", ".", "getExecutionCredentialsID", "(", ")", ")", "\n", "if", "!", "ok", "{", "// No need to log here. managedTask.applyResourceState already does that", "err", ":=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "secret", ".", "setTerminalReason", "(", "err", ".", "Error", "(", ")", ")", "\n", "return", "err", "\n", "}", "\n", "iamCredentials", ":=", "executionCredentials", ".", "GetIAMRoleCredentials", "(", ")", "\n\n", "var", "wg", "sync", ".", "WaitGroup", "\n\n", "// Get the maximum number of errors can be returned, which will be one error per goroutine", "chanLen", ":=", "secret", ".", "getGoRoutineMaxNum", "(", ")", "\n", "errorEvents", ":=", "make", "(", "chan", "error", ",", "chanLen", ")", "\n\n", "seelog", ".", "Infof", "(", "\"", "\"", ",", "secret", ".", "taskARN", ")", "\n", "secret", ".", "secretData", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n\n", "for", "region", ",", "secrets", ":=", "range", "secret", ".", "getRequiredSecrets", "(", ")", "{", "wg", ".", "Add", "(", "1", ")", "\n", "// Spin up goroutine each region to speed up processing time", "<mask>", "secret", ".", "retrieveSSMSecretValuesByRegion", "(", "region", ",", "secrets", ",", "iamCredentials", ",", "&", "wg", ",", "errorEvents", ")", "\n", "}", "\n\n", "wg", ".", "Wait", "(", ")", "\n\n", "// Get the first error returned and set as terminal reason", "select", "{", "case", "err", ":=", "<-", "errorEvents", ":", "secret", ".", "setTerminalReason", "(", "err", ".", "Error", "(", ")", ")", "\n", "return", "err", "\n", "default", ":", "return", "nil", "\n", "}", "\n", "}" ]
16,189
all-16190
[ "SetHeader", "sets", "the", "heder", "field", "and", "value", "for", "the", "message" ]
[ "func", "(", "m", "*", "Message", ")", "SetHeader", "(", "field", ",", "value", "string", ")", "{", "m", ".", "Headers", "[", "<mask>", "]", "=", "value", "\n", "}" ]
16,190
all-16191
[ "MarshalEasyJSON", "satisfies", "easyjson", ".", "Marshaler", "." ]
[ "func", "(", "t", "MonotonicTime", ")", "MarshalEasyJSON", "(", "out", "*", "jwriter", ".", "Writer", ")", "{", "v", ":=", "float64", "(", "time", ".", "Time", "(", "t", ")", ".", "Sub", "(", "*", "MonotonicTimeEpoch", ")", ")", "/", "float64", "(", "time", ".", "Second", ")", "\n\n", "out", ".", "Buffer", ".", "EnsureSpace", "(", "20", ")", "\n", "out", ".", "Buffer", ".", "Buf", "=", "strconv", ".", "AppendFloat", "(", "out", ".", "<mask>", ".", "Buf", ",", "v", ",", "'f'", ",", "-", "1", ",", "64", ")", "\n", "}" ]
16,191
all-16192
[ "<CV", "-", "qualifiers", ">", "::", "=", "[", "r", "]", "[", "V", "]", "[", "K", "]" ]
[ "func", "(", "st", "*", "<mask>", ")", "cvQualifiers", "(", ")", "Qualifiers", "{", "var", "q", "Qualifiers", "\n", "for", "len", "(", "st", ".", "str", ")", ">", "0", "{", "if", "qv", ",", "ok", ":=", "qualifiers", "[", "st", ".", "str", "[", "0", "]", "]", ";", "ok", "{", "q", "=", "append", "(", "[", "]", "string", "{", "qv", "}", ",", "q", "...", ")", "\n", "st", ".", "advance", "(", "1", ")", "\n", "}", "else", "if", "len", "(", "st", ".", "str", ")", ">", "1", "&&", "st", ".", "str", "[", ":", "2", "]", "==", "\"", "\"", "{", "q", "=", "append", "(", "[", "]", "string", "{", "\"", "\"", "}", ",", "q", "...", ")", "\n", "st", ".", "advance", "(", "2", ")", "\n", "}", "else", "{", "break", "\n", "}", "\n", "}", "\n", "return", "q", "\n", "}" ]
16,192
all-16193
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "RecordClockSyncMarkerParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "<mask>", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoTracing4", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
16,193
all-16194
[ "Dot", "returns", "the", "dot", "product", "of", "this", "vector", "with", "another", ".", "There", "are", "multiple", "ways", "to", "describe", "this", "value", ".", "One", "is", "the", "multiplication", "of", "their", "lengths", "and", "cos", "(", "theta", ")", "where", "theta", "is", "the", "angle", "between", "the", "vectors", ":", "v", ".", "v2", "=", "|v||v2|cos", "(", "theta", ")", ".", "The", "other", "(", "and", "what", "is", "actually", "done", ")", "is", "the", "sum", "of", "the", "element", "-", "wise", "multiplication", "of", "all", "elements", ".", "So", "for", "instance", "two", "Vec", "s", "would", "yield", ":", "v", ".", "x", "*", "v2", ".", "x", "+", "v", ".", "y", "*", "v2", ".", "y", "This", "means", "that", "the", "dot", "product", "of", "a", "vector", "and", "itself", "is", "the", "square", "of", "its", "Len", "(", "within", "the", "bounds", "of", "floating", "points", "error", ")", ".", "The", "dot", "product", "is", "roughly", "a", "measure", "of", "how", "closely", "two", "vectors", "are", "to", "pointing", "in", "the", "same", "direction", ".", "If", "both", "vectors", "are", "normalized", "the", "value", "will", "be", "-", "1", "for", "opposite", "pointing", "one", "for", "same", "pointing", "and", "0", "for", "perpendicular", "vectors", "." ]
[ "func", "(", "v", "Vec", ")", "Dot", "(", "v2", "Vec", ")", "float64", "{", "<mask>", "v", ".", "X", "*", "v2", ".", "X", "+", "v", ".", "Y", "*", "v2", ".", "Y", "\n", "}" ]
16,194
all-16195
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventAnimationCreated", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoAnimation14", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
16,195
all-16196
[ "/", "*", "Maps", "a", "given", "[", "symbol", "]", "to", "a", "set", "of", "typechecks", "to", "be", "used", "during", "runtime", "." ]
[ "func", "findTypeChecks", "(", "symbol", "OperatorSymbol", ")", "typeChecks", "{", "switch", "symbol", "{", "case", "GT", ":", "fallthrough", "\n", "case", "LT", ":", "fallthrough", "\n", "case", "GTE", ":", "fallthrough", "\n", "case", "LTE", ":", "return", "typeChecks", "{", "combined", ":", "comparatorTypeCheck", ",", "}", "\n", "case", "REQ", ":", "fallthrough", "\n", "case", "NREQ", ":", "return", "typeChecks", "{", "left", ":", "isString", ",", "right", ":", "isRegexOrString", ",", "}", "\n", "case", "AND", ":", "fallthrough", "\n", "case", "OR", ":", "return", "typeChecks", "{", "left", ":", "isBool", ",", "right", ":", "isBool", ",", "}", "\n", "case", "IN", ":", "return", "typeChecks", "{", "right", ":", "isArray", ",", "}", "\n", "case", "BITWISE_LSHIFT", ":", "fallthrough", "\n", "case", "BITWISE_RSHIFT", ":", "fallthrough", "\n", "case", "BITWISE_OR", ":", "fallthrough", "\n", "<mask>", "BITWISE_AND", ":", "fallthrough", "\n", "case", "BITWISE_XOR", ":", "return", "typeChecks", "{", "left", ":", "isFloat64", ",", "right", ":", "isFloat64", ",", "}", "\n", "case", "PLUS", ":", "return", "typeChecks", "{", "combined", ":", "additionTypeCheck", ",", "}", "\n", "case", "MINUS", ":", "fallthrough", "\n", "case", "MULTIPLY", ":", "fallthrough", "\n", "case", "DIVIDE", ":", "fallthrough", "\n", "case", "MODULUS", ":", "fallthrough", "\n", "case", "EXPONENT", ":", "return", "typeChecks", "{", "left", ":", "isFloat64", ",", "right", ":", "isFloat64", ",", "}", "\n", "case", "NEGATE", ":", "return", "typeChecks", "{", "right", ":", "isFloat64", ",", "}", "\n", "case", "INVERT", ":", "return", "typeChecks", "{", "right", ":", "isBool", ",", "}", "\n", "case", "BITWISE_NOT", ":", "return", "typeChecks", "{", "right", ":", "isFloat64", ",", "}", "\n", "case", "TERNARY_TRUE", ":", "return", "typeChecks", "{", "left", ":", "isBool", ",", "}", "\n\n", "// unchecked cases", "case", "EQ", ":", "fallthrough", "\n", "case", "NEQ", ":", "return", "typeChecks", "{", "}", "\n", "case", "TERNARY_FALSE", ":", "fallthrough", "\n", "case", "COALESCE", ":", "fallthrough", "\n", "default", ":", "return", "typeChecks", "{", "}", "\n", "}", "\n", "}" ]
16,196
all-16197
[ "GetManifest", "returns", "the", "image", "s", "manifest", "along", "with", "its", "MIME", "type", "(", "which", "may", "be", "empty", "when", "it", "can", "t", "be", "determined", "but", "the", "manifest", "is", "available", ")", ".", "It", "may", "use", "a", "remote", "(", "=", "slow", ")", "service", ".", "If", "instanceDigest", "is", "not", "nil", "it", "contains", "a", "digest", "of", "the", "specific", "manifest", "instance", "to", "retrieve", "(", "when", "the", "primary", "manifest", "is", "a", "manifest", "list", ")", ";", "this", "never", "happens", "if", "the", "primary", "manifest", "is", "not", "a", "manifest", "list", "(", "e", ".", "g", ".", "if", "the", "source", "never", "returns", "manifest", "lists", ")", "." ]
[ "func", "(", "s", "*", "openshiftImageSource", ")", "GetManifest", "(", "ctx", "<mask>", ".", "Context", ",", "instanceDigest", "*", "digest", ".", "Digest", ")", "(", "[", "]", "byte", ",", "string", ",", "error", ")", "{", "if", "err", ":=", "s", ".", "ensureImageIsResolved", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "s", ".", "docker", ".", "GetManifest", "(", "ctx", ",", "instanceDigest", ")", "\n", "}" ]
16,197
all-16198
[ "Indent", "prefixes", "each", "line", "of", "a", "string", "with", "the", "specified", "number", "of", "spaces" ]
[ "func", "indent", "(", "spaces", "int", ",", "s", "string", ")", "(", "string", ",", "error", ")", "{", "if", "spaces", "<", "0", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "var", "output", ",", "prefix", "[", "]", "byte", "\n", "var", "sp", "bool", "\n", "var", "size", "int", "\n", "prefix", "=", "[", "]", "byte", "(", "strings", ".", "Repeat", "(", "\"", "\"", ",", "spaces", ")", ")", "\n", "sp", "=", "<mask>", "\n", "for", "_", ",", "c", ":=", "range", "[", "]", "byte", "(", "s", ")", "{", "if", "sp", "&&", "c", "!=", "'\\n'", "{", "output", "=", "append", "(", "output", ",", "prefix", "...", ")", "\n", "size", "+=", "spaces", "\n", "}", "\n", "output", "=", "append", "(", "output", ",", "c", ")", "\n", "sp", "=", "c", "==", "'\\n'", "\n", "size", "++", "\n", "}", "\n", "return", "string", "(", "output", "[", ":", "size", "]", ")", ",", "nil", "\n", "}" ]
16,198
all-16199
[ "CheckTargetAddress", "checks", "if", "target", "address", "is", "valid", "." ]
[ "func", "CheckTargetAddress", "(", "address", "model", ".", "LabelValue", ")", "error", "{", "// For now check for a URL, we may want to expand this later.", "if", "strings", ".", "Contains", "(", "string", "(", "<mask>", ")", ",", "\"", "\"", ")", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ",", "address", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
16,199
all-16200
[ "List", "implements", "storage", "interface", "." ]
[ "func", "(", "s", "*", "Storage", ")", "List", "(", "ctx", "context", ".", "Context", ",", "offset", ",", "limit", "int64", ",", "expiredAtFrom", ",", "expiredAtTo", "*", "time", ".", "Time", ")", "(", "[", "]", "*", "mnemosynerpc", ".", "Session", ",", "error", ")", "{", "span", ",", "ctx", ":=", "opentracing", ".", "StartSpanFromContext", "(", "ctx", ",", "\"", "\"", ")", "\n", "defer", "span", ".", "Finish", "(", ")", "\n\n", "if", "limit", "==", "0", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "args", ":=", "[", "]", "interface", "{", "}", "{", "offset", ",", "limit", "}", "\n", "query", ":=", "\"", "\"", "+", "s", ".", "schema", "+", "\"", "\"", "+", "s", ".", "table", "+", "\"", "\"", "\n", "if", "expiredAtFrom", "!=", "nil", "||", "expiredAtTo", "!=", "nil", "{", "query", "+=", "\"", "\"", "\n", "}", "\n", "switch", "{", "case", "expiredAtFrom", "!=", "nil", "&&", "expiredAtTo", "==", "nil", ":", "query", "+=", "\"", "\"", "\n", "args", "=", "append", "(", "args", ",", "expiredAtFrom", ")", "\n", "case", "expiredAtFrom", "==", "nil", "&&", "expiredAtTo", "!=", "nil", ":", "query", "+=", "\"", "\"", "\n", "args", "=", "append", "(", "args", ",", "expiredAtTo", ")", "\n", "case", "expiredAtFrom", "!=", "nil", "&&", "expiredAtTo", "!=", "nil", ":", "query", "+=", "\"", "\"", "\n", "args", "=", "append", "(", "args", ",", "expiredAtFrom", ",", "expiredAtTo", ")", "\n", "}", "\n\n", "query", "+=", "\"", "\"", "\n", "labels", ":=", "prometheus", ".", "Labels", "{", "\"", "\"", ":", "\"", "\"", "}", "\n\n", "start", ":=", "time", ".", "Now", "(", ")", "\n", "rows", ",", "err", ":=", "s", ".", "<mask>", ".", "QueryContext", "(", "ctx", ",", "query", ",", "args", "...", ")", "\n", "s", ".", "incQueries", "(", "labels", ",", "start", ")", "\n", "if", "err", "!=", "nil", "{", "s", ".", "incError", "(", "labels", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "rows", ".", "Close", "(", ")", "\n\n", "sessions", ":=", "make", "(", "[", "]", "*", "mnemosynerpc", ".", "Session", ",", "0", ",", "limit", ")", "\n", "for", "rows", ".", "Next", "(", ")", "{", "var", "ent", "sessionEntity", "\n\n", "err", "=", "rows", ".", "Scan", "(", "&", "ent", ".", "AccessToken", ",", "&", "ent", ".", "RefreshToken", ",", "&", "ent", ".", "SubjectID", ",", "&", "ent", ".", "SubjectClient", ",", "&", "ent", ".", "Bag", ",", "&", "ent", ".", "ExpireAt", ",", ")", "\n", "if", "err", "!=", "nil", "{", "s", ".", "incError", "(", "labels", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "expireAt", ",", "err", ":=", "ptypes", ".", "TimestampProto", "(", "ent", ".", "ExpireAt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "sessions", "=", "append", "(", "sessions", ",", "&", "mnemosynerpc", ".", "Session", "{", "AccessToken", ":", "ent", ".", "AccessToken", ",", "RefreshToken", ":", "ent", ".", "RefreshToken", ",", "SubjectId", ":", "ent", ".", "SubjectID", ",", "SubjectClient", ":", "ent", ".", "SubjectClient", ",", "Bag", ":", "ent", ".", "Bag", ",", "ExpireAt", ":", "expireAt", ",", "}", ")", "\n", "}", "\n", "if", "rows", ".", "Err", "(", ")", "!=", "nil", "{", "s", ".", "incError", "(", "labels", ")", "\n", "return", "nil", ",", "rows", ".", "Err", "(", ")", "\n", "}", "\n\n", "return", "sessions", ",", "nil", "\n", "}" ]