id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
14,400
all-14401
[ "SetTextValue", "sets", "a", "text", "metric" ]
[ "func", "(", "m", "*", "CirconusMetrics", ")", "SetTextValue", "(", "metric", "string", ",", "val", "string", ")", "{", "m", ".", "tm", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "tm", ".", "Unlock", "(", ")", "\n", "m", ".", "<mask>", "[", "metric", "]", "=", "val", "\n", "}" ]
14,401
all-14402
[ "HasName", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "s", "*", "SyntheticsUser", ")", "HasName", "(", ")", "bool", "{", "if", "s", "!=", "nil", "&&", "s", ".", "Name", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
14,402
all-14403
[ "NewDottedVersion", "returns", "a", "new", "Version", "." ]
[ "func", "NewDottedVersion", "(", "versionString", "string", ")", "(", "*", "DottedVersion", ",", "error", ")", "{", "formatError", ":=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "versionString", ")", "\n", "split", ":=", "strings", ".", "Split", "(", "versionString", ",", "\"", "\"", ")", "\n", "if", "len", "(", "<mask>", ")", "<", "2", "{", "return", "nil", ",", "formatError", "\n", "}", "\n\n", "maj", ",", "err", ":=", "strconv", ".", "Atoi", "(", "split", "[", "0", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "formatError", "\n", "}", "\n\n", "min", ",", "err", ":=", "strconv", ".", "Atoi", "(", "split", "[", "1", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "formatError", "\n", "}", "\n\n", "patch", ":=", "-", "1", "\n", "if", "len", "(", "split", ")", "==", "3", "{", "patch", ",", "err", "=", "strconv", ".", "Atoi", "(", "split", "[", "2", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "formatError", "\n", "}", "\n", "}", "\n\n", "return", "&", "DottedVersion", "{", "Major", ":", "maj", ",", "Minor", ":", "min", ",", "Patch", ":", "patch", ",", "}", ",", "nil", "\n", "}" ]
14,403
all-14404
[ "Create", "a", "Tournament" ]
[ "func", "NewTournament", "(", "tdata", "Info", ")", "(", "*", "Tournament", ",", "error", ")", "{", "if", "err", ":=", "validateTournamentInfo", "(", "tdata", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "err", ".", "Error", "(", ")", "+", "\"", "\"", ")", "\n", "}", "\n\n", "t", ":=", "<mask>", "(", "Tournament", ")", "\n", "t", ".", "UUID", ",", "_", "=", "uuid", ".", "V4", "(", ")", "\n", "if", "err", ":=", "mergo", ".", "MergeWithOverwrite", "(", "&", "t", ".", "Info", ",", "tdata", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "err", ".", "Error", "(", ")", "+", "\"", "\"", ")", "\n", "}", "\n", "// Merge seems to not handle time.Time for some reason, thus fixup", "fixupTournamentInfo", "(", "&", "t", ".", "Info", ",", "tdata", ")", "\n", "if", "err", ":=", "storage", ".", "Store", "(", "t", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "err", ".", "Error", "(", ")", "+", "\"", "\"", ")", "\n", "}", "\n", "return", "t", ",", "nil", "\n", "}" ]
14,404
all-14405
[ "Graceful", "sets", "up", "graceful", "handling", "of", "SIGINT", "and", "SIGTERM", "typically", "for", "an", "HTTP", "server", ".", "When", "signal", "is", "trapped", "the", "shutdown", "handler", "will", "be", "invoked", "with", "a", "context", "that", "expires", "after", "DefaultShutdownTimeout", "(", "5s", ")", ".", "server", ":", "=", "graceful", ".", "WithDefaults", "(", "http", ".", "Server", "{}", ")", "if", "err", ":", "=", "graceful", ".", "Graceful", "(", "server", ".", "ListenAndServe", "server", ".", "Shutdown", ")", ";", "err", "!", "=", "nil", "{", "log", ".", "Fatal", "(", "Failed", "to", "gracefully", "shut", "down", ")", "}" ]
[ "func", "Graceful", "(", "start", "StartFunc", ",", "shutdown", "ShutdownFunc", ")", "error", "{", "var", "(", "stopChan", "=", "make", "(", "chan", "os", ".", "Signal", ")", "\n", "errChan", "=", "make", "(", "chan", "error", ")", "\n", ")", "\n\n", "// Setup the graceful shutdown handler (traps SIGINT and SIGTERM)", "go", "func", "(", ")", "{", "signal", ".", "Notify", "(", "stopChan", ",", "os", ".", "Interrupt", ",", "syscall", ".", "SIGTERM", ")", "\n\n", "<-", "stopChan", "\n\n", "timer", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "DefaultShutdownTimeout", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "if", "err", ":=", "shutdown", "(", "timer", ")", ";", "err", "!=", "nil", "{", "errChan", "<-", "errors", ".", "WithStack", "(", "err", ")", "\n", "return", "\n", "}", "\n\n", "errChan", "<-", "nil", "\n", "}", "(", ")", "\n\n", "// Start the server", "if", "err", ":=", "start", "(", ")", ";", "err", "!=", "<mask>", ".", "ErrServerClosed", "{", "return", "err", "\n", "}", "\n\n", "return", "<-", "errChan", "\n", "}" ]
14,405
all-14406
[ "Config", "returns", "the", "lens", "s", "configuration", "." ]
[ "func", "(", "lens", "Lens", ")", "Config", "(", ")", "lenses", ".", "LensConfig", "{", "return", "lenses", ".", "LensConfig", "{", "Name", ":", "name", ",", "Title", ":", "<mask>", ",", "Priority", ":", "priority", ",", "}", "\n", "}" ]
14,406
all-14407
[ "getInvalidTokenError", "gets", "the", "default", "error", "when", "an", "invalid", "or", "expired", "token", "is", "requested", "." ]
[ "func", "(", "s", "*", "SessionCache", ")", "getInvalidTokenError", "(", "token", "string", ")", "error", "{", "return", "<mask>", ".", "New", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "token", ")", ")", "\n", "}" ]
14,407
all-14408
[ "Unknownf", "is", "a", "shorthand", "function", "which", "exits", "the", "check", "with", "status", "UNKNOWN", "and", "the", "message", "provided", "." ]
[ "func", "(", "c", "*", "Check", ")", "Unknownf", "(", "format", "string", ",", "v", "...", "<mask>", "{", "}", ")", "{", "c", ".", "Exitf", "(", "UNKNOWN", ",", "format", ",", "v", "...", ")", "\n", "}" ]
14,408
all-14409
[ "TailingLogs", "listens", "indefinitely", "for", "log", "messages", "only", ";", "other", "event", "types", "are", "dropped", ".", "Whenever", "an", "error", "is", "encountered", "the", "error", "will", "be", "sent", "down", "the", "error", "channel", "and", "TailingLogs", "will", "attempt", "to", "reconnect", "up", "to", "5", "times", ".", "After", "five", "failed", "reconnection", "attempts", "TailingLogs", "will", "give", "up", "and", "close", "the", "error", "and", "LogMessage", "channels", ".", "If", "c", "is", "closed", "the", "returned", "channels", "will", "both", "be", "closed", ".", "Errors", "must", "be", "drained", "from", "the", "returned", "error", "channel", "for", "it", "to", "continue", "retrying", ";", "if", "they", "are", "not", "drained", "the", "connection", "attempts", "will", "hang", "." ]
[ "func", "(", "c", "*", "Consumer", ")", "TailingLogs", "(", "appGuid", ",", "authToken", "string", ")", "(", "<-", "chan", "*", "<mask>", ".", "LogMessage", ",", "<-", "chan", "error", ")", "{", "return", "c", ".", "tailingLogs", "(", "appGuid", ",", "authToken", ",", "true", ")", "\n", "}" ]
14,409
all-14410
[ "HasAction", "is", "a", "wrapper", "around", "g_action_group_has_action", "()", "." ]
[ "func", "(", "v", "*", "ActionGroup", ")", "HasAction", "(", "actionName", "string", ")", "bool", "{", "<mask>", "gobool", "(", "C", ".", "g_action_group_has_action", "(", "v", ".", "native", "(", ")", ",", "(", "*", "C", ".", "gchar", ")", "(", "C", ".", "CString", "(", "actionName", ")", ")", ")", ")", "\n", "}" ]
14,410
all-14411
[ "getRandomBytes", "gets", "secure", "random", "bytes", "." ]
[ "func", "getRandomBytes", "(", "r", "io", ".", "Reader", ",", "n", "int", ")", "[", "]", "<mask>", "{", "b", ":=", "make", "(", "[", "]", "byte", ",", "n", ")", "\n", "_", ",", "err", ":=", "r", ".", "Read", "(", "b", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "b", "\n", "}" ]
14,411
all-14412
[ "serveWatchClient", "forwards", "messages", "from", "the", "grpc", "stream", "to", "run", "()" ]
[ "func", "(", "w", "*", "watchGrpcStream", ")", "serveWatchClient", "(", "wc", "pb", ".", "Watch_WatchClient", ")", "{", "for", "{", "resp", ",", "err", ":=", "wc", ".", "Recv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "select", "{", "case", "w", ".", "errc", "<-", "err", ":", "case", "<-", "w", ".", "donec", ":", "}", "\n", "return", "\n", "}", "\n", "<mask>", "{", "case", "w", ".", "respc", "<-", "resp", ":", "case", "<-", "w", ".", "donec", ":", "return", "\n", "}", "\n", "}", "\n", "}" ]
14,412
all-14413
[ "NewTwilioTime", "returns", "a", "TwilioTime", "instance", ".", "val", "should", "be", "formatted", "using", "the", "TimeLayout", "." ]
[ "func", "NewTwilioTime", "(", "val", "string", ")", "*", "TwilioTime", "{", "t", ",", "err", ":=", "<mask>", ".", "Parse", "(", "TimeLayout", ",", "val", ")", "\n", "if", "err", "==", "nil", "{", "return", "&", "TwilioTime", "{", "Time", ":", "t", ",", "Valid", ":", "true", "}", "\n", "}", "else", "{", "return", "&", "TwilioTime", "{", "}", "\n", "}", "\n", "}" ]
14,413
all-14414
[ "GetOrderDirOk", "returns", "a", "tuple", "with", "the", "OrderDir", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "c", "*", "ChangeRequest", ")", "GetOrderDirOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "c", "==", "nil", "||", "c", ".", "OrderDir", "==", "nil", "{", "return", "\"", "\"", ",", "<mask>", "\n", "}", "\n", "return", "*", "c", ".", "OrderDir", ",", "true", "\n", "}" ]
14,414
all-14415
[ "instruct", "the", "GL", "server", "to", "block", "until", "the", "specified", "sync", "object", "becomes", "signaled" ]
[ "func", "WaitSync", "(", "sync", "uintptr", ",", "flags", "uint32", ",", "timeout", "uint64", ")", "{", "C", ".", "glowWaitSync", "(", "gpWaitSync", ",", "(", "C", ".", "GLsync", ")", "(", "sync", ")", ",", "(", "C", ".", "GLbitfield", ")", "(", "<mask>", ")", ",", "(", "C", ".", "GLuint64", ")", "(", "timeout", ")", ")", "\n", "}" ]
14,415
all-14416
[ "GetConfiguration", "returns", "the", "latest", "configuration", "and", "its", "associated", "index", "currently", "in", "use", ".", "This", "may", "not", "yet", "be", "committed", ".", "This", "must", "not", "be", "called", "on", "the", "main", "thread", "(", "which", "can", "access", "the", "information", "directly", ")", "." ]
[ "func", "(", "r", "*", "Raft", ")", "GetConfiguration", "(", ")", "ConfigurationFuture", "{", "configReq", ":=", "&", "configurationsFuture", "{", "}", "\n", "configReq", ".", "init", "(", ")", "\n", "select", "{", "case", "<-", "r", ".", "shutdownCh", ":", "configReq", ".", "respond", "(", "ErrRaftShutdown", ")", "\n", "return", "configReq", "\n", "<mask>", "r", ".", "configurationsCh", "<-", "configReq", ":", "return", "configReq", "\n", "}", "\n", "}" ]
14,416
all-14417
[ "Removes", "the", "specified", "number", "of", "prefixes", "from", "a", "regexp", "and", "returns", "a", "new", "regexp", ".", "This", "basically", "loosens", "validations", "on", "the", "regexp", "by", "making", "the", "specified", "number", "of", "prefixes", "optional", ".", "num", "must", "be", "greater", "than", "the", "number", "of", "prefixes", ".", "For", "example", ":", "r", ".", "String", "()", "//", "=", ">", "/", "api", "/", "catalog", "/", "collections", "/", "(", "[", "^", "/", "]", "+", ")", "/", "templates", "/", "actions", "/", "dependencies", "removePrefixes", "(", "&r", "2", ")", ".", "String", "()", "//", "=", ">", "/", "collections", "/", "(", "[", "^", "/", "]", "+", ")", "/", "templates", "/", "actions", "/", "dependencies" ]
[ "func", "removePrefixes", "(", "r", "*", "regexp", ".", "Regexp", ",", "num", "int", ")", "(", "result", "*", "regexp", ".", "Regexp", ")", "{", "path", ":=", "strings", ".", "TrimLeft", "(", "r", ".", "<mask>", "(", ")", ",", "\"", "\"", ")", "\n", "paths", ":=", "strings", ".", "Split", "(", "path", ",", "\"", "\"", ")", "\n", "result", "=", "regexp", ".", "MustCompile", "(", "\"", "\"", "+", "strings", ".", "Join", "(", "paths", "[", "num", ":", "]", ",", "\"", "\"", ")", ")", "\n", "return", "\n", "}" ]
14,417
all-14418
[ "AddSystemInterface", "adds", "a", "system", "to", "the", "world", "but", "also", "adds", "a", "filter", "that", "allows", "automatic", "adding", "of", "entities", "that", "match", "the", "provided", "in", "interface", "and", "excludes", "any", "that", "match", "the", "provided", "ex", "interface", "even", "if", "they", "also", "match", "in", ".", "in", "and", "ex", "must", "be", "pointers", "to", "the", "interface", "or", "else", "this", "panics", "." ]
[ "func", "(", "w", "*", "World", ")", "AddSystemInterface", "(", "sys", "SystemAddByInterfacer", ",", "in", "interface", "{", "}", ",", "ex", "interface", "{", "}", ")", "{", "w", ".", "AddSystem", "(", "sys", ")", "\n\n", "if", "w", ".", "sysIn", "==", "nil", "{", "w", ".", "sysIn", "=", "make", "(", "map", "[", "reflect", ".", "Type", "]", "reflect", ".", "<mask>", ")", "\n", "}", "\n\n", "w", ".", "sysIn", "[", "reflect", ".", "TypeOf", "(", "sys", ")", "]", "=", "reflect", ".", "TypeOf", "(", "in", ")", ".", "Elem", "(", ")", "\n\n", "if", "ex", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "w", ".", "sysEx", "==", "nil", "{", "w", ".", "sysEx", "=", "make", "(", "map", "[", "reflect", ".", "Type", "]", "reflect", ".", "Type", ")", "\n", "}", "\n\n", "w", ".", "sysEx", "[", "reflect", ".", "TypeOf", "(", "sys", ")", "]", "=", "reflect", ".", "TypeOf", "(", "ex", ")", ".", "Elem", "(", ")", "\n", "}" ]
14,418
all-14419
[ "cache", "data", "from", "a", "new", "row", "span", "It", "imitates", "a", "random", "data", "by", "selecting", "values", "from", "predefined", "arrays", ".", "Sizes", "of", "all", "arrays", "should", "be", "different", "to", "make", "TableView", "data", "look", "more", "random" ]
[ "func", "(", "d", "*", "dbCache", ")", "preload", "(", "firstRow", ",", "rowCount", "int", ")", "{", "if", "firstRow", "==", "d", ".", "firstRow", "&&", "rowCount", "==", "d", ".", "rowCount", "{", "// fast path: view area is the same, return immediately", "return", "\n", "}", "\n\n", "// slow path: refill cache", "fNames", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "\n", "lNames", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "\n", "posts", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "\n", "deps", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "\n", "salary", ":=", "[", "]", "int", "{", "40000", ",", "38000", ",", "41000", ",", "32000", "}", "\n\n", "d", ".", "data", "=", "make", "(", "[", "]", "[", "]", "string", ",", "rowCount", ",", "rowCount", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "rowCount", ";", "i", "++", "{", "absIndex", ":=", "firstRow", "+", "i", "\n", "d", ".", "data", "[", "i", "]", "=", "make", "(", "[", "]", "string", ",", "columnInTable", ",", "columnInTable", ")", "\n", "d", ".", "data", "[", "i", "]", "[", "0", "]", "=", "fNames", "[", "absIndex", "%", "len", "(", "fNames", ")", "]", "\n", "d", ".", "<mask>", "[", "i", "]", "[", "1", "]", "=", "lNames", "[", "absIndex", "%", "len", "(", "lNames", ")", "]", "\n", "d", ".", "data", "[", "i", "]", "[", "2", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "100", "+", "absIndex", ")", "\n", "d", ".", "data", "[", "i", "]", "[", "3", "]", "=", "posts", "[", "absIndex", "%", "len", "(", "posts", ")", "]", "\n", "d", ".", "data", "[", "i", "]", "[", "4", "]", "=", "deps", "[", "absIndex", "%", "len", "(", "deps", ")", "]", "\n", "d", ".", "data", "[", "i", "]", "[", "5", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "salary", "[", "absIndex", "%", "len", "(", "salary", ")", "]", "/", "1000", ")", "\n", "}", "\n\n", "// do not forget to save the last values", "d", ".", "firstRow", "=", "firstRow", "\n", "d", ".", "rowCount", "=", "rowCount", "\n", "}" ]
14,419
all-14420
[ "HasVerified", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "c", "*", "CreatedBy", ")", "HasVerified", "(", ")", "bool", "{", "if", "c", "!=", "nil", "&&", "c", ".", "Verified", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
14,420
all-14421
[ "Main", "draws", "the", "image", "frame", "and", "returns", "the", "filename", ".", "This", "should", "only", "be", "used", "during", "testing", "." ]
[ "func", "Main", "(", "gc", "draw2d", ".", "GraphicContext", ",", "ext", "string", ")", "(", "string", ",", "error", ")", "{", "// Margin between the image and the frame", "const", "margin", "=", "30", "\n", "// Line width od the frame", "const", "lineWidth", "=", "3", "\n\n", "// Gopher image", "gopher", ":=", "samples", ".", "<mask>", "(", "\"", "\"", ",", "\"", "\"", ",", "ext", ")", "\n\n", "// Draw gopher", "err", ":=", "Draw", "(", "gc", ",", "gopher", ",", "297", ",", "210", ",", "margin", ",", "lineWidth", ")", "\n\n", "// Return the output filename", "return", "samples", ".", "Output", "(", "\"", "\"", ",", "ext", ")", ",", "err", "\n", "}" ]
14,421
all-14422
[ "Keys", "returns", "all", "keys", "from", "the", "node", "list" ]
[ "func", "(", "l", "*", "NodeList", ")", "Keys", "(", ")", "(", "keys", "[", "]", "[", "]", "byte", ")", "{", "node", ":=", "l", ".", "<mask>", "\n", "for", "node", "!=", "nil", "{", "key", ":=", "(", "*", "Item", ")", "(", "node", ".", "Item", "(", ")", ")", ".", "Bytes", "(", ")", "\n", "keys", "=", "append", "(", "keys", ",", "key", ")", "\n", "node", "=", "node", ".", "GetLink", "(", ")", "\n", "}", "\n\n", "return", "\n", "}" ]
14,422
all-14423
[ "OnGC", "adds", "a", "new", "function", "to", "be", "set", "of", "functions", "that", "will", "be", "executed", "on", "all", "subsequent", "GC", "runs", "receiving", "the", "GC", "d", "peer", "." ]
[ "func", "(", "peers", "*", "Peers", ")", "OnGC", "(", "callback", "func", "(", "*", "Peer", ")", ")", "{", "peers", ".", "Lock", "(", ")", "\n", "defer", "peers", ".", "Unlock", "(", ")", "\n\n", "// Although the array underlying peers.onGC might be accessed", "// without holding the lock in unlockAndNotify, we don't", "// support removing callbacks, so a simple append here is", "// safe.", "peers", ".", "onGC", "=", "append", "(", "peers", ".", "onGC", ",", "<mask>", ")", "\n", "}" ]
14,423
all-14424
[ "MustInit", "initializes", "fields", "of", "the", "DockerStatsEngine", "object", "." ]
[ "func", "(", "engine", "*", "DockerStatsEngine", ")", "MustInit", "(", "ctx", "context", ".", "Context", ",", "taskEngine", "ecsengine", ".", "TaskEngine", ",", "cluster", "string", ",", "containerInstanceArn", "string", ")", "error", "{", "derivedCtx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")", "\n", "engine", ".", "stopEngine", "=", "cancel", "\n\n", "engine", ".", "ctx", "=", "derivedCtx", "\n", "// TODO ensure that this is done only once per engine object", "seelog", ".", "Info", "(", "\"", "\"", ")", "\n", "engine", ".", "cluster", "=", "cluster", "\n", "engine", ".", "containerInstanceArn", "=", "containerInstanceArn", "\n\n", "var", "err", "error", "\n", "engine", ".", "resolver", ",", "err", "=", "newDockerContainerMetadataResolver", "(", "taskEngine", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Subscribe to the container change event stream", "err", "=", "engine", ".", "containerChangeEventStream", ".", "Subscribe", "(", "containerChangeHandler", ",", "<mask>", ".", "handleDockerEvents", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "err", "=", "engine", ".", "synchronizeState", "(", ")", "\n", "if", "err", "!=", "nil", "{", "seelog", ".", "Warnf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "go", "engine", ".", "waitToStop", "(", ")", "\n", "return", "nil", "\n", "}" ]
14,424
all-14425
[ "Removes", "the", "first", "suffix", "found" ]
[ "func", "(", "w", "*", "SnowballWord", ")", "RemoveFirstSuffix", "(", "suffixes", "...", "string", ")", "(", "suffix", "<mask>", ",", "suffixRunes", "[", "]", "rune", ")", "{", "return", "w", ".", "RemoveFirstSuffixIn", "(", "0", ",", "suffixes", "...", ")", "\n", "}" ]
14,425
all-14426
[ "CreateDatabase", "provides", "a", "mock", "function", "with", "given", "fields", ":" ]
[ "func", "(", "_m", "*", "ObjectStore", ")", "CreateDatabase", "(", ")", "error", "{", "ret", ":=", "_m", ".", "Called", "(", ")", "\n\n", "<mask>", "r0", "error", "\n", "if", "rf", ",", "ok", ":=", "ret", ".", "Get", "(", "0", ")", ".", "(", "func", "(", ")", "error", ")", ";", "ok", "{", "r0", "=", "rf", "(", ")", "\n", "}", "else", "{", "r0", "=", "ret", ".", "Error", "(", "0", ")", "\n", "}", "\n\n", "return", "r0", "\n", "}" ]
14,426
all-14427
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "MarkUndoableStateParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom31", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
14,427
all-14428
[ "GetConsoleMode", "gets", "the", "console", "mode", "for", "given", "file", "descriptor", "See", "http", ":", "//", "msdn", ".", "microsoft", ".", "com", "/", "en", "-", "us", "/", "library", "/", "windows", "/", "desktop", "/", "ms683167", "(", "v", "=", "vs", ".", "85", ")", ".", "aspx", "." ]
[ "func", "GetConsoleMode", "(", "<mask>", "uintptr", ")", "(", "mode", "uint32", ",", "err", "error", ")", "{", "err", "=", "syscall", ".", "GetConsoleMode", "(", "syscall", ".", "Handle", "(", "handle", ")", ",", "&", "mode", ")", "\n", "return", "mode", ",", "err", "\n", "}" ]
14,428
all-14429
[ "RespondWithStatus", "executes", "a", "template", "with", "provided", "data", "into", "buffer", "then", "writes", "the", "the", "status", "and", "body", "to", "the", "response", "writer", ".", "A", "panic", "will", "be", "raised", "if", "the", "template", "does", "not", "exist", "or", "fails", "to", "execute", "." ]
[ "func", "(", "t", "Templates", ")", "RespondWithStatus", "(", "w", "http", ".", "ResponseWriter", ",", "name", "string", ",", "data", "interface", "{", "}", ",", "status", "int", ")", "{", "buf", ":=", "bytes", ".", "Buffer", "{", "}", "\n", "tpl", ",", "ok", ":=", "t", ".", "templates", "[", "name", "]", "\n", "if", "!", "ok", "{", "panic", "(", "&", "Error", "{", "Err", ":", "ErrUnknownTemplate", ",", "Template", ":", "name", "}", ")", "\n", "}", "\n", "if", "err", ":=", "tpl", ".", "Execute", "(", "&", "buf", ",", "data", ")", ";", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "if", "t", ".", "contentType", "!=", "\"", "\"", "{", "w", ".", "Header", "(", ")", ".", "<mask>", "(", "\"", "\"", ",", "t", ".", "contentType", ")", "\n", "}", "\n", "if", "status", ">", "0", "{", "w", ".", "WriteHeader", "(", "status", ")", "\n", "}", "\n", "if", "_", ",", "err", ":=", "buf", ".", "WriteTo", "(", "w", ")", ";", "err", "!=", "nil", "{", "t", ".", "logf", "(", "\"", "\"", ",", "name", ",", "err", ")", "\n", "}", "\n", "}" ]
14,429
all-14430
[ "ActivateKey", "is", "a", "wrapper", "around", "gtk_window_activate_key", "()", "." ]
[ "func", "(", "v", "*", "Window", ")", "ActivateKey", "(", "<mask>", "*", "gdk", ".", "EventKey", ")", "bool", "{", "c", ":=", "C", ".", "gtk_window_activate_key", "(", "v", ".", "native", "(", ")", ",", "(", "*", "C", ".", "GdkEventKey", ")", "(", "unsafe", ".", "Pointer", "(", "event", ".", "Native", "(", ")", ")", ")", ")", "\n", "return", "gobool", "(", "c", ")", "\n", "}" ]
14,430
all-14431
[ "tar", "converts", "the", "directory", "at", "src", "and", "saves", "it", "to", "dst" ]
[ "func", "tarDirectory", "(", "src", ",", "dst", "string", ")", "error", "{", "// input is a stream of bytes from the archive of the directory at path", "input", ",", "err", ":=", "archive", ".", "Tar", "(", "src", ",", "archive", ".", "Uncompressed", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "src", ")", "\n", "}", "\n\n", "// creates the tar file", "outFile", ",", "err", ":=", "os", ".", "Create", "(", "dst", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "dst", ")", "\n", "}", "\n", "defer", "outFile", ".", "Close", "(", ")", "\n\n", "// copies the contents of the directory to the tar file", "// TODO: This can take quite some time, and should ideally be cancellable using a context.Context.", "_", ",", "err", "=", "io", ".", "Copy", "(", "outFile", ",", "<mask>", ")", "\n\n", "return", "err", "\n", "}" ]
14,431
all-14432
[ "Is", "given", "rune", "listed", "as", "a", "terminator" ]
[ "func", "isTerminator", "(", "r", "rune", ",", "terminator", "...", "rune", ")", "bool", "{", "for", "_", ",", "t", ":=", "range", "terminator", "{", "if", "r", "==", "t", "{", "return", "<mask>", "\n", "}", "\n", "}", "\n", "return", "unicode", ".", "IsSpace", "(", "r", ")", "||", "!", "unicode", ".", "IsPrint", "(", "r", ")", "\n", "}" ]
14,432
all-14433
[ "AddFlags", "adds", "flags", "to", "the", "FlagSet", "that", "populate", "the", "GCS", "upload", "options", "struct", "given", "." ]
[ "func", "(", "o", "*", "Options", ")", "AddFlags", "(", "fs", "*", "flag", ".", "FlagSet", ")", "{", "fs", ".", "StringVar", "(", "&", "o", ".", "SubDir", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "fs", ".", "StringVar", "(", "&", "o", ".", "PathStrategy", ",", "\"", "\"", ",", "prowapi", ".", "PathStrategyExplicit", ",", "\"", "\"", ")", "\n", "<mask>", ".", "StringVar", "(", "&", "o", ".", "DefaultOrg", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "fs", ".", "StringVar", "(", "&", "o", ".", "DefaultRepo", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "fs", ".", "Var", "(", "&", "o", ".", "gcsPath", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "fs", ".", "StringVar", "(", "&", "o", ".", "GcsCredentialsFile", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "fs", ".", "BoolVar", "(", "&", "o", ".", "DryRun", ",", "\"", "\"", ",", "true", ",", "\"", "\"", ")", "\n", "}" ]
14,433
all-14434
[ "Do", "executes", "Emulation", ".", "setCPUThrottlingRate", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "SetCPUThrottlingRateParams", ")", "Do", "(", "ctx", "<mask>", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetCPUThrottlingRate", ",", "p", ",", "nil", ")", "\n", "}" ]
14,434
all-14435
[ "New", "fixture", "instance", "that", "will", "work", "with", "the", "database" ]
[ "func", "New", "(", "db", "*", "sql", ".", "<mask>", ",", "tables", "Tables", ")", "Fixture", "{", "fixture", ":=", "Fixture", "{", "db", ":", "db", ",", "Tables", ":", "tables", "}", "\n", "return", "fixture", "\n", "}" ]
14,435
all-14436
[ "GetManifest", "returns", "the", "image", "s", "manifest", "along", "with", "its", "MIME", "type", "(", "which", "may", "be", "empty", "when", "it", "can", "t", "be", "determined", "but", "the", "manifest", "is", "available", ")", ".", "It", "may", "use", "a", "remote", "(", "=", "slow", ")", "service", "." ]
[ "func", "(", "s", "*", "ostreeImageSource", ")", "GetManifest", "(", "ctx", "context", ".", "<mask>", ",", "instanceDigest", "*", "digest", ".", "Digest", ")", "(", "[", "]", "byte", ",", "string", ",", "error", ")", "{", "if", "instanceDigest", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Errorf", "(", "`Manifest lists are not supported by \"ostree:\"`", ")", "\n", "}", "\n", "if", "s", ".", "repo", "==", "nil", "{", "repo", ",", "err", ":=", "openRepo", "(", "s", ".", "ref", ".", "repo", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "s", ".", "repo", "=", "repo", "\n", "}", "\n\n", "b", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "ref", ".", "branchName", ")", "\n", "found", ",", "out", ",", "err", ":=", "readMetadata", "(", "s", ".", "repo", ",", "b", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "!", "found", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "m", ":=", "[", "]", "byte", "(", "out", ")", "\n", "return", "m", ",", "manifest", ".", "GuessMIMEType", "(", "m", ")", ",", "nil", "\n", "}" ]
14,436
all-14437
[ "compactLogs", "takes", "the", "last", "inclusive", "index", "of", "a", "snapshot", "and", "trims", "the", "logs", "that", "are", "no", "longer", "needed", "." ]
[ "func", "(", "r", "*", "Raft", ")", "compactLogs", "(", "snapIdx", "uint64", ")", "error", "{", "defer", "metrics", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n", "// Determine log ranges to compact", "minLog", ",", "err", ":=", "r", ".", "logs", ".", "FirstIndex", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "// Check if we have enough logs to truncate", "lastLogIdx", ",", "_", ":=", "r", ".", "getLastLog", "(", ")", "\n", "if", "lastLogIdx", "<=", "r", ".", "conf", ".", "TrailingLogs", "{", "return", "nil", "\n", "}", "\n\n", "// Truncate up to the end of the snapshot, or `TrailingLogs`", "// back from the head, which ever is further back. This ensures", "// at least `TrailingLogs` entries, but does not allow logs", "// after the snapshot to be removed.", "maxLog", ":=", "<mask>", "(", "snapIdx", ",", "lastLogIdx", "-", "r", ".", "conf", ".", "TrailingLogs", ")", "\n\n", "// Log this", "r", ".", "logger", ".", "Info", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "minLog", ",", "maxLog", ")", ")", "\n\n", "// Compact the logs", "if", "err", ":=", "r", ".", "logs", ".", "DeleteRange", "(", "minLog", ",", "maxLog", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
14,437
all-14438
[ "terminates", "reports", "whether", "fn", "is", "supposed", "to", "return", "that", "is", "if", "it", "has", "at", "least", "one", "theoretic", "path", "that", "returns", "from", "the", "function", ".", "Explicit", "panics", "do", "not", "count", "as", "terminating", "." ]
[ "func", "terminates", "(", "fn", "*", "ssa", ".", "Function", ")", "bool", "{", "if", "fn", ".", "Blocks", "==", "nil", "{", "// assuming that a function terminates is the conservative", "// choice", "return", "true", "\n", "}", "\n\n", "for", "_", ",", "block", ":=", "range", "fn", ".", "Blocks", "{", "if", "len", "(", "block", ".", "Instrs", ")", "==", "0", "{", "continue", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "block", ".", "Instrs", "[", "len", "(", "<mask>", ".", "Instrs", ")", "-", "1", "]", ".", "(", "*", "ssa", ".", "Return", ")", ";", "ok", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
14,438
all-14439
[ "ExtraLinks", "fetches", "started", ".", "json", "and", "extracts", "links", "from", "metadata", ".", "links", "." ]
[ "func", "(", "sg", "*", "Spyglass", ")", "ExtraLinks", "(", "src", "string", ")", "(", "[", "]", "ExtraLink", ",", "error", ")", "{", "artifacts", ",", "err", ":=", "sg", ".", "FetchArtifacts", "(", "src", ",", "\"", "\"", ",", "1000000", ",", "[", "]", "string", "{", "\"", "\"", "}", ")", "\n", "// Failing to find started.json is okay, just return nothing quietly.", "if", "err", "!=", "nil", "||", "len", "(", "artifacts", ")", "==", "0", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Debugf", "(", "\"", "\"", ")", "\n", "return", "nil", ",", "nil", "\n", "}", "\n", "// Failing to read an artifact we already know to exist shouldn't happen, so that's an error.", "content", ",", "err", ":=", "artifacts", "[", "0", "]", ".", "ReadAll", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// Being unable to parse a successfully fetched started.json correctly is also an error.", "started", ":=", "metadata", ".", "Started", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "content", ",", "&", "started", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// Not having any links is fine.", "links", ",", "ok", ":=", "started", ".", "Metadata", ".", "Meta", "(", "\"", "\"", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "extraLinks", ":=", "make", "(", "[", "]", "ExtraLink", ",", "0", ",", "len", "(", "*", "links", ")", ")", "\n", "for", "_", ",", "name", ":=", "range", "links", ".", "Keys", "(", ")", "{", "m", ",", "ok", ":=", "links", ".", "Meta", "(", "name", ")", "\n", "if", "!", "ok", "{", "// This should never happen, because Keys() should only return valid Metas.", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "name", ",", "artifacts", "[", "0", "]", ".", "CanonicalLink", "(", ")", ")", "\n", "continue", "\n", "}", "\n", "s", ":=", "m", ".", "Strings", "(", ")", "\n", "link", ":=", "ExtraLink", "{", "Name", ":", "name", ",", "URL", ":", "s", "[", "\"", "\"", "]", ",", "Description", ":", "s", "[", "\"", "\"", "]", ",", "}", "\n", "if", "link", ".", "URL", "==", "\"", "\"", "||", "link", ".", "Name", "==", "\"", "\"", "{", "continue", "\n", "}", "\n", "extraLinks", "=", "append", "(", "extraLinks", ",", "<mask>", ")", "\n", "}", "\n", "return", "extraLinks", ",", "nil", "\n", "}" ]
14,439
all-14440
[ "protoFileInfo", "extracts", "metadata", "from", "a", "proto", "file", ".", "The", "proto", "extension", "already", "parses", "these", "and", "stores", "metadata", "in", "proto", ".", "FileInfo", "so", "this", "is", "just", "processing", "relevant", "options", "." ]
[ "func", "protoFileInfo", "(", "path_", "string", ",", "protoInfo", "proto", ".", "FileInfo", ")", "fileInfo", "{", "info", ":=", "fileNameInfo", "(", "path_", ")", "\n\n", "// Look for \"option go_package\". If there's no / in the package option, then", "// it's just a simple package name, not a full import path.", "for", "_", ",", "opt", ":=", "range", "protoInfo", ".", "Options", "{", "if", "opt", ".", "Key", "!=", "\"", "\"", "{", "continue", "\n", "}", "\n", "if", "strings", ".", "LastIndexByte", "(", "opt", ".", "Value", ",", "'/'", ")", "==", "-", "1", "{", "info", ".", "packageName", "=", "opt", ".", "Value", "\n", "}", "else", "{", "if", "i", ":=", "strings", ".", "LastIndexByte", "(", "opt", ".", "Value", ",", "';'", ")", ";", "i", "!=", "-", "1", "{", "info", ".", "importPath", "=", "opt", ".", "Value", "[", ":", "i", "]", "\n", "info", ".", "packageName", "=", "opt", ".", "Value", "[", "i", "+", "1", ":", "]", "\n", "}", "else", "{", "info", ".", "importPath", "=", "opt", ".", "Value", "\n", "info", ".", "packageName", "=", "path", ".", "Base", "(", "opt", ".", "Value", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// Set the Go package name from the proto package name if there was no", "// option go_package.", "if", "info", ".", "packageName", "==", "\"", "\"", "&&", "protoInfo", ".", "PackageName", "!=", "\"", "\"", "{", "info", ".", "packageName", "=", "strings", ".", "Replace", "(", "protoInfo", ".", "PackageName", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n", "}", "\n\n", "<mask>", ".", "imports", "=", "protoInfo", ".", "Imports", "\n", "info", ".", "hasServices", "=", "protoInfo", ".", "HasServices", "\n", "return", "info", "\n", "}" ]
14,440
all-14441
[ "LogClose", "will", "attempt", "a", "close", "an", "log", "any", "error" ]
[ "func", "LogClose", "(", "c", "<mask>", ".", "Closer", ")", "{", "if", "err", ":=", "c", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
14,441
all-14442
[ "Send", "sends", "a", "message", "on", "the", "channel", "associated", "with", "clientID", "." ]
[ "func", "Send", "(", "c", "context", ".", "Context", ",", "clientID", ",", "message", "string", ")", "error", "{", "req", ":=", "&", "pb", ".", "SendMessageRequest", "{", "ApplicationKey", ":", "&", "clientID", ",", "Message", ":", "&", "<mask>", ",", "}", "\n", "resp", ":=", "&", "basepb", ".", "VoidProto", "{", "}", "\n", "return", "remapError", "(", "internal", ".", "Call", "(", "c", ",", "service", ",", "\"", "\"", ",", "req", ",", "resp", ")", ")", "\n", "}" ]
14,442
all-14443
[ "GuessMIMEType", "guesses", "MIME", "type", "of", "a", "manifest", "and", "returns", "it", "_if", "it", "is", "recognized_", "or", "if", "unknown", "or", "unrecognized", ".", "FIXME?", "We", "should", "in", "general", "prefer", "out", "-", "of", "-", "band", "MIME", "type", "instead", "of", "blindly", "parsing", "the", "manifest", "but", "we", "may", "not", "have", "such", "metadata", "available", "(", "e", ".", "g", ".", "when", "the", "manifest", "is", "a", "local", "file", ")", "." ]
[ "func", "GuessMIMEType", "(", "manifest", "[", "]", "<mask>", ")", "string", "{", "// A subset of manifest fields; the rest is silently ignored by json.Unmarshal.", "// Also docker/distribution/manifest.Versioned.", "meta", ":=", "struct", "{", "MediaType", "string", "`json:\"mediaType\"`", "\n", "SchemaVersion", "int", "`json:\"schemaVersion\"`", "\n", "Signatures", "interface", "{", "}", "`json:\"signatures\"`", "\n", "}", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "manifest", ",", "&", "meta", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n\n", "switch", "meta", ".", "MediaType", "{", "case", "DockerV2Schema2MediaType", ",", "DockerV2ListMediaType", ":", "// A recognized type.", "return", "meta", ".", "MediaType", "\n", "}", "\n", "// this is the only way the function can return DockerV2Schema1MediaType, and recognizing that is essential for stripping the JWS signatures = computing the correct manifest digest.", "switch", "meta", ".", "SchemaVersion", "{", "case", "1", ":", "if", "meta", ".", "Signatures", "!=", "nil", "{", "return", "DockerV2Schema1SignedMediaType", "\n", "}", "\n", "return", "DockerV2Schema1MediaType", "\n", "case", "2", ":", "// best effort to understand if this is an OCI image since mediaType", "// isn't in the manifest for OCI anymore", "// for docker v2s2 meta.MediaType should have been set. But given the data, this is our best guess.", "ociMan", ":=", "struct", "{", "Config", "struct", "{", "MediaType", "string", "`json:\"mediaType\"`", "\n", "}", "`json:\"config\"`", "\n", "Layers", "[", "]", "imgspecv1", ".", "Descriptor", "`json:\"layers\"`", "\n", "}", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "manifest", ",", "&", "ociMan", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "ociMan", ".", "Config", ".", "MediaType", "==", "imgspecv1", ".", "MediaTypeImageConfig", "&&", "len", "(", "ociMan", ".", "Layers", ")", "!=", "0", "{", "return", "imgspecv1", ".", "MediaTypeImageManifest", "\n", "}", "\n", "ociIndex", ":=", "struct", "{", "Manifests", "[", "]", "imgspecv1", ".", "Descriptor", "`json:\"manifests\"`", "\n", "}", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "manifest", ",", "&", "ociIndex", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "len", "(", "ociIndex", ".", "Manifests", ")", "!=", "0", "&&", "ociIndex", ".", "Manifests", "[", "0", "]", ".", "MediaType", "==", "imgspecv1", ".", "MediaTypeImageManifest", "{", "return", "imgspecv1", ".", "MediaTypeImageIndex", "\n", "}", "\n", "return", "DockerV2Schema2MediaType", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
14,443
all-14444
[ "Analyze", "creates", "an", "API", "descriptor", "from", "raw", "resources", "and", "types", "." ]
[ "func", "(", "a", "*", "APIAnalyzer", ")", "Analyze", "(", ")", "(", "*", "<mask>", ".", "APIDescriptor", ",", "error", ")", "{", "descriptor", ":=", "gen", ".", "APIDescriptor", "{", "Version", ":", "a", ".", "Version", ",", "Resources", ":", "make", "(", "map", "[", "string", "]", "*", "gen", ".", "Resource", ")", ",", "Types", ":", "make", "(", "map", "[", "string", "]", "*", "gen", ".", "ObjectDataType", ")", ",", "}", "\n", "a", ".", "descriptor", "=", "&", "descriptor", "\n\n", "// Sort resource names so iterations are always done in the same order", "rawResourceNames", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "a", ".", "RawResources", ")", ")", "\n", "idx", ":=", "0", "\n", "for", "name", ":=", "range", "a", ".", "RawResources", "{", "rawResourceNames", "[", "idx", "]", "=", "name", "\n", "idx", "++", "\n", "}", "\n", "sort", ".", "Strings", "(", "rawResourceNames", ")", "\n\n", "// Analyze each resource", "for", "_", ",", "name", ":=", "range", "rawResourceNames", "{", "err", ":=", "a", ".", "AnalyzeResource", "(", "name", ",", "a", ".", "RawResources", "[", "name", "]", ",", "&", "descriptor", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "// We're done", "a", ".", "Registry", ".", "FinalizeTypeNames", "(", "&", "descriptor", ")", "\n", "return", "&", "descriptor", ",", "nil", "\n", "}" ]
14,444
all-14445
[ "Shuffle", "the", "given", "byte", "string" ]
[ "func", "Shuffle", "(", "bs", "[", "]", "byte", ")", "{", "n", ":=", "len", "(", "bs", ")", "\n", "for", "i", ":=", "n", "-", "1", ";", "i", ">", "0", ";", "i", "--", "{", "rand", ".", "Seed", "(", "<mask>", ".", "Now", "(", ")", ".", "UnixNano", "(", ")", ")", "\n", "j", ":=", "rand", ".", "Intn", "(", "i", "+", "1", ")", "\n", "bs", "[", "i", "]", ",", "bs", "[", "j", "]", "=", "bs", "[", "j", "]", ",", "bs", "[", "i", "]", "\n", "}", "\n", "}" ]
14,445
all-14446
[ "Function", "that", "exposes", "all", "Agent", "Metrics", "on", "a", "given", "port", "." ]
[ "func", "(", "engine", "*", "MetricsEngine", ")", "publishMetrics", "(", ")", "{", "<mask>", "func", "(", ")", "{", "// Because we are using the DefaultRegisterer in Prometheus, we can use", "// the promhttp.Handler() function. In future cases for custom registers,", "// we can use promhttp.HandlerFor(customRegisterer, promhttp.HandlerOpts{})", "http", ".", "Handle", "(", "\"", "\"", ",", "promhttp", ".", "Handler", "(", ")", ")", "\n", "err", ":=", "http", ".", "ListenAndServe", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "config", ".", "AgentPrometheusExpositionPort", ")", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "seelog", ".", "Errorf", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "}", "(", ")", "\n", "}" ]
14,446
all-14447
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "EventBindingCalled", ")", "UnmarshalJSON", "(", "<mask>", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoRuntime36", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
14,447
all-14448
[ "Count", "adds", "n", "to", "bucket", "." ]
[ "func", "(", "c", "*", "<mask>", ")", "Count", "(", "bucket", "string", ",", "n", "interface", "{", "}", ")", "{", "if", "c", ".", "skip", "(", ")", "{", "return", "\n", "}", "\n", "c", ".", "conn", ".", "metric", "(", "c", ".", "prefix", ",", "bucket", ",", "n", ",", "\"", "\"", ",", "c", ".", "rate", ",", "c", ".", "tags", ")", "\n", "}" ]
14,448
all-14449
[ "Calculates", "the", "per", "-", "element", "absolute", "difference", "between", "an", "array", "and", "a", "scalar", "." ]
[ "func", "AbsDiffScalar", "(", "src", "*", "IplImage", ",", "value", "Scalar", ",", "dst", "*", "IplImage", ")", "{", "C", ".", "cvAbsDiffS", "(", "unsafe", ".", "Pointer", "(", "src", ")", ",", "unsafe", ".", "Pointer", "(", "dst", ")", ",", "(", "C", ".", "CvScalar", ")", "(", "<mask>", ")", ",", ")", "\n", "}" ]
14,449
all-14450
[ "Customize", "wraps", "the", "customization", "of", "a", "virtual", "machine", "and", "the", "subsequent", "waiting", "of", "the", "task", "." ]
[ "func", "Customize", "(", "vm", "*", "object", ".", "VirtualMachine", ",", "spec", "types", ".", "CustomizationSpec", ")", "error", "{", "<mask>", ".", "Printf", "(", "\"", "\"", ",", "vm", ".", "InventoryPath", ")", "\n", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "provider", ".", "DefaultAPITimeout", ")", "\n", "defer", "cancel", "(", ")", "\n", "task", ",", "err", ":=", "vm", ".", "Customize", "(", "ctx", ",", "spec", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "tctx", ",", "tcancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "provider", ".", "DefaultAPITimeout", ")", "\n", "defer", "tcancel", "(", ")", "\n", "return", "task", ".", "Wait", "(", "tctx", ")", "\n", "}" ]
14,450
all-14451
[ "verifyHandler", "ensures", "that", "the", "given", "t", "is", "a", "function", "with", "the", "following", "signature", ":", "func", "(", "json", ".", "Context", "*", "ArgType", ")", "(", "*", "ResType", "error", ")" ]
[ "func", "verifyHandler", "(", "t", "reflect", ".", "Type", ")", "error", "{", "if", "t", ".", "NumIn", "(", ")", "!=", "2", "||", "t", ".", "NumOut", "(", ")", "!=", "2", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "isStructPtr", ":=", "func", "(", "t", "reflect", ".", "Type", ")", "bool", "{", "return", "t", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "&&", "t", ".", "Elem", "(", ")", ".", "Kind", "(", ")", "==", "reflect", ".", "Struct", "\n", "}", "\n", "isMap", ":=", "func", "(", "t", "reflect", ".", "<mask>", ")", "bool", "{", "return", "t", ".", "Kind", "(", ")", "==", "reflect", ".", "Map", "&&", "t", ".", "Key", "(", ")", ".", "Kind", "(", ")", "==", "reflect", ".", "String", "\n", "}", "\n", "validateArgRes", ":=", "func", "(", "t", "reflect", ".", "Type", ",", "name", "string", ")", "error", "{", "if", "!", "isStructPtr", "(", "t", ")", "&&", "!", "isMap", "(", "t", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "return", "nil", "\n", "}", "\n\n", "if", "t", ".", "In", "(", "0", ")", "!=", "typeOfContext", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "err", ":=", "validateArgRes", "(", "t", ".", "In", "(", "1", ")", ",", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "validateArgRes", "(", "t", ".", "Out", "(", "0", ")", ",", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "!", "t", ".", "Out", "(", "1", ")", ".", "AssignableTo", "(", "typeOfError", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
14,451
all-14452
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "GetBrowserContextsParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoTarget11", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
14,452
all-14453
[ "Foreach", "()", "is", "a", "wrapper", "around", "gtk_print_settings_foreach", "()", "." ]
[ "func", "(", "ps", "*", "PrintSettings", ")", "ForEach", "(", "cb", "PrintSettingsCallback", ",", "userData", "uintptr", ")", "{", "printSettingsCallbackRegistry", ".", "Lock", "(", ")", "\n", "id", ":=", "printSettingsCallbackRegistry", ".", "next", "\n", "printSettingsCallbackRegistry", ".", "<mask>", "++", "\n", "printSettingsCallbackRegistry", ".", "m", "[", "id", "]", "=", "printSettingsCallbackData", "{", "fn", ":", "cb", ",", "userData", ":", "userData", "}", "\n", "printSettingsCallbackRegistry", ".", "Unlock", "(", ")", "\n\n", "C", ".", "_gtk_print_settings_foreach", "(", "ps", ".", "native", "(", ")", ",", "C", ".", "gpointer", "(", "uintptr", "(", "id", ")", ")", ")", "\n", "}" ]
14,453
all-14454
[ "release", "the", "mapping", "of", "a", "buffer", "object", "s", "data", "store", "into", "the", "client", "s", "address", "space" ]
[ "func", "UnmapNamedBuffer", "(", "buffer", "uint32", ")", "bool", "{", "<mask>", ",", "_", ",", "_", ":=", "syscall", ".", "Syscall", "(", "gpUnmapNamedBuffer", ",", "1", ",", "uintptr", "(", "buffer", ")", ",", "0", ",", "0", ")", "\n", "return", "ret", "!=", "0", "\n", "}" ]
14,454
all-14455
[ "ProjectNames", "returns", "the", "names", "of", "all", "available", "projects", "." ]
[ "func", "(", "c", "*", "ClusterTx", ")", "ProjectNames", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "stmt", ":=", "\"", "\"", "\n\n", "<mask>", ",", "err", ":=", "query", ".", "SelectStrings", "(", "c", ".", "tx", ",", "stmt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "names", ",", "nil", "\n", "}" ]
14,455
all-14456
[ "/", "*", "RemoveLogger", "will", "run", "ShutdownLogger", "on", "the", "given", "logger", "and", "then", "remove", "the", "given", "Logger", "from", "the", "list", "in", "Base" ]
[ "func", "(", "b", "*", "Base", ")", "RemoveLogger", "(", "logger", "Logger", ")", "error", "{", "for", "idx", ",", "rLogger", ":=", "<mask>", "b", ".", "loggers", "{", "if", "rLogger", "==", "logger", "{", "err", ":=", "rLogger", ".", "ShutdownLogger", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "b", ".", "loggers", "[", "idx", "]", "=", "b", ".", "loggers", "[", "len", "(", "b", ".", "loggers", ")", "-", "1", "]", "\n", "b", ".", "loggers", "[", "len", "(", "b", ".", "loggers", ")", "-", "1", "]", "=", "nil", "\n", "b", ".", "loggers", "=", "b", ".", "loggers", "[", ":", "len", "(", "b", ".", "loggers", ")", "-", "1", "]", "\n", "return", "nil", "\n", "}", "\n", "}", "\n\n", "// Remove any hook instances the logger has", "for", "idx", ",", "hookLogger", ":=", "range", "b", ".", "hookPreQueue", "{", "if", "hookLogger", "==", "logger", "{", "b", ".", "hookPreQueue", "[", "idx", "]", "=", "b", ".", "hookPreQueue", "[", "len", "(", "b", ".", "hookPreQueue", ")", "-", "1", "]", "\n", "b", ".", "hookPreQueue", "[", "len", "(", "b", ".", "hookPreQueue", ")", "-", "1", "]", "=", "nil", "\n", "b", ".", "hookPreQueue", "=", "b", ".", "hookPreQueue", "[", ":", "len", "(", "b", ".", "hookPreQueue", ")", "-", "1", "]", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
14,456
all-14457
[ "OpenStream", "will", "open", "a", "stream", "and", "continuously", "forward", "events", "to", "the", "specified", "receiver", "until", "the", "stream", "is", "closed", ".", "If", "a", "token", "is", "present", "it", "will", "be", "used", "to", "resume", "the", "stream", ".", "The", "provided", "opened", "function", "is", "called", "when", "the", "stream", "has", "been", "opened", "the", "first", "time", ".", "The", "passed", "manager", "is", "called", "with", "errors", "returned", "by", "the", "underlying", "change", "stream", ".", "The", "managers", "result", "is", "used", "to", "determine", "if", "the", "stream", "should", "be", "opened", "again", ".", "The", "stream", "automatically", "resumes", "on", "errors", "using", "an", "internally", "stored", "resume", "token", ".", "Applications", "that", "need", "more", "control", "should", "store", "the", "token", "externally", "and", "reopen", "the", "stream", "manually", "to", "resume", "from", "a", "specific", "position", "." ]
[ "func", "OpenStream", "(", "store", "*", "Store", ",", "model", "Model", ",", "token", "[", "]", "byte", ",", "receiver", "Receiver", ",", "opened", "func", "(", ")", ",", "manager", "func", "(", "error", ")", "bool", ")", "*", "Stream", "{", "// prepare resume token", "var", "resumeToken", "*", "bson", ".", "Raw", "\n\n", "// create resume token if available", "if", "token", "!=", "nil", "{", "resumeToken", "=", "&", "bson", ".", "Raw", "{", "Kind", ":", "bson", ".", "ElementDocument", ",", "Data", ":", "token", ",", "}", "\n", "}", "\n\n", "// create stream", "s", ":=", "&", "Stream", "{", "store", ":", "store", ",", "model", ":", "<mask>", ",", "token", ":", "resumeToken", ",", "receiver", ":", "receiver", ",", "opened", ":", "opened", ",", "manager", ":", "manager", ",", "}", "\n\n", "// open stream", "go", "s", ".", "open", "(", ")", "\n\n", "return", "s", "\n", "}" ]
14,457
all-14458
[ "Initialize", "sets", "the", "fields", "of", "Nvidia", "GPU", "Manager", "struct" ]
[ "func", "(", "n", "*", "NvidiaGPUManager", ")", "Initialize", "(", ")", "error", "{", "if", "GPUInfoFileExists", "(", ")", "{", "// GPU info file found", "gpuJSON", ",", "err", ":=", "GetGPUInfoJSON", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "var", "nvidiaGPUInfo", "NvidiaGPUManager", "\n", "err", "=", "json", ".", "Unmarshal", "(", "gpuJSON", ",", "&", "nvidiaGPUInfo", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "n", ".", "SetDriverVersion", "(", "nvidiaGPUInfo", ".", "GetDriverVersion", "(", ")", ")", "\n", "nvidiaGPUInfo", ".", "lock", ".", "RLock", "(", ")", "\n", "gpuIDs", ":=", "nvidiaGPUInfo", ".", "GetGPUIDsUnsafe", "(", ")", "\n", "nvidiaGPUInfo", ".", "lock", ".", "RUnlock", "(", ")", "\n", "n", ".", "SetGPUIDs", "(", "gpuIDs", ")", "\n", "n", ".", "SetDevices", "(", ")", "\n", "}", "else", "{", "seelog", ".", "<mask>", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
14,458
all-14459
[ "removeConnection", "will", "check", "remove", "the", "connection", "if", "it", "exists", "on", "connsPtr", "and", "returns", "whether", "it", "removed", "the", "connection", "." ]
[ "func", "(", "p", "*", "Peer", ")", "removeConnection", "(", "connsPtr", "*", "[", "]", "*", "Connection", ",", "changed", "*", "Connection", ")", "bool", "{", "conns", ":=", "*", "connsPtr", "\n", "for", "i", ",", "c", ":=", "<mask>", "conns", "{", "if", "c", "==", "changed", "{", "// Remove the connection by moving the last item forward, and slicing the list.", "last", ":=", "len", "(", "conns", ")", "-", "1", "\n", "conns", "[", "i", "]", ",", "conns", "[", "last", "]", "=", "conns", "[", "last", "]", ",", "nil", "\n", "*", "connsPtr", "=", "conns", "[", ":", "last", "]", "\n", "return", "true", "\n", "}", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
14,459
all-14460
[ "schemaHostVirtualSwitchSpec", "returns", "schema", "items", "for", "resources", "that", "need", "to", "work", "with", "a", "HostVirtualSwitchSpec", "such", "as", "virtual", "switches", "." ]
[ "func", "schemaHostVirtualSwitchSpec", "(", ")", "map", "[", "string", "]", "*", "schema", ".", "Schema", "{", "s", ":=", "map", "[", "string", "]", "*", "schema", ".", "Schema", "{", "// HostVirtualSwitchSpec", "\"", "\"", ":", "{", "Type", ":", "schema", ".", "TypeInt", ",", "Optional", ":", "true", ",", "Description", ":", "\"", "\"", ",", "Default", ":", "1500", ",", "ValidateFunc", ":", "validation", ".", "IntBetween", "(", "1", ",", "9000", ")", ",", "}", ",", "\"", "\"", ":", "{", "<mask>", ":", "schema", ".", "TypeInt", ",", "Optional", ":", "true", ",", "Description", ":", "\"", "\"", ",", "Default", ":", "128", ",", "ValidateFunc", ":", "validation", ".", "IntBetween", "(", "0", ",", "1024", ")", ",", "}", ",", "}", "\n", "structure", ".", "MergeSchema", "(", "s", ",", "schemaHostVirtualSwitchBondBridge", "(", ")", ")", "\n", "structure", ".", "MergeSchema", "(", "s", ",", "schemaHostNetworkPolicy", "(", ")", ")", "\n", "return", "s", "\n", "}" ]
14,460
all-14461
[ "IsEmpty", "tests", "to", "see", "if", "this", "List", "has", "any", "elements", "present", "." ]
[ "func", "(", "l", "*", "List", ")", "IsEmpty", "(", ")", "bool", "{", "l", ".", "<mask>", ".", "RLock", "(", ")", "\n", "defer", "l", ".", "key", ".", "RUnlock", "(", ")", "\n", "return", "0", "==", "len", "(", "l", ".", "underlyer", ")", "\n", "}" ]
14,461
all-14462
[ "fetchWithDefault", "will", "use", "reference", "fields", "of", "the", "passed", "peer", "object", "to", "look", "up", "and", "return", "an", "existing", "matching", "peer", ".", "If", "no", "matching", "peer", "is", "found", "the", "passed", "peer", "is", "saved", "and", "returned", "." ]
[ "func", "(", "peers", "*", "Peers", ")", "fetchWithDefault", "(", "peer", "*", "Peer", ")", "*", "Peer", "{", "peers", ".", "Lock", "(", ")", "\n", "var", "pending", "peersPendingNotifications", "\n", "defer", "peers", ".", "unlockAndNotify", "(", "&", "pending", ")", "\n\n", "if", "existingPeer", ",", "found", ":=", "peers", ".", "byName", "[", "peer", ".", "Name", "]", ";", "found", "{", "existingPeer", ".", "localRefCount", "++", "\n", "return", "existingPeer", "\n", "}", "\n\n", "peers", ".", "byName", "[", "peer", ".", "Name", "]", "=", "peer", "\n", "peers", ".", "addByShortID", "(", "peer", ",", "&", "pending", ")", "\n", "<mask>", ".", "localRefCount", "++", "\n", "return", "peer", "\n", "}" ]
14,462
all-14463
[ "NewTCPFrameRelay", "relays", "frames", "from", "one", "connection", "to", "another", ".", "It", "reads", "and", "writes", "frames", "using", "the", "TChannel", "frame", "functions", "." ]
[ "func", "NewTCPFrameRelay", "(", "dests", "[", "]", "string", ",", "modifier", "func", "(", "bool", ",", "*", "tchannel", ".", "Frame", ")", "*", "tchannel", ".", "Frame", ")", "(", "Relay", ",", "error", ")", "{", "<mask>", "err", "error", "\n", "r", ":=", "&", "tcpFrameRelay", "{", "modifier", ":", "modifier", "}", "\n\n", "r", ".", "tcpRelay", ",", "err", "=", "newTCPRelay", "(", "dests", ",", "r", ".", "handleConnFrameRelay", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "r", ",", "nil", "\n", "}" ]
14,463
all-14464
[ "/", "*", "Errorf", "uses", "msg", "as", "a", "format", "string", "with", "subsequent", "parameters", "as", "values", "and", "logs", "the", "resulting", "message", "to", "all", "added", "loggers", "at", "LogLevel", ".", "LevelError" ]
[ "func", "(", "la", "*", "LogAdapter", ")", "Errorf", "(", "msg", "string", ",", "a", "...", "<mask>", "{", "}", ")", "error", "{", "return", "la", ".", "Log", "(", "LevelError", ",", "nil", ",", "msg", ",", "a", "...", ")", "\n", "}" ]
14,464
all-14465
[ "IntrospectState", "returns", "the", "runtime", "state", "for", "this", "connection", "." ]
[ "func", "(", "c", "*", "Connection", ")", "IntrospectState", "(", "opts", "*", "IntrospectionOptions", ")", "ConnectionRuntimeState", "{", "c", ".", "stateMut", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "stateMut", ".", "RUnlock", "(", ")", "\n\n", "// TODO(prashantv): Add total number of health checks, and health check options.", "state", ":=", "ConnectionRuntimeState", "{", "ID", ":", "c", ".", "connID", ",", "ConnectionState", ":", "c", ".", "state", ".", "String", "(", ")", ",", "LocalHostPort", ":", "c", ".", "conn", ".", "LocalAddr", "(", ")", ".", "String", "(", ")", ",", "RemoteHostPort", ":", "c", ".", "conn", ".", "RemoteAddr", "(", ")", ".", "String", "(", ")", ",", "OutboundHostPort", ":", "c", ".", "outboundHP", ",", "RemotePeer", ":", "c", ".", "remotePeerInfo", ",", "InboundExchange", ":", "c", ".", "inbound", ".", "IntrospectState", "(", "opts", ")", ",", "OutboundExchange", ":", "c", ".", "outbound", ".", "IntrospectState", "(", "opts", ")", ",", "HealthChecks", ":", "c", ".", "healthCheckHistory", ".", "asBools", "(", ")", ",", "LastActivity", ":", "c", ".", "lastActivity", ".", "Load", "(", ")", ",", "}", "\n", "if", "c", ".", "relay", "!=", "nil", "{", "<mask>", ".", "Relayer", "=", "c", ".", "relay", ".", "IntrospectState", "(", "opts", ")", "\n", "}", "\n", "return", "state", "\n", "}" ]
14,465
all-14466
[ "PutFileWriter", "writes", "a", "file", "to", "PFS", ".", "NOTE", ":", "PutFileWriter", "returns", "an", "io", ".", "WriteCloser", "you", "must", "call", "Close", "on", "it", "when", "you", "are", "done", "writing", "." ]
[ "func", "(", "c", "APIClient", ")", "PutFileWriter", "(", "repoName", "string", ",", "commitID", "string", ",", "path", "string", ")", "(", "io", ".", "WriteCloser", ",", "error", ")", "{", "pfc", ",", "err", ":=", "c", ".", "newOneoffPutFileClient", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "pfc", ".", "PutFileWriter", "(", "repoName", ",", "commitID", ",", "<mask>", ")", "\n", "}" ]
14,466
all-14467
[ "GetXAlign", "is", "a", "wrapper", "around", "gtk_label_get_xalign", "()", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "GetXAlign", "(", ")", "float64", "{", "c", ":=", "C", ".", "gtk_label_get_xalign", "(", "v", ".", "native", "(", ")", ")", "\n", "return", "float64", "(", "c", ")", "\n", "}" ]
14,467
all-14468
[ "ListenAddresses", "returns", "a", "list", "of", "host", ":", "port", "combinations", "at", "which", "this", "machine", "can", "be", "reached" ]
[ "func", "ListenAddresses", "(", "value", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "addresses", ":=", "make", "(", "[", "]", "string", ",", "0", ")", "\n\n", "if", "value", "==", "\"", "\"", "{", "return", "addresses", ",", "nil", "\n", "}", "\n\n", "localHost", ",", "localPort", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "value", ")", "\n", "if", "err", "!=", "nil", "{", "localHost", "=", "value", "\n", "localPort", "=", "shared", ".", "DefaultPort", "\n", "}", "\n\n", "if", "localHost", "==", "\"", "\"", "||", "localHost", "==", "\"", "\"", "||", "localHost", "==", "\"", "\"", "{", "ifaces", ",", "err", ":=", "net", ".", "Interfaces", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "addresses", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "i", ":=", "range", "ifaces", "{", "addrs", ",", "err", ":=", "i", ".", "Addrs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "continue", "\n", "}", "\n\n", "for", "_", ",", "addr", ":=", "range", "addrs", "{", "var", "ip", "net", ".", "IP", "\n", "switch", "v", ":=", "addr", ".", "(", "type", ")", "{", "case", "*", "net", ".", "IPNet", ":", "ip", "=", "v", ".", "IP", "\n", "case", "*", "net", ".", "IPAddr", ":", "ip", "=", "v", ".", "IP", "\n", "}", "\n\n", "if", "!", "ip", ".", "IsGlobalUnicast", "(", ")", "{", "continue", "\n", "}", "\n\n", "if", "ip", ".", "To4", "(", ")", "==", "nil", "{", "if", "localHost", "==", "\"", "\"", "{", "continue", "\n", "}", "\n", "addresses", "=", "append", "(", "addresses", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ip", ",", "localPort", ")", ")", "\n", "}", "else", "{", "addresses", "=", "append", "(", "addresses", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "<mask>", ",", "localPort", ")", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "else", "{", "if", "strings", ".", "Contains", "(", "localHost", ",", "\"", "\"", ")", "{", "addresses", "=", "append", "(", "addresses", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "localHost", ",", "localPort", ")", ")", "\n", "}", "else", "{", "addresses", "=", "append", "(", "addresses", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "localHost", ",", "localPort", ")", ")", "\n", "}", "\n", "}", "\n\n", "return", "addresses", ",", "nil", "\n", "}" ]
14,468
all-14469
[ "Register", "register", "role", "with", "conditions" ]
[ "func", "(", "role", "*", "Role", ")", "Register", "(", "name", "string", ",", "fc", "Checker", ")", "{", "if", "role", ".", "definitions", "==", "nil", "{", "role", ".", "definitions", "=", "map", "[", "string", "]", "Checker", "{", "}", "\n", "}", "\n\n", "definition", ":=", "role", ".", "definitions", "[", "name", "]", "\n", "if", "<mask>", "!=", "nil", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "name", ")", "\n", "}", "\n", "role", ".", "definitions", "[", "name", "]", "=", "fc", "\n", "}" ]
14,469
all-14470
[ "MarshalEasyJSON", "satisfies", "easyjson", ".", "Marshaler", "." ]
[ "func", "(", "t", "ValueSourceType", ")", "MarshalEasyJSON", "(", "out", "*", "jwriter", ".", "Writer", ")", "{", "<mask>", ".", "String", "(", "string", "(", "t", ")", ")", "\n", "}" ]
14,470
all-14471
[ "/", "*", "NewBarChart", "creates", "a", "new", "bar", "chart", ".", "view", "-", "is", "a", "View", "that", "manages", "the", "control", "parent", "-", "is", "container", "that", "keeps", "the", "control", ".", "The", "same", "View", "can", "be", "a", "view", "and", "a", "parent", "at", "the", "same", "time", ".", "w", "and", "h", "-", "are", "minimal", "size", "of", "the", "control", ".", "scale", "-", "the", "way", "of", "scaling", "the", "control", "when", "the", "parent", "is", "resized", ".", "Use", "DoNotScale", "constant", "if", "the", "control", "should", "keep", "its", "original", "size", "." ]
[ "func", "CreateBarChart", "(", "parent", "Control", ",", "w", ",", "h", "int", ",", "<mask>", "int", ")", "*", "BarChart", "{", "c", ":=", "new", "(", "BarChart", ")", "\n", "c", ".", "BaseControl", "=", "NewBaseControl", "(", ")", "\n\n", "if", "w", "==", "AutoSize", "{", "w", "=", "10", "\n", "}", "\n", "if", "h", "==", "AutoSize", "{", "h", "=", "5", "\n", "}", "\n\n", "c", ".", "parent", "=", "parent", "\n\n", "c", ".", "SetSize", "(", "w", ",", "h", ")", "\n", "c", ".", "SetConstraints", "(", "w", ",", "h", ")", "\n", "c", ".", "tabSkip", "=", "true", "\n", "c", ".", "showTitles", "=", "true", "\n", "c", ".", "barWidth", "=", "3", "\n", "c", ".", "data", "=", "make", "(", "[", "]", "BarData", ",", "0", ")", "\n", "c", ".", "SetScale", "(", "scale", ")", "\n\n", "if", "parent", "!=", "nil", "{", "parent", ".", "AddChild", "(", "c", ")", "\n", "}", "\n\n", "return", "c", "\n", "}" ]
14,471
all-14472
[ "parseFlakyJobs", "parses", "JSON", "generated", "by", "the", "flakes", "bigquery", "metric", "into", "a", "sorted", "slice", "of", "*", "FlakyJob", "." ]
[ "func", "(", "fjr", "*", "FlakyJobReporter", ")", "parseFlakyJobs", "(", "jsonIn", "[", "]", "byte", ")", "(", "[", "]", "*", "FlakyJob", ",", "error", ")", "{", "var", "flakeMap", "map", "[", "string", "]", "*", "FlakyJob", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "jsonIn", ",", "&", "flakeMap", ")", "\n", "if", "err", "!=", "nil", "||", "flakeMap", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "flakyJobs", ":=", "make", "(", "[", "]", "*", "FlakyJob", ",", "0", ",", "len", "(", "flakeMap", ")", ")", "\n\n", "for", "job", ",", "fj", ":=", "range", "flakeMap", "{", "if", "job", "==", "\"", "\"", "{", "glog", ".", "Errorf", "(", "\"", "\\n", "\"", ")", "\n", "continue", "\n", "}", "\n", "if", "fj", "==", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "job", ")", "\n", "continue", "\n", "}", "\n", "if", "fj", ".", "Consistency", "==", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "job", ")", "\n", "continue", "\n", "}", "\n", "if", "fj", ".", "FlakeCount", "==", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "job", ")", "\n", "continue", "\n", "}", "\n", "if", "fj", ".", "FlakyTests", "==", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "<mask>", ")", "\n", "continue", "\n", "}", "\n", "fj", ".", "Name", "=", "job", "\n", "fj", ".", "reporter", "=", "fjr", "\n", "flakyJobs", "=", "append", "(", "flakyJobs", ",", "fj", ")", "\n", "}", "\n\n", "sort", ".", "SliceStable", "(", "flakyJobs", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "if", "*", "flakyJobs", "[", "i", "]", ".", "FlakeCount", "==", "*", "flakyJobs", "[", "j", "]", ".", "FlakeCount", "{", "return", "*", "flakyJobs", "[", "i", "]", ".", "Consistency", "<", "*", "flakyJobs", "[", "j", "]", ".", "Consistency", "\n", "}", "\n", "return", "*", "flakyJobs", "[", "i", "]", ".", "FlakeCount", ">", "*", "flakyJobs", "[", "j", "]", ".", "FlakeCount", "\n", "}", ")", "\n\n", "return", "flakyJobs", ",", "nil", "\n", "}" ]
14,472
all-14473
[ "RenderPerfdata", "accepts", "a", "slice", "of", "PerfDatum", "objects", "and", "returns", "their", "concatenated", "string", "representations", "in", "a", "form", "suitable", "to", "append", "to", "the", "first", "line", "of", "check", "output", "." ]
[ "func", "RenderPerfdata", "(", "perfdata", "[", "]", "PerfDatum", ")", "string", "{", "<mask>", ":=", "\"", "\"", "\n", "if", "len", "(", "perfdata", ")", "==", "0", "{", "return", "value", "\n", "}", "\n", "// Demarcate start of perfdata in check output.", "value", "+=", "\"", "\"", "\n", "for", "_", ",", "datum", ":=", "range", "perfdata", "{", "value", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "datum", ")", "\n", "}", "\n", "return", "value", "\n", "}" ]
14,473
all-14474
[ "MarshalEasyJSON", "satisfies", "easyjson", ".", "Marshaler", "." ]
[ "func", "(", "t", "DOMBreakpointType", ")", "MarshalEasyJSON", "(", "out", "*", "jwriter", ".", "Writer", ")", "{", "<mask>", ".", "String", "(", "string", "(", "t", ")", ")", "\n", "}" ]
14,474
all-14475
[ "getErrors", "simply", "gets", "the", "errors", "from", "the", "context", "(", "it", "s", "kind", "of", "a", "chore", ")" ]
[ "func", "getErrors", "(", "context", "martini", ".", "<mask>", ")", "Errors", "{", "return", "context", ".", "Get", "(", "reflect", ".", "TypeOf", "(", "Errors", "{", "}", ")", ")", ".", "Interface", "(", ")", ".", "(", "Errors", ")", "\n", "}" ]
14,475
all-14476
[ "NewGossipSub", "returns", "a", "new", "PubSub", "object", "using", "GossipSubRouter", "as", "the", "router", "." ]
[ "func", "NewGossipSub", "(", "ctx", "context", ".", "Context", ",", "h", "host", ".", "Host", ",", "opts", "...", "Option", ")", "(", "*", "PubSub", ",", "error", ")", "{", "rt", ":=", "&", "GossipSubRouter", "{", "peers", ":", "make", "(", "<mask>", "[", "peer", ".", "ID", "]", "protocol", ".", "ID", ")", ",", "mesh", ":", "make", "(", "map", "[", "string", "]", "map", "[", "peer", ".", "ID", "]", "struct", "{", "}", ")", ",", "fanout", ":", "make", "(", "map", "[", "string", "]", "map", "[", "peer", ".", "ID", "]", "struct", "{", "}", ")", ",", "lastpub", ":", "make", "(", "map", "[", "string", "]", "int64", ")", ",", "gossip", ":", "make", "(", "map", "[", "peer", ".", "ID", "]", "[", "]", "*", "pb", ".", "ControlIHave", ")", ",", "control", ":", "make", "(", "map", "[", "peer", ".", "ID", "]", "*", "pb", ".", "ControlMessage", ")", ",", "mcache", ":", "NewMessageCache", "(", "GossipSubHistoryGossip", ",", "GossipSubHistoryLength", ")", ",", "}", "\n", "return", "NewPubSub", "(", "ctx", ",", "h", ",", "rt", ",", "opts", "...", ")", "\n", "}" ]
14,476
all-14477
[ "extrapolatedRate", "is", "a", "utility", "function", "for", "rate", "/", "increase", "/", "delta", ".", "It", "calculates", "the", "rate", "(", "allowing", "for", "counter", "resets", "if", "isCounter", "is", "true", ")", "extrapolates", "if", "the", "first", "/", "last", "sample", "is", "close", "to", "the", "boundary", "and", "returns", "the", "result", "as", "either", "per", "-", "second", "(", "if", "isRate", "is", "true", ")", "or", "overall", "." ]
[ "func", "extrapolatedRate", "(", "vals", "[", "]", "Value", ",", "args", "Expressions", ",", "enh", "*", "EvalNodeHelper", ",", "isCounter", "bool", ",", "isRate", "bool", ")", "Vector", "{", "ms", ":=", "args", "[", "0", "]", ".", "(", "*", "MatrixSelector", ")", "\n\n", "var", "(", "matrix", "=", "vals", "[", "0", "]", ".", "(", "Matrix", ")", "\n", "rangeStart", "=", "enh", ".", "ts", "-", "durationMilliseconds", "(", "ms", ".", "<mask>", "+", "ms", ".", "Offset", ")", "\n", "rangeEnd", "=", "enh", ".", "ts", "-", "durationMilliseconds", "(", "ms", ".", "Offset", ")", "\n", ")", "\n\n", "for", "_", ",", "samples", ":=", "range", "matrix", "{", "// No sense in trying to compute a rate without at least two points. Drop", "// this Vector element.", "if", "len", "(", "samples", ".", "Points", ")", "<", "2", "{", "continue", "\n", "}", "\n", "var", "(", "counterCorrection", "float64", "\n", "lastValue", "float64", "\n", ")", "\n", "for", "_", ",", "sample", ":=", "range", "samples", ".", "Points", "{", "if", "isCounter", "&&", "sample", ".", "V", "<", "lastValue", "{", "counterCorrection", "+=", "lastValue", "\n", "}", "\n", "lastValue", "=", "sample", ".", "V", "\n", "}", "\n", "resultValue", ":=", "lastValue", "-", "samples", ".", "Points", "[", "0", "]", ".", "V", "+", "counterCorrection", "\n\n", "// Duration between first/last samples and boundary of range.", "durationToStart", ":=", "float64", "(", "samples", ".", "Points", "[", "0", "]", ".", "T", "-", "rangeStart", ")", "/", "1000", "\n", "durationToEnd", ":=", "float64", "(", "rangeEnd", "-", "samples", ".", "Points", "[", "len", "(", "samples", ".", "Points", ")", "-", "1", "]", ".", "T", ")", "/", "1000", "\n\n", "sampledInterval", ":=", "float64", "(", "samples", ".", "Points", "[", "len", "(", "samples", ".", "Points", ")", "-", "1", "]", ".", "T", "-", "samples", ".", "Points", "[", "0", "]", ".", "T", ")", "/", "1000", "\n", "averageDurationBetweenSamples", ":=", "sampledInterval", "/", "float64", "(", "len", "(", "samples", ".", "Points", ")", "-", "1", ")", "\n\n", "if", "isCounter", "&&", "resultValue", ">", "0", "&&", "samples", ".", "Points", "[", "0", "]", ".", "V", ">=", "0", "{", "// Counters cannot be negative. If we have any slope at", "// all (i.e. resultValue went up), we can extrapolate", "// the zero point of the counter. If the duration to the", "// zero point is shorter than the durationToStart, we", "// take the zero point as the start of the series,", "// thereby avoiding extrapolation to negative counter", "// values.", "durationToZero", ":=", "sampledInterval", "*", "(", "samples", ".", "Points", "[", "0", "]", ".", "V", "/", "resultValue", ")", "\n", "if", "durationToZero", "<", "durationToStart", "{", "durationToStart", "=", "durationToZero", "\n", "}", "\n", "}", "\n\n", "// If the first/last samples are close to the boundaries of the range,", "// extrapolate the result. This is as we expect that another sample", "// will exist given the spacing between samples we've seen thus far,", "// with an allowance for noise.", "extrapolationThreshold", ":=", "averageDurationBetweenSamples", "*", "1.1", "\n", "extrapolateToInterval", ":=", "sampledInterval", "\n\n", "if", "durationToStart", "<", "extrapolationThreshold", "{", "extrapolateToInterval", "+=", "durationToStart", "\n", "}", "else", "{", "extrapolateToInterval", "+=", "averageDurationBetweenSamples", "/", "2", "\n", "}", "\n", "if", "durationToEnd", "<", "extrapolationThreshold", "{", "extrapolateToInterval", "+=", "durationToEnd", "\n", "}", "else", "{", "extrapolateToInterval", "+=", "averageDurationBetweenSamples", "/", "2", "\n", "}", "\n", "resultValue", "=", "resultValue", "*", "(", "extrapolateToInterval", "/", "sampledInterval", ")", "\n", "if", "isRate", "{", "resultValue", "=", "resultValue", "/", "ms", ".", "Range", ".", "Seconds", "(", ")", "\n", "}", "\n\n", "enh", ".", "out", "=", "append", "(", "enh", ".", "out", ",", "Sample", "{", "Point", ":", "Point", "{", "V", ":", "resultValue", "}", ",", "}", ")", "\n", "}", "\n", "return", "enh", ".", "out", "\n", "}" ]
14,477
all-14478
[ "IgnoreTypes", "returns", "an", "Option", "that", "ignores", "all", "values", "assignable", "to", "certain", "types", "which", "are", "specified", "by", "passing", "in", "a", "value", "of", "each", "type", "." ]
[ "func", "IgnoreTypes", "(", "typs", "...", "interface", "{", "}", ")", "cmp", ".", "Option", "{", "tf", ":=", "newTypeFilter", "(", "typs", "...", ")", "\n", "return", "cmp", ".", "FilterPath", "(", "tf", ".", "<mask>", ",", "cmp", ".", "Ignore", "(", ")", ")", "\n", "}" ]
14,478
all-14479
[ "Lenses", "gets", "all", "views", "of", "all", "artifact", "files", "matching", "each", "regexp", "with", "a", "registered", "lens" ]
[ "func", "(", "s", "*", "Spyglass", ")", "Lenses", "(", "matchCache", "map", "[", "string", "]", "[", "]", "string", ")", "[", "]", "lenses", ".", "Lens", "{", "ls", ":=", "[", "]", "lenses", ".", "Lens", "{", "}", "\n", "for", "lensName", ",", "matches", ":=", "range", "matchCache", "{", "if", "len", "(", "matches", ")", "==", "0", "{", "continue", "\n", "}", "\n", "lens", ",", "err", ":=", "lenses", ".", "GetLens", "(", "lensName", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "WithField", "(", "\"", "\"", ",", "lens", ")", ".", "WithError", "(", "err", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "}", "else", "{", "<mask>", "=", "append", "(", "ls", ",", "lens", ")", "\n", "}", "\n", "}", "\n", "// Make sure lenses are rendered in order by ascending priority", "sort", ".", "Slice", "(", "ls", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "iconf", ":=", "ls", "[", "i", "]", ".", "Config", "(", ")", "\n", "jconf", ":=", "ls", "[", "j", "]", ".", "Config", "(", ")", "\n", "iname", ":=", "iconf", ".", "Name", "\n", "jname", ":=", "jconf", ".", "Name", "\n", "pi", ":=", "iconf", ".", "Priority", "\n", "pj", ":=", "jconf", ".", "Priority", "\n", "if", "pi", "==", "pj", "{", "return", "iname", "<", "jname", "\n", "}", "\n", "return", "pi", "<", "pj", "\n", "}", ")", "\n", "return", "ls", "\n", "}" ]
14,479
all-14480
[ "Generate", "a", "new", "password", "based", "on", "given", "policy" ]
[ "func", "Generate", "(", "p", "Policy", ")", "(", "string", ",", "error", ")", "{", "// Character length based policies should not be negative", "if", "p", ".", "MinLength", "<", "0", "||", "p", ".", "MaxLength", "<", "0", "||", "p", ".", "MinUppers", "<", "0", "||", "p", ".", "MinLowers", "<", "0", "||", "p", ".", "MinDigits", "<", "0", "||", "p", ".", "MinSpclChars", "<", "0", "{", "return", "\"", "\"", ",", "ErrNegativeLengthNotAllowed", "\n", "}", "\n\n", "collectiveMinLength", ":=", "p", ".", "MinUppers", "+", "p", ".", "MinLowers", "+", "p", ".", "MinDigits", "+", "p", ".", "MinSpclChars", "\n\n", "// Min length is the collective min length", "if", "collectiveMinLength", ">", "p", ".", "MinLength", "{", "p", ".", "MinLength", "=", "collectiveMinLength", "\n", "}", "\n\n", "// Max length should be greater than collective minimun length", "if", "p", ".", "MinLength", ">", "p", ".", "MaxLength", "{", "return", "\"", "\"", ",", "ErrMaxLengthExceeded", "\n", "}", "\n\n", "if", "p", ".", "MaxLength", "==", "0", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n\n", "capsAlpha", ":=", "[", "]", "<mask>", "(", "p", ".", "UpperPool", ")", "\n", "smallAlpha", ":=", "[", "]", "byte", "(", "p", ".", "LowerPool", ")", "\n", "digits", ":=", "[", "]", "byte", "(", "p", ".", "DigitPool", ")", "\n", "spclChars", ":=", "[", "]", "byte", "(", "p", ".", "SpclCharPool", ")", "\n", "allChars", ":=", "[", "]", "byte", "(", "p", ".", "UpperPool", "+", "p", ".", "LowerPool", "+", "p", ".", "DigitPool", "+", "p", ".", "SpclCharPool", ")", "\n\n", "passwd", ":=", "CreateRandom", "(", "capsAlpha", ",", "p", ".", "MinUppers", ")", "\n\n", "passwd", "=", "append", "(", "passwd", ",", "CreateRandom", "(", "smallAlpha", ",", "p", ".", "MinLowers", ")", "...", ")", "\n", "passwd", "=", "append", "(", "passwd", ",", "CreateRandom", "(", "digits", ",", "p", ".", "MinDigits", ")", "...", ")", "\n", "passwd", "=", "append", "(", "passwd", ",", "CreateRandom", "(", "spclChars", ",", "p", ".", "MinSpclChars", ")", "...", ")", "\n\n", "passLen", ":=", "len", "(", "passwd", ")", "\n\n", "if", "passLen", "<", "p", ".", "MaxLength", "{", "randLength", ":=", "random", "(", "p", ".", "MinLength", ",", "p", ".", "MaxLength", ")", "\n", "passwd", "=", "append", "(", "passwd", ",", "CreateRandom", "(", "allChars", ",", "randLength", "-", "passLen", ")", "...", ")", "\n", "}", "\n\n", "Shuffle", "(", "passwd", ")", "\n\n", "return", "string", "(", "passwd", ")", ",", "nil", "\n", "}" ]
14,480
all-14481
[ "handlerFunc", "returns", "the", "request", "handler", "function", "for", "the", "ecsacs", ".", "IAMRoleCredentialsMessage" ]
[ "func", "(", "refreshHandler", "*", "refreshCredentialsHandler", ")", "handlerFunc", "(", ")", "func", "(", "<mask>", "*", "ecsacs", ".", "IAMRoleCredentialsMessage", ")", "{", "// return a function that just enqueues IAMRoleCredentials messages into the message buffer", "return", "func", "(", "message", "*", "ecsacs", ".", "IAMRoleCredentialsMessage", ")", "{", "refreshHandler", ".", "messageBuffer", "<-", "message", "\n", "}", "\n", "}" ]
14,481
all-14482
[ "Set", "..." ]
[ "func", "(", "c", "*", "Context", ")", "Set", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "if", "c", ".", "set", "==", "nil", "{", "c", ".", "set", "=", "<mask>", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "}", "\n", "c", ".", "set", "[", "key", "]", "=", "value", "\n", "}" ]
14,482
all-14483
[ "GetTimeout", "returns", "the", "status", "code", "and", "body", "of", "url", ".", "The", "contents", "of", "dst", "will", "be", "replaced", "by", "the", "body", "and", "returned", "if", "the", "dst", "is", "too", "small", "a", "new", "slice", "will", "be", "allocated", ".", "The", "function", "follows", "redirects", ".", "Use", "Do", "*", "for", "manually", "handling", "redirects", ".", "ErrTimeout", "error", "is", "returned", "if", "url", "contents", "couldn", "t", "be", "fetched", "during", "the", "given", "timeout", "." ]
[ "func", "GetTimeout", "(", "dst", "[", "]", "<mask>", ",", "url", "string", ",", "timeout", "time", ".", "Duration", ")", "(", "statusCode", "int", ",", "body", "[", "]", "byte", ",", "err", "error", ")", "{", "return", "defaultClient", ".", "GetTimeout", "(", "dst", ",", "url", ",", "timeout", ")", "\n", "}" ]
14,483
all-14484
[ "Group", "creates", "a", "new", "inline", "-", "Mux", "with", "a", "fresh", "middleware", "stack", ".", "It", "s", "useful", "for", "a", "group", "of", "handlers", "along", "the", "same", "routing", "path", "that", "use", "an", "additional", "set", "of", "middlewares", ".", "See", "_examples", "/", "." ]
[ "func", "(", "mx", "*", "Mux", ")", "<mask>", "(", "fn", "func", "(", "r", "Router", ")", ")", "Router", "{", "im", ":=", "mx", ".", "With", "(", ")", ".", "(", "*", "Mux", ")", "\n", "if", "fn", "!=", "nil", "{", "fn", "(", "im", ")", "\n", "}", "\n", "return", "im", "\n", "}" ]
14,484
all-14485
[ "SetApplicationName", "is", "a", "wrapper", "around", "g_set_application_name", "()", "." ]
[ "func", "SetApplicationName", "(", "<mask>", "string", ")", "{", "cstr", ":=", "(", "*", "C", ".", "gchar", ")", "(", "C", ".", "CString", "(", "name", ")", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cstr", ")", ")", "\n\n", "C", ".", "g_set_application_name", "(", "cstr", ")", "\n", "}" ]
14,485
all-14486
[ "ReplyWithError", "sends", "a", "response", "with", "an", "error", "." ]
[ "func", "(", "c", "*", "Conn", ")", "ReplyWithError", "(", "ctx", "context", ".", "Context", ",", "id", "ID", ",", "respErr", "*", "<mask>", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "send", "(", "ctx", ",", "&", "anyMessage", "{", "response", ":", "&", "Response", "{", "ID", ":", "id", ",", "Error", ":", "respErr", "}", "}", ",", "false", ")", "\n", "return", "err", "\n", "}" ]
14,486
all-14487
[ "Sort", "returns", "a", "sorted", "list", "of", "LexSymbols", "sorted", "by", "Priority" ]
[ "func", "(", "list", "LexSymbolList", ")", "Sort", "(", ")", "LexSymbolList", "{", "sorter", ":=", "LexSymbolSorter", "{", "list", ":", "list", ",", "}", "\n", "sort", ".", "Sort", "(", "sorter", ")", "\n", "return", "sorter", ".", "<mask>", "\n", "}" ]
14,487
all-14488
[ "ReadAt", "reads", "len", "(", "p", ")", "bytes", "from", "a", "file", "in", "GCS", "at", "offset", "off" ]
[ "func", "(", "a", "*", "GCSArtifact", ")", "ReadAt", "(", "p", "[", "]", "byte", ",", "off", "int64", ")", "(", "n", "int", ",", "err", "error", ")", "{", "gzipped", ",", "err", ":=", "a", ".", "gzipped", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "if", "gzipped", "{", "return", "0", ",", "lenses", ".", "ErrGzipOffsetRead", "\n", "}", "\n", "artifactSize", ",", "err", ":=", "a", ".", "Size", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "if", "off", ">=", "artifactSize", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "var", "gotEOF", "bool", "\n", "toRead", ":=", "int64", "(", "len", "(", "p", ")", ")", "\n", "if", "toRead", "+", "off", ">", "artifactSize", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "else", "if", "toRead", "+", "off", "==", "artifactSize", "{", "gotEOF", "=", "true", "\n", "}", "\n", "<mask>", ",", "err", ":=", "a", ".", "handle", ".", "NewRangeReader", "(", "a", ".", "ctx", ",", "off", ",", "toRead", ")", "\n", "defer", "reader", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "// We need to keep reading until we fill the buffer or hit EOF.", "offset", ":=", "0", "\n", "for", "offset", "<", "len", "(", "p", ")", "{", "n", ",", "err", "=", "reader", ".", "Read", "(", "p", "[", "offset", ":", "]", ")", "\n", "offset", "+=", "n", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "io", ".", "EOF", "&&", "gotEOF", "{", "break", "\n", "}", "\n", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n", "if", "gotEOF", "{", "return", "offset", ",", "io", ".", "EOF", "\n", "}", "\n", "return", "offset", ",", "nil", "\n", "}" ]
14,488
all-14489
[ "explode", "is", "used", "to", "expand", "a", "list", "of", "keypairs", "into", "a", "deeply", "-", "nested", "hash", "." ]
[ "func", "explode", "(", "pairs", "[", "]", "*", "dep", ".", "KeyPair", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "for", "_", ",", "<mask>", ":=", "range", "pairs", "{", "if", "err", ":=", "explodeHelper", "(", "m", ",", "pair", ".", "Key", ",", "pair", ".", "Value", ",", "pair", ".", "Key", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "return", "m", ",", "nil", "\n", "}" ]
14,489
all-14490
[ "KeyToPEM", "serializes", "the", "private", "key", "in", "cert", "to", "a", "PEM", "-", "formatted", "block", "if", "it", "s", "an", "RSA", "key", "or", "nil", "otherwise", "(", "all", "certs", "returned", "by", "GenerateSelfSignedCert", "use", "RSA", "keys", ")" ]
[ "func", "KeyToPEM", "(", "cert", "*", "tls", ".", "Certificate", ")", "[", "]", "byte", "{", "switch", "k", ":=", "<mask>", ".", "PrivateKey", ".", "(", "type", ")", "{", "case", "*", "rsa", ".", "PrivateKey", ":", "return", "pem", ".", "EncodeToMemory", "(", "&", "pem", ".", "Block", "{", "Type", ":", "\"", "\"", ",", "Bytes", ":", "x509", ".", "MarshalPKCS1PrivateKey", "(", "k", ")", ",", "}", ")", "\n", "default", ":", "return", "nil", "\n", "}", "\n", "}" ]
14,490
all-14491
[ "DiscoverHTTP", "..." ]
[ "func", "DiscoverHTTP", "(", "endpoint", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "res", ",", "err", ":=", "http", ".", "Get", "(", "endpoint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "defer", "res", ".", "Body", ".", "Close", "(", ")", "\n", "var", "(", "tmp", "[", "]", "service", "\n", "services", "[", "]", "string", "\n", ")", "\n", "if", "err", ":=", "json", ".", "NewDecoder", "(", "res", ".", "Body", ")", ".", "Decode", "(", "&", "tmp", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "for", "_", ",", "s", ":=", "range", "tmp", "{", "services", "=", "append", "(", "<mask>", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "Address", ",", "s", ".", "Port", ")", ")", "\n", "}", "\n", "return", "services", ",", "nil", "\n", "}" ]
14,491
all-14492
[ "loadReviewers", "returns", "all", "reviewers", "and", "approvers", "from", "all", "OWNERS", "files", "that", "cover", "the", "provided", "filenames", "." ]
[ "func", "loadReviewers", "(", "ro", "repoowners", ".", "RepoOwner", ",", "filenames", "[", "]", "string", ")", "sets", ".", "<mask>", "{", "reviewers", ":=", "sets", ".", "String", "{", "}", "\n", "for", "_", ",", "filename", ":=", "range", "filenames", "{", "reviewers", "=", "reviewers", ".", "Union", "(", "ro", ".", "Approvers", "(", "filename", ")", ")", ".", "Union", "(", "ro", ".", "Reviewers", "(", "filename", ")", ")", "\n", "}", "\n", "return", "reviewers", "\n", "}" ]
14,492
all-14493
[ "LabelValues", "returns", "all", "potential", "values", "for", "a", "label", "name", "." ]
[ "func", "(", "q", "*", "mergeQuerier", ")", "LabelValues", "(", "name", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "results", "[", "]", "[", "]", "string", "\n", "for", "_", ",", "querier", ":=", "range", "q", ".", "queriers", "{", "<mask>", ",", "err", ":=", "querier", ".", "LabelValues", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "results", "=", "append", "(", "results", ",", "values", ")", "\n", "}", "\n", "return", "mergeStringSlices", "(", "results", ")", ",", "nil", "\n", "}" ]
14,493
all-14494
[ "DriverName", "returns", "the", "name", "of", "the", "driver" ]
[ "func", "(", "c", "*", "RPCClientDriver", ")", "DriverName", "(", ")", "string", "{", "driverName", ",", "err", ":=", "c", ".", "rpcStringCall", "(", "DriverNameMethod", ")", "\n", "if", "err", "!=", "nil", "{", "<mask>", ".", "Warnf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "return", "driverName", "\n", "}" ]
14,494
all-14495
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "CollectGarbageParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoHeapprofiler22", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
14,495
all-14496
[ "batchContainerEventUnsafe", "collects", "container", "state", "change", "events", "for", "a", "given", "task", "arn" ]
[ "func", "(", "handler", "*", "TaskHandler", ")", "batchContainerEventUnsafe", "(", "event", "api", ".", "ContainerStateChange", ")", "{", "seelog", ".", "Infof", "(", "\"", "\"", ",", "event", ".", "<mask>", "(", ")", ")", "\n", "handler", ".", "tasksToContainerStates", "[", "event", ".", "TaskArn", "]", "=", "append", "(", "handler", ".", "tasksToContainerStates", "[", "event", ".", "TaskArn", "]", ",", "event", ")", "\n", "}" ]
14,496
all-14497
[ "GetParentWindow", "is", "a", "wrapper", "around", "gtk_widget_get_parent_window", "()", "." ]
[ "func", "(", "v", "*", "Widget", ")", "GetParentWindow", "(", ")", "(", "*", "gdk", ".", "Window", ",", "error", ")", "{", "c", ":=", "C", ".", "gtk_widget_get_parent_window", "(", "v", ".", "native", "(", ")", ")", "\n", "if", "v", "==", "nil", "{", "return", "nil", ",", "nilPtrErr", "\n", "}", "\n\n", "w", ":=", "&", "gdk", ".", "Window", "{", "glib", ".", "Take", "(", "unsafe", ".", "Pointer", "(", "c", ")", ")", "}", "\n", "<mask>", "w", ",", "nil", "\n", "}" ]
14,497
all-14498
[ "SetLogger", "installs", "the", "given", "logger", "as", "global", "logger", ".", "It", "returns", "a", "function", "that", "can", "be", "used", "to", "restore", "whatever", "logger", "was", "installed", "beforehand", "." ]
[ "func", "SetLogger", "(", "newLogger", "logger", ".", "Logger", ")", "func", "(", ")", "{", "origLog", ":=", "logger", ".", "Log", "\n", "logger", ".", "<mask>", "=", "newLogger", "\n", "return", "func", "(", ")", "{", "logger", ".", "Log", "=", "origLog", "\n", "}", "\n", "}" ]
14,498
all-14499
[ "NewServer", "returns", "a", "server", "that", "can", "serve", "thrift", "services", "over", "TChannel", "." ]
[ "func", "NewServer", "(", "registrar", "tchannel", ".", "Registrar", ")", "*", "<mask>", "{", "metaHandler", ":=", "newMetaHandler", "(", ")", "\n", "server", ":=", "&", "Server", "{", "ch", ":", "registrar", ",", "log", ":", "registrar", ".", "Logger", "(", ")", ",", "handlers", ":", "make", "(", "map", "[", "string", "]", "handler", ")", ",", "metaHandler", ":", "metaHandler", ",", "ctxFn", ":", "defaultContextFn", ",", "}", "\n", "server", ".", "Register", "(", "newTChanMetaServer", "(", "metaHandler", ")", ")", "\n", "if", "ch", ",", "ok", ":=", "registrar", ".", "(", "*", "tchannel", ".", "Channel", ")", ";", "ok", "{", "// Register the meta endpoints on the \"tchannel\" service name.", "NewServer", "(", "ch", ".", "GetSubChannel", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "return", "server", "\n", "}" ]
14,499
all-14500
[ "ReleaseResponseRecorder", "releases", "a", "ResponseRecorder", "which", "has", "been", "previously", "received", "by", "AcquireResponseRecorder" ]
[ "func", "ReleaseResponseRecorder", "(", "<mask>", "*", "ResponseRecorder", ")", "{", "res", ".", "underline", "=", "nil", "\n", "res", ".", "statusCode", "=", "0", "\n", "res", ".", "chunks", "=", "res", ".", "chunks", "[", "0", ":", "0", "]", "\n", "rpool", ".", "Put", "(", "res", ")", "\n", "}" ]