id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
8,000
all-8001
[ "ReadConfigJSON", "reads", "a", "new", "-", "style", "peers", ".", "json", "and", "returns", "a", "configuration", "structure", ".", "This", "can", "be", "used", "to", "perform", "manual", "recovery", "when", "running", "protocol", "versions", "that", "use", "server", "IDs", "." ]
[ "func", "ReadConfigJSON", "(", "path", "string", ")", "(", "Configuration", ",", "error", ")", "{", "// Read in the file.", "buf", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Configuration", "{", "}", ",", "err", "\n", "}", "\n\n", "// Parse it as JSON.", "var", "peers", "[", "]", "configEntry", "\n", "dec", ":=", "json", ".", "NewDecoder", "(", "bytes", ".", "NewReader", "(", "buf", ")", ")", "\n", "if", "err", ":=", "dec", ".", "Decode", "(", "&", "peers", ")", ";", "err", "!=", "nil", "{", "return", "Configuration", "{", "}", ",", "err", "\n", "}", "\n\n", "// Map it into the new-style configuration structure.", "var", "configuration", "<mask>", "\n", "for", "_", ",", "peer", ":=", "range", "peers", "{", "suffrage", ":=", "Voter", "\n", "if", "peer", ".", "NonVoter", "{", "suffrage", "=", "Nonvoter", "\n", "}", "\n", "server", ":=", "Server", "{", "Suffrage", ":", "suffrage", ",", "ID", ":", "peer", ".", "ID", ",", "Address", ":", "peer", ".", "Address", ",", "}", "\n", "configuration", ".", "Servers", "=", "append", "(", "configuration", ".", "Servers", ",", "server", ")", "\n", "}", "\n\n", "// We should only ingest valid configurations.", "if", "err", ":=", "checkConfiguration", "(", "configuration", ")", ";", "err", "!=", "nil", "{", "return", "Configuration", "{", "}", ",", "err", "\n", "}", "\n", "return", "configuration", ",", "nil", "\n", "}" ]
8,001
all-8002
[ "Get", "finds", "the", "value", "from", "the", "LinkedList", ".", "pos", "is", "expressed", "as", "a", "zero", "-", "based", "index", "begining", "from", "the", "front", "of", "the", "list", "." ]
[ "func", "(", "list", "*", "LinkedList", ")", "Get", "(", "pos", "uint", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "list", ".", "key", ".", "RLock", "(", ")", "\n", "defer", "list", ".", "key", ".", "RUnlock", "(", ")", "\n", "node", ",", "ok", ":=", "get", "(", "list", ".", "first", ",", "<mask>", ")", "\n", "if", "ok", "{", "return", "node", ".", "payload", ",", "true", "\n", "}", "\n", "return", "nil", ",", "false", "\n", "}" ]
8,002
all-8003
[ "flattenClusterConfigSpecEx", "saves", "a", "ClusterConfigSpecEx", "into", "the", "supplied", "ResourceData", "." ]
[ "func", "flattenClusterConfigSpecEx", "(", "d", "*", "schema", ".", "ResourceData", ",", "obj", "*", "types", ".", "ClusterConfigInfoEx", ",", "version", "viapi", ".", "VSphereVersion", ")", "error", "{", "if", "err", ":=", "flattenClusterDasConfigInfo", "(", "d", ",", "obj", ".", "DasConfig", ",", "version", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "flattenClusterDpmConfigInfo", "(", "d", ",", "obj", ".", "DpmConfigInfo", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "flattenClusterDrsConfigInfo", "(", "d", ",", "obj", ".", "DrsConfig", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "version", ".", "Newer", "(", "viapi", ".", "VSphereVersion", "{", "Product", ":", "<mask>", ".", "Product", ",", "Major", ":", "6", ",", "Minor", ":", "5", "}", ")", "{", "if", "err", ":=", "flattenClusterInfraUpdateHaConfigInfo", "(", "d", ",", "obj", ".", "InfraUpdateHaConfig", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "if", "version", ".", "Newer", "(", "viapi", ".", "VSphereVersion", "{", "Product", ":", "version", ".", "Product", ",", "Major", ":", "6", ",", "Minor", ":", "5", "}", ")", "{", "if", "err", ":=", "flattenClusterOrchestrationInfo", "(", "d", ",", "obj", ".", "Orchestration", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "if", "version", ".", "Newer", "(", "viapi", ".", "VSphereVersion", "{", "Product", ":", "version", ".", "Product", ",", "Major", ":", "6", ",", "Minor", ":", "5", "}", ")", "{", "return", "flattenClusterProactiveDrsConfigInfo", "(", "d", ",", "obj", ".", "ProactiveDrsConfig", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
8,003
all-8004
[ "PurgeMissing", "removes", "from", "collections", "any", "state", "that", "refers", "to", "transaction", "documents", "that", "for", "whatever", "reason", "have", "been", "lost", "from", "the", "system", "(", "removed", "by", "accident", "or", "lost", "in", "a", "hard", "crash", "for", "example", ")", ".", "This", "method", "should", "very", "rarely", "be", "needed", "if", "at", "all", "and", "should", "never", "be", "used", "during", "the", "normal", "operation", "of", "an", "application", ".", "Its", "purpose", "is", "to", "put", "a", "system", "that", "has", "seen", "unavoidable", "corruption", "back", "in", "a", "working", "state", "." ]
[ "func", "(", "r", "*", "Runner", ")", "PurgeMissing", "(", "collections", "...", "string", ")", "error", "{", "type", "M", "map", "[", "string", "]", "interface", "{", "}", "\n", "type", "S", "[", "]", "interface", "{", "}", "\n\n", "type", "TDoc", "struct", "{", "Id", "interface", "{", "}", "\"", "\"", "\n", "TxnQueue", "[", "]", "string", "\"", "\"", "\n", "}", "\n\n", "found", ":=", "make", "(", "<mask>", "[", "bson", ".", "ObjectId", "]", "bool", ")", "\n\n", "sort", ".", "Strings", "(", "collections", ")", "\n", "for", "_", ",", "collection", ":=", "range", "collections", "{", "c", ":=", "r", ".", "tc", ".", "Database", ".", "C", "(", "collection", ")", "\n", "iter", ":=", "c", ".", "Find", "(", "nil", ")", ".", "Select", "(", "bson", ".", "M", "{", "\"", "\"", ":", "1", ",", "\"", "\"", ":", "1", "}", ")", ".", "Iter", "(", ")", "\n", "var", "tdoc", "TDoc", "\n", "for", "iter", ".", "Next", "(", "&", "tdoc", ")", "{", "for", "_", ",", "txnToken", ":=", "range", "tdoc", ".", "TxnQueue", "{", "txnId", ":=", "bson", ".", "ObjectIdHex", "(", "txnToken", "[", ":", "24", "]", ")", "\n", "if", "found", "[", "txnId", "]", "{", "continue", "\n", "}", "\n", "if", "r", ".", "tc", ".", "FindId", "(", "txnId", ")", ".", "One", "(", "nil", ")", "==", "nil", "{", "found", "[", "txnId", "]", "=", "true", "\n", "continue", "\n", "}", "\n", "logf", "(", "\"", "\"", ",", "collection", ",", "tdoc", ".", "Id", ",", "txnId", ")", "\n", "err", ":=", "c", ".", "UpdateId", "(", "tdoc", ".", "Id", ",", "M", "{", "\"", "\"", ":", "M", "{", "\"", "\"", ":", "M", "{", "\"", "\"", ":", "\"", "\"", "+", "txnId", ".", "Hex", "(", ")", "+", "\"", "\"", "}", "}", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "txnId", ".", "Hex", "(", ")", ",", "err", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "if", "err", ":=", "iter", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "collection", ",", "err", ")", "\n", "}", "\n", "}", "\n\n", "type", "StashTDoc", "struct", "{", "Id", "docKey", "\"", "\"", "\n", "TxnQueue", "[", "]", "string", "\"", "\"", "\n", "}", "\n\n", "iter", ":=", "r", ".", "sc", ".", "Find", "(", "nil", ")", ".", "Select", "(", "bson", ".", "M", "{", "\"", "\"", ":", "1", ",", "\"", "\"", ":", "1", "}", ")", ".", "Iter", "(", ")", "\n", "var", "stdoc", "StashTDoc", "\n", "for", "iter", ".", "Next", "(", "&", "stdoc", ")", "{", "for", "_", ",", "txnToken", ":=", "range", "stdoc", ".", "TxnQueue", "{", "txnId", ":=", "bson", ".", "ObjectIdHex", "(", "txnToken", "[", ":", "24", "]", ")", "\n", "if", "found", "[", "txnId", "]", "{", "continue", "\n", "}", "\n", "if", "r", ".", "tc", ".", "FindId", "(", "txnId", ")", ".", "One", "(", "nil", ")", "==", "nil", "{", "found", "[", "txnId", "]", "=", "true", "\n", "continue", "\n", "}", "\n", "logf", "(", "\"", "\"", ",", "stdoc", ".", "Id", ".", "C", ",", "stdoc", ".", "Id", ".", "Id", ",", "txnId", ")", "\n", "err", ":=", "r", ".", "sc", ".", "UpdateId", "(", "stdoc", ".", "Id", ",", "M", "{", "\"", "\"", ":", "M", "{", "\"", "\"", ":", "M", "{", "\"", "\"", ":", "\"", "\"", "+", "txnId", ".", "Hex", "(", ")", "+", "\"", "\"", "}", "}", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "txnId", ".", "Hex", "(", ")", ",", "err", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "if", "err", ":=", "iter", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
8,004
all-8005
[ "LastIndex", "implements", "the", "LogStore", "interface", "." ]
[ "func", "(", "i", "*", "InmemStore", ")", "LastIndex", "(", ")", "(", "uint64", ",", "error", ")", "{", "i", ".", "l", ".", "RLock", "(", ")", "\n", "defer", "i", ".", "l", ".", "RUnlock", "(", ")", "\n", "<mask>", "i", ".", "highIndex", ",", "nil", "\n", "}" ]
8,005
all-8006
[ "Usaget", "writes", "usage", "information", "to", "the", "specified", "io", ".", "Writer", "using", "the", "specified", "template" ]
[ "func", "Usaget", "(", "prefix", "string", ",", "<mask>", "interface", "{", "}", ",", "out", "io", ".", "Writer", ",", "tmpl", "*", "template", ".", "Template", ")", "error", "{", "// gather first", "infos", ",", "err", ":=", "gatherInfo", "(", "prefix", ",", "spec", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "tmpl", ".", "Execute", "(", "out", ",", "infos", ")", "\n", "}" ]
8,006
all-8007
[ "ToFile", "downloads", "the", "specified", "src", "URL", "to", "dest", "file", "using", "the", "specified", "FileOptions", "." ]
[ "func", "ToFile", "(", "src", ",", "dest", "string", ",", "options", "FileOptions", ")", "error", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "targetDir", ":=", "filepath", ".", "Dir", "(", "dest", ")", "\n", "if", "err", "=", "createDir", "(", "targetDir", ",", "<mask>", ".", "Mkdirs", "==", "nil", "||", "*", "options", ".", "Mkdirs", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "targetName", ":=", "filepath", ".", "Base", "(", "dest", ")", "\n", "f", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "targetDir", ",", "\"", "\"", "+", "targetName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "err", "=", "downloadFile", "(", "u", ",", "f", ",", "options", ".", "Options", ")", "\n", "if", "err", "!=", "nil", "{", "_", "=", "f", ".", "Close", "(", ")", "// #nosec", "\n", "_", "=", "os", ".", "Remove", "(", "f", ".", "Name", "(", ")", ")", "// #nosec", "\n", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "err", "=", "f", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "_", "=", "os", ".", "Remove", "(", "f", ".", "Name", "(", ")", ")", "// #nosec", "\n", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "err", "=", "renameFile", "(", "f", ".", "Name", "(", ")", ",", "dest", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
8,007
all-8008
[ "IsNetPort", "checks", "if", "this", "is", "a", "valid", "net", "port" ]
[ "func", "IsNetPort", "(", "str", "string", ")", "bool", "{", "if", "_", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "str", ",", "10", ",", "16", ")", ";", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "return", "<mask>", "\n", "}" ]
8,008
all-8009
[ "AddTickCallback", "is", "a", "wrapper", "around", "gtk_widget_add_tick_callback", "()", "." ]
[ "func", "(", "v", "*", "Widget", ")", "AddTickCallback", "(", "fn", "TickCallback", ",", "userData", "uintptr", ")", "int", "{", "tickCallbackRegistry", ".", "Lock", "(", ")", "\n", "id", ":=", "tickCallbackRegistry", ".", "next", "\n", "tickCallbackRegistry", ".", "<mask>", "++", "\n", "tickCallbackRegistry", ".", "m", "[", "id", "]", "=", "tickCallbackData", "{", "fn", ":", "fn", ",", "userData", ":", "userData", "}", "\n", "tickCallbackRegistry", ".", "Unlock", "(", ")", "\n\n", "return", "int", "(", "C", ".", "_gtk_widget_add_tick_callback", "(", "v", ".", "native", "(", ")", ",", "C", ".", "gpointer", "(", "uintptr", "(", "id", ")", ")", ")", ")", "\n", "}" ]
8,009
all-8010
[ "GetUsernameFromEnv", "returns", "the", "user", "name", "from", "the", "environment", "variable", "for", "the", "actual", "process", "." ]
[ "func", "GetUsernameFromEnv", "(", ")", "string", "{", "user_env", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "\n\n", "for", "_", ",", "val", ":=", "range", "user_env", "{", "name", ":=", "<mask>", ".", "Getenv", "(", "val", ")", "\n", "if", "name", "!=", "\"", "\"", "{", "return", "name", "\n", "}", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
8,010
all-8011
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "CaptureScreenshotReturns", ")", "UnmarshalJSON", "(", "<mask>", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage79", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
8,011
all-8012
[ "Write", "serializes", "the", "command", "to", "the", "given", "buffered", "output", "satisfies", "the", "Command", "interface", "." ]
[ "func", "(", "c", "Auth", ")", "Write", "(", "w", "*", "bufio", ".", "<mask>", ")", "(", "err", "error", ")", "{", "if", "_", ",", "err", "=", "w", ".", "WriteString", "(", "\"", "\\n", "\"", ")", ";", "err", "!=", "nil", "{", "err", "=", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "if", "err", "=", "binary", ".", "Write", "(", "w", ",", "binary", ".", "BigEndian", ",", "uint32", "(", "len", "(", "c", ".", "Secret", ")", ")", ")", ";", "err", "!=", "nil", "{", "err", "=", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "if", "_", ",", "err", "=", "w", ".", "WriteString", "(", "c", ".", "Secret", ")", ";", "err", "!=", "nil", "{", "err", "=", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "return", "\n", "}" ]
8,012
all-8013
[ "CreatePipeline", "creates", "a", "new", "pipeline", "pipelines", "are", "the", "main", "computation", "object", "in", "PPS", "they", "create", "a", "flow", "of", "data", "from", "a", "set", "of", "input", "Repos", "to", "an", "output", "Repo", "(", "which", "has", "the", "same", "name", "as", "the", "pipeline", ")", ".", "Whenever", "new", "data", "is", "committed", "to", "one", "of", "the", "input", "repos", "the", "pipelines", "will", "create", "jobs", "to", "bring", "the", "output", "Repo", "up", "to", "data", ".", "image", "is", "the", "Docker", "image", "to", "run", "the", "jobs", "in", ".", "cmd", "is", "the", "command", "passed", "to", "the", "Docker", "run", "invocation", ".", "NOTE", "as", "with", "Docker", "cmd", "is", "not", "run", "inside", "a", "shell", "that", "means", "that", "things", "like", "wildcard", "globbing", "(", "*", ")", "pipes", "(", "|", ")", "and", "file", "redirects", "(", ">", "and", ">>", ")", "will", "not", "work", ".", "To", "get", "that", "behavior", "you", "should", "have", "your", "command", "be", "a", "shell", "of", "your", "choice", "and", "pass", "a", "shell", "script", "to", "stdin", ".", "stdin", "is", "a", "slice", "of", "lines", "that", "are", "sent", "to", "your", "command", "on", "stdin", ".", "Lines", "need", "not", "end", "in", "newline", "characters", ".", "parallelism", "is", "how", "many", "copies", "of", "your", "container", "should", "run", "in", "parallel", ".", "You", "may", "pass", "0", "for", "parallelism", "in", "which", "case", "PPS", "will", "set", "the", "parallelism", "based", "on", "available", "resources", ".", "input", "specifies", "a", "set", "of", "Repos", "that", "will", "be", "visible", "to", "the", "jobs", "during", "runtime", ".", "commits", "to", "these", "repos", "will", "cause", "the", "pipeline", "to", "create", "new", "jobs", "to", "process", "them", ".", "update", "indicates", "that", "you", "want", "to", "update", "an", "existing", "pipeline" ]
[ "func", "(", "c", "APIClient", ")", "CreatePipeline", "(", "name", "string", ",", "image", "string", ",", "cmd", "[", "]", "string", ",", "stdin", "[", "]", "string", ",", "parallelismSpec", "*", "pps", ".", "ParallelismSpec", ",", "input", "*", "pps", ".", "<mask>", ",", "outputBranch", "string", ",", "update", "bool", ",", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "PpsAPIClient", ".", "CreatePipeline", "(", "c", ".", "Ctx", "(", ")", ",", "&", "pps", ".", "CreatePipelineRequest", "{", "Pipeline", ":", "NewPipeline", "(", "name", ")", ",", "Transform", ":", "&", "pps", ".", "Transform", "{", "Image", ":", "image", ",", "Cmd", ":", "cmd", ",", "Stdin", ":", "stdin", ",", "}", ",", "ParallelismSpec", ":", "parallelismSpec", ",", "Input", ":", "input", ",", "OutputBranch", ":", "outputBranch", ",", "Update", ":", "update", ",", "}", ",", ")", "\n", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}" ]
8,013
all-8014
[ "UpdateServer", "updates", "the", "server", "status", "to", "match", "the", "provided", "Server", "struct" ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "UpdateServer", "(", "<mask>", "api", ".", "ServerPut", ",", "ETag", "string", ")", "error", "{", "// Send the request", "_", ",", "_", ",", "err", ":=", "r", ".", "query", "(", "\"", "\"", ",", "\"", "\"", ",", "server", ",", "ETag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
8,014
all-8015
[ "RandomAccessToken", "generate", "Access", "Token", "with", "given", "key", "and", "generated", "hash", "of", "length", "64", "." ]
[ "func", "RandomAccessToken", "(", ")", "(", "string", ",", "error", ")", "{", "buf", ",", "err", ":=", "generateRandomBytes", "(", "128", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "// A hash needs to be 64 bytes long to have 256-bit collision resistance.", "hash", ":=", "make", "(", "[", "]", "byte", ",", "64", ")", "\n", "// Compute a 64-byte hash of buf and put it in h.", "sha3", ".", "ShakeSum256", "(", "hash", ",", "buf", ")", "\n", "hash2", ":=", "make", "(", "[", "]", "byte", ",", "hex", ".", "EncodedLen", "(", "len", "(", "hash", ")", ")", ")", "\n", "hex", ".", "Encode", "(", "hash2", ",", "<mask>", ")", "\n", "return", "string", "(", "hash2", ")", ",", "nil", "\n", "}" ]
8,015
all-8016
[ "sortedFids", "returns", "the", "file", "id", "s", "not", "pending", "deletion", "sorted", ".", "Assumes", "we", "have", "shared", "access", "to", "filesMap", "." ]
[ "func", "(", "vlog", "*", "valueLog", ")", "sortedFids", "(", ")", "[", "]", "uint32", "{", "toBeDeleted", ":=", "make", "(", "map", "[", "uint32", "]", "struct", "{", "}", ")", "\n", "for", "_", ",", "fid", ":=", "range", "vlog", ".", "filesToBeDeleted", "{", "toBeDeleted", "[", "fid", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "ret", ":=", "make", "(", "[", "]", "uint32", ",", "0", ",", "len", "(", "vlog", ".", "filesMap", ")", ")", "\n", "for", "fid", ":=", "range", "vlog", ".", "filesMap", "{", "if", "_", ",", "ok", ":=", "toBeDeleted", "[", "fid", "]", ";", "!", "ok", "{", "ret", "=", "append", "(", "<mask>", ",", "fid", ")", "\n", "}", "\n", "}", "\n", "sort", ".", "Slice", "(", "ret", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "ret", "[", "i", "]", "<", "ret", "[", "j", "]", "\n", "}", ")", "\n", "return", "ret", "\n", "}" ]
8,016
all-8017
[ "RegisterGenericCommentHandler", "registers", "a", "plugin", "s", "github", ".", "GenericCommentEvent", "handler", "." ]
[ "func", "RegisterGenericCommentHandler", "(", "name", "string", ",", "fn", "GenericCommentHandler", ",", "help", "HelpProvider", ")", "{", "pluginHelp", "[", "name", "]", "=", "help", "\n", "genericCommentHandlers", "[", "<mask>", "]", "=", "fn", "\n", "}" ]
8,017
all-8018
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "ExceptionDetails", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoRuntime28", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
8,018
all-8019
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "ClearObjectStoreParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoIndexeddb19", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
8,019
all-8020
[ "Returns", "a", "boolean", "at", "the", "key", "and", "whether", "or", "not", "the", "key", "existed", "and", "the", "value", "was", "a", "bolean" ]
[ "func", "(", "t", "Typed", ")", "BoolIf", "(", "key", "string", ")", "(", "bool", ",", "bool", ")", "{", "value", ",", "exists", ":=", "t", "[", "key", "]", "\n", "if", "exists", "==", "false", "{", "return", "false", ",", "false", "\n", "}", "\n", "if", "n", ",", "ok", ":=", "value", ".", "(", "bool", ")", ";", "ok", "{", "return", "n", ",", "true", "\n", "}", "\n", "return", "<mask>", ",", "false", "\n", "}" ]
8,020
all-8021
[ "GetRecordings", "returns", "an", "iterator", "of", "recording", "pages", "for", "this", "Call", ".", "Note", "there", "may", "be", "more", "than", "one", "Page", "of", "results", "." ]
[ "func", "(", "c", "*", "CallService", ")", "GetRecordingsIterator", "(", "callSid", "string", ",", "data", "url", ".", "Values", ")", "*", "RecordingPageIterator", "{", "if", "data", "==", "nil", "{", "data", "=", "<mask>", ".", "Values", "{", "}", "\n", "}", "\n", "// Cheat - hit the Recordings list view with a filter instead of", "// GET /calls/CA123/Recordings. The former is probably more reliable", "data", ".", "Set", "(", "\"", "\"", ",", "callSid", ")", "\n", "return", "c", ".", "client", ".", "Recordings", ".", "GetPageIterator", "(", "data", ")", "\n", "}" ]
8,021
all-8022
[ "Allow", "allows", "permission", "mode", "for", "roles" ]
[ "func", "(", "role", "*", "Role", ")", "Allow", "(", "<mask>", "PermissionMode", ",", "roles", "...", "string", ")", "*", "Permission", "{", "return", "role", ".", "NewPermission", "(", ")", ".", "Allow", "(", "mode", ",", "roles", "...", ")", "\n", "}" ]
8,022
all-8023
[ "GetId", "returns", "the", "Id", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "s", "*", "ScreenboardLite", ")", "GetId", "(", ")", "int", "{", "if", "s", "==", "nil", "||", "s", ".", "<mask>", "==", "nil", "{", "return", "0", "\n", "}", "\n", "return", "*", "s", ".", "Id", "\n", "}" ]
8,023
all-8024
[ "Publish", "sends", "the", "Pacts", "to", "a", "broker", "optionally", "tagging", "them" ]
[ "func", "(", "p", "*", "<mask>", ")", "Publish", "(", "request", "types", ".", "PublishRequest", ")", "error", "{", "log", ".", "Println", "(", "\"", "\"", ")", "\n\n", "if", "p", ".", "pactClient", "==", "nil", "{", "c", ":=", "NewClient", "(", ")", "\n", "p", ".", "pactClient", "=", "c", "\n", "}", "\n\n", "err", ":=", "request", ".", "Validate", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "p", ".", "pactClient", ".", "PublishPacts", "(", "request", ")", "\n", "}" ]
8,024
all-8025
[ "HasName", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "a", "*", "APIKey", ")", "HasName", "(", ")", "bool", "{", "if", "a", "!=", "nil", "&&", "a", ".", "<mask>", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
8,025
all-8026
[ "title", ":", "volume", "info", "path", ":", "/", "volumes", "/", "{", "name", "}", "method", ":", "GET", "produce", ":", "application", "/", "json", "responses", ":", "200", ":", "Show", "volume", "401", ":", "Unauthorized", "404", ":", "Volume", "not", "found" ]
[ "func", "volumeInfo", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "t", "auth", ".", "Token", ")", "error", "{", "v", ",", "err", ":=", "volume", ".", "Load", "(", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "volume", ".", "ErrVolumeNotFound", "{", "return", "&", "errors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusNotFound", ",", "Message", ":", "err", ".", "Error", "(", ")", "}", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "canRead", ":=", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermVolumeRead", ",", "contextsForVolume", "(", "v", ")", "...", ")", "\n", "if", "!", "canRead", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "_", ",", "err", "=", "v", ".", "LoadBinds", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "w", ".", "<mask>", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "return", "json", ".", "NewEncoder", "(", "w", ")", ".", "Encode", "(", "&", "v", ")", "\n", "}" ]
8,026
all-8027
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "GetPlaybackRateReturns", ")", "MarshalJSON", "(", ")", "(", "[", "]", "<mask>", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoAnimation9", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
8,027
all-8028
[ "UpdatedImageNeedsLayerDiffIDs", "returns", "true", "iff", "UpdatedImage", "(", "options", ")", "needs", "InformationOnly", ".", "LayerDiffIDs", ".", "This", "is", "a", "horribly", "specific", "interface", "but", "computing", "InformationOnly", ".", "LayerDiffIDs", "can", "be", "very", "expensive", "to", "compute", "(", "most", "importantly", "it", "forces", "us", "to", "download", "the", "full", "layers", "even", "if", "they", "are", "already", "present", "at", "the", "destination", ")", "." ]
[ "func", "(", "m", "*", "manifestSchema1", ")", "UpdatedImageNeedsLayerDiffIDs", "(", "options", "types", ".", "ManifestUpdateOptions", ")", "bool", "{", "return", "(", "<mask>", ".", "ManifestMIMEType", "==", "manifest", ".", "DockerV2Schema2MediaType", "||", "options", ".", "ManifestMIMEType", "==", "imgspecv1", ".", "MediaTypeImageManifest", ")", "\n", "}" ]
8,028
all-8029
[ "Do", "executes", "Memory", ".", "stopSampling", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "StopSamplingParams", ")", "Do", "(", "ctx", "context", ".", "<mask>", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandStopSampling", ",", "nil", ",", "nil", ")", "\n", "}" ]
8,029
all-8030
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "GetManifestForFrameParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoApplicationcache2", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
8,030
all-8031
[ "NewInclusiveRange", "creates", "a", "new", "InclusiveRange", "instance" ]
[ "func", "NewInclusiveRange", "(", "start", ",", "end", ",", "step", "int", ")", "*", "InclusiveRange", "{", "if", "step", "==", "0", "{", "if", "start", "<=", "end", "{", "step", "=", "1", "\n\n", "}", "else", "{", "step", "=", "-", "1", "\n", "}", "\n", "}", "\n\n", "r", ":=", "&", "InclusiveRange", "{", "start", ":", "<mask>", ",", "end", ":", "end", ",", "step", ":", "step", ",", "}", "\n", "return", "r", "\n", "}" ]
8,031
all-8032
[ "title", ":", "token", "delete", "path", ":", "/", "tokens", "/", "{", "token_id", "}", "method", ":", "DELETE", "produce", ":", "application", "/", "json", "responses", ":", "200", ":", "Token", "created", "401", ":", "Unauthorized", "404", ":", "Token", "not", "found" ]
[ "func", "tokenDelete", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "t", "auth", ".", "Token", ")", "(", "err", "error", ")", "{", "tokenID", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "teamToken", ",", "err", ":=", "servicemanager", ".", "TeamToken", ".", "FindByTokenID", "(", "tokenID", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "authTypes", ".", "ErrTeamTokenNotFound", "{", "return", "&", "errors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusNotFound", ",", "Message", ":", "err", ".", "Error", "(", ")", ",", "}", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "teamName", ":=", "teamToken", ".", "Team", "\n", "allowed", ":=", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermTeamTokenDelete", ",", "permission", ".", "Context", "(", "permTypes", ".", "CtxTeam", ",", "teamName", ")", ",", ")", "\n", "if", "!", "allowed", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "evt", ",", "err", ":=", "event", ".", "New", "(", "&", "event", ".", "Opts", "{", "Target", ":", "teamTarget", "(", "teamName", ")", ",", "Kind", ":", "permission", ".", "PermTeamTokenDelete", ",", "Owner", ":", "t", ",", "CustomData", ":", "<mask>", ".", "FormToCustomData", "(", "InputFields", "(", "r", ")", ")", ",", "Allowed", ":", "event", ".", "Allowed", "(", "permission", ".", "PermTeamReadEvents", ",", "permission", ".", "Context", "(", "permTypes", ".", "CtxTeam", ",", "teamName", ")", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "func", "(", ")", "{", "evt", ".", "Done", "(", "err", ")", "}", "(", ")", "\n", "err", "=", "servicemanager", ".", "TeamToken", ".", "Delete", "(", "tokenID", ")", "\n", "if", "err", "==", "authTypes", ".", "ErrTeamTokenNotFound", "{", "return", "&", "errors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusNotFound", ",", "Message", ":", "err", ".", "Error", "(", ")", ",", "}", "\n", "}", "\n", "return", "err", "\n", "}" ]
8,032
all-8033
[ "AddMessageError", "adds", "a", "new", "Error", "isntance", "with", "a", "code", "and", "message", "to", "the", "registry", ".", "It", "there", "already", "is", "an", "error", "or", "handler", "with", "the", "same", "code", "ErrErrorAlreadyRegistered", "will", "be", "returned", "." ]
[ "func", "(", "r", "*", "MapErrorRegistry", ")", "AddMessageError", "(", "code", "int", ",", "message", "string", ")", "(", "*", "Error", ",", "error", ")", "{", "if", "_", ",", "ok", ":=", "r", ".", "<mask>", "[", "code", "]", ";", "ok", "{", "return", "nil", ",", "ErrErrorAlreadyRegistered", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "r", ".", "handlers", "[", "code", "]", ";", "ok", "{", "return", "nil", ",", "ErrErrorAlreadyRegistered", "\n", "}", "\n", "err", ":=", "&", "Error", "{", "Message", ":", "message", ",", "Code", ":", "code", ",", "}", "\n", "r", ".", "errors", "[", "code", "]", "=", "err", "\n", "return", "err", ",", "nil", "\n", "}" ]
8,033
all-8034
[ "addArrayType", "adds", "an", "accessor", "for", "a", "array", "type", "for", "a", "given", "receiver", "and", "field" ]
[ "func", "(", "t", "*", "templateData", ")", "addArrayType", "(", "x", "*", "ast", ".", "ArrayType", ",", "receiverType", ",", "fieldName", "string", ")", "{", "// TODO: should we make this dynamic? Could handle more cases than string only", "var", "eltType", "string", "\n", "switch", "elt", ":=", "x", ".", "Elt", ".", "(", "type", ")", "{", "case", "*", "ast", ".", "Ident", ":", "eltType", "=", "elt", ".", "<mask>", "(", ")", "\n", "default", ":", "logf", "(", "\"", "\"", ",", "receiverType", ",", "fieldName", ",", "elt", ",", "elt", ")", "\n", "return", "\n", "}", "\n\n", "t", ".", "Accessors", "=", "append", "(", "t", ".", "Accessors", ",", "newAccessor", "(", "receiverType", ",", "fieldName", ",", "\"", "\"", "+", "eltType", ",", "\"", "\"", ")", ")", "\n", "}" ]
8,034
all-8035
[ "Start", "performs", "any", "initialization", "of", "the", "Server", "necessary", "for", "it", "to", "begin", "serving", "requests", ".", "It", "must", "be", "called", "before", "Do", "or", "Process", ".", "Start", "must", "be", "non", "-", "blocking", ";", "any", "long", "-", "running", "server", "functionality", "should", "be", "implemented", "in", "goroutines", "." ]
[ "func", "(", "s", "*", "EtcdServer", ")", "Start", "(", ")", "{", "s", ".", "<mask>", "(", ")", "\n", "s", ".", "goAttach", "(", "func", "(", ")", "{", "s", ".", "adjustTicks", "(", ")", "}", ")", "\n", "s", ".", "goAttach", "(", "func", "(", ")", "{", "s", ".", "publish", "(", "s", ".", "Cfg", ".", "ReqTimeout", "(", ")", ")", "}", ")", "\n", "s", ".", "goAttach", "(", "s", ".", "purgeFile", ")", "\n", "s", ".", "goAttach", "(", "func", "(", ")", "{", "monitorFileDescriptor", "(", "s", ".", "getLogger", "(", ")", ",", "s", ".", "stopping", ")", "}", ")", "\n", "s", ".", "goAttach", "(", "s", ".", "monitorVersions", ")", "\n", "s", ".", "goAttach", "(", "s", ".", "linearizableReadLoop", ")", "\n", "s", ".", "goAttach", "(", "s", ".", "monitorKVHash", ")", "\n", "}" ]
8,035
all-8036
[ "appliedCursor", "extracts", "from", "the", "Ready", "the", "highest", "index", "the", "client", "has", "applied", "(", "once", "the", "Ready", "is", "confirmed", "via", "Advance", ")", ".", "If", "no", "information", "is", "contained", "in", "the", "Ready", "returns", "zero", "." ]
[ "func", "(", "rd", "Ready", ")", "appliedCursor", "(", ")", "uint64", "{", "if", "n", ":=", "len", "(", "rd", ".", "CommittedEntries", ")", ";", "n", ">", "0", "{", "return", "rd", ".", "CommittedEntries", "[", "n", "-", "1", "]", ".", "Index", "\n", "}", "\n", "if", "<mask>", ":=", "rd", ".", "Snapshot", ".", "Metadata", ".", "Index", ";", "index", ">", "0", "{", "return", "index", "\n", "}", "\n", "return", "0", "\n", "}" ]
8,036
all-8037
[ "View", "all", "active", "purge", "requests", ".", "This", "is", "useful", "mostly", "for", "administors", "to", "view", "the", "set", "of", "open", "purge", "requests", ".", "It", "should", "not", "be", "used", "by", "workers", ".", "They", "should", "use", "the", "purgeRequests", "endpoint", "that", "is", "specific", "to", "their", "workerType", "and", "provisionerId", ".", "See", "#allPurgeRequests" ]
[ "func", "(", "purgeCache", "*", "PurgeCache", ")", "AllPurgeRequests", "(", "continuationToken", ",", "limit", "string", ")", "(", "*", "OpenAllPurgeRequestsList", ",", "error", ")", "{", "v", ":=", "<mask>", ".", "Values", "{", "}", "\n", "if", "continuationToken", "!=", "\"", "\"", "{", "v", ".", "Add", "(", "\"", "\"", ",", "continuationToken", ")", "\n", "}", "\n", "if", "limit", "!=", "\"", "\"", "{", "v", ".", "Add", "(", "\"", "\"", ",", "limit", ")", "\n", "}", "\n", "cd", ":=", "tcclient", ".", "Client", "(", "*", "purgeCache", ")", "\n", "responseObject", ",", "_", ",", "err", ":=", "(", "&", "cd", ")", ".", "APICall", "(", "nil", ",", "\"", "\"", ",", "\"", "\"", ",", "new", "(", "OpenAllPurgeRequestsList", ")", ",", "v", ")", "\n", "return", "responseObject", ".", "(", "*", "OpenAllPurgeRequestsList", ")", ",", "err", "\n", "}" ]
8,037
all-8038
[ "dispatchLog", "is", "called", "on", "the", "leader", "to", "push", "a", "log", "to", "disk", "mark", "it", "as", "inflight", "and", "begin", "replication", "of", "it", "." ]
[ "func", "(", "r", "*", "Raft", ")", "dispatchLogs", "(", "applyLogs", "[", "]", "*", "logFuture", ")", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "defer", "metrics", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "now", ")", "\n\n", "<mask>", ":=", "r", ".", "getCurrentTerm", "(", ")", "\n", "lastIndex", ":=", "r", ".", "getLastIndex", "(", ")", "\n\n", "n", ":=", "len", "(", "applyLogs", ")", "\n", "logs", ":=", "make", "(", "[", "]", "*", "Log", ",", "n", ")", "\n", "metrics", ".", "SetGauge", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "float32", "(", "n", ")", ")", "\n\n", "for", "idx", ",", "applyLog", ":=", "range", "applyLogs", "{", "applyLog", ".", "dispatch", "=", "now", "\n", "lastIndex", "++", "\n", "applyLog", ".", "log", ".", "Index", "=", "lastIndex", "\n", "applyLog", ".", "log", ".", "Term", "=", "term", "\n", "logs", "[", "idx", "]", "=", "&", "applyLog", ".", "log", "\n", "r", ".", "leaderState", ".", "inflight", ".", "PushBack", "(", "applyLog", ")", "\n", "}", "\n\n", "// Write the log entry locally", "if", "err", ":=", "r", ".", "logs", ".", "StoreLogs", "(", "logs", ")", ";", "err", "!=", "nil", "{", "r", ".", "logger", ".", "Error", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "err", ")", ")", "\n", "for", "_", ",", "applyLog", ":=", "range", "applyLogs", "{", "applyLog", ".", "respond", "(", "err", ")", "\n", "}", "\n", "r", ".", "setState", "(", "Follower", ")", "\n", "return", "\n", "}", "\n", "r", ".", "leaderState", ".", "commitment", ".", "match", "(", "r", ".", "localID", ",", "lastIndex", ")", "\n\n", "// Update the last log since it's on disk now", "r", ".", "setLastLog", "(", "lastIndex", ",", "term", ")", "\n\n", "// Notify the replicators of the new log", "for", "_", ",", "f", ":=", "range", "r", ".", "leaderState", ".", "replState", "{", "asyncNotifyCh", "(", "f", ".", "triggerCh", ")", "\n", "}", "\n", "}" ]
8,038
all-8039
[ "Fatalf", "logs", "a", "formatted", "line", "with", "a", "FATAL", "prefix", "and", "exits", "the", "process", "with", "exit", "code", "1", "." ]
[ "func", "(", "l", "*", "logger", ")", "Fatalf", "(", "format", "string", ",", "vals", "...", "<mask>", "{", "}", ")", "{", "l", ".", "mut", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "mut", ".", "Unlock", "(", ")", "\n", "s", ":=", "fmt", ".", "Sprintf", "(", "format", ",", "vals", "...", ")", "\n", "l", ".", "logger", ".", "Output", "(", "2", ",", "\"", "\"", "+", "s", ")", "\n", "l", ".", "callHandlers", "(", "LevelFatal", ",", "s", ")", "\n", "os", ".", "Exit", "(", "1", ")", "\n", "}" ]
8,039
all-8040
[ "Exe", "sets", "the", "Exe" ]
[ "func", "(", "e", "*", "execStreamerBuilder", ")", "Exe", "(", "exe", "<mask>", ")", "ExecStreamerBuilder", "{", "e", ".", "d", ".", "Exe", "=", "exe", "\n", "return", "e", "\n", "}" ]
8,040
all-8041
[ "Read", "loads", "a", "double", "array", "." ]
[ "func", "Read", "(", "r", "io", ".", "Reader", ")", "(", "DoubleArray", ",", "error", ")", "{", "var", "sz", "int64", "\n", "if", "e", ":=", "binary", ".", "Read", "(", "r", ",", "binary", ".", "LittleEndian", ",", "&", "sz", ")", ";", "e", "!=", "nil", "{", "return", "DoubleArray", "{", "}", ",", "e", "\n", "}", "\n", "//fmt.Println(\"read data len:\", sz)", "d", ":=", "make", "(", "DoubleArray", ",", "sz", ",", "sz", ")", "\n", "for", "i", ":=", "range", "d", "{", "if", "e", ":=", "binary", ".", "Read", "(", "r", ",", "binary", ".", "LittleEndian", ",", "&", "d", "[", "i", "]", ".", "Base", ")", ";", "e", "!=", "nil", "{", "return", "d", ",", "e", "\n", "}", "\n", "if", "e", ":=", "<mask>", ".", "Read", "(", "r", ",", "binary", ".", "LittleEndian", ",", "&", "d", "[", "i", "]", ".", "Check", ")", ";", "e", "!=", "nil", "{", "return", "d", ",", "e", "\n", "}", "\n", "}", "\n", "return", "d", ",", "nil", "\n", "}" ]
8,041
all-8042
[ "printLs", "writes", "a", "response", "out", "in", "a", "manner", "similar", "to", "the", "ls", "command", "in", "unix", ".", "Non", "-", "empty", "directories", "list", "their", "contents", "and", "files", "list", "their", "name", "." ]
[ "func", "printLs", "(", "c", "*", "cli", ".", "Context", ",", "resp", "*", "client", ".", "Response", ")", "{", "if", "c", ".", "GlobalString", "(", "\"", "\"", ")", "==", "\"", "\"", "{", "if", "!", "resp", ".", "Node", ".", "Dir", "{", "fmt", ".", "Println", "(", "resp", ".", "Node", ".", "Key", ")", "\n", "}", "\n", "for", "_", ",", "<mask>", ":=", "range", "resp", ".", "Node", ".", "Nodes", "{", "rPrint", "(", "c", ",", "node", ")", "\n", "}", "\n", "}", "else", "{", "// user wants JSON or extended output", "printResponseKey", "(", "resp", ",", "c", ".", "GlobalString", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}" ]
8,042
all-8043
[ "Parse", "parses", "the", "JSON", "-", "encoded", "data", "and", "stores", "the", "result", "into", "the", "value", "pointed", "at", "by", "c", ".", "Panics", "if", "unsuccessful" ]
[ "func", "Parse", "(", "jsondata", "[", "]", "byte", ",", "v", "interface", "{", "}", ")", "{", "err", ":=", "json", ".", "Unmarshal", "(", "jsondata", ",", "v", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ".", "<mask>", "(", ")", ")", "\n", "}", "\n", "}" ]
8,043
all-8044
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "list", "Vm", "params" ]
[ "func", "(", "o", "*", "ListVMParams", ")", "WithTimeout", "(", "timeout", "<mask>", ".", "Duration", ")", "*", "ListVMParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
8,044
all-8045
[ "String", "generates", "a", "textual", "representation", "of", "the", "List", "for", "the", "sake", "of", "debugging", "." ]
[ "func", "(", "l", "*", "List", ")", "String", "(", ")", "string", "{", "l", ".", "key", ".", "RLock", "(", ")", "\n", "defer", "l", ".", "key", ".", "RUnlock", "(", ")", "\n\n", "builder", ":=", "bytes", ".", "NewBufferString", "(", "\"", "\"", ")", "\n\n", "for", "i", ",", "entry", ":=", "range", "l", ".", "underlyer", "{", "if", "i", ">=", "15", "{", "<mask>", ".", "WriteString", "(", "\"", "\"", ")", "\n", "break", "\n", "}", "\n", "builder", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "entry", ")", ")", "\n", "}", "\n", "builder", ".", "Truncate", "(", "builder", ".", "Len", "(", ")", "-", "1", ")", "\n", "builder", ".", "WriteRune", "(", "']'", ")", "\n", "return", "builder", ".", "String", "(", ")", "\n", "}" ]
8,045
all-8046
[ "title", ":", "add", "team", "too", "pool", "path", ":", "/", "pools", "/", "{", "name", "}", "/", "team", "method", ":", "POST", "consume", ":", "application", "/", "x", "-", "www", "-", "form", "-", "urlencoded", "responses", ":", "200", ":", "Pool", "updated", "401", ":", "Unauthorized", "400", ":", "Invalid", "data", "404", ":", "Pool", "not", "found" ]
[ "func", "addTeamToPoolHandler", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "t", "auth", ".", "Token", ")", "(", "err", "error", ")", "{", "poolName", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "allowed", ":=", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermPoolUpdateTeamAdd", ",", "permission", ".", "<mask>", "(", "permTypes", ".", "CtxPool", ",", "poolName", ")", ")", "\n", "if", "!", "allowed", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "evt", ",", "err", ":=", "event", ".", "New", "(", "&", "event", ".", "Opts", "{", "Target", ":", "event", ".", "Target", "{", "Type", ":", "event", ".", "TargetTypePool", ",", "Value", ":", "poolName", "}", ",", "Kind", ":", "permission", ".", "PermPoolUpdateTeamAdd", ",", "Owner", ":", "t", ",", "CustomData", ":", "event", ".", "FormToCustomData", "(", "InputFields", "(", "r", ")", ")", ",", "Allowed", ":", "event", ".", "Allowed", "(", "permission", ".", "PermPoolReadEvents", ",", "permission", ".", "Context", "(", "permTypes", ".", "CtxPool", ",", "poolName", ")", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "func", "(", ")", "{", "evt", ".", "Done", "(", "err", ")", "}", "(", ")", "\n", "if", "teams", ",", "ok", ":=", "InputValues", "(", "r", ",", "\"", "\"", ")", ";", "ok", "{", "err", ":=", "pool", ".", "AddTeamsToPool", "(", "poolName", ",", "teams", ")", "\n", "if", "err", "==", "pool", ".", "ErrPoolNotFound", "{", "return", "&", "terrors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusNotFound", ",", "Message", ":", "err", ".", "Error", "(", ")", "}", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "return", "&", "terrors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusBadRequest", ",", "Message", ":", "\"", "\"", "}", "\n", "}" ]
8,046
all-8047
[ "PluginList", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockClient", ")", "PluginList", "(", "arg0", "context", ".", "Context", ",", "arg1", "filters", ".", "Args", ")", "(", "types", ".", "PluginsListResponse", ",", "error", ")", "{", "<mask>", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "types", ".", "PluginsListResponse", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
8,047
all-8048
[ "FlushSession", "closes", "the", "current", "barrier", "session", "and", "starts", "the", "new", "session", ".", "The", "caller", "should", "provide", "the", "destructor", "pointer", "for", "the", "new", "session", "." ]
[ "func", "(", "ab", "*", "AccessBarrier", ")", "FlushSession", "(", "<mask>", "unsafe", ".", "Pointer", ")", "{", "if", "ab", ".", "active", "{", "ab", ".", "Lock", "(", ")", "\n", "defer", "ab", ".", "Unlock", "(", ")", "\n\n", "bsPtr", ":=", "atomic", ".", "LoadPointer", "(", "&", "ab", ".", "session", ")", "\n", "newBsPtr", ":=", "unsafe", ".", "Pointer", "(", "newBarrierSession", "(", ")", ")", "\n", "atomic", ".", "CompareAndSwapPointer", "(", "&", "ab", ".", "session", ",", "bsPtr", ",", "newBsPtr", ")", "\n", "bs", ":=", "(", "*", "BarrierSession", ")", "(", "bsPtr", ")", "\n", "bs", ".", "objectRef", "=", "ref", "\n", "ab", ".", "activeSeqno", "++", "\n", "bs", ".", "seqno", "=", "ab", ".", "activeSeqno", "\n\n", "atomic", ".", "AddInt32", "(", "bs", ".", "liveCount", ",", "barrierFlushOffset", "+", "1", ")", "\n", "ab", ".", "Release", "(", "bs", ")", "\n", "}", "\n", "}" ]
8,048
all-8049
[ "change", "an", "active", "shader", "storage", "block", "binding" ]
[ "func", "ShaderStorageBlockBinding", "(", "program", "uint32", ",", "storageBlockIndex", "uint32", ",", "storageBlockBinding", "uint32", ")", "{", "syscall", ".", "Syscall", "(", "gpShaderStorageBlockBinding", ",", "3", ",", "uintptr", "(", "<mask>", ")", ",", "uintptr", "(", "storageBlockIndex", ")", ",", "uintptr", "(", "storageBlockBinding", ")", ")", "\n", "}" ]
8,049
all-8050
[ "Do", "executes", "Emulation", ".", "setDocumentCookieDisabled", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "SetDocumentCookieDisabledParams", ")", "Do", "(", "ctx", "context", ".", "<mask>", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetDocumentCookieDisabled", ",", "p", ",", "nil", ")", "\n", "}" ]
8,050
all-8051
[ "POST", "/", "api", "/", "current_user", "/", "actions", "/", "cloud_accounts", "Creates", "a", "cloud", "account", "in", "the", "first", "available", "child", "account", "or", "the", "account", "used", "to", "login", "if", "there", "are", "no", "available", "child", "accounts", "." ]
[ "func", "(", "loc", "*", "CurrentUserLocator", ")", "CloudAccounts", "(", "awsAccessKeyId", "string", ",", "awsAccountNumber", "string", ",", "awsSecretAccessKey", "string", ",", "cloudVendorName", "string", ")", "error", "{", "if", "awsAccessKeyId", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "awsAccountNumber", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "awsSecretAccessKey", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "cloudVendorName", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "var", "params", "rsapi", ".", "APIParams", "\n", "var", "p", "rsapi", ".", "APIParams", "\n", "p", "=", "rsapi", ".", "APIParams", "{", "\"", "\"", ":", "awsAccessKeyId", ",", "\"", "\"", ":", "awsAccountNumber", ",", "\"", "\"", ":", "awsSecretAccessKey", ",", "\"", "\"", ":", "cloudVendorName", ",", "}", "\n", "uri", ",", "err", ":=", "loc", ".", "ActionPath", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "req", ",", "err", ":=", "loc", ".", "api", ".", "BuildHTTPRequest", "(", "uri", ".", "HTTPMethod", ",", "uri", ".", "Path", ",", "APIVersion", ",", "params", ",", "p", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "resp", ",", "err", ":=", "loc", ".", "api", ".", "PerformRequest", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "if", "resp", ".", "StatusCode", "<", "200", "||", "resp", ".", "StatusCode", ">", "299", "{", "respBody", ",", "_", ":=", "ioutil", ".", "ReadAll", "(", "resp", ".", "Body", ")", "\n", "sr", ":=", "string", "(", "respBody", ")", "\n", "if", "sr", "!=", "\"", "\"", "{", "sr", "=", "\"", "\"", "+", "sr", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "resp", ".", "<mask>", ",", "sr", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
8,051
all-8052
[ "BootstrapCluster", "initializes", "a", "server", "s", "storage", "with", "the", "given", "cluster", "configuration", ".", "This", "should", "only", "be", "called", "at", "the", "beginning", "of", "time", "for", "the", "cluster", "and", "you", "absolutely", "must", "make", "sure", "that", "you", "call", "it", "with", "the", "same", "configuration", "on", "all", "the", "Voter", "servers", ".", "There", "is", "no", "need", "to", "bootstrap", "Nonvoter", "and", "Staging", "servers", ".", "One", "sane", "approach", "is", "to", "bootstrap", "a", "single", "server", "with", "a", "configuration", "listing", "just", "itself", "as", "a", "Voter", "then", "invoke", "AddVoter", "()", "on", "it", "to", "add", "other", "servers", "to", "the", "cluster", "." ]
[ "func", "BootstrapCluster", "(", "conf", "*", "Config", ",", "logs", "LogStore", ",", "stable", "StableStore", ",", "snaps", "SnapshotStore", ",", "trans", "Transport", ",", "configuration", "Configuration", ")", "error", "{", "// Validate the Raft server config.", "if", "err", ":=", "ValidateConfig", "(", "conf", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Sanity check the Raft peer configuration.", "if", "err", ":=", "checkConfiguration", "(", "configuration", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Make sure the cluster is in a clean state.", "hasState", ",", "err", ":=", "HasExistingState", "(", "logs", ",", "stable", ",", "snaps", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "if", "hasState", "{", "return", "ErrCantBootstrap", "\n", "}", "\n\n", "// Set current term to 1.", "if", "err", ":=", "stable", ".", "SetUint64", "(", "keyCurrentTerm", ",", "1", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "// Append configuration entry to log.", "entry", ":=", "&", "Log", "{", "<mask>", ":", "1", ",", "Term", ":", "1", ",", "}", "\n", "if", "conf", ".", "ProtocolVersion", "<", "3", "{", "entry", ".", "Type", "=", "LogRemovePeerDeprecated", "\n", "entry", ".", "Data", "=", "encodePeers", "(", "configuration", ",", "trans", ")", "\n", "}", "else", "{", "entry", ".", "Type", "=", "LogConfiguration", "\n", "entry", ".", "Data", "=", "encodeConfiguration", "(", "configuration", ")", "\n", "}", "\n", "if", "err", ":=", "logs", ".", "StoreLog", "(", "entry", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
8,052
all-8053
[ "HasUrl", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "i", "*", "ImageDefinition", ")", "HasUrl", "(", ")", "bool", "{", "if", "i", "!=", "nil", "&&", "i", ".", "Url", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
8,053
all-8054
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "PseudoElementMatches", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss26", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "<mask>", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
8,054
all-8055
[ "SetQueryString", "sets", "URI", "query", "string", "." ]
[ "func", "(", "u", "*", "URI", ")", "SetQueryString", "(", "queryString", "string", ")", "{", "u", ".", "queryString", "=", "<mask>", "(", "u", ".", "queryString", "[", ":", "0", "]", ",", "queryString", "...", ")", "\n", "u", ".", "parsedQueryArgs", "=", "false", "\n", "}" ]
8,055
all-8056
[ "Print", "outputs", "Print", "log" ]
[ "func", "Print", "(", "val", "...", "interface", "{", "}", ")", "error", "{", "return", "glg", ".", "<mask>", "(", "PRINT", ",", "blankFormat", "(", "len", "(", "val", ")", ")", ",", "val", "...", ")", "\n", "}" ]
8,056
all-8057
[ "Only", "initialize", "the", "minimal", "information", "we", "need", "about", "a", "given", "storage", "type", "." ]
[ "func", "(", "s", "*", "storageZfs", ")", "StorageCoreInit", "(", ")", "error", "{", "s", ".", "sType", "=", "storageTypeZfs", "\n", "typeName", ",", "err", ":=", "storageTypeToString", "(", "s", ".", "sType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "s", ".", "sTypeName", "=", "typeName", "\n\n", "if", "zfsVersion", "!=", "\"", "\"", "{", "s", ".", "sTypeVersion", "=", "zfsVersion", "\n", "return", "nil", "\n", "}", "\n\n", "util", ".", "LoadModule", "(", "\"", "\"", ")", "\n\n", "if", "!", "zfsIsEnabled", "(", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ")", "\n", "}", "\n\n", "s", ".", "sTypeVersion", ",", "err", "=", "zfsToolVersionGet", "(", ")", "\n", "if", "err", "!=", "nil", "{", "s", ".", "sTypeVersion", ",", "err", "=", "zfsModuleVersionGet", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n", "}", "\n\n", "zfsVersion", "=", "s", ".", "sTypeVersion", "\n\n", "return", "nil", "\n", "}" ]
8,057
all-8058
[ "specify", "mapping", "of", "depth", "values", "from", "normalized", "device", "coordinates", "to", "window", "coordinates", "for", "a", "specified", "viewport" ]
[ "func", "DepthRangeIndexed", "(", "<mask>", "uint32", ",", "n", "float64", ",", "f", "float64", ")", "{", "syscall", ".", "Syscall", "(", "gpDepthRangeIndexed", ",", "3", ",", "uintptr", "(", "index", ")", ",", "uintptr", "(", "math", ".", "Float64bits", "(", "n", ")", ")", ",", "uintptr", "(", "math", ".", "Float64bits", "(", "f", ")", ")", ")", "\n", "}" ]
8,058
all-8059
[ "BucketHeader", "prints", "the", "header", "of", "a", "goroutine", "signature", "." ]
[ "func", "(", "p", "*", "Palette", ")", "BucketHeader", "(", "bucket", "*", "stack", ".", "Bucket", ",", "fullPath", ",", "multipleBuckets", "bool", ")", "string", "{", "<mask>", ":=", "\"", "\"", "\n", "if", "s", ":=", "bucket", ".", "SleepString", "(", ")", ";", "s", "!=", "\"", "\"", "{", "extra", "+=", "\"", "\"", "+", "s", "+", "\"", "\"", "\n", "}", "\n", "if", "bucket", ".", "Locked", "{", "extra", "+=", "\"", "\"", "\n", "}", "\n", "if", "c", ":=", "bucket", ".", "CreatedByString", "(", "fullPath", ")", ";", "c", "!=", "\"", "\"", "{", "extra", "+=", "p", ".", "CreatedBy", "+", "\"", "\"", "+", "c", "+", "\"", "\"", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "p", ".", "routineColor", "(", "bucket", ",", "multipleBuckets", ")", ",", "len", "(", "bucket", ".", "IDs", ")", ",", "bucket", ".", "State", ",", "extra", ",", "p", ".", "EOLReset", ")", "\n", "}" ]
8,059
all-8060
[ "Accept", "a", "new", "node", "and", "add", "it", "to", "the", "cluster", ".", "This", "instance", "must", "already", "be", "clustered", ".", "Return", "an", "updated", "list", "raft", "database", "nodes", "(", "possibly", "including", "the", "newly", "accepted", "node", ")", "." ]
[ "func", "Accept", "(", "state", "*", "state", ".", "State", ",", "gateway", "*", "Gateway", ",", "name", ",", "address", "string", ",", "schema", ",", "api", "int", ")", "(", "[", "]", "db", ".", "RaftNode", ",", "error", ")", "{", "// Check parameters", "if", "name", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "address", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Insert the new node into the nodes table.", "err", ":=", "state", ".", "Cluster", ".", "Transaction", "(", "func", "(", "tx", "*", "db", ".", "ClusterTx", ")", "error", "{", "// Check that the node can be accepted with these parameters.", "err", ":=", "membershipCheckClusterStateForAccept", "(", "tx", ",", "name", ",", "address", ",", "schema", ",", "api", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "// Add the new node", "id", ",", "err", ":=", "tx", ".", "NodeAdd", "(", "name", ",", "address", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Mark the node as pending, so it will be skipped when", "// performing heartbeats or sending cluster", "// notifications.", "err", "=", "tx", ".", "NodePending", "(", "id", ",", "true", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Possibly insert the new node into the raft_nodes table (if we have", "// less than 3 database nodes).", "nodes", ",", "err", ":=", "gateway", ".", "currentRaftNodes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "nodes", ")", "<", "membershipMaxRaftNodes", "{", "err", "=", "state", ".", "<mask>", ".", "Transaction", "(", "func", "(", "tx", "*", "db", ".", "NodeTx", ")", "error", "{", "id", ",", "err", ":=", "tx", ".", "RaftNodeAdd", "(", "address", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "nodes", "=", "append", "(", "nodes", ",", "db", ".", "RaftNode", "{", "ID", ":", "id", ",", "Address", ":", "address", "}", ")", "\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "return", "nodes", ",", "nil", "\n", "}" ]
8,060
all-8061
[ "ServeExternalPluginHelp", "returns", "a", "HandlerFunc", "that", "serves", "plugin", "help", "information", "that", "is", "provided", "by", "the", "specified", "ExternalPluginHelpProvider", "." ]
[ "func", "ServeExternalPluginHelp", "(", "mux", "*", "http", ".", "ServeMux", ",", "log", "*", "logrus", ".", "Entry", ",", "provider", "ExternalPluginHelpProvider", ")", "{", "mux", ".", "HandleFunc", "(", "\"", "\"", ",", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "serverError", ":=", "func", "(", "action", "string", ",", "err", "error", ")", "{", "log", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "action", ")", "\n", "msg", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "action", ",", "err", ")", "\n", "http", ".", "Error", "(", "w", ",", "msg", ",", "http", ".", "StatusInternalServerError", ")", "\n", "}", "\n\n", "if", "r", ".", "Method", "!=", "http", ".", "MethodPost", "{", "<mask>", ".", "Errorf", "(", "\"", "\"", ",", "r", ".", "Method", ")", "\n", "http", ".", "Error", "(", "w", ",", "\"", "\"", ",", "http", ".", "StatusMethodNotAllowed", ")", "\n", "return", "\n", "}", "\n", "b", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ".", "Body", ")", "\n", "if", "err", "!=", "nil", "{", "serverError", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "var", "enabledRepos", "[", "]", "string", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "enabledRepos", ")", ";", "err", "!=", "nil", "{", "serverError", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "if", "provider", "==", "nil", "{", "serverError", "(", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "return", "\n", "}", "\n", "help", ",", "err", ":=", "provider", "(", "enabledRepos", ")", "\n", "if", "err", "!=", "nil", "{", "serverError", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "b", ",", "err", "=", "json", ".", "Marshal", "(", "help", ")", "\n", "if", "err", "!=", "nil", "{", "serverError", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n\n", "fmt", ".", "Fprint", "(", "w", ",", "string", "(", "b", ")", ")", "\n", "}", ",", ")", "\n", "}" ]
8,061
all-8062
[ "IfMode", "adjusts", "f", "so", "it", "only", "matches", "nodes", "for", "which", "fn", "(", "mode", ")", "returns", "true", "." ]
[ "func", "(", "f", "*", "FindFilter", ")", "IfMode", "(", "fn", "func", "(", "<mask>", ".", "FileMode", ")", "bool", ")", "*", "FindFilter", "{", "f", ".", "ifmode", "=", "fn", "\n", "return", "f", "\n", "}" ]
8,062
all-8063
[ "StatusCode", "attempts", "to", "return", "a", "HTTP", "status", "code", "for", "this", "Alert", ".", "Returns", "0", "if", "the", "status", "code", "cannot", "be", "found", "." ]
[ "func", "(", "a", "*", "Alert", ")", "StatusCode", "(", ")", "int", "{", "vals", ",", "err", ":=", "<mask>", ".", "ParseQuery", "(", "a", ".", "AlertText", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", "\n", "}", "\n", "if", "code", ":=", "vals", ".", "Get", "(", "\"", "\"", ")", ";", "code", "!=", "\"", "\"", "{", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "code", ",", "10", ",", "64", ")", "\n", "if", "err", "==", "nil", "&&", "i", ">", "99", "&&", "i", "<", "600", "{", "return", "int", "(", "i", ")", "\n", "}", "\n", "}", "\n", "return", "0", "\n", "}" ]
8,063
all-8064
[ "Map", "a", "function", "on", "each", "element", "of", "a", "slice", "of", "strings", "." ]
[ "func", "StringMap", "(", "f", "func", "(", "string", ")", "string", ",", "data", "[", "]", "string", ")", "[", "]", "string", "{", "size", ":=", "len", "(", "data", ")", "\n", "result", ":=", "make", "(", "[", "]", "string", ",", "size", ",", "size", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "<mask>", ";", "i", "++", "{", "result", "[", "i", "]", "=", "f", "(", "data", "[", "i", "]", ")", "\n", "}", "\n", "return", "result", "\n", "}" ]
8,064
all-8065
[ "Printf", "formats", "its", "arguments", "with", "fmt", ".", "Sprintf", "and", "adds", "the", "result", "to", "the", "event", "log", "." ]
[ "func", "(", "e", "*", "EventLog", ")", "Printf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "newfmt", ",", "newvals", ":=", "addEvent", "(", "e", ",", "format", ",", "a", "...", ")", "\n", "Log", ".", "Printf", "(", "newfmt", ",", "newvals", "...", ")", "\n", "e", ".", "<mask>", ".", "Printf", "(", "format", ",", "a", "...", ")", "\n", "}" ]
8,065
all-8066
[ "Errorf", "writes", "the", "formatted", "string", "to", "the", "Target", "logger", "." ]
[ "func", "(", "t", "*", "Target", ")", "Errorf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "t", ".", "mut", ".", "RLock", "(", ")", "\n", "defer", "t", ".", "mut", ".", "RUnlock", "(", ")", "\n", "if", "t", ".", "logger", "!=", "nil", "{", "t", ".", "logger", ".", "Errorf", "(", "format", ",", "v", "...", ")", "\n", "for", "_", ",", "item", ":=", "range", "v", "{", "if", "_", ",", "hasStack", ":=", "<mask>", ".", "(", "withStack", ")", ";", "hasStack", "{", "t", ".", "logger", ".", "Errorf", "(", "\"", "\"", ",", "item", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
8,066
all-8067
[ "NewOfferEntryExt", "creates", "a", "new", "OfferEntryExt", "." ]
[ "func", "NewOfferEntryExt", "(", "v", "int32", ",", "value", "interface", "{", "}", ")", "(", "result", "OfferEntryExt", ",", "err", "error", ")", "{", "result", ".", "V", "=", "v", "\n", "<mask>", "int32", "(", "v", ")", "{", "case", "0", ":", "// void", "}", "\n", "return", "\n", "}" ]
8,067
all-8068
[ "Do", "executes", "Emulation", ".", "setDeviceMetricsOverride", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "SetDeviceMetricsOverrideParams", ")", "Do", "(", "ctx", "context", ".", "<mask>", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetDeviceMetricsOverride", ",", "p", ",", "nil", ")", "\n", "}" ]
8,068
all-8069
[ "Next", "returns", "the", "next", "page", "of", "resources", ".", "If", "there", "are", "no", "more", "resources", "NoMoreResults", "is", "returned", "." ]
[ "func", "(", "c", "*", "IncomingPhoneNumberPageIterator", ")", "Next", "(", "ctx", "context", ".", "Context", ")", "(", "*", "IncomingPhoneNumberPage", ",", "error", ")", "{", "cp", ":=", "<mask>", "(", "IncomingPhoneNumberPage", ")", "\n", "err", ":=", "c", ".", "p", ".", "Next", "(", "ctx", ",", "cp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "c", ".", "p", ".", "SetNextPageURI", "(", "cp", ".", "NextPageURI", ")", "\n", "return", "cp", ",", "nil", "\n", "}" ]
8,069
all-8070
[ "LoadWithEnvJSON", "loads", "JSON", "files", "with", "Env" ]
[ "func", "LoadWithEnvJSON", "(", "conf", "<mask>", "{", "}", ",", "configPaths", "...", "string", ")", "error", "{", "return", "loadWithFunc", "(", "conf", ",", "configPaths", ",", "envReplacer", ",", "json", ".", "Unmarshal", ")", "\n", "}" ]
8,070
all-8071
[ "Parse", "takes", "a", "string", "representation", "of", "a", "selector", "and", "returns", "the", "corresponding", "Op", "definition" ]
[ "func", "Parse", "(", "selector", "string", ")", "(", "Op", ",", "error", ")", "{", "segments", ":=", "strings", ".", "Split", "(", "selector", ",", "\"", "\"", ")", "\n\n", "ops", ":=", "make", "(", "[", "]", "Op", ",", "0", ",", "len", "(", "segments", ")", ")", "\n", "for", "_", ",", "segment", ":=", "range", "segments", "{", "key", ":=", "strings", ".", "TrimSpace", "(", "segment", ")", "\n", "if", "key", "==", "\"", "\"", "{", "continue", "\n", "}", "\n\n", "if", "op", ",", "ok", ":=", "parseArray", "(", "key", ")", ";", "ok", "{", "ops", "=", "append", "(", "ops", ",", "op", ")", "\n", "continue", "\n", "}", "\n\n", "ops", "=", "append", "(", "ops", ",", "Dot", "(", "<mask>", ")", ")", "\n", "}", "\n\n", "return", "Chain", "(", "ops", "...", ")", ",", "nil", "\n", "}" ]
8,071
all-8072
[ "ValidateDiff", "performs", "any", "complex", "validation", "of", "an", "individual", "network_interface", "sub", "-", "resource", "that", "can", "t", "be", "done", "in", "schema", "alone", "." ]
[ "func", "(", "r", "*", "NetworkInterfaceSubresource", ")", "ValidateDiff", "(", ")", "error", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ")", "\n\n", "// Ensure that network resource allocation options are only set on vSphere", "// 6.0 and higher.", "<mask>", ":=", "viapi", ".", "ParseVersionFromClient", "(", "r", ".", "client", ")", "\n", "if", "version", ".", "Older", "(", "viapi", ".", "VSphereVersion", "{", "Product", ":", "version", ".", "Product", ",", "Major", ":", "6", "}", ")", "{", "if", "err", ":=", "r", ".", "restrictResourceAllocationSettings", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ")", "\n", "return", "nil", "\n", "}" ]
8,072
all-8073
[ "NamespacedContext", "wraps", "a", "Context", "to", "support", "namespaces", "." ]
[ "func", "NamespacedContext", "(", "ctx", "netcontext", ".", "Context", ",", "namespace", "string", ")", "netcontext", ".", "<mask>", "{", "return", "withNamespace", "(", "ctx", ",", "namespace", ")", "\n", "}" ]
8,073
all-8074
[ "ContextWithSpan", "returns", "a", "new", "context", ".", "Context", "that", "holds", "a", "reference", "to", "span", "s", "SpanContext", "." ]
[ "func", "ContextWithSpan", "(", "ctx", "context", ".", "Context", ",", "span", "Span", ")", "context", ".", "Context", "{", "return", "<mask>", ".", "WithValue", "(", "ctx", ",", "activeSpanKey", ",", "span", ")", "\n", "}" ]
8,074
all-8075
[ "GetIncludeUngroupedHostsOk", "returns", "a", "tuple", "with", "the", "IncludeUngroupedHosts", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "g", "*", "GraphDefinition", ")", "GetIncludeUngroupedHostsOk", "(", ")", "(", "bool", ",", "bool", ")", "{", "if", "g", "==", "nil", "||", "g", ".", "IncludeUngroupedHosts", "==", "nil", "{", "return", "<mask>", ",", "false", "\n", "}", "\n", "return", "*", "g", ".", "IncludeUngroupedHosts", ",", "true", "\n", "}" ]
8,075
all-8076
[ "IsDup", "returns", "whether", "err", "informs", "of", "a", "duplicate", "key", "error", "because", "a", "primary", "key", "index", "or", "a", "secondary", "unique", "index", "already", "has", "an", "entry", "with", "the", "given", "value", "." ]
[ "func", "IsDup", "(", "err", "error", ")", "bool", "{", "// Besides being handy, helps with MongoDB bugs SERVER-7164 and SERVER-11493.", "// What follows makes me sad. Hopefully conventions will be more clear over time.", "switch", "e", ":=", "err", ".", "(", "type", ")", "{", "case", "*", "LastError", ":", "return", "e", ".", "Code", "==", "11000", "||", "e", ".", "Code", "==", "11001", "||", "e", ".", "Code", "==", "12582", "||", "e", ".", "Code", "==", "16460", "&&", "strings", ".", "Contains", "(", "e", ".", "Err", ",", "\"", "\"", ")", "\n", "<mask>", "*", "QueryError", ":", "return", "e", ".", "Code", "==", "11000", "||", "e", ".", "Code", "==", "11001", "||", "e", ".", "Code", "==", "12582", "\n", "}", "\n", "return", "false", "\n", "}" ]
8,076
all-8077
[ "Handle", "the", "REST", "routing", "and", "run", "the", "user", "code", "." ]
[ "func", "(", "rt", "*", "router", ")", "AppFunc", "(", ")", "HandlerFunc", "{", "return", "func", "(", "writer", "ResponseWriter", ",", "request", "*", "Request", ")", "{", "// find the route", "route", ",", "params", ",", "pathMatched", ":=", "rt", ".", "findRouteFromURL", "(", "request", ".", "Method", ",", "request", ".", "URL", ")", "\n", "if", "route", "==", "nil", "{", "if", "pathMatched", "{", "// no route found, but path was matched: 405 Method Not Allowed", "Error", "(", "writer", ",", "\"", "\"", ",", "http", ".", "StatusMethodNotAllowed", ")", "\n", "return", "\n", "}", "\n\n", "// no route found, the path was not matched: 404 Not Found", "NotFound", "(", "<mask>", ",", "request", ")", "\n", "return", "\n", "}", "\n\n", "// a route was found, set the PathParams", "request", ".", "PathParams", "=", "params", "\n\n", "// run the user code", "handler", ":=", "route", ".", "Func", "\n", "handler", "(", "writer", ",", "request", ")", "\n", "}", "\n", "}" ]
8,077
all-8078
[ "export", "FileSequence_Ext" ]
[ "func", "FileSequence_Ext", "(", "id", "FileSeqId", ")", "*", "C", ".", "char", "{", "fs", ",", "ok", ":=", "sFileSeqs", ".", "Get", "(", "id", ")", "\n", "// caller must free string", "if", "!", "ok", "{", "return", "C", ".", "CString", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "C", ".", "CString", "(", "<mask>", ".", "Ext", "(", ")", ")", "\n", "}" ]
8,078
all-8079
[ "TwoContig", "returns", "all", "readable", "float64", "but", "in", "two", "separate", "slices", "to", "avoid", "copying", ".", "The", "two", "slices", "are", "from", "the", "same", "buffer", "but", "are", "not", "contiguous", ".", "Either", "or", "both", "may", "be", "empty", "slices", "." ]
[ "func", "(", "b", "*", "Float64RingBuf", ")", "TwoContig", "(", "makeCopy", "bool", ")", "(", "<mask>", "[", "]", "float64", ",", "second", "[", "]", "float64", ")", "{", "extent", ":=", "b", ".", "Beg", "+", "b", ".", "Readable", "\n", "if", "extent", "<=", "b", ".", "N", "{", "// we fit contiguously in this buffer without wrapping to the other.", "// Let second stay an empty slice.", "return", "b", ".", "A", "[", "b", ".", "Beg", ":", "(", "b", ".", "Beg", "+", "b", ".", "Readable", ")", "]", ",", "second", "\n", "}", "\n\n", "return", "b", ".", "A", "[", "b", ".", "Beg", ":", "b", ".", "N", "]", ",", "b", ".", "A", "[", "0", ":", "(", "extent", "%", "b", ".", "N", ")", "]", "\n", "}" ]
8,079
all-8080
[ "expandHostVirtualSwitchSpec", "reads", "certain", "ResourceData", "keys", "and", "returns", "a", "HostVirtualSwitchSpec", "." ]
[ "func", "expandHostVirtualSwitchSpec", "(", "d", "*", "schema", ".", "ResourceData", ")", "*", "types", ".", "HostVirtualSwitchSpec", "{", "obj", ":=", "&", "types", ".", "HostVirtualSwitchSpec", "{", "Mtu", ":", "int32", "(", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "int", ")", ")", ",", "NumPorts", ":", "int32", "(", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "int", ")", ")", ",", "Bridge", ":", "expandHostVirtualSwitchBondBridge", "(", "d", ")", ",", "Policy", ":", "expandHostNetworkPolicy", "(", "d", ")", ",", "}", "\n", "// If there are no NICs, we need to nil-out Bridge, as a", "// HostVirtualSwitchBondBridge with no NICs is an invalid config.", "if", "len", "(", "obj", ".", "Bridge", ".", "(", "*", "<mask>", ".", "HostVirtualSwitchBondBridge", ")", ".", "NicDevice", ")", "<", "1", "{", "obj", ".", "Bridge", "=", "nil", "\n", "}", "\n", "return", "obj", "\n", "}" ]
8,080
all-8081
[ "GetStartOk", "returns", "a", "tuple", "with", "the", "Start", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "p", "*", "Params", ")", "GetStartOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "p", "==", "nil", "||", "p", ".", "Start", "==", "nil", "{", "return", "\"", "\"", ",", "false", "\n", "}", "\n", "return", "*", "p", ".", "Start", ",", "<mask>", "\n", "}" ]
8,081
all-8082
[ "Ping", "returns", "an", "error", "if", "remote", "enpoint", "cannot", "be", "reached", "." ]
[ "func", "(", "c", "*", "Client", ")", "Ping", "(", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "client", ".", "Head", "(", "c", ".", "<mask>", "(", ")", ")", "\n", "return", "err", "\n", "}" ]
8,082
all-8083
[ "setNetworkRoutes", "applies", "any", "static", "routes", "configured", "from", "the", "host", "to", "the", "container", "nic", "." ]
[ "func", "(", "c", "*", "containerLXC", ")", "setNetworkRoutes", "(", "m", "types", ".", "Device", ")", "error", "{", "if", "!", "shared", ".", "PathExists", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", "[", "\"", "\"", "]", ")", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "m", "[", "\"", "\"", "]", ")", "\n", "}", "\n\n", "// Flush all IPv4 routes", "_", ",", "err", ":=", "shared", ".", "RunCommand", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "m", "[", "\"", "\"", "]", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Flush all IPv6 routes", "_", ",", "err", "=", "shared", ".", "RunCommand", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "m", "[", "\"", "\"", "]", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Add additional IPv4 routes", "if", "m", "[", "\"", "\"", "]", "!=", "\"", "\"", "{", "for", "_", ",", "route", ":=", "range", "strings", ".", "Split", "(", "m", "[", "\"", "\"", "]", ",", "\"", "\"", ")", "{", "route", "=", "strings", ".", "TrimSpace", "(", "route", ")", "\n", "_", ",", "err", ":=", "shared", ".", "RunCommand", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "m", "[", "\"", "\"", "]", ",", "route", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// Add additional IPv6 routes", "if", "m", "[", "\"", "\"", "]", "!=", "\"", "\"", "{", "for", "_", ",", "route", ":=", "range", "strings", ".", "Split", "(", "m", "[", "\"", "\"", "]", ",", "\"", "\"", ")", "{", "route", "=", "strings", ".", "TrimSpace", "(", "<mask>", ")", "\n", "_", ",", "err", ":=", "shared", ".", "RunCommand", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "m", "[", "\"", "\"", "]", ",", "route", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
8,083
all-8084
[ "ReportError", "reports", "an", "error", "that", "occured", "during", "the", "transaction", "." ]
[ "func", "(", "t", "*", "<mask>", ")", "ReportError", "(", "exceptionType", ",", "errorMessage", ",", "stackTrace", ",", "stackFrameDelim", "string", ")", "error", "{", "t", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "_", ",", "err", ":=", "t", ".", "Reporter", ".", "ReportError", "(", "t", ".", "id", ",", "exceptionType", ",", "errorMessage", ",", "stackTrace", ",", "stackFrameDelim", ")", "\n", "return", "err", "\n", "}" ]
8,084
all-8085
[ "SetCredentialsID", "sets", "the", "credentials", "ID", "for", "the", "task" ]
[ "func", "(", "<mask>", "*", "Task", ")", "SetCredentialsID", "(", "id", "string", ")", "{", "task", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "task", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "task", ".", "credentialsID", "=", "id", "\n", "}" ]
8,085
all-8086
[ "Contains", "checks", "if", "a", "given", "device", "exists", "in", "the", "set", "and", "if", "it", "s", "identical", "to", "that", "provided" ]
[ "func", "(", "list", "Devices", ")", "Contains", "(", "k", "string", ",", "d", "Device", ")", "bool", "{", "// If it didn't exist, it's different", "if", "list", "[", "k", "]", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "old", ":=", "<mask>", "[", "k", "]", "\n\n", "return", "deviceEquals", "(", "old", ",", "d", ")", "\n", "}" ]
8,086
all-8087
[ "Create", "a", "new", "FrameSet", "from", "a", "given", "frame", "range", "string", "Returns", "an", "error", "if", "the", "frame", "range", "could", "not", "be", "parsed", "." ]
[ "func", "NewFrameSet", "(", "frange", "string", ")", "(", "*", "FrameSet", ",", "error", ")", "{", "// Process the frame range and get a slice of match slices", "matches", ",", "err", ":=", "frameRangeMatches", "(", "frange", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "frameSet", ":=", "&", "FrameSet", "{", "frange", ",", "&", "ranges", ".", "InclusiveRanges", "{", "}", "}", "\n\n", "// Process each slice match and add it to the frame set", "for", "_", ",", "match", ":=", "<mask>", "matches", "{", "if", "err", "=", "frameSet", ".", "handleMatch", "(", "match", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "frameSet", ",", "nil", "\n", "}" ]
8,087
all-8088
[ "KVToBytes", "encodes", "key", "-", "value", "pair", "to", "item", "bytes", "which", "can", "be", "passed", "to", "the", "Put", "()", "and", "Delete", "()", "methods", "." ]
[ "func", "KVToBytes", "(", "k", ",", "v", "[", "]", "byte", ")", "[", "]", "<mask>", "{", "klen", ":=", "len", "(", "k", ")", "\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "2", ",", "len", "(", "k", ")", "+", "len", "(", "v", ")", "+", "2", ")", "\n", "binary", ".", "LittleEndian", ".", "PutUint16", "(", "buf", "[", "0", ":", "2", "]", ",", "uint16", "(", "klen", ")", ")", "\n", "buf", "=", "append", "(", "buf", ",", "k", "...", ")", "\n", "buf", "=", "append", "(", "buf", ",", "v", "...", ")", "\n\n", "return", "buf", "\n", "}" ]
8,088
all-8089
[ "define", "an", "array", "of", "color", "indexes" ]
[ "func", "IndexPointer", "(", "xtype", "uint32", ",", "stride", "int32", ",", "<mask>", "unsafe", ".", "Pointer", ")", "{", "C", ".", "glowIndexPointer", "(", "gpIndexPointer", ",", "(", "C", ".", "GLenum", ")", "(", "xtype", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "stride", ")", ",", "pointer", ")", "\n", "}" ]
8,089
all-8090
[ "BoolPolicy", "converts", "a", "bool", "into", "a", "VMware", "BoolPolicy", "value", "." ]
[ "func", "BoolPolicy", "(", "b", "bool", ")", "*", "types", ".", "BoolPolicy", "{", "bp", ":=", "&", "types", ".", "BoolPolicy", "{", "<mask>", ":", "BoolPtr", "(", "b", ")", ",", "}", "\n", "return", "bp", "\n", "}" ]
8,090
all-8091
[ "From", "https", ":", "//", "github", ".", "com", "/", "golang", "/", "go", "/", "blob", "/", "31d19c0ba34782d16b91e9d41aa88147e858bb34", "/", "src", "/", "net", "/", "url", "/", "url", ".", "go#L710", "validEncodedPath", "reports", "whether", "s", "is", "a", "valid", "encoded", "path", ".", "It", "must", "not", "contain", "any", "bytes", "that", "require", "escaping", "during", "path", "encoding", "." ]
[ "func", "validEncodedPath", "(", "s", "string", ")", "bool", "{", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "s", ")", ";", "i", "++", "{", "// RFC 3986, Appendix A.", "// pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\".", "// shouldEscape is not quite compliant with the RFC,", "// so we check the sub-delims ourselves and let", "// shouldEscape handle the others.", "<mask>", "s", "[", "i", "]", "{", "case", "'!'", ",", "'$'", ",", "'&'", ",", "'\\''", ",", "'('", ",", "')'", ",", "'*'", ",", "'+'", ",", "','", ",", "';'", ",", "'='", ",", "':'", ",", "'@'", ":", "// ok", "case", "'['", ",", "']'", ":", "// ok - not specified in RFC 3986 but left alone by modern browsers", "case", "'%'", ":", "// ok - percent encoded, will decode", "default", ":", "if", "shouldEscape", "(", "s", "[", "i", "]", ",", "encodePath", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
8,091
all-8092
[ "ShouldReport", "returns", "if", "this", "prowjob", "should", "be", "reported", "by", "the", "gerrit", "reporter" ]
[ "func", "(", "c", "*", "Client", ")", "ShouldReport", "(", "pj", "*", "v1", ".", "ProwJob", ")", "bool", "{", "if", "pj", ".", "Status", ".", "State", "==", "v1", ".", "TriggeredState", "||", "pj", ".", "Status", ".", "State", "==", "v1", ".", "PendingState", "{", "// not done yet", "logrus", ".", "WithField", "(", "\"", "\"", ",", "pj", ".", "ObjectMeta", ".", "Name", ")", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "false", "\n", "}", "\n\n", "if", "pj", ".", "Status", ".", "State", "==", "v1", ".", "AbortedState", "{", "// aborted (new patchset)", "logrus", ".", "WithField", "(", "\"", "\"", ",", "pj", ".", "ObjectMeta", ".", "Name", ")", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "false", "\n", "}", "\n\n", "// has gerrit metadata (scheduled by gerrit adapter)", "if", "pj", ".", "ObjectMeta", ".", "Annotations", "[", "client", ".", "GerritID", "]", "==", "\"", "\"", "||", "pj", ".", "ObjectMeta", ".", "Annotations", "[", "client", ".", "GerritInstance", "]", "==", "\"", "\"", "||", "pj", ".", "ObjectMeta", ".", "Labels", "[", "client", ".", "GerritRevision", "]", "==", "\"", "\"", "{", "logrus", ".", "WithField", "(", "\"", "\"", ",", "pj", ".", "ObjectMeta", ".", "Name", ")", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "false", "\n", "}", "\n\n", "// Only report when all jobs of the same type on the same revision finished", "selector", ":=", "labels", ".", "Set", "{", "client", ".", "GerritRevision", ":", "pj", ".", "ObjectMeta", ".", "Labels", "[", "client", ".", "GerritRevision", "]", ",", "kube", ".", "ProwJobTypeLabel", ":", "pj", ".", "ObjectMeta", ".", "Labels", "[", "kube", ".", "ProwJobTypeLabel", "]", ",", "}", "\n\n", "if", "pj", ".", "ObjectMeta", ".", "Labels", "[", "client", ".", "GerritReportLabel", "]", "==", "\"", "\"", "{", "// Shouldn't happen, adapter should already have defaulted to Code-Review", "logrus", ".", "Errorf", "(", "\"", "\"", ",", "pj", ".", "Spec", ".", "Job", ")", "\n", "}", "else", "{", "selector", "[", "client", ".", "GerritReportLabel", "]", "=", "pj", ".", "ObjectMeta", ".", "Labels", "[", "client", ".", "GerritReportLabel", "]", "\n", "}", "\n\n", "pjs", ",", "err", ":=", "c", ".", "lister", ".", "<mask>", "(", "selector", ".", "AsSelector", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "selector", ")", "\n", "return", "false", "\n", "}", "\n\n", "for", "_", ",", "pjob", ":=", "range", "pjs", "{", "if", "pjob", ".", "Status", ".", "State", "==", "v1", ".", "TriggeredState", "||", "pjob", ".", "Status", ".", "State", "==", "v1", ".", "PendingState", "{", "// other jobs with same label are still running on this revision, skip report", "logrus", ".", "WithField", "(", "\"", "\"", ",", "pjob", ".", "ObjectMeta", ".", "Name", ")", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "false", "\n", "}", "\n", "}", "\n\n", "return", "true", "\n", "}" ]
8,092
all-8093
[ "NewSerialDispatcher", "creates", "a", "new", "PrallelDispatcher", "with", "the", "given", "handlers" ]
[ "func", "NewSerialDispatcher", "(", "handlers", "[", "]", "<mask>", ")", "Dispatcher", "{", "return", "&", "SerialDispatcher", "{", "handlers", ":", "handlers", ",", "mutex", ":", "sync", ".", "RWMutex", "{", "}", ",", "}", "\n", "}" ]
8,093
all-8094
[ "Listen", "for", "a", "Shutdown", "signal", "or", "Outbound", "messages", "." ]
[ "func", "(", "m", "*", "MessageStream", ")", "outbound", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "m", ".", "Shutdown", ":", "log", ".", "Infof", "(", "\"", "\"", ")", "\n", "m", ".", "conn", ".", "Close", "(", ")", "\n", "return", "\n", "case", "msg", ":=", "<-", "m", ".", "Outbound", ":", "// Forward outbound messages to conn", "data", ",", "_", ":=", "msg", ".", "MarshalBinary", "(", ")", "\n", "if", "_", ",", "err", ":=", "m", ".", "conn", ".", "Write", "(", "data", ")", ";", "err", "!=", "nil", "{", "log", ".", "Warnln", "(", "\"", "\"", ",", "err", ")", "\n", "m", ".", "Error", "<-", "err", "\n", "m", ".", "Shutdown", "<-", "true", "\n", "}", "\n\n", "<mask>", ".", "Debugf", "(", "\"", "\"", ",", "len", "(", "data", ")", ",", "data", ")", "\n", "}", "\n", "}", "\n", "}" ]
8,094
all-8095
[ "Stabilize", "tries", "to", "move", "the", "player", "in", "the", "stable", "position", "(", "lean", ")", "." ]
[ "func", "(", "p", "*", "<mask>", ")", "Stabilize", "(", ")", "{", "if", "0", "<", "p", ".", "lean", "{", "p", ".", "lean", "--", "\n", "}", "\n", "if", "p", ".", "lean", "<", "0", "{", "p", ".", "lean", "++", "\n", "}", "\n", "}" ]
8,095
all-8096
[ "NewPeerHandler", "generates", "an", "http", ".", "Handler", "to", "handle", "etcd", "peer", "requests", "." ]
[ "func", "NewPeerHandler", "(", "lg", "*", "zap", ".", "Logger", ",", "s", "etcdserver", ".", "ServerPeer", ")", "http", ".", "<mask>", "{", "return", "newPeerHandler", "(", "lg", ",", "s", ".", "Cluster", "(", ")", ",", "s", ".", "RaftHandler", "(", ")", ",", "s", ".", "LeaseHandler", "(", ")", ")", "\n", "}" ]
8,096
all-8097
[ "MetadataAsMap", "parses", "the", "Response", "metadata", "into", "a", "map" ]
[ "func", "(", "r", "*", "Response", ")", "MetadataAsMap", "(", ")", "(", "map", "[", "string", "]", "<mask>", "{", "}", ",", "error", ")", "{", "ret", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "}", "\n", "err", ":=", "r", ".", "MetadataAsStruct", "(", "&", "ret", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "ret", ",", "nil", "\n", "}" ]
8,097
all-8098
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "EventLayerPainted", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoLayertree16", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
8,098
all-8099
[ "BuildResourceDependency", "adds", "a", "new", "resource", "dependency", "by", "taking", "in", "the", "required", "status", "of", "the", "resource", "that", "satisfies", "the", "dependency", "and", "the", "dependent", "container", "status", "whose", "transition", "is", "dependent", "on", "the", "resource", ".", "example", ":", "if", "container", "s", "PULLED", "transition", "is", "dependent", "on", "volume", "resource", "s", "CREATED", "status", "then", "RequiredStatus", "=", "VolumeCreated", "and", "dependentStatus", "=", "ContainerPulled" ]
[ "func", "(", "c", "*", "Container", ")", "BuildResourceDependency", "(", "resourceName", "string", ",", "requiredStatus", "resourcestatus", ".", "ResourceStatus", ",", "dependentStatus", "apicontainerstatus", ".", "ContainerStatus", ")", "{", "resourceDep", ":=", "ResourceDependency", "{", "Name", ":", "resourceName", ",", "RequiredStatus", ":", "requiredStatus", ",", "}", "\n", "if", "_", ",", "ok", ":=", "c", ".", "TransitionDependenciesMap", "[", "dependentStatus", "]", ";", "!", "ok", "{", "c", ".", "TransitionDependenciesMap", "[", "dependentStatus", "]", "=", "TransitionDependencySet", "{", "}", "\n", "}", "\n", "deps", ":=", "c", ".", "TransitionDependenciesMap", "[", "dependentStatus", "]", "\n", "deps", ".", "ResourceDependencies", "=", "<mask>", "(", "deps", ".", "ResourceDependencies", ",", "resourceDep", ")", "\n", "c", ".", "TransitionDependenciesMap", "[", "dependentStatus", "]", "=", "deps", "\n", "}" ]
8,099
all-8100
[ "Accept", "waits", "for", "and", "returns", "the", "next", "connection", "to", "the", "listener", "." ]
[ "func", "(", "l", "*", "inMemoryListener", ")", "Accept", "(", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "select", "{", "case", "conn", ":=", "<-", "l", ".", "conns", ":", "return", "conn", ",", "nil", "\n", "case", "<-", "l", ".", "<mask>", ":", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]