id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequence
pl_tokens
sequence
25,200
all-25201
[ "VerifyProvider", "runs", "the", "verification", "process", "against", "a", "running", "Provider", ".", "TODO", ":", "extract", "/", "refactor", "the", "stdout", "/", "error", "streaems", "from", "these", "functions" ]
[ "func", "(", "p", "*", "PactClient", ")", "VerifyProvider", "(", "request", "types", ".", "VerifyRequest", ")", "(", "types", ".", "ProviderVerifierResponse", ",", "error", ")", "{", "log", ".", "Println", "(", "\"", "\"", ")", "\n", "var", "response", "types", ".", "ProviderVerifierResponse", "\n\n", "// Convert request into flags, and validate request", "err", ":=", "request", ".", "Validate", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "response", ",", "err", "\n", "}", "\n\n", "address", ":=", "getAddress", "(", "request", ".", "ProviderBaseURL", ")", "\n", "<mask>", ":=", "getPort", "(", "request", ".", "ProviderBaseURL", ")", "\n\n", "waitForPort", "(", "port", ",", "p", ".", "getNetworkInterface", "(", ")", ",", "address", ",", "p", ".", "TimeoutDuration", ",", "fmt", ".", "Sprintf", "(", "`Timed out waiting for Provider API to start on port %d - are you sure it's running?`", ",", "port", ")", ")", "\n\n", "// Run command, splitting out stderr and stdout. The command can fail for", "// several reasons:", "// 1. Command is unable to run at all.", "// 2. Command runs, but fails for unknown reason.", "// 3. Command runs, and returns exit status 1 because the tests fail.", "//", "// First, attempt to decode the response of the stdout.", "// If that is successful, we are at case 3. Return stdout as message, no error.", "// Else, return an error, include stderr and stdout in both the error and message.", "svc", ":=", "p", ".", "verificationSvcManager", ".", "NewService", "(", "request", ".", "Args", ")", "\n", "cmd", ":=", "svc", ".", "Command", "(", ")", "\n\n", "stdOutPipe", ",", "err", ":=", "cmd", ".", "StdoutPipe", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "response", ",", "err", "\n", "}", "\n", "stdErrPipe", ",", "err", ":=", "cmd", ".", "StderrPipe", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "response", ",", "err", "\n", "}", "\n", "err", "=", "cmd", ".", "Start", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "response", ",", "err", "\n", "}", "\n", "stdOut", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "stdOutPipe", ")", "\n", "if", "err", "!=", "nil", "{", "return", "response", ",", "err", "\n", "}", "\n", "stdErr", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "stdErrPipe", ")", "\n", "if", "err", "!=", "nil", "{", "return", "response", ",", "err", "\n", "}", "\n\n", "err", "=", "cmd", ".", "Wait", "(", ")", "\n\n", "// Split by lines, as the content is now JSONL", "// See https://github.com/pact-foundation/pact-go/issues/88#issuecomment-404686337", "verifications", ":=", "strings", ".", "Split", "(", "string", "(", "stdOut", ")", ",", "\"", "\\n", "\"", ")", "\n\n", "var", "verification", "types", ".", "ProviderVerifierResponse", "\n", "for", "_", ",", "v", ":=", "range", "verifications", "{", "v", "=", "strings", ".", "TrimSpace", "(", "v", ")", "\n\n", "// TODO: fix once https://github.com/pact-foundation/pact-provider-verifier/issues/26", "// is addressed", "// logging to stdout breaks the JSON response", "// https://github.com/pact-foundation/pact-ruby/commit/06fa61581512ba5570c315d089f2c0fc23c8cb11", "if", "v", "!=", "\"", "\"", "&&", "strings", ".", "Index", "(", "v", ",", "\"", "\"", ")", "!=", "0", "{", "dErr", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "v", ")", ",", "&", "verification", ")", "\n\n", "response", ".", "Examples", "=", "append", "(", "response", ".", "Examples", ",", "verification", ".", "Examples", "...", ")", "\n\n", "if", "dErr", "!=", "nil", "{", "err", "=", "dErr", "\n", "}", "\n", "}", "\n", "}", "\n\n", "if", "err", "==", "nil", "{", "return", "response", ",", "err", "\n", "}", "\n\n", "return", "response", ",", "fmt", ".", "Errorf", "(", "\"", "\\n", "\\n", "\\n", "\\n", "\\n", "\\n", "\"", ",", "err", ",", "stdErr", ",", "stdOut", ")", "\n", "}" ]
25,201
all-25202
[ "Hours", "Returns", "hours", "for", "a", "venue", ".", "https", ":", "//", "developer", ".", "foursquare", ".", "com", "/", "docs", "/", "api", "/", "venues", "/", "hours" ]
[ "func", "(", "s", "*", "VenueService", ")", "Hours", "(", "id", "string", ")", "(", "*", "VenueHoursResp", ",", "*", "http", ".", "Response", ",", "error", ")", "{", "hours", ":=", "new", "(", "VenueHoursResp", ")", "\n", "response", ":=", "new", "(", "Response", ")", "\n\n", "resp", ",", "err", ":=", "s", ".", "sling", ".", "New", "(", ")", ".", "Get", "(", "id", "+", "\"", "\"", ")", ".", "Receive", "(", "response", ",", "response", ")", "\n", "if", "err", "==", "nil", "{", "json", ".", "Unmarshal", "(", "<mask>", ".", "Response", ",", "hours", ")", "\n", "}", "\n\n", "return", "hours", ",", "resp", ",", "relevantError", "(", "err", ",", "*", "response", ")", "\n", "}" ]
25,202
all-25203
[ "GetSequence", "would", "initiate", "a", "new", "sequence", "object", "generating", "it", "from", "the", "stored", "lease", "if", "available", "in", "the", "database", ".", "Sequence", "can", "be", "used", "to", "get", "a", "list", "of", "monotonically", "increasing", "integers", ".", "Multiple", "sequences", "can", "be", "created", "by", "providing", "different", "keys", ".", "Bandwidth", "sets", "the", "size", "of", "the", "lease", "determining", "how", "many", "Next", "()", "requests", "can", "be", "served", "from", "memory", ".", "GetSequence", "is", "not", "supported", "on", "ManagedDB", ".", "Calling", "this", "would", "result", "in", "a", "panic", "." ]
[ "func", "(", "db", "*", "DB", ")", "GetSequence", "(", "key", "[", "]", "byte", ",", "bandwidth", "uint64", ")", "(", "*", "Sequence", ",", "error", ")", "{", "if", "db", ".", "opt", ".", "managedTxns", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "<mask>", "{", "case", "len", "(", "key", ")", "==", "0", ":", "return", "nil", ",", "ErrEmptyKey", "\n", "case", "bandwidth", "==", "0", ":", "return", "nil", ",", "ErrZeroBandwidth", "\n", "}", "\n", "seq", ":=", "&", "Sequence", "{", "db", ":", "db", ",", "key", ":", "key", ",", "next", ":", "0", ",", "leased", ":", "0", ",", "bandwidth", ":", "bandwidth", ",", "}", "\n", "err", ":=", "seq", ".", "updateLease", "(", ")", "\n", "return", "seq", ",", "err", "\n", "}" ]
25,203
all-25204
[ "expandCustomizationIPSettings", "reads", "certain", "ResourceData", "keys", "and", "returns", "a", "CustomizationIPSettings", "." ]
[ "func", "expandCustomizationIPSettings", "(", "d", "*", "schema", ".", "ResourceData", ",", "n", "int", ",", "v4gwAdd", ",", "v6gwAdd", "bool", ")", "(", "types", ".", "CustomizationIPSettings", ",", "bool", ",", "bool", ")", "{", "var", "v4gwFound", ",", "v6gwFound", "bool", "\n", "v4addr", ",", "v4addrOk", ":=", "d", ".", "GetOk", "(", "netifKey", "(", "\"", "\"", ",", "n", ")", ")", "\n", "v4mask", ":=", "d", ".", "Get", "(", "netifKey", "(", "\"", "\"", ",", "n", ")", ")", ".", "(", "int", ")", "\n", "v4gw", ",", "v4gwOk", ":=", "d", ".", "Get", "(", "cKeyPrefix", "+", "\"", "\"", "+", "\"", "\"", ")", ".", "(", "string", ")", "\n", "<mask>", "obj", "types", ".", "CustomizationIPSettings", "\n", "switch", "{", "case", "v4addrOk", ":", "obj", ".", "Ip", "=", "&", "types", ".", "CustomizationFixedIp", "{", "IpAddress", ":", "v4addr", ".", "(", "string", ")", ",", "}", "\n", "obj", ".", "SubnetMask", "=", "v4CIDRMaskToDotted", "(", "v4mask", ")", "\n", "// Check for the gateway", "if", "v4gwAdd", "&&", "v4gwOk", "&&", "matchGateway", "(", "v4addr", ".", "(", "string", ")", ",", "v4mask", ",", "v4gw", ")", "{", "obj", ".", "Gateway", "=", "[", "]", "string", "{", "v4gw", "}", "\n", "v4gwFound", "=", "true", "\n", "}", "\n", "default", ":", "obj", ".", "Ip", "=", "&", "types", ".", "CustomizationDhcpIpGenerator", "{", "}", "\n", "}", "\n", "obj", ".", "DnsServerList", "=", "structure", ".", "SliceInterfacesToStrings", "(", "d", ".", "Get", "(", "netifKey", "(", "\"", "\"", ",", "n", ")", ")", ".", "(", "[", "]", "interface", "{", "}", ")", ")", "\n", "obj", ".", "DnsDomain", "=", "d", ".", "Get", "(", "netifKey", "(", "\"", "\"", ",", "n", ")", ")", ".", "(", "string", ")", "\n", "obj", ".", "IpV6Spec", ",", "v6gwFound", "=", "expandCustomizationIPSettingsIPV6AddressSpec", "(", "d", ",", "n", ",", "v6gwAdd", ")", "\n", "return", "obj", ",", "v4gwFound", ",", "v6gwFound", "\n", "}" ]
25,204
all-25205
[ "loadTLSFiles", "is", "a", "modified", "copy", "of", "k8s", ".", "io", "/", "kubernetes", "/", "pkg", "/", "client", "/", "transport", ".", "loadTLSFiles", ".", "loadTLSFiles", "copies", "the", "data", "from", "the", "CertFile", "KeyFile", "and", "CAFile", "fields", "into", "the", "CertData", "KeyData", "and", "CAFile", "fields", "or", "returns", "an", "error", ".", "If", "no", "error", "is", "returned", "all", "three", "fields", "are", "either", "populated", "or", "were", "empty", "to", "start", "." ]
[ "func", "loadTLSFiles", "(", "c", "*", "restConfig", ")", "error", "{", "<mask>", "err", "error", "\n", "c", ".", "CAData", ",", "err", "=", "dataFromSliceOrFile", "(", "c", ".", "CAData", ",", "c", ".", "CAFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "c", ".", "CertData", ",", "err", "=", "dataFromSliceOrFile", "(", "c", ".", "CertData", ",", "c", ".", "CertFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "c", ".", "KeyData", ",", "err", "=", "dataFromSliceOrFile", "(", "c", ".", "KeyData", ",", "c", ".", "KeyFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
25,205
all-25206
[ "Request", "returns", "the", "special", "task", "-", "queue", "HTTP", "request", "headers", "for", "the", "current", "task", "queue", "handler", ".", "Returns", "an", "error", "if", "called", "from", "outside", "a", "delay", ".", "Func", "." ]
[ "func", "RequestHeaders", "(", "c", "<mask>", ".", "Context", ")", "(", "*", "taskqueue", ".", "RequestHeaders", ",", "error", ")", "{", "if", "ret", ",", "ok", ":=", "c", ".", "Value", "(", "headersContextKey", ")", ".", "(", "*", "taskqueue", ".", "RequestHeaders", ")", ";", "ok", "{", "return", "ret", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "errOutsideDelayFunc", "\n", "}" ]
25,206
all-25207
[ "Watch", "the", "catalog", "for", "new", "services", "we", "would", "like", "to", "watch", ".", "This", "is", "called", "only", "when", "we", "don", "t", "know", "yet", "the", "names", "of", "the", "services", "and", "need", "to", "ask", "Consul", "the", "entire", "list", "of", "services", "." ]
[ "func", "(", "d", "*", "Discovery", ")", "watchServices", "(", "ctx", "context", ".", "Context", ",", "ch", "chan", "<-", "[", "]", "*", "targetgroup", ".", "Group", ",", "lastIndex", "*", "uint64", ",", "services", "map", "[", "string", "]", "func", "(", ")", ")", "error", "{", "catalog", ":=", "d", ".", "client", ".", "Catalog", "(", ")", "\n", "level", ".", "Debug", "(", "d", ".", "logger", ")", ".", "Log", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "d", ".", "watchedTags", ")", "\n\n", "t0", ":=", "time", ".", "Now", "(", ")", "\n", "opts", ":=", "&", "consul", ".", "QueryOptions", "{", "WaitIndex", ":", "*", "lastIndex", ",", "WaitTime", ":", "watchTimeout", ",", "AllowStale", ":", "d", ".", "allowStale", ",", "NodeMeta", ":", "d", ".", "watchedNodeMeta", ",", "}", "\n", "srvs", ",", "meta", ",", "err", ":=", "catalog", ".", "Services", "(", "opts", ".", "WithContext", "(", "ctx", ")", ")", "\n", "elapsed", ":=", "time", ".", "Since", "(", "t0", ")", "\n", "rpcDuration", ".", "WithLabelValues", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "Observe", "(", "elapsed", ".", "Seconds", "(", ")", ")", "\n\n", "if", "err", "!=", "nil", "{", "level", ".", "Error", "(", "d", ".", "logger", ")", ".", "Log", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "err", ")", "\n", "rpcFailuresCount", ".", "Inc", "(", ")", "\n", "time", ".", "Sleep", "(", "retryInterval", ")", "\n", "return", "err", "\n", "}", "\n", "// If the index equals the previous one, the watch timed out with no update.", "if", "meta", ".", "LastIndex", "==", "*", "lastIndex", "{", "return", "nil", "\n", "}", "\n", "*", "lastIndex", "=", "meta", ".", "LastIndex", "\n\n", "// Check for new services.", "for", "name", ":=", "<mask>", "srvs", "{", "// catalog.Service() returns a map of service name to tags, we can use that to watch", "// only the services that have the tag we are looking for (if specified).", "// In the future consul will also support server side for service metadata.", "// https://github.com/hashicorp/consul/issues/1107", "if", "!", "d", ".", "shouldWatch", "(", "name", ",", "srvs", "[", "name", "]", ")", "{", "continue", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "services", "[", "name", "]", ";", "ok", "{", "continue", "// We are already watching the service.", "\n", "}", "\n\n", "wctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")", "\n", "d", ".", "watchService", "(", "wctx", ",", "ch", ",", "name", ")", "\n", "services", "[", "name", "]", "=", "cancel", "\n", "}", "\n\n", "// Check for removed services.", "for", "name", ",", "cancel", ":=", "range", "services", "{", "if", "_", ",", "ok", ":=", "srvs", "[", "name", "]", ";", "!", "ok", "{", "// Call the watch cancellation function.", "cancel", "(", ")", "\n", "delete", "(", "services", ",", "name", ")", "\n\n", "// Send clearing target group.", "select", "{", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "return", "ctx", ".", "Err", "(", ")", "\n", "case", "ch", "<-", "[", "]", "*", "targetgroup", ".", "Group", "{", "{", "Source", ":", "name", "}", "}", ":", "}", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
25,207
all-25208
[ "/", "*", "Fatal", "uses", "msg", "as", "a", "format", "string", "with", "subsequent", "parameters", "as", "values", "and", "logs", "the", "resulting", "message", "to", "all", "added", "loggers", "at", "LogLevel", ".", "LevelFatal" ]
[ "func", "(", "b", "*", "Base", ")", "Fatal", "(", "msg", "string", ")", "error", "{", "return", "b", ".", "<mask>", "(", "LevelFatal", ",", "nil", ",", "msg", ")", "\n", "}" ]
25,208
all-25209
[ "HasWidth", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "g", "*", "GraphDefinitionRequestStyle", ")", "HasWidth", "(", ")", "bool", "{", "if", "g", "!=", "nil", "&&", "g", ".", "Width", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
25,209
all-25210
[ "RectFromCircle", "returns", "the", "minimum", "rectangle", "that", "contains", "the", "circle", "of", "center", "c", "and", "radius", "r" ]
[ "func", "RectFromCircle", "(", "c", "Vec2", ",", "r", "float32", ")", "Rectangle", "{", "<mask>", "RectWH", "(", "c", "[", "0", "]", "-", "r", ",", "c", "[", "1", "]", "-", "r", ",", "2", "*", "r", ",", "2", "*", "r", ")", "\n", "}" ]
25,210
all-25211
[ "ToSlash", "is", "being", "used", "to", "coerce", "the", "different", "os", "PathSeparators", "into", "the", "forward", "slash", "as", "the", "forward", "slash", "is", "required", "by", "Go", "s", "import", "statement" ]
[ "func", "assembleImportPath", "(", "file", "string", ")", "string", "{", "a", ",", "_", ":=", "filepath", ".", "Abs", "(", "filepath", ".", "Dir", "(", "file", ")", ")", "\n", "absPath", ",", "fullPkg", ":=", "filepath", ".", "ToSlash", "(", "a", ")", ",", "\"", "\"", "\n", "greedy", ":=", "0", "\n", "for", "_", ",", "p", ":=", "range", "filepath", ".", "SplitList", "(", "<mask>", ".", "Getenv", "(", "\"", "\"", ")", ")", "{", "a", ",", "_", "=", "filepath", ".", "Abs", "(", "p", ")", "\n", "p", "=", "filepath", ".", "ToSlash", "(", "a", ")", "\n", "symlink", ",", "_", ":=", "filepath", ".", "EvalSymlinks", "(", "p", ")", "\n", "if", "(", "strings", ".", "HasPrefix", "(", "absPath", ",", "p", ")", "||", "strings", ".", "HasPrefix", "(", "absPath", ",", "symlink", ")", ")", "&&", "len", "(", "p", ")", ">", "greedy", "{", "prefixPath", ":=", "filepath", ".", "ToSlash", "(", "filepath", ".", "Join", "(", "p", ",", "\"", "\"", ")", ")", "\n", "fullPkg", ",", "_", "=", "filepath", ".", "Rel", "(", "prefixPath", ",", "absPath", ")", "\n", "greedy", "=", "len", "(", "p", ")", "\n", "}", "\n", "}", "\n", "return", "filepath", ".", "ToSlash", "(", "fullPkg", ")", "\n", "}" ]
25,211
all-25212
[ "Normalized", "returns", "a", "new", "instance", "where", "all", "values", "have", "been", "sorted", "and", "compacted", "(", "where", "possible", ")", ".", "If", "invert", "is", "true", "then", "return", "all", "values", "within", "the", "start", "/", "end", "that", "are", "not", "in", "the", "current", "range", "." ]
[ "func", "(", "l", "*", "InclusiveRanges", ")", "normalized", "(", "invert", "bool", ")", "*", "InclusiveRanges", "{", "normalized", ":=", "&", "InclusiveRanges", "{", "}", "\n\n", "var", "(", "start", "int", "\n", "end", "int", "\n", "step", "int", "\n", "current", "int", "\n", "pending", "int", "\n", "keepValue", "bool", "\n", ")", "\n\n", "totalRange", ":=", "NewInclusiveRange", "(", "l", ".", "Min", "(", ")", ",", "l", ".", "Max", "(", ")", ",", "1", ")", "\n\n", "checkValue", ":=", "l", ".", "Contains", "\n", "if", "!", "invert", "{", "checkValue", "=", "func", "(", "value", "int", ")", "bool", "{", "return", "!", "l", ".", "Contains", "(", "value", ")", "\n", "}", "\n", "}", "\n\n", "for", "it", ":=", "totalRange", ".", "IterValues", "(", ")", ";", "!", "it", ".", "IsDone", "(", ")", ";", "{", "current", "=", "it", ".", "Next", "(", ")", "\n\n", "keepValue", "=", "checkValue", "(", "current", ")", "\n\n", "// Short-circuit if we encounter a value that", "// is not in the original sequence.", "if", "keepValue", "{", "// fmt.Println(\" Existing value\")", "// If we haven't accumulated 2+ values to", "// add, just continue now and keep trying", "if", "pending", "<", "2", "{", "step", "++", "\n", "// fmt.Println(\" Increasing step to:\", step)", "continue", "\n", "}", "\n\n", "// If the step has changed from what we have", "// already accumulated, then add what we have", "// and start a new range.", "if", "(", "current", "+", "1", "-", "end", ")", "!=", "step", "{", "// fmt.Println(\" Step changed. Adding range:\", start, end, step)", "normalized", ".", "Append", "(", "start", ",", "end", ",", "step", ")", "\n", "step", "=", "1", "\n", "start", "=", "current", "\n", "pending", "=", "0", "\n", "}", "\n\n", "continue", "\n", "}", "\n\n", "// fmt.Println(\" Unique value\")", "// If the value we want to keep is a different", "// stepping from the pending values, add what", "// we have and start a new range again.", "if", "pending", ">=", "2", "&&", "current", "-", "end", "!=", "step", "{", "// fmt.Println(\" Step changed. Adding range:\", start, end, step)", "normalized", ".", "Append", "(", "start", ",", "end", ",", "step", ")", "\n", "pending", "=", "0", "\n", "}", "\n\n", "end", "=", "current", "\n\n", "// Start a new range", "if", "pending", "==", "0", "{", "// fmt.Println(\" Starting new range\")", "start", "=", "<mask>", "\n", "step", "=", "1", "\n", "}", "\n\n", "pending", "++", "\n", "continue", "\n", "}", "\n\n", "// Flush the remaining values", "if", "pending", ">", "0", "{", "// fmt.Println(\" Flushing and adding remaining range:\", start, end, step)", "normalized", ".", "Append", "(", "start", ",", "end", ",", "step", ")", "\n", "}", "\n\n", "return", "normalized", "\n", "}" ]
25,212
all-25213
[ "URLParam", "returns", "the", "url", "parameter", "from", "a", "http", ".", "Request", "object", "." ]
[ "func", "URLParam", "(", "r", "*", "http", ".", "Request", ",", "key", "string", ")", "string", "{", "if", "rctx", ":=", "RouteContext", "(", "r", ".", "<mask>", "(", ")", ")", ";", "rctx", "!=", "nil", "{", "return", "rctx", ".", "URLParam", "(", "key", ")", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
25,213
all-25214
[ "Close", "closes", "the", "ReaderCloser", "contained", "in", "b", "." ]
[ "func", "(", "b", "*", "BackoffReadCloser", ")", "Close", "(", ")", "error", "{", "<mask>", ",", "_", ":=", "tracing", ".", "AddSpanToAnyExisting", "(", "b", ".", "ctx", ",", "\"", "\"", ")", "\n", "defer", "tracing", ".", "FinishAnySpan", "(", "span", ")", "\n", "return", "b", ".", "reader", ".", "Close", "(", ")", "\n", "}" ]
25,214
all-25215
[ "And", "will", "match", "and", "run", "both", "authorizers", "and", "return", "immediately", "if", "one", "does", "not", "return", "a", "set", "of", "enforcers", ".", "The", "two", "successfully", "returned", "enforcer", "sets", "are", "merged", "into", "one", "and", "returned", "." ]
[ "func", "And", "(", "a", ",", "b", "*", "Authorizer", ")", "*", "Authorizer", "{", "return", "A", "(", "\"", "\"", ",", "func", "(", "ctx", "*", "fire", ".", "<mask>", ")", "bool", "{", "return", "a", ".", "Matcher", "(", "ctx", ")", "&&", "b", ".", "Matcher", "(", "ctx", ")", "\n", "}", ",", "func", "(", "ctx", "*", "fire", ".", "Context", ")", "(", "[", "]", "*", "Enforcer", ",", "error", ")", "{", "// run first callback", "enforcers1", ",", "err", ":=", "a", ".", "Handler", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "else", "if", "enforcers1", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "// run second callback", "enforcers2", ",", "err", ":=", "b", ".", "Handler", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "else", "if", "enforcers2", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "// merge both sets", "enforcers", ":=", "append", "(", "S", "{", "}", ",", "enforcers1", "...", ")", "\n", "enforcers", "=", "append", "(", "enforcers", ",", "enforcers2", "...", ")", "\n\n", "return", "enforcers", ",", "nil", "\n", "}", ")", "\n", "}" ]
25,215
all-25216
[ "UnmarshalText", "hydrates", "this", "instance", "from", "text" ]
[ "func", "(", "d", "*", "Duration", ")", "UnmarshalText", "(", "data", "[", "]", "<mask>", ")", "error", "{", "// validation is performed later on", "dd", ",", "err", ":=", "ParseDuration", "(", "string", "(", "data", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "*", "d", "=", "Duration", "(", "dd", ")", "\n", "return", "nil", "\n", "}" ]
25,216
all-25217
[ "DataUploadWithMetadata", "returns", "an", "UploadFunc", "which", "copies", "all", "data", "from", "src", "reader", "into", "GCS", "and", "also", "sets", "the", "provided", "metadata", "fields", "onto", "the", "object", "." ]
[ "func", "DataUploadWithMetadata", "(", "src", "io", ".", "Reader", ",", "metadata", "map", "[", "string", "]", "string", ")", "UploadFunc", "{", "return", "func", "(", "obj", "*", "storage", ".", "ObjectHandle", ")", "error", "{", "writer", ":=", "obj", ".", "NewWriter", "(", "<mask>", ".", "Background", "(", ")", ")", "\n", "writer", ".", "Metadata", "=", "metadata", "\n", "_", ",", "copyErr", ":=", "io", ".", "Copy", "(", "writer", ",", "src", ")", "\n", "closeErr", ":=", "writer", ".", "Close", "(", ")", "\n\n", "return", "errorutil", ".", "NewAggregate", "(", "copyErr", ",", "closeErr", ")", "\n", "}", "\n", "}" ]
25,217
all-25218
[ "newDnsimpleChange", "initializes", "a", "new", "change", "to", "dns", "records" ]
[ "func", "newDnsimpleChange", "(", "action", "string", ",", "e", "*", "endpoint", ".", "Endpoint", ")", "*", "dnsimpleChange", "{", "ttl", ":=", "dnsimpleRecordTTL", "\n", "if", "e", ".", "RecordTTL", ".", "IsConfigured", "(", ")", "{", "ttl", "=", "int", "(", "e", ".", "RecordTTL", ")", "\n", "}", "\n\n", "<mask>", ":=", "&", "dnsimpleChange", "{", "Action", ":", "action", ",", "ResourceRecordSet", ":", "dnsimple", ".", "ZoneRecord", "{", "Name", ":", "e", ".", "DNSName", ",", "Type", ":", "e", ".", "RecordType", ",", "Content", ":", "e", ".", "Targets", "[", "0", "]", ",", "TTL", ":", "ttl", ",", "}", ",", "}", "\n", "return", "change", "\n", "}" ]
25,218
all-25219
[ "Validate", "that", "options", "are", "usuable" ]
[ "func", "(", "opts", "*", "Options", ")", "Validate", "(", ")", "error", "{", "if", "opts", ".", "App", ".", "IsZero", "(", ")", "{", "opts", ".", "App", "=", "meta", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "len", "(", "opts", ".", "Version", ")", "==", "0", "{", "opts", ".", "Version", "=", "runtime", ".", "Version", "\n", "}", "\n\n", "if", "len", "(", "opts", ".", "Provider", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "opts", ".", "Provider", "=", "strings", ".", "ToLower", "(", "opts", ".", "Provider", ")", "\n\n", "var", "found", "bool", "\n", "for", "_", ",", "a", ":=", "range", "Available", "{", "if", "opts", ".", "Provider", "==", "a", "{", "found", "=", "true", "\n", "break", "\n", "}", "\n", "if", "opts", ".", "Provider", "==", "a", "+", "\"", "\"", "{", "opts", ".", "Provider", "=", "a", "\n", "found", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "!", "found", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "opts", ".", "Provider", ",", "strings", ".", "Join", "(", "Available", ",", "\"", "\"", ")", ")", "\n", "}", "\n\n", "found", "=", "false", "\n", "for", "_", ",", "d", ":=", "range", "pop", ".", "AvailableDialects", "{", "if", "d", "==", "opts", ".", "DBType", "{", "found", "=", "true", "\n", "<mask>", "\n", "}", "\n", "}", "\n", "if", "!", "found", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "opts", ".", "DBType", ",", "strings", ".", "Join", "(", "pop", ".", "AvailableDialects", ",", "\"", "\"", ")", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
25,219
all-25220
[ "waitForStopReported", "will", "wait", "for", "the", "task", "to", "be", "reported", "stopped", "and", "return", "true", "or", "will", "time", "-", "out", "and", "return", "false", ".", "Messages", "on", "the", "mtask", ".", "dockerMessages", "and", "mtask", ".", "acsMessages", "channels", "will", "be", "handled", "while", "this", "function", "is", "waiting", "." ]
[ "func", "(", "mtask", "*", "managedTask", ")", "waitForStopReported", "(", ")", "bool", "{", "stoppedSentBool", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "taskStopped", ":=", "false", "\n", "go", "func", "(", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "_maxStoppedWaitTimes", ";", "i", "++", "{", "// ensure that we block until apitaskstatus.TaskStopped is actually sent", "sentStatus", ":=", "mtask", ".", "GetSentStatus", "(", ")", "\n", "if", "sentStatus", ">=", "apitaskstatus", ".", "TaskStopped", "{", "taskStopped", "=", "true", "\n", "break", "\n", "}", "\n", "seelog", ".", "Warnf", "(", "\"", "\"", ",", "mtask", ".", "Arn", ",", "sentStatus", ".", "<mask>", "(", ")", ",", "i", "+", "1", ",", "_maxStoppedWaitTimes", ")", "\n", "mtask", ".", "_time", ".", "Sleep", "(", "_stoppedSentWaitInterval", ")", "\n", "}", "\n", "stoppedSentBool", "<-", "struct", "{", "}", "{", "}", "\n", "close", "(", "stoppedSentBool", ")", "\n", "}", "(", ")", "\n", "// wait for apitaskstatus.TaskStopped to be sent", "for", "!", "mtask", ".", "waitEvent", "(", "stoppedSentBool", ")", "{", "}", "\n", "return", "taskStopped", "\n", "}" ]
25,220
all-25221
[ "ExitMaintenanceMode", "takes", "a", "host", "out", "of", "maintenance", "mode", "." ]
[ "func", "ExitMaintenanceMode", "(", "host", "*", "object", ".", "HostSystem", ",", "timeout", "int", ")", "error", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "host", ".", "Name", "(", ")", ")", "\n\n", "// Add 5 minutes to timeout for the context timeout to allow for any issues", "// with the request after.", "// TODO: Fix this so that it ultimately uses the provider context.", "ctxTimeout", ":=", "timeout", "+", "300", "\n", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "<mask>", ".", "Second", "*", "time", ".", "Duration", "(", "ctxTimeout", ")", ")", "\n", "defer", "cancel", "(", ")", "\n", "task", ",", "err", ":=", "host", ".", "ExitMaintenanceMode", "(", "ctx", ",", "int32", "(", "timeout", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "task", ".", "Wait", "(", "ctx", ")", "\n", "}" ]
25,221
all-25222
[ "ListCommitF", "lists", "commits", "calling", "f", "with", "each", "commit", ".", "If", "only", "repo", "is", "given", "all", "commits", "in", "the", "repo", "are", "returned", ".", "If", "to", "is", "given", "only", "the", "ancestors", "of", "to", "including", "to", "itself", "are", "considered", ".", "If", "from", "is", "given", "only", "the", "descendents", "of", "from", "including", "from", "itself", "are", "considered", ".", "number", "determines", "how", "many", "commits", "are", "returned", ".", "If", "number", "is", "0", "all", "commits", "that", "match", "the", "aforementioned", "criteria", "are", "returned", "." ]
[ "func", "(", "c", "APIClient", ")", "ListCommitF", "(", "repoName", "string", ",", "to", "string", ",", "from", "string", ",", "number", "uint64", ",", "f", "func", "(", "*", "pfs", ".", "CommitInfo", ")", "error", ")", "error", "{", "req", ":=", "&", "pfs", ".", "ListCommitRequest", "{", "Repo", ":", "NewRepo", "(", "repoName", ")", ",", "Number", ":", "number", ",", "}", "\n", "if", "from", "!=", "\"", "\"", "{", "req", ".", "From", "=", "NewCommit", "(", "repoName", ",", "from", ")", "\n", "}", "\n", "if", "to", "!=", "\"", "\"", "{", "req", ".", "To", "=", "NewCommit", "(", "repoName", ",", "to", ")", "\n", "}", "\n", "stream", ",", "err", ":=", "c", ".", "PfsAPIClient", ".", "ListCommitStream", "(", "c", ".", "Ctx", "(", ")", ",", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "for", "{", "ci", ",", "err", ":=", "stream", ".", "Recv", "(", ")", "\n", "if", "err", "==", "io", ".", "EOF", "{", "<mask>", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "grpcutil", ".", "ScrubGRPC", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "f", "(", "ci", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "errutil", ".", "ErrBreak", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
25,222
all-25223
[ "FieldArgs", "converts", "the", "given", "fields", "to", "function", "arguments", "rendering", "their", "name", "and", "type", "." ]
[ "func", "FieldArgs", "(", "fields", "[", "]", "*", "Field", ")", "string", "{", "args", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "fields", ")", ")", "\n", "for", "i", ",", "field", ":=", "range", "<mask>", "{", "args", "[", "i", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "lex", ".", "Minuscule", "(", "field", ".", "Name", ")", ",", "field", ".", "Type", ".", "Name", ")", "\n", "}", "\n\n", "return", "strings", ".", "Join", "(", "args", ",", "\"", "\"", ")", "\n", "}" ]
25,223
all-25224
[ "CreateDatabase", "creates", "and", "connects", "a", "new", "instance", "of", "an", "InfluxDB", "It", "is", "created", "based", "on", "the", "fields", "set", "in", "the", "configuration", "." ]
[ "func", "(", "config", "*", "InfluxConfig", ")", "CreateDatabase", "(", "tags", "map", "[", "string", "]", "string", ",", "measurement", "string", ")", "(", "*", "InfluxDB", ",", "error", ")", "{", "client", ",", "err", ":=", "influxdb", ".", "NewHTTPClient", "(", "influxdb", ".", "HTTPConfig", "{", "Addr", ":", "config", ".", "Host", ",", "Username", ":", "config", ".", "User", ",", "Password", ":", "config", ".", "Password", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "err", "=", "dropSeries", "(", "client", ",", "measurement", ",", "config", ".", "DB", ",", "tags", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "bp", ",", "err", ":=", "influxdb", ".", "NewBatchPoints", "(", "influxdb", ".", "BatchPointsConfig", "{", "<mask>", ":", "config", ".", "DB", ",", "Precision", ":", "\"", "\"", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "InfluxDB", "{", "client", ":", "client", ",", "database", ":", "config", ".", "DB", ",", "batch", ":", "bp", ",", "tags", ":", "tags", ",", "measurement", ":", "measurement", ",", "}", ",", "err", "\n", "}" ]
25,224
all-25225
[ "GetKnownExitCode", "returns", "the", "container", "exit", "code" ]
[ "func", "(", "c", "*", "<mask>", ")", "GetKnownExitCode", "(", ")", "*", "int", "{", "c", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "RUnlock", "(", ")", "\n\n", "return", "c", ".", "KnownExitCodeUnsafe", "\n", "}" ]
25,225
all-25226
[ "Read", "reads", "data", "net", ".", "Conn", "style" ]
[ "func", "(", "c", "*", "singleConn", ")", "Read", "(", "buf", "[", "]", "<mask>", ")", "(", "int", ",", "error", ")", "{", "return", "c", ".", "maconn", ".", "Read", "(", "buf", ")", "\n", "}" ]
25,226
all-25227
[ "non", "-", "blocking", "trigger", "close" ]
[ "func", "(", "l", "*", "overseerListener", ")", "release", "(", "timeout", "<mask>", ".", "Duration", ")", "{", "//stop accepting connections - release fd", "l", ".", "closeError", "=", "l", ".", "Listener", ".", "Close", "(", ")", "\n", "//start timer, close by force if deadline not met", "waited", ":=", "make", "(", "chan", "bool", ")", "\n", "go", "func", "(", ")", "{", "l", ".", "wg", ".", "Wait", "(", ")", "\n", "waited", "<-", "true", "\n", "}", "(", ")", "\n", "go", "func", "(", ")", "{", "select", "{", "case", "<-", "time", ".", "After", "(", "timeout", ")", ":", "close", "(", "l", ".", "closeByForce", ")", "\n", "case", "<-", "waited", ":", "//no need to force close", "}", "\n", "}", "(", ")", "\n", "}" ]
25,227
all-25228
[ "StatusString", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockTaskResource", ")", "StatusString", "(", "arg0", "status0", ".", "ResourceStatus", ")", "string", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "<mask>", "[", "0", "]", ".", "(", "string", ")", "\n", "return", "ret0", "\n", "}" ]
25,228
all-25229
[ "NewMockTaskResource", "creates", "a", "new", "mock", "instance" ]
[ "func", "NewMockTaskResource", "(", "ctrl", "*", "gomock", ".", "<mask>", ")", "*", "MockTaskResource", "{", "mock", ":=", "&", "MockTaskResource", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockTaskResourceMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
25,229
all-25230
[ "DockerConfig", "converts", "the", "given", "container", "in", "this", "task", "to", "the", "format", "of", "the", "Docker", "SDK", "Config", "struct" ]
[ "func", "(", "task", "*", "Task", ")", "DockerConfig", "(", "container", "*", "apicontainer", ".", "Container", ",", "apiVersion", "dockerclient", ".", "DockerVersion", ")", "(", "*", "dockercontainer", ".", "Config", ",", "*", "apierrors", ".", "DockerClientConfigError", ")", "{", "return", "task", ".", "dockerConfig", "(", "<mask>", ",", "apiVersion", ")", "\n", "}" ]
25,230
all-25231
[ "Increments", "the", "current", "interval", "by", "multiplying", "it", "with", "the", "multiplier", "." ]
[ "func", "(", "b", "*", "ExponentialBackOff", ")", "incrementCurrentInterval", "(", ")", "{", "// Check for overflow, if overflow is detected set the current interval to the max interval.", "if", "float64", "(", "b", ".", "currentInterval", ")", ">=", "float64", "(", "b", ".", "MaxInterval", ")", "/", "b", ".", "Multiplier", "{", "b", ".", "currentInterval", "=", "b", ".", "MaxInterval", "\n", "}", "else", "{", "b", ".", "currentInterval", "=", "<mask>", ".", "Duration", "(", "float64", "(", "b", ".", "currentInterval", ")", "*", "b", ".", "Multiplier", ")", "\n", "}", "\n", "}" ]
25,231
all-25232
[ "WithGestureSourceType", "which", "type", "of", "input", "events", "to", "be", "generated", "(", "default", ":", "default", "which", "queries", "the", "platform", "for", "the", "preferred", "input", "type", ")", "." ]
[ "func", "(", "p", "SynthesizePinchGestureParams", ")", "WithGestureSourceType", "(", "gestureSourceType", "GestureType", ")", "*", "SynthesizePinchGestureParams", "{", "p", ".", "GestureSourceType", "=", "gestureSourceType", "\n", "<mask>", "&", "p", "\n", "}" ]
25,232
all-25233
[ "Add", "is", "a", "wrapper", "around", "gtk_container_add", "()", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "Add", "(", "w", "IWidget", ")", "{", "C", ".", "gtk_container_add", "(", "v", ".", "native", "(", ")", ",", "w", ".", "toWidget", "(", ")", ")", "\n", "}" ]
25,233
all-25234
[ "NewFakeCollection", "====" ]
[ "func", "NewFakeCollection", "(", "updated", "int", ")", "*", "FakeCollection", "{", "fakeCol", ":=", "new", "(", "FakeCollection", ")", "\n\n", "if", "updated", "==", "-", "1", "{", "fakeCol", ".", "FakeChangeInfo", "=", "nil", "\n", "}", "else", "{", "fakeCol", ".", "FakeChangeInfo", "=", "&", "mgo", ".", "ChangeInfo", "{", "Updated", ":", "<mask>", ",", "}", "\n", "}", "\n", "return", "fakeCol", "\n", "}" ]
25,234
all-25235
[ "MakeLibrary", "creates", "a", "new", "library", "that", "contains", "the", "functions", "stored", "in", "the", "specified", "source", "string", ".", "Reference", ":", "https", ":", "//", "developer", ".", "apple", ".", "com", "/", "documentation", "/", "metal", "/", "mtldevice", "/", "1433431", "-", "makelibrary", "." ]
[ "func", "(", "d", "Device", ")", "MakeLibrary", "(", "source", "string", ",", "opt", "CompileOptions", ")", "(", "Library", ",", "error", ")", "{", "l", ":=", "C", ".", "Go_Device_MakeLibrary", "(", "d", ".", "<mask>", ",", "source", ")", "// TODO: opt.", "\n", "if", "l", ".", "Library", "==", "nil", "{", "return", "Library", "{", "}", ",", "errors", ".", "New", "(", "C", ".", "GoString", "(", "l", ".", "Error", ")", ")", "\n", "}", "\n\n", "return", "Library", "{", "l", ".", "Library", "}", ",", "nil", "\n", "}" ]
25,235
all-25236
[ "Remote", "returns", "the", "VCS", "name", "and", "the", "remote", "URL", "for", "a", "repository", "with", "the", "given", "root", "import", "path", ".", "This", "is", "suitable", "for", "creating", "new", "repository", "rules", "." ]
[ "func", "(", "r", "*", "RemoteCache", ")", "Remote", "(", "root", "string", ")", "(", "remote", ",", "vcs", "string", ",", "err", "error", ")", "{", "v", ",", "err", ":=", "r", ".", "remote", ".", "ensure", "(", "root", ",", "func", "(", ")", "(", "<mask>", "{", "}", ",", "error", ")", "{", "repo", ",", "err", ":=", "r", ".", "RepoRootForImportPath", "(", "root", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "remoteValue", "{", "remote", ":", "repo", ".", "Repo", ",", "vcs", ":", "repo", ".", "VCS", ".", "Cmd", "}", ",", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "value", ":=", "v", ".", "(", "remoteValue", ")", "\n", "return", "value", ".", "remote", ",", "value", ".", "vcs", ",", "nil", "\n", "}" ]
25,236
all-25237
[ "WithPierce", "whether", "or", "not", "iframes", "and", "shadow", "roots", "should", "be", "traversed", "when", "returning", "the", "subtree", "(", "default", "is", "false", ")", "." ]
[ "func", "(", "p", "GetDocumentParams", ")", "WithPierce", "(", "pierce", "bool", ")", "*", "GetDocumentParams", "{", "p", ".", "Pierce", "=", "pierce", "\n", "<mask>", "&", "p", "\n", "}" ]
25,237
all-25238
[ "FlushMetrics", "flushes", "current", "metrics", "to", "a", "structure", "and", "returns", "it", "(", "does", "NOT", "send", "to", "Circonus", ")" ]
[ "func", "(", "m", "*", "CirconusMetrics", ")", "FlushMetrics", "(", ")", "*", "Metrics", "{", "m", ".", "flushmu", ".", "Lock", "(", ")", "\n", "if", "m", ".", "flushing", "{", "m", ".", "flushmu", ".", "Unlock", "(", ")", "\n", "return", "&", "Metrics", "{", "}", "\n", "}", "\n\n", "m", ".", "flushing", "=", "true", "\n", "m", ".", "flushmu", ".", "Unlock", "(", ")", "\n\n", "_", ",", "output", ":=", "m", ".", "packageMetrics", "(", ")", "\n\n", "m", ".", "flushmu", ".", "Lock", "(", ")", "\n", "m", ".", "flushing", "=", "<mask>", "\n", "m", ".", "flushmu", ".", "Unlock", "(", ")", "\n\n", "return", "&", "output", "\n", "}" ]
25,238
all-25239
[ "Matches", "returns", "whether", "the", "matcher", "matches", "the", "given", "string", "value", "." ]
[ "func", "(", "m", "*", "Matcher", ")", "Matches", "(", "s", "string", ")", "bool", "{", "switch", "m", ".", "Type", "{", "case", "MatchEqual", ":", "return", "s", "==", "m", ".", "Value", "\n", "case", "MatchNotEqual", ":", "return", "s", "!=", "m", ".", "Value", "\n", "case", "MatchRegexp", ":", "return", "m", ".", "re", ".", "MatchString", "(", "s", ")", "\n", "<mask>", "MatchNotRegexp", ":", "return", "!", "m", ".", "re", ".", "MatchString", "(", "s", ")", "\n", "}", "\n", "panic", "(", "\"", "\"", ")", "\n", "}" ]
25,239
all-25240
[ "NewMockControl", "creates", "a", "new", "mock", "instance" ]
[ "func", "NewMockControl", "(", "ctrl", "*", "gomock", ".", "<mask>", ")", "*", "MockControl", "{", "mock", ":=", "&", "MockControl", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockControlMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
25,240
all-25241
[ "return", "a", "texture", "image" ]
[ "func", "GetTextureImage", "(", "texture", "uint32", ",", "<mask>", "int32", ",", "format", "uint32", ",", "xtype", "uint32", ",", "bufSize", "int32", ",", "pixels", "unsafe", ".", "Pointer", ")", "{", "C", ".", "glowGetTextureImage", "(", "gpGetTextureImage", ",", "(", "C", ".", "GLuint", ")", "(", "texture", ")", ",", "(", "C", ".", "GLint", ")", "(", "level", ")", ",", "(", "C", ".", "GLenum", ")", "(", "format", ")", ",", "(", "C", ".", "GLenum", ")", "(", "xtype", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "bufSize", ")", ",", "pixels", ")", "\n", "}" ]
25,241
all-25242
[ "GetParameterType", "is", "a", "wrapper", "around", "g_action_get_parameter_type" ]
[ "func", "(", "v", "*", "<mask>", ")", "GetParameterType", "(", ")", "*", "VariantType", "{", "c", ":=", "C", ".", "g_action_get_parameter_type", "(", "v", ".", "native", "(", ")", ")", "\n", "if", "c", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "newVariantType", "(", "(", "*", "C", ".", "GVariantType", ")", "(", "c", ")", ")", "\n", "}" ]
25,242
all-25243
[ "MapSet", "stores", "the", "value", "v", "into", "a", "key", "mk", "in", "the", "map", "named", "k", "." ]
[ "func", "(", "s", "*", "Scratch", ")", "MapSet", "(", "k", ",", "mk", "string", ",", "v", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "s", ".", "init", "(", ")", "\n\n", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "return", "s", ".", "mapSet", "(", "k", ",", "mk", ",", "v", ",", "<mask>", ")", "\n", "}" ]
25,243
all-25244
[ "Do", "executes", "Network", ".", "getAllCookies", "against", "the", "provided", "context", ".", "returns", ":", "cookies", "-", "Array", "of", "cookie", "objects", "." ]
[ "func", "(", "p", "*", "GetAllCookiesParams", ")", "Do", "(", "ctx", "<mask>", ".", "Context", ")", "(", "cookies", "[", "]", "*", "Cookie", ",", "err", "error", ")", "{", "// execute", "var", "res", "GetAllCookiesReturns", "\n", "err", "=", "cdp", ".", "Execute", "(", "ctx", ",", "CommandGetAllCookies", ",", "nil", ",", "&", "res", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "res", ".", "Cookies", ",", "nil", "\n", "}" ]
25,244
all-25245
[ "ExtractInboundSpan", "is", "a", "higher", "level", "version", "of", "extractInboundSpan", "()", ".", "If", "the", "lower", "-", "level", "attempt", "to", "create", "a", "span", "from", "incoming", "request", "was", "successful", "(", "e", ".", "g", ".", "when", "then", "Tracer", "supports", "Zipkin", "-", "style", "trace", "IDs", ")", "then", "the", "application", "headers", "are", "only", "used", "to", "read", "the", "Baggage", "and", "add", "it", "to", "the", "existing", "span", ".", "Otherwise", "the", "standard", "OpenTracing", "API", "supported", "by", "all", "tracers", "is", "used", "to", "deserialize", "the", "tracing", "context", "from", "the", "application", "headers", "and", "start", "a", "new", "server", "-", "side", "span", ".", "Once", "the", "span", "is", "started", "it", "is", "wrapped", "in", "a", "new", "Context", "which", "is", "returned", "." ]
[ "func", "ExtractInboundSpan", "(", "ctx", "context", ".", "Context", ",", "call", "*", "InboundCall", ",", "headers", "map", "[", "string", "]", "string", ",", "tracer", "opentracing", ".", "Tracer", ")", "context", ".", "Context", "{", "var", "span", "=", "call", ".", "Response", "(", ")", ".", "span", "\n", "if", "span", "!=", "nil", "{", "if", "headers", "!=", "nil", "{", "// extract SpanContext from headers, but do not start another span with it,", "// just get the baggage and copy to the already created span", "carrier", ":=", "tracingHeadersCarrier", "(", "headers", ")", "\n", "if", "sc", ",", "err", ":=", "tracer", ".", "Extract", "(", "opentracing", ".", "TextMap", ",", "carrier", ")", ";", "err", "==", "nil", "{", "sc", ".", "ForeachBaggageItem", "(", "func", "(", "k", ",", "v", "string", ")", "bool", "{", "span", ".", "SetBaggageItem", "(", "k", ",", "v", ")", "\n", "return", "true", "\n", "}", ")", "\n", "}", "\n", "carrier", ".", "RemoveTracingKeys", "(", ")", "\n", "}", "\n", "}", "else", "{", "<mask>", "parent", "opentracing", ".", "SpanContext", "\n", "if", "headers", "!=", "nil", "{", "carrier", ":=", "tracingHeadersCarrier", "(", "headers", ")", "\n", "if", "p", ",", "err", ":=", "tracer", ".", "Extract", "(", "opentracing", ".", "TextMap", ",", "carrier", ")", ";", "err", "==", "nil", "{", "parent", "=", "p", "\n", "}", "\n", "carrier", ".", "RemoveTracingKeys", "(", ")", "\n", "}", "\n", "span", "=", "tracer", ".", "StartSpan", "(", "call", ".", "MethodString", "(", ")", ",", "ext", ".", "RPCServerOption", "(", "parent", ")", ")", "\n", "ext", ".", "PeerService", ".", "Set", "(", "span", ",", "call", ".", "CallerName", "(", ")", ")", "\n", "span", ".", "SetTag", "(", "\"", "\"", ",", "string", "(", "call", ".", "Format", "(", ")", ")", ")", "\n", "call", ".", "conn", ".", "setPeerHostPort", "(", "span", ")", "\n", "call", ".", "Response", "(", ")", ".", "span", "=", "span", "\n", "}", "\n", "return", "opentracing", ".", "ContextWithSpan", "(", "ctx", ",", "span", ")", "\n", "}" ]
25,245
all-25246
[ "isAutoIncrementable", "returns", "whether", "the", "struct", "field", "is", "integer", "." ]
[ "func", "(", "db", "*", "DB", ")", "isAutoIncrementable", "(", "field", "*", "reflect", ".", "StructField", ")", "bool", "{", "switch", "field", ".", "Type", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Int", ",", "reflect", ".", "Int16", ",", "reflect", ".", "Int32", ",", "reflect", ".", "Int64", ",", "reflect", ".", "Uint", ",", "reflect", ".", "Uint16", ",", "reflect", ".", "Uint32", ",", "reflect", ".", "Uint64", ":", "return", "<mask>", "\n", "}", "\n", "return", "false", "\n", "}" ]
25,246
all-25247
[ "--------------------------------------------------------------------------------", "sha256" ]
[ "func", "hash32", "(", "input", "[", "]", "byte", ")", "(", "res", "*", "[", "32", "]", "byte", ")", "{", "hasher", ":=", "sha256", ".", "New", "(", ")", "\n", "hasher", ".", "Write", "(", "input", ")", "// does not error", "\n", "resSlice", ":=", "hasher", ".", "Sum", "(", "nil", ")", "\n", "<mask>", "=", "new", "(", "[", "32", "]", "byte", ")", "\n", "copy", "(", "res", "[", ":", "]", ",", "resSlice", ")", "\n", "return", "\n", "}" ]
25,247
all-25248
[ "Only", "initialize", "the", "minimal", "information", "we", "need", "about", "a", "given", "storage", "type", "." ]
[ "func", "(", "s", "*", "storageLvm", ")", "StorageCoreInit", "(", ")", "error", "{", "s", ".", "sType", "=", "storageTypeLvm", "\n", "typeName", ",", "err", ":=", "storageTypeToString", "(", "s", ".", "sType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "s", ".", "sTypeName", "=", "typeName", "\n\n", "if", "lvmVersion", "!=", "\"", "\"", "{", "s", ".", "sTypeVersion", "=", "lvmVersion", "\n", "return", "nil", "\n", "}", "\n\n", "output", ",", "err", ":=", "shared", ".", "RunCommand", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "err", ",", "output", ")", "\n", "}", "\n", "lines", ":=", "strings", ".", "Split", "(", "output", ",", "\"", "\\n", "\"", ")", "\n\n", "s", ".", "sTypeVersion", "=", "\"", "\"", "\n", "for", "idx", ",", "<mask>", ":=", "range", "lines", "{", "fields", ":=", "strings", ".", "SplitAfterN", "(", "line", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "fields", ")", "<", "2", "{", "continue", "\n", "}", "\n", "if", "idx", ">", "0", "{", "s", ".", "sTypeVersion", "+=", "\"", "\"", "\n", "}", "\n", "s", ".", "sTypeVersion", "+=", "strings", ".", "TrimSpace", "(", "fields", "[", "1", "]", ")", "\n", "}", "\n\n", "lvmVersion", "=", "s", ".", "sTypeVersion", "\n\n", "return", "nil", "\n", "}" ]
25,248
all-25249
[ "NewMinioClient", "creates", "an", "s3", "compatible", "client", "with", "the", "following", "credentials", ":", "endpoint", "-", "S3", "compatible", "endpoint", "bucket", "-", "S3", "bucket", "name", "id", "-", "AWS", "access", "key", "id", "secret", "-", "AWS", "secret", "access", "key", "secure", "-", "Set", "to", "true", "if", "connection", "is", "secure", ".", "isS3V2", "-", "Set", "to", "true", "if", "client", "follows", "S3V2" ]
[ "func", "NewMinioClient", "(", "endpoint", ",", "bucket", ",", "id", ",", "<mask>", "string", ",", "secure", ",", "isS3V2", "bool", ")", "(", "Client", ",", "error", ")", "{", "if", "isS3V2", "{", "return", "newMinioClientV2", "(", "endpoint", ",", "bucket", ",", "id", ",", "secret", ",", "secure", ")", "\n", "}", "\n", "return", "newMinioClient", "(", "endpoint", ",", "bucket", ",", "id", ",", "secret", ",", "secure", ")", "\n", "}" ]
25,249
all-25250
[ "resourceVSphereDatastoreClusterVMAntiAffinityRuleApplySDRSConfigSpec", "applying", "a", "SDRS", "config", "spec", "for", "the", "vsphere_datastore_cluster_vm_anti_affinity_rule", "resource", ".", "This", "is", "wrapped", "to", "abstract", "the", "fact", "that", "we", "are", "deriving", "the", "client", "from", "the", "StoragePod", ".", "This", "is", "because", "helper", "workflows", "that", "have", "been", "created", "more", "recently", "(", "ie", ":", "cluster", "helpers", ")", "do", "this", "and", "more", "than", "likely", "the", "storagepod", "helper", "will", "do", "it", "eventually", "as", "well", ".", "If", "there", "is", "ever", "an", "issue", "with", "this", "it", "can", "be", "changed", "here", ".", "There", "should", "be", "no", "issue", "though", "as", "govmomi", ".", "Client", "is", "mainly", "just", "vim25", ".", "Client", "with", "some", "additional", "session", "helper", "bits", "that", "is", "not", "normally", "needed", "during", "normal", "operation", "." ]
[ "func", "resourceVSphereDatastoreClusterVMAntiAffinityRuleApplySDRSConfigSpec", "(", "pod", "*", "object", ".", "StoragePod", ",", "spec", "<mask>", ".", "StorageDrsConfigSpec", ",", ")", "error", "{", "return", "storagepod", ".", "ApplyDRSConfiguration", "(", "&", "govmomi", ".", "Client", "{", "Client", ":", "pod", ".", "Client", "(", ")", ",", "}", ",", "pod", ",", "spec", ",", ")", "\n", "}" ]
25,250
all-25251
[ "Validate", "checks", "if", "the", "directory", "and", "the", "layout", "files", "exist", "as", "expected", "and", "configured" ]
[ "func", "(", "r", "*", "Render", ")", "Validate", "(", ")", "{", "// add trailing slash if the user has forgotten..", "if", "!", "strings", ".", "HasSuffix", "(", "r", ".", "TemplatesDir", ",", "\"", "\"", ")", "{", "r", ".", "TemplatesDir", "=", "r", ".", "TemplatesDir", "+", "\"", "\"", "\n", "}", "\n\n", "// check for templates dir", "if", "ok", ",", "_", ":=", "exists", "(", "r", ".", "TemplatesDir", ")", ";", "!", "ok", "{", "panic", "(", "r", ".", "TemplatesDir", "+", "\"", "\\n", "\\\"", "\\\"", "\"", ")", "\n", "}", "\n\n", "// check for layout file", "layoutFile", ":=", "r", ".", "TemplatesDir", "+", "r", ".", "Layout", "+", "r", ".", "Ext", "\n", "if", "ok", ",", "_", ":=", "exists", "(", "layoutFile", ")", ";", "!", "<mask>", "{", "panic", "(", "layoutFile", "+", "\"", "\"", ")", "\n", "}", "\n", "}" ]
25,251
all-25252
[ "LayerInfos", "returns", "a", "list", "of", "LayerInfos", "of", "layers", "referenced", "by", "this", "image", "in", "order", "(", "the", "root", "layer", "first", "and", "then", "successive", "layered", "layers", ")", ".", "The", "Digest", "field", "is", "guaranteed", "to", "be", "provided", ";", "Size", "may", "be", "-", "1", ".", "WARNING", ":", "The", "list", "may", "contain", "duplicates", "and", "they", "are", "semantically", "relevant", "." ]
[ "func", "(", "m", "*", "Schema2", ")", "LayerInfos", "(", ")", "[", "]", "LayerInfo", "{", "blobs", ":=", "[", "]", "LayerInfo", "{", "}", "\n", "for", "_", ",", "layer", ":=", "range", "m", ".", "LayersDescriptors", "{", "blobs", "=", "<mask>", "(", "blobs", ",", "LayerInfo", "{", "BlobInfo", ":", "BlobInfoFromSchema2Descriptor", "(", "layer", ")", ",", "EmptyLayer", ":", "false", ",", "}", ")", "\n", "}", "\n", "return", "blobs", "\n", "}" ]
25,252
all-25253
[ "createPublishHealthRequests", "creates", "the", "requests", "to", "publish", "container", "health" ]
[ "func", "(", "cs", "*", "clientServer", ")", "createPublishHealthRequests", "(", ")", "(", "[", "]", "*", "ecstcs", ".", "PublishHealthRequest", ",", "error", ")", "{", "<mask>", ",", "taskHealthMetrics", ",", "err", ":=", "cs", ".", "statsEngine", ".", "GetTaskHealthMetrics", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "metadata", "==", "nil", "||", "taskHealthMetrics", "==", "nil", "{", "seelog", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "nil", ",", "nil", "\n", "}", "\n\n", "var", "requests", "[", "]", "*", "ecstcs", ".", "PublishHealthRequest", "\n", "var", "taskHealths", "[", "]", "*", "ecstcs", ".", "TaskHealth", "\n", "numOfTasks", ":=", "len", "(", "taskHealthMetrics", ")", "\n", "for", "i", ",", "taskHealth", ":=", "range", "taskHealthMetrics", "{", "taskHealths", "=", "append", "(", "taskHealths", ",", "taskHealth", ")", "\n", "// create a request if the number of task reaches the maximum page size", "if", "(", "i", "+", "1", ")", "%", "tasksInHealthMessage", "==", "0", "{", "requestMetadata", ":=", "copyHealthMetadata", "(", "metadata", ",", "(", "i", "+", "1", ")", "==", "numOfTasks", ")", "\n", "requestTaskHealth", ":=", "copyTaskHealthMetrics", "(", "taskHealths", ")", "\n", "request", ":=", "ecstcs", ".", "NewPublishHealthMetricsRequest", "(", "requestMetadata", ",", "requestTaskHealth", ")", "\n", "requests", "=", "append", "(", "requests", ",", "request", ")", "\n", "taskHealths", "=", "taskHealths", "[", ":", "0", "]", "\n", "}", "\n", "}", "\n\n", "// Put the rest of the metrics in another request", "if", "len", "(", "taskHealths", ")", "!=", "0", "{", "requestMetadata", ":=", "copyHealthMetadata", "(", "metadata", ",", "true", ")", "\n", "requests", "=", "append", "(", "requests", ",", "ecstcs", ".", "NewPublishHealthMetricsRequest", "(", "requestMetadata", ",", "taskHealths", ")", ")", "\n", "}", "\n\n", "return", "requests", ",", "nil", "\n", "}" ]
25,253
all-25254
[ "loadRepos", "read", "what", "(", "filtered", ")", "repos", "exist", "under", "an", "org" ]
[ "func", "loadRepos", "(", "org", "string", ",", "gc", "client", ")", "(", "[", "]", "string", ",", "error", ")", "{", "org", ",", "isUser", ":=", "GetOrg", "(", "org", ")", "\n", "repos", ",", "err", ":=", "gc", ".", "GetRepos", "(", "org", ",", "isUser", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "<mask>", "rl", "[", "]", "string", "\n", "for", "_", ",", "r", ":=", "range", "repos", "{", "if", "r", ".", "Archived", "{", "continue", "\n", "}", "\n", "rl", "=", "append", "(", "rl", ",", "r", ".", "Name", ")", "\n", "}", "\n", "return", "rl", ",", "nil", "\n", "}" ]
25,254
all-25255
[ "Rollback", "implements", "Rollback", "method", "of", "PlatformService", "interface" ]
[ "func", "(", "s", "*", "platformService", ")", "Rollback", "(", "opts", "appTypes", ".", "PlatformOptions", ")", "error", "{", "if", "opts", ".", "<mask>", "==", "\"", "\"", "{", "return", "appTypes", ".", "ErrPlatformNameMissing", "\n", "}", "\n", "if", "opts", ".", "ImageName", "==", "\"", "\"", "{", "return", "appTypes", ".", "ErrPlatformImageMissing", "\n", "}", "\n", "_", ",", "err", ":=", "s", ".", "FindByName", "(", "opts", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "image", ",", "err", ":=", "servicemanager", ".", "PlatformImage", ".", "FindImage", "(", "opts", ".", "Name", ",", "opts", ".", "ImageName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "image", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "opts", ".", "ImageName", ",", "opts", ".", "Name", ")", "\n", "}", "\n", "opts", ".", "Data", "=", "[", "]", "byte", "(", "\"", "\"", "+", "image", ")", "\n", "opts", ".", "ImageName", ",", "err", "=", "servicemanager", ".", "PlatformImage", ".", "NewImage", "(", "opts", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "builder", ".", "PlatformUpdate", "(", "opts", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "servicemanager", ".", "PlatformImage", ".", "AppendImage", "(", "opts", ".", "Name", ",", "opts", ".", "ImageName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "conn", ",", "err", ":=", "db", ".", "Conn", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "conn", ".", "Close", "(", ")", "\n", "var", "apps", "[", "]", "App", "\n", "err", "=", "conn", ".", "Apps", "(", ")", ".", "Find", "(", "bson", ".", "M", "{", "\"", "\"", ":", "opts", ".", "Name", "}", ")", ".", "All", "(", "&", "apps", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "_", ",", "app", ":=", "range", "apps", "{", "app", ".", "SetUpdatePlatform", "(", "true", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
25,255
all-25256
[ "native", "returns", "a", "pointer", "to", "the", "underlying", "cairo_t", "." ]
[ "func", "(", "v", "*", "Context", ")", "native", "(", ")", "*", "C", ".", "cairo_t", "{", "if", "v", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "v", ".", "<mask>", "\n", "}" ]
25,256
all-25257
[ "RootTracer", "is", "a", "middleware", "that", "can", "be", "used", "to", "create", "root", "trace", "span", "for", "an", "incoming", "request", "." ]
[ "func", "RootTracer", "(", ")", "func", "(", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "func", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "// split url", "segments", ":=", "strings", ".", "Split", "(", "r", ".", "URL", ".", "Path", ",", "\"", "\"", ")", "\n\n", "// replace ids", "for", "i", ",", "s", ":=", "range", "segments", "{", "if", "bson", ".", "IsObjectIdHex", "(", "s", ")", "{", "segments", "[", "i", "]", "=", "\"", "\"", "\n", "}", "\n", "}", "\n\n", "// construct name", "<mask>", ":=", "strings", ".", "Join", "(", "segments", ",", "\"", "\"", ")", "\n", "name", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ".", "Method", ",", "path", ")", "\n\n", "// create root span from request", "tracer", ":=", "NewTracerFromRequest", "(", "r", ",", "name", ")", "\n", "tracer", ".", "Tag", "(", "\"", "\"", ",", "r", ".", "RemoteAddr", ")", "\n", "tracer", ".", "Tag", "(", "\"", "\"", ",", "r", ".", "Proto", ")", "\n", "tracer", ".", "Tag", "(", "\"", "\"", ",", "r", ".", "Method", ")", "\n", "tracer", ".", "Tag", "(", "\"", "\"", ",", "r", ".", "Host", ")", "\n", "tracer", ".", "Log", "(", "\"", "\"", ",", "r", ".", "URL", ".", "String", "(", ")", ")", "\n", "tracer", ".", "Log", "(", "\"", "\"", ",", "r", ".", "ContentLength", ")", "\n", "tracer", ".", "Log", "(", "\"", "\"", ",", "r", ".", "Header", ")", "\n", "r", "=", "r", ".", "WithContext", "(", "tracer", ".", "Context", "(", "r", ".", "Context", "(", ")", ")", ")", "\n", "defer", "tracer", ".", "Finish", "(", "true", ")", "\n\n", "// call next handler", "next", ".", "ServeHTTP", "(", "w", ",", "r", ")", "\n", "}", ")", "\n", "}", "\n", "}" ]
25,257
all-25258
[ "specify", "the", "alpha", "test", "function" ]
[ "func", "AlphaFunc", "(", "xfunc", "uint32", ",", "<mask>", "float32", ")", "{", "C", ".", "glowAlphaFunc", "(", "gpAlphaFunc", ",", "(", "C", ".", "GLenum", ")", "(", "xfunc", ")", ",", "(", "C", ".", "GLfloat", ")", "(", "ref", ")", ")", "\n", "}" ]
25,258
all-25259
[ "CreateIssue", "tries", "to", "create", "and", "return", "a", "new", "github", "issue", "." ]
[ "func", "(", "c", "*", "Client", ")", "CreateIssue", "(", "org", ",", "repo", ",", "title", ",", "body", "string", ",", "labels", ",", "assignees", "[", "]", "string", ")", "(", "*", "github", ".", "Issue", ",", "error", ")", "{", "glog", ".", "Infof", "(", "\"", "\\n", "\"", ",", "c", ".", "dryRun", ",", "title", ",", "labels", ",", "assignees", ")", "\n", "if", "c", ".", "dryRun", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "issue", ":=", "&", "github", ".", "IssueRequest", "{", "Title", ":", "&", "title", ",", "Body", ":", "&", "body", ",", "}", "\n", "if", "len", "(", "labels", ")", ">", "0", "{", "<mask>", ".", "Labels", "=", "&", "labels", "\n", "}", "\n", "if", "len", "(", "assignees", ")", ">", "0", "{", "issue", ".", "Assignees", "=", "&", "assignees", "\n", "}", "\n\n", "var", "result", "*", "github", ".", "Issue", "\n", "_", ",", "err", ":=", "c", ".", "retry", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "title", ")", ",", "func", "(", ")", "(", "*", "github", ".", "Response", ",", "error", ")", "{", "var", "resp", "*", "github", ".", "Response", "\n", "var", "err", "error", "\n", "result", ",", "resp", ",", "err", "=", "c", ".", "issueService", ".", "Create", "(", "context", ".", "Background", "(", ")", ",", "org", ",", "repo", ",", "issue", ")", "\n", "return", "resp", ",", "err", "\n", "}", ",", ")", "\n", "return", "result", ",", "err", "\n", "}" ]
25,259
all-25260
[ "Value", "converts", "a", "value", "to", "a", "database", "driver", "value" ]
[ "func", "(", "e", "Email", ")", "Value", "(", ")", "(", "<mask>", ".", "Value", ",", "error", ")", "{", "return", "driver", ".", "Value", "(", "string", "(", "e", ")", ")", ",", "nil", "\n", "}" ]
25,260
all-25261
[ "DeleteBalancedNic", "removes", "a", "balanced", "nic" ]
[ "func", "(", "c", "*", "Client", ")", "DeleteBalancedNic", "(", "dcid", ",", "lbalid", ",", "balnicid", "string", ")", "(", "*", "http", ".", "Header", ",", "error", ")", "{", "url", ":=", "balnicPath", "(", "dcid", ",", "lbalid", ",", "balnicid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "<mask>", ".", "pretty", ")", "\n", "ret", ":=", "&", "http", ".", "Header", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Delete", "(", "url", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
25,261
all-25262
[ "GetSetOptionsResult", "retrieves", "the", "SetOptionsResult", "value", "from", "the", "union", "returning", "ok", "if", "the", "union", "s", "switch", "indicated", "the", "value", "is", "valid", "." ]
[ "func", "(", "u", "OperationResultTr", ")", "GetSetOptionsResult", "(", ")", "(", "result", "SetOptionsResult", ",", "ok", "bool", ")", "{", "armName", ",", "_", ":=", "u", ".", "ArmForSwitch", "(", "int32", "(", "u", ".", "Type", ")", ")", "\n\n", "if", "armName", "==", "\"", "\"", "{", "result", "=", "*", "u", ".", "SetOptionsResult", "\n", "ok", "=", "<mask>", "\n", "}", "\n\n", "return", "\n", "}" ]
25,262
all-25263
[ "defaultPolicyPath", "returns", "a", "path", "to", "the", "default", "policy", "of", "the", "system", "." ]
[ "func", "defaultPolicyPath", "(", "sys", "*", "<mask>", ".", "SystemContext", ")", "string", "{", "if", "sys", "!=", "nil", "{", "if", "sys", ".", "SignaturePolicyPath", "!=", "\"", "\"", "{", "return", "sys", ".", "SignaturePolicyPath", "\n", "}", "\n", "if", "sys", ".", "RootForImplicitAbsolutePaths", "!=", "\"", "\"", "{", "return", "filepath", ".", "Join", "(", "sys", ".", "RootForImplicitAbsolutePaths", ",", "systemDefaultPolicyPath", ")", "\n", "}", "\n", "}", "\n", "return", "systemDefaultPolicyPath", "\n", "}" ]
25,263
all-25264
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "SetSkipAllPausesParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "<mask>", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger4", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
25,264
all-25265
[ "/", "*", "Identify", "the", "end", "of", "a", "segment" ]
[ "func", "SegmentEnd", "(", "id", ",", "segId", "int64", ")", "(", "int", ",", "error", ")", "{", "return", "errNo", "(", "C", ".", "newrelic_segment_end", "(", "C", ".", "long", "(", "<mask>", ")", ",", "C", ".", "long", "(", "segId", ")", ")", ")", "\n", "}" ]
25,265
all-25266
[ "DistanceForStrings", "returns", "the", "edit", "distance", "between", "source", "and", "target", ".", "It", "has", "a", "runtime", "proportional", "to", "len", "(", "source", ")", "*", "len", "(", "target", ")", "and", "memory", "use", "proportional", "to", "len", "(", "target", ")", "." ]
[ "func", "DistanceForStrings", "(", "source", "[", "]", "rune", ",", "target", "[", "]", "rune", ",", "op", "Options", ")", "int", "{", "// Note: This algorithm is a specialization of MatrixForStrings.", "// MatrixForStrings returns the full edit matrix. However, we only need a", "// single value (see DistanceForMatrix) and the main loop of the algorithm", "// only uses the current and previous row. As such we create a 2D matrix,", "// but with height 2 (enough to store current and previous row).", "height", ":=", "len", "(", "source", ")", "+", "1", "\n", "width", ":=", "len", "(", "target", ")", "+", "1", "\n", "matrix", ":=", "<mask>", "(", "[", "]", "[", "]", "int", ",", "2", ")", "\n\n", "// Initialize trivial distances (from/to empty string). That is, fill", "// the left column and the top row with row/column indices.", "for", "i", ":=", "0", ";", "i", "<", "2", ";", "i", "++", "{", "matrix", "[", "i", "]", "=", "make", "(", "[", "]", "int", ",", "width", ")", "\n", "matrix", "[", "i", "]", "[", "0", "]", "=", "i", "\n", "}", "\n", "for", "j", ":=", "1", ";", "j", "<", "width", ";", "j", "++", "{", "matrix", "[", "0", "]", "[", "j", "]", "=", "j", "\n", "}", "\n\n", "// Fill in the remaining cells: for each prefix pair, choose the", "// (edit history, operation) pair with the lowest cost.", "for", "i", ":=", "1", ";", "i", "<", "height", ";", "i", "++", "{", "cur", ":=", "matrix", "[", "i", "%", "2", "]", "\n", "prev", ":=", "matrix", "[", "(", "i", "-", "1", ")", "%", "2", "]", "\n", "cur", "[", "0", "]", "=", "i", "\n", "for", "j", ":=", "1", ";", "j", "<", "width", ";", "j", "++", "{", "delCost", ":=", "prev", "[", "j", "]", "+", "op", ".", "DelCost", "\n", "matchSubCost", ":=", "prev", "[", "j", "-", "1", "]", "\n", "if", "!", "op", ".", "Matches", "(", "source", "[", "i", "-", "1", "]", ",", "target", "[", "j", "-", "1", "]", ")", "{", "matchSubCost", "+=", "op", ".", "SubCost", "\n", "}", "\n", "insCost", ":=", "cur", "[", "j", "-", "1", "]", "+", "op", ".", "InsCost", "\n", "cur", "[", "j", "]", "=", "min", "(", "delCost", ",", "min", "(", "matchSubCost", ",", "insCost", ")", ")", "\n", "}", "\n", "}", "\n", "return", "matrix", "[", "(", "height", "-", "1", ")", "%", "2", "]", "[", "width", "-", "1", "]", "\n", "}" ]
25,266
all-25267
[ "NewMockCache", "creates", "a", "new", "mock", "instance" ]
[ "func", "NewMockCache", "(", "ctrl", "*", "gomock", ".", "<mask>", ")", "*", "MockCache", "{", "mock", ":=", "&", "MockCache", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockCacheMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
25,267
all-25268
[ "Set", "is", "required", "for", "kingpin", "interfaces", "to", "allow", "command", "line", "params", "to", "be", "set", "to", "our", "map", "datatype" ]
[ "func", "(", "o", "*", "MapInt16Option", ")", "Set", "(", "value", "string", ")", "error", "{", "parts", ":=", "stringMapRegex", ".", "Split", "(", "value", ",", "2", ")", "\n", "if", "len", "(", "parts", ")", "!=", "2", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "value", ")", "\n", "}", "\n", "val", ":=", "Int16Option", "{", "}", "\n", "val", ".", "Set", "(", "<mask>", "[", "1", "]", ")", "\n", "(", "*", "o", ")", "[", "parts", "[", "0", "]", "]", "=", "val", "\n", "return", "nil", "\n", "}" ]
25,268
all-25269
[ "Bootstrap", "turns", "a", "non", "-", "clustered", "LXD", "instance", "into", "the", "first", "(", "and", "leader", ")", "node", "of", "a", "new", "LXD", "cluster", ".", "This", "instance", "must", "already", "have", "its", "cluster", ".", "https_address", "set", "and", "be", "listening", "on", "the", "associated", "network", "address", "." ]
[ "func", "Bootstrap", "(", "state", "*", "state", ".", "State", ",", "gateway", "*", "Gateway", ",", "name", "string", ")", "error", "{", "// Check parameters", "if", "name", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "err", ":=", "membershipCheckNoLeftoverClusterCert", "(", "<mask>", ".", "OS", ".", "VarDir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "var", "address", "string", "\n\n", "err", "=", "state", ".", "Node", ".", "Transaction", "(", "func", "(", "tx", "*", "db", ".", "NodeTx", ")", "error", "{", "// Fetch current network address and raft nodes", "config", ",", "err", ":=", "node", ".", "ConfigLoad", "(", "tx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "address", "=", "config", ".", "ClusterAddress", "(", ")", "\n\n", "// Make sure node-local database state is in order.", "err", "=", "membershipCheckNodeStateForBootstrapOrJoin", "(", "tx", ",", "address", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Add ourselves as first raft node", "err", "=", "tx", ".", "RaftNodeFirst", "(", "address", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Update our own entry in the nodes table.", "err", "=", "state", ".", "Cluster", ".", "Transaction", "(", "func", "(", "tx", "*", "db", ".", "ClusterTx", ")", "error", "{", "// Make sure cluster database state is in order.", "err", ":=", "membershipCheckClusterStateForBootstrapOrJoin", "(", "tx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Add ourselves to the nodes table.", "err", "=", "tx", ".", "NodeUpdate", "(", "1", ",", "name", ",", "address", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Shutdown the gateway. This will trash any dqlite connection against", "// our in-memory dqlite driver and shutdown the associated raft", "// instance. We also lock regular access to the cluster database since", "// we don't want any other database code to run while we're", "// reconfiguring raft.", "err", "=", "state", ".", "Cluster", ".", "EnterExclusive", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "err", "=", "gateway", ".", "Shutdown", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Re-initialize the gateway. This will create a new raft factory an", "// dqlite driver instance, which will be exposed over gRPC by the", "// gateway handlers.", "err", "=", "gateway", ".", "init", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "err", "=", "gateway", ".", "waitLeadership", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// The cluster certificates are symlinks against the regular node", "// certificate.", "for", "_", ",", "ext", ":=", "range", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "{", "if", "ext", "==", "\"", "\"", "&&", "!", "shared", ".", "PathExists", "(", "filepath", ".", "Join", "(", "state", ".", "OS", ".", "VarDir", ",", "\"", "\"", ")", ")", "{", "continue", "\n", "}", "\n", "err", ":=", "os", ".", "Symlink", "(", "\"", "\"", "+", "ext", ",", "filepath", ".", "Join", "(", "state", ".", "OS", ".", "VarDir", ",", "\"", "\"", "+", "ext", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "// Make sure we can actually connect to the cluster database through", "// the network endpoint. This also releases the previously acquired", "// lock and makes the Go SQL pooling system invalidate the old", "// connection, so new queries will be executed over the new gRPC", "// network connection.", "err", "=", "state", ".", "Cluster", ".", "ExitExclusive", "(", "func", "(", "tx", "*", "db", ".", "ClusterTx", ")", "error", "{", "_", ",", "err", ":=", "tx", ".", "Nodes", "(", ")", "\n", "return", "err", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
25,269
all-25270
[ "Switch", ".", "Start", "()", "starts", "all", "the", "reactors", "peers", "and", "listeners", "." ]
[ "func", "(", "sw", "*", "Switch", ")", "OnStart", "(", ")", "error", "{", "sw", ".", "BaseService", ".", "OnStart", "(", ")", "\n", "// Start reactors", "for", "_", ",", "reactor", ":=", "<mask>", "sw", ".", "reactors", "{", "_", ",", "err", ":=", "reactor", ".", "Start", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "// Start peers", "for", "_", ",", "peer", ":=", "range", "sw", ".", "peers", ".", "List", "(", ")", "{", "sw", ".", "startInitPeer", "(", "peer", ")", "\n", "}", "\n", "// Start listeners", "for", "_", ",", "listener", ":=", "range", "sw", ".", "listeners", "{", "go", "sw", ".", "listenerRoutine", "(", "listener", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
25,270
all-25271
[ "AttrString", "returns", "the", "value", "of", "the", "named", "attribute", "if", "it", "is", "a", "scalar", "string", ".", "is", "returned", "if", "the", "attribute", "is", "not", "set", "or", "is", "not", "a", "string", "." ]
[ "func", "(", "r", "*", "Rule", ")", "AttrString", "(", "key", "string", ")", "string", "{", "attr", ",", "ok", ":=", "r", ".", "attrs", "[", "key", "]", "\n", "if", "!", "ok", "{", "return", "\"", "\"", "\n", "}", "\n", "str", ",", "ok", ":=", "attr", ".", "RHS", ".", "(", "*", "bzl", ".", "StringExpr", ")", "\n", "if", "!", "<mask>", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "str", ".", "Value", "\n", "}" ]
25,271
all-25272
[ "GetPageIterator", "returns", "an", "iterator", "which", "can", "be", "used", "to", "retrieve", "pages", "." ]
[ "func", "(", "r", "*", "RecordingService", ")", "GetPageIterator", "(", "data", "url", ".", "Values", ")", "*", "RecordingPageIterator", "{", "iter", ":=", "NewPageIterator", "(", "r", ".", "client", ",", "<mask>", ",", "recordingsPathPart", ")", "\n", "return", "&", "RecordingPageIterator", "{", "p", ":", "iter", ",", "}", "\n", "}" ]
25,272
all-25273
[ "GetAlertId", "returns", "the", "AlertId", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "a", "*", "AlertGraphDefinition", ")", "GetAlertId", "(", ")", "<mask>", "{", "if", "a", "==", "nil", "||", "a", ".", "AlertId", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "a", ".", "AlertId", "\n", "}" ]
25,273
all-25274
[ "DeleteContainerBackup", "requests", "that", "LXD", "deletes", "the", "container", "backup" ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "DeleteContainerBackup", "(", "containerName", "string", ",", "name", "string", ")", "(", "Operation", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"", "\"", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ")", "\n", "}", "\n\n", "// Send the request", "op", ",", "_", ",", "err", ":=", "r", ".", "queryOperation", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "url", ".", "QueryEscape", "(", "containerName", ")", ",", "url", ".", "QueryEscape", "(", "<mask>", ")", ")", ",", "nil", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "op", ",", "nil", "\n", "}" ]
25,274
all-25275
[ "Core", "takes", "the", "name", "of", "a", "core", "file", "and", "returns", "a", "Process", "that", "represents", "the", "state", "of", "the", "inferior", "that", "generated", "the", "core", "file", "." ]
[ "func", "Core", "(", "coreFile", ",", "base", ",", "exePath", "string", ")", "(", "*", "Process", ",", "error", ")", "{", "core", ",", "err", ":=", "os", ".", "Open", "(", "coreFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "p", ":=", "&", "Process", "{", "base", ":", "base", ",", "<mask>", ":", "make", "(", "map", "[", "string", "]", "*", "file", ")", "}", "\n", "if", "exePath", "!=", "\"", "\"", "{", "bin", ",", "err", ":=", "os", ".", "Open", "(", "exePath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "p", ".", "exe", "=", "bin", "\n", "}", "\n\n", "if", "err", ":=", "p", ".", "readExec", "(", "p", ".", "exe", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "p", ".", "readCore", "(", "core", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "p", ".", "readDebugInfo", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Sort then merge mappings, just to clean up a bit.", "mappings", ":=", "p", ".", "memory", ".", "mappings", "\n", "sort", ".", "Slice", "(", "mappings", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "mappings", "[", "i", "]", ".", "min", "<", "mappings", "[", "j", "]", ".", "min", "\n", "}", ")", "\n", "ms", ":=", "mappings", "[", "1", ":", "]", "\n", "mappings", "=", "mappings", "[", ":", "1", "]", "\n", "for", "_", ",", "m", ":=", "range", "ms", "{", "k", ":=", "mappings", "[", "len", "(", "mappings", ")", "-", "1", "]", "\n", "if", "m", ".", "min", "==", "k", ".", "max", "&&", "m", ".", "perm", "==", "k", ".", "perm", "&&", "m", ".", "f", "==", "k", ".", "f", "&&", "m", ".", "off", "==", "k", ".", "off", "+", "k", ".", "Size", "(", ")", "{", "k", ".", "max", "=", "m", ".", "max", "\n", "// TODO: also check origF?", "}", "else", "{", "mappings", "=", "append", "(", "mappings", ",", "m", ")", "\n", "}", "\n", "}", "\n", "p", ".", "memory", ".", "mappings", "=", "mappings", "\n\n", "// Memory map all the mappings.", "hostPageSize", ":=", "int64", "(", "syscall", ".", "Getpagesize", "(", ")", ")", "\n", "for", "_", ",", "m", ":=", "range", "p", ".", "memory", ".", "mappings", "{", "size", ":=", "m", ".", "max", ".", "Sub", "(", "m", ".", "min", ")", "\n", "if", "m", ".", "f", "==", "nil", "{", "// We don't have any source for this data.", "// Could be a mapped file that we couldn't find.", "// Could be a mapping madvised as MADV_DONTDUMP.", "// Pretend this is read-as-zero.", "// The other option is to just throw away", "// the mapping (and thus make Read*s of this", "// mapping fail).", "p", ".", "warnings", "=", "append", "(", "p", ".", "warnings", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "min", ",", "m", ".", "max", ")", ")", "\n", "// TODO: this allocation could be large.", "// Use mmap to avoid real backing store for all those zeros, or", "// perhaps split the mapping up into chunks and share the zero contents among them.", "m", ".", "contents", "=", "make", "(", "[", "]", "byte", ",", "size", ")", "\n", "continue", "\n", "}", "\n", "if", "m", ".", "perm", "&", "Write", "!=", "0", "&&", "m", ".", "f", "!=", "core", "{", "p", ".", "warnings", "=", "append", "(", "p", ".", "warnings", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "min", ",", "m", ".", "max", ",", "m", ".", "f", ".", "Name", "(", ")", ")", ")", "\n", "}", "\n", "// Data in core file might not be aligned enough for the host.", "// Expand memory range so we can map full pages.", "minOff", ":=", "m", ".", "off", "\n", "maxOff", ":=", "m", ".", "off", "+", "size", "\n", "minOff", "-=", "minOff", "%", "hostPageSize", "\n", "if", "maxOff", "%", "hostPageSize", "!=", "0", "{", "maxOff", "+=", "hostPageSize", "-", "maxOff", "%", "hostPageSize", "\n", "}", "\n\n", "// Read data from file.", "data", ",", "err", ":=", "mapFile", "(", "int", "(", "m", ".", "f", ".", "Fd", "(", ")", ")", ",", "minOff", ",", "int", "(", "maxOff", "-", "minOff", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "m", ".", "f", ".", "Name", "(", ")", ",", "minOff", ",", "err", ")", "\n", "}", "\n\n", "// Trim any data we mapped but don't need.", "data", "=", "data", "[", "m", ".", "off", "-", "minOff", ":", "]", "\n", "data", "=", "data", "[", ":", "size", "]", "\n\n", "m", ".", "contents", "=", "data", "\n", "}", "\n\n", "// Build page table for mapping lookup.", "for", "_", ",", "m", ":=", "range", "p", ".", "memory", ".", "mappings", "{", "err", ":=", "p", ".", "addMapping", "(", "m", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "p", ",", "nil", "\n", "}" ]
25,275
all-25276
[ "Check", "returns", "true", "if", "an", "alert", "should", "be", "raised", "based", "on", "the", "range", "(", "if", "the", "value", "is", "outside", "the", "range", "for", "normal", "semantics", "or", "if", "the", "value", "is", "inside", "the", "range", "for", "inverted", "semantics", "(" ]
[ "func", "(", "r", "*", "Range", ")", "Check", "(", "value", "float64", ")", "bool", "{", "// Ranges are treated as a closed interval.", "if", "r", ".", "Start", "<=", "<mask>", "&&", "value", "<=", "r", ".", "End", "{", "return", "r", ".", "AlertOnInside", "\n", "}", "\n", "return", "!", "r", ".", "AlertOnInside", "\n", "}" ]
25,276
all-25277
[ "String", "implements", "the", "Stringer", "interface", "." ]
[ "func", "(", "e", "*", "hdbError", ")", "<mask>", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "errorCode", ",", "e", ".", "errorPosition", ",", "e", ".", "errorTextLength", ",", "e", ".", "errorLevel", ",", "e", ".", "sqlState", ",", "e", ".", "stmtNo", ",", "e", ".", "errorText", ",", ")", "\n", "}" ]
25,277
all-25278
[ "GenerateCert", "generates", "a", "new", "certificate", "signed", "using", "the", "provided", "certificate", "authority", "files", "and", "stores", "the", "result", "in", "the", "certificate", "file", "and", "key", "provided", ".", "The", "provided", "host", "names", "are", "set", "to", "the", "appropriate", "certificate", "fields", "." ]
[ "func", "(", "xcg", "*", "X509CertGenerator", ")", "GenerateCert", "(", "opts", "*", "Options", ")", "error", "{", "template", ",", "err", ":=", "xcg", ".", "newCertificate", "(", "opts", ".", "Org", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "// client", "if", "len", "(", "opts", ".", "Hosts", ")", "==", "1", "&&", "opts", ".", "Hosts", "[", "0", "]", "==", "\"", "\"", "{", "template", ".", "ExtKeyUsage", "=", "[", "]", "x509", ".", "ExtKeyUsage", "{", "x509", ".", "ExtKeyUsageClientAuth", "}", "\n", "template", ".", "KeyUsage", "=", "x509", ".", "KeyUsageDigitalSignature", "\n", "}", "else", "{", "// server", "template", ".", "ExtKeyUsage", "=", "[", "]", "x509", ".", "ExtKeyUsage", "{", "x509", ".", "ExtKeyUsageServerAuth", "}", "\n", "if", "opts", ".", "SwarmMaster", "{", "// Extend the Swarm master's server certificate", "// permissions to also be able to connect to downstream", "// nodes as a client.", "template", ".", "ExtKeyUsage", "=", "append", "(", "template", ".", "ExtKeyUsage", ",", "x509", ".", "ExtKeyUsageClientAuth", ")", "\n", "}", "\n", "for", "_", ",", "h", ":=", "range", "opts", ".", "Hosts", "{", "if", "ip", ":=", "net", ".", "ParseIP", "(", "h", ")", ";", "ip", "!=", "nil", "{", "template", ".", "IPAddresses", "=", "append", "(", "template", ".", "IPAddresses", ",", "ip", ")", "\n", "}", "else", "{", "template", ".", "DNSNames", "=", "append", "(", "<mask>", ".", "DNSNames", ",", "h", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "tlsCert", ",", "err", ":=", "tls", ".", "LoadX509KeyPair", "(", "opts", ".", "CAFile", ",", "opts", ".", "CAKeyFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "priv", ",", "err", ":=", "rsa", ".", "GenerateKey", "(", "rand", ".", "Reader", ",", "opts", ".", "Bits", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "x509Cert", ",", "err", ":=", "x509", ".", "ParseCertificate", "(", "tlsCert", ".", "Certificate", "[", "0", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "derBytes", ",", "err", ":=", "x509", ".", "CreateCertificate", "(", "rand", ".", "Reader", ",", "template", ",", "x509Cert", ",", "&", "priv", ".", "PublicKey", ",", "tlsCert", ".", "PrivateKey", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "certOut", ",", "err", ":=", "os", ".", "Create", "(", "opts", ".", "CertFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "pem", ".", "Encode", "(", "certOut", ",", "&", "pem", ".", "Block", "{", "Type", ":", "\"", "\"", ",", "Bytes", ":", "derBytes", "}", ")", "\n", "certOut", ".", "Close", "(", ")", "\n\n", "keyOut", ",", "err", ":=", "os", ".", "OpenFile", "(", "opts", ".", "KeyFile", ",", "os", ".", "O_WRONLY", "|", "os", ".", "O_CREATE", "|", "os", ".", "O_TRUNC", ",", "0600", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "pem", ".", "Encode", "(", "keyOut", ",", "&", "pem", ".", "Block", "{", "Type", ":", "\"", "\"", ",", "Bytes", ":", "x509", ".", "MarshalPKCS1PrivateKey", "(", "priv", ")", "}", ")", "\n", "keyOut", ".", "Close", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
25,278
all-25279
[ "findGeneration", "finds", "out", "the", "generation", "of", "the", "keyIndex", "that", "the", "given", "rev", "belongs", "to", ".", "If", "the", "given", "rev", "is", "at", "the", "gap", "of", "two", "generations", "which", "means", "that", "the", "key", "does", "not", "exist", "at", "the", "given", "rev", "it", "returns", "nil", "." ]
[ "func", "(", "ki", "*", "keyIndex", ")", "findGeneration", "(", "rev", "int64", ")", "*", "generation", "{", "lastg", ":=", "len", "(", "ki", ".", "generations", ")", "-", "1", "\n", "cg", ":=", "lastg", "\n\n", "for", "cg", ">=", "0", "{", "if", "len", "(", "ki", ".", "generations", "[", "cg", "]", ".", "revs", ")", "==", "0", "{", "cg", "--", "\n", "<mask>", "\n", "}", "\n", "g", ":=", "ki", ".", "generations", "[", "cg", "]", "\n", "if", "cg", "!=", "lastg", "{", "if", "tomb", ":=", "g", ".", "revs", "[", "len", "(", "g", ".", "revs", ")", "-", "1", "]", ".", "main", ";", "tomb", "<=", "rev", "{", "return", "nil", "\n", "}", "\n", "}", "\n", "if", "g", ".", "revs", "[", "0", "]", ".", "main", "<=", "rev", "{", "return", "&", "ki", ".", "generations", "[", "cg", "]", "\n", "}", "\n", "cg", "--", "\n", "}", "\n", "return", "nil", "\n", "}" ]
25,279
all-25280
[ "DumpAST", "sets", "the", "bitmask", "for", "DumpAST", "debug", "flag" ]
[ "func", "(", "f", "*", "Flags", ")", "DumpAST", "(", "b", "bool", ")", "{", "if", "b", "{", "f", ".", "<mask>", "|=", "MaskDumpAST", "\n", "}", "else", "{", "f", ".", "flags", "&=", "^", "MaskDumpAST", "\n", "}", "\n", "}" ]
25,280
all-25281
[ "getRBDMappedDevPath", "looks", "at", "sysfs", "to", "retrieve", "the", "device", "path", "/", "dev", "/", "rbd<idx", ">", "for", "an", "RBD", "image", ".", "If", "it", "doesn", "t", "find", "it", "it", "will", "map", "it", "if", "told", "to", "do", "so", "." ]
[ "func", "getRBDMappedDevPath", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeType", "string", ",", "volumeName", "string", ",", "doMap", "bool", ",", "userName", "string", ")", "(", "string", ",", "int", ")", "{", "files", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "if", "doMap", "{", "goto", "mapImage", "\n", "}", "\n\n", "return", "\"", "\"", ",", "0", "\n", "}", "\n\n", "return", "\"", "\"", ",", "-", "1", "\n", "}", "\n\n", "for", "_", ",", "f", ":=", "range", "files", "{", "if", "!", "f", ".", "IsDir", "(", ")", "{", "continue", "\n", "}", "\n\n", "fName", ":=", "f", ".", "Name", "(", ")", "\n", "idx", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "fName", ",", "10", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "<mask>", "\n", "}", "\n\n", "tmp", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "fName", ")", "\n", "contents", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "tmp", ")", "\n", "if", "err", "!=", "nil", "{", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "continue", "\n", "}", "\n\n", "return", "\"", "\"", ",", "-", "1", "\n", "}", "\n\n", "detectedPoolName", ":=", "strings", ".", "TrimSpace", "(", "string", "(", "contents", ")", ")", "\n", "if", "detectedPoolName", "!=", "poolName", "{", "continue", "\n", "}", "\n\n", "tmp", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "fName", ")", "\n", "contents", ",", "err", "=", "ioutil", ".", "ReadFile", "(", "tmp", ")", "\n", "if", "err", "!=", "nil", "{", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "continue", "\n", "}", "\n\n", "return", "\"", "\"", ",", "-", "1", "\n", "}", "\n\n", "typedVolumeName", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "volumeType", ",", "volumeName", ")", "\n", "detectedVolumeName", ":=", "strings", ".", "TrimSpace", "(", "string", "(", "contents", ")", ")", "\n", "if", "detectedVolumeName", "!=", "typedVolumeName", "{", "continue", "\n", "}", "\n\n", "tmp", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "fName", ")", "\n", "contents", ",", "err", "=", "ioutil", ".", "ReadFile", "(", "tmp", ")", "\n", "if", "err", "!=", "nil", "{", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "1", "\n", "}", "\n\n", "return", "\"", "\"", ",", "-", "1", "\n", "}", "\n\n", "detectedSnapName", ":=", "strings", ".", "TrimSpace", "(", "string", "(", "contents", ")", ")", "\n", "if", "detectedSnapName", "!=", "\"", "\"", "{", "continue", "\n", "}", "\n\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "1", "\n", "}", "\n\n", "if", "!", "doMap", "{", "return", "\"", "\"", ",", "0", "\n", "}", "\n\n", "mapImage", ":", "devPath", ",", "err", ":=", "cephRBDVolumeMap", "(", "clusterName", ",", "poolName", ",", "volumeName", ",", "volumeType", ",", "userName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "-", "1", "\n", "}", "\n\n", "return", "strings", ".", "TrimSpace", "(", "devPath", ")", ",", "2", "\n", "}" ]
25,281
all-25282
[ "StoragePoolVolumeSnapshotsGetType", "get", "all", "snapshots", "of", "a", "storage", "volume", "attached", "to", "a", "given", "storage", "pool", "of", "a", "given", "volume", "type", "on", "the", "given", "node", "." ]
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumeSnapshotsGetType", "(", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", "int64", ")", "(", "[", "]", "string", ",", "error", ")", "{", "result", ":=", "[", "]", "string", "{", "}", "\n", "regexp", ":=", "volumeName", "+", "shared", ".", "SnapshotDelimiter", "\n", "length", ":=", "len", "(", "regexp", ")", "\n\n", "query", ":=", "\"", "\"", "\n", "inargs", ":=", "[", "]", "<mask>", "{", "}", "{", "poolID", ",", "c", ".", "nodeID", ",", "volumeType", ",", "true", ",", "length", ",", "regexp", "}", "\n", "outfmt", ":=", "[", "]", "interface", "{", "}", "{", "volumeName", "}", "\n\n", "dbResults", ",", "err", ":=", "queryScan", "(", "c", ".", "db", ",", "query", ",", "inargs", ",", "outfmt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "result", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "r", ":=", "range", "dbResults", "{", "result", "=", "append", "(", "result", ",", "r", "[", "0", "]", ".", "(", "string", ")", ")", "\n", "}", "\n\n", "return", "result", ",", "nil", "\n", "}" ]