id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
2,800
all-2801
[ "Receive", "logStr", "from", "f", "s", "logChan", "and", "print", "logstr", "to", "file" ]
[ "func", "(", "f", "*", "FileLogger", ")", "logWriter", "(", ")", "{", "defer", "func", "(", ")", "{", "if", "err", ":=", "recover", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "//TODO let printInterVal can be configure, without change sourceCode", "printInterval", ":=", "DEFAULT_PRINT_INTERVAL", "\n\n", "seqTimer", ":=", "<mask>", ".", "NewTicker", "(", "time", ".", "Duration", "(", "printInterval", ")", "*", "time", ".", "Second", ")", "\n", "for", "{", "select", "{", "case", "str", ":=", "<-", "f", ".", "logChan", ":", "f", ".", "p", "(", "str", ")", "\n", "case", "<-", "seqTimer", ".", "C", ":", "f", ".", "p", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "len", "(", "f", ".", "logChan", ")", ")", ")", "\n", "}", "\n", "}", "\n", "}" ]
2,801
all-2802
[ "CreateEtcdClientConfig", "creates", "a", "client", "configuration", "from", "member", "." ]
[ "func", "(", "m", "*", "Member", ")", "CreateEtcdClientConfig", "(", "opts", "...", "grpc", ".", "DialOption", ")", "(", "cfg", "*", "clientv3", ".", "Config", ",", "err", "error", ")", "{", "secure", ":=", "false", "\n", "for", "_", ",", "cu", ":=", "range", "m", ".", "Etcd", ".", "AdvertiseClientURLs", "{", "var", "u", "*", "url", ".", "URL", "\n", "u", ",", "err", "=", "url", ".", "Parse", "(", "cu", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "u", ".", "Scheme", "==", "\"", "\"", "{", "// TODO: handle unix", "secure", "=", "true", "\n", "}", "\n", "}", "\n\n", "cfg", "=", "&", "clientv3", ".", "Config", "{", "Endpoints", ":", "[", "]", "string", "{", "m", ".", "EtcdClientEndpoint", "}", ",", "DialTimeout", ":", "10", "*", "time", ".", "Second", ",", "DialOptions", ":", "opts", ",", "}", "\n", "if", "<mask>", "{", "// assume save TLS assets are already stord on disk", "tlsInfo", ":=", "transport", ".", "TLSInfo", "{", "CertFile", ":", "m", ".", "ClientCertPath", ",", "KeyFile", ":", "m", ".", "ClientKeyPath", ",", "TrustedCAFile", ":", "m", ".", "ClientTrustedCAPath", ",", "// TODO: remove this with generated certs", "// only need it for auto TLS", "InsecureSkipVerify", ":", "true", ",", "}", "\n", "var", "tlsConfig", "*", "tls", ".", "Config", "\n", "tlsConfig", ",", "err", "=", "tlsInfo", ".", "ClientConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "cfg", ".", "TLS", "=", "tlsConfig", "\n", "}", "\n", "return", "cfg", ",", "err", "\n", "}" ]
2,802
all-2803
[ "suitableType", "returns", "the", "DNS", "resource", "record", "type", "suitable", "for", "the", "target", ".", "In", "this", "case", "type", "A", "for", "IPs", "and", "type", "CNAME", "for", "everything", "else", "." ]
[ "func", "suitableType", "(", "target", "string", ")", "string", "{", "if", "<mask>", ".", "ParseIP", "(", "target", ")", "!=", "nil", "{", "return", "endpoint", ".", "RecordTypeA", "\n", "}", "\n", "return", "endpoint", ".", "RecordTypeCNAME", "\n", "}" ]
2,803
all-2804
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "GetAllCookiesParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork39", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "<mask>", "(", ")", "\n", "}" ]
2,804
all-2805
[ "StopAckTimer", "stops", "the", "ack", "timer", "set", "on", "the", "ENI", "attachment" ]
[ "func", "(", "eni", "*", "ENIAttachment", ")", "StopAckTimer", "(", ")", "{", "eni", ".", "<mask>", ".", "Lock", "(", ")", "\n", "defer", "eni", ".", "guard", ".", "Unlock", "(", ")", "\n\n", "eni", ".", "ackTimer", ".", "Stop", "(", ")", "\n", "}" ]
2,805
all-2806
[ "SetWriteStrategy", "..." ]
[ "func", "(", "c", "*", "Cache", ")", "SetWriteStrategy", "(", "s", "string", ")", "(", "err", "error", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n\n", "switch", "s", "{", "case", "\"", "\"", ":", "c", ".", "writeStrategy", "=", "MaximumLength", "\n", "<mask>", "\"", "\"", ":", "c", ".", "writeStrategy", "=", "TimestampOrder", "\n", "case", "\"", "\"", ":", "c", ".", "writeStrategy", "=", "Noop", "\n", "default", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
2,806
all-2807
[ "ValidateLength", "checks", "whether", "the", "given", "data", "match", "the", "given", "rules", ".", "It", "checks", "if", "the", "value", "has", "more", "or", "equal", "min", "chars", "and", "less", "or", "equal", "max", "chars", ".", "If", "you", "don", "t", "want", "to", "check", "both", "just", "pass", "a", "zero", "value", ":", "ValidateLength", "(", "value", "0", "100", ")", "//", "Checks", "if", "value", "has", "at", "most", "100", "characters", "ValidateLength", "(", "value", "100", "0", ")", "//", "Checks", "if", "value", "has", "at", "least", "100", "characters", "ValidateLength", "(", "value", "20", "100", ")", "//", "Checks", "if", "value", "has", "at", "least", "20", "characters", "and", "at", "most", "100", "characters" ]
[ "func", "ValidateLength", "(", "value", "string", ",", "min", ",", "max", "int", ")", "bool", "{", "l", ":=", "len", "(", "value", ")", "\n", "if", "min", ">", "0", "&&", "l", "<", "<mask>", "{", "return", "false", "\n", "}", "\n", "if", "max", ">", "0", "&&", "l", ">", "max", "{", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
2,807
all-2808
[ "Load", "all", "containers", "of", "this", "nodes", "under", "the", "given", "project", "." ]
[ "func", "containerLoadNodeProjectAll", "(", "s", "*", "state", ".", "State", ",", "project", "string", ")", "(", "[", "]", "container", ",", "error", ")", "{", "// Get all the container arguments", "var", "cts", "[", "]", "db", ".", "Container", "\n", "err", ":=", "s", ".", "Cluster", ".", "Transaction", "(", "func", "(", "<mask>", "*", "db", ".", "ClusterTx", ")", "error", "{", "var", "err", "error", "\n", "cts", ",", "err", "=", "tx", ".", "ContainerNodeProjectList", "(", "project", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "containerLoadAllInternal", "(", "cts", ",", "s", ")", "\n", "}" ]
2,808
all-2809
[ "ParsePeerUID", "parses", "a", "decimal", "peer", "UID", "from", "a", "string", "." ]
[ "func", "parsePeerUID", "(", "s", "string", ")", "(", "PeerUID", ",", "error", ")", "{", "uid", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "s", ",", "10", ",", "64", ")", "\n", "return", "PeerUID", "(", "uid", ")", ",", "<mask>", "\n", "}" ]
2,809
all-2810
[ "DescribeECSTagsForInstance", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockClient", ")", "DescribeECSTagsForInstance", "(", "arg0", "string", ")", "(", "[", "]", "*", "ecs", ".", "Tag", ",", "error", ")", "{", "<mask>", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "[", "]", "*", "ecs", ".", "Tag", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
2,810
all-2811
[ "FieldParams", "converts", "the", "given", "fields", "to", "function", "parameters", "rendering", "their", "name", "." ]
[ "func", "FieldParams", "(", "fields", "[", "]", "*", "Field", ")", "string", "{", "args", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "fields", ")", ")", "\n", "for", "i", ",", "field", ":=", "range", "fields", "{", "args", "[", "i", "]", "=", "lex", ".", "Minuscule", "(", "<mask>", ".", "Name", ")", "\n", "}", "\n\n", "return", "strings", ".", "Join", "(", "args", ",", "\"", "\"", ")", "\n", "}" ]
2,811
all-2812
[ "New", "--" ]
[ "func", "(", "s", "*", "FakeSku", ")", "New", "(", "tm", "skurepo", ".", "TaskManager", ",", "procurementMeta", "<mask>", "[", "string", "]", "interface", "{", "}", ")", "skurepo", ".", "Sku", "{", "return", "s", "\n", "}" ]
2,812
all-2813
[ "readFiles", "reads", "files", "and", "returns", "source", "for", "the", "parsing", "process", "." ]
[ "func", "readFiles", "(", "basePath", ",", "innerPath", "string", ",", "opts", "*", "Options", ")", "(", "*", "source", ",", "error", ")", "{", "// Read the base file.", "base", ",", "err", ":=", "readFile", "(", "basePath", ",", "opts", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Read the inner file.", "inner", ",", "err", ":=", "readFile", "(", "innerPath", ",", "opts", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "<mask>", "[", "]", "*", "File", "\n\n", "// Find include files from the base file.", "if", "err", ":=", "findIncludes", "(", "base", ".", "data", ",", "opts", ",", "&", "includes", ",", "base", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Find include files from the inner file.", "if", "err", ":=", "findIncludes", "(", "inner", ".", "data", ",", "opts", ",", "&", "includes", ",", "inner", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "NewSource", "(", "base", ",", "inner", ",", "includes", ")", ",", "nil", "\n", "}" ]
2,813
all-2814
[ "cloneEnv", "encodes", "clonerefs", "Options", "into", "json", "and", "puts", "it", "into", "an", "environment", "variable" ]
[ "func", "cloneEnv", "(", "opt", "clonerefs", ".", "Options", ")", "(", "[", "]", "coreapi", ".", "EnvVar", ",", "error", ")", "{", "// TODO(fejta): use flags", "cloneConfigEnv", ",", "err", ":=", "clonerefs", ".", "Encode", "(", "<mask>", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "kubeEnv", "(", "map", "[", "string", "]", "string", "{", "clonerefs", ".", "JSONConfigEnvVar", ":", "cloneConfigEnv", "}", ")", ",", "nil", "\n", "}" ]
2,814
all-2815
[ "RemoveTextFunc", "a", "text", "metric", "function" ]
[ "func", "(", "m", "*", "CirconusMetrics", ")", "RemoveTextFunc", "(", "metric", "string", ")", "{", "m", ".", "tfm", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "tfm", ".", "Unlock", "(", ")", "\n", "<mask>", "(", "m", ".", "textFuncs", ",", "metric", ")", "\n", "}" ]
2,815
all-2816
[ "NotFoundHandler", "returns", "the", "default", "Mux", "404", "responder", "whenever", "a", "route", "cannot", "be", "found", "." ]
[ "func", "(", "mx", "*", "Mux", ")", "NotFoundHandler", "(", ")", "<mask>", ".", "HandlerFunc", "{", "if", "mx", ".", "notFoundHandler", "!=", "nil", "{", "return", "mx", ".", "notFoundHandler", "\n", "}", "\n", "return", "http", ".", "NotFound", "\n", "}" ]
2,816
all-2817
[ "GetCreateFlags", "returns", "list", "of", "create", "flags", "driver", "accepts", "." ]
[ "func", "(", "d", "*", "Driver", ")", "GetCreateFlags", "(", ")", "[", "]", "mcnflag", ".", "Flag", "{", "return", "[", "]", "mcnflag", ".", "Flag", "{", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureEnvironment", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "Value", ":", "defaultAzureEnvironment", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureSubscriptionID", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureResourceGroup", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "Value", ":", "defaultAzureResourceGroup", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureSSHUser", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "Value", ":", "defaultSSHUser", ",", "}", ",", "mcnflag", ".", "IntFlag", "{", "Name", ":", "flAzureDockerPort", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "Value", ":", "defaultDockerPort", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureLocation", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "<mask>", ":", "defaultAzureLocation", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureSize", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "Value", ":", "defaultAzureSize", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureImage", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "Value", ":", "defaultAzureImage", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureVNet", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "Value", ":", "defaultAzureVNet", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureSubnet", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "Value", ":", "defaultAzureSubnet", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureSubnetPrefix", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "Value", ":", "defaultAzureSubnetPrefix", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureAvailabilitySet", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "Value", ":", "defaultAzureAvailabilitySet", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureCustomData", ",", "EnvVar", ":", "\"", "\"", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzurePrivateIPAddr", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureStorageType", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "Value", ":", "defaultStorageType", ",", "}", ",", "mcnflag", ".", "BoolFlag", "{", "Name", ":", "flAzureUsePrivateIP", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "BoolFlag", "{", "Name", ":", "flAzureNoPublicIP", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "BoolFlag", "{", "Name", ":", "flAzureStaticPublicIP", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureDNSLabel", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringSliceFlag", "{", "Name", ":", "flAzurePorts", ",", "Usage", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureClientID", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "}", ",", "mcnflag", ".", "StringFlag", "{", "Name", ":", "flAzureClientSecret", ",", "Usage", ":", "\"", "\"", ",", "EnvVar", ":", "\"", "\"", ",", "}", ",", "}", "\n", "}" ]
2,817
all-2818
[ "GetResource", "returns", "the", "Resource", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "r", "*", "reqGetDashboard", ")", "GetResource", "(", ")", "string", "{", "if", "r", "==", "nil", "||", "r", ".", "<mask>", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "r", ".", "Resource", "\n", "}" ]
2,818
all-2819
[ "Do", "executes", "Network", ".", "setBlockedURLs", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "SetBlockedURLSParams", ")", "Do", "(", "ctx", "<mask>", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetBlockedURLS", ",", "p", ",", "nil", ")", "\n", "}" ]
2,819
all-2820
[ "ClientAfterUncooperativeCloseRequest", "waits", "for", "the", "channel", "to", "uncooperative", "close", "starts", "the", "service", "termination", "process", "." ]
[ "func", "(", "w", "*", "Worker", ")", "ClientAfterUncooperativeCloseRequest", "(", "job", "*", "<mask>", ".", "Job", ")", "error", "{", "logger", ":=", "w", ".", "logger", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "job", ")", "\n\n", "ch", ",", "err", ":=", "w", ".", "relatedChannel", "(", "logger", ",", "job", ",", "data", ".", "JobClientAfterUncooperativeCloseRequest", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "ch", ".", "ChannelStatus", "=", "data", ".", "ChannelInChallenge", "\n", "if", "err", "=", "w", ".", "db", ".", "Update", "(", "ch", ")", ";", "err", "!=", "nil", "{", "logger", ".", "Error", "(", "err", ".", "Error", "(", ")", ")", "\n", "return", "ErrInternal", "\n", "}", "\n\n", "challengePeriod", ",", "err", ":=", "data", ".", "ReadUintSetting", "(", "w", ".", "db", ".", "Querier", ",", "data", ".", "SettingsPeriodChallange", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "w", ".", "addJobWithDelay", "(", "logger", ",", "nil", ",", "data", ".", "JobClientPreUncooperativeClose", ",", "data", ".", "JobChannel", ",", "ch", ".", "ID", ",", "time", ".", "Duration", "(", "challengePeriod", ")", "*", "eth", ".", "BlockDuration", ")", "\n", "}" ]
2,820
all-2821
[ "WithSort", "specifies", "the", "ordering", "in", "Get", "request", ".", "It", "requires", "WithRange", "and", "/", "or", "WithPrefix", "to", "be", "specified", "too", ".", "target", "specifies", "the", "target", "to", "sort", "by", ":", "key", "version", "revisions", "value", ".", "order", "can", "be", "either", "SortNone", "SortAscend", "SortDescend", "." ]
[ "func", "WithSort", "(", "target", "SortTarget", ",", "order", "SortOrder", ")", "OpOption", "{", "return", "func", "(", "op", "*", "Op", ")", "{", "if", "target", "==", "SortByKey", "&&", "order", "==", "SortAscend", "{", "// If order != SortNone, server fetches the entire key-space,", "// and then applies the sort and limit, if provided.", "// Since by default the server returns results sorted by keys", "// in lexicographically ascending order, the client should ignore", "// SortOrder if the target is SortByKey.", "<mask>", "=", "SortNone", "\n", "}", "\n", "op", ".", "sort", "=", "&", "SortOption", "{", "target", ",", "order", "}", "\n", "}", "\n", "}" ]
2,821
all-2822
[ "ApplyChanges", "applies", "a", "given", "set", "of", "changes", "in", "a", "given", "zone", "." ]
[ "func", "(", "p", "*", "AWSProvider", ")", "ApplyChanges", "(", "changes", "*", "plan", ".", "Changes", ")", "error", "{", "zones", ",", "err", ":=", "p", ".", "Zones", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "records", ",", "err", ":=", "p", ".", "records", "(", "zones", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "combinedChanges", ":=", "make", "(", "[", "]", "*", "route53", ".", "Change", ",", "0", ",", "len", "(", "changes", ".", "Create", ")", "+", "len", "(", "changes", ".", "UpdateNew", ")", "+", "len", "(", "changes", ".", "Delete", ")", ")", "\n\n", "combinedChanges", "=", "append", "(", "combinedChanges", ",", "p", ".", "newChanges", "(", "route53", ".", "ChangeActionCreate", ",", "changes", ".", "Create", ",", "records", ",", "zones", ")", "...", ")", "\n", "combinedChanges", "=", "append", "(", "combinedChanges", ",", "p", ".", "newChanges", "(", "route53", ".", "ChangeActionUpsert", ",", "<mask>", ".", "UpdateNew", ",", "records", ",", "zones", ")", "...", ")", "\n", "combinedChanges", "=", "append", "(", "combinedChanges", ",", "p", ".", "newChanges", "(", "route53", ".", "ChangeActionDelete", ",", "changes", ".", "Delete", ",", "records", ",", "zones", ")", "...", ")", "\n\n", "return", "p", ".", "submitChanges", "(", "combinedChanges", ",", "zones", ")", "\n", "}" ]
2,822
all-2823
[ "BatchSize", "returns", "a", "derivative", "query", "to", "fetch", "the", "supplied", "number", "of", "results", "at", "once", ".", "This", "value", "should", "be", "greater", "than", "zero", "and", "equal", "to", "or", "less", "than", "the", "Limit", "." ]
[ "func", "(", "q", "*", "<mask>", ")", "BatchSize", "(", "size", "int", ")", "*", "Query", "{", "q", "=", "q", ".", "clone", "(", ")", "\n", "if", "size", "<=", "0", "||", "size", ">", "math", ".", "MaxInt32", "{", "q", ".", "err", "=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "return", "q", "\n", "}", "\n", "q", ".", "count", "=", "int32", "(", "size", ")", "\n", "return", "q", "\n", "}" ]
2,823
all-2824
[ "NewSelectiveStringsValue", "creates", "a", "new", "string", "slice", "flag", "for", "which", "any", "one", "of", "the", "given", "strings", "is", "a", "valid", "value", "and", "any", "other", "value", "is", "an", "error", "." ]
[ "func", "NewSelectiveStringsValue", "(", "valids", "...", "string", ")", "*", "SelectiveStringsValue", "{", "vm", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n", "for", "_", ",", "v", ":=", "range", "valids", "{", "vm", "[", "v", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "return", "&", "SelectiveStringsValue", "{", "valids", ":", "vm", ",", "<mask>", ":", "[", "]", "string", "{", "}", "}", "\n", "}" ]
2,824
all-2825
[ "Retry", "returns", "true", "if", "this", "error", "should", "be", "considered", "retriable" ]
[ "func", "(", "err", "*", "WSError", ")", "Retry", "(", ")", "bool", "{", "for", "_", ",", "unretriable", ":=", "range", "err", ".", "Get", "(", ")", "{", "if", "reflect", ".", "TypeOf", "(", "err", ".", "ErrObj", ")", "==", "reflect", ".", "TypeOf", "(", "unretriable", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "<mask>", "\n", "}" ]
2,825
all-2826
[ "Do", "executes", "Page", ".", "setProduceCompilationCache", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "SetProduceCompilationCacheParams", ")", "Do", "(", "ctx", "<mask>", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandSetProduceCompilationCache", ",", "p", ",", "nil", ")", "\n", "}" ]
2,826
all-2827
[ "Write", "implements", "Handler", "interface" ]
[ "func", "(", "h", "*", "RotatingFileHandler", ")", "Write", "(", "p", "[", "]", "<mask>", ")", "(", "n", "int", ",", "err", "error", ")", "{", "h", ".", "doRollover", "(", ")", "\n", "n", ",", "err", "=", "h", ".", "fd", ".", "Write", "(", "p", ")", "\n", "h", ".", "curBytes", "+=", "n", "\n", "return", "\n", "}" ]
2,827
all-2828
[ "CreateVM", "creates", "a", "virtual", "machine", "on", "a", "datastore", "cluster", "via", "the", "StorageResourceManager", "API", ".", "It", "mimics", "our", "helper", "in", "the", "virtualmachine", "package", "in", "functionality", "returning", "a", "VM", "helper", "object", "on", "success", "." ]
[ "func", "CreateVM", "(", "client", "*", "govmomi", ".", "Client", ",", "fo", "*", "object", ".", "Folder", ",", "spec", "types", ".", "VirtualMachineConfigSpec", ",", "pool", "*", "object", ".", "ResourcePool", ",", "host", "*", "object", ".", "HostSystem", ",", "pod", "*", "object", ".", "StoragePod", ",", ")", "(", "*", "object", ".", "VirtualMachine", ",", "error", ")", "{", "sdrsEnabled", ",", "err", ":=", "StorageDRSEnabled", "(", "pod", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "!", "sdrsEnabled", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pod", ".", "Name", "(", ")", ")", "\n", "}", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "fo", ".", "InventoryPath", ",", "spec", ".", "Name", ")", ",", "pod", ".", "Name", "(", ")", ",", ")", "\n", "sps", ":=", "types", ".", "StoragePlacementSpec", "{", "Type", ":", "string", "(", "types", ".", "StoragePlacementSpecPlacementTypeCreate", ")", ",", "ResourcePool", ":", "types", ".", "NewReference", "(", "pool", ".", "Reference", "(", ")", ")", ",", "PodSelectionSpec", ":", "types", ".", "StorageDrsPodSelectionSpec", "{", "StoragePod", ":", "types", ".", "NewReference", "(", "pod", ".", "Reference", "(", ")", ")", ",", "InitialVmConfig", ":", "expandVMPodConfigForPlacement", "(", "spec", ".", "DeviceChange", ",", "pod", ")", ",", "}", ",", "ConfigSpec", ":", "&", "spec", ",", "Folder", ":", "types", ".", "NewReference", "(", "fo", ".", "Reference", "(", ")", ")", ",", "}", "\n", "if", "host", "!=", "nil", "{", "sps", ".", "Host", "=", "types", ".", "NewReference", "(", "host", ".", "Reference", "(", ")", ")", "\n", "}", "\n\n", "placement", ",", "err", ":=", "recommendSDRS", "(", "client", ",", "sps", ",", "provider", ".", "DefaultAPITimeout", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// If the parent resource pool is a vApp, we need to create the VM using the", "// CreateChildVM vApp function instead of directly using SDRS recommendations.", "if", "sps", ".", "ResourcePool", "!=", "nil", "{", "vc", ",", "err", ":=", "vappcontainer", ".", "FromID", "(", "client", ",", "sps", ".", "ResourcePool", ".", "Reference", "(", ")", ".", "Value", ")", "\n", "switch", "{", "case", "viapi", ".", "IsManagedObjectNotFoundError", "(", "err", ")", ":", "// This isn't a vApp container, so continue with normal SDRS work flow.", "case", "err", "==", "nil", ":", "return", "createVAppVMFromSPS", "(", "client", ",", "placement", ",", "<mask>", ",", "sps", ",", "vc", ")", "\n", "default", ":", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "return", "applySDRS", "(", "client", ",", "placement", ",", "provider", ".", "DefaultAPITimeout", ")", "\n", "}" ]
2,828
all-2829
[ "GetSignatures", "returns", "the", "image", "s", "signatures", ".", "It", "may", "use", "a", "remote", "(", "=", "slow", ")", "service", ".", "If", "instanceDigest", "is", "not", "nil", "it", "contains", "a", "digest", "of", "the", "specific", "manifest", "instance", "to", "retrieve", "signatures", "for", "(", "when", "the", "primary", "manifest", "is", "a", "manifest", "list", ")", ";", "this", "never", "happens", "if", "the", "primary", "manifest", "is", "not", "a", "manifest", "list", "(", "e", ".", "g", ".", "if", "the", "source", "never", "returns", "manifest", "lists", ")", "." ]
[ "func", "(", "*", "tarballImageSource", ")", "GetSignatures", "(", "ctx", "context", ".", "<mask>", ",", "instanceDigest", "*", "digest", ".", "Digest", ")", "(", "[", "]", "[", "]", "byte", ",", "error", ")", "{", "if", "instanceDigest", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "transportName", ")", "\n", "}", "\n", "return", "nil", ",", "nil", "\n", "}" ]
2,829
all-2830
[ "roleGetCommandFunc", "executes", "the", "role", "get", "command", "." ]
[ "func", "roleGetCommandFunc", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "if", "len", "(", "args", ")", "!=", "1", "{", "ExitWithError", "(", "ExitBadArgs", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "}", "\n\n", "<mask>", ":=", "args", "[", "0", "]", "\n", "resp", ",", "err", ":=", "mustClientFromCmd", "(", "cmd", ")", ".", "Auth", ".", "RoleGet", "(", "context", ".", "TODO", "(", ")", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "ExitWithError", "(", "ExitError", ",", "err", ")", "\n", "}", "\n\n", "display", ".", "RoleGet", "(", "name", ",", "*", "resp", ")", "\n", "}" ]
2,830
all-2831
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "ResumeParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger24", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
2,831
all-2832
[ "Run", "creates", "a", "new", "Docker", "container", "as", "defined", "by", "current", "image", "and", "container", "template", ".", "Returns", "ExternalCmdError", "or", "UnexpectedOutputError", "on", "error", "." ]
[ "func", "(", "s", "*", "Image", ")", "Run", "(", "cfg", "*", "RunConfig", ")", "(", "*", "Container", ",", "error", ")", "{", "args", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "cfg", ".", "Options", ")", "+", "len", "(", "cfg", ".", "Args", ")", "+", "1", ")", "\n", "args", "=", "append", "(", "args", ",", "cfg", ".", "Options", "...", ")", "\n", "args", "=", "<mask>", "(", "args", ",", "s", ".", "name", ")", "\n", "args", "=", "append", "(", "args", ",", "cfg", ".", "Args", "...", ")", "\n\n", "out", ",", "err", ":=", "s", ".", "docker", ".", "Run", "(", "\"", "\"", ",", "args", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "container", ":=", "&", "Container", "{", "docker", ":", "s", ".", "docker", ",", "id", ":", "strings", ".", "TrimSpace", "(", "out", ")", ",", "}", "\n", "if", "container", ".", "id", "==", "\"", "\"", "{", "return", "nil", ",", "UnexpectedOutputError", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "container", ",", "nil", "\n", "}" ]
2,832
all-2833
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "SetPauseOnExceptionsParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger8", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "<mask>", "(", ")", "\n", "}" ]
2,833
all-2834
[ "WithObjectID", "identifier", "of", "the", "object", "to", "call", "function", "on", ".", "Either", "objectId", "or", "executionContextId", "should", "be", "specified", "." ]
[ "func", "(", "p", "CallFunctionOnParams", ")", "WithObjectID", "(", "objectID", "RemoteObjectID", ")", "*", "CallFunctionOnParams", "{", "p", ".", "ObjectID", "=", "objectID", "\n", "<mask>", "&", "p", "\n", "}" ]
2,834
all-2835
[ "This", "validates", "the", "Routes", "and", "prepares", "the", "Trie", "data", "structure", ".", "It", "must", "be", "called", "once", "the", "Routes", "are", "defined", "and", "before", "trying", "to", "find", "Routes", ".", "The", "order", "matters", "if", "multiple", "Routes", "match", "the", "first", "defined", "will", "be", "used", "." ]
[ "func", "(", "rt", "*", "router", ")", "start", "(", ")", "error", "{", "rt", ".", "trie", "=", "trie", ".", "New", "(", ")", "\n", "rt", ".", "index", "=", "map", "[", "*", "<mask>", "]", "int", "{", "}", "\n\n", "for", "i", ",", "route", ":=", "range", "rt", ".", "Routes", "{", "// work with the PathExp urlencoded.", "pathExp", ",", "err", ":=", "escapedPathExp", "(", "route", ".", "PathExp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// insert in the Trie", "err", "=", "rt", ".", "trie", ".", "AddRoute", "(", "strings", ".", "ToUpper", "(", "route", ".", "HttpMethod", ")", ",", "// work with the HttpMethod in uppercase", "pathExp", ",", "route", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// index", "rt", ".", "index", "[", "route", "]", "=", "i", "\n", "}", "\n\n", "if", "rt", ".", "disableTrieCompression", "==", "false", "{", "rt", ".", "trie", ".", "Compress", "(", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
2,835
all-2836
[ "Do", "executes", "IndexedDB", ".", "clearObjectStore", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "ClearObjectStoreParams", ")", "Do", "(", "ctx", "<mask>", ".", "Context", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandClearObjectStore", ",", "p", ",", "nil", ")", "\n", "}" ]
2,836
all-2837
[ "On", "enables", "maintenance", "." ]
[ "func", "(", "s", "*", "FileStore", ")", "On", "(", ")", "(", "changed", "bool", ",", "err", "error", ")", "{", "if", "_", ",", "err", "=", "os", ".", "Stat", "(", "s", ".", "<mask>", ")", ";", "err", "==", "nil", "{", "return", "\n", "}", "\n", "err", "=", "os", ".", "MkdirAll", "(", "filepath", ".", "Dir", "(", "s", ".", "filename", ")", ",", "0777", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "f", ",", "err", ":=", "os", ".", "Create", "(", "s", ".", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "f", ".", "Close", "(", ")", "\n", "changed", "=", "true", "\n", "return", "\n", "}" ]
2,837
all-2838
[ "ArticleCtx", "middleware", "is", "used", "to", "load", "an", "Article", "object", "from", "the", "URL", "parameters", "passed", "through", "as", "the", "request", ".", "In", "case", "the", "Article", "could", "not", "be", "found", "we", "stop", "here", "and", "return", "a", "404", "." ]
[ "func", "ArticleCtx", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "<mask>", "*", "Article", "\n", "var", "err", "error", "\n\n", "if", "articleID", ":=", "chi", ".", "URLParam", "(", "r", ",", "\"", "\"", ")", ";", "articleID", "!=", "\"", "\"", "{", "article", ",", "err", "=", "dbGetArticle", "(", "articleID", ")", "\n", "}", "else", "if", "articleSlug", ":=", "chi", ".", "URLParam", "(", "r", ",", "\"", "\"", ")", ";", "articleSlug", "!=", "\"", "\"", "{", "article", ",", "err", "=", "dbGetArticleBySlug", "(", "articleSlug", ")", "\n", "}", "else", "{", "render", ".", "Render", "(", "w", ",", "r", ",", "ErrNotFound", ")", "\n", "return", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "render", ".", "Render", "(", "w", ",", "r", ",", "ErrNotFound", ")", "\n", "return", "\n", "}", "\n\n", "ctx", ":=", "context", ".", "WithValue", "(", "r", ".", "Context", "(", ")", ",", "\"", "\"", ",", "article", ")", "\n", "next", ".", "ServeHTTP", "(", "w", ",", "r", ".", "WithContext", "(", "ctx", ")", ")", "\n", "}", ")", "\n", "}" ]
2,838
all-2839
[ "ListenAndServeTLSEmbed", "serves", "HTTPS", "requests", "from", "the", "given", "TCP", "addr", "using", "the", "given", "handler", ".", "certData", "and", "keyData", "must", "contain", "valid", "TLS", "certificate", "and", "key", "data", "." ]
[ "func", "ListenAndServeTLSEmbed", "(", "addr", "string", ",", "certData", ",", "keyData", "[", "]", "byte", ",", "handler", "RequestHandler", ")", "error", "{", "s", ":=", "&", "Server", "{", "<mask>", ":", "handler", ",", "}", "\n", "return", "s", ".", "ListenAndServeTLSEmbed", "(", "addr", ",", "certData", ",", "keyData", ")", "\n", "}" ]
2,839
all-2840
[ "ApplySingleExtract", "applies", "the", "given", "JSON", "selector", "and", "returns", "the", "results", ".", "It", "s", "an", "error", "if", "the", "selector", "yields", "more", "than", "one", "value", "." ]
[ "func", "(", "d", "*", "Displayer", ")", "ApplySingleExtract", "(", "extract", "string", ")", "error", "{", "if", "err", ":=", "d", ".", "ApplyExtract", "(", "extract", ",", "true", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "outputs", ":=", "d", ".", "RawOutput", ".", "(", "[", "]", "interface", "{", "}", ")", "\n", "if", "len", "(", "outputs", ")", "!=", "1", "{", "d", ".", "RawOutput", "=", "nil", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "extract", ",", "len", "(", "outputs", ")", ")", "\n", "}", "\n", "if", "len", "(", "outputs", ")", "==", "0", "{", "d", ".", "RawOutput", "=", "\"", "\"", "\n", "}", "else", "{", "switch", "v", ":=", "outputs", "[", "0", "]", ".", "(", "type", ")", "{", "<mask>", "nil", ":", "d", ".", "RawOutput", "=", "\"", "\"", "\n", "case", "float64", ",", "bool", ":", "d", ".", "RawOutput", "=", "fmt", ".", "Sprint", "(", "v", ")", "\n", "case", "string", ":", "d", ".", "RawOutput", "=", "v", "\n", "default", ":", "d", ".", "RawOutput", "=", "v", "\n", "}", "\n", "d", ".", "RawOutput", "=", "outputs", "[", "0", "]", "\n", "}", "\n", "return", "nil", "\n", "}" ]
2,840
all-2841
[ "Load", "the", "hosts", "file", "into", "l", ".", "Lines", ".", "Load", "()", "is", "called", "by", "NewHosts", "()", "and", "Hosts", ".", "Flush", "()", "so", "you", "generally", "you", "won", "t", "need", "to", "call", "this", "yourself", "." ]
[ "func", "(", "h", "*", "Hosts", ")", "Load", "(", ")", "error", "{", "var", "lines", "[", "]", "HostsLine", "\n\n", "file", ",", "err", ":=", "<mask>", ".", "Open", "(", "h", ".", "Path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "file", ".", "Close", "(", ")", "\n\n", "scanner", ":=", "bufio", ".", "NewScanner", "(", "file", ")", "\n", "for", "scanner", ".", "Scan", "(", ")", "{", "line", ":=", "NewHostsLine", "(", "scanner", ".", "Text", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "lines", "=", "append", "(", "lines", ",", "line", ")", "\n", "}", "\n\n", "if", "err", ":=", "scanner", ".", "Err", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "h", ".", "Lines", "=", "lines", "\n\n", "return", "nil", "\n", "}" ]
2,841
all-2842
[ "Read", "reads", "the", "next", "merge", "node", "." ]
[ "func", "(", "r", "*", "Reader", ")", "Read", "(", ")", "(", "*", "MergeNode", ",", "error", ")", "{", "_k", ",", "err", ":=", "r", ".", "pbr", ".", "ReadBytes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "r", ".", "filter", "!=", "nil", "{", "for", "{", "if", "r", ".", "filter", "(", "_k", ")", "{", "<mask>", "\n", "}", "\n", "_", ",", "err", "=", "r", ".", "pbr", ".", "ReadBytes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "_k", ",", "err", "=", "r", ".", "pbr", ".", "ReadBytes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "}", "\n", "k", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "_k", ")", ")", "\n", "copy", "(", "k", ",", "_k", ")", "\n", "_v", ",", "err", ":=", "r", ".", "pbr", ".", "ReadBytes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "v", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "_v", ")", ")", "\n", "copy", "(", "v", ",", "_v", ")", "\n", "return", "&", "MergeNode", "{", "k", ":", "k", ",", "v", ":", "v", ",", "}", ",", "nil", "\n", "}" ]
2,842
all-2843
[ "GetData", "retrieves", "the", "Data", "value", "from", "the", "union", "returning", "ok", "if", "the", "union", "s", "switch", "indicated", "the", "value", "is", "valid", "." ]
[ "func", "(", "u", "LedgerEntryData", ")", "GetData", "(", ")", "(", "result", "DataEntry", ",", "ok", "bool", ")", "{", "armName", ",", "_", ":=", "u", ".", "ArmForSwitch", "(", "int32", "(", "u", ".", "Type", ")", ")", "\n\n", "if", "armName", "==", "\"", "\"", "{", "result", "=", "*", "u", ".", "Data", "\n", "<mask>", "=", "true", "\n", "}", "\n\n", "return", "\n", "}" ]
2,843
all-2844
[ "StartServer", "starts", "a", "remote", "Pact", "Mock", "Server", "." ]
[ "func", "(", "p", "*", "PactClient", ")", "StartServer", "(", "args", "[", "]", "string", ",", "port", "int", ")", "*", "types", ".", "MockServer", "{", "log", ".", "Println", "(", "\"", "\"", ",", "args", ",", "\"", "\"", ",", "port", ")", "\n", "args", "=", "append", "(", "args", ",", "[", "]", "string", "{", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "port", ")", "}", "...", ")", "\n", "svc", ":=", "p", ".", "pactMockSvcManager", ".", "NewService", "(", "args", ")", "\n", "cmd", ":=", "svc", ".", "Start", "(", ")", "\n\n", "waitForPort", "(", "port", ",", "p", ".", "getNetworkInterface", "(", ")", ",", "p", ".", "Address", ",", "p", ".", "TimeoutDuration", ",", "fmt", ".", "Sprintf", "(", "`Timed out waiting for Mock Server to start on port %d - are you sure it's running?`", ",", "port", ")", ")", "\n\n", "return", "&", "<mask>", ".", "MockServer", "{", "Pid", ":", "cmd", ".", "Process", ".", "Pid", ",", "Port", ":", "port", ",", "}", "\n", "}" ]
2,844
all-2845
[ "WIFFromPrivKeyBytes", "returns", "the", "privKeyBytes", "in", "Wallet", "Import", "Format", "." ]
[ "func", "WIFFromPrivKeyBytes", "(", "privKeyBytes", "[", "]", "byte", ",", "compress", "bool", ")", "string", "{", "versionPrefix", ":=", "btcPrefixPrivKey", "// TODO Make const or configurable", "\n", "<mask>", ":=", "append", "(", "[", "]", "byte", "{", "versionPrefix", "}", ",", "privKeyBytes", "...", ")", "\n", "if", "compress", "{", "bytes", "=", "append", "(", "bytes", ",", "byte", "(", "1", ")", ")", "\n", "}", "\n", "checksum", ":=", "CalcHash256", "(", "bytes", ")", "\n", "bytes", "=", "append", "(", "bytes", ",", "checksum", "[", ":", "4", "]", "...", ")", "\n", "return", "base58", ".", "Encode", "(", "bytes", ")", "\n", "}" ]
2,845
all-2846
[ "WithContext", "adds", "the", "context", "to", "the", "get", "apps", "app", "routes", "route", "params" ]
[ "func", "(", "o", "*", "GetAppsAppRoutesRouteParams", ")", "WithContext", "(", "ctx", "context", ".", "<mask>", ")", "*", "GetAppsAppRoutesRouteParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
2,846
all-2847
[ "retrieve", "information", "about", "attachments", "of", "a", "bound", "framebuffer", "object" ]
[ "func", "GetFramebufferAttachmentParameteriv", "(", "target", "uint32", ",", "attachment", "uint32", ",", "pname", "uint32", ",", "params", "*", "int32", ")", "{", "C", ".", "glowGetFramebufferAttachmentParameteriv", "(", "gpGetFramebufferAttachmentParameteriv", ",", "(", "C", ".", "GLenum", ")", "(", "<mask>", ")", ",", "(", "C", ".", "GLenum", ")", "(", "attachment", ")", ",", "(", "C", ".", "GLenum", ")", "(", "pname", ")", ",", "(", "*", "C", ".", "GLint", ")", "(", "unsafe", ".", "Pointer", "(", "params", ")", ")", ")", "\n", "}" ]
2,847
all-2848
[ "UnmarshalJSON", "overrides", "the", "logic", "for", "parsing", "the", "JSON", "-", "encoded", "container", "health", "data" ]
[ "func", "(", "healthStatus", "*", "ContainerHealthStatus", ")", "UnmarshalJSON", "(", "b", "[", "]", "byte", ")", "error", "{", "*", "healthStatus", "=", "ContainerHealthUnknown", "\n\n", "if", "strings", ".", "ToLower", "(", "string", "(", "b", ")", ")", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n", "if", "b", "[", "0", "]", "!=", "'\"'", "||", "b", "[", "len", "(", "b", ")", "-", "1", "]", "!=", "'\"'", "{", "return", "<mask>", ".", "New", "(", "\"", "\"", "+", "string", "(", "b", ")", ")", "\n", "}", "\n\n", "strStatus", ":=", "string", "(", "b", "[", "1", ":", "len", "(", "b", ")", "-", "1", "]", ")", "\n", "switch", "strStatus", "{", "case", "\"", "\"", ":", "// The health status is already set to ContainerHealthUnknown initially", "case", "\"", "\"", ":", "*", "healthStatus", "=", "ContainerHealthy", "\n", "case", "\"", "\"", ":", "*", "healthStatus", "=", "ContainerUnhealthy", "\n", "default", ":", "return", "errors", ".", "New", "(", "\"", "\"", "+", "string", "(", "b", ")", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
2,848
all-2849
[ "typeof", "returns", "the", "type", "of", "the", "given", "name", "which", "may", "be", "of", "the", "form", "x", "or", "p", ".", "X", "." ]
[ "func", "(", "cfg", "*", "TypeConfig", ")", "typeof", "(", "<mask>", "string", ")", "string", "{", "if", "cfg", ".", "Var", "!=", "nil", "{", "if", "t", ":=", "cfg", ".", "Var", "[", "name", "]", ";", "t", "!=", "\"", "\"", "{", "return", "t", "\n", "}", "\n", "}", "\n", "if", "cfg", ".", "Func", "!=", "nil", "{", "if", "t", ":=", "cfg", ".", "Func", "[", "name", "]", ";", "t", "!=", "\"", "\"", "{", "return", "\"", "\"", "+", "t", "\n", "}", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
2,849
all-2850
[ "AddHeader", "adds", "a", "single", "application", "header", "to", "the", "Context", "." ]
[ "func", "(", "cb", "*", "ContextBuilder", ")", "AddHeader", "(", "key", ",", "value", "string", ")", "*", "ContextBuilder", "{", "if", "cb", ".", "Headers", "==", "nil", "{", "cb", ".", "Headers", "=", "map", "[", "string", "]", "string", "{", "key", ":", "value", "}", "\n", "}", "else", "{", "cb", ".", "Headers", "[", "<mask>", "]", "=", "value", "\n", "}", "\n", "return", "cb", "\n", "}" ]
2,850
all-2851
[ "NextPos", "returns", "the", "tile", "s", "next", "position", ".", "NextPos", "is", "used", "only", "at", "testing", "so", "far", "." ]
[ "func", "(", "t", "*", "Tile", ")", "NextPos", "(", ")", "(", "int", ",", "int", ")", "{", "return", "t", ".", "next", ".", "x", ",", "t", ".", "<mask>", ".", "y", "\n", "}" ]
2,851
all-2852
[ "HasName", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "a", "*", "Alert", ")", "HasName", "(", ")", "bool", "{", "if", "a", "!=", "nil", "&&", "a", ".", "Name", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
2,852
all-2853
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "Rule", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "<mask>", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss25", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
2,853
all-2854
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "GetFrameOwnerReturns", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoDom40", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
2,854
all-2855
[ "Mksig", "creates", "a", "byte", "slice", "of", "length", "2", "*", "keyLen", "copying", "the", "bytes", "from", "r", "and", "s", "into", "the", "slice", "left", "padding", "r", "and", "s", "to", "keyLen", "." ]
[ "func", "(", "es", "*", "EccSigner", ")", "Mksig", "(", "r", ",", "s", "*", "big", ".", "Int", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "n", "int", "\n\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "2", "*", "<mask>", ".", "keyLen", ")", "\n\n", "// copy r into buf", "rb", ":=", "r", ".", "Bytes", "(", ")", "\n", "n", "=", "copy", "(", "buf", "[", "es", ".", "keyLen", "-", "len", "(", "rb", ")", ":", "]", ",", "rb", ")", "\n", "if", "n", "!=", "len", "(", "rb", ")", "{", "return", "nil", ",", "ErrMismatchedBytesCopied", "\n", "}", "\n\n", "// copy s into buf", "sb", ":=", "s", ".", "Bytes", "(", ")", "\n", "n", "=", "copy", "(", "buf", "[", "es", ".", "keyLen", "+", "(", "es", ".", "keyLen", "-", "(", "len", "(", "sb", ")", ")", ")", ":", "]", ",", "sb", ")", "\n", "if", "n", "!=", "len", "(", "sb", ")", "{", "return", "nil", ",", "ErrMismatchedBytesCopied", "\n", "}", "\n\n", "return", "buf", ",", "nil", "\n", "}" ]
2,855
all-2856
[ "NewContainerResponse", "creates", "ContainerResponse", "for", "a", "container", "." ]
[ "func", "NewContainerResponse", "(", "dockerContainer", "*", "apicontainer", ".", "DockerContainer", ",", "eni", "*", "apieni", ".", "ENI", ")", "ContainerResponse", "{", "<mask>", ":=", "dockerContainer", ".", "Container", "\n", "resp", ":=", "ContainerResponse", "{", "Name", ":", "container", ".", "Name", ",", "DockerID", ":", "dockerContainer", ".", "DockerID", ",", "DockerName", ":", "dockerContainer", ".", "DockerName", ",", "}", "\n\n", "resp", ".", "Ports", "=", "NewPortBindingsResponse", "(", "dockerContainer", ",", "eni", ")", "\n", "resp", ".", "Volumes", "=", "NewVolumesResponse", "(", "dockerContainer", ")", "\n\n", "if", "eni", "!=", "nil", "{", "resp", ".", "Networks", "=", "[", "]", "containermetadata", ".", "Network", "{", "{", "NetworkMode", ":", "utils", ".", "NetworkModeAWSVPC", ",", "IPv4Addresses", ":", "eni", ".", "GetIPV4Addresses", "(", ")", ",", "IPv6Addresses", ":", "eni", ".", "GetIPV6Addresses", "(", ")", ",", "}", ",", "}", "\n", "}", "\n", "return", "resp", "\n", "}" ]
2,856
all-2857
[ "TerminalFormat", "formats", "log", "records", "optimized", "for", "human", "readability", "on", "a", "terminal", "with", "color", "-", "coded", "level", "output", "and", "terser", "human", "friendly", "timestamp", ".", "This", "format", "should", "only", "be", "used", "for", "interactive", "programs", "or", "while", "developing", ".", "[", "TIME", "]", "[", "LEVEL", "]", "MESAGE", "key", "=", "value", "key", "=", "value", "...", "Example", ":", "[", "May", "16", "20", ":", "58", ":", "45", "]", "[", "DBUG", "]", "remove", "route", "ns", "=", "haproxy", "addr", "=", "127", ".", "0", ".", "0", ".", "1", ":", "50002" ]
[ "func", "TerminalFormat", "(", ")", "Format", "{", "return", "FormatFunc", "(", "func", "(", "r", "*", "Record", ")", "[", "]", "byte", "{", "var", "color", "=", "0", "\n", "switch", "r", ".", "Lvl", "{", "case", "LvlCrit", ":", "color", "=", "35", "\n", "case", "LvlError", ":", "color", "=", "31", "\n", "case", "LvlWarn", ":", "color", "=", "33", "\n", "case", "LvlInfo", ":", "color", "=", "32", "\n", "case", "LvlDebug", ":", "color", "=", "36", "\n", "}", "\n\n", "b", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "lvl", ":=", "strings", ".", "ToUpper", "(", "r", ".", "Lvl", ".", "String", "(", ")", ")", "\n", "if", "color", ">", "0", "{", "fmt", ".", "Fprintf", "(", "b", ",", "\"", "\\x1b", "\\x1b", "\"", ",", "color", ",", "lvl", ",", "r", ".", "Time", ".", "Format", "(", "termTimeFormat", ")", ",", "r", ".", "Msg", ")", "\n", "}", "else", "{", "fmt", ".", "Fprintf", "(", "b", ",", "\"", "\"", ",", "lvl", ",", "r", ".", "Time", ".", "Format", "(", "termTimeFormat", ")", ",", "r", ".", "Msg", ")", "\n", "}", "\n\n", "// try to justify the log output for short messages", "if", "len", "(", "r", ".", "Ctx", ")", ">", "0", "&&", "len", "(", "r", ".", "Msg", ")", "<", "termMsgJust", "{", "b", ".", "Write", "(", "bytes", ".", "Repeat", "(", "[", "]", "byte", "{", "' '", "}", ",", "termMsgJust", "-", "len", "(", "r", ".", "Msg", ")", ")", ")", "\n", "}", "\n\n", "// print the keys logfmt style", "logfmt", "(", "b", ",", "r", ".", "Ctx", ",", "<mask>", ")", "\n", "return", "b", ".", "Bytes", "(", ")", "\n", "}", ")", "\n", "}" ]
2,857
all-2858
[ "reconcile", "ensures", "a", "knative", "-", "build", "prowjob", "has", "a", "corresponding", "build", "updating", "the", "prowjob", "s", "status", "as", "the", "build", "progresses", "." ]
[ "func", "reconcile", "(", "c", "reconciler", ",", "key", "string", ")", "error", "{", "ctx", ",", "namespace", ",", "name", ",", "err", ":=", "fromKey", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "runtime", ".", "HandleError", "(", "err", ")", "\n", "return", "nil", "\n", "}", "\n\n", "if", "err", ":=", "c", ".", "terminateDupProwJobs", "(", "ctx", ",", "namespace", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Warn", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "wantBuild", "bool", "\n\n", "pj", ",", "err", ":=", "c", ".", "getProwJob", "(", "name", ")", "\n", "switch", "{", "case", "apierrors", ".", "IsNotFound", "(", "err", ")", ":", "// Do not want build", "case", "err", "!=", "nil", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "case", "pj", ".", "Spec", ".", "Agent", "!=", "prowjobv1", ".", "KnativeBuildAgent", ":", "// Do not want a build for this job", "case", "pjutil", ".", "ClusterToCtx", "(", "pj", ".", "Spec", ".", "Cluster", ")", "!=", "ctx", ":", "// Build is in wrong cluster, we do not want this build", "logrus", ".", "Warnf", "(", "\"", "\"", ",", "key", ",", "ctx", ",", "pjutil", ".", "ClusterToCtx", "(", "pj", ".", "Spec", ".", "Cluster", ")", ")", "\n", "case", "pj", ".", "DeletionTimestamp", "==", "nil", ":", "wantBuild", "=", "true", "\n", "}", "\n\n", "var", "haveBuild", "bool", "\n\n", "b", ",", "err", ":=", "c", ".", "getBuild", "(", "ctx", ",", "namespace", ",", "name", ")", "\n", "switch", "{", "case", "apierrors", ".", "IsNotFound", "(", "err", ")", ":", "// Do not have a build", "case", "err", "!=", "nil", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "<mask>", ",", "err", ")", "\n", "case", "b", ".", "DeletionTimestamp", "==", "nil", ":", "haveBuild", "=", "true", "\n", "}", "\n\n", "var", "newBuildID", "bool", "\n", "// Should we create or delete this build?", "switch", "{", "case", "!", "wantBuild", ":", "if", "!", "haveBuild", "{", "if", "pj", "!=", "nil", "&&", "pj", ".", "Spec", ".", "Agent", "==", "prowjobv1", ".", "KnativeBuildAgent", "{", "logrus", ".", "Infof", "(", "\"", "\"", ",", "key", ")", "\n", "}", "\n", "return", "nil", "\n", "}", "\n", "switch", "v", ",", "ok", ":=", "b", ".", "Labels", "[", "kube", ".", "CreatedByProw", "]", ";", "{", "case", "!", "ok", ",", "v", "!=", "\"", "\"", ":", "// Not controlled by this", "return", "nil", "\n", "}", "\n", "logrus", ".", "Infof", "(", "\"", "\"", ",", "key", ")", "\n", "if", "err", "=", "c", ".", "deleteBuild", "(", "ctx", ",", "namespace", ",", "name", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "case", "finalState", "(", "pj", ".", "Status", ".", "State", ")", ":", "logrus", ".", "Infof", "(", "\"", "\"", ",", "key", ")", "\n", "return", "nil", "\n", "case", "wantBuild", "&&", "pj", ".", "Spec", ".", "BuildSpec", "==", "nil", ":", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "case", "wantBuild", "&&", "!", "haveBuild", ":", "id", ",", "url", ",", "err", ":=", "c", ".", "buildID", "(", "*", "pj", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "pj", ".", "Status", ".", "BuildID", "=", "id", "\n", "pj", ".", "Status", ".", "URL", "=", "url", "\n", "newBuildID", "=", "true", "\n", "if", "b", ",", "err", "=", "makeBuild", "(", "*", "pj", ",", "c", ".", "defaultBuildTimeout", "(", ")", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "logrus", ".", "Infof", "(", "\"", "\"", ",", "key", ")", "\n", "if", "b", ",", "err", "=", "c", ".", "createBuild", "(", "ctx", ",", "namespace", ",", "b", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n\n", "// Ensure prowjob status is correct", "haveState", ":=", "pj", ".", "Status", ".", "State", "\n", "haveMsg", ":=", "pj", ".", "Status", ".", "Description", "\n", "wantState", ",", "wantMsg", ":=", "prowJobStatus", "(", "b", ".", "Status", ")", "\n", "if", "newBuildID", "||", "haveState", "!=", "wantState", "||", "haveMsg", "!=", "wantMsg", "{", "npj", ":=", "pj", ".", "DeepCopy", "(", ")", "\n", "if", "npj", ".", "Status", ".", "StartTime", ".", "IsZero", "(", ")", "{", "npj", ".", "Status", ".", "StartTime", "=", "c", ".", "now", "(", ")", "\n", "}", "\n", "if", "npj", ".", "Status", ".", "CompletionTime", ".", "IsZero", "(", ")", "&&", "finalState", "(", "wantState", ")", "{", "now", ":=", "c", ".", "now", "(", ")", "\n", "npj", ".", "Status", ".", "CompletionTime", "=", "&", "now", "\n", "}", "\n", "npj", ".", "Status", ".", "State", "=", "wantState", "\n", "npj", ".", "Status", ".", "Description", "=", "wantMsg", "\n", "logrus", ".", "Infof", "(", "\"", "\"", ",", "key", ")", "\n", "if", "_", ",", "err", "=", "c", ".", "updateProwJob", "(", "npj", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
2,858
all-2859
[ "GetUUID", "returns", "the", "app", "v4", "UUID", ".", "An", "UUID", "will", "be", "generated", "if", "it", "does", "not", "exist", "." ]
[ "func", "(", "app", "*", "App", ")", "GetUUID", "(", ")", "(", "string", ",", "error", ")", "{", "if", "app", ".", "UUID", "!=", "\"", "\"", "{", "return", "app", ".", "UUID", ",", "nil", "\n", "}", "\n", "uuidV4", ",", "err", ":=", "uuid", ".", "NewV4", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "errors", ".", "WithMessage", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "conn", ",", "err", ":=", "db", ".", "Conn", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "defer", "conn", ".", "Close", "(", ")", "\n", "err", "=", "conn", ".", "Apps", "(", ")", ".", "Update", "(", "bson", ".", "M", "{", "\"", "\"", ":", "app", ".", "Name", "}", ",", "bson", ".", "M", "{", "\"", "\"", ":", "bson", ".", "M", "{", "\"", "\"", ":", "uuidV4", ".", "<mask>", "(", ")", "}", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "app", ".", "UUID", "=", "uuidV4", ".", "String", "(", ")", "\n", "return", "app", ".", "UUID", ",", "nil", "\n", "}" ]
2,859
all-2860
[ "GetMessage", "returns", "the", "Message", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "c", "*", "Check", ")", "GetMessage", "(", ")", "string", "{", "if", "c", "==", "nil", "||", "c", ".", "Message", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "*", "c", ".", "<mask>", "\n", "}" ]
2,860
all-2861
[ "Pos", "returns", "the", "tile", "s", "current", "position", ".", "Pos", "is", "used", "only", "at", "testing", "so", "far", "." ]
[ "func", "(", "t", "*", "Tile", ")", "Pos", "(", ")", "(", "int", ",", "int", ")", "{", "return", "t", ".", "current", ".", "x", ",", "t", ".", "<mask>", ".", "y", "\n", "}" ]
2,861
all-2862
[ "CreateEtcdClient", "creates", "a", "client", "from", "member", "." ]
[ "func", "(", "m", "*", "Member", ")", "CreateEtcdClient", "(", "opts", "...", "grpc", ".", "DialOption", ")", "(", "*", "clientv3", ".", "<mask>", ",", "error", ")", "{", "cfg", ",", "err", ":=", "m", ".", "CreateEtcdClientConfig", "(", "opts", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "clientv3", ".", "New", "(", "*", "cfg", ")", "\n", "}" ]
2,862
all-2863
[ "newGossipChannel", "returns", "a", "named", "usable", "channel", ".", "It", "delegates", "receiving", "duties", "to", "the", "passed", "Gossiper", "." ]
[ "func", "newGossipChannel", "(", "channelName", "string", ",", "ourself", "*", "localPeer", ",", "r", "*", "routes", ",", "g", "Gossiper", ",", "logger", "Logger", ")", "*", "gossipChannel", "{", "return", "&", "gossipChannel", "{", "<mask>", ":", "channelName", ",", "ourself", ":", "ourself", ",", "routes", ":", "r", ",", "gossiper", ":", "g", ",", "logger", ":", "logger", ",", "}", "\n", "}" ]
2,863
all-2864
[ "GetConnectionInfo", "returns", "the", "basic", "connection", "information", "used", "to", "interact", "with", "the", "server" ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetConnectionInfo", "(", ")", "(", "*", "ConnectionInfo", ",", "error", ")", "{", "info", ":=", "ConnectionInfo", "{", "}", "\n", "info", ".", "Certificate", "=", "r", ".", "httpCertificate", "\n", "info", ".", "Protocol", "=", "\"", "\"", "\n", "info", ".", "URL", "=", "r", ".", "httpHost", "\n", "info", ".", "SocketPath", "=", "r", ".", "httpUnixPath", "\n", "info", ".", "Project", "=", "r", ".", "project", "\n", "if", "info", ".", "Project", "==", "\"", "\"", "{", "info", ".", "Project", "=", "\"", "\"", "\n", "}", "\n\n", "urls", ":=", "[", "]", "string", "{", "}", "\n", "if", "r", ".", "httpProtocol", "==", "\"", "\"", "{", "urls", "=", "append", "(", "urls", ",", "r", ".", "httpHost", ")", "\n", "}", "\n\n", "if", "r", ".", "server", "!=", "nil", "&&", "len", "(", "r", ".", "server", ".", "Environment", ".", "Addresses", ")", ">", "0", "{", "for", "_", ",", "addr", ":=", "range", "r", ".", "server", ".", "Environment", ".", "Addresses", "{", "<mask>", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "addr", ")", "\n", "if", "!", "shared", ".", "StringInSlice", "(", "url", ",", "urls", ")", "{", "urls", "=", "append", "(", "urls", ",", "url", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "info", ".", "Addresses", "=", "urls", "\n\n", "return", "&", "info", ",", "nil", "\n", "}" ]
2,864
all-2865
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventResetProfiles", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoHeapprofiler15", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
2,865
all-2866
[ "LogFields", "belongs", "to", "the", "Span", "interface" ]
[ "func", "(", "s", "*", "MockSpan", ")", "LogFields", "(", "<mask>", "...", "log", ".", "Field", ")", "{", "s", ".", "logFieldsWithTimestamp", "(", "time", ".", "Now", "(", ")", ",", "fields", "...", ")", "\n", "}" ]
2,866
all-2867
[ "getClient", "returns", "a", "client", "specified", "by", "the", "docker", "version", ".", "It", "s", "wrapped", "by", "GetClient", "so", "that", "it", "can", "do", "platform", "-", "specific", "magic", "." ]
[ "func", "(", "f", "*", "factory", ")", "getClient", "(", "version", "dockerclient", ".", "DockerVersion", ")", "(", "sdkclient", ".", "Client", ",", "error", ")", "{", "<mask>", ",", "ok", ":=", "f", ".", "clients", "[", "version", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", "+", "string", "(", "version", ")", ")", "\n", "}", "\n", "return", "client", ",", "nil", "\n", "}" ]
2,867
all-2868
[ "SaveMultipartFile", "saves", "multipart", "file", "fh", "under", "the", "given", "filename", "path", "." ]
[ "func", "SaveMultipartFile", "(", "fh", "*", "multipart", ".", "FileHeader", ",", "path", "string", ")", "error", "{", "f", ",", "err", ":=", "fh", ".", "Open", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "ff", ",", "<mask>", ":=", "f", ".", "(", "*", "os", ".", "File", ")", ";", "ok", "{", "// Windows can't rename files that are opened.", "if", "err", ":=", "f", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// If renaming fails we try the normal copying method.", "// Renaming could fail if the files are on different devices.", "if", "os", ".", "Rename", "(", "ff", ".", "Name", "(", ")", ",", "path", ")", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// Reopen f for the code below.", "f", ",", "err", "=", "fh", ".", "Open", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "defer", "f", ".", "Close", "(", ")", "\n\n", "ff", ",", "err", ":=", "os", ".", "Create", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "ff", ".", "Close", "(", ")", "\n", "_", ",", "err", "=", "copyZeroAlloc", "(", "ff", ",", "f", ")", "\n", "return", "err", "\n", "}" ]
2,868
all-2869
[ "MatchesDigest", "returns", "true", "iff", "the", "manifest", "matches", "expectedDigest", ".", "Error", "may", "be", "set", "if", "this", "returns", "false", ".", "Note", "that", "this", "is", "not", "doing", "ConstantTimeCompare", ";", "by", "the", "time", "we", "get", "here", "the", "cryptographic", "signature", "must", "already", "have", "been", "verified", "or", "we", "are", "not", "using", "a", "cryptographic", "channel", "and", "the", "attacker", "can", "modify", "the", "digest", "along", "with", "the", "manifest", "blob", "." ]
[ "func", "MatchesDigest", "(", "manifest", "[", "]", "byte", ",", "expectedDigest", "digest", ".", "Digest", ")", "(", "bool", ",", "error", ")", "{", "// This should eventually support various digest types.", "actualDigest", ",", "err", ":=", "Digest", "(", "manifest", ")", "\n", "if", "err", "!=", "nil", "{", "return", "<mask>", ",", "err", "\n", "}", "\n", "return", "expectedDigest", "==", "actualDigest", ",", "nil", "\n", "}" ]
2,869
all-2870
[ "Get", "returns", "a", "Media", "struct", "representing", "a", "Media", "instance", "or", "an", "error", "." ]
[ "func", "(", "m", "*", "MediaService", ")", "Get", "(", "ctx", "context", ".", "Context", ",", "messageSid", "string", ",", "sid", "string", ")", "(", "*", "Media", ",", "error", ")", "{", "<mask>", ":=", "new", "(", "Media", ")", "\n", "err", ":=", "m", ".", "client", ".", "GetResource", "(", "ctx", ",", "mediaPathPart", "(", "messageSid", ")", ",", "sid", ",", "me", ")", "\n", "return", "me", ",", "err", "\n", "}" ]
2,870
all-2871
[ "title", ":", "router", "list", "path", ":", "/", "routers", "method", ":", "GET", "produce", ":", "application", "/", "json", "responses", ":", "200", ":", "OK", "204", ":", "No", "content" ]
[ "func", "listRouters", "(", "w", "<mask>", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "t", "auth", ".", "Token", ")", "error", "{", "contexts", ":=", "permission", ".", "ContextsForPermission", "(", "t", ",", "permission", ".", "PermAppCreate", ")", "\n", "var", "teams", "[", "]", "string", "\n", "var", "global", "bool", "\n", "contexts", ":", "for", "_", ",", "c", ":=", "range", "contexts", "{", "switch", "c", ".", "CtxType", "{", "case", "permTypes", ".", "CtxGlobal", ":", "global", "=", "true", "\n", "break", "contexts", "\n", "case", "permTypes", ".", "CtxTeam", ":", "teams", "=", "append", "(", "teams", ",", "c", ".", "Value", ")", "\n", "}", "\n", "}", "\n", "routers", ",", "err", ":=", "router", ".", "ListWithInfo", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "filteredRouters", ":=", "routers", "\n", "if", "!", "global", "{", "routersAllowed", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n", "filteredRouters", "=", "[", "]", "router", ".", "PlanRouter", "{", "}", "\n", "pools", ",", "err", ":=", "pool", ".", "ListPossiblePools", "(", "teams", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "_", ",", "p", ":=", "range", "pools", "{", "rs", ",", "err", ":=", "p", ".", "GetRouters", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "_", ",", "r", ":=", "range", "rs", "{", "routersAllowed", "[", "r", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}", "\n", "for", "_", ",", "r", ":=", "range", "routers", "{", "if", "_", ",", "ok", ":=", "routersAllowed", "[", "r", ".", "Name", "]", ";", "ok", "{", "filteredRouters", "=", "append", "(", "filteredRouters", ",", "r", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "if", "len", "(", "filteredRouters", ")", "==", "0", "{", "w", ".", "WriteHeader", "(", "http", ".", "StatusNoContent", ")", "\n", "return", "nil", "\n", "}", "\n", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "return", "json", ".", "NewEncoder", "(", "w", ")", ".", "Encode", "(", "filteredRouters", ")", "\n", "}" ]
2,871
all-2872
[ "SetSelected", "makes", "the", "button", "selected", ".", "One", "should", "not", "use", "the", "method", "directly", "it", "is", "for", "RadioGroup", "control" ]
[ "func", "(", "c", "*", "Radio", ")", "SetSelected", "(", "val", "bool", ")", "{", "c", ".", "selected", "=", "val", "\n\n", "if", "c", ".", "onChange", "!=", "nil", "{", "<mask>", "c", ".", "onChange", "(", "val", ")", "\n", "}", "\n", "}" ]
2,872
all-2873
[ "RBACServer", "returns", "all", "the", "Candid", "settings", "needed", "to", "connect", "to", "a", "server", "." ]
[ "func", "(", "c", "*", "Config", ")", "RBACServer", "(", ")", "(", "string", ",", "string", ",", "int64", ",", "string", ",", "string", ",", "<mask>", ",", "string", ")", "{", "return", "c", ".", "m", ".", "GetString", "(", "\"", "\"", ")", ",", "c", ".", "m", ".", "GetString", "(", "\"", "\"", ")", ",", "c", ".", "m", ".", "GetInt64", "(", "\"", "\"", ")", ",", "c", ".", "m", ".", "GetString", "(", "\"", "\"", ")", ",", "c", ".", "m", ".", "GetString", "(", "\"", "\"", ")", ",", "c", ".", "m", ".", "GetString", "(", "\"", "\"", ")", ",", "c", ".", "m", ".", "GetString", "(", "\"", "\"", ")", "\n", "}" ]
2,873
all-2874
[ "UploadURL", "creates", "an", "upload", "URL", "for", "the", "form", "that", "the", "user", "will", "fill", "out", "passing", "the", "application", "path", "to", "load", "when", "the", "POST", "of", "the", "form", "is", "completed", ".", "These", "URLs", "expire", "and", "should", "not", "be", "reused", ".", "The", "opts", "parameter", "may", "be", "nil", "." ]
[ "func", "UploadURL", "(", "c", "context", ".", "Context", ",", "successPath", "string", ",", "opts", "*", "UploadURLOptions", ")", "(", "*", "url", ".", "URL", ",", "error", ")", "{", "req", ":=", "&", "blobpb", ".", "CreateUploadURLRequest", "{", "SuccessPath", ":", "proto", ".", "String", "(", "successPath", ")", ",", "}", "\n", "if", "opts", "!=", "nil", "{", "if", "n", ":=", "opts", ".", "MaxUploadBytes", ";", "n", "!=", "0", "{", "req", ".", "MaxUploadSizeBytes", "=", "&", "n", "\n", "}", "\n", "if", "n", ":=", "opts", ".", "MaxUploadBytesPerBlob", ";", "n", "!=", "0", "{", "req", ".", "MaxUploadSizePerBlobBytes", "=", "&", "n", "\n", "}", "\n", "if", "s", ":=", "opts", ".", "StorageBucket", ";", "s", "!=", "\"", "\"", "{", "req", ".", "GsBucketName", "=", "&", "s", "\n", "}", "\n", "}", "\n", "<mask>", ":=", "&", "blobpb", ".", "CreateUploadURLResponse", "{", "}", "\n", "if", "err", ":=", "internal", ".", "Call", "(", "c", ",", "\"", "\"", ",", "\"", "\"", ",", "req", ",", "res", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "url", ".", "Parse", "(", "*", "res", ".", "Url", ")", "\n", "}" ]
2,874
all-2875
[ "Remove", "function", "remove", "the", "node", "." ]
[ "func", "(", "n", "*", "node", ")", "Remove", "(", "dir", ",", "recursive", "bool", ",", "callback", "func", "(", "path", "string", ")", ")", "*", "v2error", ".", "Error", "{", "if", "!", "n", ".", "IsDir", "(", ")", "{", "// key-value pair", "_", ",", "name", ":=", "path", ".", "Split", "(", "n", ".", "Path", ")", "\n\n", "// find its parent and remove the node from the map", "if", "n", ".", "Parent", "!=", "nil", "&&", "n", ".", "Parent", ".", "Children", "[", "name", "]", "==", "n", "{", "delete", "(", "n", ".", "Parent", ".", "Children", ",", "name", ")", "\n", "}", "\n\n", "if", "<mask>", "!=", "nil", "{", "callback", "(", "n", ".", "Path", ")", "\n", "}", "\n\n", "if", "!", "n", ".", "IsPermanent", "(", ")", "{", "n", ".", "store", ".", "ttlKeyHeap", ".", "remove", "(", "n", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}", "\n\n", "if", "!", "dir", "{", "// cannot delete a directory without dir set to true", "return", "v2error", ".", "NewError", "(", "v2error", ".", "EcodeNotFile", ",", "n", ".", "Path", ",", "n", ".", "store", ".", "CurrentIndex", ")", "\n", "}", "\n\n", "if", "len", "(", "n", ".", "Children", ")", "!=", "0", "&&", "!", "recursive", "{", "// cannot delete a directory if it is not empty and the operation", "// is not recursive", "return", "v2error", ".", "NewError", "(", "v2error", ".", "EcodeDirNotEmpty", ",", "n", ".", "Path", ",", "n", ".", "store", ".", "CurrentIndex", ")", "\n", "}", "\n\n", "for", "_", ",", "child", ":=", "range", "n", ".", "Children", "{", "// delete all children", "child", ".", "Remove", "(", "true", ",", "true", ",", "callback", ")", "\n", "}", "\n\n", "// delete self", "_", ",", "name", ":=", "path", ".", "Split", "(", "n", ".", "Path", ")", "\n", "if", "n", ".", "Parent", "!=", "nil", "&&", "n", ".", "Parent", ".", "Children", "[", "name", "]", "==", "n", "{", "delete", "(", "n", ".", "Parent", ".", "Children", ",", "name", ")", "\n\n", "if", "callback", "!=", "nil", "{", "callback", "(", "n", ".", "Path", ")", "\n", "}", "\n\n", "if", "!", "n", ".", "IsPermanent", "(", ")", "{", "n", ".", "store", ".", "ttlKeyHeap", ".", "remove", "(", "n", ")", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
2,875
all-2876
[ "NewPool", "creates", "and", "returns", "a", "new", "pool", "." ]
[ "func", "NewPool", "(", ")", "*", "Pool", "{", "return", "&", "Pool", "{", "tasks", ":", "make", "(", "map", "[", "string", "]", "*", "Task", ")", ",", "queues", ":", "<mask>", "(", "map", "[", "*", "Queue", "]", "bool", ")", ",", "closed", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", "\n", "}" ]
2,876
all-2877
[ "Middleware", "registers", "middleware", "to", "handle", "incoming", "request", "messages", "." ]
[ "func", "(", "s", "*", "Server", ")", "Middleware", "(", "middleware", "...", "Middleware", ")", "{", "for", "_", ",", "m", ":=", "<mask>", "middleware", "{", "s", ".", "MiddlewareFunc", "(", "m", ".", "Middleware", ")", "\n", "}", "\n", "}" ]
2,877
all-2878
[ "DeleteImage", "deletes", "the", "named", "image", "from", "the", "registry", "if", "supported", "." ]
[ "func", "(", "ref", "dockerReference", ")", "DeleteImage", "(", "ctx", "<mask>", ".", "Context", ",", "sys", "*", "types", ".", "SystemContext", ")", "error", "{", "return", "deleteImage", "(", "ctx", ",", "sys", ",", "ref", ")", "\n", "}" ]
2,878
all-2879
[ "ImageID", "computes", "an", "ID", "which", "can", "uniquely", "identify", "this", "image", "by", "its", "contents", "." ]
[ "func", "(", "m", "*", "Schema2", ")", "ImageID", "(", "[", "]", "digest", ".", "Digest", ")", "(", "string", ",", "error", ")", "{", "if", "err", ":=", "m", ".", "ConfigDescriptor", ".", "Digest", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "<mask>", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "m", ".", "ConfigDescriptor", ".", "Digest", ".", "Hex", "(", ")", ",", "nil", "\n", "}" ]
2,879
all-2880
[ "SetHealthStatus", "sets", "the", "container", "health", "status" ]
[ "func", "(", "c", "*", "Container", ")", "SetHealthStatus", "(", "health", "HealthStatus", ")", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "if", "c", ".", "Health", ".", "<mask>", "==", "health", ".", "Status", "{", "return", "\n", "}", "\n\n", "c", ".", "Health", ".", "Status", "=", "health", ".", "Status", "\n", "c", ".", "Health", ".", "Since", "=", "aws", ".", "Time", "(", "time", ".", "Now", "(", ")", ")", "\n", "c", ".", "Health", ".", "Output", "=", "health", ".", "Output", "\n\n", "// Set the health exit code if the health check failed", "if", "c", ".", "Health", ".", "Status", "==", "apicontainerstatus", ".", "ContainerUnhealthy", "{", "c", ".", "Health", ".", "ExitCode", "=", "health", ".", "ExitCode", "\n", "}", "\n", "}" ]
2,880
all-2881
[ "NewDiskCache", "creates", "a", "GitHub", "cache", "RoundTripper", "that", "is", "backed", "by", "a", "disk", "cache", "." ]
[ "func", "NewDiskCache", "(", "delegate", "http", ".", "RoundTripper", ",", "cacheDir", "string", ",", "cacheSizeGB", ",", "maxConcurrency", "int", ")", "http", ".", "RoundTripper", "{", "return", "NewFromCache", "(", "delegate", ",", "diskcache", ".", "NewWithDiskv", "(", "diskv", ".", "New", "(", "diskv", ".", "Options", "{", "BasePath", ":", "<mask>", ".", "Join", "(", "cacheDir", ",", "\"", "\"", ")", ",", "TempDir", ":", "path", ".", "Join", "(", "cacheDir", ",", "\"", "\"", ")", ",", "CacheSizeMax", ":", "uint64", "(", "cacheSizeGB", ")", "*", "uint64", "(", "1000000000", ")", ",", "// convert G to B", "}", ")", ")", ",", "maxConcurrency", ",", ")", "\n", "}" ]
2,881
all-2882
[ "GetHideZeroCountsOk", "returns", "a", "tuple", "with", "the", "HideZeroCounts", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "w", "*", "Widget", ")", "GetHideZeroCountsOk", "(", ")", "(", "bool", ",", "bool", ")", "{", "if", "w", "==", "nil", "||", "w", ".", "HideZeroCounts", "==", "nil", "{", "return", "false", ",", "<mask>", "\n", "}", "\n", "return", "*", "w", ".", "HideZeroCounts", ",", "true", "\n", "}" ]
2,882
all-2883
[ "Incoming", "message", "gathering", "routine" ]
[ "func", "(", "bot", "*", "Bot", ")", "handleIncomingMessages", "(", ")", "{", "scan", ":=", "bufio", ".", "NewScanner", "(", "bot", ".", "con", ")", "\n", "for", "scan", ".", "Scan", "(", ")", "{", "// Disconnect if we have seen absolutely nothing for 300 seconds", "bot", ".", "con", ".", "SetDeadline", "(", "time", ".", "Now", "(", ")", ".", "Add", "(", "bot", ".", "PingTimeout", ")", ")", "\n", "msg", ":=", "ParseMessage", "(", "scan", ".", "Text", "(", ")", ")", "\n", "bot", ".", "Debug", "(", "\"", "\"", ",", "\"", "\"", ",", "scan", ".", "<mask>", "(", ")", ",", "\"", "\"", ",", "msg", ".", "To", ",", "\"", "\"", ",", "msg", ".", "From", ",", "\"", "\"", ",", "msg", ".", "Params", ",", "\"", "\"", ",", "msg", ".", "Trailing", ")", "\n", "go", "func", "(", ")", "{", "for", "_", ",", "h", ":=", "range", "bot", ".", "handlers", "{", "if", "h", ".", "Handle", "(", "bot", ",", "msg", ")", "{", "break", "\n", "}", "\n", "}", "\n", "}", "(", ")", "\n", "bot", ".", "Incoming", "<-", "msg", "\n", "}", "\n", "close", "(", "bot", ".", "Incoming", ")", "\n", "}" ]
2,883
all-2884
[ "Do", "executes", "Accessibility", ".", "getFullAXTree", "against", "the", "provided", "context", ".", "returns", ":", "nodes" ]
[ "func", "(", "p", "*", "GetFullAXTreeParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "nodes", "[", "]", "*", "Node", ",", "err", "error", ")", "{", "// execute", "var", "res", "GetFullAXTreeReturns", "\n", "err", "=", "cdp", ".", "Execute", "(", "ctx", ",", "CommandGetFullAXTree", ",", "nil", ",", "&", "res", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "<mask>", ".", "Nodes", ",", "nil", "\n", "}" ]
2,884
all-2885
[ "AddressToAccountId", "converts", "the", "provided", "address", "into", "a", "xdr", ".", "AccountId" ]
[ "func", "AddressToAccountId", "(", "address", "string", ")", "(", "result", "xdr", ".", "AccountId", ",", "err", "error", ")", "{", "bytes", ",", "err", ":=", "strkey", ".", "Decode", "(", "strkey", ".", "VersionByteAccountID", ",", "address", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "<mask>", "raw", "xdr", ".", "Uint256", "\n", "copy", "(", "raw", "[", ":", "]", ",", "bytes", ")", "\n", "pk", ",", "err", ":=", "xdr", ".", "NewPublicKey", "(", "xdr", ".", "CryptoKeyTypeKeyTypeEd25519", ",", "raw", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "result", "=", "xdr", ".", "AccountId", "(", "pk", ")", "\n\n", "return", "\n", "}" ]
2,885
all-2886
[ "Get", "reads", "the", "path", "s", "content", "from", "your", "local", "filesystem", "." ]
[ "func", "(", "l", "ChrootLoader", ")", "Get", "(", "path", "string", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "// Get the full path", "<mask>", ",", "err", ":=", "filepath", ".", "EvalSymlinks", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "basePath", ",", "err", ":=", "filepath", ".", "EvalSymlinks", "(", "l", ".", "Path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Validate that we're under the expected prefix", "if", "!", "strings", ".", "HasPrefix", "(", "path", ",", "basePath", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Open and read the file", "buf", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "bytes", ".", "NewReader", "(", "buf", ")", ",", "nil", "\n", "}" ]
2,886
all-2887
[ "Do", "executes", "Page", ".", "createIsolatedWorld", "against", "the", "provided", "context", ".", "returns", ":", "executionContextID", "-", "Execution", "context", "of", "the", "isolated", "world", "." ]
[ "func", "(", "p", "*", "CreateIsolatedWorldParams", ")", "Do", "(", "ctx", "context", ".", "Context", ")", "(", "executionContextID", "runtime", ".", "ExecutionContextID", ",", "err", "error", ")", "{", "// execute", "var", "<mask>", "CreateIsolatedWorldReturns", "\n", "err", "=", "cdp", ".", "Execute", "(", "ctx", ",", "CommandCreateIsolatedWorld", ",", "p", ",", "&", "res", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "return", "res", ".", "ExecutionContextID", ",", "nil", "\n", "}" ]
2,887
all-2888
[ "Destroy", "destroys", "a", "ZFS", "dataset", ".", "If", "the", "destroy", "bit", "flag", "is", "set", "any", "descendents", "of", "the", "dataset", "will", "be", "recursively", "destroyed", "including", "snapshots", ".", "If", "the", "deferred", "bit", "flag", "is", "set", "the", "snapshot", "is", "marked", "for", "deferred", "deletion", "." ]
[ "func", "(", "d", "*", "Dataset", ")", "Destroy", "(", "flags", "DestroyFlag", ")", "error", "{", "args", ":=", "make", "(", "[", "]", "string", ",", "1", ",", "3", ")", "\n", "args", "[", "0", "]", "=", "\"", "\"", "\n", "if", "flags", "&", "DestroyRecursive", "!=", "0", "{", "args", "=", "append", "(", "args", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "flags", "&", "DestroyRecursiveClones", "!=", "0", "{", "args", "=", "append", "(", "args", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "flags", "&", "DestroyDeferDeletion", "!=", "0", "{", "args", "=", "append", "(", "args", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "flags", "&", "DestroyForceUmount", "!=", "0", "{", "args", "=", "append", "(", "args", ",", "\"", "\"", ")", "\n", "}", "\n\n", "args", "=", "<mask>", "(", "args", ",", "d", ".", "Name", ")", "\n", "_", ",", "err", ":=", "zfs", "(", "args", "...", ")", "\n", "return", "err", "\n", "}" ]
2,888
all-2889
[ "TouchPosition", "returns", "the", "position", "for", "the", "touch", "of", "the", "specified", "ID", ".", "If", "the", "touch", "of", "the", "specified", "ID", "is", "not", "present", "TouchPosition", "returns", "(", "0", "0", ")", ".", "TouchPosition", "is", "cuncurrent", "-", "safe", "." ]
[ "func", "TouchPosition", "(", "id", "int", ")", "(", "int", ",", "int", ")", "{", "found", ":=", "false", "\n", "for", "_", ",", "i", ":=", "range", "uiDriver", "(", ")", ".", "Input", "(", ")", ".", "TouchIDs", "(", ")", "{", "if", "id", "==", "i", "{", "found", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "!", "<mask>", "{", "return", "0", ",", "0", "\n", "}", "\n\n", "return", "uiDriver", "(", ")", ".", "Input", "(", ")", ".", "TouchPosition", "(", "id", ")", "\n", "}" ]
2,889
all-2890
[ "PrependPageMenu", "()", "is", "a", "wrapper", "around", "gtk_notebook_prepend_page_menu", "()", "." ]
[ "func", "(", "v", "*", "Notebook", ")", "PrependPageMenu", "(", "child", "IWidget", ",", "tabLabel", "IWidget", ",", "menuLabel", "IWidget", ")", "int", "{", "c", ":=", "C", ".", "gtk_notebook_prepend_page_menu", "(", "v", ".", "native", "(", ")", ",", "<mask>", ".", "toWidget", "(", ")", ",", "tabLabel", ".", "toWidget", "(", ")", ",", "menuLabel", ".", "toWidget", "(", ")", ")", "\n", "return", "int", "(", "c", ")", "\n", "}" ]
2,890
all-2891
[ "GenPresto", "generates", "a", "Presto", "DSN", "from", "the", "passed", "URL", "." ]
[ "func", "GenPresto", "(", "u", "*", "URL", ")", "(", "string", ",", "error", ")", "{", "z", ":=", "&", "url", ".", "URL", "{", "Scheme", ":", "\"", "\"", ",", "Opaque", ":", "u", ".", "Opaque", ",", "User", ":", "u", ".", "User", ",", "Host", ":", "u", ".", "Host", ",", "RawQuery", ":", "u", ".", "RawQuery", ",", "Fragment", ":", "u", ".", "Fragment", ",", "}", "\n\n", "// change to https", "if", "strings", ".", "HasSuffix", "(", "u", ".", "OriginalScheme", ",", "\"", "\"", ")", "{", "z", ".", "Scheme", "=", "\"", "\"", "\n", "}", "\n\n", "// force user", "if", "z", ".", "User", "==", "nil", "{", "z", ".", "User", "=", "url", ".", "<mask>", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// force host", "if", "z", ".", "Host", "==", "\"", "\"", "{", "z", ".", "Host", "=", "\"", "\"", "\n", "}", "\n\n", "// force port", "if", "hostport", "(", "z", ".", "Host", ")", "==", "\"", "\"", "{", "if", "z", ".", "Scheme", "==", "\"", "\"", "{", "z", ".", "Host", "+=", "\"", "\"", "\n", "}", "else", "if", "z", ".", "Scheme", "==", "\"", "\"", "{", "z", ".", "Host", "+=", "\"", "\"", "\n", "}", "\n", "}", "\n\n", "// add parameters", "q", ":=", "z", ".", "Query", "(", ")", "\n", "dbname", ",", "schema", ":=", "strings", ".", "TrimPrefix", "(", "u", ".", "Path", ",", "\"", "\"", ")", ",", "\"", "\"", "\n", "if", "dbname", "==", "\"", "\"", "{", "dbname", "=", "\"", "\"", "\n", "}", "else", "if", "i", ":=", "strings", ".", "Index", "(", "dbname", ",", "\"", "\"", ")", ";", "i", "!=", "-", "1", "{", "schema", ",", "dbname", "=", "dbname", "[", "i", "+", "1", ":", "]", ",", "dbname", "[", ":", "i", "]", "\n", "}", "\n", "q", ".", "Set", "(", "\"", "\"", ",", "dbname", ")", "\n", "if", "schema", "!=", "\"", "\"", "{", "q", ".", "Set", "(", "\"", "\"", ",", "schema", ")", "\n", "}", "\n", "z", ".", "RawQuery", "=", "q", ".", "Encode", "(", ")", "\n\n", "return", "z", ".", "String", "(", ")", ",", "nil", "\n", "}" ]
2,891
all-2892
[ "UpdateStoragePoolVolumeSnapshot", "updates", "the", "volume", "to", "match", "the", "provided", "StoragePoolVolume", "struct" ]
[ "func", "(", "r", "*", "ProtocolLXD", ")", "UpdateStoragePoolVolumeSnapshot", "(", "pool", "string", ",", "volumeType", "string", ",", "volumeName", "string", ",", "snapshotName", "string", ",", "volume", "api", ".", "StorageVolumeSnapshotPut", ",", "ETag", "string", ")", "error", "{", "if", "!", "r", ".", "HasExtension", "(", "\"", "\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ")", "\n", "}", "\n\n", "// Send the request", "path", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "<mask>", ".", "QueryEscape", "(", "pool", ")", ",", "url", ".", "QueryEscape", "(", "volumeType", ")", ",", "url", ".", "QueryEscape", "(", "volumeName", ")", ",", "url", ".", "QueryEscape", "(", "snapshotName", ")", ")", "\n", "_", ",", "_", ",", "err", ":=", "r", ".", "queryOperation", "(", "\"", "\"", ",", "path", ",", "volume", ",", "ETag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
2,892
all-2893
[ "GetExchangeRates", "gets", "the", "current", "exchange", "rates" ]
[ "func", "(", "c", "Client", ")", "GetExchangeRates", "(", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "holder", ":=", "<mask>", "[", "string", "]", "string", "{", "}", "\n", "if", "err", ":=", "c", ".", "Get", "(", "\"", "\"", ",", "nil", ",", "&", "holder", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "holder", ",", "nil", "\n", "}" ]
2,893
all-2894
[ "Monitor", "indicates", "an", "expected", "call", "of", "Monitor" ]
[ "func", "(", "mr", "*", "MockUdevMockRecorder", ")", "Monitor", "(", "arg0", "<mask>", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockUdev", ")", "(", "nil", ")", ".", "Monitor", ")", ",", "arg0", ")", "\n", "}" ]
2,894
all-2895
[ "SettingsNewWithPath", "is", "a", "wrapper", "around", "g_settings_new_with_path", "()", "." ]
[ "func", "SettingsNewWithPath", "(", "schemaID", ",", "<mask>", "string", ")", "*", "Settings", "{", "cstr1", ":=", "(", "*", "C", ".", "gchar", ")", "(", "C", ".", "CString", "(", "schemaID", ")", ")", "\n", "defer", "C", ".", "free", "(", "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_path", "(", "cstr1", ",", "cstr2", ")", ")", "\n", "}" ]
2,895
all-2896
[ "Let", "s", "say", "we", "want", "to", "send", "the", "a", "container", "a", "including", "snapshots", "snap0", "and", "snap1", "on", "storage", "pool", "pool1", "from", "LXD", "l1", "to", "LXD", "l2", "on", "storage", "pool", "pool2", ":", "The", "pool", "layout", "on", "l1", "would", "be", ":", "pool1", "/", "container_a", "pool1", "/", "container_a" ]
[ "func", "(", "s", "*", "rbdMigrationSourceDriver", ")", "rbdSend", "(", "conn", "*", "websocket", ".", "Conn", ",", "volumeName", "string", ",", "volumeParentName", "string", ",", "readWrapper", "func", "(", "io", ".", "ReadCloser", ")", "io", ".", "ReadCloser", ")", "error", "{", "args", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "s", ".", "ceph", ".", "ClusterName", ",", "volumeName", ",", "}", "\n\n", "if", "volumeParentName", "!=", "\"", "\"", "{", "args", "=", "append", "(", "args", ",", "\"", "\"", ",", "volumeParentName", ")", "\n", "}", "\n\n", "// redirect output to stdout", "args", "=", "append", "(", "args", ",", "\"", "\"", ")", "\n\n", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "args", "...", ")", "\n\n", "stdout", ",", "err", ":=", "cmd", ".", "StdoutPipe", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "readPipe", ":=", "io", ".", "ReadCloser", "(", "stdout", ")", "\n", "if", "readWrapper", "!=", "nil", "{", "readPipe", "=", "readWrapper", "(", "stdout", ")", "\n", "}", "\n\n", "stderr", ",", "err", ":=", "cmd", ".", "StderrPipe", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "cmd", ".", "Start", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "<-", "<mask>", ".", "WebsocketSendStream", "(", "conn", ",", "readPipe", ",", "4", "*", "1024", "*", "1024", ")", "\n\n", "output", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "stderr", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Debugf", "(", "`Failed to read stderr output from \"rbd export-diff\": %s`", ",", "err", ")", "\n", "}", "\n\n", "err", "=", "cmd", ".", "Wait", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Errorf", "(", "`Failed to perform \"rbd export-diff\": %s`", ",", "string", "(", "output", ")", ")", "\n", "}", "\n\n", "return", "err", "\n", "}" ]
2,896
all-2897
[ "Log", "adds", "a", "new", "log", "message", "with", "a", "given", "severity", "level", "." ]
[ "func", "(", "l", "*", "LoggerBase", ")", "Log", "(", "lvl", "Level", ",", "msg", "string", ")", "{", "lvln", ",", "ok", ":=", "levelNums", "[", "lvl", "]", "\n", "if", "!", "ok", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "lvln", "<", "levelNums", "[", "l", ".", "conf", ".", "Level", "]", "{", "return", "\n", "}", "\n\n", "var", "stack", "*", "string", "\n", "if", "lvln", ">=", "levelNums", "[", "l", ".", "conf", ".", "StackLevel", "]", "{", "tmp", ":=", "string", "(", "debug", ".", "Stack", "(", ")", ")", "\n", "<mask>", "=", "&", "tmp", "\n", "}", "\n\n", "if", "err", ":=", "l", ".", "log", "(", "lvl", ",", "msg", ",", "l", ".", "ctx", ",", "stack", ")", ";", "err", "!=", "nil", "{", "panic", "(", "\"", "\"", "+", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n\n", "if", "lvl", "==", "Fatal", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
2,897
all-2898
[ "Upsert", "finds", "a", "single", "document", "matching", "the", "provided", "selector", "document", "and", "modifies", "it", "according", "to", "the", "update", "document", ".", "If", "no", "document", "matching", "the", "selector", "is", "found", "the", "update", "document", "is", "applied", "to", "the", "selector", "document", "and", "the", "result", "is", "inserted", "in", "the", "collection", ".", "If", "the", "session", "is", "in", "safe", "mode", "(", "see", "SetSafe", ")", "details", "of", "the", "executed", "operation", "are", "returned", "in", "info", "or", "an", "error", "of", "type", "*", "LastError", "when", "some", "problem", "is", "detected", ".", "Relevant", "documentation", ":", "http", ":", "//", "www", ".", "mongodb", ".", "org", "/", "display", "/", "DOCS", "/", "Updating", "http", ":", "//", "www", ".", "mongodb", ".", "org", "/", "display", "/", "DOCS", "/", "Atomic", "+", "Operations" ]
[ "func", "(", "c", "*", "<mask>", ")", "Upsert", "(", "selector", "interface", "{", "}", ",", "update", "interface", "{", "}", ")", "(", "info", "*", "ChangeInfo", ",", "err", "error", ")", "{", "lerr", ",", "err", ":=", "c", ".", "writeQuery", "(", "&", "updateOp", "{", "c", ".", "FullName", ",", "selector", ",", "update", ",", "1", "}", ")", "\n", "if", "err", "==", "nil", "&&", "lerr", "!=", "nil", "{", "info", "=", "&", "ChangeInfo", "{", "}", "\n", "if", "lerr", ".", "UpdatedExisting", "{", "info", ".", "Updated", "=", "lerr", ".", "N", "\n", "}", "else", "{", "info", ".", "UpsertedId", "=", "lerr", ".", "UpsertedId", "\n", "}", "\n", "}", "\n", "return", "info", ",", "err", "\n", "}" ]
2,898
all-2899
[ "UnmarshalEasyJSON", "satisfies", "easyjson", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "KeyPathType", ")", "UnmarshalEasyJSON", "(", "in", "*", "jlexer", ".", "Lexer", ")", "{", "switch", "KeyPathType", "(", "in", ".", "String", "(", ")", ")", "{", "case", "KeyPathTypeNull", ":", "*", "t", "=", "KeyPathTypeNull", "\n", "case", "KeyPathTypeString", ":", "*", "t", "=", "KeyPathTypeString", "\n", "case", "KeyPathTypeArray", ":", "*", "t", "=", "KeyPathTypeArray", "\n\n", "default", ":", "in", ".", "AddError", "(", "<mask>", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}" ]
2,899
all-2900
[ "tagByName", "locates", "a", "tag", "by", "it", "supplied", "name", "and", "category", "ID", ".", "Use", "tagCategoryByName", "to", "get", "the", "tag", "category", "ID", "if", "require", "the", "category", "ID", "as", "well", "." ]
[ "func", "tagByName", "(", "client", "*", "tags", ".", "RestClient", ",", "name", ",", "categoryID", "string", ")", "(", "string", ",", "error", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "defaultAPITimeout", ")", "\n", "defer", "cancel", "(", ")", "\n", "tags", ",", "err", ":=", "client", ".", "GetTagByNameForCategory", "(", "ctx", ",", "name", ",", "categoryID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "<mask>", ",", "err", ")", "\n", "}", "\n\n", "if", "len", "(", "tags", ")", "<", "1", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "categoryID", ")", "\n", "}", "\n", "if", "len", "(", "tags", ")", ">", "1", "{", "// This situation is very similar to the one in tagCategoryByName. The API", "// docs even say that tags need to be unique in categories, yet", "// GetTagByNameForCategory still returns multiple results.", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "vSphereTagSearchErrMultiple", ",", "name", ")", "\n", "}", "\n\n", "return", "tags", "[", "0", "]", ".", "ID", ",", "nil", "\n", "}" ]