id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
8,800
all-8801
[ "SelinuxEnabled", "returns", "whether", "selinux", "is", "currently", "enabled", "." ]
[ "func", "SelinuxEnabled", "(", ")", "bool", "{", "if", "selinuxEnabledChecked", "{", "return", "selinuxEnabled", "\n", "}", "\n", "selinuxEnabledChecked", "=", "true", "\n", "if", "fs", ":=", "getSelinuxMountPoint", "(", ")", ";", "<mask>", "!=", "\"", "\"", "{", "if", "con", ",", "_", ":=", "Getcon", "(", ")", ";", "con", "!=", "\"", "\"", "{", "selinuxEnabled", "=", "true", "\n", "}", "\n", "}", "\n", "return", "selinuxEnabled", "\n", "}" ]
8,801
all-8802
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "SetStyleSheetTextReturns", ")", "MarshalJSON", "(", ")", "(", "[", "]", "<mask>", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss13", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
8,802
all-8803
[ "Value", "converts", "a", "value", "to", "a", "database", "driver", "value" ]
[ "func", "(", "r", "Password", ")", "Value", "(", ")", "(", "driver", ".", "<mask>", ",", "error", ")", "{", "return", "driver", ".", "Value", "(", "string", "(", "r", ")", ")", ",", "nil", "\n", "}" ]
8,803
all-8804
[ "validateCgroupSpec", "checks", "the", "cgroup", "spec", "for", "valid", "path", "and", "specifications" ]
[ "func", "validateCgroupSpec", "(", "cgroupSpec", "*", "Spec", ")", "error", "{", "if", "cgroupSpec", "==", "nil", "{", "return", "<mask>", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "cgroupSpec", ".", "Root", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Validate the linux resource specs", "if", "cgroupSpec", ".", "Specs", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
8,804
all-8805
[ "Handle", "all", "methods", "with", "a", "given", "pattern" ]
[ "func", "(", "r", "*", "Router", ")", "Handle", "(", "pattern", "string", ",", "handlers", "...", "interface", "{", "}", ")", "*", "Router", "{", "c", ":=", "r", ".", "pattern", "(", "pattern", ")", "\n", "clone", ":=", "r", ".", "clone", "(", "c", ")", "\n", "clone", ".", "<mask>", "(", "handlers", ")", "\n", "return", "clone", "\n", "}" ]
8,805
all-8806
[ "NewClient", "instantiates", "a", "client", "with", "provided", "values", ".", "url", ":", "the", "jenkins", "master", "to", "connect", "to", ".", "dryRun", ":", "mutating", "calls", "such", "as", "starting", "/", "aborting", "a", "build", "will", "be", "skipped", ".", "tlsConfig", ":", "configures", "client", "transport", "if", "set", "may", "be", "nil", ".", "authConfig", ":", "configures", "the", "client", "to", "connect", "to", "Jenkins", "via", "basic", "auth", "/", "bearer", "token", "and", "optionally", "enables", "csrf", "protection", "logger", ":", "creates", "a", "standard", "logger", "if", "nil", ".", "metrics", ":", "gathers", "prometheus", "metrics", "for", "the", "Jenkins", "client", "if", "set", "." ]
[ "func", "NewClient", "(", "url", "string", ",", "dryRun", "bool", ",", "tlsConfig", "*", "tls", ".", "Config", ",", "authConfig", "*", "AuthConfig", ",", "logger", "*", "logrus", ".", "Entry", ",", "metrics", "*", "ClientMetrics", ",", ")", "(", "*", "Client", ",", "error", ")", "{", "if", "logger", "==", "nil", "{", "logger", "=", "logrus", ".", "NewEntry", "(", "logrus", ".", "StandardLogger", "(", ")", ")", "\n", "}", "\n", "c", ":=", "&", "<mask>", "{", "logger", ":", "logger", ".", "WithField", "(", "\"", "\"", ",", "\"", "\"", ")", ",", "dryRun", ":", "dryRun", ",", "baseURL", ":", "url", ",", "authConfig", ":", "authConfig", ",", "client", ":", "&", "http", ".", "Client", "{", "Timeout", ":", "30", "*", "time", ".", "Second", ",", "}", ",", "metrics", ":", "metrics", ",", "}", "\n", "if", "tlsConfig", "!=", "nil", "{", "c", ".", "client", ".", "Transport", "=", "&", "http", ".", "Transport", "{", "TLSClientConfig", ":", "tlsConfig", "}", "\n", "}", "\n", "if", "c", ".", "authConfig", ".", "CSRFProtect", "{", "if", "err", ":=", "c", ".", "CrumbRequest", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n", "return", "c", ",", "nil", "\n", "}" ]
8,806
all-8807
[ "buildNewActions", "builds", "a", "brand", "new", "actions", "/", "foo", ".", "go", "file", "and", "files", "it", "with", "actions" ]
[ "func", "buildNewActions", "(", "fn", "string", ",", "pres", "*", "presenter", ")", "genny", ".", "RunFn", "{", "return", "func", "(", "r", "*", "genny", ".", "Runner", ")", "error", "{", "for", "_", ",", "a", ":=", "range", "pres", ".", "<mask>", ".", "Actions", "{", "pres", ".", "Actions", "=", "append", "(", "pres", ".", "Actions", ",", "name", ".", "New", "(", "a", ")", ")", "\n", "}", "\n\n", "h", ",", "err", ":=", "box", ".", "FindString", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "a", ",", "err", ":=", "box", ".", "FindString", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "f", ":=", "genny", ".", "NewFileS", "(", "fn", "+", "\"", "\"", ",", "h", "+", "a", ")", "\n\n", "f", ",", "err", "=", "transform", "(", "pres", ",", "f", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "r", ".", "File", "(", "f", ")", "\n", "}", "\n", "}" ]
8,807
all-8808
[ "/", "*", "ReflectExportedStructFields", "returns", "a", "map", "from", "exported", "struct", "field", "names", "to", "values", "inlining", "anonymous", "sub", "-", "structs", "so", "that", "their", "field", "names", "are", "available", "at", "the", "base", "level", ".", "Example", ":", "type", "A", "struct", "{", "X", "int", "}", "type", "B", "Struct", "{", "A", "Y", "int", "}", "Yields", "X", "and", "Y", "instead", "of", "A", "and", "Y", ":", "ReflectExportedStructFields", "(", "reflect", ".", "ValueOf", "(", "B", "{}", "))" ]
[ "func", "ReflectExportedStructFields", "(", "v", "reflect", ".", "Value", ")", "map", "[", "string", "]", "reflect", ".", "Value", "{", "t", ":=", "v", ".", "Type", "(", ")", "\n", "if", "t", ".", "Kind", "(", ")", "!=", "reflect", ".", "Struct", "{", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "t", ")", ")", "\n", "}", "\n", "result", ":=", "make", "(", "map", "[", "string", "]", "reflect", ".", "Value", ")", "\n", "reflectExportedStructFields", "(", "v", ",", "t", ",", "result", ")", "\n", "return", "<mask>", "\n", "}" ]
8,808
all-8809
[ "Error", "returns", "a", "description", "of", "the", "error", "along", "with", "its", "code", "and", "operation", "implementing", "Go", "s", "error", "interface", "." ]
[ "func", "(", "e", "*", "Error", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "Text", ",", "e", ".", "Code", ",", "e", ".", "<mask>", ")", "\n", "}" ]
8,809
all-8810
[ "IsTLSCert", "if", "block", "is", "one", "or", "more", "TLS", "certificates", "then", "function", "returns", "true" ]
[ "func", "IsTLSCert", "(", "block", "string", ")", "bool", "{", "var", "cert", "tls", ".", "Certificate", "\n\n", "pemBlock", ":=", "[", "]", "byte", "(", "block", ")", "\n\n", "for", "{", "var", "derBlock", "*", "pem", ".", "Block", "\n", "derBlock", ",", "pemBlock", "=", "pem", ".", "Decode", "(", "pemBlock", ")", "\n", "if", "derBlock", "==", "nil", "{", "break", "\n", "}", "\n\n", "if", "derBlock", ".", "Type", "==", "certificate", "{", "cert", ".", "Certificate", "=", "append", "(", "<mask>", ".", "Certificate", ",", "derBlock", ".", "Bytes", ")", "\n", "}", "\n", "}", "\n\n", "if", "len", "(", "cert", ".", "Certificate", ")", "==", "0", "{", "return", "false", "\n", "}", "\n\n", "return", "true", "\n", "}" ]
8,810
all-8811
[ "GenerateSSHKey", "generates", "SSH", "keypair", "based", "on", "path", "of", "the", "private", "key", "The", "public", "key", "would", "be", "generated", "to", "the", "same", "path", "with", ".", "pub", "added" ]
[ "func", "GenerateSSHKey", "(", "<mask>", "string", ")", "error", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", ";", "err", "!=", "nil", "{", "if", "!", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "kp", ",", "err", ":=", "NewKeyPair", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "if", "err", ":=", "kp", ".", "WriteToFile", "(", "path", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "path", ")", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
8,811
all-8812
[ "Stdin", "sets", "the", "process", "s", "standard", "input", "." ]
[ "func", "(", "g", "*", "gitCmd", ")", "Stdin", "(", "stdin", "<mask>", ".", "Reader", ")", "{", "g", ".", "Cmd", ".", "Stdin", "=", "stdin", "\n", "}" ]
8,812
all-8813
[ "NewStdFormatter", "crete", "a", "new", "formatter", "." ]
[ "func", "NewStdFormatter", "(", "delim", ",", "tmpl", "string", ",", "entry", "Entry", ",", "values", "map", "[", "string", "]", "interface", "{", "}", ",", "timeformat", "string", ")", "(", "Formatter", ",", "error", ")", "{", "if", "delim", "==", "\"", "\"", "{", "return", "nil", ",", "e", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "tmpl", "==", "\"", "\"", "{", "return", "nil", ",", "e", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "entry", "==", "nil", "{", "return", "nil", ",", "e", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "values", "==", "nil", "{", "return", "nil", ",", "e", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "timeformat", "==", "\"", "\"", "{", "timeformat", "=", "TimeDateFormat", "\n", "}", "\n", "return", "&", "StdFormatter", "{", "Delim", ":", "[", "]", "byte", "(", "delim", ")", ",", "Tmpl", ":", "[", "]", "byte", "(", "tmpl", ")", ",", "E", ":", "<mask>", ",", "Map", ":", "values", ",", "Idx", ":", "mkindex", "(", "entry", ")", ",", "TimeFormat", ":", "timeformat", ",", "}", ",", "nil", "\n", "}" ]
8,813
all-8814
[ "ContainerEnvelopes", "connects", "to", "trafficcontroller", "via", "its", "containermetrics", "http", "(", "s", ")", "endpoint", "and", "returns", "the", "most", "recent", "dropsonde", "envelopes", "for", "an", "app", "." ]
[ "func", "(", "c", "*", "Consumer", ")", "ContainerEnvelopes", "(", "appGuid", ",", "authToken", "string", ")", "(", "[", "]", "*", "<mask>", ".", "Envelope", ",", "error", ")", "{", "envelopes", ",", "err", ":=", "c", ".", "readTC", "(", "appGuid", ",", "authToken", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "for", "_", ",", "env", ":=", "range", "envelopes", "{", "if", "env", ".", "GetEventType", "(", ")", "==", "events", ".", "Envelope_LogMessage", "{", "return", "nil", ",", "errors", ".", "New", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "env", ".", "GetLogMessage", "(", ")", ".", "GetMessage", "(", ")", ")", ")", "\n", "}", "\n", "}", "\n", "return", "envelopes", ",", "nil", "\n", "}" ]
8,814
all-8815
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "FulfillRequestParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoFetch6", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "<mask>", "(", ")", "\n", "}" ]
8,815
all-8816
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "RunScriptReturns", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoRuntime5", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
8,816
all-8817
[ "Kinds", "returns", "the", "names", "of", "all", "the", "kinds", "in", "the", "current", "namespace", "." ]
[ "func", "Kinds", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "string", ",", "error", ")", "{", "// TODO(djd): Support range queries.", "q", ":=", "NewQuery", "(", "kindKind", ")", ".", "KeysOnly", "(", ")", "\n", "keys", ",", "err", ":=", "q", ".", "GetAll", "(", "ctx", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "keyNames", "(", "<mask>", ")", ",", "nil", "\n", "}" ]
8,817
all-8818
[ "call", "parses", "a", "function", "call", ".", "<func_name", ">", "(", "[", "<arg_expr", ">", "...", "]", ")" ]
[ "func", "(", "p", "*", "parser", ")", "call", "(", "name", "string", ")", "*", "Call", "{", "const", "ctx", "=", "\"", "\"", "\n\n", "fn", ",", "exist", ":=", "getFunction", "(", "name", ")", "\n", "if", "!", "exist", "{", "p", ".", "errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n\n", "p", ".", "expect", "(", "ItemLeftParen", ",", "ctx", ")", "\n", "// Might be call without args.", "if", "p", ".", "peek", "(", ")", ".", "typ", "==", "ItemRightParen", "{", "p", ".", "next", "(", ")", "// Consume.", "\n", "return", "&", "Call", "{", "fn", ",", "nil", "}", "\n", "}", "\n\n", "var", "args", "[", "]", "Expr", "\n", "for", "{", "e", ":=", "p", ".", "expr", "(", ")", "\n", "args", "=", "append", "(", "args", ",", "e", ")", "\n\n", "// Terminate if no more arguments.", "if", "p", ".", "peek", "(", ")", ".", "typ", "!=", "ItemComma", "{", "break", "\n", "}", "\n", "p", ".", "<mask>", "(", ")", "\n", "}", "\n\n", "// Call must be closed.", "p", ".", "expect", "(", "ItemRightParen", ",", "ctx", ")", "\n\n", "return", "&", "Call", "{", "Func", ":", "fn", ",", "Args", ":", "args", "}", "\n", "}" ]
8,818
all-8819
[ "HTTPHandler", "serves", "new", "connections", "with", "events", "for", "a", "given", "stream", "..." ]
[ "func", "(", "s", "*", "Server", ")", "HTTPHandler", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "flusher", ",", "err", ":=", "w", ".", "(", "http", ".", "Flusher", ")", "\n", "if", "!", "err", "{", "http", ".", "Error", "(", "w", ",", "\"", "\"", ",", "http", ".", "StatusInternalServerError", ")", "\n", "return", "\n", "}", "\n\n", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "// Get the StreamID from the URL", "streamID", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "streamID", "==", "\"", "\"", "{", "http", ".", "Error", "(", "w", ",", "\"", "\"", ",", "http", ".", "StatusInternalServerError", ")", "\n", "return", "\n", "}", "\n\n", "stream", ":=", "s", ".", "getStream", "(", "streamID", ")", "\n\n", "if", "stream", "==", "nil", "&&", "!", "s", ".", "AutoStream", "{", "http", ".", "Error", "(", "w", ",", "\"", "\"", ",", "http", ".", "StatusInternalServerError", ")", "\n", "return", "\n", "}", "else", "if", "stream", "==", "nil", "&&", "s", ".", "AutoStream", "{", "stream", "=", "s", ".", "CreateStream", "(", "streamID", ")", "\n", "}", "\n\n", "eventid", ":=", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "eventid", "==", "\"", "\"", "{", "eventid", "=", "\"", "\"", "\n", "}", "\n\n", "// Create the stream subscriber", "<mask>", ":=", "stream", ".", "addSubscriber", "(", "eventid", ")", "\n", "defer", "sub", ".", "close", "(", ")", "\n\n", "notify", ":=", "w", ".", "(", "http", ".", "CloseNotifier", ")", ".", "CloseNotify", "(", ")", "\n", "go", "func", "(", ")", "{", "<-", "notify", "\n", "sub", ".", "close", "(", ")", "\n", "}", "(", ")", "\n\n", "// Push events to client", "for", "{", "select", "{", "case", "ev", ",", "ok", ":=", "<-", "sub", ".", "connection", ":", "if", "!", "ok", "{", "return", "\n", "}", "\n\n", "// If the data buffer is an empty string abort.", "if", "len", "(", "ev", ".", "Data", ")", "==", "0", "{", "break", "\n", "}", "\n\n", "// if the event has expired, dont send it", "if", "s", ".", "EventTTL", "!=", "0", "&&", "time", ".", "Now", "(", ")", ".", "After", "(", "ev", ".", "timestamp", ".", "Add", "(", "s", ".", "EventTTL", ")", ")", "{", "continue", "\n", "}", "\n\n", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\n", "\"", ",", "ev", ".", "ID", ")", "\n", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\n", "\"", ",", "ev", ".", "Data", ")", "\n", "if", "len", "(", "ev", ".", "Event", ")", ">", "0", "{", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\n", "\"", ",", "ev", ".", "Event", ")", "\n", "}", "\n", "if", "len", "(", "ev", ".", "Retry", ")", ">", "0", "{", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\\n", "\"", ",", "ev", ".", "Retry", ")", "\n", "}", "\n", "fmt", ".", "Fprint", "(", "w", ",", "\"", "\\n", "\"", ")", "\n", "flusher", ".", "Flush", "(", ")", "\n", "}", "\n", "}", "\n", "}" ]
8,819
all-8820
[ "GetSizing", "returns", "the", "Sizing", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "i", "*", "ImageDefinition", ")", "GetSizing", "(", ")", "string", "{", "if", "i", "==", "nil", "||", "i", ".", "Sizing", "==", "nil", "{", "<mask>", "\"", "\"", "\n", "}", "\n", "return", "*", "i", ".", "Sizing", "\n", "}" ]
8,820
all-8821
[ "GetEd25519", "retrieves", "the", "Ed25519", "value", "from", "the", "union", "returning", "ok", "if", "the", "union", "s", "switch", "indicated", "the", "value", "is", "valid", "." ]
[ "func", "(", "u", "AccountId", ")", "GetEd25519", "(", ")", "(", "result", "Uint256", ",", "<mask>", "bool", ")", "{", "return", "PublicKey", "(", "u", ")", ".", "GetEd25519", "(", ")", "\n", "}" ]
8,821
all-8822
[ "Step", "2b", "is", "the", "removal", "of", "Verb", "suffixes", "in", "RV", "that", "do", "not", "begin", "with", "i", "." ]
[ "func", "step2b", "(", "word", "*", "snowballword", ".", "SnowballWord", ")", "bool", "{", "// Search for the longest among the following suffixes in RV.", "//", "suffix", ",", "suffixRunes", ":=", "word", ".", "FirstSuffixIn", "(", "word", ".", "RVstart", ",", "len", "(", "word", ".", "RS", ")", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", ",", " ", "e", ",", " ", "e", ",", " ", "e", ",", " ", "e", ",", " ", "e", ",", "", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", ",", " ", "â", " ", "\"", "o", "", "", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", ",", "", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", ",", " ", "é", " ", "\"", "t", "", "", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", ",", " ", "a", ",", "", ")", "\n\n", "switch", "suffix", "{", "case", "\"", "\"", ":", "// Delete if in R2", "suffixLen", ":=", "len", "(", "suffixRunes", ")", "\n", "if", "word", ".", "FitsInR2", "(", "suffixLen", ")", "{", "word", ".", "RemoveLastNRunes", "(", "suffixLen", ")", "\n", "return", "true", "\n", "}", "\n", "return", "false", "\n\n", "case", "\"", ",", " ", "é", " ", "\"", "e", "\"", "é", "\"", "è", "r", "n", "r", "\"", " ", "r", "a", ",", "", "", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ":", "// Delete", "word", ".", "RemoveLastNRunes", "(", "len", "(", "suffixRunes", ")", ")", "\n", "return", "true", "\n\n", "case", "\"", ",", " ", "â", " ", "\"", "t", "\"", "a", ",", "\"", "a", "\"", "\"", "a", "e", "", "", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ":", "// Delete", "word", ".", "RemoveLastNRunes", "(", "len", "(", "suffixRunes", ")", ")", "\n\n", "// If preceded by e (unicode code point 101), delete", "//", "idx", ":=", "len", "(", "word", ".", "RS", ")", "-", "1", "\n", "if", "idx", ">=", "0", "&&", "word", ".", "RS", "[", "idx", "]", "==", "101", "&&", "word", ".", "FitsInRV", "(", "1", ")", "{", "<mask>", ".", "RemoveLastNRunes", "(", "1", ")", "\n", "}", "\n", "return", "true", "\n\n", "}", "\n", "return", "false", "\n", "}" ]
8,822
all-8823
[ "Value", "converts", "a", "value", "to", "a", "database", "driver", "value" ]
[ "func", "(", "u", "ISBN10", ")", "Value", "(", ")", "(", "driver", ".", "Value", ",", "error", ")", "{", "return", "driver", ".", "<mask>", "(", "string", "(", "u", ")", ")", ",", "nil", "\n", "}" ]
8,823
all-8824
[ "SetMaximumDrawableCount", "controls", "the", "number", "of", "Metal", "drawables", "in", "the", "resource", "pool", "managed", "by", "Core", "Animation", ".", "It", "can", "set", "to", "2", "or", "3", "only", ".", "SetMaximumDrawableCount", "panics", "for", "other", "values", ".", "Reference", ":", "https", ":", "//", "developer", ".", "apple", ".", "com", "/", "documentation", "/", "quartzcore", "/", "cametallayer", "/", "2938720", "-", "maximumdrawablecount", "." ]
[ "func", "(", "ml", "MetalLayer", ")", "SetMaximumDrawableCount", "(", "<mask>", "int", ")", "{", "e", ":=", "C", ".", "MetalLayer_SetMaximumDrawableCount", "(", "ml", ".", "metalLayer", ",", "C", ".", "uint_t", "(", "count", ")", ")", "\n", "if", "e", "!=", "nil", "{", "panic", "(", "errors", ".", "New", "(", "C", ".", "GoString", "(", "e", ")", ")", ")", "\n", "}", "\n", "}" ]
8,824
all-8825
[ "GetState", "returns", "the", "current", "state", "of", "the", "cluster", "s", "Pachyderm", "Enterprise", "key", "(", "ACTIVE", "EXPIRED", "or", "NONE", ")" ]
[ "func", "(", "a", "*", "apiServer", ")", "GetState", "(", "ctx", "<mask>", ".", "Context", ",", "req", "*", "ec", ".", "GetStateRequest", ")", "(", "resp", "*", "ec", ".", "GetStateResponse", ",", "retErr", "error", ")", "{", "a", ".", "LogReq", "(", "req", ")", "\n", "defer", "func", "(", "start", "time", ".", "Time", ")", "{", "a", ".", "pachLogger", ".", "Log", "(", "req", ",", "resp", ",", "retErr", ",", "time", ".", "Since", "(", "start", ")", ")", "}", "(", "time", ".", "Now", "(", ")", ")", "\n\n", "expiration", ",", "ok", ":=", "a", ".", "enterpriseExpiration", ".", "Load", "(", ")", ".", "(", "time", ".", "Time", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "expiration", ".", "IsZero", "(", ")", "{", "return", "&", "ec", ".", "GetStateResponse", "{", "State", ":", "ec", ".", "State_NONE", "}", ",", "nil", "\n", "}", "\n", "expirationProto", ",", "err", ":=", "types", ".", "TimestampProto", "(", "expiration", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ",", "expiration", ".", "String", "(", ")", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "resp", "=", "&", "ec", ".", "GetStateResponse", "{", "Info", ":", "&", "ec", ".", "TokenInfo", "{", "Expires", ":", "expirationProto", ",", "}", ",", "}", "\n", "if", "time", ".", "Now", "(", ")", ".", "After", "(", "expiration", ")", "{", "resp", ".", "State", "=", "ec", ".", "State_EXPIRED", "\n", "}", "else", "{", "resp", ".", "State", "=", "ec", ".", "State_ACTIVE", "\n", "}", "\n", "return", "resp", ",", "nil", "\n", "}" ]
8,825
all-8826
[ "Validate", "validates", "Kubernetes", "options", "." ]
[ "func", "(", "o", "*", "KubernetesOptions", ")", "Validate", "(", "dryRun", "bool", ")", "error", "{", "if", "dryRun", "&&", "o", ".", "DeckURI", "==", "\"", "\"", "{", "return", "<mask>", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "o", ".", "DeckURI", "!=", "\"", "\"", "{", "if", "_", ",", "err", ":=", "url", ".", "ParseRequestURI", "(", "o", ".", "DeckURI", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "o", ".", "DeckURI", ")", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
8,826
all-8827
[ "GetWidgetForResponse", "()", "is", "a", "wrapper", "around", "gtk_dialog_get_widget_for_response", "()", "." ]
[ "func", "(", "v", "*", "Dialog", ")", "GetWidgetForResponse", "(", "id", "ResponseType", ")", "(", "*", "Widget", ",", "error", ")", "{", "c", ":=", "C", ".", "gtk_dialog_get_widget_for_response", "(", "v", ".", "native", "(", ")", ",", "C", ".", "gint", "(", "<mask>", ")", ")", "\n", "if", "c", "==", "nil", "{", "return", "nil", ",", "nilPtrErr", "\n", "}", "\n", "obj", ":=", "glib", ".", "Take", "(", "unsafe", ".", "Pointer", "(", "c", ")", ")", "\n", "return", "wrapWidget", "(", "obj", ")", ",", "nil", "\n", "}" ]
8,827
all-8828
[ "Decode", "decodes", "a", "serialized", "JWT", "in", "buf", "into", "obj", "and", "verifies", "the", "JWT", "signature", "using", "the", "Algorithm", "and", "Signer", ".", "If", "the", "token", "or", "signature", "is", "invalid", "ErrInvalidToken", "or", "ErrInvalidSignature", "will", "be", "returned", "respectively", ".", "Otherwise", "any", "other", "errors", "encountered", "during", "token", "decoding", "will", "be", "returned", "." ]
[ "func", "(", "alg", "Algorithm", ")", "Decode", "(", "signer", "Signer", ",", "buf", "[", "]", "byte", ",", "obj", "<mask>", "{", "}", ")", "error", "{", "return", "Decode", "(", "alg", ",", "signer", ",", "buf", ",", "obj", ")", "\n", "}" ]
8,828
all-8829
[ "Slice", "slices", "a", "string", ".", "If", "end", "is", "negative", "then", "it", "is", "the", "from", "the", "end", "of", "the", "string", "." ]
[ "func", "Slice", "(", "s", "string", ",", "start", ",", "end", "int", ")", "string", "{", "if", "end", ">", "-", "1", "{", "return", "s", "[", "start", ":", "end", "]", "\n", "}", "\n", "L", ":=", "len", "(", "s", ")", "\n", "if", "L", "+", "end", ">", "0", "{", "return", "s", "[", "start", ":", "L", "-", "<mask>", "]", "\n", "}", "\n", "return", "s", "[", "start", ":", "]", "\n", "}" ]
8,829
all-8830
[ "Add", "will", "add", "a", "stream", "to", "the", "watcher", "." ]
[ "func", "(", "w", "*", "Watcher", ")", "Add", "(", "stream", "*", "Stream", ")", "{", "// initialize model", "coal", ".", "Init", "(", "stream", ".", "Model", ")", "\n\n", "// check existence", "if", "w", ".", "streams", "[", "stream", ".", "Name", "(", ")", "]", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "`spark: stream with name \"%s\" already exists`", ",", "stream", ".", "Name", "(", ")", ")", ")", "\n", "}", "\n\n", "// save stream", "w", ".", "streams", "[", "stream", ".", "<mask>", "(", ")", "]", "=", "stream", "\n\n", "// open stream", "coal", ".", "OpenStream", "(", "stream", ".", "Store", ",", "stream", ".", "Model", ",", "nil", ",", "func", "(", "e", "coal", ".", "Event", ",", "id", "bson", ".", "ObjectId", ",", "m", "coal", ".", "Model", ",", "token", "[", "]", "byte", ")", "{", "// ignore real deleted events when soft delete has been enabled", "if", "stream", ".", "SoftDelete", "&&", "e", "==", "coal", ".", "Deleted", "{", "return", "\n", "}", "\n\n", "// handle soft deleted documents", "if", "stream", ".", "SoftDelete", "&&", "e", "==", "coal", ".", "Updated", "{", "// get soft delete field", "softDeleteField", ":=", "coal", ".", "L", "(", "stream", ".", "Model", ",", "\"", "\"", ",", "true", ")", "\n\n", "// get deleted time", "t", ":=", "m", ".", "MustGet", "(", "softDeleteField", ")", ".", "(", "*", "time", ".", "Time", ")", "\n\n", "// change type if document has been soft deleted", "if", "t", "!=", "nil", "&&", "!", "t", ".", "IsZero", "(", ")", "{", "e", "=", "coal", ".", "Deleted", "\n", "}", "\n", "}", "\n\n", "// create event", "evt", ":=", "&", "Event", "{", "Type", ":", "e", ",", "ID", ":", "id", ",", "Model", ":", "m", ",", "Stream", ":", "stream", ",", "}", "\n\n", "// broadcast event", "w", ".", "manager", ".", "broadcast", "(", "evt", ")", "\n", "}", ",", "nil", ",", "func", "(", "err", "error", ")", "bool", "{", "// report error", "w", ".", "Reporter", "(", "err", ")", "\n\n", "return", "true", "\n", "}", ")", "\n", "}" ]
8,830
all-8831
[ "Stability", ":", "***", "EXPERIMENTAL", "***", "Get", "a", "worker", "-", "type", "from", "a", "provisioner", ".", "See", "#getWorkerType" ]
[ "func", "(", "queue", "*", "Queue", ")", "GetWorkerType", "(", "provisionerId", ",", "workerType", "string", ")", "(", "*", "WorkerTypeResponse", ",", "error", ")", "{", "cd", ":=", "tcclient", ".", "Client", "(", "*", "<mask>", ")", "\n", "responseObject", ",", "_", ",", "err", ":=", "(", "&", "cd", ")", ".", "APICall", "(", "nil", ",", "\"", "\"", ",", "\"", "\"", "+", "url", ".", "QueryEscape", "(", "provisionerId", ")", "+", "\"", "\"", "+", "url", ".", "QueryEscape", "(", "workerType", ")", ",", "new", "(", "WorkerTypeResponse", ")", ",", "nil", ")", "\n", "return", "responseObject", ".", "(", "*", "WorkerTypeResponse", ")", ",", "err", "\n", "}" ]
8,831
all-8832
[ "render", "multiple", "instances", "of", "a", "set", "of", "primitives", "from", "array", "data", "with", "a", "per", "-", "element", "offset" ]
[ "func", "DrawElementsInstancedBaseVertex", "(", "mode", "uint32", ",", "count", "int32", ",", "xtype", "uint32", ",", "indices", "unsafe", ".", "Pointer", ",", "instancecount", "int32", ",", "basevertex", "int32", ")", "{", "syscall", ".", "Syscall6", "(", "gpDrawElementsInstancedBaseVertex", ",", "6", ",", "uintptr", "(", "mode", ")", ",", "uintptr", "(", "<mask>", ")", ",", "uintptr", "(", "xtype", ")", ",", "uintptr", "(", "indices", ")", ",", "uintptr", "(", "instancecount", ")", ",", "uintptr", "(", "basevertex", ")", ")", "\n", "}" ]
8,832
all-8833
[ "UnicastAll", "returns", "the", "next", "hop", "on", "the", "unicast", "route", "to", "the", "named", "peer", "based", "on", "all", "connections", "." ]
[ "func", "(", "r", "*", "routes", ")", "UnicastAll", "(", "name", "PeerName", ")", "(", "PeerName", ",", "bool", ")", "{", "r", ".", "RLock", "(", ")", "\n", "defer", "r", ".", "RUnlock", "(", ")", "\n", "hop", ",", "<mask>", ":=", "r", ".", "unicastAll", "[", "name", "]", "\n", "return", "hop", ",", "found", "\n", "}" ]
8,833
all-8834
[ "callLine", "prints", "one", "stack", "line", "." ]
[ "func", "(", "p", "*", "Palette", ")", "callLine", "(", "line", "*", "stack", ".", "Call", ",", "srcLen", ",", "pkgLen", "int", ",", "fullPath", "bool", ")", "string", "{", "src", ":=", "\"", "\"", "\n", "if", "fullPath", "{", "src", "=", "line", ".", "FullSrcLine", "(", ")", "\n", "}", "else", "{", "src", "=", "<mask>", ".", "SrcLine", "(", ")", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "Package", ",", "pkgLen", ",", "line", ".", "Func", ".", "PkgName", "(", ")", ",", "p", ".", "SrcFile", ",", "srcLen", ",", "src", ",", "p", ".", "functionColor", "(", "line", ")", ",", "line", ".", "Func", ".", "Name", "(", ")", ",", "p", ".", "Arguments", ",", "&", "line", ".", "Args", ",", "p", ".", "EOLReset", ")", "\n", "}" ]
8,834
all-8835
[ "UnmarshalJSON", "implements", "json", ".", "Unmarshaler", "." ]
[ "func", "(", "r", "*", "Request", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "r2", "struct", "{", "Method", "string", "`json:\"method\"`", "\n", "Params", "*", "json", ".", "RawMessage", "`json:\"params,omitempty\"`", "\n", "Meta", "*", "json", ".", "RawMessage", "`json:\"meta,omitempty\"`", "\n", "ID", "*", "ID", "`json:\"id\"`", "\n", "}", "\n\n", "// Detect if the \"params\" field is JSON \"null\" or just not present", "// by seeing if the field gets overwritten to nil.", "r2", ".", "Params", "=", "&", "json", ".", "RawMessage", "{", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "r2", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "r", ".", "Method", "=", "r2", ".", "Method", "\n", "if", "r2", ".", "Params", "==", "nil", "{", "r", ".", "Params", "=", "&", "jsonNull", "\n", "}", "else", "if", "len", "(", "*", "r2", ".", "Params", ")", "==", "0", "{", "r", ".", "Params", "=", "nil", "\n", "}", "else", "{", "r", ".", "Params", "=", "r2", ".", "Params", "\n", "}", "\n", "r", ".", "Meta", "=", "r2", ".", "Meta", "\n", "if", "r2", ".", "ID", "==", "nil", "{", "r", ".", "ID", "=", "ID", "{", "}", "\n", "r", ".", "Notif", "=", "true", "\n", "}", "else", "{", "r", ".", "<mask>", "=", "*", "r2", ".", "ID", "\n", "r", ".", "Notif", "=", "false", "\n", "}", "\n", "return", "nil", "\n", "}" ]
8,835
all-8836
[ "specify", "a", "two", "-", "dimensional", "texture", "image" ]
[ "func", "TexImage2D", "(", "target", "uint32", ",", "level", "int32", ",", "internalformat", "int32", ",", "width", "int32", ",", "height", "int32", ",", "border", "int32", ",", "format", "uint32", ",", "xtype", "uint32", ",", "pixels", "unsafe", ".", "Pointer", ")", "{", "syscall", ".", "Syscall9", "(", "gpTexImage2D", ",", "9", ",", "uintptr", "(", "<mask>", ")", ",", "uintptr", "(", "level", ")", ",", "uintptr", "(", "internalformat", ")", ",", "uintptr", "(", "width", ")", ",", "uintptr", "(", "height", ")", ",", "uintptr", "(", "border", ")", ",", "uintptr", "(", "format", ")", ",", "uintptr", "(", "xtype", ")", ",", "uintptr", "(", "pixels", ")", ")", "\n", "}" ]
8,836
all-8837
[ "Register", "registers", "a", "new", "repository", "manager", "that", "can", "be", "later", "configured", "and", "used", "." ]
[ "func", "Register", "(", "name", "string", ",", "manager", "RepositoryManager", ")", "{", "if", "managers", "==", "nil", "{", "managers", "=", "<mask>", "(", "map", "[", "string", "]", "RepositoryManager", ")", "\n", "}", "\n", "managers", "[", "name", "]", "=", "manager", "\n", "}" ]
8,837
all-8838
[ "Get", "the", "IDs", "of", "all", "volumes", "with", "the", "given", "name", "and", "type", "associated", "with", "the", "given", "pool", "regardless", "of", "their", "node_id", "column", "." ]
[ "func", "storageVolumeIDsGet", "(", "tx", "*", "sql", ".", "Tx", ",", "project", ",", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", "int64", ")", "(", "[", "]", "int64", ",", "error", ")", "{", "ids", ",", "err", ":=", "query", ".", "SelectIntegers", "(", "tx", ",", "`\nSELECT storage_volumes.id\n FROM storage_volumes\n JOIN projects ON projects.id = storage_volumes.project_id\n WHERE projects.name=? AND storage_volumes.name=? AND storage_volumes.type=? AND storage_pool_id=?\n`", ",", "project", ",", "volumeName", ",", "volumeType", ",", "poolID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "ids64", ":=", "make", "(", "[", "]", "int64", ",", "len", "(", "ids", ")", ")", "\n", "for", "i", ",", "id", ":=", "range", "<mask>", "{", "ids64", "[", "i", "]", "=", "int64", "(", "id", ")", "\n", "}", "\n", "return", "ids64", ",", "nil", "\n", "}" ]
8,838
all-8839
[ "Set", "stores", "the", "value", "v", "at", "the", "key", "k", ".", "It", "will", "overwrite", "an", "existing", "value", "if", "present", "." ]
[ "func", "(", "s", "*", "Scratch", ")", "<mask>", "(", "k", "string", ",", "v", "interface", "{", "}", ")", "string", "{", "s", ".", "init", "(", ")", "\n\n", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "s", ".", "values", "[", "k", "]", "=", "v", "\n", "return", "\"", "\"", "\n", "}" ]
8,839
all-8840
[ "writeQuery", "runs", "the", "given", "modifying", "operation", "potentially", "followed", "up", "by", "a", "getLastError", "command", "in", "case", "the", "session", "is", "in", "safe", "mode", ".", "The", "LastError", "result", "is", "made", "available", "in", "lerr", "and", "if", "lerr", ".", "Err", "is", "set", "it", "will", "also", "be", "returned", "as", "err", "." ]
[ "func", "(", "c", "*", "Collection", ")", "writeQuery", "(", "op", "interface", "{", "}", ")", "(", "lerr", "*", "LastError", ",", "err", "error", ")", "{", "s", ":=", "c", ".", "Database", ".", "Session", "\n", "dbname", ":=", "c", ".", "Database", ".", "Name", "\n", "socket", ",", "err", ":=", "s", ".", "acquireSocket", "(", "dbname", "==", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "socket", ".", "Release", "(", ")", "\n\n", "s", ".", "m", ".", "RLock", "(", ")", "\n", "safeOp", ":=", "s", ".", "safeOp", "\n", "s", ".", "m", ".", "RUnlock", "(", ")", "\n\n", "// TODO Enable this path for wire version 2 as well.", "if", "socket", ".", "ServerInfo", "(", ")", ".", "MaxWireVersion", ">=", "3", "{", "// Servers with a more recent write protocol benefit from write commands.", "if", "op", ",", "ok", ":=", "op", ".", "(", "*", "insertOp", ")", ";", "ok", "&&", "len", "(", "op", ".", "documents", ")", ">", "1000", "{", "var", "firstErr", "error", "\n", "// Maximum batch size is 1000. Must split out in separate operations for compatibility.", "all", ":=", "op", ".", "documents", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "all", ")", ";", "i", "+=", "1000", "{", "l", ":=", "i", "+", "1000", "\n", "if", "l", ">", "len", "(", "all", ")", "{", "l", "=", "len", "(", "all", ")", "\n", "}", "\n", "op", ".", "documents", "=", "all", "[", "i", ":", "l", "]", "\n", "_", ",", "err", ":=", "c", ".", "writeCommand", "(", "socket", ",", "safeOp", ",", "op", ")", "\n", "if", "err", "!=", "nil", "{", "if", "op", ".", "flags", "&", "1", "!=", "0", "{", "if", "firstErr", "==", "nil", "{", "firstErr", "=", "err", "\n", "}", "\n", "}", "else", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "firstErr", "\n", "}", "\n", "return", "c", ".", "writeCommand", "(", "socket", ",", "safeOp", ",", "op", ")", "\n", "}", "\n\n", "if", "safeOp", "==", "nil", "{", "return", "nil", ",", "socket", ".", "Query", "(", "op", ")", "\n", "}", "\n\n", "var", "mutex", "sync", ".", "Mutex", "\n", "var", "replyData", "[", "]", "byte", "\n", "var", "replyErr", "error", "\n", "mutex", ".", "Lock", "(", ")", "\n", "query", ":=", "*", "safeOp", "// Copy the data.", "\n", "query", ".", "<mask>", "=", "dbname", "+", "\"", "\"", "\n", "query", ".", "replyFunc", "=", "func", "(", "err", "error", ",", "reply", "*", "replyOp", ",", "docNum", "int", ",", "docData", "[", "]", "byte", ")", "{", "replyData", "=", "docData", "\n", "replyErr", "=", "err", "\n", "mutex", ".", "Unlock", "(", ")", "\n", "}", "\n", "err", "=", "socket", ".", "Query", "(", "op", ",", "&", "query", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "mutex", ".", "Lock", "(", ")", "// Wait.", "\n", "if", "replyErr", "!=", "nil", "{", "return", "nil", ",", "replyErr", "// XXX TESTME", "\n", "}", "\n", "if", "hasErrMsg", "(", "replyData", ")", "{", "// Looks like getLastError itself failed.", "err", "=", "checkQueryError", "(", "query", ".", "collection", ",", "replyData", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "result", ":=", "&", "LastError", "{", "}", "\n", "bson", ".", "Unmarshal", "(", "replyData", ",", "&", "result", ")", "\n", "debugf", "(", "\"", "\"", ",", "result", ")", "\n", "if", "result", ".", "Err", "!=", "\"", "\"", "{", "return", "result", ",", "result", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
8,840
all-8841
[ "GetTitleAlignOk", "returns", "a", "tuple", "with", "the", "TitleAlign", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "a", "*", "AlertGraphDefinition", ")", "GetTitleAlignOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "a", "==", "nil", "||", "a", ".", "TitleAlign", "==", "nil", "{", "return", "\"", "\"", ",", "<mask>", "\n", "}", "\n", "return", "*", "a", ".", "TitleAlign", ",", "true", "\n", "}" ]
8,841
all-8842
[ "SetTimeout", "specifies", "the", "socket", "read", "/", "write", "timeout", ".", "If", "zero", "DefaultTimeout", "is", "used", ".", "If", "<", "0", "there", "s", "no", "timeout", ".", "This", "method", "must", "be", "called", "before", "any", "connections", "to", "the", "memcached", "server", "are", "opened", "." ]
[ "func", "(", "c", "*", "Client", ")", "SetTimeout", "(", "timeout", "<mask>", ".", "Duration", ")", "{", "if", "timeout", "==", "time", ".", "Duration", "(", "0", ")", "{", "timeout", "=", "DefaultTimeout", "\n", "}", "\n", "c", ".", "timeout", "=", "timeout", "\n", "}" ]
8,842
all-8843
[ "DatastorePathFromString", "is", "a", "convenience", "method", "that", "returns", "a", "fully", "-", "populated", "DatastorePath", "from", "a", "string", "containing", "a", "datastore", "path", ".", "A", "flag", "indicating", "a", "successful", "parsing", "is", "also", "returned", "." ]
[ "func", "DatastorePathFromString", "(", "p", "string", ")", "(", "*", "object", ".", "DatastorePath", ",", "bool", ")", "{", "dp", ":=", "new", "(", "<mask>", ".", "DatastorePath", ")", "\n", "success", ":=", "dp", ".", "FromString", "(", "p", ")", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "success", ",", "p", ")", "\n", "return", "dp", ",", "success", "\n", "}" ]
8,843
all-8844
[ "title", ":", "template", "update", "path", ":", "/", "iaas", "/", "templates", "/", "{", "template_name", "}", "method", ":", "PUT", "consume", ":", "application", "/", "x", "-", "www", "-", "form", "-", "urlencoded", "responses", ":", "200", ":", "OK", "400", ":", "Invalid", "data", "401", ":", "Unauthorized", "404", ":", "Not", "found" ]
[ "func", "templateUpdate", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "token", "auth", ".", "Token", ")", "(", "err", "error", ")", "{", "var", "paramTemplate", "iaas", ".", "Template", "\n", "err", "=", "ParseInput", "(", "r", ",", "&", "paramTemplate", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "templateName", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "dbTpl", ",", "err", ":=", "iaas", ".", "FindTemplate", "(", "templateName", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "mgo", ".", "ErrNotFound", "{", "return", "&", "errors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusNotFound", ",", "<mask>", ":", "\"", "\"", "}", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "iaasValue", ":=", "InputValue", "(", "r", ",", "\"", "\"", ")", "\n", "if", "iaasValue", "!=", "\"", "\"", "{", "dbTpl", ".", "IaaSName", "=", "iaasValue", "\n", "}", "\n", "iaasCtx", ":=", "permission", ".", "Context", "(", "permTypes", ".", "CtxIaaS", ",", "dbTpl", ".", "IaaSName", ")", "\n", "allowed", ":=", "permission", ".", "Check", "(", "token", ",", "permission", ".", "PermMachineTemplateUpdate", ",", "iaasCtx", ")", "\n", "if", "!", "allowed", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "evt", ",", "err", ":=", "event", ".", "New", "(", "&", "event", ".", "Opts", "{", "Target", ":", "event", ".", "Target", "{", "Type", ":", "event", ".", "TargetTypeIaas", ",", "Value", ":", "dbTpl", ".", "IaaSName", "}", ",", "Kind", ":", "permission", ".", "PermMachineTemplateUpdate", ",", "Owner", ":", "token", ",", "CustomData", ":", "event", ".", "FormToCustomData", "(", "InputFields", "(", "r", ")", ")", ",", "Allowed", ":", "event", ".", "Allowed", "(", "permission", ".", "PermMachineReadEvents", ",", "iaasCtx", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "func", "(", ")", "{", "evt", ".", "Done", "(", "err", ")", "}", "(", ")", "\n", "return", "dbTpl", ".", "Update", "(", "&", "paramTemplate", ")", "\n", "}" ]
8,844
all-8845
[ "Handler", "returns", "a", "new", "middleware", "that", "will", "compress", "the", "response", "based", "on", "the", "current", "Compressor", "." ]
[ "func", "(", "c", "*", "Compressor", ")", "Handler", "(", ")", "func", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "func", "(", "next", "<mask>", ".", "Handler", ")", "http", ".", "Handler", "{", "fn", ":=", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "encoder", ",", "encoding", ",", "cleanup", ":=", "c", ".", "selectEncoder", "(", "r", ".", "Header", ",", "w", ")", "\n\n", "cw", ":=", "&", "compressResponseWriter", "{", "ResponseWriter", ":", "w", ",", "w", ":", "w", ",", "contentTypes", ":", "c", ".", "allowedTypes", ",", "encoding", ":", "encoding", ",", "}", "\n", "if", "encoder", "!=", "nil", "{", "cw", ".", "w", "=", "encoder", "\n", "}", "\n", "// Re-add the encoder to the pool if applicable.", "defer", "cleanup", "(", ")", "\n", "defer", "cw", ".", "Close", "(", ")", "\n\n", "next", ".", "ServeHTTP", "(", "cw", ",", "r", ")", "\n", "}", "\n\n", "return", "http", ".", "HandlerFunc", "(", "fn", ")", "\n", "}", "\n\n", "}" ]
8,845
all-8846
[ "Process", "takes", "a", "raft", "message", "and", "applies", "it", "to", "the", "server", "s", "raft", "state", "machine", "respecting", "any", "timeout", "of", "the", "given", "context", "." ]
[ "func", "(", "s", "*", "EtcdServer", ")", "Process", "(", "ctx", "context", ".", "Context", ",", "m", "raftpb", ".", "Message", ")", "error", "{", "if", "s", ".", "cluster", ".", "IsIDRemoved", "(", "<mask>", ".", "ID", "(", "m", ".", "From", ")", ")", "{", "if", "lg", ":=", "s", ".", "getLogger", "(", ")", ";", "lg", "!=", "nil", "{", "lg", ".", "Warn", "(", "\"", "\"", ",", "zap", ".", "String", "(", "\"", "\"", ",", "s", ".", "ID", "(", ")", ".", "String", "(", ")", ")", ",", "zap", ".", "String", "(", "\"", "\"", ",", "types", ".", "ID", "(", "m", ".", "From", ")", ".", "String", "(", ")", ")", ",", ")", "\n", "}", "else", "{", "plog", ".", "Warningf", "(", "\"", "\"", ",", "types", ".", "ID", "(", "m", ".", "From", ")", ".", "String", "(", ")", ")", "\n", "}", "\n", "return", "httptypes", ".", "NewHTTPError", "(", "http", ".", "StatusForbidden", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "m", ".", "Type", "==", "raftpb", ".", "MsgApp", "{", "s", ".", "stats", ".", "RecvAppendReq", "(", "types", ".", "ID", "(", "m", ".", "From", ")", ".", "String", "(", ")", ",", "m", ".", "Size", "(", ")", ")", "\n", "}", "\n", "return", "s", ".", "r", ".", "Step", "(", "ctx", ",", "m", ")", "\n", "}" ]
8,846
all-8847
[ "SetTooltipItem", "is", "a", "wrapper", "around", "gtk_icon_view_set_tooltip_item", "()", "." ]
[ "func", "(", "v", "*", "IconView", ")", "SetTooltipItem", "(", "tooltip", "*", "Tooltip", ",", "<mask>", "*", "TreePath", ")", "{", "C", ".", "gtk_icon_view_set_tooltip_item", "(", "v", ".", "native", "(", ")", ",", "tooltip", ".", "native", "(", ")", ",", "path", ".", "native", "(", ")", ")", "\n", "}" ]
8,847
all-8848
[ "RedirectBytes", "sets", "Location", ":", "uri", "response", "header", "and", "sets", "the", "given", "statusCode", ".", "statusCode", "must", "have", "one", "of", "the", "following", "values", ":", "*", "StatusMovedPermanently", "(", "301", ")", "*", "StatusFound", "(", "302", ")", "*", "StatusSeeOther", "(", "303", ")", "*", "StatusTemporaryRedirect", "(", "307", ")", "*", "StatusPermanentRedirect", "(", "308", ")", "All", "other", "statusCode", "values", "are", "replaced", "by", "StatusFound", "(", "302", ")", ".", "The", "redirect", "uri", "may", "be", "either", "absolute", "or", "relative", "to", "the", "current", "request", "uri", ".", "Fasthttp", "will", "always", "send", "an", "absolute", "uri", "back", "to", "the", "client", ".", "To", "send", "a", "relative", "uri", "you", "can", "use", "the", "following", "code", ":", "strLocation", "=", "[]", "byte", "(", "Location", ")", "//", "Put", "this", "with", "your", "top", "level", "var", "()", "declarations", ".", "ctx", ".", "Response", ".", "Header", ".", "SetCanonical", "(", "strLocation", "/", "relative?uri", ")", "ctx", ".", "Response", ".", "SetStatusCode", "(", "fasthttp", ".", "StatusMovedPermanently", ")" ]
[ "func", "(", "ctx", "*", "RequestCtx", ")", "RedirectBytes", "(", "uri", "[", "]", "<mask>", ",", "statusCode", "int", ")", "{", "s", ":=", "b2s", "(", "uri", ")", "\n", "ctx", ".", "Redirect", "(", "s", ",", "statusCode", ")", "\n", "}" ]
8,848
all-8849
[ "findGoTool", "attempts", "to", "locate", "the", "go", "executable", ".", "If", "GOROOT", "is", "set", "we", "ll", "prefer", "the", "one", "in", "there", ";", "otherwise", "we", "ll", "rely", "on", "PATH", ".", "If", "the", "wrapper", "script", "generated", "by", "the", "gazelle", "rule", "is", "invoked", "by", "Bazel", "it", "will", "set", "GOROOT", "to", "the", "configured", "SDK", ".", "We", "don", "t", "want", "to", "rely", "on", "the", "host", "SDK", "in", "that", "situation", "." ]
[ "func", "findGoTool", "(", ")", "string", "{", "path", ":=", "\"", "\"", "// rely on PATH by default", "\n", "if", "goroot", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "\"", "\"", ")", ";", "<mask>", "{", "path", "=", "filepath", ".", "Join", "(", "goroot", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "path", "+=", "\"", "\"", "\n", "}", "\n", "return", "path", "\n", "}" ]
8,849
all-8850
[ "UnmarshalEasyJSON", "satisfies", "easyjson", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "CertificateErrorAction", ")", "UnmarshalEasyJSON", "(", "in", "*", "jlexer", ".", "Lexer", ")", "{", "switch", "CertificateErrorAction", "(", "in", ".", "String", "(", ")", ")", "{", "case", "CertificateErrorActionContinue", ":", "*", "t", "=", "CertificateErrorActionContinue", "\n", "case", "CertificateErrorActionCancel", ":", "*", "t", "=", "CertificateErrorActionCancel", "\n\n", "<mask>", ":", "in", ".", "AddError", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}" ]
8,850
all-8851
[ "TODO", ":", "need", "to", "remove", "the", "hack", "to", "add", "IAD3", "identifier", "--", "What", "hack?", "Not", "sure", "what", "this", "refers", "to", "." ]
[ "func", "GenServiceID", "(", "<mask>", ",", "name", ",", "proto", "string", ")", "(", "string", ",", "error", ")", "{", "h", ",", "_", ":=", "os", ".", "Hostname", "(", ")", "\n", "d", ":=", "strings", ".", "SplitN", "(", "h", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "d", ")", "!=", "2", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "service", ",", "name", ",", "proto", ",", "d", "[", "1", "]", ")", ",", "nil", "\n", "}" ]
8,851
all-8852
[ "LedgerKey", "implements", "the", "Keyer", "interface" ]
[ "func", "(", "aid", "*", "AccountId", ")", "LedgerKey", "(", ")", "(", "<mask>", "LedgerKey", ")", "{", "err", ":=", "ret", ".", "SetAccount", "(", "*", "aid", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n\n", "return", "\n", "}" ]
8,852
all-8853
[ "SimpleActionGroupNew", "is", "a", "wrapper", "around", "g_simple_action_group_new" ]
[ "func", "SimpleActionGroupNew", "(", ")", "*", "SimpleActionGroup", "{", "c", ":=", "C", ".", "g_simple_action_group_new", "(", ")", "\n", "if", "c", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "<mask>", "wrapSimpleActionGroup", "(", "wrapObject", "(", "unsafe", ".", "Pointer", "(", "c", ")", ")", ")", "\n", "}" ]
8,853
all-8854
[ "WrapMiddlewares", "calls", "the", "MiddlewareFunc", "methods", "in", "the", "reverse", "order", "and", "returns", "an", "HandlerFunc", "ready", "to", "be", "executed", ".", "This", "can", "be", "used", "to", "wrap", "a", "set", "of", "middlewares", "post", "routing", "on", "a", "per", "Route", "basis", "." ]
[ "func", "WrapMiddlewares", "(", "middlewares", "[", "]", "Middleware", ",", "<mask>", "HandlerFunc", ")", "HandlerFunc", "{", "wrapped", ":=", "handler", "\n", "for", "i", ":=", "len", "(", "middlewares", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "wrapped", "=", "middlewares", "[", "i", "]", ".", "MiddlewareFunc", "(", "wrapped", ")", "\n", "}", "\n", "return", "wrapped", "\n", "}" ]
8,854
all-8855
[ "Cursor", "returns", "a", "cursor", "for", "the", "iterator", "s", "current", "location", "." ]
[ "func", "(", "t", "*", "Iterator", ")", "Cursor", "(", ")", "(", "Cursor", ",", "error", ")", "{", "if", "t", ".", "err", "!=", "nil", "&&", "t", ".", "err", "!=", "Done", "{", "return", "Cursor", "{", "}", ",", "t", ".", "err", "\n", "}", "\n", "// If we are at either end of the current batch of results,", "// return the compiled cursor at that end.", "skipped", ":=", "t", ".", "<mask>", ".", "GetSkippedResults", "(", ")", "\n", "if", "t", ".", "i", "==", "0", "&&", "skipped", "==", "0", "{", "if", "t", ".", "prevCC", "==", "nil", "{", "// A nil pointer (of type *pb.CompiledCursor) means no constraint:", "// passing it as the end cursor of a new query means unlimited results", "// (glossing over the integer limit parameter for now).", "// A non-nil pointer to an empty pb.CompiledCursor means the start:", "// passing it as the end cursor of a new query means 0 results.", "// If prevCC was nil, then the original query had no start cursor, but", "// Iterator.Cursor should return \"the start\" instead of unlimited.", "return", "Cursor", "{", "&", "zeroCC", "}", ",", "nil", "\n", "}", "\n", "return", "Cursor", "{", "t", ".", "prevCC", "}", ",", "nil", "\n", "}", "\n", "if", "t", ".", "i", "==", "len", "(", "t", ".", "res", ".", "Result", ")", "{", "return", "Cursor", "{", "t", ".", "res", ".", "CompiledCursor", "}", ",", "nil", "\n", "}", "\n", "// Otherwise, re-run the query offset to this iterator's position, starting from", "// the most recent compiled cursor. This is done on a best-effort basis, as it", "// is racy; if a concurrent process has added or removed entities, then the", "// cursor returned may be inconsistent.", "q", ":=", "t", ".", "q", ".", "clone", "(", ")", "\n", "q", ".", "start", "=", "t", ".", "prevCC", "\n", "q", ".", "offset", "=", "skipped", "+", "int32", "(", "t", ".", "i", ")", "\n", "q", ".", "limit", "=", "0", "\n", "q", ".", "keysOnly", "=", "len", "(", "q", ".", "projection", ")", "==", "0", "\n", "t1", ":=", "q", ".", "Run", "(", "t", ".", "c", ")", "\n", "_", ",", "_", ",", "err", ":=", "t1", ".", "next", "(", ")", "\n", "if", "err", "!=", "Done", "{", "if", "err", "==", "nil", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "Cursor", "{", "}", ",", "err", "\n", "}", "\n", "return", "Cursor", "{", "t1", ".", "res", ".", "CompiledCursor", "}", ",", "nil", "\n", "}" ]
8,855
all-8856
[ "RunFixedArgs", "wraps", "a", "function", "in", "a", "function", "that", "checks", "its", "exact", "argument", "count", "." ]
[ "func", "RunFixedArgs", "(", "numArgs", "int", ",", "run", "func", "(", "[", "]", "string", ")", "error", ")", "func", "(", "*", "cobra", ".", "Command", ",", "[", "]", "string", ")", "{", "return", "func", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "if", "len", "(", "args", ")", "!=", "numArgs", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\\n", "\"", ",", "numArgs", ",", "len", "(", "args", ")", ")", "\n", "cmd", ".", "Usage", "(", ")", "\n", "}", "else", "{", "if", "err", ":=", "<mask>", "(", "args", ")", ";", "err", "!=", "nil", "{", "ErrorAndExit", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
8,856
all-8857
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventEntryAdded", ")", "MarshalJSON", "(", ")", "(", "[", "]", "<mask>", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoLog3", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
8,857
all-8858
[ "Send", "queues", "the", "given", "notification", "requests", "for", "processing", ".", "Panics", "if", "called", "on", "a", "handler", "that", "is", "not", "running", "." ]
[ "func", "(", "n", "*", "Manager", ")", "Send", "(", "alerts", "...", "*", "Alert", ")", "{", "n", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "n", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "// Attach external labels before relabelling and sending.", "for", "_", ",", "a", ":=", "range", "alerts", "{", "lb", ":=", "labels", ".", "NewBuilder", "(", "a", ".", "Labels", ")", "\n\n", "for", "_", ",", "l", ":=", "range", "n", ".", "opts", ".", "ExternalLabels", "{", "if", "a", ".", "Labels", ".", "Get", "(", "l", ".", "Name", ")", "==", "\"", "\"", "{", "lb", ".", "Set", "(", "l", ".", "Name", ",", "l", ".", "Value", ")", "\n", "}", "\n", "}", "\n\n", "a", ".", "Labels", "=", "lb", ".", "Labels", "(", ")", "\n", "}", "\n\n", "alerts", "=", "n", ".", "relabelAlerts", "(", "alerts", ")", "\n\n", "// Queue capacity should be significantly larger than a single alert", "// batch could be.", "if", "d", ":=", "len", "(", "alerts", ")", "-", "n", ".", "opts", ".", "QueueCapacity", ";", "d", ">", "0", "{", "alerts", "=", "alerts", "[", "d", ":", "]", "\n\n", "level", ".", "Warn", "(", "n", ".", "logger", ")", ".", "Log", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "d", ")", "\n", "n", ".", "metrics", ".", "dropped", ".", "Add", "(", "float64", "(", "d", ")", ")", "\n", "}", "\n\n", "// If the queue is full, remove the oldest alerts in favor", "// of newer ones.", "if", "d", ":=", "(", "len", "(", "n", ".", "queue", ")", "+", "len", "(", "alerts", ")", ")", "-", "n", ".", "opts", ".", "QueueCapacity", ";", "d", ">", "0", "{", "n", ".", "<mask>", "=", "n", ".", "queue", "[", "d", ":", "]", "\n\n", "level", ".", "Warn", "(", "n", ".", "logger", ")", ".", "Log", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "d", ")", "\n", "n", ".", "metrics", ".", "dropped", ".", "Add", "(", "float64", "(", "d", ")", ")", "\n", "}", "\n", "n", ".", "queue", "=", "append", "(", "n", ".", "queue", ",", "alerts", "...", ")", "\n\n", "// Notify sending goroutine that there are alerts to be processed.", "n", ".", "setMore", "(", ")", "\n", "}" ]
8,858
all-8859
[ "ShutdownGuest", "wraps", "the", "graceful", "shutdown", "of", "a", "guest", "VM", "and", "then", "waiting", "an", "appropriate", "amount", "of", "time", "for", "the", "guest", "power", "state", "to", "go", "to", "powered", "off", ".", "If", "the", "VM", "does", "not", "power", "off", "in", "the", "shutdown", "period", "specified", "by", "timeout", "(", "in", "minutes", ")", "an", "error", "is", "returned", ".", "The", "minimum", "value", "for", "timeout", "is", "1", "minute", "-", "setting", "to", "a", "0", "or", "negative", "value", "is", "not", "allowed", "and", "will", "just", "reset", "the", "timeout", "to", "the", "minimum", "." ]
[ "func", "ShutdownGuest", "(", "client", "*", "govmomi", ".", "Client", ",", "vm", "*", "object", ".", "VirtualMachine", ",", "timeout", "int", ")", "error", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "vm", ".", "InventoryPath", ")", "\n", "sctx", ",", "scancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "provider", ".", "DefaultAPITimeout", ")", "\n", "defer", "scancel", "(", ")", "\n", "if", "err", ":=", "vm", ".", "ShutdownGuest", "(", "sctx", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// We now wait on VM power state to be powerOff, via a property collector that waits on power state.", "p", ":=", "client", ".", "PropertyCollector", "(", ")", "\n", "if", "timeout", "<", "1", "{", "timeout", "=", "1", "\n", "}", "\n", "pctx", ",", "pcancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "time", ".", "Minute", "*", "time", ".", "Duration", "(", "timeout", ")", ")", "\n", "defer", "pcancel", "(", ")", "\n\n", "err", ":=", "property", ".", "Wait", "(", "pctx", ",", "p", ",", "vm", ".", "Reference", "(", ")", ",", "[", "]", "string", "{", "\"", "\"", "}", ",", "func", "(", "pc", "[", "]", "types", ".", "PropertyChange", ")", "bool", "{", "for", "_", ",", "c", ":=", "range", "pc", "{", "if", "c", ".", "Op", "!=", "types", ".", "PropertyChangeOpAssign", "{", "<mask>", "\n", "}", "\n\n", "switch", "v", ":=", "c", ".", "Val", ".", "(", "type", ")", "{", "case", "types", ".", "VirtualMachinePowerState", ":", "if", "v", "==", "types", ".", "VirtualMachinePowerStatePoweredOff", "{", "return", "true", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "false", "\n", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "// Provide a friendly error message if we timed out waiting for a shutdown.", "if", "pctx", ".", "Err", "(", ")", "==", "context", ".", "DeadlineExceeded", "{", "return", "errGuestShutdownTimeout", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
8,859
all-8860
[ "FormValueOrDefault", "returns", "the", "result", "of", "Request", ".", "FormValue", "and", "if", "the", "result", "is", "empty", "returns", "the", "default", "string" ]
[ "func", "(", "r", "*", "<mask>", ")", "FormValueOrDefault", "(", "key", "string", ",", "def", "string", ")", "string", "{", "val", ":=", "r", ".", "FormValue", "(", "key", ")", "\n", "if", "val", "==", "\"", "\"", "{", "val", "=", "def", "\n", "}", "\n\n", "return", "val", "\n", "}" ]
8,860
all-8861
[ "HasCompareTo", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "g", "*", "GraphDefinitionRequest", ")", "HasCompareTo", "(", ")", "bool", "{", "if", "g", "!=", "nil", "&&", "g", ".", "CompareTo", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
8,861
all-8862
[ "CreateService", "creates", "a", "new", "service", "in", "AWS", "API", ".", "Returns", "the", "created", "service", "." ]
[ "func", "(", "p", "*", "AWSSDProvider", ")", "CreateService", "(", "namespaceID", "*", "string", ",", "srvName", "*", "string", ",", "ep", "*", "endpoint", ".", "Endpoint", ")", "(", "*", "sd", ".", "Service", ",", "error", ")", "{", "log", ".", "Infof", "(", "\"", "\\\"", "\\\"", "\\\"", "\\\"", "\"", ",", "*", "srvName", ",", "*", "namespaceID", ")", "\n\n", "srvType", ":=", "p", ".", "serviceTypeFromEndpoint", "(", "ep", ")", "\n", "routingPolicy", ":=", "p", ".", "routingPolicyFromEndpoint", "(", "ep", ")", "\n\n", "ttl", ":=", "int64", "(", "sdDefaultRecordTTL", ")", "\n", "if", "ep", ".", "RecordTTL", ".", "IsConfigured", "(", ")", "{", "ttl", "=", "int64", "(", "ep", ".", "RecordTTL", ")", "\n", "}", "\n\n", "if", "!", "p", ".", "dryRun", "{", "out", ",", "err", ":=", "p", ".", "client", ".", "CreateService", "(", "&", "sd", ".", "CreateServiceInput", "{", "Name", ":", "srvName", ",", "<mask>", ":", "aws", ".", "String", "(", "ep", ".", "Labels", "[", "endpoint", ".", "AWSSDDescriptionLabel", "]", ")", ",", "DnsConfig", ":", "&", "sd", ".", "DnsConfig", "{", "NamespaceId", ":", "namespaceID", ",", "RoutingPolicy", ":", "aws", ".", "String", "(", "routingPolicy", ")", ",", "DnsRecords", ":", "[", "]", "*", "sd", ".", "DnsRecord", "{", "{", "Type", ":", "aws", ".", "String", "(", "srvType", ")", ",", "TTL", ":", "aws", ".", "Int64", "(", "ttl", ")", ",", "}", "}", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "out", ".", "Service", ",", "nil", "\n", "}", "\n\n", "// return mock service summary in case of dry run", "return", "&", "sd", ".", "Service", "{", "Id", ":", "aws", ".", "String", "(", "\"", "\"", ")", ",", "Name", ":", "aws", ".", "String", "(", "\"", "\"", ")", "}", ",", "nil", "\n", "}" ]
8,862
all-8863
[ "MoveMarkOnscreen", "is", "a", "wrapper", "around", "gtk_text_view_move_mark_onscreen", "()", "." ]
[ "func", "(", "v", "*", "TextView", ")", "MoveMarkOnscreen", "(", "<mask>", "*", "TextMark", ")", "bool", "{", "return", "gobool", "(", "C", ".", "gtk_text_view_move_mark_onscreen", "(", "v", ".", "native", "(", ")", ",", "mark", ".", "native", "(", ")", ")", ")", "\n", "}" ]
8,863
all-8864
[ "/", "*", "Integer", "looks", "for", "the", "specified", "key", "and", "returns", "it", "as", "an", "int", ".", "If", "not", "found", "the", "default", "value", "def", "is", "returned", "." ]
[ "func", "(", "config", "*", "Config", ")", "Integer", "(", "<mask>", "string", ",", "def", "int64", ")", "int64", "{", "return", "getInteger", "(", "config", ".", "values", ",", "key", ",", "def", ")", "\n", "}" ]
8,864
all-8865
[ "Catch", "creates", "middleware", "that", "processes", "errors", "stored", "while", "serving", "a", "request", ".", "Errors", "are", "passed", "to", "the", "callback", "which", "should", "write", "them", "to", "the", "response", "in", "an", "appropriate", "format", ".", "This", "is", "usually", "the", "outermost", "middleware", "in", "a", "chain", "." ]
[ "func", "Catch", "(", "h", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "<mask>", ",", "err", "error", ")", ")", "Middleware", "{", "return", "func", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "err", "error", "\n", "ctx", ":=", "context", ".", "WithValue", "(", "r", ".", "Context", "(", ")", ",", "errorKey", ",", "&", "err", ")", "\n\n", "next", ".", "ServeHTTP", "(", "w", ",", "r", ".", "WithContext", "(", "ctx", ")", ")", "\n", "if", "err", "!=", "nil", "{", "h", "(", "w", ",", "r", ",", "err", ")", "\n", "}", "\n", "}", ")", "\n", "}", "\n", "}" ]
8,865
all-8866
[ "AddInteraction", "creates", "a", "new", "Pact", "interaction", "initialising", "all", "required", "things", ".", "Will", "automatically", "start", "a", "Mock", "Service", "if", "none", "running", "." ]
[ "func", "(", "p", "*", "Pact", ")", "AddInteraction", "(", ")", "*", "Interaction", "{", "p", ".", "Setup", "(", "true", ")", "\n", "log", ".", "Println", "(", "\"", "\"", ")", "\n", "i", ":=", "&", "Interaction", "{", "}", "\n", "p", ".", "Interactions", "=", "<mask>", "(", "p", ".", "Interactions", ",", "i", ")", "\n", "return", "i", "\n", "}" ]
8,866
all-8867
[ "The", "handler", "for", "the", "delete", "operation", "." ]
[ "func", "profileDelete", "(", "d", "*", "Daemon", ",", "r", "*", "http", ".", "Request", ")", "Response", "{", "project", ":=", "projectParam", "(", "r", ")", "\n", "<mask>", ":=", "mux", ".", "Vars", "(", "r", ")", "[", "\"", "\"", "]", "\n\n", "if", "name", "==", "\"", "\"", "{", "return", "Forbidden", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n\n", "err", ":=", "d", ".", "cluster", ".", "Transaction", "(", "func", "(", "tx", "*", "db", ".", "ClusterTx", ")", "error", "{", "hasProfiles", ",", "err", ":=", "tx", ".", "ProjectHasProfiles", "(", "project", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "!", "hasProfiles", "{", "project", "=", "\"", "\"", "\n", "}", "\n\n", "profile", ",", "err", ":=", "tx", ".", "ProfileGet", "(", "project", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "len", "(", "profile", ".", "UsedBy", ")", ">", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "tx", ".", "ProfileDelete", "(", "project", ",", "name", ")", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "SmartError", "(", "err", ")", "\n", "}", "\n\n", "return", "EmptySyncResponse", "\n", "}" ]
8,867
all-8868
[ "BeginningOfMonth", "beginning", "of", "month" ]
[ "func", "(", "now", "*", "Now", ")", "BeginningOfMonth", "(", ")", "<mask>", ".", "Time", "{", "y", ",", "m", ",", "_", ":=", "now", ".", "Date", "(", ")", "\n", "return", "time", ".", "Date", "(", "y", ",", "m", ",", "1", ",", "0", ",", "0", ",", "0", ",", "0", ",", "now", ".", "Location", "(", ")", ")", "\n", "}" ]
8,868
all-8869
[ "Apply", "satisfies", "the", "StartSpanOption", "interface", "." ]
[ "func", "(", "t", "Tags", ")", "Apply", "(", "o", "*", "StartSpanOptions", ")", "{", "if", "o", ".", "Tags", "==", "nil", "{", "o", ".", "Tags", "=", "make", "(", "map", "[", "string", "]", "<mask>", "{", "}", ")", "\n", "}", "\n", "for", "k", ",", "v", ":=", "range", "t", "{", "o", ".", "Tags", "[", "k", "]", "=", "v", "\n", "}", "\n", "}" ]
8,869
all-8870
[ "Update", "updates", "a", "vsphere_virtual_machine", "cdrom", "sub", "-", "resource", "." ]
[ "func", "(", "r", "*", "CdromSubresource", ")", "Update", "(", "l", "object", ".", "VirtualDeviceList", ")", "(", "[", "]", "types", ".", "BaseVirtualDeviceConfigSpec", ",", "error", ")", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ")", "\n", "d", ",", "err", ":=", "r", ".", "FindVirtualDevice", "(", "l", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "device", ",", "ok", ":=", "d", ".", "(", "*", "types", ".", "VirtualCdrom", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "l", ".", "Name", "(", "d", ")", ")", "\n", "}", "\n\n", "// Map the CDROM to the correct device", "r", ".", "mapCdrom", "(", "device", ",", "l", ")", "\n", "spec", ",", "err", ":=", "object", ".", "VirtualDeviceList", "{", "<mask>", "}", ".", "ConfigSpec", "(", "types", ".", "VirtualDeviceConfigSpecOperationEdit", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ",", "DeviceChangeString", "(", "spec", ")", ")", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ")", "\n", "return", "spec", ",", "nil", "\n", "}" ]
8,870
all-8871
[ "SetInvisibleChar", "()", "is", "a", "wrapper", "around", "gtk_entry_set_invisible_char", "()", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "SetInvisibleChar", "(", "ch", "rune", ")", "{", "C", ".", "gtk_entry_set_invisible_char", "(", "v", ".", "native", "(", ")", ",", "C", ".", "gunichar", "(", "ch", ")", ")", "\n", "}" ]
8,871
all-8872
[ "Returns", "a", "time", ".", "Time", "or", "panics" ]
[ "func", "(", "t", "Typed", ")", "TimeMust", "(", "key", "string", ")", "<mask>", ".", "Time", "{", "tt", ",", "exists", ":=", "t", ".", "TimeIf", "(", "key", ")", "\n", "if", "exists", "==", "false", "{", "panic", "(", "\"", "\"", "+", "key", ")", "\n", "}", "\n", "return", "tt", "\n", "}" ]
8,872
all-8873
[ "QueryMap", "creates", "a", "QueryMap", "from", "TideQueries" ]
[ "func", "(", "tqs", "TideQueries", ")", "QueryMap", "(", ")", "*", "QueryMap", "{", "return", "&", "QueryMap", "{", "queries", ":", "tqs", ",", "<mask>", ":", "make", "(", "map", "[", "string", "]", "TideQueries", ")", ",", "}", "\n", "}" ]
8,873
all-8874
[ "Do", "executes", "CSS", ".", "getMediaQueries", "against", "the", "provided", "context", ".", "returns", ":", "medias" ]
[ "func", "(", "p", "*", "GetMediaQueriesParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "medias", "[", "]", "*", "Media", ",", "err", "error", ")", "{", "// execute", "var", "res", "GetMediaQueriesReturns", "\n", "err", "=", "cdp", ".", "Execute", "(", "ctx", ",", "CommandGetMediaQueries", ",", "nil", ",", "&", "<mask>", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "res", ".", "Medias", ",", "nil", "\n", "}" ]
8,874
all-8875
[ "DeepCopyInto", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "writing", "into", "out", ".", "in", "must", "be", "non", "-", "nil", "." ]
[ "func", "(", "in", "*", "DecorationConfig", ")", "DeepCopyInto", "(", "out", "*", "DecorationConfig", ")", "{", "*", "out", "=", "*", "in", "\n", "out", ".", "Timeout", "=", "in", ".", "Timeout", "\n", "<mask>", ".", "GracePeriod", "=", "in", ".", "GracePeriod", "\n", "if", "in", ".", "UtilityImages", "!=", "nil", "{", "in", ",", "out", ":=", "&", "in", ".", "UtilityImages", ",", "&", "out", ".", "UtilityImages", "\n", "*", "out", "=", "new", "(", "UtilityImages", ")", "\n", "*", "*", "out", "=", "*", "*", "in", "\n", "}", "\n", "if", "in", ".", "GCSConfiguration", "!=", "nil", "{", "in", ",", "out", ":=", "&", "in", ".", "GCSConfiguration", ",", "&", "out", ".", "GCSConfiguration", "\n", "*", "out", "=", "new", "(", "GCSConfiguration", ")", "\n", "*", "*", "out", "=", "*", "*", "in", "\n", "}", "\n", "if", "in", ".", "SSHKeySecrets", "!=", "nil", "{", "in", ",", "out", ":=", "&", "in", ".", "SSHKeySecrets", ",", "&", "out", ".", "SSHKeySecrets", "\n", "*", "out", "=", "make", "(", "[", "]", "string", ",", "len", "(", "*", "in", ")", ")", "\n", "copy", "(", "*", "out", ",", "*", "in", ")", "\n", "}", "\n", "if", "in", ".", "SSHHostFingerprints", "!=", "nil", "{", "in", ",", "out", ":=", "&", "in", ".", "SSHHostFingerprints", ",", "&", "out", ".", "SSHHostFingerprints", "\n", "*", "out", "=", "make", "(", "[", "]", "string", ",", "len", "(", "*", "in", ")", ")", "\n", "copy", "(", "*", "out", ",", "*", "in", ")", "\n", "}", "\n", "if", "in", ".", "SkipCloning", "!=", "nil", "{", "in", ",", "out", ":=", "&", "in", ".", "SkipCloning", ",", "&", "out", ".", "SkipCloning", "\n", "*", "out", "=", "new", "(", "bool", ")", "\n", "*", "*", "out", "=", "*", "*", "in", "\n", "}", "\n", "return", "\n", "}" ]
8,875
all-8876
[ "WithMethod", "if", "set", "this", "allows", "the", "request", "method", "to", "be", "overridden", ".", "Must", "not", "be", "set", "in", "response", "to", "an", "authChallenge", "." ]
[ "func", "(", "p", "ContinueInterceptedRequestParams", ")", "WithMethod", "(", "method", "string", ")", "*", "ContinueInterceptedRequestParams", "{", "p", ".", "Method", "=", "<mask>", "\n", "return", "&", "p", "\n", "}" ]
8,876
all-8877
[ "SetTaskCredentials", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockManager", ")", "SetTaskCredentials", "(", "arg0", "*", "credentials", ".", "TaskIAMRoleCredentials", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "<mask>", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
8,877
all-8878
[ "GetContainerBackupFile", "requests", "the", "container", "backup", "content" ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetContainerBackupFile", "(", "containerName", "string", ",", "name", "string", ",", "req", "*", "BackupFileRequest", ")", "(", "*", "BackupFileResponse", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"", "\"", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ")", "\n", "}", "\n\n", "// Build the URL", "uri", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ".", "httpHost", ",", "url", ".", "QueryEscape", "(", "containerName", ")", ",", "url", ".", "QueryEscape", "(", "name", ")", ")", "\n", "if", "r", ".", "project", "!=", "\"", "\"", "{", "uri", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "url", ".", "QueryEscape", "(", "r", ".", "project", ")", ")", "\n", "}", "\n\n", "// Prepare the download request", "request", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "uri", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "r", ".", "httpUserAgent", "!=", "\"", "\"", "{", "request", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "r", ".", "httpUserAgent", ")", "\n", "}", "\n\n", "// Start the request", "response", ",", "doneCh", ",", "err", ":=", "cancel", ".", "CancelableDownload", "(", "req", ".", "Canceler", ",", "r", ".", "http", ",", "request", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "response", ".", "Body", ".", "Close", "(", ")", "\n", "defer", "close", "(", "doneCh", ")", "\n\n", "if", "response", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "_", ",", "_", ",", "err", ":=", "lxdParseResponse", "(", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "// Handle the data", "body", ":=", "response", ".", "Body", "\n", "if", "req", ".", "ProgressHandler", "!=", "nil", "{", "body", "=", "&", "ioprogress", ".", "ProgressReader", "{", "ReadCloser", ":", "response", ".", "Body", ",", "Tracker", ":", "&", "ioprogress", ".", "ProgressTracker", "{", "Length", ":", "response", ".", "ContentLength", ",", "Handler", ":", "func", "(", "percent", "int64", ",", "speed", "int64", ")", "{", "req", ".", "ProgressHandler", "(", "ioprogress", ".", "ProgressData", "{", "Text", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "percent", ",", "shared", ".", "GetByteSizeString", "(", "speed", ",", "2", ")", ")", "}", ")", "\n", "}", ",", "}", ",", "}", "\n", "}", "\n\n", "size", ",", "err", ":=", "<mask>", ".", "Copy", "(", "req", ".", "BackupFile", ",", "body", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "resp", ":=", "BackupFileResponse", "{", "}", "\n", "resp", ".", "Size", "=", "size", "\n\n", "return", "&", "resp", ",", "nil", "\n", "}" ]
8,878
all-8879
[ "determine", "service", "routing", "policy", "based", "on", "endpoint", "type" ]
[ "func", "(", "p", "*", "AWSSDProvider", ")", "routingPolicyFromEndpoint", "(", "ep", "*", "endpoint", ".", "Endpoint", ")", "string", "{", "if", "ep", ".", "RecordType", "==", "endpoint", ".", "RecordTypeA", "{", "return", "sd", ".", "RoutingPolicyMultivalue", "\n", "}", "\n\n", "<mask>", "sd", ".", "RoutingPolicyWeighted", "\n", "}" ]
8,879
all-8880
[ "getTableForKey", "acquires", "a", "read", "-", "lock", "to", "access", "s", ".", "tables", ".", "It", "returns", "a", "list", "of", "tableHandlers", "." ]
[ "func", "(", "s", "*", "levelHandler", ")", "getTableForKey", "(", "key", "[", "]", "byte", ")", "(", "[", "]", "*", "table", ".", "Table", ",", "func", "(", ")", "error", ")", "{", "s", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "RUnlock", "(", ")", "\n\n", "if", "s", ".", "level", "==", "0", "{", "// For level 0, we need to check every table. Remember to make a copy as s.tables may change", "// once we exit this function, and we don't want to lock s.tables while seeking in tables.", "// CAUTION: Reverse the tables.", "out", ":=", "make", "(", "[", "]", "*", "table", ".", "Table", ",", "0", ",", "len", "(", "s", ".", "tables", ")", ")", "\n", "for", "i", ":=", "len", "(", "s", ".", "tables", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "out", "=", "append", "(", "out", ",", "s", ".", "tables", "[", "i", "]", ")", "\n", "s", ".", "tables", "[", "i", "]", ".", "IncrRef", "(", ")", "\n", "}", "\n", "return", "out", ",", "func", "(", ")", "error", "{", "for", "_", ",", "t", ":=", "<mask>", "out", "{", "if", "err", ":=", "t", ".", "DecrRef", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}", "\n", "}", "\n", "// For level >= 1, we can do a binary search as key range does not overlap.", "idx", ":=", "sort", ".", "Search", "(", "len", "(", "s", ".", "tables", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "y", ".", "CompareKeys", "(", "s", ".", "tables", "[", "i", "]", ".", "Biggest", "(", ")", ",", "key", ")", ">=", "0", "\n", "}", ")", "\n", "if", "idx", ">=", "len", "(", "s", ".", "tables", ")", "{", "// Given key is strictly > than every element we have.", "return", "nil", ",", "func", "(", ")", "error", "{", "return", "nil", "}", "\n", "}", "\n", "tbl", ":=", "s", ".", "tables", "[", "idx", "]", "\n", "tbl", ".", "IncrRef", "(", ")", "\n", "return", "[", "]", "*", "table", ".", "Table", "{", "tbl", "}", ",", "tbl", ".", "DecrRef", "\n", "}" ]
8,880
all-8881
[ "MarshalBinary", "interface", "implementation" ]
[ "func", "(", "m", "*", "AppWrapper", ")", "MarshalBinary", "(", ")", "(", "[", "]", "<mask>", ",", "error", ")", "{", "if", "m", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "swag", ".", "WriteJSON", "(", "m", ")", "\n", "}" ]
8,881
all-8882
[ "handleStoppedToRunningContainerTransition", "detects", "a", "backwards", "container", "transition", "where", "a", "known", "-", "stopped", "container", "is", "found", "to", "be", "running", "again", "and", "handles", "it", "." ]
[ "func", "(", "mtask", "*", "managedTask", ")", "handleStoppedToRunningContainerTransition", "(", "status", "apicontainerstatus", ".", "ContainerStatus", ",", "container", "*", "apicontainer", ".", "Container", ")", "{", "containerKnownStatus", ":=", "container", ".", "GetKnownStatus", "(", ")", "\n", "if", "status", ">", "containerKnownStatus", "{", "// Event status is greater than container's known status.", "// This is not a backward transition, return", "return", "\n", "}", "\n", "if", "containerKnownStatus", "!=", "apicontainerstatus", ".", "ContainerStopped", "{", "// Container's known status is not STOPPED. Nothing to do here.", "return", "\n", "}", "\n", "if", "!", "status", ".", "IsRunning", "(", ")", "{", "// Container's 'to' transition was not either of RUNNING or RESOURCES_PROVISIONED", "// states. Nothing to do in this case as well", "return", "\n", "}", "\n", "// If the container becomes running after we've stopped it (possibly", "// because we got an error running it and it ran anyways), the first time", "// update it to 'known running' so that it will be driven back to stopped", "mtask", ".", "unexpectedStart", ".", "Do", "(", "func", "(", ")", "{", "seelog", ".", "Warnf", "(", "\"", "\"", ",", "mtask", ".", "Arn", ",", "<mask>", ".", "Name", ")", "\n", "go", "mtask", ".", "engine", ".", "transitionContainer", "(", "mtask", ".", "Task", ",", "container", ",", "apicontainerstatus", ".", "ContainerStopped", ")", "\n", "// This will not proceed afterwards because status <= knownstatus below", "}", ")", "\n", "}" ]
8,882
all-8883
[ "New", "returns", "a", "CirconusMetrics", "instance" ]
[ "func", "New", "(", "cfg", "*", "Config", ")", "(", "*", "CirconusMetrics", ",", "error", ")", "{", "if", "cfg", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "cm", ":=", "&", "CirconusMetrics", "{", "counters", ":", "make", "(", "map", "[", "string", "]", "uint64", ")", ",", "counterFuncs", ":", "make", "(", "map", "[", "string", "]", "func", "(", ")", "uint64", ")", ",", "gauges", ":", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", ",", "gaugeFuncs", ":", "make", "(", "map", "[", "string", "]", "func", "(", ")", "int64", ")", ",", "histograms", ":", "make", "(", "map", "[", "string", "]", "*", "Histogram", ")", ",", "text", ":", "make", "(", "map", "[", "string", "]", "string", ")", ",", "textFuncs", ":", "make", "(", "map", "[", "string", "]", "func", "(", ")", "string", ")", ",", "lastMetrics", ":", "&", "prevMetrics", "{", "}", ",", "}", "\n\n", "// Logging", "{", "cm", ".", "Debug", "=", "cfg", ".", "Debug", "\n", "cm", ".", "Log", "=", "cfg", ".", "Log", "\n\n", "if", "cm", ".", "Debug", "&&", "cm", ".", "Log", "==", "nil", "{", "cm", ".", "<mask>", "=", "log", ".", "New", "(", "os", ".", "Stderr", ",", "\"", "\"", ",", "log", ".", "LstdFlags", ")", "\n", "}", "\n", "if", "cm", ".", "Log", "==", "nil", "{", "cm", ".", "Log", "=", "log", ".", "New", "(", "ioutil", ".", "Discard", ",", "\"", "\"", ",", "log", ".", "LstdFlags", ")", "\n", "}", "\n", "}", "\n\n", "// Flush Interval", "{", "fi", ":=", "defaultFlushInterval", "\n", "if", "cfg", ".", "Interval", "!=", "\"", "\"", "{", "fi", "=", "cfg", ".", "Interval", "\n", "}", "\n\n", "dur", ",", "err", ":=", "time", ".", "ParseDuration", "(", "fi", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "cm", ".", "flushInterval", "=", "dur", "\n", "}", "\n\n", "// metric resets", "cm", ".", "resetCounters", "=", "true", "\n", "if", "cfg", ".", "ResetCounters", "!=", "\"", "\"", "{", "setting", ",", "err", ":=", "strconv", ".", "ParseBool", "(", "cfg", ".", "ResetCounters", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "cm", ".", "resetCounters", "=", "setting", "\n", "}", "\n\n", "cm", ".", "resetGauges", "=", "true", "\n", "if", "cfg", ".", "ResetGauges", "!=", "\"", "\"", "{", "setting", ",", "err", ":=", "strconv", ".", "ParseBool", "(", "cfg", ".", "ResetGauges", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "cm", ".", "resetGauges", "=", "setting", "\n", "}", "\n\n", "cm", ".", "resetHistograms", "=", "true", "\n", "if", "cfg", ".", "ResetHistograms", "!=", "\"", "\"", "{", "setting", ",", "err", ":=", "strconv", ".", "ParseBool", "(", "cfg", ".", "ResetHistograms", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "cm", ".", "resetHistograms", "=", "setting", "\n", "}", "\n\n", "cm", ".", "resetText", "=", "true", "\n", "if", "cfg", ".", "ResetText", "!=", "\"", "\"", "{", "setting", ",", "err", ":=", "strconv", ".", "ParseBool", "(", "cfg", ".", "ResetText", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "cm", ".", "resetText", "=", "setting", "\n", "}", "\n\n", "// check manager", "{", "cfg", ".", "CheckManager", ".", "Debug", "=", "cm", ".", "Debug", "\n", "cfg", ".", "CheckManager", ".", "Log", "=", "cm", ".", "Log", "\n\n", "check", ",", "err", ":=", "checkmgr", ".", "New", "(", "&", "cfg", ".", "CheckManager", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "cm", ".", "check", "=", "check", "\n", "}", "\n\n", "// start background initialization", "cm", ".", "check", ".", "Initialize", "(", ")", "\n\n", "// if automatic flush is enabled, start it.", "// NOTE: submit will jettison metrics until initialization has completed.", "if", "cm", ".", "flushInterval", ">", "time", ".", "Duration", "(", "0", ")", "{", "go", "func", "(", ")", "{", "for", "range", "time", ".", "NewTicker", "(", "cm", ".", "flushInterval", ")", ".", "C", "{", "cm", ".", "Flush", "(", ")", "\n", "}", "\n", "}", "(", ")", "\n", "}", "\n\n", "return", "cm", ",", "nil", "\n", "}" ]
8,883
all-8884
[ "getPlugins", "returns", "a", "list", "of", "plugins", "that", "are", "enabled", "on", "a", "given", "(", "org", "repository", ")", "." ]
[ "func", "(", "pa", "*", "ConfigAgent", ")", "getPlugins", "(", "owner", ",", "repo", "string", ")", "[", "]", "string", "{", "<mask>", "plugins", "[", "]", "string", "\n\n", "fullName", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "owner", ",", "repo", ")", "\n", "plugins", "=", "append", "(", "plugins", ",", "pa", ".", "configuration", ".", "Plugins", "[", "owner", "]", "...", ")", "\n", "plugins", "=", "append", "(", "plugins", ",", "pa", ".", "configuration", ".", "Plugins", "[", "fullName", "]", "...", ")", "\n\n", "return", "plugins", "\n", "}" ]
8,884
all-8885
[ "SelectConfig", "executes", "a", "query", "statement", "against", "a", "config", "table", "which", "must", "have", "key", "and", "value", "columns", ".", "By", "default", "this", "query", "returns", "all", "keys", "but", "additional", "WHERE", "filters", "can", "be", "specified", ".", "Returns", "a", "map", "of", "key", "names", "to", "their", "associated", "values", "." ]
[ "func", "SelectConfig", "(", "tx", "*", "sql", ".", "Tx", ",", "table", "string", ",", "where", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "query", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "table", ")", "\n", "if", "where", "!=", "\"", "\"", "{", "query", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "where", ")", "\n", "}", "\n\n", "rows", ",", "err", ":=", "tx", ".", "Query", "(", "query", ",", "args", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "rows", ".", "Close", "(", ")", "\n\n", "values", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "for", "rows", ".", "Next", "(", ")", "{", "var", "key", "string", "\n", "var", "value", "string", "\n\n", "err", ":=", "rows", ".", "Scan", "(", "&", "key", ",", "&", "value", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "values", "[", "key", "]", "=", "value", "\n", "}", "\n\n", "err", "=", "rows", ".", "Err", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "<mask>", ",", "nil", "\n", "}" ]
8,885
all-8886
[ "Get", "function", "returns", "the", "value", "of", "a", "key", "in", "the", "configuration", ".", "If", "the", "key", "does", "not", "exist", "it", "returns", "empty", "string", "(", "i", ".", "e", ".", ")", "." ]
[ "func", "(", "c", "*", "Config", ")", "Get", "(", "section", "string", ",", "key", "string", ")", "string", "{", "value", ",", "ok", ":=", "c", ".", "config", "[", "section", "]", "[", "key", "]", "\n", "if", "!", "ok", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "<mask>", "\n", "}" ]
8,886
all-8887
[ "Sign", "returns", "an", "new", "TransactionEnvelopeBuilder", "using", "this", "builder", "s", "transaction", "as", "the", "basis", "and", "with", "signatures", "of", "that", "transaction", "from", "the", "provided", "Signers", "." ]
[ "func", "(", "b", "*", "TransactionBuilder", ")", "Sign", "(", "signers", "...", "string", ")", "(", "<mask>", "TransactionEnvelopeBuilder", ")", "{", "result", ".", "Mutate", "(", "b", ")", "\n\n", "for", "_", ",", "s", ":=", "range", "signers", "{", "result", ".", "Mutate", "(", "Sign", "{", "s", "}", ")", "\n", "}", "\n\n", "return", "\n", "}" ]
8,887
all-8888
[ "validateActivationCode", "checks", "the", "validity", "of", "an", "activation", "code" ]
[ "func", "validateActivationCode", "(", "code", "string", ")", "(", "expiration", "time", ".", "Time", ",", "err", "error", ")", "{", "// Parse the public key. If these steps fail, something is seriously", "// wrong and we should crash the service by panicking.", "block", ",", "_", ":=", "pem", ".", "Decode", "(", "[", "]", "byte", "(", "publicKey", ")", ")", "\n", "if", "block", "==", "nil", "{", "return", "time", ".", "Time", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "pub", ",", "err", ":=", "x509", ".", "ParsePKIXPublicKey", "(", "block", ".", "Bytes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "time", ".", "Time", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ".", "<mask>", "(", ")", ")", "\n", "}", "\n", "rsaPub", ",", "ok", ":=", "pub", ".", "(", "*", "rsa", ".", "PublicKey", ")", "\n", "if", "!", "ok", "{", "return", "time", ".", "Time", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Decode the base64-encoded activation code", "decodedActivationCode", ",", "err", ":=", "base64", ".", "StdEncoding", ".", "DecodeString", "(", "code", ")", "\n", "if", "err", "!=", "nil", "{", "return", "time", ".", "Time", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "activationCode", ":=", "&", "activationCode", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "decodedActivationCode", ",", "&", "activationCode", ")", ";", "err", "!=", "nil", "{", "return", "time", ".", "Time", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Decode the signature", "decodedSignature", ",", "err", ":=", "base64", ".", "StdEncoding", ".", "DecodeString", "(", "activationCode", ".", "Signature", ")", "\n", "if", "err", "!=", "nil", "{", "return", "time", ".", "Time", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Compute the sha256 checksum of the token", "hashedToken", ":=", "sha256", ".", "Sum256", "(", "[", "]", "byte", "(", "activationCode", ".", "Token", ")", ")", "\n\n", "// Verify that the signature is valid", "if", "err", ":=", "rsa", ".", "VerifyPKCS1v15", "(", "rsaPub", ",", "crypto", ".", "SHA256", ",", "hashedToken", "[", ":", "]", ",", "decodedSignature", ")", ";", "err", "!=", "nil", "{", "return", "time", ".", "Time", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Unmarshal the token", "token", ":=", "token", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "activationCode", ".", "Token", ")", ",", "&", "token", ")", ";", "err", "!=", "nil", "{", "return", "time", ".", "Time", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Parse the expiration. Note that this string is generated by Date.toJSON()", "// running in node, so Go's definition of RFC 3339 timestamps (which is", "// incomplete) must be compatible with the strings that node generates. So far", "// it seems to work.", "expiration", ",", "err", "=", "time", ".", "Parse", "(", "time", ".", "RFC3339", ",", "token", ".", "Expiry", ")", "\n", "if", "err", "!=", "nil", "{", "return", "time", ".", "Time", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "// Check that the activation code has not expired", "if", "time", ".", "Now", "(", ")", ".", "After", "(", "expiration", ")", "{", "return", "time", ".", "Time", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "expiration", ",", "nil", "\n", "}" ]
8,888
all-8889
[ "QueryInstant", "performs", "an", "instant", "query", "against", "a", "Prometheus", "server", "." ]
[ "func", "QueryInstant", "(", "url", ",", "query", "string", ",", "p", "printer", ")", "int", "{", "config", ":=", "api", ".", "Config", "{", "<mask>", ":", "url", ",", "}", "\n\n", "// Create new client.", "c", ",", "err", ":=", "api", ".", "NewClient", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Fprintln", "(", "os", ".", "Stderr", ",", "\"", "\"", ",", "err", ")", "\n", "return", "1", "\n", "}", "\n\n", "// Run query against client.", "api", ":=", "v1", ".", "NewAPI", "(", "c", ")", "\n\n", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "2", "*", "time", ".", "Minute", ")", "\n", "val", ",", "err", ":=", "api", ".", "Query", "(", "ctx", ",", "query", ",", "time", ".", "Now", "(", ")", ")", "\n", "cancel", "(", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Fprintln", "(", "os", ".", "Stderr", ",", "\"", "\"", ",", "err", ")", "\n", "return", "1", "\n", "}", "\n\n", "p", ".", "printValue", "(", "val", ")", "\n\n", "return", "0", "\n", "}" ]
8,889
all-8890
[ "NewIncompleteKey", "creates", "a", "new", "incomplete", "key", ".", "kind", "cannot", "be", "empty", "." ]
[ "func", "NewIncompleteKey", "(", "c", "context", ".", "Context", ",", "kind", "string", ",", "parent", "*", "<mask>", ")", "*", "Key", "{", "return", "NewKey", "(", "c", ",", "kind", ",", "\"", "\"", ",", "0", ",", "parent", ")", "\n", "}" ]
8,890
all-8891
[ "SetUserAgentBytes", "sets", "User", "-", "Agent", "header", "value", "." ]
[ "func", "(", "h", "*", "RequestHeader", ")", "SetUserAgentBytes", "(", "userAgent", "[", "]", "byte", ")", "{", "h", ".", "parseRawHeaders", "(", ")", "\n", "h", ".", "userAgent", "=", "<mask>", "(", "h", ".", "userAgent", "[", ":", "0", "]", ",", "userAgent", "...", ")", "\n", "}" ]
8,891
all-8892
[ "ResolveCreate", "is", "invoked", "when", "dns", "name", "is", "not", "owned", "by", "any", "resource", "ResolveCreate", "takes", "minimal", "(", "string", "comparison", "of", "Target", ")", "endpoint", "to", "acquire", "the", "DNS", "record" ]
[ "func", "(", "s", "PerResource", ")", "ResolveCreate", "(", "candidates", "[", "]", "*", "endpoint", ".", "Endpoint", ")", "*", "endpoint", ".", "Endpoint", "{", "var", "<mask>", "*", "endpoint", ".", "Endpoint", "\n", "for", "_", ",", "ep", ":=", "range", "candidates", "{", "if", "min", "==", "nil", "||", "s", ".", "less", "(", "ep", ",", "min", ")", "{", "min", "=", "ep", "\n", "}", "\n", "}", "\n", "return", "min", "\n", "}" ]
8,892
all-8893
[ "RevertValid", "is", "the", "same", "as", "Revert", "but", "it", "also", "validates", "the", "resulting", "string", "matching", "it", "against", "the", "compiled", "regexp", ".", "The", "values", "are", "modified", "in", "place", "and", "only", "the", "unused", "ones", "are", "left", "." ]
[ "func", "(", "r", "*", "Regexp", ")", "RevertValid", "(", "<mask>", "url", ".", "Values", ")", "(", "string", ",", "error", ")", "{", "reverse", ",", "err", ":=", "r", ".", "Revert", "(", "values", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "!", "r", ".", "compiled", ".", "MatchString", "(", "reverse", ")", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "reverse", ")", "\n", "}", "\n", "return", "reverse", ",", "nil", "\n", "}" ]
8,893
all-8894
[ "ReadResponse", "reads", "a", "server", "response", "into", "the", "received", "o", "." ]
[ "func", "(", "o", "*", "FindVmsByDeploymentReader", ")", "ReadResponse", "(", "response", "runtime", ".", "ClientResponse", ",", "consumer", "runtime", ".", "Consumer", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "switch", "response", ".", "Code", "(", ")", "{", "case", "200", ":", "result", ":=", "NewFindVmsByDeploymentOK", "(", ")", "\n", "if", "err", ":=", "result", ".", "readResponse", "(", "response", ",", "<mask>", ",", "o", ".", "formats", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "result", ",", "nil", "\n\n", "case", "404", ":", "result", ":=", "NewFindVmsByDeploymentNotFound", "(", ")", "\n", "if", "err", ":=", "result", ".", "readResponse", "(", "response", ",", "consumer", ",", "o", ".", "formats", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "nil", ",", "result", "\n\n", "default", ":", "result", ":=", "NewFindVmsByDeploymentDefault", "(", "response", ".", "Code", "(", ")", ")", "\n", "if", "err", ":=", "result", ".", "readResponse", "(", "response", ",", "consumer", ",", "o", ".", "formats", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "nil", ",", "result", "\n", "}", "\n", "}" ]
8,894
all-8895
[ "parseNetworkMetadata", "parses", "the", "docker", ".", "NetworkSettings", "struct", "and", "packages", "the", "desired", "metadata", "for", "JSON", "marshaling", "Since", "we", "accept", "incomplete", "metadata", "fields", "we", "should", "not", "return", "errors", "here", "and", "handle", "them", "at", "this", "stage", "." ]
[ "func", "parseNetworkMetadata", "(", "settings", "*", "types", ".", "NetworkSettings", ",", "hostConfig", "*", "dockercontainer", ".", "HostConfig", ")", "(", "NetworkMetadata", ",", "error", ")", "{", "// Network settings and Host configuration should not be missing except due to errors", "if", "settings", "==", "nil", "{", "err", ":=", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "return", "NetworkMetadata", "{", "}", ",", "err", "\n", "}", "\n\n", "if", "hostConfig", "==", "nil", "{", "err", ":=", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "return", "NetworkMetadata", "{", "}", ",", "err", "\n", "}", "\n\n", "// This metadata is the information provided in older versions of the API", "// We get the NetworkMode (Network interface name) from the HostConfig because this", "// this is the network with which the container is created", "ipv4AddressFromSettings", ":=", "settings", ".", "IPAddress", "\n", "networkModeFromHostConfig", ":=", "string", "(", "hostConfig", ".", "NetworkMode", ")", "\n\n", "// Extensive Network information is not available for Docker API versions 1.17-1.20", "// Instead we only get the details of the first network", "networkList", ":=", "make", "(", "[", "]", "Network", ",", "0", ")", "\n", "if", "len", "(", "settings", ".", "Networks", ")", ">", "0", "{", "for", "modeFromSettings", ",", "containerNetwork", ":=", "range", "settings", ".", "Networks", "{", "networkMode", ":=", "modeFromSettings", "\n", "ipv4Addresses", ":=", "[", "]", "string", "{", "containerNetwork", ".", "IPAddress", "}", "\n", "network", ":=", "Network", "{", "NetworkMode", ":", "networkMode", ",", "IPv4Addresses", ":", "ipv4Addresses", "}", "\n", "networkList", "=", "append", "(", "networkList", ",", "network", ")", "\n", "}", "\n", "}", "else", "{", "ipv4Addresses", ":=", "[", "]", "string", "{", "ipv4AddressFromSettings", "}", "\n", "<mask>", ":=", "Network", "{", "NetworkMode", ":", "networkModeFromHostConfig", ",", "IPv4Addresses", ":", "ipv4Addresses", "}", "\n", "networkList", "=", "append", "(", "networkList", ",", "network", ")", "\n", "}", "\n\n", "return", "NetworkMetadata", "{", "networks", ":", "networkList", ",", "}", ",", "nil", "\n", "}" ]
8,895
all-8896
[ "MarshalEasyJSON", "satisfies", "easyjson", ".", "Marshaler", "." ]
[ "func", "(", "t", "Modifier", ")", "MarshalEasyJSON", "(", "<mask>", "*", "jwriter", ".", "Writer", ")", "{", "out", ".", "Int64", "(", "int64", "(", "t", ")", ")", "\n", "}" ]
8,896
all-8897
[ "Wrap", "returns", "an", "handler", "which", "proxies", "requests", "to", "the", "given", "handler", "but", "handles", "panics", "by", "logging", "the", "stack", "trace", "and", "returning", "a", "500", "Internal", "Server", "Error", "to", "the", "client", "if", "possible", "." ]
[ "func", "Wrap", "(", "h", "http", ".", "Handler", ",", "onPanic", "PanicHandler", ")", "<mask>", ".", "Handler", "{", "return", "&", "recoveryHandler", "{", "h", ":", "h", ",", "p", ":", "onPanic", "}", "\n", "}" ]
8,897
all-8898
[ "HasTime", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "c", "*", "CheckStatusDefinition", ")", "HasTime", "(", ")", "bool", "{", "if", "c", "!=", "nil", "&&", "c", ".", "Time", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
8,898
all-8899
[ "ImportPubKey", "imports", "ASCII", "-", "armored", "public", "keys", ".", "Store", "a", "new", "Info", "object", "holding", "a", "public", "key", "only", "i", ".", "e", ".", "it", "will", "not", "be", "possible", "to", "sign", "with", "it", "as", "it", "lacks", "the", "secret", "key", "." ]
[ "func", "(", "kb", "dbKeybase", ")", "ImportPubKey", "(", "name", "string", ",", "armor", "string", ")", "(", "err", "error", ")", "{", "bz", ":=", "kb", ".", "db", ".", "Get", "(", "infoKey", "(", "name", ")", ")", "\n", "if", "len", "(", "bz", ")", ">", "0", "{", "return", "<mask>", ".", "New", "(", "\"", "\"", "+", "name", ")", "\n", "}", "\n", "pubBytes", ",", "err", ":=", "unarmorPubKeyBytes", "(", "armor", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "pubKey", ",", "err", ":=", "crypto", ".", "PubKeyFromBytes", "(", "pubBytes", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "kb", ".", "writeOfflineKey", "(", "pubKey", ",", "name", ")", "\n", "return", "\n", "}" ]
8,899
all-8900
[ "NewWithConfig", "creates", "a", "config", "from", "given", "config" ]
[ "func", "NewWithConfig", "(", "cfg", "Config", ")", "*", "Skiplist", "{", "if", "runtime", ".", "GOARCH", "!=", "\"", "\"", "{", "cfg", ".", "UseMemoryMgmt", "=", "false", "\n", "}", "\n\n", "s", ":=", "&", "Skiplist", "{", "Config", ":", "cfg", ",", "barrier", ":", "newAccessBarrier", "(", "cfg", ".", "UseMemoryMgmt", ",", "cfg", ".", "BarrierDestructor", ")", ",", "}", "\n\n", "s", ".", "newNode", "=", "func", "(", "itm", "unsafe", ".", "Pointer", ",", "level", "int", ")", "*", "Node", "{", "return", "allocNode", "(", "itm", ",", "level", ",", "cfg", ".", "Malloc", ")", "\n", "}", "\n\n", "if", "cfg", ".", "UseMemoryMgmt", "{", "s", ".", "freeNode", "=", "func", "(", "n", "*", "Node", ")", "{", "if", "Debug", "{", "debugMarkFree", "(", "n", ")", "\n", "}", "\n", "cfg", ".", "Free", "(", "unsafe", ".", "Pointer", "(", "n", ")", ")", "\n", "}", "\n", "}", "else", "{", "s", ".", "freeNode", "=", "func", "(", "*", "Node", ")", "{", "}", "\n", "}", "\n\n", "head", ":=", "allocNode", "(", "minItem", ",", "MaxLevel", ",", "nil", ")", "\n", "<mask>", ":=", "allocNode", "(", "maxItem", ",", "MaxLevel", ",", "nil", ")", "\n\n", "for", "i", ":=", "0", ";", "i", "<=", "MaxLevel", ";", "i", "++", "{", "head", ".", "setNext", "(", "i", ",", "tail", ",", "false", ")", "\n", "}", "\n\n", "s", ".", "head", "=", "head", "\n", "s", ".", "tail", "=", "tail", "\n\n", "return", "s", "\n", "}" ]