id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
144,500
billputer/go-namecheap
registrant.go
addValues
func (reg *Registrant) addValues(u url.Values) error { if u == nil { return errors.New("nil value passed as url.Values") } val := reflect.ValueOf(*reg) t := val.Type() for i := 0; i < val.NumField(); i++ { fieldName := t.Field(i).Name field := val.Field(i).String() if ty := val.Field(i).Kind(); ty != refl...
go
func (reg *Registrant) addValues(u url.Values) error { if u == nil { return errors.New("nil value passed as url.Values") } val := reflect.ValueOf(*reg) t := val.Type() for i := 0; i < val.NumField(); i++ { fieldName := t.Field(i).Name field := val.Field(i).String() if ty := val.Field(i).Kind(); ty != refl...
[ "func", "(", "reg", "*", "Registrant", ")", "addValues", "(", "u", "url", ".", "Values", ")", "error", "{", "if", "u", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "val", ":=", "reflect", ".", "ValueO...
// addValues adds the fields of this struct to the passed in url.Values. // It is important that all the fields of Registrant remain string type.
[ "addValues", "adds", "the", "fields", "of", "this", "struct", "to", "the", "passed", "in", "url", ".", "Values", ".", "It", "is", "important", "that", "all", "the", "fields", "of", "Registrant", "remain", "string", "type", "." ]
ebca3d36eda400848b1fefb99a8409f5a13a834d
https://github.com/billputer/go-namecheap/blob/ebca3d36eda400848b1fefb99a8409f5a13a834d/registrant.go#L91-L119
144,501
billputer/go-namecheap
ssl.go
SslGetList
func (client *Client) SslGetList() ([]SslGetListResult, error) { requestInfo := &ApiRequest{ command: sslGetList, method: "POST", params: url.Values{}, } resp, err := client.do(requestInfo) if err != nil { return nil, err } return resp.SslCertificates, nil }
go
func (client *Client) SslGetList() ([]SslGetListResult, error) { requestInfo := &ApiRequest{ command: sslGetList, method: "POST", params: url.Values{}, } resp, err := client.do(requestInfo) if err != nil { return nil, err } return resp.SslCertificates, nil }
[ "func", "(", "client", "*", "Client", ")", "SslGetList", "(", ")", "(", "[", "]", "SslGetListResult", ",", "error", ")", "{", "requestInfo", ":=", "&", "ApiRequest", "{", "command", ":", "sslGetList", ",", "method", ":", "\"", "\"", ",", "params", ":",...
// SslGetList gets a list of SSL certificates for a particular user
[ "SslGetList", "gets", "a", "list", "of", "SSL", "certificates", "for", "a", "particular", "user" ]
ebca3d36eda400848b1fefb99a8409f5a13a834d
https://github.com/billputer/go-namecheap/blob/ebca3d36eda400848b1fefb99a8409f5a13a834d/ssl.go#L73-L86
144,502
billputer/go-namecheap
ssl.go
SslCreate
func (client *Client) SslCreate(productType string, years int) (*SslCreateResult, error) { requestInfo := &ApiRequest{ command: sslCreate, method: "POST", params: url.Values{}, } requestInfo.params.Set("Type", productType) requestInfo.params.Set("Years", strconv.Itoa(years)) resp, err := client.do(request...
go
func (client *Client) SslCreate(productType string, years int) (*SslCreateResult, error) { requestInfo := &ApiRequest{ command: sslCreate, method: "POST", params: url.Values{}, } requestInfo.params.Set("Type", productType) requestInfo.params.Set("Years", strconv.Itoa(years)) resp, err := client.do(request...
[ "func", "(", "client", "*", "Client", ")", "SslCreate", "(", "productType", "string", ",", "years", "int", ")", "(", "*", "SslCreateResult", ",", "error", ")", "{", "requestInfo", ":=", "&", "ApiRequest", "{", "command", ":", "sslCreate", ",", "method", ...
// SslCreate creates a new SSL certificate by purchasing it using the account funds
[ "SslCreate", "creates", "a", "new", "SSL", "certificate", "by", "purchasing", "it", "using", "the", "account", "funds" ]
ebca3d36eda400848b1fefb99a8409f5a13a834d
https://github.com/billputer/go-namecheap/blob/ebca3d36eda400848b1fefb99a8409f5a13a834d/ssl.go#L89-L104
144,503
billputer/go-namecheap
ssl.go
SslActivate
func (client *Client) SslActivate(params SslActivateParams) (*SslActivateResult, error) { requestInfo := &ApiRequest{ command: sslActivate, method: "POST", params: url.Values{}, } requestInfo.params.Set("CertificateID", strconv.Itoa(params.CertificateId)) requestInfo.params.Set("CSR", params.Csr) requestIn...
go
func (client *Client) SslActivate(params SslActivateParams) (*SslActivateResult, error) { requestInfo := &ApiRequest{ command: sslActivate, method: "POST", params: url.Values{}, } requestInfo.params.Set("CertificateID", strconv.Itoa(params.CertificateId)) requestInfo.params.Set("CSR", params.Csr) requestIn...
[ "func", "(", "client", "*", "Client", ")", "SslActivate", "(", "params", "SslActivateParams", ")", "(", "*", "SslActivateResult", ",", "error", ")", "{", "requestInfo", ":=", "&", "ApiRequest", "{", "command", ":", "sslActivate", ",", "method", ":", "\"", ...
// SslActivate activates a purchased and non-activated SSL certificate
[ "SslActivate", "activates", "a", "purchased", "and", "non", "-", "activated", "SSL", "certificate" ]
ebca3d36eda400848b1fefb99a8409f5a13a834d
https://github.com/billputer/go-namecheap/blob/ebca3d36eda400848b1fefb99a8409f5a13a834d/ssl.go#L107-L136
144,504
billputer/go-namecheap
namecheap.go
NewRegistrant
func (client *Client) NewRegistrant( firstName, lastName, addr1, addr2, city, state, postalCode, country, phone, email string, ) { client.Registrant = newRegistrant( firstName, lastName, addr1, addr2, city, state, postalCode, country, phone, email, ) }
go
func (client *Client) NewRegistrant( firstName, lastName, addr1, addr2, city, state, postalCode, country, phone, email string, ) { client.Registrant = newRegistrant( firstName, lastName, addr1, addr2, city, state, postalCode, country, phone, email, ) }
[ "func", "(", "client", "*", "Client", ")", "NewRegistrant", "(", "firstName", ",", "lastName", ",", "addr1", ",", "addr2", ",", "city", ",", "state", ",", "postalCode", ",", "country", ",", "phone", ",", "email", "string", ",", ")", "{", "client", ".",...
// NewRegistrant associates a new registrant with the
[ "NewRegistrant", "associates", "a", "new", "registrant", "with", "the" ]
ebca3d36eda400848b1fefb99a8409f5a13a834d
https://github.com/billputer/go-namecheap/blob/ebca3d36eda400848b1fefb99a8409f5a13a834d/namecheap.go#L97-L109
144,505
cavaliercoder/go-rpm
version/version.go
Compare
func Compare(a, b Interface) int { // compare nils if a == nil && b == nil { return 0 } else if a == nil { return -1 } else if b == nil { return 1 } // compare epoch ae := a.Epoch() be := b.Epoch() if ae != be { if ae > be { return 1 } return -1 } // compare version if rc := rpmvercmp(a.Ver...
go
func Compare(a, b Interface) int { // compare nils if a == nil && b == nil { return 0 } else if a == nil { return -1 } else if b == nil { return 1 } // compare epoch ae := a.Epoch() be := b.Epoch() if ae != be { if ae > be { return 1 } return -1 } // compare version if rc := rpmvercmp(a.Ver...
[ "func", "Compare", "(", "a", ",", "b", "Interface", ")", "int", "{", "// compare nils", "if", "a", "==", "nil", "&&", "b", "==", "nil", "{", "return", "0", "\n", "}", "else", "if", "a", "==", "nil", "{", "return", "-", "1", "\n", "}", "else", "...
// Compare compares the version details of two packages. Versions are // compared by Epoch, Version and Release in descending order of precedence. // // If a is more recent than b, 1 is returned. If a is less recent than b, -1 is // returned. If a and b are equal, 0 is returned. // // This function does not consider if...
[ "Compare", "compares", "the", "version", "details", "of", "two", "packages", ".", "Versions", "are", "compared", "by", "Epoch", "Version", "and", "Release", "in", "descending", "order", "of", "precedence", ".", "If", "a", "is", "more", "recent", "than", "b",...
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/version/version.go#L36-L63
144,506
cavaliercoder/go-rpm
gpgcheck.go
rpmReadSigHeader
func rpmReadSigHeader(r io.Reader) (*Header, error) { // read package lead lead, err := ReadPackageLead(r) if err != nil { return nil, err } // check signature type if lead.SignatureType != 5 { // RPMSIGTYPE_HEADERSIG return nil, fmt.Errorf("Unsupported signature type: 0x%x", lead.SignatureType) } // read...
go
func rpmReadSigHeader(r io.Reader) (*Header, error) { // read package lead lead, err := ReadPackageLead(r) if err != nil { return nil, err } // check signature type if lead.SignatureType != 5 { // RPMSIGTYPE_HEADERSIG return nil, fmt.Errorf("Unsupported signature type: 0x%x", lead.SignatureType) } // read...
[ "func", "rpmReadSigHeader", "(", "r", "io", ".", "Reader", ")", "(", "*", "Header", ",", "error", ")", "{", "// read package lead", "lead", ",", "err", ":=", "ReadPackageLead", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// rpmReadSigHeader reads the lead and signature header of a rpm package and // returns a pointer to the signature header.
[ "rpmReadSigHeader", "reads", "the", "lead", "and", "signature", "header", "of", "a", "rpm", "package", "and", "returns", "a", "pointer", "to", "the", "signature", "header", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/gpgcheck.go#L93-L117
144,507
cavaliercoder/go-rpm
gpgcheck.go
GPGCheck
func GPGCheck(r io.Reader, keyring openpgp.KeyRing) (string, error) { // read signature header sigheader, err := rpmReadSigHeader(r) if err != nil { return "", err } tags := []int{ 1002, // RPMSIGTAG_PGP 1006, // RPMSIGTAG_PGP5 1005, // RPMSIGTAG_GPG } // get signature bytes var sigval []byte for _, ...
go
func GPGCheck(r io.Reader, keyring openpgp.KeyRing) (string, error) { // read signature header sigheader, err := rpmReadSigHeader(r) if err != nil { return "", err } tags := []int{ 1002, // RPMSIGTAG_PGP 1006, // RPMSIGTAG_PGP5 1005, // RPMSIGTAG_GPG } // get signature bytes var sigval []byte for _, ...
[ "func", "GPGCheck", "(", "r", "io", ".", "Reader", ",", "keyring", "openpgp", ".", "KeyRing", ")", "(", "string", ",", "error", ")", "{", "// read signature header", "sigheader", ",", "err", ":=", "rpmReadSigHeader", "(", "r", ")", "\n", "if", "err", "!=...
// GPGCheck validates the integrity of a RPM package file read from the given // io.Reader. Public keys in the given keyring are used to validate the package // signature. // // If validation succeeds, nil is returned. If validation fails, // ErrGPGValidationFailed is returned. // // This function is an expensive opera...
[ "GPGCheck", "validates", "the", "integrity", "of", "a", "RPM", "package", "file", "read", "from", "the", "given", "io", ".", "Reader", ".", "Public", "keys", "in", "the", "given", "keyring", "are", "used", "to", "validate", "the", "package", "signature", "...
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/gpgcheck.go#L127-L166
144,508
cavaliercoder/go-rpm
gpgcheck.go
MD5Check
func MD5Check(r io.Reader) error { // read signature header sigheader, err := rpmReadSigHeader(r) if err != nil { return err } // get expected payload size payloadSize := sigheader.Indexes.IntByTag(1000) // RPMSIGTAG_SIZE if payloadSize == 0 { return fmt.Errorf("RPMSIGTAG_SIZE tag not found in signature hea...
go
func MD5Check(r io.Reader) error { // read signature header sigheader, err := rpmReadSigHeader(r) if err != nil { return err } // get expected payload size payloadSize := sigheader.Indexes.IntByTag(1000) // RPMSIGTAG_SIZE if payloadSize == 0 { return fmt.Errorf("RPMSIGTAG_SIZE tag not found in signature hea...
[ "func", "MD5Check", "(", "r", "io", ".", "Reader", ")", "error", "{", "// read signature header", "sigheader", ",", "err", ":=", "rpmReadSigHeader", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// get expected pa...
// MD5Check validates the integrity of a RPM package file read from the given // io.Reader. An MD5 checksum is computed for the package payload and compared // with the checksum value specified in the package header. // // If validation succeeds, nil is returned. If validation fails, // ErrMD5ValidationFailed is return...
[ "MD5Check", "validates", "the", "integrity", "of", "a", "RPM", "package", "file", "read", "from", "the", "given", "io", ".", "Reader", ".", "An", "MD5", "checksum", "is", "computed", "for", "the", "package", "payload", "and", "compared", "with", "the", "ch...
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/gpgcheck.go#L176-L210
144,509
cavaliercoder/go-rpm
index.go
IndexByTag
func (c IndexEntries) IndexByTag(tag int) *IndexEntry { for _, e := range c { if e.Tag == tag { return &e } } return nil }
go
func (c IndexEntries) IndexByTag(tag int) *IndexEntry { for _, e := range c { if e.Tag == tag { return &e } } return nil }
[ "func", "(", "c", "IndexEntries", ")", "IndexByTag", "(", "tag", "int", ")", "*", "IndexEntry", "{", "for", "_", ",", "e", ":=", "range", "c", "{", "if", "e", ".", "Tag", "==", "tag", "{", "return", "&", "e", "\n", "}", "\n", "}", "\n\n", "retu...
// IndexByTag returns a pointer to an IndexEntry with the given tag ID or nil if // the tag is not found.
[ "IndexByTag", "returns", "a", "pointer", "to", "an", "IndexEntry", "with", "the", "given", "tag", "ID", "or", "nil", "if", "the", "tag", "is", "not", "found", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/index.go#L35-L43
144,510
cavaliercoder/go-rpm
index.go
StringsByTag
func (c IndexEntries) StringsByTag(tag int) []string { i := c.IndexByTag(tag) if i == nil || i.Value == nil { return nil } s, ok := i.Value.([]string) if !ok { return nil } return s }
go
func (c IndexEntries) StringsByTag(tag int) []string { i := c.IndexByTag(tag) if i == nil || i.Value == nil { return nil } s, ok := i.Value.([]string) if !ok { return nil } return s }
[ "func", "(", "c", "IndexEntries", ")", "StringsByTag", "(", "tag", "int", ")", "[", "]", "string", "{", "i", ":=", "c", ".", "IndexByTag", "(", "tag", ")", "\n", "if", "i", "==", "nil", "||", "i", ".", "Value", "==", "nil", "{", "return", "nil", ...
// StringsByTag returns the slice of string values of an IndexEntry or nil if // the tag is not found or has no value.
[ "StringsByTag", "returns", "the", "slice", "of", "string", "values", "of", "an", "IndexEntry", "or", "nil", "if", "the", "tag", "is", "not", "found", "or", "has", "no", "value", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/index.go#L47-L57
144,511
cavaliercoder/go-rpm
index.go
StringByTag
func (c IndexEntries) StringByTag(tag int) string { s := c.StringsByTag(tag) if s == nil || len(s) == 0 { return "" } return s[0] }
go
func (c IndexEntries) StringByTag(tag int) string { s := c.StringsByTag(tag) if s == nil || len(s) == 0 { return "" } return s[0] }
[ "func", "(", "c", "IndexEntries", ")", "StringByTag", "(", "tag", "int", ")", "string", "{", "s", ":=", "c", ".", "StringsByTag", "(", "tag", ")", "\n", "if", "s", "==", "nil", "||", "len", "(", "s", ")", "==", "0", "{", "return", "\"", "\"", "...
// StringByTag returns the string value of an IndexEntry or an empty string if // the tag is not found or has no value.
[ "StringByTag", "returns", "the", "string", "value", "of", "an", "IndexEntry", "or", "an", "empty", "string", "if", "the", "tag", "is", "not", "found", "or", "has", "no", "value", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/index.go#L61-L67
144,512
cavaliercoder/go-rpm
index.go
BytesByTag
func (c IndexEntries) BytesByTag(tag int) []byte { i := c.IndexByTag(tag) if i == nil || i.Value == nil { return nil } b, ok := i.Value.([]byte) if !ok { return nil } return b }
go
func (c IndexEntries) BytesByTag(tag int) []byte { i := c.IndexByTag(tag) if i == nil || i.Value == nil { return nil } b, ok := i.Value.([]byte) if !ok { return nil } return b }
[ "func", "(", "c", "IndexEntries", ")", "BytesByTag", "(", "tag", "int", ")", "[", "]", "byte", "{", "i", ":=", "c", ".", "IndexByTag", "(", "tag", ")", "\n", "if", "i", "==", "nil", "||", "i", ".", "Value", "==", "nil", "{", "return", "nil", "\...
// BytesByTag returns the raw value of an IndexEntry or nil if the tag is not // found or has no value.
[ "BytesByTag", "returns", "the", "raw", "value", "of", "an", "IndexEntry", "or", "nil", "if", "the", "tag", "is", "not", "found", "or", "has", "no", "value", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/index.go#L140-L150
144,513
cavaliercoder/go-rpm
index.go
TimesByTag
func (c IndexEntries) TimesByTag(tag int) []time.Time { ix := c.IndexByTag(tag) if ix == nil || ix.Value == nil { return nil } v, ok := ix.Value.([]int32) if !ok { return nil } vals := make([]time.Time, ix.ItemCount) for i := 0; i < ix.ItemCount; i++ { vals[i] = time.Unix(int64(v[i]), 0) } return vals }
go
func (c IndexEntries) TimesByTag(tag int) []time.Time { ix := c.IndexByTag(tag) if ix == nil || ix.Value == nil { return nil } v, ok := ix.Value.([]int32) if !ok { return nil } vals := make([]time.Time, ix.ItemCount) for i := 0; i < ix.ItemCount; i++ { vals[i] = time.Unix(int64(v[i]), 0) } return vals }
[ "func", "(", "c", "IndexEntries", ")", "TimesByTag", "(", "tag", "int", ")", "[", "]", "time", ".", "Time", "{", "ix", ":=", "c", ".", "IndexByTag", "(", "tag", ")", "\n", "if", "ix", "==", "nil", "||", "ix", ".", "Value", "==", "nil", "{", "re...
// TimesByTag returns the value of an IndexEntry as a slice of Go native // timestamps or nil if the tag is not found or has no value.
[ "TimesByTag", "returns", "the", "value", "of", "an", "IndexEntry", "as", "a", "slice", "of", "Go", "native", "timestamps", "or", "nil", "if", "the", "tag", "is", "not", "found", "or", "has", "no", "value", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/index.go#L154-L168
144,514
cavaliercoder/go-rpm
index.go
TimeByTag
func (c IndexEntries) TimeByTag(tag int) time.Time { vals := c.TimesByTag(tag) if vals == nil || len(vals) == 0 { return time.Time{} } return vals[0] }
go
func (c IndexEntries) TimeByTag(tag int) time.Time { vals := c.TimesByTag(tag) if vals == nil || len(vals) == 0 { return time.Time{} } return vals[0] }
[ "func", "(", "c", "IndexEntries", ")", "TimeByTag", "(", "tag", "int", ")", "time", ".", "Time", "{", "vals", ":=", "c", ".", "TimesByTag", "(", "tag", ")", "\n", "if", "vals", "==", "nil", "||", "len", "(", "vals", ")", "==", "0", "{", "return",...
// TimeByTag returns the value of an IndexEntry as a Go native timestamp or // zero-time if the tag is not found or has no value.
[ "TimeByTag", "returns", "the", "value", "of", "an", "IndexEntry", "as", "a", "Go", "native", "timestamp", "or", "zero", "-", "time", "if", "the", "tag", "is", "not", "found", "or", "has", "no", "value", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/index.go#L172-L178
144,515
cavaliercoder/go-rpm
dependency.go
String
func (c *dependency) String() string { s := c.name switch { case DepFlagLesserOrEqual == (c.flags & DepFlagLesserOrEqual): s = fmt.Sprintf("%s <=", s) case DepFlagLesser == (c.flags & DepFlagLesser): s = fmt.Sprintf("%s <", s) case DepFlagGreaterOrEqual == (c.flags & DepFlagGreaterOrEqual): s = fmt.Sprint...
go
func (c *dependency) String() string { s := c.name switch { case DepFlagLesserOrEqual == (c.flags & DepFlagLesserOrEqual): s = fmt.Sprintf("%s <=", s) case DepFlagLesser == (c.flags & DepFlagLesser): s = fmt.Sprintf("%s <", s) case DepFlagGreaterOrEqual == (c.flags & DepFlagGreaterOrEqual): s = fmt.Sprint...
[ "func", "(", "c", "*", "dependency", ")", "String", "(", ")", "string", "{", "s", ":=", "c", ".", "name", "\n\n", "switch", "{", "case", "DepFlagLesserOrEqual", "==", "(", "c", ".", "flags", "&", "DepFlagLesserOrEqual", ")", ":", "s", "=", "fmt", "."...
// String returns a string representation of a package dependency in a similar // format to `rpm -qR`.
[ "String", "returns", "a", "string", "representation", "of", "a", "package", "dependency", "in", "a", "similar", "format", "to", "rpm", "-", "qR", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/dependency.go#L72-L101
144,516
cavaliercoder/go-rpm
packagefile.go
ReadPackageFile
func ReadPackageFile(r io.Reader) (*PackageFile, error) { // See: http://ftp.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html p := &PackageFile{} // read the deprecated "lead" lead, err := ReadPackageLead(r) if err != nil { return nil, err } p.Lead = *lead // read signature and header headers p.Head...
go
func ReadPackageFile(r io.Reader) (*PackageFile, error) { // See: http://ftp.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html p := &PackageFile{} // read the deprecated "lead" lead, err := ReadPackageLead(r) if err != nil { return nil, err } p.Lead = *lead // read signature and header headers p.Head...
[ "func", "ReadPackageFile", "(", "r", "io", ".", "Reader", ")", "(", "*", "PackageFile", ",", "error", ")", "{", "// See: http://ftp.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html", "p", ":=", "&", "PackageFile", "{", "}", "\n\n", "// read the deprecated \"lead\...
// ReadPackageFile reads a rpm package file from a stream and returns a pointer // to it.
[ "ReadPackageFile", "reads", "a", "rpm", "package", "file", "from", "a", "stream", "and", "returns", "a", "pointer", "to", "it", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L36-L66
144,517
cavaliercoder/go-rpm
packagefile.go
OpenPackageFile
func OpenPackageFile(path string) (*PackageFile, error) { lc := strings.ToLower(path) if strings.HasPrefix(lc, "http://") || strings.HasPrefix(lc, "https://") { return openPackageURL(path) } return openPackageFile(path) }
go
func OpenPackageFile(path string) (*PackageFile, error) { lc := strings.ToLower(path) if strings.HasPrefix(lc, "http://") || strings.HasPrefix(lc, "https://") { return openPackageURL(path) } return openPackageFile(path) }
[ "func", "OpenPackageFile", "(", "path", "string", ")", "(", "*", "PackageFile", ",", "error", ")", "{", "lc", ":=", "strings", ".", "ToLower", "(", "path", ")", "\n", "if", "strings", ".", "HasPrefix", "(", "lc", ",", "\"", "\"", ")", "||", "strings"...
// OpenPackageFile reads a rpm package from the file system or a URL and returns // a pointer to it.
[ "OpenPackageFile", "reads", "a", "rpm", "package", "from", "the", "file", "system", "or", "a", "URL", "and", "returns", "a", "pointer", "to", "it", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L70-L77
144,518
cavaliercoder/go-rpm
packagefile.go
openPackageFile
func openPackageFile(path string) (*PackageFile, error) { f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() fi, err := f.Stat() if err != nil { return nil, err } p, err := ReadPackageFile(f) if err != nil { return nil, err } p.path = path p.fileSize = uint64(fi.Size()) p.fil...
go
func openPackageFile(path string) (*PackageFile, error) { f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() fi, err := f.Stat() if err != nil { return nil, err } p, err := ReadPackageFile(f) if err != nil { return nil, err } p.path = path p.fileSize = uint64(fi.Size()) p.fil...
[ "func", "openPackageFile", "(", "path", "string", ")", "(", "*", "PackageFile", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n",...
// openPackageFile reads package info from the file system
[ "openPackageFile", "reads", "package", "info", "from", "the", "file", "system" ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L80-L100
144,519
cavaliercoder/go-rpm
packagefile.go
openPackageURL
func openPackageURL(path string) (*PackageFile, error) { resp, err := http.Get(path) if err != nil { return nil, err } defer resp.Body.Close() p, err := ReadPackageFile(resp.Body) if err != nil { return nil, err } p.path = path p.fileSize = uint64(resp.ContentLength) if lm := resp.Header.Get("Last-Modifi...
go
func openPackageURL(path string) (*PackageFile, error) { resp, err := http.Get(path) if err != nil { return nil, err } defer resp.Body.Close() p, err := ReadPackageFile(resp.Body) if err != nil { return nil, err } p.path = path p.fileSize = uint64(resp.ContentLength) if lm := resp.Header.Get("Last-Modifi...
[ "func", "openPackageURL", "(", "path", "string", ")", "(", "*", "PackageFile", ",", "error", ")", "{", "resp", ",", "err", ":=", "http", ".", "Get", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\...
// openPackageURL reads package info from a HTTP URL
[ "openPackageURL", "reads", "package", "info", "from", "a", "HTTP", "URL" ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L103-L121
144,520
cavaliercoder/go-rpm
packagefile.go
OpenPackageFiles
func OpenPackageFiles(path string) ([]*PackageFile, error) { // read directory dir, err := ioutil.ReadDir(path) if err != nil { return nil, err } // list *.rpm files files := make([]string, 0) for _, f := range dir { if strings.HasSuffix(f.Name(), ".rpm") { files = append(files, filepath.Join(path, f.Nam...
go
func OpenPackageFiles(path string) ([]*PackageFile, error) { // read directory dir, err := ioutil.ReadDir(path) if err != nil { return nil, err } // list *.rpm files files := make([]string, 0) for _, f := range dir { if strings.HasSuffix(f.Name(), ".rpm") { files = append(files, filepath.Join(path, f.Nam...
[ "func", "OpenPackageFiles", "(", "path", "string", ")", "(", "[", "]", "*", "PackageFile", ",", "error", ")", "{", "// read directory", "dir", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// OpenPackageFiles reads all rpm packages with the .rpm suffix from the given // directory on the file systems and returns a slice of pointers to the loaded // packages.
[ "OpenPackageFiles", "reads", "all", "rpm", "packages", "with", "the", ".", "rpm", "suffix", "from", "the", "given", "directory", "on", "the", "file", "systems", "and", "returns", "a", "slice", "of", "pointers", "to", "the", "loaded", "packages", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L126-L153
144,521
cavaliercoder/go-rpm
packagefile.go
dependencies
func (c *PackageFile) dependencies(nevrsTagID, flagsTagID, namesTagID, versionsTagID int) []Dependency { // TODO: Implement NEVRS tags // TODO: error handling flgs := c.GetInts(1, flagsTagID) names := c.GetStrings(1, namesTagID) vers := c.GetStrings(1, versionsTagID) deps := make([]Dependency, len(names)) for i...
go
func (c *PackageFile) dependencies(nevrsTagID, flagsTagID, namesTagID, versionsTagID int) []Dependency { // TODO: Implement NEVRS tags // TODO: error handling flgs := c.GetInts(1, flagsTagID) names := c.GetStrings(1, namesTagID) vers := c.GetStrings(1, versionsTagID) deps := make([]Dependency, len(names)) for i...
[ "func", "(", "c", "*", "PackageFile", ")", "dependencies", "(", "nevrsTagID", ",", "flagsTagID", ",", "namesTagID", ",", "versionsTagID", "int", ")", "[", "]", "Dependency", "{", "// TODO: Implement NEVRS tags", "// TODO: error handling", "flgs", ":=", "c", ".", ...
// dependencies translates the given tag values into a slice of package // relationships such as provides, conflicts, obsoletes and requires.
[ "dependencies", "translates", "the", "given", "tag", "values", "into", "a", "slice", "of", "package", "relationships", "such", "as", "provides", "conflicts", "obsoletes", "and", "requires", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L157-L173
144,522
cavaliercoder/go-rpm
packagefile.go
GetBytes
func (c *PackageFile) GetBytes(header, tag int) []byte { if c == nil || header >= len(c.Headers) { return nil } return c.Headers[header].Indexes.BytesByTag(tag) }
go
func (c *PackageFile) GetBytes(header, tag int) []byte { if c == nil || header >= len(c.Headers) { return nil } return c.Headers[header].Indexes.BytesByTag(tag) }
[ "func", "(", "c", "*", "PackageFile", ")", "GetBytes", "(", "header", ",", "tag", "int", ")", "[", "]", "byte", "{", "if", "c", "==", "nil", "||", "header", ">=", "len", "(", "c", ".", "Headers", ")", "{", "return", "nil", "\n", "}", "\n", "ret...
// GetBytes returns the value of the given tag in the given header. Nil is // returned if the header or tag do not exist, or it the tag exists but is a // different type.
[ "GetBytes", "returns", "the", "value", "of", "the", "given", "tag", "in", "the", "given", "header", ".", "Nil", "is", "returned", "if", "the", "header", "or", "tag", "do", "not", "exist", "or", "it", "the", "tag", "exists", "but", "is", "a", "different...
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L184-L189
144,523
cavaliercoder/go-rpm
packagefile.go
GetStrings
func (c *PackageFile) GetStrings(header, tag int) []string { if c == nil || header >= len(c.Headers) { return nil } return c.Headers[header].Indexes.StringsByTag(tag) }
go
func (c *PackageFile) GetStrings(header, tag int) []string { if c == nil || header >= len(c.Headers) { return nil } return c.Headers[header].Indexes.StringsByTag(tag) }
[ "func", "(", "c", "*", "PackageFile", ")", "GetStrings", "(", "header", ",", "tag", "int", ")", "[", "]", "string", "{", "if", "c", "==", "nil", "||", "header", ">=", "len", "(", "c", ".", "Headers", ")", "{", "return", "nil", "\n", "}", "\n", ...
// GetStrings returns the string values of the given tag in the given header. // Nil is returned if the header or tag do not exist, or if the tag exists but // is a different type.
[ "GetStrings", "returns", "the", "string", "values", "of", "the", "given", "tag", "in", "the", "given", "header", ".", "Nil", "is", "returned", "if", "the", "header", "or", "tag", "do", "not", "exist", "or", "if", "the", "tag", "exists", "but", "is", "a...
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L194-L199
144,524
cavaliercoder/go-rpm
packagefile.go
GetString
func (c *PackageFile) GetString(header, tag int) string { if c == nil || header >= len(c.Headers) { return "" } return c.Headers[header].Indexes.StringByTag(tag) }
go
func (c *PackageFile) GetString(header, tag int) string { if c == nil || header >= len(c.Headers) { return "" } return c.Headers[header].Indexes.StringByTag(tag) }
[ "func", "(", "c", "*", "PackageFile", ")", "GetString", "(", "header", ",", "tag", "int", ")", "string", "{", "if", "c", "==", "nil", "||", "header", ">=", "len", "(", "c", ".", "Headers", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "return"...
// GetString returns the string value of the given tag in the given header. Nil // is returned if the header or tag do not exist, or if the tag exists but is a // different type.
[ "GetString", "returns", "the", "string", "value", "of", "the", "given", "tag", "in", "the", "given", "header", ".", "Nil", "is", "returned", "if", "the", "header", "or", "tag", "do", "not", "exist", "or", "if", "the", "tag", "exists", "but", "is", "a",...
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L204-L209
144,525
cavaliercoder/go-rpm
packagefile.go
GetInts
func (c *PackageFile) GetInts(header, tag int) []int64 { if c == nil || header >= len(c.Headers) { return nil } return c.Headers[header].Indexes.IntsByTag(tag) }
go
func (c *PackageFile) GetInts(header, tag int) []int64 { if c == nil || header >= len(c.Headers) { return nil } return c.Headers[header].Indexes.IntsByTag(tag) }
[ "func", "(", "c", "*", "PackageFile", ")", "GetInts", "(", "header", ",", "tag", "int", ")", "[", "]", "int64", "{", "if", "c", "==", "nil", "||", "header", ">=", "len", "(", "c", ".", "Headers", ")", "{", "return", "nil", "\n", "}", "\n", "ret...
// GetInts returns the int64 values of the given tag in the given header. Nil is // returned if the header or tag do not exist, or if the tag exists but is a // different type.
[ "GetInts", "returns", "the", "int64", "values", "of", "the", "given", "tag", "in", "the", "given", "header", ".", "Nil", "is", "returned", "if", "the", "header", "or", "tag", "do", "not", "exist", "or", "if", "the", "tag", "exists", "but", "is", "a", ...
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L214-L219
144,526
cavaliercoder/go-rpm
packagefile.go
GetInt
func (c *PackageFile) GetInt(header, tag int) int64 { if c == nil || header >= len(c.Headers) { return 0 } return c.Headers[header].Indexes.IntByTag(tag) }
go
func (c *PackageFile) GetInt(header, tag int) int64 { if c == nil || header >= len(c.Headers) { return 0 } return c.Headers[header].Indexes.IntByTag(tag) }
[ "func", "(", "c", "*", "PackageFile", ")", "GetInt", "(", "header", ",", "tag", "int", ")", "int64", "{", "if", "c", "==", "nil", "||", "header", ">=", "len", "(", "c", ".", "Headers", ")", "{", "return", "0", "\n", "}", "\n", "return", "c", "....
// GetInt returns the int64 value of the given tag in the given header. Zero is // returned if the header or tag do not exist, or if the tag exists but is a // different type.
[ "GetInt", "returns", "the", "int64", "value", "of", "the", "given", "tag", "in", "the", "given", "header", ".", "Zero", "is", "returned", "if", "the", "header", "or", "tag", "do", "not", "exist", "or", "if", "the", "tag", "exists", "but", "is", "a", ...
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L224-L229
144,527
cavaliercoder/go-rpm
packagefile.go
Files
func (c *PackageFile) Files() []FileInfo { if c.files != nil { return c.files } ixs := c.GetInts(1, 1116) names := c.GetStrings(1, 1117) dirs := c.GetStrings(1, 1118) modes := c.GetInts(1, 1030) sizes := c.GetInts(1, 1028) times := c.GetInts(1, 1034) owners := c.GetStrings(1, 1039) groups := c.GetStrings(1...
go
func (c *PackageFile) Files() []FileInfo { if c.files != nil { return c.files } ixs := c.GetInts(1, 1116) names := c.GetStrings(1, 1117) dirs := c.GetStrings(1, 1118) modes := c.GetInts(1, 1030) sizes := c.GetInts(1, 1028) times := c.GetInts(1, 1034) owners := c.GetStrings(1, 1039) groups := c.GetStrings(1...
[ "func", "(", "c", "*", "PackageFile", ")", "Files", "(", ")", "[", "]", "FileInfo", "{", "if", "c", ".", "files", "!=", "nil", "{", "return", "c", ".", "files", "\n", "}", "\n\n", "ixs", ":=", "c", ".", "GetInts", "(", "1", ",", "1116", ")", ...
// Files returns file information for each file that is installed by this RPM // package.
[ "Files", "returns", "file", "information", "for", "each", "file", "that", "is", "installed", "by", "this", "RPM", "package", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L324-L355
144,528
cavaliercoder/go-rpm
packagefile.go
ArchiveSize
func (c *PackageFile) ArchiveSize() uint64 { if i := uint64(c.GetInt(0, 1007)); i > 0 { return i } return uint64(c.GetInt(1, 1046)) }
go
func (c *PackageFile) ArchiveSize() uint64 { if i := uint64(c.GetInt(0, 1007)); i > 0 { return i } return uint64(c.GetInt(1, 1046)) }
[ "func", "(", "c", "*", "PackageFile", ")", "ArchiveSize", "(", ")", "uint64", "{", "if", "i", ":=", "uint64", "(", "c", ".", "GetInt", "(", "0", ",", "1007", ")", ")", ";", "i", ">", "0", "{", "return", "i", "\n", "}", "\n\n", "return", "uint64...
// ArchiveSize specifies the size of the archived payload of the package in // bytes.
[ "ArchiveSize", "specifies", "the", "size", "of", "the", "archived", "payload", "of", "the", "package", "in", "bytes", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/packagefile.go#L429-L435
144,529
cavaliercoder/go-rpm
keyring.go
KeyRing
func KeyRing(r io.Reader) (openpgp.KeyRing, error) { // decode gpgkey file p, err := armor.Decode(r) if err != nil { return nil, err } // extract keys return openpgp.ReadKeyRing(p.Body) }
go
func KeyRing(r io.Reader) (openpgp.KeyRing, error) { // decode gpgkey file p, err := armor.Decode(r) if err != nil { return nil, err } // extract keys return openpgp.ReadKeyRing(p.Body) }
[ "func", "KeyRing", "(", "r", "io", ".", "Reader", ")", "(", "openpgp", ".", "KeyRing", ",", "error", ")", "{", "// decode gpgkey file", "p", ",", "err", ":=", "armor", ".", "Decode", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ni...
// KeyRing reads a openpgp.KeyRing from the given io.Reader which may then be // used to validate GPG keys in RPM packages.
[ "KeyRing", "reads", "a", "openpgp", ".", "KeyRing", "from", "the", "given", "io", ".", "Reader", "which", "may", "then", "be", "used", "to", "validate", "GPG", "keys", "in", "RPM", "packages", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/keyring.go#L12-L21
144,530
cavaliercoder/go-rpm
keyring.go
KeyRingFromFile
func KeyRingFromFile(path string) (openpgp.KeyRing, error) { // open gpgkey file f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() // read keyring return KeyRing(f) }
go
func KeyRingFromFile(path string) (openpgp.KeyRing, error) { // open gpgkey file f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() // read keyring return KeyRing(f) }
[ "func", "KeyRingFromFile", "(", "path", "string", ")", "(", "openpgp", ".", "KeyRing", ",", "error", ")", "{", "// open gpgkey file", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",...
// KeyRingFromFile reads a openpgp.KeyRing from the given file path which may // then be used to validate GPG keys in RPM packages.
[ "KeyRingFromFile", "reads", "a", "openpgp", ".", "KeyRing", "from", "the", "given", "file", "path", "which", "may", "then", "be", "used", "to", "validate", "GPG", "keys", "in", "RPM", "packages", "." ]
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/keyring.go#L25-L35
144,531
cavaliercoder/go-rpm
lead.go
ReadPackageLead
func ReadPackageLead(r io.Reader) (*Lead, error) { var buf [r_LeadLength]byte _, err := io.ReadFull(r, buf[:]) if err != nil { return nil, err } if 0 != bytes.Compare(buf[:4], []byte{0xED, 0xAB, 0xEE, 0xDB}) { return nil, ErrNotRPMFile } lead := &Lead{ VersionMajor: int(buf[4]), VersionMinor: int(b...
go
func ReadPackageLead(r io.Reader) (*Lead, error) { var buf [r_LeadLength]byte _, err := io.ReadFull(r, buf[:]) if err != nil { return nil, err } if 0 != bytes.Compare(buf[:4], []byte{0xED, 0xAB, 0xEE, 0xDB}) { return nil, ErrNotRPMFile } lead := &Lead{ VersionMajor: int(buf[4]), VersionMinor: int(b...
[ "func", "ReadPackageLead", "(", "r", "io", ".", "Reader", ")", "(", "*", "Lead", ",", "error", ")", "{", "var", "buf", "[", "r_LeadLength", "]", "byte", "\n", "_", ",", "err", ":=", "io", ".", "ReadFull", "(", "r", ",", "buf", "[", ":", "]", ")...
// ReadPackageLead reads the deprecated lead section of an RPM file which is // used in legacy RPM versions to store package metadata. // // This function should only be used if you intend to read a package lead in // isolation.
[ "ReadPackageLead", "reads", "the", "deprecated", "lead", "section", "of", "an", "RPM", "file", "which", "is", "used", "in", "legacy", "RPM", "versions", "to", "store", "package", "metadata", ".", "This", "function", "should", "only", "be", "used", "if", "you...
7a9c54e3d83e935c2f070a97273c99be6a3ac2e9
https://github.com/cavaliercoder/go-rpm/blob/7a9c54e3d83e935c2f070a97273c99be6a3ac2e9/lead.go#L41-L66
144,532
dghubble/sessions
store.go
NewCookieStore
func NewCookieStore(keyPairs ...[]byte) *CookieStore { return &CookieStore{ Codecs: securecookie.CodecsFromPairs(keyPairs...), Config: &Config{ Path: "/", MaxAge: defaultMaxAge, HTTPOnly: true, SameSite: http.SameSiteDefaultMode, }, } }
go
func NewCookieStore(keyPairs ...[]byte) *CookieStore { return &CookieStore{ Codecs: securecookie.CodecsFromPairs(keyPairs...), Config: &Config{ Path: "/", MaxAge: defaultMaxAge, HTTPOnly: true, SameSite: http.SameSiteDefaultMode, }, } }
[ "func", "NewCookieStore", "(", "keyPairs", "...", "[", "]", "byte", ")", "*", "CookieStore", "{", "return", "&", "CookieStore", "{", "Codecs", ":", "securecookie", ".", "CodecsFromPairs", "(", "keyPairs", "...", ")", ",", "Config", ":", "&", "Config", "{",...
// NewCookieStore returns a new CookieStore which signs and optionally encrypts // session cookies.
[ "NewCookieStore", "returns", "a", "new", "CookieStore", "which", "signs", "and", "optionally", "encrypts", "session", "cookies", "." ]
9807726e891d9b288c45ada01f4eb13b2d319991
https://github.com/dghubble/sessions/blob/9807726e891d9b288c45ada01f4eb13b2d319991/store.go#L28-L38
144,533
dghubble/sessions
store.go
New
func (s *CookieStore) New(name string) *Session { session := NewSession(s, name) config := *s.Config session.Config = &config return session }
go
func (s *CookieStore) New(name string) *Session { session := NewSession(s, name) config := *s.Config session.Config = &config return session }
[ "func", "(", "s", "*", "CookieStore", ")", "New", "(", "name", "string", ")", "*", "Session", "{", "session", ":=", "NewSession", "(", "s", ",", "name", ")", "\n", "config", ":=", "*", "s", ".", "Config", "\n", "session", ".", "Config", "=", "&", ...
// New returns a new Session with the requested name and the store's config // value.
[ "New", "returns", "a", "new", "Session", "with", "the", "requested", "name", "and", "the", "store", "s", "config", "value", "." ]
9807726e891d9b288c45ada01f4eb13b2d319991
https://github.com/dghubble/sessions/blob/9807726e891d9b288c45ada01f4eb13b2d319991/store.go#L42-L47
144,534
dghubble/sessions
store.go
Get
func (s *CookieStore) Get(req *http.Request, name string) (session *Session, err error) { cookie, err := req.Cookie(name) if err == nil { session = s.New(name) err = securecookie.DecodeMulti(name, cookie.Value, &session.Values, s.Codecs...) } return session, err }
go
func (s *CookieStore) Get(req *http.Request, name string) (session *Session, err error) { cookie, err := req.Cookie(name) if err == nil { session = s.New(name) err = securecookie.DecodeMulti(name, cookie.Value, &session.Values, s.Codecs...) } return session, err }
[ "func", "(", "s", "*", "CookieStore", ")", "Get", "(", "req", "*", "http", ".", "Request", ",", "name", "string", ")", "(", "session", "*", "Session", ",", "err", "error", ")", "{", "cookie", ",", "err", ":=", "req", ".", "Cookie", "(", "name", "...
// Get returns the named Session from the Request. Returns an error if the // session cookie cannot be found, the cookie verification fails, or an error // occurs decoding the cookie value.
[ "Get", "returns", "the", "named", "Session", "from", "the", "Request", ".", "Returns", "an", "error", "if", "the", "session", "cookie", "cannot", "be", "found", "the", "cookie", "verification", "fails", "or", "an", "error", "occurs", "decoding", "the", "cook...
9807726e891d9b288c45ada01f4eb13b2d319991
https://github.com/dghubble/sessions/blob/9807726e891d9b288c45ada01f4eb13b2d319991/store.go#L52-L59
144,535
dghubble/sessions
store.go
Save
func (s *CookieStore) Save(w http.ResponseWriter, session *Session) error { cookieValue, err := securecookie.EncodeMulti(session.Name(), &session.Values, s.Codecs...) if err != nil { return err } http.SetCookie(w, newCookie(session.Name(), cookieValue, session.Config)) return nil }
go
func (s *CookieStore) Save(w http.ResponseWriter, session *Session) error { cookieValue, err := securecookie.EncodeMulti(session.Name(), &session.Values, s.Codecs...) if err != nil { return err } http.SetCookie(w, newCookie(session.Name(), cookieValue, session.Config)) return nil }
[ "func", "(", "s", "*", "CookieStore", ")", "Save", "(", "w", "http", ".", "ResponseWriter", ",", "session", "*", "Session", ")", "error", "{", "cookieValue", ",", "err", ":=", "securecookie", ".", "EncodeMulti", "(", "session", ".", "Name", "(", ")", "...
// Save adds or updates the Session on the response via a signed and optionally // encrypted session cookie. Session Values are encoded into the cookie value // and the session Config sets cookie properties.
[ "Save", "adds", "or", "updates", "the", "Session", "on", "the", "response", "via", "a", "signed", "and", "optionally", "encrypted", "session", "cookie", ".", "Session", "Values", "are", "encoded", "into", "the", "cookie", "value", "and", "the", "session", "C...
9807726e891d9b288c45ada01f4eb13b2d319991
https://github.com/dghubble/sessions/blob/9807726e891d9b288c45ada01f4eb13b2d319991/store.go#L64-L71
144,536
dghubble/sessions
store.go
Destroy
func (s *CookieStore) Destroy(w http.ResponseWriter, name string) { http.SetCookie(w, newCookie(name, "", &Config{MaxAge: -1, Path: s.Config.Path})) }
go
func (s *CookieStore) Destroy(w http.ResponseWriter, name string) { http.SetCookie(w, newCookie(name, "", &Config{MaxAge: -1, Path: s.Config.Path})) }
[ "func", "(", "s", "*", "CookieStore", ")", "Destroy", "(", "w", "http", ".", "ResponseWriter", ",", "name", "string", ")", "{", "http", ".", "SetCookie", "(", "w", ",", "newCookie", "(", "name", ",", "\"", "\"", ",", "&", "Config", "{", "MaxAge", "...
// Destroy deletes the Session with the given name by issuing an expired // session cookie with the same name.
[ "Destroy", "deletes", "the", "Session", "with", "the", "given", "name", "by", "issuing", "an", "expired", "session", "cookie", "with", "the", "same", "name", "." ]
9807726e891d9b288c45ada01f4eb13b2d319991
https://github.com/dghubble/sessions/blob/9807726e891d9b288c45ada01f4eb13b2d319991/store.go#L75-L77
144,537
dghubble/sessions
store.go
newCookie
func newCookie(name, value string, config *Config) *http.Cookie { cookie := &http.Cookie{ Name: name, Value: value, Domain: config.Domain, Path: config.Path, MaxAge: config.MaxAge, HttpOnly: config.HTTPOnly, Secure: config.Secure, SameSite: config.SameSite, } // IE <9 does not unders...
go
func newCookie(name, value string, config *Config) *http.Cookie { cookie := &http.Cookie{ Name: name, Value: value, Domain: config.Domain, Path: config.Path, MaxAge: config.MaxAge, HttpOnly: config.HTTPOnly, Secure: config.Secure, SameSite: config.SameSite, } // IE <9 does not unders...
[ "func", "newCookie", "(", "name", ",", "value", "string", ",", "config", "*", "Config", ")", "*", "http", ".", "Cookie", "{", "cookie", ":=", "&", "http", ".", "Cookie", "{", "Name", ":", "name", ",", "Value", ":", "value", ",", "Domain", ":", "con...
// newCookie returns a new http.Cookie with the given name, value, and // properties from config.
[ "newCookie", "returns", "a", "new", "http", ".", "Cookie", "with", "the", "given", "name", "value", "and", "properties", "from", "config", "." ]
9807726e891d9b288c45ada01f4eb13b2d319991
https://github.com/dghubble/sessions/blob/9807726e891d9b288c45ada01f4eb13b2d319991/store.go#L81-L97
144,538
tbruyelle/hipchat-go
hipchat/hipchat.go
NewClient
func NewClient(authToken string) *Client { baseURL, err := url.Parse(defaultBaseURL) if err != nil { panic(err) } c := &Client{ authToken: authToken, BaseURL: baseURL, client: http.DefaultClient, } c.Room = &RoomService{client: c} c.User = &UserService{client: c} c.Emoticon = &EmoticonService{clie...
go
func NewClient(authToken string) *Client { baseURL, err := url.Parse(defaultBaseURL) if err != nil { panic(err) } c := &Client{ authToken: authToken, BaseURL: baseURL, client: http.DefaultClient, } c.Room = &RoomService{client: c} c.User = &UserService{client: c} c.Emoticon = &EmoticonService{clie...
[ "func", "NewClient", "(", "authToken", "string", ")", "*", "Client", "{", "baseURL", ",", "err", ":=", "url", ".", "Parse", "(", "defaultBaseURL", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n\n", "c", ":=", "&"...
// NewClient returns a new HipChat API client. You must provide a valid // AuthToken retrieved from your HipChat account.
[ "NewClient", "returns", "a", "new", "HipChat", "API", "client", ".", "You", "must", "provide", "a", "valid", "AuthToken", "retrieved", "from", "your", "HipChat", "account", "." ]
35aebc99209aa41498ab4823a83e254037f062fd
https://github.com/tbruyelle/hipchat-go/blob/35aebc99209aa41498ab4823a83e254037f062fd/hipchat/hipchat.go#L173-L188
144,539
tbruyelle/hipchat-go
hipchat/hipchat.go
SetHTTPClient
func (c *Client) SetHTTPClient(httpClient HTTPClient) { if httpClient == nil { c.client = http.DefaultClient } else { c.client = httpClient } }
go
func (c *Client) SetHTTPClient(httpClient HTTPClient) { if httpClient == nil { c.client = http.DefaultClient } else { c.client = httpClient } }
[ "func", "(", "c", "*", "Client", ")", "SetHTTPClient", "(", "httpClient", "HTTPClient", ")", "{", "if", "httpClient", "==", "nil", "{", "c", ".", "client", "=", "http", ".", "DefaultClient", "\n", "}", "else", "{", "c", ".", "client", "=", "httpClient"...
// SetHTTPClient sets the http client for performing API requests. // This method allows overriding the default http client with any // implementation of the HTTPClient interface. It is typically used // to have finer control of the http request. // If a nil httpClient is provided, http.DefaultClient will be used.
[ "SetHTTPClient", "sets", "the", "http", "client", "for", "performing", "API", "requests", ".", "This", "method", "allows", "overriding", "the", "default", "http", "client", "with", "any", "implementation", "of", "the", "HTTPClient", "interface", ".", "It", "is",...
35aebc99209aa41498ab4823a83e254037f062fd
https://github.com/tbruyelle/hipchat-go/blob/35aebc99209aa41498ab4823a83e254037f062fd/hipchat/hipchat.go#L195-L201
144,540
tbruyelle/hipchat-go
hipchat/hipchat.go
NewRequest
func (c *Client) NewRequest(method, urlStr string, opt interface{}, body interface{}) (*http.Request, error) { rel, err := addOptions(urlStr, opt) if err != nil { return nil, err } if AuthTest { // Add the auth_test param values := rel.Query() values.Add("auth_test", strconv.FormatBool(AuthTest)) rel.Raw...
go
func (c *Client) NewRequest(method, urlStr string, opt interface{}, body interface{}) (*http.Request, error) { rel, err := addOptions(urlStr, opt) if err != nil { return nil, err } if AuthTest { // Add the auth_test param values := rel.Query() values.Add("auth_test", strconv.FormatBool(AuthTest)) rel.Raw...
[ "func", "(", "c", "*", "Client", ")", "NewRequest", "(", "method", ",", "urlStr", "string", ",", "opt", "interface", "{", "}", ",", "body", "interface", "{", "}", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "rel", ",", "err", "...
// NewRequest creates an API request. This method can be used to performs // API request not implemented in this library. Otherwise it should not be // be used directly. // Relative URLs should always be specified without a preceding slash.
[ "NewRequest", "creates", "an", "API", "request", ".", "This", "method", "can", "be", "used", "to", "performs", "API", "request", "not", "implemented", "in", "this", "library", ".", "Otherwise", "it", "should", "not", "be", "be", "used", "directly", ".", "R...
35aebc99209aa41498ab4823a83e254037f062fd
https://github.com/tbruyelle/hipchat-go/blob/35aebc99209aa41498ab4823a83e254037f062fd/hipchat/hipchat.go#L207-L238
144,541
tbruyelle/hipchat-go
hipchat/hipchat.go
Do
func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) { var policy = NoRateLimitRetryPolicy if RetryOnRateLimit { policy = RateLimitRetryPolicy } resp, err := c.doWithRetryPolicy(req, policy) if err != nil { return nil, err } if AuthTest { // If AuthTest is enabled, the reponse wo...
go
func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) { var policy = NoRateLimitRetryPolicy if RetryOnRateLimit { policy = RateLimitRetryPolicy } resp, err := c.doWithRetryPolicy(req, policy) if err != nil { return nil, err } if AuthTest { // If AuthTest is enabled, the reponse wo...
[ "func", "(", "c", "*", "Client", ")", "Do", "(", "req", "*", "http", ".", "Request", ",", "v", "interface", "{", "}", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "var", "policy", "=", "NoRateLimitRetryPolicy", "\n", "if", "Retry...
// Do performs the request, the json received in the response is decoded // and stored in the value pointed by v. // Do can be used to perform the request created with NewRequest, which // should be used only for API requests not implemented in this library.
[ "Do", "performs", "the", "request", "the", "json", "received", "in", "the", "response", "is", "decoded", "and", "stored", "in", "the", "value", "pointed", "by", "v", ".", "Do", "can", "be", "used", "to", "perform", "the", "request", "created", "with", "N...
35aebc99209aa41498ab4823a83e254037f062fd
https://github.com/tbruyelle/hipchat-go/blob/35aebc99209aa41498ab4823a83e254037f062fd/hipchat/hipchat.go#L319-L349
144,542
tbruyelle/hipchat-go
hipchat/room.go
MarshalJSON
func (c CardDescription) MarshalJSON() ([]byte, error) { if c.Format == "" { return json.Marshal(c.Value) } obj := make(map[string]string) obj["format"] = c.Format obj["value"] = c.Value return json.Marshal(obj) }
go
func (c CardDescription) MarshalJSON() ([]byte, error) { if c.Format == "" { return json.Marshal(c.Value) } obj := make(map[string]string) obj["format"] = c.Format obj["value"] = c.Value return json.Marshal(obj) }
[ "func", "(", "c", "CardDescription", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "c", ".", "Format", "==", "\"", "\"", "{", "return", "json", ".", "Marshal", "(", "c", ".", "Value", ")", "\n", "}", "\n\n", ...
// MarshalJSON serializes a CardDescription into JSON
[ "MarshalJSON", "serializes", "a", "CardDescription", "into", "JSON" ]
35aebc99209aa41498ab4823a83e254037f062fd
https://github.com/tbruyelle/hipchat-go/blob/35aebc99209aa41498ab4823a83e254037f062fd/hipchat/room.go#L127-L137
144,543
tbruyelle/hipchat-go
hipchat/room.go
UnmarshalJSON
func (c *CardDescription) UnmarshalJSON(data []byte) error { // Compact the JSON to make it easier to process below buffer := bytes.NewBuffer([]byte{}) err := json.Compact(buffer, data) if err != nil { return err } data = buffer.Bytes() // Since Description can be either a string value or an object, we // mu...
go
func (c *CardDescription) UnmarshalJSON(data []byte) error { // Compact the JSON to make it easier to process below buffer := bytes.NewBuffer([]byte{}) err := json.Compact(buffer, data) if err != nil { return err } data = buffer.Bytes() // Since Description can be either a string value or an object, we // mu...
[ "func", "(", "c", "*", "CardDescription", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "// Compact the JSON to make it easier to process below", "buffer", ":=", "bytes", ".", "NewBuffer", "(", "[", "]", "byte", "{", "}", ")", "\n", ...
// UnmarshalJSON deserializes a JSON-serialized CardDescription
[ "UnmarshalJSON", "deserializes", "a", "JSON", "-", "serialized", "CardDescription" ]
35aebc99209aa41498ab4823a83e254037f062fd
https://github.com/tbruyelle/hipchat-go/blob/35aebc99209aa41498ab4823a83e254037f062fd/hipchat/room.go#L140-L172
144,544
tbruyelle/hipchat-go
hipchat/room.go
UnmarshalJSON
func (gs *GlanceStatus) UnmarshalJSON(data []byte) error { // Compact the JSON to make it easier to process below buffer := bytes.NewBuffer([]byte{}) err := json.Compact(buffer, data) if err != nil { return err } data = buffer.Bytes() // Since Value can be either an AttributeValue or an Icon, we // must chec...
go
func (gs *GlanceStatus) UnmarshalJSON(data []byte) error { // Compact the JSON to make it easier to process below buffer := bytes.NewBuffer([]byte{}) err := json.Compact(buffer, data) if err != nil { return err } data = buffer.Bytes() // Since Value can be either an AttributeValue or an Icon, we // must chec...
[ "func", "(", "gs", "*", "GlanceStatus", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "// Compact the JSON to make it easier to process below", "buffer", ":=", "bytes", ".", "NewBuffer", "(", "[", "]", "byte", "{", "}", ")", "\n", "...
// UnmarshalJSON deserializes a JSON-serialized GlanceStatus
[ "UnmarshalJSON", "deserializes", "a", "JSON", "-", "serialized", "GlanceStatus" ]
35aebc99209aa41498ab4823a83e254037f062fd
https://github.com/tbruyelle/hipchat-go/blob/35aebc99209aa41498ab4823a83e254037f062fd/hipchat/room.go#L299-L354
144,545
tbruyelle/hipchat-go
hipchat/room.go
AddAttribute
func (c *Card) AddAttribute(mainLabel, subLabel, url, iconURL string) { attr := Attribute{Label: mainLabel} attr.Value = AttributeValue{Label: subLabel, URL: url, Icon: &Icon{URL: iconURL}} c.Attributes = append(c.Attributes, attr) }
go
func (c *Card) AddAttribute(mainLabel, subLabel, url, iconURL string) { attr := Attribute{Label: mainLabel} attr.Value = AttributeValue{Label: subLabel, URL: url, Icon: &Icon{URL: iconURL}} c.Attributes = append(c.Attributes, attr) }
[ "func", "(", "c", "*", "Card", ")", "AddAttribute", "(", "mainLabel", ",", "subLabel", ",", "url", ",", "iconURL", "string", ")", "{", "attr", ":=", "Attribute", "{", "Label", ":", "mainLabel", "}", "\n", "attr", ".", "Value", "=", "AttributeValue", "{...
// AddAttribute adds an attribute to a Card
[ "AddAttribute", "adds", "an", "attribute", "to", "a", "Card" ]
35aebc99209aa41498ab4823a83e254037f062fd
https://github.com/tbruyelle/hipchat-go/blob/35aebc99209aa41498ab4823a83e254037f062fd/hipchat/room.go#L357-L362
144,546
getlantern/hidden
hidden.go
ToString
func ToString(data []byte) string { buf := bytes.NewBuffer(make([]byte, 0, 2+hex.EncodedLen(len(data)))) // Leading NUL buf.WriteByte(0) buf.WriteString(hexencoding.EncodeToString(data)) // Trailing NUL buf.WriteByte(0) return buf.String() }
go
func ToString(data []byte) string { buf := bytes.NewBuffer(make([]byte, 0, 2+hex.EncodedLen(len(data)))) // Leading NUL buf.WriteByte(0) buf.WriteString(hexencoding.EncodeToString(data)) // Trailing NUL buf.WriteByte(0) return buf.String() }
[ "func", "ToString", "(", "data", "[", "]", "byte", ")", "string", "{", "buf", ":=", "bytes", ".", "NewBuffer", "(", "make", "(", "[", "]", "byte", ",", "0", ",", "2", "+", "hex", ".", "EncodedLen", "(", "len", "(", "data", ")", ")", ")", ")", ...
// ToString encodes the given data as a hidden string, including leadnig and // trailing NULs.
[ "ToString", "encodes", "the", "given", "data", "as", "a", "hidden", "string", "including", "leadnig", "and", "trailing", "NULs", "." ]
f02dbb02be5552811eec1040d7906424c52ae539
https://github.com/getlantern/hidden/blob/f02dbb02be5552811eec1040d7906424c52ae539/hidden.go#L33-L41
144,547
getlantern/hidden
hidden.go
FromString
func FromString(str string) ([]byte, error) { return hexencoding.DecodeString(str[1 : len(str)-1]) }
go
func FromString(str string) ([]byte, error) { return hexencoding.DecodeString(str[1 : len(str)-1]) }
[ "func", "FromString", "(", "str", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "hexencoding", ".", "DecodeString", "(", "str", "[", "1", ":", "len", "(", "str", ")", "-", "1", "]", ")", "\n", "}" ]
// FromString extracts the hidden data from a string, which is expected to // contain leading and trailing NULs.
[ "FromString", "extracts", "the", "hidden", "data", "from", "a", "string", "which", "is", "expected", "to", "contain", "leading", "and", "trailing", "NULs", "." ]
f02dbb02be5552811eec1040d7906424c52ae539
https://github.com/getlantern/hidden/blob/f02dbb02be5552811eec1040d7906424c52ae539/hidden.go#L45-L47
144,548
getlantern/hidden
hidden.go
Extract
func Extract(str string) ([][]byte, error) { m := re.FindAllString(str, -1) result := make([][]byte, 0, len(m)) for _, s := range m { b, err := FromString(s) if err != nil { return nil, err } result = append(result, b) } return result, nil }
go
func Extract(str string) ([][]byte, error) { m := re.FindAllString(str, -1) result := make([][]byte, 0, len(m)) for _, s := range m { b, err := FromString(s) if err != nil { return nil, err } result = append(result, b) } return result, nil }
[ "func", "Extract", "(", "str", "string", ")", "(", "[", "]", "[", "]", "byte", ",", "error", ")", "{", "m", ":=", "re", ".", "FindAllString", "(", "str", ",", "-", "1", ")", "\n", "result", ":=", "make", "(", "[", "]", "[", "]", "byte", ",", ...
// Extract extracts all hidden data from an arbitrary string.
[ "Extract", "extracts", "all", "hidden", "data", "from", "an", "arbitrary", "string", "." ]
f02dbb02be5552811eec1040d7906424c52ae539
https://github.com/getlantern/hidden/blob/f02dbb02be5552811eec1040d7906424c52ae539/hidden.go#L50-L61
144,549
biogo/store
kdtree/medians.go
Partition
func Partition(list sort.Interface, pivot int) int { var index, last int if last = list.Len() - 1; last < 0 { return -1 } list.Swap(pivot, last) for i := 0; i < last; i++ { if !list.Less(last, i) { list.Swap(index, i) index++ } } list.Swap(last, index) return index }
go
func Partition(list sort.Interface, pivot int) int { var index, last int if last = list.Len() - 1; last < 0 { return -1 } list.Swap(pivot, last) for i := 0; i < last; i++ { if !list.Less(last, i) { list.Swap(index, i) index++ } } list.Swap(last, index) return index }
[ "func", "Partition", "(", "list", "sort", ".", "Interface", ",", "pivot", "int", ")", "int", "{", "var", "index", ",", "last", "int", "\n", "if", "last", "=", "list", ".", "Len", "(", ")", "-", "1", ";", "last", "<", "0", "{", "return", "-", "1...
// Partition partitions list such that all elements less than the value at pivot prior to the // call are placed before that element and all elements greater than that value are placed after it. // The final location of the element at pivot prior to the call is returned.
[ "Partition", "partitions", "list", "such", "that", "all", "elements", "less", "than", "the", "value", "at", "pivot", "prior", "to", "the", "call", "are", "placed", "before", "that", "element", "and", "all", "elements", "greater", "than", "that", "value", "ar...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/medians.go#L15-L29
144,550
biogo/store
kdtree/medians.go
Select
func Select(list SortSlicer, k int) int { var ( start int end = list.Len() ) if k >= end { if k == 0 { return 0 } panic("kdtree: index out of range") } if start == end-1 { return k } for { if start == end { panic("kdtree: internal inconsistency") } sub := list.Slice(start, end) pivot...
go
func Select(list SortSlicer, k int) int { var ( start int end = list.Len() ) if k >= end { if k == 0 { return 0 } panic("kdtree: index out of range") } if start == end-1 { return k } for { if start == end { panic("kdtree: internal inconsistency") } sub := list.Slice(start, end) pivot...
[ "func", "Select", "(", "list", "SortSlicer", ",", "k", "int", ")", "int", "{", "var", "(", "start", "int", "\n", "end", "=", "list", ".", "Len", "(", ")", "\n", ")", "\n", "if", "k", ">=", "end", "{", "if", "k", "==", "0", "{", "return", "0",...
// Select partitions list such that all elements less than the kth largest element are // placed placed before k in the resulting list and all elements greater than it are placed // after the position k.
[ "Select", "partitions", "list", "such", "that", "all", "elements", "less", "than", "the", "kth", "largest", "element", "are", "placed", "placed", "before", "k", "in", "the", "resulting", "list", "and", "all", "elements", "greater", "than", "it", "are", "plac...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/medians.go#L40-L71
144,551
biogo/store
kdtree/medians.go
MedianOfMedians
func MedianOfMedians(list SortSlicer) int { n := list.Len() / 5 for i := 0; i < n; i++ { left := i * 5 sub := list.Slice(left, min(left+5, list.Len()-1)) Select(sub, 2) list.Swap(i, left+2) } Select(list.Slice(0, min(n, list.Len()-1)), min(list.Len(), n/2)) return n / 2 }
go
func MedianOfMedians(list SortSlicer) int { n := list.Len() / 5 for i := 0; i < n; i++ { left := i * 5 sub := list.Slice(left, min(left+5, list.Len()-1)) Select(sub, 2) list.Swap(i, left+2) } Select(list.Slice(0, min(n, list.Len()-1)), min(list.Len(), n/2)) return n / 2 }
[ "func", "MedianOfMedians", "(", "list", "SortSlicer", ")", "int", "{", "n", ":=", "list", ".", "Len", "(", ")", "/", "5", "\n", "for", "i", ":=", "0", ";", "i", "<", "n", ";", "i", "++", "{", "left", ":=", "i", "*", "5", "\n", "sub", ":=", ...
// MedianOfMedians returns the index to the median value of the medians of groups of 5 consecutive elements.
[ "MedianOfMedians", "returns", "the", "index", "to", "the", "median", "value", "of", "the", "medians", "of", "groups", "of", "5", "consecutive", "elements", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/medians.go#L81-L91
144,552
biogo/store
kdtree/medians.go
MedianOfRandoms
func MedianOfRandoms(list SortSlicer, n int) int { if l := list.Len(); n <= l { for i := 0; i < n; i++ { list.Swap(i, rand.Intn(n)) } } else { n = l } Select(list.Slice(0, n), n/2) return n / 2 }
go
func MedianOfRandoms(list SortSlicer, n int) int { if l := list.Len(); n <= l { for i := 0; i < n; i++ { list.Swap(i, rand.Intn(n)) } } else { n = l } Select(list.Slice(0, n), n/2) return n / 2 }
[ "func", "MedianOfRandoms", "(", "list", "SortSlicer", ",", "n", "int", ")", "int", "{", "if", "l", ":=", "list", ".", "Len", "(", ")", ";", "n", "<=", "l", "{", "for", "i", ":=", "0", ";", "i", "<", "n", ";", "i", "++", "{", "list", ".", "S...
// MedianOfRandoms returns the index to the median value of up to n randomly chosen elements in list.
[ "MedianOfRandoms", "returns", "the", "index", "to", "the", "median", "value", "of", "up", "to", "n", "randomly", "chosen", "elements", "in", "list", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/medians.go#L94-L104
144,553
biogo/store
interval/interval.go
color
func (n *Node) color() llrb.Color { if n == nil { return llrb.Black } return n.Color }
go
func (n *Node) color() llrb.Color { if n == nil { return llrb.Black } return n.Color }
[ "func", "(", "n", "*", "Node", ")", "color", "(", ")", "llrb", ".", "Color", "{", "if", "n", "==", "nil", "{", "return", "llrb", ".", "Black", "\n", "}", "\n", "return", "n", ".", "Color", "\n", "}" ]
// Helper methods // color returns the effect color of a Node. A nil node returns black.
[ "Helper", "methods", "color", "returns", "the", "effect", "color", "of", "a", "Node", ".", "A", "nil", "node", "returns", "black", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/interval.go#L90-L95
144,554
biogo/store
interval/interval.go
maxRange
func maxRange(root, left, right *Node) Comparable { end := root.Elem.End() if left != nil && left.Range.End().Compare(end) > 0 { end = left.Range.End() } if right != nil && right.Range.End().Compare(end) > 0 { end = right.Range.End() } return end }
go
func maxRange(root, left, right *Node) Comparable { end := root.Elem.End() if left != nil && left.Range.End().Compare(end) > 0 { end = left.Range.End() } if right != nil && right.Range.End().Compare(end) > 0 { end = right.Range.End() } return end }
[ "func", "maxRange", "(", "root", ",", "left", ",", "right", "*", "Node", ")", "Comparable", "{", "end", ":=", "root", ".", "Elem", ".", "End", "(", ")", "\n", "if", "left", "!=", "nil", "&&", "left", ".", "Range", ".", "End", "(", ")", ".", "Co...
// maxRange returns the furthest right position held by the subtree // rooted at root, assuming that the left and right nodes have correct // range extents.
[ "maxRange", "returns", "the", "furthest", "right", "position", "held", "by", "the", "subtree", "rooted", "at", "root", "assuming", "that", "the", "left", "and", "right", "nodes", "have", "correct", "range", "extents", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/interval.go#L100-L109
144,555
biogo/store
interval/interval.go
Insert
func (t *Tree) Insert(e Interface, fast bool) (err error) { if e.Start().Compare(e.End()) > 0 { return ErrInvertedRange } var d int t.Root, d = t.Root.insert(e, e.Start(), e.ID(), fast) t.Count += d t.Root.Color = llrb.Black return }
go
func (t *Tree) Insert(e Interface, fast bool) (err error) { if e.Start().Compare(e.End()) > 0 { return ErrInvertedRange } var d int t.Root, d = t.Root.insert(e, e.Start(), e.ID(), fast) t.Count += d t.Root.Color = llrb.Black return }
[ "func", "(", "t", "*", "Tree", ")", "Insert", "(", "e", "Interface", ",", "fast", "bool", ")", "(", "err", "error", ")", "{", "if", "e", ".", "Start", "(", ")", ".", "Compare", "(", "e", ".", "End", "(", ")", ")", ">", "0", "{", "return", "...
// Insert inserts the Interface e into the Tree. Insertions may replace // existing stored intervals.
[ "Insert", "inserts", "the", "Interface", "e", "into", "the", "Tree", ".", "Insertions", "may", "replace", "existing", "stored", "intervals", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/interval.go#L249-L258
144,556
biogo/store
interval/interval.go
DeleteMin
func (t *Tree) DeleteMin(fast bool) { if t.Root == nil { return } var d int t.Root, d = t.Root.deleteMin(fast) t.Count += d if t.Root == nil { return } t.Root.Color = llrb.Black }
go
func (t *Tree) DeleteMin(fast bool) { if t.Root == nil { return } var d int t.Root, d = t.Root.deleteMin(fast) t.Count += d if t.Root == nil { return } t.Root.Color = llrb.Black }
[ "func", "(", "t", "*", "Tree", ")", "DeleteMin", "(", "fast", "bool", ")", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "\n", "}", "\n", "var", "d", "int", "\n", "t", ".", "Root", ",", "d", "=", "t", ".", "Root", ".", "deleteMin",...
// DeleteMin deletes the left-most interval.
[ "DeleteMin", "deletes", "the", "left", "-", "most", "interval", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/interval.go#L318-L329
144,557
biogo/store
interval/interval.go
DeleteMax
func (t *Tree) DeleteMax(fast bool) { if t.Root == nil { return } var d int t.Root, d = t.Root.deleteMax(fast) t.Count += d if t.Root == nil { return } t.Root.Color = llrb.Black }
go
func (t *Tree) DeleteMax(fast bool) { if t.Root == nil { return } var d int t.Root, d = t.Root.deleteMax(fast) t.Count += d if t.Root == nil { return } t.Root.Color = llrb.Black }
[ "func", "(", "t", "*", "Tree", ")", "DeleteMax", "(", "fast", "bool", ")", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "\n", "}", "\n", "var", "d", "int", "\n", "t", ".", "Root", ",", "d", "=", "t", ".", "Root", ".", "deleteMax",...
// DeleteMax deletes the right-most interval.
[ "DeleteMax", "deletes", "the", "right", "-", "most", "interval", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/interval.go#L349-L360
144,558
biogo/store
interval/interval.go
Delete
func (t *Tree) Delete(e Interface, fast bool) (err error) { if e.Start().Compare(e.End()) > 0 { return ErrInvertedRange } if t.Root == nil || !e.Overlap(t.Root.Range) { return } var d int t.Root, d = t.Root.delete(e.Start(), e.ID(), fast) t.Count += d if t.Root == nil { return } t.Root.Color = llrb.Blac...
go
func (t *Tree) Delete(e Interface, fast bool) (err error) { if e.Start().Compare(e.End()) > 0 { return ErrInvertedRange } if t.Root == nil || !e.Overlap(t.Root.Range) { return } var d int t.Root, d = t.Root.delete(e.Start(), e.ID(), fast) t.Count += d if t.Root == nil { return } t.Root.Color = llrb.Blac...
[ "func", "(", "t", "*", "Tree", ")", "Delete", "(", "e", "Interface", ",", "fast", "bool", ")", "(", "err", "error", ")", "{", "if", "e", ".", "Start", "(", ")", ".", "Compare", "(", "e", ".", "End", "(", ")", ")", ">", "0", "{", "return", "...
// Delete deletes the element e if it exists in the Tree.
[ "Delete", "deletes", "the", "element", "e", "if", "it", "exists", "in", "the", "Tree", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/interval.go#L383-L398
144,559
biogo/store
interval/interval.go
DoReverse
func (t *Tree) DoReverse(fn Operation) bool { if t.Root == nil { return false } return t.Root.doReverse(fn) }
go
func (t *Tree) DoReverse(fn Operation) bool { if t.Root == nil { return false } return t.Root.doReverse(fn) }
[ "func", "(", "t", "*", "Tree", ")", "DoReverse", "(", "fn", "Operation", ")", "bool", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "t", ".", "Root", ".", "doReverse", "(", "fn", ")", "\n", "}" ]
// DoReverse performs fn on all intervals stored in the tree, but in reverse of sort order. A boolean // is returned indicating whether the Do traversal was interrupted by an Operation returning true. // If fn alters stored intervals' sort relationships, future tree operation behaviors are undefined.
[ "DoReverse", "performs", "fn", "on", "all", "intervals", "stored", "in", "the", "tree", "but", "in", "reverse", "of", "sort", "order", ".", "A", "boolean", "is", "returned", "indicating", "whether", "the", "Do", "traversal", "was", "interrupted", "by", "an",...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/interval.go#L580-L585
144,560
biogo/store
interval/int_interval.go
color
func (n *IntNode) color() llrb.Color { if n == nil { return llrb.Black } return n.Color }
go
func (n *IntNode) color() llrb.Color { if n == nil { return llrb.Black } return n.Color }
[ "func", "(", "n", "*", "IntNode", ")", "color", "(", ")", "llrb", ".", "Color", "{", "if", "n", "==", "nil", "{", "return", "llrb", ".", "Black", "\n", "}", "\n", "return", "n", ".", "Color", "\n", "}" ]
// Helper methods // color returns the effect color of a IntNode. A nil node returns black.
[ "Helper", "methods", "color", "returns", "the", "effect", "color", "of", "a", "IntNode", ".", "A", "nil", "node", "returns", "black", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/int_interval.go#L49-L54
144,561
biogo/store
interval/int_interval.go
intMaxRange
func intMaxRange(root, left, right *IntNode) int { end := root.Interval.End if left != nil && left.Range.End > end { end = left.Range.End } if right != nil && right.Range.End > end { end = right.Range.End } return end }
go
func intMaxRange(root, left, right *IntNode) int { end := root.Interval.End if left != nil && left.Range.End > end { end = left.Range.End } if right != nil && right.Range.End > end { end = right.Range.End } return end }
[ "func", "intMaxRange", "(", "root", ",", "left", ",", "right", "*", "IntNode", ")", "int", "{", "end", ":=", "root", ".", "Interval", ".", "End", "\n", "if", "left", "!=", "nil", "&&", "left", ".", "Range", ".", "End", ">", "end", "{", "end", "="...
// intMaxRange returns the furthest right position held by the subtree // rooted at root, assuming that the left and right nodes have correct // range extents.
[ "intMaxRange", "returns", "the", "furthest", "right", "position", "held", "by", "the", "subtree", "rooted", "at", "root", "assuming", "that", "the", "left", "and", "right", "nodes", "have", "correct", "range", "extents", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/int_interval.go#L59-L68
144,562
biogo/store
interval/int_interval.go
Insert
func (t *IntTree) Insert(e IntInterface, fast bool) (err error) { if r := e.Range(); r.Start > r.End { return ErrInvertedRange } var d int t.Root, d = t.Root.insert(e, e.Range(), e.ID(), fast) t.Count += d t.Root.Color = llrb.Black return }
go
func (t *IntTree) Insert(e IntInterface, fast bool) (err error) { if r := e.Range(); r.Start > r.End { return ErrInvertedRange } var d int t.Root, d = t.Root.insert(e, e.Range(), e.ID(), fast) t.Count += d t.Root.Color = llrb.Black return }
[ "func", "(", "t", "*", "IntTree", ")", "Insert", "(", "e", "IntInterface", ",", "fast", "bool", ")", "(", "err", "error", ")", "{", "if", "r", ":=", "e", ".", "Range", "(", ")", ";", "r", ".", "Start", ">", "r", ".", "End", "{", "return", "Er...
// Insert inserts the IntInterface e into the IntTree. Insertions may replace // existing stored intervals.
[ "Insert", "inserts", "the", "IntInterface", "e", "into", "the", "IntTree", ".", "Insertions", "may", "replace", "existing", "stored", "intervals", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/int_interval.go#L208-L217
144,563
biogo/store
interval/int_interval.go
Delete
func (t *IntTree) Delete(e IntInterface, fast bool) (err error) { if r := e.Range(); r.Start > r.End { return ErrInvertedRange } if t.Root == nil || !e.Overlap(t.Root.Range) { return } var d int t.Root, d = t.Root.delete(e.Range().Start, e.ID(), fast) t.Count += d if t.Root == nil { return } t.Root.Colo...
go
func (t *IntTree) Delete(e IntInterface, fast bool) (err error) { if r := e.Range(); r.Start > r.End { return ErrInvertedRange } if t.Root == nil || !e.Overlap(t.Root.Range) { return } var d int t.Root, d = t.Root.delete(e.Range().Start, e.ID(), fast) t.Count += d if t.Root == nil { return } t.Root.Colo...
[ "func", "(", "t", "*", "IntTree", ")", "Delete", "(", "e", "IntInterface", ",", "fast", "bool", ")", "(", "err", "error", ")", "{", "if", "r", ":=", "e", ".", "Range", "(", ")", ";", "r", ".", "Start", ">", "r", ".", "End", "{", "return", "Er...
// Delete deletes the element e if it exists in the IntTree.
[ "Delete", "deletes", "the", "element", "e", "if", "it", "exists", "in", "the", "IntTree", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/int_interval.go#L344-L359
144,564
biogo/store
interval/int_interval.go
Do
func (t *IntTree) Do(fn IntOperation) bool { if t.Root == nil { return false } return t.Root.do(fn) }
go
func (t *IntTree) Do(fn IntOperation) bool { if t.Root == nil { return false } return t.Root.do(fn) }
[ "func", "(", "t", "*", "IntTree", ")", "Do", "(", "fn", "IntOperation", ")", "bool", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "t", ".", "Root", ".", "do", "(", "fn", ")", "\n", "}" ]
// Do performs fn on all intervals stored in the tree. A boolean is returned indicating whether the // Do traversal was interrupted by an IntOperation returning true. If fn alters stored intervals' // end points, future tree operation behaviors are undefined.
[ "Do", "performs", "fn", "on", "all", "intervals", "stored", "in", "the", "tree", ".", "A", "boolean", "is", "returned", "indicating", "whether", "the", "Do", "traversal", "was", "interrupted", "by", "an", "IntOperation", "returning", "true", ".", "If", "fn",...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/int_interval.go#L516-L521
144,565
biogo/store
interval/int_interval.go
DoReverse
func (t *IntTree) DoReverse(fn IntOperation) bool { if t.Root == nil { return false } return t.Root.doReverse(fn) }
go
func (t *IntTree) DoReverse(fn IntOperation) bool { if t.Root == nil { return false } return t.Root.doReverse(fn) }
[ "func", "(", "t", "*", "IntTree", ")", "DoReverse", "(", "fn", "IntOperation", ")", "bool", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "t", ".", "Root", ".", "doReverse", "(", "fn", ")", "\n", "}"...
// DoReverse performs fn on all intervals stored in the tree, but in reverse of sort order. A boolean // is returned indicating whether the Do traversal was interrupted by an IntOperation returning true. // If fn alters stored intervals' end points, future tree operation behaviors are undefined.
[ "DoReverse", "performs", "fn", "on", "all", "intervals", "stored", "in", "the", "tree", "but", "in", "reverse", "of", "sort", "order", ".", "A", "boolean", "is", "returned", "indicating", "whether", "the", "Do", "traversal", "was", "interrupted", "by", "an",...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/interval/int_interval.go#L543-L548
144,566
biogo/store
llrb/llrb.go
Get
func (t *Tree) Get(q Comparable) Comparable { if t.Root == nil { return nil } n := t.Root.search(q) if n == nil { return nil } return n.Elem }
go
func (t *Tree) Get(q Comparable) Comparable { if t.Root == nil { return nil } n := t.Root.search(q) if n == nil { return nil } return n.Elem }
[ "func", "(", "t", "*", "Tree", ")", "Get", "(", "q", "Comparable", ")", "Comparable", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "n", ":=", "t", ".", "Root", ".", "search", "(", "q", ")", "\n", "if", "n",...
// Get returns the first match of q in the Tree. If insertion without // replacement is used, this is probably not what you want.
[ "Get", "returns", "the", "first", "match", "of", "q", "in", "the", "Tree", ".", "If", "insertion", "without", "replacement", "is", "used", "this", "is", "probably", "not", "what", "you", "want", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/llrb/llrb.go#L160-L169
144,567
biogo/store
llrb/llrb.go
DeleteMax
func (t *Tree) DeleteMax() { if t.Root == nil { return } var d int t.Root, d = t.Root.deleteMax() t.Count += d if t.Root == nil { return } t.Root.Color = Black }
go
func (t *Tree) DeleteMax() { if t.Root == nil { return } var d int t.Root, d = t.Root.deleteMax() t.Count += d if t.Root == nil { return } t.Root.Color = Black }
[ "func", "(", "t", "*", "Tree", ")", "DeleteMax", "(", ")", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "\n", "}", "\n", "var", "d", "int", "\n", "t", ".", "Root", ",", "d", "=", "t", ".", "Root", ".", "deleteMax", "(", ")", "\n...
// DeleteMax deletes the node with the maximum value in the tree. If insertion without // replacement has been used, the right-most maximum will be deleted.
[ "DeleteMax", "deletes", "the", "node", "with", "the", "maximum", "value", "in", "the", "tree", ".", "If", "insertion", "without", "replacement", "has", "been", "used", "the", "right", "-", "most", "maximum", "will", "be", "deleted", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/llrb/llrb.go#L270-L281
144,568
biogo/store
llrb/llrb.go
DoRange
func (t *Tree) DoRange(fn Operation, from, to Comparable) bool { if t.Root == nil { return false } if from.Compare(to) > 0 { panic("llrb: inverted range") } return t.Root.doRange(fn, from, to) }
go
func (t *Tree) DoRange(fn Operation, from, to Comparable) bool { if t.Root == nil { return false } if from.Compare(to) > 0 { panic("llrb: inverted range") } return t.Root.doRange(fn, from, to) }
[ "func", "(", "t", "*", "Tree", ")", "DoRange", "(", "fn", "Operation", ",", "from", ",", "to", "Comparable", ")", "bool", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "false", "\n", "}", "\n", "if", "from", ".", "Compare", "(", "to", ...
// DoRange performs fn on all values stored in the tree over the interval [from, to) from left // to right. If to is less than from DoRange will panic. A boolean is returned indicating whether // the Do traversal was interrupted by an Operation returning true. If fn alters stored values' // sort relationships future tr...
[ "DoRange", "performs", "fn", "on", "all", "values", "stored", "in", "the", "tree", "over", "the", "interval", "[", "from", "to", ")", "from", "left", "to", "right", ".", "If", "to", "is", "less", "than", "from", "DoRange", "will", "panic", ".", "A", ...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/llrb/llrb.go#L500-L508
144,569
biogo/store
llrb/llrb.go
DoRangeReverse
func (t *Tree) DoRangeReverse(fn Operation, from, to Comparable) bool { if t.Root == nil { return false } if from.Compare(to) < 0 { panic("llrb: inverted range") } return t.Root.doRangeReverse(fn, from, to) }
go
func (t *Tree) DoRangeReverse(fn Operation, from, to Comparable) bool { if t.Root == nil { return false } if from.Compare(to) < 0 { panic("llrb: inverted range") } return t.Root.doRangeReverse(fn, from, to) }
[ "func", "(", "t", "*", "Tree", ")", "DoRangeReverse", "(", "fn", "Operation", ",", "from", ",", "to", "Comparable", ")", "bool", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "false", "\n", "}", "\n", "if", "from", ".", "Compare", "(", ...
// DoRangeReverse performs fn on all values stored in the tree over the interval (to, from] from // right to left. If from is less than to DoRange will panic. A boolean is returned indicating // whether the Do traversal was interrupted by an Operation returning true. If fn alters stored // values' sort relationships fu...
[ "DoRangeReverse", "performs", "fn", "on", "all", "values", "stored", "in", "the", "tree", "over", "the", "interval", "(", "to", "from", "]", "from", "right", "to", "left", ".", "If", "from", "is", "less", "than", "to", "DoRange", "will", "panic", ".", ...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/llrb/llrb.go#L534-L542
144,570
biogo/store
step/step.go
Equal
func (f Float) Equal(e Equaler) bool { ef := e.(Float) if f != f && ef != ef { // For our purposes NaN == NaN. return true } return f == ef }
go
func (f Float) Equal(e Equaler) bool { ef := e.(Float) if f != f && ef != ef { // For our purposes NaN == NaN. return true } return f == ef }
[ "func", "(", "f", "Float", ")", "Equal", "(", "e", "Equaler", ")", "bool", "{", "ef", ":=", "e", ".", "(", "Float", ")", "\n", "if", "f", "!=", "f", "&&", "ef", "!=", "ef", "{", "// For our purposes NaN == NaN.", "return", "true", "\n", "}", "\n", ...
// Equal returns whether f equals e. For the purposes of the step package here, NaN == NaN // evaluates to true. Equal assumes the underlying type of e is Float.
[ "Equal", "returns", "whether", "f", "equals", "e", ".", "For", "the", "purposes", "of", "the", "step", "package", "here", "NaN", "==", "NaN", "evaluates", "to", "true", ".", "Equal", "assumes", "the", "underlying", "type", "of", "e", "is", "Float", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/step/step.go#L79-L85
144,571
biogo/store
step/step.go
New
func New(start, end int, zero Equaler) (*Vector, error) { if start >= end { return nil, ErrZeroLength } v := &Vector{ Zero: zero, min: &position{ pos: start, val: zero, }, max: &position{ pos: end, val: nil, }, } v.t.Insert(v.min) v.t.Insert(v.max) return v, nil }
go
func New(start, end int, zero Equaler) (*Vector, error) { if start >= end { return nil, ErrZeroLength } v := &Vector{ Zero: zero, min: &position{ pos: start, val: zero, }, max: &position{ pos: end, val: nil, }, } v.t.Insert(v.min) v.t.Insert(v.max) return v, nil }
[ "func", "New", "(", "start", ",", "end", "int", ",", "zero", "Equaler", ")", "(", "*", "Vector", ",", "error", ")", "{", "if", "start", ">=", "end", "{", "return", "nil", ",", "ErrZeroLength", "\n", "}", "\n", "v", ":=", "&", "Vector", "{", "Zero...
// New returns a new Vector with the extent defined by start and end, // and the ground state defined by zero. The Vector's extent is mutable // if the Relaxed field is set to true. If a zero length vector is requested // an error is returned.
[ "New", "returns", "a", "new", "Vector", "with", "the", "extent", "defined", "by", "start", "and", "end", "and", "the", "ground", "state", "defined", "by", "zero", ".", "The", "Vector", "s", "extent", "is", "mutable", "if", "the", "Relaxed", "field", "is"...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/step/step.go#L100-L119
144,572
biogo/store
step/step.go
At
func (v *Vector) At(i int) (Equaler, error) { if i < v.Start() || i >= v.End() { return nil, ErrOutOfRange } st := v.t.Floor(query(i)).(*position) return st.val, nil }
go
func (v *Vector) At(i int) (Equaler, error) { if i < v.Start() || i >= v.End() { return nil, ErrOutOfRange } st := v.t.Floor(query(i)).(*position) return st.val, nil }
[ "func", "(", "v", "*", "Vector", ")", "At", "(", "i", "int", ")", "(", "Equaler", ",", "error", ")", "{", "if", "i", "<", "v", ".", "Start", "(", ")", "||", "i", ">=", "v", ".", "End", "(", ")", "{", "return", "nil", ",", "ErrOutOfRange", "...
// At returns the value of the vector at position i. If i is outside the extent // of the vector an error is returned.
[ "At", "returns", "the", "value", "of", "the", "vector", "at", "position", "i", ".", "If", "i", "is", "outside", "the", "extent", "of", "the", "vector", "an", "error", "is", "returned", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/step/step.go#L136-L142
144,573
biogo/store
step/step.go
StepAt
func (v *Vector) StepAt(i int) (start, end int, e Equaler, err error) { if i < v.Start() || i >= v.End() { return 0, 0, nil, ErrOutOfRange } lo := v.t.Floor(query(i)).(*position) hi := v.t.Ceil(upper(i)).(*position) return lo.pos, hi.pos, lo.val, nil }
go
func (v *Vector) StepAt(i int) (start, end int, e Equaler, err error) { if i < v.Start() || i >= v.End() { return 0, 0, nil, ErrOutOfRange } lo := v.t.Floor(query(i)).(*position) hi := v.t.Ceil(upper(i)).(*position) return lo.pos, hi.pos, lo.val, nil }
[ "func", "(", "v", "*", "Vector", ")", "StepAt", "(", "i", "int", ")", "(", "start", ",", "end", "int", ",", "e", "Equaler", ",", "err", "error", ")", "{", "if", "i", "<", "v", ".", "Start", "(", ")", "||", "i", ">=", "v", ".", "End", "(", ...
// StepAt returns the value and range of the step at i, where start <= i < end. // If i is outside the extent of the vector, an error is returned.
[ "StepAt", "returns", "the", "value", "and", "range", "of", "the", "step", "at", "i", "where", "start", "<", "=", "i", "<", "end", ".", "If", "i", "is", "outside", "the", "extent", "of", "the", "vector", "an", "error", "is", "returned", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/step/step.go#L146-L153
144,574
biogo/store
step/step.go
Do
func (v *Vector) Do(fn Operation) { var ( la *position min = v.min.pos ) v.t.Do(func(c llrb.Comparable) (done bool) { p := c.(*position) if p.pos != min { fn(la.pos, p.pos, la.val) } la = p return }) }
go
func (v *Vector) Do(fn Operation) { var ( la *position min = v.min.pos ) v.t.Do(func(c llrb.Comparable) (done bool) { p := c.(*position) if p.pos != min { fn(la.pos, p.pos, la.val) } la = p return }) }
[ "func", "(", "v", "*", "Vector", ")", "Do", "(", "fn", "Operation", ")", "{", "var", "(", "la", "*", "position", "\n", "min", "=", "v", ".", "min", ".", "pos", "\n", ")", "\n\n", "v", ".", "t", ".", "Do", "(", "func", "(", "c", "llrb", ".",...
// Do performs the function fn on steps stored in the Vector in ascending sort order // of start position. fn is passed the start, end and value of the step.
[ "Do", "performs", "the", "function", "fn", "on", "steps", "stored", "in", "the", "Vector", "in", "ascending", "sort", "order", "of", "start", "position", ".", "fn", "is", "passed", "the", "start", "end", "and", "value", "of", "the", "step", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/step/step.go#L379-L393
144,575
biogo/store
step/step.go
DoRange
func (v *Vector) DoRange(from, to int, fn Operation) error { if to < from { return ErrInvertedRange } var ( la *position min = v.min.pos max = v.max.pos ) if to <= min || from >= max { return ErrOutOfRange } _, end, e, _ := v.StepAt(from) if end > to { end = to } fn(from, end, e) if end == to {...
go
func (v *Vector) DoRange(from, to int, fn Operation) error { if to < from { return ErrInvertedRange } var ( la *position min = v.min.pos max = v.max.pos ) if to <= min || from >= max { return ErrOutOfRange } _, end, e, _ := v.StepAt(from) if end > to { end = to } fn(from, end, e) if end == to {...
[ "func", "(", "v", "*", "Vector", ")", "DoRange", "(", "from", ",", "to", "int", ",", "fn", "Operation", ")", "error", "{", "if", "to", "<", "from", "{", "return", "ErrInvertedRange", "\n", "}", "\n", "var", "(", "la", "*", "position", "\n", "min", ...
// Do performs the function fn on steps stored in the Vector over the range [from, to) // in ascending sort order of start position. fn is passed the start, end and value of // the step.
[ "Do", "performs", "the", "function", "fn", "on", "steps", "stored", "in", "the", "Vector", "over", "the", "range", "[", "from", "to", ")", "in", "ascending", "sort", "order", "of", "start", "position", ".", "fn", "is", "passed", "the", "start", "end", ...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/step/step.go#L398-L432
144,576
biogo/store
step/step.go
Apply
func (v *Vector) Apply(m Mutator) { var ( la Equaler min = v.min.pos max = v.max.pos delQ []query ) v.t.Do(func(c llrb.Comparable) (done bool) { p := c.(*position) if p.pos == max { return true } p.val = m(p.val) if p.pos != min && p.pos != max && p.val.Equal(la) { delQ = append(delQ, qu...
go
func (v *Vector) Apply(m Mutator) { var ( la Equaler min = v.min.pos max = v.max.pos delQ []query ) v.t.Do(func(c llrb.Comparable) (done bool) { p := c.(*position) if p.pos == max { return true } p.val = m(p.val) if p.pos != min && p.pos != max && p.val.Equal(la) { delQ = append(delQ, qu...
[ "func", "(", "v", "*", "Vector", ")", "Apply", "(", "m", "Mutator", ")", "{", "var", "(", "la", "Equaler", "\n", "min", "=", "v", ".", "min", ".", "pos", "\n", "max", "=", "v", ".", "max", ".", "pos", "\n", "delQ", "[", "]", "query", "\n", ...
// Apply applies the mutator function m to steps stored in the Vector in ascending sort order // of start position. Redundant steps resulting from changes in step values are erased.
[ "Apply", "applies", "the", "mutator", "function", "m", "to", "steps", "stored", "in", "the", "Vector", "in", "ascending", "sort", "order", "of", "start", "position", ".", "Redundant", "steps", "resulting", "from", "changes", "in", "step", "values", "are", "e...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/step/step.go#L455-L479
144,577
biogo/store
step/step.go
String
func (v *Vector) String() string { sb := make([]string, 0, v.t.Len()) v.t.Do(func(c llrb.Comparable) (done bool) { p := c.(*position) sb = append(sb, fmt.Sprintf("%d:%v", p.pos, p.val)) return }) return fmt.Sprintf("%v", sb) }
go
func (v *Vector) String() string { sb := make([]string, 0, v.t.Len()) v.t.Do(func(c llrb.Comparable) (done bool) { p := c.(*position) sb = append(sb, fmt.Sprintf("%d:%v", p.pos, p.val)) return }) return fmt.Sprintf("%v", sb) }
[ "func", "(", "v", "*", "Vector", ")", "String", "(", ")", "string", "{", "sb", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "v", ".", "t", ".", "Len", "(", ")", ")", "\n", "v", ".", "t", ".", "Do", "(", "func", "(", "c", "llrb", ...
// String returns a string representation a Vector, displaying step start // positions and values. The last step indicates the end of the vector and // always has an associated value of nil.
[ "String", "returns", "a", "string", "representation", "a", "Vector", "displaying", "step", "start", "positions", "and", "values", ".", "The", "last", "step", "indicates", "the", "end", "of", "the", "vector", "and", "always", "has", "an", "associated", "value",...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/step/step.go#L582-L590
144,578
biogo/store
kdtree/kdtree.go
Contains
func (b *Bounding) Contains(c Comparable) bool { if b == nil { return true } for d := Dim(0); d < Dim(c.Dims()); d++ { if c.Compare(b[0], d) < 0 || c.Compare(b[1], d) > 0 { return false } } return true }
go
func (b *Bounding) Contains(c Comparable) bool { if b == nil { return true } for d := Dim(0); d < Dim(c.Dims()); d++ { if c.Compare(b[0], d) < 0 || c.Compare(b[1], d) > 0 { return false } } return true }
[ "func", "(", "b", "*", "Bounding", ")", "Contains", "(", "c", "Comparable", ")", "bool", "{", "if", "b", "==", "nil", "{", "return", "true", "\n", "}", "\n", "for", "d", ":=", "Dim", "(", "0", ")", ";", "d", "<", "Dim", "(", "c", ".", "Dims",...
// Contains returns whether c is within the volume of the Bounding. A nil Bounding // returns true.
[ "Contains", "returns", "whether", "c", "is", "within", "the", "volume", "of", "the", "Bounding", ".", "A", "nil", "Bounding", "returns", "true", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/kdtree.go#L75-L85
144,579
biogo/store
kdtree/kdtree.go
New
func New(p Interface, bounding bool) *Tree { if p, ok := p.(bounder); ok && bounding { return &Tree{ Root: buildBounded(p, 0, bounding), Count: p.Len(), } } return &Tree{ Root: build(p, 0), Count: p.Len(), } }
go
func New(p Interface, bounding bool) *Tree { if p, ok := p.(bounder); ok && bounding { return &Tree{ Root: buildBounded(p, 0, bounding), Count: p.Len(), } } return &Tree{ Root: build(p, 0), Count: p.Len(), } }
[ "func", "New", "(", "p", "Interface", ",", "bounding", "bool", ")", "*", "Tree", "{", "if", "p", ",", "ok", ":=", "p", ".", "(", "bounder", ")", ";", "ok", "&&", "bounding", "{", "return", "&", "Tree", "{", "Root", ":", "buildBounded", "(", "p", ...
// New returns a k-d tree constructed from the values in p. If p is a Bounder and // bounding is true, bounds are determined for each node.
[ "New", "returns", "a", "k", "-", "d", "tree", "constructed", "from", "the", "values", "in", "p", ".", "If", "p", "is", "a", "Bounder", "and", "bounding", "is", "true", "bounds", "are", "determined", "for", "each", "node", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/kdtree.go#L110-L121
144,580
biogo/store
kdtree/kdtree.go
Insert
func (t *Tree) Insert(c Comparable, bounding bool) { t.Count++ if t.Root != nil { bounding = t.Root.Bounding != nil } if c, ok := c.(Extender); ok && bounding { t.Root = t.Root.insertBounded(c, 0, bounding) return } else if !ok && t.Root != nil { // If we are not rebounding, mark the tree as non-bounded. ...
go
func (t *Tree) Insert(c Comparable, bounding bool) { t.Count++ if t.Root != nil { bounding = t.Root.Bounding != nil } if c, ok := c.(Extender); ok && bounding { t.Root = t.Root.insertBounded(c, 0, bounding) return } else if !ok && t.Root != nil { // If we are not rebounding, mark the tree as non-bounded. ...
[ "func", "(", "t", "*", "Tree", ")", "Insert", "(", "c", "Comparable", ",", "bounding", "bool", ")", "{", "t", ".", "Count", "++", "\n", "if", "t", ".", "Root", "!=", "nil", "{", "bounding", "=", "t", ".", "Root", ".", "Bounding", "!=", "nil", "...
// Insert adds a point to the tree, updating the bounding volumes if bounding is // true, and the tree is empty or the tree already has bounding volumes stored, // and c is an Extender. No rebalancing of the tree is performed.
[ "Insert", "adds", "a", "point", "to", "the", "tree", "updating", "the", "bounding", "volumes", "if", "bounding", "is", "true", "and", "the", "tree", "is", "empty", "or", "the", "tree", "already", "has", "bounding", "volumes", "stored", "and", "c", "is", ...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/kdtree.go#L163-L176
144,581
biogo/store
kdtree/kdtree.go
Contains
func (t *Tree) Contains(c Comparable) bool { if t.Root.Bounding == nil { return true } return t.Root.Contains(c) }
go
func (t *Tree) Contains(c Comparable) bool { if t.Root.Bounding == nil { return true } return t.Root.Contains(c) }
[ "func", "(", "t", "*", "Tree", ")", "Contains", "(", "c", "Comparable", ")", "bool", "{", "if", "t", ".", "Root", ".", "Bounding", "==", "nil", "{", "return", "true", "\n", "}", "\n", "return", "t", ".", "Root", ".", "Contains", "(", "c", ")", ...
// Contains returns whether a Comparable is in the bounds of the tree. If no bounding has // been constructed Contains returns true.
[ "Contains", "returns", "whether", "a", "Comparable", "is", "in", "the", "bounds", "of", "the", "tree", ".", "If", "no", "bounding", "has", "been", "constructed", "Contains", "returns", "true", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/kdtree.go#L228-L233
144,582
biogo/store
kdtree/kdtree.go
Nearest
func (t *Tree) Nearest(q Comparable) (Comparable, float64) { if t.Root == nil { return nil, inf } n, dist := t.Root.search(q, inf) if n == nil { return nil, inf } return n.Point, dist }
go
func (t *Tree) Nearest(q Comparable) (Comparable, float64) { if t.Root == nil { return nil, inf } n, dist := t.Root.search(q, inf) if n == nil { return nil, inf } return n.Point, dist }
[ "func", "(", "t", "*", "Tree", ")", "Nearest", "(", "q", "Comparable", ")", "(", "Comparable", ",", "float64", ")", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "nil", ",", "inf", "\n", "}", "\n", "n", ",", "dist", ":=", "t", ".", ...
// Nearest returns the nearest value to the query and the distance between them.
[ "Nearest", "returns", "the", "nearest", "value", "to", "the", "query", "and", "the", "distance", "between", "them", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/kdtree.go#L238-L247
144,583
biogo/store
kdtree/kdtree.go
NewNKeeper
func NewNKeeper(n int) *NKeeper { k := NKeeper{make(Heap, 1, n)} k.Heap[0].Dist = inf return &k }
go
func NewNKeeper(n int) *NKeeper { k := NKeeper{make(Heap, 1, n)} k.Heap[0].Dist = inf return &k }
[ "func", "NewNKeeper", "(", "n", "int", ")", "*", "NKeeper", "{", "k", ":=", "NKeeper", "{", "make", "(", "Heap", ",", "1", ",", "n", ")", "}", "\n", "k", ".", "Heap", "[", "0", "]", ".", "Dist", "=", "inf", "\n", "return", "&", "k", "\n", "...
// NewNKeeper returns an NKeeper with the max value of the heap set to infinite distance. The // returned NKeeper is able to retain at most n values.
[ "NewNKeeper", "returns", "an", "NKeeper", "with", "the", "max", "value", "of", "the", "heap", "set", "to", "infinite", "distance", ".", "The", "returned", "NKeeper", "is", "able", "to", "retain", "at", "most", "n", "values", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/kdtree.go#L311-L315
144,584
biogo/store
kdtree/kdtree.go
Keep
func (k *NKeeper) Keep(c ComparableDist) { if c.Dist < k.Heap[0].Dist { if len(k.Heap) == cap(k.Heap) { heap.Pop(k) } heap.Push(k, c) } }
go
func (k *NKeeper) Keep(c ComparableDist) { if c.Dist < k.Heap[0].Dist { if len(k.Heap) == cap(k.Heap) { heap.Pop(k) } heap.Push(k, c) } }
[ "func", "(", "k", "*", "NKeeper", ")", "Keep", "(", "c", "ComparableDist", ")", "{", "if", "c", ".", "Dist", "<", "k", ".", "Heap", "[", "0", "]", ".", "Dist", "{", "if", "len", "(", "k", ".", "Heap", ")", "==", "cap", "(", "k", ".", "Heap"...
// Keep add c to the heap if its distance is less than the maximum value of the heap. If adding // c would increase the size of the heap beyond the initial maximum length, the maximum value of // the heap is dropped.
[ "Keep", "add", "c", "to", "the", "heap", "if", "its", "distance", "is", "less", "than", "the", "maximum", "value", "of", "the", "heap", ".", "If", "adding", "c", "would", "increase", "the", "size", "of", "the", "heap", "beyond", "the", "initial", "maxi...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/kdtree.go#L320-L327
144,585
biogo/store
kdtree/kdtree.go
Keep
func (k *DistKeeper) Keep(c ComparableDist) { if c.Dist <= k.Heap[0].Dist { heap.Push(k, c) } }
go
func (k *DistKeeper) Keep(c ComparableDist) { if c.Dist <= k.Heap[0].Dist { heap.Push(k, c) } }
[ "func", "(", "k", "*", "DistKeeper", ")", "Keep", "(", "c", "ComparableDist", ")", "{", "if", "c", ".", "Dist", "<=", "k", ".", "Heap", "[", "0", "]", ".", "Dist", "{", "heap", ".", "Push", "(", "k", ",", "c", ")", "\n", "}", "\n", "}" ]
// Keep adds c to the heap if its distance is less than or equal to the max value of the heap.
[ "Keep", "adds", "c", "to", "the", "heap", "if", "its", "distance", "is", "less", "than", "or", "equal", "to", "the", "max", "value", "of", "the", "heap", "." ]
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/kdtree.go#L339-L343
144,586
biogo/store
kdtree/kdtree.go
DoBounded
func (t *Tree) DoBounded(fn Operation, b *Bounding) bool { if t.Root == nil { return false } if b == nil { return t.Root.do(fn, 0) } return t.Root.doBounded(fn, b, 0) }
go
func (t *Tree) DoBounded(fn Operation, b *Bounding) bool { if t.Root == nil { return false } if b == nil { return t.Root.do(fn, 0) } return t.Root.doBounded(fn, b, 0) }
[ "func", "(", "t", "*", "Tree", ")", "DoBounded", "(", "fn", "Operation", ",", "b", "*", "Bounding", ")", "bool", "{", "if", "t", ".", "Root", "==", "nil", "{", "return", "false", "\n", "}", "\n", "if", "b", "==", "nil", "{", "return", "t", ".",...
// DoBounded performs fn on all values stored in the tree that are within the specified bound. // If b is nil, the result is the same as a Do. A boolean is returned indicating whether the // DoBounded traversal was interrupted by an Operation returning true. If fn alters stored // values' sort relationships future tree...
[ "DoBounded", "performs", "fn", "on", "all", "values", "stored", "in", "the", "tree", "that", "are", "within", "the", "specified", "bound", ".", "If", "b", "is", "nil", "the", "result", "is", "the", "same", "as", "a", "Do", ".", "A", "boolean", "is", ...
884f370e325d9036057c7cf5167ca8a05fba575a
https://github.com/biogo/store/blob/884f370e325d9036057c7cf5167ca8a05fba575a/kdtree/kdtree.go#L435-L443
144,587
memcachier/mc
server_conn.go
authList
func (sc *serverConn) authList() (string, error) { m := &msg{ header: header{ Op: opAuthList, }, } err := sc.sendRecv(m) return m.val, err }
go
func (sc *serverConn) authList() (string, error) { m := &msg{ header: header{ Op: opAuthList, }, } err := sc.sendRecv(m) return m.val, err }
[ "func", "(", "sc", "*", "serverConn", ")", "authList", "(", ")", "(", "string", ",", "error", ")", "{", "m", ":=", "&", "msg", "{", "header", ":", "header", "{", "Op", ":", "opAuthList", ",", "}", ",", "}", "\n\n", "err", ":=", "sc", ".", "send...
// authList runs the SASL authentication list command with the server to // retrieve the list of support authentication mechansims.
[ "authList", "runs", "the", "SASL", "authentication", "list", "command", "with", "the", "server", "to", "retrieve", "the", "list", "of", "support", "authentication", "mechansims", "." ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/server_conn.go#L122-L131
144,588
memcachier/mc
server_conn.go
authPlain
func (sc *serverConn) authPlain() error { m := &msg{ header: header{ Op: opAuthStart, }, key: "PLAIN", val: fmt.Sprintf("\x00%s\x00%s", sc.username, sc.password), } return sc.sendRecv(m) }
go
func (sc *serverConn) authPlain() error { m := &msg{ header: header{ Op: opAuthStart, }, key: "PLAIN", val: fmt.Sprintf("\x00%s\x00%s", sc.username, sc.password), } return sc.sendRecv(m) }
[ "func", "(", "sc", "*", "serverConn", ")", "authPlain", "(", ")", "error", "{", "m", ":=", "&", "msg", "{", "header", ":", "header", "{", "Op", ":", "opAuthStart", ",", "}", ",", "key", ":", "\"", "\"", ",", "val", ":", "fmt", ".", "Sprintf", "...
// authPlain performs SASL authentication using the PLAIN method.
[ "authPlain", "performs", "SASL", "authentication", "using", "the", "PLAIN", "method", "." ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/server_conn.go#L134-L145
144,589
memcachier/mc
server_conn.go
send
func (sc *serverConn) send(m *msg) error { m.Magic = magicSend m.ExtraLen = sizeOfExtras(m.iextras) m.KeyLen = uint16(len(m.key)) m.BodyLen = uint32(m.ExtraLen) + uint32(m.KeyLen) + uint32(len(m.val)) m.Opaque = sc.opq sc.opq++ // Request err := binary.Write(sc.buf, binary.BigEndian, m.header) if err != nil {...
go
func (sc *serverConn) send(m *msg) error { m.Magic = magicSend m.ExtraLen = sizeOfExtras(m.iextras) m.KeyLen = uint16(len(m.key)) m.BodyLen = uint32(m.ExtraLen) + uint32(m.KeyLen) + uint32(len(m.val)) m.Opaque = sc.opq sc.opq++ // Request err := binary.Write(sc.buf, binary.BigEndian, m.header) if err != nil {...
[ "func", "(", "sc", "*", "serverConn", ")", "send", "(", "m", "*", "msg", ")", "error", "{", "m", ".", "Magic", "=", "magicSend", "\n", "m", ".", "ExtraLen", "=", "sizeOfExtras", "(", "m", ".", "iextras", ")", "\n", "m", ".", "KeyLen", "=", "uint1...
// send sends a request to the memcache server.
[ "send", "sends", "a", "request", "to", "the", "memcache", "server", "." ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/server_conn.go#L187-L226
144,590
memcachier/mc
server_conn.go
recv
func (sc *serverConn) recv(m *msg) error { // Make sure read does not block forever sc.conn.SetReadDeadline(time.Now().Add(sc.config.ConnectionTimeout)) err := binary.Read(sc.conn, binary.BigEndian, &m.header) if err != nil { return wrapError(StatusNetworkError, err) } bd := make([]byte, m.BodyLen) _, err = ...
go
func (sc *serverConn) recv(m *msg) error { // Make sure read does not block forever sc.conn.SetReadDeadline(time.Now().Add(sc.config.ConnectionTimeout)) err := binary.Read(sc.conn, binary.BigEndian, &m.header) if err != nil { return wrapError(StatusNetworkError, err) } bd := make([]byte, m.BodyLen) _, err = ...
[ "func", "(", "sc", "*", "serverConn", ")", "recv", "(", "m", "*", "msg", ")", "error", "{", "// Make sure read does not block forever", "sc", ".", "conn", ".", "SetReadDeadline", "(", "time", ".", "Now", "(", ")", ".", "Add", "(", "sc", ".", "config", ...
// recv receives a memcached response. It takes a msg into which to store the // response.
[ "recv", "receives", "a", "memcached", "response", ".", "It", "takes", "a", "msg", "into", "which", "to", "store", "the", "response", "." ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/server_conn.go#L230-L260
144,591
memcachier/mc
server_conn.go
sizeOfExtras
func sizeOfExtras(extras []interface{}) (l uint8) { for _, e := range extras { switch e.(type) { default: panic(fmt.Sprintf("mc: unknown extra type (%T)", e)) case uint8: l += 8 / 8 case uint16: l += 16 / 8 case uint32: l += 32 / 8 case uint64: l += 64 / 8 } } return }
go
func sizeOfExtras(extras []interface{}) (l uint8) { for _, e := range extras { switch e.(type) { default: panic(fmt.Sprintf("mc: unknown extra type (%T)", e)) case uint8: l += 8 / 8 case uint16: l += 16 / 8 case uint32: l += 32 / 8 case uint64: l += 64 / 8 } } return }
[ "func", "sizeOfExtras", "(", "extras", "[", "]", "interface", "{", "}", ")", "(", "l", "uint8", ")", "{", "for", "_", ",", "e", ":=", "range", "extras", "{", "switch", "e", ".", "(", "type", ")", "{", "default", ":", "panic", "(", "fmt", ".", "...
// sizeOfExtras returns the size of the extras field for the memcache request.
[ "sizeOfExtras", "returns", "the", "size", "of", "the", "extras", "field", "for", "the", "memcache", "request", "." ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/server_conn.go#L263-L279
144,592
memcachier/mc
server_conn.go
resetConn
func (sc *serverConn) resetConn(err error) { if err.(*Error).Status == StatusNetworkError { sc.conn.Close() sc.conn = nil } }
go
func (sc *serverConn) resetConn(err error) { if err.(*Error).Status == StatusNetworkError { sc.conn.Close() sc.conn = nil } }
[ "func", "(", "sc", "*", "serverConn", ")", "resetConn", "(", "err", "error", ")", "{", "if", "err", ".", "(", "*", "Error", ")", ".", "Status", "==", "StatusNetworkError", "{", "sc", ".", "conn", ".", "Close", "(", ")", "\n", "sc", ".", "conn", "...
// resetConn destroy connection if a network error ocurred. serverConn will // reconnect on next usage.
[ "resetConn", "destroy", "connection", "if", "a", "network", "error", "ocurred", ".", "serverConn", "will", "reconnect", "on", "next", "usage", "." ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/server_conn.go#L283-L288
144,593
memcachier/mc
protocol.go
newError
func newError(status uint16) error { switch status { case StatusOK: return nil case StatusNotFound: return ErrNotFound case StatusKeyExists: return ErrKeyExists case StatusValueTooLarge: return ErrValueTooLarge case StatusInvalidArgs: return ErrInvalidArgs case StatusValueNotStored: return ErrValueNo...
go
func newError(status uint16) error { switch status { case StatusOK: return nil case StatusNotFound: return ErrNotFound case StatusKeyExists: return ErrKeyExists case StatusValueTooLarge: return ErrValueTooLarge case StatusInvalidArgs: return ErrInvalidArgs case StatusValueNotStored: return ErrValueNo...
[ "func", "newError", "(", "status", "uint16", ")", "error", "{", "switch", "status", "{", "case", "StatusOK", ":", "return", "nil", "\n", "case", "StatusNotFound", ":", "return", "ErrNotFound", "\n", "case", "StatusKeyExists", ":", "return", "ErrKeyExists", "\n...
// newError takes a status from the server and creates a matching Error.
[ "newError", "takes", "a", "status", "from", "the", "server", "and", "creates", "a", "matching", "Error", "." ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/protocol.go#L61-L90
144,594
memcachier/mc
protocol.go
wrapError
func wrapError(status uint16, err error) error { return &Error{status, err.Error(), err} }
go
func wrapError(status uint16, err error) error { return &Error{status, err.Error(), err} }
[ "func", "wrapError", "(", "status", "uint16", ",", "err", "error", ")", "error", "{", "return", "&", "Error", "{", "status", ",", "err", ".", "Error", "(", ")", ",", "err", "}", "\n", "}" ]
// wrapError wraps an existing error in an Error value.
[ "wrapError", "wraps", "an", "existing", "error", "in", "an", "Error", "value", "." ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/protocol.go#L93-L95
144,595
memcachier/mc
client.go
NewMC
func NewMC(servers, username, password string) *Client { return NewMCwithConfig(servers, username, password, DefaultConfig()) }
go
func NewMC(servers, username, password string) *Client { return NewMCwithConfig(servers, username, password, DefaultConfig()) }
[ "func", "NewMC", "(", "servers", ",", "username", ",", "password", "string", ")", "*", "Client", "{", "return", "NewMCwithConfig", "(", "servers", ",", "username", ",", "password", ",", "DefaultConfig", "(", ")", ")", "\n", "}" ]
// NewMC creates a new client with the default configuration. For the default // configuration see DefaultConfig.
[ "NewMC", "creates", "a", "new", "client", "with", "the", "default", "configuration", ".", "For", "the", "default", "configuration", "see", "DefaultConfig", "." ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L67-L69
144,596
memcachier/mc
client.go
NewMCwithConfig
func NewMCwithConfig(servers, username, password string, config *Config) *Client { return newMockableMC(servers, username, password, config, newServerConn) }
go
func NewMCwithConfig(servers, username, password string, config *Config) *Client { return newMockableMC(servers, username, password, config, newServerConn) }
[ "func", "NewMCwithConfig", "(", "servers", ",", "username", ",", "password", "string", ",", "config", "*", "Config", ")", "*", "Client", "{", "return", "newMockableMC", "(", "servers", ",", "username", ",", "password", ",", "config", ",", "newServerConn", ")...
// NewMCwithConfig creates a new client for a given configuration
[ "NewMCwithConfig", "creates", "a", "new", "client", "for", "a", "given", "configuration" ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L72-L74
144,597
memcachier/mc
client.go
newMockableMC
func newMockableMC(servers, username, password string, config *Config, newMcConn connGen) *Client { client := &Client{config: config} s := func(r rune) bool { return r == ',' || r == ';' || r == ' ' } serverList := strings.FieldsFunc(servers, s) for _, addr := range serverList { client.servers = append(client...
go
func newMockableMC(servers, username, password string, config *Config, newMcConn connGen) *Client { client := &Client{config: config} s := func(r rune) bool { return r == ',' || r == ';' || r == ' ' } serverList := strings.FieldsFunc(servers, s) for _, addr := range serverList { client.servers = append(client...
[ "func", "newMockableMC", "(", "servers", ",", "username", ",", "password", "string", ",", "config", "*", "Config", ",", "newMcConn", "connGen", ")", "*", "Client", "{", "client", ":=", "&", "Client", "{", "config", ":", "config", "}", "\n\n", "s", ":=", ...
// newMockableMC creates a new client for testing that allows to mock the server // connection
[ "newMockableMC", "creates", "a", "new", "client", "for", "testing", "that", "allows", "to", "mock", "the", "server", "connection" ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L78-L93
144,598
memcachier/mc
client.go
Get
func (c *Client) Get(key string) (val string, flags uint32, cas uint64, err error) { // Variants: [R] Get [Q, K, KQ] // Request : MUST key; MUST NOT value, extras // Response: MAY key, value, extras ([0..3] flags) return c.getCAS(key, 0) }
go
func (c *Client) Get(key string) (val string, flags uint32, cas uint64, err error) { // Variants: [R] Get [Q, K, KQ] // Request : MUST key; MUST NOT value, extras // Response: MAY key, value, extras ([0..3] flags) return c.getCAS(key, 0) }
[ "func", "(", "c", "*", "Client", ")", "Get", "(", "key", "string", ")", "(", "val", "string", ",", "flags", "uint32", ",", "cas", "uint64", ",", "err", "error", ")", "{", "// Variants: [R] Get [Q, K, KQ]", "// Request : MUST key; MUST NOT value, extras", "// Res...
// Get retrieves a value from the cache.
[ "Get", "retrieves", "a", "value", "from", "the", "cache", "." ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L136-L141
144,599
memcachier/mc
client.go
Incr
func (c *Client) Incr(key string, delta, init uint64, exp uint32, ocas uint64) (n, cas uint64, err error) { return c.incrdecr(opIncrement, key, delta, init, exp, ocas) }
go
func (c *Client) Incr(key string, delta, init uint64, exp uint32, ocas uint64) (n, cas uint64, err error) { return c.incrdecr(opIncrement, key, delta, init, exp, ocas) }
[ "func", "(", "c", "*", "Client", ")", "Incr", "(", "key", "string", ",", "delta", ",", "init", "uint64", ",", "exp", "uint32", ",", "ocas", "uint64", ")", "(", "n", ",", "cas", "uint64", ",", "err", "error", ")", "{", "return", "c", ".", "incrdec...
// Incr increments a value in the cache. The value must be an unsigned 64bit // integer stored as an ASCII string. It will wrap when incremented outside the // range.
[ "Incr", "increments", "a", "value", "in", "the", "cache", ".", "The", "value", "must", "be", "an", "unsigned", "64bit", "integer", "stored", "as", "an", "ASCII", "string", ".", "It", "will", "wrap", "when", "incremented", "outside", "the", "range", "." ]
5d1620e2c6d86be00ea70065e3c1301ee1cb1894
https://github.com/memcachier/mc/blob/5d1620e2c6d86be00ea70065e3c1301ee1cb1894/client.go#L242-L244