id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
1,800
all-1801
[ "Detaches", "a", "shader", "object", "from", "a", "program", "object", "to", "which", "it", "is", "attached" ]
[ "func", "DetachShader", "(", "<mask>", "uint32", ",", "shader", "uint32", ")", "{", "C", ".", "glowDetachShader", "(", "gpDetachShader", ",", "(", "C", ".", "GLuint", ")", "(", "program", ")", ",", "(", "C", ".", "GLuint", ")", "(", "shader", ")", ")", "\n", "}" ]
1,801
all-1802
[ "SetUInt", "is", "a", "wrapper", "around", "g_settings_set_uint", "()", "." ]
[ "func", "(", "v", "*", "Settings", ")", "SetUInt", "(", "name", "string", ",", "value", "uint", ")", "bool", "{", "cstr1", ":=", "(", "*", "C", ".", "gchar", ")", "(", "C", ".", "CString", "(", "name", ")", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cstr1", ")", ")", "\n\n", "return", "gobool", "(", "C", ".", "g_settings_set_uint", "(", "v", ".", "native", "(", ")", ",", "cstr1", ",", "C", ".", "guint", "(", "<mask>", ")", ")", ")", "\n", "}" ]
1,802
all-1803
[ "WithApp", "adds", "the", "app", "to", "the", "post", "apps", "app", "routes", "params" ]
[ "func", "(", "o", "*", "PostAppsAppRoutesParams", ")", "WithApp", "(", "app", "<mask>", ")", "*", "PostAppsAppRoutesParams", "{", "o", ".", "SetApp", "(", "app", ")", "\n", "return", "o", "\n", "}" ]
1,803
all-1804
[ "sortBuilds", "converts", "all", "build", "from", "str", "to", "int", "and", "sorts", "all", "builds", "in", "descending", "order", "and", "returns", "the", "sorted", "slice" ]
[ "func", "sortBuilds", "(", "strBuilds", "[", "]", "string", ")", "[", "]", "int", "{", "var", "res", "[", "]", "int", "\n", "for", "_", ",", "buildStr", ":=", "<mask>", "strBuilds", "{", "num", ",", "err", ":=", "strconv", ".", "Atoi", "(", "buildStr", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "Infof", "(", "\"", "\"", ",", "buildStr", ")", "\n", "}", "else", "{", "res", "=", "append", "(", "res", ",", "num", ")", "\n", "}", "\n", "}", "\n", "sort", ".", "Sort", "(", "sort", ".", "Reverse", "(", "sort", ".", "IntSlice", "(", "res", ")", ")", ")", "\n", "return", "res", "\n", "}" ]
1,804
all-1805
[ "Parse", "creates", "an", "AST", "tree", "for", "XPath", "expressions", "." ]
[ "func", "Parse", "(", "xp", "string", ")", "(", "*", "Node", ",", "error", ")", "{", "var", "err", "error", "\n", "c", ":=", "lexer", ".", "Lex", "(", "xp", ")", "\n", "n", ":=", "&", "Node", "{", "}", "\n", "p", ":=", "&", "parseStack", "{", "cur", ":", "n", "}", "\n\n", "for", "next", ":=", "range", "c", "{", "if", "next", ".", "Typ", "!=", "lexer", ".", "XItemError", "{", "parseMap", "[", "next", ".", "Typ", "]", "(", "p", ",", "<mask>", ")", "\n", "}", "else", "if", "err", "==", "nil", "{", "err", "=", "fmt", ".", "Errorf", "(", "next", ".", "Val", ")", "\n", "}", "\n", "}", "\n\n", "return", "n", ",", "err", "\n", "}" ]
1,805
all-1806
[ "ReadObject", "implements", "ObjectStream", "." ]
[ "func", "(", "t", "*", "bufferedObjectStream", ")", "ReadObject", "(", "v", "<mask>", "{", "}", ")", "error", "{", "return", "t", ".", "codec", ".", "ReadObject", "(", "t", ".", "r", ",", "v", ")", "\n", "}" ]
1,806
all-1807
[ "IsEquivalent", "returns", "true", "if", "other", "represents", "the", "same", "data", "type", "as", "the", "target", "." ]
[ "func", "(", "e", "*", "SourceUploadDataType", ")", "IsEquivalent", "(", "other", "DataType", ")", "bool", "{", "_", ",", "ok", ":=", "other", ".", "(", "*", "SourceUploadDataType", ")", "\n", "return", "<mask>", "\n", "}" ]
1,807
all-1808
[ "UpdatePassword", "updates", "the", "password", "." ]
[ "func", "(", "h", "*", "Handler", ")", "UpdatePassword", "(", "current", ",", "new", "string", ")", "error", "{", "logger", ":=", "h", ".", "logger", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "if", "err", ":=", "h", ".", "checkPassword", "(", "logger", ",", "current", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "logger", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "if", "new", "==", "\"", "\"", "{", "logger", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "ErrEmptyPassword", "\n", "}", "\n\n", "salt", ":=", "util", ".", "NewUUID", "(", ")", "\n\n", "hashed", ",", "err", ":=", "hashedPassword", "(", "logger", ",", "new", ",", "salt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "tx", ",", "err", ":=", "beginTX", "(", "logger", ",", "h", ".", "db", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "tx", ".", "Rollback", "(", ")", "\n\n", "if", "err", ":=", "h", ".", "updatePrivateKeys", "(", "logger", ",", "tx", ",", "current", ",", "new", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "err", ":=", "<mask>", "(", "logger", ",", "tx", ".", "Querier", ",", "saltSetting", "(", "salt", ")", ",", "passwordHashSetting", "(", "hashed", ")", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "commitTX", "(", "logger", ",", "tx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "h", ".", "token", ".", "Make", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
1,808
all-1809
[ "Fetch", "returns", "a", "peer", "matching", "the", "passed", "name", "without", "incrementing", "its", "refcount", ".", "If", "no", "matching", "peer", "is", "found", "Fetch", "returns", "nil", "." ]
[ "func", "(", "peers", "*", "Peers", ")", "Fetch", "(", "<mask>", "PeerName", ")", "*", "Peer", "{", "peers", ".", "RLock", "(", ")", "\n", "defer", "peers", ".", "RUnlock", "(", ")", "\n", "return", "peers", ".", "byName", "[", "name", "]", "\n", "}" ]
1,809
all-1810
[ "GetTime", "returns", "the", "current", "Time", "(", "100s", "of", "nanoseconds", "since", "15", "Oct", "1582", ")", "and", "adjusts", "the", "clock", "sequence", "as", "needed", ".", "An", "error", "is", "returned", "if", "the", "current", "time", "cannot", "be", "determined", "." ]
[ "func", "GetTime", "(", ")", "(", "Time", ",", "error", ")", "{", "t", ":=", "timeNow", "(", ")", "\n\n", "// If we don't have a clock sequence already, set one.", "if", "clock_seq", "==", "0", "{", "SetClockSequence", "(", "-", "1", ")", "\n", "}", "\n", "now", ":=", "uint64", "(", "t", ".", "UnixNano", "(", ")", "/", "100", ")", "+", "g1582ns100", "\n\n", "// If time has gone backwards with this clock sequence then we", "// increment the clock sequence", "if", "now", "<=", "lasttime", "{", "clock_seq", "=", "(", "(", "clock_seq", "+", "1", ")", "&", "0x3fff", ")", "|", "0x8000", "\n", "}", "\n", "lasttime", "=", "<mask>", "\n", "return", "Time", "(", "now", ")", ",", "nil", "\n", "}" ]
1,810
all-1811
[ "GetCorsInfo", "derives", "CorsInfo", "from", "Request", "." ]
[ "func", "(", "r", "*", "Request", ")", "GetCorsInfo", "(", ")", "*", "CorsInfo", "{", "origin", ":=", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n\n", "var", "originUrl", "*", "url", ".", "URL", "\n", "var", "isCors", "bool", "\n\n", "if", "origin", "==", "\"", "\"", "{", "isCors", "=", "false", "\n", "}", "else", "if", "origin", "==", "\"", "\"", "{", "isCors", "=", "true", "\n", "}", "else", "{", "<mask>", "err", "error", "\n", "originUrl", ",", "err", "=", "url", ".", "ParseRequestURI", "(", "origin", ")", "\n", "isCors", "=", "err", "==", "nil", "&&", "r", ".", "Host", "!=", "originUrl", ".", "Host", "\n", "}", "\n\n", "reqMethod", ":=", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n\n", "reqHeaders", ":=", "[", "]", "string", "{", "}", "\n", "rawReqHeaders", ":=", "r", ".", "Header", "[", "http", ".", "CanonicalHeaderKey", "(", "\"", "\"", ")", "]", "\n", "for", "_", ",", "rawReqHeader", ":=", "range", "rawReqHeaders", "{", "if", "len", "(", "rawReqHeader", ")", "==", "0", "{", "continue", "\n", "}", "\n", "// net/http does not handle comma delimited headers for us", "for", "_", ",", "reqHeader", ":=", "range", "strings", ".", "Split", "(", "rawReqHeader", ",", "\"", "\"", ")", "{", "reqHeaders", "=", "append", "(", "reqHeaders", ",", "http", ".", "CanonicalHeaderKey", "(", "strings", ".", "TrimSpace", "(", "reqHeader", ")", ")", ")", "\n", "}", "\n", "}", "\n\n", "isPreflight", ":=", "isCors", "&&", "r", ".", "Method", "==", "\"", "\"", "&&", "reqMethod", "!=", "\"", "\"", "\n\n", "return", "&", "CorsInfo", "{", "IsCors", ":", "isCors", ",", "IsPreflight", ":", "isPreflight", ",", "Origin", ":", "origin", ",", "OriginUrl", ":", "originUrl", ",", "AccessControlRequestMethod", ":", "strings", ".", "ToUpper", "(", "reqMethod", ")", ",", "AccessControlRequestHeaders", ":", "reqHeaders", ",", "}", "\n", "}" ]
1,811
all-1812
[ "HTTPPostForm", "performs", "a", "HTTP", "POST", "request", "with", "data", "as", "application", "/", "x", "-", "www", "-", "form", "-", "urlencoded" ]
[ "func", "HTTPPostForm", "(", "url", "string", ",", "data", "url", ".", "Values", ")", "(", "statusCode", "int", ",", "statusText", "string", ",", "err", "error", ")", "{", "request", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "url", ",", "strings", ".", "NewReader", "(", "data", ".", "Encode", "(", ")", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "request", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "response", ",", "err", ":=", "<mask>", ".", "DefaultClient", ".", "Do", "(", "request", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "response", ".", "StatusCode", ",", "response", ".", "Status", ",", "nil", "\n", "}" ]
1,812
all-1813
[ "String", "implements", "the", "Stringer", "interface" ]
[ "func", "(", "n", "ImageName", ")", "String", "(", ")", "string", "{", "buf", ":=", "bytes", ".", "Buffer", "{", "}", "\n", "if", "n", ".", "Registry", "!=", "\"", "\"", "{", "buf", ".", "WriteString", "(", "n", ".", "Registry", ")", "\n", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "n", ".", "Repository", "!=", "\"", "\"", "{", "buf", ".", "WriteString", "(", "n", ".", "Repository", ")", "\n", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "}", "\n", "buf", ".", "WriteString", "(", "n", ".", "Name", ")", "\n", "if", "n", ".", "Digest", "!=", "\"", "\"", "{", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "buf", ".", "WriteString", "(", "n", ".", "Digest", ")", "\n", "}", "else", "{", "buf", ".", "WriteString", "(", "\"", "\"", ")", "\n", "buf", ".", "WriteString", "(", "n", ".", "Tag", ")", "\n", "}", "\n", "return", "buf", ".", "<mask>", "(", ")", "\n", "}" ]
1,813
all-1814
[ "Records", "returns", "the", "list", "of", "records", "in", "a", "given", "hosted", "zone", "." ]
[ "func", "(", "p", "*", "OCIProvider", ")", "Records", "(", ")", "(", "[", "]", "*", "endpoint", ".", "Endpoint", ",", "error", ")", "{", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "zones", ",", "err", ":=", "p", ".", "zones", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "endpoints", ":=", "[", "]", "*", "endpoint", ".", "Endpoint", "{", "}", "\n", "for", "_", ",", "zone", ":=", "range", "zones", "{", "var", "page", "*", "string", "\n", "for", "{", "resp", ",", "err", ":=", "p", ".", "client", ".", "GetZoneRecords", "(", "ctx", ",", "dns", ".", "GetZoneRecordsRequest", "{", "ZoneNameOrId", ":", "zone", ".", "Id", ",", "Page", ":", "page", ",", "CompartmentId", ":", "&", "p", ".", "cfg", ".", "CompartmentID", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "<mask>", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "*", "zone", ".", "Id", ")", "\n", "}", "\n\n", "for", "_", ",", "record", ":=", "range", "resp", ".", "Items", "{", "if", "!", "supportedRecordType", "(", "*", "record", ".", "Rtype", ")", "{", "continue", "\n", "}", "\n", "endpoints", "=", "append", "(", "endpoints", ",", "endpoint", ".", "NewEndpointWithTTL", "(", "*", "record", ".", "Domain", ",", "*", "record", ".", "Rtype", ",", "endpoint", ".", "TTL", "(", "*", "record", ".", "Ttl", ")", ",", "*", "record", ".", "Rdata", ",", ")", ",", ")", "\n", "}", "\n\n", "if", "page", "=", "resp", ".", "OpcNextPage", ";", "resp", ".", "OpcNextPage", "==", "nil", "{", "break", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "endpoints", ",", "nil", "\n", "}" ]
1,814
all-1815
[ "Head", "is", "a", "shortcut", "method", "that", "instantiates", "a", "HEAD", "route", ".", "See", "the", "Route", "object", "the", "parameters", "definitions", ".", "Equivalent", "to", "&Route", "{", "HEAD", "pathExp", "handlerFunc", "}" ]
[ "func", "Head", "(", "pathExp", "string", ",", "handlerFunc", "HandlerFunc", ")", "*", "<mask>", "{", "return", "&", "Route", "{", "HttpMethod", ":", "\"", "\"", ",", "PathExp", ":", "pathExp", ",", "Func", ":", "handlerFunc", ",", "}", "\n", "}" ]
1,815
all-1816
[ "establish", "the", "data", "storage", "format", "dimensions", "and", "number", "of", "samples", "of", "a", "multisample", "texture", "s", "image" ]
[ "func", "TexImage3DMultisample", "(", "target", "uint32", ",", "samples", "int32", ",", "internalformat", "uint32", ",", "width", "int32", ",", "height", "int32", ",", "<mask>", "int32", ",", "fixedsamplelocations", "bool", ")", "{", "C", ".", "glowTexImage3DMultisample", "(", "gpTexImage3DMultisample", ",", "(", "C", ".", "GLenum", ")", "(", "target", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "samples", ")", ",", "(", "C", ".", "GLenum", ")", "(", "internalformat", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "width", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "height", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "depth", ")", ",", "(", "C", ".", "GLboolean", ")", "(", "boolToInt", "(", "fixedsamplelocations", ")", ")", ")", "\n", "}" ]
1,816
all-1817
[ "ApplicationGetDefault", "is", "a", "wrapper", "around", "g_application_get_default", "()", "." ]
[ "func", "ApplicationGetDefault", "(", ")", "*", "<mask>", "{", "c", ":=", "C", ".", "g_application_get_default", "(", ")", "\n", "if", "c", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "wrapApplication", "(", "wrapObject", "(", "unsafe", ".", "Pointer", "(", "c", ")", ")", ")", "\n", "}" ]
1,817
all-1818
[ "EdgeDriver", "returns", "an", "instance", "of", "a", "EdgeDriver", "WebDriver", ".", "Provided", "Options", "will", "apply", "as", "default", "arguments", "for", "new", "pages", ".", "New", "pages", "will", "accept", "invalid", "SSL", "certificates", "by", "default", ".", "This", "may", "be", "disabled", "using", "the", "RejectInvalidSSL", "Option", "." ]
[ "func", "EdgeDriver", "(", "options", "...", "Option", ")", "*", "WebDriver", "{", "<mask>", "binaryName", "string", "\n", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "binaryName", "=", "\"", "\"", "\n", "}", "else", "{", "return", "nil", "\n", "}", "\n", "command", ":=", "[", "]", "string", "{", "binaryName", ",", "\"", "\"", "}", "\n", "// Using {{.Address}} means using 127.0.0.1", "// But MicrosoftWebDriver only supports localhost, not 127.0.0.1", "return", "NewWebDriver", "(", "\"", "\"", ",", "command", ",", "options", "...", ")", "\n", "}" ]
1,818
all-1819
[ "Insert3", "is", "more", "verbose", "version", "of", "Insert2" ]
[ "func", "(", "s", "*", "Skiplist", ")", "Insert3", "(", "itm", "unsafe", ".", "Pointer", ",", "insCmp", "CompareFn", ",", "eqCmp", "CompareFn", ",", "buf", "*", "ActionBuffer", ",", "itemLevel", "int", ",", "skipFindPath", "bool", ",", "sts", "*", "Stats", ")", "(", "*", "Node", ",", "bool", ")", "{", "token", ":=", "s", ".", "barrier", ".", "Acquire", "(", ")", "\n", "defer", "s", ".", "barrier", ".", "Release", "(", "token", ")", "\n\n", "x", ":=", "s", ".", "newNode", "(", "itm", ",", "itemLevel", ")", "\n\n", "retry", ":", "if", "skipFindPath", "{", "skipFindPath", "=", "false", "\n", "}", "else", "{", "if", "s", ".", "findPath", "(", "itm", ",", "insCmp", ",", "buf", ",", "sts", ")", "!=", "nil", "||", "eqCmp", "!=", "nil", "&&", "compare", "(", "eqCmp", ",", "itm", ",", "buf", ".", "preds", "[", "0", "]", ".", "Item", "(", ")", ")", "==", "0", "{", "s", ".", "freeNode", "(", "x", ")", "\n", "return", "nil", ",", "false", "\n", "}", "\n", "}", "\n\n", "// Set all next links for the node non-atomically", "for", "i", ":=", "0", ";", "i", "<=", "int", "(", "itemLevel", ")", ";", "i", "++", "{", "x", ".", "setNext", "(", "i", ",", "buf", ".", "succs", "[", "i", "]", ",", "false", ")", "\n", "}", "\n\n", "// Now node is part of the skiplist", "if", "!", "buf", ".", "preds", "[", "0", "]", ".", "dcasNext", "(", "0", ",", "buf", ".", "succs", "[", "0", "]", ",", "x", ",", "false", ",", "false", ")", "{", "sts", ".", "AddUint64", "(", "&", "sts", ".", "insertConflicts", ",", "1", ")", "\n", "goto", "retry", "\n", "}", "\n\n", "// Add to index levels", "for", "i", ":=", "1", ";", "i", "<=", "int", "(", "itemLevel", ")", ";", "i", "++", "{", "fixThisLevel", ":", "for", "{", "nodeNext", ",", "deleted", ":=", "x", ".", "getNext", "(", "i", ")", "\n", "next", ":=", "buf", ".", "succs", "[", "i", "]", "\n\n", "// Update the node's next pointer at current level if required.", "// This is the only thread which can modify next pointer at this level", "// The dcas operation can fail only if another thread marked delete", "if", "deleted", "||", "(", "nodeNext", "!=", "next", "&&", "!", "x", ".", "dcasNext", "(", "i", ",", "nodeNext", ",", "next", ",", "false", ",", "false", ")", ")", "{", "goto", "finished", "\n", "}", "\n\n", "if", "buf", ".", "preds", "[", "i", "]", ".", "dcasNext", "(", "i", ",", "next", ",", "x", ",", "false", ",", "<mask>", ")", "{", "break", "fixThisLevel", "\n", "}", "\n\n", "s", ".", "findPath", "(", "itm", ",", "insCmp", ",", "buf", ",", "sts", ")", "\n", "}", "\n", "}", "\n\n", "finished", ":", "sts", ".", "AddInt64", "(", "&", "sts", ".", "nodeAllocs", ",", "1", ")", "\n", "sts", ".", "AddInt64", "(", "&", "sts", ".", "levelNodesCount", "[", "itemLevel", "]", ",", "1", ")", "\n", "sts", ".", "AddInt64", "(", "&", "sts", ".", "usedBytes", ",", "int64", "(", "s", ".", "Size", "(", "x", ")", ")", ")", "\n", "return", "x", ",", "true", "\n", "}" ]
1,819
all-1820
[ "UpdateSecretRequest", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockSecretsManagerAPI", ")", "UpdateSecretRequest", "(", "arg0", "*", "secretsmanager", ".", "UpdateSecretInput", ")", "(", "*", "request", ".", "<mask>", ",", "*", "secretsmanager", ".", "UpdateSecretOutput", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "*", "request", ".", "Request", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "*", "secretsmanager", ".", "UpdateSecretOutput", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
1,820
all-1821
[ "Publish", "data", "to", "given", "channel", "." ]
[ "func", "(", "hub", "*", "hub", ")", "Publish", "(", "channels", "[", "]", "string", ",", "msg", "interface", "{", "}", ")", "{", "for", "_", ",", "name", ":=", "range", "channels", "{", "var", "cn", "=", "hub", ".", "getChannel", "(", "<mask>", ")", "\n", "cn", ".", "Publish", "(", "msg", ")", "\n", "}", "\n", "}" ]
1,821
all-1822
[ "PreCreateCheck", "checks", "that", "the", "machine", "creation", "process", "can", "be", "started", "safely", "." ]
[ "func", "(", "d", "*", "Driver", ")", "PreCreateCheck", "(", ")", "error", "{", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "// Create context", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "context", ".", "Background", "(", ")", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "c", ",", "err", ":=", "d", ".", "vsphereLogin", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "c", ".", "Logout", "(", "ctx", ")", "\n\n", "// Create a new finder", "f", ":=", "find", ".", "NewFinder", "(", "c", ".", "<mask>", ",", "true", ")", "\n\n", "dc", ",", "err", ":=", "f", ".", "DatacenterOrDefault", "(", "ctx", ",", "d", ".", "Datacenter", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "f", ".", "SetDatacenter", "(", "dc", ")", "\n\n", "// Folder", "if", "d", ".", "Folder", "!=", "\"", "\"", "{", "// Find the specified Folder to create the VM in.", "folders", ",", "err", ":=", "dc", ".", "Folders", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "folder", ",", "err", ":=", "f", ".", "Folder", "(", "ctx", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "folders", ".", "VmFolder", ".", "InventoryPath", ",", "d", ".", "Folder", ")", ")", "\n", "// It's an error to not find the folder, or for the search itself to fail.", "if", "err", "!=", "nil", "{", "// The search itself failed.", "return", "err", "\n", "}", "\n", "if", "folder", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "d", ".", "Folder", ")", "\n", "}", "\n", "}", "\n\n", "if", "_", ",", "err", ":=", "f", ".", "DatastoreOrDefault", "(", "ctx", ",", "d", ".", "Datastore", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// TODO: if the user has both the VSPHERE_NETWORK defined and adds --vmwarevsphere-network", "// both are used at the same time - probably should detect that and remove the one from ENV", "if", "len", "(", "d", ".", "Networks", ")", "==", "0", "{", "// machine assumes there will be a network", "d", ".", "Networks", "=", "append", "(", "d", ".", "Networks", ",", "\"", "\"", ")", "\n", "}", "\n", "for", "_", ",", "netName", ":=", "range", "d", ".", "Networks", "{", "if", "_", ",", "err", ":=", "f", ".", "NetworkOrDefault", "(", "ctx", ",", "netName", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "// d.Network needs to remain a string to cope with existing machines :/", "d", ".", "Network", "=", "d", ".", "Networks", "[", "0", "]", "\n\n", "var", "hs", "*", "object", ".", "HostSystem", "\n", "if", "d", ".", "HostSystem", "!=", "\"", "\"", "{", "var", "err", "error", "\n", "hs", ",", "err", "=", "f", ".", "HostSystemOrDefault", "(", "ctx", ",", "d", ".", "HostSystem", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "// ResourcePool", "if", "d", ".", "Pool", "!=", "\"", "\"", "{", "// Find specified Resource Pool", "if", "_", ",", "err", ":=", "f", ".", "ResourcePool", "(", "ctx", ",", "d", ".", "Pool", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "else", "if", "hs", "!=", "nil", "{", "// Pick default Resource Pool for Host System", "if", "_", ",", "err", ":=", "hs", ".", "ResourcePool", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "else", "{", "// Pick the default Resource Pool for the Datacenter.", "if", "_", ",", "err", ":=", "f", ".", "DefaultResourcePool", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
1,822
all-1823
[ "Do", "executes", "DOMDebugger", ".", "setInstrumentationBreakpoint", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "SetInstrumentationBreakpointParams", ")", "Do", "(", "ctx", "<mask>", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetInstrumentationBreakpoint", ",", "p", ",", "nil", ")", "\n", "}" ]
1,823
all-1824
[ "OpenManaged", "returns", "a", "new", "DB", "which", "allows", "more", "control", "over", "setting", "transaction", "timestamps", "aka", "managed", "mode", ".", "This", "is", "only", "useful", "for", "databases", "built", "on", "top", "of", "Badger", "(", "like", "Dgraph", ")", "and", "can", "be", "ignored", "by", "most", "users", "." ]
[ "func", "OpenManaged", "(", "opts", "<mask>", ")", "(", "*", "DB", ",", "error", ")", "{", "opts", ".", "managedTxns", "=", "true", "\n", "return", "Open", "(", "opts", ")", "\n", "}" ]
1,824
all-1825
[ "NewFakeClient", "creates", "a", "client", "that", "doesn", "t", "do", "anything", ".", "If", "you", "provide", "a", "deck", "URL", "then", "the", "client", "will", "hit", "that", "for", "the", "supported", "calls", "." ]
[ "func", "NewFakeClient", "(", "deckURL", "string", ")", "*", "<mask>", "{", "return", "&", "Client", "{", "namespace", ":", "\"", "\"", ",", "deckURL", ":", "deckURL", ",", "client", ":", "&", "http", ".", "Client", "{", "}", ",", "fake", ":", "true", ",", "}", "\n", "}" ]
1,825
all-1826
[ "HasCreator", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "m", "*", "Monitor", ")", "HasCreator", "(", ")", "bool", "{", "if", "m", "!=", "nil", "&&", "m", ".", "Creator", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
1,826
all-1827
[ "isNasVolume", "returns", "true", "if", "the", "HostFileSystemVolumeFileSystemType", "matches", "one", "of", "the", "possible", "filesystem", "types", "that", "a", "NAS", "datastore", "supports", "." ]
[ "func", "isNasVolume", "(", "t", "types", ".", "HostFileSystemVolumeFileSystemType", ")", "bool", "{", "switch", "t", "{", "case", "types", ".", "HostFileSystemVolumeFileSystemTypeNFS", ",", "<mask>", ".", "HostFileSystemVolumeFileSystemTypeNFS41", ":", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
1,827
all-1828
[ "SetVersion", "is", "a", "wrapper", "around", "gtk_about_dialog_set_version", "()", "." ]
[ "func", "(", "v", "*", "AboutDialog", ")", "SetVersion", "(", "version", "string", ")", "{", "cstr", ":=", "C", ".", "CString", "(", "<mask>", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cstr", ")", ")", "\n", "C", ".", "gtk_about_dialog_set_version", "(", "v", ".", "native", "(", ")", ",", "(", "*", "C", ".", "gchar", ")", "(", "cstr", ")", ")", "\n", "}" ]
1,828
all-1829
[ "Returns", "the", "stemmed", "version", "of", "a", "word", "if", "it", "is", "a", "special", "case", "otherwise", "returns", "the", "empty", "string", "." ]
[ "func", "stemSpecialWord", "(", "word", "string", ")", "(", "stemmed", "string", ")", "{", "switch", "word", "{", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "<mask>", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "case", "\"", "\"", ":", "stemmed", "=", "\"", "\"", "\n", "}", "\n", "return", "\n", "}" ]
1,829
all-1830
[ "timeToJulianDay", "returns", "the", "Julian", "Date", "Number", "of", "time", "s", "date", "components", ".", "The", "algorithm", "is", "taken", "from", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Julian_day", "." ]
[ "func", "timeToJulianDay", "(", "t", "<mask>", ".", "Time", ")", "int", "{", "t", "=", "t", ".", "UTC", "(", ")", "\n\n", "month", ":=", "int", "(", "t", ".", "Month", "(", ")", ")", "\n\n", "a", ":=", "(", "14", "-", "month", ")", "/", "12", "\n", "y", ":=", "t", ".", "Year", "(", ")", "+", "4800", "-", "a", "\n", "m", ":=", "month", "+", "(", "12", "*", "a", ")", "-", "3", "\n\n", "if", "t", ".", "Before", "(", "gregorianDate", ")", "{", "// Julian Calendar", "return", "t", ".", "Day", "(", ")", "+", "(", "153", "*", "m", "+", "2", ")", "/", "5", "+", "365", "*", "y", "+", "y", "/", "4", "-", "32083", "\n", "}", "\n", "// Gregorian Calendar", "return", "t", ".", "Day", "(", ")", "+", "(", "153", "*", "m", "+", "2", ")", "/", "5", "+", "365", "*", "y", "+", "y", "/", "4", "-", "y", "/", "100", "+", "y", "/", "400", "-", "32045", "\n", "}" ]
1,830
all-1831
[ "NewSSAuthenticator", "returns", "an", "authenticator", "that", "wraps", "another", "one", "and", "adds", "the", "logic", "needed", "to", "create", "sessions", "in", "Self", "-", "Service", "." ]
[ "func", "NewSSAuthenticator", "(", "auther", "Authenticator", ",", "accountID", "int", ")", "Authenticator", "{", "if", "_", ",", "ok", ":=", "auther", ".", "(", "*", "ssAuthenticator", ")", ";", "ok", "{", "// Only wrap if not wrapped already", "return", "auther", "\n", "}", "\n", "return", "&", "ssAuthenticator", "{", "auther", ":", "auther", ",", "accountID", ":", "accountID", ",", "refreshAt", ":", "time", ".", "Now", "(", ")", ".", "Add", "(", "-", "2", "*", "<mask>", ".", "Minute", ")", ",", "client", ":", "httpclient", ".", "NewNoRedirect", "(", ")", ",", "}", "\n", "}" ]
1,831
all-1832
[ "alarmListCommandFunc", "executes", "the", "alarm", "list", "command", "." ]
[ "func", "alarmListCommandFunc", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "if", "len", "(", "args", ")", "!=", "0", "{", "ExitWithError", "(", "ExitBadArgs", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "ctx", ",", "cancel", ":=", "commandCtx", "(", "cmd", ")", "\n", "resp", ",", "err", ":=", "mustClientFromCmd", "(", "cmd", ")", ".", "AlarmList", "(", "ctx", ")", "\n", "cancel", "(", ")", "\n", "if", "err", "!=", "nil", "{", "ExitWithError", "(", "ExitError", ",", "err", ")", "\n", "}", "\n", "<mask>", ".", "Alarm", "(", "*", "resp", ")", "\n", "}" ]
1,832
all-1833
[ "hasReturnType", "returns", "whether", "the", "mangled", "form", "of", "a", "will", "have", "a", "return", "type", "." ]
[ "func", "hasReturnType", "(", "a", "AST", ")", "bool", "{", "<mask>", "a", ":=", "a", ".", "(", "type", ")", "{", "case", "*", "Template", ":", "return", "!", "isCDtorConversion", "(", "a", ".", "Name", ")", "\n", "case", "*", "TypeWithQualifiers", ":", "return", "hasReturnType", "(", "a", ".", "Base", ")", "\n", "case", "*", "MethodWithQualifiers", ":", "return", "hasReturnType", "(", "a", ".", "Method", ")", "\n", "default", ":", "return", "false", "\n", "}", "\n", "}" ]
1,833
all-1834
[ "Push", "implements", "heap", "Push", "interface" ]
[ "func", "(", "ph", "*", "peerHeap", ")", "Push", "(", "x", "interface", "{", "}", ")", "{", "n", ":=", "len", "(", "ph", ".", "peerScores", ")", "\n", "item", ":=", "x", ".", "(", "*", "peerScore", ")", "\n", "<mask>", ".", "index", "=", "n", "\n", "ph", ".", "peerScores", "=", "append", "(", "ph", ".", "peerScores", ",", "item", ")", "\n", "}" ]
1,834
all-1835
[ "readCore", "reads", "corefile", "and", "returns", "core", "and", "gocore", "process", "states", "." ]
[ "func", "readCore", "(", ")", "(", "*", "core", ".", "Process", ",", "*", "gocore", ".", "Process", ",", "error", ")", "{", "cc", ":=", "coreCache", "\n", "if", "cc", ".", "cfg", "==", "cfg", "{", "return", "<mask>", ".", "coreP", ",", "cc", ".", "gocoreP", ",", "cc", ".", "err", "\n", "}", "\n", "c", ",", "err", ":=", "core", ".", "Core", "(", "cfg", ".", "corefile", ",", "cfg", ".", "base", ",", "cfg", ".", "exePath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "p", ",", "err", ":=", "gocore", ".", "Core", "(", "c", ")", "\n", "if", "os", ".", "IsNotExist", "(", "err", ")", "&&", "cfg", ".", "exePath", "==", "\"", "\"", "{", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "for", "_", ",", "w", ":=", "range", "c", ".", "Warnings", "(", ")", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\"", ",", "w", ")", "\n", "}", "\n", "cc", ".", "cfg", "=", "cfg", "\n", "cc", ".", "coreP", "=", "c", "\n", "cc", ".", "gocoreP", "=", "p", "\n", "cc", ".", "err", "=", "nil", "\n", "return", "c", ",", "p", ",", "nil", "\n", "}" ]
1,835
all-1836
[ "ParseShort", "creates", "a", "new", "*", "Durafmt", "struct", "short", "form", "returns", "error", "if", "input", "is", "invalid", "." ]
[ "func", "ParseShort", "(", "dinput", "time", ".", "Duration", ")", "*", "Durafmt", "{", "<mask>", ":=", "dinput", ".", "String", "(", ")", "\n", "return", "&", "Durafmt", "{", "dinput", ",", "input", ",", "true", "}", "\n", "}" ]
1,836
all-1837
[ "This", "will", "retrieve", "all", "old", "rows", "that", "were", "created", "before", "the", "row", "with", "id", "was", "created", "[", "1", "2", "3", "4", "]", "before", "2", "will", "return", "[", "3", "4", "]" ]
[ "func", "(", "s", "PostgresObjectStore", ")", "Before", "(", "id", "string", ",", "count", "int", ",", "skip", "int", ",", "store", "string", ")", "(", "prows", "ObjectRows", ",", "err", "error", ")", "{", "rows", ",", "err", ":=", "s", ".", "db", ".", "Table", "(", "safeStoreName", "(", "store", ")", ")", ".", "Select", "(", "\"", "\"", ")", ".", "Where", "(", "\"", "\"", ",", "<mask>", ")", ".", "Limit", "(", "count", ")", ".", "Offset", "(", "skip", ")", ".", "Rows", "(", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "sql", ".", "ErrNoRows", "{", "return", "nil", ",", "ErrNotFound", "\n", "}", "\n", "return", "\n", "}", "\n", "prows", "=", "PostgresRows", "{", "rows", "}", "\n", "return", "\n", "}" ]
1,837
all-1838
[ "BuildWithConfig", "allows", "to", "generate", "a", "Source", "implementation", "from", "the", "shared", "config" ]
[ "func", "BuildWithConfig", "(", "source", "string", ",", "p", "ClientGenerator", ",", "cfg", "*", "Config", ")", "(", "Source", ",", "error", ")", "{", "switch", "<mask>", "{", "case", "\"", "\"", ":", "client", ",", "err", ":=", "p", ".", "KubeClient", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "NewServiceSource", "(", "client", ",", "cfg", ".", "Namespace", ",", "cfg", ".", "AnnotationFilter", ",", "cfg", ".", "FQDNTemplate", ",", "cfg", ".", "CombineFQDNAndAnnotation", ",", "cfg", ".", "Compatibility", ",", "cfg", ".", "PublishInternal", ",", "cfg", ".", "PublishHostIP", ",", "cfg", ".", "ServiceTypeFilter", ",", "cfg", ".", "IgnoreHostnameAnnotation", ")", "\n", "case", "\"", "\"", ":", "client", ",", "err", ":=", "p", ".", "KubeClient", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "NewIngressSource", "(", "client", ",", "cfg", ".", "Namespace", ",", "cfg", ".", "AnnotationFilter", ",", "cfg", ".", "FQDNTemplate", ",", "cfg", ".", "CombineFQDNAndAnnotation", ",", "cfg", ".", "IgnoreHostnameAnnotation", ")", "\n", "case", "\"", "\"", ":", "kubernetesClient", ",", "err", ":=", "p", ".", "KubeClient", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "istioClient", ",", "err", ":=", "p", ".", "IstioClient", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "NewIstioGatewaySource", "(", "kubernetesClient", ",", "istioClient", ",", "cfg", ".", "IstioIngressGatewayServices", ",", "cfg", ".", "Namespace", ",", "cfg", ".", "AnnotationFilter", ",", "cfg", ".", "FQDNTemplate", ",", "cfg", ".", "CombineFQDNAndAnnotation", ",", "cfg", ".", "IgnoreHostnameAnnotation", ")", "\n", "case", "\"", "\"", ":", "return", "NewFakeSource", "(", "cfg", ".", "FQDNTemplate", ")", "\n", "case", "\"", "\"", ":", "return", "NewConnectorSource", "(", "cfg", ".", "ConnectorServer", ")", "\n", "case", "\"", "\"", ":", "client", ",", "err", ":=", "p", ".", "KubeClient", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "crdClient", ",", "scheme", ",", "err", ":=", "NewCRDClientForAPIVersionKind", "(", "client", ",", "cfg", ".", "KubeConfig", ",", "cfg", ".", "KubeMaster", ",", "cfg", ".", "CRDSourceAPIVersion", ",", "cfg", ".", "CRDSourceKind", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "NewCRDSource", "(", "crdClient", ",", "cfg", ".", "Namespace", ",", "cfg", ".", "CRDSourceKind", ",", "scheme", ")", "\n", "}", "\n", "return", "nil", ",", "ErrSourceNotFound", "\n", "}" ]
1,838
all-1839
[ "ApiClient", "retrieves", "a", "detailed", "view", "of", "one", "API", "client" ]
[ "func", "(", "c", "*", "Client", ")", "ApiClient", "(", "identifier", "string", ")", "(", "*", "ApiClient", ",", "error", ")", "{", "apiClient", ":=", "<mask>", "(", "ApiClient", ")", "\n", "_", ",", "err", ":=", "c", ".", "MakeApiRequest", "(", "\"", "\"", ",", "\"", "\"", "+", "identifier", ",", "nil", ",", "apiClient", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "apiClient", ",", "err", "\n", "}" ]
1,839
all-1840
[ "CreateStore", "will", "dial", "the", "passed", "database", "and", "return", "a", "new", "store", ".", "It", "will", "return", "an", "error", "if", "the", "initial", "connection", "failed" ]
[ "func", "CreateStore", "(", "uri", "string", ")", "(", "*", "<mask>", ",", "error", ")", "{", "session", ",", "err", ":=", "mgo", ".", "Dial", "(", "uri", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "NewStore", "(", "session", ")", ",", "nil", "\n", "}" ]
1,840
all-1841
[ "NoErrorWithinTRetry", "checks", "that", "f", "finishes", "within", "time", "t", "and", "does", "not", "emit", "an", "error", ".", "Unlike", "NoErrorWithinT", "if", "f", "does", "error", "it", "will", "retry", "it", "." ]
[ "func", "NoErrorWithinTRetry", "(", "tb", "testing", ".", "TB", ",", "t", "time", ".", "Duration", ",", "f", "func", "(", ")", "error", ",", "msgAndArgs", "...", "interface", "{", "}", ")", "{", "tb", ".", "Helper", "(", ")", "\n", "doneCh", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "timeout", ":=", "false", "\n", "<mask>", "err", "error", "\n", "go", "func", "(", ")", "{", "for", "!", "timeout", "{", "if", "err", "=", "f", "(", ")", ";", "err", "==", "nil", "{", "close", "(", "doneCh", ")", "\n", "break", "\n", "}", "\n", "}", "\n", "}", "(", ")", "\n", "select", "{", "case", "<-", "doneCh", ":", "case", "<-", "time", ".", "After", "(", "t", ")", ":", "timeout", "=", "true", "\n", "fatal", "(", "tb", ",", "msgAndArgs", ",", "\"", "\"", ",", "t", ".", "String", "(", ")", ",", "err", ")", "\n", "}", "\n", "}" ]
1,841
all-1842
[ "Do", "executes", "Profiler", ".", "stopPreciseCoverage", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "StopPreciseCoverageParams", ")", "Do", "(", "ctx", "<mask>", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandStopPreciseCoverage", ",", "nil", ",", "nil", ")", "\n", "}" ]
1,842
all-1843
[ "NewSetOptionsResult", "creates", "a", "new", "SetOptionsResult", "." ]
[ "func", "NewSetOptionsResult", "(", "code", "SetOptionsResultCode", ",", "value", "<mask>", "{", "}", ")", "(", "result", "SetOptionsResult", ",", "err", "error", ")", "{", "result", ".", "Code", "=", "code", "\n", "switch", "SetOptionsResultCode", "(", "code", ")", "{", "case", "SetOptionsResultCodeSetOptionsSuccess", ":", "// void", "default", ":", "// void", "}", "\n", "return", "\n", "}" ]
1,843
all-1844
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "SetBreakpointOnFunctionCallParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger13", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "<mask>", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
1,844
all-1845
[ "chain", "builds", "a", "http", ".", "Handler", "composed", "of", "an", "inline", "middleware", "stack", "and", "endpoint", "handler", "in", "the", "order", "they", "are", "passed", "." ]
[ "func", "chain", "(", "middlewares", "[", "]", "func", "(", "http", ".", "Handler", ")", "http", ".", "Handler", ",", "endpoint", "http", ".", "Handler", ")", "<mask>", ".", "Handler", "{", "// Return ahead of time if there aren't any middlewares for the chain", "if", "len", "(", "middlewares", ")", "==", "0", "{", "return", "endpoint", "\n", "}", "\n\n", "// Wrap the end handler with the middleware chain", "h", ":=", "middlewares", "[", "len", "(", "middlewares", ")", "-", "1", "]", "(", "endpoint", ")", "\n", "for", "i", ":=", "len", "(", "middlewares", ")", "-", "2", ";", "i", ">=", "0", ";", "i", "--", "{", "h", "=", "middlewares", "[", "i", "]", "(", "h", ")", "\n", "}", "\n\n", "return", "h", "\n", "}" ]
1,845
all-1846
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "SecurityDetails", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork19", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
1,846
all-1847
[ "QueryLabels", "queries", "for", "label", "values", "against", "a", "Prometheus", "server", "." ]
[ "func", "QueryLabels", "(", "url", "*", "url", ".", "URL", ",", "<mask>", "string", ",", "p", "printer", ")", "int", "{", "config", ":=", "api", ".", "Config", "{", "Address", ":", "url", ".", "String", "(", ")", ",", "}", "\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", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "2", "*", "time", ".", "Minute", ")", "\n", "val", ",", "err", ":=", "api", ".", "LabelValues", "(", "ctx", ",", "name", ")", "\n", "cancel", "(", ")", "\n\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Fprintln", "(", "os", ".", "Stderr", ",", "\"", "\"", ",", "err", ")", "\n", "return", "1", "\n", "}", "\n\n", "p", ".", "printLabelValues", "(", "val", ")", "\n", "return", "0", "\n", "}" ]
1,847
all-1848
[ "match", "takes", "an", "import", "path", "and", "replacement", "map", "." ]
[ "func", "(", "c", "ImportConverter", ")", "match", "(", "importpath", "string", ")", "(", "string", ",", "bool", ")", "{", "for", "key", ",", "value", ":=", "<mask>", "c", ".", "Data", "{", "if", "!", "strings", ".", "HasPrefix", "(", "importpath", ",", "key", ")", "{", "continue", "\n", "}", "\n\n", "result", ":=", "strings", ".", "Replace", "(", "importpath", ",", "key", ",", "value", ",", "1", ")", "\n", "return", "result", ",", "true", "\n", "}", "\n\n", "return", "importpath", ",", "false", "\n", "}" ]
1,848
all-1849
[ "GetConsoleScreenBufferInfo", "retrieves", "information", "about", "the", "specified", "console", "screen", "buffer", ".", "See", "http", ":", "//", "msdn", ".", "microsoft", ".", "com", "/", "en", "-", "us", "/", "library", "/", "windows", "/", "desktop", "/", "ms683171", "(", "v", "=", "vs", ".", "85", ")", ".", "aspx", "." ]
[ "func", "GetConsoleScreenBufferInfo", "(", "handle", "uintptr", ")", "(", "*", "CONSOLE_SCREEN_BUFFER_INFO", ",", "error", ")", "{", "<mask>", ":=", "CONSOLE_SCREEN_BUFFER_INFO", "{", "}", "\n", "err", ":=", "checkError", "(", "getConsoleScreenBufferInfoProc", ".", "Call", "(", "handle", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "info", ")", ")", ",", "0", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "info", ",", "nil", "\n", "}" ]
1,849
all-1850
[ "advance", "advances", "the", "read", "only", "request", "queue", "kept", "by", "the", "readonly", "struct", ".", "It", "dequeues", "the", "requests", "until", "it", "finds", "the", "read", "only", "request", "that", "has", "the", "same", "context", "as", "the", "given", "m", "." ]
[ "func", "(", "ro", "*", "readOnly", ")", "advance", "(", "m", "pb", ".", "Message", ")", "[", "]", "*", "readIndexStatus", "{", "var", "(", "i", "int", "\n", "found", "bool", "\n", ")", "\n\n", "ctx", ":=", "string", "(", "m", ".", "Context", ")", "\n", "rss", ":=", "[", "]", "*", "readIndexStatus", "{", "}", "\n\n", "for", "_", ",", "okctx", ":=", "range", "ro", ".", "readIndexQueue", "{", "i", "++", "\n", "rs", ",", "ok", ":=", "ro", ".", "pendingReadIndex", "[", "okctx", "]", "\n", "if", "!", "ok", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "rss", "=", "append", "(", "rss", ",", "rs", ")", "\n", "if", "okctx", "==", "ctx", "{", "found", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n\n", "if", "found", "{", "ro", ".", "readIndexQueue", "=", "ro", ".", "readIndexQueue", "[", "i", ":", "]", "\n", "for", "_", ",", "<mask>", ":=", "range", "rss", "{", "delete", "(", "ro", ".", "pendingReadIndex", ",", "string", "(", "rs", ".", "req", ".", "Entries", "[", "0", "]", ".", "Data", ")", ")", "\n", "}", "\n", "return", "rss", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
1,850
all-1851
[ "VerifyBasicAuth", "returns", "a", "handler", "that", "verifies", "the", "request", "contains", "a", "BasicAuth", "Authorization", "header", "matching", "the", "passed", "in", "username", "and", "password" ]
[ "func", "VerifyBasicAuth", "(", "username", "string", ",", "password", "string", ")", "http", ".", "HandlerFunc", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "<mask>", ".", "Request", ")", "{", "auth", ":=", "req", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "Expect", "(", "auth", ")", ".", "ShouldNot", "(", "Equal", "(", "\"", "\"", ")", ",", "\"", "\"", ")", "\n\n", "decoded", ",", "err", ":=", "base64", ".", "StdEncoding", ".", "DecodeString", "(", "auth", "[", "6", ":", "]", ")", "\n", "Expect", "(", "err", ")", ".", "ShouldNot", "(", "HaveOccurred", "(", ")", ")", "\n\n", "Expect", "(", "string", "(", "decoded", ")", ")", ".", "Should", "(", "Equal", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "username", ",", "password", ")", ")", ",", "\"", "\"", ")", "\n", "}", "\n", "}" ]
1,851
all-1852
[ "LastPathSegment", "returns", "the", "last", "part", "of", "uri", "path", "after", "/", ".", "Examples", ":", "*", "For", "/", "foo", "/", "bar", "/", "baz", ".", "html", "path", "returns", "baz", ".", "html", ".", "*", "For", "/", "foo", "/", "bar", "/", "returns", "empty", "byte", "slice", ".", "*", "For", "/", "foobar", ".", "js", "returns", "foobar", ".", "js", "." ]
[ "func", "(", "u", "*", "URI", ")", "LastPathSegment", "(", ")", "[", "]", "byte", "{", "path", ":=", "u", ".", "Path", "(", ")", "\n", "n", ":=", "bytes", ".", "LastIndexByte", "(", "path", ",", "'/'", ")", "\n", "if", "n", "<", "0", "{", "return", "path", "\n", "}", "\n", "return", "<mask>", "[", "n", "+", "1", ":", "]", "\n", "}" ]
1,852
all-1853
[ "UnmarshalEasyJSON", "satisfies", "easyjson", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "ResourceType", ")", "UnmarshalEasyJSON", "(", "<mask>", "*", "jlexer", ".", "Lexer", ")", "{", "switch", "ResourceType", "(", "in", ".", "String", "(", ")", ")", "{", "case", "ResourceTypeDocument", ":", "*", "t", "=", "ResourceTypeDocument", "\n", "case", "ResourceTypeStylesheet", ":", "*", "t", "=", "ResourceTypeStylesheet", "\n", "case", "ResourceTypeImage", ":", "*", "t", "=", "ResourceTypeImage", "\n", "case", "ResourceTypeMedia", ":", "*", "t", "=", "ResourceTypeMedia", "\n", "case", "ResourceTypeFont", ":", "*", "t", "=", "ResourceTypeFont", "\n", "case", "ResourceTypeScript", ":", "*", "t", "=", "ResourceTypeScript", "\n", "case", "ResourceTypeTextTrack", ":", "*", "t", "=", "ResourceTypeTextTrack", "\n", "case", "ResourceTypeXHR", ":", "*", "t", "=", "ResourceTypeXHR", "\n", "case", "ResourceTypeFetch", ":", "*", "t", "=", "ResourceTypeFetch", "\n", "case", "ResourceTypeEventSource", ":", "*", "t", "=", "ResourceTypeEventSource", "\n", "case", "ResourceTypeWebSocket", ":", "*", "t", "=", "ResourceTypeWebSocket", "\n", "case", "ResourceTypeManifest", ":", "*", "t", "=", "ResourceTypeManifest", "\n", "case", "ResourceTypeSignedExchange", ":", "*", "t", "=", "ResourceTypeSignedExchange", "\n", "case", "ResourceTypePing", ":", "*", "t", "=", "ResourceTypePing", "\n", "case", "ResourceTypeCSPViolationReport", ":", "*", "t", "=", "ResourceTypeCSPViolationReport", "\n", "case", "ResourceTypeOther", ":", "*", "t", "=", "ResourceTypeOther", "\n\n", "default", ":", "in", ".", "AddError", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}" ]
1,853
all-1854
[ "Draw", "draws", "the", "sprite", "." ]
[ "func", "(", "s", "*", "Sprite", ")", "Draw", "(", "screen", "*", "ebiten", ".", "Image", ",", "dx", ",", "dy", "int", ",", "alpha", "float64", ")", "{", "op", ":=", "&", "ebiten", ".", "DrawImageOptions", "{", "}", "\n", "op", ".", "GeoM", ".", "Translate", "(", "float64", "(", "s", ".", "x", "+", "dx", ")", ",", "float64", "(", "s", ".", "y", "+", "dy", ")", ")", "\n", "op", ".", "ColorM", ".", "Scale", "(", "1", ",", "1", ",", "1", ",", "alpha", ")", "\n", "screen", ".", "DrawImage", "(", "s", ".", "image", ",", "op", ")", "\n", "screen", ".", "DrawImage", "(", "s", ".", "<mask>", ",", "op", ")", "\n", "}" ]
1,854
all-1855
[ "IsDuration", "returns", "true", "if", "the", "provided", "string", "is", "a", "valid", "duration" ]
[ "func", "IsDuration", "(", "str", "<mask>", ")", "bool", "{", "_", ",", "err", ":=", "ParseDuration", "(", "str", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
1,855
all-1856
[ "GetUser", "returns", "the", "user", "that", "match", "a", "handle", "or", "an", "error", "if", "not", "found" ]
[ "func", "(", "client", "*", "Client", ")", "GetUser", "(", "handle", "string", ")", "(", "user", "User", ",", "err", "error", ")", "{", "var", "udata", "userData", "\n", "uri", ":=", "\"", "\"", "+", "handle", "\n", "err", "=", "client", ".", "doJsonRequest", "(", "\"", "\"", ",", "uri", ",", "nil", ",", "&", "udata", ")", "\n", "user", "=", "udata", ".", "<mask>", "\n", "return", "\n", "}" ]
1,856
all-1857
[ "CubicCurve", "draws", "a", "cubic", "curve", "with", "its", "control", "points", "." ]
[ "func", "CubicCurve", "(", "gc", "draw2d", ".", "GraphicContext", ",", "x", ",", "y", ",", "width", ",", "height", "float64", ")", "{", "sx", ",", "sy", ":=", "width", "/", "162", ",", "height", "/", "205", "\n", "x0", ",", "y0", ":=", "x", ",", "y", "+", "sy", "*", "100.0", "\n", "x1", ",", "y1", ":=", "x", "+", "sx", "*", "75", ",", "y", "+", "sy", "*", "205", "\n", "x2", ",", "y2", ":=", "x", "+", "sx", "*", "125", ",", "y", "\n", "x3", ",", "y3", ":=", "x", "+", "sx", "*", "205", ",", "y", "+", "sy", "*", "100", "\n\n", "gc", ".", "SetStrokeColor", "(", "image", ".", "Black", ")", "\n", "gc", ".", "SetFillColor", "(", "color", ".", "NRGBA", "{", "0xAA", ",", "0xAA", ",", "0xAA", ",", "0xFF", "}", ")", "\n", "gc", ".", "SetLineWidth", "(", "width", "/", "10", ")", "\n", "gc", ".", "MoveTo", "(", "x0", ",", "y0", ")", "\n", "gc", ".", "CubicCurveTo", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ",", "x3", ",", "y3", ")", "\n", "gc", ".", "Stroke", "(", ")", "\n\n", "gc", ".", "SetStrokeColor", "(", "<mask>", ".", "NRGBA", "{", "0xFF", ",", "0x33", ",", "0x33", ",", "0x88", "}", ")", "\n\n", "gc", ".", "SetLineWidth", "(", "width", "/", "20", ")", "\n", "// draw segment of curve", "gc", ".", "MoveTo", "(", "x0", ",", "y0", ")", "\n", "gc", ".", "LineTo", "(", "x1", ",", "y1", ")", "\n", "gc", ".", "LineTo", "(", "x2", ",", "y2", ")", "\n", "gc", ".", "LineTo", "(", "x3", ",", "y3", ")", "\n", "gc", ".", "Stroke", "(", ")", "\n", "}" ]
1,857
all-1858
[ "runSnapshots", "is", "a", "long", "running", "goroutine", "used", "to", "manage", "taking", "new", "snapshots", "of", "the", "FSM", ".", "It", "runs", "in", "parallel", "to", "the", "FSM", "and", "main", "goroutines", "so", "that", "snapshots", "do", "not", "block", "normal", "operation", "." ]
[ "func", "(", "r", "*", "Raft", ")", "runSnapshots", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "randomTimeout", "(", "r", ".", "conf", ".", "SnapshotInterval", ")", ":", "// Check if we should snapshot", "if", "!", "r", ".", "shouldSnapshot", "(", ")", "{", "continue", "\n", "}", "\n\n", "// Trigger a snapshot", "if", "_", ",", "err", ":=", "r", ".", "takeSnapshot", "(", ")", ";", "err", "!=", "nil", "{", "r", ".", "logger", ".", "Error", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "err", ")", ")", "\n", "}", "\n\n", "case", "future", ":=", "<-", "r", ".", "userSnapshotCh", ":", "// User-triggered, run immediately", "id", ",", "err", ":=", "r", ".", "takeSnapshot", "(", ")", "\n", "if", "err", "!=", "nil", "{", "r", ".", "logger", ".", "Error", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "err", ")", ")", "\n", "}", "else", "{", "future", ".", "opener", "=", "func", "(", ")", "(", "*", "SnapshotMeta", ",", "<mask>", ".", "ReadCloser", ",", "error", ")", "{", "return", "r", ".", "snapshots", ".", "Open", "(", "id", ")", "\n", "}", "\n", "}", "\n", "future", ".", "respond", "(", "err", ")", "\n\n", "case", "<-", "r", ".", "shutdownCh", ":", "return", "\n", "}", "\n", "}", "\n", "}" ]
1,858
all-1859
[ "String", "returns", "a", "descriptive", "string", "for", "the", "item", "." ]
[ "func", "(", "i", "item", ")", "<mask>", "(", ")", "string", "{", "switch", "{", "case", "i", ".", "typ", "==", "ItemEOF", ":", "return", "\"", "\"", "\n", "case", "i", ".", "typ", "==", "ItemError", ":", "return", "i", ".", "val", "\n", "case", "i", ".", "typ", "==", "ItemIdentifier", "||", "i", ".", "typ", "==", "ItemMetricIdentifier", ":", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "i", ".", "val", ")", "\n", "case", "i", ".", "typ", ".", "isKeyword", "(", ")", ":", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "i", ".", "val", ")", "\n", "case", "i", ".", "typ", ".", "isOperator", "(", ")", ":", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "i", ".", "val", ")", "\n", "case", "i", ".", "typ", ".", "isAggregator", "(", ")", ":", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "i", ".", "val", ")", "\n", "case", "len", "(", "i", ".", "val", ")", ">", "10", ":", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "i", ".", "val", ")", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "i", ".", "val", ")", "\n", "}" ]
1,859
all-1860
[ "ReplacePixels", "replaces", "the", "image", "pixels", "with", "the", "given", "pixels", "slice", ".", "If", "pixels", "is", "nil", "ReplacePixels", "clears", "the", "specified", "reagion", "." ]
[ "func", "(", "i", "*", "Image", ")", "ReplacePixels", "(", "pixels", "[", "]", "byte", ",", "x", ",", "y", ",", "width", ",", "height", "int", ")", "{", "w", ",", "h", ":=", "i", ".", "image", ".", "Size", "(", ")", "\n", "if", "width", "<=", "0", "||", "<mask>", "<=", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "x", "<", "0", "||", "y", "<", "0", "||", "w", "<=", "x", "||", "h", "<=", "y", "||", "x", "+", "width", "<=", "0", "||", "y", "+", "height", "<=", "0", "||", "w", "<", "x", "+", "width", "||", "h", "<", "y", "+", "height", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "x", ",", "y", ",", "width", ",", "height", ")", ")", "\n", "}", "\n\n", "// TODO: Avoid making other images stale if possible. (#514)", "// For this purpuse, images should remember which part of that is used for DrawTriangles.", "theImages", ".", "makeStaleIfDependingOn", "(", "i", ")", "\n\n", "if", "pixels", "==", "nil", "{", "pixels", "=", "make", "(", "[", "]", "byte", ",", "4", "*", "width", "*", "height", ")", "\n", "}", "\n", "i", ".", "image", ".", "ReplacePixels", "(", "pixels", ",", "x", ",", "y", ",", "width", ",", "height", ")", "\n\n", "if", "!", "IsRestoringEnabled", "(", ")", "{", "i", ".", "makeStale", "(", ")", "\n", "return", "\n", "}", "\n\n", "if", "x", "==", "0", "&&", "y", "==", "0", "&&", "width", "==", "w", "&&", "height", "==", "h", "{", "if", "pixels", "!=", "nil", "{", "if", "i", ".", "basePixels", "==", "nil", "{", "i", ".", "basePixels", "=", "&", "Pixels", "{", "length", ":", "4", "*", "w", "*", "h", ",", "}", "\n", "}", "\n", "i", ".", "basePixels", ".", "CopyFrom", "(", "pixels", ",", "0", ")", "\n", "}", "else", "{", "// If basePixels is nil, the restored pixels are cleared.", "// See restore() implementation.", "i", ".", "basePixels", "=", "nil", "\n", "}", "\n", "i", ".", "drawTrianglesHistory", "=", "nil", "\n", "i", ".", "stale", "=", "false", "\n", "return", "\n", "}", "\n\n", "if", "len", "(", "i", ".", "drawTrianglesHistory", ")", ">", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "i", ".", "stale", "{", "return", "\n", "}", "\n\n", "idx", ":=", "4", "*", "(", "y", "*", "w", "+", "x", ")", "\n", "if", "pixels", "!=", "nil", "{", "if", "i", ".", "basePixels", "==", "nil", "{", "i", ".", "basePixels", "=", "&", "Pixels", "{", "length", ":", "4", "*", "w", "*", "h", ",", "}", "\n", "}", "\n", "for", "j", ":=", "0", ";", "j", "<", "height", ";", "j", "++", "{", "i", ".", "basePixels", ".", "CopyFrom", "(", "pixels", "[", "4", "*", "j", "*", "width", ":", "4", "*", "(", "j", "+", "1", ")", "*", "width", "]", ",", "idx", ")", "\n", "idx", "+=", "4", "*", "w", "\n", "}", "\n", "}", "else", "if", "i", ".", "basePixels", "!=", "nil", "{", "zeros", ":=", "make", "(", "[", "]", "byte", ",", "4", "*", "width", ")", "\n", "for", "j", ":=", "0", ";", "j", "<", "height", ";", "j", "++", "{", "i", ".", "basePixels", ".", "CopyFrom", "(", "zeros", ",", "idx", ")", "\n", "idx", "+=", "4", "*", "w", "\n", "}", "\n", "}", "\n", "}" ]
1,860
all-1861
[ "GetAssetCode4", "retrieves", "the", "AssetCode4", "value", "from", "the", "union", "returning", "ok", "if", "the", "union", "s", "switch", "indicated", "the", "value", "is", "valid", "." ]
[ "func", "(", "u", "AllowTrustOpAsset", ")", "GetAssetCode4", "(", ")", "(", "result", "[", "4", "]", "byte", ",", "ok", "bool", ")", "{", "armName", ",", "_", ":=", "u", ".", "ArmForSwitch", "(", "int32", "(", "u", ".", "Type", ")", ")", "\n\n", "if", "armName", "==", "\"", "\"", "{", "result", "=", "*", "u", ".", "AssetCode4", "\n", "ok", "=", "<mask>", "\n", "}", "\n\n", "return", "\n", "}" ]
1,861
all-1862
[ "GetText", "returns", "the", "Text", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "p", "*", "Period", ")", "GetText", "(", ")", "string", "{", "if", "p", "==", "nil", "||", "p", ".", "<mask>", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "p", ".", "Text", "\n", "}" ]
1,862
all-1863
[ "Request", "sends", "a", "request", "with", "params", "marshaled", "into", "a", "JSON", "payload", "in", "the", "body", "The", "response", "value", "is", "marshaled", "from", "JSON", "into", "the", "specified", "holder", "struct" ]
[ "func", "(", "r", "rpc", ")", "Request", "(", "method", "string", ",", "endpoint", "string", ",", "params", "interface", "{", "}", ",", "holder", "interface", "{", "}", ")", "error", "{", "jsonParams", ",", "err", ":=", "json", ".", "Marshal", "(", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "<mask>", ",", "err", ":=", "r", ".", "createRequest", "(", "method", ",", "endpoint", ",", "jsonParams", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "var", "data", "[", "]", "byte", "\n", "if", "r", ".", "mock", "==", "true", "{", "// Mock mode: Replace actual request with expected JSON from file", "data", ",", "err", "=", "r", ".", "simulateRequest", "(", "endpoint", ",", "method", ")", "\n", "}", "else", "{", "data", ",", "err", "=", "r", ".", "executeRequest", "(", "request", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "holder", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
1,863
all-1864
[ "AddFlags", "binds", "flags", "to", "options" ]
[ "func", "(", "o", "*", "Options", ")", "AddFlags", "(", "<mask>", "*", "flag", ".", "FlagSet", ")", "{", "o", ".", "GcsOptions", ".", "AddFlags", "(", "flags", ")", "\n", "// DeprecatedWrapperOptions flags should be unused, remove immediately", "}" ]
1,864
all-1865
[ "mergeSamples", "merges", "two", "lists", "of", "sample", "pairs", "and", "removes", "duplicate", "timestamps", ".", "It", "assumes", "that", "both", "lists", "are", "sorted", "by", "timestamp", "." ]
[ "func", "mergeSamples", "(", "a", ",", "b", "[", "]", "prompb", ".", "Sample", ")", "[", "]", "prompb", ".", "Sample", "{", "result", ":=", "make", "(", "[", "]", "prompb", ".", "Sample", ",", "0", ",", "len", "(", "a", ")", "+", "len", "(", "b", ")", ")", "\n", "i", ",", "j", ":=", "0", ",", "0", "\n", "for", "i", "<", "len", "(", "a", ")", "&&", "j", "<", "len", "(", "b", ")", "{", "if", "a", "[", "i", "]", ".", "Timestamp", "<", "b", "[", "j", "]", ".", "Timestamp", "{", "result", "=", "append", "(", "result", ",", "a", "[", "i", "]", ")", "\n", "i", "++", "\n", "}", "else", "if", "a", "[", "i", "]", ".", "Timestamp", ">", "b", "[", "j", "]", ".", "Timestamp", "{", "result", "=", "append", "(", "result", ",", "b", "[", "j", "]", ")", "\n", "j", "++", "\n", "}", "else", "{", "result", "=", "<mask>", "(", "result", ",", "a", "[", "i", "]", ")", "\n", "i", "++", "\n", "j", "++", "\n", "}", "\n", "}", "\n", "result", "=", "append", "(", "result", ",", "a", "[", "i", ":", "]", "...", ")", "\n", "result", "=", "append", "(", "result", ",", "b", "[", "j", ":", "]", "...", ")", "\n", "return", "result", "\n", "}" ]
1,865
all-1866
[ "runWorker", "dequeues", "to", "reconcile", "until", "the", "queue", "has", "closed", "." ]
[ "func", "(", "c", "*", "<mask>", ")", "runWorker", "(", ")", "{", "for", "{", "key", ",", "shutdown", ":=", "c", ".", "workqueue", ".", "Get", "(", ")", "\n", "if", "shutdown", "{", "return", "\n", "}", "\n", "func", "(", ")", "{", "defer", "c", ".", "workqueue", ".", "Done", "(", "key", ")", "\n\n", "if", "err", ":=", "reconcile", "(", "c", ",", "key", ".", "(", "string", ")", ")", ";", "err", "!=", "nil", "{", "runtime", ".", "HandleError", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "key", ",", "err", ")", ")", "\n", "return", "// Do not forget so we retry later.", "\n", "}", "\n", "c", ".", "workqueue", ".", "Forget", "(", "key", ")", "\n", "}", "(", ")", "\n", "}", "\n", "}" ]
1,866
all-1867
[ "GenerateRSAKeyPair", "generates", "a", "new", "rsa", "private", "and", "public", "key" ]
[ "func", "GenerateRSAKeyPair", "(", "bits", "int", ",", "src", "<mask>", ".", "Reader", ")", "(", "PrivKey", ",", "PubKey", ",", "error", ")", "{", "if", "bits", "<", "512", "{", "return", "nil", ",", "nil", ",", "ErrRsaKeyTooSmall", "\n", "}", "\n", "priv", ",", "err", ":=", "rsa", ".", "GenerateKey", "(", "src", ",", "bits", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "pk", ":=", "&", "priv", ".", "PublicKey", "\n", "return", "&", "RsaPrivateKey", "{", "sk", ":", "priv", "}", ",", "&", "RsaPublicKey", "{", "pk", "}", ",", "nil", "\n", "}" ]
1,867
all-1868
[ "isEphemeralHostPort", "returns", "if", "hostPort", "is", "the", "default", "ephemeral", "hostPort", "." ]
[ "func", "isEphemeralHostPort", "(", "hostPort", "string", ")", "bool", "{", "<mask>", "hostPort", "==", "\"", "\"", "||", "hostPort", "==", "ephemeralHostPort", "||", "strings", ".", "HasSuffix", "(", "hostPort", ",", "\"", "\"", ")", "\n", "}" ]
1,868
all-1869
[ "opengdpr_requests" ]
[ "func", "getRequest", "(", "opts", "*", "ServerOptions", ")", "Handler", "{", "return", "func", "(", "w", "io", ".", "Writer", ",", "_", "<mask>", ".", "Reader", ",", "p", "httprouter", ".", "Params", ")", "error", "{", "resp", ",", "err", ":=", "opts", ".", "Processor", ".", "Status", "(", "p", ".", "ByName", "(", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "json", ".", "NewEncoder", "(", "w", ")", ".", "Encode", "(", "resp", ")", "\n", "}", "\n", "}" ]
1,869
all-1870
[ "UnmarshalEasyJSON", "satisfies", "easyjson", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "WindowState", ")", "UnmarshalEasyJSON", "(", "<mask>", "*", "jlexer", ".", "Lexer", ")", "{", "switch", "WindowState", "(", "in", ".", "String", "(", ")", ")", "{", "case", "WindowStateNormal", ":", "*", "t", "=", "WindowStateNormal", "\n", "case", "WindowStateMinimized", ":", "*", "t", "=", "WindowStateMinimized", "\n", "case", "WindowStateMaximized", ":", "*", "t", "=", "WindowStateMaximized", "\n", "case", "WindowStateFullscreen", ":", "*", "t", "=", "WindowStateFullscreen", "\n\n", "default", ":", "in", ".", "AddError", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}" ]
1,870
all-1871
[ "KeyFromMetadata", "gets", "the", "key", "from", "the", "metadata", "or", "returns", "ErrNoKey" ]
[ "func", "KeyFromMetadata", "(", "md", "metadata", ".", "MD", ")", "(", "string", ",", "error", ")", "{", "key", ",", "ok", ":=", "md", "[", "\"", "\"", "]", "\n", "if", "!", "ok", "||", "len", "(", "key", ")", "==", "0", "{", "return", "\"", "\"", ",", "ErrNoKey", "\n", "}", "\n", "return", "<mask>", "[", "0", "]", ",", "nil", "\n", "}" ]
1,871
all-1872
[ "FindFirstControl", "returns", "the", "first", "child", "for", "that", "fn", "returns", "true", ".", "The", "function", "is", "used", "to", "find", "active", "or", "tab", "-", "stop", "control" ]
[ "func", "FindFirstControl", "(", "parent", "Control", ",", "fn", "func", "(", "<mask>", ")", "bool", ")", "Control", "{", "linear", ":=", "getLinearControlList", "(", "parent", ",", "fn", ")", "\n", "if", "len", "(", "linear", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "return", "linear", "[", "0", "]", "\n", "}" ]
1,872
all-1873
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "CompileScriptParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoRuntime45", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
1,873
all-1874
[ "Accounts", "retrieves", "a", "list", "of", "all", "accounts", "associated", "with", "the", "client", ".", "API", "Clients", "are", "only", "ever", "associated", "with", "one", "single", "account", ".", "User", "clients", "can", "have", "multiple", "accounts", "through", "collaborations", "." ]
[ "func", "(", "c", "*", "<mask>", ")", "Accounts", "(", ")", "(", "[", "]", "Account", ",", "error", ")", "{", "var", "accounts", "[", "]", "Account", "\n", "_", ",", "err", ":=", "c", ".", "MakeApiRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "nil", ",", "&", "accounts", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "accounts", ",", "err", "\n", "}" ]
1,874
all-1875
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "Response", ")", "UnmarshalJSON", "(", "<mask>", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoHar1", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
1,875
all-1876
[ "Namespace", "returns", "the", "namespace", "to", "be", "used", "by", "Custom", "Resources" ]
[ "func", "(", "c", "*", "ClusterClient", ")", "Namespace", "(", ")", "<mask>", "{", "if", "c", ".", "CustomData", "!=", "nil", "&&", "c", ".", "CustomData", "[", "namespaceClusterKey", "]", "!=", "\"", "\"", "{", "return", "c", ".", "CustomData", "[", "namespaceClusterKey", "]", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
1,876
all-1877
[ "lineLength", "-", "Counts", "size", "of", "table", "line", "length", "(", "with", "spaces", "etc", ".", ")", "." ]
[ "func", "(", "t", "*", "Table", ")", "lineLength", "(", ")", "(", "sum", "int", ")", "{", "for", "_", ",", "l", ":=", "range", "t", ".", "fieldSizes", "{", "<mask>", "+=", "l", "+", "1", "\n", "}", "\n", "return", "sum", "+", "1", "\n", "}" ]
1,877
all-1878
[ "Active", "is", "true", "if", "all", "the", "states", "are", "active", "." ]
[ "func", "(", "m", "*", "MultiState", ")", "Active", "(", ")", "bool", "{", "for", "_", ",", "state", ":=", "range", "m", ".", "states", "{", "if", "!", "<mask>", ".", "Active", "(", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
1,878
all-1879
[ "Error", "implements", "the", "builtin", "error", "interface", "for", "demangleErr", "." ]
[ "func", "(", "de", "demangleErr", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "<mask>", ".", "err", ",", "de", ".", "off", ")", "\n", "}" ]
1,879
all-1880
[ "ConfigBlob", "returns", "the", "blob", "described", "by", "ConfigInfo", "iff", "ConfigInfo", "()", ".", "Digest", "!", "=", ";", "nil", "otherwise", ".", "The", "result", "is", "cached", ";", "it", "is", "OK", "to", "call", "this", "however", "often", "you", "need", "." ]
[ "func", "(", "m", "*", "manifestSchema2", ")", "ConfigBlob", "(", "ctx", "context", ".", "<mask>", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "m", ".", "configBlob", "==", "nil", "{", "if", "m", ".", "src", "==", "nil", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "stream", ",", "_", ",", "err", ":=", "m", ".", "src", ".", "GetBlob", "(", "ctx", ",", "manifest", ".", "BlobInfoFromSchema2Descriptor", "(", "m", ".", "m", ".", "ConfigDescriptor", ")", ",", "none", ".", "NoCache", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "stream", ".", "Close", "(", ")", "\n", "blob", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "stream", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "computedDigest", ":=", "digest", ".", "FromBytes", "(", "blob", ")", "\n", "if", "computedDigest", "!=", "m", ".", "m", ".", "ConfigDescriptor", ".", "Digest", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "computedDigest", ",", "m", ".", "m", ".", "ConfigDescriptor", ".", "Digest", ")", "\n", "}", "\n", "m", ".", "configBlob", "=", "blob", "\n", "}", "\n", "return", "m", ".", "configBlob", ",", "nil", "\n", "}" ]
1,880
all-1881
[ "NewPhoneNumber", "parses", "the", "given", "value", "as", "a", "phone", "number", "or", "returns", "an", "error", "if", "it", "cannot", "be", "parsed", "as", "one", ".", "If", "a", "phone", "number", "does", "not", "begin", "with", "a", "plus", "sign", "we", "assume", "it", "s", "a", "US", "national", "number", ".", "Numbers", "are", "stored", "in", "E", ".", "164", "format", "." ]
[ "func", "NewPhoneNumber", "(", "pn", "string", ")", "(", "PhoneNumber", ",", "error", ")", "{", "if", "len", "(", "pn", ")", "==", "0", "{", "return", "\"", "\"", ",", "ErrEmptyNumber", "\n", "}", "\n", "num", ",", "err", ":=", "libphonenumber", ".", "Parse", "(", "pn", ",", "\"", "\"", ")", "\n", "// Add some better error messages - the ones in libphonenumber are generic", "switch", "{", "case", "err", "==", "libphonenumber", ".", "ErrNotANumber", ":", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pn", ")", "\n", "case", "err", "==", "libphonenumber", ".", "ErrInvalidCountryCode", ":", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pn", ")", "\n", "<mask>", "err", "!=", "nil", ":", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "PhoneNumber", "(", "libphonenumber", ".", "Format", "(", "num", ",", "libphonenumber", ".", "E164", ")", ")", ",", "nil", "\n", "}" ]
1,881
all-1882
[ "Header", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockResponseWriter", ")", "<mask>", "(", ")", "http", ".", "Header", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "http", ".", "Header", ")", "\n", "return", "ret0", "\n", "}" ]
1,882
all-1883
[ "CreateExternalUser", "-" ]
[ "func", "(", "m", "*", "DefaultUAAManager", ")", "CreateExternalUser", "(", "userName", ",", "userEmail", ",", "externalID", ",", "origin", "string", ")", "(", "string", ",", "error", ")", "{", "if", "userName", "==", "\"", "\"", "||", "userEmail", "==", "\"", "\"", "||", "externalID", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "userName", ",", "userEmail", ",", "externalID", ")", "\n", "}", "\n", "if", "m", ".", "Peek", "{", "lo", ".", "G", ".", "Infof", "(", "\"", "\"", ",", "userName", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "userName", ",", "origin", ")", ",", "nil", "\n", "}", "\n\n", "createdUser", ",", "err", ":=", "m", ".", "Client", ".", "CreateUser", "(", "uaaclient", ".", "<mask>", "{", "Username", ":", "userName", ",", "ExternalID", ":", "externalID", ",", "Origin", ":", "origin", ",", "Emails", ":", "[", "]", "uaaclient", ".", "Email", "{", "uaaclient", ".", "Email", "{", "Value", ":", "userEmail", ",", "}", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "lo", ".", "G", ".", "Infof", "(", "\"", "\"", ",", "userName", ")", "\n", "return", "createdUser", ".", "ID", ",", "nil", "\n", "}" ]
1,883
all-1884
[ "renameTop", "renames", "all", "references", "to", "the", "top", "-", "level", "name", "old", ".", "It", "returns", "true", "if", "it", "makes", "any", "changes", "." ]
[ "func", "renameTop", "(", "f", "*", "ast", ".", "File", ",", "old", ",", "new", "string", ")", "bool", "{", "var", "fixed", "bool", "\n\n", "// Rename any conflicting imports", "// (assuming package name is last element of path).", "for", "_", ",", "s", ":=", "range", "f", ".", "Imports", "{", "if", "s", ".", "Name", "!=", "nil", "{", "if", "s", ".", "Name", ".", "Name", "==", "old", "{", "s", ".", "<mask>", ".", "Name", "=", "new", "\n", "fixed", "=", "true", "\n", "}", "\n", "}", "else", "{", "_", ",", "thisName", ":=", "path", ".", "Split", "(", "importPath", "(", "s", ")", ")", "\n", "if", "thisName", "==", "old", "{", "s", ".", "Name", "=", "ast", ".", "NewIdent", "(", "new", ")", "\n", "fixed", "=", "true", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// Rename any top-level declarations.", "for", "_", ",", "d", ":=", "range", "f", ".", "Decls", "{", "switch", "d", ":=", "d", ".", "(", "type", ")", "{", "case", "*", "ast", ".", "FuncDecl", ":", "if", "d", ".", "Recv", "==", "nil", "&&", "d", ".", "Name", ".", "Name", "==", "old", "{", "d", ".", "Name", ".", "Name", "=", "new", "\n", "d", ".", "Name", ".", "Obj", ".", "Name", "=", "new", "\n", "fixed", "=", "true", "\n", "}", "\n", "case", "*", "ast", ".", "GenDecl", ":", "for", "_", ",", "s", ":=", "range", "d", ".", "Specs", "{", "switch", "s", ":=", "s", ".", "(", "type", ")", "{", "case", "*", "ast", ".", "TypeSpec", ":", "if", "s", ".", "Name", ".", "Name", "==", "old", "{", "s", ".", "Name", ".", "Name", "=", "new", "\n", "s", ".", "Name", ".", "Obj", ".", "Name", "=", "new", "\n", "fixed", "=", "true", "\n", "}", "\n", "case", "*", "ast", ".", "ValueSpec", ":", "for", "_", ",", "n", ":=", "range", "s", ".", "Names", "{", "if", "n", ".", "Name", "==", "old", "{", "n", ".", "Name", "=", "new", "\n", "n", ".", "Obj", ".", "Name", "=", "new", "\n", "fixed", "=", "true", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// Rename top-level old to new, both unresolved names", "// (probably defined in another file) and names that resolve", "// to a declaration we renamed.", "walk", "(", "f", ",", "func", "(", "n", "interface", "{", "}", ")", "{", "id", ",", "ok", ":=", "n", ".", "(", "*", "ast", ".", "Ident", ")", "\n", "if", "ok", "&&", "isTopName", "(", "id", ",", "old", ")", "{", "id", ".", "Name", "=", "new", "\n", "fixed", "=", "true", "\n", "}", "\n", "if", "ok", "&&", "id", ".", "Obj", "!=", "nil", "&&", "id", ".", "Name", "==", "old", "&&", "id", ".", "Obj", ".", "Name", "==", "new", "{", "id", ".", "Name", "=", "id", ".", "Obj", ".", "Name", "\n", "fixed", "=", "true", "\n", "}", "\n", "}", ")", "\n\n", "return", "fixed", "\n", "}" ]
1,884
all-1885
[ "CreateReview", "creates", "a", "review", "using", "the", "draft", ".", "https", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "pulls", "/", "reviews", "/", "#create", "-", "a", "-", "pull", "-", "request", "-", "review" ]
[ "func", "(", "c", "*", "Client", ")", "CreateReview", "(", "org", ",", "repo", "string", ",", "number", "int", ",", "r", "DraftReview", ")", "error", "{", "c", ".", "log", "(", "\"", "\"", ",", "org", ",", "repo", ",", "number", ",", "r", ")", "\n", "_", ",", "err", ":=", "c", ".", "request", "(", "&", "request", "{", "method", ":", "http", ".", "MethodPost", ",", "path", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "org", ",", "repo", ",", "<mask>", ")", ",", "accept", ":", "\"", "\"", ",", "requestBody", ":", "r", ",", "exitCodes", ":", "[", "]", "int", "{", "200", "}", ",", "}", ",", "nil", ")", "\n", "return", "err", "\n", "}" ]
1,885
all-1886
[ "Parse", "will", "load", "options", "from", "the", "specified", "map" ]
[ "func", "(", "opts", "*", "jwtOptions", ")", "Parse", "(", "optMap", "map", "[", "string", "]", "string", ")", "error", "{", "var", "err", "error", "\n", "if", "ttl", ":=", "optMap", "[", "optTTL", "]", ";", "ttl", "!=", "\"", "\"", "{", "opts", ".", "TTL", ",", "err", "=", "time", ".", "ParseDuration", "(", "ttl", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "if", "file", ":=", "optMap", "[", "optPublicKey", "]", ";", "<mask>", "!=", "\"", "\"", "{", "opts", ".", "PublicKey", ",", "err", "=", "ioutil", ".", "ReadFile", "(", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "if", "file", ":=", "optMap", "[", "optPrivateKey", "]", ";", "file", "!=", "\"", "\"", "{", "opts", ".", "PrivateKey", ",", "err", "=", "ioutil", ".", "ReadFile", "(", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "// signing method is a required field", "method", ":=", "optMap", "[", "optSignMethod", "]", "\n", "opts", ".", "SignMethod", "=", "jwt", ".", "GetSigningMethod", "(", "method", ")", "\n", "if", "opts", ".", "SignMethod", "==", "nil", "{", "return", "ErrInvalidAuthMethod", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
1,886
all-1887
[ "Push", "adds", "event", "to", "the", "heap" ]
[ "func", "(", "t", "*", "EventTimeHeap", ")", "Push", "(", "x", "<mask>", "{", "}", ")", "{", "*", "t", "=", "append", "(", "*", "t", ",", "x", ".", "(", "sql", ".", "IssueEvent", ")", ")", "\n", "}" ]
1,887
all-1888
[ "Say", "write", "something", "in", "a", "chat" ]
[ "func", "(", "c", "*", "Client", ")", "Say", "(", "channel", ",", "text", "string", ")", "{", "channel", "=", "strings", ".", "ToLower", "(", "channel", ")", "\n\n", "c", ".", "send", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "<mask>", ",", "text", ")", ")", "\n", "}" ]
1,888
all-1889
[ "Get", "-" ]
[ "func", "(", "gateway", "*", "DefaultHttpGateway", ")", "Get", "(", "entity", "HttpRequestEntity", ")", "RequestAdaptor", "{", "return", "func", "(", ")", "(", "*", "http", ".", "<mask>", ",", "error", ")", "{", "return", "Request", "(", "entity", ",", "\"", "\"", ",", "nil", ")", "\n", "}", "\n", "}" ]
1,889
all-1890
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "delete", "Vm", "params" ]
[ "func", "(", "o", "*", "DeleteVMParams", ")", "WithTimeout", "(", "timeout", "<mask>", ".", "Duration", ")", "*", "DeleteVMParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
1,890
all-1891
[ "HasType", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "i", "*", "IntegrationGCPCreateRequest", ")", "HasType", "(", ")", "bool", "{", "if", "i", "!=", "nil", "&&", "i", ".", "Type", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
1,891
all-1892
[ "SetWriter", "sets", "HTTP", "header", "as", "defined", "by", "current", "instance", "to", "ResponseWriter", "Header", "." ]
[ "func", "(", "s", "*", "HttpHeader", ")", "SetWriter", "(", "h", "http", ".", "Header", ")", "*", "HttpHeader", "{", "h", ".", "<mask>", "(", "s", ".", "Name", ",", "s", ".", "Value", ")", "\n", "return", "s", "\n", "}" ]
1,892
all-1893
[ "NewPodLogArtifact", "creates", "a", "new", "PodLogArtifact" ]
[ "func", "NewPodLogArtifact", "(", "jobName", "string", ",", "buildID", "string", ",", "sizeLimit", "int64", ",", "ja", "jobAgent", ")", "(", "*", "PodLogArtifact", ",", "error", ")", "{", "if", "jobName", "==", "\"", "\"", "{", "return", "nil", ",", "errInsufficientJobInfo", "\n", "}", "\n", "if", "buildID", "==", "\"", "\"", "{", "return", "nil", ",", "errInsufficientJobInfo", "\n", "}", "\n", "if", "sizeLimit", "<", "0", "{", "return", "nil", ",", "errInvalidSizeLimit", "\n", "}", "\n", "return", "&", "PodLogArtifact", "{", "<mask>", ":", "jobName", ",", "buildID", ":", "buildID", ",", "sizeLimit", ":", "sizeLimit", ",", "jobAgent", ":", "ja", ",", "}", ",", "nil", "\n", "}" ]
1,893
all-1894
[ "DataWrapped", "acts", "the", "same", "as", "data", "struct", "field", "but", "passes", "retrieved", "value", "before", "returning", "through", "wrap", "function", "set", "by", "DataWrapper", "()", ".", "If", "no", "wrap", "function", "is", "set", "it", "returns", "raw", "unsafe", ".", "Pointer", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "Data", "(", ")", "interface", "{", "}", "{", "ptr", ":=", "v", ".", "dataRaw", "(", ")", "\n", "if", "v", ".", "dataWrap", "!=", "nil", "{", "return", "v", ".", "dataWrap", "(", "ptr", ")", "\n", "}", "\n", "return", "ptr", "\n", "}" ]
1,894
all-1895
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "GetAttributesParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoDom53", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "<mask>", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
1,895
all-1896
[ "1", ".", "Check", "commit", "messages", "in", "the", "pull", "request", "for", "the", "sign", "-", "off", "string", "2", ".", "Check", "the", "existing", "status", "context", "value", "3", ".", "Check", "the", "existing", "PR", "labels", "4", ".", "If", "signed", "off", "apply", "appropriate", "labels", "and", "status", "context", ".", "5", ".", "If", "not", "signed", "off", "apply", "appropriate", "labels", "and", "status", "context", "and", "add", "a", "comment", "." ]
[ "func", "handle", "(", "gc", "gitHubClient", ",", "cp", "commentPruner", ",", "<mask>", "*", "logrus", ".", "Entry", ",", "org", ",", "repo", "string", ",", "pr", "github", ".", "PullRequest", ",", "addComment", "bool", ")", "error", "{", "l", ":=", "log", ".", "WithField", "(", "\"", "\"", ",", "pr", ".", "Number", ")", "\n\n", "commitsMissingDCO", ",", "err", ":=", "checkCommitMessages", "(", "gc", ",", "l", ",", "org", ",", "repo", ",", "pr", ".", "Number", ")", "\n", "if", "err", "!=", "nil", "{", "l", ".", "WithError", "(", "err", ")", ".", "Infof", "(", "\"", "\"", ")", "\n", "return", "err", "\n", "}", "\n\n", "existingStatus", ",", "err", ":=", "checkExistingStatus", "(", "gc", ",", "l", ",", "org", ",", "repo", ",", "pr", ".", "Head", ".", "SHA", ")", "\n", "if", "err", "!=", "nil", "{", "l", ".", "WithError", "(", "err", ")", ".", "Infof", "(", "\"", "\"", ")", "\n", "return", "err", "\n", "}", "\n\n", "hasYesLabel", ",", "hasNoLabel", ",", "err", ":=", "checkExistingLabels", "(", "gc", ",", "l", ",", "org", ",", "repo", ",", "pr", ".", "Number", ")", "\n", "if", "err", "!=", "nil", "{", "l", ".", "WithError", "(", "err", ")", ".", "Infof", "(", "\"", "\"", ")", "\n", "return", "err", "\n", "}", "\n\n", "return", "takeAction", "(", "gc", ",", "cp", ",", "l", ",", "org", ",", "repo", ",", "pr", ",", "commitsMissingDCO", ",", "existingStatus", ",", "hasYesLabel", ",", "hasNoLabel", ",", "addComment", ")", "\n", "}" ]
1,896
all-1897
[ "MultiLogger", "creates", "a", "logger", "which", "contain", "multiple", "loggers", "." ]
[ "func", "MultiLogger", "(", "backends", "...", "Backend", ")", "LeveledBackend", "{", "<mask>", "leveledBackends", "[", "]", "LeveledBackend", "\n", "for", "_", ",", "backend", ":=", "range", "backends", "{", "leveledBackends", "=", "append", "(", "leveledBackends", ",", "AddModuleLevel", "(", "backend", ")", ")", "\n", "}", "\n", "return", "&", "multiLogger", "{", "leveledBackends", "}", "\n", "}" ]
1,897
all-1898
[ "SetLevel", "propagates", "the", "same", "level", "to", "all", "backends", "." ]
[ "func", "(", "b", "*", "multiLogger", ")", "SetLevel", "(", "level", "Level", ",", "module", "string", ")", "{", "for", "_", ",", "backend", ":=", "range", "b", ".", "backends", "{", "backend", ".", "SetLevel", "(", "<mask>", ",", "module", ")", "\n", "}", "\n", "}" ]
1,898
all-1899
[ "Sum64", "..." ]
[ "func", "Sum64", "(", "key", "string", ")", "uint64", "{", "h", ":=", "hasher", ".", "Get", "(", ")", ".", "(", "hash", ".", "Hash64", ")", "\n", "if", "_", ",", "err", ":=", "io", ".", "WriteString", "(", "h", ",", "<mask>", ")", ";", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "r", ":=", "h", ".", "Sum64", "(", ")", "\n", "h", ".", "Reset", "(", ")", "\n", "hasher", ".", "Put", "(", "h", ")", "\n", "return", "r", "\n", "}" ]
1,899
all-1900
[ "selectPackage", "chooses", "a", "package", "to", "generate", "rules", "for", "." ]
[ "func", "selectPackage", "(", "dir", ",", "rel", "string", ",", "packageMap", "map", "[", "string", "]", "*", "Package", ")", "(", "*", "Package", ",", "error", ")", "{", "if", "len", "(", "packageMap", ")", "==", "0", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "if", "len", "(", "packageMap", ")", "==", "1", "{", "for", "_", ",", "pkg", ":=", "<mask>", "packageMap", "{", "return", "pkg", ",", "nil", "\n", "}", "\n", "}", "\n", "defaultPackageName", ":=", "strings", ".", "Replace", "(", "rel", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n", "for", "_", ",", "pkg", ":=", "range", "packageMap", "{", "if", "pkgName", ":=", "goPackageName", "(", "pkg", ")", ";", "pkgName", "!=", "\"", "\"", "&&", "pkgName", "==", "defaultPackageName", "{", "return", "pkg", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "dir", ")", "\n", "}" ]