id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
3,200
all-3201
[ "VerifyJSON", "returns", "a", "handler", "that", "verifies", "that", "the", "body", "of", "the", "request", "is", "a", "valid", "JSON", "representation", "matching", "the", "passed", "in", "JSON", "string", ".", "It", "does", "this", "using", "Gomega", "s", "MatchJSON", "method", "VerifyJSON", "also", "verifies", "that", "the", "request", "s", "content", "type", "is", "application", "/", "json" ]
[ "func", "VerifyJSON", "(", "expectedJSON", "string", ")", "http", ".", "HandlerFunc", "{", "return", "CombineHandlers", "(", "VerifyMimeType", "(", "\"", "\"", ")", ",", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "<mask>", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "req", ".", "Body", ")", "\n", "req", ".", "Body", ".", "Close", "(", ")", "\n", "Expect", "(", "err", ")", ".", "ShouldNot", "(", "HaveOccurred", "(", ")", ")", "\n", "Expect", "(", "body", ")", ".", "Should", "(", "MatchJSON", "(", "expectedJSON", ")", ",", "\"", "\"", ")", "\n", "}", ",", ")", "\n", "}" ]
3,201
all-3202
[ "writeClean", "writes", "v", "after", "replacing", "special", "characters", "[", "{}", "/", "\\\\", ":", "\\", "s", ".", "]", "with", "-" ]
[ "func", "writeClean", "(", "buf", "*", "bytes", ".", "<mask>", ",", "v", "string", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "v", ")", ";", "i", "++", "{", "c", ":=", "v", "[", "i", "]", "\n", "switch", "c", "{", "case", "'{'", ",", "'}'", ",", "'/'", ",", "'\\\\'", ",", "':'", ",", "'.'", ",", "' '", ",", "'\\t'", ",", "'\\r'", ",", "'\\n'", ":", "buf", ".", "WriteByte", "(", "'-'", ")", "\n", "default", ":", "buf", ".", "WriteByte", "(", "c", ")", "\n", "}", "\n", "}", "\n", "}" ]
3,202
all-3203
[ "GetChangeTrustOp", "retrieves", "the", "ChangeTrustOp", "value", "from", "the", "union", "returning", "ok", "if", "the", "union", "s", "switch", "indicated", "the", "value", "is", "valid", "." ]
[ "func", "(", "u", "OperationBody", ")", "GetChangeTrustOp", "(", ")", "(", "result", "ChangeTrustOp", ",", "ok", "bool", ")", "{", "armName", ",", "_", ":=", "u", ".", "ArmForSwitch", "(", "int32", "(", "u", ".", "Type", ")", ")", "\n\n", "if", "armName", "==", "\"", "\"", "{", "result", "=", "*", "u", ".", "ChangeTrustOp", "\n", "ok", "=", "<mask>", "\n", "}", "\n\n", "return", "\n", "}" ]
3,203
all-3204
[ "Returns", "true", "if", "key", "is", "strictly", ">", "n", ".", "key", ".", "If", "n", "is", "nil", "this", "is", "an", "end", "marker", "and", "we", "return", "false", ".", "func", "(", "s", "*", "Skiplist", ")", "keyIsAfterNode", "(", "key", "[]", "byte", "n", "*", "node", ")", "bool", "{", "y", ".", "AssertTrue", "(", "n", "!", "=", "s", ".", "head", ")", "return", "n", "!", "=", "nil", "&&", "y", ".", "CompareKeys", "(", "key", "n", ".", "key", ")", ">", "0", "}" ]
[ "func", "randomHeight", "(", ")", "int", "{", "h", ":=", "1", "\n", "for", "h", "<", "maxHeight", "&&", "<mask>", ".", "Uint32", "(", ")", "<=", "heightIncrease", "{", "h", "++", "\n", "}", "\n", "return", "h", "\n", "}" ]
3,204
all-3205
[ "/", "*", "A", "special", "case", "where", "functions", "need", "to", "be", "of", "higher", "precedence", "than", "values", "and", "need", "a", "special", "wrapped", "execution", "stage", "operator", "." ]
[ "func", "planFunction", "(", "stream", "*", "tokenStream", ")", "(", "*", "evaluationStage", ",", "error", ")", "{", "var", "token", "ExpressionToken", "\n", "var", "rightStage", "*", "evaluationStage", "\n", "var", "err", "error", "\n\n", "token", "=", "stream", ".", "next", "(", ")", "\n\n", "if", "<mask>", ".", "Kind", "!=", "FUNCTION", "{", "stream", ".", "rewind", "(", ")", "\n", "return", "planAccessor", "(", "stream", ")", "\n", "}", "\n\n", "rightStage", ",", "err", "=", "planAccessor", "(", "stream", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "evaluationStage", "{", "symbol", ":", "FUNCTIONAL", ",", "rightStage", ":", "rightStage", ",", "operator", ":", "makeFunctionStage", "(", "token", ".", "Value", ".", "(", "ExpressionFunction", ")", ")", ",", "typeErrorFormat", ":", "\"", "\"", ",", "}", ",", "nil", "\n", "}" ]
3,205
all-3206
[ "ContainsFields", "checks", "that", "the", "mapping", "contains", "fields", "with", "the", "same", "type", "and", "name", "of", "given", "ones", "." ]
[ "func", "(", "m", "*", "Mapping", ")", "ContainsFields", "(", "fields", "[", "]", "*", "Field", ")", "bool", "{", "matches", ":=", "map", "[", "*", "Field", "]", "bool", "{", "}", "\n\n", "for", "_", ",", "field", ":=", "range", "m", ".", "Fields", "{", "for", "_", ",", "other", ":=", "<mask>", "fields", "{", "if", "field", ".", "Name", "==", "other", ".", "Name", "&&", "field", ".", "Type", ".", "Name", "==", "other", ".", "Type", ".", "Name", "{", "matches", "[", "field", "]", "=", "true", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "len", "(", "matches", ")", "==", "len", "(", "fields", ")", "\n", "}" ]
3,206
all-3207
[ "HasTitleSize", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "h", "*", "HostmapDefinition", ")", "HasTitleSize", "(", ")", "bool", "{", "if", "h", "!=", "nil", "&&", "h", ".", "TitleSize", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
3,207
all-3208
[ "CreateContainerFile", "tells", "LXD", "to", "create", "a", "file", "in", "the", "container" ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "CreateContainerFile", "(", "containerName", "string", ",", "path", "string", ",", "args", "ContainerFileArgs", ")", "error", "{", "if", "args", ".", "Type", "==", "\"", "\"", "{", "if", "!", "r", ".", "HasExtension", "(", "\"", "\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "if", "args", ".", "Type", "==", "\"", "\"", "{", "if", "!", "r", ".", "HasExtension", "(", "\"", "\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "if", "args", ".", "WriteMode", "==", "\"", "\"", "{", "if", "!", "r", ".", "HasExtension", "(", "\"", "\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "// Prepare the HTTP request", "requestURL", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ".", "httpHost", ",", "url", ".", "QueryEscape", "(", "containerName", ")", ",", "url", ".", "QueryEscape", "(", "path", ")", ")", "\n\n", "requestURL", ",", "err", ":=", "r", ".", "setQueryAttributes", "(", "requestURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "requestURL", ",", "args", ".", "Content", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Set the user agent", "if", "r", ".", "httpUserAgent", "!=", "\"", "\"", "{", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "r", ".", "httpUserAgent", ")", "\n", "}", "\n\n", "// Set the various headers", "if", "args", ".", "UID", ">", "-", "1", "{", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "args", ".", "UID", ")", ")", "\n", "}", "\n\n", "if", "args", ".", "GID", ">", "-", "1", "{", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "args", ".", "GID", ")", ")", "\n", "}", "\n\n", "if", "args", ".", "Mode", ">", "-", "1", "{", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "args", ".", "Mode", ")", ")", "\n", "}", "\n\n", "if", "args", ".", "Type", "!=", "\"", "\"", "{", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "args", ".", "Type", ")", "\n", "}", "\n\n", "if", "args", ".", "WriteMode", "!=", "\"", "\"", "{", "req", ".", "Header", ".", "<mask>", "(", "\"", "\"", ",", "args", ".", "WriteMode", ")", "\n", "}", "\n\n", "// Send the request", "resp", ",", "err", ":=", "r", ".", "do", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Check the return value for a cleaner error", "_", ",", "_", ",", "err", "=", "lxdParseResponse", "(", "resp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
3,208
all-3209
[ "DumpProfile", "dumps", "the", "profiles", "given", "to", "writer", "in", "go", "coverage", "format", "." ]
[ "func", "DumpProfile", "(", "profiles", "[", "]", "*", "cover", ".", "Profile", ",", "writer", "io", ".", "Writer", ")", "error", "{", "if", "len", "(", "profiles", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "_", ",", "err", ":=", "io", ".", "WriteString", "(", "<mask>", ",", "\"", "\"", "+", "profiles", "[", "0", "]", ".", "Mode", "+", "\"", "\\n", "\"", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "_", ",", "profile", ":=", "range", "profiles", "{", "for", "_", ",", "block", ":=", "range", "profile", ".", "Blocks", "{", "if", "_", ",", "err", ":=", "fmt", ".", "Fprintf", "(", "writer", ",", "\"", "\\n", "\"", ",", "profile", ".", "FileName", ",", "block", ".", "StartLine", ",", "block", ".", "StartCol", ",", "block", ".", "EndLine", ",", "block", ".", "EndCol", ",", "block", ".", "NumStmt", ",", "block", ".", "Count", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
3,209
all-3210
[ "HasTextAlign", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "g", "*", "GraphDefinition", ")", "HasTextAlign", "(", ")", "bool", "{", "if", "g", "!=", "nil", "&&", "g", ".", "TextAlign", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
3,210
all-3211
[ "BindApp", "makes", "the", "bind", "between", "the", "service", "instance", "and", "an", "app", "." ]
[ "func", "(", "si", "*", "ServiceInstance", ")", "BindApp", "(", "app", "bind", ".", "App", ",", "params", "BindAppParameters", ",", "shouldRestart", "bool", ",", "writer", "io", ".", "<mask>", ",", "evt", "*", "event", ".", "Event", ",", "requestID", "string", ")", "error", "{", "args", ":=", "bindPipelineArgs", "{", "serviceInstance", ":", "si", ",", "app", ":", "app", ",", "writer", ":", "writer", ",", "shouldRestart", ":", "shouldRestart", ",", "params", ":", "params", ",", "event", ":", "evt", ",", "requestID", ":", "requestID", ",", "}", "\n", "actions", ":=", "[", "]", "*", "action", ".", "Action", "{", "bindAppDBAction", ",", "bindAppEndpointAction", ",", "setBoundEnvsAction", ",", "bindUnitsAction", ",", "}", "\n", "pipeline", ":=", "action", ".", "NewPipeline", "(", "actions", "...", ")", "\n", "return", "pipeline", ".", "Execute", "(", "&", "args", ")", "\n", "}" ]
3,211
all-3212
[ "Logf", "writes", "std", "log", "event", "with", "format" ]
[ "func", "(", "g", "*", "Glg", ")", "Logf", "(", "format", "string", ",", "val", "...", "<mask>", "{", "}", ")", "error", "{", "return", "g", ".", "out", "(", "LOG", ",", "format", ",", "val", "...", ")", "\n", "}" ]
3,212
all-3213
[ "setupAppendEntries", "is", "used", "to", "setup", "an", "append", "entries", "request", "." ]
[ "func", "(", "r", "*", "Raft", ")", "setupAppendEntries", "(", "s", "*", "followerReplication", ",", "req", "*", "AppendEntriesRequest", ",", "nextIndex", ",", "lastIndex", "uint64", ")", "error", "{", "req", ".", "RPCHeader", "=", "r", ".", "getRPCHeader", "(", ")", "\n", "req", ".", "Term", "=", "s", ".", "currentTerm", "\n", "req", ".", "Leader", "=", "r", ".", "trans", ".", "EncodePeer", "(", "r", ".", "localID", ",", "r", ".", "localAddr", ")", "\n", "req", ".", "LeaderCommitIndex", "=", "r", ".", "getCommitIndex", "(", ")", "\n", "if", "err", ":=", "r", ".", "setPreviousLog", "(", "req", ",", "nextIndex", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "r", ".", "setNewLogs", "(", "req", ",", "nextIndex", ",", "lastIndex", ")", ";", "err", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n", "return", "nil", "\n", "}" ]
3,213
all-3214
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "KeyPath", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoIndexeddb9", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
3,214
all-3215
[ "IsLeader", "checks", "if", "we", "are", "currently", "the", "leader", "instance" ]
[ "func", "(", "d", "*", "DedupManager", ")", "IsLeader", "(", "tmpl", "*", "template", ".", "Template", ")", "bool", "{", "d", ".", "leaderLock", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "leaderLock", ".", "RUnlock", "(", ")", "\n\n", "lockCh", ",", "ok", ":=", "d", ".", "leader", "[", "tmpl", "]", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "select", "{", "case", "<-", "lockCh", ":", "return", "false", "\n", "default", ":", "return", "<mask>", "\n", "}", "\n", "}" ]
3,215
all-3216
[ "Do", "-", "fake", "do", "method" ]
[ "func", "(", "s", "*", "ClientDoer", ")", "Do", "(", "req", "*", "http", ".", "Request", ")", "(", "resp", "*", "<mask>", ".", "Response", ",", "err", "error", ")", "{", "s", ".", "SpyRequest", "=", "*", "req", "\n", "return", "s", ".", "Response", ",", "s", ".", "Error", "\n", "}" ]
3,216
all-3217
[ "Main", "runs", "the", "common", "functionality", "needed", "in", "a", "go", "main", "function", ".", "appEnv", "will", "be", "populated", "and", "passed", "to", "do", "defaultEnv", "can", "be", "nil", "if", "there", "is", "an", "error", "os", ".", "Exit", "(", "1", ")", "will", "be", "called", "." ]
[ "func", "Main", "(", "do", "func", "(", "interface", "{", "}", ")", "error", ",", "appEnv", "<mask>", "{", "}", ",", "decoders", "...", "Decoder", ")", "{", "if", "err", ":=", "Populate", "(", "appEnv", ",", "decoders", "...", ")", ";", "err", "!=", "nil", "{", "mainError", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "do", "(", "appEnv", ")", ";", "err", "!=", "nil", "{", "mainError", "(", "err", ")", "\n", "}", "\n", "os", ".", "Exit", "(", "0", ")", "\n", "}" ]
3,217
all-3218
[ "bind", "one", "or", "more", "named", "textures", "to", "a", "sequence", "of", "consecutive", "texture", "units" ]
[ "func", "BindTextures", "(", "first", "uint32", ",", "count", "int32", ",", "textures", "*", "uint32", ")", "{", "C", ".", "glowBindTextures", "(", "gpBindTextures", ",", "(", "C", ".", "GLuint", ")", "(", "first", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "<mask>", ")", ",", "(", "*", "C", ".", "GLuint", ")", "(", "unsafe", ".", "Pointer", "(", "textures", ")", ")", ")", "\n", "}" ]
3,218
all-3219
[ "return", "the", "polygon", "stipple", "pattern" ]
[ "func", "GetPolygonStipple", "(", "mask", "*", "uint8", ")", "{", "C", ".", "glowGetPolygonStipple", "(", "gpGetPolygonStipple", ",", "(", "*", "C", ".", "GLubyte", ")", "(", "unsafe", ".", "Pointer", "(", "<mask>", ")", ")", ")", "\n", "}" ]
3,219
all-3220
[ "New", "creates", "a", "new", "Logger", "." ]
[ "func", "New", "(", "config", "Config", ")", "(", "f", "*", "Fluent", ",", "err", "error", ")", "{", "if", "config", ".", "Server", "==", "\"", "\"", "{", "config", ".", "Server", "=", "defaultServer", "\n", "}", "\n", "if", "config", ".", "Timeout", "==", "0", "{", "config", ".", "Timeout", "=", "defaultTimeout", "\n", "}", "\n", "if", "config", ".", "RetryWait", "==", "0", "{", "config", ".", "RetryWait", "=", "defaultRetryWait", "\n", "}", "\n", "if", "config", ".", "MaxRetry", "==", "0", "{", "config", ".", "MaxRetry", "=", "defaultMaxRetry", "\n", "}", "\n", "f", "=", "&", "Fluent", "{", "Config", ":", "config", ",", "reconnecting", ":", "false", ",", "cancelReconnect", ":", "make", "(", "chan", "bool", ")", ",", "}", "\n", "err", "=", "f", ".", "<mask>", "(", ")", "\n", "return", "\n", "}" ]
3,220
all-3221
[ "DisableSvcEventHandler", "creates", "a", "new", "DISABLE_SVC_EVENT_HANDLER", "Nagios", "command", ".", "Disables", "the", "event", "handler", "for", "the", "specified", "service", "." ]
[ "func", "DisableSvcEventHandler", "(", "host_name", "string", ",", "service_description", "<mask>", ",", ")", "*", "livestatus", ".", "Command", "{", "return", "livestatus", ".", "NewCommand", "(", "\"", "\"", ",", "stringifyArg", "(", "\"", "\"", ",", "\"", "\"", ",", "host_name", ")", ",", "stringifyArg", "(", "\"", "\"", ",", "\"", "\"", ",", "service_description", ")", ",", ")", "\n", "}" ]
3,221
all-3222
[ "push", "a", "named", "debug", "group", "into", "the", "command", "stream" ]
[ "func", "PushDebugGroup", "(", "source", "uint32", ",", "id", "uint32", ",", "length", "int32", ",", "message", "*", "uint8", ")", "{", "syscall", ".", "Syscall6", "(", "gpPushDebugGroup", ",", "4", ",", "uintptr", "(", "source", ")", ",", "uintptr", "(", "id", ")", ",", "uintptr", "(", "length", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "<mask>", ")", ")", ",", "0", ",", "0", ")", "\n", "}" ]
3,222
all-3223
[ "Use", "the", "listeners", "associated", "with", "the", "file", "descriptors", "passed", "via", "socket", "-", "based", "activation", "." ]
[ "func", "activatedListeners", "(", "systemdListeners", "[", "]", "net", ".", "Listener", ",", "cert", "*", "shared", ".", "CertInfo", ")", "map", "[", "kind", "]", "net", ".", "Listener", "{", "listeners", ":=", "map", "[", "<mask>", "]", "net", ".", "Listener", "{", "}", "\n", "for", "_", ",", "listener", ":=", "range", "systemdListeners", "{", "var", "kind", "kind", "\n", "switch", "listener", ".", "(", "type", ")", "{", "case", "*", "net", ".", "UnixListener", ":", "kind", "=", "local", "\n", "case", "*", "net", ".", "TCPListener", ":", "kind", "=", "network", "\n", "listener", "=", "networkTLSListener", "(", "listener", ",", "cert", ")", "\n", "default", ":", "continue", "\n", "}", "\n", "listeners", "[", "kind", "]", "=", "listener", "\n", "}", "\n", "return", "listeners", "\n", "}" ]
3,223
all-3224
[ "GetLayoutType", "returns", "the", "LayoutType", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "b", "*", "Board", ")", "GetLayoutType", "(", ")", "<mask>", "{", "if", "b", "==", "nil", "||", "b", ".", "LayoutType", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "b", ".", "LayoutType", "\n", "}" ]
3,224
all-3225
[ "PSCAddBalanceERC20", "calls", "addBalanceERC20", "of", "Privatix", "service", "contract", "." ]
[ "func", "(", "b", "*", "backendInstance", ")", "PSCAddBalanceERC20", "(", "opts", "*", "bind", ".", "TransactOpts", ",", "amount", "uint64", ")", "(", "*", "types", ".", "Transaction", ",", "error", ")", "{", "ctx2", ",", "cancel", ":=", "b", ".", "addTimeout", "(", "opts", ".", "Context", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "opts", ".", "<mask>", "=", "ctx2", "\n\n", "tx", ",", "err", ":=", "b", ".", "psc", ".", "AddBalanceERC20", "(", "opts", ",", "amount", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "tx", ",", "nil", "\n", "}" ]
3,225
all-3226
[ "CacheFasthttpFunc", "accepts", "two", "parameters", "first", "is", "the", "fasthttp", ".", "RequestHandler", "which", "you", "want", "to", "cache", "its", "result", "the", "second", "is", "optional", "the", "cache", "Entry", "s", "expiration", "duration", "if", "the", "expiration", "<", "=", "2", "seconds", "then", "expiration", "is", "taken", "by", "the", "cache", "-", "control", "s", "maxage", "header", "returns", "a", "fasthttp", ".", "RequestHandler", "which", "you", "can", "use", "as", "your", "default", "router", "or", "per", "-", "route", "handler", "All", "type", "of", "responses", "are", "cached", "templates", "json", "text", "anything", ".", "You", "CAN", "NOT", "add", "validators", "with", "this", "function" ]
[ "func", "CacheFasthttpFunc", "(", "bodyHandler", "fasthttp", ".", "RequestHandler", ",", "expiration", "<mask>", ".", "Duration", ")", "fasthttp", ".", "RequestHandler", "{", "return", "CacheFasthttp", "(", "bodyHandler", ",", "expiration", ")", ".", "ServeHTTP", "\n", "}" ]
3,226
all-3227
[ "ValidEnum", "validates", "a", "proposed", "value", "for", "this", "enum", ".", "Implements", "the", "Enum", "interface", "for", "CryptoKeyType" ]
[ "func", "(", "e", "CryptoKeyType", ")", "ValidEnum", "(", "v", "int32", ")", "bool", "{", "_", ",", "ok", ":=", "cryptoKeyTypeMap", "[", "v", "]", "\n", "return", "<mask>", "\n", "}" ]
3,227
all-3228
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "ProfileSnapshotParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoLayertree8", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
3,228
all-3229
[ "findConflict", "finds", "the", "index", "of", "the", "conflict", ".", "It", "returns", "the", "first", "pair", "of", "conflicting", "entries", "between", "the", "existing", "entries", "and", "the", "given", "entries", "if", "there", "are", "any", ".", "If", "there", "is", "no", "conflicting", "entries", "and", "the", "existing", "entries", "contains", "all", "the", "given", "entries", "zero", "will", "be", "returned", ".", "If", "there", "is", "no", "conflicting", "entries", "but", "the", "given", "entries", "contains", "new", "entries", "the", "index", "of", "the", "first", "new", "entry", "will", "be", "returned", ".", "An", "entry", "is", "considered", "to", "be", "conflicting", "if", "it", "has", "the", "same", "index", "but", "a", "different", "term", ".", "The", "first", "entry", "MUST", "have", "an", "index", "equal", "to", "the", "argument", "from", ".", "The", "index", "of", "the", "given", "entries", "MUST", "be", "continuously", "increasing", "." ]
[ "func", "(", "l", "*", "raftLog", ")", "findConflict", "(", "ents", "[", "]", "pb", ".", "Entry", ")", "uint64", "{", "for", "_", ",", "ne", ":=", "range", "ents", "{", "if", "!", "l", ".", "matchTerm", "(", "ne", ".", "<mask>", ",", "ne", ".", "Term", ")", "{", "if", "ne", ".", "Index", "<=", "l", ".", "lastIndex", "(", ")", "{", "l", ".", "logger", ".", "Infof", "(", "\"", "\"", ",", "ne", ".", "Index", ",", "l", ".", "zeroTermOnErrCompacted", "(", "l", ".", "term", "(", "ne", ".", "Index", ")", ")", ",", "ne", ".", "Term", ")", "\n", "}", "\n", "return", "ne", ".", "Index", "\n", "}", "\n", "}", "\n", "return", "0", "\n", "}" ]
3,229
all-3230
[ "AddSystem", "adds", "the", "given", "System", "to", "the", "World", "sorted", "by", "priority", "." ]
[ "func", "(", "w", "*", "World", ")", "AddSystem", "(", "system", "System", ")", "{", "if", "initializer", ",", "ok", ":=", "system", ".", "(", "Initializer", ")", ";", "ok", "{", "initializer", ".", "New", "(", "w", ")", "\n", "}", "\n\n", "w", ".", "systems", "=", "<mask>", "(", "w", ".", "systems", ",", "system", ")", "\n", "sort", ".", "Sort", "(", "w", ".", "systems", ")", "\n", "}" ]
3,230
all-3231
[ "HTTPCompressHandlerFunc", "wraps", "a", "http", ".", "HandlerFunc", "so", "that", "the", "response", "gets", "gzip", "or", "deflate", "compressed", "if", "the", "Accept", "-", "Encoding", "header", "of", "the", "request", "allows", "it", "." ]
[ "func", "HTTPCompressHandlerFunc", "(", "handlerFunc", "http", ".", "HandlerFunc", ")", "http", ".", "HandlerFunc", "{", "return", "func", "(", "response", "<mask>", ".", "ResponseWriter", ",", "request", "*", "http", ".", "Request", ")", "{", "NewHTTPCompressHandlerFromFunc", "(", "handlerFunc", ")", ".", "ServeHTTP", "(", "response", ",", "request", ")", "\n", "}", "\n", "}" ]
3,231
all-3232
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "GPUDevice", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoSysteminfo6", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "<mask>", "(", ")", "\n", "}" ]
3,232
all-3233
[ "Set", "parses", "a", "command", "line", "set", "of", "URLs", "formatted", "like", ":", "http", ":", "//", "127", ".", "0", ".", "0", ".", "1", ":", "2380", "http", ":", "//", "10", ".", "1", ".", "1", ".", "2", ":", "80", "Implements", "flag", ".", "Value", "interface", "." ]
[ "func", "(", "us", "*", "UniqueURLs", ")", "<mask>", "(", "s", "string", ")", "error", "{", "if", "_", ",", "ok", ":=", "us", ".", "Values", "[", "s", "]", ";", "ok", "{", "return", "nil", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "us", ".", "Allowed", "[", "s", "]", ";", "ok", "{", "us", ".", "Values", "[", "s", "]", "=", "struct", "{", "}", "{", "}", "\n", "return", "nil", "\n", "}", "\n", "ss", ",", "err", ":=", "types", ".", "NewURLs", "(", "strings", ".", "Split", "(", "s", ",", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "us", ".", "Values", "=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n", "us", ".", "uss", "=", "make", "(", "[", "]", "url", ".", "URL", ",", "0", ")", "\n", "for", "_", ",", "v", ":=", "range", "ss", "{", "us", ".", "Values", "[", "v", ".", "String", "(", ")", "]", "=", "struct", "{", "}", "{", "}", "\n", "us", ".", "uss", "=", "append", "(", "us", ".", "uss", ",", "v", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
3,233
all-3234
[ "splitDevAddr", "splits", "an", "device", "addres", "into", "its", "inparticular", "parts", "and", "asserts", "that", "we", "have", "all", "the", "correct", "data", "." ]
[ "func", "splitDevAddr", "(", "id", "string", ")", "(", "string", ",", "int", ",", "int", ",", "error", ")", "{", "parts", ":=", "strings", ".", "Split", "(", "id", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", "<", "3", "{", "return", "\"", "\"", ",", "0", ",", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "id", ")", "\n", "}", "\n", "ct", ",", "cbs", ",", "dus", ":=", "parts", "[", "0", "]", ",", "parts", "[", "1", "]", ",", "<mask>", "[", "2", "]", "\n", "cb", ",", "cbe", ":=", "strconv", ".", "Atoi", "(", "cbs", ")", "\n", "du", ",", "due", ":=", "strconv", ".", "Atoi", "(", "dus", ")", "\n", "var", "found", "bool", "\n", "for", "_", ",", "v", ":=", "range", "subresourceIDControllerTypeAllowedValues", "{", "if", "v", "==", "ct", "{", "found", "=", "true", "\n", "}", "\n", "}", "\n", "if", "!", "found", "{", "return", "ct", ",", "cb", ",", "du", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ct", ")", "\n", "}", "\n", "if", "cbe", "!=", "nil", "{", "return", "ct", ",", "cb", ",", "du", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "cbs", ")", "\n", "}", "\n", "if", "due", "!=", "nil", "{", "return", "ct", ",", "cb", ",", "du", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "dus", ")", "\n", "}", "\n", "return", "ct", ",", "cb", ",", "du", ",", "nil", "\n", "}" ]
3,234
all-3235
[ "TaskByArn", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockTaskEngineState", ")", "TaskByArn", "(", "arg0", "string", ")", "(", "*", "task", ".", "Task", ",", "bool", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "task", ".", "Task", ")", "\n", "ret1", ",", "_", ":=", "<mask>", "[", "1", "]", ".", "(", "bool", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
3,235
all-3236
[ "saveTenantID", "performs", "an", "atomic", "write", "to", "the", "path", "with", "given", "tenantID", "contents", "." ]
[ "func", "saveTenantID", "(", "path", "string", ",", "tenantID", "string", ")", "error", "{", "var", "perm", "os", ".", "FileMode", "=", "0600", "\n\n", "dir", ":=", "filepath", ".", "Dir", "(", "path", ")", "\n", "if", "err", ":=", "os", ".", "MkdirAll", "(", "dir", ",", "os", ".", "ModePerm", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "dir", ",", "err", ")", "\n", "}", "\n\n", "f", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "dir", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "defer", "f", ".", "Close", "(", ")", "\n\n", "fp", ":=", "f", ".", "<mask>", "(", ")", "\n", "if", "_", ",", "err", ":=", "f", ".", "Write", "(", "[", "]", "byte", "(", "tenantID", ")", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "f", ".", "Close", "(", ")", "\n\n", "// atomic move by rename", "if", "err", ":=", "os", ".", "Rename", "(", "fp", ",", "path", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "fp", ",", "path", ",", "err", ")", "\n", "}", "\n", "if", "err", ":=", "os", ".", "Chmod", "(", "path", ",", "perm", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "path", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
3,236
all-3237
[ "CompressBlockHC", "compresses", "the", "source", "buffer", "src", "into", "the", "destination", "dst", "with", "max", "search", "depth", "(", "use", "0", "or", "negative", "value", "for", "no", "max", ")", ".", "CompressBlockHC", "compression", "ratio", "is", "better", "than", "CompressBlock", "but", "it", "is", "also", "slower", ".", "The", "size", "of", "the", "compressed", "data", "is", "returned", ".", "If", "it", "is", "0", "and", "no", "error", "then", "the", "data", "is", "not", "compressible", ".", "An", "error", "is", "returned", "if", "the", "destination", "buffer", "is", "too", "small", "." ]
[ "func", "CompressBlockHC", "(", "src", ",", "dst", "[", "]", "byte", ",", "depth", "int", ")", "(", "di", "int", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "recover", "(", ")", "!=", "nil", "{", "err", "=", "ErrInvalidSourceShortBuffer", "\n", "}", "\n", "}", "(", ")", "\n\n", "sn", ",", "dn", ":=", "len", "(", "src", ")", "-", "mfLimit", ",", "len", "(", "dst", ")", "\n", "if", "sn", "<=", "0", "||", "dn", "==", "0", "{", "return", "0", ",", "nil", "\n", "}", "\n", "var", "si", "int", "\n\n", "// hashTable: stores the last position found for a given hash", "// chaingTable: stores previous positions for a given hash", "var", "hashTable", ",", "chainTable", "[", "winSize", "]", "int", "\n\n", "if", "depth", "<=", "0", "{", "depth", "=", "winSize", "\n", "}", "\n\n", "anchor", ":=", "si", "\n", "for", "si", "<", "sn", "{", "// Hash the next 4 bytes (sequence).", "match", ":=", "binary", ".", "LittleEndian", ".", "Uint32", "(", "src", "[", "si", ":", "]", ")", "\n", "h", ":=", "blockHash", "(", "match", ")", "\n\n", "// Follow the chain until out of window and give the longest match.", "mLen", ":=", "0", "\n", "offset", ":=", "0", "\n", "for", "next", ",", "try", ":=", "hashTable", "[", "h", "]", ",", "depth", ";", "try", ">", "0", "&&", "next", ">", "0", "&&", "si", "-", "next", "<", "winSize", ";", "next", "=", "chainTable", "[", "next", "&", "winMask", "]", "{", "// The first (mLen==0) or next byte (mLen>=minMatch) at current match length", "// must match to improve on the match length.", "if", "src", "[", "next", "+", "mLen", "]", "!=", "src", "[", "si", "+", "mLen", "]", "{", "continue", "\n", "}", "\n", "ml", ":=", "0", "\n", "// Compare the current position with a previous with the same hash.", "for", "ml", "<", "sn", "-", "si", "&&", "binary", ".", "LittleEndian", ".", "Uint64", "(", "src", "[", "next", "+", "ml", ":", "]", ")", "==", "<mask>", ".", "LittleEndian", ".", "Uint64", "(", "src", "[", "si", "+", "ml", ":", "]", ")", "{", "ml", "+=", "8", "\n", "}", "\n", "for", "ml", "<", "sn", "-", "si", "&&", "src", "[", "next", "+", "ml", "]", "==", "src", "[", "si", "+", "ml", "]", "{", "ml", "++", "\n", "}", "\n", "if", "ml", "<", "minMatch", "||", "ml", "<=", "mLen", "{", "// Match too small (<minMath) or smaller than the current match.", "continue", "\n", "}", "\n", "// Found a longer match, keep its position and length.", "mLen", "=", "ml", "\n", "offset", "=", "si", "-", "next", "\n", "// Try another previous position with the same hash.", "try", "--", "\n", "}", "\n", "chainTable", "[", "si", "&", "winMask", "]", "=", "hashTable", "[", "h", "]", "\n", "hashTable", "[", "h", "]", "=", "si", "\n\n", "// No match found.", "if", "mLen", "==", "0", "{", "si", "++", "\n", "continue", "\n", "}", "\n\n", "// Match found.", "// Update hash/chain tables with overlapping bytes:", "// si already hashed, add everything from si+1 up to the match length.", "winStart", ":=", "si", "+", "1", "\n", "if", "ws", ":=", "si", "+", "mLen", "-", "winSize", ";", "ws", ">", "winStart", "{", "winStart", "=", "ws", "\n", "}", "\n", "for", "si", ",", "ml", ":=", "winStart", ",", "si", "+", "mLen", ";", "si", "<", "ml", ";", "{", "match", ">>=", "8", "\n", "match", "|=", "uint32", "(", "src", "[", "si", "+", "3", "]", ")", "<<", "24", "\n", "h", ":=", "blockHash", "(", "match", ")", "\n", "chainTable", "[", "si", "&", "winMask", "]", "=", "hashTable", "[", "h", "]", "\n", "hashTable", "[", "h", "]", "=", "si", "\n", "si", "++", "\n", "}", "\n\n", "lLen", ":=", "si", "-", "anchor", "\n", "si", "+=", "mLen", "\n", "mLen", "-=", "minMatch", "// Match length does not include minMatch.", "\n\n", "if", "mLen", "<", "0xF", "{", "dst", "[", "di", "]", "=", "byte", "(", "mLen", ")", "\n", "}", "else", "{", "dst", "[", "di", "]", "=", "0xF", "\n", "}", "\n\n", "// Encode literals length.", "if", "lLen", "<", "0xF", "{", "dst", "[", "di", "]", "|=", "byte", "(", "lLen", "<<", "4", ")", "\n", "}", "else", "{", "dst", "[", "di", "]", "|=", "0xF0", "\n", "di", "++", "\n", "l", ":=", "lLen", "-", "0xF", "\n", "for", ";", "l", ">=", "0xFF", ";", "l", "-=", "0xFF", "{", "dst", "[", "di", "]", "=", "0xFF", "\n", "di", "++", "\n", "}", "\n", "dst", "[", "di", "]", "=", "byte", "(", "l", ")", "\n", "}", "\n", "di", "++", "\n\n", "// Literals.", "copy", "(", "dst", "[", "di", ":", "di", "+", "lLen", "]", ",", "src", "[", "anchor", ":", "anchor", "+", "lLen", "]", ")", "\n", "di", "+=", "lLen", "\n", "anchor", "=", "si", "\n\n", "// Encode offset.", "di", "+=", "2", "\n", "dst", "[", "di", "-", "2", "]", ",", "dst", "[", "di", "-", "1", "]", "=", "byte", "(", "offset", ")", ",", "byte", "(", "offset", ">>", "8", ")", "\n\n", "// Encode match length part 2.", "if", "mLen", ">=", "0xF", "{", "for", "mLen", "-=", "0xF", ";", "mLen", ">=", "0xFF", ";", "mLen", "-=", "0xFF", "{", "dst", "[", "di", "]", "=", "0xFF", "\n", "di", "++", "\n", "}", "\n", "dst", "[", "di", "]", "=", "byte", "(", "mLen", ")", "\n", "di", "++", "\n", "}", "\n", "}", "\n\n", "if", "anchor", "==", "0", "{", "// Incompressible.", "return", "0", ",", "nil", "\n", "}", "\n\n", "// Last literals.", "lLen", ":=", "len", "(", "src", ")", "-", "anchor", "\n", "if", "lLen", "<", "0xF", "{", "dst", "[", "di", "]", "=", "byte", "(", "lLen", "<<", "4", ")", "\n", "}", "else", "{", "dst", "[", "di", "]", "=", "0xF0", "\n", "di", "++", "\n", "lLen", "-=", "0xF", "\n", "for", ";", "lLen", ">=", "0xFF", ";", "lLen", "-=", "0xFF", "{", "dst", "[", "di", "]", "=", "0xFF", "\n", "di", "++", "\n", "}", "\n", "dst", "[", "di", "]", "=", "byte", "(", "lLen", ")", "\n", "}", "\n", "di", "++", "\n\n", "// Write the last literals.", "if", "di", ">=", "anchor", "{", "// Incompressible.", "return", "0", ",", "nil", "\n", "}", "\n", "di", "+=", "copy", "(", "dst", "[", "di", ":", "di", "+", "len", "(", "src", ")", "-", "anchor", "]", ",", "src", "[", "anchor", ":", "]", ")", "\n", "return", "di", ",", "nil", "\n", "}" ]
3,237
all-3238
[ "CDDVDs", "returns", "an", "unordered", "slice", "of", "currently", "attached", "CD", "/", "DVD", "devices", "on", "any", "bus", "." ]
[ "func", "(", "v", "*", "VM", ")", "CDDVDs", "(", ")", "(", "[", "]", "*", "CDDVDDrive", ",", "error", ")", "{", "// Loads VMX file in memory", "err", ":=", "v", ".", "vmxfile", ".", "Read", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "model", ":=", "v", ".", "vmxfile", ".", "model", "\n\n", "var", "cddvds", "[", "]", "*", "CDDVDDrive", "\n", "model", ".", "WalkDevices", "(", "func", "(", "d", "vmx", ".", "Device", ")", "{", "bus", ":=", "BusTypeFromID", "(", "d", ".", "VMXID", ")", "\n\n", "if", "d", ".", "Type", "==", "vmx", ".", "CDROM_IMAGE", "||", "d", ".", "Type", "==", "vmx", ".", "CDROM_RAW", "{", "cddvds", "=", "append", "(", "cddvds", ",", "&", "CDDVDDrive", "{", "<mask>", ":", "d", ".", "VMXID", ",", "Bus", ":", "bus", ",", "Filename", ":", "d", ".", "Filename", ",", "}", ")", "\n", "}", "\n", "}", ")", "\n", "return", "cddvds", ",", "nil", "\n", "}" ]
3,238
all-3239
[ "PushLink", "sends", "a", "link", "to", "the", "specific", "device", "with", "the", "given", "title", "and", "url" ]
[ "func", "(", "d", "*", "Device", ")", "PushLink", "(", "<mask>", ",", "u", ",", "body", "string", ")", "error", "{", "return", "d", ".", "Client", ".", "PushLink", "(", "d", ".", "Iden", ",", "title", ",", "u", ",", "body", ")", "\n", "}" ]
3,239
all-3240
[ "On", "returns", "if", "tracing", "methods", "output", "is", "active", "." ]
[ "func", "On", "(", ")", "bool", "{", "tracer", ".", "mu", ".", "RLock", "(", ")", "\n", "on", ":=", "tracer", ".", "<mask>", "\n", "tracer", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "on", "\n", "}" ]
3,240
all-3241
[ "Specify", "the", "value", "of", "a", "uniform", "variable", "for", "the", "current", "program", "object" ]
[ "func", "Uniform1iv", "(", "location", "int32", ",", "<mask>", "int32", ",", "value", "*", "int32", ")", "{", "syscall", ".", "Syscall", "(", "gpUniform1iv", ",", "3", ",", "uintptr", "(", "location", ")", ",", "uintptr", "(", "count", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "value", ")", ")", ")", "\n", "}" ]
3,241
all-3242
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "RemoveAttributeParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom16", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
3,242
all-3243
[ "GetSortOk", "returns", "a", "tuple", "with", "the", "Sort", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "p", "*", "Params", ")", "GetSortOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "p", "==", "nil", "||", "p", ".", "Sort", "==", "nil", "{", "return", "\"", "\"", ",", "<mask>", "\n", "}", "\n", "return", "*", "p", ".", "Sort", ",", "true", "\n", "}" ]
3,243
all-3244
[ "DecrRef", "decrements", "the", "refcount", "and", "possibly", "deletes", "the", "table" ]
[ "func", "(", "t", "*", "Table", ")", "DecrRef", "(", ")", "error", "{", "newRef", ":=", "atomic", ".", "AddInt32", "(", "&", "t", ".", "ref", ",", "-", "1", ")", "\n", "if", "newRef", "==", "0", "{", "// We can safely delete this file, because for all the current files, we always have", "// at least one reference pointing to them.", "// It's necessary to delete windows files", "if", "t", ".", "loadingMode", "==", "<mask>", ".", "MemoryMap", "{", "y", ".", "Munmap", "(", "t", ".", "mmap", ")", "\n", "}", "\n", "if", "err", ":=", "t", ".", "fd", ".", "Truncate", "(", "0", ")", ";", "err", "!=", "nil", "{", "// This is very important to let the FS know that the file is deleted.", "return", "err", "\n", "}", "\n", "filename", ":=", "t", ".", "fd", ".", "Name", "(", ")", "\n", "if", "err", ":=", "t", ".", "fd", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "os", ".", "Remove", "(", "filename", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
3,244
all-3245
[ "TimeDurationVal", "returns", "the", "value", "of", "the", "string", "at", "the", "pointer", "or", "0", "if", "the", "pointer", "is", "nil", "." ]
[ "func", "TimeDurationVal", "(", "t", "*", "time", ".", "Duration", ")", "<mask>", ".", "Duration", "{", "if", "t", "==", "nil", "{", "return", "time", ".", "Duration", "(", "0", ")", "\n", "}", "\n", "return", "*", "t", "\n", "}" ]
3,245
all-3246
[ "GetHandleOk", "returns", "a", "tuple", "with", "the", "Handle", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "c", "*", "<mask>", ")", "GetHandleOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "c", "==", "nil", "||", "c", ".", "Handle", "==", "nil", "{", "return", "\"", "\"", ",", "false", "\n", "}", "\n", "return", "*", "c", ".", "Handle", ",", "true", "\n", "}" ]
3,246
all-3247
[ "GetValue", "()", "is", "a", "wrapper", "around", "gtk_spin_button_get_value", "()", "." ]
[ "func", "(", "v", "*", "SpinButton", ")", "GetValue", "(", ")", "float64", "{", "c", ":=", "C", ".", "gtk_spin_button_get_value", "(", "v", ".", "native", "(", ")", ")", "\n", "<mask>", "float64", "(", "c", ")", "\n", "}" ]
3,247
all-3248
[ "Get", "blocks", "for", "an", "available", "connection", "." ]
[ "func", "(", "p", "*", "blockingPool", ")", "Get", "(", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "//in case that pool is closed or pool.conns is set to nil", "conns", ":=", "p", ".", "conns", "\n", "if", "conns", "==", "nil", "{", "return", "nil", ",", "ErrClosed", "\n", "}", "\n\n", "select", "{", "case", "conn", ":=", "<-", "conns", ":", "if", "time", ".", "Since", "(", "conn", ".", "start", ")", ">", "p", ".", "livetime", "{", "if", "conn", ".", "Conn", "!=", "nil", "{", "conn", ".", "Conn", ".", "Close", "(", ")", "\n", "conn", ".", "Conn", "=", "nil", "\n", "}", "\n", "}", "\n", "if", "conn", ".", "Conn", "==", "nil", "{", "var", "err", "error", "\n", "conn", ".", "Conn", ",", "err", "=", "p", ".", "factory", "(", ")", "\n", "if", "err", "!=", "nil", "{", "conn", ".", "start", "=", "time", ".", "Now", "(", ")", "\n", "p", ".", "<mask>", "(", "conn", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "conn", ".", "unusable", "=", "false", "\n", "return", "conn", ",", "nil", "\n", "case", "<-", "time", ".", "After", "(", "time", ".", "Second", "*", "p", ".", "timeout", ")", ":", "return", "nil", ",", "ErrTimeout", "\n", "}", "\n", "}" ]
3,248
all-3249
[ "GValue", "converts", "a", "Go", "type", "to", "a", "comparable", "GValue", ".", "GValue", "()", "returns", "a", "non", "-", "nil", "error", "if", "the", "conversion", "was", "unsuccessful", "." ]
[ "func", "GValue", "(", "v", "<mask>", "{", "}", ")", "(", "gvalue", "*", "Value", ",", "err", "error", ")", "{", "if", "v", "==", "nil", "{", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_POINTER", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetPointer", "(", "uintptr", "(", "unsafe", ".", "Pointer", "(", "nil", ")", ")", ")", "\n", "return", "val", ",", "nil", "\n", "}", "\n\n", "switch", "e", ":=", "v", ".", "(", "type", ")", "{", "case", "bool", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_BOOLEAN", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetBool", "(", "e", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "int8", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_CHAR", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetSChar", "(", "e", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "int64", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_INT64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetInt64", "(", "e", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "int", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_INT", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetInt", "(", "e", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "uint8", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_UCHAR", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetUChar", "(", "e", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "uint64", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_UINT64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetUInt64", "(", "e", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "uint", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_UINT", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetUInt", "(", "e", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "float32", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_FLOAT", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetFloat", "(", "e", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "float64", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_DOUBLE", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetDouble", "(", "e", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "string", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_STRING", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetString", "(", "e", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "*", "Object", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_OBJECT", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetInstance", "(", "uintptr", "(", "unsafe", ".", "Pointer", "(", "e", ".", "GObject", ")", ")", ")", "\n", "return", "val", ",", "nil", "\n\n", "default", ":", "/* Try this since above doesn't catch constants under other types */", "rval", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "switch", "rval", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Int8", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_CHAR", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetSChar", "(", "int8", "(", "rval", ".", "Int", "(", ")", ")", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "reflect", ".", "Int16", ":", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n\n", "case", "reflect", ".", "Int32", ":", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n\n", "case", "reflect", ".", "Int64", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_INT64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetInt64", "(", "rval", ".", "Int", "(", ")", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "reflect", ".", "Int", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_INT", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetInt", "(", "int", "(", "rval", ".", "Int", "(", ")", ")", ")", "\n", "return", "val", ",", "nil", "\n\n", "case", "reflect", ".", "Uintptr", ",", "reflect", ".", "Ptr", ":", "val", ",", "err", ":=", "ValueInit", "(", "TYPE_POINTER", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetPointer", "(", "rval", ".", "Pointer", "(", ")", ")", "\n", "return", "val", ",", "nil", "\n", "}", "\n", "}", "\n\n", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
3,249
all-3250
[ "export", "FileSequence_SetDirname" ]
[ "func", "FileSequence_SetDirname", "(", "id", "FileSeqId", ",", "dir", "*", "C", ".", "char", ")", "{", "if", "fs", ",", "ok", ":=", "sFileSeqs", ".", "Get", "(", "id", ")", ";", "<mask>", "{", "str", ":=", "C", ".", "GoString", "(", "dir", ")", "\n", "fs", ".", "SetDirname", "(", "str", ")", "\n", "}", "\n", "}" ]
3,250
all-3251
[ "CIDRValue", "returns", "the", "value", "of", "the", "CIDR", "pointer", "passed", "in", "or", "the", "default", "value", "if", "the", "pointer", "is", "nil", "." ]
[ "func", "CIDRValue", "(", "v", "*", "strfmt", ".", "CIDR", ")", "strfmt", ".", "CIDR", "{", "if", "v", "==", "nil", "{", "<mask>", "strfmt", ".", "CIDR", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "*", "v", "\n", "}" ]
3,251
all-3252
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "GetFileInfoReturns", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom44", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
3,252
all-3253
[ "ScheduleForcedHostSvcChecks", "creates", "a", "new", "SCHEDULE_FORCED_HOST_SVC_CHECKS", "Nagios", "command", ".", "Schedules", "a", "forced", "active", "check", "of", "all", "services", "associated", "with", "a", "particular", "host", "at", "check_time", ".", "The", "check_time", "argument", "is", "specified", "in", "time_t", "format", "(", "seconds", "since", "the", "UNIX", "epoch", ")", ".", "Forced", "checks", "are", "performed", "regardless", "of", "what", "time", "it", "is", "(", "e", ".", "g", ".", "timeperiod", "restrictions", "are", "ignored", ")", "and", "whether", "or", "not", "active", "checks", "are", "enabled", "on", "a", "service", "-", "specific", "or", "program", "-", "wide", "basis", "." ]
[ "func", "ScheduleForcedHostSvcChecks", "(", "host_name", "string", ",", "check_time", "<mask>", ".", "Time", ",", ")", "*", "livestatus", ".", "Command", "{", "return", "livestatus", ".", "NewCommand", "(", "\"", "\"", ",", "stringifyArg", "(", "\"", "\"", ",", "\"", "\"", ",", "host_name", ")", ",", "stringifyArg", "(", "\"", "\"", ",", "\"", "\"", ",", "check_time", ")", ",", ")", "\n", "}" ]
3,253
all-3254
[ "Private", "stuff", ".", "load", "loads", "a", "source", "file", "and", "parses", "the", "AST", "tree", ".", "Failures", "are", "ignored", "." ]
[ "func", "(", "c", "*", "cache", ")", "load", "(", "fileName", "string", ")", "{", "if", "_", ",", "ok", ":=", "c", ".", "parsed", "[", "fileName", "]", ";", "ok", "{", "return", "\n", "}", "\n", "c", ".", "parsed", "[", "fileName", "]", "=", "nil", "\n", "if", "!", "strings", ".", "HasSuffix", "(", "fileName", ",", "\"", "\"", ")", "{", "// Ignore C and assembly.", "c", ".", "files", "[", "fileName", "]", "=", "nil", "\n", "return", "\n", "}", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "fileName", ")", "\n", "if", "_", ",", "ok", ":=", "c", ".", "files", "[", "fileName", "]", ";", "!", "<mask>", "{", "var", "err", "error", "\n", "if", "c", ".", "files", "[", "fileName", "]", ",", "err", "=", "ioutil", ".", "ReadFile", "(", "fileName", ")", ";", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "fileName", ",", "err", ")", "\n", "c", ".", "files", "[", "fileName", "]", "=", "nil", "\n", "return", "\n", "}", "\n", "}", "\n", "fset", ":=", "token", ".", "NewFileSet", "(", ")", "\n", "src", ":=", "c", ".", "files", "[", "fileName", "]", "\n", "parsed", ",", "err", ":=", "parser", ".", "ParseFile", "(", "fset", ",", "fileName", ",", "src", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "fileName", ",", "err", ")", "\n", "return", "\n", "}", "\n", "// Convert the line number into raw file offset.", "offsets", ":=", "[", "]", "int", "{", "0", ",", "0", "}", "\n", "start", ":=", "0", "\n", "for", "l", ":=", "1", ";", "start", "<", "len", "(", "src", ")", ";", "l", "++", "{", "start", "+=", "bytes", ".", "IndexByte", "(", "src", "[", "start", ":", "]", ",", "'\\n'", ")", "+", "1", "\n", "offsets", "=", "append", "(", "offsets", ",", "start", ")", "\n", "}", "\n", "c", ".", "parsed", "[", "fileName", "]", "=", "&", "parsedFile", "{", "offsets", ",", "parsed", "}", "\n", "}" ]
3,254
all-3255
[ "RunCommand", "runs", "cmd", "on", "file" ]
[ "func", "RunCommand", "(", "ctx", "context", ".", "Context", ",", "cmd", "string", ",", "args", "...", "string", ")", "(", "string", ",", "error", ")", "{", "var", "c", "*", "exec", ".", "Cmd", "\n\n", "if", "ctx", "!=", "nil", "{", "c", "=", "<mask>", ".", "CommandContext", "(", "ctx", ",", "cmd", ",", "args", "...", ")", "\n", "}", "else", "{", "c", "=", "exec", ".", "Command", "(", "cmd", ",", "args", "...", ")", "\n", "}", "\n\n", "output", ",", "err", ":=", "c", ".", "Output", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "string", "(", "output", ")", ",", "err", "\n", "}", "\n\n", "// check for exec context timeout", "if", "ctx", "!=", "nil", "{", "if", "ctx", ".", "Err", "(", ")", "==", "context", ".", "DeadlineExceeded", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "cmd", ")", "\n", "}", "\n", "}", "\n\n", "return", "string", "(", "output", ")", ",", "nil", "\n", "}" ]
3,255
all-3256
[ "AmazonBucket", "returns", "everything", "up", "to", "the", "last", ".", "in", "subdomain", ".", "It", "is", "designed", "to", "be", "used", "with", "the", "Amazon", "service", ".", "johnsmith", ".", "s3", "becomes", "johnsmith", "johnsmith", ".", "s3", "-", "eu", "-", "west", "-", "1", "becomes", "johnsmith", "www", ".", "example", ".", "com", ".", "s3", "becomes", "www", ".", "example", ".", "com" ]
[ "func", "AmazonBucket", "(", "subdomain", "string", ")", "string", "{", "if", "i", ":=", "strings", ".", "LastIndex", "(", "subdomain", ",", "\"", "\"", ")", ";", "i", "!=", "-", "1", "{", "<mask>", "subdomain", "[", ":", "i", "]", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
3,256
all-3257
[ "Get", "returns", "the", "public", "information", "about", "one", "key", "." ]
[ "func", "(", "kb", "dbKeybase", ")", "Get", "(", "name", "string", ")", "(", "Info", ",", "error", ")", "{", "bs", ":=", "kb", ".", "<mask>", ".", "Get", "(", "infoKey", "(", "name", ")", ")", "\n", "return", "readInfo", "(", "bs", ")", "\n", "}" ]
3,257
all-3258
[ "HTTPClient", "is", "a", "functional", "parameter", "that", "sets", "the", "internal", "HTTPClient", "of", "the", "roundtrip", "client", "wrapper" ]
[ "func", "HTTPClient", "(", "h", "*", "http", ".", "Client", ")", "ClientParam", "{", "return", "func", "(", "c", "*", "<mask>", ")", "error", "{", "c", ".", "client", "=", "h", "\n", "return", "nil", "\n", "}", "\n", "}" ]
3,258
all-3259
[ "ReadableN", "reports", "whether", "the", "n", "bytes", "starting", "at", "address", "a", "are", "readable", "." ]
[ "func", "(", "p", "*", "Process", ")", "ReadableN", "(", "a", "Address", ",", "n", "int64", ")", "bool", "{", "for", "{", "m", ":=", "p", ".", "findMapping", "(", "a", ")", "\n", "if", "m", "==", "nil", "||", "m", ".", "perm", "&", "Read", "==", "0", "{", "return", "false", "\n", "}", "\n", "c", ":=", "m", ".", "<mask>", ".", "Sub", "(", "a", ")", "\n", "if", "n", "<=", "c", "{", "return", "true", "\n", "}", "\n", "n", "-=", "c", "\n", "a", "=", "a", ".", "Add", "(", "c", ")", "\n", "}", "\n", "}" ]
3,259
all-3260
[ "GetTitleOk", "returns", "a", "tuple", "with", "the", "Title", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "e", "*", "EventStreamDefinition", ")", "GetTitleOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "e", "==", "nil", "||", "e", ".", "Title", "==", "nil", "{", "return", "\"", "\"", ",", "<mask>", "\n", "}", "\n", "return", "*", "e", ".", "Title", ",", "true", "\n", "}" ]
3,260
all-3261
[ "Execute", "adds", "all", "child", "commands", "to", "the", "root", "command", "sets", "flags", "appropriately", ".", "This", "is", "called", "by", "main", ".", "main", "()", ".", "It", "only", "needs", "to", "happen", "once", "to", "the", "rootCmd", "." ]
[ "func", "Execute", "(", ")", "{", "if", "err", ":=", "RootCmd", ".", "Execute", "(", ")", ";", "err", "!=", "nil", "{", "if", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "dbNotFound", ")", "||", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "popNotFound", ")", "{", "logrus", ".", "Errorf", "(", "popInstallInstructions", ")", "\n", "<mask>", ".", "Exit", "(", "-", "1", ")", "\n", "}", "\n", "logrus", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "if", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "dbNotFound", ")", "||", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "popNotFound", ")", "{", "fmt", ".", "Println", "(", "popInstallInstructions", ")", "\n", "os", ".", "Exit", "(", "-", "1", ")", "\n", "}", "\n", "os", ".", "Exit", "(", "-", "1", ")", "\n", "}", "\n", "}" ]
3,261
all-3262
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "EventLoadEventFired", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage54", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "<mask>", "(", ")", "\n", "}" ]
3,262
all-3263
[ "IsIPv4", "checks", "if", "this", "is", "a", "valid", "IPv4" ]
[ "func", "IsIPv4", "(", "s", "string", ")", "bool", "{", "<mask>", ":=", "net", ".", "ParseIP", "(", "s", ")", "\n", "return", "ip", "!=", "nil", "\n", "}" ]
3,263
all-3264
[ "Properties", "returns", "the", "ResourcePool", "managed", "object", "from", "its", "higher", "-", "level", "object", "." ]
[ "func", "Properties", "(", "obj", "*", "object", ".", "ResourcePool", ")", "(", "*", "mo", ".", "ResourcePool", ",", "error", ")", "{", "ctx", ",", "cancel", ":=", "<mask>", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "provider", ".", "DefaultAPITimeout", ")", "\n", "defer", "cancel", "(", ")", "\n", "var", "props", "mo", ".", "ResourcePool", "\n", "if", "err", ":=", "obj", ".", "Properties", "(", "ctx", ",", "obj", ".", "Reference", "(", ")", ",", "nil", ",", "&", "props", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "props", ",", "nil", "\n", "}" ]
3,264
all-3265
[ "StartListening", "starts", "reading", "from", "the", "input", "channel", "and", "writes", "to", "the", "buffer", "When", "context", "is", "cancelled", "stop", "listening" ]
[ "func", "(", "buffer", "*", "InfiniteBuffer", ")", "StartListening", "(", "ctx", "context", ".", "Context", ",", "eventChan", "<-", "chan", "events", ".", "Message", ")", "{", "for", "{", "<mask>", "{", "// If context is cancelled, drain remaining events and return", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "for", "len", "(", "eventChan", ")", ">", "0", "{", "event", ":=", "<-", "eventChan", "\n", "go", "buffer", ".", "CopyEvents", "(", "&", "event", ")", "\n", "}", "\n", "return", "\n", "case", "event", ":=", "<-", "eventChan", ":", "go", "buffer", ".", "CopyEvents", "(", "&", "event", ")", "\n", "}", "\n", "}", "\n", "}" ]
3,265
all-3266
[ "protect", "protects", "branches", "specified", "in", "the", "presubmit", "and", "branch", "-", "protection", "config", "sections", "." ]
[ "func", "(", "p", "*", "protector", ")", "protect", "(", ")", "{", "bp", ":=", "p", ".", "cfg", ".", "BranchProtection", "\n\n", "// Scan the branch-protection configuration", "for", "orgName", ":=", "range", "bp", ".", "Orgs", "{", "org", ":=", "bp", ".", "GetOrg", "(", "orgName", ")", "\n", "if", "err", ":=", "p", ".", "UpdateOrg", "(", "orgName", ",", "*", "org", ")", ";", "err", "!=", "nil", "{", "p", ".", "<mask>", ".", "add", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "orgName", ",", "err", ")", ")", "\n", "}", "\n", "}", "\n\n", "// Do not automatically protect tested repositories", "if", "!", "bp", ".", "ProtectTested", "{", "return", "\n", "}", "\n\n", "// Some repos with presubmits might not be listed in the branch-protection", "for", "repo", ":=", "range", "p", ".", "cfg", ".", "Presubmits", "{", "if", "p", ".", "completedRepos", "[", "repo", "]", "==", "true", "{", "continue", "\n", "}", "\n", "parts", ":=", "strings", ".", "Split", "(", "repo", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", "!=", "2", "{", "// TODO(fejta): use a strong type here instead", "p", ".", "errors", ".", "add", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "repo", ")", ")", "\n", "continue", "\n", "}", "\n", "orgName", ":=", "parts", "[", "0", "]", "\n", "repoName", ":=", "parts", "[", "1", "]", "\n", "repo", ":=", "bp", ".", "GetOrg", "(", "orgName", ")", ".", "GetRepo", "(", "repoName", ")", "\n", "if", "err", ":=", "p", ".", "UpdateRepo", "(", "orgName", ",", "repoName", ",", "*", "repo", ")", ";", "err", "!=", "nil", "{", "p", ".", "errors", ".", "add", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "orgName", ",", "repoName", ",", "err", ")", ")", "\n", "}", "\n", "}", "\n", "}" ]
3,266
all-3267
[ "WriteGunzip", "writes", "ungzipped", "p", "to", "w", "and", "returns", "the", "number", "of", "uncompressed", "bytes", "written", "to", "w", "." ]
[ "func", "WriteGunzip", "(", "w", "<mask>", ".", "Writer", ",", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "r", ":=", "&", "byteSliceReader", "{", "p", "}", "\n", "zr", ",", "err", ":=", "acquireGzipReader", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "n", ",", "err", ":=", "copyZeroAlloc", "(", "w", ",", "zr", ")", "\n", "releaseGzipReader", "(", "zr", ")", "\n", "nn", ":=", "int", "(", "n", ")", "\n", "if", "int64", "(", "nn", ")", "!=", "n", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "n", ")", "\n", "}", "\n", "return", "nn", ",", "err", "\n", "}" ]
3,267
all-3268
[ "newAction", "creates", "and", "returns", "an", "action", "." ]
[ "func", "newAction", "(", "ln", "*", "line", ",", "rslt", "*", "result", ",", "src", "*", "<mask>", ",", "parent", "element", ",", "opts", "*", "Options", ")", "*", "action", "{", "return", "&", "action", "{", "elementBase", ":", "newElementBase", "(", "ln", ",", "rslt", ",", "src", ",", "parent", ",", "opts", ")", ",", "}", "\n", "}" ]
3,268
all-3269
[ "readRequest", "extracts", "the", "request", "from", "the", "AdmissionReview", "reader" ]
[ "func", "readRequest", "(", "r", "<mask>", ".", "Reader", ",", "contentType", "string", ")", "(", "*", "admissionapi", ".", "AdmissionRequest", ",", "error", ")", "{", "if", "contentType", "!=", "contentTypeJSON", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "contentType", ",", "contentTypeJSON", ")", "\n", "}", "\n\n", "// Can we read the body?", "if", "r", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "body", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "// Can we convert the body into an AdmissionReview?", "var", "ar", "admissionapi", ".", "AdmissionReview", "\n", "deserializer", ":=", "codecs", ".", "UniversalDeserializer", "(", ")", "\n", "if", "_", ",", "_", ",", "err", ":=", "deserializer", ".", "Decode", "(", "body", ",", "nil", ",", "&", "ar", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "ar", ".", "Request", ",", "nil", "\n", "}" ]
3,269
all-3270
[ "OwnerHas", "reports", "whether", "the", "owner", "has", "all", "given", "permissions", "." ]
[ "func", "(", "i", "*", "info", ")", "OwnerHas", "(", "p", "...", "perm", ")", "bool", "{", "mode", ":=", "i", ".", "fi", ".", "Mode", "(", ")", "\n\n", "for", "_", ",", "v", ":=", "range", "p", "{", "<mask>", "v", "{", "case", "R", ":", "if", "mode", "&", "modeROwner", "==", "0", "{", "return", "false", "\n", "}", "\n", "case", "W", ":", "if", "mode", "&", "modeWOwner", "==", "0", "{", "return", "false", "\n", "}", "\n", "case", "X", ":", "if", "mode", "&", "modeXOwner", "==", "0", "{", "return", "false", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
3,270
all-3271
[ "Index", "returns", "the", "i", "th", "element", "in", "the", "array", "v", ".", "If", "v", ".", "Kind", "()", "!", "=", "Array", "or", "if", "i", "is", "outside", "the", "array", "bounds", "Index", "returns", "a", "null", "Value", "." ]
[ "func", "(", "v", "Value", ")", "Index", "(", "i", "int", ")", "Value", "{", "x", ",", "ok", ":=", "v", ".", "data", ".", "(", "array", ")", "\n", "if", "!", "<mask>", "||", "i", "<", "0", "||", "i", ">=", "len", "(", "x", ")", "{", "return", "Value", "{", "}", "\n", "}", "\n", "return", "v", ".", "r", ".", "resolve", "(", "v", ".", "ptr", ",", "x", "[", "i", "]", ")", "\n", "}" ]
3,271
all-3272
[ "filterHeaders", "iterates", "through", "the", "headers", "skipping", "hidden", "headers", "unless", "DumpFormat", "is", "Verbose", ".", "It", "calls", "the", "given", "iterator", "for", "each", "header", "name", "/", "value", "pair", ".", "The", "values", "are", "serialized", "as", "strings", "." ]
[ "func", "filterHeaders", "(", "dumpFormat", "Format", ",", "hiddenHeaders", "<mask>", "[", "string", "]", "bool", ",", "headers", "http", ".", "Header", ",", "iterator", "headerIterator", ")", "{", "for", "k", ",", "v", ":=", "range", "headers", "{", "if", "!", "dumpFormat", ".", "IsVerbose", "(", ")", "{", "if", "_", ",", "ok", ":=", "hiddenHeaders", "[", "k", "]", ";", "ok", "{", "continue", "\n", "}", "\n", "}", "\n", "iterator", "(", "k", ",", "v", ")", "\n", "}", "\n", "}" ]
3,272
all-3273
[ "/", "*", "BuildIn", "is", "identical", "to", "Build", "but", "allows", "you", "to", "specify", "a", "custom", "$GOPATH", "(", "the", "first", "argument", ")", "." ]
[ "func", "BuildIn", "(", "gopath", "string", ",", "packagePath", "<mask>", ",", "args", "...", "string", ")", "(", "compiledPath", "string", ",", "err", "error", ")", "{", "return", "doBuild", "(", "gopath", ",", "packagePath", ",", "nil", ",", "args", "...", ")", "\n", "}" ]
3,273
all-3274
[ "send", "filters", "out", "repeated", "events", "by", "discarding", "revisions", "older", "than", "the", "last", "one", "sent", "over", "the", "watch", "channel", "." ]
[ "func", "(", "w", "*", "watcher", ")", "send", "(", "wr", "clientv3", ".", "WatchResponse", ")", "{", "if", "wr", ".", "IsProgressNotify", "(", ")", "&&", "!", "w", ".", "progress", "{", "return", "\n", "}", "\n", "if", "w", ".", "nextrev", ">", "wr", ".", "Header", ".", "Revision", "&&", "len", "(", "wr", ".", "Events", ")", ">", "0", "{", "return", "\n", "}", "\n", "if", "w", ".", "nextrev", "==", "0", "{", "// current watch; expect updates following this revision", "w", ".", "nextrev", "=", "wr", ".", "Header", ".", "Revision", "+", "1", "\n", "}", "\n\n", "events", ":=", "make", "(", "[", "]", "*", "mvccpb", ".", "Event", ",", "0", ",", "len", "(", "wr", ".", "Events", ")", ")", "\n\n", "var", "lastRev", "int64", "\n", "for", "i", ":=", "range", "wr", ".", "Events", "{", "ev", ":=", "(", "*", "mvccpb", ".", "Event", ")", "(", "wr", ".", "Events", "[", "i", "]", ")", "\n", "if", "ev", ".", "Kv", ".", "ModRevision", "<", "w", ".", "nextrev", "{", "continue", "\n", "}", "else", "{", "// We cannot update w.rev here.", "// txn can have multiple events with the same rev.", "// If w.nextrev updates here, it would skip events in the same txn.", "lastRev", "=", "ev", ".", "Kv", ".", "ModRevision", "\n", "}", "\n\n", "filtered", ":=", "false", "\n", "for", "_", ",", "filter", ":=", "range", "w", ".", "filters", "{", "if", "filter", "(", "*", "ev", ")", "{", "filtered", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "filtered", "{", "continue", "\n", "}", "\n\n", "if", "!", "w", ".", "prevKV", "{", "evCopy", ":=", "*", "ev", "\n", "evCopy", ".", "PrevKv", "=", "nil", "\n", "ev", "=", "&", "evCopy", "\n", "}", "\n", "events", "=", "append", "(", "events", ",", "ev", ")", "\n", "}", "\n\n", "if", "lastRev", ">=", "w", ".", "nextrev", "{", "w", ".", "nextrev", "=", "lastRev", "+", "1", "\n", "}", "\n\n", "// all events are filtered out?", "if", "!", "wr", ".", "IsProgressNotify", "(", ")", "&&", "!", "wr", ".", "Created", "&&", "len", "(", "events", ")", "==", "0", "&&", "wr", ".", "CompactRevision", "==", "0", "{", "return", "\n", "}", "\n\n", "w", ".", "lastHeader", "=", "wr", ".", "Header", "\n", "w", ".", "post", "(", "&", "pb", ".", "WatchResponse", "{", "Header", ":", "&", "wr", ".", "<mask>", ",", "Created", ":", "wr", ".", "Created", ",", "CompactRevision", ":", "wr", ".", "CompactRevision", ",", "Canceled", ":", "wr", ".", "Canceled", ",", "WatchId", ":", "w", ".", "id", ",", "Events", ":", "events", ",", "}", ")", "\n", "}" ]
3,274
all-3275
[ "GetScreenboards", "returns", "a", "list", "of", "all", "screenboards", "created", "on", "this", "account", "." ]
[ "func", "(", "client", "*", "<mask>", ")", "GetScreenboards", "(", ")", "(", "[", "]", "*", "ScreenboardLite", ",", "error", ")", "{", "var", "out", "reqGetScreenboards", "\n", "if", "err", ":=", "client", ".", "doJsonRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "nil", ",", "&", "out", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "out", ".", "Screenboards", ",", "nil", "\n", "}" ]
3,275
all-3276
[ "ResValue", "returns", "the", "string", "value", "of", "the", "attribute" ]
[ "func", "(", "a", "XMLNode", ")", "ResValue", "(", ")", "string", "{", "switch", "a", ".", "NodeType", "{", "case", "tree", ".", "NtAttr", ":", "return", "a", ".", "Token", ".", "(", "*", "xml", ".", "Attr", ")", ".", "Value", "\n", "case", "tree", ".", "NtChd", ":", "return", "string", "(", "a", ".", "Token", ".", "(", "xml", ".", "CharData", ")", ")", "\n", "case", "tree", ".", "NtComm", ":", "return", "string", "(", "a", ".", "<mask>", ".", "(", "xml", ".", "Comment", ")", ")", "\n", "}", "\n", "//case tree.NtPi:", "return", "string", "(", "a", ".", "Token", ".", "(", "xml", ".", "ProcInst", ")", ".", "Inst", ")", "\n", "}" ]
3,276
all-3277
[ "Parameters", ":", "-", "Msg" ]
[ "func", "(", "p", "*", "FirstClient", ")", "Echo", "(", "<mask>", "string", ")", "(", "r", "string", ",", "err", "error", ")", "{", "if", "err", "=", "p", ".", "sendEcho", "(", "msg", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "return", "p", ".", "recvEcho", "(", ")", "\n", "}" ]
3,277
all-3278
[ "title", ":", "add", "app", "router", "path", ":", "/", "app", "/", "{", "app", "}", "/", "routers", "method", ":", "POST", "produce", ":", "application", "/", "json", "responses", ":", "200", ":", "OK", "404", ":", "App", "or", "router", "not", "found", "400", ":", "Invalid", "request" ]
[ "func", "addAppRouter", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "t", "auth", ".", "Token", ")", "(", "err", "error", ")", "{", "var", "appRouter", "appTypes", ".", "AppRouter", "\n", "err", "=", "ParseInput", "(", "r", ",", "&", "appRouter", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "appName", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "a", ",", "err", ":=", "getAppFromContext", "(", "appName", ",", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "_", ",", "err", "=", "router", ".", "Get", "(", "appRouter", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "isNotFound", ":=", "err", ".", "(", "*", "router", ".", "ErrRouterNotFound", ")", ";", "isNotFound", "{", "return", "&", "errors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusNotFound", ",", "Message", ":", "err", ".", "Error", "(", ")", "}", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "allowed", ":=", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermAppUpdateRouterAdd", ",", "contextsForApp", "(", "&", "a", ")", "...", ",", ")", "\n", "if", "!", "allowed", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n\n", "p", ",", "err", ":=", "pool", ".", "GetPoolByName", "(", "a", ".", "Pool", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "p", ".", "ValidateRouters", "(", "[", "]", "appTypes", ".", "AppRouter", "{", "appRouter", "}", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "pool", ".", "ErrPoolHasNoRouter", "{", "return", "&", "<mask>", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusBadRequest", ",", "Message", ":", "err", ".", "Error", "(", ")", "}", "\n", "}", "\n", "return", "err", "\n", "}", "\n\n", "evt", ",", "err", ":=", "event", ".", "New", "(", "&", "event", ".", "Opts", "{", "Target", ":", "appTarget", "(", "appName", ")", ",", "Kind", ":", "permission", ".", "PermAppUpdateRouterAdd", ",", "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", "return", "a", ".", "AddRouter", "(", "appRouter", ")", "\n", "}" ]
3,278
all-3279
[ "String", "returns", "a", "string", "representation", "of", "the", "Version", "." ]
[ "func", "String", "(", "v", "*", "<mask>", ".", "Version", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "v", ".", "Major", ",", "v", ".", "Minor", ",", "v", ".", "Micro", ",", "v", ".", "Additional", ")", "\n", "}" ]
3,279
all-3280
[ "HasRecoveryWindow", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "t", "*", "ThresholdWindows", ")", "HasRecoveryWindow", "(", ")", "bool", "{", "if", "t", "!=", "nil", "&&", "t", ".", "RecoveryWindow", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
3,280
all-3281
[ "HasModifiedAt", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "b", "*", "Board", ")", "HasModifiedAt", "(", ")", "bool", "{", "if", "b", "!=", "nil", "&&", "b", ".", "ModifiedAt", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
3,281
all-3282
[ "Do", "executes", "LayerTree", ".", "compositingReasons", "against", "the", "provided", "context", ".", "returns", ":", "compositingReasons", "-", "A", "list", "of", "strings", "specifying", "reasons", "for", "the", "given", "layer", "to", "become", "composited", "." ]
[ "func", "(", "p", "*", "CompositingReasonsParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "compositingReasons", "[", "]", "string", ",", "err", "error", ")", "{", "// execute", "var", "<mask>", "CompositingReasonsReturns", "\n", "err", "=", "cdp", ".", "Execute", "(", "ctx", ",", "CommandCompositingReasons", ",", "p", ",", "&", "res", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "res", ".", "CompositingReasons", ",", "nil", "\n", "}" ]
3,282
all-3283
[ "HasRole", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "u", "*", "User", ")", "HasRole", "(", ")", "bool", "{", "if", "u", "!=", "nil", "&&", "u", ".", "<mask>", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
3,283
all-3284
[ "GetUser", "fetches", "a", "user", "if", "authenticated", "and", "exists" ]
[ "func", "GetUser", "(", "c", "*", "gin", ".", "Context", ")", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "c", ".", "Header", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "id", ",", "_", ":=", "strconv", ".", "Atoi", "(", "c", ".", "Param", "(", "\"", "\"", ")", ")", "\n", "user", ",", "err", ":=", "userRepository", ".", "ByID", "(", "id", ")", "\n\n", "if", "err", "!=", "nil", "{", "c", ".", "JSON", "(", "http", ".", "StatusNotFound", ",", "gin", ".", "H", "{", "\"", "\"", ":", "\"", "\"", "}", ")", "\n", "}", "else", "{", "c", ".", "JSON", "(", "http", ".", "StatusOK", ",", "<mask>", ")", "\n", "}", "\n", "}" ]
3,284
all-3285
[ "AddOrgToConfig", "adds", "an", "organization", "to", "the", "cf", "-", "mgmt", "configuration", "." ]
[ "func", "(", "m", "*", "yamlManager", ")", "AddOrgToConfig", "(", "orgConfig", "*", "OrgConfig", ",", "spaces", "*", "Spaces", ")", "error", "{", "orgList", ",", "err", ":=", "m", ".", "Orgs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "orgName", ":=", "orgConfig", ".", "Org", "\n", "if", "orgName", "==", "\"", "\"", "{", "return", "<mask>", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "orgList", ".", "Contains", "(", "orgName", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "orgName", ",", "orgList", ".", "Orgs", ")", "\n", "}", "\n", "lo", ".", "G", ".", "Infof", "(", "\"", "\"", ",", "orgName", ")", "\n", "orgList", ".", "Orgs", "=", "append", "(", "orgList", ".", "Orgs", ",", "orgName", ")", "\n", "if", "err", "=", "m", ".", "SaveOrgs", "(", "orgList", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "m", ".", "SaveOrgConfig", "(", "orgConfig", ")", "\n", "return", "m", ".", "SaveOrgSpaces", "(", "spaces", ")", "\n", "}" ]
3,285
all-3286
[ "handleRelease", ":", "Handler", "for", "/", "release", "Method", ":", "POST", "URL", "Params", ":", "Required", ":", "name", "=", "[", "string", "]", ":", "name", "of", "finished", "resource", "Required", ":", "owner", "=", "[", "string", "]", ":", "owner", "of", "the", "resource", "Required", ":", "dest", "=", "[", "string", "]", ":", "dest", "state" ]
[ "func", "handleRelease", "(", "r", "*", "ranch", ".", "Ranch", ")", "http", ".", "HandlerFunc", "{", "return", "func", "(", "res", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "logrus", ".", "WithField", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "Infof", "(", "\"", "\"", ",", "req", ".", "RemoteAddr", ")", "\n\n", "if", "req", ".", "Method", "!=", "http", ".", "MethodPost", "{", "msg", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "req", ".", "Method", ")", "\n", "logrus", ".", "Warning", "(", "msg", ")", "\n", "http", ".", "Error", "(", "res", ",", "msg", ",", "http", ".", "StatusMethodNotAllowed", ")", "\n", "return", "\n", "}", "\n\n", "name", ":=", "req", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "dest", ":=", "req", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "owner", ":=", "req", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "name", "==", "\"", "\"", "||", "dest", "==", "\"", "\"", "||", "owner", "==", "\"", "\"", "{", "msg", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ",", "dest", ",", "owner", ")", "\n", "logrus", ".", "Warning", "(", "msg", ")", "\n", "http", ".", "Error", "(", "res", ",", "msg", ",", "http", ".", "StatusBadRequest", ")", "\n", "return", "\n", "}", "\n\n", "if", "err", ":=", "r", ".", "Release", "(", "name", ",", "dest", ",", "owner", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "<mask>", ",", "dest", ",", "owner", ")", "\n", "http", ".", "Error", "(", "res", ",", "err", ".", "Error", "(", ")", ",", "ErrorToStatus", "(", "err", ")", ")", "\n", "return", "\n", "}", "\n\n", "logrus", ".", "Infof", "(", "\"", "\"", ",", "name", ",", "dest", ")", "\n", "}", "\n", "}" ]
3,286
all-3287
[ "NewMemoryStore", "returns", "a", "new", "memory", "store", "for", "the", "cache", "note", "that", "httpcache", "package", "provides", "one", "global", "default", "cache", "service", "which", "provides", "these", "functions", ":", "httpcache", ".", "Cache", "httpcache", ".", "Invalidate", "and", "httpcache", ".", "Start", "If", "you", "use", "only", "one", "global", "cache", "for", "all", "of", "your", "routes", "use", "the", "httpcache", ".", "New", "instead" ]
[ "func", "NewMemoryStore", "(", ")", "Store", "{", "return", "&", "memoryStore", "{", "cache", ":", "make", "(", "map", "[", "string", "]", "*", "entry", ".", "Entry", ")", ",", "mu", ":", "<mask>", ".", "RWMutex", "{", "}", ",", "}", "\n", "}" ]
3,287
all-3288
[ "IterNChildren", "is", "a", "wrapper", "around", "gtk_tree_model_iter_n_children", "()", "." ]
[ "func", "(", "v", "*", "TreeModel", ")", "IterNChildren", "(", "iter", "*", "TreeIter", ")", "int", "{", "<mask>", "cIter", "*", "C", ".", "GtkTreeIter", "\n", "if", "iter", "!=", "nil", "{", "cIter", "=", "iter", ".", "native", "(", ")", "\n", "}", "\n", "c", ":=", "C", ".", "gtk_tree_model_iter_n_children", "(", "v", ".", "native", "(", ")", ",", "cIter", ")", "\n", "return", "int", "(", "c", ")", "\n", "}" ]
3,288
all-3289
[ "QuerySelector", "executes", "querySelector", "on", "a", "given", "node", ".", "See", ":", "https", ":", "//", "chromedevtools", ".", "github", ".", "io", "/", "devtools", "-", "protocol", "/", "tot", "/", "DOM#method", "-", "querySelector", "parameters", ":", "nodeID", "-", "Id", "of", "the", "node", "to", "query", "upon", ".", "selector", "-", "Selector", "string", "." ]
[ "func", "QuerySelector", "(", "nodeID", "cdp", ".", "NodeID", ",", "selector", "<mask>", ")", "*", "QuerySelectorParams", "{", "return", "&", "QuerySelectorParams", "{", "NodeID", ":", "nodeID", ",", "Selector", ":", "selector", ",", "}", "\n", "}" ]
3,289
all-3290
[ "Args", "sets", "the", "Args" ]
[ "func", "(", "e", "*", "execStreamerBuilder", ")", "Args", "(", "args", "...", "<mask>", ")", "ExecStreamerBuilder", "{", "e", ".", "d", ".", "Args", "=", "args", "\n", "return", "e", "\n", "}" ]
3,290
all-3291
[ "ForEach", "iterates", "over", "all", "key", "values", "of", "a", "folder", "decode", "non", "-", "nil", "values", "using", "gob", "." ]
[ "func", "(", "tx", "Tx", ")", "ForEachGob", "(", "folders", "[", "]", "[", "]", "byte", ",", "f", "func", "(", "Bucket", ",", "bytesp", ".", "Slice", ",", "<mask>", "{", "}", ")", "error", ")", "error", "{", "return", "tx", ".", "ForEach", "(", "folders", ",", "func", "(", "b", "Bucket", ",", "k", ",", "bs", "bytesp", ".", "Slice", ")", "error", "{", "var", "v", "interface", "{", "}", "\n", "if", "err", ":=", "gob", ".", "NewDecoder", "(", "&", "bs", ")", ".", "Decode", "(", "&", "v", ")", ";", "err", "!=", "nil", "{", "return", "errorsp", ".", "WithStacksAndMessage", "(", "err", ",", "\"", "\"", ",", "len", "(", "bs", ")", ",", "string", "(", "k", ")", ")", "\n", "}", "\n", "return", "errorsp", ".", "WithStacks", "(", "f", "(", "b", ",", "k", ",", "v", ")", ")", "\n", "}", ")", "\n", "}" ]
3,291
all-3292
[ "HasRequests", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "h", "*", "HostmapDefinition", ")", "HasRequests", "(", ")", "bool", "{", "if", "h", "!=", "nil", "&&", "h", ".", "Requests", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
3,292
all-3293
[ "resolveCommit", "contains", "the", "essential", "implementation", "of", "inspectCommit", ":", "it", "converts", "commit", "(", "which", "may", "be", "a", "commit", "ID", "or", "branch", "reference", "plus", "~", "and", "/", "or", "^", ")", "to", "a", "repo", "+", "commit", "ID", ".", "It", "accepts", "an", "STM", "so", "that", "it", "can", "be", "used", "in", "a", "transaction", "and", "avoids", "an", "inconsistent", "call", "to", "d", ".", "inspectCommit", "()" ]
[ "func", "(", "d", "*", "<mask>", ")", "resolveCommit", "(", "stm", "col", ".", "STM", ",", "userCommit", "*", "pfs", ".", "Commit", ")", "(", "*", "pfs", ".", "CommitInfo", ",", "error", ")", "{", "if", "userCommit", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "userCommit", ".", "ID", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "commit", ":=", "proto", ".", "Clone", "(", "userCommit", ")", ".", "(", "*", "pfs", ".", "Commit", ")", "// back up user commit, for error reporting", "\n", "// Extract any ancestor tokens from 'commit.ID' (i.e. ~ and ^)", "var", "ancestryLength", "int", "\n", "commit", ".", "ID", ",", "ancestryLength", "=", "ancestry", ".", "Parse", "(", "commit", ".", "ID", ")", "\n\n", "// Keep track of the commit branch, in case it isn't set in the commitInfo already", "var", "commitBranch", "*", "pfs", ".", "Branch", "\n", "// Check if commit.ID is already a commit ID (i.e. a UUID).", "if", "!", "uuid", ".", "IsUUIDWithoutDashes", "(", "commit", ".", "ID", ")", "{", "branches", ":=", "d", ".", "branches", "(", "commit", ".", "Repo", ".", "Name", ")", ".", "ReadWrite", "(", "stm", ")", "\n", "branchInfo", ":=", "&", "pfs", ".", "BranchInfo", "{", "}", "\n", "// See if we are given a branch", "if", "err", ":=", "branches", ".", "Get", "(", "commit", ".", "ID", ",", "branchInfo", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "branchInfo", ".", "Head", "==", "nil", "{", "return", "nil", ",", "pfsserver", ".", "ErrNoHead", "{", "branchInfo", ".", "Branch", "}", "\n", "}", "\n", "commitBranch", "=", "branchInfo", ".", "Branch", "\n", "commit", ".", "ID", "=", "branchInfo", ".", "Head", ".", "ID", "\n", "}", "\n\n", "// Traverse commits' parents until you've reached the right ancestor", "commits", ":=", "d", ".", "commits", "(", "commit", ".", "Repo", ".", "Name", ")", ".", "ReadWrite", "(", "stm", ")", "\n", "commitInfo", ":=", "&", "pfs", ".", "CommitInfo", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<=", "ancestryLength", ";", "i", "++", "{", "if", "commit", "==", "nil", "{", "return", "nil", ",", "pfsserver", ".", "ErrCommitNotFound", "{", "userCommit", "}", "\n", "}", "\n", "childCommit", ":=", "commit", "// preserve child for error reporting", "\n", "if", "err", ":=", "commits", ".", "Get", "(", "commit", ".", "ID", ",", "commitInfo", ")", ";", "err", "!=", "nil", "{", "if", "col", ".", "IsErrNotFound", "(", "err", ")", "{", "if", "i", "==", "0", "{", "return", "nil", ",", "pfsserver", ".", "ErrCommitNotFound", "{", "childCommit", "}", "\n", "}", "\n", "return", "nil", ",", "pfsserver", ".", "ErrParentCommitNotFound", "{", "childCommit", "}", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "commit", "=", "commitInfo", ".", "ParentCommit", "\n", "}", "\n", "if", "commitInfo", ".", "Branch", "==", "nil", "{", "commitInfo", ".", "Branch", "=", "commitBranch", "\n", "}", "\n", "userCommit", ".", "ID", "=", "commitInfo", ".", "Commit", ".", "ID", "\n", "return", "commitInfo", ",", "nil", "\n", "}" ]
3,293
all-3294
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "GetTargetsReturns", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoTarget6", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "<mask>", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
3,294
all-3295
[ "Recognize", "a", "clone", "suffix", ".", "These", "are", "not", "part", "of", "the", "mangling", "API", "but", "are", "added", "by", "GCC", "when", "cloning", "functions", "." ]
[ "func", "(", "st", "*", "<mask>", ")", "cloneSuffix", "(", "a", "AST", ")", "AST", "{", "i", ":=", "0", "\n", "if", "len", "(", "st", ".", "str", ")", ">", "1", "&&", "st", ".", "str", "[", "0", "]", "==", "'.'", "&&", "(", "isLower", "(", "st", ".", "str", "[", "1", "]", ")", "||", "st", ".", "str", "[", "1", "]", "==", "'_'", ")", "{", "i", "+=", "2", "\n", "for", "len", "(", "st", ".", "str", ")", ">", "i", "&&", "(", "isLower", "(", "st", ".", "str", "[", "i", "]", ")", "||", "st", ".", "str", "[", "i", "]", "==", "'_'", ")", "{", "i", "++", "\n", "}", "\n", "}", "\n", "for", "len", "(", "st", ".", "str", ")", ">", "i", "+", "1", "&&", "st", ".", "str", "[", "i", "]", "==", "'.'", "&&", "isDigit", "(", "st", ".", "str", "[", "i", "+", "1", "]", ")", "{", "i", "+=", "2", "\n", "for", "len", "(", "st", ".", "str", ")", ">", "i", "&&", "isDigit", "(", "st", ".", "str", "[", "i", "]", ")", "{", "i", "++", "\n", "}", "\n", "}", "\n", "suffix", ":=", "st", ".", "str", "[", ":", "i", "]", "\n", "st", ".", "advance", "(", "i", ")", "\n", "return", "&", "Clone", "{", "Base", ":", "a", ",", "Suffix", ":", "suffix", "}", "\n", "}" ]
3,295
all-3296
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "AppSpec", "." ]
[ "func", "(", "in", "*", "AppSpec", ")", "DeepCopy", "(", ")", "*", "AppSpec", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "<mask>", ":=", "new", "(", "AppSpec", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
3,296
all-3297
[ "SwalkerWrite", "is", "a", "convenience", "wrapper", "around", "swalker", ".", "Write", "that", "automatically", "converts", "value", "to", "an", "appropriate", "int", "uint", "or", "bool", "type", "based", "on", "the", "destination", "field", "s", "type", "if", "appropriate", "." ]
[ "func", "SwalkerWrite", "(", "exp", "string", ",", "obj", "interface", "{", "}", ",", "value", "string", ")", "error", "{", "v", ",", "err", ":=", "swalker", ".", "Read", "(", "exp", ",", "obj", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "rv", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "switch", "rv", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Int", ":", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "value", ",", "10", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "int", "(", "i", ")", ")", "\n", "case", "reflect", ".", "Int8", ":", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "value", ",", "10", ",", "8", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "int8", "(", "i", ")", ")", "\n", "case", "reflect", ".", "Int16", ":", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "value", ",", "10", ",", "16", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "int16", "(", "i", ")", ")", "\n", "case", "reflect", ".", "Int32", ":", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "value", ",", "10", ",", "32", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "int32", "(", "i", ")", ")", "\n", "case", "reflect", ".", "Int64", ":", "i", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "value", ",", "10", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "i", ")", "\n", "case", "reflect", ".", "Uint", ":", "i", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "<mask>", ",", "10", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "uint", "(", "i", ")", ")", "\n", "case", "reflect", ".", "Uint8", ":", "i", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "value", ",", "10", ",", "8", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "uint8", "(", "i", ")", ")", "\n", "case", "reflect", ".", "Uint16", ":", "i", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "value", ",", "10", ",", "16", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "uint16", "(", "i", ")", ")", "\n", "case", "reflect", ".", "Uint32", ":", "i", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "value", ",", "10", ",", "32", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "uint32", "(", "i", ")", ")", "\n", "case", "reflect", ".", "Uint64", ":", "i", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "value", ",", "10", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "i", ")", "\n", "case", "reflect", ".", "Bool", ":", "b", ",", "err", ":=", "strconv", ".", "ParseBool", "(", "value", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "b", ")", "\n", "}", "\n\n", "return", "swalker", ".", "Write", "(", "exp", ",", "obj", ",", "value", ")", "\n", "}" ]
3,297
all-3298
[ "NoErrorWithinT", "checks", "that", "f", "finishes", "within", "time", "t", "and", "does", "not", "emit", "an", "error" ]
[ "func", "NoErrorWithinT", "(", "tb", "testing", ".", "TB", ",", "t", "time", ".", "Duration", ",", "f", "func", "(", ")", "error", ",", "msgAndArgs", "...", "interface", "{", "}", ")", "{", "tb", ".", "Helper", "(", ")", "\n", "errCh", ":=", "make", "(", "chan", "error", ")", "\n", "go", "func", "(", ")", "{", "// This goro will leak if the timeout is exceeded, but it's okay because the", "// test is failing anyway", "errCh", "<-", "f", "(", ")", "\n", "}", "(", ")", "\n", "<mask>", "{", "case", "err", ":=", "<-", "errCh", ":", "if", "err", "!=", "nil", "{", "fatal", "(", "tb", ",", "msgAndArgs", ",", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "case", "<-", "time", ".", "After", "(", "t", ")", ":", "fatal", "(", "tb", ",", "msgAndArgs", ",", "\"", "\"", ",", "t", ".", "String", "(", ")", ")", "\n", "}", "\n", "}" ]
3,298
all-3299
[ "GetRandomPasswordWithContext", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockSecretsManagerAPI", ")", "GetRandomPasswordWithContext", "(", "arg0", "aws", ".", "Context", ",", "arg1", "*", "secretsmanager", ".", "GetRandomPasswordInput", ",", "arg2", "...", "request", ".", "Option", ")", "(", "*", "secretsmanager", ".", "GetRandomPasswordOutput", ",", "error", ")", "{", "varargs", ":=", "[", "]", "interface", "{", "}", "{", "arg0", ",", "arg1", "}", "\n", "for", "_", ",", "a", ":=", "range", "arg2", "{", "varargs", "=", "append", "(", "varargs", ",", "a", ")", "\n", "}", "\n", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "varargs", "...", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "secretsmanager", ".", "GetRandomPasswordOutput", ")", "\n", "ret1", ",", "_", ":=", "<mask>", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
3,299
all-3300
[ "GetPageIterator", "returns", "a", "QueuePageIterator", "with", "the", "given", "page", "filters", ".", "Call", "iterator", ".", "Next", "()", "to", "get", "the", "first", "page", "of", "resources", "(", "and", "again", "to", "retrieve", "subsequent", "pages", ")", "." ]
[ "func", "(", "c", "*", "QueueService", ")", "GetPageIterator", "(", "data", "url", ".", "Values", ")", "*", "QueuePageIterator", "{", "iter", ":=", "NewPageIterator", "(", "c", ".", "<mask>", ",", "data", ",", "queuePathPart", ")", "\n", "return", "&", "QueuePageIterator", "{", "p", ":", "iter", ",", "}", "\n", "}" ]