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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
138,700
pilosa/pdk
kafkagen/kafkagen.go
Run
func (m *Main) Run() error { conf := sarama.NewConfig() conf.Version = sarama.V0_10_0_0 conf.Producer.Return.Successes = true producer, err := sarama.NewSyncProducer(m.Hosts, conf) if err != nil { return errors.Wrap(err, "getting new producer") } defer producer.Close() for ticker := time.NewTicker(m.Rate); t...
go
func (m *Main) Run() error { conf := sarama.NewConfig() conf.Version = sarama.V0_10_0_0 conf.Producer.Return.Successes = true producer, err := sarama.NewSyncProducer(m.Hosts, conf) if err != nil { return errors.Wrap(err, "getting new producer") } defer producer.Close() for ticker := time.NewTicker(m.Rate); t...
[ "func", "(", "m", "*", "Main", ")", "Run", "(", ")", "error", "{", "conf", ":=", "sarama", ".", "NewConfig", "(", ")", "\n", "conf", ".", "Version", "=", "sarama", ".", "V0_10_0_0", "\n", "conf", ".", "Producer", ".", "Return", ".", "Successes", "=...
// Run runs the kafka generator.
[ "Run", "runs", "the", "kafka", "generator", "." ]
bba49352d71e5c23dc4a2c0d3ea08d8560678e1a
https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/kafkagen/kafkagen.go#L82-L102
138,701
pilosa/pdk
parser.go
Subject
func (p SubjectPath) Subject(e *Entity) (string, error) { var next Object = e var prev *Entity var item string for _, item = range p { ent, ok := next.(*Entity) if !ok { return "", errors.Errorf("can't get '%v' out of non-entity %#v.", item, next) } prev = ent next = ent.Objects[Property(item)] } del...
go
func (p SubjectPath) Subject(e *Entity) (string, error) { var next Object = e var prev *Entity var item string for _, item = range p { ent, ok := next.(*Entity) if !ok { return "", errors.Errorf("can't get '%v' out of non-entity %#v.", item, next) } prev = ent next = ent.Objects[Property(item)] } del...
[ "func", "(", "p", "SubjectPath", ")", "Subject", "(", "e", "*", "Entity", ")", "(", "string", ",", "error", ")", "{", "var", "next", "Object", "=", "e", "\n", "var", "prev", "*", "Entity", "\n", "var", "item", "string", "\n", "for", "_", ",", "it...
// Subject implements EntitySubjecter.
[ "Subject", "implements", "EntitySubjecter", "." ]
bba49352d71e5c23dc4a2c0d3ea08d8560678e1a
https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/parser.go#L73-L96
138,702
pilosa/pdk
parser.go
NewDefaultGenericParser
func NewDefaultGenericParser() *GenericParser { return &GenericParser{ Subjecter: BlankSubjecter{}, // Reasonable defaults for crosscutting dependencies. Stats: termstat.NewCollector(os.Stdout), Log: StdLogger{log.New(os.Stderr, "Ingest", log.LstdFlags)}, } }
go
func NewDefaultGenericParser() *GenericParser { return &GenericParser{ Subjecter: BlankSubjecter{}, // Reasonable defaults for crosscutting dependencies. Stats: termstat.NewCollector(os.Stdout), Log: StdLogger{log.New(os.Stderr, "Ingest", log.LstdFlags)}, } }
[ "func", "NewDefaultGenericParser", "(", ")", "*", "GenericParser", "{", "return", "&", "GenericParser", "{", "Subjecter", ":", "BlankSubjecter", "{", "}", ",", "// Reasonable defaults for crosscutting dependencies.", "Stats", ":", "termstat", ".", "NewCollector", "(", ...
// NewDefaultGenericParser returns a GenericParser with basic implementations of // its components. In order to track the mapping of Pilosa columns to records, // you must replace the Subjecter with something other than a BlankSubjecter.
[ "NewDefaultGenericParser", "returns", "a", "GenericParser", "with", "basic", "implementations", "of", "its", "components", ".", "In", "order", "to", "track", "the", "mapping", "of", "Pilosa", "columns", "to", "records", "you", "must", "replace", "the", "Subjecter"...
bba49352d71e5c23dc4a2c0d3ea08d8560678e1a
https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/parser.go#L121-L129
138,703
pilosa/pdk
parser.go
Parse
func (m *GenericParser) Parse(data interface{}) (e *Entity, err error) { val := reflect.ValueOf(data) // dereference pointers, and get concrete values from interfaces val = deref(val) // Map and Struct are the only valid Kinds at the top level. switch val.Kind() { case reflect.Map: e, err = m.parseMap(val) cas...
go
func (m *GenericParser) Parse(data interface{}) (e *Entity, err error) { val := reflect.ValueOf(data) // dereference pointers, and get concrete values from interfaces val = deref(val) // Map and Struct are the only valid Kinds at the top level. switch val.Kind() { case reflect.Map: e, err = m.parseMap(val) cas...
[ "func", "(", "m", "*", "GenericParser", ")", "Parse", "(", "data", "interface", "{", "}", ")", "(", "e", "*", "Entity", ",", "err", "error", ")", "{", "val", ":=", "reflect", ".", "ValueOf", "(", "data", ")", "\n", "// dereference pointers, and get concr...
// Parse of the GenericParser tries to parse any value into a pdk.Entity.
[ "Parse", "of", "the", "GenericParser", "tries", "to", "parse", "any", "value", "into", "a", "pdk", ".", "Entity", "." ]
bba49352d71e5c23dc4a2c0d3ea08d8560678e1a
https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/parser.go#L132-L158
138,704
pilosa/pdk
parser.go
parseContainer
func (m *GenericParser) parseContainer(val reflect.Value) (Object, error) { if dtype := val.Type(); dtype.Elem().Kind() == reflect.Uint8 { if dtype.Kind() == reflect.Slice { return S(val.Bytes()), nil } else if dtype.Kind() == reflect.Array { ret := make([]byte, dtype.Len()) for i := 0; i < dtype.Len(); i...
go
func (m *GenericParser) parseContainer(val reflect.Value) (Object, error) { if dtype := val.Type(); dtype.Elem().Kind() == reflect.Uint8 { if dtype.Kind() == reflect.Slice { return S(val.Bytes()), nil } else if dtype.Kind() == reflect.Array { ret := make([]byte, dtype.Len()) for i := 0; i < dtype.Len(); i...
[ "func", "(", "m", "*", "GenericParser", ")", "parseContainer", "(", "val", "reflect", ".", "Value", ")", "(", "Object", ",", "error", ")", "{", "if", "dtype", ":=", "val", ".", "Type", "(", ")", ";", "dtype", ".", "Elem", "(", ")", ".", "Kind", "...
// parseContainer parses arrays and slices.
[ "parseContainer", "parses", "arrays", "and", "slices", "." ]
bba49352d71e5c23dc4a2c0d3ea08d8560678e1a
https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/parser.go#L264-L290
138,705
pilosa/pdk
parser.go
anyImplements
func anyImplements(thing reflect.Value, iface reflect.Type) (reflect.Value, bool) { if thing.Type().Implements(iface) { return thing, true } else if thing.CanAddr() && reflect.PtrTo(thing.Type()).Implements(iface) { return thing.Addr(), true } return reflect.Value{}, false }
go
func anyImplements(thing reflect.Value, iface reflect.Type) (reflect.Value, bool) { if thing.Type().Implements(iface) { return thing, true } else if thing.CanAddr() && reflect.PtrTo(thing.Type()).Implements(iface) { return thing.Addr(), true } return reflect.Value{}, false }
[ "func", "anyImplements", "(", "thing", "reflect", ".", "Value", ",", "iface", "reflect", ".", "Type", ")", "(", "reflect", ".", "Value", ",", "bool", ")", "{", "if", "thing", ".", "Type", "(", ")", ".", "Implements", "(", "iface", ")", "{", "return",...
// anyImplements determines whether an interface is implemented by a value, or a // pointer to that value. It returns a potentially new value which can be cast // to the interface, and a boolean. If the boolean is false, the value will be // the zero value, and cannot be cast to the interface.
[ "anyImplements", "determines", "whether", "an", "interface", "is", "implemented", "by", "a", "value", "or", "a", "pointer", "to", "that", "value", ".", "It", "returns", "a", "potentially", "new", "value", "which", "can", "be", "cast", "to", "the", "interface...
bba49352d71e5c23dc4a2c0d3ea08d8560678e1a
https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/parser.go#L360-L367
138,706
pilosa/pdk
parser.go
getProperty
func (m *GenericParser) getProperty(mapKey reflect.Value) (Property, error) { properteerType := reflect.TypeOf(new(Properteer)).Elem() stringerType := reflect.TypeOf(new(fmt.Stringer)).Elem() // if mapKey implements the pdk.Properteer interface, use that. if k2, ok := anyImplements(mapKey, properteerType); ok { ...
go
func (m *GenericParser) getProperty(mapKey reflect.Value) (Property, error) { properteerType := reflect.TypeOf(new(Properteer)).Elem() stringerType := reflect.TypeOf(new(fmt.Stringer)).Elem() // if mapKey implements the pdk.Properteer interface, use that. if k2, ok := anyImplements(mapKey, properteerType); ok { ...
[ "func", "(", "m", "*", "GenericParser", ")", "getProperty", "(", "mapKey", "reflect", ".", "Value", ")", "(", "Property", ",", "error", ")", "{", "properteerType", ":=", "reflect", ".", "TypeOf", "(", "new", "(", "Properteer", ")", ")", ".", "Elem", "(...
// getProperty turns anything that can be a map key into a string. Exceptions // are channels, interface values whose dynamic types are channels, structs // which contain channels, and pointers to any of these things.
[ "getProperty", "turns", "anything", "that", "can", "be", "a", "map", "key", "into", "a", "string", ".", "Exceptions", "are", "channels", "interface", "values", "whose", "dynamic", "types", "are", "channels", "structs", "which", "contain", "channels", "and", "p...
bba49352d71e5c23dc4a2c0d3ea08d8560678e1a
https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/parser.go#L372-L406
138,707
pilosa/pdk
cmd/userid.go
NewUseridCommand
func NewUseridCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { var err error UseridMain = userid.NewMain() useridCommand := &cobra.Command{ Use: "userid", Short: "Adds a user ID field to an existing index and associates an ID with each column.", RunE: func(cmd *cobra.Command, args []string...
go
func NewUseridCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { var err error UseridMain = userid.NewMain() useridCommand := &cobra.Command{ Use: "userid", Short: "Adds a user ID field to an existing index and associates an ID with each column.", RunE: func(cmd *cobra.Command, args []string...
[ "func", "NewUseridCommand", "(", "stdin", "io", ".", "Reader", ",", "stdout", ",", "stderr", "io", ".", "Writer", ")", "*", "cobra", ".", "Command", "{", "var", "err", "error", "\n", "UseridMain", "=", "userid", ".", "NewMain", "(", ")", "\n", "useridC...
// NewUseridCommand returns a new cobra command wrapping UseridMain.
[ "NewUseridCommand", "returns", "a", "new", "cobra", "command", "wrapping", "UseridMain", "." ]
bba49352d71e5c23dc4a2c0d3ea08d8560678e1a
https://github.com/pilosa/pdk/blob/bba49352d71e5c23dc4a2c0d3ea08d8560678e1a/cmd/userid.go#L17-L39
138,708
qedus/nds
put.go
PutMulti
func PutMulti(c context.Context, keys []*datastore.Key, vals interface{}) ([]*datastore.Key, error) { if len(keys) == 0 { return nil, nil } v := reflect.ValueOf(vals) if err := checkKeysValues(keys, v); err != nil { return nil, err } callCount := (len(keys)-1)/putMultiLimit + 1 putKeys := make([][]*datas...
go
func PutMulti(c context.Context, keys []*datastore.Key, vals interface{}) ([]*datastore.Key, error) { if len(keys) == 0 { return nil, nil } v := reflect.ValueOf(vals) if err := checkKeysValues(keys, v); err != nil { return nil, err } callCount := (len(keys)-1)/putMultiLimit + 1 putKeys := make([][]*datas...
[ "func", "PutMulti", "(", "c", "context", ".", "Context", ",", "keys", "[", "]", "*", "datastore", ".", "Key", ",", "vals", "interface", "{", "}", ")", "(", "[", "]", "*", "datastore", ".", "Key", ",", "error", ")", "{", "if", "len", "(", "keys", ...
// PutMulti is a batch version of Put. It works just like datastore.PutMulti // except it interacts appropriately with NDS's caching strategy. It also // removes the API limit of 500 entities per request by calling the datastore as // many times as required to put all the keys. It does this efficiently and // concurren...
[ "PutMulti", "is", "a", "batch", "version", "of", "Put", ".", "It", "works", "just", "like", "datastore", ".", "PutMulti", "except", "it", "interacts", "appropriately", "with", "NDS", "s", "caching", "strategy", ".", "It", "also", "removes", "the", "API", "...
304641cf4f9b2d8041f40a5c804e9ffca11fc746
https://github.com/qedus/nds/blob/304641cf4f9b2d8041f40a5c804e9ffca11fc746/put.go#L23-L92
138,709
qedus/nds
put.go
Put
func Put(c context.Context, key *datastore.Key, val interface{}) (*datastore.Key, error) { keys := []*datastore.Key{key} vals := []interface{}{val} if err := checkKeysValues(keys, reflect.ValueOf(vals)); err != nil { return nil, err } keys, err := putMulti(c, keys, vals) switch e := err.(type) { case nil: ...
go
func Put(c context.Context, key *datastore.Key, val interface{}) (*datastore.Key, error) { keys := []*datastore.Key{key} vals := []interface{}{val} if err := checkKeysValues(keys, reflect.ValueOf(vals)); err != nil { return nil, err } keys, err := putMulti(c, keys, vals) switch e := err.(type) { case nil: ...
[ "func", "Put", "(", "c", "context", ".", "Context", ",", "key", "*", "datastore", ".", "Key", ",", "val", "interface", "{", "}", ")", "(", "*", "datastore", ".", "Key", ",", "error", ")", "{", "keys", ":=", "[", "]", "*", "datastore", ".", "Key",...
// Put saves the entity val into the datastore with key. val must be a struct // pointer; if a struct pointer then any unexported fields of that struct will // be skipped. If key is an incomplete key, the returned key will be a unique // key generated by the datastore.
[ "Put", "saves", "the", "entity", "val", "into", "the", "datastore", "with", "key", ".", "val", "must", "be", "a", "struct", "pointer", ";", "if", "a", "struct", "pointer", "then", "any", "unexported", "fields", "of", "that", "struct", "will", "be", "skip...
304641cf4f9b2d8041f40a5c804e9ffca11fc746
https://github.com/qedus/nds/blob/304641cf4f9b2d8041f40a5c804e9ffca11fc746/put.go#L98-L116
138,710
qedus/nds
put.go
putMulti
func putMulti(c context.Context, keys []*datastore.Key, vals interface{}) ([]*datastore.Key, error) { lockMemcacheKeys := make([]string, 0, len(keys)) lockMemcacheItems := make([]*memcache.Item, 0, len(keys)) for _, key := range keys { if !key.Incomplete() { item := &memcache.Item{ Key: createMemca...
go
func putMulti(c context.Context, keys []*datastore.Key, vals interface{}) ([]*datastore.Key, error) { lockMemcacheKeys := make([]string, 0, len(keys)) lockMemcacheItems := make([]*memcache.Item, 0, len(keys)) for _, key := range keys { if !key.Incomplete() { item := &memcache.Item{ Key: createMemca...
[ "func", "putMulti", "(", "c", "context", ".", "Context", ",", "keys", "[", "]", "*", "datastore", ".", "Key", ",", "vals", "interface", "{", "}", ")", "(", "[", "]", "*", "datastore", ".", "Key", ",", "error", ")", "{", "lockMemcacheKeys", ":=", "m...
// putMulti puts the entities into the datastore and then its local cache.
[ "putMulti", "puts", "the", "entities", "into", "the", "datastore", "and", "then", "its", "local", "cache", "." ]
304641cf4f9b2d8041f40a5c804e9ffca11fc746
https://github.com/qedus/nds/blob/304641cf4f9b2d8041f40a5c804e9ffca11fc746/put.go#L119-L164
138,711
qedus/nds
delete.go
DeleteMulti
func DeleteMulti(c context.Context, keys []*datastore.Key) error { callCount := (len(keys)-1)/deleteMultiLimit + 1 errs := make([]error, callCount) var wg sync.WaitGroup wg.Add(callCount) for i := 0; i < callCount; i++ { lo := i * deleteMultiLimit hi := (i + 1) * deleteMultiLimit if hi > len(keys) { hi ...
go
func DeleteMulti(c context.Context, keys []*datastore.Key) error { callCount := (len(keys)-1)/deleteMultiLimit + 1 errs := make([]error, callCount) var wg sync.WaitGroup wg.Add(callCount) for i := 0; i < callCount; i++ { lo := i * deleteMultiLimit hi := (i + 1) * deleteMultiLimit if hi > len(keys) { hi ...
[ "func", "DeleteMulti", "(", "c", "context", ".", "Context", ",", "keys", "[", "]", "*", "datastore", ".", "Key", ")", "error", "{", "callCount", ":=", "(", "len", "(", "keys", ")", "-", "1", ")", "/", "deleteMultiLimit", "+", "1", "\n", "errs", ":=...
// DeleteMulti works just like datastore.DeleteMulti except it maintains // cache consistency with other NDS methods. It also removes the API limit of // 500 entities per request by calling the datastore as many times as required // to put all the keys. It does this efficiently and concurrently.
[ "DeleteMulti", "works", "just", "like", "datastore", ".", "DeleteMulti", "except", "it", "maintains", "cache", "consistency", "with", "other", "NDS", "methods", ".", "It", "also", "removes", "the", "API", "limit", "of", "500", "entities", "per", "request", "by...
304641cf4f9b2d8041f40a5c804e9ffca11fc746
https://github.com/qedus/nds/blob/304641cf4f9b2d8041f40a5c804e9ffca11fc746/delete.go#L20-L46
138,712
qedus/nds
transaction.go
RunInTransaction
func RunInTransaction(c context.Context, f func(tc context.Context) error, opts *datastore.TransactionOptions) error { return datastore.RunInTransaction(c, func(tc context.Context) error { tx := &transaction{} tc = context.WithValue(tc, &transactionKey, tx) if err := f(tc); err != nil { return err } //...
go
func RunInTransaction(c context.Context, f func(tc context.Context) error, opts *datastore.TransactionOptions) error { return datastore.RunInTransaction(c, func(tc context.Context) error { tx := &transaction{} tc = context.WithValue(tc, &transactionKey, tx) if err := f(tc); err != nil { return err } //...
[ "func", "RunInTransaction", "(", "c", "context", ".", "Context", ",", "f", "func", "(", "tc", "context", ".", "Context", ")", "error", ",", "opts", "*", "datastore", ".", "TransactionOptions", ")", "error", "{", "return", "datastore", ".", "RunInTransaction"...
// RunInTransaction works just like datastore.RunInTransaction however it // interacts correctly with memcache. You should always use this method for // transactions if you are using the NDS package.
[ "RunInTransaction", "works", "just", "like", "datastore", ".", "RunInTransaction", "however", "it", "interacts", "correctly", "with", "memcache", ".", "You", "should", "always", "use", "this", "method", "for", "transactions", "if", "you", "are", "using", "the", ...
304641cf4f9b2d8041f40a5c804e9ffca11fc746
https://github.com/qedus/nds/blob/304641cf4f9b2d8041f40a5c804e9ffca11fc746/transaction.go#L26-L45
138,713
qedus/nds
get.go
Get
func Get(c context.Context, key *datastore.Key, val interface{}) error { // GetMulti catches nil interface; we need to catch nil ptr here. if val == nil { return datastore.ErrInvalidEntityType } err := GetMulti(c, []*datastore.Key{key}, []interface{}{val}) if me, ok := err.(appengine.MultiError); ok { return ...
go
func Get(c context.Context, key *datastore.Key, val interface{}) error { // GetMulti catches nil interface; we need to catch nil ptr here. if val == nil { return datastore.ErrInvalidEntityType } err := GetMulti(c, []*datastore.Key{key}, []interface{}{val}) if me, ok := err.(appengine.MultiError); ok { return ...
[ "func", "Get", "(", "c", "context", ".", "Context", ",", "key", "*", "datastore", ".", "Key", ",", "val", "interface", "{", "}", ")", "error", "{", "// GetMulti catches nil interface; we need to catch nil ptr here.", "if", "val", "==", "nil", "{", "return", "d...
// Get loads the entity stored for key into val, which must be a struct pointer. // Currently PropertyLoadSaver is not implemented. If there is no such entity // for the key, Get returns ErrNoSuchEntity. // // The values of val's unmatched struct fields are not modified, and matching // slice-typed fields are not reset...
[ "Get", "loads", "the", "entity", "stored", "for", "key", "into", "val", "which", "must", "be", "a", "struct", "pointer", ".", "Currently", "PropertyLoadSaver", "is", "not", "implemented", ".", "If", "there", "is", "no", "such", "entity", "for", "the", "key...
304641cf4f9b2d8041f40a5c804e9ffca11fc746
https://github.com/qedus/nds/blob/304641cf4f9b2d8041f40a5c804e9ffca11fc746/get.go#L107-L118
138,714
hekmon/transmissionrpc
torrent_accessors.go
TorrentGetAll
func (c *Client) TorrentGetAll() (torrents []*Torrent, err error) { // Send already validated fields to the low level fx return c.torrentGet(validTorrentFields, nil) }
go
func (c *Client) TorrentGetAll() (torrents []*Torrent, err error) { // Send already validated fields to the low level fx return c.torrentGet(validTorrentFields, nil) }
[ "func", "(", "c", "*", "Client", ")", "TorrentGetAll", "(", ")", "(", "torrents", "[", "]", "*", "Torrent", ",", "err", "error", ")", "{", "// Send already validated fields to the low level fx", "return", "c", ".", "torrentGet", "(", "validTorrentFields", ",", ...
// TorrentGetAll returns all the known fields for all the torrents.
[ "TorrentGetAll", "returns", "all", "the", "known", "fields", "for", "all", "the", "torrents", "." ]
4352aea9f1b8457261dc9b03e8d32ced8fa1a471
https://github.com/hekmon/transmissionrpc/blob/4352aea9f1b8457261dc9b03e8d32ced8fa1a471/torrent_accessors.go#L27-L30
138,715
hekmon/transmissionrpc
torrent_accessors.go
TorrentGetAllFor
func (c *Client) TorrentGetAllFor(ids []int64) (torrents []*Torrent, err error) { return c.torrentGet(validTorrentFields, ids) }
go
func (c *Client) TorrentGetAllFor(ids []int64) (torrents []*Torrent, err error) { return c.torrentGet(validTorrentFields, ids) }
[ "func", "(", "c", "*", "Client", ")", "TorrentGetAllFor", "(", "ids", "[", "]", "int64", ")", "(", "torrents", "[", "]", "*", "Torrent", ",", "err", "error", ")", "{", "return", "c", ".", "torrentGet", "(", "validTorrentFields", ",", "ids", ")", "\n"...
// TorrentGetAllFor returns all known fields for the given torrent's ids.
[ "TorrentGetAllFor", "returns", "all", "known", "fields", "for", "the", "given", "torrent", "s", "ids", "." ]
4352aea9f1b8457261dc9b03e8d32ced8fa1a471
https://github.com/hekmon/transmissionrpc/blob/4352aea9f1b8457261dc9b03e8d32ced8fa1a471/torrent_accessors.go#L33-L35
138,716
hekmon/transmissionrpc
controller.go
New
func New(host, user, password string, conf *AdvancedConfig) (c *Client, err error) { // Config if conf != nil { // Check custom config if conf.Port == 0 { conf.Port = defaultPort } if conf.RPCURI == "" { conf.RPCURI = defaultRPCPath } if conf.HTTPTimeout == 0 { conf.HTTPTimeout = defaultTimeout ...
go
func New(host, user, password string, conf *AdvancedConfig) (c *Client, err error) { // Config if conf != nil { // Check custom config if conf.Port == 0 { conf.Port = defaultPort } if conf.RPCURI == "" { conf.RPCURI = defaultRPCPath } if conf.HTTPTimeout == 0 { conf.HTTPTimeout = defaultTimeout ...
[ "func", "New", "(", "host", ",", "user", ",", "password", "string", ",", "conf", "*", "AdvancedConfig", ")", "(", "c", "*", "Client", ",", "err", "error", ")", "{", "// Config", "if", "conf", "!=", "nil", "{", "// Check custom config", "if", "conf", "....
// New returns an initialized and ready to use Controller
[ "New", "returns", "an", "initialized", "and", "ready", "to", "use", "Controller" ]
4352aea9f1b8457261dc9b03e8d32ced8fa1a471
https://github.com/hekmon/transmissionrpc/blob/4352aea9f1b8457261dc9b03e8d32ced8fa1a471/controller.go#L46-L96
138,717
hekmon/transmissionrpc
session_arguments.go
GetSpeed
func (u *Units) GetSpeed() (speed cunits.Bits) { return cunits.ImportInByte(float64(u.SpeedBytes)) }
go
func (u *Units) GetSpeed() (speed cunits.Bits) { return cunits.ImportInByte(float64(u.SpeedBytes)) }
[ "func", "(", "u", "*", "Units", ")", "GetSpeed", "(", ")", "(", "speed", "cunits", ".", "Bits", ")", "{", "return", "cunits", ".", "ImportInByte", "(", "float64", "(", "u", ".", "SpeedBytes", ")", ")", "\n", "}" ]
// GetSpeed returns the speed in a handy format
[ "GetSpeed", "returns", "the", "speed", "in", "a", "handy", "format" ]
4352aea9f1b8457261dc9b03e8d32ced8fa1a471
https://github.com/hekmon/transmissionrpc/blob/4352aea9f1b8457261dc9b03e8d32ced8fa1a471/session_arguments.go#L152-L154
138,718
hekmon/transmissionrpc
session_arguments.go
GetSize
func (u *Units) GetSize() (size cunits.Bits) { return cunits.ImportInByte(float64(u.SizeBytes)) }
go
func (u *Units) GetSize() (size cunits.Bits) { return cunits.ImportInByte(float64(u.SizeBytes)) }
[ "func", "(", "u", "*", "Units", ")", "GetSize", "(", ")", "(", "size", "cunits", ".", "Bits", ")", "{", "return", "cunits", ".", "ImportInByte", "(", "float64", "(", "u", ".", "SizeBytes", ")", ")", "\n", "}" ]
// GetSize returns the size in a handy format
[ "GetSize", "returns", "the", "size", "in", "a", "handy", "format" ]
4352aea9f1b8457261dc9b03e8d32ced8fa1a471
https://github.com/hekmon/transmissionrpc/blob/4352aea9f1b8457261dc9b03e8d32ced8fa1a471/session_arguments.go#L157-L159
138,719
hekmon/transmissionrpc
session_arguments.go
GetMemory
func (u *Units) GetMemory() (memory cunits.Bits) { return cunits.ImportInByte(float64(u.MemoryBytes)) }
go
func (u *Units) GetMemory() (memory cunits.Bits) { return cunits.ImportInByte(float64(u.MemoryBytes)) }
[ "func", "(", "u", "*", "Units", ")", "GetMemory", "(", ")", "(", "memory", "cunits", ".", "Bits", ")", "{", "return", "cunits", ".", "ImportInByte", "(", "float64", "(", "u", ".", "MemoryBytes", ")", ")", "\n", "}" ]
// GetMemory returns the memory in a handy format
[ "GetMemory", "returns", "the", "memory", "in", "a", "handy", "format" ]
4352aea9f1b8457261dc9b03e8d32ced8fa1a471
https://github.com/hekmon/transmissionrpc/blob/4352aea9f1b8457261dc9b03e8d32ced8fa1a471/session_arguments.go#L162-L164
138,720
hekmon/transmissionrpc
session_stats.go
GetDownloaded
func (cs *CumulativeStats) GetDownloaded() (downloaded cunits.Bits) { return cunits.ImportInByte(float64(cs.DownloadedBytes)) }
go
func (cs *CumulativeStats) GetDownloaded() (downloaded cunits.Bits) { return cunits.ImportInByte(float64(cs.DownloadedBytes)) }
[ "func", "(", "cs", "*", "CumulativeStats", ")", "GetDownloaded", "(", ")", "(", "downloaded", "cunits", ".", "Bits", ")", "{", "return", "cunits", ".", "ImportInByte", "(", "float64", "(", "cs", ".", "DownloadedBytes", ")", ")", "\n", "}" ]
// GetDownloaded returns cumulative stats downloaded size in a handy format
[ "GetDownloaded", "returns", "cumulative", "stats", "downloaded", "size", "in", "a", "handy", "format" ]
4352aea9f1b8457261dc9b03e8d32ced8fa1a471
https://github.com/hekmon/transmissionrpc/blob/4352aea9f1b8457261dc9b03e8d32ced8fa1a471/session_stats.go#L46-L48
138,721
hekmon/transmissionrpc
session_stats.go
GetUploaded
func (cs *CumulativeStats) GetUploaded() (uploaded cunits.Bits) { return cunits.ImportInByte(float64(cs.UploadedBytes)) }
go
func (cs *CumulativeStats) GetUploaded() (uploaded cunits.Bits) { return cunits.ImportInByte(float64(cs.UploadedBytes)) }
[ "func", "(", "cs", "*", "CumulativeStats", ")", "GetUploaded", "(", ")", "(", "uploaded", "cunits", ".", "Bits", ")", "{", "return", "cunits", ".", "ImportInByte", "(", "float64", "(", "cs", ".", "UploadedBytes", ")", ")", "\n", "}" ]
// GetUploaded returns cumulative stats uploaded size in a handy format
[ "GetUploaded", "returns", "cumulative", "stats", "uploaded", "size", "in", "a", "handy", "format" ]
4352aea9f1b8457261dc9b03e8d32ced8fa1a471
https://github.com/hekmon/transmissionrpc/blob/4352aea9f1b8457261dc9b03e8d32ced8fa1a471/session_stats.go#L51-L53
138,722
alphazero/Go-Redis
future.go
send
func send(c chan result, v interface{}, e Error) { c <- result{v, e} }
go
func send(c chan result, v interface{}, e Error) { c <- result{v, e} }
[ "func", "send", "(", "c", "chan", "result", ",", "v", "interface", "{", "}", ",", "e", "Error", ")", "{", "c", "<-", "result", "{", "v", ",", "e", "}", "\n", "}" ]
// creates a result struct using the provided references // and sends it on the specified channel.
[ "creates", "a", "result", "struct", "using", "the", "provided", "references", "and", "sends", "it", "on", "the", "specified", "channel", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/future.go#L40-L42
138,723
alphazero/Go-Redis
synchclient.go
NewSynchClient
func NewSynchClient() (c Client, err Error) { spec := DefaultSpec() c, err = NewSynchClientWithSpec(spec) if err != nil { log.Println("NewSynchClientWithSpec raised error: ", err) } if c == nil { log.Println("NewSynchClientWithSpec returned nil Client.") err = newSystemError("NewSynchClientWithSpec returned ...
go
func NewSynchClient() (c Client, err Error) { spec := DefaultSpec() c, err = NewSynchClientWithSpec(spec) if err != nil { log.Println("NewSynchClientWithSpec raised error: ", err) } if c == nil { log.Println("NewSynchClientWithSpec returned nil Client.") err = newSystemError("NewSynchClientWithSpec returned ...
[ "func", "NewSynchClient", "(", ")", "(", "c", "Client", ",", "err", "Error", ")", "{", "spec", ":=", "DefaultSpec", "(", ")", "\n", "c", ",", "err", "=", "NewSynchClientWithSpec", "(", "spec", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "...
// Create a new syncClient and connects to the Redis server using the // default ConnectionSpec. //
[ "Create", "a", "new", "syncClient", "and", "connects", "to", "the", "Redis", "server", "using", "the", "default", "ConnectionSpec", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L36-L47
138,724
alphazero/Go-Redis
synchclient.go
NewSynchClientWithSpec
func NewSynchClientWithSpec(spec *ConnectionSpec) (c Client, err Error) { _c := new(syncClient) _c.conn, err = NewSyncConnection(spec) if err != nil { return nil, withError(err) } // _c.conn = conn return _c, nil }
go
func NewSynchClientWithSpec(spec *ConnectionSpec) (c Client, err Error) { _c := new(syncClient) _c.conn, err = NewSyncConnection(spec) if err != nil { return nil, withError(err) } // _c.conn = conn return _c, nil }
[ "func", "NewSynchClientWithSpec", "(", "spec", "*", "ConnectionSpec", ")", "(", "c", "Client", ",", "err", "Error", ")", "{", "_c", ":=", "new", "(", "syncClient", ")", "\n", "_c", ".", "conn", ",", "err", "=", "NewSyncConnection", "(", "spec", ")", "\...
// Create a new syncClient and connects to the Redis server using the // specified ConnectionSpec. //
[ "Create", "a", "new", "syncClient", "and", "connects", "to", "the", "Redis", "server", "using", "the", "specified", "ConnectionSpec", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L52-L60
138,725
alphazero/Go-Redis
synchclient.go
Get
func (c *syncClient) Get(arg0 string) (result []byte, err Error) { arg0bytes := []byte(arg0) var resp Response resp, err = c.conn.ServiceRequest(&GET, [][]byte{arg0bytes}) if err == nil { result = resp.GetBulkData() } return result, err }
go
func (c *syncClient) Get(arg0 string) (result []byte, err Error) { arg0bytes := []byte(arg0) var resp Response resp, err = c.conn.ServiceRequest(&GET, [][]byte{arg0bytes}) if err == nil { result = resp.GetBulkData() } return result, err }
[ "func", "(", "c", "*", "syncClient", ")", "Get", "(", "arg0", "string", ")", "(", "result", "[", "]", "byte", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n\n", "var", "resp", "Response", "\n", "resp", "...
// Redis GET command.
[ "Redis", "GET", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L73-L83
138,726
alphazero/Go-Redis
synchclient.go
Set
func (c *syncClient) Set(arg0 string, arg1 []byte) (err Error) { arg0bytes := []byte(arg0) arg1bytes := arg1 _, err = c.conn.ServiceRequest(&SET, [][]byte{arg0bytes, arg1bytes}) return }
go
func (c *syncClient) Set(arg0 string, arg1 []byte) (err Error) { arg0bytes := []byte(arg0) arg1bytes := arg1 _, err = c.conn.ServiceRequest(&SET, [][]byte{arg0bytes, arg1bytes}) return }
[ "func", "(", "c", "*", "syncClient", ")", "Set", "(", "arg0", "string", ",", "arg1", "[", "]", "byte", ")", "(", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1bytes", ":=", "arg1", "\n\n", "_", ",", ...
// Redis SET command.
[ "Redis", "SET", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L98-L104
138,727
alphazero/Go-Redis
synchclient.go
Mget
func (c *syncClient) Mget(arg0 string, arg1 []string) (result [][]byte, err Error) { args := appendAndConvert(arg0, arg1...) var resp Response resp, err = c.conn.ServiceRequest(&MGET, args) if err == nil { result = resp.GetMultiBulkData() } return result, err }
go
func (c *syncClient) Mget(arg0 string, arg1 []string) (result [][]byte, err Error) { args := appendAndConvert(arg0, arg1...) var resp Response resp, err = c.conn.ServiceRequest(&MGET, args) if err == nil { result = resp.GetMultiBulkData() } return result, err }
[ "func", "(", "c", "*", "syncClient", ")", "Mget", "(", "arg0", "string", ",", "arg1", "[", "]", "string", ")", "(", "result", "[", "]", "[", "]", "byte", ",", "err", "Error", ")", "{", "args", ":=", "appendAndConvert", "(", "arg0", ",", "arg1", "...
// Redis MGET command.
[ "Redis", "MGET", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L244-L252
138,728
alphazero/Go-Redis
synchclient.go
Decrby
func (c *syncClient) Decrby(arg0 string, arg1 int64) (result int64, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(fmt.Sprintf("%d", arg1)) var resp Response resp, err = c.conn.ServiceRequest(&DECRBY, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.GetNumberValue() } return result, e...
go
func (c *syncClient) Decrby(arg0 string, arg1 int64) (result int64, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(fmt.Sprintf("%d", arg1)) var resp Response resp, err = c.conn.ServiceRequest(&DECRBY, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.GetNumberValue() } return result, e...
[ "func", "(", "c", "*", "syncClient", ")", "Decrby", "(", "arg0", "string", ",", "arg1", "int64", ")", "(", "result", "int64", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1bytes", ":=", "[", "]", ...
// Redis DECRBY command.
[ "Redis", "DECRBY", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L295-L306
138,729
alphazero/Go-Redis
synchclient.go
Rpush
func (c *syncClient) Rpush(arg0 string, arg1 []byte) (err Error) { arg0bytes := []byte(arg0) arg1bytes := arg1 _, err = c.conn.ServiceRequest(&RPUSH, [][]byte{arg0bytes, arg1bytes}) return }
go
func (c *syncClient) Rpush(arg0 string, arg1 []byte) (err Error) { arg0bytes := []byte(arg0) arg1bytes := arg1 _, err = c.conn.ServiceRequest(&RPUSH, [][]byte{arg0bytes, arg1bytes}) return }
[ "func", "(", "c", "*", "syncClient", ")", "Rpush", "(", "arg0", "string", ",", "arg1", "[", "]", "byte", ")", "(", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1bytes", ":=", "arg1", "\n\n", "_", ",",...
// Redis RPUSH command.
[ "Redis", "RPUSH", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L385-L391
138,730
alphazero/Go-Redis
synchclient.go
Lpop
func (c *syncClient) Lpop(arg0 string) (result []byte, err Error) { arg0bytes := []byte(arg0) var resp Response resp, err = c.conn.ServiceRequest(&LPOP, [][]byte{arg0bytes}) if err == nil { result = resp.GetBulkData() } return result, err }
go
func (c *syncClient) Lpop(arg0 string) (result []byte, err Error) { arg0bytes := []byte(arg0) var resp Response resp, err = c.conn.ServiceRequest(&LPOP, [][]byte{arg0bytes}) if err == nil { result = resp.GetBulkData() } return result, err }
[ "func", "(", "c", "*", "syncClient", ")", "Lpop", "(", "arg0", "string", ")", "(", "result", "[", "]", "byte", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n\n", "var", "resp", "Response", "\n", "resp", ...
// Redis LPOP command.
[ "Redis", "LPOP", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L480-L490
138,731
alphazero/Go-Redis
synchclient.go
Rpop
func (c *syncClient) Rpop(arg0 string) (result []byte, err Error) { arg0bytes := []byte(arg0) var resp Response resp, err = c.conn.ServiceRequest(&RPOP, [][]byte{arg0bytes}) if err == nil { result = resp.GetBulkData() } return result, err }
go
func (c *syncClient) Rpop(arg0 string) (result []byte, err Error) { arg0bytes := []byte(arg0) var resp Response resp, err = c.conn.ServiceRequest(&RPOP, [][]byte{arg0bytes}) if err == nil { result = resp.GetBulkData() } return result, err }
[ "func", "(", "c", "*", "syncClient", ")", "Rpop", "(", "arg0", "string", ")", "(", "result", "[", "]", "byte", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n\n", "var", "resp", "Response", "\n", "resp", ...
// Redis RPOP command.
[ "Redis", "RPOP", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L507-L517
138,732
alphazero/Go-Redis
synchclient.go
Rpoplpush
func (c *syncClient) Rpoplpush(arg0 string, arg1 string) (result []byte, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(arg1) var resp Response resp, err = c.conn.ServiceRequest(&RPOPLPUSH, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.GetBulkData() } return result, err }
go
func (c *syncClient) Rpoplpush(arg0 string, arg1 string) (result []byte, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(arg1) var resp Response resp, err = c.conn.ServiceRequest(&RPOPLPUSH, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.GetBulkData() } return result, err }
[ "func", "(", "c", "*", "syncClient", ")", "Rpoplpush", "(", "arg0", "string", ",", "arg1", "string", ")", "(", "result", "[", "]", "byte", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1bytes", ":="...
// Redis RPOPLPUSH command.
[ "Redis", "RPOPLPUSH", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L534-L545
138,733
alphazero/Go-Redis
synchclient.go
Sadd
func (c *syncClient) Sadd(arg0 string, arg1 []byte) (result bool, err Error) { arg0bytes := []byte(arg0) arg1bytes := arg1 var resp Response resp, err = c.conn.ServiceRequest(&SADD, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.GetBooleanValue() } return result, err }
go
func (c *syncClient) Sadd(arg0 string, arg1 []byte) (result bool, err Error) { arg0bytes := []byte(arg0) arg1bytes := arg1 var resp Response resp, err = c.conn.ServiceRequest(&SADD, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.GetBooleanValue() } return result, err }
[ "func", "(", "c", "*", "syncClient", ")", "Sadd", "(", "arg0", "string", ",", "arg1", "[", "]", "byte", ")", "(", "result", "bool", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1bytes", ":=", "ar...
// Redis SADD command.
[ "Redis", "SADD", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L563-L574
138,734
alphazero/Go-Redis
synchclient.go
Scard
func (c *syncClient) Scard(arg0 string) (result int64, err Error) { arg0bytes := []byte(arg0) var resp Response resp, err = c.conn.ServiceRequest(&SCARD, [][]byte{arg0bytes}) if err == nil { result = resp.GetNumberValue() } return result, err }
go
func (c *syncClient) Scard(arg0 string) (result int64, err Error) { arg0bytes := []byte(arg0) var resp Response resp, err = c.conn.ServiceRequest(&SCARD, [][]byte{arg0bytes}) if err == nil { result = resp.GetNumberValue() } return result, err }
[ "func", "(", "c", "*", "syncClient", ")", "Scard", "(", "arg0", "string", ")", "(", "result", "int64", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n\n", "var", "resp", "Response", "\n", "resp", ",", "err"...
// Redis SCARD command.
[ "Redis", "SCARD", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L620-L630
138,735
alphazero/Go-Redis
synchclient.go
Sinterstore
func (c *syncClient) Sinterstore(arg0 string, arg1 []string) (err Error) { _, err = c.conn.ServiceRequest(&SINTERSTORE, appendAndConvert(arg0, arg1...)) return }
go
func (c *syncClient) Sinterstore(arg0 string, arg1 []string) (err Error) { _, err = c.conn.ServiceRequest(&SINTERSTORE, appendAndConvert(arg0, arg1...)) return }
[ "func", "(", "c", "*", "syncClient", ")", "Sinterstore", "(", "arg0", "string", ",", "arg1", "[", "]", "string", ")", "(", "err", "Error", ")", "{", "_", ",", "err", "=", "c", ".", "conn", ".", "ServiceRequest", "(", "&", "SINTERSTORE", ",", "appen...
// Redis SINTERSTORE command.
[ "Redis", "SINTERSTORE", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L673-L676
138,736
alphazero/Go-Redis
synchclient.go
Sdiffstore
func (c *syncClient) Sdiffstore(arg0 string, arg1 []string) (err Error) { _, err = c.conn.ServiceRequest(&SDIFFSTORE, appendAndConvert(arg0, arg1...)) return }
go
func (c *syncClient) Sdiffstore(arg0 string, arg1 []string) (err Error) { _, err = c.conn.ServiceRequest(&SDIFFSTORE, appendAndConvert(arg0, arg1...)) return }
[ "func", "(", "c", "*", "syncClient", ")", "Sdiffstore", "(", "arg0", "string", ",", "arg1", "[", "]", "string", ")", "(", "err", "Error", ")", "{", "_", ",", "err", "=", "c", ".", "conn", ".", "ServiceRequest", "(", "&", "SDIFFSTORE", ",", "appendA...
// Redis SDIFFSTORE command.
[ "Redis", "SDIFFSTORE", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L708-L711
138,737
alphazero/Go-Redis
synchclient.go
Hgetall
func (c *syncClient) Hgetall(arg0 string) (result [][]byte, err Error) { arg0bytes := []byte(arg0) var resp Response resp, err = c.conn.ServiceRequest(&HGETALL, [][]byte{arg0bytes}) if err == nil { result = resp.GetMultiBulkData() } return result, err }
go
func (c *syncClient) Hgetall(arg0 string) (result [][]byte, err Error) { arg0bytes := []byte(arg0) var resp Response resp, err = c.conn.ServiceRequest(&HGETALL, [][]byte{arg0bytes}) if err == nil { result = resp.GetMultiBulkData() } return result, err }
[ "func", "(", "c", "*", "syncClient", ")", "Hgetall", "(", "arg0", "string", ")", "(", "result", "[", "]", "[", "]", "byte", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n\n", "var", "resp", "Response", "...
// Redis HGETALL command.
[ "Redis", "HGETALL", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L879-L889
138,738
alphazero/Go-Redis
synchclient.go
Move
func (c *syncClient) Move(arg0 string, arg1 int64) (result bool, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(fmt.Sprintf("%d", arg1)) var resp Response resp, err = c.conn.ServiceRequest(&MOVE, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.GetBooleanValue() } return result, err ...
go
func (c *syncClient) Move(arg0 string, arg1 int64) (result bool, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(fmt.Sprintf("%d", arg1)) var resp Response resp, err = c.conn.ServiceRequest(&MOVE, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.GetBooleanValue() } return result, err ...
[ "func", "(", "c", "*", "syncClient", ")", "Move", "(", "arg0", "string", ",", "arg1", "int64", ")", "(", "result", "bool", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1bytes", ":=", "[", "]", "b...
// Redis MOVE command.
[ "Redis", "MOVE", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L904-L915
138,739
alphazero/Go-Redis
synchclient.go
Publish
func (c *syncClient) Publish(arg0 string, arg1 []byte) (rcvCnt int64, err Error) { arg0bytes := []byte(arg0) arg1bytes := arg1 var resp Response resp, err = c.conn.ServiceRequest(&PUBLISH, [][]byte{arg0bytes, arg1bytes}) if err == nil { rcvCnt = resp.GetNumberValue() } return rcvCnt, err }
go
func (c *syncClient) Publish(arg0 string, arg1 []byte) (rcvCnt int64, err Error) { arg0bytes := []byte(arg0) arg1bytes := arg1 var resp Response resp, err = c.conn.ServiceRequest(&PUBLISH, [][]byte{arg0bytes, arg1bytes}) if err == nil { rcvCnt = resp.GetNumberValue() } return rcvCnt, err }
[ "func", "(", "c", "*", "syncClient", ")", "Publish", "(", "arg0", "string", ",", "arg1", "[", "]", "byte", ")", "(", "rcvCnt", "int64", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1bytes", ":=", ...
// Redis PUBLISH command.
[ "Redis", "PUBLISH", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/synchclient.go#L935-L945
138,740
alphazero/Go-Redis
specification.go
GetKeyType
func GetKeyType(typename string) (keytype KeyType) { switch { case typename == "none": keytype = RT_NONE case typename == "string": keytype = RT_STRING case typename == "list": keytype = RT_LIST case typename == "set": keytype = RT_SET case typename == "zset": keytype = RT_ZSET default: panic("BUG - ...
go
func GetKeyType(typename string) (keytype KeyType) { switch { case typename == "none": keytype = RT_NONE case typename == "string": keytype = RT_STRING case typename == "list": keytype = RT_LIST case typename == "set": keytype = RT_SET case typename == "zset": keytype = RT_ZSET default: panic("BUG - ...
[ "func", "GetKeyType", "(", "typename", "string", ")", "(", "keytype", "KeyType", ")", "{", "switch", "{", "case", "typename", "==", "\"", "\"", ":", "keytype", "=", "RT_NONE", "\n", "case", "typename", "==", "\"", "\"", ":", "keytype", "=", "RT_STRING", ...
// Returns KeyType by name //
[ "Returns", "KeyType", "by", "name" ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/specification.go#L47-L63
138,741
alphazero/Go-Redis
specification.go
anyClientRedisErrSpec
func anyClientRedisErrSpec(spec *MethodSpec, method string) *MethodSpec { // Commands that can return ERR given random input and state switch method { // Redis-Spec: Background save may be running already and can raise -ERR case "Bgsave": spec.NoRedisErr = false } return spec }
go
func anyClientRedisErrSpec(spec *MethodSpec, method string) *MethodSpec { // Commands that can return ERR given random input and state switch method { // Redis-Spec: Background save may be running already and can raise -ERR case "Bgsave": spec.NoRedisErr = false } return spec }
[ "func", "anyClientRedisErrSpec", "(", "spec", "*", "MethodSpec", ",", "method", "string", ")", "*", "MethodSpec", "{", "// Commands that can return ERR given random input and state", "switch", "method", "{", "// Redis-Spec: Background save may be running already and can raise -ERR"...
// spec.NoRedisErr // Specs MethodSpec.NoRedisErr - client type invariant
[ "spec", ".", "NoRedisErr", "Specs", "MethodSpec", ".", "NoRedisErr", "-", "client", "type", "invariant" ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/specification.go#L246-L255
138,742
alphazero/Go-Redis
specification.go
anyClientNilResultValueSpec
func anyClientNilResultValueSpec(spec *MethodSpec, method string) *MethodSpec { // Commands that can return nil/zero-value given random input and state switch method { // Redis-Spec: DB may be empty and AllKeys can return nil result // REVU: check if this is actually conformant case "AllKeys": spec.NoNilResultVa...
go
func anyClientNilResultValueSpec(spec *MethodSpec, method string) *MethodSpec { // Commands that can return nil/zero-value given random input and state switch method { // Redis-Spec: DB may be empty and AllKeys can return nil result // REVU: check if this is actually conformant case "AllKeys": spec.NoNilResultVa...
[ "func", "anyClientNilResultValueSpec", "(", "spec", "*", "MethodSpec", ",", "method", "string", ")", "*", "MethodSpec", "{", "// Commands that can return nil/zero-value given random input and state", "switch", "method", "{", "// Redis-Spec: DB may be empty and AllKeys can return ni...
// spec.NoNilResultValue // Specs MethodSpec.NoNilResultValue - client type invariant
[ "spec", ".", "NoNilResultValue", "Specs", "MethodSpec", ".", "NoNilResultValue", "-", "client", "type", "invariant" ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/specification.go#L259-L269
138,743
alphazero/Go-Redis
connection.go
DefaultSpec
func DefaultSpec() *ConnectionSpec { return &ConnectionSpec{ DefaultRedisHost, DefaultRedisPort, DefaultRedisPassword, DefaultRedisDB, DefaultTCPReadBuffSize, DefaultTCPWriteBuffSize, DefaultTCPReadTimeoutNSecs, DefaultTCPWriteTimeoutNSecs, DefaultTCPKeepalive, DefaultTCPLinger, DefaultReqChanSiz...
go
func DefaultSpec() *ConnectionSpec { return &ConnectionSpec{ DefaultRedisHost, DefaultRedisPort, DefaultRedisPassword, DefaultRedisDB, DefaultTCPReadBuffSize, DefaultTCPWriteBuffSize, DefaultTCPReadTimeoutNSecs, DefaultTCPWriteTimeoutNSecs, DefaultTCPKeepalive, DefaultTCPLinger, DefaultReqChanSiz...
[ "func", "DefaultSpec", "(", ")", "*", "ConnectionSpec", "{", "return", "&", "ConnectionSpec", "{", "DefaultRedisHost", ",", "DefaultRedisPort", ",", "DefaultRedisPassword", ",", "DefaultRedisDB", ",", "DefaultTCPReadBuffSize", ",", "DefaultTCPWriteBuffSize", ",", "Defau...
// Creates a ConnectionSpec using default settings. // using the DefaultXXX consts of redis package.
[ "Creates", "a", "ConnectionSpec", "using", "default", "settings", ".", "using", "the", "DefaultXXX", "consts", "of", "redis", "package", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L97-L114
138,744
alphazero/Go-Redis
connection.go
Db
func (spec *ConnectionSpec) Db(db int) *ConnectionSpec { spec.db = db return spec }
go
func (spec *ConnectionSpec) Db(db int) *ConnectionSpec { spec.db = db return spec }
[ "func", "(", "spec", "*", "ConnectionSpec", ")", "Db", "(", "db", "int", ")", "*", "ConnectionSpec", "{", "spec", ".", "db", "=", "db", "\n", "return", "spec", "\n", "}" ]
// Sets the db for connection spec and returns the reference // Note that you should not this after you have already connected.
[ "Sets", "the", "db", "for", "connection", "spec", "and", "returns", "the", "reference", "Note", "that", "you", "should", "not", "this", "after", "you", "have", "already", "connected", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L118-L121
138,745
alphazero/Go-Redis
connection.go
Host
func (spec *ConnectionSpec) Host(host string) *ConnectionSpec { spec.host = host return spec }
go
func (spec *ConnectionSpec) Host(host string) *ConnectionSpec { spec.host = host return spec }
[ "func", "(", "spec", "*", "ConnectionSpec", ")", "Host", "(", "host", "string", ")", "*", "ConnectionSpec", "{", "spec", ".", "host", "=", "host", "\n", "return", "spec", "\n", "}" ]
// Sets the host for connection spec and returns the reference // Note that you should not this after you have already connected.
[ "Sets", "the", "host", "for", "connection", "spec", "and", "returns", "the", "reference", "Note", "that", "you", "should", "not", "this", "after", "you", "have", "already", "connected", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L125-L128
138,746
alphazero/Go-Redis
connection.go
Port
func (spec *ConnectionSpec) Port(port int) *ConnectionSpec { spec.port = port return spec }
go
func (spec *ConnectionSpec) Port(port int) *ConnectionSpec { spec.port = port return spec }
[ "func", "(", "spec", "*", "ConnectionSpec", ")", "Port", "(", "port", "int", ")", "*", "ConnectionSpec", "{", "spec", ".", "port", "=", "port", "\n", "return", "spec", "\n", "}" ]
// Sets the port for connection spec and returns the reference // Note that you should not this after you have already connected.
[ "Sets", "the", "port", "for", "connection", "spec", "and", "returns", "the", "reference", "Note", "that", "you", "should", "not", "this", "after", "you", "have", "already", "connected", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L132-L135
138,747
alphazero/Go-Redis
connection.go
Password
func (spec *ConnectionSpec) Password(password string) *ConnectionSpec { spec.password = password return spec }
go
func (spec *ConnectionSpec) Password(password string) *ConnectionSpec { spec.password = password return spec }
[ "func", "(", "spec", "*", "ConnectionSpec", ")", "Password", "(", "password", "string", ")", "*", "ConnectionSpec", "{", "spec", ".", "password", "=", "password", "\n", "return", "spec", "\n", "}" ]
// Sets the password for connection spec and returns the reference // Note that you should not this after you have already connected.
[ "Sets", "the", "password", "for", "connection", "spec", "and", "returns", "the", "reference", "Note", "that", "you", "should", "not", "this", "after", "you", "have", "already", "connected", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L139-L142
138,748
alphazero/Go-Redis
connection.go
String
func (c *connHdl) String() string { return fmt.Sprintf("conn<redis-server@%s:%d [db %d]>", c.spec.host, c.spec.port, c.spec.db) }
go
func (c *connHdl) String() string { return fmt.Sprintf("conn<redis-server@%s:%d [db %d]>", c.spec.host, c.spec.port, c.spec.db) }
[ "func", "(", "c", "*", "connHdl", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "spec", ".", "host", ",", "c", ".", "spec", ".", "port", ",", "c", ".", "spec", ".", "db", ")", "\n", ...
// Returns minimal info string for logging, etc
[ "Returns", "minimal", "info", "string", "for", "logging", "etc" ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L218-L220
138,749
alphazero/Go-Redis
connection.go
NewSyncConnection
func NewSyncConnection(spec *ConnectionSpec) (c SyncConnection, err Error) { defer func() { if e := recover(); e != nil { connerr := e.(error) err = newSystemErrorWithCause("NewSyncConnection", connerr) } }() connHdl := newConnHdl(spec) connHdl.connect() c = connHdl return }
go
func NewSyncConnection(spec *ConnectionSpec) (c SyncConnection, err Error) { defer func() { if e := recover(); e != nil { connerr := e.(error) err = newSystemErrorWithCause("NewSyncConnection", connerr) } }() connHdl := newConnHdl(spec) connHdl.connect() c = connHdl return }
[ "func", "NewSyncConnection", "(", "spec", "*", "ConnectionSpec", ")", "(", "c", "SyncConnection", ",", "err", "Error", ")", "{", "defer", "func", "(", ")", "{", "if", "e", ":=", "recover", "(", ")", ";", "e", "!=", "nil", "{", "connerr", ":=", "e", ...
// Creates a new SyncConnection using the provided ConnectionSpec. // Note that this function will also connect to the specified redis server.
[ "Creates", "a", "new", "SyncConnection", "using", "the", "provided", "ConnectionSpec", ".", "Note", "that", "this", "function", "will", "also", "connect", "to", "the", "specified", "redis", "server", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L320-L332
138,750
alphazero/Go-Redis
connection.go
ServiceRequest
func (c *connHdl) ServiceRequest(cmd *Command, args [][]byte) (resp Response, err Error) { loginfo := "connHdl.ServiceRequest" defer func() { if re := recover(); re != nil { // REVU - needs to be logged - TODO err = newSystemErrorWithCause("ServiceRequest", re.(error)) } }() if !c.connected { panic(fm...
go
func (c *connHdl) ServiceRequest(cmd *Command, args [][]byte) (resp Response, err Error) { loginfo := "connHdl.ServiceRequest" defer func() { if re := recover(); re != nil { // REVU - needs to be logged - TODO err = newSystemErrorWithCause("ServiceRequest", re.(error)) } }() if !c.connected { panic(fm...
[ "func", "(", "c", "*", "connHdl", ")", "ServiceRequest", "(", "cmd", "*", "Command", ",", "args", "[", "]", "[", "]", "byte", ")", "(", "resp", "Response", ",", "err", "Error", ")", "{", "loginfo", ":=", "\"", "\"", "\n\n", "defer", "func", "(", ...
// Implementation of SyncConnection.ServiceRequest.
[ "Implementation", "of", "SyncConnection", ".", "ServiceRequest", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L335-L371
138,751
alphazero/Go-Redis
connection.go
newAsyncConnHdl
func newAsyncConnHdl(spec *ConnectionSpec) *asyncConnHdl { c := new(asyncConnHdl) // connection base connHdl := newConnHdl(spec) // panics c.super = connHdl // conn management c.managerCtl = make(workerCtl) c.feedback = make(chan workerStatus) c.shutdown = make(chan bool, 1) // request processing c.writer...
go
func newAsyncConnHdl(spec *ConnectionSpec) *asyncConnHdl { c := new(asyncConnHdl) // connection base connHdl := newConnHdl(spec) // panics c.super = connHdl // conn management c.managerCtl = make(workerCtl) c.feedback = make(chan workerStatus) c.shutdown = make(chan bool, 1) // request processing c.writer...
[ "func", "newAsyncConnHdl", "(", "spec", "*", "ConnectionSpec", ")", "*", "asyncConnHdl", "{", "c", ":=", "new", "(", "asyncConnHdl", ")", "\n\n", "// connection base", "connHdl", ":=", "newConnHdl", "(", "spec", ")", "// panics", "\n", "c", ".", "super", "="...
// Creates a new asyncConnHdl with a new connHdl as its delegated 'super'. // Note it does not start the processing goroutines for the channels. // // REVU - PubSub could be checked here
[ "Creates", "a", "new", "asyncConnHdl", "with", "a", "new", "connHdl", "as", "its", "delegated", "super", ".", "Note", "it", "does", "not", "start", "the", "processing", "goroutines", "for", "the", "channels", ".", "REVU", "-", "PubSub", "could", "be", "che...
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L483-L519
138,752
alphazero/Go-Redis
connection.go
startup
func (c *asyncConnHdl) startup() { protocol := c.spec().protocol go c.worker(manager, "manager", managementTask, c.managerCtl, nil) c.managerCtl <- start // heartbeat only on REDIS_DB protocol if protocol == REDIS_DB { go c.worker(heartbeatworker, "heartbeat", heartbeatTask, c.heartbeatCtl, c.feedback) c.he...
go
func (c *asyncConnHdl) startup() { protocol := c.spec().protocol go c.worker(manager, "manager", managementTask, c.managerCtl, nil) c.managerCtl <- start // heartbeat only on REDIS_DB protocol if protocol == REDIS_DB { go c.worker(heartbeatworker, "heartbeat", heartbeatTask, c.heartbeatCtl, c.feedback) c.he...
[ "func", "(", "c", "*", "asyncConnHdl", ")", "startup", "(", ")", "{", "protocol", ":=", "c", ".", "spec", "(", ")", ".", "protocol", "\n\n", "go", "c", ".", "worker", "(", "manager", ",", "\"", "\"", ",", "managementTask", ",", "c", ".", "managerCt...
// responsible for managing the various moving parts of the asyncConnHdl
[ "responsible", "for", "managing", "the", "various", "moving", "parts", "of", "the", "asyncConnHdl" ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L681-L711
138,753
alphazero/Go-Redis
connection.go
reqProcessingTask
func reqProcessingTask(c *asyncConnHdl, ctl workerCtl) (ic *interrupt_code, ts *taskStatus) { var err error var errmsg string bytecnt := 0 blen := 0 bufsize := c.spec().wBufSize var sig interrupt_code select { case req := <-c.pendingReqs: blen, err := c.processAsyncRequest(req) if err != nil { errmsg ...
go
func reqProcessingTask(c *asyncConnHdl, ctl workerCtl) (ic *interrupt_code, ts *taskStatus) { var err error var errmsg string bytecnt := 0 blen := 0 bufsize := c.spec().wBufSize var sig interrupt_code select { case req := <-c.pendingReqs: blen, err := c.processAsyncRequest(req) if err != nil { errmsg ...
[ "func", "reqProcessingTask", "(", "c", "*", "asyncConnHdl", ",", "ctl", "workerCtl", ")", "(", "ic", "*", "interrupt_code", ",", "ts", "*", "taskStatus", ")", "{", "var", "err", "error", "\n", "var", "errmsg", "string", "\n\n", "bytecnt", ":=", "0", "\n"...
// Pending further tests, this addresses bug in earlier version // and can be interrupted
[ "Pending", "further", "tests", "this", "addresses", "bug", "in", "earlier", "version", "and", "can", "be", "interrupted" ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L958-L1010
138,754
alphazero/Go-Redis
connection.go
nextId
func (c *asyncConnHdl) nextId() (id int64) { id = c.nextid c.nextid++ return }
go
func (c *asyncConnHdl) nextId() (id int64) { id = c.nextid c.nextid++ return }
[ "func", "(", "c", "*", "asyncConnHdl", ")", "nextId", "(", ")", "(", "id", "int64", ")", "{", "id", "=", "c", ".", "nextid", "\n", "c", ".", "nextid", "++", "\n", "return", "\n", "}" ]
// request id needs to be unique in context of associated connection // only one goroutine calls this so no need to provide concurrency guards
[ "request", "id", "needs", "to", "be", "unique", "in", "context", "of", "associated", "connection", "only", "one", "goroutine", "calls", "this", "so", "no", "need", "to", "provide", "concurrency", "guards" ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/connection.go#L1050-L1054
138,755
alphazero/Go-Redis
bench/asyncbench.go
benchTask
func benchTask(taskspec taskSpec, iterations int, workers int, printReport bool) (delta time.Duration, err error) { // channel to signal completion signal := make(chan int, workers) // spec and initialize an AsyncClient // will flush your db13 as noted in README .. spec := redis.DefaultSpec().Db(13).Password("go-...
go
func benchTask(taskspec taskSpec, iterations int, workers int, printReport bool) (delta time.Duration, err error) { // channel to signal completion signal := make(chan int, workers) // spec and initialize an AsyncClient // will flush your db13 as noted in README .. spec := redis.DefaultSpec().Db(13).Password("go-...
[ "func", "benchTask", "(", "taskspec", "taskSpec", ",", "iterations", "int", ",", "workers", "int", ",", "printReport", "bool", ")", "(", "delta", "time", ".", "Duration", ",", "err", "error", ")", "{", "// channel to signal completion", "signal", ":=", "make",...
// Use a single redis.AsyncClient with specified number // of workers to bench concurrent load on the async client
[ "Use", "a", "single", "redis", ".", "AsyncClient", "with", "specified", "number", "of", "workers", "to", "bench", "concurrent", "load", "on", "the", "async", "client" ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/bench/asyncbench.go#L70-L105
138,756
alphazero/Go-Redis
asynchclient.go
NewAsynchClientWithSpec
func NewAsynchClientWithSpec(spec *ConnectionSpec) (client AsyncClient, err Error) { c := new(asyncClient) c.conn, err = NewAsynchConnection(spec) if err != nil { if debug() { log.Println("NewAsyncConnection() raised error: ", err) } return nil, err } return c, nil }
go
func NewAsynchClientWithSpec(spec *ConnectionSpec) (client AsyncClient, err Error) { c := new(asyncClient) c.conn, err = NewAsynchConnection(spec) if err != nil { if debug() { log.Println("NewAsyncConnection() raised error: ", err) } return nil, err } return c, nil }
[ "func", "NewAsynchClientWithSpec", "(", "spec", "*", "ConnectionSpec", ")", "(", "client", "AsyncClient", ",", "err", "Error", ")", "{", "c", ":=", "new", "(", "asyncClient", ")", "\n", "c", ".", "conn", ",", "err", "=", "NewAsynchConnection", "(", "spec",...
// Create a new asynClient and connects to the Redis server using the // specified ConnectionSpec. //
[ "Create", "a", "new", "asynClient", "and", "connects", "to", "the", "Redis", "server", "using", "the", "specified", "ConnectionSpec", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/asynchclient.go#L42-L52
138,757
alphazero/Go-Redis
asynchclient.go
Getset
func (c *asyncClient) Getset(arg0 string, arg1 []byte) (result FutureBytes, err Error) { arg0bytes := []byte(arg0) arg1bytes := arg1 var resp *PendingResponse resp, err = c.conn.QueueRequest(&GETSET, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.future.(FutureBytes) } return result, err }
go
func (c *asyncClient) Getset(arg0 string, arg1 []byte) (result FutureBytes, err Error) { arg0bytes := []byte(arg0) arg1bytes := arg1 var resp *PendingResponse resp, err = c.conn.QueueRequest(&GETSET, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.future.(FutureBytes) } return result, err }
[ "func", "(", "c", "*", "asyncClient", ")", "Getset", "(", "arg0", "string", ",", "arg1", "[", "]", "byte", ")", "(", "result", "FutureBytes", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1bytes", "...
// Redis GETSET command.
[ "Redis", "GETSET", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/asynchclient.go#L207-L218
138,758
alphazero/Go-Redis
asynchclient.go
Incr
func (c *asyncClient) Incr(arg0 string) (result FutureInt64, err Error) { arg0bytes := []byte(arg0) var resp *PendingResponse resp, err = c.conn.QueueRequest(&INCR, [][]byte{arg0bytes}) if err == nil { result = resp.future.(FutureInt64) } return result, err }
go
func (c *asyncClient) Incr(arg0 string) (result FutureInt64, err Error) { arg0bytes := []byte(arg0) var resp *PendingResponse resp, err = c.conn.QueueRequest(&INCR, [][]byte{arg0bytes}) if err == nil { result = resp.future.(FutureInt64) } return result, err }
[ "func", "(", "c", "*", "asyncClient", ")", "Incr", "(", "arg0", "string", ")", "(", "result", "FutureInt64", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n\n", "var", "resp", "*", "PendingResponse", "\n", "r...
// Redis INCR command.
[ "Redis", "INCR", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/asynchclient.go#L237-L247
138,759
alphazero/Go-Redis
asynchclient.go
Incrby
func (c *asyncClient) Incrby(arg0 string, arg1 int64) (result FutureInt64, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(fmt.Sprintf("%d", arg1)) var resp *PendingResponse resp, err = c.conn.QueueRequest(&INCRBY, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.future.(FutureInt64) } ...
go
func (c *asyncClient) Incrby(arg0 string, arg1 int64) (result FutureInt64, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(fmt.Sprintf("%d", arg1)) var resp *PendingResponse resp, err = c.conn.QueueRequest(&INCRBY, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.future.(FutureInt64) } ...
[ "func", "(", "c", "*", "asyncClient", ")", "Incrby", "(", "arg0", "string", ",", "arg1", "int64", ")", "(", "result", "FutureInt64", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1bytes", ":=", "[", ...
// Redis INCRBY command.
[ "Redis", "INCRBY", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/asynchclient.go#L250-L261
138,760
alphazero/Go-Redis
asynchclient.go
Renamenx
func (c *asyncClient) Renamenx(arg0 string, arg1 string) (result FutureBool, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(arg1) var resp *PendingResponse resp, err = c.conn.QueueRequest(&RENAMENX, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.future.(FutureBool) } return result, ...
go
func (c *asyncClient) Renamenx(arg0 string, arg1 string) (result FutureBool, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(arg1) var resp *PendingResponse resp, err = c.conn.QueueRequest(&RENAMENX, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.future.(FutureBool) } return result, ...
[ "func", "(", "c", "*", "asyncClient", ")", "Renamenx", "(", "arg0", "string", ",", "arg1", "string", ")", "(", "result", "FutureBool", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1bytes", ":=", "[",...
// Redis RENAMENX command.
[ "Redis", "RENAMENX", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/asynchclient.go#L315-L326
138,761
alphazero/Go-Redis
asynchclient.go
Expire
func (c *asyncClient) Expire(arg0 string, arg1 int64) (result FutureBool, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(fmt.Sprintf("%d", arg1)) var resp *PendingResponse resp, err = c.conn.QueueRequest(&EXPIRE, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.future.(FutureBool) } r...
go
func (c *asyncClient) Expire(arg0 string, arg1 int64) (result FutureBool, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(fmt.Sprintf("%d", arg1)) var resp *PendingResponse resp, err = c.conn.QueueRequest(&EXPIRE, [][]byte{arg0bytes, arg1bytes}) if err == nil { result = resp.future.(FutureBool) } r...
[ "func", "(", "c", "*", "asyncClient", ")", "Expire", "(", "arg0", "string", ",", "arg1", "int64", ")", "(", "result", "FutureBool", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1bytes", ":=", "[", ...
// Redis EXPIRE command.
[ "Redis", "EXPIRE", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/asynchclient.go#L340-L351
138,762
alphazero/Go-Redis
asynchclient.go
Ltrim
func (c *asyncClient) Ltrim(arg0 string, arg1 int64, arg2 int64) (stat FutureBool, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(fmt.Sprintf("%d", arg1)) arg2bytes := []byte(fmt.Sprintf("%d", arg2)) resp, err := c.conn.QueueRequest(&LTRIM, [][]byte{arg0bytes, arg1bytes, arg2bytes}) if err == nil { ...
go
func (c *asyncClient) Ltrim(arg0 string, arg1 int64, arg2 int64) (stat FutureBool, err Error) { arg0bytes := []byte(arg0) arg1bytes := []byte(fmt.Sprintf("%d", arg1)) arg2bytes := []byte(fmt.Sprintf("%d", arg2)) resp, err := c.conn.QueueRequest(&LTRIM, [][]byte{arg0bytes, arg1bytes, arg2bytes}) if err == nil { ...
[ "func", "(", "c", "*", "asyncClient", ")", "Ltrim", "(", "arg0", "string", ",", "arg1", "int64", ",", "arg2", "int64", ")", "(", "stat", "FutureBool", ",", "err", "Error", ")", "{", "arg0bytes", ":=", "[", "]", "byte", "(", "arg0", ")", "\n", "arg1...
// Redis LTRIM command.
[ "Redis", "LTRIM", "command", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/asynchclient.go#L450-L461
138,763
alphazero/Go-Redis
protocol.go
CreateFuture
func CreateFuture(cmd *Command) (future interface{}) { switch cmd.RespType { case BOOLEAN: future = newFutureBool() case BULK: future = newFutureBytes() case MULTI_BULK: future = newFutureBytesArray() case NUMBER: future = newFutureInt64() case STATUS: future = newFutureBool() case STRING: future = n...
go
func CreateFuture(cmd *Command) (future interface{}) { switch cmd.RespType { case BOOLEAN: future = newFutureBool() case BULK: future = newFutureBytes() case MULTI_BULK: future = newFutureBytesArray() case NUMBER: future = newFutureInt64() case STATUS: future = newFutureBool() case STRING: future = n...
[ "func", "CreateFuture", "(", "cmd", "*", "Command", ")", "(", "future", "interface", "{", "}", ")", "{", "switch", "cmd", ".", "RespType", "{", "case", "BOOLEAN", ":", "future", "=", "newFutureBool", "(", ")", "\n", "case", "BULK", ":", "future", "=", ...
// Creates a specific Future type for the given Redis command // and returns it as a generic reference.
[ "Creates", "a", "specific", "Future", "type", "for", "the", "given", "Redis", "command", "and", "returns", "it", "as", "a", "generic", "reference", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/protocol.go#L92-L111
138,764
alphazero/Go-Redis
protocol.go
SetFutureResult
func SetFutureResult(future interface{}, cmd *Command, r Response) { if r.IsError() { future.(FutureResult).onError(newRedisError(r.GetMessage())) } else { switch cmd.RespType { case BOOLEAN: future.(FutureBool).set(r.GetBooleanValue()) case BULK: future.(FutureBytes).set(r.GetBulkData()) case MULTI_B...
go
func SetFutureResult(future interface{}, cmd *Command, r Response) { if r.IsError() { future.(FutureResult).onError(newRedisError(r.GetMessage())) } else { switch cmd.RespType { case BOOLEAN: future.(FutureBool).set(r.GetBooleanValue()) case BULK: future.(FutureBytes).set(r.GetBulkData()) case MULTI_B...
[ "func", "SetFutureResult", "(", "future", "interface", "{", "}", ",", "cmd", "*", "Command", ",", "r", "Response", ")", "{", "if", "r", ".", "IsError", "(", ")", "{", "future", ".", "(", "FutureResult", ")", ".", "onError", "(", "newRedisError", "(", ...
// Sets the type specific result value from the response for the future reference // based on the command type.
[ "Sets", "the", "type", "specific", "result", "value", "from", "the", "response", "for", "the", "future", "reference", "based", "on", "the", "command", "type", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/protocol.go#L115-L137
138,765
alphazero/Go-Redis
compliance/compliance.go
main
func main() { flag.Parse() specfname, e := getSpecFileName("compliance.prop") if e != nil { log.Println("error -", e) } rmspec, e1 := readCommandsFromSpecFile(specfname) if e1 != nil { log.Println("error -", e1) return } var rctype clientType fmt.Println() fmt.Println("///////////////////////////////...
go
func main() { flag.Parse() specfname, e := getSpecFileName("compliance.prop") if e != nil { log.Println("error -", e) } rmspec, e1 := readCommandsFromSpecFile(specfname) if e1 != nil { log.Println("error -", e1) return } var rctype clientType fmt.Println() fmt.Println("///////////////////////////////...
[ "func", "main", "(", ")", "{", "flag", ".", "Parse", "(", ")", "\n\n", "specfname", ",", "e", ":=", "getSpecFileName", "(", "\"", "\"", ")", "\n", "if", "e", "!=", "nil", "{", "log", ".", "Println", "(", "\"", "\"", ",", "e", ")", "\n", "}", ...
// Checks Redis client interfaces' methods against a // a list of canonical Redis methods obtained from a // spec file and reports the missing methods
[ "Checks", "Redis", "client", "interfaces", "methods", "against", "a", "a", "list", "of", "canonical", "Redis", "methods", "obtained", "from", "a", "spec", "file", "and", "reports", "the", "missing", "methods" ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/compliance/compliance.go#L42-L67
138,766
alphazero/Go-Redis
compliance/compliance.go
analyzeAndReport
func analyzeAndReport(rctype clientType, rmspec []string) { defined, e2 := getDefinedMethods(rctype) if e2 != nil { log.Println("error -", e2) return } reportCompliance(rctype, defined, rmspec) }
go
func analyzeAndReport(rctype clientType, rmspec []string) { defined, e2 := getDefinedMethods(rctype) if e2 != nil { log.Println("error -", e2) return } reportCompliance(rctype, defined, rmspec) }
[ "func", "analyzeAndReport", "(", "rctype", "clientType", ",", "rmspec", "[", "]", "string", ")", "{", "defined", ",", "e2", ":=", "getDefinedMethods", "(", "rctype", ")", "\n", "if", "e2", "!=", "nil", "{", "log", ".", "Println", "(", "\"", "\"", ",", ...
// Get the defined methods for the specified client type // and report compliance
[ "Get", "the", "defined", "methods", "for", "the", "specified", "client", "type", "and", "report", "compliance" ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/compliance/compliance.go#L71-L78
138,767
alphazero/Go-Redis
compliance/compliance.go
reportCompliance
func reportCompliance(rctype clientType, mmap map[string]string, specms []string) { fmt.Printf("=== compliance report [%s] =========================\n", rctype) var nccnt = 0 for _, method := range specms { if mmap[method] == "" { nccnt++ fmt.Printf("not defined - [%d]: %s\n", nccnt, method) } } if nccnt...
go
func reportCompliance(rctype clientType, mmap map[string]string, specms []string) { fmt.Printf("=== compliance report [%s] =========================\n", rctype) var nccnt = 0 for _, method := range specms { if mmap[method] == "" { nccnt++ fmt.Printf("not defined - [%d]: %s\n", nccnt, method) } } if nccnt...
[ "func", "reportCompliance", "(", "rctype", "clientType", ",", "mmap", "map", "[", "string", "]", "string", ",", "specms", "[", "]", "string", ")", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ",", "rctype", ")", "\n", "var", "nccnt", "=", "0", ...
// check method name map against spec'd method names // and report undefined methods
[ "check", "method", "name", "map", "against", "spec", "d", "method", "names", "and", "report", "undefined", "methods" ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/compliance/compliance.go#L82-L94
138,768
alphazero/Go-Redis
compliance/compliance.go
getSpecFileName
func getSpecFileName(csmetafile string) (string, error) { var fname string buff, e := ioutil.ReadFile(csmetafile) if e != nil { return fname, e } fname = string(buff) return fname[:len(fname)-1], nil }
go
func getSpecFileName(csmetafile string) (string, error) { var fname string buff, e := ioutil.ReadFile(csmetafile) if e != nil { return fname, e } fname = string(buff) return fname[:len(fname)-1], nil }
[ "func", "getSpecFileName", "(", "csmetafile", "string", ")", "(", "string", ",", "error", ")", "{", "var", "fname", "string", "\n", "buff", ",", "e", ":=", "ioutil", ".", "ReadFile", "(", "csmetafile", ")", "\n", "if", "e", "!=", "nil", "{", "return", ...
// Reads the spec file to use for the check // csmetafile is the name of the expected prop file and // should contain just the name of another file.
[ "Reads", "the", "spec", "file", "to", "use", "for", "the", "check", "csmetafile", "is", "the", "name", "of", "the", "expected", "prop", "file", "and", "should", "contain", "just", "the", "name", "of", "another", "file", "." ]
a0637b1543645181061469efea75f57ad2e3f23a
https://github.com/alphazero/Go-Redis/blob/a0637b1543645181061469efea75f57ad2e3f23a/compliance/compliance.go#L156-L164
138,769
linki/instrumented_http
client.go
RoundTrip
func (it *Transport) RoundTrip(req *http.Request) (*http.Response, error) { statusCode := BogusStatusCode // Remember the current time. now := time.Now() // Make the request using the next RoundTripper. resp, err := it.next.RoundTrip(req) if resp != nil { statusCode = resp.StatusCode } // Observe the time ...
go
func (it *Transport) RoundTrip(req *http.Request) (*http.Response, error) { statusCode := BogusStatusCode // Remember the current time. now := time.Now() // Make the request using the next RoundTripper. resp, err := it.next.RoundTrip(req) if resp != nil { statusCode = resp.StatusCode } // Observe the time ...
[ "func", "(", "it", "*", "Transport", ")", "RoundTrip", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "statusCode", ":=", "BogusStatusCode", "\n\n", "// Remember the current time.", "now", ":=", "ti...
// RoundTrip implements http.RoundTripper. It forwards the request to the // next RoundTripper and measures the time it took in Prometheus summary.
[ "RoundTrip", "implements", "http", ".", "RoundTripper", ".", "It", "forwards", "the", "request", "to", "the", "next", "RoundTripper", "and", "measures", "the", "time", "it", "took", "in", "Prometheus", "summary", "." ]
ff7c0aeddedba068c35f6d07eaab3df955cba6d7
https://github.com/linki/instrumented_http/blob/ff7c0aeddedba068c35f6d07eaab3df955cba6d7/client.go#L78-L102
138,770
linki/instrumented_http
client.go
NewTransport
func NewTransport(next http.RoundTripper, cbs *Callbacks) http.RoundTripper { // If next RoundTripper is not defined we'll use http.DefaultTransport. if next == nil { next = http.DefaultTransport } // If cbs is not defined we'll initilialize it with defaults. if cbs == nil { cbs = &Callbacks{} } // By defau...
go
func NewTransport(next http.RoundTripper, cbs *Callbacks) http.RoundTripper { // If next RoundTripper is not defined we'll use http.DefaultTransport. if next == nil { next = http.DefaultTransport } // If cbs is not defined we'll initilialize it with defaults. if cbs == nil { cbs = &Callbacks{} } // By defau...
[ "func", "NewTransport", "(", "next", "http", ".", "RoundTripper", ",", "cbs", "*", "Callbacks", ")", "http", ".", "RoundTripper", "{", "// If next RoundTripper is not defined we'll use http.DefaultTransport.", "if", "next", "==", "nil", "{", "next", "=", "http", "."...
// NewTransport takes a http.RoundTripper, wraps it with instrumentation and // returns it as a new http.RoundTripper. Optionally, It can receive a // collection of callbacks that process request path and query into a suitable // label value.
[ "NewTransport", "takes", "a", "http", ".", "RoundTripper", "wraps", "it", "with", "instrumentation", "and", "returns", "it", "as", "a", "new", "http", ".", "RoundTripper", ".", "Optionally", "It", "can", "receive", "a", "collection", "of", "callbacks", "that",...
ff7c0aeddedba068c35f6d07eaab3df955cba6d7
https://github.com/linki/instrumented_http/blob/ff7c0aeddedba068c35f6d07eaab3df955cba6d7/client.go#L123-L146
138,771
theplant/cldr
calendar.go
Format
func (c Calendar) Format(datetime time.Time, pattern string) (string, error) { parsed, err := c.parseDateTimeFormat(pattern) if err != nil { return "", err } return c.formatDateTime(datetime, parsed) }
go
func (c Calendar) Format(datetime time.Time, pattern string) (string, error) { parsed, err := c.parseDateTimeFormat(pattern) if err != nil { return "", err } return c.formatDateTime(datetime, parsed) }
[ "func", "(", "c", "Calendar", ")", "Format", "(", "datetime", "time", ".", "Time", ",", "pattern", "string", ")", "(", "string", ",", "error", ")", "{", "parsed", ",", "err", ":=", "c", ".", "parseDateTimeFormat", "(", "pattern", ")", "\n", "if", "er...
// Format takes a time struct and a format and returns a formatted // string. Callers should use a DateFormat, TimeFormat, or DateTimeFormat // constant.
[ "Format", "takes", "a", "time", "struct", "and", "a", "format", "and", "returns", "a", "formatted", "string", ".", "Callers", "should", "use", "a", "DateFormat", "TimeFormat", "or", "DateTimeFormat", "constant", "." ]
9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2
https://github.com/theplant/cldr/blob/9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2/calendar.go#L139-L146
138,772
theplant/cldr
calendar.go
formatDateTime
func (c Calendar) formatDateTime(datetime time.Time, pattern []*datetimePatternComponent) (string, error) { formatted := "" for _, component := range pattern { if component.componentType == datetimePatternComponentLiteral { formatted += component.pattern } else { f, err := c.formatDateTimeComponent(datetime...
go
func (c Calendar) formatDateTime(datetime time.Time, pattern []*datetimePatternComponent) (string, error) { formatted := "" for _, component := range pattern { if component.componentType == datetimePatternComponentLiteral { formatted += component.pattern } else { f, err := c.formatDateTimeComponent(datetime...
[ "func", "(", "c", "Calendar", ")", "formatDateTime", "(", "datetime", "time", ".", "Time", ",", "pattern", "[", "]", "*", "datetimePatternComponent", ")", "(", "string", ",", "error", ")", "{", "formatted", ":=", "\"", "\"", "\n", "for", "_", ",", "com...
// formatDateTime takes a time.Time and a sequence of parsed pattern components // and returns an internationalized string representation.
[ "formatDateTime", "takes", "a", "time", ".", "Time", "and", "a", "sequence", "of", "parsed", "pattern", "components", "and", "returns", "an", "internationalized", "string", "representation", "." ]
9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2
https://github.com/theplant/cldr/blob/9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2/calendar.go#L150-L165
138,773
theplant/cldr
calendar.go
formatDateTimeComponent
func (c Calendar) formatDateTimeComponent(datetime time.Time, pattern string) (string, error) { switch pattern[0:1] { case string(datetimeFormatUnitEra): return c.formatDateTimeComponentEra(datetime, len(pattern)) case string(datetimeFormatUnitYear): return c.formatDateTimeComponentYear(datetime, len(pattern)) ...
go
func (c Calendar) formatDateTimeComponent(datetime time.Time, pattern string) (string, error) { switch pattern[0:1] { case string(datetimeFormatUnitEra): return c.formatDateTimeComponentEra(datetime, len(pattern)) case string(datetimeFormatUnitYear): return c.formatDateTimeComponentYear(datetime, len(pattern)) ...
[ "func", "(", "c", "Calendar", ")", "formatDateTimeComponent", "(", "datetime", "time", ".", "Time", ",", "pattern", "string", ")", "(", "string", ",", "error", ")", "{", "switch", "pattern", "[", "0", ":", "1", "]", "{", "case", "string", "(", "datetim...
// formatDateTimeComponent renders a single component of a datetime format // pattern.
[ "formatDateTimeComponent", "renders", "a", "single", "component", "of", "a", "datetime", "format", "pattern", "." ]
9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2
https://github.com/theplant/cldr/blob/9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2/calendar.go#L169-L200
138,774
theplant/cldr
calendar.go
formatDateTimeComponentMonthWide
func (c Calendar) formatDateTimeComponentMonthWide(month int) string { switch month { case 1: return c.FormatNames.Months.Wide.Jan case 2: return c.FormatNames.Months.Wide.Feb case 3: return c.FormatNames.Months.Wide.Mar case 4: return c.FormatNames.Months.Wide.Apr case 5: return c.FormatNames.Months.Wi...
go
func (c Calendar) formatDateTimeComponentMonthWide(month int) string { switch month { case 1: return c.FormatNames.Months.Wide.Jan case 2: return c.FormatNames.Months.Wide.Feb case 3: return c.FormatNames.Months.Wide.Mar case 4: return c.FormatNames.Months.Wide.Apr case 5: return c.FormatNames.Months.Wi...
[ "func", "(", "c", "Calendar", ")", "formatDateTimeComponentMonthWide", "(", "month", "int", ")", "string", "{", "switch", "month", "{", "case", "1", ":", "return", "c", ".", "FormatNames", ".", "Months", ".", "Wide", ".", "Jan", "\n", "case", "2", ":", ...
// formatDateTimeComponentMonthWide renders a full text month component.
[ "formatDateTimeComponentMonthWide", "renders", "a", "full", "text", "month", "component", "." ]
9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2
https://github.com/theplant/cldr/blob/9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2/calendar.go#L310-L339
138,775
theplant/cldr
calendar.go
formatDateTimeComponentMonthNarrow
func (c Calendar) formatDateTimeComponentMonthNarrow(month int) string { switch month { case 1: return c.FormatNames.Months.Narrow.Jan case 2: return c.FormatNames.Months.Narrow.Feb case 3: return c.FormatNames.Months.Narrow.Mar case 4: return c.FormatNames.Months.Narrow.Apr case 5: return c.FormatNames...
go
func (c Calendar) formatDateTimeComponentMonthNarrow(month int) string { switch month { case 1: return c.FormatNames.Months.Narrow.Jan case 2: return c.FormatNames.Months.Narrow.Feb case 3: return c.FormatNames.Months.Narrow.Mar case 4: return c.FormatNames.Months.Narrow.Apr case 5: return c.FormatNames...
[ "func", "(", "c", "Calendar", ")", "formatDateTimeComponentMonthNarrow", "(", "month", "int", ")", "string", "{", "switch", "month", "{", "case", "1", ":", "return", "c", ".", "FormatNames", ".", "Months", ".", "Narrow", ".", "Jan", "\n", "case", "2", ":...
// formatDateTimeComponentMonthNarrow renders a super-short month compontent - // not guaranteed to be unique for different months.
[ "formatDateTimeComponentMonthNarrow", "renders", "a", "super", "-", "short", "month", "compontent", "-", "not", "guaranteed", "to", "be", "unique", "for", "different", "months", "." ]
9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2
https://github.com/theplant/cldr/blob/9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2/calendar.go#L343-L372
138,776
theplant/cldr
calendar.go
formatDateTimeComponentDayOfWeekNarrow
func (c Calendar) formatDateTimeComponentDayOfWeekNarrow(dayOfWeek time.Weekday) string { switch dayOfWeek { case time.Sunday: return c.FormatNames.Days.Narrow.Sun case time.Monday: return c.FormatNames.Days.Narrow.Mon case time.Tuesday: return c.FormatNames.Days.Narrow.Tue case time.Wednesday: return c.Fo...
go
func (c Calendar) formatDateTimeComponentDayOfWeekNarrow(dayOfWeek time.Weekday) string { switch dayOfWeek { case time.Sunday: return c.FormatNames.Days.Narrow.Sun case time.Monday: return c.FormatNames.Days.Narrow.Mon case time.Tuesday: return c.FormatNames.Days.Narrow.Tue case time.Wednesday: return c.Fo...
[ "func", "(", "c", "Calendar", ")", "formatDateTimeComponentDayOfWeekNarrow", "(", "dayOfWeek", "time", ".", "Weekday", ")", "string", "{", "switch", "dayOfWeek", "{", "case", "time", ".", "Sunday", ":", "return", "c", ".", "FormatNames", ".", "Days", ".", "N...
// formatDateTimeComponentDayOfWeekNarrow renders a super-short day-of-week // compontent - not guaranteed to be unique for different days.
[ "formatDateTimeComponentDayOfWeekNarrow", "renders", "a", "super", "-", "short", "day", "-", "of", "-", "week", "compontent", "-", "not", "guaranteed", "to", "be", "unique", "for", "different", "days", "." ]
9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2
https://github.com/theplant/cldr/blob/9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2/calendar.go#L463-L482
138,777
theplant/cldr
number.go
chunkString
func chunkString(str string, size int) []string { if str == "" { return []string{} } if size == 0 { return []string{str} } chunks := make([]string, int64(math.Ceil(float64(len(str))/float64(size)))) for len(str) < len(chunks)*size { str = " " + str } for i := 0; i < len(chunks); i++ { start := i * s...
go
func chunkString(str string, size int) []string { if str == "" { return []string{} } if size == 0 { return []string{str} } chunks := make([]string, int64(math.Ceil(float64(len(str))/float64(size)))) for len(str) < len(chunks)*size { str = " " + str } for i := 0; i < len(chunks); i++ { start := i * s...
[ "func", "chunkString", "(", "str", "string", ",", "size", "int", ")", "[", "]", "string", "{", "if", "str", "==", "\"", "\"", "{", "return", "[", "]", "string", "{", "}", "\n", "}", "\n\n", "if", "size", "==", "0", "{", "return", "[", "]", "str...
// chunkString takes a string and chunks it into size-sized pieces in a slice. // If the length of the string is not divisible by the size, then the first // chunk in the slice will be padded to compensate.
[ "chunkString", "takes", "a", "string", "and", "chunks", "it", "into", "size", "-", "sized", "pieces", "in", "a", "slice", ".", "If", "the", "length", "of", "the", "string", "is", "not", "divisible", "by", "the", "size", "then", "the", "first", "chunk", ...
9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2
https://github.com/theplant/cldr/blob/9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2/number.go#L242-L266
138,778
theplant/cldr
locale.go
GetLocale
func GetLocale(locale string) (*Locale, bool) { l, ok := locales[locale] return l, ok }
go
func GetLocale(locale string) (*Locale, bool) { l, ok := locales[locale] return l, ok }
[ "func", "GetLocale", "(", "locale", "string", ")", "(", "*", "Locale", ",", "bool", ")", "{", "l", ",", "ok", ":=", "locales", "[", "locale", "]", "\n", "return", "l", ",", "ok", "\n", "}" ]
// GetLocale returns a pointer to an existing locale object and a boolean whether the locale exists.
[ "GetLocale", "returns", "a", "pointer", "to", "an", "existing", "locale", "object", "and", "a", "boolean", "whether", "the", "locale", "exists", "." ]
9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2
https://github.com/theplant/cldr/blob/9f76f7ce4ee8058b01f92739cf0d0cceaeda3cb2/locale.go#L109-L112
138,779
mitchellh/iochan
iochan.go
DelimReader
func DelimReader(r io.Reader, delim byte) <-chan string { ch := make(chan string) go func() { buf := bufio.NewReader(r) for { line, err := buf.ReadString(delim) if line != "" { ch <- line } if err != nil { break } } close(ch) }() return ch }
go
func DelimReader(r io.Reader, delim byte) <-chan string { ch := make(chan string) go func() { buf := bufio.NewReader(r) for { line, err := buf.ReadString(delim) if line != "" { ch <- line } if err != nil { break } } close(ch) }() return ch }
[ "func", "DelimReader", "(", "r", "io", ".", "Reader", ",", "delim", "byte", ")", "<-", "chan", "string", "{", "ch", ":=", "make", "(", "chan", "string", ")", "\n\n", "go", "func", "(", ")", "{", "buf", ":=", "bufio", ".", "NewReader", "(", "r", "...
// DelimReader takes an io.Reader and produces the contents of the reader // on the returned channel. The contents on the channel will be returned // on boundaries specified by the delim parameter, and will include this // delimiter. // // If an error occurs while reading from the reader, the reading will end. // // In...
[ "DelimReader", "takes", "an", "io", ".", "Reader", "and", "produces", "the", "contents", "of", "the", "reader", "on", "the", "returned", "channel", ".", "The", "contents", "on", "the", "channel", "will", "be", "returned", "on", "boundaries", "specified", "by...
b6e3aadd28864e14dae41ff5c7261455b1242d24
https://github.com/mitchellh/iochan/blob/b6e3aadd28864e14dae41ff5c7261455b1242d24/iochan.go#L20-L41
138,780
mattetti/filebuffer
filebuffer.go
Bytes
func (f *Buffer) Bytes() []byte { if f.isClosed || f.Index >= int64(f.Buff.Len()) { return []byte{} } return f.Buff.Bytes()[f.Index:] }
go
func (f *Buffer) Bytes() []byte { if f.isClosed || f.Index >= int64(f.Buff.Len()) { return []byte{} } return f.Buff.Bytes()[f.Index:] }
[ "func", "(", "f", "*", "Buffer", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "if", "f", ".", "isClosed", "||", "f", ".", "Index", ">=", "int64", "(", "f", ".", "Buff", ".", "Len", "(", ")", ")", "{", "return", "[", "]", "byte", "{", "}",...
// Bytes returns the bytes available until the end of the buffer.
[ "Bytes", "returns", "the", "bytes", "available", "until", "the", "end", "of", "the", "buffer", "." ]
3a1e8e5a6548ea21cce597660d0c0dcc8c77a520
https://github.com/mattetti/filebuffer/blob/3a1e8e5a6548ea21cce597660d0c0dcc8c77a520/filebuffer.go#L35-L40
138,781
fgrosse/zaptest
logger.go
Write
func (o testOutput) Write(p []byte) (int, error) { msg := strings.TrimSpace(string(p)) o.Log(msg) return len(p), nil }
go
func (o testOutput) Write(p []byte) (int, error) { msg := strings.TrimSpace(string(p)) o.Log(msg) return len(p), nil }
[ "func", "(", "o", "testOutput", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "msg", ":=", "strings", ".", "TrimSpace", "(", "string", "(", "p", ")", ")", "\n", "o", ".", "Log", "(", "msg", ")", "\n", "ret...
// Write logs all messages as logs via o.
[ "Write", "logs", "all", "messages", "as", "logs", "via", "o", "." ]
c15df62b6d517f1bc693998900e3e2cd28319b7f
https://github.com/fgrosse/zaptest/blob/c15df62b6d517f1bc693998900e3e2cd28319b7f/logger.go#L79-L83
138,782
tucnak/store
store.go
Register
func Register(extension string, m MarshalFunc, um UnmarshalFunc) { formats[extension] = format{m, um} }
go
func Register(extension string, m MarshalFunc, um UnmarshalFunc) { formats[extension] = format{m, um} }
[ "func", "Register", "(", "extension", "string", ",", "m", "MarshalFunc", ",", "um", "UnmarshalFunc", ")", "{", "formats", "[", "extension", "]", "=", "format", "{", "m", ",", "um", "}", "\n", "}" ]
// Register is the way you register configuration formats, by mapping some // file name extension to corresponding marshal and unmarshal functions. // Once registered, the format given would be compatible with Load and Save.
[ "Register", "is", "the", "way", "you", "register", "configuration", "formats", "by", "mapping", "some", "file", "name", "extension", "to", "corresponding", "marshal", "and", "unmarshal", "functions", ".", "Once", "registered", "the", "format", "given", "would", ...
b02ecdcc6dfb2cbc3a16da35ec1499618f64e1b6
https://github.com/tucnak/store/blob/b02ecdcc6dfb2cbc3a16da35ec1499618f64e1b6/store.go#L62-L64
138,783
tucnak/store
store.go
LoadWith
func LoadWith(path string, v interface{}, um UnmarshalFunc) error { if applicationName == "" { panic("store: application name not defined") } globalPath := buildPlatformPath(path) data, err := ioutil.ReadFile(globalPath) if err != nil { // There is a chance that file we are looking for // just doesn't exi...
go
func LoadWith(path string, v interface{}, um UnmarshalFunc) error { if applicationName == "" { panic("store: application name not defined") } globalPath := buildPlatformPath(path) data, err := ioutil.ReadFile(globalPath) if err != nil { // There is a chance that file we are looking for // just doesn't exi...
[ "func", "LoadWith", "(", "path", "string", ",", "v", "interface", "{", "}", ",", "um", "UnmarshalFunc", ")", "error", "{", "if", "applicationName", "==", "\"", "\"", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "globalPath", ":=", "buildPlatf...
// LoadWith loads the configuration using any unmarshaler at all.
[ "LoadWith", "loads", "the", "configuration", "using", "any", "unmarshaler", "at", "all", "." ]
b02ecdcc6dfb2cbc3a16da35ec1499618f64e1b6
https://github.com/tucnak/store/blob/b02ecdcc6dfb2cbc3a16da35ec1499618f64e1b6/store.go#L109-L138
138,784
tucnak/store
store.go
SaveWith
func SaveWith(path string, v interface{}, m MarshalFunc) error { if applicationName == "" { panic("store: application name not defined") } var b bytes.Buffer if data, err := m(v); err == nil { b.Write(data) } else { return fmt.Errorf("store: failed to marshal %s: %v", path, err) } b.WriteRune('\n') gl...
go
func SaveWith(path string, v interface{}, m MarshalFunc) error { if applicationName == "" { panic("store: application name not defined") } var b bytes.Buffer if data, err := m(v); err == nil { b.Write(data) } else { return fmt.Errorf("store: failed to marshal %s: %v", path, err) } b.WriteRune('\n') gl...
[ "func", "SaveWith", "(", "path", "string", ",", "v", "interface", "{", "}", ",", "m", "MarshalFunc", ")", "error", "{", "if", "applicationName", "==", "\"", "\"", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "b", "bytes", ".", "Buf...
// SaveWith saves the configuration using any marshaler at all.
[ "SaveWith", "saves", "the", "configuration", "using", "any", "marshaler", "at", "all", "." ]
b02ecdcc6dfb2cbc3a16da35ec1499618f64e1b6
https://github.com/tucnak/store/blob/b02ecdcc6dfb2cbc3a16da35ec1499618f64e1b6/store.go#L141-L166
138,785
tucnak/store
store.go
buildPlatformPath
func buildPlatformPath(path string) string { if runtime.GOOS == "windows" { return fmt.Sprintf("%s\\%s\\%s", os.Getenv("APPDATA"), applicationName, path) } var unixConfigDir string if xdg := os.Getenv("XDG_CONFIG_HOME"); xdg != "" { unixConfigDir = xdg } else { unixConfigDir = os.Getenv("HOME") + "/.c...
go
func buildPlatformPath(path string) string { if runtime.GOOS == "windows" { return fmt.Sprintf("%s\\%s\\%s", os.Getenv("APPDATA"), applicationName, path) } var unixConfigDir string if xdg := os.Getenv("XDG_CONFIG_HOME"); xdg != "" { unixConfigDir = xdg } else { unixConfigDir = os.Getenv("HOME") + "/.c...
[ "func", "buildPlatformPath", "(", "path", "string", ")", "string", "{", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\\\", "\\\\", "\"", ",", "os", ".", "Getenv", "(", "\"", "\"", ")", ",", "app...
// buildPlatformPath builds a platform-dependent path for relative path given.
[ "buildPlatformPath", "builds", "a", "platform", "-", "dependent", "path", "for", "relative", "path", "given", "." ]
b02ecdcc6dfb2cbc3a16da35ec1499618f64e1b6
https://github.com/tucnak/store/blob/b02ecdcc6dfb2cbc3a16da35ec1499618f64e1b6/store.go#L179-L196
138,786
creack/goselect
select.go
Select
func Select(n int, r, w, e *FDSet, timeout time.Duration) error { var timeval *syscall.Timeval if timeout >= 0 { t := syscall.NsecToTimeval(timeout.Nanoseconds()) timeval = &t } return sysSelect(n, r, w, e, timeval) }
go
func Select(n int, r, w, e *FDSet, timeout time.Duration) error { var timeval *syscall.Timeval if timeout >= 0 { t := syscall.NsecToTimeval(timeout.Nanoseconds()) timeval = &t } return sysSelect(n, r, w, e, timeval) }
[ "func", "Select", "(", "n", "int", ",", "r", ",", "w", ",", "e", "*", "FDSet", ",", "timeout", "time", ".", "Duration", ")", "error", "{", "var", "timeval", "*", "syscall", ".", "Timeval", "\n", "if", "timeout", ">=", "0", "{", "t", ":=", "syscal...
// Select wraps syscall.Select with Go types
[ "Select", "wraps", "syscall", ".", "Select", "with", "Go", "types" ]
c98c4e62c41618cf78d3ff759af0d4dbaa677748
https://github.com/creack/goselect/blob/c98c4e62c41618cf78d3ff759af0d4dbaa677748/select.go#L9-L17
138,787
creack/goselect
select.go
RetrySelect
func RetrySelect(n int, r, w, e *FDSet, timeout time.Duration, retries int, retryDelay time.Duration) (err error) { for i := 0; i < retries; i++ { if err = Select(n, r, w, e, timeout); err != syscall.EINTR { return err } time.Sleep(retryDelay) } return err }
go
func RetrySelect(n int, r, w, e *FDSet, timeout time.Duration, retries int, retryDelay time.Duration) (err error) { for i := 0; i < retries; i++ { if err = Select(n, r, w, e, timeout); err != syscall.EINTR { return err } time.Sleep(retryDelay) } return err }
[ "func", "RetrySelect", "(", "n", "int", ",", "r", ",", "w", ",", "e", "*", "FDSet", ",", "timeout", "time", ".", "Duration", ",", "retries", "int", ",", "retryDelay", "time", ".", "Duration", ")", "(", "err", "error", ")", "{", "for", "i", ":=", ...
// RetrySelect wraps syscall.Select with Go types, and retries a number of times, with a given retryDelay.
[ "RetrySelect", "wraps", "syscall", ".", "Select", "with", "Go", "types", "and", "retries", "a", "number", "of", "times", "with", "a", "given", "retryDelay", "." ]
c98c4e62c41618cf78d3ff759af0d4dbaa677748
https://github.com/creack/goselect/blob/c98c4e62c41618cf78d3ff759af0d4dbaa677748/select.go#L20-L28
138,788
kris-nova/lolgopher
writer.go
writeRaw
func (w *Writer) writeRaw(s string) (int, error) { c, err := w.getColorer() if err != nil { return -1, err } nWritten := 0 for _, r := range s { c.rainbow(freq, float64(w.origin)+float64(w.lineIdx)/spread) _, err := w.Output.Write(c.format()) if err != nil { return nWritten, err } n, err := w.Output...
go
func (w *Writer) writeRaw(s string) (int, error) { c, err := w.getColorer() if err != nil { return -1, err } nWritten := 0 for _, r := range s { c.rainbow(freq, float64(w.origin)+float64(w.lineIdx)/spread) _, err := w.Output.Write(c.format()) if err != nil { return nWritten, err } n, err := w.Output...
[ "func", "(", "w", "*", "Writer", ")", "writeRaw", "(", "s", "string", ")", "(", "int", ",", "error", ")", "{", "c", ",", "err", ":=", "w", ".", "getColorer", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "1", ",", "err", "\n",...
// writeRaw will write a lol'd s to the underlying writer. It does no line // detection.
[ "writeRaw", "will", "write", "a", "lol", "d", "s", "to", "the", "underlying", "writer", ".", "It", "does", "no", "line", "detection", "." ]
313b3abb0d9bb53e3c43230132061a7a9cb100fc
https://github.com/kris-nova/lolgopher/blob/313b3abb0d9bb53e3c43230132061a7a9cb100fc/writer.go#L36-L60
138,789
kris-nova/lolgopher
writer.go
Write
func (w *Writer) Write(p []byte) (int, error) { nWritten := 0 ss := strings.Split(string(p), "\n") for i, s := range ss { // TODO: strip out pre-existing ANSI codes and expand tabs. Would be // great to expand tabs in a context aware way (line linux expand // command). n, err := w.writeRaw(s) if err != ni...
go
func (w *Writer) Write(p []byte) (int, error) { nWritten := 0 ss := strings.Split(string(p), "\n") for i, s := range ss { // TODO: strip out pre-existing ANSI codes and expand tabs. Would be // great to expand tabs in a context aware way (line linux expand // command). n, err := w.writeRaw(s) if err != ni...
[ "func", "(", "w", "*", "Writer", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "nWritten", ":=", "0", "\n", "ss", ":=", "strings", ".", "Split", "(", "string", "(", "p", ")", ",", "\"", "\\n", "\"", ")", ...
// Write will write a byte slice to the Writer
[ "Write", "will", "write", "a", "byte", "slice", "to", "the", "Writer" ]
313b3abb0d9bb53e3c43230132061a7a9cb100fc
https://github.com/kris-nova/lolgopher/blob/313b3abb0d9bb53e3c43230132061a7a9cb100fc/writer.go#L77-L104
138,790
kris-nova/lolgopher
writer.go
NewLolWriter
func NewLolWriter() io.Writer { colorMode := ColorMode256 if noColor { colorMode = ColorMode0 } return &Writer{ Output: stdout, ColorMode: colorMode, } }
go
func NewLolWriter() io.Writer { colorMode := ColorMode256 if noColor { colorMode = ColorMode0 } return &Writer{ Output: stdout, ColorMode: colorMode, } }
[ "func", "NewLolWriter", "(", ")", "io", ".", "Writer", "{", "colorMode", ":=", "ColorMode256", "\n", "if", "noColor", "{", "colorMode", "=", "ColorMode0", "\n", "}", "\n", "return", "&", "Writer", "{", "Output", ":", "stdout", ",", "ColorMode", ":", "col...
// NewLolWriter will return a new io.Writer with a default ColorMode of 256
[ "NewLolWriter", "will", "return", "a", "new", "io", ".", "Writer", "with", "a", "default", "ColorMode", "of", "256" ]
313b3abb0d9bb53e3c43230132061a7a9cb100fc
https://github.com/kris-nova/lolgopher/blob/313b3abb0d9bb53e3c43230132061a7a9cb100fc/writer.go#L107-L116
138,791
kris-nova/lolgopher
writer.go
NewTruecolorLolWriter
func NewTruecolorLolWriter() io.Writer { colorMode := ColorModeTrueColor if noColor { colorMode = ColorMode0 } return &Writer{ Output: stdout, ColorMode: colorMode, } }
go
func NewTruecolorLolWriter() io.Writer { colorMode := ColorModeTrueColor if noColor { colorMode = ColorMode0 } return &Writer{ Output: stdout, ColorMode: colorMode, } }
[ "func", "NewTruecolorLolWriter", "(", ")", "io", ".", "Writer", "{", "colorMode", ":=", "ColorModeTrueColor", "\n", "if", "noColor", "{", "colorMode", "=", "ColorMode0", "\n", "}", "\n", "return", "&", "Writer", "{", "Output", ":", "stdout", ",", "ColorMode"...
// NewTruecolorLolWriter will return a new io.Writer with a default ColorMode of truecolor
[ "NewTruecolorLolWriter", "will", "return", "a", "new", "io", ".", "Writer", "with", "a", "default", "ColorMode", "of", "truecolor" ]
313b3abb0d9bb53e3c43230132061a7a9cb100fc
https://github.com/kris-nova/lolgopher/blob/313b3abb0d9bb53e3c43230132061a7a9cb100fc/writer.go#L119-L128
138,792
kelseyhightower/memkv
store.go
New
func New() Store { s := Store{m: make(map[string]KVPair)} s.FuncMap = map[string]interface{}{ "exists": s.Exists, "ls": s.List, "lsdir": s.ListDir, "get": s.Get, "gets": s.GetAll, "getv": s.GetValue, "getvs": s.GetAllValues, } return s }
go
func New() Store { s := Store{m: make(map[string]KVPair)} s.FuncMap = map[string]interface{}{ "exists": s.Exists, "ls": s.List, "lsdir": s.ListDir, "get": s.Get, "gets": s.GetAll, "getv": s.GetValue, "getvs": s.GetAllValues, } return s }
[ "func", "New", "(", ")", "Store", "{", "s", ":=", "Store", "{", "m", ":", "make", "(", "map", "[", "string", "]", "KVPair", ")", "}", "\n", "s", ".", "FuncMap", "=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "s",...
// New creates and initializes a new Store.
[ "New", "creates", "and", "initializes", "a", "new", "Store", "." ]
892bfd468afa0fa476556e7bd7734a087cda08b3
https://github.com/kelseyhightower/memkv/blob/892bfd468afa0fa476556e7bd7734a087cda08b3/store.go#L37-L49
138,793
kelseyhightower/memkv
store.go
Del
func (s Store) Del(key string) { s.Lock() delete(s.m, key) s.Unlock() }
go
func (s Store) Del(key string) { s.Lock() delete(s.m, key) s.Unlock() }
[ "func", "(", "s", "Store", ")", "Del", "(", "key", "string", ")", "{", "s", ".", "Lock", "(", ")", "\n", "delete", "(", "s", ".", "m", ",", "key", ")", "\n", "s", ".", "Unlock", "(", ")", "\n", "}" ]
// Delete deletes the KVPair associated with key.
[ "Delete", "deletes", "the", "KVPair", "associated", "with", "key", "." ]
892bfd468afa0fa476556e7bd7734a087cda08b3
https://github.com/kelseyhightower/memkv/blob/892bfd468afa0fa476556e7bd7734a087cda08b3/store.go#L52-L56
138,794
kelseyhightower/memkv
store.go
Exists
func (s Store) Exists(key string) bool { _, err := s.Get(key) if err != nil { return false } return true }
go
func (s Store) Exists(key string) bool { _, err := s.Get(key) if err != nil { return false } return true }
[ "func", "(", "s", "Store", ")", "Exists", "(", "key", "string", ")", "bool", "{", "_", ",", "err", ":=", "s", ".", "Get", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Exists checks for the existence of key in the store.
[ "Exists", "checks", "for", "the", "existence", "of", "key", "in", "the", "store", "." ]
892bfd468afa0fa476556e7bd7734a087cda08b3
https://github.com/kelseyhightower/memkv/blob/892bfd468afa0fa476556e7bd7734a087cda08b3/store.go#L59-L65
138,795
kelseyhightower/memkv
store.go
GetValue
func (s Store) GetValue(key string, v ...string) (string, error) { kv, err := s.Get(key) if err != nil { if len(v) > 0 { // Take default return v[0], nil } return "", err } return kv.Value, nil }
go
func (s Store) GetValue(key string, v ...string) (string, error) { kv, err := s.Get(key) if err != nil { if len(v) > 0 { // Take default return v[0], nil } return "", err } return kv.Value, nil }
[ "func", "(", "s", "Store", ")", "GetValue", "(", "key", "string", ",", "v", "...", "string", ")", "(", "string", ",", "error", ")", "{", "kv", ",", "err", ":=", "s", ".", "Get", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "if", "len...
// GetValue gets the value associated with key. If there are no values // associated with key, GetValue returns "", ErrNotExist.
[ "GetValue", "gets", "the", "value", "associated", "with", "key", ".", "If", "there", "are", "no", "values", "associated", "with", "key", "GetValue", "returns", "ErrNotExist", "." ]
892bfd468afa0fa476556e7bd7734a087cda08b3
https://github.com/kelseyhightower/memkv/blob/892bfd468afa0fa476556e7bd7734a087cda08b3/store.go#L81-L91
138,796
kelseyhightower/memkv
store.go
GetAll
func (s Store) GetAll(pattern string) (KVPairs, error) { ks := make(KVPairs, 0) s.RLock() defer s.RUnlock() for _, kv := range s.m { m, err := path.Match(pattern, kv.Key) if err != nil { return nil, err } if m { ks = append(ks, kv) } } if len(ks) == 0 { return ks, nil } sort.Sort(ks) return k...
go
func (s Store) GetAll(pattern string) (KVPairs, error) { ks := make(KVPairs, 0) s.RLock() defer s.RUnlock() for _, kv := range s.m { m, err := path.Match(pattern, kv.Key) if err != nil { return nil, err } if m { ks = append(ks, kv) } } if len(ks) == 0 { return ks, nil } sort.Sort(ks) return k...
[ "func", "(", "s", "Store", ")", "GetAll", "(", "pattern", "string", ")", "(", "KVPairs", ",", "error", ")", "{", "ks", ":=", "make", "(", "KVPairs", ",", "0", ")", "\n", "s", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "RUnlock", "(", ")",...
// GetAll returns a KVPair for all nodes with keys matching pattern. // The syntax of patterns is the same as in path.Match.
[ "GetAll", "returns", "a", "KVPair", "for", "all", "nodes", "with", "keys", "matching", "pattern", ".", "The", "syntax", "of", "patterns", "is", "the", "same", "as", "in", "path", ".", "Match", "." ]
892bfd468afa0fa476556e7bd7734a087cda08b3
https://github.com/kelseyhightower/memkv/blob/892bfd468afa0fa476556e7bd7734a087cda08b3/store.go#L95-L113
138,797
kelseyhightower/memkv
store.go
Set
func (s Store) Set(key string, value string) { s.Lock() s.m[key] = KVPair{key, value} s.Unlock() }
go
func (s Store) Set(key string, value string) { s.Lock() s.m[key] = KVPair{key, value} s.Unlock() }
[ "func", "(", "s", "Store", ")", "Set", "(", "key", "string", ",", "value", "string", ")", "{", "s", ".", "Lock", "(", ")", "\n", "s", ".", "m", "[", "key", "]", "=", "KVPair", "{", "key", ",", "value", "}", "\n", "s", ".", "Unlock", "(", ")...
// Set sets the KVPair entry associated with key to value.
[ "Set", "sets", "the", "KVPair", "entry", "associated", "with", "key", "to", "value", "." ]
892bfd468afa0fa476556e7bd7734a087cda08b3
https://github.com/kelseyhightower/memkv/blob/892bfd468afa0fa476556e7bd7734a087cda08b3/store.go#L176-L180
138,798
appscode/go-hetzner
client.go
NewRequest
func (c *Client) NewRequest(method, path string, request interface{}) (*http.Request, error) { var u *url.URL var err error if c.BaseURL != "" { u, err = url.Parse(c.BaseURL) if err != nil { return nil, err } } qv, err := query.Values(request) if err != nil { return nil, err } qs := encode(qv) if ...
go
func (c *Client) NewRequest(method, path string, request interface{}) (*http.Request, error) { var u *url.URL var err error if c.BaseURL != "" { u, err = url.Parse(c.BaseURL) if err != nil { return nil, err } } qv, err := query.Values(request) if err != nil { return nil, err } qs := encode(qv) if ...
[ "func", "(", "c", "*", "Client", ")", "NewRequest", "(", "method", ",", "path", "string", ",", "request", "interface", "{", "}", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "var", "u", "*", "url", ".", "URL", "\n", "var", "err"...
// NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL // of the Client. If specified, the value pointed to by request is www-form-urlencoded and included in as the request body.
[ "NewRequest", "creates", "an", "API", "request", ".", "A", "relative", "URL", "can", "be", "provided", "in", "urlStr", "which", "will", "be", "resolved", "to", "the", "BaseURL", "of", "the", "Client", ".", "If", "specified", "the", "value", "pointed", "to"...
c038e08b19b1c760484d443de8958880e35bd879
https://github.com/appscode/go-hetzner/blob/c038e08b19b1c760484d443de8958880e35bd879/client.go#L96-L155
138,799
appscode/go-hetzner
client.go
checkResponse
func checkResponse(r *http.Response) error { if c := r.StatusCode; c >= 200 && c <= 299 { return nil } apiErr := &APIError{Response: r} data, err := ioutil.ReadAll(r.Body) if err == nil && len(data) > 0 { type E struct { Error *APIError `json:"error"` } e := E{} if err = json.Unmarshal(data, &e); err...
go
func checkResponse(r *http.Response) error { if c := r.StatusCode; c >= 200 && c <= 299 { return nil } apiErr := &APIError{Response: r} data, err := ioutil.ReadAll(r.Body) if err == nil && len(data) > 0 { type E struct { Error *APIError `json:"error"` } e := E{} if err = json.Unmarshal(data, &e); err...
[ "func", "checkResponse", "(", "r", "*", "http", ".", "Response", ")", "error", "{", "if", "c", ":=", "r", ".", "StatusCode", ";", "c", ">=", "200", "&&", "c", "<=", "299", "{", "return", "nil", "\n", "}", "\n\n", "apiErr", ":=", "&", "APIError", ...
// CheckResponse checks the API response for errors, and returns them if present. A response is considered an // error if it has a status code outside the 200 range. API error responses are expected to have either no response // body, or a JSON response body that maps to APIError.
[ "CheckResponse", "checks", "the", "API", "response", "for", "errors", "and", "returns", "them", "if", "present", ".", "A", "response", "is", "considered", "an", "error", "if", "it", "has", "a", "status", "code", "outside", "the", "200", "range", ".", "API"...
c038e08b19b1c760484d443de8958880e35bd879
https://github.com/appscode/go-hetzner/blob/c038e08b19b1c760484d443de8958880e35bd879/client.go#L231-L249