id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
listlengths
1
418
pl_tokens
listlengths
22
4.98k
21,900
all-21901
[ "NewTxnCommand", "returns", "the", "cobra", "command", "for", "txn", "." ]
[ "func", "NewTxnCommand", "(", ")", "*", "cobra", ".", "Command", "{", "cmd", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"", "\"", ",", "Short", ":", "\"", "\"", ",", "Run", ":", "txnCommandFunc", ",", "}", "\n", "cmd", ".", "Flags", "(", ")", ".", "BoolVarP", "(", "&", "txnInteractive", ",", "\"", "\"", ",", "\"", "\"", ",", "<mask>", ",", "\"", "\"", ")", "\n", "return", "cmd", "\n", "}" ]
21,901
all-21902
[ "SetAppliedStatus", "sets", "the", "applied", "status", "of", "resource", "and", "returns", "whether", "the", "resource", "is", "already", "in", "a", "transition" ]
[ "func", "(", "auth", "*", "ASMAuthResource", ")", "SetAppliedStatus", "(", "status", "resourcestatus", ".", "ResourceStatus", ")", "bool", "{", "auth", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "auth", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "if", "auth", ".", "appliedStatus", "!=", "resourcestatus", ".", "ResourceStatus", "(", "ASMAuthStatusNone", ")", "{", "// return false to indicate the set operation failed", "return", "false", "\n", "}", "\n\n", "auth", ".", "appliedStatus", "=", "status", "\n", "return", "<mask>", "\n", "}" ]
21,902
all-21903
[ "MakeDisjointSet", "creates", "a", "DisjointSet", "." ]
[ "func", "MakeDisjointSet", "(", "forests", "*", "Forests", ",", "name", "string", ")", "{", "newDS", ":=", "&", "DisjointSet", "{", "}", "\n", "newDS", ".", "represent", "=", "name", "\n", "<mask>", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n", "members", "[", "name", "]", "=", "struct", "{", "}", "{", "}", "\n", "newDS", ".", "members", "=", "members", "\n", "forests", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "forests", ".", "mu", ".", "Unlock", "(", ")", "\n", "forests", ".", "data", "[", "newDS", "]", "=", "struct", "{", "}", "{", "}", "\n", "}" ]
21,903
all-21904
[ "SettingsNewWithBackendAndPath", "is", "a", "wrapper", "around", "g_settings_new_with_backend_and_path", "()", "." ]
[ "func", "SettingsNewWithBackendAndPath", "(", "schemaID", "string", ",", "backend", "*", "SettingsBackend", ",", "path", "string", ")", "*", "Settings", "{", "cstr1", ":=", "(", "*", "C", ".", "gchar", ")", "(", "C", ".", "CString", "(", "schemaID", ")", ")", "\n", "defer", "C", ".", "<mask>", "(", "unsafe", ".", "Pointer", "(", "cstr1", ")", ")", "\n\n", "cstr2", ":=", "(", "*", "C", ".", "gchar", ")", "(", "C", ".", "CString", "(", "path", ")", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cstr2", ")", ")", "\n\n", "return", "wrapFullSettings", "(", "C", ".", "g_settings_new_with_backend_and_path", "(", "cstr1", ",", "backend", ".", "native", "(", ")", ",", "cstr2", ")", ")", "\n", "}" ]
21,904
all-21905
[ "NewClient", "creates", "a", "new", "Client", "." ]
[ "func", "NewClient", "(", "client", "*", "http", ".", "Client", ",", "hostname", "string", ")", "*", "Client", "{", "return", "&", "<mask>", "{", "client", ",", "hostname", "}", "\n", "}" ]
21,905
all-21906
[ "Loop", "..." ]
[ "func", "(", "app", "*", "App", ")", "Loop", "(", ")", "{", "app", ".", "RLock", "(", ")", "\n", "exitChan", ":=", "app", ".", "exit", "\n", "app", ".", "RUnlock", "(", ")", "\n\n", "if", "exitChan", "!=", "nil", "{", "<-", "app", ".", "<mask>", "\n", "}", "\n", "}" ]
21,906
all-21907
[ "merge", "merges", "data", "from", "bb", "into", "bbsrc", "." ]
[ "func", "(", "bb", "*", "bucketBuffer", ")", "merge", "(", "bbsrc", "*", "bucketBuffer", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "bbsrc", ".", "used", ";", "i", "++", "{", "bb", ".", "add", "(", "bbsrc", ".", "buf", "[", "i", "]", ".", "key", ",", "bbsrc", ".", "buf", "[", "i", "]", ".", "val", ")", "\n", "}", "\n", "if", "bb", ".", "used", "==", "bbsrc", ".", "used", "{", "return", "\n", "}", "\n", "if", "bytes", ".", "Compare", "(", "bb", ".", "buf", "[", "(", "bb", ".", "used", "-", "bbsrc", ".", "used", ")", "-", "1", "]", ".", "key", ",", "bbsrc", ".", "buf", "[", "0", "]", ".", "<mask>", ")", "<", "0", "{", "return", "\n", "}", "\n\n", "sort", ".", "Stable", "(", "bb", ")", "\n\n", "// remove duplicates, using only newest update", "widx", ":=", "0", "\n", "for", "ridx", ":=", "1", ";", "ridx", "<", "bb", ".", "used", ";", "ridx", "++", "{", "if", "!", "bytes", ".", "Equal", "(", "bb", ".", "buf", "[", "ridx", "]", ".", "key", ",", "bb", ".", "buf", "[", "widx", "]", ".", "key", ")", "{", "widx", "++", "\n", "}", "\n", "bb", ".", "buf", "[", "widx", "]", "=", "bb", ".", "buf", "[", "ridx", "]", "\n", "}", "\n", "bb", ".", "used", "=", "widx", "+", "1", "\n", "}" ]
21,907
all-21908
[ "roleIsManaged", "checks", "if", "the", "role", "should", "be", "managed", "(", "and", "thus", "deleted", ")", "by", "us", "In", "particular", "we", "want", "to", "avoid", "system", "AWS", "roles", "or", "roles", "that", "might", "support", "test", "-", "infra" ]
[ "func", "roleIsManaged", "(", "role", "*", "iam", ".", "Role", ")", "bool", "{", "name", ":=", "aws", ".", "StringValue", "(", "role", ".", "RoleName", ")", "\n", "path", ":=", "aws", ".", "StringValue", "(", "role", ".", "Path", ")", "\n\n", "// Most AWS system roles are in a directory called `aws-service-role`", "if", "strings", ".", "HasPrefix", "(", "path", ",", "\"", "\"", ")", "{", "return", "false", "\n", "}", "\n\n", "// kops roles have names start with `masters.` or `nodes.`", "if", "strings", ".", "HasPrefix", "(", "name", ",", "\"", "\"", ")", "||", "strings", ".", "HasPrefix", "(", "name", ",", "\"", "\"", ")", "{", "return", "true", "\n", "}", "\n\n", "klog", ".", "Infof", "(", "\"", "\"", ",", "<mask>", ",", "path", ")", "\n", "return", "false", "\n", "}" ]
21,908
all-21909
[ "NewImageSource", "returns", "a", "types", ".", "ImageSource", "for", "this", "reference", ".", "The", "caller", "must", "call", ".", "Close", "()", "on", "the", "returned", "ImageSource", "." ]
[ "func", "(", "ref", "ostreeReference", ")", "NewImageSource", "(", "ctx", "context", ".", "Context", ",", "sys", "*", "types", ".", "SystemContext", ")", "(", "types", ".", "ImageSource", ",", "error", ")", "{", "var", "tmpDir", "string", "\n", "if", "sys", "==", "nil", "||", "sys", ".", "OSTreeTmpDirPath", "==", "\"", "\"", "{", "tmpDir", "=", "<mask>", ".", "TempDir", "(", ")", "\n", "}", "else", "{", "tmpDir", "=", "sys", ".", "OSTreeTmpDirPath", "\n", "}", "\n", "return", "newImageSource", "(", "tmpDir", ",", "ref", ")", "\n", "}" ]
21,909
all-21910
[ "TriggerWithDetails", "triggers", "an", "incident", "using", "the", "default", "client", "with", "a", "description", "string", "and", "a", "key", "-", "value", "map", "that", "will", "be", "saved", "as", "the", "incident", "s", "details", "." ]
[ "func", "TriggerWithDetails", "(", "description", "string", ",", "details", "<mask>", "[", "string", "]", "interface", "{", "}", ")", "(", "incidentKey", "string", ",", "err", "error", ")", "{", "return", "trigger", "(", "description", ",", "\"", "\"", ",", "details", ")", "\n", "}" ]
21,910
all-21911
[ "SetGauge", "sets", "a", "gauge", "to", "a", "value" ]
[ "func", "(", "m", "*", "CirconusMetrics", ")", "SetGauge", "(", "metric", "string", ",", "val", "<mask>", "{", "}", ")", "{", "m", ".", "gm", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "gm", ".", "Unlock", "(", ")", "\n", "m", ".", "gauges", "[", "metric", "]", "=", "val", "\n", "}" ]
21,911
all-21912
[ "Compute", "API", "URL", "given", "a", "scheme", "hostname", "and", "a", "path" ]
[ "func", "buildURL", "(", "<mask>", ",", "path", "string", ")", "string", "{", "scheme", ":=", "\"", "\"", "\n", "if", "httpclient", ".", "Insecure", "{", "scheme", "=", "\"", "\"", "\n", "}", "\n", "u", ":=", "url", ".", "URL", "{", "Scheme", ":", "scheme", ",", "Host", ":", "host", ",", "Path", ":", "path", ",", "}", "\n", "return", "u", ".", "String", "(", ")", "\n", "}" ]
21,912
all-21913
[ "Start", "a", "Service", "and", "log", "its", "output", "." ]
[ "func", "(", "s", "*", "ServiceMock", ")", "Start", "(", ")", "*", "exec", ".", "Cmd", "{", "s", ".", "ServiceStartCount", "++", "\n", "cmd", ":=", "s", ".", "ExecFunc", "(", ")", "\n", "cmd", ".", "Start", "(", ")", "\n", "if", "s", ".", "processes", "==", "nil", "{", "s", ".", "processes", "=", "make", "(", "<mask>", "[", "int", "]", "*", "exec", ".", "Cmd", ")", "\n", "}", "\n", "s", ".", "processes", "[", "cmd", ".", "Process", ".", "Pid", "]", "=", "cmd", "\n\n", "return", "cmd", "\n", "}" ]
21,913
all-21914
[ "Update", "updates", "a", "vsphere_virtual_machine", "disk", "sub", "-", "resource", "." ]
[ "func", "(", "r", "*", "DiskSubresource", ")", "Update", "(", "l", "<mask>", ".", "VirtualDeviceList", ")", "(", "[", "]", "types", ".", "BaseVirtualDeviceConfigSpec", ",", "error", ")", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ")", "\n", "disk", ",", "err", ":=", "r", ".", "findVirtualDisk", "(", "l", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "// Has the unit number changed?", "if", "r", ".", "HasChange", "(", "\"", "\"", ")", "{", "ctlr", ",", "err", ":=", "r", ".", "assignDisk", "(", "l", ",", "disk", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "r", ".", "SetRestart", "(", "\"", "\"", ")", "\n", "if", "err", ":=", "r", ".", "SaveDevIDs", "(", "disk", ",", "ctlr", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "// A change in disk unit number forces a device key change after the", "// reconfigure. We need to keep the key in the device change spec we send", "// along, but we can reset it here safely. Set it to 0, which will send it", "// though the new device loop, but will distinguish it from newly-created", "// devices.", "r", ".", "Set", "(", "\"", "\"", ",", "0", ")", "\n", "}", "\n\n", "// We can now expand the rest of the settings.", "if", "err", ":=", "r", ".", "expandDiskSettings", "(", "disk", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "dspec", ",", "err", ":=", "object", ".", "VirtualDeviceList", "{", "disk", "}", ".", "ConfigSpec", "(", "types", ".", "VirtualDeviceConfigSpecOperationEdit", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "len", "(", "dspec", ")", "!=", "1", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "dspec", ")", ")", "\n", "}", "\n", "// Clear file operation - VirtualDeviceList currently sets this to replace, which is invalid", "dspec", "[", "0", "]", ".", "GetVirtualDeviceConfigSpec", "(", ")", ".", "FileOperation", "=", "\"", "\"", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ",", "DeviceChangeString", "(", "dspec", ")", ")", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ")", "\n", "return", "dspec", ",", "nil", "\n", "}" ]
21,914
all-21915
[ "String", "returns", "the", "position", "of", "the", "string", "that", "begins", "at", "the", "specified", "pos" ]
[ "func", "String", "(", "in", "[", "]", "byte", ",", "<mask>", "int", ")", "(", "int", ",", "error", ")", "{", "pos", ",", "err", ":=", "skipSpace", "(", "in", ",", "pos", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "max", ":=", "len", "(", "in", ")", "\n\n", "if", "v", ":=", "in", "[", "pos", "]", ";", "v", "!=", "'\"'", "{", "return", "0", ",", "newError", "(", "pos", ",", "v", ")", "\n", "}", "\n", "pos", "++", "\n\n", "for", "{", "switch", "in", "[", "pos", "]", "{", "case", "'\\\\'", ":", "if", "in", "[", "pos", "+", "1", "]", "==", "'\"'", "{", "pos", "++", "\n", "}", "\n", "case", "'\"'", ":", "return", "pos", "+", "1", ",", "nil", "\n", "}", "\n", "pos", "++", "\n\n", "if", "pos", ">=", "max", "{", "break", "\n", "}", "\n", "}", "\n\n", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
21,915
all-21916
[ "void", "pango_cairo_layout_path", "(", "cairo_t", "*", "cr", "PangoLayout", "*", "layout", ")", ";" ]
[ "func", "CairoLayoutPath", "(", "cr", "*", "cairo", ".", "Context", ",", "layout", "*", "Layout", ")", "{", "C", ".", "pango_cairo_layout_path", "(", "cairo_context", "(", "cr", ")", ",", "<mask>", ".", "native", "(", ")", ")", "\n", "}" ]
21,916
all-21917
[ "DecodeCenter", "decodes", "the", "string", "geohash", "to", "the", "central", "point", "of", "the", "bounding", "box", "." ]
[ "func", "DecodeCenter", "(", "hash", "string", ")", "(", "lat", ",", "lng", "float64", ")", "{", "box", ":=", "BoundingBox", "(", "<mask>", ")", "\n", "return", "box", ".", "Center", "(", ")", "\n", "}" ]
21,917
all-21918
[ "Validate", "validates", "this", "Vm", "response" ]
[ "func", "(", "m", "*", "VMResponse", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateVM", "(", "formats", ")", ";", "err", "!=", "nil", "{", "// prop", "res", "=", "append", "(", "res", ",", "err", ")", "\n", "}", "\n\n", "if", "len", "(", "res", ")", ">", "0", "{", "return", "<mask>", ".", "CompositeValidationError", "(", "res", "...", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
21,918
all-21919
[ "HasAutoscale", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "t", "*", "TileDef", ")", "HasAutoscale", "(", ")", "bool", "{", "if", "t", "!=", "nil", "&&", "t", ".", "Autoscale", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
21,919
all-21920
[ "GetRepoLabels", "returns", "the", "list", "of", "labels", "accessible", "to", "org", "/", "repo", ".", "See", "https", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "issues", "/", "labels", "/", "#list", "-", "all", "-", "labels", "-", "for", "-", "this", "-", "repository" ]
[ "func", "(", "c", "*", "Client", ")", "GetRepoLabels", "(", "org", ",", "repo", "string", ")", "(", "[", "]", "Label", ",", "error", ")", "{", "c", ".", "<mask>", "(", "\"", "\"", ",", "org", ",", "repo", ")", "\n", "return", "c", ".", "getLabels", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "org", ",", "repo", ")", ")", "\n", "}" ]
21,920
all-21921
[ "returns", "a", "list", "of", "countries", "where", "Twilio", "voice", "services", "are", "available", "and", "the", "corresponding", "URL", "for", "retrieving", "the", "country", "specific", "voice", "prices", "." ]
[ "func", "(", "cvps", "*", "CountryVoicePriceService", ")", "GetPage", "(", "ctx", "context", ".", "Context", ",", "data", "<mask>", ".", "Values", ")", "(", "*", "CountriesPricePage", ",", "error", ")", "{", "return", "cvps", ".", "GetPageIterator", "(", "data", ")", ".", "Next", "(", "ctx", ")", "\n", "}" ]
21,921
all-21922
[ "absorbBlockBlake2Safe", "Performs", "an", "absorb", "operation", "for", "a", "single", "block", "(", "BLOCK_LEN_BLAKE2_SAFE_INT64", "words", "of", "type", "uint64_t", ")", "using", "Blake2b", "s", "G", "function", "as", "the", "internal", "permutation" ]
[ "func", "absorbBlockBlake2Safe", "(", "state", "[", "]", "uint64", ",", "in", "[", "]", "uint64", ")", "{", "//XORs the first BLOCK_LEN_BLAKE2_SAFE_INT64 words of \"in\" with the current state", "state", "[", "0", "]", "^=", "in", "[", "0", "]", "\n", "state", "[", "1", "]", "^=", "in", "[", "1", "]", "\n", "<mask>", "[", "2", "]", "^=", "in", "[", "2", "]", "\n", "state", "[", "3", "]", "^=", "in", "[", "3", "]", "\n", "state", "[", "4", "]", "^=", "in", "[", "4", "]", "\n", "state", "[", "5", "]", "^=", "in", "[", "5", "]", "\n", "state", "[", "6", "]", "^=", "in", "[", "6", "]", "\n", "state", "[", "7", "]", "^=", "in", "[", "7", "]", "\n\n", "//Applies the transformation f to the sponge's state", "blake2bLyra", "(", "state", ")", "\n\n", "}" ]
21,922
all-21923
[ "CommentPruner", "will", "return", "the", "commentpruner", ".", "EventClient", "attached", "to", "the", "agent", "or", "an", "error", "if", "one", "is", "not", "attached", "." ]
[ "func", "(", "a", "*", "Agent", ")", "CommentPruner", "(", ")", "(", "*", "commentpruner", ".", "EventClient", ",", "error", ")", "{", "if", "a", ".", "commentPruner", "==", "nil", "{", "return", "nil", ",", "<mask>", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "a", ".", "commentPruner", ",", "nil", "\n", "}" ]
21,923
all-21924
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "EventAttributeModified", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom68", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
21,924
all-21925
[ "GetEndpoints", "returns", "endpoints", "." ]
[ "func", "(", "h", "*", "Handler", ")", "GetEndpoints", "(", "tkn", ",", "channel", ",", "template", "string", ")", "(", "[", "]", "data", ".", "Endpoint", ",", "error", ")", "{", "logger", ":=", "h", ".", "logger", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "channel", ",", "\"", "\"", ",", "template", ")", "\n\n", "if", "!", "h", ".", "token", ".", "Check", "(", "tkn", ")", "{", "logger", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "nil", ",", "ErrAccessDenied", "\n", "}", "\n\n", "tail", ",", "args", ":=", "h", ".", "getEndpointsConditions", "(", "channel", ",", "template", ")", "\n\n", "result", ",", "err", ":=", "h", ".", "selectAllFrom", "(", "logger", ",", "data", ".", "EndpointTable", ",", "tail", ",", "args", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "endpoints", ":=", "make", "(", "[", "]", "data", ".", "Endpoint", ",", "len", "(", "result", ")", ")", "\n", "for", "i", ",", "item", ":=", "range", "<mask>", "{", "endpoints", "[", "i", "]", "=", "*", "item", ".", "(", "*", "data", ".", "Endpoint", ")", "\n", "}", "\n\n", "return", "endpoints", ",", "nil", "\n", "}" ]
21,925
all-21926
[ "GetTitleAlignOk", "returns", "a", "tuple", "with", "the", "TitleAlign", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "c", "*", "CheckStatusDefinition", ")", "GetTitleAlignOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "c", "==", "nil", "||", "c", ".", "TitleAlign", "==", "nil", "{", "return", "\"", "\"", ",", "<mask>", "\n", "}", "\n", "return", "*", "c", ".", "TitleAlign", ",", "true", "\n", "}" ]
21,926
all-21927
[ "Handle", "appends", "message", "to", "Messages", "array", "." ]
[ "func", "(", "handler", "*", "MemoryHandler", ")", "Handle", "(", "record", "*", "Record", ")", "error", "{", "handler", ".", "lock", ".", "Lock", "(", ")", "\n", "handler", ".", "Messages", "=", "append", "(", "handler", ".", "Messages", ",", "<mask>", ".", "Formatter", ".", "Format", "(", "record", ")", ")", "\n", "handler", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "nil", "\n", "}" ]
21,927
all-21928
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "RemoveDOMStorageItemParams", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoDomstorage2", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
21,928
all-21929
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventResourceChangedPriority", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork49", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
21,929
all-21930
[ "Resolve", "resolves", "the", "URL", "host", "to", "its", "IP", "address", ".", "It", "s", "a", "shortcut", "for", "Parse", "()", "and", "Resolve", "()", "funcs", "." ]
[ "func", "ResolveString", "(", "rawURL", "string", ")", "(", "*", "<mask>", ".", "IPAddr", ",", "error", ")", "{", "u", ",", "err", ":=", "Parse", "(", "rawURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "Resolve", "(", "u", ")", "\n", "}" ]
21,930
all-21931
[ "SetFinishedAt", "sets", "the", "timestamp", "for", "container", "s", "stopped", "time" ]
[ "func", "(", "c", "*", "Container", ")", "SetFinishedAt", "(", "finishedAt", "time", ".", "Time", ")", "{", "if", "finishedAt", ".", "IsZero", "(", ")", "{", "return", "\n", "}", "\n\n", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "<mask>", ".", "Unlock", "(", ")", "\n\n", "c", ".", "finishedAt", "=", "finishedAt", "\n", "}" ]
21,931
all-21932
[ "UpdateLoadbalancer", "updates", "a", "load", "balancer" ]
[ "func", "(", "c", "*", "Client", ")", "UpdateLoadbalancer", "(", "dcid", "string", ",", "lbalid", "string", ",", "obj", "LoadbalancerProperties", ")", "(", "*", "Loadbalancer", ",", "error", ")", "{", "url", ":=", "lbalPath", "(", "dcid", ",", "lbalid", ")", "+", "`?depth=`", "+", "c", ".", "client", ".", "depth", "+", "`&pretty=`", "+", "strconv", ".", "FormatBool", "(", "c", ".", "client", ".", "pretty", ")", "\n", "ret", ":=", "&", "Loadbalancer", "{", "}", "\n", "err", ":=", "c", ".", "client", ".", "Patch", "(", "<mask>", ",", "obj", ",", "ret", ",", "http", ".", "StatusAccepted", ")", "\n", "return", "ret", ",", "err", "\n", "}" ]
21,932
all-21933
[ "StoragePoolVolumeCreate", "creates", "a", "new", "storage", "volume", "attached", "to", "a", "given", "storage", "pool", "." ]
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumeCreate", "(", "project", ",", "volumeName", ",", "volumeDescription", "string", ",", "volumeType", "int", ",", "snapshot", "bool", ",", "poolID", "int64", ",", "volumeConfig", "map", "[", "string", "]", "string", ")", "(", "int64", ",", "error", ")", "{", "var", "thisVolumeID", "int64", "\n\n", "err", ":=", "c", ".", "Transaction", "(", "func", "(", "tx", "*", "ClusterTx", ")", "error", "{", "nodeIDs", ":=", "[", "]", "int", "{", "int", "(", "c", ".", "nodeID", ")", "}", "\n", "driver", ",", "err", ":=", "storagePoolDriverGet", "(", "tx", ".", "tx", ",", "poolID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "// If the driver is ceph, create a volume entry for each node.", "if", "driver", "==", "\"", "\"", "{", "nodeIDs", ",", "err", "=", "query", ".", "SelectIntegers", "(", "tx", ".", "tx", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "for", "_", ",", "nodeID", ":=", "range", "nodeIDs", "{", "result", ",", "err", ":=", "tx", ".", "tx", ".", "Exec", "(", "`\nINSERT INTO storage_volumes (storage_pool_id, node_id, type, snapshot, name, description, project_id) VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM projects WHERE name = ?))\n`", ",", "poolID", ",", "nodeID", ",", "volumeType", ",", "snapshot", ",", "volumeName", ",", "volumeDescription", ",", "project", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "volumeID", ",", "err", ":=", "result", ".", "LastInsertId", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "int64", "(", "nodeID", ")", "==", "c", ".", "nodeID", "{", "// Return the ID of the volume created on this node.", "thisVolumeID", "=", "volumeID", "\n", "}", "\n\n", "err", "=", "StorageVolumeConfigAdd", "(", "tx", ".", "<mask>", ",", "volumeID", ",", "volumeConfig", ")", "\n", "if", "err", "!=", "nil", "{", "tx", ".", "tx", ".", "Rollback", "(", ")", "\n", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "thisVolumeID", "=", "-", "1", "\n", "}", "\n\n", "return", "thisVolumeID", ",", "err", "\n", "}" ]
21,933
all-21934
[ "DisableRule", "disables", "specific", "rule", "." ]
[ "func", "(", "s", "*", "Seekret", ")", "DisableRule", "(", "name", "string", ")", "error", "{", "return", "setRuleEnabled", "(", "s", ".", "ruleList", ",", "<mask>", ",", "false", ")", "\n", "}" ]
21,934
all-21935
[ "Do", "executes", "Network", ".", "setExtraHTTPHeaders", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "SetExtraHTTPHeadersParams", ")", "Do", "(", "ctx", "context", ".", "<mask>", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetExtraHTTPHeaders", ",", "p", ",", "nil", ")", "\n", "}" ]
21,935
all-21936
[ "Validate", "ensures", "that", "the", "set", "of", "options", "are", "self", "-", "consistent", "and", "valid" ]
[ "func", "(", "o", "*", "Options", ")", "Validate", "(", ")", "error", "{", "if", "o", ".", "ProcessLog", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "o", ".", "MarkerFile", "==", "\"", "\"", "{", "return", "<mask>", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
21,936
all-21937
[ "Encrypt", "encrypts", "the", "given", "text", "with", "a", "hard", "-", "coded", "secret", ".", "Not", "truly", "secure", "." ]
[ "func", "Encrypt", "(", "text", "string", ")", "(", "string", ",", "error", ")", "{", "bytes", ":=", "[", "]", "byte", "(", "text", ")", "\n", "key", ":=", "seekret", "(", ")", "\n", "block", ",", "err", ":=", "aes", ".", "NewCipher", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "b", ":=", "encodeBase64", "(", "bytes", ")", "\n", "ciphertext", ":=", "make", "(", "[", "]", "byte", ",", "aes", ".", "BlockSize", "+", "len", "(", "b", ")", ")", "\n", "iv", ":=", "ciphertext", "[", ":", "aes", ".", "BlockSize", "]", "\n", "if", "_", ",", "err", ":=", "<mask>", ".", "ReadFull", "(", "rand", ".", "Reader", ",", "iv", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "cfb", ":=", "cipher", ".", "NewCFBEncrypter", "(", "block", ",", "iv", ")", "\n", "cfb", ".", "XORKeyStream", "(", "ciphertext", "[", "aes", ".", "BlockSize", ":", "]", ",", "b", ")", "\n", "return", "string", "(", "encodeBase64", "(", "ciphertext", ")", ")", ",", "nil", "\n", "}" ]
21,937
all-21938
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "EventCacheStorageListUpdated", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoStorage9", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
21,938
all-21939
[ "NewHelperMap", "containing", "all", "of", "the", "default", "helpers", "from", "plush", ".", "Helpers", "." ]
[ "func", "NewHelperMap", "(", ")", "(", "HelperMap", ",", "error", ")", "{", "hm", ":=", "HelperMap", "{", "helpers", ":", "map", "[", "string", "]", "<mask>", "{", "}", "{", "}", ",", "moot", ":", "&", "sync", ".", "Mutex", "{", "}", ",", "}", "\n\n", "err", ":=", "hm", ".", "AddMany", "(", "Helpers", ".", "Helpers", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "hm", ",", "err", "\n", "}", "\n", "return", "hm", ",", "nil", "\n", "}" ]
21,939
all-21940
[ "Open", "returns", "a", "fresh", "file", "for", "writing", ".", "Rename", "the", "file", "before", "calling", "Open", "again", "or", "there", "will", "be", "file", "collisions", "." ]
[ "func", "(", "fp", "*", "filePipeline", ")", "Open", "(", ")", "(", "f", "*", "fileutil", ".", "LockedFile", ",", "err", "error", ")", "{", "select", "{", "<mask>", "f", "=", "<-", "fp", ".", "filec", ":", "case", "err", "=", "<-", "fp", ".", "errc", ":", "}", "\n", "return", "f", ",", "err", "\n", "}" ]
21,940
all-21941
[ "Metric", "will", "query", "current", "metric", "for", "target", "resource", "type", ".", "Return", "a", "common", ".", "Metric", "object", "on", "success", "." ]
[ "func", "(", "c", "*", "<mask>", ")", "Metric", "(", "rtype", "string", ")", "(", "common", ".", "Metric", ",", "error", ")", "{", "return", "c", ".", "metric", "(", "rtype", ")", "\n", "}" ]
21,941
all-21942
[ "typeName", "returns", "a", "string", "representing", "the", "type", "of", "this", "object", "." ]
[ "func", "typeName", "(", "c", "*", "gocore", ".", "Process", ",", "x", "gocore", ".", "Object", ")", "string", "{", "size", ":=", "c", ".", "Size", "(", "x", ")", "\n", "typ", ",", "repeat", ":=", "c", ".", "Type", "(", "x", ")", "\n", "if", "typ", "==", "nil", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "size", ")", "\n", "}", "\n", "name", ":=", "typ", ".", "String", "(", ")", "\n", "n", ":=", "size", "/", "typ", ".", "Size", "\n", "if", "n", ">", "1", "{", "if", "repeat", "<", "n", "{", "name", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "repeat", ",", "n", "-", "repeat", ",", "name", ")", "\n", "}", "else", "{", "name", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "repeat", ",", "name", ")", "\n", "}", "\n", "}", "\n", "return", "<mask>", "\n", "}" ]
21,942
all-21943
[ "ReadOnly", "tells", "whether", "or", "not", "the", "VM", "is", "read", "-", "only", "." ]
[ "func", "(", "v", "*", "VM", ")", "ReadOnly", "(", ")", "(", "bool", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "readonly", ":=", "C", ".", "VIX_PROPERTY_NONE", "\n\n", "err", "=", "C", ".", "get_property", "(", "v", ".", "handle", ",", "C", ".", "VIX_PROPERTY_VM_READ_ONLY", ",", "unsafe", ".", "Pointer", "(", "&", "readonly", ")", ")", "\n\n", "if", "C", ".", "VIX_OK", "!=", "err", "{", "return", "<mask>", ",", "&", "Error", "{", "Operation", ":", "\"", "\"", ",", "Code", ":", "int", "(", "err", "&", "0xFFFF", ")", ",", "Text", ":", "C", ".", "GoString", "(", "C", ".", "Vix_GetErrorText", "(", "err", ",", "nil", ")", ")", ",", "}", "\n", "}", "\n\n", "if", "readonly", "==", "0", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "return", "true", ",", "nil", "\n", "}" ]
21,943
all-21944
[ "ArmForSwitch", "returns", "which", "field", "name", "should", "be", "used", "for", "storing", "the", "value", "for", "an", "instance", "of", "BucketEntry" ]
[ "func", "(", "u", "BucketEntry", ")", "ArmForSwitch", "(", "sw", "int32", ")", "(", "string", ",", "bool", ")", "{", "switch", "BucketEntryType", "(", "sw", ")", "{", "case", "BucketEntryTypeLiveentry", ":", "return", "\"", "\"", ",", "true", "\n", "case", "BucketEntryTypeDeadentry", ":", "return", "\"", "\"", ",", "<mask>", "\n", "}", "\n", "return", "\"", "\"", ",", "false", "\n", "}" ]
21,944
all-21945
[ "CloudAccountLocator", "builds", "a", "locator", "from", "the", "given", "href", "." ]
[ "func", "(", "api", "*", "API", ")", "CloudAccountLocator", "(", "href", "<mask>", ")", "*", "CloudAccountLocator", "{", "return", "&", "CloudAccountLocator", "{", "Href", "(", "href", ")", ",", "api", "}", "\n", "}" ]
21,945
all-21946
[ "Execute", "returns", "an", "Error", "LintResult", "if", "the", "certificate", "is", "not", "an", "EV", "certificate", ".", "CheckApplies", "has", "already", "verified", "the", "certificate", "contains", "one", "or", "more", ".", "onion", "subjects", "and", "so", "it", "must", "be", "an", "EV", "certificate", "." ]
[ "func", "(", "l", "*", "onionNotEV", ")", "Execute", "(", "c", "*", "x509", ".", "Certificate", ")", "*", "LintResult", "{", "/*\n\t * Effective May 1, 2015, each CA SHALL revoke all unexpired Certificates with an\n\t * Internal Name using onion as the right-most label in an entry in the\n\t * subjectAltName Extension or commonName field unless such Certificate was\n\t * issued in accordance with Appendix F of the EV Guidelines.\n\t */", "if", "!", "util", ".", "IsEV", "(", "c", ".", "PolicyIdentifiers", ")", "{", "return", "&", "LintResult", "{", "Status", ":", "Error", ",", "Details", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "onionTLD", ")", ",", "}", "\n", "}", "\n", "return", "&", "LintResult", "{", "<mask>", ":", "Pass", "}", "\n", "}" ]
21,946
all-21947
[ "Initialize", "fills", "the", "resource", "fileds" ]
[ "func", "(", "cgroup", "*", "CgroupResource", ")", "Initialize", "(", "resourceFields", "*", "taskresource", ".", "ResourceFields", ",", "taskKnownStatus", "status", ".", "TaskStatus", ",", "taskDesiredStatus", "<mask>", ".", "TaskStatus", ")", "{", "}" ]
21,947
all-21948
[ "Remove", "is", "a", "wrapper", "around", "gtk_tree_store_remove", "()", "." ]
[ "func", "(", "v", "*", "TreeStore", ")", "Remove", "(", "iter", "*", "TreeIter", ")", "bool", "{", "<mask>", "ti", "*", "C", ".", "GtkTreeIter", "\n", "if", "iter", "!=", "nil", "{", "ti", "=", "iter", ".", "native", "(", ")", "\n", "}", "\n", "return", "0", "!=", "C", ".", "gtk_tree_store_remove", "(", "v", ".", "native", "(", ")", ",", "ti", ")", "\n", "}" ]
21,948
all-21949
[ "===", "histogram_quantile", "(", "k", "ValueTypeScalar", "Vector", "ValueTypeVector", ")", "Vector", "===" ]
[ "func", "funcHistogramQuantile", "(", "vals", "[", "]", "Value", ",", "args", "Expressions", ",", "enh", "*", "EvalNodeHelper", ")", "Vector", "{", "q", ":=", "vals", "[", "0", "]", ".", "(", "Vector", ")", "[", "0", "]", ".", "V", "\n", "inVec", ":=", "vals", "[", "1", "]", ".", "(", "Vector", ")", "\n", "sigf", ":=", "enh", ".", "signatureFunc", "(", "false", ",", "excludedLabels", "...", ")", "\n\n", "if", "enh", ".", "signatureToMetricWithBuckets", "==", "nil", "{", "enh", ".", "signatureToMetricWithBuckets", "=", "map", "[", "uint64", "]", "*", "metricWithBuckets", "{", "}", "\n", "}", "else", "{", "for", "_", ",", "v", ":=", "range", "enh", ".", "signatureToMetricWithBuckets", "{", "v", ".", "buckets", "=", "v", ".", "buckets", "[", ":", "0", "]", "\n", "}", "\n", "}", "\n", "for", "_", ",", "el", ":=", "range", "inVec", "{", "upperBound", ",", "err", ":=", "strconv", ".", "ParseFloat", "(", "el", ".", "Metric", ".", "Get", "(", "model", ".", "BucketLabel", ")", ",", "64", ",", ")", "\n", "if", "err", "!=", "nil", "{", "// Oops, no bucket label or malformed label value. Skip.", "// TODO(beorn7): Issue a warning somehow.", "continue", "\n", "}", "\n", "hash", ":=", "sigf", "(", "el", ".", "Metric", ")", "\n\n", "mb", ",", "ok", ":=", "enh", ".", "signatureToMetricWithBuckets", "[", "hash", "]", "\n", "if", "!", "ok", "{", "el", ".", "Metric", "=", "labels", ".", "NewBuilder", "(", "el", ".", "Metric", ")", ".", "Del", "(", "labels", ".", "BucketLabel", ",", "labels", ".", "MetricName", ")", ".", "Labels", "(", ")", "\n\n", "mb", "=", "&", "metricWithBuckets", "{", "el", ".", "Metric", ",", "nil", "}", "\n", "enh", ".", "signatureToMetricWithBuckets", "[", "hash", "]", "=", "mb", "\n", "}", "\n", "mb", ".", "buckets", "=", "append", "(", "<mask>", ".", "buckets", ",", "bucket", "{", "upperBound", ",", "el", ".", "V", "}", ")", "\n", "}", "\n\n", "for", "_", ",", "mb", ":=", "range", "enh", ".", "signatureToMetricWithBuckets", "{", "if", "len", "(", "mb", ".", "buckets", ")", ">", "0", "{", "enh", ".", "out", "=", "append", "(", "enh", ".", "out", ",", "Sample", "{", "Metric", ":", "mb", ".", "metric", ",", "Point", ":", "Point", "{", "V", ":", "bucketQuantile", "(", "q", ",", "mb", ".", "buckets", ")", "}", ",", "}", ")", "\n", "}", "\n", "}", "\n\n", "return", "enh", ".", "out", "\n", "}" ]
21,949
all-21950
[ "NewURLsMapFromStringMap", "takes", "a", "map", "of", "strings", "and", "returns", "a", "URLsMap", ".", "The", "string", "values", "in", "the", "map", "can", "be", "multiple", "values", "separated", "by", "the", "sep", "string", "." ]
[ "func", "NewURLsMapFromStringMap", "(", "m", "<mask>", "[", "string", "]", "string", ",", "sep", "string", ")", "(", "URLsMap", ",", "error", ")", "{", "var", "err", "error", "\n", "um", ":=", "URLsMap", "{", "}", "\n", "for", "k", ",", "v", ":=", "range", "m", "{", "um", "[", "k", "]", ",", "err", "=", "NewURLs", "(", "strings", ".", "Split", "(", "v", ",", "sep", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "return", "um", ",", "nil", "\n", "}" ]
21,950
all-21951
[ "CCAddrs", "returns", "a", "copy", "of", "MailBuilder", "with", "the", "specified", "CC", "addresses", "." ]
[ "func", "(", "p", "MailBuilder", ")", "CCAddrs", "(", "<mask>", "[", "]", "mail", ".", "Address", ")", "MailBuilder", "{", "p", ".", "cc", "=", "cc", "\n", "return", "p", "\n", "}" ]
21,951
all-21952
[ "FieldColumns", "converts", "thegiven", "fields", "to", "list", "of", "column", "names", "separated", "by", "a", "comma", "." ]
[ "func", "FieldColumns", "(", "fields", "[", "]", "*", "<mask>", ")", "string", "{", "columns", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "fields", ")", ")", "\n\n", "for", "i", ",", "field", ":=", "range", "fields", "{", "columns", "[", "i", "]", "=", "field", ".", "Column", "(", ")", "\n", "}", "\n\n", "return", "strings", ".", "Join", "(", "columns", ",", "\"", "\"", ")", "\n", "}" ]
21,952
all-21953
[ "Get", "the", "address", "given", "a", "URL" ]
[ "func", "getAddress", "(", "rawURL", "string", ")", "string", "{", "parsedURL", ",", "err", ":=", "<mask>", ".", "Parse", "(", "rawURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n\n", "splitHost", ":=", "strings", ".", "Split", "(", "parsedURL", ".", "Host", ",", "\"", "\"", ")", "\n", "return", "splitHost", "[", "0", "]", "\n", "}" ]
21,953
all-21954
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "StartRuleUsageTrackingParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss8", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
21,954
all-21955
[ "Save", "fetches", "snapshot", "from", "remote", "etcd", "server", "and", "saves", "data", "to", "target", "path", "." ]
[ "func", "(", "s", "*", "v3Manager", ")", "Save", "(", "ctx", "context", ".", "Context", ",", "cfg", "clientv3", ".", "Config", ",", "dbPath", "string", ")", "error", "{", "if", "len", "(", "cfg", ".", "Endpoints", ")", "!=", "1", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "cfg", ".", "Endpoints", ")", "\n", "}", "\n", "cli", ",", "err", ":=", "clientv3", ".", "New", "(", "cfg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "cli", ".", "Close", "(", ")", "\n\n", "partpath", ":=", "dbPath", "+", "\"", "\"", "\n", "defer", "os", ".", "RemoveAll", "(", "partpath", ")", "\n\n", "<mask>", "f", "*", "os", ".", "File", "\n", "f", ",", "err", "=", "os", ".", "OpenFile", "(", "partpath", ",", "os", ".", "O_WRONLY", "|", "os", ".", "O_CREATE", "|", "os", ".", "O_TRUNC", ",", "fileutil", ".", "PrivateFileMode", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "partpath", ",", "err", ")", "\n", "}", "\n", "s", ".", "lg", ".", "Info", "(", "\"", "\"", ",", "zap", ".", "String", "(", "\"", "\"", ",", "partpath", ")", ",", ")", "\n\n", "now", ":=", "time", ".", "Now", "(", ")", "\n", "var", "rd", "io", ".", "ReadCloser", "\n", "rd", ",", "err", "=", "cli", ".", "Snapshot", "(", "ctx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "s", ".", "lg", ".", "Info", "(", "\"", "\"", ",", "zap", ".", "String", "(", "\"", "\"", ",", "cfg", ".", "Endpoints", "[", "0", "]", ")", ",", ")", "\n", "if", "_", ",", "err", "=", "io", ".", "Copy", "(", "f", ",", "rd", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", "=", "fileutil", ".", "Fsync", "(", "f", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", "=", "f", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "s", ".", "lg", ".", "Info", "(", "\"", "\"", ",", "zap", ".", "String", "(", "\"", "\"", ",", "cfg", ".", "Endpoints", "[", "0", "]", ")", ",", "zap", ".", "Duration", "(", "\"", "\"", ",", "time", ".", "Since", "(", "now", ")", ")", ",", ")", "\n\n", "if", "err", "=", "os", ".", "Rename", "(", "partpath", ",", "dbPath", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "partpath", ",", "dbPath", ",", "err", ")", "\n", "}", "\n", "s", ".", "lg", ".", "Info", "(", "\"", "\"", ",", "zap", ".", "String", "(", "\"", "\"", ",", "dbPath", ")", ")", "\n", "return", "nil", "\n", "}" ]
21,955
all-21956
[ "Stop", "gracefully", "shutsdown", "the", "producer", "cancelling", "all", "inflight", "requests", "and", "waiting", "for", "all", "backend", "connections", "to", "be", "closed", ".", "It", "is", "safe", "to", "call", "the", "method", "multiple", "times", "and", "from", "multiple", "goroutines", "they", "will", "all", "block", "until", "the", "producer", "has", "been", "completely", "shutdown", "." ]
[ "func", "(", "p", "*", "Producer", ")", "Stop", "(", ")", "{", "p", ".", "once", ".", "Do", "(", "p", ".", "<mask>", ")", "\n", "err", ":=", "errors", ".", "New", "(", "\"", "\"", ")", "\n\n", "for", "req", ":=", "range", "p", ".", "reqs", "{", "req", ".", "complete", "(", "err", ")", "\n", "}", "\n\n", "p", ".", "join", ".", "Wait", "(", ")", "\n", "}" ]
21,956
all-21957
[ "HasLogQuery", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "c", "*", "ChangeRequest", ")", "HasLogQuery", "(", ")", "bool", "{", "if", "c", "!=", "nil", "&&", "c", ".", "LogQuery", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
21,957
all-21958
[ "/", "*", "we", "can", "ran", "this", "as", "binary", "for", "unit", "tests", "(", "for", "example", "build", "it", "on", "on", "one", "machine", "(", "mac", "or", "win", ")", "and", "run", "on", "other", "(", "linux", ")", "probably", "later", "will", "convert", "into", "ipvs_test", ".", "go" ]
[ "func", "main", "(", ")", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "ipvs", ":=", "<mask>", "(", "gnl2go", ".", "IpvsClient", ")", "\n", "ipvs", ".", "Init", "(", ")", "\n", "defer", "ipvs", ".", "Exit", "(", ")", "\n", "data", ",", "_", ":=", "ipvs", ".", "GetAllStatsBrief", "(", ")", "\n", "for", "k", ",", "v", ":=", "range", "data", "{", "fmt", ".", "Println", "(", "k", ")", "\n", "stats", ":=", "v", ".", "GetStats", "(", ")", "\n", "for", "nk", ",", "nv", ":=", "range", "stats", "{", "fmt", ".", "Printf", "(", "\"", "\"", ",", "nk", ",", "nv", ")", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ")", "\n", "}", "\n", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "}" ]
21,958
all-21959
[ "Update", "a", "single", "image", ".", "The", "operation", "can", "be", "nil", "if", "no", "progress", "tracking", "is", "needed", ".", "Returns", "whether", "the", "image", "has", "been", "updated", "." ]
[ "func", "autoUpdateImage", "(", "d", "*", "Daemon", ",", "op", "*", "operation", ",", "id", "int", ",", "info", "*", "api", ".", "Image", ",", "project", "string", ")", "error", "{", "fingerprint", ":=", "info", ".", "Fingerprint", "\n", "_", ",", "source", ",", "err", ":=", "d", ".", "cluster", ".", "ImageSourceGet", "(", "id", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "fingerprint", "}", ")", "\n", "return", "err", "\n", "}", "\n\n", "// Get the IDs of all storage pools on which a storage volume", "// for the requested image currently exists.", "poolIDs", ",", "err", ":=", "d", ".", "cluster", ".", "ImageGetPools", "(", "fingerprint", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "fingerprint", "}", ")", "\n", "return", "err", "\n", "}", "\n\n", "// Translate the IDs to poolNames.", "poolNames", ",", "err", ":=", "d", ".", "cluster", ".", "ImageGetPoolNamesFromIDs", "(", "poolIDs", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "fingerprint", "}", ")", "\n", "return", "err", "\n", "}", "\n\n", "// If no optimized pools at least update the base store", "if", "len", "(", "poolNames", ")", "==", "0", "{", "poolNames", "=", "append", "(", "poolNames", ",", "\"", "\"", ")", "\n", "}", "\n\n", "logger", ".", "Debug", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "fingerprint", ",", "\"", "\"", ":", "source", ".", "Server", ",", "\"", "\"", ":", "source", ".", "Protocol", ",", "\"", "\"", ":", "source", ".", "Alias", "}", ")", "\n\n", "// Set operation metadata to indicate whether a refresh happened", "setRefreshResult", ":=", "func", "(", "result", "bool", ")", "{", "if", "op", "==", "nil", "{", "return", "\n", "}", "\n\n", "metadata", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "result", "}", "\n", "op", ".", "UpdateMetadata", "(", "metadata", ")", "\n", "}", "\n\n", "// Update the image on each pool where it currently exists.", "hash", ":=", "fingerprint", "\n", "for", "_", ",", "poolName", ":=", "range", "poolNames", "{", "newInfo", ",", "err", ":=", "d", ".", "ImageDownload", "(", "op", ",", "source", ".", "Server", ",", "source", ".", "Protocol", ",", "<mask>", ".", "Certificate", ",", "\"", "\"", ",", "source", ".", "Alias", ",", "false", ",", "true", ",", "poolName", ",", "false", ",", "project", ")", "\n\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "fingerprint", "}", ")", "\n", "continue", "\n", "}", "\n\n", "hash", "=", "newInfo", ".", "Fingerprint", "\n", "if", "hash", "==", "fingerprint", "{", "logger", ".", "Debug", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "fingerprint", "}", ")", "\n", "continue", "\n", "}", "\n\n", "newId", ",", "_", ",", "err", ":=", "d", ".", "cluster", ".", "ImageGet", "(", "\"", "\"", ",", "hash", ",", "false", ",", "true", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "hash", "}", ")", "\n", "continue", "\n", "}", "\n\n", "if", "info", ".", "Cached", "{", "err", "=", "d", ".", "cluster", ".", "ImageLastAccessInit", "(", "hash", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "hash", "}", ")", "\n", "continue", "\n", "}", "\n", "}", "\n\n", "err", "=", "d", ".", "cluster", ".", "ImageLastAccessUpdate", "(", "hash", ",", "info", ".", "LastUsedAt", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "hash", "}", ")", "\n", "continue", "\n", "}", "\n\n", "err", "=", "d", ".", "cluster", ".", "ImageAliasesMove", "(", "id", ",", "newId", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "hash", "}", ")", "\n", "continue", "\n", "}", "\n\n", "// If we do have optimized pools, make sure we remove", "// the volumes associated with the image.", "if", "poolName", "!=", "\"", "\"", "{", "err", "=", "doDeleteImageFromPool", "(", "d", ".", "State", "(", ")", ",", "fingerprint", ",", "poolName", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "\"", "\"", ",", "log", ".", "Ctx", "{", "\"", "\"", ":", "err", ",", "\"", "\"", ":", "fingerprint", "}", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// Image didn't change, nothing to do.", "if", "hash", "==", "fingerprint", "{", "setRefreshResult", "(", "false", ")", "\n", "return", "nil", "\n", "}", "\n\n", "// Remove main image file.", "fname", ":=", "filepath", ".", "Join", "(", "d", ".", "os", ".", "VarDir", ",", "\"", "\"", ",", "fingerprint", ")", "\n", "if", "shared", ".", "PathExists", "(", "fname", ")", "{", "err", "=", "os", ".", "Remove", "(", "fname", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "fname", ",", "err", ")", "\n", "}", "\n", "}", "\n\n", "// Remove the rootfs file for the image.", "fname", "=", "filepath", ".", "Join", "(", "d", ".", "os", ".", "VarDir", ",", "\"", "\"", ",", "fingerprint", ")", "+", "\"", "\"", "\n", "if", "shared", ".", "PathExists", "(", "fname", ")", "{", "err", "=", "os", ".", "Remove", "(", "fname", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "fname", ",", "err", ")", "\n", "}", "\n", "}", "\n\n", "// Remove the database entry for the image.", "if", "err", "=", "d", ".", "cluster", ".", "ImageDelete", "(", "id", ")", ";", "err", "!=", "nil", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "fname", ",", "err", ")", "\n", "}", "\n\n", "setRefreshResult", "(", "true", ")", "\n", "return", "nil", "\n", "}" ]
21,959
all-21960
[ "setPreviousReportState", "sets", "the", "github", "key", "for", "PrevReportStates", "to", "current", "state", ".", "This", "is", "a", "work", "-", "around", "for", "plank", "-", ">", "crier", "migration", "to", "become", "seamless", "." ]
[ "func", "(", "c", "*", "Controller", ")", "setPreviousReportState", "(", "pj", "prowapi", ".", "ProwJob", ")", "error", "{", "// fetch latest before replace", "latestPJ", ",", "err", ":=", "c", ".", "kc", ".", "GetProwJob", "(", "pj", ".", "ObjectMeta", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "latestPJ", ".", "<mask>", ".", "PrevReportStates", "==", "nil", "{", "latestPJ", ".", "Status", ".", "PrevReportStates", "=", "map", "[", "string", "]", "prowapi", ".", "ProwJobState", "{", "}", "\n", "}", "\n", "latestPJ", ".", "Status", ".", "PrevReportStates", "[", "reporter", ".", "GitHubReporterName", "]", "=", "latestPJ", ".", "Status", ".", "State", "\n", "_", ",", "err", "=", "c", ".", "kc", ".", "ReplaceProwJob", "(", "latestPJ", ".", "ObjectMeta", ".", "Name", ",", "latestPJ", ")", "\n", "return", "err", "\n", "}" ]
21,960
all-21961
[ "AccelGroupsActivate", "is", "a", "wrapper", "around", "gtk_accel_groups_activate", "()", "." ]
[ "func", "AccelGroupsActivate", "(", "obj", "*", "glib", ".", "<mask>", ",", "key", "uint", ",", "mods", "gdk", ".", "ModifierType", ")", "bool", "{", "return", "gobool", "(", "C", ".", "gtk_accel_groups_activate", "(", "(", "*", "C", ".", "GObject", ")", "(", "unsafe", ".", "Pointer", "(", "obj", ".", "Native", "(", ")", ")", ")", ",", "C", ".", "guint", "(", "key", ")", ",", "C", ".", "GdkModifierType", "(", "mods", ")", ")", ")", "\n", "}" ]
21,961
all-21962
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "SetTimeDomainParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoPerformance", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
21,962
all-21963
[ "retrieve", "the", "label", "of", "a", "named", "object", "identified", "within", "a", "namespace" ]
[ "func", "GetObjectLabel", "(", "identifier", "uint32", ",", "name", "uint32", ",", "bufSize", "int32", ",", "length", "*", "int32", ",", "<mask>", "*", "uint8", ")", "{", "syscall", ".", "Syscall6", "(", "gpGetObjectLabel", ",", "5", ",", "uintptr", "(", "identifier", ")", ",", "uintptr", "(", "name", ")", ",", "uintptr", "(", "bufSize", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "length", ")", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "label", ")", ")", ",", "0", ")", "\n", "}" ]
21,963
all-21964
[ "SafeCreate", "creates", "a", "file", "creating", "parent", "directories", "if", "needed" ]
[ "func", "SafeCreate", "(", "name", "...", "string", ")", "(", "file", "*", "os", ".", "File", ",", "err", "error", ")", "{", "p", ",", "e", ":=", "ensurePath", "(", "path", ".", "Join", "(", "<mask>", "...", ")", ")", "\n\n", "if", "e", "!=", "nil", "{", "return", "nil", ",", "e", "\n", "}", "\n", "return", "os", ".", "Create", "(", "p", ")", "\n", "}" ]
21,964
all-21965
[ "Fetch", "the", "binary", "from", "the", "provided", "Repository" ]
[ "func", "(", "h", "*", "Github", ")", "Fetch", "(", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "//delay fetches after first", "if", "h", ".", "delay", "{", "time", ".", "Sleep", "(", "h", ".", "Interval", ")", "\n", "}", "\n", "h", ".", "delay", "=", "true", "\n", "//check release status", "resp", ",", "err", ":=", "http", ".", "Get", "(", "h", ".", "releaseURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "resp", ".", "StatusCode", ")", "\n", "}", "\n", "//clear assets", "h", ".", "latestRelease", ".", "Assets", "=", "nil", "\n", "if", "err", ":=", "json", ".", "NewDecoder", "(", "resp", ".", "Body", ")", ".", "Decode", "(", "&", "h", ".", "latestRelease", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "//find appropriate asset", "assetURL", ":=", "\"", "\"", "\n", "for", "_", ",", "a", ":=", "range", "h", ".", "latestRelease", ".", "Assets", "{", "if", "h", ".", "Asset", "(", "a", ".", "Name", ")", "{", "assetURL", "=", "a", ".", "URL", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "assetURL", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "h", ".", "latestRelease", ".", "TagName", ")", "\n", "}", "\n", "//fetch location", "req", ",", "_", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "assetURL", ",", "nil", ")", "\n", "resp", ",", "err", "=", "http", ".", "DefaultTransport", ".", "RoundTrip", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusFound", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "resp", ".", "StatusCode", ")", "\n", "}", "\n", "s3URL", ":=", "resp", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "//pseudo-HEAD request", "req", ",", "err", "=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "s3URL", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "req", ".", "<mask>", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "// HEAD not allowed so we request for 1 byte", "\n", "resp", ",", "err", "=", "http", ".", "DefaultTransport", ".", "RoundTrip", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusPartialContent", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "resp", ".", "StatusCode", ")", "\n", "}", "\n", "etag", ":=", "resp", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "if", "etag", "!=", "\"", "\"", "&&", "h", ".", "lastETag", "==", "etag", "{", "return", "nil", ",", "nil", "//skip, hash match", "\n", "}", "\n", "//get binary request", "resp", ",", "err", "=", "http", ".", "Get", "(", "s3URL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "if", "resp", ".", "StatusCode", "!=", "http", ".", "StatusOK", "{", "resp", ".", "Body", ".", "Close", "(", ")", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "resp", ".", "StatusCode", ")", "\n", "}", "\n", "h", ".", "lastETag", "=", "etag", "\n", "//success!", "//extract gz files", "if", "strings", ".", "HasSuffix", "(", "assetURL", ",", "\"", "\"", ")", "&&", "resp", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "return", "gzip", ".", "NewReader", "(", "resp", ".", "Body", ")", "\n", "}", "\n", "return", "resp", ".", "Body", ",", "nil", "\n", "}" ]
21,965
all-21966
[ "WithFunction", "adds", "a", "function", "to", "templates", "." ]
[ "func", "WithFunction", "(", "name", "string", ",", "fn", "interface", "{", "}", ")", "Option", "{", "return", "func", "(", "o", "*", "<mask>", ")", "{", "o", ".", "functions", "[", "name", "]", "=", "fn", "}", "\n", "}" ]
21,966
all-21967
[ "Describe", "implements", "prometheus", "Collector", "interface", "." ]
[ "func", "(", "c", "*", "Cache", ")", "Describe", "(", "in", "chan", "<-", "*", "prometheus", ".", "Desc", ")", "{", "c", ".", "hitsTotal", ".", "Describe", "(", "in", ")", "\n", "c", ".", "refreshTotal", ".", "Describe", "(", "in", ")", "\n", "c", ".", "missesTotal", ".", "Describe", "(", "<mask>", ")", "\n", "}" ]
21,967
all-21968
[ "AppendGzipBytesLevel", "appends", "gzipped", "src", "to", "dst", "using", "the", "given", "compression", "level", "and", "returns", "the", "resulting", "dst", ".", "Supported", "compression", "levels", "are", ":", "*", "CompressNoCompression", "*", "CompressBestSpeed", "*", "CompressBestCompression", "*", "CompressDefaultCompression", "*", "CompressHuffmanOnly" ]
[ "func", "AppendGzipBytesLevel", "(", "dst", ",", "src", "[", "]", "byte", ",", "level", "int", ")", "[", "]", "<mask>", "{", "w", ":=", "&", "byteSliceWriter", "{", "dst", "}", "\n", "WriteGzipLevel", "(", "w", ",", "src", ",", "level", ")", "\n", "return", "w", ".", "b", "\n", "}" ]
21,968
all-21969
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "SamplingHeapProfileNode", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoHeapprofiler7", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
21,969
all-21970
[ "GetModified", "returns", "the", "Modified", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "d", "*", "DashboardLite", ")", "GetModified", "(", ")", "<mask>", "{", "if", "d", "==", "nil", "||", "d", ".", "Modified", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "d", ".", "Modified", "\n", "}" ]
21,970
all-21971
[ "NewMemberRemoveCommand", "returns", "the", "cobra", "command", "for", "member", "remove", "." ]
[ "func", "NewMemberRemoveCommand", "(", ")", "*", "cobra", ".", "Command", "{", "cc", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"", "\"", ",", "Short", ":", "\"", "\"", ",", "Run", ":", "memberRemoveCommandFunc", ",", "}", "\n\n", "return", "<mask>", "\n", "}" ]
21,971
all-21972
[ "Md5", "functions" ]
[ "func", "(", "lo", "*", "largeObject", ")", "md5Content", "(", "r", "io", ".", "ReadSeeker", ")", "(", "string", ",", "string", ",", "error", ")", "{", "// #nosec G401", "h", ":=", "md5", ".", "New", "(", ")", "\n", "mw", ":=", "io", ".", "MultiWriter", "(", "h", ",", "lo", ".", "md5", ")", "\n", "if", "_", ",", "err", ":=", "io", ".", "Copy", "(", "mw", ",", "r", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "sum", ":=", "h", ".", "Sum", "(", "nil", ")", "\n", "hexSum", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "sum", ")", "\n", "// add to checksum of all parts for verification on upload completion", "if", "_", ",", "err", ":=", "lo", ".", "md5OfParts", ".", "Write", "(", "sum", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "base64", ".", "StdEncoding", ".", "EncodeToString", "(", "<mask>", ")", ",", "hexSum", ",", "nil", "\n", "}" ]
21,972
all-21973
[ "SetErrorHandler", "returns", "Middleware", "that", "can", "be", "used", "to", "set", "the", "error", "handler" ]
[ "func", "SetErrorHandler", "(", "status", "int", ",", "handler", "ErrorHandler", ")", "scaffold", ".", "Middleware", "{", "return", "scaffold", ".", "Middleware", "(", "func", "(", "next", "scaffold", ".", "Handler", ")", "scaffold", ".", "Handler", "{", "return", "scaffold", ".", "HandlerFunc", "(", "func", "(", "ctx", "context", ".", "Context", ",", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "key", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "<mask>", ")", "\n", "ctx", "=", "context", ".", "WithValue", "(", "ctx", ",", "key", ",", "handler", ")", "\n\n", "next", ".", "CtxServeHTTP", "(", "ctx", ",", "w", ",", "r", ")", "\n", "}", ")", "\n", "}", ")", "\n", "}" ]
21,973
all-21974
[ "GetQuery", "returns", "the", "Query", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "t", "*", "TileDefRequest", ")", "GetQuery", "(", ")", "string", "{", "if", "t", "==", "nil", "||", "t", ".", "<mask>", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "t", ".", "Query", "\n", "}" ]
21,974
all-21975
[ "GetId", "returns", "the", "Id", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "b", "*", "Board", ")", "GetId", "(", ")", "string", "{", "if", "b", "==", "nil", "||", "b", ".", "Id", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "b", ".", "<mask>", "\n", "}" ]
21,975
all-21976
[ "SubscribeByTopicDescriptor", "lets", "you", "subscribe", "a", "topic", "using", "a", "pb", ".", "TopicDescriptor", "." ]
[ "func", "(", "p", "*", "PubSub", ")", "SubscribeByTopicDescriptor", "(", "td", "*", "pb", ".", "TopicDescriptor", ",", "opts", "...", "SubOpt", ")", "(", "*", "Subscription", ",", "error", ")", "{", "if", "td", ".", "GetAuth", "(", ")", ".", "GetMode", "(", ")", "!=", "pb", ".", "TopicDescriptor_AuthOpts_NONE", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "td", ".", "GetEnc", "(", ")", ".", "GetMode", "(", ")", "!=", "pb", ".", "TopicDescriptor_EncOpts_NONE", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "sub", ":=", "&", "Subscription", "{", "topic", ":", "td", ".", "GetName", "(", ")", ",", "}", "\n\n", "for", "_", ",", "<mask>", ":=", "range", "opts", "{", "err", ":=", "opt", "(", "sub", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "out", ":=", "make", "(", "chan", "*", "Subscription", ",", "1", ")", "\n", "p", ".", "addSub", "<-", "&", "addSubReq", "{", "sub", ":", "sub", ",", "resp", ":", "out", ",", "}", "\n\n", "return", "<-", "out", ",", "nil", "\n", "}" ]
21,976
all-21977
[ "returns", "dialer", "that", "can", "dial", "the", "given", "address" ]
[ "func", "(", "d", "*", "Dialer", ")", "subDialerForAddr", "(", "raddr", "ma", ".", "Multiaddr", ")", "transport", ".", "Dialer", "{", "for", "_", ",", "pd", ":=", "<mask>", "d", ".", "Dialers", "{", "if", "pd", ".", "Matches", "(", "raddr", ")", "{", "return", "pd", "\n", "}", "\n", "}", "\n\n", "if", "d", ".", "fallback", ".", "Matches", "(", "raddr", ")", "{", "return", "d", ".", "fallback", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
21,977
all-21978
[ "Stop", "halts", "the", "execution", "of", "this", "runner", "and", "its", "subprocesses", "." ]
[ "func", "(", "r", "*", "<mask>", ")", "Stop", "(", ")", "{", "r", ".", "stopLock", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "stopLock", ".", "Unlock", "(", ")", "\n\n", "if", "r", ".", "stopped", "{", "return", "\n", "}", "\n\n", "log", ".", "Printf", "(", "\"", "\"", ")", "\n", "r", ".", "stopDedup", "(", ")", "\n", "r", ".", "stopWatcher", "(", ")", "\n", "r", ".", "stopChild", "(", ")", "\n\n", "if", "err", ":=", "r", ".", "deletePid", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "r", ".", "config", ".", "PidFile", ",", "err", ")", "\n", "}", "\n\n", "r", ".", "stopped", "=", "true", "\n\n", "close", "(", "r", ".", "DoneCh", ")", "\n", "}" ]
21,978
all-21979
[ "return", "parameters", "of", "a", "buffer", "object" ]
[ "func", "GetBufferParameteriv", "(", "target", "uint32", ",", "pname", "uint32", ",", "params", "*", "int32", ")", "{", "syscall", ".", "Syscall", "(", "gpGetBufferParameteriv", ",", "3", ",", "uintptr", "(", "<mask>", ")", ",", "uintptr", "(", "pname", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "params", ")", ")", ")", "\n", "}" ]
21,979
all-21980
[ "ParseRate", "is", "a", "helper", "function", "to", "get", "all", "the", "Rate", "info" ]
[ "func", "ParseRate", "(", "resp", "*", "http", ".", "Response", ")", "*", "RateLimit", "{", "limit", ":=", "resp", ".", "Header", ".", "Get", "(", "headerRateLimit", ")", "\n", "<mask>", ":=", "resp", ".", "Header", ".", "Get", "(", "headerRatePath", ")", "\n", "remain", ":=", "resp", ".", "Header", ".", "Get", "(", "headerRateRemaining", ")", "\n\n", "l", ",", "_", ":=", "strconv", ".", "Atoi", "(", "limit", ")", "\n", "r", ",", "_", ":=", "strconv", ".", "Atoi", "(", "remain", ")", "\n\n", "return", "&", "RateLimit", "{", "Limit", ":", "l", ",", "Path", ":", "path", ",", "Remaining", ":", "r", ",", "}", "\n", "}" ]
21,980
all-21981
[ "DeviceListString", "pretty", "-", "prints", "each", "device", "in", "a", "virtual", "device", "list", "used", "for", "logging", "purposes", "and", "what", "not", "." ]
[ "func", "DeviceListString", "(", "l", "object", ".", "VirtualDeviceList", ")", "string", "{", "var", "names", "[", "]", "string", "\n", "for", "_", ",", "d", ":=", "range", "l", "{", "if", "d", "==", "nil", "{", "names", "=", "append", "(", "names", ",", "\"", "\"", ")", "\n", "}", "else", "{", "names", "=", "append", "(", "names", ",", "l", ".", "<mask>", "(", "d", ")", ")", "\n", "}", "\n", "}", "\n", "return", "strings", ".", "Join", "(", "names", ",", "\"", "\"", ")", "\n", "}" ]
21,981
all-21982
[ "Insert", "marks", "this", "statement", "for", "insertion", "at", "the", "given", "index", ".", "If", "multiple", "statements", "are", "inserted", "at", "the", "same", "index", "they", "will", "be", "inserted", "in", "the", "order", "Insert", "is", "called", "." ]
[ "func", "(", "l", "*", "Load", ")", "Insert", "(", "f", "*", "File", ",", "index", "int", ")", "{", "l", ".", "index", "=", "index", "\n", "l", ".", "inserted", "=", "<mask>", "\n", "f", ".", "Loads", "=", "append", "(", "f", ".", "Loads", ",", "l", ")", "\n", "}" ]
21,982
all-21983
[ "GetInt", "returns", "int", "value", "for", "the", "given", "key" ]
[ "func", "(", "c", "GConfig", ")", "GetInt", "(", "key", "string", ")", "int", "{", "i", ",", "_", ":=", "strconv", ".", "Atoi", "(", "c", ".", "getStringValue", "(", "<mask>", ")", ")", "\n", "return", "i", "\n", "}" ]
21,983
all-21984
[ "HandleEvent", "handles", "a", "GitHub", "PR", "event", "to", "determine", "if", "the", "needs", "-", "rebase", "label", "needs", "to", "be", "added", "or", "removed", ".", "It", "depends", "on", "GitHub", "mergeability", "check", "to", "decide", "the", "need", "for", "a", "rebase", "." ]
[ "func", "HandleEvent", "(", "log", "*", "logrus", ".", "Entry", ",", "ghc", "githubClient", ",", "pre", "*", "github", ".", "PullRequestEvent", ")", "error", "{", "if", "pre", ".", "Action", "!=", "github", ".", "PullRequestActionOpened", "&&", "pre", ".", "Action", "!=", "github", ".", "PullRequestActionSynchronize", "&&", "pre", ".", "Action", "!=", "github", ".", "PullRequestActionReopened", "{", "return", "nil", "\n", "}", "\n\n", "// Before checking mergeability wait a few seconds to give github a chance to calculate it.", "// This initial delay prevents us from always wasting the first API token.", "sleep", "(", "time", ".", "Second", "*", "5", ")", "\n\n", "org", ":=", "pre", ".", "Repo", ".", "Owner", ".", "Login", "\n", "repo", ":=", "pre", ".", "Repo", ".", "Name", "\n", "<mask>", ":=", "pre", ".", "Number", "\n", "sha", ":=", "pre", ".", "PullRequest", ".", "Head", ".", "SHA", "\n\n", "mergeable", ",", "err", ":=", "ghc", ".", "IsMergeable", "(", "org", ",", "repo", ",", "number", ",", "sha", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "issueLabels", ",", "err", ":=", "ghc", ".", "GetIssueLabels", "(", "org", ",", "repo", ",", "number", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "hasLabel", ":=", "github", ".", "HasLabel", "(", "labels", ".", "NeedsRebase", ",", "issueLabels", ")", "\n\n", "return", "takeAction", "(", "log", ",", "ghc", ",", "org", ",", "repo", ",", "number", ",", "pre", ".", "PullRequest", ".", "User", ".", "Login", ",", "hasLabel", ",", "mergeable", ")", "\n", "}" ]
21,984
all-21985
[ "ClientAfterCooperativeClose", "changed", "channel", "status", "to", "closed", "cooperative", "and", "launches", "of", "terminate", "service", "procedure", "." ]
[ "func", "(", "w", "*", "Worker", ")", "ClientAfterCooperativeClose", "(", "job", "*", "data", ".", "Job", ")", "error", "{", "logger", ":=", "w", ".", "logger", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "job", ")", "\n\n", "ch", ",", "err", ":=", "w", ".", "relatedChannel", "(", "logger", ",", "job", ",", "data", ".", "JobClientAfterCooperativeClose", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "logger", "=", "logger", ".", "Add", "(", "\"", "\"", ",", "ch", ")", "\n\n", "ch", ".", "ChannelStatus", "=", "data", ".", "ChannelClosedCoop", "\n", "if", "err", ":=", "w", ".", "saveRecord", "(", "logger", ",", "w", ".", "db", ".", "Querier", ",", "ch", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "ch", ".", "ServiceStatus", "!=", "<mask>", ".", "ServiceTerminated", "{", "_", ",", "err", "=", "w", ".", "processor", ".", "TerminateChannel", "(", "ch", ".", "ID", ",", "data", ".", "JobTask", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "err", ".", "Error", "(", ")", ")", "\n", "return", "ErrTerminateChannel", "\n", "}", "\n", "}", "\n\n", "client", ",", "err", ":=", "w", ".", "account", "(", "logger", ",", "ch", ".", "Client", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "w", ".", "addJob", "(", "logger", ",", "nil", ",", "data", ".", "JobAccountUpdateBalances", ",", "data", ".", "JobAccount", ",", "client", ".", "ID", ")", "\n", "}" ]
21,985
all-21986
[ "Initialize", "for", "sending", "metrics" ]
[ "func", "(", "cm", "*", "CheckManager", ")", "Initialize", "(", ")", "{", "// if not managing the check, quicker initialization", "if", "!", "cm", ".", "enabled", "{", "err", ":=", "cm", ".", "initializeTrapURL", "(", ")", "\n", "if", "err", "==", "nil", "{", "cm", ".", "initializedmu", ".", "Lock", "(", ")", "\n", "cm", ".", "initialized", "=", "true", "\n", "cm", ".", "initializedmu", ".", "Unlock", "(", ")", "\n", "}", "else", "{", "cm", ".", "Log", ".", "Printf", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "return", "\n", "}", "\n\n", "// background initialization when we have to reach out to the api", "go", "func", "(", ")", "{", "cm", ".", "apih", ".", "EnableExponentialBackoff", "(", ")", "\n", "err", ":=", "cm", ".", "initializeTrapURL", "(", ")", "\n", "if", "err", "==", "nil", "{", "cm", ".", "initializedmu", ".", "Lock", "(", ")", "\n", "cm", ".", "initialized", "=", "<mask>", "\n", "cm", ".", "initializedmu", ".", "Unlock", "(", ")", "\n", "}", "else", "{", "cm", ".", "Log", ".", "Printf", "(", "\"", "\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "cm", ".", "apih", ".", "DisableExponentialBackoff", "(", ")", "\n", "}", "(", ")", "\n", "}" ]
21,986
all-21987
[ "NewBool", "creates", "a", "new", "Bool" ]
[ "func", "NewBool", "(", "b", "bool", ",", "valid", "bool", ")", "Bool", "{", "return", "Bool", "{", "NullBool", ":", "sql", ".", "NullBool", "{", "Bool", ":", "b", ",", "Valid", ":", "<mask>", ",", "}", ",", "}", "\n", "}" ]
21,987
all-21988
[ "AddStateChangeEvent", "queues", "up", "the", "state", "change", "event", "to", "be", "sent", "to", "ECS", ".", "If", "the", "event", "is", "for", "a", "container", "state", "change", "it", "just", "gets", "added", "to", "the", "handler", ".", "tasksToContainerStates", "map", ".", "If", "the", "event", "is", "for", "task", "state", "change", "it", "triggers", "the", "non", "-", "blocking", "handler", ".", "submitTaskEvents", "method", "to", "submit", "the", "batched", "container", "state", "changes", "and", "the", "task", "state", "change", "to", "ECS" ]
[ "func", "(", "<mask>", "*", "TaskHandler", ")", "AddStateChangeEvent", "(", "change", "statechange", ".", "Event", ",", "client", "api", ".", "ECSClient", ")", "error", "{", "handler", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "handler", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "switch", "change", ".", "GetEventType", "(", ")", "{", "case", "statechange", ".", "TaskEvent", ":", "event", ",", "ok", ":=", "change", ".", "(", "api", ".", "TaskStateChange", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "// Task event: gather all the container events and send them", "// to ECS by invoking the async submitTaskEvents method from", "// the sendable event list object", "handler", ".", "flushBatchUnsafe", "(", "&", "event", ",", "client", ")", "\n", "return", "nil", "\n\n", "case", "statechange", ".", "ContainerEvent", ":", "event", ",", "ok", ":=", "change", ".", "(", "api", ".", "ContainerStateChange", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "handler", ".", "batchContainerEventUnsafe", "(", "event", ")", "\n", "return", "nil", "\n\n", "default", ":", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
21,988
all-21989
[ "TemporaryDirectoryForBigFiles", "returns", "a", "directory", "for", "temporary", "(", "big", ")", "files", ".", "On", "non", "Windows", "systems", "it", "avoids", "the", "use", "of", "os", ".", "TempDir", "()", "because", "the", "default", "temporary", "directory", "usually", "falls", "under", "/", "tmp", "which", "on", "systemd", "based", "systems", "could", "be", "the", "unsuitable", "tmpfs", "filesystem", "." ]
[ "func", "TemporaryDirectoryForBigFiles", "(", ")", "string", "{", "<mask>", "temporaryDirectoryForBigFiles", "string", "\n", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "temporaryDirectoryForBigFiles", "=", "os", ".", "TempDir", "(", ")", "\n", "}", "else", "{", "temporaryDirectoryForBigFiles", "=", "unixTempDirForBigFiles", "\n", "}", "\n", "return", "temporaryDirectoryForBigFiles", "\n", "}" ]
21,989
all-21990
[ "bind", "stages", "of", "a", "program", "object", "to", "a", "program", "pipeline" ]
[ "func", "UseProgramStages", "(", "pipeline", "uint32", ",", "stages", "uint32", ",", "<mask>", "uint32", ")", "{", "C", ".", "glowUseProgramStages", "(", "gpUseProgramStages", ",", "(", "C", ".", "GLuint", ")", "(", "pipeline", ")", ",", "(", "C", ".", "GLbitfield", ")", "(", "stages", ")", ",", "(", "C", ".", "GLuint", ")", "(", "program", ")", ")", "\n", "}" ]
21,990
all-21991
[ "Initialize", "loads", "the", "consul", "KV", "s", "from", "the", "namespace", "into", "cache", "for", "later", "retrieval" ]
[ "func", "(", "c", "*", "cachedLoader", ")", "Initialize", "(", ")", "error", "{", "pairs", ",", "_", ",", "err", ":=", "c", ".", "consulKV", ".", "List", "(", "c", ".", "namespace", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "//write lock the cache incase init is called more than once", "c", ".", "cacheLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "cacheLock", ".", "Unlock", "(", ")", "\n\n", "c", ".", "cache", "=", "make", "(", "map", "[", "string", "]", "[", "]", "byte", ")", "\n", "for", "_", ",", "kv", ":=", "<mask>", "pairs", "{", "c", ".", "cache", "[", "kv", ".", "Key", "]", "=", "kv", ".", "Value", "\n", "}", "\n", "return", "nil", "\n", "}" ]
21,991
all-21992
[ "GetExecutablePath", "returns", "the", "absolute", "path", "to", "the", "currently", "running", "executable", ".", "It", "is", "used", "internally", "by", "the", "godaemon", "package", "and", "exported", "publicly", "because", "it", "s", "useful", "outside", "of", "the", "package", "too", "." ]
[ "func", "GetExecutablePath", "(", ")", "(", "string", ",", "error", ")", "{", "PATH_MAX", ":=", "1024", "// From <sys/syslimits.h>", "\n", "exePath", ":=", "<mask>", "(", "[", "]", "byte", ",", "PATH_MAX", ")", "\n", "exeLen", ":=", "C", ".", "size_t", "(", "len", "(", "exePath", ")", ")", "\n\n", "// Beware: sizeof(int) != sizeof(C.int)", "var", "mib", "[", "4", "]", "C", ".", "int", "\n", "// From <sys/sysctl.h>", "mib", "[", "0", "]", "=", "1", "// CTL_KERN", "\n", "mib", "[", "1", "]", "=", "14", "// KERN_PROC", "\n", "mib", "[", "2", "]", "=", "12", "// KERN_PROC_PATHNAME", "\n", "mib", "[", "3", "]", "=", "-", "1", "\n\n", "status", ",", "err", ":=", "C", ".", "sysctl", "(", "(", "*", "C", ".", "int", ")", "(", "unsafe", ".", "Pointer", "(", "&", "mib", "[", "0", "]", ")", ")", ",", "4", ",", "unsafe", ".", "Pointer", "(", "&", "exePath", "[", "0", "]", ")", ",", "&", "exeLen", ",", "nil", ",", "0", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "// Not sure why this might happen with err being nil, but...", "if", "status", "!=", "0", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "status", ")", "\n", "}", "\n\n", "// Convert from null-padded []byte to a clean string. (Can't simply cast!)", "exePathStringLen", ":=", "bytes", ".", "Index", "(", "exePath", ",", "[", "]", "byte", "{", "0", "}", ")", "\n", "exePathString", ":=", "string", "(", "exePath", "[", ":", "exePathStringLen", "]", ")", "\n\n", "return", "filepath", ".", "Clean", "(", "exePathString", ")", ",", "nil", "\n", "}" ]
21,992
all-21993
[ "ServeHTTP", "handle", "a", "pre", "-", "flight", "request", "." ]
[ "func", "(", "s", "*", "CORSPreflight", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "origin", ":=", "HttpHeader_Origin", "(", ")", ".", "GetReader", "(", "r", ".", "Header", ")", "\n", "status", ":=", "http", ".", "StatusBadRequest", "\n", "msg", ":=", "\"", "\"", "\n", "defer", "func", "(", ")", "{", "w", ".", "WriteHeader", "(", "status", ")", "\n", "w", ".", "Write", "(", "[", "]", "byte", "(", "msg", ")", ")", "\n", "}", "(", ")", "\n\n", "if", "origin", ".", "Value", "!=", "\"", "\"", "{", "if", "!", "s", ".", "PredicateOrigin", "(", "origin", ".", "Value", ")", "{", "status", "=", "http", ".", "StatusForbidden", "\n", "return", "\n", "}", "\n\n", "method", ":=", "HttpHeader_AccessControlRequestMethod", "(", ")", ".", "GetReader", "(", "r", ".", "Header", ")", ".", "Value", "\n", "header", ":=", "strings", ".", "Split", "(", "HttpHeader_AccessControlRequestHeaders", "(", ")", ".", "GetReader", "(", "r", ".", "Header", ")", ".", "Value", ",", "\"", "\"", ")", "\n", "if", "len", "(", "header", ")", "==", "1", "&&", "header", "[", "0", "]", "==", "\"", "\"", "{", "header", "=", "[", "]", "string", "{", "}", "\n", "}", "\n\n", "if", "!", "raiqub", ".", "StringSlice", "(", "s", ".", "Methods", ")", ".", "Exists", "(", "method", ")", "{", "msg", "=", "\"", "\"", "\n", "return", "\n", "}", "\n\n", "if", "len", "(", "s", ".", "Headers", ")", "==", "0", "{", "HttpHeader_AccessControlAllowHeaders", "(", ")", ".", "SetWriter", "(", "w", ".", "Header", "(", ")", ")", "\n", "}", "else", "{", "if", "len", "(", "header", ")", ">", "0", "&&", "!", "raiqub", ".", "StringSlice", "(", "s", ".", "Headers", ")", ".", "ExistsAllIgnoreCase", "(", "<mask>", ")", "{", "msg", "=", "\"", "\"", "\n", "return", "\n", "}", "\n", "HttpHeader_AccessControlAllowHeaders", "(", ")", ".", "SetValue", "(", "strings", ".", "Join", "(", "s", ".", "Headers", ",", "\"", "\"", ")", ")", ".", "SetWriter", "(", "w", ".", "Header", "(", ")", ")", "\n", "}", "\n\n", "HttpHeader_AccessControlAllowMethods", "(", ")", ".", "SetValue", "(", "strings", ".", "Join", "(", "s", ".", "Methods", ",", "\"", "\"", ")", ")", ".", "SetWriter", "(", "w", ".", "Header", "(", ")", ")", "\n", "HttpHeader_AccessControlAllowOrigin", "(", ")", ".", "SetValue", "(", "origin", ".", "Value", ")", ".", "SetWriter", "(", "w", ".", "Header", "(", ")", ")", "\n", "HttpHeader_AccessControlAllowCredentials", "(", ")", ".", "SetValue", "(", "strconv", ".", "FormatBool", "(", "s", ".", "UseCredentials", ")", ")", ".", "SetWriter", "(", "w", ".", "Header", "(", ")", ")", "\n", "// Optional", "HttpHeader_AccessControlMaxAge", "(", ")", ".", "SetValue", "(", "strconv", ".", "Itoa", "(", "int", "(", "DEFAULT_CORS_MAX_AGE", ")", ")", ")", ".", "SetWriter", "(", "w", ".", "Header", "(", ")", ")", "\n", "status", "=", "http", ".", "StatusOK", "\n", "}", "else", "{", "status", "=", "http", ".", "StatusNotFound", "\n", "}", "\n", "}" ]
21,993
all-21994
[ "FetchArtifacts", "constructs", "and", "returns", "Artifact", "objects", "for", "each", "artifact", "name", "in", "the", "list", ".", "This", "includes", "getting", "any", "handles", "needed", "for", "read", "write", "operations", "direct", "artifact", "links", "etc", "." ]
[ "func", "(", "s", "*", "Spyglass", ")", "FetchArtifacts", "(", "src", "string", ",", "podName", "string", ",", "sizeLimit", "int64", ",", "artifactNames", "[", "]", "string", ")", "(", "[", "]", "lenses", ".", "Artifact", ",", "error", ")", "{", "artStart", ":=", "time", ".", "Now", "(", ")", "\n", "arts", ":=", "[", "]", "lenses", ".", "Artifact", "{", "}", "\n", "keyType", ",", "key", ",", "err", ":=", "splitSrc", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "arts", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "jobName", ",", "buildID", ",", "err", ":=", "s", ".", "KeyToJob", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "arts", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "gcsKey", ":=", "\"", "\"", "\n", "switch", "keyType", "{", "case", "gcsKeyType", ":", "gcsKey", "=", "strings", ".", "TrimSuffix", "(", "key", ",", "\"", "\"", ")", "\n", "case", "prowKeyType", ":", "if", "gcsKey", ",", "err", "=", "s", ".", "prowToGCS", "(", "key", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "Warningln", "(", "err", ")", "\n", "}", "\n", "<mask>", ":", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "src", ")", "\n", "}", "\n\n", "podLogNeeded", ":=", "false", "\n", "for", "_", ",", "name", ":=", "range", "artifactNames", "{", "art", ",", "err", ":=", "s", ".", "GCSArtifactFetcher", ".", "artifact", "(", "gcsKey", ",", "name", ",", "sizeLimit", ")", "\n", "if", "err", "==", "nil", "{", "// Actually try making a request, because calling GCSArtifactFetcher.artifact does no I/O.", "// (these files are being explicitly requested and so will presumably soon be accessed, so", "// the extra network I/O should not be too problematic).", "_", ",", "err", "=", "art", ".", "Size", "(", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "if", "name", "==", "\"", "\"", "{", "podLogNeeded", "=", "true", "\n", "}", "\n", "continue", "\n", "}", "\n", "arts", "=", "append", "(", "arts", ",", "art", ")", "\n", "}", "\n\n", "if", "podLogNeeded", "{", "art", ",", "err", ":=", "s", ".", "PodLogArtifactFetcher", ".", "artifact", "(", "jobName", ",", "buildID", ",", "sizeLimit", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "else", "{", "arts", "=", "append", "(", "arts", ",", "art", ")", "\n", "}", "\n", "}", "\n\n", "logrus", ".", "WithField", "(", "\"", "\"", ",", "time", ".", "Since", "(", "artStart", ")", ")", ".", "Infof", "(", "\"", "\"", ",", "src", ")", "\n", "return", "arts", ",", "nil", "\n", "}" ]
21,994
all-21995
[ "reversePluginMaps", "inverts", "the", "Configuration", ".", "Plugins", "and", "Configuration", ".", "ExternalPlugins", "maps", "and", "expands", "any", "org", "strings", "to", "org", "/", "repo", "strings", ".", "The", "returned", "values", "map", "plugin", "names", "to", "the", "set", "of", "org", "/", "repo", "strings", "they", "are", "enabled", "on", "." ]
[ "func", "reversePluginMaps", "(", "config", "*", "plugins", ".", "Configuration", ",", "orgToRepos", "map", "[", "string", "]", "sets", ".", "String", ")", "(", "normal", ",", "external", "map", "[", "string", "]", "[", "]", "string", ")", "{", "normal", "=", "map", "[", "string", "]", "[", "]", "string", "{", "}", "\n", "for", "repo", ",", "enabledPlugins", ":=", "range", "config", ".", "Plugins", "{", "<mask>", "repos", "[", "]", "string", "\n", "if", "!", "strings", ".", "Contains", "(", "repo", ",", "\"", "\"", ")", "{", "if", "flattened", ",", "ok", ":=", "orgToRepos", "[", "repo", "]", ";", "ok", "{", "repos", "=", "flattened", ".", "List", "(", ")", "\n", "}", "\n", "}", "else", "{", "repos", "=", "[", "]", "string", "{", "repo", "}", "\n", "}", "\n", "for", "_", ",", "plugin", ":=", "range", "enabledPlugins", "{", "normal", "[", "plugin", "]", "=", "append", "(", "normal", "[", "plugin", "]", ",", "repos", "...", ")", "\n", "}", "\n", "}", "\n", "external", "=", "map", "[", "string", "]", "[", "]", "string", "{", "}", "\n", "for", "repo", ",", "extPlugins", ":=", "range", "config", ".", "ExternalPlugins", "{", "var", "repos", "[", "]", "string", "\n", "if", "flattened", ",", "ok", ":=", "orgToRepos", "[", "repo", "]", ";", "ok", "{", "repos", "=", "flattened", ".", "List", "(", ")", "\n", "}", "else", "{", "repos", "=", "[", "]", "string", "{", "repo", "}", "\n", "}", "\n", "for", "_", ",", "plugin", ":=", "range", "extPlugins", "{", "external", "[", "plugin", ".", "Name", "]", "=", "append", "(", "external", "[", "plugin", ".", "Name", "]", ",", "repos", "...", ")", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
21,995
all-21996
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "SetMediaTextReturns", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss17", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
21,996
all-21997
[ "HasReadOnly", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "d", "*", "DashboardLite", ")", "HasReadOnly", "(", ")", "bool", "{", "if", "d", "!=", "nil", "&&", "d", ".", "ReadOnly", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
21,997
all-21998
[ "Move", "moves", "a", "virtual", "disk", "from", "one", "location", "to", "another", ".", "The", "move", "is", "not", "forced", ".", "srcPath", "needs", "to", "be", "a", "datastore", "path", "(", "ie", ":", "[", "datastore1", "]", "vm", "/", "vm", ".", "vmdk", ")", "however", "the", "destination", "path", "(", "dstPath", ")", "can", "be", "a", "simple", "path", "-", "if", "it", "is", "the", "source", "datastore", "is", "used", "and", "dstDC", "is", "ignored", ".", "Further", "if", "dstPath", "has", "no", "directory", "the", "directory", "of", "srcPath", "is", "used", ".", "dstDC", "can", "be", "nil", "if", "the", "destination", "datastore", "is", "in", "the", "same", "datacenter", ".", "The", "new", "datastore", "path", "is", "returned", "along", "with", "any", "error", "to", "avoid", "the", "need", "to", "re", "-", "calculate", "the", "path", "separately", "." ]
[ "func", "Move", "(", "client", "*", "govmomi", ".", "Client", ",", "srcPath", "string", ",", "srcDC", "*", "object", ".", "Datacenter", ",", "dstPath", "string", ",", "dstDC", "*", "object", ".", "Datacenter", ")", "(", "string", ",", "error", ")", "{", "vdm", ":=", "object", ".", "NewVirtualDiskManager", "(", "client", ".", "Client", ")", "\n", "if", "srcDC", "==", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "!", "IsVmdkDatastorePath", "(", "srcPath", ")", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "srcPath", ")", "\n", "}", "\n", "if", "!", "IsVmdkDatastorePath", "(", "dstPath", ")", "{", "ddp", ":=", "dstDataStorePathFromLocalSrc", "(", "srcPath", ",", "dstPath", ")", "\n", "// One more validation", "if", "!", "IsVmdkDatastorePath", "(", "ddp", ")", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "dstPath", ")", "\n", "}", "\n", "dstPath", "=", "ddp", "\n", "dstDC", "=", "nil", "\n", "}", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "srcPath", ",", "srcDC", ",", "dstPath", ",", "structure", ".", "LogCond", "(", "dstDC", "!=", "nil", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "dstDC", ")", ",", "\"", "\"", ")", ",", ")", "\n", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "provider", ".", "DefaultAPITimeout", ")", "\n", "defer", "cancel", "(", ")", "\n", "task", ",", "err", ":=", "vdm", ".", "MoveVirtualDisk", "(", "ctx", ",", "srcPath", ",", "srcDC", ",", "dstPath", ",", "dstDC", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "tctx", ",", "tcancel", ":=", "context", ".", "WithTimeout", "(", "<mask>", ".", "Background", "(", ")", ",", "provider", ".", "DefaultAPITimeout", ")", "\n", "defer", "tcancel", "(", ")", "\n", "if", "err", ":=", "task", ".", "Wait", "(", "tctx", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "srcPath", ",", "srcDC", ",", "dstPath", ",", "structure", ".", "LogCond", "(", "dstDC", "!=", "nil", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "dstDC", ")", ",", "\"", "\"", ")", ",", ")", "\n", "return", "dstPath", ",", "nil", "\n", "}" ]
21,998
all-21999
[ "GetVizTypeOk", "returns", "a", "tuple", "with", "the", "VizType", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "w", "*", "Widget", ")", "GetVizTypeOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "w", "==", "nil", "||", "w", ".", "VizType", "==", "nil", "{", "return", "\"", "\"", ",", "false", "\n", "}", "\n", "return", "*", "w", ".", "VizType", ",", "<mask>", "\n", "}" ]
21,999
all-22000
[ "getStreamContext", "is", "used", "retrieve", "the", "current", "stream", "context", "." ]
[ "func", "(", "n", "*", "NetworkTransport", ")", "getStreamContext", "(", ")", "context", ".", "<mask>", "{", "n", ".", "streamCtxLock", ".", "RLock", "(", ")", "\n", "defer", "n", ".", "streamCtxLock", ".", "RUnlock", "(", ")", "\n", "return", "n", ".", "streamCtx", "\n", "}" ]