id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
listlengths
1
418
pl_tokens
listlengths
22
4.98k
18,100
all-18101
[ "Deploy", "runs", "a", "deployment", "of", "an", "application", ".", "It", "will", "first", "try", "to", "run", "an", "archive", "based", "deploy", "(", "if", "opts", ".", "ArchiveURL", "is", "not", "empty", ")", "and", "then", "fallback", "to", "the", "Git", "based", "deployment", "." ]
[ "func", "Deploy", "(", "opts", "DeployOptions", ")", "(", "string", ",", "error", ")", "{", "if", "opts", ".", "Event", "==", "nil", "{", "return", "\"", "\"", ",", "errors", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "opts", ".", "Rollback", "&&", "!", "regexp", ".", "MustCompile", "(", "\"", "\"", ")", ".", "MatchString", "(", "opts", ".", "Image", ")", "{", "imageName", ",", "err", ":=", "<mask>", ".", "GetAppImageBySuffix", "(", "opts", ".", "App", ".", "Name", ",", "opts", ".", "Image", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "opts", ".", "Image", "=", "imageName", "\n", "}", "\n", "logWriter", ":=", "LogWriter", "{", "App", ":", "opts", ".", "App", "}", "\n", "logWriter", ".", "Async", "(", ")", "\n", "defer", "logWriter", ".", "Close", "(", ")", "\n", "opts", ".", "Event", ".", "SetLogWriter", "(", "io", ".", "MultiWriter", "(", "&", "tsuruIo", ".", "NoErrorWriter", "{", "Writer", ":", "opts", ".", "OutputStream", "}", ",", "&", "logWriter", ")", ")", "\n", "imageID", ",", "err", ":=", "deployToProvisioner", "(", "&", "opts", ",", "opts", ".", "Event", ")", "\n", "rebuild", ".", "RoutesRebuildOrEnqueue", "(", "opts", ".", "App", ".", "Name", ")", "\n", "quotaErr", ":=", "opts", ".", "App", ".", "fixQuota", "(", ")", "\n", "if", "quotaErr", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "quotaErr", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "var", "logLines", "[", "]", "Applog", "\n", "if", "provision", ".", "IsStartupError", "(", "err", ")", "{", "logLines", ",", "_", "=", "opts", ".", "App", ".", "lastLogs", "(", "10", ",", "Applog", "{", "Source", ":", "\"", "\"", ",", "}", ",", "true", ")", "\n", "}", "\n", "err", "=", "&", "errorWithLog", "{", "err", ":", "err", ",", "logs", ":", "logLines", "}", "\n", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "err", "=", "incrementDeploy", "(", "opts", ".", "App", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "opts", ")", "\n", "}", "\n", "if", "opts", ".", "Kind", "==", "DeployImage", "||", "opts", ".", "Kind", "==", "DeployRollback", "{", "if", "!", "opts", ".", "App", ".", "UpdatePlatform", "{", "opts", ".", "App", ".", "SetUpdatePlatform", "(", "true", ")", "\n", "}", "\n", "}", "else", "if", "opts", ".", "App", ".", "UpdatePlatform", "{", "opts", ".", "App", ".", "SetUpdatePlatform", "(", "false", ")", "\n", "}", "\n", "return", "imageID", ",", "nil", "\n", "}" ]
18,101
all-18102
[ "FillString", "draws", "the", "text", "at", "point", "(", "0", "0", ")" ]
[ "func", "(", "gc", "*", "GraphicContext", ")", "FillString", "(", "text", "string", ")", "(", "<mask>", "float64", ")", "{", "return", "gc", ".", "FillStringAt", "(", "text", ",", "0", ",", "0", ")", "\n", "}" ]
18,102
all-18103
[ "GetApmQuery", "returns", "the", "ApmQuery", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "c", "*", "ChangeRequest", ")", "GetApmQuery", "(", ")", "WidgetApmOrLogQuery", "{", "if", "c", "==", "nil", "||", "c", ".", "ApmQuery", "==", "nil", "{", "<mask>", "WidgetApmOrLogQuery", "{", "}", "\n", "}", "\n", "return", "*", "c", ".", "ApmQuery", "\n", "}" ]
18,103
all-18104
[ "newFragmentingWriter", "creates", "a", "new", "fragmenting", "writer" ]
[ "func", "newFragmentingWriter", "(", "logger", "Logger", ",", "sender", "fragmentSender", ",", "checksum", "Checksum", ")", "*", "fragmentingWriter", "{", "return", "&", "fragmentingWriter", "{", "logger", ":", "logger", ",", "sender", ":", "sender", ",", "checksum", ":", "checksum", ",", "<mask>", ":", "fragmentingWriteStart", ",", "}", "\n", "}" ]
18,104
all-18105
[ "GetName", "safely", "returns", "the", "name", "of", "the", "resource" ]
[ "func", "(", "auth", "*", "ASMAuthResource", ")", "GetName", "(", ")", "string", "{", "auth", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "auth", ".", "<mask>", ".", "RUnlock", "(", ")", "\n\n", "return", "ResourceName", "\n", "}" ]
18,105
all-18106
[ "finalState", "returns", "true", "if", "the", "prowjob", "has", "already", "finished" ]
[ "func", "finalState", "(", "status", "prowjobv1", ".", "ProwJobState", ")", "bool", "{", "switch", "<mask>", "{", "case", "\"", "\"", ",", "prowjobv1", ".", "PendingState", ",", "prowjobv1", ".", "TriggeredState", ":", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
18,106
all-18107
[ "Add", "adds", "key", "=", "value", "argument", ".", "Multiple", "values", "for", "the", "same", "key", "may", "be", "added", "." ]
[ "func", "(", "a", "*", "Args", ")", "Add", "(", "key", ",", "value", "string", ")", "{", "a", ".", "args", "=", "appendArg", "(", "a", ".", "args", ",", "<mask>", ",", "value", ",", "argsHasValue", ")", "\n", "}" ]
18,107
all-18108
[ "API", "Key", "+", "Secret", "authentication", "requires", "a", "request", "header", "of", "the", "HMAC", "SHA", "-", "256", "signature", "of", "the", "message", "as", "well", "as", "an", "incrementing", "nonce", "and", "the", "API", "key" ]
[ "func", "(", "a", "apiKeyAuthentication", ")", "authenticate", "(", "req", "*", "http", ".", "Request", ",", "endpoint", "string", ",", "params", "[", "]", "byte", ")", "error", "{", "nonce", ":=", "strconv", ".", "FormatInt", "(", "time", ".", "Now", "(", ")", ".", "UTC", "(", ")", ".", "UnixNano", "(", ")", ",", "10", ")", "\n", "message", ":=", "nonce", "+", "endpoint", "+", "string", "(", "params", ")", "//As per Coinbase Documentation", "\n\n", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "a", ".", "Key", ")", "\n\n", "h", ":=", "hmac", ".", "New", "(", "sha256", ".", "New", ",", "[", "]", "byte", "(", "a", ".", "Secret", ")", ")", "\n", "h", ".", "Write", "(", "[", "]", "byte", "(", "message", ")", ")", "\n\n", "signature", ":=", "hex", ".", "EncodeToString", "(", "h", ".", "Sum", "(", "nil", ")", ")", "\n\n", "req", ".", "Header", ".", "<mask>", "(", "\"", "\"", ",", "signature", ")", "\n", "req", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "nonce", ")", "\n\n", "return", "nil", "\n", "}" ]
18,108
all-18109
[ "Earliest", "returns", "the", "earliest", "written", "value", "v", ".", "ok", "will", "be", "true", "unless", "the", "ring", "is", "empty", "in", "which", "case", "ok", "will", "be", "false", "and", "v", "will", "be", "zero", "." ]
[ "func", "(", "b", "*", "Float64RingBuf", ")", "Earliest", "(", ")", "(", "v", "float64", ",", "<mask>", "bool", ")", "{", "if", "b", ".", "Readable", "==", "0", "{", "return", "\n", "}", "\n\n", "return", "b", ".", "A", "[", "b", ".", "Beg", "]", ",", "true", "\n", "}" ]
18,109
all-18110
[ "ServiceInfoFromIncomingContext", "gets", "the", "service", "information", "from", "the", "incoming", "context", "or", "returns", "empty", "strings" ]
[ "func", "ServiceInfoFromIncomingContext", "(", "ctx", "context", ".", "Context", ")", "(", "serviceName", ",", "serviceVersion", ",", "netAddress", "string", ",", "err", "error", ")", "{", "md", ":=", "MetadataFromIncomingContext", "(", "ctx", ")", "\n", "return", "ServiceInfoFromMetadata", "(", "<mask>", ")", "\n", "}" ]
18,110
all-18111
[ "SetValue", "()", "is", "a", "wrapper", "around", "gtk_scale_button_set_value", "()", "." ]
[ "func", "(", "v", "*", "ScaleButton", ")", "SetValue", "(", "value", "float64", ")", "{", "C", ".", "gtk_scale_button_set_value", "(", "v", ".", "native", "(", ")", ",", "C", ".", "gdouble", "(", "<mask>", ")", ")", "\n", "}" ]
18,111
all-18112
[ "Set", "is", "required", "for", "kingpin", "interfaces", "to", "allow", "command", "line", "params", "to", "be", "set", "to", "our", "map", "datatype" ]
[ "func", "(", "o", "*", "MapIntOption", ")", "Set", "(", "value", "string", ")", "error", "{", "parts", ":=", "stringMapRegex", ".", "Split", "(", "value", ",", "2", ")", "\n", "if", "len", "(", "parts", ")", "!=", "2", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "value", ")", "\n", "}", "\n", "val", ":=", "IntOption", "{", "}", "\n", "val", ".", "<mask>", "(", "parts", "[", "1", "]", ")", "\n", "(", "*", "o", ")", "[", "parts", "[", "0", "]", "]", "=", "val", "\n", "return", "nil", "\n", "}" ]
18,112
all-18113
[ "Serve", "the", "application", "at", "the", "specified", "address", "/", "port", "and", "listen", "for", "OS", "interrupt", "and", "kill", "signals", "and", "will", "attempt", "to", "stop", "the", "application", "gracefully", ".", "This", "will", "also", "start", "the", "Worker", "process", "unless", "WorkerOff", "is", "enabled", "." ]
[ "func", "(", "a", "*", "App", ")", "Serve", "(", "srvs", "...", "servers", ".", "Server", ")", "error", "{", "a", ".", "Logger", ".", "Infof", "(", "\"", "\"", ",", "a", ".", "Options", ".", "Addr", ")", "\n\n", "payload", ":=", "events", ".", "Payload", "{", "\"", "\"", ":", "a", ",", "}", "\n", "if", "err", ":=", "events", ".", "EmitPayload", "(", "EvtAppStart", ",", "payload", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "len", "(", "srvs", ")", "==", "0", "{", "if", "strings", ".", "HasPrefix", "(", "a", ".", "Options", ".", "Addr", ",", "\"", "\"", ")", "{", "tcp", ",", "err", ":=", "servers", ".", "UnixSocket", "(", "a", ".", "Options", ".", "Addr", "[", "5", ":", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "srvs", "=", "append", "(", "srvs", ",", "tcp", ")", "\n", "}", "else", "{", "srvs", "=", "append", "(", "srvs", ",", "servers", ".", "New", "(", ")", ")", "\n", "}", "\n", "}", "\n\n", "ctx", ",", "cancel", ":=", "sigtx", ".", "WithCancel", "(", "a", ".", "Context", ",", "syscall", ".", "SIGTERM", ",", "os", ".", "Interrupt", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "go", "func", "(", ")", "{", "// gracefully shut down the application when the context is cancelled", "<-", "ctx", ".", "Done", "(", ")", "\n", "a", ".", "Logger", ".", "Info", "(", "\"", "\"", ")", "\n\n", "events", ".", "EmitError", "(", "EvtAppStop", ",", "ctx", ".", "Err", "(", ")", ",", "payload", ")", "\n\n", "if", "err", ":=", "a", ".", "Stop", "(", "ctx", ".", "Err", "(", ")", ")", ";", "err", "!=", "nil", "{", "events", ".", "EmitError", "(", "EvtAppStopErr", ",", "err", ",", "payload", ")", "\n", "a", ".", "Logger", ".", "Error", "(", "err", ")", "\n", "}", "\n\n", "if", "!", "a", ".", "WorkerOff", "{", "// stop the workers", "a", ".", "Logger", ".", "Info", "(", "\"", "\"", ")", "\n", "events", ".", "EmitPayload", "(", "EvtWorkerStop", ",", "payload", ")", "\n", "if", "err", ":=", "a", ".", "Worker", ".", "Stop", "(", ")", ";", "err", "!=", "nil", "{", "<mask>", ".", "EmitError", "(", "EvtWorkerStopErr", ",", "err", ",", "payload", ")", "\n", "a", ".", "Logger", ".", "Error", "(", "err", ")", "\n", "}", "\n", "}", "\n\n", "for", "_", ",", "s", ":=", "range", "srvs", "{", "if", "err", ":=", "s", ".", "Shutdown", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "a", ".", "Logger", ".", "Error", "(", "err", ")", "\n", "}", "\n", "}", "\n\n", "}", "(", ")", "\n\n", "// if configured to do so, start the workers", "if", "!", "a", ".", "WorkerOff", "{", "go", "func", "(", ")", "{", "events", ".", "EmitPayload", "(", "EvtWorkerStart", ",", "payload", ")", "\n", "if", "err", ":=", "a", ".", "Worker", ".", "Start", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "a", ".", "Stop", "(", "err", ")", "\n", "}", "\n", "}", "(", ")", "\n", "}", "\n\n", "for", "_", ",", "s", ":=", "range", "srvs", "{", "s", ".", "SetAddr", "(", "a", ".", "Addr", ")", "\n", "go", "func", "(", "s", "servers", ".", "Server", ")", "{", "if", "err", ":=", "s", ".", "Start", "(", "ctx", ",", "a", ")", ";", "err", "!=", "nil", "{", "a", ".", "Stop", "(", "err", ")", "\n", "}", "\n", "}", "(", "s", ")", "\n", "}", "\n\n", "<-", "ctx", ".", "Done", "(", ")", "\n\n", "return", "a", ".", "Context", ".", "Err", "(", ")", "\n", "}" ]
18,113
all-18114
[ "MustParseXML", "is", "like", "ParseXML", "but", "panics", "instead", "of", "returning", "an", "error", "." ]
[ "func", "MustParseXML", "(", "r", "io", ".", "Reader", ",", "op", "...", "ParseSettings", ")", "<mask>", ".", "Node", "{", "ret", ",", "err", ":=", "ParseXML", "(", "r", ",", "op", "...", ")", "\n\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n\n", "return", "ret", "\n", "}" ]
18,114
all-18115
[ "AutoDecompress", "takes", "a", "stream", "and", "returns", "an", "uncompressed", "version", "of", "the", "same", "stream", ".", "The", "caller", "must", "call", "Close", "()", "on", "the", "returned", "stream", "(", "even", "if", "the", "input", "does", "not", "need", "or", "does", "not", "even", "support", "closing!", ")", "." ]
[ "func", "AutoDecompress", "(", "stream", "io", ".", "Reader", ")", "(", "<mask>", ".", "ReadCloser", ",", "bool", ",", "error", ")", "{", "decompressor", ",", "stream", ",", "err", ":=", "DetectCompression", "(", "stream", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "false", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "var", "res", "io", ".", "ReadCloser", "\n", "if", "decompressor", "!=", "nil", "{", "res", ",", "err", "=", "decompressor", "(", "stream", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "false", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "else", "{", "res", "=", "ioutil", ".", "NopCloser", "(", "stream", ")", "\n", "}", "\n", "return", "res", ",", "decompressor", "!=", "nil", ",", "nil", "\n", "}" ]
18,115
all-18116
[ "LOCKS_EXCLUDED", "(", "t", ".", "mu", ")" ]
[ "func", "(", "t", "*", "throttle", ")", "Wait", "(", "ctx", "context", ".", "Context", ",", "tokens", "uint64", ")", "(", "err", "error", ")", "{", "now", ":=", "MonotonicTime", "(", "time", ".", "Now", "(", ")", ".", "Sub", "(", "t", ".", "startTime", ")", ")", "\n\n", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "sleepUntil", ":=", "t", ".", "bucket", ".", "Remove", "(", "now", ",", "tokens", ")", "\n", "t", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "select", "{", "<mask>", "<-", "ctx", ".", "Done", "(", ")", ":", "err", "=", "ctx", ".", "Err", "(", ")", "\n", "return", "\n\n", "case", "<-", "time", ".", "After", "(", "time", ".", "Duration", "(", "sleepUntil", "-", "now", ")", ")", ":", "return", "\n", "}", "\n", "}" ]
18,116
all-18117
[ "process", "goes", "through", "arguments", "one", "-", "by", "-", "one", "parses", "them", "and", "assigns", "the", "result", "to", "the", "underlying", "struct", "field" ]
[ "func", "process", "(", "specs", "[", "]", "*", "spec", ",", "args", "[", "]", "string", ")", "error", "{", "// track the options we have seen", "wasPresent", ":=", "make", "(", "map", "[", "*", "spec", "]", "bool", ")", "\n\n", "// construct a map from --option to spec", "optionMap", ":=", "make", "(", "map", "[", "string", "]", "*", "spec", ")", "\n", "for", "_", ",", "spec", ":=", "range", "specs", "{", "if", "spec", ".", "positional", "{", "continue", "\n", "}", "\n", "if", "spec", ".", "long", "!=", "\"", "\"", "{", "optionMap", "[", "spec", ".", "long", "]", "=", "spec", "\n", "}", "\n", "if", "spec", ".", "short", "!=", "\"", "\"", "{", "optionMap", "[", "spec", ".", "short", "]", "=", "spec", "\n", "}", "\n", "}", "\n\n", "// deal with environment vars", "for", "_", ",", "spec", ":=", "range", "specs", "{", "if", "spec", ".", "env", "==", "\"", "\"", "{", "continue", "\n", "}", "\n\n", "value", ",", "found", ":=", "os", ".", "LookupEnv", "(", "spec", ".", "env", ")", "\n", "if", "!", "found", "{", "continue", "\n", "}", "\n\n", "if", "spec", ".", "<mask>", "{", "// expect a CSV string in an environment", "// variable in the case of multiple values", "values", ",", "err", ":=", "csv", ".", "NewReader", "(", "strings", ".", "NewReader", "(", "value", ")", ")", ".", "Read", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "spec", ".", "env", ",", "err", ",", ")", "\n", "}", "\n", "if", "err", "=", "setSlice", "(", "spec", ".", "dest", ",", "values", ",", "!", "spec", ".", "separate", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "spec", ".", "env", ",", "err", ",", ")", "\n", "}", "\n", "}", "else", "{", "if", "err", ":=", "scalar", ".", "ParseValue", "(", "spec", ".", "dest", ",", "value", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "spec", ".", "env", ",", "err", ")", "\n", "}", "\n", "}", "\n", "wasPresent", "[", "spec", "]", "=", "true", "\n", "}", "\n\n", "// process each string from the command line", "var", "allpositional", "bool", "\n", "var", "positionals", "[", "]", "string", "\n\n", "// must use explicit for loop, not range, because we manipulate i inside the loop", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "args", ")", ";", "i", "++", "{", "arg", ":=", "args", "[", "i", "]", "\n", "if", "arg", "==", "\"", "\"", "{", "allpositional", "=", "true", "\n", "continue", "\n", "}", "\n\n", "if", "!", "isFlag", "(", "arg", ")", "||", "allpositional", "{", "positionals", "=", "append", "(", "positionals", ",", "arg", ")", "\n", "continue", "\n", "}", "\n\n", "// check for an equals sign, as in \"--foo=bar\"", "var", "value", "string", "\n", "opt", ":=", "strings", ".", "TrimLeft", "(", "arg", ",", "\"", "\"", ")", "\n", "if", "pos", ":=", "strings", ".", "Index", "(", "opt", ",", "\"", "\"", ")", ";", "pos", "!=", "-", "1", "{", "value", "=", "opt", "[", "pos", "+", "1", ":", "]", "\n", "opt", "=", "opt", "[", ":", "pos", "]", "\n", "}", "\n\n", "// lookup the spec for this option", "spec", ",", "ok", ":=", "optionMap", "[", "opt", "]", "\n", "if", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "arg", ")", "\n", "}", "\n", "wasPresent", "[", "spec", "]", "=", "true", "\n\n", "// deal with the case of multiple values", "if", "spec", ".", "multiple", "{", "var", "values", "[", "]", "string", "\n", "if", "value", "==", "\"", "\"", "{", "for", "i", "+", "1", "<", "len", "(", "args", ")", "&&", "!", "isFlag", "(", "args", "[", "i", "+", "1", "]", ")", "{", "values", "=", "append", "(", "values", ",", "args", "[", "i", "+", "1", "]", ")", "\n", "i", "++", "\n", "if", "spec", ".", "separate", "{", "break", "\n", "}", "\n", "}", "\n", "}", "else", "{", "values", "=", "append", "(", "values", ",", "value", ")", "\n", "}", "\n", "err", ":=", "setSlice", "(", "spec", ".", "dest", ",", "values", ",", "!", "spec", ".", "separate", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "arg", ",", "err", ")", "\n", "}", "\n", "continue", "\n", "}", "\n\n", "// if it's a flag and it has no value then set the value to true", "// use boolean because this takes account of TextUnmarshaler", "if", "spec", ".", "boolean", "&&", "value", "==", "\"", "\"", "{", "value", "=", "\"", "\"", "\n", "}", "\n\n", "// if we have something like \"--foo\" then the value is the next argument", "if", "value", "==", "\"", "\"", "{", "if", "i", "+", "1", "==", "len", "(", "args", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "arg", ")", "\n", "}", "\n", "if", "!", "nextIsNumeric", "(", "spec", ".", "dest", ".", "Type", "(", ")", ",", "args", "[", "i", "+", "1", "]", ")", "&&", "isFlag", "(", "args", "[", "i", "+", "1", "]", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "arg", ")", "\n", "}", "\n", "value", "=", "args", "[", "i", "+", "1", "]", "\n", "i", "++", "\n", "}", "\n\n", "err", ":=", "scalar", ".", "ParseValue", "(", "spec", ".", "dest", ",", "value", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "arg", ",", "err", ")", "\n", "}", "\n", "}", "\n\n", "// process positionals", "for", "_", ",", "spec", ":=", "range", "specs", "{", "if", "!", "spec", ".", "positional", "{", "continue", "\n", "}", "\n", "if", "len", "(", "positionals", ")", "==", "0", "{", "break", "\n", "}", "\n", "wasPresent", "[", "spec", "]", "=", "true", "\n", "if", "spec", ".", "multiple", "{", "err", ":=", "setSlice", "(", "spec", ".", "dest", ",", "positionals", ",", "true", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "spec", ".", "long", ",", "err", ")", "\n", "}", "\n", "positionals", "=", "nil", "\n", "}", "else", "{", "err", ":=", "scalar", ".", "ParseValue", "(", "spec", ".", "dest", ",", "positionals", "[", "0", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "spec", ".", "long", ",", "err", ")", "\n", "}", "\n", "positionals", "=", "positionals", "[", "1", ":", "]", "\n", "}", "\n", "}", "\n", "if", "len", "(", "positionals", ")", ">", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "positionals", "[", "0", "]", ")", "\n", "}", "\n\n", "// finally check that all the required args were provided", "for", "_", ",", "spec", ":=", "range", "specs", "{", "if", "spec", ".", "required", "&&", "!", "wasPresent", "[", "spec", "]", "{", "name", ":=", "spec", ".", "long", "\n", "if", "!", "spec", ".", "positional", "{", "name", "=", "\"", "\"", "+", "spec", ".", "long", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
18,117
all-18118
[ "GetMessageOk", "returns", "a", "tuple", "with", "the", "Message", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "m", "*", "Monitor", ")", "GetMessageOk", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "m", "==", "nil", "||", "m", ".", "Message", "==", "nil", "{", "return", "\"", "\"", ",", "false", "\n", "}", "\n", "return", "*", "m", ".", "<mask>", ",", "true", "\n", "}" ]
18,118
all-18119
[ "HandleHealth", "registers", "health", "handler", "on", "/", "health", "." ]
[ "func", "HandleHealth", "(", "mux", "*", "<mask>", ".", "ServeMux", ",", "c", "*", "clientv3", ".", "Client", ")", "{", "mux", ".", "Handle", "(", "etcdhttp", ".", "PathHealth", ",", "etcdhttp", ".", "NewHealthHandler", "(", "func", "(", ")", "etcdhttp", ".", "Health", "{", "return", "checkHealth", "(", "c", ")", "}", ")", ")", "\n", "}" ]
18,119
all-18120
[ "ProfileSample", "will", "wrap", "a", "writer", "and", "reader", "pair", "and", "collect", "samples", "of", "where", "time", "is", "spent", ":", "writing", "or", "reading", ".", "The", "result", "is", "an", "approximation", "that", "is", "returned", "when", "the", "done", "func", "is", "called", ".", "The", "done", "func", "can", "be", "called", "*", "only", "once", "*", ".", "This", "call", "is", "not", "as", "precise", "as", "the", "Profile", "call", "but", "the", "performance", "overhead", "is", "much", "reduced", "." ]
[ "func", "ProfileSample", "(", "w", "<mask>", ".", "Writer", ",", "r", "io", ".", "Reader", ",", "res", "time", ".", "Duration", ")", "(", "pw", "io", ".", "Writer", ",", "pr", "io", ".", "Reader", ",", "done", "func", "(", ")", "SamplingProfile", ")", "{", "return", "profileSample", "(", "clock", ".", "New", "(", ")", ",", "w", ",", "r", ",", "res", ")", "\n", "}" ]
18,120
all-18121
[ "IsDone", "returns", "false", "while", "the", "iterator", "is", "valid", "and", "can", "produce", "another", "value", "via", "a", "call", "to", "Next", "()" ]
[ "func", "(", "<mask>", "*", "inclusiveRangesIt", ")", "IsDone", "(", ")", "bool", "{", "if", "!", "it", ".", "init", "(", ")", "{", "return", "true", "\n", "}", "\n\n", "return", "it", ".", "current", ".", "IsDone", "(", ")", "\n", "}" ]
18,121
all-18122
[ "Last", "checks", "if", "the", "name", "is", "the", "last", "of", "the", "parts" ]
[ "func", "(", "opts", "Options", ")", "Last", "(", "n", "<mask>", ".", "Ident", ")", "bool", "{", "return", "opts", ".", "Parts", "[", "len", "(", "opts", ".", "Parts", ")", "-", "1", "]", ".", "String", "(", ")", "==", "n", ".", "String", "(", ")", "\n", "}" ]
18,122
all-18123
[ "Watch", "does", "nothing", "on", "a", "dry", "-", "run", "client" ]
[ "func", "(", "c", "*", "dryRunProwJobClient", ")", "Watch", "(", "opts", "metav1", ".", "ListOptions", ")", "(", "<mask>", ".", "Interface", ",", "error", ")", "{", "return", "nil", ",", "nil", "\n", "}" ]
18,123
all-18124
[ "create", "or", "replace", "a", "display", "list" ]
[ "func", "NewList", "(", "<mask>", "uint32", ",", "mode", "uint32", ")", "{", "C", ".", "glowNewList", "(", "gpNewList", ",", "(", "C", ".", "GLuint", ")", "(", "list", ")", ",", "(", "C", ".", "GLenum", ")", "(", "mode", ")", ")", "\n", "}" ]
18,124
all-18125
[ "GetHasSelection", "()", "is", "a", "wrapper", "around", "gtk_print_operation_get_has_selection", "()", "." ]
[ "func", "(", "po", "*", "PrintOperation", ")", "GetHasSelection", "(", ")", "bool", "{", "c", ":=", "C", ".", "gtk_print_operation_get_has_selection", "(", "<mask>", ".", "native", "(", ")", ")", "\n", "return", "gobool", "(", "c", ")", "\n", "}" ]
18,125
all-18126
[ "Select", "implements", "storage", ".", "Querier", "and", "uses", "the", "given", "matchers", "to", "read", "series", "sets", "from", "the", "Client", "." ]
[ "func", "(", "q", "*", "querier", ")", "Select", "(", "p", "*", "storage", ".", "SelectParams", ",", "matchers", "...", "*", "labels", ".", "Matcher", ")", "(", "storage", ".", "SeriesSet", ",", "storage", ".", "Warnings", ",", "error", ")", "{", "query", ",", "err", ":=", "ToQuery", "(", "q", ".", "mint", ",", "q", ".", "maxt", ",", "matchers", ",", "p", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "remoteReadGauge", ":=", "remoteReadQueries", ".", "WithLabelValues", "(", "q", ".", "client", ".", "Name", "(", ")", ")", "\n", "remoteReadGauge", ".", "Inc", "(", ")", "\n", "defer", "remoteReadGauge", ".", "Dec", "(", ")", "\n\n", "<mask>", ",", "err", ":=", "q", ".", "client", ".", "Read", "(", "q", ".", "ctx", ",", "query", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "return", "FromQueryResult", "(", "res", ")", ",", "nil", ",", "nil", "\n", "}" ]
18,126
all-18127
[ "writeToMetadata", "puts", "the", "metadata", "into", "JSON", "format", "and", "writes", "into", "the", "metadata", "file" ]
[ "func", "writeToMetadataFile", "(", "osWrap", "oswrapper", ".", "OS", ",", "ioutilWrap", "ioutilwrapper", ".", "IOUtil", ",", "data", "[", "]", "byte", ",", "taskARN", "string", ",", "containerName", "string", ",", "dataDir", "string", ")", "error", "{", "metadataFileDir", ",", "err", ":=", "getMetadataFilePath", "(", "taskARN", ",", "containerName", ",", "dataDir", ")", "\n", "// Boundary case if file path is bad (Such as if task arn is incorrectly formatted)", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "taskARN", ",", "containerName", ",", "err", ")", "\n", "}", "\n", "metadataFileName", ":=", "filepath", ".", "Join", "(", "metadataFileDir", ",", "metadataFile", ")", "\n\n", "file", ",", "err", ":=", "osWrap", ".", "OpenFile", "(", "metadataFileName", ",", "<mask>", ".", "O_WRONLY", "|", "os", ".", "O_CREATE", ",", "metadataPerm", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "file", ".", "Close", "(", ")", "\n\n", "_", ",", "err", "=", "file", ".", "Write", "(", "data", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "file", ".", "Sync", "(", ")", "\n", "}" ]
18,127
all-18128
[ "Finalize", "ensures", "there", "no", "nil", "pointers", "." ]
[ "func", "(", "c", "*", "SyslogConfig", ")", "Finalize", "(", ")", "{", "if", "c", ".", "Enabled", "==", "nil", "{", "c", ".", "Enabled", "=", "Bool", "(", "StringPresent", "(", "c", ".", "Facility", ")", ")", "\n", "}", "\n\n", "if", "c", ".", "Facility", "==", "nil", "{", "c", ".", "Facility", "=", "<mask>", "(", "DefaultSyslogFacility", ")", "\n", "}", "\n", "}" ]
18,128
all-18129
[ "lex", "creates", "a", "new", "scanner", "for", "the", "input", "string", "." ]
[ "func", "lex", "(", "input", "string", ")", "*", "lexer", "{", "l", ":=", "&", "lexer", "{", "input", ":", "input", ",", "items", ":", "make", "(", "chan", "<mask>", ")", ",", "}", "\n", "go", "l", ".", "run", "(", ")", "\n", "return", "l", "\n", "}" ]
18,129
all-18130
[ "NewStorage", "creates", "a", "new", "Storage", "." ]
[ "func", "NewStorage", "(", "objC", "obj", ".", "Client", ",", "prefix", "string", ")", "*", "<mask>", "{", "return", "&", "Storage", "{", "objC", ":", "objC", ",", "prefix", ":", "prefix", ",", "}", "\n", "}" ]
18,130
all-18131
[ "Specify", "the", "value", "of", "a", "uniform", "variable", "for", "the", "current", "program", "object" ]
[ "func", "Uniform3fv", "(", "location", "int32", ",", "count", "int32", ",", "value", "*", "float32", ")", "{", "syscall", ".", "Syscall", "(", "gpUniform3fv", ",", "3", ",", "uintptr", "(", "location", ")", ",", "uintptr", "(", "<mask>", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "value", ")", ")", ")", "\n", "}" ]
18,131
all-18132
[ "Wait", "lets", "you", "wait", "until", "the", "operation", "reaches", "a", "final", "state" ]
[ "func", "(", "op", "*", "remoteOperation", ")", "Wait", "(", ")", "error", "{", "<-", "op", ".", "chDone", "\n\n", "if", "op", ".", "chPost", "!=", "nil", "{", "<-", "op", ".", "chPost", "\n", "}", "\n\n", "return", "op", ".", "<mask>", "\n", "}" ]
18,132
all-18133
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "GetBestEffortCoverageParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoProfiler20", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
18,133
all-18134
[ "GetApmQueryOk", "returns", "a", "tuple", "with", "the", "ApmQuery", "field", "if", "it", "s", "non", "-", "nil", "zero", "value", "otherwise", "and", "a", "boolean", "to", "check", "if", "the", "value", "has", "been", "set", "." ]
[ "func", "(", "t", "*", "ToplistRequest", ")", "GetApmQueryOk", "(", ")", "(", "WidgetApmOrLogQuery", ",", "bool", ")", "{", "if", "t", "==", "nil", "||", "t", ".", "ApmQuery", "==", "nil", "{", "return", "WidgetApmOrLogQuery", "{", "}", ",", "false", "\n", "}", "\n", "return", "*", "t", ".", "ApmQuery", ",", "<mask>", "\n", "}" ]
18,134
all-18135
[ "WriteToEventStream", "writes", "event", "to", "the", "event", "stream" ]
[ "func", "(", "eventStream", "*", "EventStream", ")", "WriteToEventStream", "(", "<mask>", "interface", "{", "}", ")", "error", "{", "eventStream", ".", "statusLock", ".", "RLock", "(", ")", "\n", "defer", "eventStream", ".", "statusLock", ".", "RUnlock", "(", ")", "\n\n", "if", "!", "eventStream", ".", "open", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "eventStream", ".", "event", "<-", "event", "\n", "return", "nil", "\n", "}" ]
18,135
all-18136
[ "Scan", "implements", "sql", ".", "Scanner", "so", "UUIDs", "can", "be", "read", "from", "databases", "transparently", "Currently", "database", "types", "that", "map", "to", "string", "and", "[]", "byte", "are", "supported", ".", "Please", "consult", "database", "-", "specific", "driver", "documentation", "for", "matching", "types", "." ]
[ "func", "(", "uuid", "*", "UUID", ")", "Scan", "(", "src", "interface", "{", "}", ")", "error", "{", "switch", "src", ":=", "src", ".", "(", "type", ")", "{", "case", "nil", ":", "return", "nil", "\n\n", "case", "string", ":", "// if an empty UUID comes from a table, we return a null UUID", "if", "src", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "// see Parse for required string format", "u", ",", "err", ":=", "Parse", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "*", "uuid", "=", "u", "\n\n", "case", "[", "]", "byte", ":", "// if an empty UUID comes from a table, we return a null UUID", "if", "len", "(", "src", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "// assumes a simple slice of bytes if 16 bytes", "// otherwise attempts to parse", "if", "len", "(", "src", ")", "!=", "16", "{", "return", "uuid", ".", "Scan", "(", "string", "(", "src", ")", ")", "\n", "}", "\n", "copy", "(", "(", "*", "uuid", ")", "[", ":", "]", ",", "src", ")", "\n\n", "<mask>", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "src", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
18,136
all-18137
[ "Same", "as", "findHeapInfo", "but", "allocates", "the", "heapInfo", "if", "it", "hasn", "t", "been", "allocated", "yet", "." ]
[ "func", "(", "p", "*", "Process", ")", "allocHeapInfo", "(", "a", "core", ".", "Address", ")", "*", "heapInfo", "{", "k", ":=", "a", "/", "heapInfoSize", "/", "pageTableSize", "\n", "i", ":=", "a", "/", "heapInfoSize", "%", "pageTableSize", "\n", "t", ":=", "p", ".", "pageTable", "[", "k", "]", "\n", "if", "t", "==", "nil", "{", "t", "=", "new", "(", "pageTableEntry", ")", "\n", "for", "j", ":=", "0", ";", "j", "<", "pageTableSize", ";", "j", "++", "{", "t", "[", "j", "]", ".", "firstIdx", "=", "-", "1", "\n", "}", "\n", "p", ".", "pageTable", "[", "k", "]", "=", "t", "\n", "p", ".", "<mask>", "=", "append", "(", "p", ".", "pages", ",", "k", ")", "\n", "}", "\n", "return", "&", "t", "[", "i", "]", "\n", "}" ]
18,137
all-18138
[ "clone", "function", "clones", "the", "watcherHub", "and", "return", "the", "cloned", "one", ".", "only", "clone", "the", "static", "content", ".", "do", "not", "clone", "the", "current", "watchers", "." ]
[ "func", "(", "wh", "*", "watcherHub", ")", "clone", "(", ")", "*", "watcherHub", "{", "clonedHistory", ":=", "wh", ".", "EventHistory", ".", "<mask>", "(", ")", "\n\n", "return", "&", "watcherHub", "{", "EventHistory", ":", "clonedHistory", ",", "}", "\n", "}" ]
18,138
all-18139
[ "AcceleratorParse", "is", "a", "wrapper", "around", "gtk_accelerator_parse", "()", "." ]
[ "func", "AcceleratorParse", "(", "acc", "string", ")", "(", "key", "uint", ",", "<mask>", "gdk", ".", "ModifierType", ")", "{", "cstr", ":=", "C", ".", "CString", "(", "acc", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cstr", ")", ")", "\n\n", "k", ":=", "C", ".", "guint", "(", "0", ")", "\n", "m", ":=", "C", ".", "GdkModifierType", "(", "0", ")", "\n\n", "C", ".", "gtk_accelerator_parse", "(", "(", "*", "C", ".", "gchar", ")", "(", "cstr", ")", ",", "&", "k", ",", "&", "m", ")", "\n", "return", "uint", "(", "k", ")", ",", "gdk", ".", "ModifierType", "(", "m", ")", "\n", "}" ]
18,139
all-18140
[ "ToStringInterfaceMap", "encodes", "fields", "tagged", "with", "tagName", "in", "input", "into", "map", "[", "string", "]", "interface", "{}", ".", "Optional", "argument", "properties", "specifies", "fields", "to", "encode", "." ]
[ "func", "ToStringInterfaceMap", "(", "tagName", "string", ",", "input", "interface", "{", "}", ",", "properties", "...", "string", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "vmap", ":=", "imap", "(", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", ")", "\n", "s", ":=", "structs", ".", "New", "(", "input", ")", "\n", "s", ".", "TagName", "=", "tagName", "\n", "if", "len", "(", "properties", ")", "==", "0", "{", "properties", "=", "s", ".", "Names", "(", ")", "\n", "}", "\n\n", "for", "_", ",", "field", ":=", "range", "s", ".", "Fields", "(", ")", "{", "if", "!", "<mask>", ".", "IsExported", "(", ")", "{", "continue", "\n", "}", "\n\n", "if", "!", "stringInSlice", "(", "field", ".", "Name", "(", ")", ",", "properties", ")", "{", "continue", "\n", "}", "\n\n", "fieldName", ",", "opts", ":=", "parseTag", "(", "field", ".", "Tag", "(", "tagName", ")", ")", "\n", "squash", ",", "omitempty", ",", "include", ":=", "opts", ".", "Has", "(", "\"", "\"", ")", ",", "opts", ".", "Has", "(", "\"", "\"", ")", ",", "opts", ".", "Has", "(", "\"", "\"", ")", "\n", "if", "!", "squash", "&&", "(", "fieldName", "==", "\"", "\"", "||", "fieldName", "==", "\"", "\"", ")", "{", "continue", "\n", "}", "\n\n", "val", ":=", "field", ".", "Value", "(", ")", "\n\n", "if", "omitempty", "{", "if", "field", ".", "IsZero", "(", ")", "{", "continue", "\n", "}", "\n", "if", "z", ",", "ok", ":=", "val", ".", "(", "isZeroer", ")", ";", "ok", "&&", "z", ".", "IsZero", "(", ")", "{", "continue", "\n", "}", "\n", "if", "z", ",", "ok", ":=", "val", ".", "(", "isEmptier", ")", ";", "ok", "&&", "z", ".", "IsEmpty", "(", ")", "{", "continue", "\n", "}", "\n", "}", "\n\n", "kind", ":=", "field", ".", "Kind", "(", ")", "\n", "if", "kind", "==", "reflect", ".", "Ptr", "{", "v", ":=", "reflect", ".", "ValueOf", "(", "val", ")", "\n", "if", "v", ".", "IsNil", "(", ")", "{", "if", "fieldName", "!=", "\"", "\"", "&&", "fieldName", "!=", "\"", "\"", "{", "vmap", ".", "Set", "(", "fieldName", ",", "nil", ")", "\n", "}", "\n", "continue", "\n", "}", "\n", "elem", ":=", "v", ".", "Elem", "(", ")", "\n", "kind", "=", "elem", ".", "Kind", "(", ")", "\n", "val", "=", "elem", ".", "Interface", "(", ")", "\n", "}", "\n\n", "if", "(", "squash", "||", "include", ")", "&&", "kind", "==", "reflect", ".", "Struct", "{", "var", "newProperties", "[", "]", "string", "\n", "for", "_", ",", "prop", ":=", "range", "properties", "{", "if", "strings", ".", "HasPrefix", "(", "prop", ",", "field", ".", "Name", "(", ")", "+", "\"", "\"", ")", "{", "newProperties", "=", "append", "(", "newProperties", ",", "strings", ".", "TrimPrefix", "(", "prop", ",", "field", ".", "Name", "(", ")", "+", "\"", "\"", ")", ")", "\n", "}", "\n", "}", "\n", "m", ",", "err", ":=", "ToStringInterfaceMap", "(", "tagName", ",", "val", ",", "newProperties", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "prefix", "string", "\n", "if", "!", "squash", "{", "prefix", "=", "fieldName", "+", "\"", "\"", "\n", "}", "\n\n", "for", "k", ",", "v", ":=", "range", "m", "{", "vmap", ".", "Set", "(", "prefix", "+", "k", ",", "v", ")", "\n", "}", "\n", "continue", "\n", "}", "\n\n", "vmap", ".", "Set", "(", "fieldName", ",", "val", ")", "\n", "}", "\n", "return", "vmap", ",", "nil", "\n", "}" ]
18,140
all-18141
[ "EncodeItem", "encodes", "in", "[", "2", "byte", "len", "]", "[", "item_bytes", "]", "format", "." ]
[ "func", "(", "m", "*", "Nitro", ")", "EncodeItem", "(", "itm", "*", "Item", ",", "buf", "[", "]", "byte", ",", "w", "io", ".", "Writer", ")", "error", "{", "l", ":=", "2", "\n", "if", "len", "(", "buf", ")", "<", "l", "{", "return", "errNotEnoughSpace", "\n", "}", "\n\n", "<mask>", ".", "BigEndian", ".", "PutUint16", "(", "buf", "[", "0", ":", "2", "]", ",", "uint16", "(", "itm", ".", "dataLen", ")", ")", "\n", "if", "_", ",", "err", ":=", "w", ".", "Write", "(", "buf", "[", "0", ":", "2", "]", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "_", ",", "err", ":=", "w", ".", "Write", "(", "itm", ".", "Bytes", "(", ")", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
18,141
all-18142
[ "UnmarshalJSON", "deserialises", "the", "raw", "JSON", "to", "a", "ASMSecretResource", "struct" ]
[ "func", "(", "secret", "*", "ASMSecretResource", ")", "UnmarshalJSON", "(", "b", "[", "]", "byte", ")", "error", "{", "temp", ":=", "ASMSecretResourceJSON", "{", "}", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "<mask>", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "temp", ".", "DesiredStatus", "!=", "nil", "{", "secret", ".", "SetDesiredStatus", "(", "resourcestatus", ".", "ResourceStatus", "(", "*", "temp", ".", "DesiredStatus", ")", ")", "\n", "}", "\n", "if", "temp", ".", "KnownStatus", "!=", "nil", "{", "secret", ".", "SetKnownStatus", "(", "resourcestatus", ".", "ResourceStatus", "(", "*", "temp", ".", "KnownStatus", ")", ")", "\n", "}", "\n", "if", "temp", ".", "CreatedAt", "!=", "nil", "&&", "!", "temp", ".", "CreatedAt", ".", "IsZero", "(", ")", "{", "secret", ".", "SetCreatedAt", "(", "*", "temp", ".", "CreatedAt", ")", "\n", "}", "\n", "if", "temp", ".", "RequiredSecrets", "!=", "nil", "{", "secret", ".", "requiredSecrets", "=", "temp", ".", "RequiredSecrets", "\n", "}", "\n", "secret", ".", "taskARN", "=", "temp", ".", "TaskARN", "\n", "secret", ".", "executionCredentialsID", "=", "temp", ".", "ExecutionCredentialsID", "\n\n", "return", "nil", "\n", "}" ]
18,142
all-18143
[ "RaftNodeDelete", "removes", "a", "node", "from", "the", "current", "list", "of", "LXD", "nodes", "that", "are", "part", "of", "the", "dqlite", "Raft", "cluster", "." ]
[ "func", "(", "n", "*", "NodeTx", ")", "RaftNodeDelete", "(", "id", "int64", ")", "error", "{", "deleted", ",", "err", ":=", "<mask>", ".", "DeleteObject", "(", "n", ".", "tx", ",", "\"", "\"", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "!", "deleted", "{", "return", "ErrNoSuchObject", "\n", "}", "\n", "return", "nil", "\n", "}" ]
18,143
all-18144
[ "ReadObject", "implements", "jsonrpc2", ".", "ObjectStream", "." ]
[ "func", "(", "t", "ObjectStream", ")", "ReadObject", "(", "v", "interface", "{", "}", ")", "error", "{", "err", ":=", "t", ".", "conn", ".", "ReadJSON", "(", "v", ")", "\n", "if", "e", ",", "<mask>", ":=", "err", ".", "(", "*", "websocket", ".", "CloseError", ")", ";", "ok", "{", "if", "e", ".", "Code", "==", "websocket", ".", "CloseAbnormalClosure", "&&", "e", ".", "Text", "==", "io", ".", "ErrUnexpectedEOF", ".", "Error", "(", ")", "{", "// Suppress a noisy (but harmless) log message by", "// unwrapping this error.", "err", "=", "io", ".", "ErrUnexpectedEOF", "\n", "}", "\n", "}", "\n", "return", "err", "\n", "}" ]
18,144
all-18145
[ "InvertedFrameRange", "returns", "a", "new", "frame", "range", "string", "that", "represents", "all", "frames", "*", "not", "*", "within", "the", "current", "FrameSet", ".", "That", "is", "it", "will", "create", "a", "range", "that", "fills", "in", "the", "current", "one", "." ]
[ "func", "(", "s", "*", "FrameSet", ")", "InvertedFrameRange", "(", "pad", "int", ")", "string", "{", "frange", ":=", "s", ".", "rangePtr", ".", "Inverted", "(", ")", ".", "<mask>", "(", ")", "\n", "if", "pad", ">", "1", "{", "frange", "=", "PadFrameRange", "(", "frange", ",", "pad", ")", "\n", "}", "\n", "return", "frange", "\n", "}" ]
18,145
all-18146
[ "GetPullStoppedAt", "returns", "the", "PullStoppedAt", "timestamp" ]
[ "func", "(", "task", "*", "<mask>", ")", "GetPullStoppedAt", "(", ")", "time", ".", "Time", "{", "task", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "task", ".", "lock", ".", "RUnlock", "(", ")", "\n\n", "return", "task", ".", "PullStoppedAtUnsafe", "\n", "}" ]
18,146
all-18147
[ "GetAppFromUnitID", "returns", "app", "from", "unit", "id" ]
[ "func", "(", "p", "*", "dockerProvisioner", ")", "GetAppFromUnitID", "(", "unitID", "string", ")", "(", "provision", ".", "App", ",", "error", ")", "{", "cnt", ",", "err", ":=", "p", ".", "GetContainer", "(", "unitID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "a", ",", "<mask>", ":=", "app", ".", "GetByName", "(", "cnt", ".", "AppName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "a", ",", "nil", "\n", "}" ]
18,147
all-18148
[ "ContainerProfilesInsert", "associates", "the", "container", "with", "the", "given", "ID", "with", "the", "profiles", "with", "the", "given", "names", "in", "the", "given", "project", "." ]
[ "func", "ContainerProfilesInsert", "(", "tx", "*", "sql", ".", "Tx", ",", "id", "int", ",", "project", "string", ",", "profiles", "[", "]", "string", ")", "error", "{", "enabled", ",", "err", ":=", "projectHasProfiles", "(", "tx", ",", "project", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "!", "enabled", "{", "project", "=", "\"", "\"", "\n", "}", "\n\n", "applyOrder", ":=", "1", "\n", "str", ":=", "`\nINSERT INTO containers_profiles (container_id, profile_id, apply_order)\n VALUES (\n ?,\n (SELECT profiles.id\n FROM profiles\n JOIN projects ON projects.id=profiles.project_id\n WHERE projects.name=? AND profiles.name=?),\n ?\n )\n`", "\n", "stmt", ",", "err", ":=", "tx", ".", "Prepare", "(", "str", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "stmt", ".", "Close", "(", ")", "\n", "for", "_", ",", "<mask>", ":=", "range", "profiles", "{", "_", ",", "err", "=", "stmt", ".", "Exec", "(", "id", ",", "project", ",", "profile", ",", "applyOrder", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "profile", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n", "applyOrder", "=", "applyOrder", "+", "1", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
18,148
all-18149
[ "FromRequest", "return", "client", "s", "real", "public", "IP", "address", "from", "http", "request", "headers", "." ]
[ "func", "FromRequest", "(", "r", "*", "http", ".", "Request", ")", "string", "{", "// Fetch header value", "xRealIP", ":=", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "xForwardedFor", ":=", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n\n", "// If both empty, return IP from remote address", "if", "xRealIP", "==", "\"", "\"", "&&", "xForwardedFor", "==", "\"", "\"", "{", "var", "remoteIP", "string", "\n\n", "// If there are colon in remote address, remove the port number", "// otherwise, return remote address as is", "if", "strings", ".", "ContainsRune", "(", "r", ".", "RemoteAddr", ",", "':'", ")", "{", "remoteIP", ",", "_", ",", "_", "=", "<mask>", ".", "SplitHostPort", "(", "r", ".", "RemoteAddr", ")", "\n", "}", "else", "{", "remoteIP", "=", "r", ".", "RemoteAddr", "\n", "}", "\n\n", "return", "remoteIP", "\n", "}", "\n\n", "// Check list of IP in X-Forwarded-For and return the first global address", "for", "_", ",", "address", ":=", "range", "strings", ".", "Split", "(", "xForwardedFor", ",", "\"", "\"", ")", "{", "address", "=", "strings", ".", "TrimSpace", "(", "address", ")", "\n", "isPrivate", ",", "err", ":=", "isPrivateAddress", "(", "address", ")", "\n", "if", "!", "isPrivate", "&&", "err", "==", "nil", "{", "return", "address", "\n", "}", "\n", "}", "\n\n", "// If nothing succeed, return X-Real-IP", "return", "xRealIP", "\n", "}" ]
18,149
all-18150
[ "MarshalEasyJSON", "satisfies", "easyjson", ".", "Marshaler", "." ]
[ "func", "(", "t", "ConnectionType", ")", "MarshalEasyJSON", "(", "<mask>", "*", "jwriter", ".", "Writer", ")", "{", "out", ".", "String", "(", "string", "(", "t", ")", ")", "\n", "}" ]
18,150
all-18151
[ "processMountOperations", "processes", "all", "pending", "mount", "operations", "by", "diffing", "old", "and", "new", "and", "adding", "any", "hosts", "that", "were", "not", "found", "in", "old", ".", "The", "datastore", "is", "returned", "along", "with", "any", "error", "." ]
[ "func", "(", "p", "*", "nasDatastoreMountProcessor", ")", "processMountOperations", "(", ")", "(", "*", "<mask>", ".", "Datastore", ",", "error", ")", "{", "hosts", ":=", "p", ".", "diffNewOld", "(", ")", "\n", "if", "len", "(", "hosts", ")", "<", "1", "{", "// Nothing to do", "return", "p", ".", "ds", ",", "nil", "\n", "}", "\n", "// Validate we are vCenter if we are working with multiple hosts", "if", "len", "(", "hosts", ")", ">", "1", "{", "if", "err", ":=", "viapi", ".", "ValidateVirtualCenter", "(", "p", ".", "client", ")", ";", "err", "!=", "nil", "{", "return", "p", ".", "ds", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n", "for", "_", ",", "hsID", ":=", "range", "hosts", "{", "dss", ",", "err", ":=", "hostDatastoreSystemFromHostSystemID", "(", "p", ".", "client", ",", "hsID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "p", ".", "ds", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "hostsystem", ".", "NameOrID", "(", "p", ".", "client", ",", "hsID", ")", ",", "err", ")", "\n", "}", "\n", "ctx", ",", "cancel", ":=", "context", ".", "WithTimeout", "(", "context", ".", "Background", "(", ")", ",", "defaultAPITimeout", ")", "\n", "defer", "cancel", "(", ")", "\n", "ds", ",", "err", ":=", "dss", ".", "CreateNasDatastore", "(", "ctx", ",", "*", "p", ".", "volSpec", ")", "\n", "if", "err", "!=", "nil", "{", "return", "p", ".", "ds", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "hostsystem", ".", "NameOrID", "(", "p", ".", "client", ",", "hsID", ")", ",", "err", ")", "\n", "}", "\n", "if", "err", ":=", "p", ".", "validateDatastore", "(", "ds", ")", ";", "err", "!=", "nil", "{", "return", "p", ".", "ds", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "hostsystem", ".", "NameOrID", "(", "p", ".", "client", ",", "hsID", ")", ",", "err", ")", "\n", "}", "\n", "}", "\n", "return", "p", ".", "ds", ",", "nil", "\n", "}" ]
18,151
all-18152
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventAccepted", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoTethering1", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "<mask>", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
18,152
all-18153
[ "WriteMessage", "wraps", "the", "low", "level", "websocket", "write", "method", "with", "a", "lock" ]
[ "func", "(", "cs", "*", "ClientServerImpl", ")", "WriteMessage", "(", "send", "[", "]", "byte", ")", "error", "{", "cs", ".", "writeLock", ".", "Lock", "(", ")", "\n", "defer", "cs", ".", "writeLock", ".", "Unlock", "(", ")", "\n\n", "// This is just future proofing. Ignore the error as the gorilla websocket", "// library returns 'nil' anyway for SetWriteDeadline", "// https://github.com/gorilla/websocket/blob/4201258b820c74ac8e6922fc9e6b52f71fe46f8d/conn.go#L761", "if", "err", ":=", "cs", ".", "conn", ".", "SetWriteDeadline", "(", "time", ".", "Now", "(", ")", ".", "Add", "(", "cs", ".", "RWTimeout", ")", ")", ";", "err", "!=", "nil", "{", "seelog", ".", "Warnf", "(", "\"", "\"", ",", "err", ",", "cs", ".", "URL", ")", "\n", "}", "\n\n", "return", "<mask>", ".", "conn", ".", "WriteMessage", "(", "websocket", ".", "TextMessage", ",", "send", ")", "\n", "}" ]
18,153
all-18154
[ "HasMin", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "y", "*", "Yaxis", ")", "HasMin", "(", ")", "bool", "{", "if", "y", "!=", "nil", "&&", "y", ".", "Min", "!=", "nil", "{", "return", "true", "\n", "}", "\n\n", "return", "<mask>", "\n", "}" ]
18,154
all-18155
[ "SetMaxWidthChars", "is", "a", "wrapper", "around", "gtk_label_set_max_width_chars", "()", "." ]
[ "func", "(", "v", "*", "<mask>", ")", "SetMaxWidthChars", "(", "nChars", "int", ")", "{", "C", ".", "gtk_label_set_max_width_chars", "(", "v", ".", "native", "(", ")", ",", "C", ".", "gint", "(", "nChars", ")", ")", "\n", "}" ]
18,155
all-18156
[ "Performs", "handshake", "and", "returns", "a", "new", "authenticated", "SecretConnection", ".", "Returns", "nil", "if", "error", "in", "handshake", ".", "Caller", "should", "call", "conn", ".", "Close", "()", "See", "docs", "/", "sts", "-", "final", ".", "pdf", "for", "more", "information", "." ]
[ "func", "MakeSecretConnection", "(", "<mask>", "io", ".", "ReadWriteCloser", ",", "locPrivKey", "crypto", ".", "PrivKeyEd25519", ")", "(", "*", "SecretConnection", ",", "error", ")", "{", "locPubKey", ":=", "locPrivKey", ".", "PubKey", "(", ")", ".", "(", "crypto", ".", "PubKeyEd25519", ")", "\n\n", "// Generate ephemeral keys for perfect forward secrecy.", "locEphPub", ",", "locEphPriv", ":=", "genEphKeys", "(", ")", "\n\n", "// Write local ephemeral pubkey and receive one too.", "// NOTE: every 32-byte string is accepted as a Curve25519 public key", "// (see DJB's Curve25519 paper: http://cr.yp.to/ecdh/curve25519-20060209.pdf)", "remEphPub", ",", "err", ":=", "shareEphPubKey", "(", "conn", ",", "locEphPub", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Compute common shared secret.", "shrSecret", ":=", "computeSharedSecret", "(", "remEphPub", ",", "locEphPriv", ")", "\n\n", "// Sort by lexical order.", "loEphPub", ",", "hiEphPub", ":=", "sort32", "(", "locEphPub", ",", "remEphPub", ")", "\n\n", "// Generate nonces to use for secretbox.", "recvNonce", ",", "sendNonce", ":=", "genNonces", "(", "loEphPub", ",", "hiEphPub", ",", "locEphPub", "==", "loEphPub", ")", "\n\n", "// Generate common challenge to sign.", "challenge", ":=", "genChallenge", "(", "loEphPub", ",", "hiEphPub", ")", "\n\n", "// Construct SecretConnection.", "sc", ":=", "&", "SecretConnection", "{", "conn", ":", "conn", ",", "recvBuffer", ":", "nil", ",", "recvNonce", ":", "recvNonce", ",", "sendNonce", ":", "sendNonce", ",", "shrSecret", ":", "shrSecret", ",", "}", "\n\n", "// Sign the challenge bytes for authentication.", "locSignature", ":=", "signChallenge", "(", "challenge", ",", "locPrivKey", ")", "\n\n", "// Share (in secret) each other's pubkey & challenge signature", "authSigMsg", ",", "err", ":=", "shareAuthSignature", "(", "sc", ",", "locPubKey", ",", "locSignature", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "remPubKey", ",", "remSignature", ":=", "authSigMsg", ".", "Key", ",", "authSigMsg", ".", "Sig", "\n", "if", "!", "remPubKey", ".", "VerifyBytes", "(", "challenge", "[", ":", "]", ",", "remSignature", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// We've authorized.", "sc", ".", "remPubKey", "=", "remPubKey", ".", "(", "crypto", ".", "PubKeyEd25519", ")", "\n", "return", "sc", ",", "nil", "\n", "}" ]
18,156
all-18157
[ "DeepCopyInto", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "writing", "into", "out", ".", "in", "must", "be", "non", "-", "nil", "." ]
[ "func", "(", "<mask>", "*", "ProwJobStatus", ")", "DeepCopyInto", "(", "out", "*", "ProwJobStatus", ")", "{", "*", "out", "=", "*", "in", "\n", "in", ".", "StartTime", ".", "DeepCopyInto", "(", "&", "out", ".", "StartTime", ")", "\n", "if", "in", ".", "CompletionTime", "!=", "nil", "{", "in", ",", "out", ":=", "&", "in", ".", "CompletionTime", ",", "&", "out", ".", "CompletionTime", "\n", "*", "out", "=", "(", "*", "in", ")", ".", "DeepCopy", "(", ")", "\n", "}", "\n", "if", "in", ".", "PrevReportStates", "!=", "nil", "{", "in", ",", "out", ":=", "&", "in", ".", "PrevReportStates", ",", "&", "out", ".", "PrevReportStates", "\n", "*", "out", "=", "make", "(", "map", "[", "string", "]", "ProwJobState", ",", "len", "(", "*", "in", ")", ")", "\n", "for", "key", ",", "val", ":=", "range", "*", "in", "{", "(", "*", "out", ")", "[", "key", "]", "=", "val", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
18,157
all-18158
[ "Traverses", "recursively", "both", "values", "assigning", "src", "s", "fields", "values", "to", "dst", ".", "The", "map", "argument", "tracks", "comparisons", "that", "have", "already", "been", "seen", "which", "allows", "short", "circuiting", "on", "recursive", "types", "." ]
[ "func", "deepMerge", "(", "dst", ",", "src", "reflect", ".", "Value", ",", "visited", "map", "[", "uintptr", "]", "*", "visit", ",", "depth", "int", ",", "config", "*", "Config", ")", "(", "err", "error", ")", "{", "overwrite", ":=", "config", ".", "Overwrite", "\n", "typeCheck", ":=", "config", ".", "TypeCheck", "\n", "overwriteWithEmptySrc", ":=", "config", ".", "overwriteWithEmptyValue", "\n", "config", ".", "overwriteWithEmptyValue", "=", "false", "\n\n", "if", "!", "src", ".", "IsValid", "(", ")", "{", "return", "\n", "}", "\n", "if", "dst", ".", "CanAddr", "(", ")", "{", "addr", ":=", "dst", ".", "UnsafeAddr", "(", ")", "\n", "h", ":=", "17", "*", "addr", "\n", "seen", ":=", "visited", "[", "h", "]", "\n", "typ", ":=", "dst", ".", "Type", "(", ")", "\n", "for", "p", ":=", "<mask>", ";", "p", "!=", "nil", ";", "p", "=", "p", ".", "next", "{", "if", "p", ".", "ptr", "==", "addr", "&&", "p", ".", "typ", "==", "typ", "{", "return", "nil", "\n", "}", "\n", "}", "\n", "// Remember, remember...", "visited", "[", "h", "]", "=", "&", "visit", "{", "addr", ",", "typ", ",", "seen", "}", "\n", "}", "\n\n", "if", "config", ".", "Transformers", "!=", "nil", "&&", "!", "isEmptyValue", "(", "dst", ")", "{", "if", "fn", ":=", "config", ".", "Transformers", ".", "Transformer", "(", "dst", ".", "Type", "(", ")", ")", ";", "fn", "!=", "nil", "{", "err", "=", "fn", "(", "dst", ",", "src", ")", "\n", "return", "\n", "}", "\n", "}", "\n\n", "switch", "dst", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Struct", ":", "if", "hasExportedField", "(", "dst", ")", "{", "for", "i", ",", "n", ":=", "0", ",", "dst", ".", "NumField", "(", ")", ";", "i", "<", "n", ";", "i", "++", "{", "if", "err", "=", "deepMerge", "(", "dst", ".", "Field", "(", "i", ")", ",", "src", ".", "Field", "(", "i", ")", ",", "visited", ",", "depth", "+", "1", ",", "config", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "}", "\n", "}", "else", "{", "if", "dst", ".", "CanSet", "(", ")", "&&", "(", "!", "isEmptyValue", "(", "src", ")", "||", "overwriteWithEmptySrc", ")", "&&", "(", "overwrite", "||", "isEmptyValue", "(", "dst", ")", ")", "{", "dst", ".", "Set", "(", "src", ")", "\n", "}", "\n", "}", "\n", "case", "reflect", ".", "Map", ":", "if", "dst", ".", "IsNil", "(", ")", "&&", "!", "src", ".", "IsNil", "(", ")", "{", "dst", ".", "Set", "(", "reflect", ".", "MakeMap", "(", "dst", ".", "Type", "(", ")", ")", ")", "\n", "}", "\n", "for", "_", ",", "key", ":=", "range", "src", ".", "MapKeys", "(", ")", "{", "srcElement", ":=", "src", ".", "MapIndex", "(", "key", ")", "\n", "if", "!", "srcElement", ".", "IsValid", "(", ")", "{", "continue", "\n", "}", "\n", "dstElement", ":=", "dst", ".", "MapIndex", "(", "key", ")", "\n", "switch", "srcElement", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Chan", ",", "reflect", ".", "Func", ",", "reflect", ".", "Map", ",", "reflect", ".", "Interface", ",", "reflect", ".", "Slice", ":", "if", "srcElement", ".", "IsNil", "(", ")", "{", "continue", "\n", "}", "\n", "fallthrough", "\n", "default", ":", "if", "!", "srcElement", ".", "CanInterface", "(", ")", "{", "continue", "\n", "}", "\n", "switch", "reflect", ".", "TypeOf", "(", "srcElement", ".", "Interface", "(", ")", ")", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Struct", ":", "fallthrough", "\n", "case", "reflect", ".", "Ptr", ":", "fallthrough", "\n", "case", "reflect", ".", "Map", ":", "srcMapElm", ":=", "srcElement", "\n", "dstMapElm", ":=", "dstElement", "\n", "if", "srcMapElm", ".", "CanInterface", "(", ")", "{", "srcMapElm", "=", "reflect", ".", "ValueOf", "(", "srcMapElm", ".", "Interface", "(", ")", ")", "\n", "if", "dstMapElm", ".", "IsValid", "(", ")", "{", "dstMapElm", "=", "reflect", ".", "ValueOf", "(", "dstMapElm", ".", "Interface", "(", ")", ")", "\n", "}", "\n", "}", "\n", "if", "err", "=", "deepMerge", "(", "dstMapElm", ",", "srcMapElm", ",", "visited", ",", "depth", "+", "1", ",", "config", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "case", "reflect", ".", "Slice", ":", "srcSlice", ":=", "reflect", ".", "ValueOf", "(", "srcElement", ".", "Interface", "(", ")", ")", "\n\n", "var", "dstSlice", "reflect", ".", "Value", "\n", "if", "!", "dstElement", ".", "IsValid", "(", ")", "||", "dstElement", ".", "IsNil", "(", ")", "{", "dstSlice", "=", "reflect", ".", "MakeSlice", "(", "srcSlice", ".", "Type", "(", ")", ",", "0", ",", "srcSlice", ".", "Len", "(", ")", ")", "\n", "}", "else", "{", "dstSlice", "=", "reflect", ".", "ValueOf", "(", "dstElement", ".", "Interface", "(", ")", ")", "\n", "}", "\n\n", "if", "(", "!", "isEmptyValue", "(", "src", ")", "||", "overwriteWithEmptySrc", ")", "&&", "(", "overwrite", "||", "isEmptyValue", "(", "dst", ")", ")", "&&", "!", "config", ".", "AppendSlice", "{", "if", "typeCheck", "&&", "srcSlice", ".", "Type", "(", ")", "!=", "dstSlice", ".", "Type", "(", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "srcSlice", ".", "Type", "(", ")", ",", "dstSlice", ".", "Type", "(", ")", ")", "\n", "}", "\n", "dstSlice", "=", "srcSlice", "\n", "}", "else", "if", "config", ".", "AppendSlice", "{", "if", "srcSlice", ".", "Type", "(", ")", "!=", "dstSlice", ".", "Type", "(", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "srcSlice", ".", "Type", "(", ")", ",", "dstSlice", ".", "Type", "(", ")", ")", "\n", "}", "\n", "dstSlice", "=", "reflect", ".", "AppendSlice", "(", "dstSlice", ",", "srcSlice", ")", "\n", "}", "\n", "dst", ".", "SetMapIndex", "(", "key", ",", "dstSlice", ")", "\n", "}", "\n", "}", "\n", "if", "dstElement", ".", "IsValid", "(", ")", "&&", "!", "isEmptyValue", "(", "dstElement", ")", "&&", "(", "reflect", ".", "TypeOf", "(", "srcElement", ".", "Interface", "(", ")", ")", ".", "Kind", "(", ")", "==", "reflect", ".", "Map", "||", "reflect", ".", "TypeOf", "(", "srcElement", ".", "Interface", "(", ")", ")", ".", "Kind", "(", ")", "==", "reflect", ".", "Slice", ")", "{", "continue", "\n", "}", "\n\n", "if", "srcElement", ".", "IsValid", "(", ")", "&&", "(", "overwrite", "||", "(", "!", "dstElement", ".", "IsValid", "(", ")", "||", "isEmptyValue", "(", "dstElement", ")", ")", ")", "{", "if", "dst", ".", "IsNil", "(", ")", "{", "dst", ".", "Set", "(", "reflect", ".", "MakeMap", "(", "dst", ".", "Type", "(", ")", ")", ")", "\n", "}", "\n", "dst", ".", "SetMapIndex", "(", "key", ",", "srcElement", ")", "\n", "}", "\n", "}", "\n", "case", "reflect", ".", "Slice", ":", "if", "!", "dst", ".", "CanSet", "(", ")", "{", "break", "\n", "}", "\n", "if", "(", "!", "isEmptyValue", "(", "src", ")", "||", "overwriteWithEmptySrc", ")", "&&", "(", "overwrite", "||", "isEmptyValue", "(", "dst", ")", ")", "&&", "!", "config", ".", "AppendSlice", "{", "dst", ".", "Set", "(", "src", ")", "\n", "}", "else", "if", "config", ".", "AppendSlice", "{", "if", "src", ".", "Type", "(", ")", "!=", "dst", ".", "Type", "(", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "src", ".", "Type", "(", ")", ",", "dst", ".", "Type", "(", ")", ")", "\n", "}", "\n", "dst", ".", "Set", "(", "reflect", ".", "AppendSlice", "(", "dst", ",", "src", ")", ")", "\n", "}", "\n", "case", "reflect", ".", "Ptr", ":", "fallthrough", "\n", "case", "reflect", ".", "Interface", ":", "if", "src", ".", "IsNil", "(", ")", "{", "break", "\n", "}", "\n\n", "if", "dst", ".", "Kind", "(", ")", "!=", "reflect", ".", "Ptr", "&&", "src", ".", "Type", "(", ")", ".", "AssignableTo", "(", "dst", ".", "Type", "(", ")", ")", "{", "if", "dst", ".", "IsNil", "(", ")", "||", "overwrite", "{", "if", "dst", ".", "CanSet", "(", ")", "&&", "(", "overwrite", "||", "isEmptyValue", "(", "dst", ")", ")", "{", "dst", ".", "Set", "(", "src", ")", "\n", "}", "\n", "}", "\n", "break", "\n", "}", "\n\n", "if", "src", ".", "Kind", "(", ")", "!=", "reflect", ".", "Interface", "{", "if", "dst", ".", "IsNil", "(", ")", "||", "overwrite", "{", "if", "dst", ".", "CanSet", "(", ")", "&&", "(", "overwrite", "||", "isEmptyValue", "(", "dst", ")", ")", "{", "dst", ".", "Set", "(", "src", ")", "\n", "}", "\n", "}", "else", "if", "src", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "if", "err", "=", "deepMerge", "(", "dst", ".", "Elem", "(", ")", ",", "src", ".", "Elem", "(", ")", ",", "visited", ",", "depth", "+", "1", ",", "config", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "}", "else", "if", "dst", ".", "Elem", "(", ")", ".", "Type", "(", ")", "==", "src", ".", "Type", "(", ")", "{", "if", "err", "=", "deepMerge", "(", "dst", ".", "Elem", "(", ")", ",", "src", ",", "visited", ",", "depth", "+", "1", ",", "config", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "}", "else", "{", "return", "ErrDifferentArgumentsTypes", "\n", "}", "\n", "break", "\n", "}", "\n", "if", "dst", ".", "IsNil", "(", ")", "||", "overwrite", "{", "if", "dst", ".", "CanSet", "(", ")", "&&", "(", "overwrite", "||", "isEmptyValue", "(", "dst", ")", ")", "{", "dst", ".", "Set", "(", "src", ")", "\n", "}", "\n", "}", "else", "if", "err", "=", "deepMerge", "(", "dst", ".", "Elem", "(", ")", ",", "src", ".", "Elem", "(", ")", ",", "visited", ",", "depth", "+", "1", ",", "config", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "default", ":", "if", "dst", ".", "CanSet", "(", ")", "&&", "(", "!", "isEmptyValue", "(", "src", ")", "||", "overwriteWithEmptySrc", ")", "&&", "(", "overwrite", "||", "isEmptyValue", "(", "dst", ")", ")", "{", "dst", ".", "Set", "(", "src", ")", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
18,158
all-18159
[ "NOTE", ":", "UNSAFE" ]
[ "func", "EncodeFloat32", "(", "w", "<mask>", ".", "Writer", ",", "f", "float32", ")", "(", "err", "error", ")", "{", "return", "EncodeUint32", "(", "w", ",", "math", ".", "Float32bits", "(", "f", ")", ")", "\n", "}" ]
18,159
all-18160
[ "FileGetLines", "returns", "a", "string", "slice", "with", "the", "text", "lines", "of", "filenameOrURL", ".", "The", "lines", "can", "be", "separated", "by", "\\", "n", "or", "\\", "r", "\\", "n", "." ]
[ "func", "FileGetLines", "(", "filenameOrURL", "string", ",", "timeout", "...", "<mask>", ".", "Duration", ")", "(", "lines", "[", "]", "string", ",", "err", "error", ")", "{", "data", ",", "err", ":=", "FileGetBytes", "(", "filenameOrURL", ",", "timeout", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "lastR", ":=", "-", "1", "\n", "lastN", ":=", "-", "1", "\n", "for", "i", ",", "c", ":=", "range", "data", "{", "if", "c", "==", "'\\r'", "{", "l", ":=", "string", "(", "data", "[", "lastN", "+", "1", ":", "i", "]", ")", "\n", "lines", "=", "append", "(", "lines", ",", "l", ")", "\n", "lastR", "=", "i", "\n", "}", "\n", "if", "c", "==", "'\\n'", "{", "if", "i", "!=", "lastR", "+", "1", "{", "l", ":=", "string", "(", "data", "[", "lastN", "+", "1", ":", "i", "]", ")", "\n", "lines", "=", "append", "(", "lines", ",", "l", ")", "\n", "}", "\n", "lastN", "=", "i", "\n", "}", "\n", "}", "\n", "l", ":=", "string", "(", "data", "[", "lastN", "+", "1", ":", "]", ")", "\n", "lines", "=", "append", "(", "lines", ",", "l", ")", "\n", "return", "lines", ",", "nil", "\n", "}" ]
18,160
all-18161
[ "resourceVSphereVirtualMachineUpdateReconfigureWithSDRS", "runs", "the", "reconfigure", "part", "of", "resourceVSphereVirtualMachineUpdate", "through", "storage", "DRS", ".", "It", "s", "designed", "to", "be", "run", "when", "a", "storage", "cluster", "is", "specified", "versus", "simply", "specifying", "datastores", "." ]
[ "func", "resourceVSphereVirtualMachineUpdateReconfigureWithSDRS", "(", "d", "*", "schema", ".", "ResourceData", ",", "meta", "interface", "{", "}", ",", "vm", "*", "object", ".", "VirtualMachine", ",", "spec", "types", ".", "VirtualMachineConfigSpec", ",", ")", "error", "{", "// Check to see if we have any disk creation operations first, as sending an", "// update through SDRS without any disk creation operations will fail.", "if", "!", "storagepod", ".", "HasDiskCreationOperations", "(", "spec", ".", "DeviceChange", ")", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "vm", ".", "InventoryPath", ")", "\n", "return", "virtualmachine", ".", "Reconfigure", "(", "vm", ",", "spec", ")", "\n", "}", "\n\n", "<mask>", ":=", "meta", ".", "(", "*", "VSphereClient", ")", ".", "vimClient", "\n", "if", "err", ":=", "viapi", ".", "ValidateVirtualCenter", "(", "client", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "log", ".", "Printf", "(", "\"", "\"", ",", "resourceVSphereVirtualMachineIDString", "(", "d", ")", ")", "\n", "pod", ",", "err", ":=", "storagepod", ".", "FromID", "(", "client", ",", "d", ".", "Get", "(", "\"", "\"", ")", ".", "(", "string", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "err", "=", "storagepod", ".", "ReconfigureVM", "(", "client", ",", "vm", ",", "spec", ",", "pod", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pod", ".", "Name", "(", ")", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
18,161
all-18162
[ "bind", "a", "named", "texture", "to", "a", "texturing", "target" ]
[ "func", "BindTexture", "(", "target", "uint32", ",", "texture", "uint32", ")", "{", "C", ".", "glowBindTexture", "(", "gpBindTexture", ",", "(", "C", ".", "GLenum", ")", "(", "<mask>", ")", ",", "(", "C", ".", "GLuint", ")", "(", "texture", ")", ")", "\n", "}" ]
18,162
all-18163
[ "Change", "the", "values", "of", "this", "configuration", "Map", ".", "Return", "a", "map", "of", "key", "/", "value", "pairs", "that", "were", "actually", "changed", ".", "If", "some", "keys", "fail", "to", "apply", "details", "are", "included", "in", "the", "returned", "ErrorList", "." ]
[ "func", "(", "m", "*", "Map", ")", "Change", "(", "changes", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "values", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "m", ".", "schema", ")", ")", "\n\n", "errors", ":=", "ErrorList", "{", "}", "\n", "for", "name", ",", "change", ":=", "range", "changes", "{", "key", ",", "ok", ":=", "m", ".", "schema", "[", "name", "]", "\n\n", "// When a hidden value is set to \"true\" in the change set, it", "// means \"keep it unchanged\", so we replace it with our current", "// value.", "if", "ok", "&&", "key", ".", "Hidden", "&&", "change", "==", "true", "{", "change", "=", "m", ".", "GetRaw", "(", "name", ")", "\n", "}", "\n\n", "// A nil object means the empty string.", "if", "change", "==", "nil", "{", "change", "=", "\"", "\"", "\n", "}", "\n\n", "// Sanity check that we were actually passed a string.", "s", ":=", "reflect", ".", "ValueOf", "(", "<mask>", ")", "\n", "if", "s", ".", "Kind", "(", ")", "!=", "reflect", ".", "String", "{", "errors", ".", "add", "(", "name", ",", "nil", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "Kind", "(", ")", ")", ")", "\n", "continue", "\n", "}", "\n\n", "values", "[", "name", "]", "=", "change", ".", "(", "string", ")", "\n", "}", "\n\n", "if", "errors", ".", "Len", "(", ")", ">", "0", "{", "return", "nil", ",", "errors", "\n", "}", "\n\n", "// Any key not explicitly set, is considered unset.", "for", "name", ",", "key", ":=", "range", "m", ".", "schema", "{", "_", ",", "ok", ":=", "values", "[", "name", "]", "\n", "if", "!", "ok", "{", "values", "[", "name", "]", "=", "key", ".", "Default", "\n", "}", "\n", "}", "\n\n", "names", ",", "err", ":=", "m", ".", "update", "(", "values", ")", "\n\n", "changed", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "for", "_", ",", "name", ":=", "range", "names", "{", "changed", "[", "name", "]", "=", "m", ".", "GetRaw", "(", "name", ")", "\n", "}", "\n", "return", "changed", ",", "err", "\n", "}" ]
18,163
all-18164
[ "Numbers", "emits", "the", "integers", "x", "..", "y" ]
[ "func", "Numbers", "(", "x", ",", "y", "int", ")", "<mask>", "{", "return", "FilterFunc", "(", "func", "(", "arg", "Arg", ")", "error", "{", "for", "i", ":=", "x", ";", "i", "<=", "y", ";", "i", "++", "{", "arg", ".", "Out", "<-", "fmt", ".", "Sprint", "(", "i", ")", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "}" ]
18,164
all-18165
[ "Float32", "adds", "a", "float32", "-", "valued", "key", ":", "value", "pair", "to", "a", "Span", ".", "LogFields", "()", "record" ]
[ "func", "Float32", "(", "key", "string", ",", "val", "float32", ")", "Field", "{", "return", "Field", "{", "key", ":", "<mask>", ",", "fieldType", ":", "float32Type", ",", "numericVal", ":", "int64", "(", "math", ".", "Float32bits", "(", "val", ")", ")", ",", "}", "\n", "}" ]
18,165
all-18166
[ "DecodeArray", "provides", "the", "implementation", "of", "the", "algorithm", "for", "decoding", "arrays", "where", "f", "is", "called", "to", "decode", "each", "element", "of", "the", "array", "." ]
[ "func", "(", "d", "Decoder", ")", "DecodeArray", "(", "f", "func", "(", "Decoder", ")", "error", ")", "(", "err", "error", ")", "{", "<mask>", "typ", "Type", "\n\n", "if", "d", ".", "off", "!=", "0", "{", "if", "d", ".", "off", ",", "err", "=", "0", ",", "d", ".", "Parser", ".", "ParseMapValue", "(", "d", ".", "off", "-", "1", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "}", "\n\n", "if", "typ", ",", "err", "=", "d", ".", "Parser", ".", "ParseType", "(", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "err", "=", "d", ".", "decodeArrayImpl", "(", "typ", ",", "f", ")", "\n", "return", "\n", "}" ]
18,166
all-18167
[ "Do", "performs", "the", "given", "http", "request", "and", "fills", "the", "given", "http", "response", ".", "Request", "must", "contain", "at", "least", "non", "-", "zero", "RequestURI", "with", "full", "url", "(", "including", "scheme", "and", "host", ")", "or", "non", "-", "zero", "Host", "header", "+", "RequestURI", ".", "Client", "determines", "the", "server", "to", "be", "requested", "in", "the", "following", "order", ":", "-", "from", "RequestURI", "if", "it", "contains", "full", "url", "with", "scheme", "and", "host", ";", "-", "from", "Host", "header", "otherwise", ".", "The", "function", "doesn", "t", "follow", "redirects", ".", "Use", "Get", "*", "for", "following", "redirects", ".", "Response", "is", "ignored", "if", "resp", "is", "nil", ".", "ErrNoFreeConns", "is", "returned", "if", "all", "DefaultMaxConnsPerHost", "connections", "to", "the", "requested", "host", "are", "busy", ".", "It", "is", "recommended", "obtaining", "req", "and", "resp", "via", "AcquireRequest", "and", "AcquireResponse", "in", "performance", "-", "critical", "code", "." ]
[ "func", "Do", "(", "req", "*", "Request", ",", "resp", "*", "<mask>", ")", "error", "{", "return", "defaultClient", ".", "Do", "(", "req", ",", "resp", ")", "\n", "}" ]
18,167
all-18168
[ "Replace", "a", "suffix", "and", "adjust", "R1start", "and", "R2start", "as", "needed", ".", "If", "force", "is", "false", "check", "to", "make", "sure", "the", "suffix", "exists", "first", "." ]
[ "func", "(", "w", "*", "SnowballWord", ")", "ReplaceSuffixRunes", "(", "suffixRunes", "[", "]", "rune", ",", "replacementRunes", "[", "]", "rune", ",", "<mask>", "bool", ")", "bool", "{", "if", "force", "||", "w", ".", "HasSuffixRunes", "(", "suffixRunes", ")", "{", "lenWithoutSuffix", ":=", "len", "(", "w", ".", "RS", ")", "-", "len", "(", "suffixRunes", ")", "\n", "w", ".", "RS", "=", "append", "(", "w", ".", "RS", "[", ":", "lenWithoutSuffix", "]", ",", "replacementRunes", "...", ")", "\n\n", "// If R, R2, & RV are now beyond the length", "// of the word, they are set to the length", "// of the word. Otherwise, they are left", "// as they were.", "w", ".", "resetR1R2", "(", ")", "\n", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
18,168
all-18169
[ "GetIP", "returns", "an", "IP", "or", "hostname", "that", "this", "host", "is", "available", "at", "e", ".", "g", ".", "1", ".", "2", ".", "3", ".", "4", "or", "docker", "-", "host", "-", "d60b70a14d3a", ".", "cloudapp", ".", "net" ]
[ "func", "(", "d", "*", "SerialDriver", ")", "GetIP", "(", ")", "(", "string", ",", "<mask>", ")", "{", "d", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "Unlock", "(", ")", "\n", "return", "d", ".", "Driver", ".", "GetIP", "(", ")", "\n", "}" ]
18,169
all-18170
[ "UnmarshalText", "hydrates", "this", "instance", "from", "text" ]
[ "func", "(", "h", "*", "HexColor", ")", "UnmarshalText", "(", "data", "[", "]", "byte", ")", "error", "{", "// validation is performed later on", "*", "h", "=", "HexColor", "(", "string", "(", "<mask>", ")", ")", "\n", "return", "nil", "\n", "}" ]
18,170
all-18171
[ "GetOrderBy", "returns", "the", "OrderBy", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "g", "*", "GraphDefinitionRequest", ")", "GetOrderBy", "(", ")", "string", "{", "if", "g", "==", "nil", "||", "g", ".", "OrderBy", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "<mask>", "*", "g", ".", "OrderBy", "\n", "}" ]
18,171
all-18172
[ "expandDistributedVirtualSwitchHostMemberConfigSpec", "reads", "certain", "keys", "from", "a", "Set", "object", "map", "and", "returns", "a", "DistributedVirtualSwitchHostMemberConfigSpec", "." ]
[ "func", "expandDistributedVirtualSwitchHostMemberConfigSpec", "(", "d", "map", "[", "string", "]", "interface", "{", "}", ")", "<mask>", ".", "DistributedVirtualSwitchHostMemberConfigSpec", "{", "hostRef", ":=", "&", "types", ".", "ManagedObjectReference", "{", "Type", ":", "\"", "\"", ",", "Value", ":", "d", "[", "\"", "\"", "]", ".", "(", "string", ")", ",", "}", "\n\n", "var", "pnSpecs", "[", "]", "types", ".", "DistributedVirtualSwitchHostMemberPnicSpec", "\n", "nics", ":=", "structure", ".", "SliceInterfacesToStrings", "(", "d", "[", "\"", "\"", "]", ".", "(", "[", "]", "interface", "{", "}", ")", ")", "\n", "for", "_", ",", "nic", ":=", "range", "nics", "{", "pnSpec", ":=", "types", ".", "DistributedVirtualSwitchHostMemberPnicSpec", "{", "PnicDevice", ":", "nic", ",", "}", "\n", "pnSpecs", "=", "append", "(", "pnSpecs", ",", "pnSpec", ")", "\n", "}", "\n", "backing", ":=", "types", ".", "DistributedVirtualSwitchHostMemberPnicBacking", "{", "PnicSpec", ":", "pnSpecs", ",", "}", "\n\n", "obj", ":=", "types", ".", "DistributedVirtualSwitchHostMemberConfigSpec", "{", "Host", ":", "*", "hostRef", ",", "Backing", ":", "&", "backing", ",", "}", "\n", "return", "obj", "\n", "}" ]
18,172
all-18173
[ "Locator", "returns", "a", "locator", "for", "the", "given", "resource" ]
[ "func", "(", "r", "*", "<mask>", ")", "Locator", "(", "api", "*", "API", ")", "*", "ImageLocator", "{", "return", "api", ".", "ImageLocator", "(", "r", ".", "Href", ")", "\n", "}" ]
18,173
all-18174
[ "ApplyTransition", "calls", "the", "function", "required", "to", "move", "to", "the", "specified", "status" ]
[ "func", "(", "auth", "*", "ASMAuthResource", ")", "ApplyTransition", "(", "nextState", "resourcestatus", ".", "ResourceStatus", ")", "error", "{", "transitionFunc", ",", "ok", ":=", "auth", ".", "resourceStatusToTransitionFunction", "[", "nextState", "]", "\n", "if", "!", "<mask>", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ",", "auth", ".", "GetName", "(", ")", ",", "auth", ".", "StatusString", "(", "nextState", ")", ")", "\n", "}", "\n", "return", "transitionFunc", "(", ")", "\n", "}" ]
18,174
all-18175
[ "isAction", "returns", "true", "if", "the", "line", "is", "an", "action", "." ]
[ "func", "(", "l", "*", "<mask>", ")", "isAction", "(", ")", "bool", "{", "str", ":=", "strings", ".", "TrimSpace", "(", "l", ".", "str", ")", "\n", "return", "strings", ".", "HasPrefix", "(", "str", ",", "l", ".", "opts", ".", "DelimLeft", ")", "&&", "strings", ".", "HasSuffix", "(", "str", ",", "l", ".", "opts", ".", "DelimRight", ")", "\n", "}" ]
18,175
all-18176
[ "Validate", "that", "options", "are", "usuable" ]
[ "func", "(", "opts", "*", "Options", ")", "Validate", "(", ")", "error", "{", "if", "opts", ".", "App", ".", "IsZero", "(", ")", "{", "opts", ".", "App", "=", "meta", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "found", "bool", "\n", "for", "_", ",", "a", ":=", "range", "Available", "{", "if", "opts", ".", "Provider", "==", "a", "{", "found", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "!", "<mask>", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "opts", ".", "Provider", ",", "strings", ".", "Join", "(", "Available", ",", "\"", "\"", ")", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
18,176
all-18177
[ "Promotes", "an", "address", "from", "new", "to", "old", ".", "TODO", ":", "Move", "to", "old", "probabilistically", ".", "The", "better", "a", "node", "is", "the", "less", "likely", "it", "should", "be", "evicted", "from", "an", "old", "bucket", "." ]
[ "func", "(", "a", "*", "AddrBook", ")", "moveToOld", "(", "ka", "*", "knownAddress", ")", "{", "// Sanity check", "if", "ka", ".", "isOld", "(", ")", "{", "log", ".", "Warn", "(", "Fmt", "(", "\"", "\"", ",", "ka", ")", ")", "\n", "return", "\n", "}", "\n", "if", "len", "(", "ka", ".", "Buckets", ")", "==", "0", "{", "log", ".", "Warn", "(", "Fmt", "(", "\"", "\"", ",", "ka", ")", ")", "\n", "return", "\n", "}", "\n\n", "// Remember one of the buckets in which ka is in.", "freedBucket", ":=", "ka", ".", "Buckets", "[", "0", "]", "\n", "// Remove from all (new) buckets.", "a", ".", "removeFromAllBuckets", "(", "ka", ")", "\n", "// It's officially old now.", "ka", ".", "BucketType", "=", "bucketTypeOld", "\n\n", "// Try to add it to its oldBucket destination.", "oldBucketIdx", ":=", "a", ".", "calcOldBucket", "(", "ka", ".", "Addr", ")", "\n", "added", ":=", "a", ".", "addToOldBucket", "(", "ka", ",", "oldBucketIdx", ")", "\n", "if", "!", "added", "{", "// No room, must evict something", "oldest", ":=", "a", ".", "pickOldest", "(", "bucketTypeOld", ",", "oldBucketIdx", ")", "\n", "a", ".", "removeFromBucket", "(", "oldest", ",", "bucketTypeOld", ",", "oldBucketIdx", ")", "\n", "// Find new bucket to put oldest in", "newBucketIdx", ":=", "a", ".", "calcNewBucket", "(", "oldest", ".", "Addr", ",", "oldest", ".", "Src", ")", "\n", "added", ":=", "a", ".", "addToNewBucket", "(", "oldest", ",", "newBucketIdx", ")", "\n", "// No space in newBucket either, just put it in freedBucket from above.", "if", "!", "<mask>", "{", "added", ":=", "a", ".", "addToNewBucket", "(", "oldest", ",", "freedBucket", ")", "\n", "if", "!", "added", "{", "log", ".", "Warn", "(", "Fmt", "(", "\"", "\"", ",", "oldest", ",", "freedBucket", ")", ")", "\n", "}", "\n", "}", "\n", "// Finally, add to bucket again.", "added", "=", "a", ".", "addToOldBucket", "(", "ka", ",", "oldBucketIdx", ")", "\n", "if", "!", "added", "{", "log", ".", "Warn", "(", "Fmt", "(", "\"", "\"", ",", "ka", ",", "oldBucketIdx", ")", ")", "\n", "}", "\n", "}", "\n", "}" ]
18,177
all-18178
[ "UpdateCloudIP", "updates", "an", "existing", "cloud", "ip", "s", "attributes", ".", "Not", "all", "attributes", "can", "be", "changed", "after", "creation", "time", "(", "such", "as", "Id", "which", "is", "allocated", "for", "you", ")", ".", "Specify", "the", "cloud", "ip", "you", "want", "to", "update", "using", "the", "CloudIPOptions", "Id", "field" ]
[ "func", "(", "c", "*", "Client", ")", "UpdateCloudIP", "(", "updateCloudIP", "*", "CloudIPOptions", ")", "(", "*", "CloudIP", ",", "error", ")", "{", "cip", ":=", "<mask>", "(", "CloudIP", ")", "\n", "_", ",", "err", ":=", "c", ".", "MakeApiRequest", "(", "\"", "\"", ",", "\"", "\"", "+", "updateCloudIP", ".", "Id", ",", "updateCloudIP", ",", "&", "cip", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "cip", ",", "nil", "\n", "}" ]
18,178
all-18179
[ "um_resources_type_path", "returns", "the", "string", "resources", "/", "{", "resourceType", "}", "/", "{", "resourceId", "}" ]
[ "func", "umResourcesTypePath", "(", "restype", "string", ",", "resourceid", "<mask>", ")", "string", "{", "return", "um", "(", ")", "+", "slash", "(", "\"", "\"", ")", "+", "slash", "(", "restype", ")", "+", "slash", "(", "resourceid", ")", "\n", "}" ]
18,179
all-18180
[ "MustUnmarshalJSON", "panics", "if", "an", "error", "occurs", ".", "Besides", "tha", "behaves", "exactly", "like", "UnmarshalJSON", "." ]
[ "func", "(", "cdc", "*", "Codec", ")", "MustUnmarshalJSON", "(", "bz", "[", "]", "byte", ",", "ptr", "<mask>", "{", "}", ")", "{", "if", "err", ":=", "cdc", ".", "UnmarshalJSON", "(", "bz", ",", "ptr", ")", ";", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "}" ]
18,180
all-18181
[ "HasTickPos", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "w", "*", "Widget", ")", "HasTickPos", "(", ")", "bool", "{", "if", "w", "!=", "nil", "&&", "w", ".", "TickPos", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
18,181
all-18182
[ "HasRole", "check", "if", "current", "user", "has", "role" ]
[ "func", "(", "role", "*", "Role", ")", "HasRole", "(", "req", "*", "http", ".", "Request", ",", "user", "interface", "{", "}", ",", "roles", "...", "string", ")", "bool", "{", "if", "definitions", ":=", "role", ".", "definitions", ";", "definitions", "!=", "nil", "{", "for", "_", ",", "name", ":=", "range", "roles", "{", "if", "definition", ",", "ok", ":=", "definitions", "[", "name", "]", ";", "<mask>", "{", "if", "definition", "(", "req", ",", "user", ")", "{", "return", "true", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
18,182
all-18183
[ "Get", "gets", "the", "item", "for", "the", "given", "key", ".", "ErrCacheMiss", "is", "returned", "for", "a", "memcache", "cache", "miss", ".", "The", "key", "must", "be", "at", "most", "250", "bytes", "in", "length", "." ]
[ "func", "(", "c", "*", "<mask>", ")", "Get", "(", "key", "string", ")", "(", "*", "Item", ",", "error", ")", "{", "cn", ",", "err", ":=", "c", ".", "sendCommand", "(", "key", ",", "cmdGet", ",", "nil", ",", "0", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "c", ".", "parseItemResponse", "(", "key", ",", "cn", ",", "true", ")", "\n", "}" ]
18,183
all-18184
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "InheritedStyleEntry", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss34", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "<mask>", "\n", "}" ]
18,184
all-18185
[ "Start", "starts", "the", "Push", "Center", "." ]
[ "func", "(", "p", "*", "PushCenter", ")", "Start", "(", ")", "error", "{", "if", "p", ".", "isRunning", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "p", ".", "isRunning", "=", "true", "\n\n", "go", "func", "(", ")", "{", "lastEventID", ":=", "\"", "\"", "\n", "for", "{", "go", "p", ".", "session", ".", "NextEvent", "(", "p", ".", "Channel", ",", "lastEventID", ")", "\n", "select", "{", "case", "notification", ":=", "<-", "p", ".", "Channel", ":", "for", "_", ",", "event", ":=", "range", "notification", ".", "Events", "{", "buffer", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "if", "err", ":=", "json", ".", "NewEncoder", "(", "buffer", ")", ".", "Encode", "(", "event", ".", "DataMap", "[", "0", "]", ")", ";", "err", "!=", "nil", "{", "continue", "\n", "}", "\n", "event", ".", "Data", "=", "buffer", ".", "Bytes", "(", ")", "\n\n", "lastEventID", "=", "notification", ".", "UUID", "\n", "if", "p", ".", "defaultHander", "!=", "nil", "{", "p", ".", "defaultHander", "(", "event", ")", "\n", "}", "\n\n", "if", "handler", ",", "exists", ":=", "p", ".", "handlers", "[", "event", ".", "EntityType", "]", ";", "exists", "{", "handler", "(", "<mask>", ")", "\n", "}", "\n", "}", "\n", "case", "<-", "p", ".", "stop", ":", "return", "\n", "}", "\n", "}", "\n", "}", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
18,185
all-18186
[ "goTypePrefix", "returns", "the", "Go", "type", "name", "for", "the", "given", "thrift", "type", "with", "the", "prefix", "." ]
[ "func", "(", "s", "*", "State", ")", "goTypePrefix", "(", "prefix", "string", ",", "thriftType", "*", "parser", ".", "Type", ")", "string", "{", "switch", "thriftType", ".", "Name", "{", "case", "\"", "\"", ":", "return", "\"", "\"", "\n", "case", "\"", "\"", ":", "return", "\"", "\"", "+", "s", ".", "goType", "(", "thriftType", ".", "ValueType", ")", "\n", "case", "\"", "\"", ":", "return", "\"", "\"", "+", "s", ".", "goType", "(", "thriftType", ".", "ValueType", ")", "+", "\"", "\"", "\n", "case", "\"", "\"", ":", "return", "\"", "\"", "+", "s", ".", "goType", "(", "thriftType", ".", "KeyType", ")", "+", "\"", "\"", "+", "s", ".", "goType", "(", "thriftType", ".", "ValueType", ")", "\n", "}", "\n\n", "// If the type is imported, then ignore the package.", "if", "state", ",", "newType", ",", "include", ":=", "s", ".", "checkInclude", "(", "thriftType", ")", ";", "include", "!=", "nil", "{", "return", "state", ".", "goTypePrefix", "(", "include", ".", "Package", "(", ")", "+", "\"", "\"", ",", "newType", ")", "\n", "}", "\n\n", "// If the type is a direct Go type, use that.", "if", "goType", ",", "<mask>", ":=", "thriftToGo", "[", "thriftType", ".", "Name", "]", ";", "ok", "{", "return", "goType", "\n", "}", "\n\n", "goThriftName", ":=", "goPublicFieldName", "(", "thriftType", ".", "Name", ")", "\n", "goThriftName", "=", "prefix", "+", "goThriftName", "\n\n", "// Check if the type has a typedef to the direct Go type.", "rootType", ":=", "s", ".", "rootType", "(", "thriftType", ")", "\n", "if", "_", ",", "ok", ":=", "thriftToGo", "[", "rootType", ".", "Name", "]", ";", "ok", "{", "return", "goThriftName", "\n", "}", "\n", "if", "rootType", ".", "Name", "==", "\"", "\"", "||", "rootType", ".", "Name", "==", "\"", "\"", "||", "rootType", ".", "Name", "==", "\"", "\"", "{", "return", "goThriftName", "\n", "}", "\n\n", "// If it's a typedef to another struct, then the typedef is defined as a pointer", "// so we do not want the pointer type here.", "if", "rootType", "!=", "thriftType", "{", "return", "goThriftName", "\n", "}", "\n\n", "// If it's not a typedef for a basic type, we use a pointer.", "return", "\"", "\"", "+", "goThriftName", "\n", "}" ]
18,186
all-18187
[ "CreateZpool", "creates", "a", "new", "ZFS", "zpool", "with", "the", "specified", "name", "properties", "and", "optional", "arguments", ".", "A", "full", "list", "of", "available", "ZFS", "properties", "and", "command", "-", "line", "arguments", "may", "be", "found", "here", ":", "https", ":", "//", "www", ".", "freebsd", ".", "org", "/", "cgi", "/", "man", ".", "cgi?zfs", "(", "8", ")", "." ]
[ "func", "CreateZpool", "(", "name", "string", ",", "properties", "map", "[", "string", "]", "string", ",", "args", "...", "string", ")", "(", "*", "Zpool", ",", "error", ")", "{", "cli", ":=", "make", "(", "[", "]", "string", ",", "1", ",", "4", ")", "\n", "cli", "[", "0", "]", "=", "\"", "\"", "\n", "if", "properties", "!=", "nil", "{", "cli", "=", "append", "(", "<mask>", ",", "propsSlice", "(", "properties", ")", "...", ")", "\n", "}", "\n", "cli", "=", "append", "(", "cli", ",", "name", ")", "\n", "cli", "=", "append", "(", "cli", ",", "args", "...", ")", "\n", "_", ",", "err", ":=", "zpool", "(", "cli", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "Zpool", "{", "Name", ":", "name", "}", ",", "nil", "\n", "}" ]
18,187
all-18188
[ "KeyWithTs", "generates", "a", "new", "key", "by", "appending", "ts", "to", "key", "." ]
[ "func", "KeyWithTs", "(", "key", "[", "]", "byte", ",", "ts", "uint64", ")", "[", "]", "byte", "{", "out", ":=", "<mask>", "(", "[", "]", "byte", ",", "len", "(", "key", ")", "+", "8", ")", "\n", "copy", "(", "out", ",", "key", ")", "\n", "binary", ".", "BigEndian", ".", "PutUint64", "(", "out", "[", "len", "(", "key", ")", ":", "]", ",", "math", ".", "MaxUint64", "-", "ts", ")", "\n", "return", "out", "\n", "}" ]
18,188
all-18189
[ "UUID", "generates", "a", "random", "UUID", "according", "to", "RFC", "4122", "." ]
[ "func", "UUID", "(", ")", "string", "{", "uuid", ":=", "<mask>", "(", "[", "]", "byte", ",", "16", ")", "\n", "uuidMutex", ".", "Lock", "(", ")", "\n", "_", ",", "_", "=", "uuidRand", ".", "Read", "(", "uuid", ")", "\n", "uuidMutex", ".", "Unlock", "(", ")", "\n", "// variant bits; see section 4.1.1", "uuid", "[", "8", "]", "=", "uuid", "[", "8", "]", "&^", "0xc0", "|", "0x80", "\n", "// version 4 (pseudo-random); see section 4.1.3", "uuid", "[", "6", "]", "=", "uuid", "[", "6", "]", "&^", "0xf0", "|", "0x40", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "uuid", "[", "0", ":", "4", "]", ",", "uuid", "[", "4", ":", "6", "]", ",", "uuid", "[", "6", ":", "8", "]", ",", "uuid", "[", "8", ":", "10", "]", ",", "uuid", "[", "10", ":", "]", ")", "\n", "}" ]
18,189
all-18190
[ "InitialAcquire", "obtains", "the", "first", "reference", "to", "the", "socket", "either", "right", "after", "the", "connection", "is", "made", "or", "once", "a", "recycled", "socket", "is", "being", "put", "back", "in", "use", "." ]
[ "func", "(", "socket", "*", "mongoSocket", ")", "InitialAcquire", "(", "serverInfo", "*", "mongoServerInfo", ",", "timeout", "time", ".", "Duration", ")", "error", "{", "socket", ".", "Lock", "(", ")", "\n", "if", "socket", ".", "references", ">", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "<mask>", ".", "dead", "!=", "nil", "{", "dead", ":=", "socket", ".", "dead", "\n", "socket", ".", "Unlock", "(", ")", "\n", "return", "dead", "\n", "}", "\n", "socket", ".", "references", "++", "\n", "socket", ".", "serverInfo", "=", "serverInfo", "\n", "socket", ".", "timeout", "=", "timeout", "\n", "stats", ".", "socketsInUse", "(", "+", "1", ")", "\n", "stats", ".", "socketRefs", "(", "+", "1", ")", "\n", "socket", ".", "Unlock", "(", ")", "\n", "return", "nil", "\n", "}" ]
18,190
all-18191
[ "Abs", "resolves", "a", "filename", "relative", "to", "the", "base", "directory", ".", "Absolute", "paths", "are", "allowed", ".", "When", "there", "s", "no", "base", "dir", "set", "the", "absolute", "path", "to", "the", "filename", "will", "be", "calculated", "based", "on", "either", "the", "provided", "base", "directory", "(", "which", "might", "be", "a", "path", "of", "a", "template", "which", "includes", "another", "template", ")", "or", "the", "current", "working", "directory", "." ]
[ "func", "(", "l", "ChrootLoader", ")", "Abs", "(", "base", "string", ",", "name", "string", ")", "string", "{", "return", "filepath", ".", "Clean", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "l", ".", "<mask>", ",", "name", ")", ")", "\n", "}" ]
18,191
all-18192
[ "NewMockTime", "creates", "a", "new", "mock", "instance" ]
[ "func", "NewMockTime", "(", "ctrl", "*", "gomock", ".", "<mask>", ")", "*", "MockTime", "{", "mock", ":=", "&", "MockTime", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockTimeMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
18,192
all-18193
[ "Addr", "returns", "an", "address", "of", "slave", "." ]
[ "func", "(", "s", "*", "Slave", ")", "Addr", "(", ")", "string", "{", "return", "net", ".", "JoinHostPort", "(", "s", ".", "<mask>", ",", "s", ".", "port", ")", "\n", "}" ]
18,193
all-18194
[ "UnmarshalEasyJSON", "satisfies", "easyjson", ".", "Unmarshaler", "." ]
[ "func", "(", "t", "*", "Level", ")", "UnmarshalEasyJSON", "(", "in", "*", "jlexer", ".", "Lexer", ")", "{", "switch", "Level", "(", "in", ".", "String", "(", ")", ")", "{", "case", "LevelVerbose", ":", "*", "t", "=", "LevelVerbose", "\n", "case", "LevelInfo", ":", "*", "t", "=", "LevelInfo", "\n", "case", "LevelWarning", ":", "*", "t", "=", "LevelWarning", "\n", "<mask>", "LevelError", ":", "*", "t", "=", "LevelError", "\n\n", "default", ":", "in", ".", "AddError", "(", "errors", ".", "New", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "}" ]
18,194
all-18195
[ "title", ":", "metric", "envs", "path", ":", "/", "apps", "/", "{", "app", "}", "/", "metric", "/", "envs", "method", ":", "GET", "produce", ":", "application", "/", "json", "responses", ":", "200", ":", "Ok", "401", ":", "Unauthorized", "404", ":", "App", "not", "found" ]
[ "func", "appMetricEnvs", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "<mask>", ".", "Request", ",", "t", "auth", ".", "Token", ")", "error", "{", "a", ",", "err", ":=", "getAppFromContext", "(", "r", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "\"", "\"", ")", ",", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "allowed", ":=", "permission", ".", "Check", "(", "t", ",", "permission", ".", "PermAppReadMetric", ",", "contextsForApp", "(", "&", "a", ")", "...", ",", ")", "\n", "if", "!", "allowed", "{", "return", "permission", ".", "ErrUnauthorized", "\n", "}", "\n", "w", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "metricMap", ",", "err", ":=", "a", ".", "MetricEnvs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "json", ".", "NewEncoder", "(", "w", ")", ".", "Encode", "(", "metricMap", ")", "\n", "}" ]
18,195
all-18196
[ "Do", "executes", "Memory", ".", "prepareForLeakDetection", "against", "the", "provided", "context", "." ]
[ "func", "(", "p", "*", "PrepareForLeakDetectionParams", ")", "Do", "(", "ctx", "context", ".", "<mask>", ")", "(", "err", "error", ")", "{", "return", "cdp", ".", "Execute", "(", "ctx", ",", "CommandPrepareForLeakDetection", ",", "nil", ",", "nil", ")", "\n", "}" ]
18,196
all-18197
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "EventDomStorageItemRemoved", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "<mask>", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoDomstorage7", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "Buffer", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
18,197
all-18198
[ "Panics", "if", "error", "." ]
[ "func", "(", "cdc", "*", "Codec", ")", "MustMarshalBinaryLengthPrefixed", "(", "o", "<mask>", "{", "}", ")", "[", "]", "byte", "{", "bz", ",", "err", ":=", "cdc", ".", "MarshalBinaryLengthPrefixed", "(", "o", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "bz", "\n", "}" ]
18,198
all-18199
[ "SetStringPolicy", "sets", "a", "ResourceData", "field", "depending", "on", "if", "a", "StringPolicy", "exists", "or", "not", ".", "The", "field", "is", "not", "set", "if", "it", "s", "nil", "." ]
[ "func", "SetStringPolicy", "(", "d", "*", "schema", ".", "ResourceData", ",", "key", "string", ",", "val", "*", "types", ".", "StringPolicy", ")", "error", "{", "if", "val", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "err", ":=", "d", ".", "Set", "(", "key", ",", "val", ".", "<mask>", ")", "\n", "return", "err", "\n", "}" ]
18,199
all-18200
[ "LimitFromMetadata", "gets", "the", "limit", "from", "the", "metadata" ]
[ "func", "LimitFromMetadata", "(", "md", "metadata", ".", "MD", ")", "(", "uint64", ",", "error", ")", "{", "limit", ",", "<mask>", ":=", "md", "[", "\"", "\"", "]", "\n", "if", "!", "ok", "||", "len", "(", "limit", ")", "==", "0", "{", "return", "0", ",", "nil", "\n", "}", "\n", "return", "strconv", ".", "ParseUint", "(", "limit", "[", "0", "]", ",", "10", ",", "64", ")", "\n", "}" ]