id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
listlengths
1
418
pl_tokens
listlengths
22
4.98k
18,200
all-18201
[ "MarshalEasyJSON", "satisfies", "easyjson", ".", "Marshaler", "." ]
[ "func", "(", "t", "ResourcePriority", ")", "MarshalEasyJSON", "(", "out", "*", "jwriter", ".", "Writer", ")", "{", "out", ".", "<mask>", "(", "string", "(", "t", ")", ")", "\n", "}" ]
18,201
all-18202
[ "Run", "executes", "the", "given", "vm", ".", "ByteCode", "using", "the", "given", "variables", ".", "For", "historical", "reasons", "it", "also", "allows", "re", "-", "executing", "the", "previous", "bytecode", "instructions", "given", "to", "a", "virtual", "machine", "but", "this", "will", "probably", "be", "removed", "in", "the", "future" ]
[ "func", "(", "vm", "*", "VM", ")", "Run", "(", "bc", "*", "ByteCode", ",", "vars", "Vars", ",", "output", "io", ".", "Writer", ")", "{", "if", "!", "vm", ".", "IsSupportedByteCodeVersion", "(", "bc", ")", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "bc", ".", "Version", ",", ")", ")", "\n", "}", "\n\n", "st", ":=", "vm", ".", "st", "\n\n", "if", "_", ",", "ok", ":=", "output", ".", "(", "*", "bufio", ".", "Writer", ")", ";", "!", "<mask>", "{", "output", "=", "bufio", ".", "NewWriter", "(", "output", ")", "\n", "defer", "output", ".", "(", "*", "bufio", ".", "Writer", ")", ".", "Flush", "(", ")", "\n", "}", "\n", "st", ".", "Reset", "(", ")", "\n", "st", ".", "pc", "=", "bc", "\n", "st", ".", "output", "=", "output", "\n", "newvars", ":=", "Vars", "(", "rvpool", ".", "Get", "(", ")", ")", "\n", "defer", "rvpool", ".", "Release", "(", "newvars", ")", "\n", "defer", "newvars", ".", "Reset", "(", ")", "\n\n", "st", ".", "vars", "=", "newvars", "\n", "if", "fc", ":=", "vm", ".", "functions", ";", "fc", "!=", "nil", "{", "for", "k", ",", "v", ":=", "range", "vm", ".", "functions", "{", "st", ".", "vars", "[", "k", "]", "=", "v", "\n", "}", "\n", "}", "\n\n", "if", "vars", "!=", "nil", "{", "for", "k", ",", "v", ":=", "range", "vars", "{", "st", ".", "vars", "[", "k", "]", "=", "v", "\n", "}", "\n", "}", "\n", "st", ".", "Loader", "=", "vm", ".", "Loader", "\n\n", "// This is the main loop", "for", "op", ":=", "st", ".", "CurrentOp", "(", ")", ";", "op", ".", "Type", "(", ")", "!=", "TXOPEnd", ";", "op", "=", "st", ".", "CurrentOp", "(", ")", "{", "op", ".", "Call", "(", "st", ")", "\n", "}", "\n", "}" ]
18,202
all-18203
[ "CreateConfigIfNotExists", "initializes", "a", "new", "configuration", "directory", ".", "If", "the", "specified", "configuration", "directory", "already", "exists", "it", "is", "left", "unmodified", "." ]
[ "func", "(", "m", "*", "yamlManager", ")", "CreateConfigIfNotExists", "(", "uaaOrigin", "string", ")", "error", "{", "if", "FileOrDirectoryExists", "(", "m", ".", "ConfigDir", ")", "{", "lo", ".", "G", ".", "Infof", "(", "\"", "\"", ",", "m", ".", "ConfigDir", ")", "\n", "return", "nil", "\n", "}", "\n", "if", "err", ":=", "os", ".", "MkdirAll", "(", "m", ".", "ConfigDir", ",", "0755", ")", ";", "err", "!=", "nil", "{", "lo", ".", "G", ".", "Errorf", "(", "\"", "\"", ",", "m", ".", "ConfigDir", ",", "err", ")", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "m", ".", "ConfigDir", ",", "err", ")", "\n", "}", "\n", "lo", ".", "G", ".", "Infof", "(", "\"", "\"", ",", "m", ".", "ConfigDir", ")", "\n\n", "asgDir", ":=", "path", ".", "Join", "(", "m", ".", "ConfigDir", ",", "\"", "\"", ")", "\n", "if", "err", ":=", "os", ".", "MkdirAll", "(", "asgDir", ",", "0755", ")", ";", "err", "!=", "nil", "{", "lo", ".", "G", ".", "Errorf", "(", "\"", "\"", ",", "asgDir", ",", "err", ")", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "asgDir", ",", "err", ")", "\n", "}", "\n", "lo", ".", "G", ".", "Infof", "(", "\"", "\"", ",", "asgDir", ")", "\n\n", "asgDir", "=", "path", ".", "Join", "(", "m", ".", "ConfigDir", ",", "\"", "\"", ")", "\n", "if", "err", ":=", "os", ".", "MkdirAll", "(", "asgDir", ",", "0755", ")", ";", "err", "!=", "nil", "{", "lo", ".", "G", ".", "Errorf", "(", "\"", "\"", ",", "asgDir", ",", "err", ")", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "asgDir", ",", "err", ")", "\n", "}", "\n", "lo", ".", "G", ".", "Infof", "(", "\"", "\"", ",", "asgDir", ")", "\n\n", "orgQuotasDir", ":=", "path", ".", "Join", "(", "m", ".", "ConfigDir", ",", "\"", "\"", ")", "\n", "if", "err", ":=", "<mask>", ".", "MkdirAll", "(", "orgQuotasDir", ",", "0755", ")", ";", "err", "!=", "nil", "{", "lo", ".", "G", ".", "Errorf", "(", "\"", "\"", ",", "orgQuotasDir", ",", "err", ")", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "orgQuotasDir", ",", "err", ")", "\n", "}", "\n", "lo", ".", "G", ".", "Infof", "(", "\"", "\"", ",", "orgQuotasDir", ")", "\n\n", "if", "err", ":=", "m", ".", "SaveGlobalConfig", "(", "&", "GlobalConfig", "{", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "WriteFile", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "ConfigDir", ")", ",", "&", "LdapConfig", "{", "TLS", ":", "false", ",", "Origin", ":", "uaaOrigin", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "err", ":=", "WriteFile", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "ConfigDir", ")", ",", "&", "Orgs", "{", "EnableDeleteOrgs", ":", "true", ",", "ProtectedOrgs", ":", "DefaultProtectedOrgs", ",", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "WriteFile", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "ConfigDir", ")", ",", "struct", "{", "Developer", "UserMgmt", "`yaml:\"space-developer\"`", "\n", "Manager", "UserMgmt", "`yaml:\"space-manager\"`", "\n", "Auditor", "UserMgmt", "`yaml:\"space-auditor\"`", "\n", "}", "{", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
18,203
all-18204
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "RemoveScriptToEvaluateOnNewDocumentParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage20", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
18,204
all-18205
[ "Delete", "the", "label" ]
[ "func", "kill", "(", "repo", "string", ",", "label", "<mask>", ")", "Update", "{", "logrus", ".", "WithField", "(", "\"", "\"", ",", "repo", ")", ".", "WithField", "(", "\"", "\"", ",", "label", ".", "Name", ")", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "Update", "{", "Why", ":", "\"", "\"", ",", "Current", ":", "&", "label", ",", "repo", ":", "repo", "}", "\n", "}" ]
18,205
all-18206
[ "HasServiceKey", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "s", "*", "ServicePDRequest", ")", "HasServiceKey", "(", ")", "bool", "{", "if", "s", "!=", "nil", "&&", "s", ".", "ServiceKey", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
18,206
all-18207
[ "SetAccount", "mutates", "key", "such", "that", "it", "represents", "the", "identity", "of", "account" ]
[ "func", "(", "key", "*", "LedgerKey", ")", "SetAccount", "(", "account", "AccountId", ")", "error", "{", "<mask>", ":=", "LedgerKeyAccount", "{", "account", "}", "\n", "nkey", ",", "err", ":=", "NewLedgerKey", "(", "LedgerEntryTypeAccount", ",", "data", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "*", "key", "=", "nkey", "\n", "return", "nil", "\n", "}" ]
18,207
all-18208
[ "modifiedGoFiles", "returns", "a", "map", "from", "filename", "to", "patch", "string", "for", "all", "go", "files", "that", "are", "modified", "in", "the", "PR", "excluding", "vendor", "/", "and", "generated", "files", "." ]
[ "func", "modifiedGoFiles", "(", "ghc", "githubClient", ",", "org", ",", "repo", "string", ",", "number", "int", ",", "sha", "string", ")", "(", "<mask>", "[", "string", "]", "string", ",", "error", ")", "{", "changes", ",", "err", ":=", "ghc", ".", "GetPullRequestChanges", "(", "org", ",", "repo", ",", "number", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "gfg", ",", "err", ":=", "genfiles", ".", "NewGroup", "(", "ghc", ",", "org", ",", "repo", ",", "sha", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "modifiedFiles", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "for", "_", ",", "change", ":=", "range", "changes", "{", "switch", "{", "case", "strings", ".", "HasPrefix", "(", "change", ".", "Filename", ",", "\"", "\"", ")", ":", "continue", "\n", "case", "filepath", ".", "Ext", "(", "change", ".", "Filename", ")", "!=", "\"", "\"", ":", "continue", "\n", "case", "gfg", ".", "Match", "(", "change", ".", "Filename", ")", ":", "continue", "\n", "case", "change", ".", "Status", "==", "github", ".", "PullRequestFileRemoved", "||", "change", ".", "Status", "==", "github", ".", "PullRequestFileRenamed", ":", "continue", "\n", "}", "\n", "modifiedFiles", "[", "change", ".", "Filename", "]", "=", "change", ".", "Patch", "\n", "}", "\n", "return", "modifiedFiles", ",", "nil", "\n", "}" ]
18,208
all-18209
[ "Increment", "atomically", "increments", "key", "by", "delta", ".", "The", "return", "value", "is", "the", "new", "value", "after", "being", "incremented", "or", "an", "error", ".", "If", "the", "value", "didn", "t", "exist", "in", "memcached", "the", "error", "is", "ErrCacheMiss", ".", "The", "value", "in", "memcached", "must", "be", "an", "decimal", "number", "or", "an", "error", "will", "be", "returned", ".", "On", "64", "-", "bit", "overflow", "the", "new", "value", "wraps", "around", "." ]
[ "func", "(", "c", "*", "<mask>", ")", "Increment", "(", "key", "string", ",", "delta", "uint64", ")", "(", "newValue", "uint64", ",", "err", "error", ")", "{", "return", "c", ".", "incrDecr", "(", "cmdIncr", ",", "key", ",", "delta", ")", "\n", "}" ]
18,209
all-18210
[ "flattenBaseClusterDasAdmissionControlPolicy", "saves", "a", "BaseClusterDasAdmissionControlPolicy", "into", "the", "supplied", "ResourceData", "." ]
[ "func", "flattenBaseClusterDasAdmissionControlPolicy", "(", "d", "*", "schema", ".", "ResourceData", ",", "obj", "types", ".", "BaseClusterDasAdmissionControlPolicy", ",", "version", "viapi", ".", "VSphereVersion", ",", ")", "error", "{", "var", "policy", "string", "\n\n", "switch", "t", ":=", "obj", ".", "(", "type", ")", "{", "case", "*", "types", ".", "ClusterFailoverResourcesAdmissionControlPolicy", ":", "if", "err", ":=", "flattenClusterFailoverResourcesAdmissionControlPolicy", "(", "d", ",", "t", ",", "version", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "policy", "=", "clusterAdmissionControlTypeResourcePercentage", "\n", "case", "*", "types", ".", "ClusterFailoverLevelAdmissionControlPolicy", ":", "if", "err", ":=", "flattenClusterFailoverLevelAdmissionControlPolicy", "(", "d", ",", "t", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "policy", "=", "clusterAdmissionControlTypeSlotPolicy", "\n", "case", "*", "types", ".", "ClusterFailoverHostAdmissionControlPolicy", ":", "if", "err", ":=", "flattenClusterFailoverHostAdmissionControlPolicy", "(", "d", ",", "t", ",", "version", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "policy", "=", "clusterAdmissionControlTypeFailoverHosts", "\n", "default", ":", "policy", "=", "clusterAdmissionControlTypeDisabled", "\n", "}", "\n\n", "return", "d", ".", "Set", "(", "\"", "\"", ",", "<mask>", ")", "\n", "}" ]
18,210
all-18211
[ "Fetch", "queries", "the", "Consul", "API", "defined", "by", "the", "given", "client", "." ]
[ "func", "(", "d", "*", "KVListQuery", ")", "Fetch", "(", "clients", "*", "ClientSet", ",", "opts", "*", "QueryOptions", ")", "(", "interface", "{", "}", ",", "*", "ResponseMetadata", ",", "error", ")", "{", "select", "{", "case", "<-", "d", ".", "stopCh", ":", "return", "nil", ",", "nil", ",", "ErrStopped", "\n", "default", ":", "}", "\n\n", "opts", "=", "opts", ".", "Merge", "(", "&", "QueryOptions", "{", "Datacenter", ":", "d", ".", "dc", ",", "}", ")", "\n\n", "log", ".", "Printf", "(", "\"", "\"", ",", "d", ",", "&", "url", ".", "URL", "{", "Path", ":", "\"", "\"", "+", "d", ".", "<mask>", ",", "RawQuery", ":", "opts", ".", "String", "(", ")", ",", "}", ")", "\n\n", "list", ",", "qm", ",", "err", ":=", "clients", ".", "Consul", "(", ")", ".", "KV", "(", ")", ".", "List", "(", "d", ".", "prefix", ",", "opts", ".", "ToConsulOpts", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "d", ".", "String", "(", ")", ")", "\n", "}", "\n\n", "log", ".", "Printf", "(", "\"", "\"", ",", "d", ",", "len", "(", "list", ")", ")", "\n\n", "pairs", ":=", "make", "(", "[", "]", "*", "KeyPair", ",", "0", ",", "len", "(", "list", ")", ")", "\n", "for", "_", ",", "pair", ":=", "range", "list", "{", "key", ":=", "strings", ".", "TrimPrefix", "(", "pair", ".", "Key", ",", "d", ".", "prefix", ")", "\n", "key", "=", "strings", ".", "TrimLeft", "(", "key", ",", "\"", "\"", ")", "\n\n", "pairs", "=", "append", "(", "pairs", ",", "&", "KeyPair", "{", "Path", ":", "pair", ".", "Key", ",", "Key", ":", "key", ",", "Value", ":", "string", "(", "pair", ".", "Value", ")", ",", "CreateIndex", ":", "pair", ".", "CreateIndex", ",", "ModifyIndex", ":", "pair", ".", "ModifyIndex", ",", "LockIndex", ":", "pair", ".", "LockIndex", ",", "Flags", ":", "pair", ".", "Flags", ",", "Session", ":", "pair", ".", "Session", ",", "}", ")", "\n", "}", "\n\n", "rm", ":=", "&", "ResponseMetadata", "{", "LastIndex", ":", "qm", ".", "LastIndex", ",", "LastContact", ":", "qm", ".", "LastContact", ",", "}", "\n\n", "return", "pairs", ",", "rm", ",", "nil", "\n", "}" ]
18,211
all-18212
[ "Ps", "lists", "the", "running", "processes", "in", "the", "guest", "operating", "system", ".", "Since", "Workstation", "6", ".", "0", "Minimum", "Supported", "Guest", "OS", ":", "Microsoft", "Windows", "NT", "Series", "Linux" ]
[ "func", "(", "g", "*", "Guest", ")", "Ps", "(", ")", "(", "[", "]", "*", "GuestProcess", ",", "error", ")", "{", "var", "jobHandle", "C", ".", "VixHandle", "=", "C", ".", "VIX_INVALID_HANDLE", "\n", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "var", "processes", "[", "]", "*", "GuestProcess", "\n\n", "jobHandle", "=", "C", ".", "VixVM_ListProcessesInGuest", "(", "g", ".", "handle", ",", "0", ",", "nil", ",", "nil", ")", "\n", "defer", "C", ".", "Vix_ReleaseHandle", "(", "jobHandle", ")", "\n\n", "err", "=", "C", ".", "vix_job_wait", "(", "jobHandle", ")", "\n", "if", "C", ".", "VIX_OK", "!=", "err", "{", "return", "nil", ",", "&", "Error", "{", "Operation", ":", "\"", "\"", ",", "Code", ":", "int", "(", "err", "&", "0xFFFF", ")", ",", "Text", ":", "C", ".", "GoString", "(", "C", ".", "Vix_GetErrorText", "(", "err", ",", "nil", ")", ")", ",", "}", "\n", "}", "\n\n", "num", ":=", "C", ".", "VixJob_GetNumProperties", "(", "jobHandle", ",", "C", ".", "VIX_PROPERTY_JOB_RESULT_ITEM_NAME", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "int", "(", "num", ")", ";", "i", "++", "{", "var", "name", "*", "C", ".", "char", "\n", "var", "pid", "*", "C", ".", "uint64", "\n", "var", "owner", "*", "C", ".", "char", "\n", "var", "cmdline", "*", "C", ".", "char", "\n", "var", "isDebugged", "*", "C", ".", "Bool", "\n", "var", "startTime", "*", "C", ".", "int", "\n\n", "gprocess", ":=", "&", "GuestProcess", "{", "}", "\n\n", "err", "=", "C", ".", "get_guest_process", "(", "jobHandle", ",", "C", ".", "int", "(", "i", ")", ",", "name", ",", "pid", ",", "owner", ",", "cmdline", ",", "isDebugged", ",", "startTime", ")", "\n\n", "if", "C", ".", "VIX_OK", "!=", "err", "{", "return", "nil", ",", "&", "Error", "{", "Operation", ":", "\"", "\"", ",", "Code", ":", "int", "(", "err", "&", "0xFFFF", ")", ",", "Text", ":", "C", ".", "GoString", "(", "C", ".", "Vix_GetErrorText", "(", "err", ",", "nil", ")", ")", ",", "}", "\n", "}", "\n\n", "gprocess", ".", "Name", "=", "C", ".", "GoString", "(", "name", ")", "\n", "C", ".", "Vix_FreeBuffer", "(", "unsafe", ".", "Pointer", "(", "name", ")", ")", "\n\n", "gprocess", ".", "Pid", "=", "uint64", "(", "*", "<mask>", ")", "\n\n", "gprocess", ".", "Owner", "=", "C", ".", "GoString", "(", "owner", ")", "\n", "C", ".", "Vix_FreeBuffer", "(", "unsafe", ".", "Pointer", "(", "owner", ")", ")", "\n\n", "gprocess", ".", "Cmdline", "=", "C", ".", "GoString", "(", "cmdline", ")", "\n", "C", ".", "Vix_FreeBuffer", "(", "unsafe", ".", "Pointer", "(", "cmdline", ")", ")", "\n\n", "if", "*", "isDebugged", "==", "1", "{", "gprocess", ".", "IsDebugged", "=", "true", "\n", "}", "else", "{", "gprocess", ".", "IsDebugged", "=", "false", "\n", "}", "\n\n", "gprocess", ".", "StartTime", "=", "int", "(", "*", "startTime", ")", "\n\n", "processes", "=", "append", "(", "processes", ",", "gprocess", ")", "\n", "}", "\n\n", "return", "processes", ",", "nil", "\n", "}" ]
18,212
all-18213
[ "Locator", "returns", "a", "locator", "for", "the", "given", "resource" ]
[ "func", "(", "r", "*", "Repository", ")", "Locator", "(", "api", "*", "API", ")", "*", "RepositoryLocator", "{", "for", "_", ",", "l", ":=", "<mask>", "r", ".", "Links", "{", "if", "l", "[", "\"", "\"", "]", "==", "\"", "\"", "{", "return", "api", ".", "RepositoryLocator", "(", "l", "[", "\"", "\"", "]", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
18,213
all-18214
[ "UpdateOffering", "updates", "an", "offering", "." ]
[ "func", "(", "h", "*", "Handler", ")", "UpdateOffering", "(", "tkn", "string", ",", "offering", "*", "data", ".", "Offering", ")", "error", "{", "logger", ":=", "h", ".", "logger", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "offering", ")", "\n\n", "if", "!", "h", ".", "token", ".", "Check", "(", "tkn", ")", "{", "logger", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "ErrAccessDenied", "\n", "}", "\n\n", "err", ":=", "h", ".", "findByPrimaryKey", "(", "logger", ",", "ErrOfferingNotFound", ",", "&", "data", ".", "Offering", "{", "}", ",", "offering", ".", "ID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "<mask>", "(", "logger", ",", "h", ".", "db", ".", "Querier", ",", "offering", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
18,214
all-18215
[ "gtk_popover_new", "()" ]
[ "func", "PopoverNew", "(", "<mask>", "IWidget", ")", "(", "*", "Popover", ",", "error", ")", "{", "//Takes relative to widget", "var", "c", "*", "C", ".", "struct__GtkWidget", "\n", "if", "relative", "==", "nil", "{", "c", "=", "C", ".", "gtk_popover_new", "(", "nil", ")", "\n", "}", "else", "{", "c", "=", "C", ".", "gtk_popover_new", "(", "relative", ".", "toWidget", "(", ")", ")", "\n", "}", "\n", "if", "c", "==", "nil", "{", "return", "nil", ",", "nilPtrErr", "\n", "}", "\n", "return", "wrapPopover", "(", "glib", ".", "Take", "(", "unsafe", ".", "Pointer", "(", "c", ")", ")", ")", ",", "nil", "\n", "}" ]
18,215
all-18216
[ "Populate", "a", "field", "consisting", "of", "a", "slice", "of", "objects", "referencing", "the", "entity", ".", "This", "information", "is", "available", "by", "joining", "a", "the", "view", "or", "table", "associated", "with", "the", "type", "of", "the", "referenced", "objects", "which", "must", "contain", "the", "natural", "key", "of", "the", "entity", "." ]
[ "func", "(", "m", "*", "Method", ")", "fillSliceReferenceField", "(", "buf", "*", "file", ".", "Buffer", ",", "nk", "[", "]", "*", "Field", ",", "field", "*", "Field", ")", "error", "{", "objectsVar", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "lex", ".", "Minuscule", "(", "field", ".", "Name", ")", ")", "\n", "methodName", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "lex", ".", "Capital", "(", "m", ".", "entity", ")", ",", "<mask>", ".", "Name", ")", "\n\n", "buf", ".", "L", "(", "\"", "\"", ",", "field", ".", "Name", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ",", "objectsVar", ",", "methodName", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ")", "\n", "buf", ".", "L", "(", "\"", "\\\"", "\\\"", "\"", ",", "field", ".", "Name", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ")", "\n", "buf", ".", "N", "(", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ")", "\n", "needle", ":=", "\"", "\"", "\n", "for", "i", ",", "key", ":=", "range", "nk", "[", ":", "len", "(", "nk", ")", "-", "1", "]", "{", "needle", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "key", ".", "Name", ")", "\n", "subIndexTyp", ":=", "indexType", "(", "nk", "[", "i", "+", "1", ":", "]", ",", "field", ".", "Type", ".", "Name", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ",", "objectsVar", ",", "needle", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ",", "subIndexTyp", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ",", "objectsVar", ",", "needle", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ")", "\n", "buf", ".", "N", "(", ")", "\n", "}", "\n\n", "needle", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "nk", "[", "len", "(", "nk", ")", "-", "1", "]", ".", "Name", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ",", "objectsVar", ",", "needle", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ",", "field", ".", "Type", ".", "Name", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ",", "field", ".", "Name", ")", "\n", "buf", ".", "L", "(", "\"", "\"", ")", "\n", "buf", ".", "N", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
18,216
all-18217
[ "GetContainerConsoleLog", "requests", "that", "LXD", "attaches", "to", "the", "console", "device", "of", "a", "container", ".", "Note", "that", "it", "s", "the", "caller", "s", "responsibility", "to", "close", "the", "returned", "ReadCloser" ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetContainerConsoleLog", "(", "containerName", "string", ",", "args", "*", "ContainerConsoleLogArgs", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"", "\"", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ")", "\n", "}", "\n\n", "// Prepare the HTTP request", "url", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ".", "httpHost", ",", "url", ".", "QueryEscape", "(", "containerName", ")", ")", "\n\n", "url", ",", "err", ":=", "r", ".", "setQueryAttributes", "(", "url", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "<mask>", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Set the user agent", "if", "r", ".", "httpUserAgent", "!=", "\"", "\"", "{", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "r", ".", "httpUserAgent", ")", "\n", "}", "\n\n", "// Send the request", "resp", ",", "err", ":=", "r", ".", "do", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Check the return value for a cleaner error", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "_", ",", "_", ",", "err", ":=", "lxdParseResponse", "(", "resp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "resp", ".", "Body", ",", "err", "\n", "}" ]
18,217
all-18218
[ "IsExpired", "returns", "if", "the", "credentials", "are", "no", "longer", "valid", "and", "need", "to", "be", "retrieved", "." ]
[ "func", "(", "v", "*", "vaultCredentialsProvider", ")", "IsExpired", "(", ")", "bool", "{", "v", ".", "leaseMu", ".", "Lock", "(", ")", "\n", "defer", "v", ".", "leaseMu", ".", "Unlock", "(", ")", "\n", "return", "<mask>", ".", "Now", "(", ")", ".", "After", "(", "v", ".", "leaseLastRenew", ".", "Add", "(", "v", ".", "leaseDuration", ")", ")", "\n", "}" ]
18,218
all-18219
[ "Devices", "fetches", "a", "list", "of", "devices", "from", "PushBullet", "." ]
[ "func", "(", "c", "*", "Client", ")", "Devices", "(", ")", "(", "[", "]", "*", "Device", ",", "error", ")", "{", "req", ":=", "c", ".", "buildRequest", "(", "\"", "\"", ",", "nil", ")", "\n", "resp", ",", "err", ":=", "c", ".", "Client", ".", "Do", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "var", "errjson", "errorResponse", "\n", "dec", ":=", "json", ".", "NewDecoder", "(", "resp", ".", "Body", ")", "\n", "err", "=", "dec", ".", "Decode", "(", "&", "errjson", ")", "\n", "if", "err", "==", "nil", "{", "return", "nil", ",", "&", "errjson", ".", "ErrResponse", "\n", "}", "\n\n", "return", "nil", ",", "errors", ".", "New", "(", "resp", ".", "<mask>", ")", "\n", "}", "\n\n", "var", "devResp", "deviceResponse", "\n", "dec", ":=", "json", ".", "NewDecoder", "(", "resp", ".", "Body", ")", "\n", "err", "=", "dec", ".", "Decode", "(", "&", "devResp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "for", "i", ":=", "range", "devResp", ".", "Devices", "{", "devResp", ".", "Devices", "[", "i", "]", ".", "Client", "=", "c", "\n", "}", "\n", "devices", ":=", "append", "(", "devResp", ".", "Devices", ",", "devResp", ".", "SharedDevices", "...", ")", "\n", "return", "devices", ",", "nil", "\n", "}" ]
18,219
all-18220
[ "DeleteCookie", "deletes", "a", "cookie", "on", "the", "page", "by", "name", "." ]
[ "func", "(", "p", "*", "Page", ")", "DeleteCookie", "(", "name", "string", ")", "error", "{", "if", "err", ":=", "p", ".", "<mask>", ".", "DeleteCookie", "(", "name", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
18,220
all-18221
[ "ListResourcesByType", "list", "resources", "by", "type" ]
[ "func", "(", "c", "*", "Client", ")", "ListResourcesByType", "(", "resourcetype", "string", ")", "(", "*", "Resources", ",", "error", ")", "{", "url", ":=", "umResourcesType", "(", "resourcetype", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "<mask>", ":=", "&", "Resources", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Get", "(", "url", ",", "ret", ",", "http", ".", "StatusOK", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
18,221
all-18222
[ "Get", "a", "list", "of", "all", "roles", "each", "role", "object", "also", "includes", "the", "list", "of", "scopes", "it", "expands", "to", ".", "See", "#listRoles" ]
[ "func", "(", "auth", "*", "Auth", ")", "ListRoles", "(", ")", "(", "*", "GetAllRolesNoPagination", ",", "error", ")", "{", "cd", ":=", "tcclient", ".", "Client", "(", "*", "auth", ")", "\n", "responseObject", ",", "_", ",", "err", ":=", "(", "&", "cd", ")", ".", "APICall", "(", "nil", ",", "\"", "\"", ",", "\"", "\"", ",", "<mask>", "(", "GetAllRolesNoPagination", ")", ",", "nil", ")", "\n", "return", "responseObject", ".", "(", "*", "GetAllRolesNoPagination", ")", ",", "err", "\n", "}" ]
18,222
all-18223
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "GetNodeForLocationReturns", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoDom38", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
18,223
all-18224
[ "normalizeRegistries", "removes", "trailing", "slashes", "from", "registries", "which", "is", "a", "common", "pitfall", "when", "configuring", "registries", "(", "e", ".", "g", ".", "docker", ".", "io", "/", "library", "/", ")", "." ]
[ "func", "normalizeRegistries", "(", "regs", "*", "registries", ")", "{", "for", "i", ":=", "<mask>", "regs", ".", "Registries", "{", "regs", ".", "Registries", "[", "i", "]", "=", "strings", ".", "TrimRight", "(", "regs", ".", "Registries", "[", "i", "]", ",", "\"", "\"", ")", "\n", "}", "\n", "}" ]
18,224
all-18225
[ "Open", "explicitly", "tells", "the", "encoder", "to", "start", "the", "stream", "setting", "the", "number", "of", "values", "to", "n", ".", "Depending", "on", "the", "actual", "format", "that", "the", "stream", "is", "encoding", "to", "n", "may", "or", "may", "not", "have", "to", "be", "accurate", "some", "formats", "also", "support", "passing", "a", "negative", "value", "to", "indicate", "that", "the", "number", "of", "elements", "is", "unknown", "." ]
[ "func", "(", "e", "*", "StreamEncoder", ")", "Open", "(", "n", "int", ")", "error", "{", "if", "err", ":=", "e", ".", "err", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "e", ".", "<mask>", "{", "return", "io", ".", "ErrClosedPipe", "\n", "}", "\n\n", "if", "!", "e", ".", "opened", "{", "e", ".", "max", "=", "n", "\n", "e", ".", "opened", "=", "true", "\n\n", "if", "!", "e", ".", "oneshot", "{", "e", ".", "err", "=", "e", ".", "Emitter", ".", "EmitArrayBegin", "(", "n", ")", "\n", "}", "\n", "}", "\n\n", "return", "e", ".", "err", "\n", "}" ]
18,225
all-18226
[ "ValidateController", "validates", "the", "provided", "controller", "config", "." ]
[ "func", "ValidateController", "(", "c", "*", "<mask>", ")", "error", "{", "urlTmpl", ",", "err", ":=", "template", ".", "New", "(", "\"", "\"", ")", ".", "Parse", "(", "c", ".", "JobURLTemplateString", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "c", ".", "JobURLTemplate", "=", "urlTmpl", "\n\n", "reportTmpl", ",", "err", ":=", "template", ".", "New", "(", "\"", "\"", ")", ".", "Parse", "(", "c", ".", "ReportTemplateString", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "c", ".", "ReportTemplate", "=", "reportTmpl", "\n", "if", "c", ".", "MaxConcurrency", "<", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "c", ".", "MaxConcurrency", ")", "\n", "}", "\n", "if", "c", ".", "MaxGoroutines", "==", "0", "{", "c", ".", "MaxGoroutines", "=", "20", "\n", "}", "\n", "if", "c", ".", "MaxGoroutines", "<=", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "c", ".", "MaxGoroutines", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
18,226
all-18227
[ "Update", "implements", "Update", "method", "of", "PlatformService", "interface" ]
[ "func", "(", "s", "*", "platformService", ")", "Update", "(", "opts", "appTypes", ".", "PlatformOptions", ")", "error", "{", "if", "opts", ".", "Name", "==", "\"", "\"", "{", "return", "appTypes", ".", "ErrPlatformNameMissing", "\n", "}", "\n", "conn", ",", "err", ":=", "db", ".", "Conn", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "conn", ".", "Close", "(", ")", "\n", "_", ",", "err", "=", "s", ".", "FindByName", "(", "opts", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "opts", ".", "Input", "!=", "nil", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "opts", ".", "Input", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "len", "(", "data", ")", "==", "0", "{", "return", "appTypes", ".", "ErrMissingFileContent", "\n", "}", "\n", "opts", ".", "Data", "=", "data", "\n", "opts", ".", "ImageName", ",", "err", "=", "servicemanager", ".", "PlatformImage", ".", "NewImage", "(", "opts", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "builder", ".", "PlatformUpdate", "(", "opts", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "servicemanager", ".", "PlatformImage", ".", "AppendImage", "(", "opts", ".", "Name", ",", "opts", ".", "ImageName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "var", "apps", "[", "]", "App", "\n", "err", "=", "conn", ".", "Apps", "(", ")", ".", "Find", "(", "bson", ".", "M", "{", "\"", "\"", ":", "opts", ".", "Name", "}", ")", ".", "All", "(", "&", "apps", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "_", ",", "app", ":=", "range", "apps", "{", "app", ".", "SetUpdatePlatform", "(", "true", ")", "\n", "}", "\n", "}", "\n", "if", "opts", ".", "Args", "[", "\"", "\"", "]", "!=", "\"", "\"", "{", "disableBool", ",", "err", ":=", "strconv", ".", "ParseBool", "(", "opts", ".", "Args", "[", "\"", "\"", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "s", ".", "storage", ".", "Update", "(", "appTypes", ".", "Platform", "{", "Name", ":", "opts", ".", "<mask>", ",", "Disabled", ":", "disableBool", "}", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
18,227
all-18228
[ "DeleteExpiredKeys", "will", "delete", "all", "expired", "keys" ]
[ "func", "(", "s", "*", "store", ")", "DeleteExpiredKeys", "(", "cutoff", "time", ".", "Time", ")", "{", "s", ".", "worldLock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "worldLock", ".", "Unlock", "(", ")", "\n\n", "for", "{", "node", ":=", "s", ".", "ttlKeyHeap", ".", "top", "(", ")", "\n", "if", "node", "==", "nil", "||", "node", ".", "ExpireTime", ".", "After", "(", "cutoff", ")", "{", "break", "\n", "}", "\n\n", "s", ".", "CurrentIndex", "++", "\n", "e", ":=", "newEvent", "(", "Expire", ",", "node", ".", "Path", ",", "s", ".", "CurrentIndex", ",", "node", ".", "CreatedIndex", ")", "\n", "e", ".", "EtcdIndex", "=", "s", ".", "CurrentIndex", "\n", "e", ".", "PrevNode", "=", "node", ".", "Repr", "(", "false", ",", "false", ",", "s", ".", "clock", ")", "\n", "if", "node", ".", "IsDir", "(", ")", "{", "e", ".", "Node", ".", "Dir", "=", "true", "\n", "}", "\n\n", "callback", ":=", "func", "(", "path", "string", ")", "{", "// notify function", "// notify the watchers with deleted set true", "s", ".", "WatcherHub", ".", "notifyWatchers", "(", "e", ",", "<mask>", ",", "true", ")", "\n", "}", "\n\n", "s", ".", "ttlKeyHeap", ".", "pop", "(", ")", "\n", "node", ".", "Remove", "(", "true", ",", "true", ",", "callback", ")", "\n\n", "reportExpiredKey", "(", ")", "\n", "s", ".", "Stats", ".", "Inc", "(", "ExpireCount", ")", "\n\n", "s", ".", "WatcherHub", ".", "notify", "(", "e", ")", "\n", "}", "\n\n", "}" ]
18,228
all-18229
[ "PromptCmd", "represents", "the", "kubicorn", "interactive", "prompt", "." ]
[ "func", "PromptCmd", "(", ")", "*", "cobra", ".", "Command", "{", "return", "&", "cobra", ".", "Command", "{", "Use", ":", "\"", "\"", ",", "Short", ":", "\"", "\"", ",", "Long", ":", "`Use this command to use the Kubicron API via a shell prompt.\n\t\n\tThis command will open a prompt using go-prompt (with auto-completion) to\n\tallow you to run commands interactively from the shell.\n\tCurrently this doesn't work on Windows systems.`", ",", "Run", ":", "func", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "logger", ".", "Critical", "(", "\"", "\"", ")", "\n", "<mask>", ".", "Exit", "(", "1", ")", "\n", "}", ",", "}", "\n", "}" ]
18,229
all-18230
[ "Get", "value", "by", "key", "insert", "the", "key", "if", "not", "exist" ]
[ "func", "(", "da", "*", "cedar", ")", "get", "(", "key", "[", "]", "byte", ",", "from", ",", "pos", "int", ")", "*", "int", "{", "for", ";", "pos", "<", "len", "(", "key", ")", ";", "pos", "++", "{", "if", "value", ":=", "da", ".", "Array", "[", "from", "]", ".", "Value", ";", "value", ">=", "0", "&&", "value", "!=", "ValueLimit", "{", "to", ":=", "da", ".", "follow", "(", "from", ",", "0", ")", "\n", "da", ".", "Array", "[", "to", "]", ".", "Value", "=", "value", "\n", "}", "\n", "from", "=", "da", ".", "follow", "(", "from", ",", "key", "[", "<mask>", "]", ")", "\n", "}", "\n", "to", ":=", "from", "\n", "if", "da", ".", "Array", "[", "from", "]", ".", "Value", "<", "0", "{", "to", "=", "da", ".", "follow", "(", "from", ",", "0", ")", "\n", "}", "\n", "return", "&", "da", ".", "Array", "[", "to", "]", ".", "Value", "\n", "}" ]
18,230
all-18231
[ "CreateCluster", "creates", "a", "cluster", "from", "a", "given", "name", "and", "returns", "its", "arn" ]
[ "func", "(", "client", "*", "APIECSClient", ")", "CreateCluster", "(", "clusterName", "string", ")", "(", "string", ",", "error", ")", "{", "resp", ",", "err", ":=", "<mask>", ".", "standardClient", ".", "CreateCluster", "(", "&", "ecs", ".", "CreateClusterInput", "{", "ClusterName", ":", "&", "clusterName", "}", ")", "\n", "if", "err", "!=", "nil", "{", "seelog", ".", "Criticalf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "seelog", ".", "Infof", "(", "\"", "\"", ",", "clusterName", ")", "\n", "return", "*", "resp", ".", "Cluster", ".", "ClusterName", ",", "nil", "\n", "}" ]
18,231
all-18232
[ "UTCTime" ]
[ "func", "parseUTCTime", "(", "bytes", "[", "]", "byte", ")", "(", "ret", "time", ".", "Time", ",", "err", "error", ")", "{", "s", ":=", "string", "(", "bytes", ")", "\n\n", "formatStr", ":=", "\"", "\"", "\n", "ret", ",", "err", "=", "time", ".", "Parse", "(", "formatStr", ",", "s", ")", "\n", "if", "err", "!=", "nil", "{", "formatStr", "=", "\"", "\"", "\n", "<mask>", ",", "err", "=", "time", ".", "Parse", "(", "formatStr", ",", "s", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "if", "serialized", ":=", "ret", ".", "Format", "(", "formatStr", ")", ";", "serialized", "!=", "s", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ",", "serialized", ")", "\n", "return", "\n", "}", "\n\n", "if", "ret", ".", "Year", "(", ")", ">=", "2050", "{", "// UTCTime only encodes times prior to 2050. See https://tools.ietf.org/html/rfc5280#section-4.1.2.5.1", "ret", "=", "ret", ".", "AddDate", "(", "-", "100", ",", "0", ",", "0", ")", "\n", "}", "\n\n", "return", "\n", "}" ]
18,232
all-18233
[ "expandHostNetworkPolicy", "reads", "certain", "ResourceData", "keys", "and", "returns", "a", "HostNetworkPolicy", "." ]
[ "func", "expandHostNetworkPolicy", "(", "d", "*", "schema", ".", "ResourceData", ")", "*", "<mask>", ".", "HostNetworkPolicy", "{", "obj", ":=", "&", "types", ".", "HostNetworkPolicy", "{", "Security", ":", "expandHostNetworkSecurityPolicy", "(", "d", ")", ",", "NicTeaming", ":", "expandHostNicTeamingPolicy", "(", "d", ")", ",", "ShapingPolicy", ":", "expandHostNetworkTrafficShapingPolicy", "(", "d", ")", ",", "}", "\n", "return", "obj", "\n", "}" ]
18,233
all-18234
[ "Get", "returns", "the", "value", "associated", "with", "the", "given", "key", ".", "It", "is", "equivalent", "to", "id", "err1", "=", "Jump", "(", "key", ")", "value", "err2", "=", "Value", "(", "id", ")", "Thus", "it", "may", "return", "ErrNoPath", "or", "ErrNoValue" ]
[ "func", "(", "da", "*", "Cedar", ")", "Get", "(", "key", "[", "]", "byte", ")", "(", "value", "int", ",", "err", "error", ")", "{", "to", ",", "err", ":=", "da", ".", "Jump", "(", "key", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "return", "da", ".", "<mask>", "(", "to", ")", "\n", "}" ]
18,234
all-18235
[ "MarshalEasyJSON", "writes", "the", "DateTime", "to", "a", "easyjson", ".", "Writer" ]
[ "func", "(", "t", "DateTime", ")", "MarshalEasyJSON", "(", "w", "*", "jwriter", ".", "<mask>", ")", "{", "w", ".", "String", "(", "time", ".", "Time", "(", "t", ")", ".", "Format", "(", "MarshalFormat", ")", ")", "\n", "}" ]
18,235
all-18236
[ "SetEvaluationDuration", "updates", "evaluationDuration", "to", "the", "duration", "it", "took", "to", "evaluate", "the", "rule", "on", "its", "last", "evaluation", "." ]
[ "func", "(", "r", "*", "AlertingRule", ")", "SetEvaluationDuration", "(", "dur", "<mask>", ".", "Duration", ")", "{", "r", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "mtx", ".", "Unlock", "(", ")", "\n", "r", ".", "evaluationDuration", "=", "dur", "\n", "}" ]
18,236
all-18237
[ "Snapshot", "returns", "the", "current", "value", "." ]
[ "func", "(", "g", "*", "Gauge", ")", "Snapshot", "(", ")", "float64", "{", "u", ":=", "atomic", ".", "LoadUint64", "(", "&", "g", ".", "<mask>", ")", "\n", "return", "math", ".", "Float64frombits", "(", "u", ")", "\n", "}" ]
18,237
all-18238
[ "ProjectDelete", "deletes", "the", "project", "matching", "the", "given", "key", "parameters", "." ]
[ "func", "(", "c", "*", "ClusterTx", ")", "ProjectDelete", "(", "name", "string", ")", "error", "{", "stmt", ":=", "c", ".", "stmt", "(", "projectDelete", ")", "\n", "result", ",", "err", ":=", "stmt", ".", "Exec", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "n", ",", "err", ":=", "<mask>", ".", "RowsAffected", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "n", "!=", "1", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "n", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
18,238
all-18239
[ "DeleteLease", "--", "allows", "a", "client", "user", "to", "make", "a", "DELETE", "lease", "call", "to", "dispenser" ]
[ "func", "(", "s", "*", "PDClient", ")", "DeleteLease", "(", "leaseID", ",", "inventoryID", ",", "skuID", "string", ",", "metadata", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "res", "*", "http", ".", "Response", ",", "err", "error", ")", "{", "var", "body", "io", ".", "Reader", "\n", "if", "body", ",", "err", "=", "s", ".", "getRequestBody", "(", "leaseID", ",", "inventoryID", ",", "skuID", ",", "\"", "\"", ",", "0", ",", "metadata", ")", ";", "err", "==", "nil", "{", "req", ",", "_", ":=", "s", ".", "createRequest", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "URL", ")", ",", "body", ")", "\n\n", "if", "<mask>", ",", "err", "=", "s", ".", "client", ".", "Do", "(", "req", ")", ";", "err", "!=", "nil", "||", "res", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "lo", ".", "G", ".", "Error", "(", "\"", "\"", ",", "err", ")", "\n", "lo", ".", "G", ".", "Error", "(", "\"", "\"", ",", "res", ")", "\n", "err", "=", "ErrInvalidDispenserResponse", "\n", "}", "\n\n", "}", "else", "{", "lo", ".", "G", ".", "Error", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "return", "\n", "}" ]
18,239
all-18240
[ "Set", "records", "the", "value", "passed" ]
[ "func", "(", "r", "*", "stringSlice", ")", "Set", "(", "<mask>", "string", ")", "error", "{", "r", ".", "data", "=", "append", "(", "r", ".", "data", ",", "value", ")", "\n", "return", "nil", "\n", "}" ]
18,240
all-18241
[ "Name", "returns", "the", "associated", "filename", "if", "any" ]
[ "func", "(", "d", "*", "Data", ")", "<mask>", "(", ")", "string", "{", "return", "C", ".", "GoString", "(", "C", ".", "gpgme_data_get_file_name", "(", "d", ".", "dh", ")", ")", "\n", "}" ]
18,241
all-18242
[ "Snapshot", "implements", "the", "Storage", "interface", "." ]
[ "func", "(", "ms", "*", "MemoryStorage", ")", "Snapshot", "(", ")", "(", "pb", ".", "Snapshot", ",", "error", ")", "{", "ms", ".", "Lock", "(", ")", "\n", "defer", "<mask>", ".", "Unlock", "(", ")", "\n", "return", "ms", ".", "snapshot", ",", "nil", "\n", "}" ]
18,242
all-18243
[ "Check", "Router", "It", "verifies", "your", "router", "configuration", "and", "validates", "related", "confs", "." ]
[ "func", "checkRouter", "(", ")", "error", "{", "defaultRouter", ",", "_", ":=", "config", ".", "GetString", "(", "\"", "\"", ")", "\n", "if", "defaultRouter", "==", "\"", "\"", "{", "return", "<mask>", ".", "Errorf", "(", "`You must configure a default router in \"docker:router\".`", ")", "\n", "}", "\n", "isHipacheOld", ":=", "false", "\n", "if", "defaultRouter", "==", "\"", "\"", "{", "hipacheOld", ",", "_", ":=", "config", ".", "Get", "(", "\"", "\"", ")", "\n", "isHipacheOld", "=", "hipacheOld", "!=", "nil", "\n", "}", "\n", "routerConf", ",", "_", ":=", "config", ".", "Get", "(", "\"", "\"", "+", "defaultRouter", ")", "\n", "if", "isHipacheOld", "{", "return", "config", ".", "NewWarning", "(", "`Setting \"hipache:*\" config entries is deprecated. You should configure your router with \"routers:*\". See http://docs.tsuru.io/en/latest/reference/config.html#routers for more details.`", ")", "\n", "}", "\n", "if", "routerConf", "==", "nil", "{", "return", "errors", ".", "Errorf", "(", "`You must configure your default router %q in \"routers:%s\".`", ",", "defaultRouter", ",", "defaultRouter", ")", "\n", "}", "\n", "routerType", ",", "_", ":=", "config", ".", "Get", "(", "\"", "\"", "+", "defaultRouter", "+", "\"", "\"", ")", "\n", "if", "routerType", "==", "nil", "{", "return", "errors", ".", "Errorf", "(", "`You must configure your default router type in \"routers:%s:type\".`", ",", "defaultRouter", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
18,243
all-18244
[ "PickID", "returns", "a", "call", "option", "which", "sets", "the", "ID", "on", "a", "request", ".", "Care", "must", "be", "taken", "to", "ensure", "there", "are", "no", "conflicts", "with", "any", "previously", "picked", "ID", "nor", "with", "the", "default", "sequence", "ID", "." ]
[ "func", "PickID", "(", "id", "ID", ")", "CallOption", "{", "return", "callOptionFunc", "(", "func", "(", "r", "*", "<mask>", ")", "error", "{", "r", ".", "ID", "=", "id", "\n", "return", "nil", "\n", "}", ")", "\n", "}" ]
18,244
all-18245
[ "Do", "executes", "Debugger", ".", "setAsyncCallStackDepth", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "SetAsyncCallStackDepthParams", ")", "Do", "(", "ctx", "context", ".", "<mask>", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetAsyncCallStackDepth", ",", "p", ",", "nil", ")", "\n", "}" ]
18,245
all-18246
[ "Ungrab", "()", "is", "a", "wrapper", "around", "gdk_device_ungrab", "()", "." ]
[ "func", "(", "v", "*", "Device", ")", "Ungrab", "(", "time", "uint32", ")", "{", "C", ".", "gdk_device_ungrab", "(", "v", ".", "native", "(", ")", ",", "C", ".", "guint32", "(", "<mask>", ")", ")", "\n", "}" ]
18,246
all-18247
[ "UpdateMountPoints", "updates", "the", "mount", "points", "of", "volumes", "that", "were", "created", "without", "specifying", "a", "host", "path", ".", "This", "is", "used", "as", "part", "of", "the", "empty", "host", "volume", "feature", "." ]
[ "func", "(", "task", "*", "Task", ")", "UpdateMountPoints", "(", "cont", "*", "apicontainer", ".", "Container", ",", "vols", "[", "]", "types", ".", "MountPoint", ")", "{", "for", "_", ",", "mountPoint", ":=", "range", "cont", ".", "MountPoints", "{", "containerPath", ":=", "getCanonicalPath", "(", "mountPoint", ".", "ContainerPath", ")", "\n", "for", "_", ",", "vol", ":=", "range", "vols", "{", "if", "strings", ".", "Compare", "(", "vol", ".", "Destination", ",", "containerPath", ")", "==", "0", "||", "// /path/ -> /path or \\path\\ -> \\path", "strings", ".", "Compare", "(", "vol", ".", "Destination", ",", "strings", ".", "TrimRight", "(", "containerPath", ",", "string", "(", "filepath", ".", "Separator", ")", ")", ")", "==", "0", "{", "if", "hostVolume", ",", "exists", ":=", "<mask>", ".", "HostVolumeByName", "(", "mountPoint", ".", "SourceVolume", ")", ";", "exists", "{", "if", "empty", ",", "ok", ":=", "hostVolume", ".", "(", "*", "taskresourcevolume", ".", "LocalDockerVolume", ")", ";", "ok", "{", "empty", ".", "HostPath", "=", "vol", ".", "Source", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
18,247
all-18248
[ "New", "creates", "a", "new", "Xslate", "instance", ".", "If", "called", "without", "any", "arguments", "creates", "a", "new", "Xslate", "instance", "using", "all", "default", "settings", ".", "To", "pass", "parameters", "use", "xslate", ".", "Vars", "Possible", "Options", ":", "*", "ConfigureLoader", ":", "Callback", "to", "setup", "the", "Loader", ".", "See", "DefaultLoader", "*", "ConfigureParser", ":", "Callback", "to", "setup", "the", "Parser", ".", "See", "DefaultParser", "*", "ConfigureCompiler", ":", "Callback", "to", "setup", "the", "Compiler", ".", "See", "DefaultCompiler", "*", "ConfigureVM", ":", "Callback", "to", "setup", "the", "Virtual", "Machine", ".", "See", "DefaultVM", "*", "Parser", ":", "Arbitrary", "arguments", "passed", "to", "ConfigureParser", "function", "*", "Loader", ":", "Arbitrary", "arguments", "passed", "to", "ConfigureLoader", "function", "*", "Compiler", ":", "Arbitrary", "arguments", "passed", "to", "ConfigureCompiler", "function", "*", "VM", ":", "Arbitrary", "arguments", "passed", "to", "ConfigureVM", "function" ]
[ "func", "New", "(", "args", "...", "Args", ")", "(", "*", "Xslate", ",", "error", ")", "{", "tx", ":=", "&", "Xslate", "{", "}", "\n\n", "// We jump through hoops because there are A LOT of configuration options", "// but most of them only need to use the default values", "if", "len", "(", "args", ")", "<=", "0", "{", "args", "=", "[", "]", "Args", "{", "Args", "{", "}", "}", "\n", "}", "\n", "err", ":=", "tx", ".", "Configure", "(", "args", "[", "0", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "<mask>", ",", "nil", "\n", "}" ]
18,248
all-18249
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "PrintToPDFParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage23", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
18,249
all-18250
[ "Run", "enables", "mainthread", "package", "functionality", ".", "To", "use", "mainthread", "package", "put", "your", "main", "function", "code", "into", "the", "run", "function", "(", "the", "argument", "to", "Run", ")", "and", "simply", "call", "Run", "from", "the", "real", "main", "function", ".", "Run", "returns", "when", "run", "(", "argument", ")", "function", "finishes", "." ]
[ "func", "Run", "(", "run", "func", "(", ")", ")", "{", "callQueue", "=", "make", "(", "chan", "func", "(", ")", ",", "CallQueueCap", ")", "\n\n", "<mask>", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "go", "func", "(", ")", "{", "run", "(", ")", "\n", "done", "<-", "struct", "{", "}", "{", "}", "\n", "}", "(", ")", "\n\n", "for", "{", "select", "{", "case", "f", ":=", "<-", "callQueue", ":", "f", "(", ")", "\n", "case", "<-", "done", ":", "return", "\n", "}", "\n", "}", "\n", "}" ]
18,250
all-18251
[ "Do", "executes", "Fetch", ".", "failRequest", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "FailRequestParams", ")", "Do", "(", "ctx", "context", ".", "<mask>", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandFailRequest", ",", "p", ",", "nil", ")", "\n", "}" ]
18,251
all-18252
[ "FetchNext", "fetches", "next", "chunk", "in", "query", "result", "set", "." ]
[ "func", "(", "s", "*", "Session", ")", "FetchNext", "(", "id", "uint64", ",", "resultFieldSet", "*", "ResultFieldSet", ",", "fieldValues", "*", "FieldValues", ")", "(", "PartAttributes", ",", "error", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "s", ".", "resultsetID", ".", "id", "=", "&", "id", "\n", "if", "err", ":=", "s", ".", "writeRequest", "(", "mtFetchNext", ",", "false", ",", "s", ".", "resultsetID", ",", "fetchsize", "(", "s", ".", "prm", ".", "FetchSize", "(", ")", ")", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "f", ":=", "func", "(", "p", "replyPart", ")", "{", "switch", "p", ":=", "p", ".", "(", "<mask>", ")", "{", "case", "*", "resultset", ":", "p", ".", "s", "=", "s", "\n", "p", ".", "resultFieldSet", "=", "resultFieldSet", "\n", "p", ".", "fieldValues", "=", "fieldValues", "\n", "}", "\n", "}", "\n\n", "if", "err", ":=", "s", ".", "readReply", "(", "f", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "s", ".", "ph", ".", "partAttributes", ",", "nil", "\n", "}" ]
18,252
all-18253
[ "Makes", "a", "node", "ID", "secure", "in", "-", "place", ".", "The", "ID", "is", "20", "raw", "bytes", ".", "http", ":", "//", "www", ".", "libtorrent", ".", "org", "/", "dht_sec", ".", "html" ]
[ "func", "SecureNodeId", "(", "id", "*", "[", "20", "]", "byte", ",", "ip", "<mask>", ".", "IP", ")", "{", "crc", ":=", "crcIP", "(", "ip", ",", "id", "[", "19", "]", ")", "\n", "id", "[", "0", "]", "=", "byte", "(", "crc", ">>", "24", "&", "0xff", ")", "\n", "id", "[", "1", "]", "=", "byte", "(", "crc", ">>", "16", "&", "0xff", ")", "\n", "id", "[", "2", "]", "=", "byte", "(", "crc", ">>", "8", "&", "0xf8", ")", "|", "id", "[", "2", "]", "&", "7", "\n", "}" ]
18,253
all-18254
[ "VerifySuspendedChannelsAndTryToTerminate", "scans", "all", "suspended", "channels", "and", "terminates", "those", "of", "them", "who", "are", "staying", "suspended", "too", "long", "." ]
[ "func", "(", "m", "*", "Monitor", ")", "VerifySuspendedChannelsAndTryToTerminate", "(", ")", "error", "{", "<mask>", ":=", "`\n SELECT channels.id::text\n\t\tFROM channels\n LEFT JOIN offerings offer\n ON channels.offering = offer.id\n\n INNER JOIN accounts acc\n ON channels.agent = acc.eth_addr\n WHERE channels.service_status = 'suspended'\n AND channels.channel_status NOT IN ('pending')\n AND acc.in_use\n AND channels.service_changed_time + (offer.max_suspended_time * INTERVAL '1 SECOND') < now();`", "\n\n", "return", "m", ".", "processEachChannel", "(", "query", ",", "m", ".", "terminateService", ")", "\n", "}" ]
18,254
all-18255
[ "See", "https", ":", "//", "github", ".", "com", "/", "gorilla", "/", "websocket", "/", "blob", "/", "87f6f6a22ebfbc3f89b9ccdc7fddd1b914c095f9", "/", "conn", ".", "go#L650" ]
[ "func", "permissibleCloseCode", "(", "err", "<mask>", ")", "bool", "{", "return", "websocket", ".", "IsCloseError", "(", "err", ",", "websocket", ".", "CloseNormalClosure", ",", "// websocket error code 1000", "websocket", ".", "CloseAbnormalClosure", ",", "// websocket error code 1006", "websocket", ".", "CloseGoingAway", ",", "// websocket error code 1001", "websocket", ".", "CloseInternalServerErr", ")", "// websocket error code 1011", "\n", "}" ]
18,255
all-18256
[ "NewLogFormatter", "creates", "a", "new", "log", ".", "Formatter", "customised", "for", "writer" ]
[ "func", "NewLogFormatter", "(", "out", "io", ".", "Writer", ")", "log", ".", "Formatter", "{", "var", "ret", "=", "logFormatter", "{", "}", "\n", "if", "f", ",", "ok", ":=", "<mask>", ".", "(", "*", "os", ".", "File", ")", ";", "ok", "{", "ret", ".", "colorise", "=", "terminal", ".", "IsTerminal", "(", "int", "(", "f", ".", "Fd", "(", ")", ")", ")", "\n", "ret", ".", "escapes", "=", "terminal", ".", "NewTerminal", "(", "f", ",", "\"", "\"", ")", ".", "Escape", "\n", "}", "\n", "return", "&", "ret", "\n", "}" ]
18,256
all-18257
[ "printBase", "is", "common", "print", "code", "for", "types", "that", "are", "printed", "with", "a", "simple", "suffix", "." ]
[ "func", "printBase", "(", "ps", "*", "printState", ",", "qual", ",", "base", "AST", ")", "{", "ps", ".", "inner", "=", "append", "(", "ps", ".", "inner", ",", "qual", ")", "\n", "ps", ".", "print", "(", "base", ")", "\n", "if", "len", "(", "ps", ".", "inner", ")", ">", "0", "{", "qual", ".", "(", "innerPrinter", ")", ".", "printInner", "(", "<mask>", ")", "\n", "ps", ".", "inner", "=", "ps", ".", "inner", "[", ":", "len", "(", "ps", ".", "inner", ")", "-", "1", "]", "\n", "}", "\n", "}" ]
18,257
all-18258
[ "submitChanges", "takes", "a", "zone", "and", "a", "collection", "of", "Changes", "and", "sends", "them", "as", "a", "single", "transaction", "." ]
[ "func", "(", "p", "*", "AWSProvider", ")", "submitChanges", "(", "changes", "[", "]", "*", "route53", ".", "Change", ",", "zones", "map", "[", "string", "]", "*", "route53", ".", "HostedZone", ")", "error", "{", "// return early if there is nothing to change", "if", "len", "(", "changes", ")", "==", "0", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n\n", "// separate into per-zone change sets to be passed to the API.", "changesByZone", ":=", "changesByZone", "(", "zones", ",", "changes", ")", "\n", "if", "len", "(", "changesByZone", ")", "==", "0", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "failedZones", "[", "]", "string", "\n", "for", "z", ",", "cs", ":=", "range", "changesByZone", "{", "var", "failedUpdate", "bool", "\n\n", "batchCs", ":=", "batchChangeSet", "(", "cs", ",", "p", ".", "batchChangeSize", ")", "\n\n", "for", "i", ",", "b", ":=", "range", "batchCs", "{", "for", "_", ",", "c", ":=", "range", "b", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "*", "c", ".", "Action", ",", "*", "c", ".", "ResourceRecordSet", ".", "Name", ",", "*", "c", ".", "ResourceRecordSet", ".", "Type", ")", "\n", "}", "\n\n", "if", "!", "p", ".", "dryRun", "{", "params", ":=", "&", "route53", ".", "ChangeResourceRecordSetsInput", "{", "HostedZoneId", ":", "aws", ".", "<mask>", "(", "z", ")", ",", "ChangeBatch", ":", "&", "route53", ".", "ChangeBatch", "{", "Changes", ":", "b", ",", "}", ",", "}", "\n\n", "if", "_", ",", "err", ":=", "p", ".", "client", ".", "ChangeResourceRecordSets", "(", "params", ")", ";", "err", "!=", "nil", "{", "log", ".", "Error", "(", "err", ")", "//TODO(ideahitme): consider changing the interface in cases when this error might be a concern for other components", "\n", "failedUpdate", "=", "true", "\n", "}", "else", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "len", "(", "b", ")", ",", "aws", ".", "StringValue", "(", "zones", "[", "z", "]", ".", "Name", ")", ")", "\n", "}", "\n\n", "if", "i", "!=", "len", "(", "batchCs", ")", "-", "1", "{", "time", ".", "Sleep", "(", "p", ".", "batchChangeInterval", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "if", "failedUpdate", "{", "failedZones", "=", "append", "(", "failedZones", ",", "z", ")", "\n", "}", "\n", "}", "\n\n", "if", "len", "(", "failedZones", ")", ">", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "failedZones", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
18,258
all-18259
[ "GetBlob", "returns", "a", "stream", "for", "the", "specified", "blob", "and", "the", "blob’s", "size", "(", "or", "-", "1", "if", "unknown", ")", ".", "The", "Digest", "field", "in", "BlobInfo", "is", "guaranteed", "to", "be", "provided", "Size", "may", "be", "-", "1", "and", "MediaType", "may", "be", "optionally", "provided", ".", "May", "update", "BlobInfoCache", "preferably", "after", "it", "knows", "for", "certain", "that", "a", "blob", "truly", "exists", "at", "a", "specific", "location", "." ]
[ "func", "(", "is", "*", "tarballImageSource", ")", "GetBlob", "(", "ctx", "context", ".", "Context", ",", "blobinfo", "types", ".", "BlobInfo", ",", "cache", "types", ".", "BlobInfoCache", ")", "(", "io", ".", "ReadCloser", ",", "int64", ",", "error", ")", "{", "// We should only be asked about things in the manifest. Maybe the configuration blob.", "if", "blobinfo", ".", "Digest", "==", "is", ".", "configID", "{", "return", "ioutil", ".", "NopCloser", "(", "<mask>", ".", "NewBuffer", "(", "is", ".", "config", ")", ")", ",", "is", ".", "configSize", ",", "nil", "\n", "}", "\n", "// Maybe one of the layer blobs.", "for", "i", ":=", "range", "is", ".", "blobIDs", "{", "if", "blobinfo", ".", "Digest", "==", "is", ".", "blobIDs", "[", "i", "]", "{", "// We want to read that layer: open the file or memory block and hand it back.", "if", "is", ".", "filenames", "[", "i", "]", "==", "\"", "\"", "{", "return", "ioutil", ".", "NopCloser", "(", "bytes", ".", "NewBuffer", "(", "is", ".", "reference", ".", "stdin", ")", ")", ",", "int64", "(", "len", "(", "is", ".", "reference", ".", "stdin", ")", ")", ",", "nil", "\n", "}", "\n", "reader", ",", "err", ":=", "os", ".", "Open", "(", "is", ".", "filenames", "[", "i", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "-", "1", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "is", ".", "filenames", "[", "i", "]", ",", "err", ")", "\n", "}", "\n", "return", "reader", ",", "is", ".", "blobSizes", "[", "i", "]", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "-", "1", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "blobinfo", ".", "Digest", ".", "String", "(", ")", ")", "\n", "}" ]
18,259
all-18260
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "RemoveNodeParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoDom15", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
18,260
all-18261
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "CloseTargetReturns", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoTarget26", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
18,261
all-18262
[ "Create", "does", "nothing", "on", "a", "dry", "-", "run", "client" ]
[ "func", "(", "c", "*", "dryRunProwJobClient", ")", "Create", "(", "*", "prowapi", ".", "ProwJob", ")", "(", "*", "prowapi", ".", "ProwJob", ",", "<mask>", ")", "{", "return", "nil", ",", "nil", "\n", "}" ]
18,262
all-18263
[ "HasResource", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "d", "*", "DashboardLite", ")", "HasResource", "(", ")", "bool", "{", "if", "d", "!=", "nil", "&&", "d", ".", "Resource", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
18,263
all-18264
[ "Mutate", "applies", "the", "provided", "mutators", "to", "this", "builder", "s", "payment", "or", "operation", "." ]
[ "func", "(", "b", "*", "SetOptionsBuilder", ")", "Mutate", "(", "muts", "...", "interface", "{", "}", ")", "{", "for", "_", ",", "m", ":=", "<mask>", "muts", "{", "var", "err", "error", "\n", "switch", "mut", ":=", "m", ".", "(", "type", ")", "{", "case", "SetOptionsMutator", ":", "err", "=", "mut", ".", "MutateSetOptions", "(", "&", "b", ".", "SO", ")", "\n", "case", "OperationMutator", ":", "err", "=", "mut", ".", "MutateOperation", "(", "&", "b", ".", "O", ")", "\n", "default", ":", "err", "=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "err", "!=", "nil", "{", "b", ".", "Err", "=", "err", "\n", "return", "\n", "}", "\n", "}", "\n", "}" ]
18,264
all-18265
[ "AsErrorList", "checks", "if", "err", "is", "already", "an", "ErrorList", "and", "returns", "it", "if", "this", "is", "the", "case", ".", "Else", "an", "ErrorList", "with", "err", "as", "element", "is", "created", ".", "Useful", "if", "a", "function", "potentially", "returns", "an", "ErrorList", "as", "error", "and", "you", "want", "to", "avoid", "creating", "nested", "ErrorLists", "." ]
[ "func", "AsErrorList", "(", "err", "error", ")", "ErrorList", "{", "if", "list", ",", "ok", ":=", "err", ".", "(", "ErrorList", ")", ";", "<mask>", "{", "return", "list", "\n", "}", "\n", "return", "ErrorList", "{", "err", "}", "\n", "}" ]
18,265
all-18266
[ "Create", "a", "Typed", "helper", "from", "the", "given", "JSON", "bytes" ]
[ "func", "Json", "(", "data", "[", "]", "byte", ")", "(", "Typed", ",", "error", ")", "{", "<mask>", "m", "map", "[", "string", "]", "interface", "{", "}", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "m", ")", "\n", "return", "Typed", "(", "m", ")", ",", "err", "\n", "}" ]
18,266
all-18267
[ "Stop", "stops", "the", "timer", "and", "returns", "whether", "the", "timer", "was", "stopped", ".", "It", "returns", "the", "same", "behaviour", "as", "https", ":", "//", "golang", ".", "org", "/", "pkg", "/", "time", "/", "#Timer", ".", "Stop", ".", "This", "method", "is", "safe", "for", "concurrent", "use", "and", "is", "typically", "used", "to", "check", "whether", "a", "timer", "was", "stopped", "possibly", "with", "other", "goroutines", "or", "when", "the", "timer", "fires", "." ]
[ "func", "(", "rt", "*", "relayTimer", ")", "Stop", "(", ")", "bool", "{", "rt", ".", "verifyNotReleased", "(", ")", "\n", "stopped", ":=", "rt", ".", "<mask>", ".", "Stop", "(", ")", "\n", "if", "stopped", "{", "rt", ".", "markTimerInactive", "(", ")", "\n", "}", "\n", "return", "stopped", "\n", "}" ]
18,267
all-18268
[ "Zones", "returns", "the", "list", "of", "hosted", "zones", "." ]
[ "func", "(", "p", "*", "DigitalOceanProvider", ")", "Zones", "(", ")", "(", "[", "]", "godo", ".", "Domain", ",", "error", ")", "{", "<mask>", ":=", "[", "]", "godo", ".", "Domain", "{", "}", "\n\n", "zones", ",", "err", ":=", "p", ".", "fetchZones", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "zone", ":=", "range", "zones", "{", "if", "p", ".", "domainFilter", ".", "Match", "(", "zone", ".", "Name", ")", "{", "result", "=", "append", "(", "result", ",", "zone", ")", "\n", "}", "\n", "}", "\n\n", "return", "result", ",", "nil", "\n", "}" ]
18,268
all-18269
[ "schemaHostNasVolumeSpec", "returns", "schema", "items", "for", "resources", "that", "need", "to", "work", "with", "a", "HostNasVolumeSpec", "." ]
[ "func", "schemaHostNasVolumeSpec", "(", ")", "map", "[", "string", "]", "*", "schema", ".", "Schema", "{", "return", "map", "[", "string", "]", "*", "schema", ".", "Schema", "{", "// HostNasVolumeSpec", "// Skipped attributes: localPath (this is the name attribute)", "// All CIFS attributes (we currently do not support CIFS as it's not", "// available in the vSphere client and there is not much data about how to", "// get it working)", "\"", "\"", ":", "{", "Type", ":", "schema", ".", "TypeString", ",", "Default", ":", "hostNasVolumeAccessModeReadWrite", ",", "Description", ":", "\"", "\"", ",", "ForceNew", ":", "true", ",", "Optional", ":", "true", ",", "ValidateFunc", ":", "validation", ".", "StringInSlice", "(", "[", "]", "string", "{", "hostNasVolumeAccessModeReadOnly", ",", "hostNasVolumeAccessModeReadWrite", ",", "}", ",", "false", ",", ")", ",", "}", ",", "\"", "\"", ":", "{", "Type", ":", "schema", ".", "TypeList", ",", "Description", ":", "\"", "\"", ",", "Elem", ":", "&", "schema", ".", "Schema", "{", "Type", ":", "schema", ".", "TypeString", "}", ",", "ForceNew", ":", "true", ",", "MinItems", ":", "1", ",", "Required", ":", "true", ",", "}", ",", "\"", "\"", ":", "{", "Type", ":", "schema", ".", "TypeString", ",", "Description", ":", "\"", "\"", ",", "ForceNew", ":", "true", ",", "Required", ":", "true", ",", "}", ",", "\"", "\"", ":", "{", "Type", ":", "schema", ".", "TypeString", ",", "Description", ":", "\"", "\"", ",", "ForceNew", ":", "true", ",", "Optional", ":", "true", ",", "ValidateFunc", ":", "validation", ".", "StringInSlice", "(", "[", "]", "string", "{", "hostNasVolumeSecurityTypeAuthSys", ",", "hostNasVolumeSecurityTypeSecKrb5", ",", "hostNasVolumeSecurityTypeSecKrb5i", ",", "}", ",", "false", ",", ")", ",", "}", ",", "\"", "\"", ":", "{", "Type", ":", "schema", ".", "TypeString", ",", "Default", ":", "\"", "\"", ",", "Description", ":", "\"", "\"", ",", "ForceNew", ":", "true", ",", "Optional", ":", "true", ",", "ValidateFunc", ":", "validation", ".", "StringInSlice", "(", "[", "]", "string", "{", "string", "(", "types", ".", "HostFileSystemVolumeFileSystemTypeNFS", ")", ",", "string", "(", "<mask>", ".", "HostFileSystemVolumeFileSystemTypeNFS41", ")", ",", "}", ",", "false", ",", ")", ",", "}", ",", "\"", "\"", ":", "{", "Type", ":", "schema", ".", "TypeString", ",", "Description", ":", "\"", "\"", ",", "Computed", ":", "true", ",", "}", ",", "}", "\n", "}" ]
18,269
all-18270
[ "NewBot", "creates", "a", "new", "instance", "of", "Bot" ]
[ "func", "NewBot", "(", "host", ",", "nick", "string", ",", "options", "...", "func", "(", "*", "Bot", ")", ")", "(", "*", "Bot", ",", "error", ")", "{", "// Defaults are set here", "bot", ":=", "Bot", "{", "Incoming", ":", "make", "(", "chan", "*", "Message", ",", "16", ")", ",", "outgoing", ":", "make", "(", "chan", "string", ",", "16", ")", ",", "started", ":", "time", ".", "Now", "(", ")", ",", "unixastr", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "<mask>", ",", "nick", ")", ",", "Host", ":", "host", ",", "Nick", ":", "nick", ",", "ThrottleDelay", ":", "200", "*", "time", ".", "Millisecond", ",", "PingTimeout", ":", "300", "*", "time", ".", "Second", ",", "HijackSession", ":", "false", ",", "SSL", ":", "false", ",", "SASL", ":", "false", ",", "Channels", ":", "[", "]", "string", "{", "\"", "\"", "}", ",", "Password", ":", "\"", "\"", ",", "}", "\n", "for", "_", ",", "option", ":=", "range", "options", "{", "option", "(", "&", "bot", ")", "\n", "}", "\n", "// Discard logs by default", "bot", ".", "Logger", "=", "log", ".", "New", "(", "\"", "\"", ",", "logext", ".", "RandId", "(", "8", ")", ",", "\"", "\"", ",", "bot", ".", "Host", ",", "\"", "\"", ",", "log", ".", "Lazy", "{", "bot", ".", "getNick", "}", ")", "\n\n", "bot", ".", "Logger", ".", "SetHandler", "(", "log", ".", "DiscardHandler", "(", ")", ")", "\n", "bot", ".", "AddTrigger", "(", "pingPong", ")", "\n", "bot", ".", "AddTrigger", "(", "joinChannels", ")", "\n", "return", "&", "bot", ",", "nil", "\n", "}" ]
18,270
all-18271
[ "GetSpaceDefaults", "returns", "the", "default", "space", "configuration", "if", "one", "was", "provided", ".", "If", "no", "space", "defaults", "were", "configured", "a", "nil", "config", "and", "a", "nil", "error", "are", "returned", "." ]
[ "func", "(", "m", "*", "yamlManager", ")", "GetSpaceDefaults", "(", ")", "(", "*", "SpaceConfig", ",", "error", ")", "{", "fp", ":=", "filepath", ".", "Join", "(", "m", ".", "ConfigDir", ",", "\"", "\"", ")", "\n\n", "if", "!", "FileOrDirectoryExists", "(", "fp", ")", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "result", ":=", "SpaceConfig", "{", "}", "\n", "err", ":=", "LoadFile", "(", "fp", ",", "&", "result", ")", "\n", "return", "&", "<mask>", ",", "err", "\n", "}" ]
18,271
all-18272
[ "RequestVote", "sends", "the", "appropriate", "RPC", "to", "the", "target", "node", "." ]
[ "func", "(", "t", "*", "transport", ")", "RequestVote", "(", "<mask>", "raft", ".", "ServerID", ",", "target", "raft", ".", "ServerAddress", ",", "args", "*", "raft", ".", "RequestVoteRequest", ",", "resp", "*", "raft", ".", "RequestVoteResponse", ")", "error", "{", "return", "t", ".", "sendRPC", "(", "string", "(", "target", ")", ",", "args", ",", "resp", ")", "\n", "}" ]
18,272
all-18273
[ "handleContainerChange", "updates", "a", "container", "s", "known", "status", ".", "If", "the", "message", "contains", "any", "interesting", "information", "(", "like", "exit", "codes", "or", "ports", ")", "they", "are", "propagated", "." ]
[ "func", "(", "mtask", "*", "managedTask", ")", "handleContainerChange", "(", "containerChange", "dockerContainerChange", ")", "{", "// locate the container", "container", ":=", "containerChange", ".", "<mask>", "\n", "found", ":=", "mtask", ".", "isContainerFound", "(", "container", ")", "\n", "if", "!", "found", "{", "seelog", ".", "Criticalf", "(", "\"", "\"", ",", "mtask", ".", "Arn", ",", "container", ".", "Name", ")", "\n", "return", "\n", "}", "\n\n", "event", ":=", "containerChange", ".", "event", "\n", "seelog", ".", "Debugf", "(", "\"", "\"", ",", "mtask", ".", "Arn", ",", "event", ",", "container", ".", "Name", ")", "\n\n", "// If this is a backwards transition stopped->running, the first time set it", "// to be known running so it will be stopped. Subsequently ignore these backward transitions", "containerKnownStatus", ":=", "container", ".", "GetKnownStatus", "(", ")", "\n", "mtask", ".", "handleStoppedToRunningContainerTransition", "(", "event", ".", "Status", ",", "container", ")", "\n", "if", "event", ".", "Status", "<=", "containerKnownStatus", "{", "seelog", ".", "Infof", "(", "\"", "\"", ",", "mtask", ".", "Arn", ",", "container", ".", "Name", ",", "event", ".", "Status", ".", "String", "(", ")", ",", "containerKnownStatus", ".", "String", "(", ")", ")", "\n", "return", "\n", "}", "\n\n", "// Update the container to be known", "currentKnownStatus", ":=", "containerKnownStatus", "\n", "container", ".", "SetKnownStatus", "(", "event", ".", "Status", ")", "\n", "updateContainerMetadata", "(", "&", "event", ".", "DockerContainerMetadata", ",", "container", ",", "mtask", ".", "Task", ")", "\n\n", "if", "event", ".", "Error", "!=", "nil", "{", "proceedAnyway", ":=", "mtask", ".", "handleEventError", "(", "containerChange", ",", "currentKnownStatus", ")", "\n", "if", "!", "proceedAnyway", "{", "return", "\n", "}", "\n", "}", "\n\n", "// Update the container health status", "if", "container", ".", "HealthStatusShouldBeReported", "(", ")", "{", "container", ".", "SetHealthStatus", "(", "event", ".", "Health", ")", "\n", "}", "\n\n", "mtask", ".", "RecordExecutionStoppedAt", "(", "container", ")", "\n", "seelog", ".", "Debugf", "(", "\"", "\"", ",", "mtask", ".", "Arn", ",", "container", ".", "Name", ",", "event", ".", "DockerID", ",", "event", ".", "Status", ".", "String", "(", ")", ")", "\n", "err", ":=", "mtask", ".", "containerChangeEventStream", ".", "WriteToEventStream", "(", "event", ")", "\n", "if", "err", "!=", "nil", "{", "seelog", ".", "Warnf", "(", "\"", "\"", ",", "mtask", ".", "Arn", ",", "container", ".", "Name", ",", "err", ")", "\n", "}", "\n\n", "mtask", ".", "emitContainerEvent", "(", "mtask", ".", "Task", ",", "container", ",", "\"", "\"", ")", "\n", "if", "mtask", ".", "UpdateStatus", "(", ")", "{", "seelog", ".", "Debugf", "(", "\"", "\"", ",", "mtask", ".", "Arn", ",", "container", ".", "Name", ",", "mtask", ".", "GetDesiredStatus", "(", ")", ".", "String", "(", ")", ")", "\n", "// If knownStatus changed, let it be known", "var", "taskStateChangeReason", "string", "\n", "if", "mtask", ".", "GetKnownStatus", "(", ")", ".", "Terminal", "(", ")", "{", "taskStateChangeReason", "=", "mtask", ".", "Task", ".", "GetTerminalReason", "(", ")", "\n", "}", "\n", "mtask", ".", "emitTaskEvent", "(", "mtask", ".", "Task", ",", "taskStateChangeReason", ")", "\n", "}", "\n", "seelog", ".", "Debugf", "(", "\"", "\"", ",", "mtask", ".", "Arn", ",", "container", ".", "Name", ",", "mtask", ".", "GetDesiredStatus", "(", ")", ".", "String", "(", ")", ")", "\n", "}" ]
18,273
all-18274
[ "Returns", "an", "slice", "of", "boolean", "or", "the", "specified", "slice" ]
[ "func", "(", "t", "Typed", ")", "BoolsOr", "(", "key", "string", ",", "d", "[", "]", "bool", ")", "[", "]", "bool", "{", "n", ",", "ok", ":=", "t", ".", "BoolsIf", "(", "<mask>", ")", "\n", "if", "ok", "{", "return", "n", "\n", "}", "\n", "return", "d", "\n", "}" ]
18,274
all-18275
[ "Do", "executes", "IndexedDB", ".", "requestData", "against", "the", "provided", "context", ".", "returns", ":", "objectStoreDataEntries", "-", "Array", "of", "object", "store", "data", "entries", ".", "hasMore", "-", "If", "true", "there", "are", "more", "entries", "to", "fetch", "in", "the", "given", "range", "." ]
[ "func", "(", "p", "*", "RequestDataParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "objectStoreDataEntries", "[", "]", "*", "DataEntry", ",", "hasMore", "bool", ",", "err", "error", ")", "{", "// execute", "<mask>", "res", "RequestDataReturns", "\n", "err", "=", "cdp", ".", "Execute", "(", "ctx", ",", "CommandRequestData", ",", "p", ",", "&", "res", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "false", ",", "err", "\n", "}", "\n\n", "return", "res", ".", "ObjectStoreDataEntries", ",", "res", ".", "HasMore", ",", "nil", "\n", "}" ]
18,275
all-18276
[ "GetCreateFlags", "registers", "the", "flags", "this", "driver", "adds", "to", "docker", "hosts", "create" ]
[ "func", "(", "d", "*", "Driver", ")", "GetCreateFlags", "(", ")", "[", "]", "mcnflag", ".", "Flag", "{", "return", "[", "]", "mcnflag", ".", "Flag", "{", "mcnflag", ".", "IntFlag", "{", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "<mask>", ":", "engine", ".", "DefaultPort", ",", "EnvVar", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "Value", ":", "drivers", ".", "DefaultSSHUser", ",", "EnvVar", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "Value", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "IntFlag", "{", "Name", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "Value", ":", "drivers", ".", "DefaultSSHPort", ",", "EnvVar", ":", "\"", "\"", ",", "}", ",", "}", "\n", "}" ]
18,276
all-18277
[ "Collect", "implements", "prometheus", "Collector", "interface", "." ]
[ "func", "(", "sm", "*", "sessionManager", ")", "Collect", "(", "in", "chan", "<-", "prometheus", ".", "Metric", ")", "{", "<mask>", ".", "cleanupErrorsTotal", ".", "Collect", "(", "in", ")", "\n", "}" ]
18,277
all-18278
[ "Put", "copies", "the", "content", "reader", "until", "the", "end", "into", "the", "cache", "at", "key", "if", "contentSHA256", "is", "not", "then", "the", "contents", "will", "only", "be", "stored", "in", "the", "cache", "if", "the", "content", "s", "hex", "string", "SHA256", "matches" ]
[ "func", "(", "c", "*", "Cache", ")", "Put", "(", "key", "string", ",", "content", "io", ".", "Reader", ",", "contentSHA256", "string", ")", "error", "{", "// make sure directory exists", "path", ":=", "c", ".", "KeyToPath", "(", "key", ")", "\n", "dir", ":=", "filepath", ".", "Dir", "(", "path", ")", "\n", "err", ":=", "ensureDir", "(", "dir", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "dir", ")", "\n", "}", "\n\n", "// create a temp file to get the content on disk", "temp", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "dir", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "// fast path copying when not hashing content,s", "if", "contentSHA256", "==", "\"", "\"", "{", "_", ",", "err", "=", "io", ".", "Copy", "(", "temp", ",", "content", ")", "\n", "if", "err", "!=", "nil", "{", "removeTemp", "(", "temp", ".", "Name", "(", ")", ")", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "}", "else", "{", "hasher", ":=", "sha256", ".", "New", "(", ")", "\n", "_", ",", "err", "=", "io", ".", "Copy", "(", "io", ".", "MultiWriter", "(", "temp", ",", "hasher", ")", ",", "content", ")", "\n", "if", "err", "!=", "nil", "{", "removeTemp", "(", "temp", ".", "Name", "(", ")", ")", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "actualContentSHA256", ":=", "hex", ".", "EncodeToString", "(", "hasher", ".", "Sum", "(", "nil", ")", ")", "\n", "if", "actualContentSHA256", "!=", "contentSHA256", "{", "removeTemp", "(", "temp", ".", "Name", "(", ")", ")", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "key", ",", "contentSHA256", ",", "actualContentSHA256", ")", "\n", "}", "\n", "}", "\n\n", "// move the content to the key location", "err", "=", "temp", ".", "Sync", "(", ")", "\n", "if", "err", "!=", "nil", "{", "removeTemp", "(", "temp", ".", "Name", "(", ")", ")", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "temp", ".", "Close", "(", ")", "\n", "err", "=", "os", ".", "Rename", "(", "temp", ".", "Name", "(", ")", ",", "path", ")", "\n", "if", "err", "!=", "nil", "{", "removeTemp", "(", "<mask>", ".", "Name", "(", ")", ")", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
18,278
all-18279
[ "GetOverallStateOk", "returns", "a", "tuple", "with", "the", "OverallState", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "m", "*", "Monitor", ")", "GetOverallStateOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "m", "==", "nil", "||", "m", ".", "OverallState", "==", "nil", "{", "return", "\"", "\"", ",", "<mask>", "\n", "}", "\n", "return", "*", "m", ".", "OverallState", ",", "true", "\n", "}" ]
18,279
all-18280
[ "checkLeaderLease", "is", "used", "to", "check", "if", "we", "can", "contact", "a", "quorum", "of", "nodes", "within", "the", "last", "leader", "lease", "interval", ".", "If", "not", "we", "need", "to", "step", "down", "as", "we", "may", "have", "lost", "connectivity", ".", "Returns", "the", "maximum", "duration", "without", "contact", ".", "This", "must", "only", "be", "called", "from", "the", "main", "thread", "." ]
[ "func", "(", "r", "*", "Raft", ")", "checkLeaderLease", "(", ")", "time", ".", "Duration", "{", "// Track contacted nodes, we can always contact ourself", "contacted", ":=", "1", "\n\n", "// Check each follower", "var", "maxDiff", "time", ".", "Duration", "\n", "now", ":=", "time", ".", "Now", "(", ")", "\n", "for", "peer", ",", "f", ":=", "range", "r", ".", "leaderState", ".", "replState", "{", "diff", ":=", "now", ".", "Sub", "(", "f", ".", "LastContact", "(", ")", ")", "\n", "if", "diff", "<=", "r", ".", "conf", ".", "LeaderLeaseTimeout", "{", "contacted", "++", "\n", "if", "diff", ">", "maxDiff", "{", "maxDiff", "=", "diff", "\n", "}", "\n", "}", "else", "{", "// Log at least once at high value, then debug. Otherwise it gets very verbose.", "if", "diff", "<=", "3", "*", "r", ".", "conf", ".", "LeaderLeaseTimeout", "{", "r", ".", "logger", ".", "Warn", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "peer", ",", "diff", ")", ")", "\n", "}", "else", "{", "r", ".", "logger", ".", "Debug", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "peer", ",", "diff", ")", ")", "\n", "}", "\n", "}", "\n", "metrics", ".", "AddSample", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "float32", "(", "diff", "/", "<mask>", ".", "Millisecond", ")", ")", "\n", "}", "\n\n", "// Verify we can contact a quorum", "quorum", ":=", "r", ".", "quorumSize", "(", ")", "\n", "if", "contacted", "<", "quorum", "{", "r", ".", "logger", ".", "Warn", "(", "\"", "\"", ")", "\n", "r", ".", "setState", "(", "Follower", ")", "\n", "metrics", ".", "IncrCounter", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "1", ")", "\n", "}", "\n", "return", "maxDiff", "\n", "}" ]
18,280
all-18281
[ "Specify", "the", "value", "of", "a", "uniform", "variable", "for", "the", "current", "program", "object" ]
[ "func", "UniformMatrix2x3fv", "(", "<mask>", "int32", ",", "count", "int32", ",", "transpose", "bool", ",", "value", "*", "float32", ")", "{", "syscall", ".", "Syscall6", "(", "gpUniformMatrix2x3fv", ",", "4", ",", "uintptr", "(", "location", ")", ",", "uintptr", "(", "count", ")", ",", "boolToUintptr", "(", "transpose", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "value", ")", ")", ",", "0", ",", "0", ")", "\n", "}" ]
18,281
all-18282
[ "Connect", "to", "the", "database", "using", "the", "provided", "config" ]
[ "func", "(", "m", "*", "Connection", ")", "Connect", "(", ")", "(", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "r", ":=", "recover", "(", ")", ";", "r", "!=", "nil", "{", "// panic(r)", "// return", "if", "e", ",", "ok", ":=", "r", ".", "(", "error", ")", ";", "ok", "{", "err", "=", "e", "\n", "}", "else", "if", "e", ",", "ok", ":=", "r", ".", "(", "string", ")", ";", "ok", "{", "err", "=", "errors", ".", "New", "(", "e", ")", "\n", "}", "else", "{", "err", "=", "<mask>", ".", "New", "(", "fmt", ".", "Sprint", "(", "r", ")", ")", "\n", "}", "\n\n", "}", "\n", "}", "(", ")", "\n\n", "if", "m", ".", "Config", ".", "DialInfo", "==", "nil", "{", "if", "m", ".", "Config", ".", "DialInfo", ",", "err", "=", "mgo", ".", "ParseURL", "(", "m", ".", "Config", ".", "ConnectionString", ")", ";", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "Config", ".", "ConnectionString", ",", "err", ".", "Error", "(", ")", ")", ")", "\n", "}", "\n", "}", "\n\n", "session", ",", "err", ":=", "mgo", ".", "DialWithInfo", "(", "m", ".", "Config", ".", "DialInfo", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "m", ".", "Session", "=", "session", "\n\n", "m", ".", "Session", ".", "SetMode", "(", "mgo", ".", "Monotonic", ",", "true", ")", "\n\n", "return", "nil", "\n", "}" ]
18,282
all-18283
[ "HasCreatedBy", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "d", "*", "DashboardLite", ")", "HasCreatedBy", "(", ")", "bool", "{", "if", "d", "!=", "nil", "&&", "d", ".", "CreatedBy", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
18,283
all-18284
[ "UnmarshalText", "hydrates", "this", "instance", "from", "text" ]
[ "func", "(", "h", "*", "Hostname", ")", "UnmarshalText", "(", "data", "[", "]", "byte", ")", "error", "{", "// validation is performed later on", "*", "h", "=", "Hostname", "(", "string", "(", "<mask>", ")", ")", "\n", "return", "nil", "\n", "}" ]
18,284
all-18285
[ "Sets", "the", "settings", "files", "of", "the", "caller", "." ]
[ "func", "init", "(", ")", "{", "var", "err", "error", "\n\n", "_SETTINGS", ",", "err", "=", "getSettingsForUid", "(", "<mask>", ".", "Getuid", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "}" ]
18,285
all-18286
[ "NewClient", "creates", "a", "new", "connection", "to", "a", "host", "given", "as", "hostname", "or", "hostname", ":", "port", ".", "If", "host", "is", "not", "specified", "the", "DNS", "SRV", "should", "be", "used", "to", "find", "the", "host", "from", "the", "domainpart", "of", "the", "JID", ".", "Default", "the", "port", "to", "5222", "." ]
[ "func", "NewClient", "(", "host", ",", "user", ",", "passwd", "string", ",", "<mask>", "bool", ")", "(", "*", "Client", ",", "error", ")", "{", "opts", ":=", "Options", "{", "Host", ":", "host", ",", "User", ":", "user", ",", "Password", ":", "passwd", ",", "Debug", ":", "debug", ",", "Session", ":", "false", ",", "}", "\n", "return", "opts", ".", "NewClient", "(", ")", "\n", "}" ]
18,286
all-18287
[ "Finds", "the", "handler", "matching", "the", "given", "service", "and", "method", ".", "See", "https", ":", "//", "github", ".", "com", "/", "golang", "/", "go", "/", "issues", "/", "3512", "for", "the", "reason", "that", "method", "is", "[]", "byte", "instead", "of", "a", "string" ]
[ "func", "(", "hmap", "*", "handlerMap", ")", "find", "(", "method", "[", "]", "byte", ")", "Handler", "{", "hmap", ".", "RLock", "(", ")", "\n", "<mask>", ":=", "hmap", ".", "handlers", "[", "string", "(", "method", ")", "]", "\n", "hmap", ".", "RUnlock", "(", ")", "\n\n", "return", "handler", "\n", "}" ]
18,287
all-18288
[ "MenuNew", "is", "a", "wrapper", "around", "g_menu_new", "()", "." ]
[ "func", "MenuNew", "(", ")", "*", "<mask>", "{", "c", ":=", "C", ".", "g_menu_new", "(", ")", "\n", "if", "c", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "wrapMenu", "(", "wrapObject", "(", "unsafe", ".", "Pointer", "(", "c", ")", ")", ")", "\n", "}" ]
18,288
all-18289
[ "ListRepoHooks", "returns", "a", "list", "of", "hooks", "for", "the", "repo", ".", "https", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "repos", "/", "hooks", "/", "#list", "-", "hooks" ]
[ "func", "(", "c", "*", "<mask>", ")", "ListRepoHooks", "(", "org", ",", "repo", "string", ")", "(", "[", "]", "Hook", ",", "error", ")", "{", "c", ".", "log", "(", "\"", "\"", ",", "org", ",", "repo", ")", "\n", "return", "c", ".", "listHooks", "(", "org", ",", "&", "repo", ")", "\n", "}" ]
18,289
all-18290
[ "setup", "configures", "a", "new", "Git", "service", "routine", "." ]
[ "func", "setup", "(", "c", "*", "caddy", ".", "Controller", ")", "error", "{", "git", ",", "err", ":=", "parse", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// repos configured with webhooks", "var", "hookRepos", "[", "]", "*", "Repo", "\n\n", "// functions to execute at startup", "var", "startupFuncs", "[", "]", "func", "(", ")", "error", "\n\n", "// loop through all repos and and start monitoring", "for", "i", ":=", "range", "git", "{", "repo", ":=", "git", ".", "Repo", "(", "i", ")", "\n\n", "// If a HookUrl is set, we switch to event based pulling.", "// Install the url handler", "if", "repo", ".", "Hook", ".", "URL", "!=", "\"", "\"", "{", "hookRepos", "=", "append", "(", "hookRepos", ",", "repo", ")", "\n\n", "startupFuncs", "=", "<mask>", "(", "startupFuncs", ",", "func", "(", ")", "error", "{", "return", "repo", ".", "Pull", "(", ")", "\n", "}", ")", "\n\n", "}", "else", "{", "startupFuncs", "=", "append", "(", "startupFuncs", ",", "func", "(", ")", "error", "{", "// Start service routine in background", "Start", "(", "repo", ")", "\n\n", "// Do a pull right away to return error", "return", "repo", ".", "Pull", "(", ")", "\n", "}", ")", "\n", "}", "\n", "}", "\n\n", "// ensure the functions are executed once per server block", "// for cases like server1.com, server2.com { ... }", "c", ".", "OncePerServerBlock", "(", "func", "(", ")", "error", "{", "for", "i", ":=", "range", "startupFuncs", "{", "c", ".", "OnStartup", "(", "startupFuncs", "[", "i", "]", ")", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "// if there are repo(s) with webhook", "// return handler", "if", "len", "(", "hookRepos", ")", ">", "0", "{", "webhook", ":=", "&", "WebHook", "{", "Repos", ":", "hookRepos", "}", "\n", "httpserver", ".", "GetConfig", "(", "c", ")", ".", "AddMiddleware", "(", "func", "(", "next", "httpserver", ".", "Handler", ")", "httpserver", ".", "Handler", "{", "webhook", ".", "Next", "=", "next", "\n", "return", "webhook", "\n", "}", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
18,290
all-18291
[ "returns", "a", "subset", "of", "a", "buffer", "object", "s", "data", "store" ]
[ "func", "GetNamedBufferSubData", "(", "buffer", "uint32", ",", "<mask>", "int", ",", "size", "int", ",", "data", "unsafe", ".", "Pointer", ")", "{", "C", ".", "glowGetNamedBufferSubData", "(", "gpGetNamedBufferSubData", ",", "(", "C", ".", "GLuint", ")", "(", "buffer", ")", ",", "(", "C", ".", "GLintptr", ")", "(", "offset", ")", ",", "(", "C", ".", "GLsizeiptr", ")", "(", "size", ")", ",", "data", ")", "\n", "}" ]
18,291
all-18292
[ "MakeBufferWithBytes", "allocates", "a", "new", "buffer", "of", "a", "given", "length", "and", "initializes", "its", "contents", "by", "copying", "existing", "data", "into", "it", ".", "Reference", ":", "https", ":", "//", "developer", ".", "apple", ".", "com", "/", "documentation", "/", "metal", "/", "mtldevice", "/", "1433429", "-", "makebuffer", "." ]
[ "func", "(", "d", "Device", ")", "MakeBufferWithBytes", "(", "bytes", "unsafe", ".", "Pointer", ",", "length", "uintptr", ",", "opt", "ResourceOptions", ")", "Buffer", "{", "return", "Buffer", "{", "C", ".", "Device_MakeBufferWithBytes", "(", "d", ".", "device", ",", "bytes", ",", "C", ".", "size_t", "(", "<mask>", ")", ",", "C", ".", "uint16_t", "(", "opt", ")", ")", "}", "\n", "}" ]
18,292
all-18293
[ "DropAll", "would", "drop", "all", "the", "data", "stored", "in", "Badger", ".", "It", "does", "this", "in", "the", "following", "way", ".", "-", "Stop", "accepting", "new", "writes", ".", "-", "Pause", "memtable", "flushes", "and", "compactions", ".", "-", "Pick", "all", "tables", "from", "all", "levels", "create", "a", "changeset", "to", "delete", "all", "these", "tables", "and", "apply", "it", "to", "manifest", ".", "-", "Pick", "all", "log", "files", "from", "value", "log", "and", "delete", "all", "of", "them", ".", "Restart", "value", "log", "files", "from", "zero", ".", "-", "Resume", "memtable", "flushes", "and", "compactions", ".", "NOTE", ":", "DropAll", "is", "resilient", "to", "concurrent", "writes", "but", "not", "to", "reads", ".", "It", "is", "up", "to", "the", "user", "to", "not", "do", "any", "reads", "while", "DropAll", "is", "going", "on", "otherwise", "they", "may", "result", "in", "panics", ".", "Ideally", "both", "reads", "and", "writes", "are", "paused", "before", "running", "DropAll", "and", "resumed", "after", "it", "is", "finished", "." ]
[ "func", "(", "db", "*", "DB", ")", "DropAll", "(", ")", "error", "{", "db", ".", "opt", ".", "Infof", "(", "\"", "\"", ")", "\n", "f", ":=", "db", ".", "prepareToDrop", "(", ")", "\n", "defer", "f", "(", ")", "\n\n", "// Block all foreign interactions with memory tables.", "db", ".", "Lock", "(", ")", "\n", "defer", "db", ".", "Unlock", "(", ")", "\n\n", "// Remove inmemory tables. Calling DecrRef for safety. Not sure if they're absolutely needed.", "<mask>", ".", "mt", ".", "DecrRef", "(", ")", "\n", "for", "_", ",", "mt", ":=", "range", "db", ".", "imm", "{", "mt", ".", "DecrRef", "(", ")", "\n", "}", "\n", "db", ".", "imm", "=", "db", ".", "imm", "[", ":", "0", "]", "\n", "db", ".", "mt", "=", "skl", ".", "NewSkiplist", "(", "arenaSize", "(", "db", ".", "opt", ")", ")", "// Set it up for future writes.", "\n\n", "num", ",", "err", ":=", "db", ".", "lc", ".", "dropTree", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "db", ".", "opt", ".", "Infof", "(", "\"", "\\n", "\"", ",", "num", ")", "\n\n", "num", ",", "err", "=", "db", ".", "vlog", ".", "dropAll", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "db", ".", "vhead", "=", "valuePointer", "{", "}", "// Zero it out.", "\n", "db", ".", "opt", ".", "Infof", "(", "\"", "\\n", "\"", ",", "num", ")", "\n", "return", "nil", "\n", "}" ]
18,293
all-18294
[ "resourceVSphereComputeClusterHostGroupFlattenID", "makes", "an", "ID", "for", "the", "vsphere_cluster_host_group", "resource", "." ]
[ "func", "resourceVSphereComputeClusterHostGroupFlattenID", "(", "cluster", "*", "object", ".", "ClusterComputeResource", ",", "<mask>", "string", ")", "(", "string", ",", "error", ")", "{", "clusterID", ":=", "cluster", ".", "Reference", "(", ")", ".", "Value", "\n", "return", "strings", ".", "Join", "(", "[", "]", "string", "{", "clusterID", ",", "name", "}", ",", "\"", "\"", ")", ",", "nil", "\n", "}" ]
18,294
all-18295
[ "return", "a", "texture", "image" ]
[ "func", "GetTexImage", "(", "target", "uint32", ",", "level", "int32", ",", "format", "uint32", ",", "xtype", "uint32", ",", "pixels", "unsafe", ".", "Pointer", ")", "{", "C", ".", "glowGetTexImage", "(", "gpGetTexImage", ",", "(", "C", ".", "GLenum", ")", "(", "<mask>", ")", ",", "(", "C", ".", "GLint", ")", "(", "level", ")", ",", "(", "C", ".", "GLenum", ")", "(", "format", ")", ",", "(", "C", ".", "GLenum", ")", "(", "xtype", ")", ",", "pixels", ")", "\n", "}" ]
18,295
all-18296
[ "Arg2Reader", "returns", "an", "ArgReader", "to", "read", "the", "second", "argument", ".", "The", "ReadCloser", "must", "be", "closed", "once", "the", "argument", "has", "been", "read", "." ]
[ "func", "(", "response", "*", "OutboundCallResponse", ")", "Arg2Reader", "(", ")", "(", "ArgReader", ",", "error", ")", "{", "var", "method", "[", "]", "byte", "\n", "if", "err", ":=", "NewArgReader", "(", "response", ".", "arg1Reader", "(", ")", ")", ".", "Read", "(", "&", "method", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "<mask>", ".", "arg2Reader", "(", ")", "\n", "}" ]
18,296
all-18297
[ "Sets", "a", "host", "to", "an", "IP", ".", "Note", "that", "this", "is", "not", "the", "FQDN", "but", "a", "hostname", "." ]
[ "func", "(", "ds", "*", "DNSServer", ")", "SetA", "(", "<mask>", "string", ",", "ip", "net", ".", "IP", ")", "{", "ds", ".", "aMutex", ".", "Lock", "(", ")", "\n", "ds", ".", "aRecords", "[", "ds", ".", "qualifyHost", "(", "host", ")", "]", "=", "ip", "\n", "ds", ".", "aMutex", ".", "Unlock", "(", ")", "\n", "}" ]
18,297
all-18298
[ "tokenFromFile", "returns", "a", "token", "from", "the", "specified", "file", "if", "it", "is", "found", "otherwise", "returns", "nil", ".", "Any", "error", "retrieving", "or", "creating", "the", "token", "is", "returned", "as", "an", "error", "." ]
[ "func", "tokenFromFile", "(", "oauthCfg", "azure", ".", "OAuthConfig", ",", "tokenPath", ",", "clientID", ",", "resource", "string", ",", "<mask>", "azure", ".", "TokenRefreshCallback", ")", "(", "*", "azure", ".", "ServicePrincipalToken", ",", "error", ")", "{", "log", ".", "Debug", "(", "\"", "\"", ",", "logutil", ".", "Fields", "{", "\"", "\"", ":", "tokenPath", "}", ")", "\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "tokenPath", ")", ";", "err", "!=", "nil", "{", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "// file not found", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "token", ",", "err", ":=", "azure", ".", "LoadToken", "(", "tokenPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "spt", ",", "err", ":=", "azure", ".", "NewServicePrincipalTokenFromManualToken", "(", "oauthCfg", ",", "clientID", ",", "resource", ",", "*", "token", ",", "callback", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "spt", ",", "nil", "\n", "}" ]
18,298
all-18299
[ "GetDefault", "returns", "the", "Default", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "t", "*", "TemplateVariable", ")", "GetDefault", "(", ")", "string", "{", "if", "t", "==", "nil", "||", "t", ".", "<mask>", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "t", ".", "Default", "\n", "}" ]
18,299
all-18300
[ "ReadPrivate", "loads", "ecdsa", ".", "PrivateKey", "from", "given", "PKCS1", "or", "PKCS8", "blobs" ]
[ "func", "ReadPrivate", "(", "raw", "[", "]", "byte", ")", "(", "key", "*", "ecdsa", ".", "PrivateKey", ",", "err", "error", ")", "{", "var", "encoded", "*", "pem", ".", "Block", "\n\n", "if", "encoded", ",", "_", "=", "pem", ".", "Decode", "(", "raw", ")", ";", "encoded", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "parsedKey", "interface", "{", "}", "\n\n", "if", "parsedKey", ",", "err", "=", "x509", ".", "ParseECPrivateKey", "(", "encoded", ".", "Bytes", ")", ";", "err", "!=", "nil", "{", "if", "parsedKey", ",", "err", "=", "x509", ".", "ParsePKCS8PrivateKey", "(", "encoded", ".", "Bytes", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "var", "ok", "bool", "\n", "if", "key", ",", "ok", "=", "parsedKey", ".", "(", "*", "ecdsa", ".", "PrivateKey", ")", ";", "!", "ok", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "<mask>", ",", "nil", "\n", "}" ]