id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
1,600
all-1601
[ "KeyFromIncomingContext", "gets", "the", "key", "from", "the", "incoming", "context", "or", "returns", "ErrNoKey" ]
[ "func", "KeyFromIncomingContext", "(", "ctx", "context", ".", "<mask>", ")", "(", "string", ",", "error", ")", "{", "md", ":=", "MetadataFromIncomingContext", "(", "ctx", ")", "\n", "return", "KeyFromMetadata", "(", "md", ")", "\n", "}" ]
1,601
all-1602
[ "flattenHostNetworkSecurityPolicy", "reads", "various", "fields", "from", "a", "HostNetworkSecurityPolicy", "into", "the", "passed", "in", "ResourceData", "." ]
[ "func", "flattenHostNetworkSecurityPolicy", "(", "d", "*", "schema", ".", "ResourceData", ",", "obj", "*", "types", ".", "HostNetworkSecurityPolicy", ")", "error", "{", "if", "obj", ".", "AllowPromiscuous", "!=", "nil", "{", "d", ".", "<mask>", "(", "\"", "\"", ",", "*", "obj", ".", "AllowPromiscuous", ")", "\n", "}", "\n", "if", "obj", ".", "ForgedTransmits", "!=", "nil", "{", "d", ".", "Set", "(", "\"", "\"", ",", "*", "obj", ".", "ForgedTransmits", ")", "\n", "}", "\n", "if", "obj", ".", "MacChanges", "!=", "nil", "{", "d", ".", "Set", "(", "\"", "\"", ",", "*", "obj", ".", "MacChanges", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
1,602
all-1603
[ "UnmarshalJSON", "satisfies", "json", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "SetEmitTouchEventsForMouseConfiguration", ")", "UnmarshalJSON", "(", "buf", "[", "]", "<mask>", ")", "error", "{", "return", "easyjson", ".", "Unmarshal", "(", "buf", ",", "t", ")", "\n", "}" ]
1,603
all-1604
[ "parseMatcher", "returns", "matcher", "and", "name", "from", "the", "given", "pattern", "string", "." ]
[ "func", "parseMatcher", "(", "pat", "string", ")", "(", "matcher", "Matcher", ",", "<mask>", "string", ")", "{", "if", "!", "isMatchPattern", "(", "pat", ")", "{", "panic", "(", "\"", "\\\"", "\"", "+", "pat", "+", "\"", "\\\"", "\"", ")", "\n", "}", "\n\n", "s", ":=", "pat", "[", "1", ":", "len", "(", "pat", ")", "-", "1", "]", "\n", "ss", ":=", "strings", ".", "Split", "(", "s", ",", "\"", "\"", ")", "\n", "var", "matchType", "string", "\n", "if", "len", "(", "ss", ")", "==", "1", "{", "name", "=", "ss", "[", "0", "]", "\n", "}", "else", "{", "matchType", "=", "ss", "[", "0", "]", "\n", "name", "=", "ss", "[", "1", "]", "\n", "}", "\n", "if", "matchType", "==", "\"", "\"", "{", "matchType", "=", "\"", "\"", "\n", "}", "\n\n", "matcher", "=", "MatcherMap", "[", "matchType", "]", "\n", "if", "matcher", "==", "nil", "{", "panic", "(", "errors", ".", "New", "(", "\"", "\"", "+", "matchType", ")", ")", "\n", "}", "\n\n", "return", "matcher", ",", "name", "\n", "}" ]
1,604
all-1605
[ "Pop", "implements", "heap", "Pop", "interface" ]
[ "func", "(", "ph", "*", "peerHeap", ")", "Pop", "(", ")", "interface", "{", "}", "{", "old", ":=", "*", "ph", "\n", "n", ":=", "len", "(", "old", ".", "peerScores", ")", "\n", "item", ":=", "<mask>", ".", "peerScores", "[", "n", "-", "1", "]", "\n", "item", ".", "index", "=", "-", "1", "// for safety", "\n", "ph", ".", "peerScores", "=", "old", ".", "peerScores", "[", ":", "n", "-", "1", "]", "\n", "return", "item", "\n", "}" ]
1,605
all-1606
[ "secret", "must", "be", "32", "bytes", "long", ".", "Use", "something", "like", "Sha256", "(", "Bcrypt", "(", "passphrase", "))", "The", "ciphertext", "is", "(", "secretbox", ".", "Overhead", "+", "24", ")", "bytes", "longer", "than", "the", "plaintext", "." ]
[ "func", "DecryptSymmetric", "(", "ciphertext", "[", "]", "byte", ",", "secret", "[", "]", "byte", ")", "(", "plaintext", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "len", "(", "secret", ")", "!=", "secretLen", "{", "PanicSanity", "(", "Fmt", "(", "\"", "\"", ",", "len", "(", "secret", ")", ")", ")", "\n", "}", "\n", "if", "len", "(", "ciphertext", ")", "<=", "secretbox", ".", "Overhead", "+", "nonceLen", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "nonce", ":=", "ciphertext", "[", ":", "nonceLen", "]", "\n", "nonceArr", ":=", "[", "nonceLen", "]", "byte", "{", "}", "\n", "copy", "(", "nonceArr", "[", ":", "]", ",", "nonce", ")", "\n", "secretArr", ":=", "[", "secretLen", "]", "byte", "{", "}", "\n", "copy", "(", "secretArr", "[", ":", "]", ",", "secret", ")", "\n", "plaintext", "=", "make", "(", "[", "]", "byte", ",", "len", "(", "ciphertext", ")", "-", "nonceLen", "-", "secretbox", ".", "Overhead", ")", "\n", "_", ",", "<mask>", ":=", "secretbox", ".", "Open", "(", "plaintext", "[", ":", "0", "]", ",", "ciphertext", "[", "nonceLen", ":", "]", ",", "&", "nonceArr", ",", "&", "secretArr", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "plaintext", ",", "nil", "\n", "}" ]
1,606
all-1607
[ "GetClusterFromRemotePeers", "takes", "a", "set", "of", "URLs", "representing", "etcd", "peers", "and", "attempts", "to", "construct", "a", "Cluster", "by", "accessing", "the", "members", "endpoint", "on", "one", "of", "these", "URLs", ".", "The", "first", "URL", "to", "provide", "a", "response", "is", "used", ".", "If", "no", "URLs", "provide", "a", "response", "or", "a", "Cluster", "cannot", "be", "successfully", "created", "from", "a", "received", "response", "an", "error", "is", "returned", ".", "Each", "request", "has", "a", "10", "-", "second", "timeout", ".", "Because", "the", "upper", "limit", "of", "TTL", "is", "5s", "10", "second", "is", "enough", "for", "building", "connection", "and", "finishing", "request", "." ]
[ "func", "GetClusterFromRemotePeers", "(", "lg", "*", "zap", ".", "Logger", ",", "urls", "[", "]", "string", ",", "rt", "<mask>", ".", "RoundTripper", ")", "(", "*", "membership", ".", "RaftCluster", ",", "error", ")", "{", "return", "getClusterFromRemotePeers", "(", "lg", ",", "urls", ",", "10", "*", "time", ".", "Second", ",", "true", ",", "rt", ")", "\n", "}" ]
1,607
all-1608
[ "Sets", "the", "given", "value", "under", "the", "specified", "key", "." ]
[ "func", "(", "c", "*", "Cache", ")", "Add", "(", "p", "*", "points", ".", "Points", ")", "{", "s", ":=", "c", ".", "settings", ".", "Load", "(", ")", ".", "(", "*", "cacheSettings", ")", "\n\n", "if", "s", ".", "xlog", "!=", "nil", "{", "p", ".", "WriteTo", "(", "s", ".", "xlog", ")", "\n", "return", "\n", "}", "\n\n", "if", "s", ".", "tagsEnabled", "{", "var", "err", "error", "\n", "p", ".", "Metric", ",", "err", "=", "tags", ".", "Normalize", "(", "p", ".", "Metric", ")", "\n", "if", "err", "!=", "nil", "{", "atomic", ".", "AddUint32", "(", "&", "c", ".", "stat", ".", "tagsNormalizeErrors", ",", "1", ")", "\n", "return", "\n", "}", "\n", "}", "\n\n", "// Get map shard.", "count", ":=", "len", "(", "p", ".", "Data", ")", "\n\n", "if", "s", ".", "maxSize", ">", "0", "&&", "c", ".", "Size", "(", ")", ">", "s", ".", "maxSize", "{", "atomic", ".", "AddUint32", "(", "&", "c", ".", "stat", ".", "overflowCnt", ",", "uint32", "(", "count", ")", ")", "\n", "return", "\n", "}", "\n\n", "shard", ":=", "c", ".", "GetShard", "(", "p", ".", "Metric", ")", "\n\n", "shard", ".", "Lock", "(", ")", "\n", "if", "<mask>", ",", "exists", ":=", "shard", ".", "items", "[", "p", ".", "Metric", "]", ";", "exists", "{", "values", ".", "Data", "=", "append", "(", "values", ".", "Data", ",", "p", ".", "Data", "...", ")", "\n", "}", "else", "{", "shard", ".", "items", "[", "p", ".", "Metric", "]", "=", "p", "\n", "}", "\n", "shard", ".", "Unlock", "(", ")", "\n\n", "atomic", ".", "AddInt32", "(", "&", "c", ".", "stat", ".", "size", ",", "int32", "(", "count", ")", ")", "\n", "}" ]
1,608
all-1609
[ "String", "returns", "a", "human", "readable", "string", "representation", "of", "this", "object" ]
[ "func", "(", "task", "*", "Task", ")", "String", "(", ")", "string", "{", "<mask>", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "task", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "task", ".", "stringUnsafe", "(", ")", "\n", "}" ]
1,609
all-1610
[ "Apply", "updates", "the", "report", "with", "provided", "paritial", "stats" ]
[ "func", "(", "report", "*", "StatsReport", ")", "Apply", "(", "s", "*", "Stats", ")", "{", "var", "totalNextPtrs", "int", "\n", "var", "totalNodes", "int", "\n\n", "report", ".", "ReadConflicts", "+=", "s", ".", "readConflicts", "\n", "report", ".", "InsertConflicts", "+=", "s", ".", "insertConflicts", "\n\n", "for", "i", ",", "c", ":=", "<mask>", "s", ".", "levelNodesCount", "{", "report", ".", "NodeDistribution", "[", "i", "]", "+=", "c", "\n", "nodesAtlevel", ":=", "report", ".", "NodeDistribution", "[", "i", "]", "\n", "totalNodes", "+=", "int", "(", "nodesAtlevel", ")", "\n", "totalNextPtrs", "+=", "(", "i", "+", "1", ")", "*", "int", "(", "nodesAtlevel", ")", "\n", "}", "\n\n", "report", ".", "SoftDeletes", "+=", "s", ".", "softDeletes", "\n", "report", ".", "NodeCount", "=", "totalNodes", "\n", "report", ".", "NextPointersPerNode", "=", "float64", "(", "totalNextPtrs", ")", "/", "float64", "(", "totalNodes", ")", "\n", "report", ".", "NodeAllocs", "+=", "s", ".", "nodeAllocs", "\n", "report", ".", "NodeFrees", "+=", "s", ".", "nodeFrees", "\n", "report", ".", "Memory", "+=", "s", ".", "usedBytes", "\n", "}" ]
1,610
all-1611
[ "Execute", "-", "adds", "a", "named", "asg", "to", "the", "configuration" ]
[ "func", "(", "c", "*", "AddASGToConfigurationCommand", ")", "Execute", "(", "[", "]", "string", ")", "error", "{", "c", ".", "initConfig", "(", ")", "\n\n", "errorString", ":=", "\"", "\"", "\n\n", "if", "errorString", "!=", "\"", "\"", "{", "return", "errors", ".", "New", "(", "errorString", ")", "\n", "}", "\n\n", "if", "!", "c", ".", "Override", "{", "if", "c", ".", "ASGType", "==", "\"", "\"", "{", "asgConfigs", ",", "err", ":=", "c", ".", "ConfigManager", ".", "GetASGConfigs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "_", ",", "asgConfig", ":=", "range", "asgConfigs", "{", "if", "c", ".", "ASGName", "==", "asgConfig", ".", "<mask>", "{", "return", "errors", ".", "New", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "ASGName", ")", ")", "\n", "}", "\n", "}", "\n", "}", "else", "{", "asgConfigs", ",", "err", ":=", "c", ".", "ConfigManager", ".", "GetDefaultASGConfigs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "_", ",", "asgConfig", ":=", "range", "asgConfigs", "{", "if", "c", ".", "ASGName", "==", "asgConfig", ".", "Name", "{", "return", "errors", ".", "New", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "ASGName", ")", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "securityGroupsBytes", ":=", "[", "]", "byte", "(", "\"", "\"", ")", "\n", "if", "c", ".", "FilePath", "!=", "\"", "\"", "{", "bytes", ",", "err", ":=", "config", ".", "LoadFileBytes", "(", "c", ".", "FilePath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "securityGroupsBytes", "=", "bytes", "\n", "}", "\n", "if", "c", ".", "ASGType", "==", "\"", "\"", "{", "if", "err", ":=", "config", ".", "NewManager", "(", "c", ".", "ConfigDirectory", ")", ".", "AddSecurityGroup", "(", "c", ".", "ASGName", ",", "securityGroupsBytes", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "else", "{", "if", "err", ":=", "config", ".", "NewManager", "(", "c", ".", "ConfigDirectory", ")", ".", "AddDefaultSecurityGroup", "(", "c", ".", "ASGName", ",", "securityGroupsBytes", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "fmt", ".", "Println", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "ASGName", ")", ")", "\n", "return", "nil", "\n", "}" ]
1,611
all-1612
[ "BTCAddrFromPubKeyBytes", "returns", "a", "B58", "encoded", "Bitcoin", "mainnet", "address", "." ]
[ "func", "BTCAddrFromPubKeyBytes", "(", "pubKeyBytes", "[", "]", "<mask>", ")", "string", "{", "versionPrefix", ":=", "btcPrefixPubKeyHash", "// TODO Make const or configurable", "\n", "h160", ":=", "CalcHash160", "(", "pubKeyBytes", ")", "\n", "h160", "=", "append", "(", "[", "]", "byte", "{", "versionPrefix", "}", ",", "h160", "...", ")", "\n", "checksum", ":=", "CalcHash256", "(", "h160", ")", "\n", "b", ":=", "append", "(", "h160", ",", "checksum", "[", ":", "4", "]", "...", ")", "\n", "return", "base58", ".", "Encode", "(", "b", ")", "\n", "}" ]
1,612
all-1613
[ "TokenSource", "returns", "a", "oauth2", ".", "TokenSource", "for", "the", "Google", "Service", "Account", "using", "the", "provided", "context", "and", "scopes", ".", "The", "resulting", "token", "source", "should", "be", "wrapped", "with", "oauth2", ".", "ReusableTokenSource", "prior", "to", "being", "used", "elsewhere", ".", "If", "the", "supplied", "context", "is", "nil", "context", ".", "Background", "()", "will", "be", "used", ".", "If", "additional", "claims", "need", "to", "be", "added", "to", "the", "TokenSource", "(", "ie", "subject", "or", "the", "sub", "field", ")", "use", "jwt", "/", "bearer", ".", "Claim", "to", "add", "them", "before", "wrapping", "the", "TokenSource", "with", "oauth2", ".", "ReusableTokenSource", "." ]
[ "func", "(", "gsa", "*", "GServiceAccount", ")", "TokenSource", "(", "ctxt", "context", ".", "<mask>", ",", "scopes", "...", "string", ")", "(", "*", "bearer", ".", "Bearer", ",", "error", ")", "{", "var", "err", "error", "\n\n", "// simple check that required fields are present", "if", "gsa", ".", "ClientEmail", "==", "\"", "\"", "||", "gsa", ".", "TokenURI", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// set up subject and context", "if", "ctxt", "==", "nil", "{", "ctxt", "=", "context", ".", "Background", "(", ")", "\n", "}", "\n\n", "// get signer", "signer", ",", "err", ":=", "gsa", ".", "Signer", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// determine expiration", "expiration", ":=", "gsa", ".", "expiration", "\n", "if", "expiration", "==", "0", "{", "expiration", "=", "DefaultExpiration", "\n", "}", "\n\n", "// bearer grant options", "opts", ":=", "[", "]", "bearer", ".", "Option", "{", "bearer", ".", "ExpiresIn", "(", "expiration", ")", ",", "bearer", ".", "IssuedAt", "(", "true", ")", ",", "bearer", ".", "Claim", "(", "\"", "\"", ",", "gsa", ".", "ClientEmail", ")", ",", "bearer", ".", "Claim", "(", "\"", "\"", ",", "gsa", ".", "TokenURI", ")", ",", "bearer", ".", "Scope", "(", "scopes", "...", ")", ",", "}", "\n\n", "// add transport", "if", "gsa", ".", "transport", "!=", "nil", "{", "opts", "=", "append", "(", "opts", ",", "bearer", ".", "Transport", "(", "gsa", ".", "transport", ")", ")", "\n", "}", "\n\n", "// create token source", "b", ",", "err", ":=", "bearer", ".", "NewTokenSource", "(", "signer", ",", "gsa", ".", "TokenURI", ",", "ctxt", ",", "opts", "...", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "b", ",", "nil", "\n", "}" ]
1,613
all-1614
[ "check", "returns", "true", "if", "all", "of", "the", "tags", "are", "true", ".", "Tags", "that", "start", "with", "!", "are", "negated", "(", "but", "!!", ")", "is", "not", "allowed", ".", "Go", "release", "tags", "(", "e", ".", "g", ".", "go1", ".", "8", ")", "are", "ignored", ".", "If", "the", "group", "contains", "an", "os", "or", "arch", "tag", "but", "the", "os", "or", "arch", "parameters", "are", "empty", "check", "returns", "false", "even", "if", "the", "tag", "is", "negated", "." ]
[ "func", "(", "g", "tagGroup", ")", "check", "(", "c", "*", "config", ".", "Config", ",", "os", ",", "arch", "string", ")", "bool", "{", "goConf", ":=", "getGoConfig", "(", "c", ")", "\n", "for", "_", ",", "t", ":=", "range", "g", "{", "if", "strings", ".", "HasPrefix", "(", "t", ",", "\"", "\"", ")", "{", "// bad syntax, reject always", "return", "false", "\n", "}", "\n", "not", ":=", "strings", ".", "HasPrefix", "(", "t", ",", "\"", "\"", ")", "\n", "if", "not", "{", "t", "=", "t", "[", "1", ":", "]", "\n", "}", "\n", "if", "isIgnoredTag", "(", "t", ")", "{", "// Release tags are treated as \"unknown\" and are considered true,", "// whether or not they are negated.", "continue", "\n", "}", "\n", "var", "match", "bool", "\n", "if", "_", ",", "ok", ":=", "rule", ".", "KnownOSSet", "[", "t", "]", ";", "ok", "{", "if", "os", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "match", "=", "os", "==", "t", "\n", "}", "else", "if", "_", ",", "<mask>", ":=", "rule", ".", "KnownArchSet", "[", "t", "]", ";", "ok", "{", "if", "arch", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "match", "=", "arch", "==", "t", "\n", "}", "else", "{", "match", "=", "goConf", ".", "genericTags", "[", "t", "]", "\n", "}", "\n", "if", "not", "{", "match", "=", "!", "match", "\n", "}", "\n", "if", "!", "match", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
1,614
all-1615
[ "DeleteConfig", "deletes", "an", "existing", "config", "if", "it", "exists", "or", "fail", "otherwise" ]
[ "func", "(", "s", "*", "<mask>", ")", "DeleteConfig", "(", "name", "string", ")", "error", "{", "return", "s", ".", "configs", ".", "Delete", "(", "name", ")", "\n", "}" ]
1,615
all-1616
[ "ForwardWordEnds", "is", "a", "wrapper", "around", "gtk_text_iter_forward_word_ends", "()", "." ]
[ "func", "(", "v", "*", "TextIter", ")", "ForwardWordEnds", "(", "v1", "int", ")", "bool", "{", "<mask>", "gobool", "(", "C", ".", "gtk_text_iter_forward_word_ends", "(", "v", ".", "native", "(", ")", ",", "C", ".", "gint", "(", "v1", ")", ")", ")", "\n", "}" ]
1,616
all-1617
[ "Do", "the", "same", "thing", "as", "fmt", ".", "Sprintf", "except", "it", "uses", "the", "optimal", "precition", "for", "floats", ":", "(", "0", "-", "3", ")", "for", "f", "and", "(", "0", "-", "6", ")", "for", "F", "eg", ".", ":", "optiSprintf", "(", "%f", "3", ".", "0", ")", "=", ">", "fmt", ".", "Sprintf", "(", "%", ".", "0f", "3", ".", "0", ")", "optiSprintf", "(", "%f", "3", ".", "33", ")", "=", ">", "fmt", ".", "Sprintf", "(", "%", ".", "2f", "3", ".", "33", ")", "optiSprintf", "(", "%f", "3", ".", "3001", ")", "=", ">", "fmt", ".", "Sprintf", "(", "%", ".", "1f", "3", ".", "3001", ")", "optiSprintf", "(", "%f", "3", ".", "333333333333333", ")", "=", ">", "fmt", ".", "Sprintf", "(", "%", ".", "3f", "3", ".", "333333333333333", ")", "optiSprintf", "(", "%F", "3", ".", "333333333333333", ")", "=", ">", "fmt", ".", "Sprintf", "(", "%", ".", "6f", "3", ".", "333333333333333", ")" ]
[ "func", "optiSprintf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "string", "{", "chunks", ":=", "strings", ".", "Split", "(", "format", ",", "\"", "\"", ")", "\n", "newChunks", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "chunks", ")", ")", "\n", "for", "i", ",", "chunk", ":=", "<mask>", "chunks", "{", "if", "i", "!=", "0", "{", "verb", ":=", "chunk", "[", "0", "]", "\n", "if", "verb", "==", "'f'", "||", "verb", "==", "'F'", "{", "num", ":=", "a", "[", "i", "-", "1", "]", ".", "(", "float64", ")", "\n", "p", ":=", "strconv", ".", "Itoa", "(", "getPrec", "(", "num", ",", "verb", "==", "'F'", ")", ")", "\n", "chunk", "=", "strings", ".", "Replace", "(", "chunk", ",", "string", "(", "verb", ")", ",", "\"", "\"", "+", "p", "+", "\"", "\"", ",", "1", ")", "\n", "}", "\n", "}", "\n", "newChunks", "[", "i", "]", "=", "chunk", "\n", "}", "\n", "format", "=", "strings", ".", "Join", "(", "newChunks", ",", "\"", "\"", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "format", ",", "a", "...", ")", "\n", "}" ]
1,617
all-1618
[ "Using", "the", "classic", "API", "posts", "a", "count", "of", "1", "to", "a", "stat", "." ]
[ "func", "(", "r", "*", "BasicReporter", ")", "PostCountOne", "(", "statKey", ",", "userKey", "<mask>", ")", "error", "{", "return", "r", ".", "PostCount", "(", "statKey", ",", "userKey", ",", "1", ")", "\n", "}" ]
1,618
all-1619
[ "GetEventSize", "returns", "the", "EventSize", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "w", "*", "Widget", ")", "GetEventSize", "(", ")", "<mask>", "{", "if", "w", "==", "nil", "||", "w", ".", "EventSize", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "w", ".", "EventSize", "\n", "}" ]
1,619
all-1620
[ "CreateFromType", "creates", "an", "instance", "of", "the", "given", "type" ]
[ "func", "(", "di", "*", "dependencyInjector", ")", "CreateFromType", "(", "atype", "reflect", ".", "<mask>", ")", "reflect", ".", "Value", "{", "if", "di", ".", "caching", "{", "return", "di", ".", "cachedCreateFromType", "(", "atype", ")", "\n", "}", "else", "{", "return", "di", ".", "createFromType", "(", "atype", ")", "\n", "}", "\n", "}" ]
1,620
all-1621
[ "HasMetricQuery", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "t", "*", "ToplistRequest", ")", "HasMetricQuery", "(", ")", "bool", "{", "if", "t", "!=", "nil", "&&", "t", ".", "MetricQuery", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
1,621
all-1622
[ "HasTitleAlign", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "h", "*", "HeatmapDefinition", ")", "HasTitleAlign", "(", ")", "bool", "{", "if", "h", "!=", "nil", "&&", "h", ".", "TitleAlign", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
1,622
all-1623
[ "Get", "the", "storage", "." ]
[ "func", "(", "s", "*", "ReadyStorage", ")", "Get", "(", ")", "*", "tsdb", ".", "<mask>", "{", "if", "x", ":=", "s", ".", "get", "(", ")", ";", "x", "!=", "nil", "{", "return", "x", ".", "db", "\n", "}", "\n", "return", "nil", "\n", "}" ]
1,623
all-1624
[ "Next", "would", "return", "the", "next", "integer", "in", "the", "sequence", "updating", "the", "lease", "by", "running", "a", "transaction", "if", "needed", "." ]
[ "func", "(", "seq", "*", "Sequence", ")", "Next", "(", ")", "(", "uint64", ",", "error", ")", "{", "seq", ".", "Lock", "(", ")", "\n", "defer", "seq", ".", "Unlock", "(", ")", "\n", "if", "seq", ".", "next", ">=", "seq", ".", "leased", "{", "if", "err", ":=", "seq", ".", "updateLease", "(", ")", ";", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "}", "\n", "val", ":=", "seq", ".", "next", "\n", "seq", ".", "<mask>", "++", "\n", "return", "val", ",", "nil", "\n", "}" ]
1,624
all-1625
[ "Set", "sets", "the", "specified", "key", "/", "value", "pair", "in", "the", "subresource", "." ]
[ "func", "(", "r", "*", "Subresource", ")", "Set", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "{", "if", "v", ":=", "structure", ".", "NormalizeValue", "(", "value", ")", ";", "v", "!=", "nil", "{", "r", ".", "data", "[", "<mask>", "]", "=", "v", "\n", "}", "\n", "}" ]
1,625
all-1626
[ "Attaches", "a", "shader", "object", "to", "a", "program", "object" ]
[ "func", "AttachShader", "(", "program", "uint32", ",", "shader", "uint32", ")", "{", "syscall", ".", "Syscall", "(", "gpAttachShader", ",", "2", ",", "uintptr", "(", "<mask>", ")", ",", "uintptr", "(", "shader", ")", ",", "0", ")", "\n", "}" ]
1,626
all-1627
[ "Reset", "reinitializes", "canvas", ":", "set", "clipping", "rectangle", "to", "the", "whole", "terminal", "window", "clears", "clip", "and", "color", "saved", "data", "sets", "colors", "to", "default", "ones" ]
[ "func", "Reset", "(", ")", "{", "canvas", ".", "<mask>", ",", "canvas", ".", "height", "=", "term", ".", "Size", "(", ")", "\n", "canvas", ".", "clipX", ",", "canvas", ".", "clipY", "=", "0", ",", "0", "\n", "canvas", ".", "clipW", ",", "canvas", ".", "clipH", "=", "canvas", ".", "width", ",", "canvas", ".", "height", "\n", "canvas", ".", "textColor", "=", "ColorWhite", "\n", "canvas", ".", "backColor", "=", "ColorBlack", "\n\n", "canvas", ".", "attrStack", "=", "make", "(", "[", "]", "attr", ",", "0", ")", "\n", "canvas", ".", "clipStack", "=", "make", "(", "[", "]", "rect", ",", "0", ")", "\n", "}" ]
1,627
all-1628
[ "UnmarshalJSON", "satisfies", "json", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "VersionRunningStatus", ")", "UnmarshalJSON", "(", "buf", "[", "]", "<mask>", ")", "error", "{", "return", "easyjson", ".", "Unmarshal", "(", "buf", ",", "t", ")", "\n", "}" ]
1,628
all-1629
[ "Loads", "the", "registry", "configuration", "file", "from", "the", "filesystem", "and", "then", "unmarshals", "it", ".", "Returns", "the", "unmarshalled", "object", "." ]
[ "func", "loadRegistryConf", "(", "configPath", "string", ")", "(", "*", "tomlConfig", ",", "error", ")", "{", "config", ":=", "&", "tomlConfig", "{", "}", "\n\n", "configBytes", ",", "err", ":=", "readConf", "(", "configPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "err", "=", "toml", ".", "Unmarshal", "(", "configBytes", ",", "&", "config", ")", "\n", "<mask>", "config", ",", "err", "\n", "}" ]
1,629
all-1630
[ "Asset", "get", "content", "with", "name", "from", "assetfs" ]
[ "func", "(", "<mask>", "*", "AssetFileSystem", ")", "Asset", "(", "name", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "for", "_", ",", "pth", ":=", "range", "fs", ".", "paths", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "filepath", ".", "Join", "(", "pth", ",", "name", ")", ")", ";", "err", "==", "nil", "{", "return", "ioutil", ".", "ReadFile", "(", "filepath", ".", "Join", "(", "pth", ",", "name", ")", ")", "\n", "}", "\n", "}", "\n", "return", "[", "]", "byte", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}" ]
1,630
all-1631
[ "goPackageName", "guesses", "the", "identifier", "in", "package", "declarations", "at", "the", "top", "of", "the", ".", "pb", ".", "go", "files", "that", "will", "be", "generated", "for", "this", "package", ".", "is", "returned", "if", "the", "package", "name", "cannot", "be", "determined", ".", "TODO", "(", "jayconrod", ")", ":", "remove", "all", "Go", "-", "specific", "functionality", ".", "This", "is", "here", "temporarily", "for", "compatibility", "." ]
[ "func", "goPackageName", "(", "pkg", "*", "Package", ")", "string", "{", "if", "opt", ",", "<mask>", ":=", "pkg", ".", "Options", "[", "\"", "\"", "]", ";", "ok", "{", "if", "i", ":=", "strings", ".", "IndexByte", "(", "opt", ",", "';'", ")", ";", "i", ">=", "0", "{", "return", "opt", "[", "i", "+", "1", ":", "]", "\n", "}", "else", "if", "i", ":=", "strings", ".", "LastIndexByte", "(", "opt", ",", "'/'", ")", ";", "i", ">=", "0", "{", "return", "opt", "[", "i", "+", "1", ":", "]", "\n", "}", "else", "{", "return", "opt", "\n", "}", "\n", "}", "\n", "if", "pkg", ".", "Name", "!=", "\"", "\"", "{", "return", "strings", ".", "Replace", "(", "pkg", ".", "Name", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n", "}", "\n", "if", "len", "(", "pkg", ".", "Files", ")", "==", "1", "{", "for", "s", ":=", "range", "pkg", ".", "Files", "{", "return", "strings", ".", "TrimSuffix", "(", "s", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
1,631
all-1632
[ "L", "accumulates", "a", "single", "line", "of", "source", "code", "." ]
[ "func", "(", "b", "*", "Buffer", ")", "L", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "fmt", ".", "Fprintf", "(", "b", ".", "buf", ",", "<mask>", ",", "a", "...", ")", "\n", "b", ".", "N", "(", ")", "\n", "}" ]
1,632
all-1633
[ "Callers", "returns", "a", "Trace", "for", "the", "current", "goroutine", "with", "element", "0", "identifying", "the", "calling", "function", "." ]
[ "func", "Callers", "(", ")", "Trace", "{", "pcs", ":=", "poolBuf", "(", ")", "\n", "pcs", "=", "pcs", "[", ":", "cap", "(", "pcs", ")", "]", "\n", "n", ":=", "runtime", ".", "Callers", "(", "2", ",", "pcs", ")", "\n", "cs", ":=", "make", "(", "[", "]", "Call", ",", "n", ")", "\n", "for", "i", ",", "pc", ":=", "<mask>", "pcs", "[", ":", "n", "]", "{", "cs", "[", "i", "]", "=", "Call", "(", "pc", ")", "\n", "}", "\n", "putPoolBuf", "(", "pcs", ")", "\n", "return", "cs", "\n", "}" ]
1,633
all-1634
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventCacheStorageListUpdated", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoStorage9", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
1,634
all-1635
[ "ParseRetentionDefs", "parses", "retention", "definitions", "into", "a", "Retentions", "structure" ]
[ "func", "ParseRetentionDefs", "(", "retentionDefs", "string", ")", "(", "whisper", ".", "Retentions", ",", "error", ")", "{", "retentions", ":=", "make", "(", "whisper", ".", "Retentions", ",", "0", ")", "\n", "for", "_", ",", "retentionDef", ":=", "range", "strings", ".", "Split", "(", "retentionDefs", ",", "\"", "\"", ")", "{", "retentionDef", "=", "strings", ".", "TrimSpace", "(", "retentionDef", ")", "\n", "parts", ":=", "strings", ".", "Split", "(", "retentionDef", ",", "\"", "\"", ")", "\n", "if", "len", "(", "<mask>", ")", "!=", "2", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "retentionDef", ")", "\n", "}", "\n\n", "// try old format", "val1", ",", "err1", ":=", "strconv", ".", "ParseInt", "(", "parts", "[", "0", "]", ",", "10", ",", "0", ")", "\n", "val2", ",", "err2", ":=", "strconv", ".", "ParseInt", "(", "parts", "[", "1", "]", ",", "10", ",", "0", ")", "\n\n", "if", "err1", "==", "nil", "&&", "err2", "==", "nil", "{", "retention", ":=", "whisper", ".", "NewRetention", "(", "int", "(", "val1", ")", ",", "int", "(", "val2", ")", ")", "\n", "retentions", "=", "append", "(", "retentions", ",", "&", "retention", ")", "\n", "continue", "\n", "}", "\n\n", "// try new format", "retention", ",", "err", ":=", "whisper", ".", "ParseRetentionDef", "(", "retentionDef", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "retentions", "=", "append", "(", "retentions", ",", "retention", ")", "\n", "}", "\n", "return", "retentions", ",", "nil", "\n", "}" ]
1,635
all-1636
[ "HasWidth", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "w", "*", "WidgetLayout", ")", "HasWidth", "(", ")", "bool", "{", "if", "w", "!=", "nil", "&&", "w", ".", "Width", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
1,636
all-1637
[ "VisitAll", "calls", "f", "for", "each", "header", ".", "f", "must", "not", "retain", "references", "to", "key", "and", "/", "or", "value", "after", "returning", ".", "Copy", "key", "and", "/", "or", "value", "contents", "before", "returning", "if", "you", "need", "retaining", "them", "." ]
[ "func", "(", "h", "*", "ResponseHeader", ")", "VisitAll", "(", "f", "func", "(", "key", ",", "value", "[", "]", "byte", ")", ")", "{", "if", "len", "(", "h", ".", "contentLengthBytes", ")", ">", "0", "{", "f", "(", "strContentLength", ",", "h", ".", "contentLengthBytes", ")", "\n", "}", "\n", "contentType", ":=", "h", ".", "ContentType", "(", ")", "\n", "if", "len", "(", "contentType", ")", ">", "0", "{", "f", "(", "strContentType", ",", "contentType", ")", "\n", "}", "\n", "server", ":=", "h", ".", "Server", "(", ")", "\n", "if", "len", "(", "server", ")", ">", "0", "{", "f", "(", "strServer", ",", "server", ")", "\n", "}", "\n", "if", "len", "(", "h", ".", "cookies", ")", ">", "0", "{", "visitArgs", "(", "h", ".", "cookies", ",", "func", "(", "k", ",", "v", "[", "]", "<mask>", ")", "{", "f", "(", "strSetCookie", ",", "v", ")", "\n", "}", ")", "\n", "}", "\n", "visitArgs", "(", "h", ".", "h", ",", "f", ")", "\n", "if", "h", ".", "ConnectionClose", "(", ")", "{", "f", "(", "strConnection", ",", "strClose", ")", "\n", "}", "\n", "}" ]
1,637
all-1638
[ "Write", "sends", "n", "bytes", "from", "p", "to", "the", "server", ".", "Note", "that", "Write", "can", "only", "be", "used", "for", "sending", "TELNET", "(", "and", "TELNETS", ")", "data", "to", "the", "server", ".", "TELNET", "(", "and", "TELNETS", ")", "command", "codes", "cannot", "be", "sent", "using", "this", "method", "as", "Write", "deals", "with", "TELNET", "(", "and", "TELNETS", ")", "escaping", "and", "will", "properly", "escape", "anything", "written", "with", "it", ".", "Write", "makes", "Conn", "fit", "the", "io", ".", "Writer", "interface", "." ]
[ "func", "(", "clientConn", "*", "Conn", ")", "Write", "(", "p", "[", "]", "<mask>", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "clientConn", ".", "dataWriter", ".", "Write", "(", "p", ")", "\n", "}" ]
1,638
all-1639
[ "Execute", "takes", "a", "TemplateMsg", "and", "applies", "it", "to", "the", "Go", "template", ".", "If", "colorize", "is", "true", "the", "template", "will", "insert", "ANSI", "color", "codes", "within", "the", "resulting", "string", "." ]
[ "func", "(", "t", "*", "Template", ")", "Execute", "(", "<mask>", "*", "TemplateMsg", ",", "colorize", "bool", ")", "(", "string", ",", "error", ")", "{", "tplLevel", ":=", "msg", ".", "Level", "\n", "if", "!", "colorize", "{", "tplLevel", "=", "LevelNone", "\n", "}", "\n", "var", "buf", "bytes", ".", "Buffer", "\n", "execTpl", ":=", "t", ".", "tpls", "[", "tplLevel", "]", "\n", "if", "execTpl", "==", "nil", "{", "return", "\"", "\"", ",", "ErrUnknownLevel", "\n", "}", "\n", "err", ":=", "execTpl", ".", "Execute", "(", "&", "buf", ",", "msg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "buf", ".", "String", "(", ")", ",", "nil", "\n", "}" ]
1,639
all-1640
[ "Ensure", "that", "the", "container", "s", "policy", "namespace", "is", "unloaded", "to", "free", "kernel", "memory", ".", "This", "does", "not", "delete", "the", "policy", "from", "disk", "or", "cache", "." ]
[ "func", "AADestroy", "(", "c", "container", ")", "error", "{", "state", ":=", "c", ".", "DaemonState", "(", ")", "\n", "if", "!", "state", ".", "OS", ".", "AppArmorAdmin", "{", "return", "nil", "\n", "}", "\n\n", "if", "state", ".", "OS", ".", "AppArmorStacking", "&&", "!", "state", ".", "OS", ".", "AppArmorStacked", "{", "p", ":=", "path", ".", "Join", "(", "\"", "\"", ",", "AANamespace", "(", "c", ")", ")", "\n", "if", "err", ":=", "os", ".", "Remove", "(", "p", ")", ";", "err", "!=", "nil", "{", "logger", ".", "<mask>", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "p", "}", ")", "\n", "}", "\n", "}", "\n\n", "return", "runApparmor", "(", "APPARMOR_CMD_UNLOAD", ",", "c", ")", "\n", "}" ]
1,640
all-1641
[ "ListTeams", "gets", "a", "list", "of", "teams", "for", "the", "given", "org", "See", "https", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "teams", "/", "#list", "-", "teams" ]
[ "func", "(", "c", "*", "Client", ")", "ListTeams", "(", "org", "string", ")", "(", "[", "]", "Team", ",", "error", ")", "{", "c", ".", "log", "(", "\"", "\"", ",", "org", ")", "\n", "if", "c", ".", "fake", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "<mask>", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "org", ")", "\n", "var", "teams", "[", "]", "Team", "\n", "err", ":=", "c", ".", "readPaginatedResults", "(", "path", ",", "// This accept header enables the nested teams preview.", "// https://developer.github.com/changes/2017-08-30-preview-nested-teams/", "\"", "\"", ",", "func", "(", ")", "interface", "{", "}", "{", "return", "&", "[", "]", "Team", "{", "}", "\n", "}", ",", "func", "(", "obj", "interface", "{", "}", ")", "{", "teams", "=", "append", "(", "teams", ",", "*", "(", "obj", ".", "(", "*", "[", "]", "Team", ")", ")", "...", ")", "\n", "}", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "teams", ",", "nil", "\n", "}" ]
1,641
all-1642
[ "Get", "the", "string", "representation", "of", "the", "wrapper", "error", "or", "an", "empty", "string", "if", "wrappedErr", "is", "nil" ]
[ "func", "(", "e", "*", "err", ")", "wrappedErrStr", "(", ")", "string", "{", "if", "e", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "e", ".", "wrappedErr", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "e", ".", "wrappedErr", ".", "<mask>", "(", ")", "\n", "}" ]
1,642
all-1643
[ "checkpointScheduledLeases", "finds", "all", "scheduled", "lease", "checkpoints", "that", "are", "due", "and", "submits", "them", "to", "the", "checkpointer", "to", "persist", "them", "to", "the", "consensus", "log", "." ]
[ "func", "(", "le", "*", "lessor", ")", "checkpointScheduledLeases", "(", ")", "{", "<mask>", "cps", "[", "]", "*", "pb", ".", "LeaseCheckpoint", "\n\n", "// rate limit", "for", "i", ":=", "0", ";", "i", "<", "leaseCheckpointRate", "/", "2", ";", "i", "++", "{", "le", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "le", ".", "isPrimary", "(", ")", "{", "cps", "=", "le", ".", "findDueScheduledCheckpoints", "(", "maxLeaseCheckpointBatchSize", ")", "\n", "}", "\n", "le", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "len", "(", "cps", ")", "!=", "0", "{", "le", ".", "cp", "(", "context", ".", "Background", "(", ")", ",", "&", "pb", ".", "LeaseCheckpointRequest", "{", "Checkpoints", ":", "cps", "}", ")", "\n", "}", "\n", "if", "len", "(", "cps", ")", "<", "maxLeaseCheckpointBatchSize", "{", "return", "\n", "}", "\n", "}", "\n", "}" ]
1,643
all-1644
[ "CallErr", "queues", "function", "f", "on", "the", "main", "thread", "and", "returns", "an", "error", "returned", "by", "f", "." ]
[ "func", "CallErr", "(", "f", "func", "(", ")", "error", ")", "error", "{", "checkRun", "(", ")", "\n", "errChan", ":=", "<mask>", "(", "chan", "error", ")", "\n", "callQueue", "<-", "func", "(", ")", "{", "errChan", "<-", "f", "(", ")", "\n", "}", "\n", "return", "<-", "errChan", "\n", "}" ]
1,644
all-1645
[ "skipRequested", "posts", "skipped", "statuses", "for", "the", "config", ".", "Presubmits", "that", "are", "requested" ]
[ "func", "skipRequested", "(", "c", "Client", ",", "pr", "*", "github", ".", "PullRequest", ",", "skippedJobs", "[", "]", "config", ".", "Presubmit", ")", "error", "{", "var", "errors", "[", "]", "error", "\n", "for", "_", ",", "job", ":=", "range", "skippedJobs", "{", "if", "job", ".", "SkipReport", "{", "continue", "\n", "}", "\n", "c", ".", "Logger", ".", "Infof", "(", "\"", "\"", ",", "job", ".", "Name", ")", "\n", "if", "err", ":=", "c", ".", "GitHubClient", ".", "CreateStatus", "(", "pr", ".", "Base", ".", "Repo", ".", "Owner", ".", "Login", ",", "pr", ".", "Base", ".", "Repo", ".", "Name", ",", "pr", ".", "Head", ".", "SHA", ",", "skippedStatusFor", "(", "job", ".", "Context", ")", ")", ";", "err", "!=", "nil", "{", "errors", "=", "append", "(", "<mask>", ",", "err", ")", "\n", "}", "\n", "}", "\n", "return", "errorutil", ".", "NewAggregate", "(", "errors", "...", ")", "\n", "}" ]
1,645
all-1646
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "LayoutViewport", ")", "UnmarshalJSON", "(", "<mask>", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage28", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
1,646
all-1647
[ "helper", "to", "update", "disk", "metrics" ]
[ "func", "updateMetrics", "(", "interval", "time", ".", "Duration", ",", "diskRoot", "string", ")", "{", "logger", ":=", "logrus", ".", "WithField", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "ticker", ":=", "time", ".", "NewTicker", "(", "interval", ")", "\n", "for", ";", "true", ";", "<-", "ticker", ".", "C", "{", "logger", ".", "Info", "(", "\"", "\"", ")", "\n", "_", ",", "bytesFree", ",", "bytesUsed", ",", "err", ":=", "diskutil", ".", "GetDiskUsage", "(", "diskRoot", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "WithError", "(", "err", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "}", "else", "{", "promMetrics", ".", "DiskFree", ".", "Set", "(", "float64", "(", "bytesFree", ")", "/", "1e9", ")", "\n", "promMetrics", ".", "DiskUsed", ".", "Set", "(", "float64", "(", "bytesUsed", ")", "/", "1e9", ")", "\n", "promMetrics", ".", "DiskTotal", ".", "<mask>", "(", "float64", "(", "bytesFree", "+", "bytesUsed", ")", "/", "1e9", ")", "\n", "}", "\n", "}", "\n", "}" ]
1,647
all-1648
[ "batchSetAsync", "is", "the", "asynchronous", "version", "of", "batchSet", ".", "It", "accepts", "a", "callback", "function", "which", "is", "called", "when", "all", "the", "sets", "are", "complete", ".", "If", "a", "request", "level", "error", "occurs", "it", "will", "be", "passed", "back", "via", "the", "callback", ".", "err", ":", "=", "kv", ".", "BatchSetAsync", "(", "entries", "func", "(", "err", "error", "))", "{", "Check", "(", "err", ")", "}" ]
[ "func", "(", "db", "*", "<mask>", ")", "batchSetAsync", "(", "entries", "[", "]", "*", "Entry", ",", "f", "func", "(", "error", ")", ")", "error", "{", "req", ",", "err", ":=", "db", ".", "sendToWriteCh", "(", "entries", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "go", "func", "(", ")", "{", "err", ":=", "req", ".", "Wait", "(", ")", "\n", "// Write is complete. Let's call the callback function now.", "f", "(", "err", ")", "\n", "}", "(", ")", "\n", "return", "nil", "\n", "}" ]
1,648
all-1649
[ "WithContext", "adds", "the", "context", "to", "the", "find", "vms", "by", "filters", "params" ]
[ "func", "(", "o", "*", "FindVmsByFiltersParams", ")", "WithContext", "(", "ctx", "context", ".", "<mask>", ")", "*", "FindVmsByFiltersParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
1,649
all-1650
[ "Update", "the", "call", "with", "the", "given", "data", ".", "Valid", "parameters", "may", "be", "found", "here", ":", "https", ":", "//", "www", ".", "twilio", ".", "com", "/", "docs", "/", "api", "/", "rest", "/", "change", "-", "call", "-", "state#post", "-", "parameters" ]
[ "func", "(", "c", "*", "CallService", ")", "Update", "(", "ctx", "context", ".", "Context", ",", "sid", "string", ",", "data", "url", ".", "Values", ")", "(", "*", "Call", ",", "error", ")", "{", "call", ":=", "new", "(", "Call", ")", "\n", "err", ":=", "c", ".", "client", ".", "UpdateResource", "(", "ctx", ",", "callsPathPart", ",", "sid", ",", "data", ",", "call", ")", "\n", "return", "<mask>", ",", "err", "\n", "}" ]
1,650
all-1651
[ "AllowProjectPermission", "is", "a", "wrapper", "to", "check", "access", "against", "the", "project", "its", "features", "and", "RBAC", "permission" ]
[ "func", "AllowProjectPermission", "(", "feature", "string", ",", "permission", "string", ")", "func", "(", "d", "*", "Daemon", ",", "r", "*", "http", ".", "Request", ")", "<mask>", "{", "return", "func", "(", "d", "*", "Daemon", ",", "r", "*", "http", ".", "Request", ")", "Response", "{", "// Shortcut for speed", "if", "d", ".", "userIsAdmin", "(", "r", ")", "{", "return", "EmptySyncResponse", "\n", "}", "\n\n", "// Get the project", "project", ":=", "projectParam", "(", "r", ")", "\n\n", "// Validate whether the user has the needed permission", "if", "!", "d", ".", "userHasPermission", "(", "r", ",", "project", ",", "permission", ")", "{", "return", "Forbidden", "(", "nil", ")", "\n", "}", "\n\n", "return", "EmptySyncResponse", "\n", "}", "\n", "}" ]
1,651
all-1652
[ "IsSlug", "returns", "True", "if", "provided", "text", "does", "not", "contain", "white", "characters", "punctuation", "all", "letters", "are", "lower", "case", "and", "only", "from", "ASCII", "range", ".", "It", "could", "contain", "-", "and", "_", "but", "not", "at", "the", "beginning", "or", "end", "of", "the", "text", ".", "It", "should", "be", "in", "range", "of", "the", "MaxLength", "var", "if", "specified", ".", "All", "output", "from", "slug", ".", "Make", "(", "text", ")", "should", "pass", "this", "test", "." ]
[ "func", "IsSlug", "(", "text", "string", ")", "bool", "{", "if", "text", "==", "\"", "\"", "||", "(", "MaxLength", ">", "0", "&&", "len", "(", "text", ")", ">", "MaxLength", ")", "||", "<mask>", "[", "0", "]", "==", "'-'", "||", "text", "[", "0", "]", "==", "'_'", "||", "text", "[", "len", "(", "text", ")", "-", "1", "]", "==", "'-'", "||", "text", "[", "len", "(", "text", ")", "-", "1", "]", "==", "'_'", "{", "return", "false", "\n", "}", "\n", "for", "_", ",", "c", ":=", "range", "text", "{", "if", "(", "c", "<", "'a'", "||", "c", ">", "'z'", ")", "&&", "c", "!=", "'-'", "&&", "c", "!=", "'_'", "&&", "(", "c", "<", "'0'", "||", "c", ">", "'9'", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
1,652
all-1653
[ "NewMongo", "creates", "a", "newinstance", "of", "Mongo" ]
[ "func", "NewMongo", "(", "filename", "string", ",", "environment", "string", ")", "(", "*", "Mongo", ",", "error", ")", "{", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "cnf", ",", "err", ":=", "GetMongo", "(", "filename", ",", "environment", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "<mask>", "uri", "string", "\n", "if", "len", "(", "cnf", ".", "Username", ")", ">", "0", "&&", "len", "(", "cnf", ".", "Password", ")", ">", "0", "{", "uri", "=", "fmt", ".", "Sprintf", "(", "`mongodb://%s:%s@%s:%d/%s`", ",", "cnf", ".", "Username", ",", "cnf", ".", "Password", ",", "cnf", ".", "Host", ",", "cnf", ".", "Port", ",", "cnf", ".", "Database", ",", ")", "\n", "}", "else", "{", "uri", "=", "fmt", ".", "Sprintf", "(", "`mongodb://%s:%d/%s`", ",", "cnf", ".", "Host", ",", "cnf", ".", "Port", ",", "cnf", ".", "Database", ",", ")", "\n", "}", "\n", "client", ",", "err", ":=", "mongo", ".", "NewClient", "(", "uri", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "uri", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "err", "=", "client", ".", "Connect", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Print", "(", "\"", "\"", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "db", ":=", "client", ".", "Database", "(", "cnf", ".", "Database", ")", "\n\n", "err", "=", "client", ".", "Ping", "(", "ctx", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "cnf", ".", "Host", ",", "cnf", ".", "Port", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "Mongo", "{", "Client", ":", "client", ",", "Database", ":", "db", ",", "context", ":", "ctx", "}", ",", "nil", "\n", "}" ]
1,653
all-1654
[ "deleteOneSignature", "deletes", "a", "signature", "from", "url", "if", "it", "exists", ".", "If", "it", "successfully", "determines", "that", "the", "signature", "does", "not", "exist", "returns", "(", "true", "nil", ")", "NOTE", ":", "Keep", "this", "in", "sync", "with", "docs", "/", "signature", "-", "protocols", ".", "md!" ]
[ "func", "(", "c", "*", "dockerClient", ")", "deleteOneSignature", "(", "url", "*", "url", ".", "URL", ")", "(", "missing", "bool", ",", "err", "error", ")", "{", "switch", "url", ".", "Scheme", "{", "case", "\"", "\"", ":", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "url", ".", "Path", ")", "\n", "err", ":=", "os", ".", "Remove", "(", "url", ".", "<mask>", ")", "\n", "if", "err", "!=", "nil", "&&", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "true", ",", "nil", "\n", "}", "\n", "return", "false", ",", "err", "\n\n", "case", "\"", "\"", ",", "\"", "\"", ":", "return", "false", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "url", ".", "Scheme", ",", "url", ".", "String", "(", ")", ")", "\n", "default", ":", "return", "false", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "url", ".", "String", "(", ")", ")", "\n", "}", "\n", "}" ]
1,654
all-1655
[ "NewMockNetLink", "creates", "a", "new", "mock", "instance" ]
[ "func", "NewMockNetLink", "(", "ctrl", "*", "gomock", ".", "<mask>", ")", "*", "MockNetLink", "{", "mock", ":=", "&", "MockNetLink", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockNetLinkMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
1,655
all-1656
[ "Write", "writes", "len", "(", "p", ")", "float64", "values", "from", "p", "to", "the", "underlying", "data", "stream", ".", "It", "returns", "the", "number", "of", "bytes", "written", "from", "p", "(", "0", "<", "=", "n", "<", "=", "len", "(", "p", "))", "and", "any", "error", "encountered", "that", "caused", "the", "write", "to", "stop", "early", ".", "Write", "must", "return", "a", "non", "-", "nil", "error", "if", "it", "returns", "n", "<", "len", "(", "p", ")", "." ]
[ "func", "(", "b", "*", "Float64RingBuf", ")", "Write", "(", "p", "[", "]", "float64", ")", "(", "n", "int", ",", "err", "error", ")", "{", "for", "{", "if", "len", "(", "p", ")", "==", "0", "{", "// nothing (left) to copy in; notice we shorten our", "// local copy p (below) as we read from it.", "return", "\n", "}", "\n\n", "writeCapacity", ":=", "b", ".", "N", "-", "b", ".", "Readable", "\n", "if", "writeCapacity", "<=", "0", "{", "// we are all full up already.", "return", "n", ",", "<mask>", ".", "ErrShortWrite", "\n", "}", "\n", "if", "len", "(", "p", ")", ">", "writeCapacity", "{", "err", "=", "io", ".", "ErrShortWrite", "\n", "// leave err set and", "// keep going, write what we can.", "}", "\n\n", "writeStart", ":=", "(", "b", ".", "Beg", "+", "b", ".", "Readable", ")", "%", "b", ".", "N", "\n\n", "upperLim", ":=", "intMin", "(", "writeStart", "+", "writeCapacity", ",", "b", ".", "N", ")", "\n\n", "k", ":=", "copy", "(", "b", ".", "A", "[", "writeStart", ":", "upperLim", "]", ",", "p", ")", "\n\n", "n", "+=", "k", "\n", "b", ".", "Readable", "+=", "k", "\n", "p", "=", "p", "[", "k", ":", "]", "\n\n", "// we can fill from b.A[0:something] from", "// p's remainder, so loop", "}", "\n", "}" ]
1,656
all-1657
[ "HexToHash", "returns", "the", "ethereum", "s", "hash", "represented", "by", "the", "hex", "of", "string", "s", "." ]
[ "func", "HexToHash", "(", "h", "HexString", ")", "(", "<mask>", ".", "Hash", ",", "error", ")", "{", "hashBytes", ",", "err", ":=", "HexToBytes", "(", "h", ")", "\n", "if", "err", "!=", "nil", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "common", ".", "BytesToHash", "(", "hashBytes", ")", ",", "err", "\n", "}" ]
1,657
all-1658
[ "expandCustomizationGuiRunOnce", "reads", "certain", "ResourceData", "keys", "and", "returns", "a", "CustomizationGuiRunOnce", "." ]
[ "func", "expandCustomizationGuiRunOnce", "(", "d", "*", "schema", ".", "ResourceData", ")", "*", "types", ".", "CustomizationGuiRunOnce", "{", "obj", ":=", "&", "types", ".", "CustomizationGuiRunOnce", "{", "CommandList", ":", "structure", ".", "SliceInterfacesToStrings", "(", "d", ".", "Get", "(", "cWindowsKeyPrefix", "+", "\"", "\"", "+", "\"", "\"", ")", ".", "(", "[", "]", "<mask>", "{", "}", ")", ")", ",", "}", "\n", "if", "len", "(", "obj", ".", "CommandList", ")", "<", "1", "{", "return", "nil", "\n", "}", "\n", "return", "obj", "\n", "}" ]
1,658
all-1659
[ "GetTopMargin", "()", "is", "a", "wrapper", "around", "gtk_page_setup_get_top_margin", "()", "." ]
[ "func", "(", "ps", "*", "PageSetup", ")", "GetTopMargin", "(", "<mask>", "Unit", ")", "float64", "{", "c", ":=", "C", ".", "gtk_page_setup_get_top_margin", "(", "ps", ".", "native", "(", ")", ",", "C", ".", "GtkUnit", "(", "unit", ")", ")", "\n", "return", "float64", "(", "c", ")", "\n", "}" ]
1,659
all-1660
[ "HasTitle", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "q", "*", "QueryValueDefinition", ")", "HasTitle", "(", ")", "bool", "{", "if", "q", "!=", "nil", "&&", "q", ".", "Title", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
1,660
all-1661
[ "Sets", "the", "output", "path", "for", "generated", "snapshots", "." ]
[ "func", "(", "t", "*", "BTTracer", ")", "SetOutputPath", "(", "path", "string", ",", "perm", "<mask>", ".", "FileMode", ")", "error", "{", "return", "nil", "\n", "}" ]
1,661
all-1662
[ "Name", "returns", "v", "s", "name", "value", ".", "If", "v", ".", "Kind", "()", "!", "=", "Name", "Name", "returns", "the", "empty", "string", ".", "The", "returned", "name", "does", "not", "include", "the", "leading", "slash", ":", "if", "v", "corresponds", "to", "the", "name", "written", "using", "the", "syntax", "/", "Helvetica", "Name", "()", "==", "Helvetica", "." ]
[ "func", "(", "v", "Value", ")", "Name", "(", ")", "string", "{", "x", ",", "ok", ":=", "v", ".", "data", ".", "(", "<mask>", ")", "\n", "if", "!", "ok", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "string", "(", "x", ")", "\n", "}" ]
1,662
all-1663
[ "GetLocked", "returns", "the", "Locked", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "o", "*", "Options", ")", "GetLocked", "(", ")", "bool", "{", "if", "o", "==", "nil", "||", "o", ".", "Locked", "==", "nil", "{", "return", "<mask>", "\n", "}", "\n", "return", "*", "o", ".", "Locked", "\n", "}" ]
1,663
all-1664
[ "goValue", "converts", "a", "*", "Object", "to", "a", "Go", "type", "(", "e", ".", "g", ".", "*", "Object", "=", ">", "*", "gtk", ".", "Entry", ")", ".", "It", "is", "used", "in", "goMarshal", "to", "convert", "generic", "GObject", "parameters", "to", "signal", "handlers", "to", "the", "actual", "types", "expected", "by", "the", "signal", "handler", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "goValue", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "objType", ":=", "Type", "(", "C", ".", "_g_type_from_instance", "(", "C", ".", "gpointer", "(", "v", ".", "native", "(", ")", ")", ")", ")", "\n", "f", ",", "err", ":=", "gValueMarshalers", ".", "lookupType", "(", "objType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// The marshalers expect Values, not Objects", "val", ",", "err", ":=", "ValueInit", "(", "objType", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "val", ".", "SetInstance", "(", "uintptr", "(", "unsafe", ".", "Pointer", "(", "v", ".", "GObject", ")", ")", ")", "\n", "rv", ",", "err", ":=", "f", "(", "uintptr", "(", "unsafe", ".", "Pointer", "(", "val", ".", "native", "(", ")", ")", ")", ")", "\n", "return", "rv", ",", "err", "\n", "}" ]
1,664
all-1665
[ "SendMarkdownMsg", "发送markdown消息,仅支持以下格式", "/", "*", "标题", "#", "一级标题", "##", "二级标题", "###", "三级标题", "####", "四级标题", "#####", "五级标题", "######", "六级标题" ]
[ "func", "(", "w", "*", "Webhook", ")", "SendMarkdownMsg", "(", "title", ",", "content", "string", ",", "isAtAll", "bool", ",", "mobiles", "...", "string", ")", "error", "{", "return", "w", ".", "SendPayload", "(", "&", "Payload", "{", "MsgType", ":", "\"", "\"", ",", "Markdown", ":", "struct", "{", "<mask>", "string", "`json:\"text\"`", "\n", "Title", "string", "`json:\"title\"`", "\n", "}", "{", "Text", ":", "content", ",", "Title", ":", "title", ",", "}", ",", "At", ":", "struct", "{", "AtMobiles", "[", "]", "string", "`json:\"atMobiles\"`", "\n", "IsAtAll", "bool", "`json:\"isAtAll\"`", "\n", "}", "{", "AtMobiles", ":", "mobiles", ",", "IsAtAll", ":", "isAtAll", ",", "}", ",", "}", ")", "\n", "}" ]
1,665
all-1666
[ "recvMsg", "receives", "a", "message", "(", "possibly", "dropping", "a", "message", "on", "full", "buffers", ")" ]
[ "func", "(", "s", "*", "Stream", ")", "recvMsg", "(", "msg", "<mask>", "{", "}", ")", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "if", "s", ".", "recvBuffer", "==", "nil", "{", "s", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "\n", "}", "\n", "defer", "s", ".", "mu", ".", "RUnlock", "(", ")", "\n", "select", "{", "case", "s", ".", "recvBuffer", "<-", "msg", ":", "// normal flow if the channel is not blocked", "default", ":", "s", ".", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "atomic", ".", "AddUint64", "(", "&", "s", ".", "dropped", ",", "1", ")", "\n", "<-", "s", ".", "recvBuffer", "// drop oldest and try again (if application temporarily unavailable)", "\n", "select", "{", "case", "s", ".", "recvBuffer", "<-", "msg", ":", "default", ":", "// drop newest (too many cuncurrent recvMsg)", "atomic", ".", "AddUint64", "(", "&", "s", ".", "dropped", ",", "1", ")", "\n", "s", ".", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "}" ]
1,666
all-1667
[ "Methods", "returns", "the", "methods", "on", "this", "service", "not", "including", "methods", "from", "inherited", "services", "." ]
[ "func", "(", "s", "*", "Service", ")", "Methods", "(", ")", "[", "]", "*", "Method", "{", "if", "s", ".", "methods", "!=", "nil", "{", "return", "s", ".", "methods", "\n", "}", "\n\n", "for", "_", ",", "m", ":=", "<mask>", "s", ".", "Service", ".", "Methods", "{", "s", ".", "methods", "=", "append", "(", "s", ".", "methods", ",", "&", "Method", "{", "m", ",", "s", ",", "s", ".", "state", "}", ")", "\n", "}", "\n", "sort", ".", "Sort", "(", "byMethodName", "(", "s", ".", "methods", ")", ")", "\n", "return", "s", ".", "methods", "\n", "}" ]
1,667
all-1668
[ "initializeSSMSecretResource", "builds", "the", "resource", "dependency", "map", "for", "the", "SSM", "ssmsecret", "resource" ]
[ "func", "(", "task", "*", "Task", ")", "initializeSSMSecretResource", "(", "credentialsManager", "credentials", ".", "<mask>", ",", "resourceFields", "*", "taskresource", ".", "ResourceFields", ")", "{", "ssmSecretResource", ":=", "ssmsecret", ".", "NewSSMSecretResource", "(", "task", ".", "Arn", ",", "task", ".", "getAllSSMSecretRequirements", "(", ")", ",", "task", ".", "ExecutionCredentialsID", ",", "credentialsManager", ",", "resourceFields", ".", "SSMClientCreator", ")", "\n", "task", ".", "AddResource", "(", "ssmsecret", ".", "ResourceName", ",", "ssmSecretResource", ")", "\n\n", "// for every container that needs ssm secret vending as env, it needs to wait all secrets got retrieved", "for", "_", ",", "container", ":=", "range", "task", ".", "Containers", "{", "if", "container", ".", "ShouldCreateWithSSMSecret", "(", ")", "{", "container", ".", "BuildResourceDependency", "(", "ssmSecretResource", ".", "GetName", "(", ")", ",", "resourcestatus", ".", "ResourceStatus", "(", "ssmsecret", ".", "SSMSecretCreated", ")", ",", "apicontainerstatus", ".", "ContainerCreated", ")", "\n", "}", "\n", "}", "\n", "}" ]
1,668
all-1669
[ "NewGoogleClient", "creates", "a", "google", "client", "with", "the", "given", "bucket", "name", "." ]
[ "func", "NewGoogleClient", "(", "bucket", "string", ",", "opts", "[", "]", "option", ".", "ClientOption", ")", "(", "<mask>", ",", "error", ")", "{", "return", "newGoogleClient", "(", "bucket", ",", "opts", ")", "\n", "}" ]
1,669
all-1670
[ "startStream", "will", "start", "a", "new", "XML", "decoder", "for", "the", "connection", "signal", "the", "start", "of", "a", "stream", "to", "the", "server", "and", "verify", "that", "the", "server", "has", "also", "started", "the", "stream", ";", "if", "o", ".", "Debug", "is", "true", "startStream", "will", "tee", "decoded", "XML", "data", "to", "stderr", ".", "The", "features", "advertised", "by", "the", "server", "will", "be", "returned", "." ]
[ "func", "(", "c", "*", "Client", ")", "startStream", "(", "o", "*", "Options", ",", "domain", "string", ")", "(", "*", "streamFeatures", ",", "error", ")", "{", "if", "o", ".", "Debug", "{", "c", ".", "p", "=", "xml", ".", "NewDecoder", "(", "tee", "{", "c", ".", "conn", ",", "DebugWriter", "}", ")", "\n", "}", "else", "{", "c", ".", "p", "=", "xml", ".", "NewDecoder", "(", "c", ".", "conn", ")", "\n", "}", "\n\n", "_", ",", "err", ":=", "fmt", ".", "Fprintf", "(", "c", ".", "<mask>", ",", "\"", "\\n", "\"", "+", "\"", "\\n", "\"", "+", "\"", "\\n", "\"", ",", "xmlEscape", "(", "domain", ")", ",", "nsClient", ",", "nsStream", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// We expect the server to start a <stream>.", "se", ",", "err", ":=", "nextStart", "(", "c", ".", "p", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "se", ".", "Name", ".", "Space", "!=", "nsStream", "||", "se", ".", "Name", ".", "Local", "!=", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "se", ".", "Name", ".", "Local", ",", "se", ".", "Name", ".", "Space", ")", "\n", "}", "\n\n", "// Now we're in the stream and can use Unmarshal.", "// Next message should be <features> to tell us authentication options.", "// See section 4.6 in RFC 3920.", "f", ":=", "new", "(", "streamFeatures", ")", "\n", "if", "err", "=", "c", ".", "p", ".", "DecodeElement", "(", "f", ",", "nil", ")", ";", "err", "!=", "nil", "{", "return", "f", ",", "errors", ".", "New", "(", "\"", "\"", "+", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "return", "f", ",", "nil", "\n", "}" ]
1,670
all-1671
[ "EnsureIndex", "creates", "an", "index", "on", "the", "server", "if", "it", "does", "not", "exist", "." ]
[ "func", "(", "c", "*", "Client", ")", "EnsureIndex", "(", "<mask>", "*", "Index", ")", "error", "{", "err", ":=", "c", ".", "CreateIndex", "(", "index", ")", "\n", "if", "err", "==", "ErrIndexExists", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}" ]
1,671
all-1672
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "ResolveNodeParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom11", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
1,672
all-1673
[ "diff", "is", "what", "diffOldNew", "and", "diffNewOld", "hand", "off", "to", "." ]
[ "func", "(", "p", "*", "tagDiffProcessor", ")", "diff", "(", "a", ",", "b", "[", "]", "string", ")", "[", "]", "string", "{", "var", "<mask>", "bool", "\n", "c", ":=", "make", "(", "[", "]", "string", ",", "0", ")", "\n", "for", "_", ",", "v1", ":=", "range", "a", "{", "for", "_", ",", "v2", ":=", "range", "b", "{", "if", "v1", "==", "v2", "{", "found", "=", "true", "\n", "}", "\n", "}", "\n", "if", "!", "found", "{", "c", "=", "append", "(", "c", ",", "v1", ")", "\n", "}", "\n", "found", "=", "false", "\n", "}", "\n", "return", "c", "\n", "}" ]
1,673
all-1674
[ "Body", "creates", "a", "view", "for", "prow", "job", "metadata", "." ]
[ "func", "(", "lens", "Lens", ")", "Body", "(", "artifacts", "[", "]", "lenses", ".", "Artifact", ",", "resourceDir", "string", ",", "data", "string", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "type", "MetadataViewData", "struct", "{", "Status", "string", "\n", "StartTime", "time", ".", "Time", "\n", "FinishedTime", "time", ".", "Time", "\n", "Elapsed", "time", ".", "Duration", "\n", "Metadata", "map", "[", "string", "]", "string", "\n", "}", "\n", "metadataViewData", ":=", "MetadataViewData", "{", "Status", ":", "\"", "\"", "}", "\n", "started", ":=", "gcs", ".", "Started", "{", "}", "\n", "finished", ":=", "gcs", ".", "Finished", "{", "}", "\n", "for", "_", ",", "a", ":=", "range", "artifacts", "{", "read", ",", "err", ":=", "a", ".", "ReadAll", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "a", ".", "JobPath", "(", ")", "==", "\"", "\"", "{", "if", "err", "=", "json", ".", "Unmarshal", "(", "read", ",", "&", "started", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "<mask>", "(", "\"", "\"", ")", "\n", "}", "\n", "metadataViewData", ".", "StartTime", "=", "time", ".", "Unix", "(", "started", ".", "Timestamp", ",", "0", ")", "\n", "}", "else", "if", "a", ".", "JobPath", "(", ")", "==", "\"", "\"", "{", "if", "err", "=", "json", ".", "Unmarshal", "(", "read", ",", "&", "finished", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "finished", ".", "Timestamp", "!=", "nil", "{", "metadataViewData", ".", "FinishedTime", "=", "time", ".", "Unix", "(", "*", "finished", ".", "Timestamp", ",", "0", ")", "\n", "}", "\n", "metadataViewData", ".", "Status", "=", "finished", ".", "Result", "\n", "}", "\n", "}", "\n\n", "if", "!", "metadataViewData", ".", "StartTime", ".", "IsZero", "(", ")", "{", "if", "metadataViewData", ".", "FinishedTime", ".", "IsZero", "(", ")", "{", "metadataViewData", ".", "Elapsed", "=", "time", ".", "Now", "(", ")", ".", "Sub", "(", "metadataViewData", ".", "StartTime", ")", "\n", "}", "else", "{", "metadataViewData", ".", "Elapsed", "=", "metadataViewData", ".", "FinishedTime", ".", "Sub", "(", "metadataViewData", ".", "StartTime", ")", "\n", "}", "\n", "metadataViewData", ".", "Elapsed", "=", "metadataViewData", ".", "Elapsed", ".", "Round", "(", "time", ".", "Second", ")", "\n", "}", "\n\n", "metadataViewData", ".", "Metadata", "=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "started", ".", "Node", "}", "\n\n", "metadatas", ":=", "[", "]", "metadata", ".", "Metadata", "{", "started", ".", "Metadata", ",", "finished", ".", "Metadata", "}", "\n", "for", "_", ",", "m", ":=", "range", "metadatas", "{", "for", "k", ",", "v", ":=", "range", "m", "{", "if", "s", ",", "ok", ":=", "v", ".", "(", "string", ")", ";", "ok", "&&", "v", "!=", "\"", "\"", "{", "metadataViewData", ".", "Metadata", "[", "k", "]", "=", "s", "\n", "}", "\n", "}", "\n", "}", "\n\n", "metadataTemplate", ",", "err", ":=", "template", ".", "ParseFiles", "(", "filepath", ".", "Join", "(", "resourceDir", ",", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "if", "err", ":=", "metadataTemplate", ".", "ExecuteTemplate", "(", "&", "buf", ",", "\"", "\"", ",", "metadataViewData", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "buf", ".", "String", "(", ")", "\n", "}" ]
1,674
all-1675
[ "expandVMwareUplinkPortOrderPolicy", "reads", "certain", "ResourceData", "keys", "and", "returns", "a", "VMwareUplinkPortOrderPolicy", "." ]
[ "func", "expandVMwareUplinkPortOrderPolicy", "(", "d", "*", "schema", ".", "ResourceData", ")", "*", "types", ".", "VMwareUplinkPortOrderPolicy", "{", "obj", ":=", "&", "types", ".", "VMwareUplinkPortOrderPolicy", "{", "ActiveUplinkPort", ":", "structure", ".", "SliceInterfacesToStrings", "(", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "[", "]", "<mask>", "{", "}", ")", ")", ",", "StandbyUplinkPort", ":", "structure", ".", "SliceInterfacesToStrings", "(", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "[", "]", "interface", "{", "}", ")", ")", ",", "}", "\n\n", "if", "structure", ".", "AllFieldsEmpty", "(", "obj", ")", "{", "return", "nil", "\n", "}", "\n", "return", "obj", "\n", "}" ]
1,675
all-1676
[ "Dereference", "pointer", "recursively", "or", "return", "zero", "value", ".", "drv", ":", "the", "final", "non", "-", "pointer", "value", "(", "which", "is", "never", "invalid", ")", ".", "isPtr", ":", "whether", "rv", ".", "Kind", "()", "==", "reflect", ".", "Ptr", ".", "isNilPtr", ":", "whether", "a", "nil", "pointer", "at", "any", "level", "." ]
[ "func", "derefPointersZero", "(", "rv", "reflect", ".", "<mask>", ")", "(", "drv", "reflect", ".", "Value", ",", "isPtr", "bool", ",", "isNilPtr", "bool", ")", "{", "for", "rv", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "isPtr", "=", "true", "\n", "if", "rv", ".", "IsNil", "(", ")", "{", "isNilPtr", "=", "true", "\n", "rt", ":=", "rv", ".", "Type", "(", ")", ".", "Elem", "(", ")", "\n", "for", "rt", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "rt", "=", "rt", ".", "Elem", "(", ")", "\n", "}", "\n", "drv", "=", "reflect", ".", "New", "(", "rt", ")", ".", "Elem", "(", ")", "\n", "return", "\n", "}", "\n", "rv", "=", "rv", ".", "Elem", "(", ")", "\n", "}", "\n", "drv", "=", "rv", "\n", "return", "\n", "}" ]
1,676
all-1677
[ "SaveJPEG", "is", "a", "wrapper", "around", "gdk_pixbuf_save", "()", ".", "Quality", "is", "a", "number", "between", "0", "...", "100" ]
[ "func", "(", "v", "*", "Pixbuf", ")", "SaveJPEG", "(", "path", "string", ",", "quality", "int", ")", "error", "{", "cpath", ":=", "C", ".", "CString", "(", "path", ")", "\n", "cquality", ":=", "C", ".", "CString", "(", "strconv", ".", "Itoa", "(", "<mask>", ")", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cpath", ")", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cquality", ")", ")", "\n\n", "var", "err", "*", "C", ".", "GError", "\n", "c", ":=", "C", ".", "_gdk_pixbuf_save_jpeg", "(", "v", ".", "native", "(", ")", ",", "cpath", ",", "&", "err", ",", "cquality", ")", "\n", "if", "!", "gobool", "(", "c", ")", "{", "defer", "C", ".", "g_error_free", "(", "err", ")", "\n", "return", "errors", ".", "New", "(", "C", ".", "GoString", "(", "(", "*", "C", ".", "char", ")", "(", "err", ".", "message", ")", ")", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
1,677
all-1678
[ "sync", "function", "syncs", "content", "of", "latest", "value", "log", "file", "to", "disk", ".", "Syncing", "of", "value", "log", "directory", "is", "not", "required", "here", "as", "it", "happens", "every", "time", "a", "value", "log", "file", "rotation", "happens", "(", "check", "createVlogFile", "function", ")", ".", "During", "rotation", "previous", "value", "log", "file", "also", "gets", "synced", "to", "disk", ".", "It", "only", "syncs", "file", "if", "fid", ">", "=", "vlog", ".", "maxFid", ".", "In", "some", "cases", "such", "as", "replay", "(", "while", "openning", "db", ")", "it", "might", "be", "called", "with", "fid", "<", "vlog", ".", "maxFid", ".", "To", "sync", "irrespective", "of", "file", "id", "just", "call", "it", "with", "math", ".", "MaxUint32", "." ]
[ "func", "(", "vlog", "*", "valueLog", ")", "sync", "(", "fid", "uint32", ")", "error", "{", "if", "vlog", ".", "<mask>", ".", "SyncWrites", "{", "return", "nil", "\n", "}", "\n\n", "vlog", ".", "filesLock", ".", "RLock", "(", ")", "\n", "maxFid", ":=", "atomic", ".", "LoadUint32", "(", "&", "vlog", ".", "maxFid", ")", "\n", "// During replay it is possible to get sync call with fid less than maxFid.", "// Because older file has already been synced, we can return from here.", "if", "fid", "<", "maxFid", "||", "len", "(", "vlog", ".", "filesMap", ")", "==", "0", "{", "vlog", ".", "filesLock", ".", "RUnlock", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "curlf", ":=", "vlog", ".", "filesMap", "[", "maxFid", "]", "\n", "// Sometimes it is possible that vlog.maxFid has been increased but file creation", "// with same id is still in progress and this function is called. In those cases", "// entry for the file might not be present in vlog.filesMap.", "if", "curlf", "==", "nil", "{", "vlog", ".", "filesLock", ".", "RUnlock", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "curlf", ".", "lock", ".", "RLock", "(", ")", "\n", "vlog", ".", "filesLock", ".", "RUnlock", "(", ")", "\n\n", "err", ":=", "curlf", ".", "sync", "(", ")", "\n", "curlf", ".", "lock", ".", "RUnlock", "(", ")", "\n", "return", "err", "\n", "}" ]
1,678
all-1679
[ "ToError", "converts", "error", "into", "Error", "pointer", "." ]
[ "func", "ToError", "(", "err", "error", ")", "*", "Error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "err", ",", "ok", ":=", "err", ".", "(", "rpc", ".", "Error", ")", ";", "<mask>", "{", "return", "&", "Error", "{", "Code", ":", "err", ".", "ErrorCode", "(", ")", ",", "Message", ":", "err", ".", "Error", "(", ")", "}", "\n", "}", "\n\n", "return", "&", "Error", "{", "Message", ":", "err", ".", "Error", "(", ")", "}", "\n", "}" ]
1,679
all-1680
[ "Unregister", "unregisters", "a", "Scheme", "and", "all", "associated", "aliases", "." ]
[ "func", "Unregister", "(", "<mask>", "string", ")", "*", "Scheme", "{", "scheme", ",", "ok", ":=", "schemeMap", "[", "name", "]", "\n", "if", "ok", "{", "for", "_", ",", "alias", ":=", "range", "scheme", ".", "Aliases", "{", "delete", "(", "schemeMap", ",", "alias", ")", "\n", "}", "\n", "delete", "(", "schemeMap", ",", "name", ")", "\n", "return", "scheme", "\n", "}", "\n", "return", "nil", "\n", "}" ]
1,680
all-1681
[ "BytesFilter", "filters", "out", "all", "bytes", "where", "the", "function", "does", "not", "return", "true", "." ]
[ "func", "BytesFilter", "(", "f", "func", "(", "byte", ")", "bool", ",", "data", "[", "]", "<mask>", ")", "[", "]", "byte", "{", "result", ":=", "make", "(", "[", "]", "byte", ",", "0", ",", "0", ")", "\n", "for", "_", ",", "element", ":=", "range", "data", "{", "if", "f", "(", "element", ")", "{", "result", "=", "append", "(", "result", ",", "element", ")", "\n", "}", "\n", "}", "\n", "return", "result", "\n", "}" ]
1,681
all-1682
[ "UUIDsForManagedObjectReferences", "returns", "a", "MOIDForUUIDResults", "for", "a", "list", "of", "ManagedObjectReferences", ".", "If", "one", "cannot", "be", "found", "an", "error", "is", "returned", ".", "There", "are", "no", "partial", "results", "returned", "." ]
[ "func", "UUIDsForManagedObjectReferences", "(", "client", "*", "govmomi", ".", "Client", ",", "refs", "[", "]", "types", ".", "ManagedObjectReference", ")", "(", "MOIDForUUIDResults", ",", "error", ")", "{", "var", "moids", "[", "]", "string", "\n", "for", "_", ",", "ref", ":=", "range", "refs", "{", "moids", "=", "append", "(", "moids", ",", "ref", ".", "Value", ")", "\n", "}", "\n", "return", "UUIDsForMOIDs", "(", "<mask>", ",", "moids", ")", "\n", "}" ]
1,682
all-1683
[ "DeepCopy", "copies", "the", "receiver", "into", "a", "new", "DateTime", "." ]
[ "func", "(", "t", "*", "DateTime", ")", "DeepCopy", "(", ")", "*", "DateTime", "{", "if", "t", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "<mask>", "(", "DateTime", ")", "\n", "t", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
1,683
all-1684
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "StopPreciseCoverageParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "<mask>", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoProfiler8", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
1,684
all-1685
[ "Kebab", "returns", "a", "kebab", "-", "cased", "string", "with", "all", "lowercase", "letters", "." ]
[ "func", "(", "k", "*", "Kace", ")", "Kebab", "(", "s", "string", ")", "string", "{", "return", "delimitedCase", "(", "s", ",", "kebabDelim", ",", "<mask>", ")", "\n", "}" ]
1,685
all-1686
[ "New", "creates", "a", "new", "Args", "object", "from", "the", "argument", "list" ]
[ "func", "New", "(", "arguments", "[", "]", "string", ")", "(", "*", "Args", ",", "error", ")", "{", "flagset", ":=", "<mask>", ".", "NewFlagSet", "(", "\"", "\"", ",", "flag", ".", "ContinueOnError", ")", "\n\n", "args", ":=", "&", "Args", "{", "Version", ":", "flagset", ".", "Bool", "(", "versionFlagName", ",", "false", ",", "versionUsage", ")", ",", "LogLevel", ":", "flagset", ".", "String", "(", "logLevelFlagName", ",", "\"", "\"", ",", "logLevelUsage", ")", ",", "AcceptInsecureCert", ":", "flagset", ".", "Bool", "(", "acceptInsecureCertFlagName", ",", "false", ",", "acceptInsecureCertUsage", ")", ",", "License", ":", "flagset", ".", "Bool", "(", "licenseFlagName", ",", "false", ",", "licenseUsage", ")", ",", "BlackholeEC2Metadata", ":", "flagset", ".", "Bool", "(", "blackholeEC2MetadataFlagName", ",", "false", ",", "blacholeEC2MetadataUsage", ")", ",", "ECSAttributes", ":", "flagset", ".", "Bool", "(", "ecsAttributesFlagName", ",", "false", ",", "ecsAttributesUsage", ")", ",", "WindowsService", ":", "flagset", ".", "Bool", "(", "windowsServiceFlagName", ",", "false", ",", "windowsServiceUsage", ")", ",", "}", "\n\n", "err", ":=", "flagset", ".", "Parse", "(", "arguments", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "args", ",", "nil", "\n", "}" ]
1,686
all-1687
[ "Rebalance", "the", "raft", "cluster", "trying", "to", "see", "if", "we", "have", "a", "spare", "online", "node", "that", "we", "can", "promote", "to", "database", "node", "if", "we", "are", "below", "membershipMaxRaftNodes", ".", "If", "there", "s", "such", "spare", "node", "return", "its", "address", "as", "well", "as", "the", "new", "list", "of", "raft", "nodes", "." ]
[ "func", "Rebalance", "(", "state", "*", "state", ".", "State", ",", "gateway", "*", "Gateway", ")", "(", "string", ",", "[", "]", "db", ".", "RaftNode", ",", "error", ")", "{", "// First get the current raft members, since this method should be", "// called after a node has left.", "currentRaftNodes", ",", "err", ":=", "gateway", ".", "currentRaftNodes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "currentRaftNodes", ")", ">=", "membershipMaxRaftNodes", "{", "// We're already at full capacity.", "return", "\"", "\"", ",", "nil", ",", "nil", "\n", "}", "\n\n", "currentRaftAddresses", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "currentRaftNodes", ")", ")", "\n", "for", "i", ",", "node", ":=", "range", "currentRaftNodes", "{", "currentRaftAddresses", "[", "i", "]", "=", "node", ".", "Address", "\n", "}", "\n\n", "// Check if we have a spare node that we can turn into a database one.", "address", ":=", "\"", "\"", "\n", "err", "=", "state", ".", "Cluster", ".", "Transaction", "(", "func", "(", "tx", "*", "db", ".", "ClusterTx", ")", "error", "{", "config", ",", "err", ":=", "ConfigLoad", "(", "tx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "nodes", ",", "err", ":=", "tx", ".", "Nodes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "// Find a node that is not part of the raft cluster yet.", "for", "_", ",", "node", ":=", "range", "nodes", "{", "if", "shared", ".", "StringInSlice", "(", "node", ".", "Address", ",", "currentRaftAddresses", ")", "{", "continue", "// This is already a database node", "\n", "}", "\n", "if", "node", ".", "IsOffline", "(", "config", ".", "OfflineThreshold", "(", ")", ")", "{", "continue", "// This node is offline", "\n", "}", "\n", "logger", ".", "Debugf", "(", "\"", "\"", ",", "node", ".", "<mask>", ",", "node", ".", "Address", ")", "\n", "address", "=", "node", ".", "Address", "\n", "break", "\n", "}", "\n\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "nil", ",", "err", "\n", "}", "\n\n", "if", "address", "==", "\"", "\"", "{", "// No node to promote", "return", "\"", "\"", ",", "nil", ",", "nil", "\n", "}", "\n\n", "// Update the local raft_table adding the new member and building a new", "// list.", "updatedRaftNodes", ":=", "currentRaftNodes", "\n", "err", "=", "gateway", ".", "db", ".", "Transaction", "(", "func", "(", "tx", "*", "db", ".", "NodeTx", ")", "error", "{", "id", ",", "err", ":=", "tx", ".", "RaftNodeAdd", "(", "address", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "updatedRaftNodes", "=", "append", "(", "updatedRaftNodes", ",", "db", ".", "RaftNode", "{", "ID", ":", "id", ",", "Address", ":", "address", "}", ")", "\n", "err", "=", "tx", ".", "RaftNodesReplace", "(", "updatedRaftNodes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "nil", ",", "err", "\n", "}", "\n", "return", "address", ",", "updatedRaftNodes", ",", "nil", "\n", "}" ]
1,687
all-1688
[ "EqualsElement", "returns", "whether", "or", "not", "two", "selections", "of", "exactly", "one", "element", "refer", "to", "the", "same", "element", "." ]
[ "func", "(", "s", "*", "Selection", ")", "EqualsElement", "(", "other", "interface", "{", "}", ")", "(", "bool", ",", "error", ")", "{", "otherSelection", ",", "ok", ":=", "other", ".", "(", "*", "Selection", ")", "\n", "if", "!", "ok", "{", "multiSelection", ",", "ok", ":=", "other", ".", "(", "*", "MultiSelection", ")", "\n", "if", "!", "ok", "{", "return", "<mask>", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "otherSelection", "=", "&", "multiSelection", ".", "Selection", "\n", "}", "\n\n", "selectedElement", ",", "err", ":=", "s", ".", "elements", ".", "GetExactlyOne", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ",", "err", ")", "\n", "}", "\n\n", "otherElement", ",", "err", ":=", "otherSelection", ".", "elements", ".", "GetExactlyOne", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "other", ",", "err", ")", "\n", "}", "\n\n", "equal", ",", "err", ":=", "selectedElement", ".", "IsEqualTo", "(", "otherElement", ".", "(", "*", "api", ".", "Element", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ",", "other", ",", "err", ")", "\n", "}", "\n\n", "return", "equal", ",", "nil", "\n", "}" ]
1,688
all-1689
[ "CreateAuthorizeUrl", "create", "the", "Authorize", "Url", "used", "to", "redirect", "users", "for", "coinbase", "app", "authorization", ".", "The", "scope", "parameter", "includes", "the", "specific", "permissions", "one", "wants", "to", "ask", "from", "the", "user" ]
[ "func", "(", "o", "OAuth", ")", "CreateAuthorizeUrl", "(", "scope", "[", "]", "string", ")", "string", "{", "Url", ",", "_", ":=", "url", ".", "Parse", "(", "\"", "\"", ")", "\n", "Url", ".", "Path", "+=", "\"", "\"", "\n\n", "parameters", ":=", "url", ".", "Values", "{", "}", "\n", "parameters", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "parameters", ".", "Add", "(", "\"", "\"", ",", "o", ".", "ClientId", ")", "\n", "parameters", ".", "Add", "(", "\"", "\"", ",", "o", ".", "RedirectUri", ")", "\n", "parameters", ".", "Add", "(", "\"", "\"", ",", "strings", ".", "Join", "(", "<mask>", ",", "\"", "\"", ")", ")", "\n", "Url", ".", "RawQuery", "=", "parameters", ".", "Encode", "(", ")", "\n\n", "return", "Url", ".", "String", "(", ")", "\n", "}" ]
1,689
all-1690
[ "WriteTimeout", "sets", "the", "connection", "timeout", "for", "write", "operations", ".", "A", "value", "of", "0", "disables", "the", "timeout", "." ]
[ "func", "(", "q", "*", "<mask>", ")", "WriteTimeout", "(", "timeout", "time", ".", "Duration", ")", "*", "Query", "{", "q", ".", "writeTimeout", "=", "timeout", "\n", "return", "q", "\n", "}" ]
1,690
all-1691
[ "CommonLogHandler", "returns", "a", "handler", "that", "serves", "HTTP", "requests", "If", "a", "logger", "is", "not", "provided", "stdout", "will", "be", "used" ]
[ "func", "CommonLogHandler", "(", "logger", "*", "log", ".", "Logger", ",", "templ", "string", ",", "h", "http", ".", "Handler", ")", "http", ".", "<mask>", "{", "if", "logger", "==", "nil", "{", "logger", "=", "log", ".", "New", "(", "os", ".", "Stdout", ",", "\"", "\"", ",", "0", ")", "\n", "}", "\n", "if", "templ", "==", "\"", "\"", "{", "templ", "=", "CommonLogFormat", "\n", "}", "\n\n", "return", "&", "commonLogHandler", "{", "handler", ":", "h", ",", "logger", ":", "logger", ",", "template", ":", "template", ".", "Must", "(", "template", ".", "New", "(", "\"", "\"", ")", ".", "Parse", "(", "templ", ")", ")", ",", "}", "\n", "}" ]
1,691
all-1692
[ "stringUnsafe", "returns", "a", "human", "readable", "string", "representation", "of", "this", "object" ]
[ "func", "(", "task", "*", "Task", ")", "stringUnsafe", "(", ")", "string", "{", "res", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "task", ".", "Family", ",", "task", ".", "<mask>", ",", "task", ".", "Arn", ",", "task", ".", "KnownStatusUnsafe", ".", "String", "(", ")", ",", "task", ".", "DesiredStatusUnsafe", ".", "String", "(", ")", ")", "\n", "res", "+=", "\"", "\"", "\n", "for", "_", ",", "container", ":=", "range", "task", ".", "Containers", "{", "res", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "container", ".", "Name", ",", "container", ".", "GetKnownStatus", "(", ")", ".", "String", "(", ")", ",", "container", ".", "GetDesiredStatus", "(", ")", ".", "String", "(", ")", ")", "\n", "}", "\n\n", "if", "task", ".", "ENI", "!=", "nil", "{", "res", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "task", ".", "ENI", ".", "String", "(", ")", ")", "\n", "}", "\n", "return", "res", "+", "\"", "\"", "\n", "}" ]
1,692
all-1693
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "StopRuleUsageTrackingReturns", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss6", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
1,693
all-1694
[ "NewDataWriter", "returns", "a", "new", "callback", "based", "data", "buffer" ]
[ "func", "NewDataWriter", "(", "w", "io", ".", "<mask>", ")", "(", "*", "Data", ",", "error", ")", "{", "d", ":=", "newData", "(", ")", "\n", "d", ".", "w", "=", "w", "\n", "d", ".", "cbs", ".", "write", "=", "C", ".", "gpgme_data_write_cb_t", "(", "C", ".", "gogpgme_writefunc", ")", "\n", "cbc", ":=", "callbackAdd", "(", "d", ")", "\n", "d", ".", "cbc", "=", "cbc", "\n", "return", "d", ",", "handleError", "(", "C", ".", "gogpgme_data_new_from_cbs", "(", "&", "d", ".", "dh", ",", "&", "d", ".", "cbs", ",", "C", ".", "uintptr_t", "(", "cbc", ")", ")", ")", "\n", "}" ]
1,694
all-1695
[ "FlattenExpr", "takes", "an", "expression", "that", "may", "have", "been", "generated", "from", "PlatformStrings", "and", "returns", "its", "values", "in", "a", "flat", "sorted", "de", "-", "duplicated", "list", ".", "Comments", "are", "accumulated", "and", "de", "-", "duplicated", "across", "duplicate", "expressions", ".", "If", "the", "expression", "could", "not", "have", "been", "generted", "by", "PlatformStrings", "the", "expression", "will", "be", "returned", "unmodified", "." ]
[ "func", "FlattenExpr", "(", "e", "bzl", ".", "Expr", ")", "bzl", ".", "Expr", "{", "ps", ",", "err", ":=", "extractPlatformStringsExprs", "(", "e", ")", "\n", "if", "err", "!=", "nil", "{", "return", "e", "\n", "}", "\n\n", "ls", ":=", "makeListSquasher", "(", ")", "\n", "addElem", ":=", "func", "(", "e", "bzl", ".", "Expr", ")", "bool", "{", "s", ",", "ok", ":=", "e", ".", "(", "*", "bzl", ".", "StringExpr", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "ls", ".", "<mask>", "(", "s", ")", "\n", "return", "true", "\n", "}", "\n", "addList", ":=", "func", "(", "e", "bzl", ".", "Expr", ")", "bool", "{", "l", ",", "ok", ":=", "e", ".", "(", "*", "bzl", ".", "ListExpr", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "for", "_", ",", "elem", ":=", "range", "l", ".", "List", "{", "if", "!", "addElem", "(", "elem", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}", "\n", "addDict", ":=", "func", "(", "d", "*", "bzl", ".", "DictExpr", ")", "bool", "{", "for", "_", ",", "kv", ":=", "range", "d", ".", "List", "{", "if", "!", "addList", "(", "kv", ".", "(", "*", "bzl", ".", "KeyValueExpr", ")", ".", "Value", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}", "\n\n", "if", "ps", ".", "generic", "!=", "nil", "{", "if", "!", "addList", "(", "ps", ".", "generic", ")", "{", "return", "e", "\n", "}", "\n", "}", "\n", "for", "_", ",", "d", ":=", "range", "[", "]", "*", "bzl", ".", "DictExpr", "{", "ps", ".", "os", ",", "ps", ".", "arch", ",", "ps", ".", "platform", "}", "{", "if", "d", "==", "nil", "{", "continue", "\n", "}", "\n", "if", "!", "addDict", "(", "d", ")", "{", "return", "e", "\n", "}", "\n", "}", "\n\n", "return", "ls", ".", "list", "(", ")", "\n", "}" ]
1,695
all-1696
[ "Locator", "returns", "a", "locator", "for", "the", "given", "resource" ]
[ "func", "(", "r", "*", "<mask>", ")", "Locator", "(", "api", "*", "API", ")", "*", "SessionLocator", "{", "for", "_", ",", "l", ":=", "range", "r", ".", "Links", "{", "if", "l", "[", "\"", "\"", "]", "==", "\"", "\"", "{", "return", "api", ".", "SessionLocator", "(", "l", "[", "\"", "\"", "]", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
1,696
all-1697
[ "SetCurrentFolder", "is", "a", "wrapper", "around", "gtk_file_chooser_set_current_folder", "()", "." ]
[ "func", "(", "v", "*", "FileChooser", ")", "SetCurrentFolder", "(", "folder", "string", ")", "bool", "{", "cstr", ":=", "C", ".", "CString", "(", "folder", ")", "\n", "defer", "C", ".", "<mask>", "(", "unsafe", ".", "Pointer", "(", "cstr", ")", ")", "\n", "c", ":=", "C", ".", "gtk_file_chooser_set_current_folder", "(", "v", ".", "native", "(", ")", ",", "(", "*", "C", ".", "gchar", ")", "(", "cstr", ")", ")", "\n", "return", "gobool", "(", "c", ")", "\n", "}" ]
1,697
all-1698
[ "FileExists", "takes", "a", "path", "in", "the", "datastore", "and", "checks", "to", "see", "if", "it", "exists", ".", "The", "path", "should", "be", "a", "bare", "path", "not", "a", "datastore", "path", ".", "Globs", "are", "not", "allowed", "." ]
[ "func", "FileExists", "(", "ds", "*", "object", ".", "Datastore", ",", "name", "string", ")", "(", "bool", ",", "error", ")", "{", "files", ",", "err", ":=", "SearchDatastore", "(", "ds", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "if", "len", "(", "files", ")", ">", "1", "{", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "ds", ")", "\n", "}", "\n", "if", "len", "(", "files", ")", "<", "1", "{", "return", "false", ",", "nil", "\n", "}", "\n", "return", "path", ".", "<mask>", "(", "name", ")", "==", "files", "[", "0", "]", ".", "Path", ",", "nil", "\n", "}" ]
1,698
all-1699
[ "NewPathSlashesStripper", "returns", "path", "rewriter", "which", "strips", "slashesCount", "leading", "slashes", "from", "the", "path", ".", "Examples", ":", "*", "slashesCount", "=", "0", "original", "path", ":", "/", "foo", "/", "bar", "result", ":", "/", "foo", "/", "bar", "*", "slashesCount", "=", "1", "original", "path", ":", "/", "foo", "/", "bar", "result", ":", "/", "bar", "*", "slashesCount", "=", "2", "original", "path", ":", "/", "foo", "/", "bar", "result", ":", "The", "returned", "path", "rewriter", "may", "be", "used", "as", "FS", ".", "PathRewrite", "." ]
[ "func", "NewPathSlashesStripper", "(", "slashesCount", "int", ")", "PathRewriteFunc", "{", "return", "func", "(", "ctx", "*", "RequestCtx", ")", "[", "]", "byte", "{", "return", "stripLeadingSlashes", "(", "ctx", ".", "<mask>", "(", ")", ",", "slashesCount", ")", "\n", "}", "\n", "}" ]
1,699
all-1700
[ "Timing", "sends", "a", "timing", "value", "to", "a", "bucket", "." ]
[ "func", "(", "c", "*", "<mask>", ")", "Timing", "(", "bucket", "string", ",", "value", "interface", "{", "}", ")", "{", "if", "c", ".", "skip", "(", ")", "{", "return", "\n", "}", "\n", "c", ".", "conn", ".", "metric", "(", "c", ".", "prefix", ",", "bucket", ",", "value", ",", "\"", "\"", ",", "c", ".", "rate", ",", "c", ".", "tags", ")", "\n", "}" ]