id
int32
0
25.3k
idx
stringlengths
5
9
nl_tokens
sequencelengths
1
418
pl_tokens
sequencelengths
22
4.98k
5,600
all-5601
[ "The", "V1", "procotol", "consists", "of", "the", "protocol", "identification", "/", "version", "header", "followed", "by", "a", "stream", "of", "gobified", "values", ".", "The", "first", "value", "is", "the", "encoded", "features", "map", "(", "never", "encrypted", ")", ".", "The", "subsequent", "values", "are", "the", "messages", "on", "the", "connection", "(", "encrypted", "for", "an", "encrypted", "connection", ")", ".", "For", "an", "encrypted", "connection", "the", "public", "key", "is", "passed", "in", "the", "PublicKey", "feature", "as", "a", "string", "of", "hex", "digits", "." ]
[ "func", "(", "res", "*", "protocolIntroResults", ")", "doIntroV1", "(", "params", "protocolIntroParams", ",", "pubKey", ",", "privKey", "*", "[", "32", "]", "byte", ")", "error", "{", "features", ":=", "filterV1Features", "(", "params", ".", "Features", ")", "\n", "if", "pubKey", "!=", "nil", "{", "features", "[", "\"", "\"", "]", "=", "hex", ".", "EncodeToString", "(", "pubKey", "[", ":", "]", ")", "\n", "}", "\n\n", "enc", ":=", "gob", ".", "NewEncoder", "(", "params", ".", "Conn", ")", "\n", "dec", ":=", "gob", ".", "NewDecoder", "(", "params", ".", "Conn", ")", "\n\n", "// Encode in a separate goroutine to avoid the possibility of", "// deadlock. The result channel is of size 1 so that the", "// goroutine does not linger even if we encounter an error on", "// the read side.", "encodeDone", ":=", "make", "(", "chan", "error", ",", "1", ")", "\n", "go", "func", "(", ")", "{", "encodeDone", "<-", "enc", ".", "Encode", "(", "features", ")", "\n", "}", "(", ")", "\n\n", "if", "err", ":=", "dec", ".", "Decode", "(", "&", "res", ".", "Features", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "err", ":=", "<-", "encodeDone", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "res", ".", "Sender", "=", "newGobTCPSender", "(", "enc", ")", "\n", "res", ".", "Receiver", "=", "newGobTCPReceiver", "(", "dec", ")", "\n\n", "if", "pubKey", "==", "nil", "{", "if", "_", ",", "present", ":=", "res", ".", "Features", "[", "\"", "\"", "]", ";", "present", "{", "return", "errExpectedNoCrypto", "\n", "}", "\n", "}", "else", "{", "remotePubKeyStr", ",", "ok", ":=", "res", ".", "Features", "[", "\"", "\"", "]", "\n", "if", "!", "ok", "{", "return", "errExpectedCrypto", "\n", "}", "\n\n", "remotePubKey", ",", "err", ":=", "hex", ".", "DecodeString", "(", "remotePubKeyStr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "res", ".", "setupCrypto", "(", "params", ",", "remotePubKey", ",", "privKey", ")", "\n", "}", "\n\n", "<mask>", ".", "Features", "=", "filterV1Features", "(", "res", ".", "Features", ")", "\n", "return", "nil", "\n", "}" ]
5,601
all-5602
[ "Depending", "on", "the", "parameters", "passed", "and", "on", "local", "state", "this", "endpoint", "will", "either", ":", "-", "bootstrap", "a", "new", "cluster", "(", "if", "this", "node", "is", "not", "clustered", "yet", ")", "-", "request", "to", "join", "an", "existing", "cluster", "-", "disable", "clustering", "on", "a", "node", "The", "client", "is", "required", "to", "be", "trusted", "." ]
[ "func", "clusterPut", "(", "d", "*", "Daemon", ",", "r", "*", "<mask>", ".", "Request", ")", "Response", "{", "req", ":=", "api", ".", "ClusterPut", "{", "}", "\n\n", "// Parse the request", "err", ":=", "json", ".", "NewDecoder", "(", "r", ".", "Body", ")", ".", "Decode", "(", "&", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "BadRequest", "(", "err", ")", "\n", "}", "\n\n", "// Sanity checks", "if", "req", ".", "ServerName", "==", "\"", "\"", "&&", "req", ".", "Enabled", "{", "return", "BadRequest", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "}", "\n", "if", "req", ".", "ServerName", "!=", "\"", "\"", "&&", "!", "req", ".", "Enabled", "{", "return", "BadRequest", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "}", "\n\n", "// Disable clustering.", "if", "!", "req", ".", "Enabled", "{", "return", "clusterPutDisable", "(", "d", ")", "\n", "}", "\n\n", "// Depending on the provided parameters we either bootstrap a brand new", "// cluster with this node as first node, or perform a request to join a", "// given cluster.", "if", "req", ".", "ClusterAddress", "==", "\"", "\"", "{", "return", "clusterPutBootstrap", "(", "d", ",", "req", ")", "\n", "}", "\n\n", "return", "clusterPutJoin", "(", "d", ",", "req", ")", "\n", "}" ]
5,602
all-5603
[ "printHistogram", "prints", "the", "histogram", "data", "in", "a", "human", "-", "readable", "format", "." ]
[ "func", "(", "histogram", "histogramData", ")", "printHistogram", "(", ")", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "histogram", ".", "totalCount", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "histogram", ".", "min", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "histogram", ".", "max", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "float64", "(", "histogram", ".", "sum", ")", "/", "float64", "(", "histogram", ".", "totalCount", ")", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "numBins", ":=", "len", "(", "histogram", ".", "bins", ")", "\n", "for", "index", ",", "count", ":=", "range", "histogram", ".", "countPerBin", "{", "if", "count", "==", "0", "{", "continue", "\n", "}", "\n\n", "// The last bin represents the bin that contains the range from", "// the last bin up to infinity so it's processed differently than the", "// other bins.", "if", "index", "==", "len", "(", "histogram", ".", "countPerBin", ")", "-", "1", "{", "lowerBound", ":=", "int", "(", "histogram", ".", "bins", "[", "numBins", "-", "1", "]", ")", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "lowerBound", ",", "\"", "\"", ",", "count", ")", "\n", "continue", "\n", "}", "\n\n", "upperBound", ":=", "int", "(", "histogram", ".", "bins", "[", "index", "]", ")", "\n", "lowerBound", ":=", "0", "\n", "if", "<mask>", ">", "0", "{", "lowerBound", "=", "int", "(", "histogram", ".", "bins", "[", "index", "-", "1", "]", ")", "\n", "}", "\n\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "lowerBound", ",", "upperBound", ",", "count", ")", "\n", "}", "\n", "fmt", ".", "Println", "(", ")", "\n", "}" ]
5,603
all-5604
[ "IsErrNotSignedIn", "returns", "true", "if", "err", "is", "a", "ErrNotSignedIn" ]
[ "func", "IsErrNotSignedIn", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "<mask>", "\n", "}", "\n", "// TODO(msteffen) This is unstructured because we have no way to propagate", "// structured errors across GRPC boundaries. Fix", "return", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "status", ".", "Convert", "(", "ErrNotSignedIn", ")", ".", "Message", "(", ")", ")", "\n", "}" ]
5,604
all-5605
[ "AddException", "adds", "a", "new", "exception", "into", "the", "context", "." ]
[ "func", "(", "s", "*", "Seekret", ")", "AddException", "(", "exception", "models", ".", "<mask>", ")", "{", "s", ".", "exceptionList", "=", "append", "(", "s", ".", "exceptionList", ",", "exception", ")", "\n", "}" ]
5,605
all-5606
[ "Add", "creates", "a", "new", "key", "/", "value", "record", "if", "it", "does", "not", "yet", "exist", "and", "positions", "the", "iterator", "on", "it", ".", "If", "the", "record", "already", "exists", "then", "Add", "positions", "the", "iterator", "on", "the", "most", "current", "value", "and", "returns", "ErrRecordExists", ".", "If", "there", "isn", "t", "enough", "room", "in", "the", "arena", "then", "Add", "returns", "ErrArenaFull", "." ]
[ "func", "(", "it", "*", "Iterator", ")", "Add", "(", "key", "[", "]", "byte", ",", "val", "[", "]", "byte", ",", "meta", "uint16", ")", "error", "{", "var", "spl", "[", "maxHeight", "]", "splice", "\n", "if", "it", ".", "seekForSplice", "(", "key", ",", "&", "spl", ")", "{", "// Found a matching node, but handle case where it's been deleted.", "return", "it", ".", "setValueIfDeleted", "(", "spl", "[", "0", "]", ".", "next", ",", "val", ",", "meta", ")", "\n", "}", "\n\n", "if", "it", ".", "list", ".", "testing", "{", "// Add delay to make it easier to test race between this thread", "// and another thread that sees the intermediate state between", "// finding the splice and using it.", "runtime", ".", "Gosched", "(", ")", "\n", "}", "\n\n", "nd", ",", "height", ",", "err", ":=", "it", ".", "list", ".", "newNode", "(", "key", ",", "val", ",", "meta", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "value", ":=", "nd", ".", "value", "\n", "ndOffset", ":=", "it", ".", "arena", ".", "GetPointerOffset", "(", "unsafe", ".", "Pointer", "(", "nd", ")", ")", "\n\n", "// We always insert from the base level and up. After you add a node in base", "// level, we cannot create a node in the level above because it would have", "// discovered the node in the base level.", "var", "<mask>", "bool", "\n", "for", "i", ":=", "0", ";", "i", "<", "int", "(", "height", ")", ";", "i", "++", "{", "prev", ":=", "spl", "[", "i", "]", ".", "prev", "\n", "next", ":=", "spl", "[", "i", "]", ".", "next", "\n\n", "if", "prev", "==", "nil", "{", "// New node increased the height of the skiplist, so assume that the", "// new level has not yet been populated.", "if", "next", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "prev", "=", "it", ".", "list", ".", "head", "\n", "next", "=", "it", ".", "list", ".", "tail", "\n", "}", "\n\n", "// +----------------+ +------------+ +----------------+", "// | prev | | nd | | next |", "// | prevNextOffset |---->| | | |", "// | |<----| prevOffset | | |", "// | | | nextOffset |---->| |", "// | | | |<----| nextPrevOffset |", "// +----------------+ +------------+ +----------------+", "//", "// 1. Initialize prevOffset and nextOffset to point to prev and next.", "// 2. CAS prevNextOffset to repoint from next to nd.", "// 3. CAS nextPrevOffset to repoint from prev to nd.", "for", "{", "prevOffset", ":=", "it", ".", "arena", ".", "GetPointerOffset", "(", "unsafe", ".", "Pointer", "(", "prev", ")", ")", "\n", "nextOffset", ":=", "it", ".", "arena", ".", "GetPointerOffset", "(", "unsafe", ".", "Pointer", "(", "next", ")", ")", "\n", "nd", ".", "tower", "[", "i", "]", ".", "init", "(", "prevOffset", ",", "nextOffset", ")", "\n\n", "// Check whether next has an updated link to prev. If it does not,", "// that can mean one of two things:", "// 1. The thread that added the next node hasn't yet had a chance", "// to add the prev link (but will shortly).", "// 2. Another thread has added a new node between prev and next.", "nextPrevOffset", ":=", "next", ".", "prevOffset", "(", "i", ")", "\n", "if", "nextPrevOffset", "!=", "prevOffset", "{", "// Determine whether #1 or #2 is true by checking whether prev", "// is still pointing to next. As long as the atomic operations", "// have at least acquire/release semantics (no need for", "// sequential consistency), this works, as it is equivalent to", "// the \"publication safety\" pattern.", "prevNextOffset", ":=", "prev", ".", "nextOffset", "(", "i", ")", "\n", "if", "prevNextOffset", "==", "nextOffset", "{", "// Ok, case #1 is true, so help the other thread along by", "// updating the next node's prev link.", "next", ".", "casPrevOffset", "(", "i", ",", "nextPrevOffset", ",", "prevOffset", ")", "\n", "}", "\n", "}", "\n\n", "if", "prev", ".", "casNextOffset", "(", "i", ",", "nextOffset", ",", "ndOffset", ")", "{", "// Managed to insert nd between prev and next, so update the next", "// node's prev link and go to the next level.", "if", "it", ".", "list", ".", "testing", "{", "// Add delay to make it easier to test race between this thread", "// and another thread that sees the intermediate state between", "// setting next and setting prev.", "runtime", ".", "Gosched", "(", ")", "\n", "}", "\n\n", "next", ".", "casPrevOffset", "(", "i", ",", "prevOffset", ",", "ndOffset", ")", "\n", "break", "\n", "}", "\n\n", "// CAS failed. We need to recompute prev and next. It is unlikely to", "// be helpful to try to use a different level as we redo the search,", "// because it is unlikely that lots of nodes are inserted between prev", "// and next.", "prev", ",", "next", ",", "found", "=", "it", ".", "list", ".", "findSpliceForLevel", "(", "key", ",", "i", ",", "prev", ")", "\n", "if", "found", "{", "if", "i", "!=", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "it", ".", "setValueIfDeleted", "(", "next", ",", "val", ",", "meta", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "it", ".", "value", "=", "value", "\n", "it", ".", "nd", "=", "nd", "\n", "return", "nil", "\n", "}" ]
5,606
all-5607
[ "GithookService", "returns", "a", "k8s", "service", "that", "exposes", "a", "public", "IP" ]
[ "func", "GithookService", "(", "namespace", "string", ")", "*", "v1", ".", "Service", "{", "name", ":=", "\"", "\"", "\n", "return", "&", "v1", ".", "Service", "{", "TypeMeta", ":", "metav1", ".", "TypeMeta", "{", "Kind", ":", "\"", "\"", ",", "APIVersion", ":", "\"", "\"", ",", "}", ",", "ObjectMeta", ":", "objectMeta", "(", "name", ",", "labels", "(", "name", ")", ",", "nil", ",", "namespace", ")", ",", "Spec", ":", "v1", ".", "ServiceSpec", "{", "Type", ":", "v1", ".", "ServiceTypeLoadBalancer", ",", "Selector", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "pachdName", ",", "}", ",", "Ports", ":", "[", "]", "v1", ".", "ServicePort", "{", "{", "TargetPort", ":", "intstr", ".", "FromInt", "(", "githook", ".", "GitHookPort", ")", ",", "<mask>", ":", "\"", "\"", ",", "Port", ":", "githook", ".", "ExternalPort", "(", ")", ",", "}", ",", "}", ",", "}", ",", "}", "\n", "}" ]
5,607
all-5608
[ "DockerReferenceIdentity", "returns", "a", "string", "representation", "of", "the", "reference", "suitable", "for", "policy", "lookup", "as", "a", "backend", "for", "ImageReference", ".", "PolicyConfigurationIdentity", ".", "The", "reference", "must", "satisfy", "!reference", ".", "IsNameOnly", "()", "." ]
[ "func", "DockerReferenceIdentity", "(", "ref", "reference", ".", "Named", ")", "(", "string", ",", "error", ")", "{", "res", ":=", "ref", ".", "Name", "(", ")", "\n", "tagged", ",", "isTagged", ":=", "ref", ".", "(", "reference", ".", "NamedTagged", ")", "\n", "digested", ",", "isDigested", ":=", "ref", ".", "(", "reference", ".", "Canonical", ")", "\n", "switch", "{", "case", "isTagged", "&&", "isDigested", ":", "// Note that this CAN actually happen.", "return", "\"", "\"", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "reference", ".", "FamiliarString", "(", "<mask>", ")", ")", "\n", "case", "!", "isTagged", "&&", "!", "isDigested", ":", "// This should not happen, the caller is expected to ensure !reference.IsNameOnly()", "return", "\"", "\"", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "reference", ".", "FamiliarString", "(", "ref", ")", ")", "\n", "case", "isTagged", ":", "res", "=", "res", "+", "\"", "\"", "+", "tagged", ".", "Tag", "(", ")", "\n", "case", "isDigested", ":", "res", "=", "res", "+", "\"", "\"", "+", "digested", ".", "Digest", "(", ")", ".", "String", "(", ")", "\n", "default", ":", "// Coverage: The above was supposed to be exhaustive.", "return", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "res", ",", "nil", "\n", "}" ]
5,608
all-5609
[ "clamp", "clamps", "v", "to", "the", "range", "[", "min", "max", "]", "." ]
[ "func", "clamp", "(", "v", ",", "min", ",", "max", "int", ")", "int", "{", "if", "min", ">", "max", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "v", "<", "<mask>", "{", "return", "min", "\n", "}", "\n", "if", "max", "<", "v", "{", "return", "max", "\n", "}", "\n", "return", "v", "\n", "}" ]
5,609
all-5610
[ "UpdateRuleSetGroup", "updates", "passed", "rule", "set", "group", "." ]
[ "func", "(", "a", "*", "API", ")", "UpdateRuleSetGroup", "(", "cfg", "*", "RuleSetGroup", ")", "(", "*", "RuleSetGroup", ",", "error", ")", "{", "if", "cfg", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "groupCID", ":=", "string", "(", "cfg", ".", "CID", ")", "\n\n", "matched", ",", "err", ":=", "regexp", ".", "MatchString", "(", "config", ".", "RuleSetGroupCIDRegex", ",", "groupCID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "!", "matched", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "groupCID", ")", "\n", "}", "\n\n", "jsonCfg", ",", "err", ":=", "json", ".", "Marshal", "(", "cfg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "a", ".", "Debug", "{", "a", ".", "Log", ".", "Printf", "(", "\"", "\"", ",", "string", "(", "jsonCfg", ")", ")", "\n", "}", "\n\n", "result", ",", "err", ":=", "a", ".", "Put", "(", "groupCID", ",", "jsonCfg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "<mask>", ":=", "&", "RuleSetGroup", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "result", ",", "groups", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "groups", ",", "nil", "\n", "}" ]
5,610
all-5611
[ "Add", "will", "append", "a", "URL", "parameter", "to", "the", "end", "of", "the", "route", "param" ]
[ "func", "(", "s", "*", "RouteParams", ")", "Add", "(", "key", ",", "<mask>", "string", ")", "{", "(", "*", "s", ")", ".", "Keys", "=", "append", "(", "(", "*", "s", ")", ".", "Keys", ",", "key", ")", "\n", "(", "*", "s", ")", ".", "Values", "=", "append", "(", "(", "*", "s", ")", ".", "Values", ",", "value", ")", "\n", "}" ]
5,611
all-5612
[ "Make", "a", "deep", "copy", "from", "src", "into", "dst", "." ]
[ "func", "Copy", "(", "dst", "interface", "{", "}", ",", "src", "interface", "{", "}", ")", "error", "{", "if", "dst", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "src", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "<mask>", ",", "err", ":=", "json", ".", "Marshal", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "err", "=", "json", ".", "Unmarshal", "(", "bytes", ",", "dst", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
5,612
all-5613
[ "SetSupportSelection", "()", "is", "a", "wrapper", "around", "gtk_print_operation_set_support_selection", "()", "." ]
[ "func", "(", "po", "*", "PrintOperation", ")", "SetSupportSelection", "(", "selection", "bool", ")", "{", "C", ".", "gtk_print_operation_set_support_selection", "(", "<mask>", ".", "native", "(", ")", ",", "gbool", "(", "selection", ")", ")", "\n", "}" ]
5,613
all-5614
[ "getGubernatorMetadata", "returns", "a", "JSON", "string", "with", "machine", "-", "readable", "information", "about", "approvers", ".", "This", "MUST", "be", "kept", "in", "sync", "with", "gubernator", "/", "github", "/", "classifier", ".", "py", "particularly", "get_approvers", "." ]
[ "func", "getGubernatorMetadata", "(", "toBeAssigned", "[", "]", "string", ")", "string", "{", "bytes", ",", "err", ":=", "json", ".", "Marshal", "(", "map", "[", "string", "]", "[", "]", "string", "{", "\"", "\"", ":", "toBeAssigned", "}", ")", "\n", "if", "err", "==", "nil", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "<mask>", ")", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
5,614
all-5615
[ "Create", "the", "specified", "image", "alises", "updating", "those", "that", "already", "exist" ]
[ "func", "ensureImageAliases", "(", "client", "lxd", ".", "ContainerServer", ",", "aliases", "[", "]", "api", ".", "ImageAlias", ",", "fingerprint", "string", ")", "error", "{", "if", "len", "(", "aliases", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "names", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "aliases", ")", ")", "\n", "for", "i", ",", "alias", ":=", "range", "aliases", "{", "names", "[", "i", "]", "=", "alias", ".", "Name", "\n", "}", "\n", "sort", ".", "Strings", "(", "names", ")", "\n\n", "resp", ",", "err", ":=", "client", ".", "GetImageAliases", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Delete existing aliases that match provided ones", "for", "_", ",", "alias", ":=", "range", "GetExistingAliases", "(", "names", ",", "resp", ")", "{", "err", ":=", "client", ".", "DeleteImageAlias", "(", "alias", ".", "Name", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Println", "(", "fmt", ".", "Sprintf", "(", "i18n", ".", "G", "(", "\"", "\"", ")", ",", "alias", ".", "Name", ")", ")", "\n", "}", "\n", "}", "\n", "// Create new aliases", "for", "_", ",", "alias", ":=", "range", "aliases", "{", "aliasPost", ":=", "api", ".", "ImageAliasesPost", "{", "}", "\n", "aliasPost", ".", "Name", "=", "alias", ".", "Name", "\n", "aliasPost", ".", "Target", "=", "fingerprint", "\n", "err", ":=", "client", ".", "CreateImageAlias", "(", "aliasPost", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Println", "(", "fmt", ".", "Sprintf", "(", "i18n", ".", "G", "(", "\"", "\"", ")", ",", "alias", ".", "<mask>", ")", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
5,615
all-5616
[ "Returns", "the", "Bottom", "-", "Right", "Point", "of", "the", "rectangle" ]
[ "func", "(", "r", "*", "Rect", ")", "BR", "(", ")", "<mask>", "{", "return", "Point", "{", "int", "(", "r", ".", "x", ")", "+", "int", "(", "r", ".", "width", ")", ",", "int", "(", "r", ".", "y", ")", "+", "int", "(", "r", ".", "height", ")", "}", "\n", "}" ]
5,616
all-5617
[ "specify", "the", "organization", "of", "vertex", "arrays" ]
[ "func", "VertexAttribFormat", "(", "attribindex", "uint32", ",", "size", "int32", ",", "xtype", "uint32", ",", "normalized", "bool", ",", "relativeoffset", "uint32", ")", "{", "C", ".", "glowVertexAttribFormat", "(", "gpVertexAttribFormat", ",", "(", "C", ".", "GLuint", ")", "(", "attribindex", ")", ",", "(", "C", ".", "GLint", ")", "(", "<mask>", ")", ",", "(", "C", ".", "GLenum", ")", "(", "xtype", ")", ",", "(", "C", ".", "GLboolean", ")", "(", "boolToInt", "(", "normalized", ")", ")", ",", "(", "C", ".", "GLuint", ")", "(", "relativeoffset", ")", ")", "\n", "}" ]
5,617
all-5618
[ "GetEvaluationDuration", "returns", "the", "time", "in", "seconds", "it", "took", "to", "evaluate", "the", "alerting", "rule", "." ]
[ "func", "(", "r", "*", "AlertingRule", ")", "GetEvaluationDuration", "(", ")", "<mask>", ".", "Duration", "{", "r", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "mtx", ".", "Unlock", "(", ")", "\n", "return", "r", ".", "evaluationDuration", "\n", "}" ]
5,618
all-5619
[ "Locator", "returns", "a", "locator", "for", "the", "given", "resource" ]
[ "func", "(", "r", "*", "Network", ")", "Locator", "(", "api", "*", "API", ")", "*", "NetworkLocator", "{", "for", "_", ",", "l", ":=", "<mask>", "r", ".", "Links", "{", "if", "l", "[", "\"", "\"", "]", "==", "\"", "\"", "{", "return", "api", ".", "NetworkLocator", "(", "l", "[", "\"", "\"", "]", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
5,619
all-5620
[ "getActiveConn", "will", "randomly", "select", "an", "active", "connection", ".", "TODO", "(", "prashant", ")", ":", "Should", "we", "clear", "inactive", "connections?", "TODO", "(", "prashant", ")", ":", "Do", "we", "want", "some", "sort", "of", "scoring", "for", "connections?" ]
[ "func", "(", "p", "*", "Peer", ")", "getActiveConn", "(", ")", "(", "*", "Connection", ",", "bool", ")", "{", "p", ".", "RLock", "(", ")", "\n", "conn", ",", "ok", ":=", "p", ".", "getActiveConnLocked", "(", ")", "\n", "p", ".", "RUnlock", "(", ")", "\n\n", "return", "conn", ",", "<mask>", "\n", "}" ]
5,620
all-5621
[ "TLSConnectionState", "returns", "TLS", "connection", "state", ".", "The", "function", "returns", "nil", "if", "the", "underlying", "connection", "isn", "t", "tls", ".", "Conn", ".", "The", "returned", "state", "may", "be", "used", "for", "verifying", "TLS", "version", "client", "certificates", "etc", "." ]
[ "func", "(", "ctx", "*", "RequestCtx", ")", "TLSConnectionState", "(", ")", "*", "tls", ".", "ConnectionState", "{", "tlsConn", ",", "ok", ":=", "ctx", ".", "c", ".", "(", "connTLSer", ")", "\n", "if", "!", "<mask>", "{", "return", "nil", "\n", "}", "\n", "state", ":=", "tlsConn", ".", "ConnectionState", "(", ")", "\n", "return", "&", "state", "\n", "}" ]
5,621
all-5622
[ "RunCommand", "parses", "and", "runs", "the", "command", "with", "the", "given", "name", "." ]
[ "func", "(", "a", "*", "API", ")", "RunCommand", "(", "cmd", "string", ")", "(", "*", "http", ".", "<mask>", ",", "error", ")", "{", "parsed", ",", "err", ":=", "a", ".", "ParseCommand", "(", "cmd", ",", "\"", "\"", ",", "commandValues", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "href", ":=", "parsed", ".", "URI", "\n", "if", "!", "strings", ".", "HasPrefix", "(", "href", ",", "\"", "\"", ")", "{", "href", "=", "path", ".", "Join", "(", "\"", "\"", ",", "href", ")", "\n", "}", "\n", "req", ",", "err", ":=", "a", ".", "BuildHTTPRequest", "(", "\"", "\"", ",", "href", ",", "\"", "\"", ",", "parsed", ".", "QueryParams", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "a", ".", "PerformRequest", "(", "req", ")", "\n", "}" ]
5,622
all-5623
[ "HasCompareTo", "returns", "a", "boolean", "if", "a", "field", "has", "been", "set", "." ]
[ "func", "(", "t", "*", "TileDefRequest", ")", "HasCompareTo", "(", ")", "bool", "{", "if", "t", "!=", "nil", "&&", "t", ".", "CompareTo", "!=", "nil", "{", "return", "<mask>", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
5,623
all-5624
[ "Round", "returns", "a", "point", "inside", "the", "box", "making", "an", "effort", "to", "round", "to", "minimal", "precision", "." ]
[ "func", "(", "b", "Box", ")", "Round", "(", ")", "(", "<mask>", ",", "lng", "float64", ")", "{", "x", ":=", "maxDecimalPower", "(", "b", ".", "MaxLat", "-", "b", ".", "MinLat", ")", "\n", "lat", "=", "math", ".", "Ceil", "(", "b", ".", "MinLat", "/", "x", ")", "*", "x", "\n", "x", "=", "maxDecimalPower", "(", "b", ".", "MaxLng", "-", "b", ".", "MinLng", ")", "\n", "lng", "=", "math", ".", "Ceil", "(", "b", ".", "MinLng", "/", "x", ")", "*", "x", "\n", "return", "\n", "}" ]
5,624
all-5625
[ "GetIncludeZero", "returns", "the", "IncludeZero", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "y", "*", "Yaxis", ")", "GetIncludeZero", "(", ")", "bool", "{", "if", "y", "==", "nil", "||", "y", ".", "IncludeZero", "==", "nil", "{", "return", "<mask>", "\n", "}", "\n", "return", "*", "y", ".", "IncludeZero", "\n", "}" ]
5,625
all-5626
[ "WriteTaskMetadataResponse", "writes", "the", "task", "metadata", "to", "response", "writer", "." ]
[ "func", "WriteTaskMetadataResponse", "(", "w", "http", ".", "ResponseWriter", ",", "taskARN", "string", ",", "cluster", "string", ",", "state", "dockerstate", ".", "TaskEngineState", ",", "ecsClient", "api", ".", "ECSClient", ",", "az", ",", "containerInstanceArn", "string", ",", "propagateTags", "bool", ")", "{", "// Generate a response for the task", "taskResponse", ",", "err", ":=", "NewTaskResponse", "(", "taskARN", ",", "<mask>", ",", "ecsClient", ",", "cluster", ",", "az", ",", "containerInstanceArn", ",", "propagateTags", ")", "\n", "if", "err", "!=", "nil", "{", "errResponseJSON", ",", "_", ":=", "json", ".", "Marshal", "(", "\"", "\"", "+", "taskARN", "+", "\"", "\"", ")", "\n", "utils", ".", "WriteJSONToResponse", "(", "w", ",", "http", ".", "StatusBadRequest", ",", "errResponseJSON", ",", "utils", ".", "RequestTypeTaskMetadata", ")", "\n", "return", "\n", "}", "\n\n", "responseJSON", ",", "_", ":=", "json", ".", "Marshal", "(", "taskResponse", ")", "\n", "utils", ".", "WriteJSONToResponse", "(", "w", ",", "http", ".", "StatusOK", ",", "responseJSON", ",", "utils", ".", "RequestTypeTaskMetadata", ")", "\n", "}" ]
5,626
all-5627
[ "ToMap", "is", "used", "to", "walk", "the", "tree", "and", "convert", "it", "into", "a", "map" ]
[ "func", "(", "t", "*", "Tree", ")", "ToMap", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "out", ":=", "<mask>", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "t", ".", "size", ")", "\n", "t", ".", "Walk", "(", "func", "(", "k", "string", ",", "v", "interface", "{", "}", ")", "bool", "{", "out", "[", "k", "]", "=", "v", "\n", "return", "false", "\n", "}", ")", "\n", "return", "out", "\n", "}" ]
5,627
all-5628
[ "Read", "reads", "and", "decrypts", "data", "into", "p", ".", "If", "the", "input", "is", "not", "a", "multiple", "of", "the", "cipher", "block", "size", "the", "trailing", "bytes", "will", "be", "ignored", "." ]
[ "func", "(", "cr", "*", "cipherBlockReader", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "for", "{", "if", "cr", ".", "n", "<", "len", "(", "cr", ".", "outbuf", ")", "{", "// return buffered output", "n", "=", "copy", "(", "p", ",", "cr", ".", "outbuf", "[", "cr", ".", "n", ":", "]", ")", "\n", "cr", ".", "n", "+=", "n", "\n", "return", "n", ",", "nil", "\n", "}", "\n", "if", "cr", ".", "err", "!=", "nil", "{", "err", "=", "cr", ".", "err", "\n", "cr", ".", "err", "=", "nil", "\n", "return", "0", ",", "err", "\n", "}", "\n", "if", "len", "(", "p", ")", ">=", "cap", "(", "cr", ".", "outbuf", ")", "{", "break", "\n", "}", "\n", "// p is not large enough to process a block, use outbuf instead", "n", ",", "cr", ".", "err", "=", "cr", ".", "read", "(", "cr", ".", "outbuf", "[", ":", "cap", "(", "cr", ".", "outbuf", ")", "]", ")", "\n", "cr", ".", "outbuf", "=", "cr", ".", "outbuf", "[", ":", "n", "]", "\n", "cr", ".", "n", "=", "0", "\n", "}", "\n", "// read blocks into p", "return", "cr", ".", "<mask>", "(", "p", ")", "\n", "}" ]
5,628
all-5629
[ "Links", "returns", "URLs", "or", "identifies", "from", "third", "parties", "for", "this", "venue", "https", ":", "//", "developer", ".", "foursquare", ".", "com", "/", "docs", "/", "api", "/", "venues", "/", "links" ]
[ "func", "(", "s", "*", "VenueService", ")", "Links", "(", "id", "string", ")", "(", "*", "Links", ",", "*", "http", ".", "Response", ",", "error", ")", "{", "links", ":=", "new", "(", "venueLinkResp", ")", "\n", "response", ":=", "new", "(", "Response", ")", "\n\n", "resp", ",", "err", ":=", "s", ".", "sling", ".", "New", "(", ")", ".", "Get", "(", "<mask>", "+", "\"", "\"", ")", ".", "Receive", "(", "response", ",", "response", ")", "\n", "if", "err", "==", "nil", "{", "json", ".", "Unmarshal", "(", "response", ".", "Response", ",", "links", ")", "\n", "}", "\n\n", "return", "&", "links", ".", "Links", ",", "resp", ",", "relevantError", "(", "err", ",", "*", "response", ")", "\n", "}" ]
5,629
all-5630
[ "Default", "returns", "the", "default", "router" ]
[ "func", "Default", "(", ")", "(", "string", ",", "error", ")", "{", "plans", ",", "err", ":=", "List", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "len", "(", "plans", ")", "==", "0", "{", "return", "\"", "\"", ",", "ErrDefaultRouterNotFound", "\n", "}", "\n", "if", "len", "(", "plans", ")", "==", "1", "{", "return", "plans", "[", "0", "]", ".", "Name", ",", "nil", "\n", "}", "\n", "for", "_", ",", "p", ":=", "range", "plans", "{", "if", "p", ".", "<mask>", "{", "return", "p", ".", "Name", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "\"", "\"", ",", "ErrDefaultRouterNotFound", "\n", "}" ]
5,630
all-5631
[ "Resource", "maps", "an", "implementation", "of", "the", "Resource", "interface", "to", "the", "appropriate", "RESTful", "mappings", ".", "Resource", "returns", "the", "*", "App", "associated", "with", "this", "group", "of", "mappings", "so", "you", "can", "set", "middleware", "etc", "...", "on", "that", "group", "just", "as", "if", "you", "had", "used", "the", "a", ".", "Group", "functionality", ".", "/", "*", "a", ".", "Resource", "(", "/", "users", "&UsersResource", "{}", ")" ]
[ "func", "(", "a", "*", "App", ")", "Resource", "(", "p", "string", ",", "r", "Resource", ")", "*", "App", "{", "g", ":=", "a", ".", "Group", "(", "p", ")", "\n", "p", "=", "\"", "\"", "\n\n", "rv", ":=", "reflect", ".", "ValueOf", "(", "r", ")", "\n", "if", "rv", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "rv", "=", "rv", ".", "Elem", "(", ")", "\n", "}", "\n\n", "rt", ":=", "rv", ".", "Type", "(", ")", "\n", "rname", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "rt", ".", "PkgPath", "(", ")", ",", "rt", ".", "Name", "(", ")", ")", "+", "\"", "\"", "\n\n", "n", ":=", "strings", ".", "TrimSuffix", "(", "rt", ".", "Name", "(", ")", ",", "\"", "\"", ")", "\n", "paramName", ":=", "name", ".", "New", "(", "n", ")", ".", "ParamID", "(", ")", ".", "String", "(", ")", "\n\n", "type", "paramKeyable", "interface", "{", "ParamKey", "(", ")", "string", "\n", "}", "\n\n", "if", "pk", ",", "ok", ":=", "r", ".", "(", "paramKeyable", ")", ";", "ok", "{", "paramName", "=", "pk", ".", "ParamKey", "(", ")", "\n", "}", "\n\n", "spath", ":=", "path", ".", "Join", "(", "p", ",", "\"", "\"", "+", "paramName", "+", "\"", "\"", ")", "\n", "setFuncKey", "(", "r", ".", "List", ",", "fmt", ".", "Sprintf", "(", "rname", ",", "\"", "\"", ")", ")", "\n", "g", ".", "<mask>", "(", "p", ",", "r", ".", "List", ")", "\n\n", "if", "n", ",", "ok", ":=", "r", ".", "(", "newable", ")", ";", "ok", "{", "setFuncKey", "(", "n", ".", "New", ",", "fmt", ".", "Sprintf", "(", "rname", ",", "\"", "\"", ")", ")", "\n", "g", ".", "GET", "(", "path", ".", "Join", "(", "p", ",", "\"", "\"", ")", ",", "n", ".", "New", ")", "\n", "}", "\n\n", "setFuncKey", "(", "r", ".", "Show", ",", "fmt", ".", "Sprintf", "(", "rname", ",", "\"", "\"", ")", ")", "\n", "g", ".", "GET", "(", "path", ".", "Join", "(", "spath", ")", ",", "r", ".", "Show", ")", "\n\n", "if", "n", ",", "ok", ":=", "r", ".", "(", "editable", ")", ";", "ok", "{", "setFuncKey", "(", "n", ".", "Edit", ",", "fmt", ".", "Sprintf", "(", "rname", ",", "\"", "\"", ")", ")", "\n", "g", ".", "GET", "(", "path", ".", "Join", "(", "spath", ",", "\"", "\"", ")", ",", "n", ".", "Edit", ")", "\n", "}", "\n\n", "setFuncKey", "(", "r", ".", "Create", ",", "fmt", ".", "Sprintf", "(", "rname", ",", "\"", "\"", ")", ")", "\n", "g", ".", "POST", "(", "p", ",", "r", ".", "Create", ")", "\n", "setFuncKey", "(", "r", ".", "Update", ",", "fmt", ".", "Sprintf", "(", "rname", ",", "\"", "\"", ")", ")", "\n", "g", ".", "PUT", "(", "path", ".", "Join", "(", "spath", ")", ",", "r", ".", "Update", ")", "\n", "setFuncKey", "(", "r", ".", "Destroy", ",", "fmt", ".", "Sprintf", "(", "rname", ",", "\"", "\"", ")", ")", "\n", "g", ".", "DELETE", "(", "path", ".", "Join", "(", "spath", ")", ",", "r", ".", "Destroy", ")", "\n", "g", ".", "Prefix", "=", "path", ".", "Join", "(", "g", ".", "Prefix", ",", "spath", ")", "\n", "return", "g", "\n", "}" ]
5,631
all-5632
[ "ProcessChange", "creates", "new", "presubmit", "prowjobs", "base", "off", "the", "gerrit", "changes" ]
[ "func", "(", "c", "*", "Controller", ")", "ProcessChange", "(", "instance", "string", ",", "change", "client", ".", "ChangeInfo", ")", "error", "{", "logger", ":=", "logrus", ".", "WithField", "(", "\"", "\"", ",", "change", ".", "Number", ")", "\n\n", "cloneURI", ",", "err", ":=", "makeCloneURI", "(", "instance", ",", "change", ".", "Project", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "baseSHA", ",", "err", ":=", "c", ".", "gc", ".", "GetBranchRevision", "(", "instance", ",", "change", ".", "Project", ",", "change", ".", "Branch", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "triggeredJobs", ":=", "[", "]", "string", "{", "}", "\n\n", "refs", ",", "err", ":=", "createRefs", "(", "instance", ",", "change", ",", "cloneURI", ",", "baseSHA", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "type", "jobSpec", "struct", "{", "spec", "prowapi", ".", "ProwJobSpec", "\n", "labels", "map", "[", "string", "]", "string", "\n", "}", "\n\n", "var", "jobSpecs", "[", "]", "jobSpec", "\n\n", "changedFiles", ":=", "listChangedFiles", "(", "change", ")", "\n\n", "switch", "change", ".", "Status", "{", "case", "client", ".", "Merged", ":", "postsubmits", ":=", "c", ".", "config", "(", ")", ".", "Postsubmits", "[", "cloneURI", ".", "String", "(", ")", "]", "\n", "postsubmits", "=", "append", "(", "postsubmits", ",", "c", ".", "config", "(", ")", ".", "Postsubmits", "[", "cloneURI", ".", "Host", "+", "\"", "\"", "+", "cloneURI", ".", "<mask>", "]", "...", ")", "\n", "for", "_", ",", "postsubmit", ":=", "range", "postsubmits", "{", "if", "shouldRun", ",", "err", ":=", "postsubmit", ".", "ShouldRun", "(", "change", ".", "Branch", ",", "changedFiles", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "postsubmit", ".", "Name", ",", "err", ")", "\n", "}", "else", "if", "shouldRun", "{", "jobSpecs", "=", "append", "(", "jobSpecs", ",", "jobSpec", "{", "spec", ":", "pjutil", ".", "PostsubmitSpec", "(", "postsubmit", ",", "refs", ")", ",", "labels", ":", "postsubmit", ".", "Labels", ",", "}", ")", "\n", "}", "\n", "}", "\n", "case", "client", ".", "New", ":", "presubmits", ":=", "c", ".", "config", "(", ")", ".", "Presubmits", "[", "cloneURI", ".", "String", "(", ")", "]", "\n", "presubmits", "=", "append", "(", "presubmits", ",", "c", ".", "config", "(", ")", ".", "Presubmits", "[", "cloneURI", ".", "Host", "+", "\"", "\"", "+", "cloneURI", ".", "Path", "]", "...", ")", "\n", "var", "filters", "[", "]", "pjutil", ".", "Filter", "\n", "filter", ",", "err", ":=", "messageFilter", "(", "c", ".", "lastUpdate", ",", "change", ",", "presubmits", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "WithError", "(", "err", ")", ".", "Warn", "(", "\"", "\"", ")", "\n", "}", "else", "{", "filters", "=", "append", "(", "filters", ",", "filter", ")", "\n", "}", "\n", "if", "change", ".", "Revisions", "[", "change", ".", "CurrentRevision", "]", ".", "Created", ".", "Time", ".", "After", "(", "c", ".", "lastUpdate", ")", "{", "filters", "=", "append", "(", "filters", ",", "pjutil", ".", "TestAllFilter", "(", ")", ")", "\n", "}", "\n", "toTrigger", ",", "_", ",", "err", ":=", "pjutil", ".", "FilterPresubmits", "(", "pjutil", ".", "AggregateFilter", "(", "filters", ")", ",", "listChangedFiles", "(", "change", ")", ",", "change", ".", "Branch", ",", "presubmits", ",", "logger", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "for", "_", ",", "presubmit", ":=", "range", "toTrigger", "{", "jobSpecs", "=", "append", "(", "jobSpecs", ",", "jobSpec", "{", "spec", ":", "pjutil", ".", "PresubmitSpec", "(", "presubmit", ",", "refs", ")", ",", "labels", ":", "presubmit", ".", "Labels", ",", "}", ")", "\n", "}", "\n", "}", "\n\n", "annotations", ":=", "map", "[", "string", "]", "string", "{", "client", ".", "GerritID", ":", "change", ".", "ID", ",", "client", ".", "GerritInstance", ":", "instance", ",", "}", "\n\n", "for", "_", ",", "jSpec", ":=", "range", "jobSpecs", "{", "labels", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "for", "k", ",", "v", ":=", "range", "jSpec", ".", "labels", "{", "labels", "[", "k", "]", "=", "v", "\n", "}", "\n", "labels", "[", "client", ".", "GerritRevision", "]", "=", "change", ".", "CurrentRevision", "\n\n", "if", "gerritLabel", ",", "ok", ":=", "labels", "[", "client", ".", "GerritReportLabel", "]", ";", "!", "ok", "||", "gerritLabel", "==", "\"", "\"", "{", "labels", "[", "client", ".", "GerritReportLabel", "]", "=", "client", ".", "CodeReview", "\n", "}", "\n\n", "pj", ":=", "pjutil", ".", "NewProwJobWithAnnotation", "(", "jSpec", ".", "spec", ",", "labels", ",", "annotations", ")", "\n", "if", "_", ",", "err", ":=", "c", ".", "kc", ".", "CreateProwJob", "(", "pj", ")", ";", "err", "!=", "nil", "{", "logger", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "pj", ")", "\n", "}", "else", "{", "logger", ".", "Infof", "(", "\"", "\"", ",", "jSpec", ".", "spec", ".", "Job", ")", "\n", "triggeredJobs", "=", "append", "(", "triggeredJobs", ",", "jSpec", ".", "spec", ".", "Job", ")", "\n", "}", "\n", "}", "\n\n", "if", "len", "(", "triggeredJobs", ")", ">", "0", "{", "// comment back to gerrit", "message", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "len", "(", "triggeredJobs", ")", ")", "\n", "for", "_", ",", "job", ":=", "range", "triggeredJobs", "{", "message", "+=", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "job", ")", "\n", "}", "\n\n", "if", "err", ":=", "c", ".", "gc", ".", "SetReview", "(", "instance", ",", "change", ".", "ID", ",", "change", ".", "CurrentRevision", ",", "message", ",", "nil", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
5,632
all-5633
[ "UnmarshalJSON", "implements", "the", "json", ".", "Unmarshaler", "interface", "." ]
[ "func", "(", "m", "*", "policyTransportsMap", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "// We can't unmarshal directly into map values because it is not possible to take an address of a map value.", "// So, use a temporary map of pointers-to-slices and convert.", "tmpMap", ":=", "map", "[", "string", "]", "*", "PolicyTransportScopes", "{", "}", "\n", "if", "err", ":=", "paranoidUnmarshalJSONObject", "(", "data", ",", "func", "(", "key", "string", ")", "interface", "{", "}", "{", "// transport can be nil", "transport", ":=", "transports", ".", "Get", "(", "key", ")", "\n", "// paranoidUnmarshalJSONObject detects key duplication for us, check just to be safe.", "if", "_", ",", "ok", ":=", "tmpMap", "[", "key", "]", ";", "ok", "{", "return", "nil", "\n", "}", "\n", "ptsWithTransport", ":=", "policyTransportScopesWithTransport", "{", "transport", ":", "transport", ",", "dest", ":", "&", "PolicyTransportScopes", "{", "}", ",", "// This allocates a new instance on each call.", "}", "\n", "tmpMap", "[", "key", "]", "=", "ptsWithTransport", ".", "dest", "\n", "return", "&", "ptsWithTransport", "\n", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "for", "key", ",", "ptr", ":=", "range", "tmpMap", "{", "(", "*", "m", ")", "[", "key", "]", "=", "*", "ptr", "\n", "}", "\n", "return", "nil", "\n", "}" ]
5,633
all-5634
[ "Reset", "clears", "response", "header", "." ]
[ "func", "(", "h", "*", "ResponseHeader", ")", "Reset", "(", ")", "{", "h", ".", "disableNormalizing", "=", "<mask>", "\n", "h", ".", "noDefaultContentType", "=", "false", "\n", "h", ".", "resetSkipNormalize", "(", ")", "\n", "}" ]
5,634
all-5635
[ "MutateTX", "runs", "Mutate", "on", "the", "underlying", "transaction", "using", "the", "provided", "mutators", "." ]
[ "func", "(", "b", "*", "TransactionEnvelopeBuilder", ")", "MutateTX", "(", "muts", "...", "TransactionMutator", ")", "{", "b", ".", "Init", "(", ")", "\n\n", "if", "b", ".", "Err", "!=", "nil", "{", "return", "\n", "}", "\n\n", "b", ".", "child", ".", "Mutate", "(", "muts", "...", ")", "\n", "b", ".", "Err", "=", "b", ".", "<mask>", ".", "Err", "\n", "}" ]
5,635
all-5636
[ "TODO", "(", "amwat", ")", ":", "remove", "this", "logic", "when", "we", "get", "rid", "of", "--", "project", "." ]
[ "func", "<mask>", "(", "rtype", "string", ")", "string", "{", "splits", ":=", "strings", ".", "Split", "(", "rtype", ",", "\"", "\"", ")", "\n", "return", "splits", "[", "len", "(", "splits", ")", "-", "1", "]", "\n", "}" ]
5,636
all-5637
[ "Encoder", "returns", "a", "new", "StreamEncoder", "which", "can", "be", "used", "to", "re", "-", "encode", "the", "stream", "decoded", "by", "d", "into", "e", ".", "The", "method", "panics", "if", "e", "is", "nil", "." ]
[ "func", "(", "d", "*", "StreamDecoder", ")", "Encoder", "(", "e", "Emitter", ")", "(", "enc", "*", "StreamEncoder", ",", "err", "error", ")", "{", "var", "typ", "<mask>", "\n\n", "if", "typ", ",", "err", "=", "d", ".", "Parser", ".", "ParseType", "(", ")", ";", "err", "==", "nil", "{", "enc", "=", "NewStreamEncoder", "(", "e", ")", "\n", "enc", ".", "oneshot", "=", "typ", "!=", "Array", "\n", "}", "\n\n", "return", "\n", "}" ]
5,637
all-5638
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "SetFileInputFilesParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "<mask>", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom7", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "Error", "(", ")", "\n", "}" ]
5,638
all-5639
[ "Func", "renderer", "allows", "for", "easily", "building", "one", "of", "renderers", "using", "just", "a", "RendererFunc", "and", "not", "having", "to", "build", "a", "whole", "implementation", "of", "the", "Render", "interface", "." ]
[ "func", "(", "e", "*", "<mask>", ")", "Func", "(", "s", "string", ",", "fn", "RendererFunc", ")", "Renderer", "{", "return", "Func", "(", "s", ",", "fn", ")", "\n", "}" ]
5,639
all-5640
[ "SetTransitionDuration", "is", "a", "wrapper", "around", "gtk_stack_set_transition_duration", "()", "." ]
[ "func", "(", "v", "*", "Stack", ")", "SetTransitionDuration", "(", "duration", "uint", ")", "{", "C", ".", "gtk_stack_set_transition_duration", "(", "v", ".", "native", "(", ")", ",", "C", ".", "guint", "(", "<mask>", ")", ")", "\n", "}" ]
5,640
all-5641
[ "SetRadio", "is", "a", "wrapper", "around", "gtk_cell_renderer_toggle_set_radio", "()", "." ]
[ "func", "(", "v", "*", "CellRendererToggle", ")", "SetRadio", "(", "<mask>", "bool", ")", "{", "C", ".", "gtk_cell_renderer_toggle_set_radio", "(", "v", ".", "native", "(", ")", ",", "gbool", "(", "set", ")", ")", "\n", "}" ]
5,641
all-5642
[ "applyCompare", "applies", "the", "compare", "request", ".", "If", "the", "comparison", "succeeds", "it", "returns", "true", ".", "Otherwise", "returns", "false", "." ]
[ "func", "applyCompare", "(", "rv", "mvcc", ".", "ReadView", ",", "c", "*", "pb", ".", "Compare", ")", "bool", "{", "// TODO: possible optimizations", "// * chunk reads for large ranges to conserve memory", "// * rewrite rules for common patterns:", "//\tex. \"[a, b) createrev > 0\" => \"limit 1 /\\ kvs > 0\"", "// * caching", "rr", ",", "err", ":=", "rv", ".", "Range", "(", "c", ".", "Key", ",", "mkGteRange", "(", "c", ".", "RangeEnd", ")", ",", "mvcc", ".", "RangeOptions", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "if", "len", "(", "rr", ".", "KVs", ")", "==", "0", "{", "if", "c", ".", "Target", "==", "<mask>", ".", "Compare_VALUE", "{", "// Always fail if comparing a value on a key/keys that doesn't exist;", "// nil == empty string in grpc; no way to represent missing value", "return", "false", "\n", "}", "\n", "return", "compareKV", "(", "c", ",", "mvccpb", ".", "KeyValue", "{", "}", ")", "\n", "}", "\n", "for", "_", ",", "kv", ":=", "range", "rr", ".", "KVs", "{", "if", "!", "compareKV", "(", "c", ",", "kv", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
5,642
all-5643
[ "SetGroup", "is", "a", "wrapper", "around", "gtk_radio_menu_item_set_group", "()", "." ]
[ "func", "(", "v", "*", "RadioMenuItem", ")", "SetGroup", "(", "group", "*", "glib", ".", "SList", ")", "{", "C", ".", "gtk_radio_menu_item_set_group", "(", "v", ".", "native", "(", ")", ",", "cGSList", "(", "<mask>", ")", ")", "\n", "}" ]
5,643
all-5644
[ "RunServer", "will", "set", "up", "GET", "PUT", "and", "DELETE", "endpoints", "for", "the", "specified", "path", "calling", "the", "appropriate", "service", "functions", ":", "PUT", "-", ">", "Write", "GET", "-", ">", "Read", "DELETE", "-", ">", "Delete", "It", "will", "also", "setup", "the", "healthcheck", "and", "ping", "endpoints", "Endpoints", "are", "wrapped", "in", "a", "metrics", "timer", "and", "request", "loggin", "including", "transactionID", "which", "is", "generated", "if", "not", "found", "on", "the", "request", "as", "X", "-", "Request", "-", "Id", "header" ]
[ "func", "RunServer", "(", "services", "map", "[", "string", "]", "Service", ",", "healthHandler", "func", "(", "http", ".", "ResponseWriter", ",", "*", "http", ".", "<mask>", ")", ",", "port", "int", ",", "serviceName", "string", ",", "env", "string", ")", "{", "RunServerWithConf", "(", "RWConf", "{", "EnableReqLog", ":", "true", ",", "Services", ":", "services", ",", "Env", ":", "env", ",", "HealthHandler", ":", "healthHandler", ",", "Port", ":", "port", ",", "ServiceName", ":", "serviceName", ",", "}", ")", "\n", "}" ]
5,644
all-5645
[ "simultaneously", "specify", "storage", "for", "all", "levels", "of", "a", "one", "-", "dimensional", "texture" ]
[ "func", "TexStorage1D", "(", "target", "uint32", ",", "levels", "int32", ",", "internalformat", "uint32", ",", "<mask>", "int32", ")", "{", "C", ".", "glowTexStorage1D", "(", "gpTexStorage1D", ",", "(", "C", ".", "GLenum", ")", "(", "target", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "levels", ")", ",", "(", "C", ".", "GLenum", ")", "(", "internalformat", ")", ",", "(", "C", ".", "GLsizei", ")", "(", "width", ")", ")", "\n", "}" ]
5,645
all-5646
[ "GetResourceTags", "mocks", "base", "method" ]
[ "func", "(", "m", "*", "MockECSClient", ")", "GetResourceTags", "(", "arg0", "string", ")", "(", "[", "]", "*", "ecs", ".", "<mask>", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "[", "]", "*", "ecs", ".", "Tag", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
5,646
all-5647
[ "evalSubquery", "evaluates", "given", "SubqueryExpr", "and", "returns", "an", "equivalent", "evaluated", "MatrixSelector", "in", "its", "place", ".", "Note", "that", "the", "Name", "and", "LabelMatchers", "are", "not", "set", "." ]
[ "func", "(", "ev", "*", "evaluator", ")", "evalSubquery", "(", "subq", "*", "SubqueryExpr", ")", "*", "MatrixSelector", "{", "val", ":=", "ev", ".", "eval", "(", "subq", ")", ".", "(", "Matrix", ")", "\n", "ms", ":=", "&", "MatrixSelector", "{", "Range", ":", "subq", ".", "Range", ",", "Offset", ":", "subq", ".", "Offset", ",", "series", ":", "make", "(", "[", "]", "storage", ".", "Series", ",", "0", ",", "len", "(", "val", ")", ")", ",", "}", "\n", "for", "_", ",", "s", ":=", "range", "val", "{", "<mask>", ".", "series", "=", "append", "(", "ms", ".", "series", ",", "NewStorageSeries", "(", "s", ")", ")", "\n", "}", "\n", "return", "ms", "\n", "}" ]
5,647
all-5648
[ "startTask", "creates", "a", "managedTask", "construct", "to", "track", "the", "task", "and", "then", "begins", "pushing", "it", "towards", "its", "desired", "state", "when", "allowed", "startTask", "is", "protected", "by", "the", "tasksLock", "lock", "of", "AddTask", ".", "It", "should", "not", "be", "called", "from", "anywhere", "else", "and", "should", "exit", "quickly", "to", "allow", "AddTask", "to", "do", "more", "work", "." ]
[ "func", "(", "engine", "*", "DockerTaskEngine", ")", "startTask", "(", "task", "*", "apitask", ".", "Task", ")", "{", "// Create a channel that may be used to communicate with this task, survey", "// what tasks need to be waited for for this one to start, and then spin off", "// a goroutine to oversee this task", "thisTask", ":=", "engine", ".", "newManagedTask", "(", "task", ")", "\n", "thisTask", ".", "_time", "=", "engine", ".", "<mask>", "(", ")", "\n\n", "go", "thisTask", ".", "overseeTask", "(", ")", "\n", "}" ]
5,648
all-5649
[ "NewWatcher", "wraps", "a", "Watcher", "instance", "so", "that", "all", "Watch", "requests", "are", "prefixed", "with", "a", "given", "string", "and", "all", "Watch", "responses", "have", "the", "prefix", "removed", "." ]
[ "func", "NewWatcher", "(", "w", "clientv3", ".", "Watcher", ",", "prefix", "string", ")", "clientv3", ".", "Watcher", "{", "return", "&", "watcherPrefix", "{", "Watcher", ":", "w", ",", "pfx", ":", "<mask>", ",", "stopc", ":", "make", "(", "chan", "struct", "{", "}", ")", "}", "\n", "}" ]
5,649
all-5650
[ "read", "reads", "bytes", "from", "the", "beginning", "of", "the", "window", "into", "p" ]
[ "func", "(", "w", "*", "window", ")", "read", "(", "p", "[", "]", "<mask>", ")", "(", "n", "int", ")", "{", "if", "w", ".", "r", ">", "w", ".", "w", "{", "n", "=", "copy", "(", "p", ",", "w", ".", "buf", "[", "w", ".", "r", ":", "]", ")", "\n", "w", ".", "r", "=", "(", "w", ".", "r", "+", "n", ")", "&", "w", ".", "mask", "\n", "p", "=", "p", "[", "n", ":", "]", "\n", "}", "\n", "if", "w", ".", "r", "<", "w", ".", "w", "{", "l", ":=", "copy", "(", "p", ",", "w", ".", "buf", "[", "w", ".", "r", ":", "w", ".", "w", "]", ")", "\n", "w", ".", "r", "+=", "l", "\n", "n", "+=", "l", "\n", "}", "\n", "if", "w", ".", "l", ">", "0", "&&", "n", ">", "0", "{", "// if we have successfully read data, copy any", "// leftover data from a previous copyBytes.", "l", ":=", "w", ".", "l", "\n", "w", ".", "l", "=", "0", "\n", "w", ".", "copyBytes", "(", "l", ",", "w", ".", "o", ")", "\n", "}", "\n", "return", "n", "\n", "}" ]
5,650
all-5651
[ "StreamClientInterceptor", "logs", "streaming", "RPCs", "on", "the", "client", "side" ]
[ "func", "StreamClientInterceptor", "(", "log", "ttnlog", ".", "Interface", ")", "grpc", ".", "StreamClientInterceptor", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "desc", "*", "grpc", ".", "StreamDesc", ",", "cc", "*", "grpc", ".", "ClientConn", ",", "method", "string", ",", "streamer", "grpc", ".", "Streamer", ",", "opts", "...", "grpc", ".", "CallOption", ")", "(", "stream", "grpc", ".", "ClientStream", ",", "err", "error", ")", "{", "log", ":=", "getLog", "(", "<mask>", ")", ".", "WithField", "(", "\"", "\"", ",", "method", ")", "\n", "log", "=", "log", ".", "WithFields", "(", "FieldsFromOutgoingContext", "(", "ctx", ")", ")", "\n", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "stream", ",", "err", "=", "streamer", "(", "ctx", ",", "desc", ",", "cc", ",", "method", ",", "opts", "...", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "context", ".", "Canceled", "||", "grpc", ".", "Code", "(", "err", ")", "==", "codes", ".", "Canceled", "{", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "log", ".", "WithError", "(", "err", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "go", "func", "(", ")", "{", "<-", "stream", ".", "Context", "(", ")", ".", "Done", "(", ")", "\n", "if", "err", ":=", "stream", ".", "Context", "(", ")", ".", "Err", "(", ")", ";", "err", "!=", "nil", "{", "log", "=", "log", ".", "WithError", "(", "err", ")", "\n", "}", "\n", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "(", ")", "\n", "return", "\n", "}", "\n", "}" ]
5,651
all-5652
[ "UnmarshalJSON", "supports", "json", ".", "Unmarshaler", "interface" ]
[ "func", "(", "v", "*", "GetEncodedResponseParams", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "r", ":=", "jlexer", ".", "Lexer", "{", "Data", ":", "data", "}", "\n", "easyjsonC5a4559bDecodeGithubComChromedpCdprotoAudits1", "(", "&", "r", ",", "v", ")", "\n", "return", "r", ".", "<mask>", "(", ")", "\n", "}" ]
5,652
all-5653
[ "Subscribe", "adds", "the", "handler", "to", "be", "called", "into", "EventStream" ]
[ "func", "(", "eventStream", "*", "EventStream", ")", "Subscribe", "(", "name", "string", ",", "<mask>", "eventHandler", ")", "error", "{", "eventStream", ".", "handlersLock", ".", "Lock", "(", ")", "\n", "defer", "eventStream", ".", "handlersLock", ".", "Unlock", "(", ")", "\n\n", "if", "_", ",", "ok", ":=", "eventStream", ".", "handlers", "[", "name", "]", ";", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n\n", "eventStream", ".", "handlers", "[", "name", "]", "=", "handler", "\n", "return", "nil", "\n", "}" ]
5,653
all-5654
[ "AppendBodyString", "appends", "s", "to", "request", "body", "." ]
[ "func", "(", "req", "*", "<mask>", ")", "AppendBodyString", "(", "s", "string", ")", "{", "req", ".", "RemoveMultipartFormFiles", "(", ")", "\n", "req", ".", "closeBodyStream", "(", ")", "\n", "req", ".", "bodyBuffer", "(", ")", ".", "WriteString", "(", "s", ")", "\n", "}" ]
5,654
all-5655
[ "NewStateStore", "returns", "clusterStorer", "object", "based", "on", "type", "." ]
[ "func", "(", "options", "Options", ")", "NewStateStore", "(", ")", "(", "state", ".", "ClusterStorer", ",", "error", ")", "{", "var", "stateStore", "<mask>", ".", "ClusterStorer", "\n\n", "switch", "options", ".", "StateStore", "{", "case", "\"", "\"", ":", "logger", ".", "Info", "(", "\"", "\"", ")", "\n", "stateStore", "=", "fs", ".", "NewFileSystemStore", "(", "&", "fs", ".", "FileSystemStoreOptions", "{", "BasePath", ":", "options", ".", "StateStorePath", ",", "ClusterName", ":", "options", ".", "Name", ",", "}", ")", "\n", "case", "\"", "\"", ":", "logger", ".", "Info", "(", "\"", "\"", ")", "\n", "stateStore", "=", "crd", ".", "NewCRDStore", "(", "&", "crd", ".", "CRDStoreOptions", "{", "BasePath", ":", "options", ".", "StateStorePath", ",", "ClusterName", ":", "options", ".", "Name", ",", "}", ")", "\n", "case", "\"", "\"", ":", "logger", ".", "Info", "(", "\"", "\"", ")", "\n", "if", "options", ".", "GitRemote", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "user", ",", "_", ":=", "gg", ".", "Global", "(", "\"", "\"", ")", "\n", "email", ",", "_", ":=", "gg", ".", "Email", "(", ")", "\n\n", "stateStore", "=", "git", ".", "NewJSONGitStore", "(", "&", "git", ".", "JSONGitStoreOptions", "{", "BasePath", ":", "options", ".", "StateStorePath", ",", "ClusterName", ":", "options", ".", "Name", ",", "CommitConfig", ":", "&", "git", ".", "JSONGitCommitConfig", "{", "Name", ":", "user", ",", "Email", ":", "email", ",", "Remote", ":", "options", ".", "GitRemote", ",", "}", ",", "}", ")", "\n", "case", "\"", "\"", ":", "logger", ".", "Info", "(", "\"", "\"", ")", "\n", "stateStore", "=", "jsonfs", ".", "NewJSONFileSystemStore", "(", "&", "jsonfs", ".", "JSONFileSystemStoreOptions", "{", "BasePath", ":", "options", ".", "StateStorePath", ",", "ClusterName", ":", "options", ".", "Name", ",", "}", ")", "\n", "case", "\"", "\"", ":", "logger", ".", "Info", "(", "\"", "\"", ")", "\n", "client", ",", "err", ":=", "minio", ".", "New", "(", "options", ".", "BucketEndpointURL", ",", "options", ".", "S3AccessKey", ",", "options", ".", "S3SecretKey", ",", "options", ".", "BucketSSL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "stateStore", "=", "s3", ".", "NewJSONFS3Store", "(", "&", "s3", ".", "JSONS3StoreOptions", "{", "BasePath", ":", "options", ".", "StateStorePath", ",", "ClusterName", ":", "options", ".", "Name", ",", "Client", ":", "client", ",", "BucketOptions", ":", "&", "s3", ".", "S3BucketOptions", "{", "EndpointURL", ":", "options", ".", "BucketEndpointURL", ",", "BucketName", ":", "options", ".", "BucketName", ",", "}", ",", "}", ")", "\n", "default", ":", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "options", ".", "Name", ",", "options", ".", "StateStore", ")", "\n", "}", "\n\n", "return", "stateStore", ",", "nil", "\n", "}" ]
5,655
all-5656
[ "toRetryParameter", "converts", "RetryOptions", "to", "pb", ".", "TaskQueueRetryParameters", "." ]
[ "func", "(", "opt", "*", "RetryOptions", ")", "toRetryParameters", "(", ")", "*", "pb", ".", "TaskQueueRetryParameters", "{", "params", ":=", "&", "<mask>", ".", "TaskQueueRetryParameters", "{", "}", "\n", "if", "opt", ".", "RetryLimit", ">", "0", "{", "params", ".", "RetryLimit", "=", "proto", ".", "Int32", "(", "opt", ".", "RetryLimit", ")", "\n", "}", "\n", "if", "opt", ".", "AgeLimit", ">", "0", "{", "params", ".", "AgeLimitSec", "=", "proto", ".", "Int64", "(", "int64", "(", "opt", ".", "AgeLimit", ".", "Seconds", "(", ")", ")", ")", "\n", "}", "\n", "if", "opt", ".", "MinBackoff", ">", "0", "{", "params", ".", "MinBackoffSec", "=", "proto", ".", "Float64", "(", "opt", ".", "MinBackoff", ".", "Seconds", "(", ")", ")", "\n", "}", "\n", "if", "opt", ".", "MaxBackoff", ">", "0", "{", "params", ".", "MaxBackoffSec", "=", "proto", ".", "Float64", "(", "opt", ".", "MaxBackoff", ".", "Seconds", "(", ")", ")", "\n", "}", "\n", "if", "opt", ".", "MaxDoublings", ">", "0", "||", "(", "opt", ".", "MaxDoublings", "==", "0", "&&", "opt", ".", "ApplyZeroMaxDoublings", ")", "{", "params", ".", "MaxDoublings", "=", "proto", ".", "Int32", "(", "opt", ".", "MaxDoublings", ")", "\n", "}", "\n", "return", "params", "\n", "}" ]
5,656
all-5657
[ "Private", "function", "for", "now", "." ]
[ "func", "(", "t", "*", "Trie", ")", "printDebug", "(", ")", "{", "fmt", ".", "Print", "(", "\"", "\\n", "\"", ")", "\n", "t", ".", "<mask>", ".", "printDebug", "(", "0", ")", "\n", "fmt", ".", "Print", "(", "\"", "\\n", "\"", ")", "\n", "}" ]
5,657
all-5658
[ "Return", "the", "state", "of", "a", "given", "workertype", "as", "stored", "by", "the", "provisioner", ".", "This", "state", "is", "stored", "as", "three", "lists", ":", "1", "for", "running", "instances", "1", "for", "pending", "requests", ".", "The", "summary", "property", "contains", "an", "updated", "summary", "similar", "to", "that", "returned", "from", "listWorkerTypeSummaries", ".", "See", "https", ":", "//", "docs", ".", "taskcluster", ".", "net", "/", "reference", "/", "core", "/", "aws", "-", "provisioner", "/", "api", "-", "docs#state" ]
[ "func", "(", "awsProvisioner", "*", "AwsProvisioner", ")", "State", "(", "workerType", "string", ")", "error", "{", "cd", ":=", "tcclient", ".", "Client", "(", "*", "awsProvisioner", ")", "\n", "_", ",", "_", ",", "err", ":=", "(", "&", "<mask>", ")", ".", "APICall", "(", "nil", ",", "\"", "\"", ",", "\"", "\"", "+", "url", ".", "QueryEscape", "(", "workerType", ")", ",", "nil", ",", "nil", ")", "\n", "return", "err", "\n", "}" ]
5,658
all-5659
[ "Errorf", "records", "the", "log", "with", "error", "level" ]
[ "func", "(", "l", "*", "Logger", ")", "Errorf", "(", "format", "string", ",", "args", "...", "<mask>", "{", "}", ")", "{", "l", ".", "Output", "(", "2", ",", "LevelError", ",", "fmt", ".", "Sprintf", "(", "format", ",", "args", "...", ")", ")", "\n", "}" ]
5,659
all-5660
[ "Retry", "on", "transport", "failures", ".", "Does", "not", "retry", "on", "500s", "." ]
[ "func", "(", "c", "*", "Client", ")", "requestRetryStream", "(", "r", "*", "request", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "if", "c", ".", "fake", "&&", "r", ".", "deckPath", "==", "\"", "\"", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "resp", ",", "err", ":=", "c", ".", "retry", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "resp", ".", "StatusCode", "==", "409", "{", "return", "nil", ",", "NewConflictError", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "}", "else", "if", "resp", ".", "StatusCode", "<", "200", "||", "resp", ".", "StatusCode", ">", "299", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\\\"", "\\\"", "\"", ",", "resp", ".", "<mask>", ")", "\n", "}", "\n", "return", "resp", ".", "Body", ",", "nil", "\n", "}" ]
5,660
all-5661
[ "/", "*", "Say", "is", "a", "Gomega", "matcher", "that", "operates", "on", "gbytes", ".", "Buffers", ":" ]
[ "func", "Say", "(", "expected", "string", ",", "args", "...", "interface", "{", "}", ")", "*", "sayMatcher", "{", "if", "len", "(", "args", ")", ">", "0", "{", "<mask>", "=", "fmt", ".", "Sprintf", "(", "expected", ",", "args", "...", ")", "\n", "}", "\n", "return", "&", "sayMatcher", "{", "re", ":", "regexp", ".", "MustCompile", "(", "expected", ")", ",", "}", "\n", "}" ]
5,661
all-5662
[ "successor", "is", "the", "next", "in", "-", "order", "node", "in", "the", "tree" ]
[ "func", "(", "x", "*", "intervalNode", ")", "successor", "(", ")", "*", "intervalNode", "{", "if", "x", ".", "<mask>", "!=", "nil", "{", "return", "x", ".", "right", ".", "min", "(", ")", "\n", "}", "\n", "y", ":=", "x", ".", "parent", "\n", "for", "y", "!=", "nil", "&&", "x", "==", "y", ".", "right", "{", "x", "=", "y", "\n", "y", "=", "y", ".", "parent", "\n", "}", "\n", "return", "y", "\n", "}" ]
5,662
all-5663
[ "UnmarshalYAML", "implements", "the", "yaml", ".", "Unmarshaler", "interface", "." ]
[ "func", "(", "c", "*", "SDConfig", ")", "UnmarshalYAML", "(", "unmarshal", "func", "(", "interface", "{", "}", ")", "error", ")", "error", "{", "*", "c", "=", "DefaultSDConfig", "\n", "type", "plain", "SDConfig", "\n", "err", ":=", "unmarshal", "(", "(", "*", "plain", ")", "(", "c", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "c", ".", "Project", "==", "\"", "\"", "{", "return", "<mask>", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "c", ".", "Zone", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
5,663
all-5664
[ "Draw", "paints", "current", "game", "state", "." ]
[ "func", "(", "w", "*", "World", ")", "Draw", "(", "pix", "[", "]", "byte", ")", "{", "for", "i", ",", "v", ":=", "<mask>", "w", ".", "area", "{", "if", "v", "{", "pix", "[", "4", "*", "i", "]", "=", "0xff", "\n", "pix", "[", "4", "*", "i", "+", "1", "]", "=", "0xff", "\n", "pix", "[", "4", "*", "i", "+", "2", "]", "=", "0xff", "\n", "pix", "[", "4", "*", "i", "+", "3", "]", "=", "0xff", "\n", "}", "else", "{", "pix", "[", "4", "*", "i", "]", "=", "0", "\n", "pix", "[", "4", "*", "i", "+", "1", "]", "=", "0", "\n", "pix", "[", "4", "*", "i", "+", "2", "]", "=", "0", "\n", "pix", "[", "4", "*", "i", "+", "3", "]", "=", "0", "\n", "}", "\n", "}", "\n", "}" ]
5,664
all-5665
[ "Conn", "reads", "the", "tsuru", "config", "and", "calls", "storage", ".", "Open", "to", "get", "a", "database", "connection", ".", "Most", "tsuru", "packages", "should", "probably", "use", "this", "function", ".", "storage", ".", "Open", "is", "intended", "for", "use", "when", "supporting", "more", "than", "one", "database", "." ]
[ "func", "Conn", "(", ")", "(", "*", "Storage", ",", "error", ")", "{", "var", "(", "strg", "<mask>", "\n", "err", "error", "\n", ")", "\n", "url", ",", "dbname", ":=", "DbConfig", "(", "\"", "\"", ")", "\n", "strg", ".", "Storage", ",", "err", "=", "storage", ".", "Open", "(", "url", ",", "dbname", ")", "\n", "return", "&", "strg", ",", "err", "\n", "}" ]
5,665
all-5666
[ "Stability", ":", "***", "EXPERIMENTAL", "***", "This", "method", "is", "only", "for", "debugging", "the", "ec2", "-", "manager", "Required", "scopes", ":", "ec2", "-", "manager", ":", "internals", "See", "https", ":", "//", "docs", ".", "taskcluster", ".", "net", "/", "reference", "/", "core", "/", "ec2", "-", "manager", "/", "api", "-", "docs#regions" ]
[ "func", "(", "eC2Manager", "*", "EC2Manager", ")", "Regions", "(", ")", "error", "{", "cd", ":=", "tcclient", ".", "Client", "(", "*", "eC2Manager", ")", "\n", "_", ",", "_", ",", "err", ":=", "(", "&", "<mask>", ")", ".", "APICall", "(", "nil", ",", "\"", "\"", ",", "\"", "\"", ",", "nil", ",", "nil", ")", "\n", "return", "err", "\n", "}" ]
5,666
all-5667
[ "GetOverwrite", "is", "a", "wrapper", "around", "gtk_text_view_get_overwrite", "()", "." ]
[ "func", "(", "v", "*", "TextView", ")", "GetOverwrite", "(", ")", "bool", "{", "c", ":=", "C", ".", "gtk_text_view_get_overwrite", "(", "v", ".", "native", "(", ")", ")", "\n", "<mask>", "gobool", "(", "c", ")", "\n", "}" ]
5,667
all-5668
[ "GetNewId", "returns", "the", "NewId", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "d", "*", "Dashboard", ")", "GetNewId", "(", ")", "string", "{", "if", "d", "==", "nil", "||", "d", ".", "NewId", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "<mask>", "*", "d", ".", "NewId", "\n", "}" ]
5,668
all-5669
[ "LinkByName", "indicates", "an", "expected", "call", "of", "LinkByName" ]
[ "func", "(", "mr", "*", "MockNetLinkMockRecorder", ")", "LinkByName", "(", "arg0", "<mask>", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockNetLink", ")", "(", "nil", ")", ".", "LinkByName", ")", ",", "arg0", ")", "\n", "}" ]
5,669
all-5670
[ "Next", "calls", "the", "next", "handler", "in", "the", "stack", "but", "only", "if", "the", "response", "isn", "t", "already", "written", "." ]
[ "func", "(", "ctx", "*", "Context", ")", "Next", "(", ")", "{", "// Call the next handler only if there is one and the response hasn't been written.", "if", "!", "ctx", ".", "Written", "(", ")", "&&", "ctx", ".", "<mask>", "<", "len", "(", "ctx", ".", "handlersStack", ".", "Handlers", ")", "-", "1", "{", "ctx", ".", "index", "++", "\n", "ctx", ".", "handlersStack", ".", "Handlers", "[", "ctx", ".", "index", "]", "(", "ctx", ")", "\n", "}", "\n", "}" ]
5,670
all-5671
[ "extractInboundSpan", "attempts", "to", "create", "a", "new", "OpenTracing", "Span", "for", "inbound", "request", "using", "only", "trace", "IDs", "stored", "in", "the", "frame", "s", "tracing", "field", ".", "It", "only", "works", "if", "the", "tracer", "understand", "Zipkin", "-", "style", "trace", "IDs", ".", "If", "such", "attempt", "fails", "another", "attempt", "will", "be", "made", "from", "the", "higher", "level", "function", "ExtractInboundSpan", "()", "once", "the", "application", "headers", "are", "read", "from", "the", "wire", "." ]
[ "func", "(", "c", "*", "Connection", ")", "extractInboundSpan", "(", "callReq", "*", "callReq", ")", "opentracing", ".", "Span", "{", "spanCtx", ",", "err", ":=", "c", ".", "Tracer", "(", ")", ".", "Extract", "(", "zipkinSpanFormat", ",", "&", "callReq", ".", "Tracing", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "!=", "opentracing", ".", "ErrUnsupportedFormat", "&&", "err", "!=", "opentracing", ".", "ErrSpanContextNotFound", "{", "c", ".", "log", ".", "WithFields", "(", "ErrField", "(", "err", ")", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}", "\n", "if", "spanCtx", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "operationName", ":=", "\"", "\"", "// not known at this point, will be set later", "\n", "span", ":=", "c", ".", "Tracer", "(", ")", ".", "StartSpan", "(", "operationName", ",", "ext", ".", "RPCServerOption", "(", "spanCtx", ")", ")", "\n", "span", ".", "SetTag", "(", "\"", "\"", ",", "callReq", ".", "Headers", "[", "ArgScheme", "]", ")", "\n", "ext", ".", "PeerService", ".", "Set", "(", "span", ",", "callReq", ".", "Headers", "[", "CallerName", "]", ")", "\n", "c", ".", "setPeerHostPort", "(", "span", ")", "\n", "return", "<mask>", "\n", "}" ]
5,671
all-5672
[ "LicenseHandler", "creates", "response", "for", "/", "license", "API", "." ]
[ "func", "LicenseHandler", "(", "w", "http", ".", "ResponseWriter", ",", "h", "*", "http", ".", "Request", ")", "{", "text", ",", "err", ":=", "licenseProvider", ".", "GetText", "(", ")", "\n", "if", "err", "!=", "nil", "{", "w", ".", "WriteHeader", "(", "http", ".", "StatusInternalServerError", ")", "\n", "}", "else", "{", "w", ".", "Write", "(", "[", "]", "byte", "(", "<mask>", ")", ")", "\n", "}", "\n", "}" ]
5,672
all-5673
[ "own", "methods", "AddItem", "adds", "a", "new", "item", "to", "item", "list", ".", "Returns", "true", "if", "the", "operation", "is", "successful" ]
[ "func", "(", "l", "*", "ListBox", ")", "AddItem", "(", "item", "string", ")", "bool", "{", "l", ".", "items", "=", "<mask>", "(", "l", ".", "items", ",", "item", ")", "\n", "return", "true", "\n", "}" ]
5,673
all-5674
[ "txnCommandFunc", "executes", "the", "txn", "command", "." ]
[ "func", "txnCommandFunc", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "if", "len", "(", "args", ")", "!=", "0", "{", "ExitWithError", "(", "ExitBadArgs", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ")", "\n", "}", "\n\n", "reader", ":=", "bufio", ".", "NewReader", "(", "os", ".", "Stdin", ")", "\n\n", "txn", ":=", "mustClientFromCmd", "(", "cmd", ")", ".", "Txn", "(", "<mask>", ".", "Background", "(", ")", ")", "\n", "promptInteractive", "(", "\"", "\"", ")", "\n", "txn", ".", "If", "(", "readCompares", "(", "reader", ")", "...", ")", "\n", "promptInteractive", "(", "\"", "\"", ")", "\n", "txn", ".", "Then", "(", "readOps", "(", "reader", ")", "...", ")", "\n", "promptInteractive", "(", "\"", "\"", ")", "\n", "txn", ".", "Else", "(", "readOps", "(", "reader", ")", "...", ")", "\n\n", "resp", ",", "err", ":=", "txn", ".", "Commit", "(", ")", "\n", "if", "err", "!=", "nil", "{", "ExitWithError", "(", "ExitError", ",", "err", ")", "\n", "}", "\n\n", "display", ".", "Txn", "(", "*", "resp", ")", "\n", "}" ]
5,674
all-5675
[ "SubscribeRaw", "to", "an", "sse", "endpoint" ]
[ "func", "(", "c", "*", "Client", ")", "SubscribeRaw", "(", "handler", "func", "(", "<mask>", "*", "Event", ")", ")", "error", "{", "return", "c", ".", "Subscribe", "(", "\"", "\"", ",", "handler", ")", "\n", "}" ]
5,675
all-5676
[ "MarshalJSON", "supports", "json", ".", "Marshaler", "interface" ]
[ "func", "(", "v", "RequestCachedResponseReturns", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "w", ":=", "jwriter", ".", "Writer", "{", "}", "\n", "easyjsonC5a4559bEncodeGithubComChromedpCdprotoCachestorage2", "(", "&", "w", ",", "v", ")", "\n", "return", "w", ".", "<mask>", ".", "BuildBytes", "(", ")", ",", "w", ".", "Error", "\n", "}" ]
5,676
all-5677
[ "changesByZone", "separates", "a", "multi", "-", "zone", "change", "into", "a", "single", "change", "per", "zone", "." ]
[ "func", "changesByZone", "(", "zones", "map", "[", "string", "]", "*", "route53", ".", "HostedZone", ",", "changeSet", "[", "]", "*", "route53", ".", "Change", ")", "map", "[", "string", "]", "[", "]", "*", "route53", ".", "Change", "{", "changes", ":=", "make", "(", "map", "[", "string", "]", "[", "]", "*", "route53", ".", "Change", ")", "\n\n", "for", "_", ",", "z", ":=", "range", "zones", "{", "changes", "[", "aws", ".", "StringValue", "(", "z", ".", "Id", ")", "]", "=", "[", "]", "*", "route53", ".", "Change", "{", "}", "\n", "}", "\n\n", "for", "_", ",", "c", ":=", "range", "changeSet", "{", "hostname", ":=", "ensureTrailingDot", "(", "aws", ".", "StringValue", "(", "c", ".", "ResourceRecordSet", ".", "Name", ")", ")", "\n\n", "zones", ":=", "suitableZones", "(", "hostname", ",", "zones", ")", "\n", "if", "len", "(", "zones", ")", "==", "0", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "c", ".", "String", "(", ")", ")", "\n", "continue", "\n", "}", "\n", "for", "_", ",", "z", ":=", "range", "zones", "{", "changes", "[", "aws", ".", "StringValue", "(", "z", ".", "Id", ")", "]", "=", "append", "(", "changes", "[", "aws", ".", "StringValue", "(", "z", ".", "Id", ")", "]", ",", "c", ")", "\n", "log", ".", "Debugf", "(", "\"", "\"", ",", "hostname", ",", "aws", ".", "StringValue", "(", "z", ".", "Name", ")", ",", "aws", ".", "StringValue", "(", "z", ".", "Id", ")", ")", "\n", "}", "\n", "}", "\n\n", "// separating a change could lead to empty sub changes, remove them here.", "for", "<mask>", ",", "change", ":=", "range", "changes", "{", "if", "len", "(", "change", ")", "==", "0", "{", "delete", "(", "changes", ",", "zone", ")", "\n", "}", "\n", "}", "\n\n", "return", "changes", "\n", "}" ]
5,677
all-5678
[ "MarshalJSON", "returns", "the", "Email", "as", "JSON" ]
[ "func", "(", "e", "Email", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "<mask>", "w", "jwriter", ".", "Writer", "\n", "e", ".", "MarshalEasyJSON", "(", "&", "w", ")", "\n", "return", "w", ".", "BuildBytes", "(", ")", "\n", "}" ]
5,678
all-5679
[ "Analyze", "all", "parameters", "and", "categorize", "them", "Initialize", "all", "fields", "of", "ParamAnalyzer", "struct" ]
[ "func", "(", "p", "*", "ParamAnalyzer", ")", "Analyze", "(", ")", "{", "// Order params using their length so \"foo[bar]\" is analyzed before \"foo\"", "params", ":=", "p", ".", "rawParams", "\n", "paths", ":=", "<mask>", "(", "[", "]", "string", ",", "len", "(", "params", ")", ")", "\n", "i", ":=", "0", "\n", "for", "n", ":=", "range", "params", "{", "paths", "[", "i", "]", "=", "n", "\n", "i", "++", "\n", "}", "\n", "sort", ".", "Strings", "(", "paths", ")", "\n", "sort", ".", "Sort", "(", "ByReverseLength", "(", "paths", ")", ")", "\n", "rawLeafParams", ":=", "[", "]", "string", "{", "}", "\n", "for", "_", ",", "p", ":=", "range", "paths", "{", "hasLeaf", ":=", "false", "\n", "for", "_", ",", "r", ":=", "range", "rawLeafParams", "{", "if", "strings", ".", "HasSuffix", "(", "r", ",", "\"", "\"", ")", "&&", "strings", ".", "HasPrefix", "(", "r", ",", "p", ")", "{", "hasLeaf", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "hasLeaf", "{", "continue", "\n", "}", "\n", "rawLeafParams", "=", "append", "(", "rawLeafParams", ",", "p", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "rawLeafParams", ")", "\n", "p", ".", "leafParamNames", "=", "rawLeafParams", "\n\n", "// Iterate through all params and build corresponding ActionParam structs", "p", ".", "parsed", "=", "map", "[", "string", "]", "*", "gen", ".", "ActionParam", "{", "}", "\n", "top", ":=", "map", "[", "string", "]", "*", "gen", ".", "ActionParam", "{", "}", "\n", "for", "_", ",", "path", ":=", "range", "paths", "{", "if", "strings", ".", "HasSuffix", "(", "path", ",", "\"", "\"", ")", "{", "// Cheat a little bit - there a couple of cases where parent type is", "// Hash instead of Enumerable, make that enumerable everywhere", "// There are also cases where there's no parent path, fix that up also", "matches", ":=", "parentPathRegexp", ".", "FindStringSubmatch", "(", "path", ")", "\n", "if", "hashParam", ",", "ok", ":=", "params", "[", "matches", "[", "1", "]", "]", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", ";", "ok", "{", "hashParam", "[", "\"", "\"", "]", "=", "\"", "\"", "\n", "}", "else", "{", "// Create parent", "rawParams", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "}", "\n", "parentPath", ":=", "matches", "[", "1", "]", "\n", "p", ".", "parsed", "[", "parentPath", "]", "=", "p", ".", "newParam", "(", "parentPath", ",", "rawParams", ",", "new", "(", "gen", ".", "EnumerableDataType", ")", ")", "\n", "if", "parentPathRegexp", ".", "FindStringSubmatch", "(", "parentPath", ")", "==", "nil", "{", "top", "[", "parentPath", "]", "=", "p", ".", "parsed", "[", "parentPath", "]", "\n", "}", "\n", "}", "\n", "continue", "\n", "}", "\n", "var", "child", "*", "gen", ".", "ActionParam", "\n", "origPath", ":=", "path", "\n", "origParam", ":=", "params", "[", "path", "]", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "matches", ":=", "parentPathRegexp", ".", "FindStringSubmatch", "(", "path", ")", "\n", "isTop", ":=", "(", "matches", "==", "nil", ")", "\n", "if", "prev", ",", "ok", ":=", "p", ".", "parsed", "[", "path", "]", ";", "ok", "{", "if", "isTop", "{", "top", "[", "path", "]", "=", "prev", "\n", "}", "\n", "continue", "\n", "}", "\n", "var", "branch", "[", "]", "*", "gen", ".", "ActionParam", "\n", "for", "matches", "!=", "nil", "{", "param", ":=", "params", "[", "path", "]", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "parentPath", ":=", "matches", "[", "1", "]", "\n", "var", "isArrayChild", "bool", "\n", "if", "strings", ".", "HasSuffix", "(", "parentPath", ",", "\"", "\"", ")", "{", "isArrayChild", "=", "true", "\n", "}", "\n", "if", "parent", ",", "ok", ":=", "p", ".", "parsed", "[", "parentPath", "]", ";", "ok", "{", "a", ",", "ok", ":=", "parent", ".", "Type", ".", "(", "*", "gen", ".", "ArrayDataType", ")", "\n", "if", "ok", "{", "parent", "=", "a", ".", "ElemType", "\n", "}", "\n", "child", "=", "p", ".", "parseParam", "(", "path", ",", "param", ",", "child", ")", "\n", "if", "!", "parent", ".", "Mandatory", "{", "// Make required fields of optional hashes optional.", "child", ".", "Mandatory", "=", "false", "\n", "}", "\n", "branch", "=", "append", "(", "branch", ",", "child", ")", "\n", "if", "_", ",", "ok", "=", "parent", ".", "Type", ".", "(", "*", "gen", ".", "EnumerableDataType", ")", ";", "!", "ok", "{", "o", ":=", "parent", ".", "Type", ".", "(", "*", "gen", ".", "ObjectDataType", ")", "\n", "o", ".", "Fields", "=", "appendSorted", "(", "o", ".", "Fields", ",", "child", ")", "\n", "p", ".", "parsed", "[", "path", "]", "=", "child", "\n", "}", "\n", "break", "// No need to keep going back, we already have a parent", "\n", "}", "else", "{", "child", "=", "p", ".", "parseParam", "(", "path", ",", "param", ",", "child", ")", "\n", "branch", "=", "append", "(", "branch", ",", "child", ")", "\n", "p", ".", "parsed", "[", "path", "]", "=", "child", "\n", "if", "isArrayChild", "{", "// Generate array item as it's not listed explicitly in JSON", "itemPath", ":=", "matches", "[", "1", "]", "+", "\"", "\"", "\n", "typeName", ":=", "p", ".", "typeName", "(", "matches", "[", "1", "]", ")", "\n", "parent", "=", "p", ".", "newParam", "(", "itemPath", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "}", ",", "&", "gen", ".", "ObjectDataType", "{", "typeName", ",", "[", "]", "*", "gen", ".", "ActionParam", "{", "child", "}", "}", ")", "\n", "p", ".", "parsed", "[", "parentPath", "]", "=", "parent", "\n", "child", "=", "parent", "\n", "branch", "=", "append", "(", "branch", ",", "child", ")", "\n", "parentPath", "=", "parentPath", "[", ":", "len", "(", "parentPath", ")", "-", "2", "]", "\n", "}", "\n", "}", "\n", "path", "=", "parentPath", "\n", "matches", "=", "parentPathRegexp", ".", "FindStringSubmatch", "(", "path", ")", "\n", "}", "\n", "if", "isTop", "{", "if", "_", ",", "ok", ":=", "p", ".", "parsed", "[", "path", "]", ";", "!", "ok", "{", "actionParam", ":=", "p", ".", "parseParam", "(", "path", ",", "origParam", ",", "nil", ")", "\n", "p", ".", "parsed", "[", "path", "]", "=", "actionParam", "\n", "}", "\n", "top", "[", "path", "]", "=", "p", ".", "parsed", "[", "path", "]", "\n", "}", "else", "{", "matches", ":=", "rootRegexp", ".", "FindStringSubmatch", "(", "origPath", ")", "\n", "rootPath", ":=", "matches", "[", "1", "]", "\n", "if", "_", ",", "ok", ":=", "p", ".", "parsed", "[", "rootPath", "]", ";", "!", "ok", "{", "p", ".", "parsed", "[", "rootPath", "]", "=", "p", ".", "parseParam", "(", "rootPath", ",", "params", "[", "rootPath", "]", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", ",", "child", ")", "\n", "}", "\n", "actionParam", ",", "_", ":=", "p", ".", "parsed", "[", "rootPath", "]", "\n", "mandatory", ":=", "actionParam", ".", "Mandatory", "\n", "if", "len", "(", "branch", ")", ">", "0", "{", "for", "i", ":=", "len", "(", "branch", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "p", ":=", "branch", "[", "i", "]", "\n", "if", "mandatory", "{", "if", "!", "p", ".", "Mandatory", "{", "mandatory", "=", "false", "\n", "}", "\n", "}", "else", "{", "p", ".", "Mandatory", "=", "false", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "// Now do a second pass on parsed params to generate their declarations", "p", ".", "ParamTypes", "=", "make", "(", "map", "[", "string", "]", "*", "gen", ".", "ObjectDataType", ")", "\n", "for", "_", ",", "param", ":=", "range", "top", "{", "p", ".", "recordTypes", "(", "param", ".", "Type", ")", "\n", "}", "\n\n", "i", "=", "0", "\n", "res", ":=", "make", "(", "[", "]", "*", "gen", ".", "ActionParam", ",", "len", "(", "top", ")", ")", "\n", "for", "_", ",", "param", ":=", "range", "top", "{", "res", "[", "i", "]", "=", "param", "\n", "i", "++", "\n", "}", "\n", "sort", ".", "Sort", "(", "gen", ".", "ByName", "(", "res", ")", ")", "\n", "p", ".", "Params", "=", "res", "\n", "}" ]
5,679
all-5680
[ "recvRoutine", "reads", "msgPackets", "and", "reconstructs", "the", "message", "using", "the", "channels", "recving", "buffer", ".", "After", "a", "whole", "message", "has", "been", "assembled", "it", "s", "pushed", "to", "onReceive", "()", ".", "Blocks", "depending", "on", "how", "the", "connection", "is", "throttled", "." ]
[ "func", "(", "c", "*", "MConnection", ")", "recvRoutine", "(", ")", "{", "defer", "c", ".", "_recover", "(", ")", "\n\n", "FOR_LOOP", ":", "for", "{", "// Block until .recvMonitor says we can read.", "c", ".", "recvMonitor", ".", "Limit", "(", "maxMsgPacketTotalSize", ",", "atomic", ".", "LoadInt64", "(", "&", "c", ".", "config", ".", "RecvRate", ")", ",", "true", ")", "\n\n", "/*\n\t\t\t// Peek into bufReader for debugging\n\t\t\tif numBytes := c.bufReader.Buffered(); numBytes > 0 {\n\t\t\t\tlog.Info(\"Peek connection buffer\", \"numBytes\", numBytes, \"bytes\", log15.Lazy{func() []byte {\n\t\t\t\t\tbytes, err := c.bufReader.Peek(MinInt(numBytes, 100))\n\t\t\t\t\tif err == nil {\n\t\t\t\t\t\treturn bytes\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlog.Warn(\"Error peeking connection buffer\", \"error\", err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t}})\n\t\t\t}\n\t\t*/", "// Read packet type", "<mask>", "n", "int", "\n", "var", "err", "error", "\n", "pktType", ":=", "wire", ".", "ReadByte", "(", "c", ".", "bufReader", ",", "&", "n", ",", "&", "err", ")", "\n", "c", ".", "recvMonitor", ".", "Update", "(", "int", "(", "n", ")", ")", "\n", "if", "err", "!=", "nil", "{", "if", "c", ".", "IsRunning", "(", ")", "{", "log", ".", "Warn", "(", "\"", "\"", ",", "\"", "\"", ",", "c", ",", "\"", "\"", ",", "err", ")", "\n", "c", ".", "stopForError", "(", "err", ")", "\n", "}", "\n", "break", "FOR_LOOP", "\n", "}", "\n\n", "// Read more depending on packet type.", "switch", "pktType", "{", "case", "packetTypePing", ":", "// TODO: prevent abuse, as they cause flush()'s.", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "c", ".", "pong", "<-", "struct", "{", "}", "{", "}", "\n", "case", "packetTypePong", ":", "// do nothing", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "case", "packetTypeMsg", ":", "pkt", ",", "n", ",", "err", ":=", "msgPacket", "{", "}", ",", "int", "(", "0", ")", ",", "error", "(", "nil", ")", "\n", "wire", ".", "ReadBinaryPtr", "(", "&", "pkt", ",", "c", ".", "bufReader", ",", "maxMsgPacketTotalSize", ",", "&", "n", ",", "&", "err", ")", "\n", "c", ".", "recvMonitor", ".", "Update", "(", "int", "(", "n", ")", ")", "\n", "if", "err", "!=", "nil", "{", "if", "c", ".", "IsRunning", "(", ")", "{", "log", ".", "Warn", "(", "\"", "\"", ",", "\"", "\"", ",", "c", ",", "\"", "\"", ",", "err", ")", "\n", "c", ".", "stopForError", "(", "err", ")", "\n", "}", "\n", "break", "FOR_LOOP", "\n", "}", "\n", "channel", ",", "ok", ":=", "c", ".", "channelsIdx", "[", "pkt", ".", "ChannelID", "]", "\n", "if", "!", "ok", "||", "channel", "==", "nil", "{", "cmn", ".", "PanicQ", "(", "cmn", ".", "Fmt", "(", "\"", "\"", ",", "pkt", ".", "ChannelID", ")", ")", "\n", "}", "\n", "msgBytes", ",", "err", ":=", "channel", ".", "recvMsgPacket", "(", "pkt", ")", "\n", "if", "err", "!=", "nil", "{", "if", "c", ".", "IsRunning", "(", ")", "{", "log", ".", "Warn", "(", "\"", "\"", ",", "\"", "\"", ",", "c", ",", "\"", "\"", ",", "err", ")", "\n", "c", ".", "stopForError", "(", "err", ")", "\n", "}", "\n", "break", "FOR_LOOP", "\n", "}", "\n", "if", "msgBytes", "!=", "nil", "{", "log", ".", "Debug", "(", "\"", "\"", ",", "\"", "\"", ",", "pkt", ".", "ChannelID", ",", "\"", "\"", ",", "msgBytes", ")", "\n", "c", ".", "onReceive", "(", "pkt", ".", "ChannelID", ",", "msgBytes", ")", "\n", "}", "\n", "default", ":", "cmn", ".", "PanicSanity", "(", "cmn", ".", "Fmt", "(", "\"", "\"", ",", "pktType", ")", ")", "\n", "}", "\n\n", "// TODO: shouldn't this go in the sendRoutine?", "// Better to send a ping packet when *we* haven't sent anything for a while.", "c", ".", "pingTimer", ".", "Reset", "(", ")", "\n", "}", "\n\n", "// Cleanup", "close", "(", "c", ".", "pong", ")", "\n", "for", "_", "=", "range", "c", ".", "pong", "{", "// Drain", "}", "\n", "}" ]
5,680
all-5681
[ "IsStub", "reports", "whether", "a", "function", "is", "a", "stub", ".", "A", "function", "is", "considered", "a", "stub", "if", "it", "has", "no", "instructions", "or", "exactly", "one", "instruction", "which", "must", "be", "either", "returning", "only", "constant", "values", "or", "a", "panic", "." ]
[ "func", "(", "d", "*", "Descriptions", ")", "IsStub", "(", "fn", "*", "ssa", ".", "Function", ")", "bool", "{", "if", "len", "(", "fn", ".", "Blocks", ")", "==", "0", "{", "return", "true", "\n", "}", "\n", "if", "len", "(", "fn", ".", "Blocks", ")", ">", "1", "{", "return", "<mask>", "\n", "}", "\n", "instrs", ":=", "lintdsl", ".", "FilterDebug", "(", "fn", ".", "Blocks", "[", "0", "]", ".", "Instrs", ")", "\n", "if", "len", "(", "instrs", ")", "!=", "1", "{", "return", "false", "\n", "}", "\n\n", "switch", "instrs", "[", "0", "]", ".", "(", "type", ")", "{", "case", "*", "ssa", ".", "Return", ":", "// Since this is the only instruction, the return value must", "// be a constant. We consider all constants as stubs, not just", "// the zero value. This does not, unfortunately, cover zero", "// initialised structs, as these cause additional", "// instructions.", "return", "true", "\n", "case", "*", "ssa", ".", "Panic", ":", "return", "true", "\n", "default", ":", "return", "false", "\n", "}", "\n", "}" ]
5,681
all-5682
[ "HasChildren", "checks", "to", "see", "if", "a", "resource", "pool", "has", "any", "child", "items", "(", "virtual", "machines", "vApps", "or", "resource", "pools", ")", "and", "returns", "true", "if", "that", "is", "the", "case", ".", "This", "is", "useful", "when", "checking", "to", "see", "if", "a", "resource", "pool", "is", "safe", "to", "delete", ".", "Destroying", "a", "resource", "pool", "in", "vSphere", "destroys", "*", "all", "*", "children", "if", "at", "all", "possible", "so", "extra", "verification", "is", "necessary", "to", "prevent", "accidental", "removal", "." ]
[ "func", "HasChildren", "(", "rp", "*", "object", ".", "ResourcePool", ")", "(", "bool", ",", "error", ")", "{", "props", ",", "err", ":=", "Properties", "(", "rp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "<mask>", ",", "err", "\n", "}", "\n", "if", "len", "(", "props", ".", "Vm", ")", ">", "0", "||", "len", "(", "props", ".", "ResourcePool", ")", ">", "0", "{", "return", "true", ",", "nil", "\n", "}", "\n", "return", "false", ",", "nil", "\n", "}" ]
5,682
all-5683
[ "/", "*", "polymorph", "AppWrapper", "app", "false", "/", "*", "polymorph", "AppWrapper", "error", "false", "Validate", "validates", "this", "app", "wrapper" ]
[ "func", "(", "m", "*", "AppWrapper", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateApp", "(", "formats", ")", ";", "err", "!=", "nil", "{", "// prop", "res", "=", "append", "(", "res", ",", "err", ")", "\n", "}", "\n\n", "if", "err", ":=", "m", ".", "validateError", "(", "formats", ")", ";", "err", "!=", "nil", "{", "// prop", "res", "=", "append", "(", "res", ",", "err", ")", "\n", "}", "\n\n", "if", "len", "(", "res", ")", ">", "0", "{", "return", "errors", ".", "CompositeValidationError", "(", "<mask>", "...", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
5,683
all-5684
[ "Glob", "list", "matched", "files", "from", "assetfs" ]
[ "func", "(", "fs", "*", "AssetFileSystem", ")", "Glob", "(", "pattern", "string", ")", "(", "matches", "[", "]", "string", ",", "err", "error", ")", "{", "for", "_", ",", "pth", ":=", "range", "fs", ".", "paths", "{", "if", "results", ",", "err", ":=", "filepath", ".", "Glob", "(", "filepath", ".", "Join", "(", "pth", ",", "pattern", ")", ")", ";", "err", "==", "nil", "{", "for", "_", ",", "result", ":=", "<mask>", "results", "{", "matches", "=", "append", "(", "matches", ",", "strings", ".", "TrimPrefix", "(", "result", ",", "pth", ")", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
5,684
all-5685
[ "applyCreate", "will", "dry", "-", "run", "create", "and", "then", "pipe", "this", "to", "kubectl", "apply", ".", "If", "we", "use", "the", "create", "verb", "it", "will", "fail", "if", "the", "secret", "already", "exists", ".", "And", "kubectl", "will", "reject", "the", "apply", "verb", "with", "a", "secret", "." ]
[ "func", "applyCreate", "(", "ctx", "string", ",", "args", "...", "string", ")", "error", "{", "create", ":=", "<mask>", ".", "Command", "(", "\"", "\"", ",", "append", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "args", "...", ")", "...", ")", "\n", "create", ".", "Stderr", "=", "os", ".", "Stderr", "\n", "obj", ",", "err", ":=", "create", ".", "StdoutPipe", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "if", "err", ":=", "create", ".", "Start", "(", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "if", "err", ":=", "apply", "(", "ctx", ",", "obj", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "if", "err", ":=", "create", ".", "Wait", "(", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
5,685
all-5686
[ "NewMockFactory", "creates", "a", "new", "mock", "instance" ]
[ "func", "NewMockFactory", "(", "ctrl", "*", "gomock", ".", "<mask>", ")", "*", "MockFactory", "{", "mock", ":=", "&", "MockFactory", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockFactoryMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
5,686
all-5687
[ "Select", "an", "available", "port", "trying", "the", "specified", "port", "first", "falling", "back", "on", "an", "OS", "selected", "port", "." ]
[ "func", "getAvailableTCPPort", "(", "port", "int", ")", "(", "int", ",", "error", ")", "{", "for", "i", ":=", "0", ";", "i", "<=", "10", ";", "i", "++", "{", "ln", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "port", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "defer", "ln", ".", "Close", "(", ")", "\n", "addr", ":=", "ln", ".", "Addr", "(", ")", ".", "String", "(", ")", "\n", "addrParts", ":=", "strings", ".", "SplitN", "(", "addr", ",", "\"", "\"", ",", "2", ")", "\n", "p", ",", "err", ":=", "strconv", ".", "Atoi", "(", "addrParts", "[", "1", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "if", "p", "!=", "0", "{", "port", "=", "p", "\n", "return", "port", ",", "nil", "\n", "}", "\n", "port", "=", "0", "// Throw away the port hint before trying again", "\n", "<mask>", ".", "Sleep", "(", "1", ")", "\n", "}", "\n", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}" ]
5,687
all-5688
[ "resourceVSphereDatastoreClusterVMAntiAffinityRuleFindEntryByName", "attempts", "to", "locate", "an", "existing", "VM", "anti", "-", "affinity", "rule", "in", "a", "datastore", "cluster", "s", "configuration", "by", "name", ".", "It", "differs", "from", "the", "standard", "resourceVSphereDatastoreClusterVMAntiAffinityRuleFindEntry", "in", "that", "we", "don", "t", "allow", "missing", "entries", "as", "it", "s", "designed", "to", "be", "used", "in", "places", "where", "we", "don", "t", "want", "to", "allow", "for", "missing", "entries", "such", "as", "during", "creation", "and", "import", "." ]
[ "func", "resourceVSphereDatastoreClusterVMAntiAffinityRuleFindEntryByName", "(", "pod", "*", "object", ".", "StoragePod", ",", "name", "string", ",", ")", "(", "*", "<mask>", ".", "ClusterAntiAffinityRuleSpec", ",", "error", ")", "{", "props", ",", "err", ":=", "storagepod", ".", "Properties", "(", "pod", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "for", "_", ",", "info", ":=", "range", "props", ".", "PodStorageDrsEntry", ".", "StorageDrsConfig", ".", "PodConfig", ".", "Rule", "{", "if", "info", ".", "GetClusterRuleInfo", "(", ")", ".", "Name", "==", "name", "{", "if", "vmAntiAffinityRuleInfo", ",", "ok", ":=", "info", ".", "(", "*", "types", ".", "ClusterAntiAffinityRuleSpec", ")", ";", "ok", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "name", ",", "pod", ".", "Name", "(", ")", ")", "\n", "return", "vmAntiAffinityRuleInfo", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "pod", ".", "Name", "(", ")", ")", "\n", "}", "\n", "}", "\n\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "pod", ".", "Name", "(", ")", ")", "\n", "}" ]
5,688
all-5689
[ "AddPeer", "adds", "a", "peer", "to", "the", "peer", "heap", "." ]
[ "func", "(", "ph", "*", "peerHeap", ")", "addPeer", "(", "peerScore", "*", "peerScore", ")", "{", "ph", ".", "pushPeer", "(", "peerScore", ")", "\n\n", "// Pick a random element, and swap the order with that peerScore.", "r", ":=", "ph", ".", "rng", ".", "Intn", "(", "ph", ".", "Len", "(", ")", ")", "\n", "ph", ".", "swapOrder", "(", "peerScore", ".", "<mask>", ",", "r", ")", "\n", "}" ]
5,689
all-5690
[ "GetTitleSize", "returns", "the", "TitleSize", "field", "if", "non", "-", "nil", "zero", "value", "otherwise", "." ]
[ "func", "(", "a", "*", "AlertGraphDefinition", ")", "GetTitleSize", "(", ")", "string", "{", "if", "a", "==", "nil", "||", "a", ".", "TitleSize", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "<mask>", "*", "a", ".", "TitleSize", "\n", "}" ]
5,690
all-5691
[ "EncryptedKey", "returns", "encrypted", "keystore", ".", "Key", "in", "base64", "." ]
[ "func", "EncryptedKey", "(", "pkey", "*", "ecdsa", ".", "PrivateKey", ",", "auth", "string", ")", "(", "Base64String", ",", "error", ")", "{", "key", ":=", "keystore", ".", "NewKeyForDirectICAP", "(", "rand", ".", "Reader", ")", "\n", "key", ".", "Address", "=", "crypto", ".", "PubkeyToAddress", "(", "pkey", ".", "PublicKey", ")", "\n", "<mask>", ".", "PrivateKey", "=", "pkey", "\n", "encryptedBytes", ",", "err", ":=", "keystore", ".", "EncryptKey", "(", "key", ",", "auth", ",", "keystore", ".", "StandardScryptN", ",", "keystore", ".", "StandardScryptP", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "FromBytes", "(", "encryptedBytes", ")", ",", "nil", "\n", "}" ]
5,691
all-5692
[ "Specify", "the", "value", "of", "a", "uniform", "variable", "for", "a", "specified", "program", "object" ]
[ "func", "ProgramUniform3uiv", "(", "program", "uint32", ",", "<mask>", "int32", ",", "count", "int32", ",", "value", "*", "uint32", ")", "{", "syscall", ".", "Syscall6", "(", "gpProgramUniform3uiv", ",", "4", ",", "uintptr", "(", "program", ")", ",", "uintptr", "(", "location", ")", ",", "uintptr", "(", "count", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "value", ")", ")", ",", "0", ",", "0", ")", "\n", "}" ]
5,692
all-5693
[ "SetCreatedAt", "sets", "the", "timestamp", "for", "resource", "s", "creation", "time" ]
[ "func", "(", "secret", "*", "SSMSecretResource", ")", "SetCreatedAt", "(", "createdAt", "time", ".", "Time", ")", "{", "if", "createdAt", ".", "IsZero", "(", ")", "{", "return", "\n", "}", "\n", "secret", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "secret", ".", "<mask>", ".", "Unlock", "(", ")", "\n\n", "secret", ".", "createdAt", "=", "createdAt", "\n", "}" ]
5,693
all-5694
[ "MemoryInUse", "returns", "total", "memory", "used", "by", "all", "Nitro", "instances", "in", "the", "current", "process" ]
[ "func", "MemoryInUse", "(", ")", "(", "sz", "int64", ")", "{", "buf", ":=", "dbInstances", ".", "MakeBuf", "(", ")", "\n", "defer", "dbInstances", ".", "FreeBuf", "(", "buf", ")", "\n", "iter", ":=", "dbInstances", ".", "NewIterator", "(", "CompareNitro", ",", "buf", ")", "\n", "for", "iter", ".", "SeekFirst", "(", ")", ";", "iter", ".", "Valid", "(", ")", ";", "iter", ".", "Next", "(", ")", "{", "<mask>", ":=", "(", "*", "Nitro", ")", "(", "iter", ".", "Get", "(", ")", ")", "\n", "sz", "+=", "db", ".", "MemoryInUse", "(", ")", "\n", "}", "\n\n", "return", "\n", "}" ]
5,694
all-5695
[ "resourceVSphereComputeClusterVMAntiAffinityRuleObjects", "handles", "the", "fetching", "of", "the", "cluster", "and", "rule", "key", "depending", "on", "what", "attributes", "are", "available", ":", "*", "If", "the", "resource", "ID", "is", "available", "the", "data", "is", "derived", "from", "the", "ID", ".", "*", "If", "not", "only", "the", "cluster", "is", "retrieved", "from", "compute_cluster_id", ".", "-", "1", "is", "returned", "for", "the", "key", "." ]
[ "func", "resourceVSphereComputeClusterVMAntiAffinityRuleObjects", "(", "d", "*", "schema", ".", "ResourceData", ",", "meta", "<mask>", "{", "}", ",", ")", "(", "*", "object", ".", "ClusterComputeResource", ",", "int32", ",", "error", ")", "{", "if", "d", ".", "Id", "(", ")", "!=", "\"", "\"", "{", "return", "resourceVSphereComputeClusterVMAntiAffinityRuleObjectsFromID", "(", "d", ",", "meta", ")", "\n", "}", "\n", "return", "resourceVSphereComputeClusterVMAntiAffinityRuleObjectsFromAttributes", "(", "d", ",", "meta", ")", "\n", "}" ]
5,695
all-5696
[ "SetTimeoutPerAttempt", "sets", "TimeoutPerAttempt", "in", "RetryOptions", "." ]
[ "func", "(", "cb", "*", "ContextBuilder", ")", "SetTimeoutPerAttempt", "(", "timeoutPerAttempt", "<mask>", ".", "Duration", ")", "*", "ContextBuilder", "{", "if", "cb", ".", "RetryOptions", "==", "nil", "{", "cb", ".", "RetryOptions", "=", "&", "RetryOptions", "{", "}", "\n", "}", "\n", "cb", ".", "RetryOptions", ".", "TimeoutPerAttempt", "=", "timeoutPerAttempt", "\n", "return", "cb", "\n", "}" ]
5,696
all-5697
[ "GetExtFromCert", "returns", "the", "extension", "with", "the", "matching", "OID", "if", "present", ".", "If", "the", "extension", "if", "not", "present", "it", "returns", "nil", "." ]
[ "func", "GetExtFromCert", "(", "cert", "*", "x509", ".", "Certificate", ",", "oid", "asn1", ".", "ObjectIdentifier", ")", "*", "pkix", ".", "Extension", "{", "for", "i", ":=", "<mask>", "cert", ".", "Extensions", "{", "if", "oid", ".", "Equal", "(", "cert", ".", "Extensions", "[", "i", "]", ".", "Id", ")", "{", "return", "&", "(", "cert", ".", "Extensions", "[", "i", "]", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
5,697
all-5698
[ "Raw", "returns", "the", "bytes", "of", "the", "key" ]
[ "func", "(", "k", "*", "Secp256k1PrivateKey", ")", "Raw", "(", ")", "(", "[", "]", "<mask>", ",", "error", ")", "{", "return", "(", "*", "btcec", ".", "PrivateKey", ")", "(", "k", ")", ".", "Serialize", "(", ")", ",", "nil", "\n", "}" ]
5,698
all-5699
[ "String", "returns", "a", "formatted", "string", "representation", "of", "the", "integer", "range" ]
[ "func", "(", "r", "*", "InclusiveRange", ")", "String", "(", ")", "string", "{", "var", "buf", "strings", ".", "Builder", "\n\n", "// Always for a single value", "buf", ".", "WriteString", "(", "strconv", ".", "Itoa", "(", "r", ".", "Start", "(", ")", ")", ")", "\n\n", "// If we have a range, express the end value", "if", "r", ".", "End", "(", ")", "!=", "r", ".", "Start", "(", ")", "{", "buf", ".", "WriteString", "(", "`-`", ")", "\n", "buf", ".", "WriteString", "(", "strconv", ".", "Itoa", "(", "r", ".", "End", "(", ")", ")", ")", "\n\n", "// Express the stepping, if its not 1", "step", ":=", "r", ".", "Step", "(", ")", "\n", "if", "step", ">", "1", "||", "<mask>", "<", "-", "1", "{", "buf", ".", "WriteString", "(", "`x`", ")", "\n", "buf", ".", "WriteString", "(", "strconv", ".", "Itoa", "(", "r", ".", "Step", "(", ")", ")", ")", "\n", "}", "\n", "}", "\n", "return", "buf", ".", "String", "(", ")", "\n", "}" ]
5,699
all-5700
[ "Acquire", "checks", "out", "a", "type", "of", "resource", "in", "certain", "state", "without", "an", "owner", "and", "move", "the", "checked", "out", "resource", "to", "the", "end", "of", "the", "resource", "list", ".", "In", ":", "rtype", "-", "name", "of", "the", "target", "resource", "state", "-", "current", "state", "of", "the", "requested", "resource", "dest", "-", "destination", "state", "of", "the", "requested", "resource", "owner", "-", "requester", "of", "the", "resource", "Out", ":", "A", "valid", "Resource", "object", "on", "success", "or", "ResourceNotFound", "error", "if", "target", "type", "resource", "does", "not", "exist", "in", "target", "state", "." ]
[ "func", "(", "r", "*", "Ranch", ")", "Acquire", "(", "rType", ",", "state", ",", "dest", ",", "owner", "string", ")", "(", "*", "common", ".", "Resource", ",", "error", ")", "{", "r", ".", "resourcesLock", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "resourcesLock", ".", "Unlock", "(", ")", "\n\n", "resources", ",", "err", ":=", "r", ".", "Storage", ".", "GetResources", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ")", "\n", "return", "nil", ",", "&", "ResourceNotFound", "{", "rType", "}", "\n", "}", "\n\n", "foundType", ":=", "false", "\n", "for", "idx", ":=", "<mask>", "resources", "{", "res", ":=", "resources", "[", "idx", "]", "\n", "if", "rType", "==", "res", ".", "Type", "{", "foundType", "=", "true", "\n", "if", "state", "==", "res", ".", "State", "&&", "res", ".", "Owner", "==", "\"", "\"", "{", "res", ".", "LastUpdate", "=", "r", ".", "UpdateTime", "(", ")", "\n", "res", ".", "Owner", "=", "owner", "\n", "res", ".", "State", "=", "dest", "\n", "if", "err", ":=", "r", ".", "Storage", ".", "UpdateResource", "(", "res", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Errorf", "(", "\"", "\"", ",", "res", ".", "Name", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "res", ",", "nil", "\n", "}", "\n", "}", "\n", "}", "\n", "if", "foundType", "{", "return", "nil", ",", "&", "ResourceNotFound", "{", "rType", "}", "\n", "}", "\n", "return", "nil", ",", "&", "ResourceTypeNotFound", "{", "rType", "}", "\n", "}" ]