id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
700
all-701
[ "Sender", "yields", "the", "GossipSender", "for", "the", "named", "channel", ".", "It", "will", "use", "the", "factory", "function", "if", "no", "sender", "yet", "exists", "." ]
[ "func", "(", "gs", "*", "gossipSenders", ")", "Sender", "(", "channelName", "string", ",", "makeGossipSender", "func", "(", "sender", "protocolSender", ",", "stop", "<-", "chan", "struct", "{", "}", ")", "*", "gossipSender", ")", "*", "gossipSender", "{", "gs", ".", "Lock", "(", ")", "\n", "defer", "gs", ".", "Unlock", "(", ")", "\n", "s", ",", "found", ":=", "gs", ".", "senders", "[", "channelName", "]", "\n", "if", "!", "<mask>", "{", "s", "=", "makeGossipSender", "(", "gs", ".", "sender", ",", "gs", ".", "stop", ")", "\n", "gs", ".", "senders", "[", "channelName", "]", "=", "s", "\n", "}", "\n", "return", "s", "\n", "}" ]
701
all-702
[ "snapshot", "returns", "a", "copy", "of", "the", "values", "of", "all", "registered", "counters", "and", "gauges", "." ]
[ "func", "(", "m", "*", "CirconusMetrics", ")", "snapshot", "(", ")", "(", "c", "map", "[", "string", "]", "uint64", ",", "g", "map", "[", "string", "]", "interface", "{", "}", ",", "h", "map", "[", "string", "]", "*", "circonusllhist", ".", "Histogram", ",", "t", "<mask>", "[", "string", "]", "string", ")", "{", "c", "=", "m", ".", "snapCounters", "(", ")", "\n", "g", "=", "m", ".", "snapGauges", "(", ")", "\n", "h", "=", "m", ".", "snapHistograms", "(", ")", "\n", "t", "=", "m", ".", "snapText", "(", ")", "\n\n", "return", "\n", "}" ]
702
all-703
[ "Camel", "returns", "a", "camelCased", "string", "." ]
[ "func", "(", "k", "*", "Kace", ")", "Camel", "(", "s", "string", ")", "string", "{", "return", "camelCase", "(", "k", ".", "t", ",", "s", ",", "<mask>", ")", "\n", "}" ]
703
all-704
[ "getClientWithoutTimeout", "returns", "a", "modified", "client", "that", "doesn", "t", "have", "the", "ResponseHeaderTimeout", "field", "set", "in", "its", "Transport", "." ]
[ "func", "(", "d", "*", "dumpClient", ")", "getClientWithoutTimeout", "(", ")", "*", "http", ".", "Client", "{", "// Get a copy of the client and modify as multiple concurrent go routines can be using this client.", "client", ":=", "*", "d", ".", "Client", "\n", "tr", ",", "ok", ":=", "client", ".", "Transport", ".", "(", "*", "http", ".", "Transport", ")", "\n", "if", "ok", "{", "// note that the http.Transport struct has internal mutex fields that are", "// not safe to copy. we have to be selective in copying fields.", "trCopy", ":=", "&", "http", ".", "Transport", "{", "Proxy", ":", "tr", ".", "Proxy", ",", "DialContext", ":", "tr", ".", "DialContext", ",", "Dial", ":", "tr", ".", "Dial", ",", "DialTLS", ":", "tr", ".", "DialTLS", ",", "TLSClientConfig", ":", "tr", ".", "TLSClientConfig", ",", "TLSHandshakeTimeout", ":", "tr", ".", "TLSHandshakeTimeout", ",", "DisableKeepAlives", ":", "tr", ".", "DisableKeepAlives", ",", "DisableCompression", ":", "tr", ".", "DisableCompression", ",", "MaxIdleConns", ":", "tr", ".", "MaxIdleConns", ",", "MaxIdleConnsPerHost", ":", "tr", ".", "MaxIdleConnsPerHost", ",", "IdleConnTimeout", ":", "tr", ".", "IdleConnTimeout", ",", "ResponseHeaderTimeout", ":", "0", ",", "// explicitly zeroed-out", "ExpectContinueTimeout", ":", "tr", ".", "ExpectContinueTimeout", ",", "TLSNextProto", ":", "tr", ".", "TLSNextProto", ",", "MaxResponseHeaderBytes", ":", "tr", ".", "MaxResponseHeaderBytes", ",", "}", "\n", "tr", "=", "trCopy", "\n", "}", "else", "{", "// note that the following code has a known issue in that it depends on the", "// current value of the NoCertCheck global. if that global changes after", "// creation of this client then the behavior is undefined.", "tr", "=", "&", "http", ".", "Transport", "{", "Proxy", ":", "http", ".", "ProxyFromEnvironment", "}", "\n", "tr", ".", "TLSClientConfig", "=", "&", "tls", ".", "Config", "{", "InsecureSkipVerify", ":", "NoCertCheck", "}", "\n", "}", "\n", "client", ".", "Transport", "=", "tr", "\n", "return", "&", "<mask>", "\n", "}" ]
704
all-705
[ "WithObjectGroup", "symbolic", "group", "name", "that", "can", "be", "used", "to", "release", "the", "results", "." ]
[ "func", "(", "p", "QueryObjectsParams", ")", "WithObjectGroup", "(", "objectGroup", "<mask>", ")", "*", "QueryObjectsParams", "{", "p", ".", "ObjectGroup", "=", "objectGroup", "\n", "return", "&", "p", "\n", "}" ]
705
all-706
[ "WithHTTPClient", "adds", "the", "HTTPClient", "to", "the", "get", "tasks", "params" ]
[ "func", "(", "o", "*", "GetTasksParams", ")", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "*", "GetTasksParams", "{", "o", ".", "SetHTTPClient", "(", "<mask>", ")", "\n", "return", "o", "\n", "}" ]
706
all-707
[ "String", "returns", "a", "string", "representation", "of", "r", "." ]
[ "func", "(", "r", "Rectangle", ")", "<mask>", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ".", "Min", ",", "r", ".", "Max", ")", "\n", "}" ]
707
all-708
[ "UnmarshalJSON", "implements", "the", "json", ".", "Unmarshaler", "interface", "." ]
[ "func", "(", "kt", "*", "sbKeyType", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "*", "kt", "=", "sbKeyType", "(", "\"", "\"", ")", "\n", "<mask>", "s", "string", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "s", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "!", "sbKeyType", "(", "s", ")", ".", "IsValid", "(", ")", "{", "return", "InvalidPolicyFormatError", "(", "fmt", ".", "Sprintf", "(", "\"", "\\\"", "\\\"", "\"", ",", "s", ")", ")", "\n", "}", "\n", "*", "kt", "=", "sbKeyType", "(", "s", ")", "\n", "return", "nil", "\n", "}" ]
708
all-709
[ "WithIncludeCommandLineAPI", "specifies", "whether", "command", "line", "API", "should", "be", "available", "to", "the", "evaluated", "expression", "defaults", "to", "false", "." ]
[ "func", "(", "p", "EvaluateOnCallFrameParams", ")", "WithIncludeCommandLineAPI", "(", "includeCommandLineAPI", "bool", ")", "*", "EvaluateOnCallFrameParams", "{", "p", ".", "IncludeCommandLineAPI", "=", "includeCommandLineAPI", "\n", "<mask>", "&", "p", "\n", "}" ]
709
all-710
[ "Tournament", "related", "functions", "and", "methods", "Helpers" ]
[ "func", "validateTournamentInfo", "(", "info", "Info", ")", "error", "{", "if", "info", ".", "Scheduled", ".", "IsZero", "(", ")", "{", "return", "<mask>", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "info", ".", "Stake", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "info", ".", "Season", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
710
all-711
[ "AddHandler", "adds", "event", "handler", "to", "Pinger", ".", "event", "arg", "should", "be", "receive", "or", "idle", "string", ".", "**", "CAUTION", "**", "This", "function", "is", "deprecated", ".", "Please", "use", "OnRecv", "and", "OnIdle", "field", "of", "Pinger", "struct", "to", "set", "following", "handlers", ".", "receive", "handler", "should", "be", "func", "(", "addr", "*", "net", ".", "IPAddr", "rtt", "time", ".", "Duration", ")", "type", "function", ".", "The", "handler", "is", "called", "with", "a", "response", "packet", "s", "source", "address", "and", "its", "elapsed", "time", "when", "Pinger", "receives", "a", "response", "packet", ".", "idle", "handler", "should", "be", "func", "()", "type", "function", ".", "The", "handler", "is", "called", "when", "MaxRTT", "time", "passed", ".", "For", "more", "detail", "please", "see", "Run", "()", "and", "RunLoop", "()", "." ]
[ "func", "(", "p", "*", "Pinger", ")", "AddHandler", "(", "event", "string", ",", "handler", "interface", "{", "}", ")", "error", "{", "switch", "event", "{", "case", "\"", "\"", ":", "if", "hdl", ",", "<mask>", ":=", "handler", ".", "(", "func", "(", "*", "net", ".", "IPAddr", ",", "time", ".", "Duration", ")", ")", ";", "ok", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "p", ".", "OnRecv", "=", "hdl", "\n", "p", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "case", "\"", "\"", ":", "if", "hdl", ",", "ok", ":=", "handler", ".", "(", "func", "(", ")", ")", ";", "ok", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "p", ".", "OnIdle", "=", "hdl", "\n", "p", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "errors", ".", "New", "(", "\"", "\"", "+", "event", ")", "\n", "}" ]
711
all-712
[ "NextControl", "returns", "the", "next", "or", "previous", "child", "(", "depends", "on", "next", "parameter", ")", "that", "has", "tab", "-", "stop", "feature", "on", ".", "Used", "by", "library", "when", "processing", "TAB", "key" ]
[ "func", "NextControl", "(", "parent", "Control", ",", "curr", "Control", ",", "<mask>", "bool", ")", "Control", "{", "fnTab", ":=", "func", "(", "c", "Control", ")", "bool", "{", "isVisible", ":=", "func", "(", ")", "bool", "{", "ctrl", ":=", "c", ".", "Parent", "(", ")", "\n\n", "for", "ctrl", "!=", "nil", "{", "if", "!", "ctrl", ".", "Visible", "(", ")", "{", "return", "false", "\n", "}", "\n\n", "ctrl", "=", "ctrl", ".", "Parent", "(", ")", "\n", "}", "\n\n", "return", "c", ".", "Visible", "(", ")", "\n", "}", "\n\n", "return", "c", ".", "TabStop", "(", ")", "&&", "isVisible", "(", ")", "&&", "c", ".", "Enabled", "(", ")", "\n", "}", "\n\n", "linear", ":=", "getLinearControlList", "(", "parent", ",", "fnTab", ")", "\n\n", "if", "len", "(", "linear", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "var", "pIndex", ",", "nIndex", "int", "\n\n", "for", "i", ",", "ch", ":=", "range", "linear", "{", "if", "ch", "!=", "curr", "{", "continue", "\n", "}", "\n\n", "pIndex", "=", "i", "-", "1", "\n", "nIndex", "=", "i", "+", "1", "\n", "break", "\n", "}", "\n\n", "if", "nIndex", ">", "len", "(", "linear", ")", "-", "1", "{", "nIndex", "=", "0", "\n", "}", "\n\n", "if", "pIndex", "<", "0", "{", "pIndex", "=", "len", "(", "linear", ")", "-", "1", "\n", "}", "\n\n", "if", "next", "{", "return", "linear", "[", "nIndex", "]", "\n", "}", "else", "{", "return", "linear", "[", "pIndex", "]", "\n", "}", "\n", "}" ]
712
all-713
[ "hasPRChanged", "indicates", "that", "the", "code", "diff", "may", "have", "changed", "." ]
[ "func", "hasPRChanged", "(", "pr", "github", ".", "PullRequestEvent", ")", "bool", "{", "switch", "pr", ".", "Action", "{", "case", "github", ".", "PullRequestActionOpened", ":", "return", "true", "\n", "case", "github", ".", "PullRequestActionReopened", ":", "return", "true", "\n", "<mask>", "github", ".", "PullRequestActionSynchronize", ":", "return", "true", "\n", "default", ":", "return", "false", "\n", "}", "\n", "}" ]
713
all-714
[ "handleWindowsRequests", "is", "a", "loop", "intended", "to", "run", "in", "a", "goroutine", ".", "It", "handles", "bidirectional", "communication", "with", "the", "Windows", "service", "manager", ".", "This", "function", "works", "by", "pretty", "much", "immediately", "moving", "to", "running", "and", "then", "waiting", "for", "a", "stop", "or", "shut", "down", "message", "from", "Windows", "or", "to", "be", "canceled", "(", "which", "could", "happen", "if", "the", "agent", "exits", "by", "itself", "and", "the", "calling", "function", "cancels", "the", "context", ")", "." ]
[ "func", "(", "h", "*", "handler", ")", "handleWindowsRequests", "(", "ctx", "context", ".", "Context", ",", "requests", "<-", "chan", "svc", ".", "ChangeRequest", ",", "responses", "chan", "<-", "svc", ".", "Status", ")", "{", "// Immediately tell Windows that we are pending service start.", "responses", "<-", "svc", ".", "Status", "{", "State", ":", "svc", ".", "StartPending", "}", "\n", "seelog", ".", "Info", "(", "\"", "\"", ")", "\n\n", "// TODO: Pre-start hooks go here (unclear if we need any yet)", "// https://msdn.microsoft.com/en-us/library/windows/desktop/ms682108(v=vs.85).aspx", "// Not sure if a better link exists to describe what these values mean", "accepts", ":=", "svc", ".", "AcceptStop", "|", "svc", ".", "AcceptShutdown", "\n\n", "// Announce that we are running and we accept the above-mentioned commands", "responses", "<-", "svc", ".", "Status", "{", "State", ":", "svc", ".", "Running", ",", "Accepts", ":", "accepts", "}", "\n\n", "defer", "func", "(", ")", "{", "// Announce that we are stopping", "seelog", ".", "Info", "(", "\"", "\"", ")", "\n", "responses", "<-", "svc", ".", "Status", "{", "State", ":", "svc", ".", "StopPending", "}", "\n", "}", "(", ")", "\n\n", "for", "{", "select", "{", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "return", "\n", "case", "r", ":=", "<-", "requests", ":", "switch", "r", ".", "Cmd", "{", "<mask>", "svc", ".", "Interrogate", ":", "// Our status doesn't change unless we are told to stop or shutdown", "responses", "<-", "r", ".", "CurrentStatus", "\n", "case", "svc", ".", "Stop", ",", "svc", ".", "Shutdown", ":", "return", "\n", "default", ":", "continue", "\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
714
all-715
[ "Do", "executes", "Network", ".", "enable", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "EnableParams", ")", "Do", "(", "ctx", "<mask>", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandEnable", ",", "p", ",", "nil", ")", "\n", "}" ]
715
all-716
[ "/", "*", "Close", "signifies", "that", "the", "buffer", "will", "no", "longer", "be", "written", "to" ]
[ "func", "(", "b", "*", "Buffer", ")", "Close", "(", ")", "error", "{", "b", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "b", ".", "closed", "=", "<mask>", "\n\n", "return", "nil", "\n", "}" ]
716
all-717
[ "Walk", "executes", "a", "callback", "against", "every", "node", "in", "the", "subtree", "of", "path", "." ]
[ "func", "(", "h", "*", "dbHashTree", ")", "Walk", "(", "path", "string", ",", "f", "func", "(", "path", "string", ",", "node", "*", "NodeProto", ")", "error", ")", "error", "{", "path", "=", "clean", "(", "path", ")", "\n", "return", "h", ".", "View", "(", "func", "(", "tx", "*", "bolt", ".", "Tx", ")", "error", "{", "c", ":=", "fs", "(", "tx", ")", ".", "Cursor", "(", ")", "\n", "for", "k", ",", "v", ":=", "c", ".", "Seek", "(", "b", "(", "path", ")", ")", ";", "k", "!=", "nil", "&&", "strings", ".", "HasPrefix", "(", "s", "(", "k", ")", ",", "path", ")", ";", "k", ",", "v", "=", "c", ".", "Next", "(", ")", "{", "node", ":=", "&", "NodeProto", "{", "}", "\n", "if", "err", ":=", "node", ".", "Unmarshal", "(", "v", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "nodePath", ":=", "s", "(", "k", ")", "\n", "if", "nodePath", "==", "\"", "\"", "{", "nodePath", "=", "\"", "\"", "\n", "}", "\n", "if", "nodePath", "!=", "<mask>", "&&", "!", "strings", ".", "HasPrefix", "(", "nodePath", ",", "path", "+", "\"", "\"", ")", "{", "// node is a sibling of path, and thus doesn't get walked", "continue", "\n", "}", "\n", "if", "err", ":=", "f", "(", "nodePath", ",", "node", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "errutil", ".", "ErrBreak", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "}" ]
717
all-718
[ "dialWithBalancer", "dials", "the", "client", "s", "current", "load", "balanced", "resolver", "group", ".", "The", "scheme", "of", "the", "host", "of", "the", "provided", "endpoint", "determines", "the", "scheme", "used", "for", "all", "endpoints", "of", "the", "client", "connection", "." ]
[ "func", "(", "c", "*", "Client", ")", "dialWithBalancer", "(", "ep", "string", ",", "dopts", "...", "grpc", ".", "DialOption", ")", "(", "*", "grpc", ".", "ClientConn", ",", "error", ")", "{", "_", ",", "host", ",", "_", ":=", "endpoint", ".", "ParseEndpoint", "(", "ep", ")", "\n", "target", ":=", "c", ".", "resolverGroup", ".", "Target", "(", "<mask>", ")", "\n", "creds", ":=", "c", ".", "dialWithBalancerCreds", "(", "ep", ")", "\n", "return", "c", ".", "dial", "(", "target", ",", "creds", ",", "dopts", "...", ")", "\n", "}" ]
718
all-719
[ "Copy", "returns", "a", "copy", "of", "the", "PeerList", "as", "a", "map", "from", "hostPort", "to", "peer", "." ]
[ "func", "(", "l", "*", "PeerList", ")", "Copy", "(", ")", "map", "[", "string", "]", "*", "Peer", "{", "l", ".", "RLock", "(", ")", "\n", "defer", "l", ".", "RUnlock", "(", ")", "\n\n", "listCopy", ":=", "<mask>", "(", "map", "[", "string", "]", "*", "Peer", ")", "\n", "for", "k", ",", "v", ":=", "range", "l", ".", "peersByHostPort", "{", "listCopy", "[", "k", "]", "=", "v", ".", "Peer", "\n", "}", "\n", "return", "listCopy", "\n", "}" ]
719
all-720
[ "TempFile", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockIOUtil", ")", "TempFile", "(", "arg0", ",", "arg1", "string", ")", "(", "oswrapper", ".", "<mask>", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "oswrapper", ".", "File", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
720
all-721
[ "ReadBytes", "returns", "the", "next", "n", "bytes", "from", "the", "buffer" ]
[ "func", "(", "r", "*", "ReadBuffer", ")", "ReadBytes", "(", "n", "int", ")", "[", "]", "<mask>", "{", "if", "r", ".", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "r", ".", "remaining", ")", "<", "n", "{", "r", ".", "err", "=", "ErrEOF", "\n", "return", "nil", "\n", "}", "\n\n", "b", ":=", "r", ".", "remaining", "[", "0", ":", "n", "]", "\n", "r", ".", "remaining", "=", "r", ".", "remaining", "[", "n", ":", "]", "\n", "return", "b", "\n", "}" ]
721
all-722
[ "With", "enables", "the", "provided", "feature", "(", "ex", ".", "trustAllSSLCertificates", ")", "." ]
[ "func", "(", "c", "Capabilities", ")", "With", "(", "feature", "string", ")", "Capabilities", "{", "c", "[", "feature", "]", "=", "<mask>", "\n", "return", "c", "\n", "}" ]
722
all-723
[ "CacheRemote", "receives", "a", "handler", "its", "cache", "expiration", "and", "the", "remote", "address", "of", "the", "remote", "cache", "server", "(", "look", "ListenAndServe", ")", "returns", "a", "remote", "-", "cached", "handler", "You", "can", "add", "validators", "with", "this", "function" ]
[ "func", "CacheRemote", "(", "bodyHandler", "<mask>", ".", "Handler", ",", "expiration", "time", ".", "Duration", ",", "remoteServerAddr", "string", ")", "*", "nethttp", ".", "ClientHandler", "{", "return", "nethttp", ".", "NewClientHandler", "(", "bodyHandler", ",", "expiration", ",", "remoteServerAddr", ")", "\n", "}" ]
723
all-724
[ "Format", "implements", "fmt", ".", "Formatter", "by", "printing", "the", "Trace", "as", "square", "brackes", "(", "[", "]", ")", "surrounding", "a", "space", "separated", "list", "of", "Calls", "each", "formatted", "with", "the", "supplied", "verb", "and", "options", "." ]
[ "func", "(", "pcs", "Trace", ")", "Format", "(", "s", "fmt", ".", "State", ",", "c", "rune", ")", "{", "s", ".", "Write", "(", "[", "]", "byte", "(", "\"", "\"", ")", ")", "\n", "for", "i", ",", "pc", ":=", "<mask>", "pcs", "{", "if", "i", ">", "0", "{", "s", ".", "Write", "(", "[", "]", "byte", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "pc", ".", "Format", "(", "s", ",", "c", ")", "\n", "}", "\n", "s", ".", "Write", "(", "[", "]", "byte", "(", "\"", "\"", ")", ")", "\n", "}" ]
724
all-725
[ "newDnsimpleChanges", "returns", "a", "slice", "of", "changes", "based", "on", "given", "action", "and", "record" ]
[ "func", "newDnsimpleChanges", "(", "<mask>", "string", ",", "endpoints", "[", "]", "*", "endpoint", ".", "Endpoint", ")", "[", "]", "*", "dnsimpleChange", "{", "changes", ":=", "make", "(", "[", "]", "*", "dnsimpleChange", ",", "0", ",", "len", "(", "endpoints", ")", ")", "\n", "for", "_", ",", "e", ":=", "range", "endpoints", "{", "changes", "=", "append", "(", "changes", ",", "newDnsimpleChange", "(", "action", ",", "e", ")", ")", "\n", "}", "\n", "return", "changes", "\n", "}" ]
725
all-726
[ "ReceiveComment", "is", "a", "wrapper", "on", "plugin", ".", "ReceiveComment", "()" ]
[ "func", "(", "o", "*", "FakeOpenPluginWrapper", ")", "ReceiveComment", "(", "comment", "sql", ".", "<mask>", ")", "[", "]", "Point", "{", "return", "o", ".", "plugin", ".", "ReceiveComment", "(", "comment", ")", "\n", "}" ]
726
all-727
[ "SyncResources", "will", "update", "resources", "every", "10", "mins", ".", "It", "will", "append", "newly", "added", "resources", "to", "ranch", ".", "Resources", "And", "try", "to", "remove", "newly", "deleted", "resources", "from", "ranch", ".", "Resources", ".", "If", "the", "newly", "deleted", "resource", "is", "currently", "held", "by", "a", "user", "the", "deletion", "will", "yield", "to", "next", "update", "cycle", "." ]
[ "func", "(", "s", "*", "Storage", ")", "SyncResources", "(", "data", "[", "]", "common", ".", "Resource", ")", "error", "{", "s", ".", "resourcesLock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "resourcesLock", ".", "Unlock", "(", ")", "\n\n", "resources", ",", "err", ":=", "s", ".", "GetResources", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "return", "err", "\n", "}", "\n\n", "var", "finalError", "error", "\n\n", "// delete non-exist resource", "valid", ":=", "0", "\n", "for", "_", ",", "res", ":=", "range", "resources", "{", "// If currently busy, yield deletion to later cycles.", "if", "res", ".", "Owner", "!=", "\"", "\"", "{", "resources", "[", "valid", "]", "=", "res", "\n", "valid", "++", "\n", "continue", "\n", "}", "\n", "toDelete", ":=", "true", "\n", "for", "_", ",", "newRes", ":=", "range", "data", "{", "if", "res", ".", "Name", "==", "newRes", ".", "Name", "{", "resources", "[", "valid", "]", "=", "res", "\n", "valid", "++", "\n", "toDelete", "=", "false", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "toDelete", "{", "logrus", ".", "Infof", "(", "\"", "\"", ",", "res", ".", "Name", ")", "\n", "if", "err", ":=", "s", ".", "DeleteResource", "(", "res", ".", "Name", ")", ";", "err", "!=", "nil", "{", "finalError", "=", "multierror", ".", "Append", "(", "finalError", ",", "err", ")", "\n", "logrus", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "res", ".", "Name", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "resources", "=", "<mask>", "[", ":", "valid", "]", "\n\n", "// add new resource", "for", "_", ",", "p", ":=", "range", "data", "{", "found", ":=", "false", "\n", "for", "idx", ":=", "range", "resources", "{", "exist", ":=", "resources", "[", "idx", "]", "\n", "if", "p", ".", "Name", "==", "exist", ".", "Name", "{", "found", "=", "true", "\n", "logrus", ".", "Infof", "(", "\"", "\"", ",", "p", ".", "Name", ")", "\n", "break", "\n", "}", "\n", "}", "\n\n", "if", "!", "found", "{", "if", "p", ".", "State", "==", "\"", "\"", "{", "p", ".", "State", "=", "common", ".", "Free", "\n", "}", "\n", "logrus", ".", "Infof", "(", "\"", "\"", ",", "p", ".", "Name", ")", "\n", "resources", "=", "append", "(", "resources", ",", "p", ")", "\n", "if", "err", ":=", "s", ".", "AddResource", "(", "p", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "p", ".", "Name", ")", "\n", "finalError", "=", "multierror", ".", "Append", "(", "finalError", ",", "err", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "finalError", "\n", "}" ]
727
all-728
[ "HasStart", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "m", "*", "ManageStatusDefinition", ")", "HasStart", "(", ")", "bool", "{", "if", "m", "!=", "nil", "&&", "m", ".", "Start", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
728
all-729
[ "Detect", "detects", "user", "s", "current", "shell", "." ]
[ "func", "Detect", "(", ")", "(", "string", ",", "error", ")", "{", "shell", ":=", "<mask>", ".", "Getenv", "(", "\"", "\"", ")", "\n\n", "if", "shell", "==", "\"", "\"", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\\n", "\"", ")", "\n", "return", "\"", "\"", ",", "ErrUnknownShell", "\n", "}", "\n\n", "return", "filepath", ".", "Base", "(", "shell", ")", ",", "nil", "\n", "}" ]
729
all-730
[ "Returns", "a", "Point" ]
[ "func", "(", "p", "CvPoint", ")", "ToPoint", "(", ")", "<mask>", "{", "return", "Point", "{", "int", "(", "p", ".", "x", ")", ",", "int", "(", "p", ".", "y", ")", "}", "\n", "}" ]
730
all-731
[ "WithLogFunc", "sets", "the", "function", "that", "will", "perform", "message", "logging", ".", "Default", "is", "log", ".", "Printf", "." ]
[ "func", "WithLogFunc", "(", "logf", "func", "(", "format", "string", ",", "a", "...", "<mask>", "{", "}", ")", ")", "Option", "{", "return", "func", "(", "o", "*", "Handler", ")", "{", "o", ".", "logf", "=", "logf", "}", "\n", "}" ]
731
all-732
[ "SAMLRequests", "returns", "the", "saml_requests", "from", "MongoDB", "." ]
[ "func", "(", "s", "*", "Storage", ")", "SAMLRequests", "(", ")", "*", "storage", ".", "Collection", "{", "id", ":=", "mgo", ".", "Index", "{", "Key", ":", "[", "]", "string", "{", "\"", "\"", "}", "}", "\n", "coll", ":=", "s", ".", "Collection", "(", "\"", "\"", ")", "\n", "coll", ".", "EnsureIndex", "(", "<mask>", ")", "\n", "return", "coll", "\n", "}" ]
732
all-733
[ "WithYDistance", "the", "distance", "to", "scroll", "along", "the", "Y", "axis", "(", "positive", "to", "scroll", "up", ")", "." ]
[ "func", "(", "p", "SynthesizeScrollGestureParams", ")", "WithYDistance", "(", "yDistance", "float64", ")", "*", "SynthesizeScrollGestureParams", "{", "p", ".", "YDistance", "=", "yDistance", "\n", "<mask>", "&", "p", "\n", "}" ]
733
all-734
[ "GetEnum", "is", "a", "wrapper", "around", "g_settings_get_enum", "()", "." ]
[ "func", "(", "v", "*", "Settings", ")", "GetEnum", "(", "name", "string", ")", "int", "{", "cstr1", ":=", "(", "*", "C", ".", "gchar", ")", "(", "C", ".", "CString", "(", "name", ")", ")", "\n", "defer", "C", ".", "<mask>", "(", "unsafe", ".", "Pointer", "(", "cstr1", ")", ")", "\n\n", "return", "int", "(", "C", ".", "g_settings_get_enum", "(", "v", ".", "native", "(", ")", ",", "cstr1", ")", ")", "\n", "}" ]
734
all-735
[ "HandleRedirect", "handles", "the", "redirection", "from", "GitHub", ".", "It", "exchanges", "the", "code", "from", "redirect", "URL", "for", "user", "access", "token", ".", "The", "access", "token", "is", "then", "saved", "to", "the", "cookie", "and", "the", "page", "is", "redirected", "to", "the", "final", "destination", "in", "the", "config", "which", "should", "be", "the", "front", "-", "end", "." ]
[ "func", "(", "ga", "*", "Agent", ")", "HandleRedirect", "(", "client", "OAuthClient", ",", "getter", "GitHubClientGetter", ")", "<mask>", ".", "HandlerFunc", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "state", ":=", "r", ".", "FormValue", "(", "\"", "\"", ")", "\n", "stateTokenRaw", ",", "err", ":=", "hex", ".", "DecodeString", "(", "state", ")", "\n", "if", "err", "!=", "nil", "{", "ga", ".", "serverError", "(", "w", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "stateToken", ":=", "string", "(", "stateTokenRaw", ")", "\n", "// Check if the state token is still valid or not.", "if", "!", "xsrftoken", ".", "Valid", "(", "stateToken", ",", "ga", ".", "gc", ".", "ClientSecret", ",", "\"", "\"", ",", "\"", "\"", ")", "{", "ga", ".", "serverError", "(", "w", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "return", "\n", "}", "\n\n", "oauthSession", ",", "err", ":=", "ga", ".", "gc", ".", "CookieStore", ".", "Get", "(", "r", ",", "oauthSessionCookie", ")", "\n", "if", "err", "!=", "nil", "{", "ga", ".", "serverError", "(", "w", ",", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "secretState", ",", "ok", ":=", "oauthSession", ".", "Values", "[", "stateKey", "]", ".", "(", "string", ")", "\n", "if", "!", "ok", "{", "ga", ".", "serverError", "(", "w", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "return", "\n", "}", "\n", "// Validate the state parameter to prevent cross-site attack.", "if", "state", "==", "\"", "\"", "||", "subtle", ".", "ConstantTimeCompare", "(", "[", "]", "byte", "(", "state", ")", ",", "[", "]", "byte", "(", "secretState", ")", ")", "!=", "1", "{", "ga", ".", "serverError", "(", "w", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "return", "\n", "}", "\n\n", "// Exchanges the code for user access token.", "code", ":=", "r", ".", "FormValue", "(", "\"", "\"", ")", "\n", "token", ",", "err", ":=", "client", ".", "Exchange", "(", "context", ".", "Background", "(", ")", ",", "code", ")", "\n", "if", "err", "!=", "nil", "{", "if", "gherror", ":=", "r", ".", "FormValue", "(", "\"", "\"", ")", ";", "len", "(", "gherror", ")", ">", "0", "{", "gherrorDescription", ":=", "r", ".", "FormValue", "(", "\"", "\"", ")", "\n", "gherrorURI", ":=", "r", ".", "FormValue", "(", "\"", "\"", ")", "\n", "fields", ":=", "logrus", ".", "Fields", "{", "\"", "\"", ":", "gherror", ",", "\"", "\"", ":", "gherrorDescription", ",", "\"", "\"", ":", "gherrorURI", ",", "}", "\n", "ga", ".", "logger", ".", "WithFields", "(", "fields", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "ga", ".", "serverError", "(", "w", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "gherror", ")", ")", "\n", "}", "else", "{", "ga", ".", "serverError", "(", "w", ",", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "\n", "}", "\n\n", "// New session that stores the token.", "session", ",", "err", ":=", "ga", ".", "gc", ".", "CookieStore", ".", "New", "(", "r", ",", "tokenSession", ")", "\n", "session", ".", "Options", ".", "Secure", "=", "true", "\n", "session", ".", "Options", ".", "HttpOnly", "=", "true", "\n", "if", "err", "!=", "nil", "{", "ga", ".", "serverError", "(", "w", ",", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n\n", "session", ".", "Values", "[", "tokenKey", "]", "=", "token", "\n", "if", "err", ":=", "session", ".", "Save", "(", "r", ",", "w", ")", ";", "err", "!=", "nil", "{", "ga", ".", "serverError", "(", "w", ",", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "ghc", ":=", "getter", ".", "GetGitHubClient", "(", "token", ".", "AccessToken", ",", "false", ")", "\n", "user", ",", "err", ":=", "ghc", ".", "GetUser", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "ga", ".", "serverError", "(", "w", ",", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "http", ".", "SetCookie", "(", "w", ",", "&", "http", ".", "Cookie", "{", "Name", ":", "loginSession", ",", "Value", ":", "*", "user", ".", "Login", ",", "Path", ":", "\"", "\"", ",", "Expires", ":", "time", ".", "Now", "(", ")", ".", "Add", "(", "time", ".", "Hour", "*", "24", "*", "30", ")", ",", "Secure", ":", "true", ",", "}", ")", "\n", "http", ".", "Redirect", "(", "w", ",", "r", ",", "ga", ".", "gc", ".", "FinalRedirectURL", ",", "http", ".", "StatusFound", ")", "\n", "}", "\n", "}" ]
735
all-736
[ "export", "FrameSet_Copy" ]
[ "func", "FrameSet_Copy", "(", "id", "FrameSetId", ")", "FrameSetId", "{", "fs", ",", "ok", ":=", "sFrameSets", ".", "Get", "(", "<mask>", ")", "\n", "if", "!", "ok", "{", "return", "0", "\n", "}", "\n\n", "copyFs", ",", "_", ":=", "fileseq", ".", "NewFrameSet", "(", "fs", ".", "FrameRange", "(", ")", ")", "\n", "copyId", ":=", "sFrameSets", ".", "Add", "(", "*", "copyFs", ")", "\n", "return", "copyId", "\n", "}" ]
736
all-737
[ "Creates", "a", "new", "cache", "instance" ]
[ "func", "New", "(", ")", "*", "Cache", "{", "c", ":=", "&", "Cache", "{", "data", ":", "make", "(", "[", "]", "*", "Shard", ",", "shardCount", ")", ",", "writeStrategy", ":", "Noop", ",", "}", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "shardCount", ";", "i", "++", "{", "c", ".", "data", "[", "i", "]", "=", "&", "Shard", "{", "items", ":", "make", "(", "map", "[", "string", "]", "*", "<mask>", ".", "Points", ")", ",", "notConfirmed", ":", "make", "(", "[", "]", "*", "points", ".", "Points", ",", "4", ")", ",", "}", "\n", "}", "\n\n", "settings", ":=", "cacheSettings", "{", "maxSize", ":", "1000000", ",", "tagsEnabled", ":", "false", ",", "xlog", ":", "nil", ",", "}", "\n\n", "c", ".", "settings", ".", "Store", "(", "&", "settings", ")", "\n\n", "c", ".", "writeoutQueue", "=", "NewWriteoutQueue", "(", "c", ")", "\n", "return", "c", "\n", "}" ]
737
all-738
[ "Results", "retrieves", "the", "completed", "jobs", "." ]
[ "func", "(", "pool", "*", "Pool", ")", "Results", "(", ")", "(", "res", "[", "]", "*", "<mask>", ")", "{", "res", "=", "make", "(", "[", "]", "*", "Job", ",", "pool", ".", "jobs_completed", ".", "Len", "(", ")", ")", "\n", "i", ":=", "0", "\n", "for", "e", ":=", "pool", ".", "jobs_completed", ".", "Front", "(", ")", ";", "e", "!=", "nil", ";", "e", "=", "e", ".", "Next", "(", ")", "{", "res", "[", "i", "]", "=", "e", ".", "Value", ".", "(", "*", "Job", ")", "\n", "i", "++", "\n", "}", "\n", "pool", ".", "jobs_completed", "=", "list", ".", "New", "(", ")", "\n", "return", "\n", "}" ]
738
all-739
[ "readPartial", "keeps", "reading", "from", "reader", "into", "provided", "buffer", "until", "buffer", "size", "reaches", "exactly", "n2", ".", "n1", "is", "initial", "buffer", "size", ".", "useful", "to", "ensure", "we", "get", "an", "specific", "buffer", "size", "from", "reader", "withstanding", "partial", "reads", "." ]
[ "func", "readPartial", "(", "c", "*", "Cmp", ",", "r", "<mask>", ".", "Reader", ",", "buf", "[", "]", "byte", ",", "n1", ",", "n2", "int", ")", "(", "int", ",", "error", ")", "{", "for", "n1", "<", "n2", "{", "n", ",", "err", ":=", "c", ".", "read", "(", "r", ",", "buf", "[", "n1", ":", "n2", "]", ")", "\n", "n1", "+=", "n", "\n", "if", "err", "!=", "nil", "{", "return", "n1", ",", "err", "\n", "}", "\n", "}", "\n", "return", "n1", ",", "nil", "\n", "}" ]
739
all-740
[ "TearDown", "implements", "storage", "interface", "." ]
[ "func", "(", "s", "*", "Storage", ")", "TearDown", "(", ")", "error", "{", "_", ",", "err", ":=", "s", ".", "<mask>", ".", "Exec", "(", "`DROP SCHEMA IF EXISTS `", "+", "s", ".", "schema", "+", "` CASCADE`", ")", "\n\n", "return", "err", "\n", "}" ]
740
all-741
[ "ParseLine", "makes", "a", "new", "Line", "with", "the", "given", "data", "." ]
[ "func", "ParseLine", "(", "n", "int", ",", "unsafeText", "[", "]", "byte", ")", "(", "*", "Line", ",", "error", ")", "{", "linetype", ":=", "LineTypePlain", "\n", "// trim off comments", "var", "comment", "[", "]", "byte", "\n", "text", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "unsafeText", ")", ")", "\n", "copy", "(", "text", ",", "unsafeText", ")", "\n", "if", "bytes", ".", "Contains", "(", "text", ",", "commentPrefix", ")", "{", "segs", ":=", "bytes", ".", "Split", "(", "text", ",", "commentPrefix", ")", "\n", "text", "=", "segs", "[", "0", "]", "\n", "comment", "=", "segs", "[", "1", "]", "\n", "}", "\n", "var", "rx", "*", "regexp", ".", "Regexp", "\n", "for", "_", ",", "item", ":=", "range", "matchTypes", "{", "if", "regexes", "[", "item", ".", "R", "]", ".", "Match", "(", "text", ")", "{", "linetype", "=", "item", ".", "Type", "\n", "rx", "=", "regexes", "[", "item", ".", "R", "]", "\n", "break", "\n", "}", "\n", "}", "\n", "// parse the detail now", "var", "d", "*", "Detail", "\n", "if", "linetype", "==", "LineTypeDetail", "||", "linetype", "==", "LineTypeParam", "{", "var", "err", "error", "\n", "d", ",", "err", "=", "parseDetail", "(", "text", ",", "rx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "&", "ErrLine", "{", "N", ":", "n", ",", "Err", ":", "err", "}", "\n", "}", "\n", "}", "\n", "return", "&", "Line", "{", "Number", ":", "n", ",", "Type", ":", "linetype", ",", "Bytes", ":", "text", ",", "Regexp", ":", "rx", ",", "Comment", ":", "<mask>", ",", "detail", ":", "d", ",", "}", ",", "nil", "\n", "}" ]
741
all-742
[ "Children", "returns", "a", "slice", "of", "children", "of", "the", "receiving", "ZFS", "dataset", ".", "A", "recursion", "depth", "may", "be", "specified", "or", "a", "depth", "of", "0", "allows", "unlimited", "recursion", "." ]
[ "func", "(", "d", "*", "Dataset", ")", "Children", "(", "depth", "uint64", ")", "(", "[", "]", "*", "Dataset", ",", "error", ")", "{", "args", ":=", "[", "]", "string", "{", "\"", "\"", "}", "\n", "if", "depth", ">", "0", "{", "args", "=", "append", "(", "args", ",", "\"", "\"", ")", "\n", "args", "=", "append", "(", "args", ",", "strconv", ".", "FormatUint", "(", "depth", ",", "10", ")", ")", "\n", "}", "else", "{", "args", "=", "<mask>", "(", "args", ",", "\"", "\"", ")", "\n", "}", "\n", "args", "=", "append", "(", "args", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "dsPropListOptions", ")", "\n", "args", "=", "append", "(", "args", ",", "d", ".", "Name", ")", "\n\n", "out", ",", "err", ":=", "zfs", "(", "args", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "datasets", "[", "]", "*", "Dataset", "\n", "name", ":=", "\"", "\"", "\n", "var", "ds", "*", "Dataset", "\n", "for", "_", ",", "line", ":=", "range", "out", "{", "if", "name", "!=", "line", "[", "0", "]", "{", "name", "=", "line", "[", "0", "]", "\n", "ds", "=", "&", "Dataset", "{", "Name", ":", "name", "}", "\n", "datasets", "=", "append", "(", "datasets", ",", "ds", ")", "\n", "}", "\n", "if", "err", ":=", "ds", ".", "parseLine", "(", "line", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "return", "datasets", "[", "1", ":", "]", ",", "nil", "\n", "}" ]
742
all-743
[ "Converts", "options", "into", "CORS", "headers", "for", "a", "preflight", "response", "." ]
[ "func", "(", "o", "*", "Options", ")", "PreflightHeader", "(", "origin", ",", "rMethod", ",", "rHeaders", "string", ")", "(", "<mask>", "map", "[", "string", "]", "string", ")", "{", "headers", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "if", "!", "o", ".", "AllowAllOrigins", "&&", "!", "o", ".", "IsOriginAllowed", "(", "origin", ")", "{", "return", "\n", "}", "\n", "// verify if requested method is allowed", "// TODO: Too many for loops", "for", "_", ",", "method", ":=", "range", "o", ".", "AllowMethods", "{", "if", "method", "==", "rMethod", "{", "headers", "[", "headerAllowMethods", "]", "=", "strings", ".", "Join", "(", "o", ".", "AllowMethods", ",", "\"", "\"", ")", "\n", "break", "\n", "}", "\n", "}", "\n\n", "// verify if requested headers are allowed", "var", "allowed", "[", "]", "string", "\n", "for", "_", ",", "rHeader", ":=", "range", "strings", ".", "Split", "(", "rHeaders", ",", "\"", "\"", ")", "{", "lookupLoop", ":", "for", "_", ",", "allowedHeader", ":=", "range", "o", ".", "AllowHeaders", "{", "if", "rHeader", "==", "allowedHeader", "{", "allowed", "=", "append", "(", "allowed", ",", "rHeader", ")", "\n", "break", "lookupLoop", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// add allowed headers", "if", "len", "(", "allowed", ")", ">", "0", "{", "headers", "[", "headerAllowHeaders", "]", "=", "strings", ".", "Join", "(", "allowed", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// add exposed headers", "if", "len", "(", "o", ".", "ExposeHeaders", ")", ">", "0", "{", "headers", "[", "headerExposeHeaders", "]", "=", "strings", ".", "Join", "(", "o", ".", "ExposeHeaders", ",", "\"", "\"", ")", "\n", "}", "\n", "// add a max age header", "if", "o", ".", "MaxAge", ">", "time", ".", "Duration", "(", "0", ")", "{", "headers", "[", "headerMaxAge", "]", "=", "strconv", ".", "FormatInt", "(", "int64", "(", "o", ".", "MaxAge", "/", "time", ".", "Second", ")", ",", "10", ")", "\n", "}", "\n", "return", "\n", "}" ]
743
all-744
[ "NewSimpleClientset", "returns", "a", "clientset", "that", "will", "respond", "with", "the", "provided", "objects", ".", "It", "s", "backed", "by", "a", "very", "simple", "object", "tracker", "that", "processes", "creates", "updates", "and", "deletions", "as", "-", "is", "without", "applying", "any", "validations", "and", "/", "or", "defaults", ".", "It", "shouldn", "t", "be", "considered", "a", "replacement", "for", "a", "real", "clientset", "and", "is", "mostly", "useful", "in", "simple", "unit", "tests", "." ]
[ "func", "NewSimpleClientset", "(", "objects", "...", "runtime", ".", "Object", ")", "*", "Clientset", "{", "o", ":=", "testing", ".", "NewObjectTracker", "(", "scheme", ",", "codecs", ".", "UniversalDecoder", "(", ")", ")", "\n", "for", "_", ",", "obj", ":=", "range", "<mask>", "{", "if", "err", ":=", "o", ".", "Add", "(", "obj", ")", ";", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "}", "\n\n", "fakePtr", ":=", "testing", ".", "Fake", "{", "}", "\n", "fakePtr", ".", "AddReactor", "(", "\"", "\"", ",", "\"", "\"", ",", "testing", ".", "ObjectReaction", "(", "o", ")", ")", "\n", "fakePtr", ".", "AddWatchReactor", "(", "\"", "\"", ",", "testing", ".", "DefaultWatchReactor", "(", "watch", ".", "NewFake", "(", ")", ",", "nil", ")", ")", "\n\n", "return", "&", "Clientset", "{", "fakePtr", ",", "&", "fakediscovery", ".", "FakeDiscovery", "{", "Fake", ":", "&", "fakePtr", "}", "}", "\n", "}" ]
744
all-745
[ "AddNetworkList", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockCNI", ")", "AddNetworkList", "(", "arg0", "*", "libcni", ".", "NetworkConfigList", ",", "arg1", "*", "libcni", ".", "RuntimeConf", ")", "(", "types", ".", "Result", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "<mask>", "[", "0", "]", ".", "(", "types", ".", "Result", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
745
all-746
[ "ApplicationNew", "is", "a", "wrapper", "around", "gtk_application_new", "()", "." ]
[ "func", "ApplicationNew", "(", "appId", "string", ",", "<mask>", "glib", ".", "ApplicationFlags", ")", "(", "*", "Application", ",", "error", ")", "{", "cstr", ":=", "(", "*", "C", ".", "gchar", ")", "(", "C", ".", "CString", "(", "appId", ")", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cstr", ")", ")", "\n\n", "c", ":=", "C", ".", "gtk_application_new", "(", "cstr", ",", "C", ".", "GApplicationFlags", "(", "flags", ")", ")", "\n", "if", "c", "==", "nil", "{", "return", "nil", ",", "nilPtrErr", "\n", "}", "\n", "return", "wrapApplication", "(", "glib", ".", "Take", "(", "unsafe", ".", "Pointer", "(", "c", ")", ")", ")", ",", "nil", "\n", "}" ]
746
all-747
[ "/", "*", "Using", "presence", "channels", "is", "similar", "to", "private", "channels", "but", "in", "order", "to", "identify", "a", "user", "clients", "are", "sent", "a", "user_id", "and", "optionally", "custom", "data", "." ]
[ "func", "(", "c", "*", "Client", ")", "AuthenticatePresenceChannel", "(", "params", "[", "]", "byte", ",", "member", "MemberData", ")", "(", "response", "[", "]", "<mask>", ",", "err", "error", ")", "{", "return", "c", ".", "authenticateChannel", "(", "params", ",", "&", "member", ")", "\n", "}" ]
747
all-748
[ "getImageState", "returns", "the", "ImageState", "object", "that", "the", "container", "is", "referenced", "at" ]
[ "func", "(", "imageManager", "*", "dockerImageManager", ")", "getImageState", "(", "containerImageID", "string", ")", "(", "*", "image", ".", "ImageState", ",", "bool", ")", "{", "for", "_", ",", "imageState", ":=", "range", "imageManager", ".", "getAllImageStates", "(", ")", "{", "if", "imageState", ".", "<mask>", ".", "ImageID", "==", "containerImageID", "{", "return", "imageState", ",", "true", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "false", "\n", "}" ]
748
all-749
[ "CallSC", "makes", "a", "call", "using", "the", "given", "subcahnnel" ]
[ "func", "CallSC", "(", "ctx", "context", ".", "Context", ",", "sc", "*", "tchannel", ".", "SubChannel", ",", "<mask>", "string", ",", "arg2", ",", "arg3", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "[", "]", "byte", ",", "*", "tchannel", ".", "OutboundCallResponse", ",", "error", ")", "{", "call", ",", "err", ":=", "sc", ".", "BeginCall", "(", "ctx", ",", "method", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "return", "WriteArgs", "(", "call", ",", "arg2", ",", "arg3", ")", "\n", "}" ]
749
all-750
[ "PutBlob", "writes", "contents", "of", "stream", "and", "returns", "data", "representing", "the", "result", ".", "inputInfo", ".", "Digest", "can", "be", "optionally", "provided", "if", "known", ";", "it", "is", "not", "mandatory", "for", "the", "implementation", "to", "verify", "it", ".", "inputInfo", ".", "Size", "is", "the", "expected", "length", "of", "stream", "if", "known", ".", "inputInfo", ".", "MediaType", "describes", "the", "blob", "format", "if", "known", ".", "May", "update", "cache", ".", "WARNING", ":", "The", "contents", "of", "stream", "are", "being", "verified", "on", "the", "fly", ".", "Until", "stream", ".", "Read", "()", "returns", "io", ".", "EOF", "the", "contents", "of", "the", "data", "SHOULD", "NOT", "be", "available", "to", "any", "other", "readers", "for", "download", "using", "the", "supplied", "digest", ".", "If", "stream", ".", "Read", "()", "at", "any", "time", "ESPECIALLY", "at", "end", "of", "input", "returns", "an", "error", "PutBlob", "MUST", "1", ")", "fail", "and", "2", ")", "delete", "any", "data", "stored", "so", "far", "." ]
[ "func", "(", "s", "*", "storageImageDestination", ")", "PutBlob", "(", "ctx", "context", ".", "Context", ",", "stream", "io", ".", "Reader", ",", "blobinfo", "types", ".", "BlobInfo", ",", "cache", "types", ".", "BlobInfoCache", ",", "isConfig", "bool", ")", "(", "types", ".", "BlobInfo", ",", "error", ")", "{", "// Stores a layer or data blob in our temporary directory, checking that any information", "// in the blobinfo matches the incoming data.", "errorBlobInfo", ":=", "types", ".", "BlobInfo", "{", "Digest", ":", "\"", "\"", ",", "Size", ":", "-", "1", ",", "}", "\n", "// Set up to digest the blob and count its size while saving it to a file.", "hasher", ":=", "digest", ".", "Canonical", ".", "Digester", "(", ")", "\n", "if", "blobinfo", ".", "Digest", ".", "Validate", "(", ")", "==", "nil", "{", "if", "a", ":=", "blobinfo", ".", "Digest", ".", "Algorithm", "(", ")", ";", "a", ".", "Available", "(", ")", "{", "hasher", "=", "a", ".", "Digester", "(", ")", "\n", "}", "\n", "}", "\n", "diffID", ":=", "digest", ".", "Canonical", ".", "Digester", "(", ")", "\n", "filename", ":=", "s", ".", "computeNextBlobCacheFile", "(", ")", "\n", "file", ",", "err", ":=", "os", ".", "OpenFile", "(", "filename", ",", "os", ".", "O_CREATE", "|", "os", ".", "O_TRUNC", "|", "os", ".", "O_WRONLY", "|", "os", ".", "O_EXCL", ",", "0600", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errorBlobInfo", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "filename", ")", "\n", "}", "\n", "defer", "file", ".", "Close", "(", ")", "\n", "<mask>", ":=", "ioutils", ".", "NewWriteCounter", "(", "hasher", ".", "Hash", "(", ")", ")", "\n", "reader", ":=", "io", ".", "TeeReader", "(", "io", ".", "TeeReader", "(", "stream", ",", "counter", ")", ",", "file", ")", "\n", "decompressed", ",", "err", ":=", "archive", ".", "DecompressStream", "(", "reader", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errorBlobInfo", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "// Copy the data to the file.", "// TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().", "_", ",", "err", "=", "io", ".", "Copy", "(", "diffID", ".", "Hash", "(", ")", ",", "decompressed", ")", "\n", "decompressed", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errorBlobInfo", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "filename", ")", "\n", "}", "\n", "// Ensure that any information that we were given about the blob is correct.", "if", "blobinfo", ".", "Digest", ".", "Validate", "(", ")", "==", "nil", "&&", "blobinfo", ".", "Digest", "!=", "hasher", ".", "Digest", "(", ")", "{", "return", "errorBlobInfo", ",", "ErrBlobDigestMismatch", "\n", "}", "\n", "if", "blobinfo", ".", "Size", ">=", "0", "&&", "blobinfo", ".", "Size", "!=", "counter", ".", "Count", "{", "return", "errorBlobInfo", ",", "ErrBlobSizeMismatch", "\n", "}", "\n", "// Record information about the blob.", "s", ".", "putBlobMutex", ".", "Lock", "(", ")", "\n", "s", ".", "blobDiffIDs", "[", "hasher", ".", "Digest", "(", ")", "]", "=", "diffID", ".", "Digest", "(", ")", "\n", "s", ".", "fileSizes", "[", "hasher", ".", "Digest", "(", ")", "]", "=", "counter", ".", "Count", "\n", "s", ".", "filenames", "[", "hasher", ".", "Digest", "(", ")", "]", "=", "filename", "\n", "s", ".", "putBlobMutex", ".", "Unlock", "(", ")", "\n", "blobDigest", ":=", "blobinfo", ".", "Digest", "\n", "if", "blobDigest", ".", "Validate", "(", ")", "!=", "nil", "{", "blobDigest", "=", "hasher", ".", "Digest", "(", ")", "\n", "}", "\n", "blobSize", ":=", "blobinfo", ".", "Size", "\n", "if", "blobSize", "<", "0", "{", "blobSize", "=", "counter", ".", "Count", "\n", "}", "\n", "// This is safe because we have just computed both values ourselves.", "cache", ".", "RecordDigestUncompressedPair", "(", "blobDigest", ",", "diffID", ".", "Digest", "(", ")", ")", "\n", "return", "types", ".", "BlobInfo", "{", "Digest", ":", "blobDigest", ",", "Size", ":", "blobSize", ",", "MediaType", ":", "blobinfo", ".", "MediaType", ",", "}", ",", "nil", "\n", "}" ]
750
all-751
[ "Verify", "checks", "a", "signature", "agains", "the", "input", "data", "." ]
[ "func", "(", "k", "*", "Ed25519PublicKey", ")", "Verify", "(", "data", "[", "]", "byte", ",", "sig", "[", "]", "byte", ")", "(", "bool", ",", "error", ")", "{", "return", "ed25519", ".", "Verify", "(", "k", ".", "k", ",", "<mask>", ",", "sig", ")", ",", "nil", "\n", "}" ]
751
all-752
[ "appendDefaultEgressIgnoredIPs", "append", "task", "metadata", "endpoint", "ip", "and", "instance", "metadata", "ip", "address", "to", "egress", "ignored", "IPs", "if", "does", "not", "exist" ]
[ "func", "appendDefaultEgressIgnoredIPs", "(", "egressIgnoredIPs", "[", "]", "string", ")", "[", "]", "string", "{", "hasTaskMetadataEndpointIP", ":=", "false", "\n", "hasInstanceMetadataEndpointIP", ":=", "false", "\n", "for", "_", ",", "egressIgnoredIP", ":=", "range", "egressIgnoredIPs", "{", "if", "strings", ".", "TrimSpace", "(", "egressIgnoredIP", ")", "==", "taskMetadataEndpointIP", "{", "hasTaskMetadataEndpointIP", "=", "true", "\n", "}", "\n", "if", "strings", ".", "TrimSpace", "(", "egressIgnoredIP", ")", "==", "instanceMetadataEndpointIP", "{", "hasInstanceMetadataEndpointIP", "=", "true", "\n", "}", "\n", "}", "\n\n", "if", "!", "hasTaskMetadataEndpointIP", "{", "egressIgnoredIPs", "=", "<mask>", "(", "egressIgnoredIPs", ",", "taskMetadataEndpointIP", ")", "\n", "}", "\n", "if", "!", "hasInstanceMetadataEndpointIP", "{", "egressIgnoredIPs", "=", "append", "(", "egressIgnoredIPs", ",", "instanceMetadataEndpointIP", ")", "\n", "}", "\n\n", "return", "egressIgnoredIPs", "\n", "}" ]
752
all-753
[ "MakeLang", "returns", "slug", "generated", "from", "provided", "string", "and", "will", "use", "provided", "language", "for", "chars", "substitution", "." ]
[ "func", "MakeLang", "(", "s", "string", ",", "lang", "string", ")", "(", "slug", "string", ")", "{", "slug", "=", "strings", ".", "TrimSpace", "(", "s", ")", "\n\n", "// Custom substitutions", "// Always substitute runes first", "slug", "=", "SubstituteRune", "(", "slug", ",", "CustomRuneSub", ")", "\n", "slug", "=", "Substitute", "(", "slug", ",", "CustomSub", ")", "\n\n", "// Process string with selected substitution language", "switch", "lang", "{", "case", "\"", "\"", ":", "slug", "=", "SubstituteRune", "(", "slug", ",", "deSub", ")", "\n", "case", "\"", "\"", ":", "slug", "=", "SubstituteRune", "(", "slug", ",", "enSub", ")", "\n", "case", "\"", "\"", ":", "slug", "=", "SubstituteRune", "(", "slug", ",", "esSub", ")", "\n", "<mask>", "\"", "\"", ":", "slug", "=", "SubstituteRune", "(", "slug", ",", "fiSub", ")", "\n", "case", "\"", "\"", ":", "slug", "=", "SubstituteRune", "(", "slug", ",", "grSub", ")", "\n", "case", "\"", "\"", ":", "slug", "=", "SubstituteRune", "(", "slug", ",", "nlSub", ")", "\n", "case", "\"", "\"", ":", "slug", "=", "SubstituteRune", "(", "slug", ",", "plSub", ")", "\n", "case", "\"", "\"", ":", "slug", "=", "SubstituteRune", "(", "slug", ",", "trSub", ")", "\n", "default", ":", "// fallback to \"en\" if lang not found", "slug", "=", "SubstituteRune", "(", "slug", ",", "enSub", ")", "\n", "}", "\n\n", "// Process all non ASCII symbols", "slug", "=", "unidecode", ".", "Unidecode", "(", "slug", ")", "\n\n", "slug", "=", "strings", ".", "ToLower", "(", "slug", ")", "\n\n", "// Process all remaining symbols", "slug", "=", "regexpNonAuthorizedChars", ".", "ReplaceAllString", "(", "slug", ",", "\"", "\"", ")", "\n", "slug", "=", "regexpMultipleDashes", ".", "ReplaceAllString", "(", "slug", ",", "\"", "\"", ")", "\n", "slug", "=", "strings", ".", "Trim", "(", "slug", ",", "\"", "\"", ")", "\n\n", "if", "MaxLength", ">", "0", "{", "slug", "=", "smartTruncate", "(", "slug", ")", "\n", "}", "\n\n", "return", "slug", "\n", "}" ]
753
all-754
[ "cleanupVM", "cleans", "up", "VM", "VIX", "handle", "." ]
[ "func", "cleanupVM", "(", "v", "*", "VM", ")", "{", "if", "v", ".", "handle", "!=", "C", ".", "VIX_INVALID_HANDLE", "{", "C", ".", "Vix_ReleaseHandle", "(", "v", ".", "<mask>", ")", "\n", "v", ".", "handle", "=", "C", ".", "VIX_INVALID_HANDLE", "\n", "}", "\n", "}" ]
754
all-755
[ "Put", "implements", "gRPC", "KVServer", ".", "Put", "puts", "the", "given", "key", "into", "the", "store", ".", "A", "put", "request", "increases", "the", "revision", "of", "the", "store", "and", "generates", "one", "event", "in", "the", "event", "history", "." ]
[ "func", "(", "s", "*", "etcdStore", ")", "Put", "(", "ctx", "context", ".", "Context", ",", "req", "*", "etcdserverpb", ".", "PutRequest", ")", "(", "*", "etcdserverpb", ".", "PutResponse", ",", "error", ")", "{", "ireq", ":=", "etcdserverpb", ".", "InternalRaftRequest", "{", "ID", ":", "<-", "s", ".", "idgen", ",", "Put", ":", "req", "}", "\n", "msgc", ",", "errc", ",", "err", ":=", "s", ".", "proposeInternalRaftRequest", "(", "ireq", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "select", "{", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "s", ".", "cancelInternalRaftRequest", "(", "ireq", ")", "\n", "return", "nil", ",", "ctx", ".", "Err", "(", ")", "\n", "<mask>", "msg", ":=", "<-", "msgc", ":", "return", "msg", ".", "(", "*", "etcdserverpb", ".", "PutResponse", ")", ",", "nil", "\n", "case", "err", ":=", "<-", "errc", ":", "return", "nil", ",", "err", "\n", "case", "<-", "s", ".", "quitc", ":", "return", "nil", ",", "errStopped", "\n", "}", "\n", "}" ]
755
all-756
[ "GetIntegrationAWS", "gets", "all", "the", "AWS", "Accounts", "in", "the", "AWS", "Integrations", "from", "Datadog", "." ]
[ "func", "(", "client", "*", "Client", ")", "GetIntegrationAWS", "(", ")", "(", "*", "[", "]", "IntegrationAWSAccount", ",", "error", ")", "{", "var", "<mask>", "IntegrationAWSAccountGetResponse", "\n", "if", "err", ":=", "client", ".", "doJsonRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "nil", ",", "&", "response", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "response", ".", "Accounts", ",", "nil", "\n", "}" ]
756
all-757
[ "CreateJob", "creates", "a", "new", "job", "based", "on", "the", "provided", "structure", "." ]
[ "func", "(", "c", "*", "Client", ")", "CreateJob", "(", "job", "*", "JobDetail", ")", "(", "*", "JobSummary", ",", "error", ")", "{", "return", "c", ".", "importJob", "(", "<mask>", ",", "\"", "\"", ")", "\n", "}" ]
757
all-758
[ "NewAuthenticatedMessage", "creates", "a", "new", "AuthenticatedMessage", "." ]
[ "func", "NewAuthenticatedMessage", "(", "v", "Uint32", ",", "value", "<mask>", "{", "}", ")", "(", "result", "AuthenticatedMessage", ",", "err", "error", ")", "{", "result", ".", "V", "=", "v", "\n", "switch", "Uint32", "(", "v", ")", "{", "case", "0", ":", "tv", ",", "ok", ":=", "value", ".", "(", "AuthenticatedMessageV0", ")", "\n", "if", "!", "ok", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "result", ".", "V0", "=", "&", "tv", "\n", "}", "\n", "return", "\n", "}" ]
758
all-759
[ "grabEncodeTargets", "grabs", "the", "fields", "for", "the", "obj", "." ]
[ "func", "grabEncodeTargets", "(", "alg", "Algorithm", ",", "obj", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "interface", "{", "}", ",", "error", ")", "{", "<mask>", "headerObj", ",", "payloadObj", "interface", "{", "}", "\n\n", "// get header", "if", "headerVal", ":=", "getFieldWithTag", "(", "obj", ",", "\"", "\"", ")", ";", "headerVal", "!=", "nil", "{", "headerObj", "=", "headerVal", ".", "Interface", "(", ")", "\n", "}", "\n", "if", "headerObj", "==", "nil", "{", "headerObj", "=", "alg", ".", "Header", "(", ")", "\n", "}", "\n\n", "// get payload", "if", "payloadVal", ":=", "getFieldWithTag", "(", "obj", ",", "\"", "\"", ")", ";", "payloadVal", "!=", "nil", "{", "payloadObj", "=", "payloadVal", ".", "Interface", "(", ")", "\n", "}", "\n", "if", "payloadObj", "==", "nil", "{", "payloadObj", "=", "obj", "\n", "}", "\n\n", "return", "headerObj", ",", "payloadObj", ",", "nil", "\n", "}" ]
759
all-760
[ "TimeOrderedUUID", "generates", "a", "time", "ordered", "UUID", ".", "Top", "32b", "are", "timestamp", "bottom", "96b", "are", "random", "." ]
[ "func", "TimeOrderedUUID", "(", ")", "string", "{", "unixTime", ":=", "uint32", "(", "time", ".", "Now", "(", ")", ".", "UTC", "(", ")", ".", "Unix", "(", ")", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "unixTime", ",", "rand", ".", "MustGenerateRandomBytes", "(", "2", ")", ",", "rand", ".", "MustGenerateRandomBytes", "(", "2", ")", ",", "rand", ".", "MustGenerateRandomBytes", "(", "2", ")", ",", "rand", ".", "MustGenerateRandomBytes", "(", "2", ")", ",", "<mask>", ".", "MustGenerateRandomBytes", "(", "4", ")", ")", "\n", "}" ]
760
all-761
[ "OptImportSort", "tells", "the", "importer", "whether", "or", "not", "to", "sort", "batches", "of", "records", "on", "by", "default", ".", "Sorting", "imposes", "some", "performance", "cost", "especially", "on", "data", "that", "s", "already", "sorted", "but", "dramatically", "improves", "performance", "in", "pathological", "cases", ".", "It", "is", "enabled", "by", "default", "because", "the", "pathological", "cases", "are", "awful", "and", "the", "performance", "hit", "is", "comparatively", "small", "but", "the", "performance", "cost", "can", "be", "significant", "if", "you", "know", "your", "data", "is", "sorted", "." ]
[ "func", "OptImportSort", "(", "sorting", "bool", ")", "ImportOption", "{", "return", "func", "(", "<mask>", "*", "ImportOptions", ")", "error", "{", "// skipSort is expressed negatively because we want to", "// keep sorting enabled by default, so the zero value should", "// be that default behavior. The client option expresses it", "// positively because that's easier for API users.", "options", ".", "skipSort", "=", "!", "sorting", "\n", "return", "nil", "\n", "}", "\n", "}" ]
761
all-762
[ "Readable", "reports", "whether", "the", "address", "a", "is", "readable", "." ]
[ "func", "(", "p", "*", "<mask>", ")", "Readable", "(", "a", "Address", ")", "bool", "{", "return", "p", ".", "findMapping", "(", "a", ")", "!=", "nil", "\n", "}" ]
762
all-763
[ "Expiration", "sets", "the", "expiration", "time", "of", "the", "auth", "token" ]
[ "func", "Expiration", "(", "e", "<mask>", ".", "Duration", ")", "TokenOpt", "{", "return", "TokenOpt", "{", "func", "(", "o", "*", "options", ")", "{", "o", ".", "expiration", "=", "e", "\n", "}", "}", "\n", "}" ]
763
all-764
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "AttachToTargetParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoTarget29", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
764
all-765
[ "GetContacts", "gets", "a", "users", "contacts" ]
[ "func", "(", "c", "<mask>", ")", "GetContacts", "(", "params", "*", "ContactsParams", ")", "(", "*", "contactsHolder", ",", "error", ")", "{", "holder", ":=", "contactsHolder", "{", "}", "\n", "if", "err", ":=", "c", ".", "Get", "(", "\"", "\"", ",", "params", ",", "&", "holder", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "for", "_", ",", "contact", ":=", "range", "holder", ".", "Contacts", "{", "if", "contact", ".", "Contact", ".", "Email", "!=", "\"", "\"", "{", "holder", ".", "Emails", "=", "append", "(", "holder", ".", "Emails", ",", "contact", ".", "Contact", ".", "Email", ")", "\n", "}", "\n", "}", "\n", "return", "&", "holder", ",", "nil", "\n", "}" ]
765
all-766
[ "Restore", "restores", "the", "terminal", "connected", "to", "the", "given", "file", "descriptor", "to", "a", "previous", "state", "." ]
[ "func", "Restore", "(", "fd", "int", ",", "state", "*", "State", ")", "error", "{", "ret", ",", "err", ":=", "C", ".", "tcsetattr", "(", "C", ".", "int", "(", "fd", ")", ",", "C", ".", "TCSANOW", ",", "(", "*", "C", ".", "struct_termios", ")", "(", "unsafe", ".", "Pointer", "(", "&", "<mask>", ".", "Termios", ")", ")", ")", "\n", "if", "ret", "!=", "0", "{", "return", "err", ".", "(", "syscall", ".", "Errno", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
766
all-767
[ "PrintBranch", "pretty", "-", "prints", "a", "Branch", "." ]
[ "func", "PrintBranch", "(", "w", "io", ".", "Writer", ",", "branchInfo", "*", "pfs", ".", "BranchInfo", ")", "{", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\t", "\"", ",", "branchInfo", ".", "Branch", ".", "Name", ")", "\n", "if", "branchInfo", ".", "Head", "!=", "nil", "{", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\t", "\\n", "\"", ",", "branchInfo", ".", "Head", ".", "<mask>", ")", "\n", "}", "else", "{", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\t", "\\n", "\"", ")", "\n", "}", "\n", "}" ]
767
all-768
[ "Load", "a", "backup", "from", "the", "database" ]
[ "func", "backupLoadByName", "(", "s", "*", "state", ".", "State", ",", "project", ",", "name", "string", ")", "(", "*", "backup", ",", "error", ")", "{", "// Get the backup database record", "args", ",", "err", ":=", "s", ".", "Cluster", ".", "ContainerGetBackup", "(", "project", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Load the container it belongs to", "c", ",", "err", ":=", "containerLoadById", "(", "s", ",", "args", ".", "ContainerID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Return the backup struct", "return", "&", "backup", "{", "state", ":", "s", ",", "container", ":", "c", ",", "id", ":", "args", ".", "ID", ",", "<mask>", ":", "name", ",", "creationDate", ":", "args", ".", "CreationDate", ",", "expiryDate", ":", "args", ".", "ExpiryDate", ",", "containerOnly", ":", "args", ".", "ContainerOnly", ",", "optimizedStorage", ":", "args", ".", "OptimizedStorage", ",", "}", ",", "nil", "\n", "}" ]
768
all-769
[ "ContainerBackupRemove", "removes", "the", "container", "backup", "with", "the", "given", "name", "from", "the", "database", "." ]
[ "func", "(", "c", "*", "Cluster", ")", "ContainerBackupRemove", "(", "name", "string", ")", "error", "{", "id", ",", "err", ":=", "c", ".", "ContainerBackupID", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "<mask>", "(", "c", ".", "db", ",", "\"", "\"", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
769
all-770
[ "GetContainerServer", "returns", "a", "ContainerServer", "struct", "for", "the", "remote" ]
[ "func", "(", "c", "*", "Config", ")", "GetContainerServer", "(", "name", "string", ")", "(", "lxd", ".", "ContainerServer", ",", "error", ")", "{", "// Get the remote", "remote", ",", "ok", ":=", "c", ".", "Remotes", "[", "name", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ",", "name", ")", "\n", "}", "\n\n", "// Sanity checks", "if", "remote", ".", "Public", "||", "remote", ".", "Protocol", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Get connection arguments", "args", ",", "err", ":=", "c", ".", "getConnectionArgs", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Unix socket", "if", "strings", ".", "HasPrefix", "(", "remote", ".", "Addr", ",", "\"", "\"", ")", "{", "d", ",", "err", ":=", "lxd", ".", "ConnectLXDUnix", "(", "strings", ".", "TrimPrefix", "(", "strings", ".", "TrimPrefix", "(", "remote", ".", "Addr", ",", "\"", "\"", ")", ",", "\"", "\"", ")", ",", "args", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "remote", ".", "Project", "!=", "\"", "\"", "&&", "remote", ".", "Project", "!=", "\"", "\"", "{", "d", "=", "d", ".", "UseProject", "(", "remote", ".", "Project", ")", "\n", "}", "\n\n", "if", "c", ".", "ProjectOverride", "!=", "\"", "\"", "{", "d", "=", "d", ".", "UseProject", "(", "c", ".", "ProjectOverride", ")", "\n", "}", "\n\n", "return", "d", ",", "nil", "\n", "}", "\n\n", "// HTTPs", "if", "remote", ".", "AuthType", "!=", "\"", "\"", "&&", "(", "args", ".", "TLSClientCert", "==", "\"", "\"", "||", "args", ".", "TLSClientKey", "==", "\"", "\"", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "d", ",", "err", ":=", "lxd", ".", "ConnectLXD", "(", "remote", ".", "Addr", ",", "args", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "remote", ".", "Project", "!=", "\"", "\"", "&&", "remote", ".", "<mask>", "!=", "\"", "\"", "{", "d", "=", "d", ".", "UseProject", "(", "remote", ".", "Project", ")", "\n", "}", "\n\n", "if", "c", ".", "ProjectOverride", "!=", "\"", "\"", "{", "d", "=", "d", ".", "UseProject", "(", "c", ".", "ProjectOverride", ")", "\n", "}", "\n\n", "return", "d", ",", "nil", "\n", "}" ]
770
all-771
[ "pushMsg", "pushes", "a", "message", "performing", "validation", "as", "necessary" ]
[ "func", "(", "p", "*", "PubSub", ")", "pushMsg", "(", "vals", "[", "]", "*", "topicVal", ",", "src", "peer", ".", "ID", ",", "msg", "*", "Message", ")", "{", "// reject messages from blacklisted peers", "if", "p", ".", "blacklist", ".", "Contains", "(", "src", ")", "{", "log", ".", "Warningf", "(", "\"", "\"", ",", "src", ")", "\n", "return", "\n", "}", "\n\n", "// even if they are forwarded by good peers", "if", "p", ".", "blacklist", ".", "Contains", "(", "msg", ".", "GetFrom", "(", ")", ")", "{", "<mask>", ".", "Warningf", "(", "\"", "\"", ",", "src", ")", "\n", "return", "\n", "}", "\n\n", "// reject unsigned messages when strict before we even process the id", "if", "p", ".", "signStrict", "&&", "msg", ".", "Signature", "==", "nil", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "src", ")", "\n", "return", "\n", "}", "\n\n", "// have we already seen and validated this message?", "id", ":=", "msgID", "(", "msg", ".", "Message", ")", "\n", "if", "p", ".", "seenMessage", "(", "id", ")", "{", "return", "\n", "}", "\n\n", "if", "len", "(", "vals", ")", ">", "0", "||", "msg", ".", "Signature", "!=", "nil", "{", "// validation is asynchronous and globally throttled with the throttleValidate semaphore.", "// the purpose of the global throttle is to bound the goncurrency possible from incoming", "// network traffic; each validator also has an individual throttle to preclude", "// slow (or faulty) validators from starving other topics; see validate below.", "select", "{", "case", "p", ".", "validateThrottle", "<-", "struct", "{", "}", "{", "}", ":", "go", "func", "(", ")", "{", "p", ".", "validate", "(", "vals", ",", "src", ",", "msg", ")", "\n", "<-", "p", ".", "validateThrottle", "\n", "}", "(", ")", "\n", "default", ":", "log", ".", "Warningf", "(", "\"", "\"", ",", "src", ")", "\n", "}", "\n", "return", "\n", "}", "\n\n", "p", ".", "publishMessage", "(", "src", ",", "msg", ".", "Message", ")", "\n", "}" ]
771
all-772
[ "KnownCreated", "returns", "true", "if", "the", "volume", "s", "known", "status", "is", "CREATED" ]
[ "func", "(", "vol", "*", "VolumeResource", ")", "KnownCreated", "(", ")", "bool", "{", "vol", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "vol", ".", "<mask>", ".", "RUnlock", "(", ")", "\n\n", "return", "vol", ".", "knownStatusUnsafe", "==", "resourcestatus", ".", "ResourceStatus", "(", "VolumeCreated", ")", "\n", "}" ]
772
all-773
[ "GetBoolStringPtr", "reads", "a", "ResourceData", "*", "string", "*", "field", ".", "This", "field", "is", "handled", "in", "the", "following", "way", ":", "*", "If", "it", "s", "empty", "nil", "is", "returned", ".", "*", "The", "string", "is", "then", "sent", "through", "ParseBool", ".", "This", "will", "return", "a", "valid", "value", "for", "anything", "ParseBool", "returns", "a", "value", "for", ".", "*", "If", "it", "s", "anything", "else", "an", "error", "is", "returned", ".", "This", "is", "designed", "to", "address", "the", "current", "lack", "of", "HCL", "and", "Terraform", "to", "be", "able", "to", "distinguish", "between", "nil", "states", "and", "zero", "values", "properly", ".", "This", "is", "a", "systemic", "issue", "that", "affects", "reading", "writing", "and", "diffing", "of", "these", "values", ".", "These", "issues", "will", "eventually", "be", "addressed", "in", "HCL2", "." ]
[ "func", "GetBoolStringPtr", "(", "d", "*", "schema", ".", "ResourceData", ",", "key", "string", ")", "(", "*", "bool", ",", "error", ")", "{", "v", ",", "ok", ":=", "d", ".", "GetOk", "(", "<mask>", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "b", ",", "err", ":=", "strconv", ".", "ParseBool", "(", "v", ".", "(", "string", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "b", ",", "nil", "\n", "}" ]
773
all-774
[ "GetPublicKey", "retrieves", "the", "public", "key", "associated", "with", "the", "given", "peer", "ID", "from", "the", "value", "store", ".", "If", "the", "ValueStore", "is", "also", "a", "PubKeyFetcher", "this", "method", "will", "call", "GetPublicKey", "(", "which", "may", "be", "better", "optimized", ")", "instead", "of", "GetValue", "." ]
[ "func", "GetPublicKey", "(", "r", "ValueStore", ",", "ctx", "context", ".", "Context", ",", "p", "peer", ".", "ID", ")", "(", "ci", ".", "PubKey", ",", "error", ")", "{", "switch", "k", ",", "err", ":=", "p", ".", "ExtractPublicKey", "(", ")", ";", "err", "{", "case", "peer", ".", "ErrNoPublicKey", ":", "// check the datastore", "<mask>", "nil", ":", "return", "k", ",", "nil", "\n", "default", ":", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "dht", ",", "ok", ":=", "r", ".", "(", "PubKeyFetcher", ")", ";", "ok", "{", "// If we have a DHT as our routing system, use optimized fetcher", "return", "dht", ".", "GetPublicKey", "(", "ctx", ",", "p", ")", "\n", "}", "\n", "key", ":=", "KeyForPublicKey", "(", "p", ")", "\n", "pkval", ",", "err", ":=", "r", ".", "GetValue", "(", "ctx", ",", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// get PublicKey from node.Data", "return", "ci", ".", "UnmarshalPublicKey", "(", "pkval", ")", "\n", "}" ]
774
all-775
[ "Append", "is", "a", "wrapper", "around", "gtk_combo_box_text_append", "()", "." ]
[ "func", "(", "v", "*", "ComboBoxText", ")", "Append", "(", "id", ",", "text", "string", ")", "{", "cid", ":=", "C", ".", "CString", "(", "id", ")", "\n", "ctext", ":=", "C", ".", "CString", "(", "text", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cid", ")", ")", "\n", "defer", "C", ".", "<mask>", "(", "unsafe", ".", "Pointer", "(", "ctext", ")", ")", "\n", "C", ".", "gtk_combo_box_text_append", "(", "v", ".", "native", "(", ")", ",", "(", "*", "C", ".", "gchar", ")", "(", "cid", ")", ",", "(", "*", "C", ".", "gchar", ")", "(", "ctext", ")", ")", "\n", "}" ]
775
all-776
[ "ValidEnum", "validates", "a", "proposed", "value", "for", "this", "enum", ".", "Implements", "the", "Enum", "interface", "for", "OfferEntryFlags" ]
[ "func", "(", "e", "OfferEntryFlags", ")", "ValidEnum", "(", "v", "int32", ")", "bool", "{", "_", ",", "ok", ":=", "offerEntryFlagsMap", "[", "v", "]", "\n", "return", "<mask>", "\n", "}" ]
776
all-777
[ "title", ":", "delete", "app", "router", "path", ":", "/", "app", "/", "{", "app", "}", "/", "routers", "/", "{", "router", "}", "method", ":", "DELETE", "produce", ":", "application", "/", "json", "responses", ":", "200", ":", "OK", "404", ":", "App", "or", "router", "not", "found" ]
[ "func", "removeAppRouter", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "t", "auth", ".", "Token", ")", "(", "err", "error", ")", "{", "appName", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "routerName", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "a", ",", "err", ":=", "getAppFromContext", "(", "appName", ",", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "allowed", ":=", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermAppUpdateRouterRemove", ",", "contextsForApp", "(", "&", "a", ")", "...", ",", ")", "\n", "if", "!", "allowed", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "evt", ",", "err", ":=", "<mask>", ".", "New", "(", "&", "event", ".", "Opts", "{", "Target", ":", "appTarget", "(", "appName", ")", ",", "Kind", ":", "permission", ".", "PermAppUpdateRouterRemove", ",", "Owner", ":", "t", ",", "CustomData", ":", "event", ".", "FormToCustomData", "(", "InputFields", "(", "r", ")", ")", ",", "Allowed", ":", "event", ".", "Allowed", "(", "permission", ".", "PermAppReadEvents", ",", "contextsForApp", "(", "&", "a", ")", "...", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "func", "(", ")", "{", "evt", ".", "Done", "(", "err", ")", "}", "(", ")", "\n", "err", "=", "a", ".", "RemoveRouter", "(", "routerName", ")", "\n", "if", "_", ",", "isNotFound", ":=", "err", ".", "(", "*", "router", ".", "ErrRouterNotFound", ")", ";", "isNotFound", "{", "return", "&", "errors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusNotFound", ",", "Message", ":", "err", ".", "Error", "(", ")", "}", "\n", "}", "\n", "return", "err", "\n", "}" ]
777
all-778
[ "Close", "forces", "closing", "all", "sockets", "that", "are", "alive", "whether", "they", "re", "currently", "in", "use", "or", "not", "." ]
[ "func", "(", "<mask>", "*", "mongoServer", ")", "Close", "(", ")", "{", "server", ".", "Lock", "(", ")", "\n", "server", ".", "closed", "=", "true", "\n", "liveSockets", ":=", "server", ".", "liveSockets", "\n", "unusedSockets", ":=", "server", ".", "unusedSockets", "\n", "server", ".", "liveSockets", "=", "nil", "\n", "server", ".", "unusedSockets", "=", "nil", "\n", "server", ".", "Unlock", "(", ")", "\n", "logf", "(", "\"", "\"", ",", "server", ".", "Addr", ",", "len", "(", "liveSockets", ")", ")", "\n", "for", "i", ",", "s", ":=", "range", "liveSockets", "{", "s", ".", "Close", "(", ")", "\n", "liveSockets", "[", "i", "]", "=", "nil", "\n", "}", "\n", "for", "i", ":=", "range", "unusedSockets", "{", "unusedSockets", "[", "i", "]", "=", "nil", "\n", "}", "\n", "}" ]
778
all-779
[ "PreCreateCheck", "allows", "for", "pre", "-", "create", "operations", "to", "make", "sure", "a", "driver", "is", "ready", "for", "creation" ]
[ "func", "(", "d", "*", "Driver", ")", "PreCreateCheck", "(", ")", "error", "{", "if", "d", ".", "UserDataFile", "!=", "\"", "\"", "{", "if", "_", ",", "err", ":=", "<mask>", ".", "Stat", "(", "d", ".", "UserDataFile", ")", ";", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "d", ".", "UserDataFile", ")", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
779
all-780
[ "NewDefaultStatusPolicy", "returns", "a", "status", "policy", "that", "assigns", "relative", "severity", "in", "accordance", "with", "conventional", "Nagios", "plugin", "return", "codes", ".", "Statuses", "associated", "with", "higher", "return", "codes", "are", "more", "severe", "." ]
[ "func", "NewDefaultStatusPolicy", "(", ")", "*", "statusPolicy", "{", "return", "&", "statusPolicy", "{", "<mask>", ":", "statusSeverity", "(", "OK", ")", ",", "WARNING", ":", "statusSeverity", "(", "WARNING", ")", ",", "CRITICAL", ":", "statusSeverity", "(", "CRITICAL", ")", ",", "UNKNOWN", ":", "statusSeverity", "(", "UNKNOWN", ")", ",", "}", "\n", "}" ]
780
all-781
[ "IntVar", "defines", "an", "int", "flag", "with", "specified", "name", "default", "value", "and", "usage", "string", ".", "The", "argument", "p", "points", "to", "an", "int", "variable", "in", "which", "to", "store", "the", "value", "of", "the", "flag", "." ]
[ "func", "IntVar", "(", "p", "*", "int", ",", "name", "string", ",", "value", "int", ",", "usage", "string", ")", "{", "EnvironmentFlags", ".", "IntVar", "(", "p", ",", "name", ",", "<mask>", ",", "usage", ")", "\n", "}" ]
781
all-782
[ "UnmarshalYAML", "implements", "the", "yaml", ".", "Unmarshaler", "interface", "." ]
[ "func", "(", "c", "*", "ServersetSDConfig", ")", "UnmarshalYAML", "(", "unmarshal", "func", "(", "interface", "{", "}", ")", "error", ")", "error", "{", "*", "c", "=", "DefaultServersetSDConfig", "\n", "type", "<mask>", "ServersetSDConfig", "\n", "err", ":=", "unmarshal", "(", "(", "*", "plain", ")", "(", "c", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "len", "(", "c", ".", "Servers", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "c", ".", "Paths", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "for", "_", ",", "path", ":=", "range", "c", ".", "Paths", "{", "if", "!", "strings", ".", "HasPrefix", "(", "path", ",", "\"", "\"", ")", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ",", "path", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
782
all-783
[ "Detach", "a", "slave", "from", "a", "bridge", "device", ".", "This", "is", "more", "backward", "-", "compatible", "than", "netlink", ".", "NetworkSetMaster", "and", "works", "on", "RHEL", "6", "." ]
[ "func", "DelFromBridge", "(", "iface", ",", "master", "*", "<mask>", ".", "Interface", ")", "error", "{", "return", "ifIoctBridge", "(", "iface", ",", "master", ",", "SIOC_BRDELIF", ")", "\n", "}" ]
783
all-784
[ "processRPC", "is", "called", "to", "handle", "an", "incoming", "RPC", "request", ".", "This", "must", "only", "be", "called", "from", "the", "main", "thread", "." ]
[ "func", "(", "r", "*", "Raft", ")", "processRPC", "(", "rpc", "RPC", ")", "{", "if", "err", ":=", "r", ".", "checkRPCHeader", "(", "rpc", ")", ";", "err", "!=", "nil", "{", "rpc", ".", "Respond", "(", "nil", ",", "err", ")", "\n", "return", "\n", "}", "\n\n", "switch", "cmd", ":=", "rpc", ".", "Command", ".", "(", "type", ")", "{", "case", "*", "AppendEntriesRequest", ":", "r", ".", "appendEntries", "(", "rpc", ",", "cmd", ")", "\n", "case", "*", "RequestVoteRequest", ":", "r", ".", "requestVote", "(", "rpc", ",", "cmd", ")", "\n", "<mask>", "*", "InstallSnapshotRequest", ":", "r", ".", "installSnapshot", "(", "rpc", ",", "cmd", ")", "\n", "default", ":", "r", ".", "logger", ".", "Error", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "rpc", ".", "Command", ")", ")", "\n", "rpc", ".", "Respond", "(", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}" ]
784
all-785
[ "Root", "returns", "the", "portion", "of", "an", "import", "path", "that", "corresponds", "to", "the", "root", "directory", "of", "the", "repository", "containing", "the", "given", "import", "path", ".", "For", "example", "given", "golang", ".", "org", "/", "x", "/", "tools", "/", "go", "/", "loader", "this", "will", "return", "golang", ".", "org", "/", "x", "/", "tools", ".", "The", "workspace", "name", "of", "the", "repository", "is", "also", "returned", ".", "This", "may", "be", "a", "custom", "name", "set", "in", "WORKSPACE", "or", "it", "may", "be", "a", "generated", "name", "based", "on", "the", "root", "path", "." ]
[ "func", "(", "r", "*", "RemoteCache", ")", "Root", "(", "importPath", "string", ")", "(", "root", ",", "name", "string", ",", "err", "error", ")", "{", "// Try prefixes of the import path in the cache, but don't actually go out", "// to vcs yet. We do this before handling known special cases because", "// the cache is pre-populated with repository rules, and we want to use their", "// names if we can.", "prefix", ":=", "importPath", "\n", "for", "{", "v", ",", "ok", ",", "err", ":=", "r", ".", "root", ".", "get", "(", "prefix", ")", "\n", "if", "ok", "{", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "value", ":=", "v", ".", "(", "rootValue", ")", "\n", "return", "value", ".", "root", ",", "value", ".", "name", ",", "nil", "\n", "}", "\n\n", "prefix", "=", "path", ".", "Dir", "(", "prefix", ")", "\n", "if", "prefix", "==", "\"", "\"", "||", "prefix", "==", "\"", "\"", "{", "break", "\n", "}", "\n", "}", "\n\n", "// Try known prefixes.", "for", "_", ",", "p", ":=", "range", "knownPrefixes", "{", "if", "pathtools", ".", "HasPrefix", "(", "importPath", ",", "p", ".", "prefix", ")", "{", "rest", ":=", "pathtools", ".", "TrimPrefix", "(", "importPath", ",", "p", ".", "prefix", ")", "\n", "var", "components", "[", "]", "string", "\n", "if", "rest", "!=", "\"", "\"", "{", "components", "=", "strings", ".", "Split", "(", "rest", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "components", ")", "<", "p", ".", "missing", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "importPath", ",", "p", ".", "prefix", ")", "\n", "}", "\n", "root", "=", "p", ".", "prefix", "\n", "for", "_", ",", "c", ":=", "range", "components", "[", ":", "p", ".", "missing", "]", "{", "root", "=", "path", ".", "Join", "(", "root", ",", "c", ")", "\n", "}", "\n", "name", "=", "label", ".", "ImportPathToBazelRepoName", "(", "root", ")", "\n", "return", "root", ",", "name", ",", "nil", "\n", "}", "\n", "}", "\n\n", "// gopkg.in is special, and might have either one or two levels of", "// missing paths. See http://labix.org/gopkg.in for URL patterns.", "if", "match", ":=", "gopkginPattern", ".", "FindStringSubmatch", "(", "importPath", ")", ";", "len", "(", "<mask>", ")", ">", "0", "{", "root", "=", "match", "[", "1", "]", "\n", "name", "=", "label", ".", "ImportPathToBazelRepoName", "(", "root", ")", "\n", "return", "root", ",", "name", ",", "nil", "\n", "}", "\n\n", "// Find the prefix using vcs and cache the result.", "v", ",", "err", ":=", "r", ".", "root", ".", "ensure", "(", "importPath", ",", "func", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "res", ",", "err", ":=", "r", ".", "RepoRootForImportPath", "(", "importPath", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "rootValue", "{", "res", ".", "Root", ",", "label", ".", "ImportPathToBazelRepoName", "(", "res", ".", "Root", ")", "}", ",", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "value", ":=", "v", ".", "(", "rootValue", ")", "\n", "return", "value", ".", "root", ",", "value", ".", "name", ",", "nil", "\n", "}" ]
785
all-786
[ "resourceVSphereComputeClusterVMGroupObjects", "handles", "the", "fetching", "of", "the", "cluster", "and", "group", "name", "depending", "on", "what", "attributes", "are", "available", ":", "*", "If", "the", "resource", "ID", "is", "available", "the", "data", "is", "derived", "from", "the", "ID", ".", "*", "If", "not", "it", "s", "derived", "from", "the", "compute_cluster_id", "and", "name", "attributes", "." ]
[ "func", "resourceVSphereComputeClusterVMGroupObjects", "(", "d", "*", "schema", ".", "ResourceData", ",", "meta", "<mask>", "{", "}", ",", ")", "(", "*", "object", ".", "ClusterComputeResource", ",", "string", ",", "error", ")", "{", "if", "d", ".", "Id", "(", ")", "!=", "\"", "\"", "{", "return", "resourceVSphereComputeClusterVMGroupObjectsFromID", "(", "d", ",", "meta", ")", "\n", "}", "\n", "return", "resourceVSphereComputeClusterVMGroupObjectsFromAttributes", "(", "d", ",", "meta", ")", "\n", "}" ]
786
all-787
[ "Write", "serializes", "the", "frame", "to", "the", "given", "buffered", "output", "satisfies", "the", "Frame", "interface", "." ]
[ "func", "(", "f", "UnknownFrame", ")", "Write", "(", "w", "*", "bufio", ".", "Writer", ")", "(", "err", "error", ")", "{", "if", "err", "=", "writeFrameHeader", "(", "w", ",", "f", ".", "<mask>", ",", "len", "(", "f", ".", "Data", ")", ")", ";", "err", "!=", "nil", "{", "err", "=", "errors", ".", "WithMessage", "(", "err", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "if", "_", ",", "err", "=", "w", ".", "Write", "(", "f", ".", "Data", ")", ";", "err", "!=", "nil", "{", "err", "=", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n\n", "return", "\n", "}" ]
787
all-788
[ "HasClientEmail", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "i", "*", "IntegrationGCPDeleteRequest", ")", "HasClientEmail", "(", ")", "bool", "{", "if", "i", "!=", "nil", "&&", "i", ".", "ClientEmail", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
788
all-789
[ "GetTypeOk", "returns", "a", "tuple", "with", "the", "Type", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "a", "*", "AlertGraphDefinition", ")", "GetTypeOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "a", "==", "nil", "||", "a", ".", "Type", "==", "nil", "{", "return", "\"", "\"", ",", "false", "\n", "}", "\n", "return", "*", "a", ".", "<mask>", ",", "true", "\n", "}" ]
789
all-790
[ "cephRBDSnapshotProtect", "protects", "a", "given", "snapshot", "from", "being", "deleted", "This", "is", "a", "precondition", "to", "be", "able", "to", "create", "RBD", "clones", "from", "a", "given", "snapshot", "." ]
[ "func", "cephRBDSnapshotProtect", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeName", "string", ",", "volumeType", "string", ",", "snapshotName", "string", ",", "userName", "string", ")", "error", "{", "_", ",", "err", ":=", "shared", ".", "RunCommand", "(", "\"", "\"", ",", "\"", "\"", ",", "userName", ",", "\"", "\"", ",", "clusterName", ",", "\"", "\"", ",", "poolName", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "snapshotName", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "volumeType", ",", "volumeName", ")", ")", "\n", "if", "err", "!=", "nil", "{", "runError", ",", "ok", ":=", "err", ".", "(", "shared", ".", "RunError", ")", "\n", "if", "ok", "{", "exitError", ",", "ok", ":=", "runError", ".", "Err", ".", "(", "*", "exec", ".", "ExitError", ")", "\n", "if", "<mask>", "{", "waitStatus", ":=", "exitError", ".", "Sys", "(", ")", ".", "(", "syscall", ".", "WaitStatus", ")", "\n", "if", "waitStatus", ".", "ExitStatus", "(", ")", "==", "16", "{", "// EBUSY (snapshot already protected)", "return", "nil", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
790
all-791
[ "notify", "function", "accepts", "an", "event", "and", "notify", "to", "the", "watchers", "." ]
[ "func", "(", "wh", "*", "watcherHub", ")", "notify", "(", "e", "*", "Event", ")", "{", "e", "=", "wh", ".", "EventHistory", ".", "addEvent", "(", "e", ")", "// add event into the eventHistory", "\n\n", "segments", ":=", "strings", ".", "Split", "(", "e", ".", "Node", ".", "Key", ",", "\"", "\"", ")", "\n\n", "currPath", ":=", "\"", "\"", "\n\n", "// walk through all the segments of the path and notify the watchers", "// if the path is \"/foo/bar\", it will notify watchers with path \"/\",", "// \"/foo\" and \"/foo/bar\"", "for", "_", ",", "segment", ":=", "<mask>", "segments", "{", "currPath", "=", "path", ".", "Join", "(", "currPath", ",", "segment", ")", "\n", "// notify the watchers who interests in the changes of current path", "wh", ".", "notifyWatchers", "(", "e", ",", "currPath", ",", "false", ")", "\n", "}", "\n", "}" ]
791
all-792
[ "Embed", "svg", "font", "definition", "to", "svg", "tree", "itself", "Or", "update", "existing", "if", "already", "exists", "for", "curent", "font", "data" ]
[ "func", "(", "gc", "*", "GraphicContext", ")", "embedSvgFont", "(", "text", "string", ")", "*", "Font", "{", "fontName", ":=", "gc", ".", "Current", ".", "FontData", ".", "Name", "\n", "gc", ".", "loadCurrentFont", "(", ")", "\n\n", "// find or create font Element", "svgFont", ":=", "(", "*", "Font", ")", "(", "nil", ")", "\n", "for", "_", ",", "font", ":=", "range", "gc", ".", "svg", ".", "Fonts", "{", "if", "font", ".", "Name", "==", "fontName", "{", "svgFont", "=", "font", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "svgFont", "==", "nil", "{", "// create new", "svgFont", "=", "&", "Font", "{", "}", "\n", "// and attach", "gc", ".", "svg", ".", "Fonts", "=", "append", "(", "gc", ".", "svg", ".", "Fonts", ",", "svgFont", ")", "\n", "}", "\n\n", "// fill with glyphs", "gc", ".", "Save", "(", ")", "\n", "defer", "gc", ".", "Restore", "(", ")", "\n", "gc", ".", "SetFontSize", "(", "2048", ")", "\n", "defer", "gc", ".", "SetDPI", "(", "gc", ".", "GetDPI", "(", ")", ")", "\n", "gc", ".", "SetDPI", "(", "92", ")", "\n", "filling", ":", "for", "_", ",", "rune", ":=", "range", "text", "{", "for", "_", ",", "g", ":=", "range", "svgFont", ".", "Glyphs", "{", "if", "g", ".", "Rune", "==", "Rune", "(", "rune", ")", "{", "continue", "filling", "\n", "}", "\n", "}", "\n", "glyph", ":=", "gc", ".", "glyphCache", ".", "Fetch", "(", "gc", ",", "gc", ".", "GetFontName", "(", ")", ",", "rune", ")", "\n", "// glyphCache.Load indirectly calls CreateStringPath for single rune string", "glypPath", ":=", "glyph", ".", "Path", ".", "VerticalFlip", "(", ")", "// svg font glyphs have oposite y axe", "\n", "svgFont", ".", "Glyphs", "=", "append", "(", "svgFont", ".", "Glyphs", ",", "&", "Glyph", "{", "Rune", ":", "Rune", "(", "rune", ")", ",", "Desc", ":", "toSvgPathDesc", "(", "glypPath", ")", ",", "HorizAdvX", ":", "glyph", ".", "Width", ",", "}", ")", "\n", "}", "\n\n", "// set attrs", "svgFont", ".", "Id", "=", "\"", "\"", "+", "strconv", ".", "Itoa", "(", "len", "(", "gc", ".", "svg", ".", "Fonts", ")", ")", "\n", "svgFont", ".", "<mask>", "=", "fontName", "\n\n", "// TODO use css @font-face with id instead of this", "svgFont", ".", "Face", "=", "&", "Face", "{", "Family", ":", "fontName", ",", "Units", ":", "2048", ",", "HorizAdvX", ":", "2048", "}", "\n", "return", "svgFont", "\n", "}" ]
792
all-793
[ "GetLayout", "returns", "the", "Layout", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "b", "*", "BoardWidget", ")", "GetLayout", "(", ")", "WidgetLayout", "{", "if", "b", "==", "nil", "||", "b", ".", "Layout", "==", "nil", "{", "return", "WidgetLayout", "{", "}", "\n", "}", "\n", "<mask>", "*", "b", ".", "Layout", "\n", "}" ]
793
all-794
[ "GetNameOk", "returns", "a", "tuple", "with", "the", "Name", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "g", "*", "GroupData", ")", "GetNameOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "g", "==", "nil", "||", "g", ".", "Name", "==", "nil", "{", "return", "\"", "\"", ",", "false", "\n", "}", "\n", "return", "*", "g", ".", "<mask>", ",", "true", "\n", "}" ]
794
all-795
[ "WithContext", "adds", "the", "context", "to", "the", "update", "Vm", "with", "state", "params" ]
[ "func", "(", "o", "*", "UpdateVMWithStateParams", ")", "WithContext", "(", "ctx", "<mask>", ".", "Context", ")", "*", "UpdateVMWithStateParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
795
all-796
[ "HasModifiedAt", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "s", "*", "SyntheticsTest", ")", "HasModifiedAt", "(", ")", "bool", "{", "if", "s", "!=", "nil", "&&", "s", ".", "ModifiedAt", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
796
all-797
[ "GetLastResolvedTs", "returns", "the", "LastResolvedTs", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "g", "*", "GroupData", ")", "GetLastResolvedTs", "(", ")", "int", "{", "if", "g", "==", "nil", "||", "g", ".", "LastResolvedTs", "==", "nil", "{", "<mask>", "0", "\n", "}", "\n", "return", "*", "g", ".", "LastResolvedTs", "\n", "}" ]
797
all-798
[ "Convert", "param", "string", "like", "param1", "=", "value1", ";", "param2", "=", "value2", "to", "mesos", ".", "Labels" ]
[ "func", "StringToLabels", "(", "s", "string", ")", "*", "mesos", ".", "Labels", "{", "labels", ":=", "&", "mesos", ".", "Labels", "{", "Labels", ":", "make", "(", "[", "]", "*", "mesos", ".", "Label", ",", "0", ")", "}", "\n", "if", "s", "==", "\"", "\"", "{", "return", "labels", "\n", "}", "\n", "pairs", ":=", "strings", ".", "Split", "(", "s", ",", "\"", "\"", ")", "\n", "for", "_", ",", "pair", ":=", "range", "pairs", "{", "kv", ":=", "strings", ".", "Split", "(", "pair", ",", "\"", "\"", ")", "\n", "key", ",", "value", ":=", "kv", "[", "0", "]", ",", "kv", "[", "1", "]", "\n", "label", ":=", "&", "mesos", ".", "Label", "{", "Key", ":", "proto", ".", "String", "(", "key", ")", ",", "Value", ":", "proto", ".", "<mask>", "(", "value", ")", "}", "\n", "labels", ".", "Labels", "=", "append", "(", "labels", ".", "Labels", ",", "label", ")", "\n", "}", "\n", "return", "labels", "\n", "}" ]
798
all-799
[ "Log", "implements", "the", "Backend", "interface", "." ]
[ "func", "(", "b", "*", "LogBackend", ")", "Log", "(", "level", "Level", ",", "calldepth", "int", ",", "rec", "*", "Record", ")", "error", "{", "if", "b", ".", "Color", "{", "col", ":=", "colors", "[", "level", "]", "\n", "if", "len", "(", "b", ".", "ColorConfig", ")", ">", "int", "(", "level", ")", "&&", "b", ".", "ColorConfig", "[", "level", "]", "!=", "\"", "\"", "{", "col", "=", "b", ".", "ColorConfig", "[", "level", "]", "\n", "}", "\n\n", "buf", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "buf", ".", "Write", "(", "[", "]", "byte", "(", "col", ")", ")", "\n", "buf", ".", "Write", "(", "[", "]", "byte", "(", "rec", ".", "Formatted", "(", "calldepth", "+", "1", ")", ")", ")", "\n", "buf", ".", "Write", "(", "[", "]", "<mask>", "(", "\"", "\\033", "\"", ")", ")", "\n", "// For some reason, the Go logger arbitrarily decided \"2\" was the correct", "// call depth...", "return", "b", ".", "Logger", ".", "Output", "(", "calldepth", "+", "2", ",", "buf", ".", "String", "(", ")", ")", "\n", "}", "\n\n", "return", "b", ".", "Logger", ".", "Output", "(", "calldepth", "+", "2", ",", "rec", ".", "Formatted", "(", "calldepth", "+", "1", ")", ")", "\n", "}" ]
799
all-800
[ "Returns", "an", "slice", "of", "ints", "or", "the", "specified", "slice", "if", "the", "key", "doesn", "t", "exist", "or", "isn", "t", "a", "valid", "[]", "int", ".", "Some", "conversion", "is", "done", "to", "handle", "the", "fact", "that", "JSON", "ints", "are", "represented", "as", "floats", "." ]
[ "func", "(", "t", "Typed", ")", "Ints64Or", "(", "key", "string", ",", "d", "[", "]", "int64", ")", "[", "]", "int64", "{", "n", ",", "<mask>", ":=", "t", ".", "Ints64If", "(", "key", ")", "\n", "if", "ok", "{", "return", "n", "\n", "}", "\n", "return", "d", "\n", "}" ]