id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
29,300
ahmetb/go-linq
result.go
FirstWith
func (q Query) FirstWith(predicate func(interface{}) bool) interface{} { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { if predicate(item) { return item } } return nil }
go
func (q Query) FirstWith(predicate func(interface{}) bool) interface{} { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { if predicate(item) { return item } } return nil }
[ "func", "(", "q", "Query", ")", "FirstWith", "(", "predicate", "func", "(", "interface", "{", "}", ")", "bool", ")", "interface", "{", "}", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n\n", "for", "item", ",", "ok", ":=", "next", "(", ")"...
// FirstWith returns the first element of a collection that satisfies a // specified condition.
[ "FirstWith", "returns", "the", "first", "element", "of", "a", "collection", "that", "satisfies", "a", "specified", "condition", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L194-L204
29,301
ahmetb/go-linq
result.go
ForEach
func (q Query) ForEach(action func(interface{})) { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { action(item) } }
go
func (q Query) ForEach(action func(interface{})) { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { action(item) } }
[ "func", "(", "q", "Query", ")", "ForEach", "(", "action", "func", "(", "interface", "{", "}", ")", ")", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n\n", "for", "item", ",", "ok", ":=", "next", "(", ")", ";", "ok", ";", "item", ",", "...
// ForEach performs the specified action on each element of a collection.
[ "ForEach", "performs", "the", "specified", "action", "on", "each", "element", "of", "a", "collection", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L229-L235
29,302
ahmetb/go-linq
result.go
ForEachIndexed
func (q Query) ForEachIndexed(action func(int, interface{})) { next := q.Iterate() index := 0 for item, ok := next(); ok; item, ok = next() { action(index, item) index++ } }
go
func (q Query) ForEachIndexed(action func(int, interface{})) { next := q.Iterate() index := 0 for item, ok := next(); ok; item, ok = next() { action(index, item) index++ } }
[ "func", "(", "q", "Query", ")", "ForEachIndexed", "(", "action", "func", "(", "int", ",", "interface", "{", "}", ")", ")", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n", "index", ":=", "0", "\n\n", "for", "item", ",", "ok", ":=", "next",...
// ForEachIndexed performs the specified action on each element of a collection. // // The first argument to action represents the zero-based index of that // element in the source collection. This can be useful if the elements are in a // known order and you want to do something with an element at a particular // inde...
[ "ForEachIndexed", "performs", "the", "specified", "action", "on", "each", "element", "of", "a", "collection", ".", "The", "first", "argument", "to", "action", "represents", "the", "zero", "-", "based", "index", "of", "that", "element", "in", "the", "source", ...
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L267-L275
29,303
ahmetb/go-linq
result.go
Last
func (q Query) Last() (r interface{}) { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { r = item } return }
go
func (q Query) Last() (r interface{}) { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { r = item } return }
[ "func", "(", "q", "Query", ")", "Last", "(", ")", "(", "r", "interface", "{", "}", ")", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n\n", "for", "item", ",", "ok", ":=", "next", "(", ")", ";", "ok", ";", "item", ",", "ok", "=", "nex...
// Last returns the last element of a collection.
[ "Last", "returns", "the", "last", "element", "of", "a", "collection", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L300-L308
29,304
ahmetb/go-linq
result.go
LastWith
func (q Query) LastWith(predicate func(interface{}) bool) (r interface{}) { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { if predicate(item) { r = item } } return }
go
func (q Query) LastWith(predicate func(interface{}) bool) (r interface{}) { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { if predicate(item) { r = item } } return }
[ "func", "(", "q", "Query", ")", "LastWith", "(", "predicate", "func", "(", "interface", "{", "}", ")", "bool", ")", "(", "r", "interface", "{", "}", ")", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n\n", "for", "item", ",", "ok", ":=", ...
// LastWith returns the last element of a collection that satisfies a specified // condition.
[ "LastWith", "returns", "the", "last", "element", "of", "a", "collection", "that", "satisfies", "a", "specified", "condition", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L312-L322
29,305
ahmetb/go-linq
result.go
Min
func (q Query) Min() (r interface{}) { next := q.Iterate() item, ok := next() if !ok { return nil } compare := getComparer(item) r = item for item, ok := next(); ok; item, ok = next() { if compare(item, r) < 0 { r = item } } return }
go
func (q Query) Min() (r interface{}) { next := q.Iterate() item, ok := next() if !ok { return nil } compare := getComparer(item) r = item for item, ok := next(); ok; item, ok = next() { if compare(item, r) < 0 { r = item } } return }
[ "func", "(", "q", "Query", ")", "Min", "(", ")", "(", "r", "interface", "{", "}", ")", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n", "item", ",", "ok", ":=", "next", "(", ")", "\n", "if", "!", "ok", "{", "return", "nil", "\n", "}"...
// Min returns the minimum value in a collection of values.
[ "Min", "returns", "the", "minimum", "value", "in", "a", "collection", "of", "values", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L367-L384
29,306
ahmetb/go-linq
result.go
Results
func (q Query) Results() (r []interface{}) { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { r = append(r, item) } return }
go
func (q Query) Results() (r []interface{}) { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { r = append(r, item) } return }
[ "func", "(", "q", "Query", ")", "Results", "(", ")", "(", "r", "[", "]", "interface", "{", "}", ")", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n\n", "for", "item", ",", "ok", ":=", "next", "(", ")", ";", "ok", ";", "item", ",", "o...
// Results iterates over a collection and returnes slice of interfaces
[ "Results", "iterates", "over", "a", "collection", "and", "returnes", "slice", "of", "interfaces" ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L387-L395
29,307
ahmetb/go-linq
result.go
SequenceEqual
func (q Query) SequenceEqual(q2 Query) bool { next := q.Iterate() next2 := q2.Iterate() for item, ok := next(); ok; item, ok = next() { item2, ok2 := next2() if !ok2 || item != item2 { return false } } _, ok2 := next2() return !ok2 }
go
func (q Query) SequenceEqual(q2 Query) bool { next := q.Iterate() next2 := q2.Iterate() for item, ok := next(); ok; item, ok = next() { item2, ok2 := next2() if !ok2 || item != item2 { return false } } _, ok2 := next2() return !ok2 }
[ "func", "(", "q", "Query", ")", "SequenceEqual", "(", "q2", "Query", ")", "bool", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n", "next2", ":=", "q2", ".", "Iterate", "(", ")", "\n\n", "for", "item", ",", "ok", ":=", "next", "(", ")", "...
// SequenceEqual determines whether two collections are equal.
[ "SequenceEqual", "determines", "whether", "two", "collections", "are", "equal", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L398-L411
29,308
ahmetb/go-linq
result.go
Single
func (q Query) Single() interface{} { next := q.Iterate() item, ok := next() if !ok { return nil } _, ok = next() if ok { return nil } return item }
go
func (q Query) Single() interface{} { next := q.Iterate() item, ok := next() if !ok { return nil } _, ok = next() if ok { return nil } return item }
[ "func", "(", "q", "Query", ")", "Single", "(", ")", "interface", "{", "}", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n", "item", ",", "ok", ":=", "next", "(", ")", "\n", "if", "!", "ok", "{", "return", "nil", "\n", "}", "\n\n", "_",...
// Single returns the only element of a collection, and nil if there is not // exactly one element in the collection.
[ "Single", "returns", "the", "only", "element", "of", "a", "collection", "and", "nil", "if", "there", "is", "not", "exactly", "one", "element", "in", "the", "collection", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L415-L428
29,309
ahmetb/go-linq
result.go
SingleWith
func (q Query) SingleWith(predicate func(interface{}) bool) (r interface{}) { next := q.Iterate() found := false for item, ok := next(); ok; item, ok = next() { if predicate(item) { if found { return nil } found = true r = item } } return }
go
func (q Query) SingleWith(predicate func(interface{}) bool) (r interface{}) { next := q.Iterate() found := false for item, ok := next(); ok; item, ok = next() { if predicate(item) { if found { return nil } found = true r = item } } return }
[ "func", "(", "q", "Query", ")", "SingleWith", "(", "predicate", "func", "(", "interface", "{", "}", ")", "bool", ")", "(", "r", "interface", "{", "}", ")", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n", "found", ":=", "false", "\n\n", "f...
// SingleWith returns the only element of a collection that satisfies a // specified condition, and nil if more than one such element exists.
[ "SingleWith", "returns", "the", "only", "element", "of", "a", "collection", "that", "satisfies", "a", "specified", "condition", "and", "nil", "if", "more", "than", "one", "such", "element", "exists", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L432-L448
29,310
ahmetb/go-linq
result.go
ToChannel
func (q Query) ToChannel(result chan<- interface{}) { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { result <- item } close(result) }
go
func (q Query) ToChannel(result chan<- interface{}) { next := q.Iterate() for item, ok := next(); ok; item, ok = next() { result <- item } close(result) }
[ "func", "(", "q", "Query", ")", "ToChannel", "(", "result", "chan", "<-", "interface", "{", "}", ")", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n\n", "for", "item", ",", "ok", ":=", "next", "(", ")", ";", "ok", ";", "item", ",", "ok",...
// ToChannel iterates over a collection and outputs each element to a channel, // then closes it.
[ "ToChannel", "iterates", "over", "a", "collection", "and", "outputs", "each", "element", "to", "a", "channel", "then", "closes", "it", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L537-L545
29,311
ahmetb/go-linq
result.go
ToMap
func (q Query) ToMap(result interface{}) { q.ToMapBy( result, func(i interface{}) interface{} { return i.(KeyValue).Key }, func(i interface{}) interface{} { return i.(KeyValue).Value }) }
go
func (q Query) ToMap(result interface{}) { q.ToMapBy( result, func(i interface{}) interface{} { return i.(KeyValue).Key }, func(i interface{}) interface{} { return i.(KeyValue).Value }) }
[ "func", "(", "q", "Query", ")", "ToMap", "(", "result", "interface", "{", "}", ")", "{", "q", ".", "ToMapBy", "(", "result", ",", "func", "(", "i", "interface", "{", "}", ")", "interface", "{", "}", "{", "return", "i", ".", "(", "KeyValue", ")", ...
// ToMap iterates over a collection and populates result map with elements. // Collection elements have to be of KeyValue type to use this method. To // populate a map with elements of different type use ToMapBy method. ToMap // doesn't empty the result map before populating it.
[ "ToMap", "iterates", "over", "a", "collection", "and", "populates", "result", "map", "with", "elements", ".", "Collection", "elements", "have", "to", "be", "of", "KeyValue", "type", "to", "use", "this", "method", ".", "To", "populate", "a", "map", "with", ...
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L551-L560
29,312
ahmetb/go-linq
result.go
ToMapBy
func (q Query) ToMapBy(result interface{}, keySelector func(interface{}) interface{}, valueSelector func(interface{}) interface{}) { res := reflect.ValueOf(result) m := reflect.Indirect(res) next := q.Iterate() for item, ok := next(); ok; item, ok = next() { key := reflect.ValueOf(keySelector(item)) value :=...
go
func (q Query) ToMapBy(result interface{}, keySelector func(interface{}) interface{}, valueSelector func(interface{}) interface{}) { res := reflect.ValueOf(result) m := reflect.Indirect(res) next := q.Iterate() for item, ok := next(); ok; item, ok = next() { key := reflect.ValueOf(keySelector(item)) value :=...
[ "func", "(", "q", "Query", ")", "ToMapBy", "(", "result", "interface", "{", "}", ",", "keySelector", "func", "(", "interface", "{", "}", ")", "interface", "{", "}", ",", "valueSelector", "func", "(", "interface", "{", "}", ")", "interface", "{", "}", ...
// ToMapBy iterates over a collection and populates the result map with // elements. Functions keySelector and valueSelector are executed for each // element of the collection to generate key and value for the map. Generated // key and value types must be assignable to the map's key and value types. // ToMapBy doesn't ...
[ "ToMapBy", "iterates", "over", "a", "collection", "and", "populates", "the", "result", "map", "with", "elements", ".", "Functions", "keySelector", "and", "valueSelector", "are", "executed", "for", "each", "element", "of", "the", "collection", "to", "generate", "...
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L567-L582
29,313
ahmetb/go-linq
result.go
ToSlice
func (q Query) ToSlice(v interface{}) { res := reflect.ValueOf(v) slice := reflect.Indirect(res) cap := slice.Cap() res.Elem().Set(slice.Slice(0, cap)) // make len(slice)==cap(slice) from now on next := q.Iterate() index := 0 for item, ok := next(); ok; item, ok = next() { if index >= cap { slice, cap = g...
go
func (q Query) ToSlice(v interface{}) { res := reflect.ValueOf(v) slice := reflect.Indirect(res) cap := slice.Cap() res.Elem().Set(slice.Slice(0, cap)) // make len(slice)==cap(slice) from now on next := q.Iterate() index := 0 for item, ok := next(); ok; item, ok = next() { if index >= cap { slice, cap = g...
[ "func", "(", "q", "Query", ")", "ToSlice", "(", "v", "interface", "{", "}", ")", "{", "res", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "slice", ":=", "reflect", ".", "Indirect", "(", "res", ")", "\n\n", "cap", ":=", "slice", ".", "Cap...
// ToSlice iterates over a collection and saves the results in the slice pointed // by v. It overwrites the existing slice, starting from index 0. // // If the slice pointed by v has sufficient capacity, v will be pointed to a // resliced slice. If it does not, a new underlying array will be allocated and // v will poi...
[ "ToSlice", "iterates", "over", "a", "collection", "and", "saves", "the", "results", "in", "the", "slice", "pointed", "by", "v", ".", "It", "overwrites", "the", "existing", "slice", "starting", "from", "index", "0", ".", "If", "the", "slice", "pointed", "by...
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/result.go#L625-L644
29,314
ahmetb/go-linq
union.go
Union
func (q Query) Union(q2 Query) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() next2 := q2.Iterate() set := make(map[interface{}]bool) use1 := true return func() (item interface{}, ok bool) { if use1 { for item, ok = next(); ok; item, ok = next() { if _, has := se...
go
func (q Query) Union(q2 Query) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() next2 := q2.Iterate() set := make(map[interface{}]bool) use1 := true return func() (item interface{}, ok bool) { if use1 { for item, ok = next(); ok; item, ok = next() { if _, has := se...
[ "func", "(", "q", "Query", ")", "Union", "(", "q2", "Query", ")", "Query", "{", "return", "Query", "{", "Iterate", ":", "func", "(", ")", "Iterator", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n", "next2", ":=", "q2", ".", "Iterate", "("...
// Union produces the set union of two collections. // // This method excludes duplicates from the return set. This is different // behavior to the Concat method, which returns all the elements in the input // collection including duplicates.
[ "Union", "produces", "the", "set", "union", "of", "two", "collections", ".", "This", "method", "excludes", "duplicates", "from", "the", "return", "set", ".", "This", "is", "different", "behavior", "to", "the", "Concat", "method", "which", "returns", "all", "...
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/union.go#L8-L40
29,315
ahmetb/go-linq
select.go
Select
func (q Query) Select(selector func(interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() return func() (item interface{}, ok bool) { var it interface{} it, ok = next() if ok { item = selector(it) } return } }, } }
go
func (q Query) Select(selector func(interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() return func() (item interface{}, ok bool) { var it interface{} it, ok = next() if ok { item = selector(it) } return } }, } }
[ "func", "(", "q", "Query", ")", "Select", "(", "selector", "func", "(", "interface", "{", "}", ")", "interface", "{", "}", ")", "Query", "{", "return", "Query", "{", "Iterate", ":", "func", "(", ")", "Iterator", "{", "next", ":=", "q", ".", "Iterat...
// Select projects each element of a collection into a new form. Returns a query // with the result of invoking the transform function on each element of // original source. // // This projection method requires the transform function, selector, to produce // one value for each value in the source collection. If select...
[ "Select", "projects", "each", "element", "of", "a", "collection", "into", "a", "new", "form", ".", "Returns", "a", "query", "with", "the", "result", "of", "invoking", "the", "transform", "function", "on", "each", "element", "of", "original", "source", ".", ...
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/select.go#L15-L31
29,316
ahmetb/go-linq
select.go
SelectIndexed
func (q Query) SelectIndexed(selector func(int, interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() index := 0 return func() (item interface{}, ok bool) { var it interface{} it, ok = next() if ok { item = selector(index, it) index++ } ...
go
func (q Query) SelectIndexed(selector func(int, interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() index := 0 return func() (item interface{}, ok bool) { var it interface{} it, ok = next() if ok { item = selector(index, it) index++ } ...
[ "func", "(", "q", "Query", ")", "SelectIndexed", "(", "selector", "func", "(", "int", ",", "interface", "{", "}", ")", "interface", "{", "}", ")", "Query", "{", "return", "Query", "{", "Iterate", ":", "func", "(", ")", "Iterator", "{", "next", ":=", ...
// SelectIndexed projects each element of a collection into a new form by // incorporating the element's index. Returns a query with the result of // invoking the transform function on each element of original source. // // The first argument to selector represents the zero-based index of that // element in the source ...
[ "SelectIndexed", "projects", "each", "element", "of", "a", "collection", "into", "a", "new", "form", "by", "incorporating", "the", "element", "s", "index", ".", "Returns", "a", "query", "with", "the", "result", "of", "invoking", "the", "transform", "function",...
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/select.go#L72-L90
29,317
ahmetb/go-linq
reverse.go
Reverse
func (q Query) Reverse() Query { return Query{ Iterate: func() Iterator { next := q.Iterate() items := []interface{}{} for item, ok := next(); ok; item, ok = next() { items = append(items, item) } index := len(items) - 1 return func() (item interface{}, ok bool) { if index < 0 { retu...
go
func (q Query) Reverse() Query { return Query{ Iterate: func() Iterator { next := q.Iterate() items := []interface{}{} for item, ok := next(); ok; item, ok = next() { items = append(items, item) } index := len(items) - 1 return func() (item interface{}, ok bool) { if index < 0 { retu...
[ "func", "(", "q", "Query", ")", "Reverse", "(", ")", "Query", "{", "return", "Query", "{", "Iterate", ":", "func", "(", ")", "Iterator", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n\n", "items", ":=", "[", "]", "interface", "{", "}", "{"...
// Reverse inverts the order of the elements in a collection. // // Unlike OrderBy, this sorting method does not consider the actual values // themselves in determining the order. Rather, it just returns the elements in // the reverse order from which they are produced by the underlying source.
[ "Reverse", "inverts", "the", "order", "of", "the", "elements", "in", "a", "collection", ".", "Unlike", "OrderBy", "this", "sorting", "method", "does", "not", "consider", "the", "actual", "values", "themselves", "in", "determining", "the", "order", ".", "Rather...
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/reverse.go#L8-L30
29,318
ahmetb/go-linq
zip.go
Zip
func (q Query) Zip(q2 Query, resultSelector func(interface{}, interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { next1 := q.Iterate() next2 := q2.Iterate() return func() (item interface{}, ok bool) { item1, ok1 := next1() item2, ok2 := next2() if ok1 && ok2 { ret...
go
func (q Query) Zip(q2 Query, resultSelector func(interface{}, interface{}) interface{}) Query { return Query{ Iterate: func() Iterator { next1 := q.Iterate() next2 := q2.Iterate() return func() (item interface{}, ok bool) { item1, ok1 := next1() item2, ok2 := next2() if ok1 && ok2 { ret...
[ "func", "(", "q", "Query", ")", "Zip", "(", "q2", "Query", ",", "resultSelector", "func", "(", "interface", "{", "}", ",", "interface", "{", "}", ")", "interface", "{", "}", ")", "Query", "{", "return", "Query", "{", "Iterate", ":", "func", "(", ")...
// Zip applies a specified function to the corresponding elements of two // collections, producing a collection of the results. // // The method steps through the two input collections, applying function // resultSelector to corresponding elements of the two collections. The method // returns a collection of the values...
[ "Zip", "applies", "a", "specified", "function", "to", "the", "corresponding", "elements", "of", "two", "collections", "producing", "a", "collection", "of", "the", "results", ".", "The", "method", "steps", "through", "the", "two", "input", "collections", "applyin...
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/zip.go#L13-L33
29,319
ahmetb/go-linq
from.go
From
func From(source interface{}) Query { src := reflect.ValueOf(source) switch src.Kind() { case reflect.Slice, reflect.Array: len := src.Len() return Query{ Iterate: func() Iterator { index := 0 return func() (item interface{}, ok bool) { ok = index < len if ok { item = src.Index(inde...
go
func From(source interface{}) Query { src := reflect.ValueOf(source) switch src.Kind() { case reflect.Slice, reflect.Array: len := src.Len() return Query{ Iterate: func() Iterator { index := 0 return func() (item interface{}, ok bool) { ok = index < len if ok { item = src.Index(inde...
[ "func", "From", "(", "source", "interface", "{", "}", ")", "Query", "{", "src", ":=", "reflect", ".", "ValueOf", "(", "source", ")", "\n\n", "switch", "src", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Slice", ",", "reflect", ".", "Array", ...
// From initializes a linq query with passed slice, array or map as the source. // String, channel or struct implementing Iterable interface can be used as an // input. In this case From delegates it to FromString, FromChannel and // FromIterable internally.
[ "From", "initializes", "a", "linq", "query", "with", "passed", "slice", "array", "or", "map", "as", "the", "source", ".", "String", "channel", "or", "struct", "implementing", "Iterable", "interface", "can", "be", "used", "as", "an", "input", ".", "In", "th...
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/from.go#L32-L85
29,320
ahmetb/go-linq
from.go
FromChannel
func FromChannel(source <-chan interface{}) Query { return Query{ Iterate: func() Iterator { return func() (item interface{}, ok bool) { item, ok = <-source return } }, } }
go
func FromChannel(source <-chan interface{}) Query { return Query{ Iterate: func() Iterator { return func() (item interface{}, ok bool) { item, ok = <-source return } }, } }
[ "func", "FromChannel", "(", "source", "<-", "chan", "interface", "{", "}", ")", "Query", "{", "return", "Query", "{", "Iterate", ":", "func", "(", ")", "Iterator", "{", "return", "func", "(", ")", "(", "item", "interface", "{", "}", ",", "ok", "bool"...
// FromChannel initializes a linq query with passed channel, linq iterates over // channel until it is closed.
[ "FromChannel", "initializes", "a", "linq", "query", "with", "passed", "channel", "linq", "iterates", "over", "channel", "until", "it", "is", "closed", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/from.go#L89-L98
29,321
ahmetb/go-linq
from.go
FromString
func FromString(source string) Query { runes := []rune(source) len := len(runes) return Query{ Iterate: func() Iterator { index := 0 return func() (item interface{}, ok bool) { ok = index < len if ok { item = runes[index] index++ } return } }, } }
go
func FromString(source string) Query { runes := []rune(source) len := len(runes) return Query{ Iterate: func() Iterator { index := 0 return func() (item interface{}, ok bool) { ok = index < len if ok { item = runes[index] index++ } return } }, } }
[ "func", "FromString", "(", "source", "string", ")", "Query", "{", "runes", ":=", "[", "]", "rune", "(", "source", ")", "\n", "len", ":=", "len", "(", "runes", ")", "\n\n", "return", "Query", "{", "Iterate", ":", "func", "(", ")", "Iterator", "{", "...
// FromString initializes a linq query with passed string, linq iterates over // runes of string.
[ "FromString", "initializes", "a", "linq", "query", "with", "passed", "string", "linq", "iterates", "over", "runes", "of", "string", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/from.go#L102-L121
29,322
ahmetb/go-linq
from.go
Range
func Range(start, count int) Query { return Query{ Iterate: func() Iterator { index := 0 current := start return func() (item interface{}, ok bool) { if index >= count { return nil, false } item, ok = current, true index++ current++ return } }, } }
go
func Range(start, count int) Query { return Query{ Iterate: func() Iterator { index := 0 current := start return func() (item interface{}, ok bool) { if index >= count { return nil, false } item, ok = current, true index++ current++ return } }, } }
[ "func", "Range", "(", "start", ",", "count", "int", ")", "Query", "{", "return", "Query", "{", "Iterate", ":", "func", "(", ")", "Iterator", "{", "index", ":=", "0", "\n", "current", ":=", "start", "\n\n", "return", "func", "(", ")", "(", "item", "...
// Range generates a sequence of integral numbers within a specified range.
[ "Range", "generates", "a", "sequence", "of", "integral", "numbers", "within", "a", "specified", "range", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/from.go#L133-L152
29,323
ahmetb/go-linq
from.go
Repeat
func Repeat(value interface{}, count int) Query { return Query{ Iterate: func() Iterator { index := 0 return func() (item interface{}, ok bool) { if index >= count { return nil, false } item, ok = value, true index++ return } }, } }
go
func Repeat(value interface{}, count int) Query { return Query{ Iterate: func() Iterator { index := 0 return func() (item interface{}, ok bool) { if index >= count { return nil, false } item, ok = value, true index++ return } }, } }
[ "func", "Repeat", "(", "value", "interface", "{", "}", ",", "count", "int", ")", "Query", "{", "return", "Query", "{", "Iterate", ":", "func", "(", ")", "Iterator", "{", "index", ":=", "0", "\n\n", "return", "func", "(", ")", "(", "item", "interface"...
// Repeat generates a sequence that contains one repeated value.
[ "Repeat", "generates", "a", "sequence", "that", "contains", "one", "repeated", "value", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/from.go#L155-L172
29,324
ahmetb/go-linq
genericfunc.go
Call
func (g *genericFunc) Call(params ...interface{}) interface{} { paramsIn := make([]reflect.Value, len(params)) for i, param := range params { paramsIn[i] = reflect.ValueOf(param) } paramsOut := g.Cache.FnValue.Call(paramsIn) if len(paramsOut) >= 1 { return paramsOut[0].Interface() } return nil }
go
func (g *genericFunc) Call(params ...interface{}) interface{} { paramsIn := make([]reflect.Value, len(params)) for i, param := range params { paramsIn[i] = reflect.ValueOf(param) } paramsOut := g.Cache.FnValue.Call(paramsIn) if len(paramsOut) >= 1 { return paramsOut[0].Interface() } return nil }
[ "func", "(", "g", "*", "genericFunc", ")", "Call", "(", "params", "...", "interface", "{", "}", ")", "interface", "{", "}", "{", "paramsIn", ":=", "make", "(", "[", "]", "reflect", ".", "Value", ",", "len", "(", "params", ")", ")", "\n", "for", "...
// Call calls a dynamic function.
[ "Call", "calls", "a", "dynamic", "function", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/genericfunc.go#L30-L40
29,325
ahmetb/go-linq
genericfunc.go
newGenericFunc
func newGenericFunc(methodName, paramName string, fn interface{}, validateFunc func(*functionCache) error) (*genericFunc, error) { cache := &functionCache{} cache.FnValue = reflect.ValueOf(fn) if cache.FnValue.Kind() != reflect.Func { return nil, fmt.Errorf("%s: parameter [%s] is not a function type. It is a '%s'...
go
func newGenericFunc(methodName, paramName string, fn interface{}, validateFunc func(*functionCache) error) (*genericFunc, error) { cache := &functionCache{} cache.FnValue = reflect.ValueOf(fn) if cache.FnValue.Kind() != reflect.Func { return nil, fmt.Errorf("%s: parameter [%s] is not a function type. It is a '%s'...
[ "func", "newGenericFunc", "(", "methodName", ",", "paramName", "string", ",", "fn", "interface", "{", "}", ",", "validateFunc", "func", "(", "*", "functionCache", ")", "error", ")", "(", "*", "genericFunc", ",", "error", ")", "{", "cache", ":=", "&", "fu...
// newGenericFunc instantiates a new genericFunc pointer
[ "newGenericFunc", "instantiates", "a", "new", "genericFunc", "pointer" ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/genericfunc.go#L43-L69
29,326
ahmetb/go-linq
genericfunc.go
simpleParamValidator
func simpleParamValidator(In []reflect.Type, Out []reflect.Type) func(cache *functionCache) error { return func(cache *functionCache) error { var isValid = func() bool { if In != nil { if len(In) != len(cache.TypesIn) { return false } for i, paramIn := range In { if paramIn != genericTp && p...
go
func simpleParamValidator(In []reflect.Type, Out []reflect.Type) func(cache *functionCache) error { return func(cache *functionCache) error { var isValid = func() bool { if In != nil { if len(In) != len(cache.TypesIn) { return false } for i, paramIn := range In { if paramIn != genericTp && p...
[ "func", "simpleParamValidator", "(", "In", "[", "]", "reflect", ".", "Type", ",", "Out", "[", "]", "reflect", ".", "Type", ")", "func", "(", "cache", "*", "functionCache", ")", "error", "{", "return", "func", "(", "cache", "*", "functionCache", ")", "e...
// simpleParamValidator creates a function to validate genericFunc based in the // In and Out function parameters.
[ "simpleParamValidator", "creates", "a", "function", "to", "validate", "genericFunc", "based", "in", "the", "In", "and", "Out", "function", "parameters", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/genericfunc.go#L73-L104
29,327
ahmetb/go-linq
genericfunc.go
newElemTypeSlice
func newElemTypeSlice(items ...interface{}) []reflect.Type { typeList := make([]reflect.Type, len(items)) for i, item := range items { typeItem := reflect.TypeOf(item) if typeItem.Kind() == reflect.Ptr { typeList[i] = typeItem.Elem() } } return typeList }
go
func newElemTypeSlice(items ...interface{}) []reflect.Type { typeList := make([]reflect.Type, len(items)) for i, item := range items { typeItem := reflect.TypeOf(item) if typeItem.Kind() == reflect.Ptr { typeList[i] = typeItem.Elem() } } return typeList }
[ "func", "newElemTypeSlice", "(", "items", "...", "interface", "{", "}", ")", "[", "]", "reflect", ".", "Type", "{", "typeList", ":=", "make", "(", "[", "]", "reflect", ".", "Type", ",", "len", "(", "items", ")", ")", "\n", "for", "i", ",", "item", ...
// newElemTypeSlice creates a slice of items elem types.
[ "newElemTypeSlice", "creates", "a", "slice", "of", "items", "elem", "types", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/genericfunc.go#L107-L116
29,328
ahmetb/go-linq
genericfunc.go
formatFnSignature
func formatFnSignature(In []reflect.Type, Out []reflect.Type) string { paramInNames := make([]string, len(In)) for i, typeIn := range In { if typeIn == genericTp { paramInNames[i] = "T" } else { paramInNames[i] = typeIn.String() } } paramOutNames := make([]string, len(Out)) for i, typeOut := range Out...
go
func formatFnSignature(In []reflect.Type, Out []reflect.Type) string { paramInNames := make([]string, len(In)) for i, typeIn := range In { if typeIn == genericTp { paramInNames[i] = "T" } else { paramInNames[i] = typeIn.String() } } paramOutNames := make([]string, len(Out)) for i, typeOut := range Out...
[ "func", "formatFnSignature", "(", "In", "[", "]", "reflect", ".", "Type", ",", "Out", "[", "]", "reflect", ".", "Type", ")", "string", "{", "paramInNames", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "In", ")", ")", "\n", "for", "i", ...
// formatFnSignature formats the func signature based in the parameters types.
[ "formatFnSignature", "formats", "the", "func", "signature", "based", "in", "the", "parameters", "types", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/genericfunc.go#L119-L138
29,329
ahmetb/go-linq
concat.go
Append
func (q Query) Append(item interface{}) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() appended := false return func() (interface{}, bool) { i, ok := next() if ok { return i, ok } if !appended { appended = true return item, true } return nil, f...
go
func (q Query) Append(item interface{}) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() appended := false return func() (interface{}, bool) { i, ok := next() if ok { return i, ok } if !appended { appended = true return item, true } return nil, f...
[ "func", "(", "q", "Query", ")", "Append", "(", "item", "interface", "{", "}", ")", "Query", "{", "return", "Query", "{", "Iterate", ":", "func", "(", ")", "Iterator", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n", "appended", ":=", "false"...
// Append inserts an item to the end of a collection, so it becomes the last // item.
[ "Append", "inserts", "an", "item", "to", "the", "end", "of", "a", "collection", "so", "it", "becomes", "the", "last", "item", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/concat.go#L5-L26
29,330
ahmetb/go-linq
concat.go
Concat
func (q Query) Concat(q2 Query) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() next2 := q2.Iterate() use1 := true return func() (item interface{}, ok bool) { if use1 { item, ok = next() if ok { return } use1 = false } return next2() } },...
go
func (q Query) Concat(q2 Query) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() next2 := q2.Iterate() use1 := true return func() (item interface{}, ok bool) { if use1 { item, ok = next() if ok { return } use1 = false } return next2() } },...
[ "func", "(", "q", "Query", ")", "Concat", "(", "q2", "Query", ")", "Query", "{", "return", "Query", "{", "Iterate", ":", "func", "(", ")", "Iterator", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n", "next2", ":=", "q2", ".", "Iterate", "(...
// Concat concatenates two collections. // // The Concat method differs from the Union method because the Concat method // returns all the original elements in the input sequences. The Union method // returns only unique elements.
[ "Concat", "concatenates", "two", "collections", ".", "The", "Concat", "method", "differs", "from", "the", "Union", "method", "because", "the", "Concat", "method", "returns", "all", "the", "original", "elements", "in", "the", "input", "sequences", ".", "The", "...
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/concat.go#L33-L54
29,331
ahmetb/go-linq
concat.go
Prepend
func (q Query) Prepend(item interface{}) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() prepended := false return func() (interface{}, bool) { if prepended { return next() } prepended = true return item, true } }, } }
go
func (q Query) Prepend(item interface{}) Query { return Query{ Iterate: func() Iterator { next := q.Iterate() prepended := false return func() (interface{}, bool) { if prepended { return next() } prepended = true return item, true } }, } }
[ "func", "(", "q", "Query", ")", "Prepend", "(", "item", "interface", "{", "}", ")", "Query", "{", "return", "Query", "{", "Iterate", ":", "func", "(", ")", "Iterator", "{", "next", ":=", "q", ".", "Iterate", "(", ")", "\n", "prepended", ":=", "fals...
// Prepend inserts an item to the beginning of a collection, so it becomes the // first item.
[ "Prepend", "inserts", "an", "item", "to", "the", "beginning", "of", "a", "collection", "so", "it", "becomes", "the", "first", "item", "." ]
9f6960b5d2e017ec4b7820f045fbd7db66dd53b6
https://github.com/ahmetb/go-linq/blob/9f6960b5d2e017ec4b7820f045fbd7db66dd53b6/concat.go#L58-L74
29,332
sfreiberg/gotwilio
proxy_participant.go
AddParticipant
func (session *ProxySession) AddParticipant(req ParticipantRequest) (response Participant, exception *Exception, err error) { twilioUrl := fmt.Sprintf("%s/%s/%s/%s/%s/%s", ProxyBaseUrl, "Services", session.ServiceSid, "Sessions", session.Sid, "Participants") res, err := session.twilio.post(participantFormValues(req...
go
func (session *ProxySession) AddParticipant(req ParticipantRequest) (response Participant, exception *Exception, err error) { twilioUrl := fmt.Sprintf("%s/%s/%s/%s/%s/%s", ProxyBaseUrl, "Services", session.ServiceSid, "Sessions", session.Sid, "Participants") res, err := session.twilio.post(participantFormValues(req...
[ "func", "(", "session", "*", "ProxySession", ")", "AddParticipant", "(", "req", "ParticipantRequest", ")", "(", "response", "Participant", ",", "exception", "*", "Exception", ",", "err", "error", ")", "{", "twilioUrl", ":=", "fmt", ".", "Sprintf", "(", "\"",...
// AddParticipant adds Participant to Session
[ "AddParticipant", "adds", "Participant", "to", "Session" ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/proxy_participant.go#L89-L116
29,333
sfreiberg/gotwilio
proxy_participant.go
DeleteParticipant
func (session *ProxySession) DeleteParticipant(participantID string) (exception *Exception, err error) { twilioUrl := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", ProxyBaseUrl, "Services", session.ServiceSid, "Sessions", session.Sid, "Participants", participantID) res, err := session.twilio.delete(twilioUrl) if err != nil ...
go
func (session *ProxySession) DeleteParticipant(participantID string) (exception *Exception, err error) { twilioUrl := fmt.Sprintf("%s/%s/%s/%s/%s/%s/%s", ProxyBaseUrl, "Services", session.ServiceSid, "Sessions", session.Sid, "Participants", participantID) res, err := session.twilio.delete(twilioUrl) if err != nil ...
[ "func", "(", "session", "*", "ProxySession", ")", "DeleteParticipant", "(", "participantID", "string", ")", "(", "exception", "*", "Exception", ",", "err", "error", ")", "{", "twilioUrl", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "ProxyBaseUrl", "...
// Participants cannot be changed once added. To add a new Participant, delete a Participant and add a new one.
[ "Participants", "cannot", "be", "changed", "once", "added", ".", "To", "add", "a", "new", "Participant", "delete", "a", "Participant", "and", "add", "a", "new", "one", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/proxy_participant.go#L179-L199
29,334
sfreiberg/gotwilio
gotwilio.go
NewTwilioClientCustomHTTP
func NewTwilioClientCustomHTTP(accountSid, authToken string, HTTPClient *http.Client) *Twilio { if HTTPClient == nil { HTTPClient = defaultClient } return &Twilio{ AccountSid: accountSid, AuthToken: authToken, BaseUrl: baseURL, VideoUrl: videoURL, HTTPClient: HTTPClient, } }
go
func NewTwilioClientCustomHTTP(accountSid, authToken string, HTTPClient *http.Client) *Twilio { if HTTPClient == nil { HTTPClient = defaultClient } return &Twilio{ AccountSid: accountSid, AuthToken: authToken, BaseUrl: baseURL, VideoUrl: videoURL, HTTPClient: HTTPClient, } }
[ "func", "NewTwilioClientCustomHTTP", "(", "accountSid", ",", "authToken", "string", ",", "HTTPClient", "*", "http", ".", "Client", ")", "*", "Twilio", "{", "if", "HTTPClient", "==", "nil", "{", "HTTPClient", "=", "defaultClient", "\n", "}", "\n\n", "return", ...
// Create a new Twilio client, optionally using a custom http.Client
[ "Create", "a", "new", "Twilio", "client", "optionally", "using", "a", "custom", "http", ".", "Client" ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/gotwilio.go#L49-L61
29,335
sfreiberg/gotwilio
fax.go
DateCreatedAsTime
func (d *FaxBase) DateCreatedAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, d.DateCreated) }
go
func (d *FaxBase) DateCreatedAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, d.DateCreated) }
[ "func", "(", "d", "*", "FaxBase", ")", "DateCreatedAsTime", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "time", ".", "RFC1123Z", ",", "d", ".", "DateCreated", ")", "\n", "}" ]
// DateCreatedAsTime returns FaxBase.DateCreated as a time.Time object // instead of a string.
[ "DateCreatedAsTime", "returns", "FaxBase", ".", "DateCreated", "as", "a", "time", ".", "Time", "object", "instead", "of", "a", "string", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/fax.go#L20-L22
29,336
sfreiberg/gotwilio
fax.go
DateUpdatesAsTime
func (d *FaxBase) DateUpdatesAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, d.DateUpdated) }
go
func (d *FaxBase) DateUpdatesAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, d.DateUpdated) }
[ "func", "(", "d", "*", "FaxBase", ")", "DateUpdatesAsTime", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "time", ".", "RFC1123Z", ",", "d", ".", "DateUpdated", ")", "\n", "}" ]
// DateUpdatesAsTime returns FaxBase.DateUpdated as a time.Time object // instead of a string.
[ "DateUpdatesAsTime", "returns", "FaxBase", ".", "DateUpdated", "as", "a", "time", ".", "Time", "object", "instead", "of", "a", "string", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/fax.go#L26-L28
29,337
sfreiberg/gotwilio
sms.go
DateCreatedAsTime
func (sms *SmsResponse) DateCreatedAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, sms.DateCreated) }
go
func (sms *SmsResponse) DateCreatedAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, sms.DateCreated) }
[ "func", "(", "sms", "*", "SmsResponse", ")", "DateCreatedAsTime", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "time", ".", "RFC1123Z", ",", "sms", ".", "DateCreated", ")", "\n", "}" ]
// DateCreatedAsTime returns SmsResponse.DateCreated as a time.Time object // instead of a string.
[ "DateCreatedAsTime", "returns", "SmsResponse", ".", "DateCreated", "as", "a", "time", ".", "Time", "object", "instead", "of", "a", "string", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/sms.go#L31-L33
29,338
sfreiberg/gotwilio
sms.go
DateUpdateAsTime
func (sms *SmsResponse) DateUpdateAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, sms.DateUpdate) }
go
func (sms *SmsResponse) DateUpdateAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, sms.DateUpdate) }
[ "func", "(", "sms", "*", "SmsResponse", ")", "DateUpdateAsTime", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "time", ".", "RFC1123Z", ",", "sms", ".", "DateUpdate", ")", "\n", "}" ]
// DateUpdateAsTime returns SmsResponse.DateUpdate as a time.Time object // instead of a string.
[ "DateUpdateAsTime", "returns", "SmsResponse", ".", "DateUpdate", "as", "a", "time", ".", "Time", "object", "instead", "of", "a", "string", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/sms.go#L37-L39
29,339
sfreiberg/gotwilio
sms.go
DateSentAsTime
func (sms *SmsResponse) DateSentAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, sms.DateSent) }
go
func (sms *SmsResponse) DateSentAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, sms.DateSent) }
[ "func", "(", "sms", "*", "SmsResponse", ")", "DateSentAsTime", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "time", ".", "RFC1123Z", ",", "sms", ".", "DateSent", ")", "\n", "}" ]
// DateSentAsTime returns SmsResponse.DateSent as a time.Time object // instead of a string.
[ "DateSentAsTime", "returns", "SmsResponse", ".", "DateSent", "as", "a", "time", ".", "Time", "object", "instead", "of", "a", "string", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/sms.go#L43-L45
29,340
sfreiberg/gotwilio
sms.go
sendMessage
func (twilio *Twilio) sendMessage(formValues url.Values) (smsResponse *SmsResponse, exception *Exception, err error) { twilioUrl := twilio.BaseUrl + "/Accounts/" + twilio.AccountSid + "/Messages.json" res, err := twilio.post(formValues, twilioUrl) if err != nil { return smsResponse, exception, err } defer res.B...
go
func (twilio *Twilio) sendMessage(formValues url.Values) (smsResponse *SmsResponse, exception *Exception, err error) { twilioUrl := twilio.BaseUrl + "/Accounts/" + twilio.AccountSid + "/Messages.json" res, err := twilio.post(formValues, twilioUrl) if err != nil { return smsResponse, exception, err } defer res.B...
[ "func", "(", "twilio", "*", "Twilio", ")", "sendMessage", "(", "formValues", "url", ".", "Values", ")", "(", "smsResponse", "*", "SmsResponse", ",", "exception", "*", "Exception", ",", "err", "error", ")", "{", "twilioUrl", ":=", "twilio", ".", "BaseUrl", ...
// Core method to send message
[ "Core", "method", "to", "send", "message" ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/sms.go#L107-L133
29,341
sfreiberg/gotwilio
voice.go
DateCreatedAsTime
func (vr *VoiceResponse) DateCreatedAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, vr.DateCreated) }
go
func (vr *VoiceResponse) DateCreatedAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, vr.DateCreated) }
[ "func", "(", "vr", "*", "VoiceResponse", ")", "DateCreatedAsTime", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "time", ".", "RFC1123Z", ",", "vr", ".", "DateCreated", ")", "\n", "}" ]
// DateCreatedAsTime returns VoiceResponse.DateCreated as a time.Time object // instead of a string.
[ "DateCreatedAsTime", "returns", "VoiceResponse", ".", "DateCreated", "as", "a", "time", ".", "Time", "object", "instead", "of", "a", "string", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/voice.go#L65-L67
29,342
sfreiberg/gotwilio
voice.go
DateUpdatedAsTime
func (vr *VoiceResponse) DateUpdatedAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, vr.DateUpdated) }
go
func (vr *VoiceResponse) DateUpdatedAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, vr.DateUpdated) }
[ "func", "(", "vr", "*", "VoiceResponse", ")", "DateUpdatedAsTime", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "time", ".", "RFC1123Z", ",", "vr", ".", "DateUpdated", ")", "\n", "}" ]
// DateUpdatedAsTime returns VoiceResponse.DateUpdated as a time.Time object // instead of a string.
[ "DateUpdatedAsTime", "returns", "VoiceResponse", ".", "DateUpdated", "as", "a", "time", ".", "Time", "object", "instead", "of", "a", "string", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/voice.go#L71-L73
29,343
sfreiberg/gotwilio
voice.go
StartTimeAsTime
func (vr *VoiceResponse) StartTimeAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, vr.StartTime) }
go
func (vr *VoiceResponse) StartTimeAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, vr.StartTime) }
[ "func", "(", "vr", "*", "VoiceResponse", ")", "StartTimeAsTime", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "time", ".", "RFC1123Z", ",", "vr", ".", "StartTime", ")", "\n", "}" ]
// StartTimeAsTime returns VoiceResponse.StartTime as a time.Time object // instead of a string.
[ "StartTimeAsTime", "returns", "VoiceResponse", ".", "StartTime", "as", "a", "time", ".", "Time", "object", "instead", "of", "a", "string", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/voice.go#L77-L79
29,344
sfreiberg/gotwilio
voice.go
EndTimeAsTime
func (vr *VoiceResponse) EndTimeAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, vr.EndTime) }
go
func (vr *VoiceResponse) EndTimeAsTime() (time.Time, error) { return time.Parse(time.RFC1123Z, vr.EndTime) }
[ "func", "(", "vr", "*", "VoiceResponse", ")", "EndTimeAsTime", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "time", ".", "RFC1123Z", ",", "vr", ".", "EndTime", ")", "\n", "}" ]
// EndTimeAsTime returns VoiceResponse.EndTime as a time.Time object // instead of a string.
[ "EndTimeAsTime", "returns", "VoiceResponse", ".", "EndTime", "as", "a", "time", ".", "Time", "object", "instead", "of", "a", "string", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/voice.go#L83-L85
29,345
sfreiberg/gotwilio
voice.go
CallWithUrlCallbacks
func (twilio *Twilio) CallWithUrlCallbacks(from, to string, callbackParameters *CallbackParameters) (*VoiceResponse, *Exception, error) { formValues := url.Values{} formValues.Set("From", from) formValues.Set("To", to) formValues.Set("Url", callbackParameters.Url) // Optional values if callbackParameters.Method ...
go
func (twilio *Twilio) CallWithUrlCallbacks(from, to string, callbackParameters *CallbackParameters) (*VoiceResponse, *Exception, error) { formValues := url.Values{} formValues.Set("From", from) formValues.Set("To", to) formValues.Set("Url", callbackParameters.Url) // Optional values if callbackParameters.Method ...
[ "func", "(", "twilio", "*", "Twilio", ")", "CallWithUrlCallbacks", "(", "from", ",", "to", "string", ",", "callbackParameters", "*", "CallbackParameters", ")", "(", "*", "VoiceResponse", ",", "*", "Exception", ",", "error", ")", "{", "formValues", ":=", "url...
// Place a voice call with a list of callbacks specified.
[ "Place", "a", "voice", "call", "with", "a", "list", "of", "callbacks", "specified", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/voice.go#L122-L183
29,346
sfreiberg/gotwilio
voice.go
CallWithApplicationCallbacks
func (twilio *Twilio) CallWithApplicationCallbacks(from, to, applicationSid string) (*VoiceResponse, *Exception, error) { formValues := url.Values{} formValues.Set("From", from) formValues.Set("To", to) formValues.Set("ApplicationSid", applicationSid) return twilio.voicePost(formValues) }
go
func (twilio *Twilio) CallWithApplicationCallbacks(from, to, applicationSid string) (*VoiceResponse, *Exception, error) { formValues := url.Values{} formValues.Set("From", from) formValues.Set("To", to) formValues.Set("ApplicationSid", applicationSid) return twilio.voicePost(formValues) }
[ "func", "(", "twilio", "*", "Twilio", ")", "CallWithApplicationCallbacks", "(", "from", ",", "to", ",", "applicationSid", "string", ")", "(", "*", "VoiceResponse", ",", "*", "Exception", ",", "error", ")", "{", "formValues", ":=", "url", ".", "Values", "{"...
// Place a voice call with an ApplicationSid specified.
[ "Place", "a", "voice", "call", "with", "an", "ApplicationSid", "specified", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/voice.go#L186-L193
29,347
sfreiberg/gotwilio
voice.go
voicePost
func (twilio *Twilio) voicePost(formValues url.Values) (*VoiceResponse, *Exception, error) { var voiceResponse *VoiceResponse var exception *Exception twilioUrl := twilio.BaseUrl + "/Accounts/" + twilio.AccountSid + "/Calls.json" res, err := twilio.post(formValues, twilioUrl) if err != nil { return voiceRespons...
go
func (twilio *Twilio) voicePost(formValues url.Values) (*VoiceResponse, *Exception, error) { var voiceResponse *VoiceResponse var exception *Exception twilioUrl := twilio.BaseUrl + "/Accounts/" + twilio.AccountSid + "/Calls.json" res, err := twilio.post(formValues, twilioUrl) if err != nil { return voiceRespons...
[ "func", "(", "twilio", "*", "Twilio", ")", "voicePost", "(", "formValues", "url", ".", "Values", ")", "(", "*", "VoiceResponse", ",", "*", "Exception", ",", "error", ")", "{", "var", "voiceResponse", "*", "VoiceResponse", "\n", "var", "exception", "*", "...
// This is a private method that has the common bits for making a voice call.
[ "This", "is", "a", "private", "method", "that", "has", "the", "common", "bits", "for", "making", "a", "voice", "call", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/voice.go#L196-L221
29,348
sfreiberg/gotwilio
util.go
CheckRequestSignature
func (twilio *Twilio) CheckRequestSignature(r *http.Request, baseURL string) (bool, error) { if r.Method != "POST" { return false, errors.New("Checking signatures on non-POST requests is not implemented") } if err := r.ParseForm(); err != nil { return false, err } url := baseURL + r.URL.String() expected, ...
go
func (twilio *Twilio) CheckRequestSignature(r *http.Request, baseURL string) (bool, error) { if r.Method != "POST" { return false, errors.New("Checking signatures on non-POST requests is not implemented") } if err := r.ParseForm(); err != nil { return false, err } url := baseURL + r.URL.String() expected, ...
[ "func", "(", "twilio", "*", "Twilio", ")", "CheckRequestSignature", "(", "r", "*", "http", ".", "Request", ",", "baseURL", "string", ")", "(", "bool", ",", "error", ")", "{", "if", "r", ".", "Method", "!=", "\"", "\"", "{", "return", "false", ",", ...
// CheckRequestSignature checks that the X-Twilio-Signature header on a request // matches the expected signature defined by the GenerateSignature function. // // The baseUrl parameter will be prepended to the request URL. It is useful for // specifying the protocol and host parts of the server URL hosting your endpoin...
[ "CheckRequestSignature", "checks", "that", "the", "X", "-", "Twilio", "-", "Signature", "header", "on", "a", "request", "matches", "the", "expected", "signature", "defined", "by", "the", "GenerateSignature", "function", ".", "The", "baseUrl", "parameter", "will", ...
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/util.go#L62-L84
29,349
sfreiberg/gotwilio
access_token.go
NewAccessToken
func (twilio *Twilio) NewAccessToken() *AccessToken { return &AccessToken{ AccountSid: twilio.AccountSid, APIKeySid: twilio.APIKeySid, APIKeySecret: twilio.APIKeySecret, } }
go
func (twilio *Twilio) NewAccessToken() *AccessToken { return &AccessToken{ AccountSid: twilio.AccountSid, APIKeySid: twilio.APIKeySid, APIKeySecret: twilio.APIKeySecret, } }
[ "func", "(", "twilio", "*", "Twilio", ")", "NewAccessToken", "(", ")", "*", "AccessToken", "{", "return", "&", "AccessToken", "{", "AccountSid", ":", "twilio", ".", "AccountSid", ",", "APIKeySid", ":", "twilio", ".", "APIKeySid", ",", "APIKeySecret", ":", ...
// NewAccessToken creates a new Access Token which // can be used to authenticate Twilio Client SDKs // for a short period of time.
[ "NewAccessToken", "creates", "a", "new", "Access", "Token", "which", "can", "be", "used", "to", "authenticate", "Twilio", "Client", "SDKs", "for", "a", "short", "period", "of", "time", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/access_token.go#L45-L51
29,350
sfreiberg/gotwilio
access_token.go
AddGrant
func (a *AccessToken) AddGrant(grant Grant) *AccessToken { a.Grants = append(a.Grants, grant) return a }
go
func (a *AccessToken) AddGrant(grant Grant) *AccessToken { a.Grants = append(a.Grants, grant) return a }
[ "func", "(", "a", "*", "AccessToken", ")", "AddGrant", "(", "grant", "Grant", ")", "*", "AccessToken", "{", "a", ".", "Grants", "=", "append", "(", "a", ".", "Grants", ",", "grant", ")", "\n", "return", "a", "\n", "}" ]
// AddGrant adds a given Grant to the Access Token.
[ "AddGrant", "adds", "a", "given", "Grant", "to", "the", "Access", "Token", "." ]
4c78e78c98b65cf3b9ab4edbe635d4080c6db6da
https://github.com/sfreiberg/gotwilio/blob/4c78e78c98b65cf3b9ab4edbe635d4080c6db6da/access_token.go#L54-L57
29,351
kr/pty
run.go
Start
func Start(c *exec.Cmd) (pty *os.File, err error) { return StartWithSize(c, nil) }
go
func Start(c *exec.Cmd) (pty *os.File, err error) { return StartWithSize(c, nil) }
[ "func", "Start", "(", "c", "*", "exec", ".", "Cmd", ")", "(", "pty", "*", "os", ".", "File", ",", "err", "error", ")", "{", "return", "StartWithSize", "(", "c", ",", "nil", ")", "\n", "}" ]
// Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, // and c.Stderr, calls c.Start, and returns the File of the tty's // corresponding pty.
[ "Start", "assigns", "a", "pseudo", "-", "terminal", "tty", "os", ".", "File", "to", "c", ".", "Stdin", "c", ".", "Stdout", "and", "c", ".", "Stderr", "calls", "c", ".", "Start", "and", "returns", "the", "File", "of", "the", "tty", "s", "corresponding...
b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17
https://github.com/kr/pty/blob/b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17/run.go#L14-L16
29,352
kr/pty
run.go
StartWithSize
func StartWithSize(c *exec.Cmd, sz *Winsize) (pty *os.File, err error) { pty, tty, err := Open() if err != nil { return nil, err } defer tty.Close() if sz != nil { err = Setsize(pty, sz) if err != nil { pty.Close() return nil, err } } if c.Stdout == nil { c.Stdout = tty } if c.Stderr == nil { ...
go
func StartWithSize(c *exec.Cmd, sz *Winsize) (pty *os.File, err error) { pty, tty, err := Open() if err != nil { return nil, err } defer tty.Close() if sz != nil { err = Setsize(pty, sz) if err != nil { pty.Close() return nil, err } } if c.Stdout == nil { c.Stdout = tty } if c.Stderr == nil { ...
[ "func", "StartWithSize", "(", "c", "*", "exec", ".", "Cmd", ",", "sz", "*", "Winsize", ")", "(", "pty", "*", "os", ".", "File", ",", "err", "error", ")", "{", "pty", ",", "tty", ",", "err", ":=", "Open", "(", ")", "\n", "if", "err", "!=", "ni...
// StartWithSize assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, // and c.Stderr, calls c.Start, and returns the File of the tty's // corresponding pty. // // This will resize the pty to the specified size before starting the command
[ "StartWithSize", "assigns", "a", "pseudo", "-", "terminal", "tty", "os", ".", "File", "to", "c", ".", "Stdin", "c", ".", "Stdout", "and", "c", ".", "Stderr", "calls", "c", ".", "Start", "and", "returns", "the", "File", "of", "the", "tty", "s", "corre...
b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17
https://github.com/kr/pty/blob/b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17/run.go#L23-L57
29,353
kr/pty
pty_dragonfly.go
open
func open() (pty, tty *os.File, err error) { p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) if err != nil { return nil, nil, err } // In case of error after this point, make sure we close the ptmx fd. defer func() { if err != nil { _ = p.Close() // Best effort. } }() sname, err := ptsname(p) if err ...
go
func open() (pty, tty *os.File, err error) { p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) if err != nil { return nil, nil, err } // In case of error after this point, make sure we close the ptmx fd. defer func() { if err != nil { _ = p.Close() // Best effort. } }() sname, err := ptsname(p) if err ...
[ "func", "open", "(", ")", "(", "pty", ",", "tty", "*", "os", ".", "File", ",", "err", "error", ")", "{", "p", ",", "err", ":=", "os", ".", "OpenFile", "(", "\"", "\"", ",", "os", ".", "O_RDWR", ",", "0", ")", "\n", "if", "err", "!=", "nil",...
// same code as pty_darwin.go
[ "same", "code", "as", "pty_darwin", ".", "go" ]
b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17
https://github.com/kr/pty/blob/b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17/pty_dragonfly.go#L12-L42
29,354
kr/pty
util.go
InheritSize
func InheritSize(pty, tty *os.File) error { size, err := GetsizeFull(pty) if err != nil { return err } err = Setsize(tty, size) if err != nil { return err } return nil }
go
func InheritSize(pty, tty *os.File) error { size, err := GetsizeFull(pty) if err != nil { return err } err = Setsize(tty, size) if err != nil { return err } return nil }
[ "func", "InheritSize", "(", "pty", ",", "tty", "*", "os", ".", "File", ")", "error", "{", "size", ",", "err", ":=", "GetsizeFull", "(", "pty", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "Setsize", "(",...
// InheritSize applies the terminal size of pty to tty. This should be run // in a signal handler for syscall.SIGWINCH to automatically resize the tty when // the pty receives a window size change notification.
[ "InheritSize", "applies", "the", "terminal", "size", "of", "pty", "to", "tty", ".", "This", "should", "be", "run", "in", "a", "signal", "handler", "for", "syscall", ".", "SIGWINCH", "to", "automatically", "resize", "the", "tty", "when", "the", "pty", "rece...
b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17
https://github.com/kr/pty/blob/b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17/util.go#L14-L24
29,355
kr/pty
util.go
Setsize
func Setsize(t *os.File, ws *Winsize) error { return windowRectCall(ws, t.Fd(), syscall.TIOCSWINSZ) }
go
func Setsize(t *os.File, ws *Winsize) error { return windowRectCall(ws, t.Fd(), syscall.TIOCSWINSZ) }
[ "func", "Setsize", "(", "t", "*", "os", ".", "File", ",", "ws", "*", "Winsize", ")", "error", "{", "return", "windowRectCall", "(", "ws", ",", "t", ".", "Fd", "(", ")", ",", "syscall", ".", "TIOCSWINSZ", ")", "\n", "}" ]
// Setsize resizes t to s.
[ "Setsize", "resizes", "t", "to", "s", "." ]
b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17
https://github.com/kr/pty/blob/b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17/util.go#L27-L29
29,356
kr/pty
util.go
GetsizeFull
func GetsizeFull(t *os.File) (size *Winsize, err error) { var ws Winsize err = windowRectCall(&ws, t.Fd(), syscall.TIOCGWINSZ) return &ws, err }
go
func GetsizeFull(t *os.File) (size *Winsize, err error) { var ws Winsize err = windowRectCall(&ws, t.Fd(), syscall.TIOCGWINSZ) return &ws, err }
[ "func", "GetsizeFull", "(", "t", "*", "os", ".", "File", ")", "(", "size", "*", "Winsize", ",", "err", "error", ")", "{", "var", "ws", "Winsize", "\n", "err", "=", "windowRectCall", "(", "&", "ws", ",", "t", ".", "Fd", "(", ")", ",", "syscall", ...
// GetsizeFull returns the full terminal size description.
[ "GetsizeFull", "returns", "the", "full", "terminal", "size", "description", "." ]
b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17
https://github.com/kr/pty/blob/b6e1bdd4a4f88614e0c6e5e8089c7abed98aae17/util.go#L32-L36
29,357
justinas/nosurf
handler.go
extractToken
func extractToken(r *http.Request) []byte { // Prefer the header over form value sentToken := r.Header.Get(HeaderName) // Then POST values if len(sentToken) == 0 { sentToken = r.PostFormValue(FormFieldName) } // If all else fails, try a multipart value. // PostFormValue() will already have called ParseMultip...
go
func extractToken(r *http.Request) []byte { // Prefer the header over form value sentToken := r.Header.Get(HeaderName) // Then POST values if len(sentToken) == 0 { sentToken = r.PostFormValue(FormFieldName) } // If all else fails, try a multipart value. // PostFormValue() will already have called ParseMultip...
[ "func", "extractToken", "(", "r", "*", "http", ".", "Request", ")", "[", "]", "byte", "{", "// Prefer the header over form value", "sentToken", ":=", "r", ".", "Header", ".", "Get", "(", "HeaderName", ")", "\n\n", "// Then POST values", "if", "len", "(", "se...
// Extracts the "sent" token from the request // and returns an unmasked version of it
[ "Extracts", "the", "sent", "token", "from", "the", "request", "and", "returns", "an", "unmasked", "version", "of", "it" ]
05988550ea1890c49b702363e53b3afa7aad2b4b
https://github.com/justinas/nosurf/blob/05988550ea1890c49b702363e53b3afa7aad2b4b/handler.go#L68-L87
29,358
justinas/nosurf
handler.go
New
func New(handler http.Handler) *CSRFHandler { baseCookie := http.Cookie{} baseCookie.MaxAge = MaxAge csrf := &CSRFHandler{successHandler: handler, failureHandler: http.HandlerFunc(defaultFailureHandler), baseCookie: baseCookie, } return csrf }
go
func New(handler http.Handler) *CSRFHandler { baseCookie := http.Cookie{} baseCookie.MaxAge = MaxAge csrf := &CSRFHandler{successHandler: handler, failureHandler: http.HandlerFunc(defaultFailureHandler), baseCookie: baseCookie, } return csrf }
[ "func", "New", "(", "handler", "http", ".", "Handler", ")", "*", "CSRFHandler", "{", "baseCookie", ":=", "http", ".", "Cookie", "{", "}", "\n", "baseCookie", ".", "MaxAge", "=", "MaxAge", "\n\n", "csrf", ":=", "&", "CSRFHandler", "{", "successHandler", "...
// Constructs a new CSRFHandler that calls // the specified handler if the CSRF check succeeds.
[ "Constructs", "a", "new", "CSRFHandler", "that", "calls", "the", "specified", "handler", "if", "the", "CSRF", "check", "succeeds", "." ]
05988550ea1890c49b702363e53b3afa7aad2b4b
https://github.com/justinas/nosurf/blob/05988550ea1890c49b702363e53b3afa7aad2b4b/handler.go#L91-L101
29,359
justinas/nosurf
handler.go
RegenerateToken
func (h *CSRFHandler) RegenerateToken(w http.ResponseWriter, r *http.Request) string { token := generateToken() h.setTokenCookie(w, r, token) return Token(r) }
go
func (h *CSRFHandler) RegenerateToken(w http.ResponseWriter, r *http.Request) string { token := generateToken() h.setTokenCookie(w, r, token) return Token(r) }
[ "func", "(", "h", "*", "CSRFHandler", ")", "RegenerateToken", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "string", "{", "token", ":=", "generateToken", "(", ")", "\n", "h", ".", "setTokenCookie", "(", "w", ",",...
// Generates a new token, sets it on the given request and returns it
[ "Generates", "a", "new", "token", "sets", "it", "on", "the", "given", "request", "and", "returns", "it" ]
05988550ea1890c49b702363e53b3afa7aad2b4b
https://github.com/justinas/nosurf/blob/05988550ea1890c49b702363e53b3afa7aad2b4b/handler.go#L197-L202
29,360
justinas/nosurf
context_legacy.go
ctxSetToken
func ctxSetToken(req *http.Request, token []byte) *http.Request { cmMutex.Lock() defer cmMutex.Unlock() ctx, ok := contextMap[req] if !ok { ctx = new(csrfContext) contextMap[req] = ctx } ctx.token = b64encode(maskToken(token)) return req }
go
func ctxSetToken(req *http.Request, token []byte) *http.Request { cmMutex.Lock() defer cmMutex.Unlock() ctx, ok := contextMap[req] if !ok { ctx = new(csrfContext) contextMap[req] = ctx } ctx.token = b64encode(maskToken(token)) return req }
[ "func", "ctxSetToken", "(", "req", "*", "http", ".", "Request", ",", "token", "[", "]", "byte", ")", "*", "http", ".", "Request", "{", "cmMutex", ".", "Lock", "(", ")", "\n", "defer", "cmMutex", ".", "Unlock", "(", ")", "\n\n", "ctx", ",", "ok", ...
// Takes a raw token, masks it with a per-request key, // encodes in base64 and makes it available to the wrapped handler
[ "Takes", "a", "raw", "token", "masks", "it", "with", "a", "per", "-", "request", "key", "encodes", "in", "base64", "and", "makes", "it", "available", "to", "the", "wrapped", "handler" ]
05988550ea1890c49b702363e53b3afa7aad2b4b
https://github.com/justinas/nosurf/blob/05988550ea1890c49b702363e53b3afa7aad2b4b/context_legacy.go#L67-L80
29,361
justinas/nosurf
token.go
verifyMasked
func verifyMasked(realToken, sentToken []byte) bool { sentPlain := unmaskToken(sentToken) return subtle.ConstantTimeCompare(realToken, sentPlain) == 1 }
go
func verifyMasked(realToken, sentToken []byte) bool { sentPlain := unmaskToken(sentToken) return subtle.ConstantTimeCompare(realToken, sentPlain) == 1 }
[ "func", "verifyMasked", "(", "realToken", ",", "sentToken", "[", "]", "byte", ")", "bool", "{", "sentPlain", ":=", "unmaskToken", "(", "sentToken", ")", "\n", "return", "subtle", ".", "ConstantTimeCompare", "(", "realToken", ",", "sentPlain", ")", "==", "1",...
// Verifies the masked token
[ "Verifies", "the", "masked", "token" ]
05988550ea1890c49b702363e53b3afa7aad2b4b
https://github.com/justinas/nosurf/blob/05988550ea1890c49b702363e53b3afa7aad2b4b/token.go#L86-L89
29,362
justinas/nosurf
exempt.go
IsExempt
func (h *CSRFHandler) IsExempt(r *http.Request) bool { if h.exemptFunc != nil && h.exemptFunc(r) { return true } path := r.URL.Path if sContains(h.exemptPaths, path) { return true } // then the globs for _, glob := range h.exemptGlobs { matched, err := pathModule.Match(glob, path) if matched && err == ...
go
func (h *CSRFHandler) IsExempt(r *http.Request) bool { if h.exemptFunc != nil && h.exemptFunc(r) { return true } path := r.URL.Path if sContains(h.exemptPaths, path) { return true } // then the globs for _, glob := range h.exemptGlobs { matched, err := pathModule.Match(glob, path) if matched && err == ...
[ "func", "(", "h", "*", "CSRFHandler", ")", "IsExempt", "(", "r", "*", "http", ".", "Request", ")", "bool", "{", "if", "h", ".", "exemptFunc", "!=", "nil", "&&", "h", ".", "exemptFunc", "(", "r", ")", "{", "return", "true", "\n", "}", "\n\n", "pat...
// Checks if the given request is exempt from CSRF checks. // It checks the ExemptFunc first, then the exact paths, // then the globs and finally the regexps.
[ "Checks", "if", "the", "given", "request", "is", "exempt", "from", "CSRF", "checks", ".", "It", "checks", "the", "ExemptFunc", "first", "then", "the", "exact", "paths", "then", "the", "globs", "and", "finally", "the", "regexps", "." ]
05988550ea1890c49b702363e53b3afa7aad2b4b
https://github.com/justinas/nosurf/blob/05988550ea1890c49b702363e53b3afa7aad2b4b/exempt.go#L14-L40
29,363
prometheus/haproxy_exporter
haproxy_exporter.go
NewExporter
func NewExporter(uri string, sslVerify bool, selectedServerMetrics map[int]*prometheus.Desc, timeout time.Duration) (*Exporter, error) { u, err := url.Parse(uri) if err != nil { return nil, err } var fetch func() (io.ReadCloser, error) switch u.Scheme { case "http", "https", "file": fetch = fetchHTTP(uri, ss...
go
func NewExporter(uri string, sslVerify bool, selectedServerMetrics map[int]*prometheus.Desc, timeout time.Duration) (*Exporter, error) { u, err := url.Parse(uri) if err != nil { return nil, err } var fetch func() (io.ReadCloser, error) switch u.Scheme { case "http", "https", "file": fetch = fetchHTTP(uri, ss...
[ "func", "NewExporter", "(", "uri", "string", ",", "sslVerify", "bool", ",", "selectedServerMetrics", "map", "[", "int", "]", "*", "prometheus", ".", "Desc", ",", "timeout", "time", ".", "Duration", ")", "(", "*", "Exporter", ",", "error", ")", "{", "u", ...
// NewExporter returns an initialized Exporter.
[ "NewExporter", "returns", "an", "initialized", "Exporter", "." ]
f9813cf8bc6d469e80f7e6007a66c095b45616ed
https://github.com/prometheus/haproxy_exporter/blob/f9813cf8bc6d469e80f7e6007a66c095b45616ed/haproxy_exporter.go#L188-L224
29,364
prometheus/haproxy_exporter
haproxy_exporter.go
Describe
func (e *Exporter) Describe(ch chan<- *prometheus.Desc) { for _, m := range frontendMetrics { ch <- m } for _, m := range backendMetrics { ch <- m } for _, m := range e.serverMetrics { ch <- m } ch <- haproxyUp ch <- e.totalScrapes.Desc() ch <- e.csvParseFailures.Desc() }
go
func (e *Exporter) Describe(ch chan<- *prometheus.Desc) { for _, m := range frontendMetrics { ch <- m } for _, m := range backendMetrics { ch <- m } for _, m := range e.serverMetrics { ch <- m } ch <- haproxyUp ch <- e.totalScrapes.Desc() ch <- e.csvParseFailures.Desc() }
[ "func", "(", "e", "*", "Exporter", ")", "Describe", "(", "ch", "chan", "<-", "*", "prometheus", ".", "Desc", ")", "{", "for", "_", ",", "m", ":=", "range", "frontendMetrics", "{", "ch", "<-", "m", "\n", "}", "\n", "for", "_", ",", "m", ":=", "r...
// Describe describes all the metrics ever exported by the HAProxy exporter. It // implements prometheus.Collector.
[ "Describe", "describes", "all", "the", "metrics", "ever", "exported", "by", "the", "HAProxy", "exporter", ".", "It", "implements", "prometheus", ".", "Collector", "." ]
f9813cf8bc6d469e80f7e6007a66c095b45616ed
https://github.com/prometheus/haproxy_exporter/blob/f9813cf8bc6d469e80f7e6007a66c095b45616ed/haproxy_exporter.go#L228-L241
29,365
prometheus/haproxy_exporter
haproxy_exporter.go
Collect
func (e *Exporter) Collect(ch chan<- prometheus.Metric) { e.mutex.Lock() // To protect metrics from concurrent collects. defer e.mutex.Unlock() up := e.scrape(ch) ch <- prometheus.MustNewConstMetric(haproxyUp, prometheus.GaugeValue, up) ch <- e.totalScrapes ch <- e.csvParseFailures }
go
func (e *Exporter) Collect(ch chan<- prometheus.Metric) { e.mutex.Lock() // To protect metrics from concurrent collects. defer e.mutex.Unlock() up := e.scrape(ch) ch <- prometheus.MustNewConstMetric(haproxyUp, prometheus.GaugeValue, up) ch <- e.totalScrapes ch <- e.csvParseFailures }
[ "func", "(", "e", "*", "Exporter", ")", "Collect", "(", "ch", "chan", "<-", "prometheus", ".", "Metric", ")", "{", "e", ".", "mutex", ".", "Lock", "(", ")", "// To protect metrics from concurrent collects.", "\n", "defer", "e", ".", "mutex", ".", "Unlock",...
// Collect fetches the stats from configured HAProxy location and delivers them // as Prometheus metrics. It implements prometheus.Collector.
[ "Collect", "fetches", "the", "stats", "from", "configured", "HAProxy", "location", "and", "delivers", "them", "as", "Prometheus", "metrics", ".", "It", "implements", "prometheus", ".", "Collector", "." ]
f9813cf8bc6d469e80f7e6007a66c095b45616ed
https://github.com/prometheus/haproxy_exporter/blob/f9813cf8bc6d469e80f7e6007a66c095b45616ed/haproxy_exporter.go#L245-L254
29,366
prometheus/haproxy_exporter
haproxy_exporter.go
filterServerMetrics
func filterServerMetrics(filter string) (map[int]*prometheus.Desc, error) { metrics := map[int]*prometheus.Desc{} if len(filter) == 0 { return metrics, nil } selected := map[int]struct{}{} for _, f := range strings.Split(filter, ",") { field, err := strconv.Atoi(f) if err != nil { return nil, fmt.Errorf(...
go
func filterServerMetrics(filter string) (map[int]*prometheus.Desc, error) { metrics := map[int]*prometheus.Desc{} if len(filter) == 0 { return metrics, nil } selected := map[int]struct{}{} for _, f := range strings.Split(filter, ",") { field, err := strconv.Atoi(f) if err != nil { return nil, fmt.Errorf(...
[ "func", "filterServerMetrics", "(", "filter", "string", ")", "(", "map", "[", "int", "]", "*", "prometheus", ".", "Desc", ",", "error", ")", "{", "metrics", ":=", "map", "[", "int", "]", "*", "prometheus", ".", "Desc", "{", "}", "\n", "if", "len", ...
// filterServerMetrics returns the set of server metrics specified by the comma // separated filter.
[ "filterServerMetrics", "returns", "the", "set", "of", "server", "metrics", "specified", "by", "the", "comma", "separated", "filter", "." ]
f9813cf8bc6d469e80f7e6007a66c095b45616ed
https://github.com/prometheus/haproxy_exporter/blob/f9813cf8bc6d469e80f7e6007a66c095b45616ed/haproxy_exporter.go#L407-L428
29,367
go-chat-bot/bot
rocket/rocket.go
Run
func Run(c *Config) { config = c client = rest.NewClient(config.Server, config.Port, config.UseTLS, config.Debug) err := client.Login(api.UserCredentials{Email: config.Email, Name: config.User, Password: config.Password}) if err != nil { log.Fatalf("login err: %s\n", err) } b := bot.New(&bot.Handlers{ Respon...
go
func Run(c *Config) { config = c client = rest.NewClient(config.Server, config.Port, config.UseTLS, config.Debug) err := client.Login(api.UserCredentials{Email: config.Email, Name: config.User, Password: config.Password}) if err != nil { log.Fatalf("login err: %s\n", err) } b := bot.New(&bot.Handlers{ Respon...
[ "func", "Run", "(", "c", "*", "Config", ")", "{", "config", "=", "c", "\n", "client", "=", "rest", ".", "NewClient", "(", "config", ".", "Server", ",", "config", ".", "Port", ",", "config", ".", "UseTLS", ",", "config", ".", "Debug", ")", "\n", "...
// Run reads the Config, connect to the specified rocket.chat server and starts the bot.
[ "Run", "reads", "the", "Config", "connect", "to", "the", "specified", "rocket", ".", "chat", "server", "and", "starts", "the", "bot", "." ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/rocket/rocket.go#L52-L91
29,368
go-chat-bot/bot
cmd.go
URI
func (c *ChannelData) URI() string { return fmt.Sprintf("%s://%s/%s", c.Protocol, c.Server, c.Channel) }
go
func (c *ChannelData) URI() string { return fmt.Sprintf("%s://%s/%s", c.Protocol, c.Server, c.Channel) }
[ "func", "(", "c", "*", "ChannelData", ")", "URI", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "Protocol", ",", "c", ".", "Server", ",", "c", ".", "Channel", ")", "\n", "}" ]
// URI gives back an URI-fied string containing protocol, server and channel.
[ "URI", "gives", "back", "an", "URI", "-", "fied", "string", "containing", "protocol", "server", "and", "channel", "." ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/cmd.go#L38-L40
29,369
go-chat-bot/bot
cmd.go
RegisterCommandV2
func RegisterCommandV2(command, description, exampleArgs string, cmdFunc activeCmdFuncV2) { commands[command] = &customCommand{ Version: v2, Cmd: command, CmdFuncV2: cmdFunc, Description: description, ExampleArgs: exampleArgs, } }
go
func RegisterCommandV2(command, description, exampleArgs string, cmdFunc activeCmdFuncV2) { commands[command] = &customCommand{ Version: v2, Cmd: command, CmdFuncV2: cmdFunc, Description: description, ExampleArgs: exampleArgs, } }
[ "func", "RegisterCommandV2", "(", "command", ",", "description", ",", "exampleArgs", "string", ",", "cmdFunc", "activeCmdFuncV2", ")", "{", "commands", "[", "command", "]", "=", "&", "customCommand", "{", "Version", ":", "v2", ",", "Cmd", ":", "command", ","...
// RegisterCommandV2 adds a new command to the bot. // It is the same as RegisterCommand but the command can specify the channel to reply to
[ "RegisterCommandV2", "adds", "a", "new", "command", "to", "the", "bot", ".", "It", "is", "the", "same", "as", "RegisterCommand", "but", "the", "command", "can", "specify", "the", "channel", "to", "reply", "to" ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/cmd.go#L196-L204
29,370
go-chat-bot/bot
cmd.go
RegisterCommandV3
func RegisterCommandV3(command, description, exampleArgs string, cmdFunc activeCmdFuncV3) { commands[command] = &customCommand{ Version: v3, Cmd: command, CmdFuncV3: cmdFunc, Description: description, ExampleArgs: exampleArgs, } }
go
func RegisterCommandV3(command, description, exampleArgs string, cmdFunc activeCmdFuncV3) { commands[command] = &customCommand{ Version: v3, Cmd: command, CmdFuncV3: cmdFunc, Description: description, ExampleArgs: exampleArgs, } }
[ "func", "RegisterCommandV3", "(", "command", ",", "description", ",", "exampleArgs", "string", ",", "cmdFunc", "activeCmdFuncV3", ")", "{", "commands", "[", "command", "]", "=", "&", "customCommand", "{", "Version", ":", "v3", ",", "Cmd", ":", "command", ","...
// RegisterCommandV3 adds a new command to the bot. // It is the same as RegisterCommand but the command return a chan
[ "RegisterCommandV3", "adds", "a", "new", "command", "to", "the", "bot", ".", "It", "is", "the", "same", "as", "RegisterCommand", "but", "the", "command", "return", "a", "chan" ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/cmd.go#L208-L216
29,371
go-chat-bot/bot
cmd.go
Disable
func (b *Bot) Disable(cmds []string) { b.disabledCmds = append(b.disabledCmds, cmds...) }
go
func (b *Bot) Disable(cmds []string) { b.disabledCmds = append(b.disabledCmds, cmds...) }
[ "func", "(", "b", "*", "Bot", ")", "Disable", "(", "cmds", "[", "]", "string", ")", "{", "b", ".", "disabledCmds", "=", "append", "(", "b", ".", "disabledCmds", ",", "cmds", "...", ")", "\n", "}" ]
// Disable allows disabling commands that were registered. // It is useful when running multiple bot instances to disabled some plugins like url which // is already present on some protocols.
[ "Disable", "allows", "disabling", "commands", "that", "were", "registered", ".", "It", "is", "useful", "when", "running", "multiple", "bot", "instances", "to", "disabled", "some", "plugins", "like", "url", "which", "is", "already", "present", "on", "some", "pr...
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/cmd.go#L296-L298
29,372
go-chat-bot/bot
bot.go
New
func New(h *Handlers, bc *Config) *Bot { if h.Errored == nil { h.Errored = logErrorHandler } b := &Bot{ handlers: h, cron: cron.New(), msgsToSend: make(chan responseMessage, MsgBuffer), done: make(chan struct{}), Protocol: bc.Protocol, Server: bc.Server, } // Launch the backgrou...
go
func New(h *Handlers, bc *Config) *Bot { if h.Errored == nil { h.Errored = logErrorHandler } b := &Bot{ handlers: h, cron: cron.New(), msgsToSend: make(chan responseMessage, MsgBuffer), done: make(chan struct{}), Protocol: bc.Protocol, Server: bc.Server, } // Launch the backgrou...
[ "func", "New", "(", "h", "*", "Handlers", ",", "bc", "*", "Config", ")", "*", "Bot", "{", "if", "h", ".", "Errored", "==", "nil", "{", "h", ".", "Errored", "=", "logErrorHandler", "\n", "}", "\n\n", "b", ":=", "&", "Bot", "{", "handlers", ":", ...
// New configures a new bot instance
[ "New", "configures", "a", "new", "bot", "instance" ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/bot.go#L77-L99
29,373
go-chat-bot/bot
bot.go
MessageReceived
func (b *Bot) MessageReceived(channel *ChannelData, message *Message, sender *User) { command, err := parse(message.Text, channel, sender) if err != nil { b.SendMessage(channel.Channel, err.Error(), sender) return } if command == nil { b.executePassiveCommands(&PassiveCmd{ Raw: message.Text, Me...
go
func (b *Bot) MessageReceived(channel *ChannelData, message *Message, sender *User) { command, err := parse(message.Text, channel, sender) if err != nil { b.SendMessage(channel.Channel, err.Error(), sender) return } if command == nil { b.executePassiveCommands(&PassiveCmd{ Raw: message.Text, Me...
[ "func", "(", "b", "*", "Bot", ")", "MessageReceived", "(", "channel", "*", "ChannelData", ",", "message", "*", "Message", ",", "sender", "*", "User", ")", "{", "command", ",", "err", ":=", "parse", "(", "message", ".", "Text", ",", "channel", ",", "s...
// MessageReceived must be called by the protocol upon receiving a message
[ "MessageReceived", "must", "be", "called", "by", "the", "protocol", "upon", "receiving", "a", "message" ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/bot.go#L160-L188
29,374
go-chat-bot/bot
bot.go
SendMessage
func (b *Bot) SendMessage(target string, message string, sender *User) { message = b.executeFilterCommands(&FilterCmd{ Target: target, Message: message, User: sender}) if message == "" { return } select { case b.msgsToSend <- responseMessage{target, message, sender}: default: b.errored("Failed to q...
go
func (b *Bot) SendMessage(target string, message string, sender *User) { message = b.executeFilterCommands(&FilterCmd{ Target: target, Message: message, User: sender}) if message == "" { return } select { case b.msgsToSend <- responseMessage{target, message, sender}: default: b.errored("Failed to q...
[ "func", "(", "b", "*", "Bot", ")", "SendMessage", "(", "target", "string", ",", "message", "string", ",", "sender", "*", "User", ")", "{", "message", "=", "b", ".", "executeFilterCommands", "(", "&", "FilterCmd", "{", "Target", ":", "target", ",", "Mes...
// SendMessage queues a message for a target recipient, optionally from a particular sender.
[ "SendMessage", "queues", "a", "message", "for", "a", "target", "recipient", "optionally", "from", "a", "particular", "sender", "." ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/bot.go#L191-L205
29,375
go-chat-bot/bot
slack/slack.go
FindUserBySlackID
func FindUserBySlackID(userID string) *bot.User { slackUser, err := api.GetUserInfo(userID) if err != nil { fmt.Printf("Error retrieving slack user: %s\n", err) return &bot.User{ ID: userID, IsBot: false} } return &bot.User{ ID: userID, Nick: slackUser.Name, RealName: slackUser.Profile....
go
func FindUserBySlackID(userID string) *bot.User { slackUser, err := api.GetUserInfo(userID) if err != nil { fmt.Printf("Error retrieving slack user: %s\n", err) return &bot.User{ ID: userID, IsBot: false} } return &bot.User{ ID: userID, Nick: slackUser.Name, RealName: slackUser.Profile....
[ "func", "FindUserBySlackID", "(", "userID", "string", ")", "*", "bot", ".", "User", "{", "slackUser", ",", "err", ":=", "api", ".", "GetUserInfo", "(", "userID", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ...
// FindUserBySlackID converts a slack.User into a bot.User struct
[ "FindUserBySlackID", "converts", "a", "slack", ".", "User", "into", "a", "bot", ".", "User", "struct" ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/slack/slack.go#L42-L55
29,376
go-chat-bot/bot
slack/slack.go
extractUser
func extractUser(event *slack.MessageEvent) *bot.User { var isBot bool var userID string if len(event.User) == 0 { userID = event.BotID isBot = true } else { userID = event.User isBot = false } user := FindUserBySlackID(userID) if len(user.Nick) == 0 { user.IsBot = isBot } return user }
go
func extractUser(event *slack.MessageEvent) *bot.User { var isBot bool var userID string if len(event.User) == 0 { userID = event.BotID isBot = true } else { userID = event.User isBot = false } user := FindUserBySlackID(userID) if len(user.Nick) == 0 { user.IsBot = isBot } return user }
[ "func", "extractUser", "(", "event", "*", "slack", ".", "MessageEvent", ")", "*", "bot", ".", "User", "{", "var", "isBot", "bool", "\n", "var", "userID", "string", "\n", "if", "len", "(", "event", ".", "User", ")", "==", "0", "{", "userID", "=", "e...
// Extracts user information from slack API
[ "Extracts", "user", "information", "from", "slack", "API" ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/slack/slack.go#L58-L74
29,377
go-chat-bot/bot
slack/slack.go
RunWithFilter
func RunWithFilter(token string, customMessageFilter MessageFilter) { if customMessageFilter == nil { panic("A valid message filter must be provided.") } messageFilter = customMessageFilter Run(token) }
go
func RunWithFilter(token string, customMessageFilter MessageFilter) { if customMessageFilter == nil { panic("A valid message filter must be provided.") } messageFilter = customMessageFilter Run(token) }
[ "func", "RunWithFilter", "(", "token", "string", ",", "customMessageFilter", "MessageFilter", ")", "{", "if", "customMessageFilter", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "messageFilter", "=", "customMessageFilter", "\n", "Run", "("...
// RunWithFilter executes the bot and sets up a message filter which will // receive all the messages before they are sent to slack
[ "RunWithFilter", "executes", "the", "bot", "and", "sets", "up", "a", "message", "filter", "which", "will", "receive", "all", "the", "messages", "before", "they", "are", "sent", "to", "slack" ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/slack/slack.go#L118-L124
29,378
go-chat-bot/bot
slack/slack.go
Run
func Run(token string) { api = slack.New(token) rtm = api.NewRTM() teaminfo, _ = api.GetTeamInfo() b := bot.New(&bot.Handlers{ Response: responseHandler, }, &bot.Config{ Protocol: protocol, Server: teaminfo.Domain, }, ) b.Disable([]string{"url"}) go rtm.ManageConnection() Loop: for { select...
go
func Run(token string) { api = slack.New(token) rtm = api.NewRTM() teaminfo, _ = api.GetTeamInfo() b := bot.New(&bot.Handlers{ Response: responseHandler, }, &bot.Config{ Protocol: protocol, Server: teaminfo.Domain, }, ) b.Disable([]string{"url"}) go rtm.ManageConnection() Loop: for { select...
[ "func", "Run", "(", "token", "string", ")", "{", "api", "=", "slack", ".", "New", "(", "token", ")", "\n", "rtm", "=", "api", ".", "NewRTM", "(", ")", "\n", "teaminfo", ",", "_", "=", "api", ".", "GetTeamInfo", "(", ")", "\n\n", "b", ":=", "bot...
// Run connects to slack RTM API using the provided token
[ "Run", "connects", "to", "slack", "RTM", "API", "using", "the", "provided", "token" ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/slack/slack.go#L127-L187
29,379
go-chat-bot/bot
irc/irc.go
SetUpConn
func SetUpConn(c *Config) (*bot.Bot, *ircevent.Connection) { return SetUp(c), ircConn }
go
func SetUpConn(c *Config) (*bot.Bot, *ircevent.Connection) { return SetUp(c), ircConn }
[ "func", "SetUpConn", "(", "c", "*", "Config", ")", "(", "*", "bot", ".", "Bot", ",", "*", "ircevent", ".", "Connection", ")", "{", "return", "SetUp", "(", "c", ")", ",", "ircConn", "\n", "}" ]
// SetUpConn wraps SetUp and returns ircConn in addition to bot
[ "SetUpConn", "wraps", "SetUp", "and", "returns", "ircConn", "in", "addition", "to", "bot" ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/irc/irc.go#L128-L130
29,380
go-chat-bot/bot
irc/irc.go
Run
func Run(c *Config) { if c != nil { SetUp(c) } err := ircConn.Connect(config.Server) if err != nil { log.Fatal(err) } ircConn.Loop() }
go
func Run(c *Config) { if c != nil { SetUp(c) } err := ircConn.Connect(config.Server) if err != nil { log.Fatal(err) } ircConn.Loop() }
[ "func", "Run", "(", "c", "*", "Config", ")", "{", "if", "c", "!=", "nil", "{", "SetUp", "(", "c", ")", "\n", "}", "\n\n", "err", ":=", "ircConn", ".", "Connect", "(", "config", ".", "Server", ")", "\n", "if", "err", "!=", "nil", "{", "log", "...
// Run reads the Config, connect to the specified IRC server and starts the bot. // The bot will automatically join all the channels specified in the configuration
[ "Run", "reads", "the", "Config", "connect", "to", "the", "specified", "IRC", "server", "and", "starts", "the", "bot", ".", "The", "bot", "will", "automatically", "join", "all", "the", "channels", "specified", "in", "the", "configuration" ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/irc/irc.go#L134-L144
29,381
go-chat-bot/bot
telegram/telegram.go
Run
func Run(token string, debug bool) { var err error tg, err = tgbotapi.NewBotAPI(token) if err != nil { log.Fatal(err) } tg.Debug = debug log.Printf("Authorized on account %s", tg.Self.UserName) u := tgbotapi.NewUpdate(0) u.Timeout = 60 updates, err := tg.GetUpdatesChan(u) if err != nil { log.Fatal(err...
go
func Run(token string, debug bool) { var err error tg, err = tgbotapi.NewBotAPI(token) if err != nil { log.Fatal(err) } tg.Debug = debug log.Printf("Authorized on account %s", tg.Self.UserName) u := tgbotapi.NewUpdate(0) u.Timeout = 60 updates, err := tg.GetUpdatesChan(u) if err != nil { log.Fatal(err...
[ "func", "Run", "(", "token", "string", ",", "debug", "bool", ")", "{", "var", "err", "error", "\n", "tg", ",", "err", "=", "tgbotapi", ".", "NewBotAPI", "(", "token", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatal", "(", "err", ")",...
// Run executes the bot and connects to Telegram using the provided token. Use the debug flag if you wish to see all traffic logged
[ "Run", "executes", "the", "bot", "and", "connects", "to", "Telegram", "using", "the", "provided", "token", ".", "Use", "the", "debug", "flag", "if", "you", "wish", "to", "see", "all", "traffic", "logged" ]
a72276ecd4eadb8f0129aa19caad1fc180d8f0f7
https://github.com/go-chat-bot/bot/blob/a72276ecd4eadb8f0129aa19caad1fc180d8f0f7/telegram/telegram.go#L34-L79
29,382
stathat/consistent
consistent.go
New
func New() *Consistent { c := new(Consistent) c.NumberOfReplicas = 20 c.circle = make(map[uint32]string) c.members = make(map[string]bool) return c }
go
func New() *Consistent { c := new(Consistent) c.NumberOfReplicas = 20 c.circle = make(map[uint32]string) c.members = make(map[string]bool) return c }
[ "func", "New", "(", ")", "*", "Consistent", "{", "c", ":=", "new", "(", "Consistent", ")", "\n", "c", ".", "NumberOfReplicas", "=", "20", "\n", "c", ".", "circle", "=", "make", "(", "map", "[", "uint32", "]", "string", ")", "\n", "c", ".", "membe...
// New creates a new Consistent object with a default setting of 20 replicas for each entry. // // To change the number of replicas, set NumberOfReplicas before adding entries.
[ "New", "creates", "a", "new", "Consistent", "object", "with", "a", "default", "setting", "of", "20", "replicas", "for", "each", "entry", ".", "To", "change", "the", "number", "of", "replicas", "set", "NumberOfReplicas", "before", "adding", "entries", "." ]
ad91dc4a3a642859730ff3d65929fce009bfdc23
https://github.com/stathat/consistent/blob/ad91dc4a3a642859730ff3d65929fce009bfdc23/consistent.go#L59-L65
29,383
stathat/consistent
consistent.go
eltKey
func (c *Consistent) eltKey(elt string, idx int) string { // return elt + "|" + strconv.Itoa(idx) return strconv.Itoa(idx) + elt }
go
func (c *Consistent) eltKey(elt string, idx int) string { // return elt + "|" + strconv.Itoa(idx) return strconv.Itoa(idx) + elt }
[ "func", "(", "c", "*", "Consistent", ")", "eltKey", "(", "elt", "string", ",", "idx", "int", ")", "string", "{", "// return elt + \"|\" + strconv.Itoa(idx)", "return", "strconv", ".", "Itoa", "(", "idx", ")", "+", "elt", "\n", "}" ]
// eltKey generates a string key for an element with an index.
[ "eltKey", "generates", "a", "string", "key", "for", "an", "element", "with", "an", "index", "." ]
ad91dc4a3a642859730ff3d65929fce009bfdc23
https://github.com/stathat/consistent/blob/ad91dc4a3a642859730ff3d65929fce009bfdc23/consistent.go#L68-L71
29,384
stathat/consistent
consistent.go
Add
func (c *Consistent) Add(elt string) { c.Lock() defer c.Unlock() c.add(elt) }
go
func (c *Consistent) Add(elt string) { c.Lock() defer c.Unlock() c.add(elt) }
[ "func", "(", "c", "*", "Consistent", ")", "Add", "(", "elt", "string", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "c", ".", "add", "(", "elt", ")", "\n", "}" ]
// Add inserts a string element in the consistent hash.
[ "Add", "inserts", "a", "string", "element", "in", "the", "consistent", "hash", "." ]
ad91dc4a3a642859730ff3d65929fce009bfdc23
https://github.com/stathat/consistent/blob/ad91dc4a3a642859730ff3d65929fce009bfdc23/consistent.go#L74-L78
29,385
stathat/consistent
consistent.go
Remove
func (c *Consistent) Remove(elt string) { c.Lock() defer c.Unlock() c.remove(elt) }
go
func (c *Consistent) Remove(elt string) { c.Lock() defer c.Unlock() c.remove(elt) }
[ "func", "(", "c", "*", "Consistent", ")", "Remove", "(", "elt", "string", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "c", ".", "remove", "(", "elt", ")", "\n", "}" ]
// Remove removes an element from the hash.
[ "Remove", "removes", "an", "element", "from", "the", "hash", "." ]
ad91dc4a3a642859730ff3d65929fce009bfdc23
https://github.com/stathat/consistent/blob/ad91dc4a3a642859730ff3d65929fce009bfdc23/consistent.go#L91-L95
29,386
stathat/consistent
consistent.go
Set
func (c *Consistent) Set(elts []string) { c.Lock() defer c.Unlock() for k := range c.members { found := false for _, v := range elts { if k == v { found = true break } } if !found { c.remove(k) } } for _, v := range elts { _, exists := c.members[v] if exists { continue } c.add...
go
func (c *Consistent) Set(elts []string) { c.Lock() defer c.Unlock() for k := range c.members { found := false for _, v := range elts { if k == v { found = true break } } if !found { c.remove(k) } } for _, v := range elts { _, exists := c.members[v] if exists { continue } c.add...
[ "func", "(", "c", "*", "Consistent", ")", "Set", "(", "elts", "[", "]", "string", ")", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "for", "k", ":=", "range", "c", ".", "members", "{", "found", ":=", "fa...
// Set sets all the elements in the hash. If there are existing elements not // present in elts, they will be removed.
[ "Set", "sets", "all", "the", "elements", "in", "the", "hash", ".", "If", "there", "are", "existing", "elements", "not", "present", "in", "elts", "they", "will", "be", "removed", "." ]
ad91dc4a3a642859730ff3d65929fce009bfdc23
https://github.com/stathat/consistent/blob/ad91dc4a3a642859730ff3d65929fce009bfdc23/consistent.go#L109-L131
29,387
stathat/consistent
consistent.go
Get
func (c *Consistent) Get(name string) (string, error) { c.RLock() defer c.RUnlock() if len(c.circle) == 0 { return "", ErrEmptyCircle } key := c.hashKey(name) i := c.search(key) return c.circle[c.sortedHashes[i]], nil }
go
func (c *Consistent) Get(name string) (string, error) { c.RLock() defer c.RUnlock() if len(c.circle) == 0 { return "", ErrEmptyCircle } key := c.hashKey(name) i := c.search(key) return c.circle[c.sortedHashes[i]], nil }
[ "func", "(", "c", "*", "Consistent", ")", "Get", "(", "name", "string", ")", "(", "string", ",", "error", ")", "{", "c", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "RUnlock", "(", ")", "\n", "if", "len", "(", "c", ".", "circle", ")", "=...
// Get returns an element close to where name hashes to in the circle.
[ "Get", "returns", "an", "element", "close", "to", "where", "name", "hashes", "to", "in", "the", "circle", "." ]
ad91dc4a3a642859730ff3d65929fce009bfdc23
https://github.com/stathat/consistent/blob/ad91dc4a3a642859730ff3d65929fce009bfdc23/consistent.go#L144-L153
29,388
stathat/consistent
consistent.go
GetTwo
func (c *Consistent) GetTwo(name string) (string, string, error) { c.RLock() defer c.RUnlock() if len(c.circle) == 0 { return "", "", ErrEmptyCircle } key := c.hashKey(name) i := c.search(key) a := c.circle[c.sortedHashes[i]] if c.count == 1 { return a, "", nil } start := i var b string for i = start ...
go
func (c *Consistent) GetTwo(name string) (string, string, error) { c.RLock() defer c.RUnlock() if len(c.circle) == 0 { return "", "", ErrEmptyCircle } key := c.hashKey(name) i := c.search(key) a := c.circle[c.sortedHashes[i]] if c.count == 1 { return a, "", nil } start := i var b string for i = start ...
[ "func", "(", "c", "*", "Consistent", ")", "GetTwo", "(", "name", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "c", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "RUnlock", "(", ")", "\n", "if", "len", "(", "c", ".", ...
// GetTwo returns the two closest distinct elements to the name input in the circle.
[ "GetTwo", "returns", "the", "two", "closest", "distinct", "elements", "to", "the", "name", "input", "in", "the", "circle", "." ]
ad91dc4a3a642859730ff3d65929fce009bfdc23
https://github.com/stathat/consistent/blob/ad91dc4a3a642859730ff3d65929fce009bfdc23/consistent.go#L167-L193
29,389
stathat/consistent
consistent.go
GetN
func (c *Consistent) GetN(name string, n int) ([]string, error) { c.RLock() defer c.RUnlock() if len(c.circle) == 0 { return nil, ErrEmptyCircle } if c.count < int64(n) { n = int(c.count) } var ( key = c.hashKey(name) i = c.search(key) start = i res = make([]string, 0, n) elem = c.circl...
go
func (c *Consistent) GetN(name string, n int) ([]string, error) { c.RLock() defer c.RUnlock() if len(c.circle) == 0 { return nil, ErrEmptyCircle } if c.count < int64(n) { n = int(c.count) } var ( key = c.hashKey(name) i = c.search(key) start = i res = make([]string, 0, n) elem = c.circl...
[ "func", "(", "c", "*", "Consistent", ")", "GetN", "(", "name", "string", ",", "n", "int", ")", "(", "[", "]", "string", ",", "error", ")", "{", "c", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "RUnlock", "(", ")", "\n\n", "if", "len", "(...
// GetN returns the N closest distinct elements to the name input in the circle.
[ "GetN", "returns", "the", "N", "closest", "distinct", "elements", "to", "the", "name", "input", "in", "the", "circle", "." ]
ad91dc4a3a642859730ff3d65929fce009bfdc23
https://github.com/stathat/consistent/blob/ad91dc4a3a642859730ff3d65929fce009bfdc23/consistent.go#L196-L236
29,390
tecbot/gorocksdb
ratelimiter.go
NewRateLimiter
func NewRateLimiter(rate_bytes_per_sec, refill_period_us int64, fairness int32) *RateLimiter { return NewNativeRateLimiter(C.rocksdb_ratelimiter_create( C.int64_t(rate_bytes_per_sec), C.int64_t(refill_period_us), C.int32_t(fairness), )) }
go
func NewRateLimiter(rate_bytes_per_sec, refill_period_us int64, fairness int32) *RateLimiter { return NewNativeRateLimiter(C.rocksdb_ratelimiter_create( C.int64_t(rate_bytes_per_sec), C.int64_t(refill_period_us), C.int32_t(fairness), )) }
[ "func", "NewRateLimiter", "(", "rate_bytes_per_sec", ",", "refill_period_us", "int64", ",", "fairness", "int32", ")", "*", "RateLimiter", "{", "return", "NewNativeRateLimiter", "(", "C", ".", "rocksdb_ratelimiter_create", "(", "C", ".", "int64_t", "(", "rate_bytes_p...
// NewDefaultRateLimiter creates a default RateLimiter object.
[ "NewDefaultRateLimiter", "creates", "a", "default", "RateLimiter", "object", "." ]
8752a943348155073ae407010e2b75c40480271a
https://github.com/tecbot/gorocksdb/blob/8752a943348155073ae407010e2b75c40480271a/ratelimiter.go#L14-L20
29,391
tecbot/gorocksdb
ratelimiter.go
Destroy
func (self *RateLimiter) Destroy() { C.rocksdb_ratelimiter_destroy(self.c) self.c = nil }
go
func (self *RateLimiter) Destroy() { C.rocksdb_ratelimiter_destroy(self.c) self.c = nil }
[ "func", "(", "self", "*", "RateLimiter", ")", "Destroy", "(", ")", "{", "C", ".", "rocksdb_ratelimiter_destroy", "(", "self", ".", "c", ")", "\n", "self", ".", "c", "=", "nil", "\n", "}" ]
// Destroy deallocates the RateLimiter object.
[ "Destroy", "deallocates", "the", "RateLimiter", "object", "." ]
8752a943348155073ae407010e2b75c40480271a
https://github.com/tecbot/gorocksdb/blob/8752a943348155073ae407010e2b75c40480271a/ratelimiter.go#L28-L31
29,392
tecbot/gorocksdb
dbpath.go
NewDBPath
func NewDBPath(path string, target_size uint64) *DBPath { cpath := C.CString(path) defer C.free(unsafe.Pointer(cpath)) return NewNativeDBPath(C.rocksdb_dbpath_create(cpath, C.uint64_t(target_size))) }
go
func NewDBPath(path string, target_size uint64) *DBPath { cpath := C.CString(path) defer C.free(unsafe.Pointer(cpath)) return NewNativeDBPath(C.rocksdb_dbpath_create(cpath, C.uint64_t(target_size))) }
[ "func", "NewDBPath", "(", "path", "string", ",", "target_size", "uint64", ")", "*", "DBPath", "{", "cpath", ":=", "C", ".", "CString", "(", "path", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cpath", ")", ")", "\n", "...
// NewDBPath creates a DBPath object // with the given path and target_size.
[ "NewDBPath", "creates", "a", "DBPath", "object", "with", "the", "given", "path", "and", "target_size", "." ]
8752a943348155073ae407010e2b75c40480271a
https://github.com/tecbot/gorocksdb/blob/8752a943348155073ae407010e2b75c40480271a/dbpath.go#L15-L19
29,393
tecbot/gorocksdb
dbpath.go
NewDBPathsFromData
func NewDBPathsFromData(paths []string, target_sizes []uint64) []*DBPath { dbpaths := make([]*DBPath, len(paths)) for i, path := range paths { targetSize := target_sizes[i] dbpaths[i] = NewDBPath(path, targetSize) } return dbpaths }
go
func NewDBPathsFromData(paths []string, target_sizes []uint64) []*DBPath { dbpaths := make([]*DBPath, len(paths)) for i, path := range paths { targetSize := target_sizes[i] dbpaths[i] = NewDBPath(path, targetSize) } return dbpaths }
[ "func", "NewDBPathsFromData", "(", "paths", "[", "]", "string", ",", "target_sizes", "[", "]", "uint64", ")", "[", "]", "*", "DBPath", "{", "dbpaths", ":=", "make", "(", "[", "]", "*", "DBPath", ",", "len", "(", "paths", ")", ")", "\n", "for", "i",...
// NewDBPathsFromData creates a slice with allocated DBPath objects // from paths and target_sizes.
[ "NewDBPathsFromData", "creates", "a", "slice", "with", "allocated", "DBPath", "objects", "from", "paths", "and", "target_sizes", "." ]
8752a943348155073ae407010e2b75c40480271a
https://github.com/tecbot/gorocksdb/blob/8752a943348155073ae407010e2b75c40480271a/dbpath.go#L33-L41
29,394
tecbot/gorocksdb
options_read.go
Destroy
func (opts *ReadOptions) Destroy() { C.rocksdb_readoptions_destroy(opts.c) opts.c = nil }
go
func (opts *ReadOptions) Destroy() { C.rocksdb_readoptions_destroy(opts.c) opts.c = nil }
[ "func", "(", "opts", "*", "ReadOptions", ")", "Destroy", "(", ")", "{", "C", ".", "rocksdb_readoptions_destroy", "(", "opts", ".", "c", ")", "\n", "opts", ".", "c", "=", "nil", "\n", "}" ]
// Destroy deallocates the ReadOptions object.
[ "Destroy", "deallocates", "the", "ReadOptions", "object", "." ]
8752a943348155073ae407010e2b75c40480271a
https://github.com/tecbot/gorocksdb/blob/8752a943348155073ae407010e2b75c40480271a/options_read.go#L122-L125
29,395
tecbot/gorocksdb
transaction.go
Commit
func (transaction *Transaction) Commit() error { var ( cErr *C.char ) C.rocksdb_transaction_commit(transaction.c, &cErr) if cErr != nil { defer C.free(unsafe.Pointer(cErr)) return errors.New(C.GoString(cErr)) } return nil }
go
func (transaction *Transaction) Commit() error { var ( cErr *C.char ) C.rocksdb_transaction_commit(transaction.c, &cErr) if cErr != nil { defer C.free(unsafe.Pointer(cErr)) return errors.New(C.GoString(cErr)) } return nil }
[ "func", "(", "transaction", "*", "Transaction", ")", "Commit", "(", ")", "error", "{", "var", "(", "cErr", "*", "C", ".", "char", "\n", ")", "\n", "C", ".", "rocksdb_transaction_commit", "(", "transaction", ".", "c", ",", "&", "cErr", ")", "\n", "if"...
// Commit commits the transaction to the database.
[ "Commit", "commits", "the", "transaction", "to", "the", "database", "." ]
8752a943348155073ae407010e2b75c40480271a
https://github.com/tecbot/gorocksdb/blob/8752a943348155073ae407010e2b75c40480271a/transaction.go#L23-L33
29,396
tecbot/gorocksdb
transaction.go
Rollback
func (transaction *Transaction) Rollback() error { var ( cErr *C.char ) C.rocksdb_transaction_rollback(transaction.c, &cErr) if cErr != nil { defer C.free(unsafe.Pointer(cErr)) return errors.New(C.GoString(cErr)) } return nil }
go
func (transaction *Transaction) Rollback() error { var ( cErr *C.char ) C.rocksdb_transaction_rollback(transaction.c, &cErr) if cErr != nil { defer C.free(unsafe.Pointer(cErr)) return errors.New(C.GoString(cErr)) } return nil }
[ "func", "(", "transaction", "*", "Transaction", ")", "Rollback", "(", ")", "error", "{", "var", "(", "cErr", "*", "C", ".", "char", "\n", ")", "\n", "C", ".", "rocksdb_transaction_rollback", "(", "transaction", ".", "c", ",", "&", "cErr", ")", "\n\n", ...
// Rollback performs a rollback on the transaction.
[ "Rollback", "performs", "a", "rollback", "on", "the", "transaction", "." ]
8752a943348155073ae407010e2b75c40480271a
https://github.com/tecbot/gorocksdb/blob/8752a943348155073ae407010e2b75c40480271a/transaction.go#L36-L47
29,397
tecbot/gorocksdb
transaction.go
Put
func (transaction *Transaction) Put(key, value []byte) error { var ( cErr *C.char cKey = byteToChar(key) cValue = byteToChar(value) ) C.rocksdb_transaction_put( transaction.c, cKey, C.size_t(len(key)), cValue, C.size_t(len(value)), &cErr, ) if cErr != nil { defer C.free(unsafe.Pointer(cErr)) return...
go
func (transaction *Transaction) Put(key, value []byte) error { var ( cErr *C.char cKey = byteToChar(key) cValue = byteToChar(value) ) C.rocksdb_transaction_put( transaction.c, cKey, C.size_t(len(key)), cValue, C.size_t(len(value)), &cErr, ) if cErr != nil { defer C.free(unsafe.Pointer(cErr)) return...
[ "func", "(", "transaction", "*", "Transaction", ")", "Put", "(", "key", ",", "value", "[", "]", "byte", ")", "error", "{", "var", "(", "cErr", "*", "C", ".", "char", "\n", "cKey", "=", "byteToChar", "(", "key", ")", "\n", "cValue", "=", "byteToChar...
// Put writes data associated with a key to the transaction.
[ "Put", "writes", "data", "associated", "with", "a", "key", "to", "the", "transaction", "." ]
8752a943348155073ae407010e2b75c40480271a
https://github.com/tecbot/gorocksdb/blob/8752a943348155073ae407010e2b75c40480271a/transaction.go#L84-L98
29,398
tecbot/gorocksdb
transaction.go
Delete
func (transaction *Transaction) Delete(key []byte) error { var ( cErr *C.char cKey = byteToChar(key) ) C.rocksdb_transaction_delete(transaction.c, cKey, C.size_t(len(key)), &cErr) if cErr != nil { defer C.free(unsafe.Pointer(cErr)) return errors.New(C.GoString(cErr)) } return nil }
go
func (transaction *Transaction) Delete(key []byte) error { var ( cErr *C.char cKey = byteToChar(key) ) C.rocksdb_transaction_delete(transaction.c, cKey, C.size_t(len(key)), &cErr) if cErr != nil { defer C.free(unsafe.Pointer(cErr)) return errors.New(C.GoString(cErr)) } return nil }
[ "func", "(", "transaction", "*", "Transaction", ")", "Delete", "(", "key", "[", "]", "byte", ")", "error", "{", "var", "(", "cErr", "*", "C", ".", "char", "\n", "cKey", "=", "byteToChar", "(", "key", ")", "\n", ")", "\n", "C", ".", "rocksdb_transac...
// Delete removes the data associated with the key from the transaction.
[ "Delete", "removes", "the", "data", "associated", "with", "the", "key", "from", "the", "transaction", "." ]
8752a943348155073ae407010e2b75c40480271a
https://github.com/tecbot/gorocksdb/blob/8752a943348155073ae407010e2b75c40480271a/transaction.go#L101-L112
29,399
tecbot/gorocksdb
transaction.go
NewIterator
func (transaction *Transaction) NewIterator(opts *ReadOptions) *Iterator { return NewNativeIterator( unsafe.Pointer(C.rocksdb_transaction_create_iterator(transaction.c, opts.c))) }
go
func (transaction *Transaction) NewIterator(opts *ReadOptions) *Iterator { return NewNativeIterator( unsafe.Pointer(C.rocksdb_transaction_create_iterator(transaction.c, opts.c))) }
[ "func", "(", "transaction", "*", "Transaction", ")", "NewIterator", "(", "opts", "*", "ReadOptions", ")", "*", "Iterator", "{", "return", "NewNativeIterator", "(", "unsafe", ".", "Pointer", "(", "C", ".", "rocksdb_transaction_create_iterator", "(", "transaction", ...
// NewIterator returns an Iterator over the database that uses the // ReadOptions given.
[ "NewIterator", "returns", "an", "Iterator", "over", "the", "database", "that", "uses", "the", "ReadOptions", "given", "." ]
8752a943348155073ae407010e2b75c40480271a
https://github.com/tecbot/gorocksdb/blob/8752a943348155073ae407010e2b75c40480271a/transaction.go#L116-L119