id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
listlengths
1
418
pl_tokens
listlengths
22
4.98k
16,900
all-16901
[ "Listen", "bind", "port", ".", "Receive", "messages", "and", "send", "to", "out", "channel" ]
[ "func", "(", "listener", "*", "CarbonlinkListener", ")", "Listen", "(", "addr", "*", "net", ".", "TCPAddr", ")", "error", "{", "return", "listener", ".", "StartFunc", "(", "func", "(", ")", "error", "{", "tcpListener", ",", "err", ":=", "net", ".", "ListenTCP", "(", "\"", "\"", ",", "addr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "listener", ".", "tcpListener", "=", "tcpListener", "\n\n", "listener", ".", "Go", "(", "func", "(", "exit", "chan", "bool", ")", "{", "select", "{", "case", "<-", "exit", ":", "tcpListener", ".", "Close", "(", ")", "\n", "}", "\n", "}", ")", "\n\n", "listener", ".", "Go", "(", "func", "(", "exit", "chan", "bool", ")", "{", "defer", "tcpListener", ".", "Close", "(", ")", "\n\n", "for", "{", "conn", ",", "err", ":=", "tcpListener", ".", "Accept", "(", ")", "\n", "if", "err", "!=", "nil", "{", "if", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "\"", "\"", ")", "{", "break", "\n", "}", "\n", "zapwriter", ".", "Logger", "(", "\"", "\"", ")", ".", "<mask>", "(", "\"", "\"", ",", "zap", ".", "Error", "(", "err", ")", ")", "\n", "continue", "\n", "}", "\n", "framedConn", ",", "_", ":=", "framing", ".", "NewConn", "(", "conn", ",", "byte", "(", "4", ")", ",", "binary", ".", "BigEndian", ")", "\n", "framedConn", ".", "MaxFrameSize", "=", "1048576", "// 1MB max frame size for read and write", "\n", "go", "listener", ".", "HandleConnection", "(", "*", "framedConn", ")", "\n", "}", "\n", "}", ")", "\n\n", "return", "nil", "\n", "}", ")", "\n", "}" ]
16,901
all-16902
[ "FindOne", "-" ]
[ "func", "(", "s", "*", "MockPersistence", ")", "FindOne", "(", "query", "interface", "{", "}", ",", "result", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "goutil", ".", "Unpack", "(", "[", "]", "interface", "{", "}", "{", "s", ".", "Result", "}", ",", "<mask>", ")", "\n", "err", "=", "s", ".", "Err", "\n", "return", "\n", "}" ]
16,902
all-16903
[ "GetAttributes", "returns", "the", "error", "attributes", "or", "falls", "back", "to", "empty", "attributes" ]
[ "func", "GetAttributes", "(", "err", "error", ")", "Attributes", "{", "e", ",", "ok", ":=", "err", ".", "(", "<mask>", ")", "\n", "if", "ok", "{", "return", "e", ".", "Attributes", "(", ")", "\n", "}", "\n\n", "return", "Attributes", "{", "}", "\n", "}" ]
16,903
all-16904
[ "ImageGetPoolNamesFromIDs", "get", "the", "names", "of", "all", "storage", "pools", "on", "which", "a", "given", "image", "exists", "." ]
[ "func", "(", "c", "*", "Cluster", ")", "ImageGetPoolNamesFromIDs", "(", "poolIDs", "[", "]", "int64", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "poolName", "string", "\n", "query", ":=", "\"", "\"", "\n\n", "poolNames", ":=", "[", "]", "string", "{", "}", "\n", "for", "_", ",", "poolID", ":=", "range", "poolIDs", "{", "inargs", ":=", "[", "]", "<mask>", "{", "}", "{", "poolID", "}", "\n", "outargs", ":=", "[", "]", "interface", "{", "}", "{", "poolName", "}", "\n\n", "result", ",", "err", ":=", "queryScan", "(", "c", ".", "db", ",", "query", ",", "inargs", ",", "outargs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "string", "{", "}", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "r", ":=", "range", "result", "{", "poolNames", "=", "append", "(", "poolNames", ",", "r", "[", "0", "]", ".", "(", "string", ")", ")", "\n", "}", "\n", "}", "\n\n", "return", "poolNames", ",", "nil", "\n", "}" ]
16,904
all-16905
[ "Run", "receives", "and", "saves", "target", "set", "updates", "and", "triggers", "the", "scraping", "loops", "reloading", ".", "Reloading", "happens", "in", "the", "background", "so", "that", "it", "doesn", "t", "block", "receiving", "targets", "updates", "." ]
[ "func", "(", "m", "*", "Manager", ")", "Run", "(", "tsets", "<-", "chan", "map", "[", "string", "]", "[", "]", "*", "targetgroup", ".", "Group", ")", "error", "{", "go", "m", ".", "reloader", "(", ")", "\n", "for", "{", "<mask>", "{", "case", "ts", ":=", "<-", "tsets", ":", "m", ".", "updateTsets", "(", "ts", ")", "\n\n", "select", "{", "case", "m", ".", "triggerReload", "<-", "struct", "{", "}", "{", "}", ":", "default", ":", "}", "\n\n", "case", "<-", "m", ".", "graceShut", ":", "return", "nil", "\n", "}", "\n", "}", "\n", "}" ]
16,905
all-16906
[ "HasIsLandscape", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "s", "*", "SyntheticsDevice", ")", "HasIsLandscape", "(", ")", "bool", "{", "if", "s", "!=", "nil", "&&", "s", ".", "IsLandscape", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
16,906
all-16907
[ "Perform", "a", "job", "as", "soon", "as", "possibly", "using", "a", "goroutine", "." ]
[ "func", "(", "w", "Simple", ")", "Perform", "(", "job", "Job", ")", "error", "{", "w", ".", "Logger", ".", "Debugf", "(", "\"", "\"", ",", "job", ")", "\n", "if", "job", ".", "Handler", "==", "\"", "\"", "{", "err", ":=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "job", ")", "\n", "w", ".", "Logger", ".", "Error", "(", "err", ")", "\n", "return", "err", "\n", "}", "\n", "w", ".", "moot", ".", "Lock", "(", ")", "\n", "defer", "w", ".", "moot", ".", "Unlock", "(", ")", "\n", "if", "h", ",", "ok", ":=", "w", ".", "handlers", "[", "job", ".", "Handler", "]", ";", "ok", "{", "<mask>", "func", "(", ")", "{", "err", ":=", "safe", ".", "RunE", "(", "func", "(", ")", "error", "{", "return", "h", "(", "job", ".", "Args", ")", "\n", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "w", ".", "Logger", ".", "Error", "(", "err", ")", "\n", "}", "\n", "w", ".", "Logger", ".", "Debugf", "(", "\"", "\"", ",", "job", ")", "\n", "}", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "err", ":=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "job", ".", "Handler", ")", "\n", "w", ".", "Logger", ".", "Error", "(", "err", ")", "\n", "return", "err", "\n", "}" ]
16,907
all-16908
[ "GetMetadata", "returns", "the", "metadata", "from", "instance", "metadata", "service", "specified", "by", "the", "path" ]
[ "func", "(", "c", "*", "ec2MetadataClientImpl", ")", "GetMetadata", "(", "path", "string", ")", "(", "string", ",", "error", ")", "{", "return", "c", ".", "client", ".", "GetMetadata", "(", "<mask>", ")", "\n", "}" ]
16,908
all-16909
[ "NewTransactionHistoryResultEntryExt", "creates", "a", "new", "TransactionHistoryResultEntryExt", "." ]
[ "func", "NewTransactionHistoryResultEntryExt", "(", "v", "int32", ",", "value", "interface", "{", "}", ")", "(", "result", "TransactionHistoryResultEntryExt", ",", "err", "error", ")", "{", "result", ".", "V", "=", "v", "\n", "<mask>", "int32", "(", "v", ")", "{", "case", "0", ":", "// void", "}", "\n", "return", "\n", "}" ]
16,909
all-16910
[ "containsResultsInRange", "returns", "true", "if", "any", "results", "are", "in", "the", "range", "[", "start", "end", ")", "." ]
[ "func", "containsResultsInRange", "(", "start", "time", ".", "Time", ",", "end", "time", ".", "Time", ",", "results", "[", "]", "time", ".", "Time", ")", "bool", "{", "for", "_", ",", "<mask>", ":=", "range", "results", "{", "if", "(", "result", ".", "Equal", "(", "start", ")", "||", "result", ".", "After", "(", "start", ")", ")", "&&", "result", ".", "Before", "(", "end", ")", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
16,910
all-16911
[ "NewRemoveDirCommand", "returns", "the", "CLI", "command", "for", "rmdir", "." ]
[ "func", "NewRemoveDirCommand", "(", ")", "cli", ".", "Command", "{", "return", "cli", ".", "Command", "{", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "ArgsUsage", ":", "\"", "\"", ",", "Action", ":", "func", "(", "c", "*", "<mask>", ".", "Context", ")", "error", "{", "rmdirCommandFunc", "(", "c", ",", "mustNewKeyAPI", "(", "c", ")", ")", "\n", "return", "nil", "\n", "}", ",", "}", "\n", "}" ]
16,911
all-16912
[ "define", "the", "scissor", "box", "for", "a", "specific", "viewport" ]
[ "func", "ScissorIndexed", "(", "index", "uint32", ",", "left", "int32", ",", "bottom", "int32", ",", "width", "int32", ",", "height", "int32", ")", "{", "syscall", ".", "Syscall6", "(", "gpScissorIndexed", ",", "5", ",", "uintptr", "(", "index", ")", ",", "uintptr", "(", "left", ")", ",", "uintptr", "(", "<mask>", ")", ",", "uintptr", "(", "width", ")", ",", "uintptr", "(", "height", ")", ",", "0", ")", "\n", "}" ]
16,912
all-16913
[ "Uint64", "returns", "the", "uint64", "value", "stored", "in", "r", ".", "r", "must", "have", "type", "uint64", "." ]
[ "func", "(", "r", "<mask>", ")", "Uint64", "(", ")", "uint64", "{", "if", "r", ".", "typ", ".", "Kind", "!=", "KindUint", "||", "r", ".", "typ", ".", "Size", "!=", "8", "{", "panic", "(", "\"", "\"", "+", "r", ".", "typ", ".", "Name", ")", "\n", "}", "\n", "return", "r", ".", "p", ".", "proc", ".", "ReadUint64", "(", "r", ".", "a", ")", "\n", "}" ]
16,913
all-16914
[ "GetClusterMember", "returns", "information", "about", "the", "given", "member" ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetClusterMember", "(", "name", "string", ")", "(", "*", "api", ".", "ClusterMember", ",", "string", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"", "\"", ")", "{", "return", "nil", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ")", "\n", "}", "\n\n", "member", ":=", "api", ".", "ClusterMember", "{", "}", "\n", "etag", ",", "err", ":=", "r", ".", "queryStruct", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "<mask>", ")", ",", "nil", ",", "\"", "\"", ",", "&", "member", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "&", "member", ",", "etag", ",", "nil", "\n", "}" ]
16,914
all-16915
[ "stop", "the", "shards", ";", "subsequent", "call", "to", "enqueue", "will", "return", "false", "." ]
[ "func", "(", "s", "*", "shards", ")", "stop", "(", ")", "{", "// Attempt a clean shutdown, but only wait flushDeadline for all the shards", "// to cleanly exit. As we're doing RPCs, enqueue can block indefinitely.", "// We must be able so call stop concurrently, hence we can only take the", "// RLock here.", "s", ".", "mtx", ".", "RLock", "(", ")", "\n", "close", "(", "s", ".", "softShutdown", ")", "\n", "s", ".", "mtx", ".", "RUnlock", "(", ")", "\n\n", "// Enqueue should now be unblocked, so we can take the write lock. This", "// also ensures we don't race with writes to the queues, and get a panic:", "// send on closed channel.", "s", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mtx", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "queue", ":=", "range", "s", ".", "queues", "{", "close", "(", "queue", ")", "\n", "}", "\n", "select", "{", "<mask>", "<-", "s", ".", "done", ":", "return", "\n", "case", "<-", "time", ".", "After", "(", "s", ".", "qm", ".", "flushDeadline", ")", ":", "level", ".", "Error", "(", "s", ".", "qm", ".", "logger", ")", ".", "Log", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Force an unclean shutdown.", "s", ".", "hardShutdown", "(", ")", "\n", "<-", "s", ".", "done", "\n", "}" ]
16,915
all-16916
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventScreencastVisibilityChanged", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage51", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
16,916
all-16917
[ "Implements", "Bitcoin", "style", "addresses", ":", "RIPEMD160", "(", "SHA256", "(", "pubkey", "))" ]
[ "func", "(", "pubKey", "PubKeySecp256k1", ")", "<mask>", "(", ")", "Address", "{", "hasherSHA256", ":=", "sha256", ".", "New", "(", ")", "\n", "hasherSHA256", ".", "Write", "(", "pubKey", "[", ":", "]", ")", "// does not error", "\n", "sha", ":=", "hasherSHA256", ".", "Sum", "(", "nil", ")", "\n\n", "hasherRIPEMD160", ":=", "ripemd160", ".", "New", "(", ")", "\n", "hasherRIPEMD160", ".", "Write", "(", "sha", ")", "// does not error", "\n", "return", "Address", "(", "hasherRIPEMD160", ".", "Sum", "(", "nil", ")", ")", "\n", "}" ]
16,917
all-16918
[ "/", "*", "DeleteVM", "deletes", "a", "vm", "from", "pool" ]
[ "func", "(", "a", "*", "Client", ")", "DeleteVM", "(", "params", "*", "DeleteVMParams", ")", "(", "*", "DeleteVMNoContent", ",", "error", ")", "{", "// TODO: Validate the params before sending", "if", "params", "==", "nil", "{", "params", "=", "NewDeleteVMParams", "(", ")", "\n", "}", "\n\n", "result", ",", "err", ":=", "a", ".", "transport", ".", "Submit", "(", "&", "runtime", ".", "ClientOperation", "{", "ID", ":", "\"", "\"", ",", "Method", ":", "\"", "\"", ",", "PathPattern", ":", "\"", "\"", ",", "ProducesMediaTypes", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "ConsumesMediaTypes", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "Schemes", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "Params", ":", "params", ",", "Reader", ":", "&", "DeleteVMReader", "{", "formats", ":", "a", ".", "formats", "}", ",", "Context", ":", "params", ".", "Context", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "<mask>", ".", "(", "*", "DeleteVMNoContent", ")", ",", "nil", "\n\n", "}" ]
16,918
all-16919
[ "Add", "adds", "a", "new", "format", "return", "true", "if", "this", "was", "a", "new", "item", "instead", "of", "a", "replacement" ]
[ "func", "(", "f", "*", "defaultFormats", ")", "Add", "(", "name", "string", ",", "strfmt", "Format", ",", "validator", "Validator", ")", "bool", "{", "f", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "Unlock", "(", ")", "\n\n", "nme", ":=", "f", ".", "normalizeName", "(", "name", ")", "\n\n", "tpe", ":=", "reflect", ".", "TypeOf", "(", "strfmt", ")", "\n", "if", "tpe", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "tpe", "=", "tpe", ".", "Elem", "(", ")", "\n", "}", "\n\n", "for", "i", ":=", "range", "f", ".", "data", "{", "v", ":=", "&", "f", ".", "data", "[", "i", "]", "\n", "if", "v", ".", "Name", "==", "nme", "{", "v", ".", "Type", "=", "tpe", "\n", "v", ".", "Validator", "=", "validator", "\n", "return", "false", "\n", "}", "\n", "}", "\n\n", "// turns out it's new after all", "f", ".", "data", "=", "append", "(", "f", ".", "data", ",", "knownFormat", "{", "<mask>", ":", "nme", ",", "OrigName", ":", "name", ",", "Type", ":", "tpe", ",", "Validator", ":", "validator", "}", ")", "\n", "return", "true", "\n", "}" ]
16,919
all-16920
[ "GetOverallState", "returns", "the", "OverallState", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "m", "*", "Monitor", ")", "GetOverallState", "(", ")", "string", "{", "if", "m", "==", "nil", "||", "m", ".", "OverallState", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "<mask>", "*", "m", ".", "OverallState", "\n", "}" ]
16,920
all-16921
[ "Dispatch", "implements", "Dispatcher", ".", "Dispatch" ]
[ "func", "(", "d", "*", "SerialDispatcher", ")", "Dispatch", "(", "cmd", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "d", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mutex", ".", "RUnlock", "(", ")", "\n\n", "defer", "func", "(", ")", "{", "if", "e", ":=", "recover", "(", ")", ";", "e", "!=", "nil", "{", "err", "=", "e", ".", "(", "error", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "found", ":=", "false", "\n", "for", "_", ",", "handler", ":=", "range", "d", ".", "handlers", "{", "if", "handler", "==", "nil", "{", "continue", "\n", "}", "\n", "if", "!", "<mask>", ".", "CanHandle", "(", "cmd", ")", "{", "continue", "\n", "}", "\n", "found", "=", "true", "\n", "if", "err", "=", "handler", ".", "Handle", "(", "cmd", ",", "d", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "}", "\n\n", "if", "!", "found", "{", "return", "&", "NoHandlerFoundError", "{", "Command", ":", "cmd", ",", "}", "\n", "}", "\n\n", "return", "\n", "}" ]
16,921
all-16922
[ "TODO", "(", "jrick", ")", "GdkPixbuf", "/", "*", "func", "(", "v", "*", "Entry", ")", "GetIconPixbuf", "()", "{", "}", "GetIconName", "()", "is", "a", "wrapper", "around", "gtk_entry_get_icon_name", "()", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "GetIconName", "(", "iconPos", "EntryIconPosition", ")", "(", "string", ",", "error", ")", "{", "c", ":=", "C", ".", "gtk_entry_get_icon_name", "(", "v", ".", "native", "(", ")", ",", "C", ".", "GtkEntryIconPosition", "(", "iconPos", ")", ")", "\n", "if", "c", "==", "nil", "{", "return", "\"", "\"", ",", "nilPtrErr", "\n", "}", "\n", "return", "goString", "(", "c", ")", ",", "nil", "\n", "}" ]
16,922
all-16923
[ "shouldNotOverrideApproval", "decides", "whether", "or", "not", "we", "should", "keep", "the", "original", "approval", ":", "If", "someone", "approves", "a", "PR", "multiple", "times", "we", "only", "want", "to", "keep", "the", "latest", "approval", "unless", "a", "previous", "approval", "was", "no", "-", "issue", "and", "the", "most", "recent", "isn", "t", "." ]
[ "func", "(", "ap", "*", "Approvers", ")", "shouldNotOverrideApproval", "(", "login", "<mask>", ",", "noIssue", "bool", ")", "bool", "{", "login", "=", "strings", ".", "ToLower", "(", "login", ")", "\n", "approval", ",", "alreadyApproved", ":=", "ap", ".", "approvers", "[", "login", "]", "\n\n", "return", "alreadyApproved", "&&", "approval", ".", "NoIssue", "&&", "!", "noIssue", "\n", "}" ]
16,923
all-16924
[ "RespondWithProto", "returns", "a", "handler", "that", "responds", "to", "a", "request", "with", "the", "specified", "status", "code", "and", "a", "body", "containing", "the", "protobuf", "serialization", "of", "the", "provided", "message", ".", "Also", "RespondWithProto", "can", "be", "given", "an", "optional", "http", ".", "Header", ".", "The", "headers", "defined", "therein", "will", "be", "added", "to", "the", "response", "headers", "." ]
[ "func", "RespondWithProto", "(", "statusCode", "int", ",", "message", "proto", ".", "Message", ",", "optionalHeader", "...", "http", ".", "Header", ")", "http", ".", "HandlerFunc", "{", "return", "func", "(", "w", "<mask>", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "data", ",", "err", ":=", "proto", ".", "Marshal", "(", "message", ")", "\n", "Expect", "(", "err", ")", ".", "ShouldNot", "(", "HaveOccurred", "(", ")", ")", "\n\n", "var", "headers", "http", ".", "Header", "\n", "if", "len", "(", "optionalHeader", ")", "==", "1", "{", "headers", "=", "optionalHeader", "[", "0", "]", "\n", "}", "else", "{", "headers", "=", "make", "(", "http", ".", "Header", ")", "\n", "}", "\n", "if", "_", ",", "found", ":=", "headers", "[", "\"", "\"", "]", ";", "!", "found", "{", "headers", "[", "\"", "\"", "]", "=", "[", "]", "string", "{", "\"", "\"", "}", "\n", "}", "\n", "copyHeader", "(", "headers", ",", "w", ".", "Header", "(", ")", ")", "\n\n", "w", ".", "WriteHeader", "(", "statusCode", ")", "\n", "w", ".", "Write", "(", "data", ")", "\n", "}", "\n", "}" ]
16,924
all-16925
[ "GetRequest", "returns", "the", "Request", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "s", "*", "SyntheticsConfig", ")", "GetRequest", "(", ")", "SyntheticsRequest", "{", "if", "s", "==", "nil", "||", "s", ".", "<mask>", "==", "nil", "{", "return", "SyntheticsRequest", "{", "}", "\n", "}", "\n", "return", "*", "s", ".", "Request", "\n", "}" ]
16,925
all-16926
[ "isNotFoundError", "checks", "an", "error", "to", "see", "if", "it", "s", "of", "the", "NotFoundError", "type", ".", "Note", "this", "is", "different", "from", "the", "other", "not", "found", "faults", "and", "is", "an", "error", "type", "in", "its", "own", "right", ".", "Use", "IsAnyNotFoundError", "to", "check", "for", "any", "not", "found", "type", "." ]
[ "func", "isNotFoundError", "(", "err", "error", ")", "bool", "{", "if", "f", ",", "ok", ":=", "vimSoapFault", "(", "err", ")", ";", "<mask>", "{", "if", "_", ",", "ok", ":=", "f", ".", "(", "types", ".", "NotFound", ")", ";", "ok", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
16,926
all-16927
[ "NewReference", "returns", "an", "OSTree", "reference", "for", "a", "specified", "repo", "and", "image", "." ]
[ "func", "NewReference", "(", "image", "string", ",", "repo", "string", ")", "(", "types", ".", "ImageReference", ",", "error", ")", "{", "// image is not _really_ in a containers/image/docker/reference format;", "// as far as the libOSTree ociimage/* namespace is concerned, it is more or", "// less an arbitrary string with an implied tag.", "// Parse the image using reference.ParseNormalizedNamed so that we can", "// check whether the images has a tag specified and we can add \":latest\" if needed", "ostreeImage", ",", "err", ":=", "reference", ".", "ParseNormalizedNamed", "(", "image", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "reference", ".", "IsNameOnly", "(", "ostreeImage", ")", "{", "image", "=", "image", "+", "\"", "\"", "\n", "}", "\n\n", "resolved", ",", "err", ":=", "explicitfilepath", ".", "ResolvePathToFullyExplicit", "(", "repo", ")", "\n", "if", "err", "!=", "nil", "{", "// With os.IsNotExist(err), the parent directory of repo is also not existent;", "// that should ordinarily not happen, but it would be a bit weird to reject", "// references which do not specify a repo just because the implicit defaultOSTreeRepo", "// does not exist.", "if", "os", ".", "IsNotExist", "(", "err", ")", "&&", "repo", "==", "defaultOSTreeRepo", "{", "resolved", "=", "repo", "\n", "}", "else", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "// This is necessary to prevent directory paths returned by PolicyConfigurationNamespaces", "// from being ambiguous with values of PolicyConfigurationIdentity.", "if", "strings", ".", "Contains", "(", "resolved", ",", "\"", "\"", ")", "{", "return", "nil", ",", "<mask>", ".", "Errorf", "(", "\"", "\"", ",", "image", ",", "repo", ",", "resolved", ")", "\n", "}", "\n\n", "return", "ostreeReference", "{", "image", ":", "image", ",", "branchName", ":", "encodeOStreeRef", "(", "image", ")", ",", "repo", ":", "resolved", ",", "}", ",", "nil", "\n", "}" ]
16,927
all-16928
[ "Write", "logs", "an", "Error", "message", "to", "a", "logger", "." ]
[ "func", "(", "lw", "ErrorLogWriter", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "lw", ".", "Error", "(", "string", "(", "<mask>", ".", "TrimRightFunc", "(", "p", ",", "unicode", ".", "IsSpace", ")", ")", ")", "\n", "return", "len", "(", "p", ")", ",", "nil", "\n", "}" ]
16,928
all-16929
[ "NewFromURL", "creates", "a", "new", "etcdv3", "client", "from", "a", "URL", "." ]
[ "func", "NewFromURL", "(", "<mask>", "string", ")", "(", "*", "Client", ",", "error", ")", "{", "return", "New", "(", "Config", "{", "Endpoints", ":", "[", "]", "string", "{", "url", "}", "}", ")", "\n", "}" ]
16,929
all-16930
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "KeyframesRule", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss32", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "<mask>", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
16,930
all-16931
[ "/", "*", "Returns", "the", "string", "that", "was", "read", "until", "the", "given", "[", "condition", "]", "was", "false", "or", "whitespace", "was", "broken", ".", "Returns", "false", "if", "the", "stream", "ended", "before", "whitespace", "was", "broken", "or", "condition", "was", "met", "." ]
[ "func", "readUntilFalse", "(", "stream", "*", "lexerStream", ",", "includeWhitespace", "bool", ",", "breakWhitespace", "bool", ",", "allowEscaping", "bool", ",", "condition", "func", "(", "rune", ")", "bool", ")", "(", "string", ",", "bool", ")", "{", "var", "tokenBuffer", "bytes", ".", "Buffer", "\n", "var", "character", "rune", "\n", "var", "conditioned", "bool", "\n\n", "conditioned", "=", "false", "\n\n", "for", "stream", ".", "canRead", "(", ")", "{", "character", "=", "<mask>", ".", "readCharacter", "(", ")", "\n\n", "// Use backslashes to escape anything", "if", "allowEscaping", "&&", "character", "==", "'\\\\'", "{", "character", "=", "stream", ".", "readCharacter", "(", ")", "\n", "tokenBuffer", ".", "WriteString", "(", "string", "(", "character", ")", ")", "\n", "continue", "\n", "}", "\n\n", "if", "unicode", ".", "IsSpace", "(", "character", ")", "{", "if", "breakWhitespace", "&&", "tokenBuffer", ".", "Len", "(", ")", ">", "0", "{", "conditioned", "=", "true", "\n", "break", "\n", "}", "\n", "if", "!", "includeWhitespace", "{", "continue", "\n", "}", "\n", "}", "\n\n", "if", "condition", "(", "character", ")", "{", "tokenBuffer", ".", "WriteString", "(", "string", "(", "character", ")", ")", "\n", "}", "else", "{", "conditioned", "=", "true", "\n", "stream", ".", "rewind", "(", "1", ")", "\n", "break", "\n", "}", "\n", "}", "\n\n", "return", "tokenBuffer", ".", "String", "(", ")", ",", "conditioned", "\n", "}" ]
16,931
all-16932
[ "Returns", "a", "signed", "URL", "for", "WebsocktunnelToken", "valid", "for", "the", "specified", "duration", ".", "Required", "scopes", ":", "auth", ":", "websocktunnel", "-", "token", ":", "<wstAudience", ">", "/", "<wstClient", ">", "See", "WebsocktunnelToken", "for", "more", "details", "." ]
[ "func", "(", "auth", "*", "Auth", ")", "WebsocktunnelToken_SignedURL", "(", "wstAudience", ",", "wstClient", "string", ",", "duration", "time", ".", "Duration", ")", "(", "*", "url", ".", "URL", ",", "error", ")", "{", "cd", ":=", "tcclient", ".", "Client", "(", "*", "auth", ")", "\n", "return", "(", "&", "cd", ")", ".", "SignedURL", "(", "\"", "\"", "+", "url", ".", "QueryEscape", "(", "wstAudience", ")", "+", "\"", "\"", "+", "url", ".", "QueryEscape", "(", "wstClient", ")", ",", "nil", ",", "<mask>", ")", "\n", "}" ]
16,932
all-16933
[ "Command", "returns", "the", "full", "command", "as", "configured", "in", "Caddyfile", "." ]
[ "func", "(", "g", "*", "gitCmd", ")", "Command", "(", ")", "string", "{", "return", "g", ".", "<mask>", "+", "\"", "\"", "+", "strings", ".", "Join", "(", "g", ".", "args", ",", "\"", "\"", ")", "\n", "}" ]
16,933
all-16934
[ "Returns", "a", "random", "rant" ]
[ "func", "(", "c", "*", "Client", ")", "Surprise", "(", ")", "(", "RantModel", ",", "error", ")", "{", "url", ":=", "fmt", ".", "Sprintf", "(", "SURPRISE_PATH", ",", "API", ",", "APP_VERSION", ")", "\n", "res", ",", "err", ":=", "http", ".", "Get", "(", "url", ")", "\n", "if", "err", "!=", "nil", "{", "return", "RantModel", "{", "}", ",", "err", "\n", "}", "\n", "var", "data", "RantResponse", "\n", "json", ".", "NewDecoder", "(", "res", ".", "Body", ")", ".", "Decode", "(", "&", "data", ")", "\n", "if", "!", "data", ".", "Success", "&&", "data", ".", "<mask>", "!=", "\"", "\"", "{", "return", "RantModel", "{", "}", ",", "errors", ".", "New", "(", "data", ".", "Error", ")", "\n", "}", "\n", "return", "data", ".", "Rant", ",", "nil", "\n", "}" ]
16,934
all-16935
[ "GetLayoutType", "returns", "the", "LayoutType", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "g", "*", "GroupDefinition", ")", "GetLayoutType", "(", ")", "<mask>", "{", "if", "g", "==", "nil", "||", "g", ".", "LayoutType", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "g", ".", "LayoutType", "\n", "}" ]
16,935
all-16936
[ "WithWorldName", "if", "specified", "creates", "an", "isolated", "world", "with", "the", "given", "name", "and", "evaluates", "given", "script", "in", "it", ".", "This", "world", "name", "will", "be", "used", "as", "the", "ExecutionContextDescription", "::", "name", "when", "the", "corresponding", "event", "is", "emitted", "." ]
[ "func", "(", "p", "AddScriptToEvaluateOnNewDocumentParams", ")", "WithWorldName", "(", "worldName", "<mask>", ")", "*", "AddScriptToEvaluateOnNewDocumentParams", "{", "p", ".", "WorldName", "=", "worldName", "\n", "return", "&", "p", "\n", "}" ]
16,936
all-16937
[ "GenerateToken", "returns", "a", "new", "token", "for", "the", "provided", "information", "." ]
[ "func", "(", "p", "*", "Policy", ")", "GenerateToken", "(", "id", "bson", ".", "ObjectId", ",", "issuedAt", ",", "expiresAt", "time", ".", "Time", ",", "client", "Client", ",", "resourceOwner", "ResourceOwner", ",", "token", "GenericToken", ")", "(", "string", ",", "error", ")", "{", "// prepare claims", "claims", ":=", "&", "TokenClaims", "{", "}", "\n", "claims", ".", "<mask>", "=", "id", ".", "Hex", "(", ")", "\n", "claims", ".", "IssuedAt", "=", "issuedAt", ".", "Unix", "(", ")", "\n", "claims", ".", "ExpiresAt", "=", "expiresAt", ".", "Unix", "(", ")", "\n\n", "// set user data", "if", "p", ".", "TokenData", "!=", "nil", "{", "claims", ".", "Data", "=", "p", ".", "TokenData", "(", "client", ",", "resourceOwner", ",", "token", ")", "\n", "}", "\n\n", "// create token", "tkn", ":=", "jwt", ".", "NewWithClaims", "(", "jwt", ".", "SigningMethodHS256", ",", "claims", ")", "\n\n", "// sign token", "str", ",", "err", ":=", "tkn", ".", "SignedString", "(", "p", ".", "Secret", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n\n", "return", "str", ",", "nil", "\n", "}" ]
16,937
all-16938
[ "UpdateAPIKey", "updates", "given", "API", "key", "(", "only", "Name", "can", "be", "updated", ")", "returns", "an", "error" ]
[ "func", "(", "client", "*", "Client", ")", "UpdateAPIKey", "(", "apikey", "*", "APIKey", ")", "error", "{", "out", ":=", "reqAPIKey", "{", "APIKey", ":", "apikey", "}", "\n", "toPost", ":=", "struct", "{", "Name", "*", "string", "`json:\"name,omitempty\"`", "\n", "}", "{", "apikey", ".", "Name", ",", "}", "\n", "return", "client", ".", "doJsonRequest", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "*", "apikey", ".", "Key", ")", ",", "toPost", ",", "&", "<mask>", ")", "\n", "}" ]
16,938
all-16939
[ "RecoverHandlerJson", "is", "a", "HTTP", "request", "middleware", "that", "captures", "panic", "errors", "and", "returns", "it", "as", "HTTP", "JSON", "response", "." ]
[ "func", "RecoverHandlerJson", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "fn", ":=", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "<mask>", ".", "Request", ")", "{", "defer", "func", "(", ")", "{", "if", "err", ":=", "recover", "(", ")", ";", "err", "!=", "nil", "{", "jerr", ":=", "NewJsonErrorFromError", "(", "http", ".", "StatusInternalServerError", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", ")", "\n", "JsonWrite", "(", "w", ",", "jerr", ".", "Status", ",", "jerr", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "next", ".", "ServeHTTP", "(", "w", ",", "r", ")", "\n", "}", "\n\n", "return", "http", ".", "HandlerFunc", "(", "fn", ")", "\n", "}" ]
16,939
all-16940
[ "NewStatsdReporter", "returns", "a", "StatsReporter", "that", "reports", "to", "statsd", "on", "the", "given", "addr", "." ]
[ "func", "NewStatsdReporter", "(", "addr", ",", "prefix", "string", ")", "(", "tchannel", ".", "StatsReporter", ",", "error", ")", "{", "client", ",", "err", ":=", "statsd", ".", "NewBufferedClient", "(", "addr", ",", "prefix", ",", "time", ".", "Second", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "NewStatsdReporterClient", "(", "<mask>", ")", ",", "nil", "\n", "}" ]
16,940
all-16941
[ "Action", "sets", "the", "handler", "that", "will", "be", "called", "after", "all", "the", "middleware", "has", "been", "invoked", ".", "This", "is", "set", "to", "macaron", ".", "Router", "in", "a", "macaron", ".", "Classic", "()", "." ]
[ "func", "(", "m", "*", "Macaron", ")", "Action", "(", "handler", "Handler", ")", "{", "handler", "=", "validateAndWrapHandler", "(", "<mask>", ")", "\n", "m", ".", "action", "=", "handler", "\n", "}" ]
16,941
all-16942
[ "Every", "calls", "the", "given", "ProcessFunc", "at", "periodic", "intervals", ".", "Internally", "it", "uses", "<", "-", "time", ".", "After", "(", "interval", ")", "so", "it", "will", "have", "the", "behavior", "of", "waiting", "_at", "least_", "interval", "in", "between", "calls", ".", "If", "you", "d", "prefer", "the", "time", ".", "Ticker", "behavior", "use", "periodicproc", ".", "Tick", "instead", ".", "This", "is", "sequentially", "rate", "limited", "only", "one", "call", "will", "be", "in", "-", "flight", "at", "a", "time", "." ]
[ "func", "Every", "(", "interval", "time", ".", "Duration", ",", "procfunc", "gp", ".", "ProcessFunc", ")", "gp", ".", "<mask>", "{", "return", "gp", ".", "Go", "(", "func", "(", "proc", "gp", ".", "Process", ")", "{", "for", "{", "select", "{", "case", "<-", "time", ".", "After", "(", "interval", ")", ":", "select", "{", "case", "<-", "proc", ".", "Go", "(", "procfunc", ")", ".", "Closed", "(", ")", ":", "// spin it out as a child, and wait till it's done.", "case", "<-", "proc", ".", "Closing", "(", ")", ":", "// we're told to close", "return", "\n", "}", "\n", "case", "<-", "proc", ".", "Closing", "(", ")", ":", "// we're told to close", "return", "\n", "}", "\n", "}", "\n", "}", ")", "\n", "}" ]
16,942
all-16943
[ "Analyze", "creates", "an", "API", "descriptor", "from", "raw", "resources", "and", "types", "." ]
[ "func", "(", "a", "*", "APIAnalyzer", ")", "Analyze", "(", ")", "(", "*", "gen", ".", "APIDescriptor", ",", "error", ")", "{", "api", ":=", "gen", ".", "APIDescriptor", "{", "Version", ":", "a", ".", "Version", ",", "Resources", ":", "make", "(", "map", "[", "string", "]", "*", "gen", ".", "Resource", ")", ",", "Types", ":", "make", "(", "map", "[", "string", "]", "*", "gen", ".", "ObjectDataType", ")", ",", "}", "\n", "a", ".", "api", "=", "&", "api", "\n\n", "sortedVerbs", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "\n", "paths", ":=", "[", "]", "string", "{", "}", "\n", "for", "path", ":=", "range", "a", ".", "Doc", ".", "Paths", "{", "paths", "=", "append", "(", "paths", ",", "path", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "paths", ")", "\n", "for", "_", ",", "path", ":=", "<mask>", "paths", "{", "endpointMap", ":=", "a", ".", "Doc", ".", "Paths", "[", "path", "]", "\n", "for", "_", ",", "verb", ":=", "range", "sortedVerbs", "{", "if", "ep", ",", "ok", ":=", "endpointMap", "[", "verb", "]", ";", "ok", "{", "a", ".", "AnalyzeEndpoint", "(", "verb", ",", "path", ",", "ep", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "a", ".", "finalize", "(", ")", "\n\n", "return", "&", "api", ",", "nil", "\n", "}" ]
16,943
all-16944
[ "Apply", "applies", "the", "given", "options", "to", "this", "Options" ]
[ "func", "(", "opts", "*", "Options", ")", "Apply", "(", "<mask>", "...", "Option", ")", "error", "{", "for", "_", ",", "o", ":=", "range", "options", "{", "if", "err", ":=", "o", "(", "opts", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
16,944
all-16945
[ "internalSize", "returns", "the", "size", "of", "the", "internal", "texture", "." ]
[ "func", "(", "i", "*", "<mask>", ")", "internalSize", "(", ")", "(", "int", ",", "int", ")", "{", "if", "i", ".", "w2", "==", "0", "||", "i", ".", "h2", "==", "0", "{", "w", ",", "h", ":=", "i", ".", "image", ".", "Size", "(", ")", "\n", "i", ".", "w2", "=", "graphics", ".", "InternalImageSize", "(", "w", ")", "\n", "i", ".", "h2", "=", "graphics", ".", "InternalImageSize", "(", "h", ")", "\n", "}", "\n", "return", "i", ".", "w2", ",", "i", ".", "h2", "\n", "}" ]
16,945
all-16946
[ "WithObjectID", "JavaScript", "object", "id", "of", "the", "node", "wrapper", "." ]
[ "func", "(", "p", "GetContentQuadsParams", ")", "WithObjectID", "(", "objectID", "runtime", ".", "RemoteObjectID", ")", "*", "GetContentQuadsParams", "{", "p", ".", "ObjectID", "=", "objectID", "\n", "<mask>", "&", "p", "\n", "}" ]
16,946
all-16947
[ "resourceVSphereComputeClusterVMHostRuleFindEntryByName", "attempts", "to", "locate", "an", "existing", "VM", "/", "host", "rule", "in", "a", "cluster", "s", "configuration", "by", "name", ".", "It", "differs", "from", "the", "standard", "resourceVSphereComputeClusterVMHostRuleFindEntry", "in", "that", "we", "don", "t", "allow", "missing", "entries", "as", "it", "s", "designed", "to", "be", "used", "in", "places", "where", "we", "don", "t", "want", "to", "allow", "for", "missing", "entries", "such", "as", "during", "creation", "and", "import", "." ]
[ "func", "resourceVSphereComputeClusterVMHostRuleFindEntryByName", "(", "cluster", "*", "object", ".", "ClusterComputeResource", ",", "<mask>", "string", ",", ")", "(", "*", "types", ".", "ClusterVmHostRuleInfo", ",", "error", ")", "{", "props", ",", "err", ":=", "clustercomputeresource", ".", "Properties", "(", "cluster", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "for", "_", ",", "info", ":=", "range", "props", ".", "ConfigurationEx", ".", "(", "*", "types", ".", "ClusterConfigInfoEx", ")", ".", "Rule", "{", "if", "info", ".", "GetClusterRuleInfo", "(", ")", ".", "Name", "==", "name", "{", "if", "vmHostRuleInfo", ",", "ok", ":=", "info", ".", "(", "*", "types", ".", "ClusterVmHostRuleInfo", ")", ";", "ok", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "name", ",", "cluster", ".", "Name", "(", ")", ")", "\n", "return", "vmHostRuleInfo", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "cluster", ".", "Name", "(", ")", ")", "\n", "}", "\n", "}", "\n\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "cluster", ".", "Name", "(", ")", ")", "\n", "}" ]
16,947
all-16948
[ "WithSilent", "in", "silent", "mode", "exceptions", "thrown", "during", "evaluation", "are", "not", "reported", "and", "do", "not", "pause", "execution", ".", "Overrides", "setPauseOnException", "state", "." ]
[ "func", "(", "p", "RunScriptParams", ")", "WithSilent", "(", "silent", "bool", ")", "*", "RunScriptParams", "{", "p", ".", "Silent", "=", "silent", "\n", "<mask>", "&", "p", "\n", "}" ]
16,948
all-16949
[ "ContainerPool", "returns", "the", "storage", "pool", "of", "a", "given", "container", ".", "This", "is", "a", "non", "-", "transactional", "variant", "of", "ClusterTx", ".", "ContainerPool", "()", "." ]
[ "func", "(", "c", "*", "Cluster", ")", "ContainerPool", "(", "<mask>", ",", "containerName", "string", ")", "(", "string", ",", "error", ")", "{", "var", "poolName", "string", "\n", "err", ":=", "c", ".", "Transaction", "(", "func", "(", "tx", "*", "ClusterTx", ")", "error", "{", "var", "err", "error", "\n", "poolName", ",", "err", "=", "tx", ".", "ContainerPool", "(", "project", ",", "containerName", ")", "\n", "return", "err", "\n", "}", ")", "\n", "return", "poolName", ",", "err", "\n", "}" ]
16,949
all-16950
[ "SendSingleActionCardMsg", "发送整体跳转ActionCard类型消息" ]
[ "func", "(", "w", "*", "Webhook", ")", "SendSingleActionCardMsg", "(", "<mask>", ",", "content", ",", "linkTitle", ",", "linkURL", "string", ",", "hideAvatar", ",", "btnOrientation", "bool", ")", "error", "{", "var", "strHideAvatar", "=", "\"", "\"", "\n", "if", "hideAvatar", "{", "strHideAvatar", "=", "\"", "\"", "\n", "}", "\n", "var", "strBtnOrientation", "=", "\"", "\"", "\n", "if", "btnOrientation", "{", "strBtnOrientation", "=", "\"", "\"", "\n", "}", "\n\n", "return", "w", ".", "SendPayload", "(", "&", "Payload", "{", "MsgType", ":", "\"", "\"", ",", "ActionCard", ":", "ActionCard", "{", "Text", ":", "content", ",", "Title", ":", "title", ",", "HideAvatar", ":", "strHideAvatar", ",", "BtnOrientation", ":", "strBtnOrientation", ",", "SingleTitle", ":", "linkTitle", ",", "SingleURL", ":", "linkURL", ",", "}", ",", "}", ")", "\n", "}" ]
16,950
all-16951
[ "Sign", "returns", "a", "signature", "of", "the", "input", "data" ]
[ "func", "(", "sk", "*", "RsaPrivateKey", ")", "Sign", "(", "message", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "hashed", ":=", "sha256", ".", "Sum256", "(", "message", ")", "\n", "return", "rsa", ".", "SignPKCS1v15", "(", "<mask>", ".", "Reader", ",", "sk", ".", "sk", ",", "crypto", ".", "SHA256", ",", "hashed", "[", ":", "]", ")", "\n", "}" ]
16,951
all-16952
[ "WriteMessage", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockWebsocketConn", ")", "WriteMessage", "(", "arg0", "int", ",", "arg1", "[", "]", "byte", ")", "error", "{", "<mask>", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
16,952
all-16953
[ "IsEqual", "()", "is", "a", "wrapper", "around", "gtk_paper_size_is_equal", "()", "." ]
[ "func", "(", "ps", "*", "PaperSize", ")", "IsEqual", "(", "<mask>", "*", "PaperSize", ")", "bool", "{", "c", ":=", "C", ".", "gtk_paper_size_is_equal", "(", "ps", ".", "native", "(", ")", ",", "other", ".", "native", "(", ")", ")", "\n", "return", "gobool", "(", "c", ")", "\n", "}" ]
16,953
all-16954
[ "InTail", "follow", "the", "tail", "of", "file", "and", "post", "BulkMessage", "to", "channel", "." ]
[ "func", "(", "t", "*", "InTail", ")", "Run", "(", "c", "*", "Context", ")", "{", "c", ".", "InputProcess", ".", "Add", "(", "1", ")", "\n", "defer", "c", ".", "InputProcess", ".", "Done", "(", ")", "\n\n", "t", ".", "messageCh", "=", "c", ".", "MessageCh", "\n", "t", ".", "monitorCh", "=", "c", ".", "MonitorCh", "\n\n", "c", ".", "StartProcess", ".", "Done", "(", ")", "\n\n", "if", "t", ".", "eventCh", "==", "nil", "{", "err", ":=", "t", ".", "TailStdin", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "Signal", ")", ";", "ok", "{", "log", ".", "Println", "(", "\"", "\"", ",", "err", ")", "\n", "}", "else", "{", "log", ".", "Println", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "}", "\n\n", "log", ".", "Println", "(", "\"", "\"", ",", "t", ".", "filename", ")", "\n", "f", ",", "err", ":=", "t", ".", "newTrailFile", "(", "SEEK_TAIL", ",", "c", ")", "\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "Signal", ")", ";", "ok", "{", "log", ".", "Println", "(", "\"", "\"", ",", "err", ")", "\n", "}", "else", "{", "log", ".", "Println", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "for", "{", "for", "{", "err", ":=", "t", ".", "watchFileEvent", "(", "f", ",", "c", ")", "\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "Signal", ")", ";", "ok", "{", "log", ".", "Println", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "else", "{", "<mask>", ".", "Println", "(", "\"", "\"", ",", "err", ")", "\n", "break", "\n", "}", "\n", "}", "\n", "}", "\n", "// re open file", "var", "err", "error", "\n", "f", ",", "err", "=", "t", ".", "newTrailFile", "(", "SEEK_HEAD", ",", "c", ")", "\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "Signal", ")", ";", "ok", "{", "log", ".", "Println", "(", "\"", "\"", ",", "err", ")", "\n", "}", "else", "{", "log", ".", "Println", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "}", "\n", "}" ]
16,954
all-16955
[ "backoff", "is", "used", "to", "compute", "an", "exponential", "backoff", "duration", ".", "Base", "time", "is", "scaled", "by", "the", "current", "round", "up", "to", "some", "maximum", "scale", "factor", "." ]
[ "func", "backoff", "(", "base", "time", ".", "Duration", ",", "round", ",", "limit", "uint64", ")", "time", ".", "Duration", "{", "power", ":=", "min", "(", "round", ",", "limit", ")", "\n", "for", "power", ">", "2", "{", "<mask>", "*=", "2", "\n", "power", "--", "\n", "}", "\n", "return", "base", "\n", "}" ]
16,955
all-16956
[ "Set", "writes", "a", "new", "value", "for", "key", "." ]
[ "func", "(", "c", "*", "Config", ")", "Set", "(", "key", ",", "value", "string", ")", "error", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n\n", "if", "_", ",", "found", ":=", "c", ".", "data", "[", "key", "]", ";", "!", "found", "{", "return", "ErrKey", "\n", "}", "\n\n", "separator", ":=", "string", "(", "c", ".", "Separator", "(", ")", ")", "\n", "replAt", ":=", "[", "]", "file", ".", "ReplacerAtLine", "{", "{", "key", "+", "separator", ",", "separator", "+", "\"", "\"", ",", "separator", "+", "value", "}", ",", "}", "\n\n", "if", "err", ":=", "file", ".", "ReplaceAtLine", "(", "c", ".", "<mask>", ",", "replAt", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "c", ".", "data", "[", "key", "]", "=", "value", "\n", "return", "nil", "\n", "}" ]
16,956
all-16957
[ "Start", "will", "start", "the", "job", "and", "periodically", "update", "it", "." ]
[ "func", "(", "ja", "*", "JobAgent", ")", "Start", "(", ")", "{", "ja", ".", "tryUpdate", "(", ")", "\n", "go", "func", "(", ")", "{", "t", ":=", "<mask>", ".", "Tick", "(", "period", ")", "\n", "for", "range", "t", "{", "ja", ".", "tryUpdate", "(", ")", "\n", "}", "\n", "}", "(", ")", "\n", "}" ]
16,957
all-16958
[ "native", "()", "returns", "a", "pointer", "to", "the", "underlying", "GtkSizeGroup" ]
[ "func", "(", "v", "*", "SizeGroup", ")", "native", "(", ")", "*", "C", ".", "GtkSizeGroup", "{", "if", "v", "==", "nil", "||", "v", ".", "GObject", "==", "nil", "{", "<mask>", "nil", "\n", "}", "\n", "p", ":=", "unsafe", ".", "Pointer", "(", "v", ".", "GObject", ")", "\n", "return", "C", ".", "toGtkSizeGroup", "(", "p", ")", "\n", "}" ]
16,958
all-16959
[ "IsEmpty", "tests", "the", "list", "to", "determine", "if", "it", "is", "populate", "or", "not", "." ]
[ "func", "(", "list", "*", "LinkedList", ")", "IsEmpty", "(", ")", "bool", "{", "list", ".", "<mask>", ".", "RLock", "(", ")", "\n", "defer", "list", ".", "key", ".", "RUnlock", "(", ")", "\n\n", "return", "list", ".", "first", "==", "nil", "\n", "}" ]
16,959
all-16960
[ "ReleaseBody", "retires", "the", "response", "body", "if", "it", "is", "greater", "than", "size", "bytes", ".", "This", "permits", "GC", "to", "reclaim", "the", "large", "buffer", ".", "If", "used", "must", "be", "before", "ReleaseResponse", ".", "Use", "this", "method", "only", "if", "you", "really", "understand", "how", "it", "works", ".", "The", "majority", "of", "workloads", "don", "t", "need", "this", "method", "." ]
[ "func", "(", "resp", "*", "Response", ")", "ReleaseBody", "(", "size", "int", ")", "{", "resp", ".", "bodyRaw", "=", "nil", "\n", "if", "cap", "(", "resp", ".", "body", ".", "B", ")", ">", "size", "{", "resp", ".", "closeBodyStream", "(", ")", "\n", "resp", ".", "<mask>", "=", "nil", "\n", "}", "\n", "}" ]
16,960
all-16961
[ "ChangeSvcModattr", "creates", "a", "new", "CHANGE_SVC_MODATTR", "Nagios", "command", ".", "This", "command", "changes", "the", "modified", "attributes", "value", "for", "the", "specified", "service", ".", "Modified", "attributes", "values", "are", "used", "by", "Nagios", "to", "determine", "which", "object", "properties", "should", "be", "retained", "across", "program", "restarts", ".", "Thus", "modifying", "the", "value", "of", "the", "attributes", "can", "affect", "data", "retention", ".", "This", "is", "an", "advanced", "option", "and", "should", "only", "be", "used", "by", "people", "who", "are", "intimately", "familiar", "with", "the", "data", "retention", "logic", "in", "Nagios", "." ]
[ "func", "ChangeSvcModattr", "(", "host_name", "string", ",", "service_description", "string", ",", "value", "string", ",", ")", "*", "livestatus", ".", "Command", "{", "return", "livestatus", ".", "NewCommand", "(", "\"", "\"", ",", "stringifyArg", "(", "\"", "\"", ",", "\"", "\"", ",", "host_name", ")", ",", "stringifyArg", "(", "\"", "\"", ",", "\"", "\"", ",", "service_description", ")", ",", "stringifyArg", "(", "\"", "\"", ",", "\"", "\"", ",", "<mask>", ")", ",", ")", "\n", "}" ]
16,961
all-16962
[ "blobExists", "returns", "true", "iff", "repo", "contains", "a", "blob", "with", "digest", "and", "if", "so", "also", "its", "size", ".", "If", "the", "destination", "does", "not", "contain", "the", "blob", "or", "it", "is", "unknown", "blobExists", "ordinarily", "returns", "(", "false", "-", "1", "nil", ")", ";", "it", "returns", "a", "non", "-", "nil", "error", "only", "on", "an", "unexpected", "failure", "." ]
[ "func", "(", "d", "*", "dockerImageDestination", ")", "blobExists", "(", "ctx", "context", ".", "Context", ",", "repo", "reference", ".", "Named", ",", "digest", "digest", ".", "Digest", ",", "extraScope", "*", "authScope", ")", "(", "bool", ",", "int64", ",", "error", ")", "{", "checkPath", ":=", "fmt", ".", "Sprintf", "(", "blobsPath", ",", "reference", ".", "Path", "(", "repo", ")", ",", "digest", ".", "String", "(", ")", ")", "\n", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "checkPath", ")", "\n", "res", ",", "err", ":=", "d", ".", "c", ".", "makeRequest", "(", "ctx", ",", "\"", "\"", ",", "checkPath", ",", "nil", ",", "nil", ",", "v2Auth", ",", "extraScope", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "-", "1", ",", "err", "\n", "}", "\n", "defer", "res", ".", "Body", ".", "Close", "(", ")", "\n", "switch", "res", ".", "StatusCode", "{", "case", "<mask>", ".", "StatusOK", ":", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n", "return", "true", ",", "getBlobSize", "(", "res", ")", ",", "nil", "\n", "case", "http", ".", "StatusUnauthorized", ":", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n", "return", "false", ",", "-", "1", ",", "errors", ".", "Wrapf", "(", "client", ".", "HandleErrorResponse", "(", "res", ")", ",", "\"", "\"", ",", "digest", ",", "repo", ".", "Name", "(", ")", ")", "\n", "case", "http", ".", "StatusNotFound", ":", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n", "return", "false", ",", "-", "1", ",", "nil", "\n", "default", ":", "return", "false", ",", "-", "1", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "reference", ".", "Path", "(", "d", ".", "ref", ".", "ref", ")", ",", "res", ".", "StatusCode", ",", "http", ".", "StatusText", "(", "res", ".", "StatusCode", ")", ")", "\n", "}", "\n", "}" ]
16,962
all-16963
[ "VerifyMessageConsumerRaw", "creates", "a", "new", "Pact", "_message_", "interaction", "to", "build", "a", "testable", "interaction", ".", "A", "Message", "Consumer", "is", "analagous", "to", "a", "Provider", "in", "the", "HTTP", "Interaction", "model", ".", "It", "is", "the", "receiver", "of", "an", "interaction", "and", "needs", "to", "be", "able", "to", "handle", "whatever", "request", "was", "provided", "." ]
[ "func", "(", "p", "*", "Pact", ")", "VerifyMessageConsumerRaw", "(", "message", "*", "Message", ",", "handler", "MessageConsumer", ")", "error", "{", "log", ".", "Printf", "(", "\"", "\"", ")", "\n", "p", ".", "Setup", "(", "false", ")", "\n\n", "// Reify the message back to its \"example/generated\" form", "reified", ",", "err", ":=", "p", ".", "pactClient", ".", "ReifyMessage", "(", "&", "types", ".", "PactReificationRequest", "{", "Message", ":", "message", ".", "Content", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "t", ":=", "reflect", ".", "TypeOf", "(", "message", ".", "Type", ")", "\n", "if", "t", "!=", "nil", "&&", "t", ".", "Name", "(", ")", "!=", "\"", "\"", "{", "log", ".", "Println", "(", "\"", "\"", ",", "t", ".", "Name", "(", ")", ")", "\n", "err", "=", "json", ".", "Unmarshal", "(", "reified", ".", "ResponseRaw", ",", "&", "message", ".", "Type", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "t", ".", "Name", "(", ")", ",", "err", ")", "\n", "}", "\n", "}", "\n\n", "// Yield message, and send through handler function", "generatedMessage", ":=", "Message", "{", "Content", ":", "message", ".", "<mask>", ",", "States", ":", "message", ".", "States", ",", "Description", ":", "message", ".", "Description", ",", "Metadata", ":", "message", ".", "Metadata", ",", "}", "\n\n", "err", "=", "handler", "(", "generatedMessage", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// If no errors, update Message Pact", "return", "p", ".", "pactClient", ".", "UpdateMessagePact", "(", "types", ".", "PactMessageRequest", "{", "Message", ":", "message", ",", "Consumer", ":", "p", ".", "Consumer", ",", "Provider", ":", "p", ".", "Provider", ",", "PactDir", ":", "p", ".", "PactDir", ",", "}", ")", "\n", "}" ]
16,963
all-16964
[ "NewFakeOpenPluginWrapper", "is", "the", "constructor", "for", "FakeOpenPluginWrapper" ]
[ "func", "NewFakeOpenPluginWrapper", "(", "plugin", "Plugin", ")", "*", "FakeOpenPluginWrapper", "{", "return", "&", "FakeOpenPluginWrapper", "{", "plugin", ":", "plugin", ",", "alreadyOpen", ":", "<mask>", "[", "string", "]", "bool", "{", "}", ",", "}", "\n", "}" ]
16,964
all-16965
[ "Create", "fetches", "credentials", "from", "ASM" ]
[ "func", "(", "auth", "*", "ASMAuthResource", ")", "Create", "(", ")", "error", "{", "seelog", ".", "Infof", "(", "\"", "\"", ",", "auth", ".", "taskARN", ")", "\n", "if", "auth", ".", "dockerAuthData", "==", "nil", "{", "auth", ".", "dockerAuthData", "=", "make", "(", "<mask>", "[", "string", "]", "types", ".", "AuthConfig", ")", "\n", "}", "\n", "for", "_", ",", "a", ":=", "range", "auth", ".", "GetRequiredASMResources", "(", ")", "{", "err", ":=", "auth", ".", "retrieveASMDockerAuthData", "(", "a", ")", "\n", "if", "err", "!=", "nil", "{", "auth", ".", "setTerminalReason", "(", "err", ".", "Error", "(", ")", ")", "\n", "return", "err", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
16,965
all-16966
[ "Sign", "adds", "the", "OAuth", "bearer", "header", "to", "the", "*", "http", ".", "Request" ]
[ "func", "(", "s", "*", "oAuthSigner", ")", "Sign", "(", "req", "*", "http", ".", "Request", ")", "error", "{", "if", "time", ".", "Now", "(", ")", ".", "After", "(", "s", ".", "refreshAt", ")", "{", "jsonStr", ":=", "fmt", ".", "Sprintf", "(", "`{\"grant_type\":\"refresh_token\",\"refresh_token\":\"%s\"}`", ",", "s", ".", "refreshToken", ")", "\n", "authReq", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "buildURL", "(", "s", ".", "host", ",", "\"", "\"", ")", ",", "bytes", ".", "NewBufferString", "(", "jsonStr", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "authReq", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "authReq", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "resp", ",", "err", ":=", "s", ".", "client", ".", "DoHidden", "(", "authReq", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "// TBD RETRY A FEW TIMES", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "var", "session", "map", "[", "string", "]", "<mask>", "{", "}", "\n", "jsonBytes", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "resp", ".", "Body", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "if", "resp", ".", "StatusCode", "!=", "200", "{", "body", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "resp", ".", "Body", ")", "\n", "var", "msg", "string", "\n", "if", "err", "!=", "nil", "{", "msg", "=", "\"", "\"", "\n", "}", "\n", "if", "len", "(", "body", ")", ">", "0", "{", "msg", "=", "\"", "\"", "+", "string", "(", "body", ")", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "resp", ".", "Status", ",", "msg", ")", "\n", "}", "\n", "err", "=", "json", ".", "Unmarshal", "(", "jsonBytes", ",", "&", "session", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "accessToken", ",", "ok", ":=", "session", "[", "\"", "\"", "]", ".", "(", "string", ")", "\n", "if", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "jsonBytes", ")", "\n", "}", "\n", "s", ".", "accessToken", "=", "accessToken", "\n", "d", ",", "err", ":=", "time", ".", "ParseDuration", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "session", "[", "\"", "\"", "]", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "s", ".", "refreshAt", "=", "time", ".", "Now", "(", ")", ".", "Add", "(", "d", "/", "2", ")", "\n", "}", "\n", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "accessToken", ")", ")", "\n", "if", "s", ".", "accountID", "!=", "0", "{", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "s", ".", "accountID", ")", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
16,966
all-16967
[ "ImagePull", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockClient", ")", "ImagePull", "(", "arg0", "context", ".", "Context", ",", "arg1", "string", ",", "arg2", "types", ".", "ImagePullOptions", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ",", "arg2", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "io", ".", "ReadCloser", ")", "\n", "ret1", ",", "_", ":=", "<mask>", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
16,967
all-16968
[ "LineReaderFrom", "returns", "a", "channel", "that", "reads", "the", "contents", "of", "a", "file", "line", "-", "by", "-", "line", "." ]
[ "func", "LineReaderFrom", "(", "path", "string", ")", "(", "<-", "chan", "string", ",", "error", ")", "{", "return", "lineReader", "(", "func", "(", ")", "(", "io", ".", "Reader", ",", "func", "(", ")", ",", "error", ")", "{", "if", "!", "FileExists", "(", "path", ")", "{", "return", "nil", ",", "nil", ",", "nil", "\n", "}", "\n", "f", ",", "err", ":=", "<mask>", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "return", "f", ",", "func", "(", ")", "{", "f", ".", "Close", "(", ")", "}", ",", "nil", "\n", "}", ")", "\n", "}" ]
16,968
all-16969
[ "AddConfig", "adds", "a", "new", "config" ]
[ "func", "(", "s", "*", "Storage", ")", "AddConfig", "(", "conf", "<mask>", ".", "ResourcesConfig", ")", "error", "{", "return", "s", ".", "configs", ".", "Add", "(", "conf", ")", "\n", "}" ]
16,969
all-16970
[ "WithBody", "adds", "the", "body", "to", "the", "patch", "apps", "app", "params" ]
[ "func", "(", "o", "*", "PatchAppsAppParams", ")", "WithBody", "(", "body", "*", "<mask>", ".", "AppWrapper", ")", "*", "PatchAppsAppParams", "{", "o", ".", "SetBody", "(", "body", ")", "\n", "return", "o", "\n", "}" ]
16,970
all-16971
[ "Create", "a", "base", "raft", "configuration", "tweaked", "for", "a", "network", "with", "the", "given", "latency", "measure", "." ]
[ "func", "raftConfig", "(", "latency", "float64", ")", "*", "raft", ".", "Config", "{", "config", ":=", "raft", ".", "DefaultConfig", "(", ")", "\n", "scale", ":=", "func", "(", "duration", "*", "time", ".", "Duration", ")", "{", "*", "duration", "=", "time", ".", "Duration", "(", "(", "math", ".", "Ceil", "(", "float64", "(", "*", "duration", ")", "*", "latency", ")", ")", ")", "\n", "}", "\n", "durations", ":=", "[", "]", "*", "time", ".", "Duration", "{", "&", "config", ".", "HeartbeatTimeout", ",", "&", "config", ".", "ElectionTimeout", ",", "&", "config", ".", "CommitTimeout", ",", "&", "config", ".", "LeaderLeaseTimeout", ",", "}", "\n", "for", "_", ",", "duration", ":=", "<mask>", "durations", "{", "scale", "(", "duration", ")", "\n", "}", "\n\n", "config", ".", "SnapshotThreshold", "=", "1024", "\n", "config", ".", "TrailingLogs", "=", "512", "\n\n", "return", "config", "\n", "}" ]
16,971
all-16972
[ "Project", "is", "local", "project", "." ]
[ "func", "tasks", "(", "p", "*", "do", ".", "Project", ")", "{", "p", ".", "Task", "(", "\"", "\"", ",", "do", ".", "S", "{", "\"", "\"", "}", ",", "nil", ")", "\n\n", "p", ".", "Task", "(", "\"", "\"", ",", "nil", ",", "func", "(", "c", "*", "do", ".", "Context", ")", "{", "c", ".", "Run", "(", "\"", "\"", ")", "\n", "}", ")", "\n\n", "p", ".", "Task", "(", "\"", "\"", ",", "nil", ",", "func", "(", "c", "*", "do", ".", "Context", ")", "{", "c", ".", "Run", "(", "\"", "\"", ")", "\n", "c", ".", "Run", "(", "\"", "\"", ")", "\n", "c", ".", "Run", "(", "\"", "\"", ")", "\n", "c", ".", "Run", "(", "\"", "\"", ")", "\n", "}", ")", "\n\n", "p", ".", "Task", "(", "\"", "\"", ",", "nil", ",", "func", "(", "c", "*", "do", ".", "Context", ")", "{", "c", ".", "Run", "(", "\"", "\"", ")", "\n\n", "packageName", ",", "_", ":=", "util", ".", "PackageName", "(", "\"", "\"", ")", "\n\n", "// add godoc link", "goa", ".", "Pipe", "(", "f", ".", "Load", "(", "\"", "\"", ")", ",", "f", ".", "Str", "(", "str", ".", "ReplaceF", "(", "\"", "\"", ",", "\"", "\\n", "\"", "+", "packageName", "+", "\"", "\\n", "\"", ",", "1", ")", ")", ",", "f", ".", "Write", "(", ")", ",", ")", "\n", "}", ")", ".", "Src", "(", "\"", "\"", ")", "\n\n", "p", ".", "Task", "(", "\"", "\"", ",", "nil", ",", "func", "(", "c", "*", "<mask>", ".", "Context", ")", "{", "c", ".", "Run", "(", "\"", "\"", ")", "\n", "}", ")", "\n", "}" ]
16,972
all-16973
[ "StartTime", "implements", "the", "Storage", "interface", "." ]
[ "func", "(", "f", "*", "fanout", ")", "StartTime", "(", ")", "(", "int64", ",", "error", ")", "{", "// StartTime of a fanout should be the earliest StartTime of all its storages,", "// both primary and secondaries.", "firstTime", ",", "err", ":=", "f", ".", "primary", ".", "StartTime", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "int64", "(", "model", ".", "Latest", ")", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "storage", ":=", "range", "f", ".", "secondaries", "{", "t", ",", "err", ":=", "storage", ".", "StartTime", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "int64", "(", "<mask>", ".", "Latest", ")", ",", "err", "\n", "}", "\n", "if", "t", "<", "firstTime", "{", "firstTime", "=", "t", "\n", "}", "\n", "}", "\n", "return", "firstTime", ",", "nil", "\n", "}" ]
16,973
all-16974
[ "SetLabel", "is", "a", "wrapper", "around", "g_menu_item_set_label", "()", "." ]
[ "func", "(", "v", "*", "MenuItem", ")", "SetLabel", "(", "label", "string", ")", "{", "cstr1", ":=", "(", "*", "C", ".", "gchar", ")", "(", "C", ".", "CString", "(", "label", ")", ")", "\n", "defer", "C", ".", "<mask>", "(", "unsafe", ".", "Pointer", "(", "cstr1", ")", ")", "\n\n", "C", ".", "g_menu_item_set_label", "(", "v", ".", "native", "(", ")", ",", "cstr1", ")", "\n", "}" ]
16,974
all-16975
[ "WriteResponse", "writes", "the", "given", "Res", "to", "the", "InboundCallResponse", "." ]
[ "func", "WriteResponse", "(", "<mask>", "*", "tchannel", ".", "InboundCallResponse", ",", "resp", "*", "Res", ")", "error", "{", "if", "resp", ".", "SystemErr", "!=", "nil", "{", "return", "response", ".", "SendSystemError", "(", "resp", ".", "SystemErr", ")", "\n", "}", "\n", "if", "resp", ".", "IsErr", "{", "if", "err", ":=", "response", ".", "SetApplicationError", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "if", "err", ":=", "tchannel", ".", "NewArgWriter", "(", "response", ".", "Arg2Writer", "(", ")", ")", ".", "Write", "(", "resp", ".", "Arg2", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "tchannel", ".", "NewArgWriter", "(", "response", ".", "Arg3Writer", "(", ")", ")", ".", "Write", "(", "resp", ".", "Arg3", ")", "\n", "}" ]
16,975
all-16976
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "SetStyleTextsParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss12", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
16,976
all-16977
[ "Returns", "the", "value", "of", "a", "uniform", "variable" ]
[ "func", "GetUniformiv", "(", "program", "uint32", ",", "<mask>", "int32", ",", "params", "*", "int32", ")", "{", "syscall", ".", "Syscall", "(", "gpGetUniformiv", ",", "3", ",", "uintptr", "(", "program", ")", ",", "uintptr", "(", "location", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "params", ")", ")", ")", "\n", "}" ]
16,977
all-16978
[ "ChompLeft", "removes", "prefix", "at", "the", "start", "of", "a", "string", "." ]
[ "func", "ChompLeft", "(", "s", ",", "<mask>", "string", ")", "string", "{", "if", "strings", ".", "HasPrefix", "(", "s", ",", "prefix", ")", "{", "return", "s", "[", "len", "(", "prefix", ")", ":", "]", "\n", "}", "\n", "return", "s", "\n", "}" ]
16,978
all-16979
[ "RequestProgress", "requests", "a", "progress", "notify", "response", "be", "sent", "in", "all", "watch", "channels", "." ]
[ "func", "(", "w", "*", "watcher", ")", "RequestProgress", "(", "ctx", "<mask>", ".", "Context", ")", "(", "err", "error", ")", "{", "ctxKey", ":=", "streamKeyFromCtx", "(", "ctx", ")", "\n\n", "w", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "w", ".", "streams", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "wgs", ":=", "w", ".", "streams", "[", "ctxKey", "]", "\n", "if", "wgs", "==", "nil", "{", "wgs", "=", "w", ".", "newWatcherGrpcStream", "(", "ctx", ")", "\n", "w", ".", "streams", "[", "ctxKey", "]", "=", "wgs", "\n", "}", "\n", "donec", ":=", "wgs", ".", "donec", "\n", "reqc", ":=", "wgs", ".", "reqc", "\n", "w", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "pr", ":=", "&", "progressRequest", "{", "}", "\n\n", "select", "{", "case", "reqc", "<-", "pr", ":", "return", "nil", "\n", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "if", "err", "==", "nil", "{", "return", "ctx", ".", "Err", "(", ")", "\n", "}", "\n", "return", "err", "\n", "case", "<-", "donec", ":", "if", "wgs", ".", "closeErr", "!=", "nil", "{", "return", "wgs", ".", "closeErr", "\n", "}", "\n", "// retry; may have dropped stream from no ctxs", "return", "w", ".", "RequestProgress", "(", "ctx", ")", "\n", "}", "\n", "}" ]
16,979
all-16980
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "put", "apps", "app", "routes", "route", "params" ]
[ "func", "(", "o", "*", "PutAppsAppRoutesRouteParams", ")", "WithTimeout", "(", "timeout", "<mask>", ".", "Duration", ")", "*", "PutAppsAppRoutesRouteParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
16,980
all-16981
[ "String", "implements", "String", "from", "the", "Stringer", "interface", "and", "allows", "results", "to", "be", "serialized", "to", "a", "sting" ]
[ "func", "(", "r", "Row", ")", "<mask>", "(", ")", "string", "{", "rStr", ":=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "r", ".", "StartTime", ".", "UTC", "(", ")", ")", "\n", "rStr", "=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "rStr", ",", "r", ".", "ElapsedTime", ")", "\n", "rStr", "=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "rStr", ",", "r", ".", "Threads", ")", "\n", "rStr", "=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "rStr", ",", "r", ".", "TotalRequests", ")", "\n", "rStr", "=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "rStr", ",", "r", ".", "AvgRequestTime", ")", "\n", "rStr", "=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "rStr", ",", "r", ".", "TotalSuccess", ")", "\n", "rStr", "=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "rStr", ",", "r", ".", "TotalTimeouts", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "rStr", ",", "r", ".", "TotalFailures", ")", "\n", "}" ]
16,981
all-16982
[ "GetIterLocation", "is", "a", "wrapper", "around", "gtk_text_view_get_iter_location", "()", "." ]
[ "func", "(", "v", "*", "TextView", ")", "GetIterLocation", "(", "iter", "*", "TextIter", ")", "*", "gdk", ".", "Rectangle", "{", "<mask>", "rect", "C", ".", "GdkRectangle", "\n", "C", ".", "gtk_text_view_get_iter_location", "(", "v", ".", "native", "(", ")", ",", "iter", ".", "native", "(", ")", ",", "&", "rect", ")", "\n", "return", "gdk", ".", "WrapRectangle", "(", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "rect", ")", ")", ")", "\n", "}" ]
16,982
all-16983
[ "return", "a", "texture", "image" ]
[ "func", "GetTexImage", "(", "target", "uint32", ",", "<mask>", "int32", ",", "format", "uint32", ",", "xtype", "uint32", ",", "pixels", "unsafe", ".", "Pointer", ")", "{", "syscall", ".", "Syscall6", "(", "gpGetTexImage", ",", "5", ",", "uintptr", "(", "target", ")", ",", "uintptr", "(", "level", ")", ",", "uintptr", "(", "format", ")", ",", "uintptr", "(", "xtype", ")", ",", "uintptr", "(", "pixels", ")", ",", "0", ")", "\n", "}" ]
16,983
all-16984
[ "saveDoc", "converts", "from", "a", "struct", "pointer", "or", "FieldLoadSaver", "/", "FieldMetadataLoadSaver", "to", "the", "Document", "protobuf", "." ]
[ "func", "saveDoc", "(", "src", "interface", "{", "}", ")", "(", "*", "pb", ".", "Document", ",", "error", ")", "{", "var", "err", "error", "\n", "var", "fields", "[", "]", "Field", "\n", "var", "meta", "*", "DocumentMetadata", "\n", "switch", "x", ":=", "src", ".", "(", "type", ")", "{", "case", "FieldLoadSaver", ":", "fields", ",", "meta", ",", "err", "=", "x", ".", "Save", "(", ")", "\n", "default", ":", "fields", ",", "meta", ",", "err", "=", "saveStructWithMeta", "(", "src", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "fieldsProto", ",", "err", ":=", "fieldsToProto", "(", "fields", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "d", ":=", "&", "<mask>", ".", "Document", "{", "Field", ":", "fieldsProto", ",", "OrderId", ":", "proto", ".", "Int32", "(", "int32", "(", "time", ".", "Since", "(", "orderIDEpoch", ")", ".", "Seconds", "(", ")", ")", ")", ",", "OrderIdSource", ":", "pb", ".", "Document_DEFAULTED", ".", "Enum", "(", ")", ",", "}", "\n", "if", "meta", "!=", "nil", "{", "if", "meta", ".", "Rank", "!=", "0", "{", "if", "!", "validDocRank", "(", "meta", ".", "Rank", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "meta", ".", "Rank", ")", "\n", "}", "\n", "*", "d", ".", "OrderId", "=", "int32", "(", "meta", ".", "Rank", ")", "\n", "d", ".", "OrderIdSource", "=", "pb", ".", "Document_SUPPLIED", ".", "Enum", "(", ")", "\n", "}", "\n", "if", "len", "(", "meta", ".", "Facets", ")", ">", "0", "{", "facets", ",", "err", ":=", "facetsToProto", "(", "meta", ".", "Facets", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "d", ".", "Facet", "=", "facets", "\n", "}", "\n", "}", "\n", "return", "d", ",", "nil", "\n", "}" ]
16,984
all-16985
[ "ForwardedResponse", "takes", "a", "request", "directed", "to", "a", "node", "and", "forwards", "it", "to", "another", "node", "writing", "back", "the", "response", "it", "gegs", "." ]
[ "func", "ForwardedResponse", "(", "client", "lxd", ".", "ContainerServer", ",", "request", "*", "http", ".", "Request", ")", "Response", "{", "return", "&", "forwardedResponse", "{", "<mask>", ":", "client", ",", "request", ":", "request", ",", "}", "\n", "}" ]
16,985
all-16986
[ "HasHideValue", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "w", "*", "WidgetConditionalFormat", ")", "HasHideValue", "(", ")", "bool", "{", "if", "w", "!=", "nil", "&&", "w", ".", "HideValue", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
16,986
all-16987
[ "DockerReferenceNamespaces", "returns", "a", "list", "of", "other", "policy", "configuration", "namespaces", "to", "search", "as", "a", "backend", "for", "ImageReference", ".", "PolicyConfigurationIdentity", ".", "The", "reference", "must", "satisfy", "!reference", ".", "IsNameOnly", "()", "." ]
[ "func", "DockerReferenceNamespaces", "(", "ref", "reference", ".", "Named", ")", "[", "]", "string", "{", "// Look for a match of the repository, and then of the possible parent", "// namespaces. Note that this only happens on the expanded host names", "// and repository names, i.e. \"busybox\" is looked up as \"docker.io/library/busybox\",", "// then in its parent \"docker.io/library\"; in none of \"busybox\",", "// un-namespaced \"library\" nor in \"\" supposedly implicitly representing \"library/\".", "//", "// ref.FullName() == ref.Hostname() + \"/\" + ref.RemoteName(), so the last", "// iteration matches the host name (for any namespace).", "res", ":=", "[", "]", "string", "{", "}", "\n", "name", ":=", "ref", ".", "Name", "(", ")", "\n", "for", "{", "res", "=", "append", "(", "<mask>", ",", "name", ")", "\n\n", "lastSlash", ":=", "strings", ".", "LastIndex", "(", "name", ",", "\"", "\"", ")", "\n", "if", "lastSlash", "==", "-", "1", "{", "break", "\n", "}", "\n", "name", "=", "name", "[", ":", "lastSlash", "]", "\n", "}", "\n", "return", "res", "\n", "}" ]
16,987
all-16988
[ "Validate", "options" ]
[ "func", "(", "opts", "*", "<mask>", ")", "Validate", "(", ")", "error", "{", "if", "len", "(", "opts", ".", "Args", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "opts", ".", "Namespaced", "=", "strings", ".", "Contains", "(", "opts", ".", "Args", "[", "0", "]", ",", "\"", "\"", ")", "\n\n", "for", "_", ",", "n", ":=", "range", "strings", ".", "Split", "(", "opts", ".", "Args", "[", "0", "]", ",", "\"", "\"", ")", "{", "opts", ".", "Parts", "=", "append", "(", "opts", ".", "Parts", ",", "name", ".", "New", "(", "n", ")", ")", "\n", "}", "\n", "opts", ".", "Name", "=", "opts", ".", "Parts", "[", "len", "(", "opts", ".", "Parts", ")", "-", "1", "]", "\n", "return", "nil", "\n", "}" ]
16,988
all-16989
[ "Watch", "returns", "a", "watch", ".", "Interface", "that", "watches", "the", "requested", "apps", "." ]
[ "func", "(", "c", "*", "FakeApps", ")", "Watch", "(", "opts", "v1", ".", "ListOptions", ")", "(", "<mask>", ".", "Interface", ",", "error", ")", "{", "return", "c", ".", "Fake", ".", "InvokesWatch", "(", "testing", ".", "NewWatchAction", "(", "appsResource", ",", "c", ".", "ns", ",", "opts", ")", ")", "\n\n", "}" ]
16,989
all-16990
[ "SafeUnmarshalBase64", "first", "decodes", "the", "provided", "reader", "from", "base64", "before", "decoding", "the", "xdr", "into", "the", "provided", "destination", ".", "Also", "ensures", "that", "the", "reader", "is", "fully", "consumed", "." ]
[ "func", "SafeUnmarshalBase64", "(", "data", "string", ",", "<mask>", "interface", "{", "}", ")", "error", "{", "count", ":=", "&", "countWriter", "{", "}", "\n", "l", ":=", "len", "(", "data", ")", "\n\n", "b64", ":=", "io", ".", "TeeReader", "(", "strings", ".", "NewReader", "(", "data", ")", ",", "count", ")", "\n", "raw", ":=", "base64", ".", "NewDecoder", "(", "base64", ".", "StdEncoding", ",", "b64", ")", "\n", "_", ",", "err", ":=", "Unmarshal", "(", "raw", ",", "dest", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "count", ".", "Count", "!=", "l", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "l", ",", "count", ".", "Count", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
16,990
all-16991
[ "Scan", "scans", "the", "current", "input", "state", "and", "assigns", "the", "given", "virtual", "gamepad", "button", "b", "to", "the", "current", "(", "pysical", ")", "pressed", "buttons", "of", "the", "gamepad", "." ]
[ "func", "(", "c", "*", "gamepadConfig", ")", "Scan", "(", "b", "virtualGamepadButton", ")", "bool", "{", "if", "!", "c", ".", "gamepadIDInitialized", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "c", ".", "initializeIfNeeded", "(", ")", "\n\n", "delete", "(", "c", ".", "buttons", ",", "b", ")", "\n", "<mask>", "(", "c", ".", "axes", ",", "b", ")", "\n\n", "ebn", ":=", "ebiten", ".", "GamepadButton", "(", "ebiten", ".", "GamepadButtonNum", "(", "c", ".", "gamepadID", ")", ")", "\n", "for", "eb", ":=", "ebiten", ".", "GamepadButton", "(", "0", ")", ";", "eb", "<", "ebn", ";", "eb", "++", "{", "if", "_", ",", "ok", ":=", "c", ".", "assignedButtons", "[", "eb", "]", ";", "ok", "{", "continue", "\n", "}", "\n", "if", "inpututil", ".", "IsGamepadButtonJustPressed", "(", "c", ".", "gamepadID", ",", "eb", ")", "{", "c", ".", "buttons", "[", "b", "]", "=", "eb", "\n", "c", ".", "assignedButtons", "[", "eb", "]", "=", "struct", "{", "}", "{", "}", "\n", "return", "true", "\n", "}", "\n", "}", "\n\n", "na", ":=", "ebiten", ".", "GamepadAxisNum", "(", "c", ".", "gamepadID", ")", "\n", "for", "a", ":=", "0", ";", "a", "<", "na", ";", "a", "++", "{", "v", ":=", "ebiten", ".", "GamepadAxis", "(", "c", ".", "gamepadID", ",", "a", ")", "\n", "const", "delta", "=", "0.25", "\n\n", "// Check |v| < 1.0 because there is a bug that a button returns", "// an axis value wrongly and the value may be over 1 on some platforms.", "if", "axisThreshold", "<=", "v", "&&", "v", "<=", "1.0", "&&", "(", "v", "<", "c", ".", "defaultAxesValues", "[", "a", "]", "-", "delta", "||", "c", ".", "defaultAxesValues", "[", "a", "]", "+", "delta", "<", "v", ")", "{", "if", "_", ",", "ok", ":=", "c", ".", "assignedAxes", "[", "axis", "{", "a", ",", "true", "}", "]", ";", "!", "ok", "{", "c", ".", "axes", "[", "b", "]", "=", "axis", "{", "a", ",", "true", "}", "\n", "c", ".", "assignedAxes", "[", "axis", "{", "a", ",", "true", "}", "]", "=", "struct", "{", "}", "{", "}", "\n", "return", "true", "\n", "}", "\n", "}", "\n", "if", "-", "1.0", "<=", "v", "&&", "v", "<=", "-", "axisThreshold", "&&", "(", "v", "<", "c", ".", "defaultAxesValues", "[", "a", "]", "-", "delta", "||", "c", ".", "defaultAxesValues", "[", "a", "]", "+", "delta", "<", "v", ")", "{", "if", "_", ",", "ok", ":=", "c", ".", "assignedAxes", "[", "axis", "{", "a", ",", "false", "}", "]", ";", "!", "ok", "{", "c", ".", "axes", "[", "b", "]", "=", "axis", "{", "a", ",", "false", "}", "\n", "c", ".", "assignedAxes", "[", "axis", "{", "a", ",", "false", "}", "]", "=", "struct", "{", "}", "{", "}", "\n", "return", "true", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
16,991
all-16992
[ "Pretty", "will", "attempt", "to", "convert", "any", "Go", "structure", "into", "a", "string", "suitable", "for", "logging" ]
[ "func", "Pretty", "(", "input", "interface", "{", "}", ")", "string", "{", "pretty", ",", "err", ":=", "json", ".", "MarshalIndent", "(", "input", ",", "\"", "\\t", "\"", ",", "\"", "\\t", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "input", ")", "\n", "}", "\n\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\\t", "\"", ",", "<mask>", ")", "\n", "}" ]
16,992
all-16993
[ "Return", "the", "name", "of", "the", "global", "variable", "holding", "the", "registration", "code", "for", "the", "given", "kind", "of", "statement", "aganst", "the", "given", "entity", "." ]
[ "func", "stmtCodeVar", "(", "entity", "string", ",", "kind", "string", ",", "filters", "...", "string", ")", "string", "{", "name", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "entity", ",", "lex", ".", "Camel", "(", "kind", ")", ")", "\n\n", "if", "len", "(", "filters", ")", ">", "0", "{", "name", "+=", "\"", "\"", "\n", "<mask>", "+=", "strings", ".", "Join", "(", "filters", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "name", "\n", "}" ]
16,993
all-16994
[ "title", ":", "app", "shell", "path", ":", "/", "apps", "/", "{", "name", "}", "/", "shell", "method", ":", "GET", "produce", ":", "Websocket", "connection", "upgrade", "responses", ":", "101", ":", "Switch", "Protocol", "to", "websocket" ]
[ "func", "remoteShellHandler", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "ws", ",", "err", ":=", "upgrader", ".", "Upgrade", "(", "w", ",", "r", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Fprintf", "(", "w", ",", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "var", "httpErr", "*", "errors", ".", "HTTP", "\n", "defer", "func", "(", ")", "{", "if", "httpErr", "!=", "nil", "{", "var", "msg", "string", "\n", "switch", "httpErr", ".", "Code", "{", "case", "http", ".", "StatusUnauthorized", ":", "msg", "=", "\"", "\\n", "\"", "\n", "default", ":", "msg", "=", "httpErr", ".", "Message", "+", "\"", "\\n", "\"", "\n", "}", "\n", "ws", ".", "WriteMessage", "(", "websocket", ".", "TextMessage", ",", "[", "]", "byte", "(", "\"", "\"", "+", "msg", ")", ")", "\n", "}", "\n", "ws", ".", "WriteMessage", "(", "websocket", ".", "CloseMessage", ",", "websocket", ".", "FormatCloseMessage", "(", "websocket", ".", "CloseNormalClosure", ",", "\"", "\"", ")", ")", "\n", "ws", ".", "Close", "(", ")", "\n", "}", "(", ")", "\n", "<mask>", ":=", "context", ".", "GetAuthToken", "(", "r", ")", "\n", "if", "token", "==", "nil", "{", "httpErr", "=", "&", "errors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusUnauthorized", ",", "Message", ":", "\"", "\"", ",", "}", "\n", "return", "\n", "}", "\n", "appName", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "a", ",", "err", ":=", "getAppFromContext", "(", "appName", ",", "r", ")", "\n", "if", "err", "!=", "nil", "{", "if", "herr", ",", "ok", ":=", "err", ".", "(", "*", "errors", ".", "HTTP", ")", ";", "ok", "{", "httpErr", "=", "herr", "\n", "}", "else", "{", "httpErr", "=", "&", "errors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusInternalServerError", ",", "Message", ":", "err", ".", "Error", "(", ")", ",", "}", "\n", "}", "\n", "return", "\n", "}", "\n", "allowed", ":=", "permission", ".", "Check", "(", "token", ",", "permission", ".", "PermAppRunShell", ",", "contextsForApp", "(", "&", "a", ")", "...", ")", "\n", "if", "!", "allowed", "{", "httpErr", "=", "permission", ".", "ErrUnauthorized", "\n", "return", "\n", "}", "\n", "buf", ":=", "&", "optionalWriterCloser", "{", "}", "\n", "var", "term", "*", "terminal", ".", "Terminal", "\n", "unitID", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "isolated", ",", "_", ":=", "strconv", ".", "ParseBool", "(", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", ")", "\n", "width", ",", "_", ":=", "strconv", ".", "Atoi", "(", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", ")", "\n", "height", ",", "_", ":=", "strconv", ".", "Atoi", "(", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", ")", "\n", "clientTerm", ":=", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", "\n", "evt", ",", "err", ":=", "event", ".", "New", "(", "&", "event", ".", "Opts", "{", "Target", ":", "appTarget", "(", "appName", ")", ",", "Kind", ":", "permission", ".", "PermAppRunShell", ",", "Owner", ":", "token", ",", "CustomData", ":", "event", ".", "FormToCustomData", "(", "InputFields", "(", "r", ")", ")", ",", "Allowed", ":", "event", ".", "Allowed", "(", "permission", ".", "PermAppReadEvents", ",", "contextsForApp", "(", "&", "a", ")", "...", ")", ",", "DisableLock", ":", "true", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "httpErr", "=", "&", "errors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusInternalServerError", ",", "Message", ":", "err", ".", "Error", "(", ")", ",", "}", "\n", "return", "\n", "}", "\n", "defer", "func", "(", ")", "{", "var", "finalErr", "error", "\n", "if", "httpErr", "!=", "nil", "{", "finalErr", "=", "httpErr", "\n", "}", "\n", "for", "term", "!=", "nil", "{", "buf", ".", "disableWrite", "=", "true", "\n", "var", "line", "string", "\n", "line", ",", "err", "=", "term", ".", "ReadLine", "(", ")", "\n", "if", "err", "!=", "nil", "{", "break", "\n", "}", "\n", "fmt", ".", "Fprintf", "(", "evt", ",", "\"", "\\n", "\"", ",", "line", ")", "\n", "}", "\n", "evt", ".", "Done", "(", "finalErr", ")", "\n", "}", "(", ")", "\n", "term", "=", "terminal", ".", "NewTerminal", "(", "buf", ",", "\"", "\"", ")", "\n", "ws", ".", "SetReadDeadline", "(", "time", ".", "Now", "(", ")", ".", "Add", "(", "pongWait", ")", ")", "\n", "ws", ".", "SetPongHandler", "(", "func", "(", "string", ")", "error", "{", "ws", ".", "SetReadDeadline", "(", "time", ".", "Now", "(", ")", ".", "Add", "(", "pongWait", ")", ")", "\n", "return", "nil", "\n", "}", ")", "\n", "quit", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "defer", "close", "(", "quit", ")", "\n", "go", "func", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "quit", ":", "return", "\n", "case", "<-", "time", ".", "After", "(", "pingInterval", ")", ":", "}", "\n", "ws", ".", "WriteControl", "(", "websocket", ".", "PingMessage", ",", "nil", ",", "time", ".", "Now", "(", ")", ".", "Add", "(", "2", "*", "time", ".", "Second", ")", ")", "\n", "}", "\n", "}", "(", ")", "\n", "conn", ":=", "&", "cmdLogger", "{", "base", ":", "&", "wsReadWriteCloser", "{", "ws", "}", ",", "term", ":", "term", "}", "\n", "opts", ":=", "provision", ".", "ExecOptions", "{", "Stdout", ":", "conn", ",", "Stderr", ":", "conn", ",", "Stdin", ":", "conn", ",", "Width", ":", "width", ",", "Height", ":", "height", ",", "Units", ":", "unitsForShell", "(", "a", ",", "unitID", ",", "isolated", ")", ",", "Term", ":", "clientTerm", ",", "}", "\n", "err", "=", "a", ".", "Shell", "(", "opts", ")", "\n", "if", "err", "!=", "nil", "{", "httpErr", "=", "&", "errors", ".", "HTTP", "{", "Code", ":", "http", ".", "StatusInternalServerError", ",", "Message", ":", "err", ".", "Error", "(", ")", ",", "}", "\n", "}", "\n", "}" ]
16,994
all-16995
[ "watchCommandFunc", "executes", "the", "watch", "command", "." ]
[ "func", "watchCommandFunc", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "envKey", ",", "envRange", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", ",", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "envKey", "==", "\"", "\"", "&&", "envRange", "!=", "\"", "\"", "{", "ExitWithError", "(", "ExitBadArgs", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "envRange", ")", ")", "\n", "}", "\n\n", "if", "watchInteractive", "{", "watchInteractiveFunc", "(", "cmd", ",", "os", ".", "Args", ",", "envKey", ",", "envRange", ")", "\n", "return", "\n", "}", "\n\n", "watchArgs", ",", "execArgs", ",", "err", ":=", "parseWatchArgs", "(", "os", ".", "Args", ",", "args", ",", "envKey", ",", "envRange", ",", "<mask>", ")", "\n", "if", "err", "!=", "nil", "{", "ExitWithError", "(", "ExitBadArgs", ",", "err", ")", "\n", "}", "\n\n", "c", ":=", "mustClientFromCmd", "(", "cmd", ")", "\n", "wc", ",", "err", ":=", "getWatchChan", "(", "c", ",", "watchArgs", ")", "\n", "if", "err", "!=", "nil", "{", "ExitWithError", "(", "ExitBadArgs", ",", "err", ")", "\n", "}", "\n\n", "printWatchCh", "(", "c", ",", "wc", ",", "execArgs", ")", "\n", "if", "err", "=", "c", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "ExitWithError", "(", "ExitBadConnection", ",", "err", ")", "\n", "}", "\n", "ExitWithError", "(", "ExitInterrupted", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "}" ]
16,995
all-16996
[ "HTTPMembers", "returns", "a", "list", "of", "all", "active", "members", "as", "client", ".", "Members" ]
[ "func", "(", "c", "*", "cluster", ")", "HTTPMembers", "(", ")", "[", "]", "client", ".", "Member", "{", "ms", ":=", "[", "]", "<mask>", ".", "Member", "{", "}", "\n", "for", "_", ",", "m", ":=", "range", "c", ".", "Members", "{", "pScheme", ":=", "schemeFromTLSInfo", "(", "m", ".", "PeerTLSInfo", ")", "\n", "cScheme", ":=", "schemeFromTLSInfo", "(", "m", ".", "ClientTLSInfo", ")", "\n", "cm", ":=", "client", ".", "Member", "{", "Name", ":", "m", ".", "Name", "}", "\n", "for", "_", ",", "ln", ":=", "range", "m", ".", "PeerListeners", "{", "cm", ".", "PeerURLs", "=", "append", "(", "cm", ".", "PeerURLs", ",", "pScheme", "+", "\"", "\"", "+", "ln", ".", "Addr", "(", ")", ".", "String", "(", ")", ")", "\n", "}", "\n", "for", "_", ",", "ln", ":=", "range", "m", ".", "ClientListeners", "{", "cm", ".", "ClientURLs", "=", "append", "(", "cm", ".", "ClientURLs", ",", "cScheme", "+", "\"", "\"", "+", "ln", ".", "Addr", "(", ")", ".", "String", "(", ")", ")", "\n", "}", "\n", "ms", "=", "append", "(", "ms", ",", "cm", ")", "\n", "}", "\n", "return", "ms", "\n", "}" ]
16,996
all-16997
[ "ServeErrorPage", "Implements", "ErrorHandler", ".", "ServeErrorPage" ]
[ "func", "(", "e", "ErrorHandlerFunc", ")", "ServeErrorPage", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "<mask>", ".", "Request", ",", "status", "int", ",", "err", "error", ")", "{", "e", "(", "ctx", ",", "w", ",", "r", ",", "status", ",", "err", ")", "\n", "}" ]
16,997
all-16998
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "EventScreenshotRequested", ")", "UnmarshalJSON", "(", "<mask>", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoOverlay17", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
16,998
all-16999
[ "getStringValue", "returns", "a", "value", "for", "a", "given", "key", "as", "type", "interface", "which", "is", "converted", "to", "actual", "return", "type", "by", "individual", "Get", "*", "functions", "." ]
[ "func", "(", "c", "GConfig", ")", "getStringValue", "(", "<mask>", "string", ")", "string", "{", "v", ":=", "c", ".", "getValue", "(", "key", ")", "\n", "strV", ":=", "v", ".", "(", "string", ")", "\n", "if", "s", ".", "HasPrefix", "(", "strV", ",", "\"", "\"", ")", "&&", "s", ".", "HasSuffix", "(", "strV", ",", "\"", "\"", ")", "{", "return", "os", ".", "ExpandEnv", "(", "strV", ")", "\n", "}", "\n\n", "return", "strV", "\n", "}" ]
16,999
all-17000
[ "Add", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockCgroup", ")", "Add", "(", "arg0", "cgroups", ".", "Process", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "<mask>", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]