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
150,900
wildducktheories/go-csv
writer.go
Blank
func (w *writer) Blank() Record { return w.builder(make([]string, len(w.header), len(w.header))) }
go
func (w *writer) Blank() Record { return w.builder(make([]string, len(w.header), len(w.header))) }
[ "func", "(", "w", "*", "writer", ")", "Blank", "(", ")", "Record", "{", "return", "w", ".", "builder", "(", "make", "(", "[", "]", "string", ",", "len", "(", "w", ".", "header", ")", ",", "len", "(", "w", ".", "header", ")", ")", ")", "\n", ...
// Answer a blank record for the output stream
[ "Answer", "a", "blank", "record", "for", "the", "output", "stream" ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/writer.go#L55-L57
150,901
wildducktheories/go-csv
writer.go
Write
func (w *writer) Write(r Record) error { if w.err != nil { return w.err } h := r.Header() var d []string if len(h) > 0 && len(w.header) == len(h) && &h[0] == &w.header[0] { // optimisation to avoid copying or iterating over slice in default case d = r.AsSlice() } else { // fallback in case where the stream and the record have a different header d := make([]string, len(w.header), len(w.header)) for i, k := range w.header { d[i] = r.Get(k) } } return w.encoder.Write(d) }
go
func (w *writer) Write(r Record) error { if w.err != nil { return w.err } h := r.Header() var d []string if len(h) > 0 && len(w.header) == len(h) && &h[0] == &w.header[0] { // optimisation to avoid copying or iterating over slice in default case d = r.AsSlice() } else { // fallback in case where the stream and the record have a different header d := make([]string, len(w.header), len(w.header)) for i, k := range w.header { d[i] = r.Get(k) } } return w.encoder.Write(d) }
[ "func", "(", "w", "*", "writer", ")", "Write", "(", "r", "Record", ")", "error", "{", "if", "w", ".", "err", "!=", "nil", "{", "return", "w", ".", "err", "\n", "}", "\n", "h", ":=", "r", ".", "Header", "(", ")", "\n", "var", "d", "[", "]", ...
// Write a record into the underlying stream.
[ "Write", "a", "record", "into", "the", "underlying", "stream", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/writer.go#L60-L77
150,902
wildducktheories/go-csv
writer.go
Close
func (w *writer) Close(err error) error { w.encoder.Flush() if err == nil { err = w.encoder.Error() } w.err = err if w.closer != nil { return w.closer.Close() } else { return nil } }
go
func (w *writer) Close(err error) error { w.encoder.Flush() if err == nil { err = w.encoder.Error() } w.err = err if w.closer != nil { return w.closer.Close() } else { return nil } }
[ "func", "(", "w", "*", "writer", ")", "Close", "(", "err", "error", ")", "error", "{", "w", ".", "encoder", ".", "Flush", "(", ")", "\n", "if", "err", "==", "nil", "{", "err", "=", "w", ".", "encoder", ".", "Error", "(", ")", "\n", "}", "\n",...
// Close the stream and propagate an error
[ "Close", "the", "stream", "and", "propagate", "an", "error" ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/writer.go#L84-L95
150,903
wildducktheories/go-csv
sort.go
AsSortProcess
func (b *Sortable) AsSortProcess() *SortProcess { return &SortProcess{ Keys: b.Keys, AsSort: func(data []Record) sort.Interface { b.Data = data return b }, } }
go
func (b *Sortable) AsSortProcess() *SortProcess { return &SortProcess{ Keys: b.Keys, AsSort: func(data []Record) sort.Interface { b.Data = data return b }, } }
[ "func", "(", "b", "*", "Sortable", ")", "AsSortProcess", "(", ")", "*", "SortProcess", "{", "return", "&", "SortProcess", "{", "Keys", ":", "b", ".", "Keys", ",", "AsSort", ":", "func", "(", "data", "[", "]", "Record", ")", "sort", ".", "Interface", ...
// Derives a SortProcess from the receiver. Note that it isn't safe // to run multiple processes derived from the same Sortable at the same // time.
[ "Derives", "a", "SortProcess", "from", "the", "receiver", ".", "Note", "that", "it", "isn", "t", "safe", "to", "run", "multiple", "processes", "derived", "from", "the", "same", "Sortable", "at", "the", "same", "time", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/sort.go#L42-L50
150,904
wildducktheories/go-csv
sort.go
Comparator
func (b *Sortable) Comparator(k string, less StringComparator) SortComparator { return func(i, j int) bool { return less(b.Data[i].Get(k), b.Data[j].Get(k)) } }
go
func (b *Sortable) Comparator(k string, less StringComparator) SortComparator { return func(i, j int) bool { return less(b.Data[i].Get(k), b.Data[j].Get(k)) } }
[ "func", "(", "b", "*", "Sortable", ")", "Comparator", "(", "k", "string", ",", "less", "StringComparator", ")", "SortComparator", "{", "return", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "less", "(", "b", ".", "Data", "[", "i", ...
// Answer a comparator for the field named k, using the string comparator specified by less.
[ "Answer", "a", "comparator", "for", "the", "field", "named", "k", "using", "the", "string", "comparator", "specified", "by", "less", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/sort.go#L53-L57
150,905
wildducktheories/go-csv
sort.go
AsSort
func (p *SortKeys) AsSort(data []Record) sort.Interface { return p.AsSortable(data) }
go
func (p *SortKeys) AsSort(data []Record) sort.Interface { return p.AsSortable(data) }
[ "func", "(", "p", "*", "SortKeys", ")", "AsSort", "(", "data", "[", "]", "Record", ")", "sort", ".", "Interface", "{", "return", "p", ".", "AsSortable", "(", "data", ")", "\n", "}" ]
// Answer a Sort for the specified slice of CSV records, using the comparators derived from the // keys specified by the receiver.
[ "Answer", "a", "Sort", "for", "the", "specified", "slice", "of", "CSV", "records", "using", "the", "comparators", "derived", "from", "the", "keys", "specified", "by", "the", "receiver", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/sort.go#L87-L89
150,906
wildducktheories/go-csv
sort.go
AsSortable
func (p *SortKeys) AsSortable(data []Record) *Sortable { bk := &Sortable{ Keys: p.Keys, Data: data, Comparators: make([]SortComparator, len(p.Keys), len(p.Keys)), } for x, c := range p.AsRecordComparators() { c := c bk.Comparators[x] = func(i, j int) bool { return c(bk.Data[i], bk.Data[j]) } } return bk }
go
func (p *SortKeys) AsSortable(data []Record) *Sortable { bk := &Sortable{ Keys: p.Keys, Data: data, Comparators: make([]SortComparator, len(p.Keys), len(p.Keys)), } for x, c := range p.AsRecordComparators() { c := c bk.Comparators[x] = func(i, j int) bool { return c(bk.Data[i], bk.Data[j]) } } return bk }
[ "func", "(", "p", "*", "SortKeys", ")", "AsSortable", "(", "data", "[", "]", "Record", ")", "*", "Sortable", "{", "bk", ":=", "&", "Sortable", "{", "Keys", ":", "p", ".", "Keys", ",", "Data", ":", "data", ",", "Comparators", ":", "make", "(", "["...
// Answer a Sortable whose comparators have been initialized with string or numerical string // comparators according the specification of the receiver.
[ "Answer", "a", "Sortable", "whose", "comparators", "have", "been", "initialized", "with", "string", "or", "numerical", "string", "comparators", "according", "the", "specification", "of", "the", "receiver", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/sort.go#L93-L106
150,907
wildducktheories/go-csv
sort.go
AsSortProcess
func (p *SortKeys) AsSortProcess() *SortProcess { return &SortProcess{ AsSort: p.AsSort, Keys: p.Keys, } }
go
func (p *SortKeys) AsSortProcess() *SortProcess { return &SortProcess{ AsSort: p.AsSort, Keys: p.Keys, } }
[ "func", "(", "p", "*", "SortKeys", ")", "AsSortProcess", "(", ")", "*", "SortProcess", "{", "return", "&", "SortProcess", "{", "AsSort", ":", "p", ".", "AsSort", ",", "Keys", ":", "p", ".", "Keys", ",", "}", "\n", "}" ]
// Derive a SortProcess from the receiver.
[ "Derive", "a", "SortProcess", "from", "the", "receiver", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/sort.go#L109-L114
150,908
wildducktheories/go-csv
sort.go
AsStringProjection
func (p *SortKeys) AsStringProjection() StringProjection { return func(r Record) []string { result := make([]string, len(p.Keys)) for i, k := range p.Keys { result[i] = r.Get(k) } return result } }
go
func (p *SortKeys) AsStringProjection() StringProjection { return func(r Record) []string { result := make([]string, len(p.Keys)) for i, k := range p.Keys { result[i] = r.Get(k) } return result } }
[ "func", "(", "p", "*", "SortKeys", ")", "AsStringProjection", "(", ")", "StringProjection", "{", "return", "func", "(", "r", "Record", ")", "[", "]", "string", "{", "result", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "p", ".", "Keys", ...
// Derive a StringProjection from the sort keys.
[ "Derive", "a", "StringProjection", "from", "the", "sort", "keys", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/sort.go#L117-L125
150,909
wildducktheories/go-csv
sort.go
AsStringSliceComparator
func (p *SortKeys) AsStringSliceComparator() StringSliceComparator { numeric := utils.NewIndex(p.Numeric) reverseIndex := utils.NewIndex(p.Reversed) comparators := make([]StringComparator, len(p.Keys)) for i, k := range p.Keys { if numeric.Contains(k) { comparators[i] = LessNumericStrings } else { comparators[i] = LessStrings } if reverseIndex.Contains(k) { f := comparators[i] comparators[i] = func(l, r string) bool { return !f(l, r) } } } return AsStringSliceComparator(comparators) }
go
func (p *SortKeys) AsStringSliceComparator() StringSliceComparator { numeric := utils.NewIndex(p.Numeric) reverseIndex := utils.NewIndex(p.Reversed) comparators := make([]StringComparator, len(p.Keys)) for i, k := range p.Keys { if numeric.Contains(k) { comparators[i] = LessNumericStrings } else { comparators[i] = LessStrings } if reverseIndex.Contains(k) { f := comparators[i] comparators[i] = func(l, r string) bool { return !f(l, r) } } } return AsStringSliceComparator(comparators) }
[ "func", "(", "p", "*", "SortKeys", ")", "AsStringSliceComparator", "(", ")", "StringSliceComparator", "{", "numeric", ":=", "utils", ".", "NewIndex", "(", "p", ".", "Numeric", ")", "\n", "reverseIndex", ":=", "utils", ".", "NewIndex", "(", "p", ".", "Rever...
// Answers a comparator that can compare two slices.
[ "Answers", "a", "comparator", "that", "can", "compare", "two", "slices", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/sort.go#L128-L146
150,910
wildducktheories/go-csv
sort.go
AsRecordComparators
func (p *SortKeys) AsRecordComparators() []RecordComparator { numeric := utils.NewIndex(p.Numeric) reverseIndex := utils.NewIndex(p.Reversed) comparators := make([]RecordComparator, len(p.Keys)) for i, k := range p.Keys { k := k if numeric.Contains(k) { comparators[i] = func(l, r Record) bool { return LessNumericStrings(l.Get(k), r.Get(k)) } } else { comparators[i] = func(l, r Record) bool { return LessStrings(l.Get(k), r.Get(k)) } } if reverseIndex.Contains(k) { f := comparators[i] comparators[i] = func(l, r Record) bool { return !f(l, r) } } } return comparators }
go
func (p *SortKeys) AsRecordComparators() []RecordComparator { numeric := utils.NewIndex(p.Numeric) reverseIndex := utils.NewIndex(p.Reversed) comparators := make([]RecordComparator, len(p.Keys)) for i, k := range p.Keys { k := k if numeric.Contains(k) { comparators[i] = func(l, r Record) bool { return LessNumericStrings(l.Get(k), r.Get(k)) } } else { comparators[i] = func(l, r Record) bool { return LessStrings(l.Get(k), r.Get(k)) } } if reverseIndex.Contains(k) { f := comparators[i] comparators[i] = func(l, r Record) bool { return !f(l, r) } } } return comparators }
[ "func", "(", "p", "*", "SortKeys", ")", "AsRecordComparators", "(", ")", "[", "]", "RecordComparator", "{", "numeric", ":=", "utils", ".", "NewIndex", "(", "p", ".", "Numeric", ")", "\n", "reverseIndex", ":=", "utils", ".", "NewIndex", "(", "p", ".", "...
// Answers a slice of comparators that can compare two records.
[ "Answers", "a", "slice", "of", "comparators", "that", "can", "compare", "two", "records", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/sort.go#L149-L172
150,911
wildducktheories/go-csv
sort.go
Run
func (p *SortProcess) Run(reader Reader, builder WriterBuilder, errCh chan<- error) { errCh <- func() (err error) { defer reader.Close() keys := p.Keys // get the data header dataHeader := reader.Header() writer := builder(dataHeader) defer writer.Close(err) _, x, _ := utils.Intersect(keys, dataHeader) if len(x) != 0 { return fmt.Errorf("invalid keys: %v", x) } if all, err := ReadAll(reader); err != nil { return err } else { sort.Sort(p.AsSort(all)) for _, e := range all { if err := writer.Write(e); err != nil { return err } } } return nil }() }
go
func (p *SortProcess) Run(reader Reader, builder WriterBuilder, errCh chan<- error) { errCh <- func() (err error) { defer reader.Close() keys := p.Keys // get the data header dataHeader := reader.Header() writer := builder(dataHeader) defer writer.Close(err) _, x, _ := utils.Intersect(keys, dataHeader) if len(x) != 0 { return fmt.Errorf("invalid keys: %v", x) } if all, err := ReadAll(reader); err != nil { return err } else { sort.Sort(p.AsSort(all)) for _, e := range all { if err := writer.Write(e); err != nil { return err } } } return nil }() }
[ "func", "(", "p", "*", "SortProcess", ")", "Run", "(", "reader", "Reader", ",", "builder", "WriterBuilder", ",", "errCh", "chan", "<-", "error", ")", "{", "errCh", "<-", "func", "(", ")", "(", "err", "error", ")", "{", "defer", "reader", ".", "Close"...
// Run the sort process specified by the receiver against the specified CSV reader, // writing the results to a Writer constructed from the specified builder. // Termination of the sort process is signalled by writing nil or at most one error // into the specified error channel. // It is an error to apply the receiving process to a reader whose Header is not // a strict superset of the receiver's Keys.
[ "Run", "the", "sort", "process", "specified", "by", "the", "receiver", "against", "the", "specified", "CSV", "reader", "writing", "the", "results", "to", "a", "Writer", "constructed", "from", "the", "specified", "builder", ".", "Termination", "of", "the", "sor...
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/sort.go#L193-L224
150,912
wildducktheories/go-csv
influx-line-format.go
Run
func (p *InfluxLineFormatProcess) Run(reader Reader, out io.Writer, errCh chan<- error) { errCh <- func() (err error) { defer reader.Close() sort.Strings(p.Tags) sort.Strings(p.Values) // see: http://stackoverflow.com/questions/13340717/json-numbers-regular-expression numberMatcher := regexp.MustCompile("^ *-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)? *$") if location, err := time.LoadLocation(p.Location); err != nil { return err } else { maxLen := len(p.Measurement) count := 1 for data := range reader.C() { count++ stringTs := data.Get(p.Timestamp) parse := func(s string) (time.Time, error) { if p.Format == "ns" { if ns, err := strconv.ParseInt(s, 10, 64); err != nil { return time.Unix(0, 0), err } else { return time.Unix(0, ns), nil } } else if p.Format == "s" { if sec, err := strconv.ParseInt(s, 10, 64); err != nil { return time.Unix(0, 0), err } else { return time.Unix(sec, 0), nil } } else if p.Format == "ms" { if ms, err := strconv.ParseInt(s, 10, 64); err != nil { return time.Unix(0, 0), err } else { return time.Unix(0, ms*1000000), nil } } else { return time.ParseInLocation(p.Format, stringTs, location) } } if ts, err := parse(stringTs); err != nil { return err } else { buffer := make([]byte, 0, maxLen) buffer = append(buffer, p.Measurement...) for _, t := range p.Tags { v := data.Get(t) if v == "" { continue } buffer = append(buffer, ","...) buffer = append(buffer, t...) buffer = append(buffer, "="...) buffer = append(buffer, escapeTag([]byte(v))...) } buffer = append(buffer, " "...) first := true appended := 0 for _, f := range p.Values { v := data.Get(f) if v == "" { continue } appended++ if !first { buffer = append(buffer, ","...) } else { first = false } buffer = append(buffer, f...) buffer = append(buffer, "="...) if numberMatcher.MatchString(v) || v == "true" || v == "false" { buffer = append(buffer, v...) } else { buffer = append(buffer, strconv.Quote(v)...) } } if appended == 0 { fmt.Fprintf(os.Stderr, "%d: dropping field-less point\n", count) continue } if len(buffer) > maxLen { maxLen = len(buffer) } buffer = append(buffer, " "...) buffer = append(buffer, strconv.FormatInt(ts.UnixNano(), 10)...) buffer = append(buffer, "\n"...) if _, err := out.Write(buffer); err != nil { return err } } } return reader.Error() } }() }
go
func (p *InfluxLineFormatProcess) Run(reader Reader, out io.Writer, errCh chan<- error) { errCh <- func() (err error) { defer reader.Close() sort.Strings(p.Tags) sort.Strings(p.Values) // see: http://stackoverflow.com/questions/13340717/json-numbers-regular-expression numberMatcher := regexp.MustCompile("^ *-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)? *$") if location, err := time.LoadLocation(p.Location); err != nil { return err } else { maxLen := len(p.Measurement) count := 1 for data := range reader.C() { count++ stringTs := data.Get(p.Timestamp) parse := func(s string) (time.Time, error) { if p.Format == "ns" { if ns, err := strconv.ParseInt(s, 10, 64); err != nil { return time.Unix(0, 0), err } else { return time.Unix(0, ns), nil } } else if p.Format == "s" { if sec, err := strconv.ParseInt(s, 10, 64); err != nil { return time.Unix(0, 0), err } else { return time.Unix(sec, 0), nil } } else if p.Format == "ms" { if ms, err := strconv.ParseInt(s, 10, 64); err != nil { return time.Unix(0, 0), err } else { return time.Unix(0, ms*1000000), nil } } else { return time.ParseInLocation(p.Format, stringTs, location) } } if ts, err := parse(stringTs); err != nil { return err } else { buffer := make([]byte, 0, maxLen) buffer = append(buffer, p.Measurement...) for _, t := range p.Tags { v := data.Get(t) if v == "" { continue } buffer = append(buffer, ","...) buffer = append(buffer, t...) buffer = append(buffer, "="...) buffer = append(buffer, escapeTag([]byte(v))...) } buffer = append(buffer, " "...) first := true appended := 0 for _, f := range p.Values { v := data.Get(f) if v == "" { continue } appended++ if !first { buffer = append(buffer, ","...) } else { first = false } buffer = append(buffer, f...) buffer = append(buffer, "="...) if numberMatcher.MatchString(v) || v == "true" || v == "false" { buffer = append(buffer, v...) } else { buffer = append(buffer, strconv.Quote(v)...) } } if appended == 0 { fmt.Fprintf(os.Stderr, "%d: dropping field-less point\n", count) continue } if len(buffer) > maxLen { maxLen = len(buffer) } buffer = append(buffer, " "...) buffer = append(buffer, strconv.FormatInt(ts.UnixNano(), 10)...) buffer = append(buffer, "\n"...) if _, err := out.Write(buffer); err != nil { return err } } } return reader.Error() } }() }
[ "func", "(", "p", "*", "InfluxLineFormatProcess", ")", "Run", "(", "reader", "Reader", ",", "out", "io", ".", "Writer", ",", "errCh", "chan", "<-", "error", ")", "{", "errCh", "<-", "func", "(", ")", "(", "err", "error", ")", "{", "defer", "reader", ...
// Run exhausts the reader, writing one record in influx line format per CSV input record.
[ "Run", "exhausts", "the", "reader", "writing", "one", "record", "in", "influx", "line", "format", "per", "CSV", "input", "record", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/influx-line-format.go#L42-L149
150,913
wildducktheories/go-csv
comparator.go
AsRecordComparator
func AsRecordComparator(comparators []RecordComparator) RecordComparator { return func(l, r Record) bool { for _, c := range comparators { if c(l, r) { return true } else if c(r, l) { return false } } return false } }
go
func AsRecordComparator(comparators []RecordComparator) RecordComparator { return func(l, r Record) bool { for _, c := range comparators { if c(l, r) { return true } else if c(r, l) { return false } } return false } }
[ "func", "AsRecordComparator", "(", "comparators", "[", "]", "RecordComparator", ")", "RecordComparator", "{", "return", "func", "(", "l", ",", "r", "Record", ")", "bool", "{", "for", "_", ",", "c", ":=", "range", "comparators", "{", "if", "c", "(", "l", ...
// Constructs a single RecordComparator from a slice of RecordComparators
[ "Constructs", "a", "single", "RecordComparator", "from", "a", "slice", "of", "RecordComparators" ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/comparator.go#L8-L20
150,914
wildducktheories/go-csv
join.go
fill
func (g *groupReader) fill() bool { if g.next == nil { g.next = <-g.reader.C() } if g.next == nil { return false } else { g.key = g.tokey(g.next) } g.group = []Record{g.next} for { g.next = <-g.reader.C() var k []string if g.next != nil { k = g.tokey(g.next) } if g.next == nil || g.less(k, g.key) || g.less(g.key, k) { return true } else { g.group = append(g.group, g.next) } } }
go
func (g *groupReader) fill() bool { if g.next == nil { g.next = <-g.reader.C() } if g.next == nil { return false } else { g.key = g.tokey(g.next) } g.group = []Record{g.next} for { g.next = <-g.reader.C() var k []string if g.next != nil { k = g.tokey(g.next) } if g.next == nil || g.less(k, g.key) || g.less(g.key, k) { return true } else { g.group = append(g.group, g.next) } } }
[ "func", "(", "g", "*", "groupReader", ")", "fill", "(", ")", "bool", "{", "if", "g", ".", "next", "==", "nil", "{", "g", ".", "next", "=", "<-", "g", ".", "reader", ".", "C", "(", ")", "\n", "}", "\n", "if", "g", ".", "next", "==", "nil", ...
// Fill up the group slice with the set of records in the underlying stream that have the same key
[ "Fill", "up", "the", "group", "slice", "with", "the", "set", "of", "records", "in", "the", "underlying", "stream", "that", "have", "the", "same", "key" ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/join.go#L29-L51
150,915
wildducktheories/go-csv
join.go
get
func (g *groupReader) get() []Record { if !g.hasNext() { panic("illegal state: get() called when hasNext() is false") } r := g.group g.group = nil return r }
go
func (g *groupReader) get() []Record { if !g.hasNext() { panic("illegal state: get() called when hasNext() is false") } r := g.group g.group = nil return r }
[ "func", "(", "g", "*", "groupReader", ")", "get", "(", ")", "[", "]", "Record", "{", "if", "!", "g", ".", "hasNext", "(", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "r", ":=", "g", ".", "group", "\n", "g", ".", "group", "=", ...
// Answers the next group of records from the stream.
[ "Answers", "the", "next", "group", "of", "records", "from", "the", "stream", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/join.go#L62-L69
150,916
wildducktheories/go-csv
join.go
less
func (p *Join) less() StringSliceComparator { return (&SortKeys{ Keys: p.LeftKeys, Numeric: p.Numeric, }).AsStringSliceComparator() }
go
func (p *Join) less() StringSliceComparator { return (&SortKeys{ Keys: p.LeftKeys, Numeric: p.Numeric, }).AsStringSliceComparator() }
[ "func", "(", "p", "*", "Join", ")", "less", "(", ")", "StringSliceComparator", "{", "return", "(", "&", "SortKeys", "{", "Keys", ":", "p", ".", "LeftKeys", ",", "Numeric", ":", "p", ".", "Numeric", ",", "}", ")", ".", "AsStringSliceComparator", "(", ...
// Construct a key comparison function for key values
[ "Construct", "a", "key", "comparison", "function", "for", "key", "values" ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/join.go#L72-L77
150,917
wildducktheories/go-csv
join.go
headers
func (p *Join) headers(leftHeader []string, rightHeader []string) ([]string, []string, []string, []string) { i, a, _ := utils.Intersect(leftHeader, p.LeftKeys) _, b, _ := utils.Intersect(rightHeader, p.RightKeys) f := make([]string, len(i)+len(a)+len(b)) copy(f, i) copy(f[len(i):], a) copy(f[len(i)+len(a):], b) return f, i, a, b }
go
func (p *Join) headers(leftHeader []string, rightHeader []string) ([]string, []string, []string, []string) { i, a, _ := utils.Intersect(leftHeader, p.LeftKeys) _, b, _ := utils.Intersect(rightHeader, p.RightKeys) f := make([]string, len(i)+len(a)+len(b)) copy(f, i) copy(f[len(i):], a) copy(f[len(i)+len(a):], b) return f, i, a, b }
[ "func", "(", "p", "*", "Join", ")", "headers", "(", "leftHeader", "[", "]", "string", ",", "rightHeader", "[", "]", "string", ")", "(", "[", "]", "string", ",", "[", "]", "string", ",", "[", "]", "string", ",", "[", "]", "string", ")", "{", "i"...
// split the headers into the set of all headers, the set of key headers, the set of left headers // and the set of right headers
[ "split", "the", "headers", "into", "the", "set", "of", "all", "headers", "the", "set", "of", "key", "headers", "the", "set", "of", "left", "headers", "and", "the", "set", "of", "right", "headers" ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/join.go#L81-L91
150,918
wildducktheories/go-csv
join.go
WithRight
func (p *Join) WithRight(r Reader) Process { return &joinProcess{ join: p, right: r, } }
go
func (p *Join) WithRight(r Reader) Process { return &joinProcess{ join: p, right: r, } }
[ "func", "(", "p", "*", "Join", ")", "WithRight", "(", "r", "Reader", ")", "Process", "{", "return", "&", "joinProcess", "{", "join", ":", "p", ",", "right", ":", "r", ",", "}", "\n", "}" ]
// Binds the specified reader as the right-hand side of a join and returns // a Process whose reader will be considered as the left-hand side of the join.
[ "Binds", "the", "specified", "reader", "as", "the", "right", "-", "hand", "side", "of", "a", "join", "and", "returns", "a", "Process", "whose", "reader", "will", "be", "considered", "as", "the", "left", "-", "hand", "side", "of", "the", "join", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/join.go#L201-L206
150,919
wildducktheories/go-csv
single-record.go
Parse
func Parse(record string) ([]string, error) { reader := csv.NewReader(strings.NewReader(record)) result, err := reader.Read() if err != nil { return nil, err } return result, nil }
go
func Parse(record string) ([]string, error) { reader := csv.NewReader(strings.NewReader(record)) result, err := reader.Read() if err != nil { return nil, err } return result, nil }
[ "func", "Parse", "(", "record", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "reader", ":=", "csv", ".", "NewReader", "(", "strings", ".", "NewReader", "(", "record", ")", ")", "\n", "result", ",", "err", ":=", "reader", ".", "Re...
//Parse a string representing one or more encoded CSV record and returns the first such record.
[ "Parse", "a", "string", "representing", "one", "or", "more", "encoded", "CSV", "record", "and", "returns", "the", "first", "such", "record", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/single-record.go#L10-L17
150,920
wildducktheories/go-csv
single-record.go
Format
func Format(record []string) string { buffer := bytes.NewBufferString("") writer := csv.NewWriter(buffer) writer.Write(record) writer.Flush() return strings.TrimRight(buffer.String(), "\n") }
go
func Format(record []string) string { buffer := bytes.NewBufferString("") writer := csv.NewWriter(buffer) writer.Write(record) writer.Flush() return strings.TrimRight(buffer.String(), "\n") }
[ "func", "Format", "(", "record", "[", "]", "string", ")", "string", "{", "buffer", ":=", "bytes", ".", "NewBufferString", "(", "\"", "\"", ")", "\n", "writer", ":=", "csv", ".", "NewWriter", "(", "buffer", ")", "\n", "writer", ".", "Write", "(", "rec...
//Format the specified slice as a CSV record using the default CSV encoding conventions.
[ "Format", "the", "specified", "slice", "as", "a", "CSV", "record", "using", "the", "default", "CSV", "encoding", "conventions", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/single-record.go#L20-L26
150,921
wildducktheories/go-csv
pipe.go
NewPipe
func NewPipe() Pipe { return &pipe{ ch: make(chan Record), err: nil, init: make(chan interface{}), } }
go
func NewPipe() Pipe { return &pipe{ ch: make(chan Record), err: nil, init: make(chan interface{}), } }
[ "func", "NewPipe", "(", ")", "Pipe", "{", "return", "&", "pipe", "{", "ch", ":", "make", "(", "chan", "Record", ")", ",", "err", ":", "nil", ",", "init", ":", "make", "(", "chan", "interface", "{", "}", ")", ",", "}", "\n", "}" ]
// Answer a new Pipe whose Builder and Reader can be used to connect two chained // processes.
[ "Answer", "a", "new", "Pipe", "whose", "Builder", "and", "Reader", "can", "be", "used", "to", "connect", "two", "chained", "processes", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/pipe.go#L23-L29
150,922
wildducktheories/go-csv
pipe.go
NewPipeLine
func NewPipeLine(p []Process) Process { if p == nil || len(p) == 0 { p = []Process{&CatProcess{}} } return &pipeline{ stages: p, } }
go
func NewPipeLine(p []Process) Process { if p == nil || len(p) == 0 { p = []Process{&CatProcess{}} } return &pipeline{ stages: p, } }
[ "func", "NewPipeLine", "(", "p", "[", "]", "Process", ")", "Process", "{", "if", "p", "==", "nil", "||", "len", "(", "p", ")", "==", "0", "{", "p", "=", "[", "]", "Process", "{", "&", "CatProcess", "{", "}", "}", "\n", "}", "\n", "return", "&...
// Join a sequence of processes by connecting them with pipes, returning a new process that // represents the entire pipeline.
[ "Join", "a", "sequence", "of", "processes", "by", "connecting", "them", "with", "pipes", "returning", "a", "new", "process", "that", "represents", "the", "entire", "pipeline", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/pipe.go#L91-L98
150,923
wildducktheories/go-csv
pipe.go
Run
func (p *pipeline) Run(r Reader, b WriterBuilder, errCh chan<- error) { errCh <- func() (err error) { errors := make(chan error, len(p.stages)) for _, c := range p.stages[:len(p.stages)-1] { p := NewPipe() go c.Run(r, p.Builder(), errors) r = p.Reader() } go p.stages[len(p.stages)-1].Run(r, b, errors) running := len(p.stages) for running > 0 { e := <-errors running-- if err == nil { err = e } } return err }() }
go
func (p *pipeline) Run(r Reader, b WriterBuilder, errCh chan<- error) { errCh <- func() (err error) { errors := make(chan error, len(p.stages)) for _, c := range p.stages[:len(p.stages)-1] { p := NewPipe() go c.Run(r, p.Builder(), errors) r = p.Reader() } go p.stages[len(p.stages)-1].Run(r, b, errors) running := len(p.stages) for running > 0 { e := <-errors running-- if err == nil { err = e } } return err }() }
[ "func", "(", "p", "*", "pipeline", ")", "Run", "(", "r", "Reader", ",", "b", "WriterBuilder", ",", "errCh", "chan", "<-", "error", ")", "{", "errCh", "<-", "func", "(", ")", "(", "err", "error", ")", "{", "errors", ":=", "make", "(", "chan", "err...
// Run the pipeline by connecting each stage with pipes and then running each stage // as a goroutine.
[ "Run", "the", "pipeline", "by", "connecting", "each", "stage", "with", "pipes", "and", "then", "running", "each", "stage", "as", "a", "goroutine", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/pipe.go#L102-L125
150,924
wildducktheories/go-csv
reader.go
ReadAll
func ReadAll(reader Reader) ([]Record, error) { all := make([]Record, 0, 1) for record := range reader.C() { all = append(all, record) } return all, reader.Error() }
go
func ReadAll(reader Reader) ([]Record, error) { all := make([]Record, 0, 1) for record := range reader.C() { all = append(all, record) } return all, reader.Error() }
[ "func", "ReadAll", "(", "reader", "Reader", ")", "(", "[", "]", "Record", ",", "error", ")", "{", "all", ":=", "make", "(", "[", "]", "Record", ",", "0", ",", "1", ")", "\n", "for", "record", ":=", "range", "reader", ".", "C", "(", ")", "{", ...
// ReadAll reads all the records from the specified reader and only returns a non-nil error // if an error, other than EOF, occurs during the reading process.
[ "ReadAll", "reads", "all", "the", "records", "from", "the", "specified", "reader", "and", "only", "returns", "a", "non", "-", "nil", "error", "if", "an", "error", "other", "than", "EOF", "occurs", "during", "the", "reading", "process", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/reader.go#L31-L37
150,925
wildducktheories/go-csv
reader.go
WithIoReader
func WithIoReader(io io.ReadCloser) Reader { csvReader := csv.NewReader(io) csvReader.FieldsPerRecord = -1 return WithCsvReader(csvReader, io) }
go
func WithIoReader(io io.ReadCloser) Reader { csvReader := csv.NewReader(io) csvReader.FieldsPerRecord = -1 return WithCsvReader(csvReader, io) }
[ "func", "WithIoReader", "(", "io", "io", ".", "ReadCloser", ")", "Reader", "{", "csvReader", ":=", "csv", ".", "NewReader", "(", "io", ")", "\n", "csvReader", ".", "FieldsPerRecord", "=", "-", "1", "\n", "return", "WithCsvReader", "(", "csvReader", ",", ...
// WithIoReader creates a csv Reader from the specified io Reader.
[ "WithIoReader", "creates", "a", "csv", "Reader", "from", "the", "specified", "io", "Reader", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/reader.go#L40-L44
150,926
wildducktheories/go-csv
reader.go
WithProcess
func WithProcess(r Reader, p Process) Reader { pipe := NewPipe() go p.Run(r, pipe.Builder(), make(chan error, 1)) return pipe.Reader() }
go
func WithProcess(r Reader, p Process) Reader { pipe := NewPipe() go p.Run(r, pipe.Builder(), make(chan error, 1)) return pipe.Reader() }
[ "func", "WithProcess", "(", "r", "Reader", ",", "p", "Process", ")", "Reader", "{", "pipe", ":=", "NewPipe", "(", ")", "\n", "go", "p", ".", "Run", "(", "r", ",", "pipe", ".", "Builder", "(", ")", ",", "make", "(", "chan", "error", ",", "1", ")...
// Given a reader and a process, answer a new reader which is the result of // applying the specified process to the specified reader.
[ "Given", "a", "reader", "and", "a", "process", "answer", "a", "new", "reader", "which", "is", "the", "result", "of", "applying", "the", "specified", "process", "to", "the", "specified", "reader", "." ]
a843eda7bf0911b9acdfd11a9a41ed87282dcbdd
https://github.com/wildducktheories/go-csv/blob/a843eda7bf0911b9acdfd11a9a41ed87282dcbdd/reader.go#L113-L117
150,927
bjwbell/gensimd
simd/parse.go
ParseFile
func ParseFile(f string) (*File, error) { fs := token.NewFileSet() if !strings.HasSuffix(f, ".go") { return nil, errors.New("Invalid file, file suffix not .go") } parsed, err := parser.ParseFile(fs, f, nil, parser.ParseComments) if err != nil { //log.Fatalf("parsing file: %s: %s", f, err) return nil, errors.New(fmt.Sprintf("go/parser.ParseFile error \"%v\"", err)) } file := File{ast: parsed, pathName: f, fs: fs} file.Check() return &file, nil }
go
func ParseFile(f string) (*File, error) { fs := token.NewFileSet() if !strings.HasSuffix(f, ".go") { return nil, errors.New("Invalid file, file suffix not .go") } parsed, err := parser.ParseFile(fs, f, nil, parser.ParseComments) if err != nil { //log.Fatalf("parsing file: %s: %s", f, err) return nil, errors.New(fmt.Sprintf("go/parser.ParseFile error \"%v\"", err)) } file := File{ast: parsed, pathName: f, fs: fs} file.Check() return &file, nil }
[ "func", "ParseFile", "(", "f", "string", ")", "(", "*", "File", ",", "error", ")", "{", "fs", ":=", "token", ".", "NewFileSet", "(", ")", "\n", "if", "!", "strings", ".", "HasSuffix", "(", "f", ",", "\"", "\"", ")", "{", "return", "nil", ",", "...
// ParseFile analyzes the single file passed in.
[ "ParseFile", "analyzes", "the", "single", "file", "passed", "in", "." ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/simd/parse.go#L47-L60
150,928
bjwbell/gensimd
simd/simd_common.go
SubI8x16
func SubI8x16(x, y I8x16) I8x16 { val := I8x16{} for i := 0; i < 16; i++ { val[i] = x[i] - y[i] } return val }
go
func SubI8x16(x, y I8x16) I8x16 { val := I8x16{} for i := 0; i < 16; i++ { val[i] = x[i] - y[i] } return val }
[ "func", "SubI8x16", "(", "x", ",", "y", "I8x16", ")", "I8x16", "{", "val", ":=", "I8x16", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "16", ";", "i", "++", "{", "val", "[", "i", "]", "=", "x", "[", "i", "]", "-", "y", "[", "i"...
// SubI8x16 subtracts y from x
[ "SubI8x16", "subtracts", "y", "from", "x" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/simd/simd_common.go#L15-L21
150,929
bjwbell/gensimd
simd/simd_common.go
SubI16x8
func SubI16x8(x, y I16x8) I16x8 { val := I16x8{} for i := 0; i < 8; i++ { val[i] = x[i] - y[i] } return val }
go
func SubI16x8(x, y I16x8) I16x8 { val := I16x8{} for i := 0; i < 8; i++ { val[i] = x[i] - y[i] } return val }
[ "func", "SubI16x8", "(", "x", ",", "y", "I16x8", ")", "I16x8", "{", "val", ":=", "I16x8", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "8", ";", "i", "++", "{", "val", "[", "i", "]", "=", "x", "[", "i", "]", "-", "y", "[", "i",...
// SubI16x8 subtracts y from x
[ "SubI16x8", "subtracts", "y", "from", "x" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/simd/simd_common.go#L32-L38
150,930
bjwbell/gensimd
simd/simd_common.go
SubI32x4
func SubI32x4(x, y I32x4) I32x4 { val := I32x4{} for i := 0; i < 4; i++ { val[i] = x[i] - y[i] } return val }
go
func SubI32x4(x, y I32x4) I32x4 { val := I32x4{} for i := 0; i < 4; i++ { val[i] = x[i] - y[i] } return val }
[ "func", "SubI32x4", "(", "x", ",", "y", "I32x4", ")", "I32x4", "{", "val", ":=", "I32x4", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "4", ";", "i", "++", "{", "val", "[", "i", "]", "=", "x", "[", "i", "]", "-", "y", "[", "i",...
// SubI32x4 subtracts y from x
[ "SubI32x4", "subtracts", "y", "from", "x" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/simd/simd_common.go#L70-L76
150,931
bjwbell/gensimd
simd/simd_common.go
SubI64x2
func SubI64x2(x, y I64x2) I64x2 { val := I64x2{} for i := 0; i < 2; i++ { val[i] = x[i] - y[i] } return val }
go
func SubI64x2(x, y I64x2) I64x2 { val := I64x2{} for i := 0; i < 2; i++ { val[i] = x[i] - y[i] } return val }
[ "func", "SubI64x2", "(", "x", ",", "y", "I64x2", ")", "I64x2", "{", "val", ":=", "I64x2", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "2", ";", "i", "++", "{", "val", "[", "i", "]", "=", "x", "[", "i", "]", "-", "y", "[", "i",...
// SubI64x2 subtracts y from x
[ "SubI64x2", "subtracts", "y", "from", "x" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/simd/simd_common.go#L124-L130
150,932
bjwbell/gensimd
simd/simd_common.go
SubU8x16
func SubU8x16(x, y U8x16) U8x16 { val := U8x16{} for i := 0; i < 16; i++ { val[i] = x[i] - y[i] } return val }
go
func SubU8x16(x, y U8x16) U8x16 { val := U8x16{} for i := 0; i < 16; i++ { val[i] = x[i] - y[i] } return val }
[ "func", "SubU8x16", "(", "x", ",", "y", "U8x16", ")", "U8x16", "{", "val", ":=", "U8x16", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "16", ";", "i", "++", "{", "val", "[", "i", "]", "=", "x", "[", "i", "]", "-", "y", "[", "i"...
// SubU8x16 subtracts y from x
[ "SubU8x16", "subtracts", "y", "from", "x" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/simd/simd_common.go#L148-L154
150,933
bjwbell/gensimd
simd/simd_common.go
SubU16x8
func SubU16x8(x, y U16x8) U16x8 { val := U16x8{} for i := 0; i < 8; i++ { val[i] = x[i] - y[i] } return val }
go
func SubU16x8(x, y U16x8) U16x8 { val := U16x8{} for i := 0; i < 8; i++ { val[i] = x[i] - y[i] } return val }
[ "func", "SubU16x8", "(", "x", ",", "y", "U16x8", ")", "U16x8", "{", "val", ":=", "U16x8", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "8", ";", "i", "++", "{", "val", "[", "i", "]", "=", "x", "[", "i", "]", "-", "y", "[", "i",...
// SubU16x8 subtracts y from x
[ "SubU16x8", "subtracts", "y", "from", "x" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/simd/simd_common.go#L165-L171
150,934
bjwbell/gensimd
simd/simd_common.go
SubU32x4
func SubU32x4(x, y U32x4) U32x4 { val := U32x4{} for i := 0; i < 4; i++ { val[i] = x[i] - y[i] } return val }
go
func SubU32x4(x, y U32x4) U32x4 { val := U32x4{} for i := 0; i < 4; i++ { val[i] = x[i] - y[i] } return val }
[ "func", "SubU32x4", "(", "x", ",", "y", "U32x4", ")", "U32x4", "{", "val", ":=", "U32x4", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "4", ";", "i", "++", "{", "val", "[", "i", "]", "=", "x", "[", "i", "]", "-", "y", "[", "i",...
// SubU32x4 subtracts y from x
[ "SubU32x4", "subtracts", "y", "from", "x" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/simd/simd_common.go#L203-L209
150,935
bjwbell/gensimd
simd/simd_common.go
SubU64x2
func SubU64x2(x, y U64x2) U64x2 { val := U64x2{} for i := 0; i < 2; i++ { val[i] = x[i] - y[i] } return val }
go
func SubU64x2(x, y U64x2) U64x2 { val := U64x2{} for i := 0; i < 2; i++ { val[i] = x[i] - y[i] } return val }
[ "func", "SubU64x2", "(", "x", ",", "y", "U64x2", ")", "U64x2", "{", "val", ":=", "U64x2", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "2", ";", "i", "++", "{", "val", "[", "i", "]", "=", "x", "[", "i", "]", "-", "y", "[", "i",...
// SubU64x2 subtracts y from x
[ "SubU64x2", "subtracts", "y", "from", "x" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/simd/simd_common.go#L258-L264
150,936
bjwbell/gensimd
simd/simd_common.go
SubF32x4
func SubF32x4(x, y F32x4) F32x4 { val := F32x4{} for i := 0; i < 4; i++ { val[i] = x[i] - y[i] } return val }
go
func SubF32x4(x, y F32x4) F32x4 { val := F32x4{} for i := 0; i < 4; i++ { val[i] = x[i] - y[i] } return val }
[ "func", "SubF32x4", "(", "x", ",", "y", "F32x4", ")", "F32x4", "{", "val", ":=", "F32x4", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "4", ";", "i", "++", "{", "val", "[", "i", "]", "=", "x", "[", "i", "]", "-", "y", "[", "i",...
// SubF32x4 subtracts y from x
[ "SubF32x4", "subtracts", "y", "from", "x" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/simd/simd_common.go#L289-L295
150,937
bjwbell/gensimd
simd/simd_common.go
SubF64x2
func SubF64x2(x, y F64x2) F64x2 { val := F64x2{} for i := 0; i < 2; i++ { val[i] = x[i] - y[i] } return val }
go
func SubF64x2(x, y F64x2) F64x2 { val := F64x2{} for i := 0; i < 2; i++ { val[i] = x[i] - y[i] } return val }
[ "func", "SubF64x2", "(", "x", ",", "y", "F64x2", ")", "F64x2", "{", "val", ":=", "F64x2", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "2", ";", "i", "++", "{", "val", "[", "i", "]", "=", "x", "[", "i", "]", "-", "y", "[", "i",...
// SubF64x2 subtracts y from x
[ "SubF64x2", "subtracts", "y", "from", "x" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/simd/simd_common.go#L320-L326
150,938
bjwbell/gensimd
codegen/instramd64.go
GetInstr
func GetInstr(tinst InstructionType, datatype OpDataType) Instruction { if datatype.op == OP_XMM || datatype.op == OP_PACKED { return GetXmmInstruction(tinst).Select(datatype.xmmvariant) } else { return GetInstruction(tinst).GetSized(datatype.size) } }
go
func GetInstr(tinst InstructionType, datatype OpDataType) Instruction { if datatype.op == OP_XMM || datatype.op == OP_PACKED { return GetXmmInstruction(tinst).Select(datatype.xmmvariant) } else { return GetInstruction(tinst).GetSized(datatype.size) } }
[ "func", "GetInstr", "(", "tinst", "InstructionType", ",", "datatype", "OpDataType", ")", "Instruction", "{", "if", "datatype", ".", "op", "==", "OP_XMM", "||", "datatype", ".", "op", "==", "OP_PACKED", "{", "return", "GetXmmInstruction", "(", "tinst", ")", "...
// GetInstr, the size is in bytes
[ "GetInstr", "the", "size", "is", "in", "bytes" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/instramd64.go#L370-L376
150,939
bjwbell/gensimd
codegen/instramd64.go
instrImmUnsignedReg
func instrImmUnsignedReg(ctx context, instr Instruction, imm64 uint64, size uint, r *register, spill bool) string { if r.width < 8*size { ice("Invalid register width") } var asm string info, ok := instrTable[instr] if !ok { ice(fmt.Sprintf("couldn't look up instruction (%v) information", instr)) } flags := info.Flags if (flags&RightRdwr != 0) || (flags&RightWrite != 0) { asm += r.modified(ctx, spill) } asm += fmt.Sprintf("%-9v $%v, %v\n", instr, imm64, r.name) return asm }
go
func instrImmUnsignedReg(ctx context, instr Instruction, imm64 uint64, size uint, r *register, spill bool) string { if r.width < 8*size { ice("Invalid register width") } var asm string info, ok := instrTable[instr] if !ok { ice(fmt.Sprintf("couldn't look up instruction (%v) information", instr)) } flags := info.Flags if (flags&RightRdwr != 0) || (flags&RightWrite != 0) { asm += r.modified(ctx, spill) } asm += fmt.Sprintf("%-9v $%v, %v\n", instr, imm64, r.name) return asm }
[ "func", "instrImmUnsignedReg", "(", "ctx", "context", ",", "instr", "Instruction", ",", "imm64", "uint64", ",", "size", "uint", ",", "r", "*", "register", ",", "spill", "bool", ")", "string", "{", "if", "r", ".", "width", "<", "8", "*", "size", "{", ...
// instrImmUnsignedReg outputs instr with imm64, reg
[ "instrImmUnsignedReg", "outputs", "instr", "with", "imm64", "reg" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/instramd64.go#L508-L523
150,940
bjwbell/gensimd
codegen/instramd64.go
ZeroReg
func ZeroReg(ctx context, reg *register) string { var dt OpDataType if reg.typ == XMM_REG { dt = OpDataType{OP_XMM, InstrData{}, XMM_2X_F64} } else { dt = OpDataType{OP_DATA, InstrData{signed: false, size: reg.width / 8}, XMM_INVALID} } return instrRegReg(ctx, GetInstr(I_XOR, dt), reg, reg, false) }
go
func ZeroReg(ctx context, reg *register) string { var dt OpDataType if reg.typ == XMM_REG { dt = OpDataType{OP_XMM, InstrData{}, XMM_2X_F64} } else { dt = OpDataType{OP_DATA, InstrData{signed: false, size: reg.width / 8}, XMM_INVALID} } return instrRegReg(ctx, GetInstr(I_XOR, dt), reg, reg, false) }
[ "func", "ZeroReg", "(", "ctx", "context", ",", "reg", "*", "register", ")", "string", "{", "var", "dt", "OpDataType", "\n", "if", "reg", ".", "typ", "==", "XMM_REG", "{", "dt", "=", "OpDataType", "{", "OP_XMM", ",", "InstrData", "{", "}", ",", "XMM_2...
// ZeroReg generates "XORQ reg, reg" instructions
[ "ZeroReg", "generates", "XORQ", "reg", "reg", "instructions" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/instramd64.go#L598-L607
150,941
bjwbell/gensimd
codegen/instramd64.go
MulRegReg
func MulRegReg(ctx context, datatype OpDataType, src, dst *register, spill bool) string { if dst.width != src.width { ice("Invalid register width") } asm := "" if datatype.op == OP_DATA { rax := getRegister(REG_AX) rdx := getRegister(REG_DX) if rax.width != 64 || rdx.width != 64 { ice("Invalid rax or rdx register width") } // rax is the implicit destination for MULQ asm = MovRegReg(ctx, datatype, dst, rax, false) // the low order part of the result is stored in rax and the high order part // is stored in rdx var tinstr InstructionType if datatype.signed { tinstr = I_IMUL } else { tinstr = I_MUL } mul := GetInstr(tinstr, datatype) asm += instrReg(ctx, mul, src, false) asm += MovRegReg(ctx, datatype, rax, dst, spill) return asm } if datatype.op == OP_XMM { asm += instrRegReg(ctx, GetInstr(I_MUL, datatype), src, dst, spill) } return asm }
go
func MulRegReg(ctx context, datatype OpDataType, src, dst *register, spill bool) string { if dst.width != src.width { ice("Invalid register width") } asm := "" if datatype.op == OP_DATA { rax := getRegister(REG_AX) rdx := getRegister(REG_DX) if rax.width != 64 || rdx.width != 64 { ice("Invalid rax or rdx register width") } // rax is the implicit destination for MULQ asm = MovRegReg(ctx, datatype, dst, rax, false) // the low order part of the result is stored in rax and the high order part // is stored in rdx var tinstr InstructionType if datatype.signed { tinstr = I_IMUL } else { tinstr = I_MUL } mul := GetInstr(tinstr, datatype) asm += instrReg(ctx, mul, src, false) asm += MovRegReg(ctx, datatype, rax, dst, spill) return asm } if datatype.op == OP_XMM { asm += instrRegReg(ctx, GetInstr(I_MUL, datatype), src, dst, spill) } return asm }
[ "func", "MulRegReg", "(", "ctx", "context", ",", "datatype", "OpDataType", ",", "src", ",", "dst", "*", "register", ",", "spill", "bool", ")", "string", "{", "if", "dst", ".", "width", "!=", "src", ".", "width", "{", "ice", "(", "\"", "\"", ")", "\...
// MulRegReg multiplies the src register by the dst register and stores // the result in the dst register. Overflow is discarded
[ "MulRegReg", "multiplies", "the", "src", "register", "by", "the", "dst", "register", "and", "stores", "the", "result", "in", "the", "dst", "register", ".", "Overflow", "is", "discarded" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/instramd64.go#L915-L945
150,942
bjwbell/gensimd
codegen/instramd64.go
DivRegReg
func DivRegReg(ctx context, signed bool, datatype InstrOpType, dividend, divisor *register, size uint) (asm string, rax *register, rdx *register) { if dividend.width != divisor.width || divisor.width < size*8 { ice("Invalid register width for DivRegReg") } if datatype != OP_DATA { ice("Unsupported arithmetic data type") } rax = getRegister(REG_AX) if size > 1 { rdx = getRegister(REG_DX) } if rax.width != 64 || (size > 1 && rdx.width != 64) { ice("Invalid rax or rdx register width") } // rdx:rax are the upper and lower parts of the dividend respectively, // and rdx:rax are the implicit destination of DIVQ asm = "" asm += ZeroReg(ctx, rax) if size > 1 { asm += ZeroReg(ctx, rdx) } dt := OpDataType{datatype, InstrData{signed: signed, size: size}, XMM_INVALID} asm += MovRegReg(ctx, dt, dividend, rax, false) // the low order part of the result is stored in rax and the high order part // is stored in rdx var tinstr InstructionType if signed { tinstr = I_IDIV } else { tinstr = I_DIV } asm += instrReg(ctx, GetInstr(tinstr, dt), divisor, false) return asm, rax, rdx }
go
func DivRegReg(ctx context, signed bool, datatype InstrOpType, dividend, divisor *register, size uint) (asm string, rax *register, rdx *register) { if dividend.width != divisor.width || divisor.width < size*8 { ice("Invalid register width for DivRegReg") } if datatype != OP_DATA { ice("Unsupported arithmetic data type") } rax = getRegister(REG_AX) if size > 1 { rdx = getRegister(REG_DX) } if rax.width != 64 || (size > 1 && rdx.width != 64) { ice("Invalid rax or rdx register width") } // rdx:rax are the upper and lower parts of the dividend respectively, // and rdx:rax are the implicit destination of DIVQ asm = "" asm += ZeroReg(ctx, rax) if size > 1 { asm += ZeroReg(ctx, rdx) } dt := OpDataType{datatype, InstrData{signed: signed, size: size}, XMM_INVALID} asm += MovRegReg(ctx, dt, dividend, rax, false) // the low order part of the result is stored in rax and the high order part // is stored in rdx var tinstr InstructionType if signed { tinstr = I_IDIV } else { tinstr = I_DIV } asm += instrReg(ctx, GetInstr(tinstr, dt), divisor, false) return asm, rax, rdx }
[ "func", "DivRegReg", "(", "ctx", "context", ",", "signed", "bool", ",", "datatype", "InstrOpType", ",", "dividend", ",", "divisor", "*", "register", ",", "size", "uint", ")", "(", "asm", "string", ",", "rax", "*", "register", ",", "rdx", "*", "register",...
// DivRegReg divides the "dividend" register by the "divisor" register and stores // the quotient in rax and the remainder in rdx. DivRegReg is only for integer division.
[ "DivRegReg", "divides", "the", "dividend", "register", "by", "the", "divisor", "register", "and", "stores", "the", "quotient", "in", "rax", "and", "the", "remainder", "in", "rdx", ".", "DivRegReg", "is", "only", "for", "integer", "division", "." ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/instramd64.go#L949-L985
150,943
bjwbell/gensimd
codegen/instramd64.go
DivFloatRegReg
func DivFloatRegReg(ctx context, datatype OpDataType, dividend, divisor *register, spill bool) string { if dividend.width != divisor.width { ice("Invalid register width") } if datatype.op != OP_XMM { ice("Unsupported data type for floating point division") } return instrRegReg(ctx, GetInstr(I_DIV, datatype), divisor, dividend, true) }
go
func DivFloatRegReg(ctx context, datatype OpDataType, dividend, divisor *register, spill bool) string { if dividend.width != divisor.width { ice("Invalid register width") } if datatype.op != OP_XMM { ice("Unsupported data type for floating point division") } return instrRegReg(ctx, GetInstr(I_DIV, datatype), divisor, dividend, true) }
[ "func", "DivFloatRegReg", "(", "ctx", "context", ",", "datatype", "OpDataType", ",", "dividend", ",", "divisor", "*", "register", ",", "spill", "bool", ")", "string", "{", "if", "dividend", ".", "width", "!=", "divisor", ".", "width", "{", "ice", "(", "\...
// DivFloatRegReg performs floating point division by dividing the dividend register // by the divisor register and stores the quotient in the dividend register
[ "DivFloatRegReg", "performs", "floating", "point", "division", "by", "dividing", "the", "dividend", "register", "by", "the", "divisor", "register", "and", "stores", "the", "quotient", "in", "the", "dividend", "register" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/instramd64.go#L989-L997
150,944
bjwbell/gensimd
codegen/instramd64.go
AndRegReg
func AndRegReg(ctx context, src, dst *register, size uint, spill bool) string { if src.width != dst.width { ice("Invalid register width") } dt := OpDataType{OP_DATA, InstrData{signed: false, size: size}, XMM_INVALID} and := GetInstr(I_AND, dt) return instrRegReg(ctx, and, src, dst, spill) }
go
func AndRegReg(ctx context, src, dst *register, size uint, spill bool) string { if src.width != dst.width { ice("Invalid register width") } dt := OpDataType{OP_DATA, InstrData{signed: false, size: size}, XMM_INVALID} and := GetInstr(I_AND, dt) return instrRegReg(ctx, and, src, dst, spill) }
[ "func", "AndRegReg", "(", "ctx", "context", ",", "src", ",", "dst", "*", "register", ",", "size", "uint", ",", "spill", "bool", ")", "string", "{", "if", "src", ".", "width", "!=", "dst", ".", "width", "{", "ice", "(", "\"", "\"", ")", "\n", "}",...
// AndRegReg AND's the src register by the dst register and stores // the result in the dst register.
[ "AndRegReg", "AND", "s", "the", "src", "register", "by", "the", "dst", "register", "and", "stores", "the", "result", "in", "the", "dst", "register", "." ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/instramd64.go#L1040-L1047
150,945
bjwbell/gensimd
codegen/codegen.go
zeroReg
func (f *Function) zeroReg(r *register) string { ctx := context{f, nil} return ZeroReg(ctx, r) }
go
func (f *Function) zeroReg(r *register) string { ctx := context{f, nil} return ZeroReg(ctx, r) }
[ "func", "(", "f", "*", "Function", ")", "zeroReg", "(", "r", "*", "register", ")", "string", "{", "ctx", ":=", "context", "{", "f", ",", "nil", "}", "\n", "return", "ZeroReg", "(", "ctx", ",", "r", ")", "\n", "}" ]
// zeroReg returns the assembly for zeroing the passed in register
[ "zeroReg", "returns", "the", "assembly", "for", "zeroing", "the", "passed", "in", "register" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/codegen.go#L1820-L1823
150,946
bjwbell/gensimd
codegen/codegen.go
paramsSize
func (f *Function) paramsSize() uint { size := uint(0) for _, p := range f.ssa.Params { size += sizeof(p.Type()) } return size }
go
func (f *Function) paramsSize() uint { size := uint(0) for _, p := range f.ssa.Params { size += sizeof(p.Type()) } return size }
[ "func", "(", "f", "*", "Function", ")", "paramsSize", "(", ")", "uint", "{", "size", ":=", "uint", "(", "0", ")", "\n", "for", "_", ",", "p", ":=", "range", "f", ".", "ssa", ".", "Params", "{", "size", "+=", "sizeof", "(", "p", ".", "Type", "...
// paramsSize returns the size of the parameters in bytes
[ "paramsSize", "returns", "the", "size", "of", "the", "parameters", "in", "bytes" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/codegen.go#L1830-L1836
150,947
bjwbell/gensimd
codegen/codegen.go
retType
func (f *Function) retType() types.Type { results := f.ssa.Signature.Results() if results.Len() == 0 { return nil } if results.Len() > 1 { panic("Functions with more than one return value not supported") } return results.At(0).Type() }
go
func (f *Function) retType() types.Type { results := f.ssa.Signature.Results() if results.Len() == 0 { return nil } if results.Len() > 1 { panic("Functions with more than one return value not supported") } return results.At(0).Type() }
[ "func", "(", "f", "*", "Function", ")", "retType", "(", ")", "types", ".", "Type", "{", "results", ":=", "f", ".", "ssa", ".", "Signature", ".", "Results", "(", ")", "\n", "if", "results", ".", "Len", "(", ")", "==", "0", "{", "return", "nil", ...
// retType gives the return type
[ "retType", "gives", "the", "return", "type" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/codegen.go#L1843-L1852
150,948
bjwbell/gensimd
codegen/codegen.go
retOffset
func (f *Function) retOffset() int { align := f.retAlign() // TODO: FIX // HACK!!! if isSimd(f.retType()) || isSSE2(f.retType()) { align = 8 } padding := align - f.paramsSize()%align if padding == align { padding = 0 } return int(f.paramsSize() + padding) }
go
func (f *Function) retOffset() int { align := f.retAlign() // TODO: FIX // HACK!!! if isSimd(f.retType()) || isSSE2(f.retType()) { align = 8 } padding := align - f.paramsSize()%align if padding == align { padding = 0 } return int(f.paramsSize() + padding) }
[ "func", "(", "f", "*", "Function", ")", "retOffset", "(", ")", "int", "{", "align", ":=", "f", ".", "retAlign", "(", ")", "\n", "// TODO: FIX", "// HACK!!!", "if", "isSimd", "(", "f", ".", "retType", "(", ")", ")", "||", "isSSE2", "(", "f", ".", ...
// retOffset returns the offset of the return value in bytes
[ "retOffset", "returns", "the", "offset", "of", "the", "return", "value", "in", "bytes" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/codegen.go#L1861-L1873
150,949
bjwbell/gensimd
codegen/codegen.go
retAlign
func (f *Function) retAlign() uint { align := align(f.retType()) // TODO: fix, why always 8 bytes with go compiler? if align < 8 { align = 8 } return align }
go
func (f *Function) retAlign() uint { align := align(f.retType()) // TODO: fix, why always 8 bytes with go compiler? if align < 8 { align = 8 } return align }
[ "func", "(", "f", "*", "Function", ")", "retAlign", "(", ")", "uint", "{", "align", ":=", "align", "(", "f", ".", "retType", "(", ")", ")", "\n", "// TODO: fix, why always 8 bytes with go compiler?", "if", "align", "<", "8", "{", "align", "=", "8", "\n",...
// retAlign returns the byte alignment alignment for the return value
[ "retAlign", "returns", "the", "byte", "alignment", "alignment", "for", "the", "return", "value" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/codegen.go#L1876-L1883
150,950
bjwbell/gensimd
codegen/storage.go
check
func (a *aliaser) check() { for i := range a.aliases { for j := range a.aliases { if i == j { continue } a1 := a.aliases[i] a2 := a.aliases[j] if a1.dst == a2.dst { ice("duplicate aliases") } if a1.overlap(a2.region).size != 0 { ice("overlapping aliases") } } } }
go
func (a *aliaser) check() { for i := range a.aliases { for j := range a.aliases { if i == j { continue } a1 := a.aliases[i] a2 := a.aliases[j] if a1.dst == a2.dst { ice("duplicate aliases") } if a1.overlap(a2.region).size != 0 { ice("overlapping aliases") } } } }
[ "func", "(", "a", "*", "aliaser", ")", "check", "(", ")", "{", "for", "i", ":=", "range", "a", ".", "aliases", "{", "for", "j", ":=", "range", "a", ".", "aliases", "{", "if", "i", "==", "j", "{", "continue", "\n", "}", "\n", "a1", ":=", "a", ...
// check looks for duplicate aliases and panics if any are found
[ "check", "looks", "for", "duplicate", "aliases", "and", "panics", "if", "any", "are", "found" ]
06eb18285485c0d572cc7f024050fc6cb652ed4c
https://github.com/bjwbell/gensimd/blob/06eb18285485c0d572cc7f024050fc6cb652ed4c/codegen/storage.go#L66-L82
150,951
grokify/go-ringcentral
clientutil/glip.go
AtMentionedOrGroupOfTwo
func (apiUtil *GlipApiUtil) AtMentionedOrGroupOfTwo(userId, groupId string, mentions []rc.GlipMentionsInfo) (bool, error) { if IsAtMentioned(userId, mentions) { return true, nil } count, err := apiUtil.GlipGroupMemberCount(groupId) if err != nil { return false, err } if count == int64(2) { return true, nil } return false, nil }
go
func (apiUtil *GlipApiUtil) AtMentionedOrGroupOfTwo(userId, groupId string, mentions []rc.GlipMentionsInfo) (bool, error) { if IsAtMentioned(userId, mentions) { return true, nil } count, err := apiUtil.GlipGroupMemberCount(groupId) if err != nil { return false, err } if count == int64(2) { return true, nil } return false, nil }
[ "func", "(", "apiUtil", "*", "GlipApiUtil", ")", "AtMentionedOrGroupOfTwo", "(", "userId", ",", "groupId", "string", ",", "mentions", "[", "]", "rc", ".", "GlipMentionsInfo", ")", "(", "bool", ",", "error", ")", "{", "if", "IsAtMentioned", "(", "userId", "...
// DirectMessage means a group of 2 or a team of 2
[ "DirectMessage", "means", "a", "group", "of", "2", "or", "a", "team", "of", "2" ]
ed99006e85f1098a4da6a08c03a4b2455ebf9e11
https://github.com/grokify/go-ringcentral/blob/ed99006e85f1098a4da6a08c03a4b2455ebf9e11/clientutil/glip.go#L87-L100
150,952
layeh/gumble
gumble/version.go
SemanticVersion
func (v *Version) SemanticVersion() (major uint16, minor, patch uint8) { major = uint16(v.Version>>16) & 0xFFFF minor = uint8(v.Version>>8) & 0xFF patch = uint8(v.Version) & 0xFF return }
go
func (v *Version) SemanticVersion() (major uint16, minor, patch uint8) { major = uint16(v.Version>>16) & 0xFFFF minor = uint8(v.Version>>8) & 0xFF patch = uint8(v.Version) & 0xFF return }
[ "func", "(", "v", "*", "Version", ")", "SemanticVersion", "(", ")", "(", "major", "uint16", ",", "minor", ",", "patch", "uint8", ")", "{", "major", "=", "uint16", "(", "v", ".", "Version", ">>", "16", ")", "&", "0xFFFF", "\n", "minor", "=", "uint8"...
// SemanticVersion returns the version's semantic version components.
[ "SemanticVersion", "returns", "the", "version", "s", "semantic", "version", "components", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/version.go#L19-L24
150,953
layeh/gumble
gumble/listeners.go
Attach
func (e *Listeners) Attach(listener EventListener) Detacher { item := &eventItem{ parent: e, prev: e.tail, listener: listener, } if e.head == nil { e.head = item } if e.tail != nil { e.tail.next = item } e.tail = item return item }
go
func (e *Listeners) Attach(listener EventListener) Detacher { item := &eventItem{ parent: e, prev: e.tail, listener: listener, } if e.head == nil { e.head = item } if e.tail != nil { e.tail.next = item } e.tail = item return item }
[ "func", "(", "e", "*", "Listeners", ")", "Attach", "(", "listener", "EventListener", ")", "Detacher", "{", "item", ":=", "&", "eventItem", "{", "parent", ":", "e", ",", "prev", ":", "e", ".", "tail", ",", "listener", ":", "listener", ",", "}", "\n", ...
// Attach adds a new event listener to the end of the current list of listeners.
[ "Attach", "adds", "a", "new", "event", "listener", "to", "the", "end", "of", "the", "current", "list", "of", "listeners", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/listeners.go#L29-L43
150,954
layeh/gumble
gumble/channel.go
Add
func (c *Channel) Add(name string, temporary bool) { packet := MumbleProto.ChannelState{ Parent: &c.ID, Name: &name, Temporary: &temporary, } c.client.Conn.WriteProto(&packet) }
go
func (c *Channel) Add(name string, temporary bool) { packet := MumbleProto.ChannelState{ Parent: &c.ID, Name: &name, Temporary: &temporary, } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "Channel", ")", "Add", "(", "name", "string", ",", "temporary", "bool", ")", "{", "packet", ":=", "MumbleProto", ".", "ChannelState", "{", "Parent", ":", "&", "c", ".", "ID", ",", "Name", ":", "&", "name", ",", "Temporary", "...
// Add will add a sub-channel to the given channel.
[ "Add", "will", "add", "a", "sub", "-", "channel", "to", "the", "given", "channel", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/channel.go#L46-L53
150,955
layeh/gumble
gumble/channel.go
Remove
func (c *Channel) Remove() { packet := MumbleProto.ChannelRemove{ ChannelId: &c.ID, } c.client.Conn.WriteProto(&packet) }
go
func (c *Channel) Remove() { packet := MumbleProto.ChannelRemove{ ChannelId: &c.ID, } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "Channel", ")", "Remove", "(", ")", "{", "packet", ":=", "MumbleProto", ".", "ChannelRemove", "{", "ChannelId", ":", "&", "c", ".", "ID", ",", "}", "\n", "c", ".", "client", ".", "Conn", ".", "WriteProto", "(", "&", "packet",...
// Remove will remove the given channel and all sub-channels from the server's // channel tree.
[ "Remove", "will", "remove", "the", "given", "channel", "and", "all", "sub", "-", "channels", "from", "the", "server", "s", "channel", "tree", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/channel.go#L57-L62
150,956
layeh/gumble
gumble/channel.go
SetName
func (c *Channel) SetName(name string) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, Name: &name, } c.client.Conn.WriteProto(&packet) }
go
func (c *Channel) SetName(name string) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, Name: &name, } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "Channel", ")", "SetName", "(", "name", "string", ")", "{", "packet", ":=", "MumbleProto", ".", "ChannelState", "{", "ChannelId", ":", "&", "c", ".", "ID", ",", "Name", ":", "&", "name", ",", "}", "\n", "c", ".", "client", ...
// SetName will set the name of the channel. This will have no effect if the // channel is the server's root channel.
[ "SetName", "will", "set", "the", "name", "of", "the", "channel", ".", "This", "will", "have", "no", "effect", "if", "the", "channel", "is", "the", "server", "s", "root", "channel", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/channel.go#L66-L72
150,957
layeh/gumble
gumble/channel.go
SetDescription
func (c *Channel) SetDescription(description string) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, Description: &description, } c.client.Conn.WriteProto(&packet) }
go
func (c *Channel) SetDescription(description string) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, Description: &description, } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "Channel", ")", "SetDescription", "(", "description", "string", ")", "{", "packet", ":=", "MumbleProto", ".", "ChannelState", "{", "ChannelId", ":", "&", "c", ".", "ID", ",", "Description", ":", "&", "description", ",", "}", "\n", ...
// SetDescription will set the description of the channel.
[ "SetDescription", "will", "set", "the", "description", "of", "the", "channel", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/channel.go#L75-L81
150,958
layeh/gumble
gumble/channel.go
SetPosition
func (c *Channel) SetPosition(position int32) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, Position: &position, } c.client.Conn.WriteProto(&packet) }
go
func (c *Channel) SetPosition(position int32) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, Position: &position, } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "Channel", ")", "SetPosition", "(", "position", "int32", ")", "{", "packet", ":=", "MumbleProto", ".", "ChannelState", "{", "ChannelId", ":", "&", "c", ".", "ID", ",", "Position", ":", "&", "position", ",", "}", "\n", "c", ".",...
// SetPosition will set the position of the channel.
[ "SetPosition", "will", "set", "the", "position", "of", "the", "channel", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/channel.go#L84-L90
150,959
layeh/gumble
gumble/channel.go
SetMaxUsers
func (c *Channel) SetMaxUsers(maxUsers uint32) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, MaxUsers: &maxUsers, } c.client.Conn.WriteProto(&packet) }
go
func (c *Channel) SetMaxUsers(maxUsers uint32) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, MaxUsers: &maxUsers, } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "Channel", ")", "SetMaxUsers", "(", "maxUsers", "uint32", ")", "{", "packet", ":=", "MumbleProto", ".", "ChannelState", "{", "ChannelId", ":", "&", "c", ".", "ID", ",", "MaxUsers", ":", "&", "maxUsers", ",", "}", "\n", "c", "."...
// SetMaxUsers will set the maximum number of users allowed in the channel.
[ "SetMaxUsers", "will", "set", "the", "maximum", "number", "of", "users", "allowed", "in", "the", "channel", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/channel.go#L93-L99
150,960
layeh/gumble
gumble/channel.go
RequestACL
func (c *Channel) RequestACL() { packet := MumbleProto.ACL{ ChannelId: &c.ID, Query: proto.Bool(true), } c.client.Conn.WriteProto(&packet) }
go
func (c *Channel) RequestACL() { packet := MumbleProto.ACL{ ChannelId: &c.ID, Query: proto.Bool(true), } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "Channel", ")", "RequestACL", "(", ")", "{", "packet", ":=", "MumbleProto", ".", "ACL", "{", "ChannelId", ":", "&", "c", ".", "ID", ",", "Query", ":", "proto", ".", "Bool", "(", "true", ")", ",", "}", "\n", "c", ".", "cli...
// RequestACL requests that the channel's ACL to be sent to the client.
[ "RequestACL", "requests", "that", "the", "channel", "s", "ACL", "to", "be", "sent", "to", "the", "client", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/channel.go#L136-L142
150,961
layeh/gumble
gumble/channel.go
Send
func (c *Channel) Send(message string, recursive bool) { textMessage := TextMessage{ Message: message, } if recursive { textMessage.Trees = []*Channel{c} } else { textMessage.Channels = []*Channel{c} } c.client.Send(&textMessage) }
go
func (c *Channel) Send(message string, recursive bool) { textMessage := TextMessage{ Message: message, } if recursive { textMessage.Trees = []*Channel{c} } else { textMessage.Channels = []*Channel{c} } c.client.Send(&textMessage) }
[ "func", "(", "c", "*", "Channel", ")", "Send", "(", "message", "string", ",", "recursive", "bool", ")", "{", "textMessage", ":=", "TextMessage", "{", "Message", ":", "message", ",", "}", "\n", "if", "recursive", "{", "textMessage", ".", "Trees", "=", "...
// Send will send a text message to the channel.
[ "Send", "will", "send", "a", "text", "message", "to", "the", "channel", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/channel.go#L157-L167
150,962
layeh/gumble
gumble/channel.go
Link
func (c *Channel) Link(channel ...*Channel) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, LinksAdd: make([]uint32, len(channel)), } for i, ch := range channel { packet.LinksAdd[i] = ch.ID } c.client.Conn.WriteProto(&packet) }
go
func (c *Channel) Link(channel ...*Channel) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, LinksAdd: make([]uint32, len(channel)), } for i, ch := range channel { packet.LinksAdd[i] = ch.ID } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "Channel", ")", "Link", "(", "channel", "...", "*", "Channel", ")", "{", "packet", ":=", "MumbleProto", ".", "ChannelState", "{", "ChannelId", ":", "&", "c", ".", "ID", ",", "LinksAdd", ":", "make", "(", "[", "]", "uint32", "...
// Link links the given channels to the channel.
[ "Link", "links", "the", "given", "channels", "to", "the", "channel", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/channel.go#L176-L185
150,963
layeh/gumble
gumble/channel.go
Unlink
func (c *Channel) Unlink(channel ...*Channel) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, } if len(channel) == 0 { packet.LinksRemove = make([]uint32, len(c.Links)) i := 0 for channelID := range c.Links { packet.LinksRemove[i] = channelID i++ } } else { packet.LinksRemove = make([]uint32, len(channel)) for i, ch := range channel { packet.LinksRemove[i] = ch.ID } } c.client.Conn.WriteProto(&packet) }
go
func (c *Channel) Unlink(channel ...*Channel) { packet := MumbleProto.ChannelState{ ChannelId: &c.ID, } if len(channel) == 0 { packet.LinksRemove = make([]uint32, len(c.Links)) i := 0 for channelID := range c.Links { packet.LinksRemove[i] = channelID i++ } } else { packet.LinksRemove = make([]uint32, len(channel)) for i, ch := range channel { packet.LinksRemove[i] = ch.ID } } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "Channel", ")", "Unlink", "(", "channel", "...", "*", "Channel", ")", "{", "packet", ":=", "MumbleProto", ".", "ChannelState", "{", "ChannelId", ":", "&", "c", ".", "ID", ",", "}", "\n", "if", "len", "(", "channel", ")", "=="...
// Unlink unlinks the given channels from the channel. If no arguments are // passed, all linked channels are unlinked.
[ "Unlink", "unlinks", "the", "given", "channels", "from", "the", "channel", ".", "If", "no", "arguments", "are", "passed", "all", "linked", "channels", "are", "unlinked", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/channel.go#L189-L207
150,964
layeh/gumble
gumbleutil/textmessage.go
PlainText
func PlainText(tm *gumble.TextMessage) string { d := xml.NewDecoder(strings.NewReader(tm.Message)) d.Strict = false d.AutoClose = xml.HTMLAutoClose d.Entity = xml.HTMLEntity var b bytes.Buffer newline := false for { t, _ := d.Token() if t == nil { break } switch node := t.(type) { case xml.CharData: if len(node) > 0 { b.Write(node) newline = false } case xml.StartElement: switch node.Name.Local { case "address", "article", "aside", "audio", "blockquote", "canvas", "dd", "div", "dl", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "noscript", "ol", "output", "p", "pre", "section", "table", "tfoot", "ul", "video": if !newline { b.WriteByte('\n') newline = true } case "br": b.WriteByte('\n') newline = true } } } return b.String() }
go
func PlainText(tm *gumble.TextMessage) string { d := xml.NewDecoder(strings.NewReader(tm.Message)) d.Strict = false d.AutoClose = xml.HTMLAutoClose d.Entity = xml.HTMLEntity var b bytes.Buffer newline := false for { t, _ := d.Token() if t == nil { break } switch node := t.(type) { case xml.CharData: if len(node) > 0 { b.Write(node) newline = false } case xml.StartElement: switch node.Name.Local { case "address", "article", "aside", "audio", "blockquote", "canvas", "dd", "div", "dl", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "noscript", "ol", "output", "p", "pre", "section", "table", "tfoot", "ul", "video": if !newline { b.WriteByte('\n') newline = true } case "br": b.WriteByte('\n') newline = true } } } return b.String() }
[ "func", "PlainText", "(", "tm", "*", "gumble", ".", "TextMessage", ")", "string", "{", "d", ":=", "xml", ".", "NewDecoder", "(", "strings", ".", "NewReader", "(", "tm", ".", "Message", ")", ")", "\n", "d", ".", "Strict", "=", "false", "\n", "d", "....
// PlainText returns the Message string without HTML tags or entities.
[ "PlainText", "returns", "the", "Message", "string", "without", "HTML", "tags", "or", "entities", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/textmessage.go#L12-L45
150,965
layeh/gumble
gumbleutil/acl.go
UserGroups
func UserGroups(client *gumble.Client, user *gumble.User, channel *gumble.Channel) <-chan []string { ch := make(chan []string) if !user.IsRegistered() { close(ch) return ch } var detacher gumble.Detacher listener := Listener{ Disconnect: func(e *gumble.DisconnectEvent) { detacher.Detach() close(ch) }, ChannelChange: func(e *gumble.ChannelChangeEvent) { if e.Channel == channel && e.Type.Has(gumble.ChannelChangeRemoved) { detacher.Detach() close(ch) } }, PermissionDenied: func(e *gumble.PermissionDeniedEvent) { if e.Channel == channel && e.Type == gumble.PermissionDeniedPermission && (e.Permission&gumble.PermissionWrite) != 0 { detacher.Detach() close(ch) } }, ACL: func(e *gumble.ACLEvent) { if e.ACL.Channel != channel { return } var names []string for _, g := range e.ACL.Groups { if (g.UsersAdd[user.UserID] != nil || g.UsersInherited[user.UserID] != nil) && g.UsersRemove[user.UserID] == nil { names = append(names, g.Name) } } detacher.Detach() ch <- names close(ch) }, } detacher = client.Config.Attach(&listener) channel.RequestACL() return ch }
go
func UserGroups(client *gumble.Client, user *gumble.User, channel *gumble.Channel) <-chan []string { ch := make(chan []string) if !user.IsRegistered() { close(ch) return ch } var detacher gumble.Detacher listener := Listener{ Disconnect: func(e *gumble.DisconnectEvent) { detacher.Detach() close(ch) }, ChannelChange: func(e *gumble.ChannelChangeEvent) { if e.Channel == channel && e.Type.Has(gumble.ChannelChangeRemoved) { detacher.Detach() close(ch) } }, PermissionDenied: func(e *gumble.PermissionDeniedEvent) { if e.Channel == channel && e.Type == gumble.PermissionDeniedPermission && (e.Permission&gumble.PermissionWrite) != 0 { detacher.Detach() close(ch) } }, ACL: func(e *gumble.ACLEvent) { if e.ACL.Channel != channel { return } var names []string for _, g := range e.ACL.Groups { if (g.UsersAdd[user.UserID] != nil || g.UsersInherited[user.UserID] != nil) && g.UsersRemove[user.UserID] == nil { names = append(names, g.Name) } } detacher.Detach() ch <- names close(ch) }, } detacher = client.Config.Attach(&listener) channel.RequestACL() return ch }
[ "func", "UserGroups", "(", "client", "*", "gumble", ".", "Client", ",", "user", "*", "gumble", ".", "User", ",", "channel", "*", "gumble", ".", "Channel", ")", "<-", "chan", "[", "]", "string", "{", "ch", ":=", "make", "(", "chan", "[", "]", "strin...
// UserGroups fetches the group names the given user belongs to in the given // channel. The slice of group names sent via the returned channel. On error, // the returned channel is closed without without sending a slice.
[ "UserGroups", "fetches", "the", "group", "names", "the", "given", "user", "belongs", "to", "in", "the", "given", "channel", ".", "The", "slice", "of", "group", "names", "sent", "via", "the", "returned", "channel", ".", "On", "error", "the", "returned", "ch...
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleutil/acl.go#L10-L55
150,966
layeh/gumble
gumbleffmpeg/stream.go
New
func New(client *gumble.Client, source Source) *Stream { return &Stream{ client: client, Volume: 1.0, Source: source, Command: "ffmpeg", pause: make(chan struct{}), state: StateInitial, } }
go
func New(client *gumble.Client, source Source) *Stream { return &Stream{ client: client, Volume: 1.0, Source: source, Command: "ffmpeg", pause: make(chan struct{}), state: StateInitial, } }
[ "func", "New", "(", "client", "*", "gumble", ".", "Client", ",", "source", "Source", ")", "*", "Stream", "{", "return", "&", "Stream", "{", "client", ":", "client", ",", "Volume", ":", "1.0", ",", "Source", ":", "source", ",", "Command", ":", "\"", ...
// New returns a new Stream for the given gumble Client and Source.
[ "New", "returns", "a", "new", "Stream", "for", "the", "given", "gumble", "Client", "and", "Source", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleffmpeg/stream.go#L54-L63
150,967
layeh/gumble
gumbleffmpeg/stream.go
Play
func (s *Stream) Play() error { s.l.Lock() defer s.l.Unlock() switch s.state { case StatePaused: s.state = StatePlaying go s.process() return nil case StatePlaying: return errors.New("gumbleffmpeg: stream already playing") case StateStopped: return errors.New("gumbleffmpeg: stream has stopped") } // fresh stream if s.Source == nil { return errors.New("gumbleffmpeg: nil source") } args := s.Source.arguments() if s.Offset > 0 { args = append([]string{"-ss", strconv.FormatFloat(s.Offset.Seconds(), 'f', -1, 64)}, args...) } args = append(args, "-ac", strconv.Itoa(gumble.AudioChannels), "-ar", strconv.Itoa(gumble.AudioSampleRate), "-f", "s16le", "-") cmd := exec.Command(s.Command, args...) var err error s.pipe, err = cmd.StdoutPipe() if err != nil { return err } if err := s.Source.start(cmd); err != nil { return err } if err := cmd.Start(); err != nil { s.Source.done() return err } s.wg.Add(1) s.cmd = cmd s.state = StatePlaying go s.process() return nil }
go
func (s *Stream) Play() error { s.l.Lock() defer s.l.Unlock() switch s.state { case StatePaused: s.state = StatePlaying go s.process() return nil case StatePlaying: return errors.New("gumbleffmpeg: stream already playing") case StateStopped: return errors.New("gumbleffmpeg: stream has stopped") } // fresh stream if s.Source == nil { return errors.New("gumbleffmpeg: nil source") } args := s.Source.arguments() if s.Offset > 0 { args = append([]string{"-ss", strconv.FormatFloat(s.Offset.Seconds(), 'f', -1, 64)}, args...) } args = append(args, "-ac", strconv.Itoa(gumble.AudioChannels), "-ar", strconv.Itoa(gumble.AudioSampleRate), "-f", "s16le", "-") cmd := exec.Command(s.Command, args...) var err error s.pipe, err = cmd.StdoutPipe() if err != nil { return err } if err := s.Source.start(cmd); err != nil { return err } if err := cmd.Start(); err != nil { s.Source.done() return err } s.wg.Add(1) s.cmd = cmd s.state = StatePlaying go s.process() return nil }
[ "func", "(", "s", "*", "Stream", ")", "Play", "(", ")", "error", "{", "s", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "l", ".", "Unlock", "(", ")", "\n\n", "switch", "s", ".", "state", "{", "case", "StatePaused", ":", "s", ".",...
// Play begins playing
[ "Play", "begins", "playing" ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleffmpeg/stream.go#L66-L109
150,968
layeh/gumble
gumbleffmpeg/stream.go
State
func (s *Stream) State() State { s.l.Lock() defer s.l.Unlock() return s.state }
go
func (s *Stream) State() State { s.l.Lock() defer s.l.Unlock() return s.state }
[ "func", "(", "s", "*", "Stream", ")", "State", "(", ")", "State", "{", "s", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "l", ".", "Unlock", "(", ")", "\n", "return", "s", ".", "state", "\n", "}" ]
// State returns the state of the stream.
[ "State", "returns", "the", "state", "of", "the", "stream", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleffmpeg/stream.go#L112-L116
150,969
layeh/gumble
gumbleffmpeg/stream.go
Pause
func (s *Stream) Pause() error { s.l.Lock() if s.state != StatePlaying { s.l.Unlock() return errors.New("gumbleffmpeg: stream is not playing") } s.state = StatePaused s.l.Unlock() s.pause <- struct{}{} return nil }
go
func (s *Stream) Pause() error { s.l.Lock() if s.state != StatePlaying { s.l.Unlock() return errors.New("gumbleffmpeg: stream is not playing") } s.state = StatePaused s.l.Unlock() s.pause <- struct{}{} return nil }
[ "func", "(", "s", "*", "Stream", ")", "Pause", "(", ")", "error", "{", "s", ".", "l", ".", "Lock", "(", ")", "\n", "if", "s", ".", "state", "!=", "StatePlaying", "{", "s", ".", "l", ".", "Unlock", "(", ")", "\n", "return", "errors", ".", "New...
// Pause pauses a playing stream.
[ "Pause", "pauses", "a", "playing", "stream", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleffmpeg/stream.go#L119-L129
150,970
layeh/gumble
gumbleffmpeg/stream.go
Stop
func (s *Stream) Stop() error { s.l.Lock() switch s.state { case StateStopped, StateInitial: s.l.Unlock() return errors.New("gumbleffmpeg: stream is not playing nor paused") } s.cleanup() s.Wait() return nil }
go
func (s *Stream) Stop() error { s.l.Lock() switch s.state { case StateStopped, StateInitial: s.l.Unlock() return errors.New("gumbleffmpeg: stream is not playing nor paused") } s.cleanup() s.Wait() return nil }
[ "func", "(", "s", "*", "Stream", ")", "Stop", "(", ")", "error", "{", "s", ".", "l", ".", "Lock", "(", ")", "\n", "switch", "s", ".", "state", "{", "case", "StateStopped", ",", "StateInitial", ":", "s", ".", "l", ".", "Unlock", "(", ")", "\n", ...
// Stop stops the stream.
[ "Stop", "stops", "the", "stream", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleffmpeg/stream.go#L132-L142
150,971
layeh/gumble
gumbleffmpeg/stream.go
Elapsed
func (s *Stream) Elapsed() time.Duration { return time.Duration(atomic.LoadInt64(&s.elapsed)) }
go
func (s *Stream) Elapsed() time.Duration { return time.Duration(atomic.LoadInt64(&s.elapsed)) }
[ "func", "(", "s", "*", "Stream", ")", "Elapsed", "(", ")", "time", ".", "Duration", "{", "return", "time", ".", "Duration", "(", "atomic", ".", "LoadInt64", "(", "&", "s", ".", "elapsed", ")", ")", "\n", "}" ]
// Elapsed returns the amount of audio that has been played by the stream.
[ "Elapsed", "returns", "the", "amount", "of", "audio", "that", "has", "been", "played", "by", "the", "stream", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleffmpeg/stream.go#L150-L152
150,972
layeh/gumble
gumbleffmpeg/source.go
SourceExec
func SourceExec(name string, arg ...string) Source { return &sourceExec{ name: name, arg: arg, } }
go
func SourceExec(name string, arg ...string) Source { return &sourceExec{ name: name, arg: arg, } }
[ "func", "SourceExec", "(", "name", "string", ",", "arg", "...", "string", ")", "Source", "{", "return", "&", "sourceExec", "{", "name", ":", "name", ",", "arg", ":", "arg", ",", "}", "\n", "}" ]
// SourceExec uses the output of the given command and arguments as source // data.
[ "SourceExec", "uses", "the", "output", "of", "the", "given", "command", "and", "arguments", "as", "source", "data", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumbleffmpeg/source.go#L71-L76
150,973
layeh/gumble
gumble/client.go
pingRoutine
func (c *Client) pingRoutine() { ticker := time.NewTicker(time.Second * 5) defer ticker.Stop() var timestamp uint64 var tcpPingAvg float32 var tcpPingVar float32 packet := MumbleProto.Ping{ Timestamp: &timestamp, TcpPackets: &c.tcpPacketsReceived, TcpPingAvg: &tcpPingAvg, TcpPingVar: &tcpPingVar, } t := time.Now() for { timestamp = uint64(t.UnixNano()) tcpPingAvg = math.Float32frombits(atomic.LoadUint32(&c.tcpPingAvg)) tcpPingVar = math.Float32frombits(atomic.LoadUint32(&c.tcpPingVar)) c.Conn.WriteProto(&packet) select { case <-c.end: return case t = <-ticker.C: // continue to top of loop } } }
go
func (c *Client) pingRoutine() { ticker := time.NewTicker(time.Second * 5) defer ticker.Stop() var timestamp uint64 var tcpPingAvg float32 var tcpPingVar float32 packet := MumbleProto.Ping{ Timestamp: &timestamp, TcpPackets: &c.tcpPacketsReceived, TcpPingAvg: &tcpPingAvg, TcpPingVar: &tcpPingVar, } t := time.Now() for { timestamp = uint64(t.UnixNano()) tcpPingAvg = math.Float32frombits(atomic.LoadUint32(&c.tcpPingAvg)) tcpPingVar = math.Float32frombits(atomic.LoadUint32(&c.tcpPingVar)) c.Conn.WriteProto(&packet) select { case <-c.end: return case t = <-ticker.C: // continue to top of loop } } }
[ "func", "(", "c", "*", "Client", ")", "pingRoutine", "(", ")", "{", "ticker", ":=", "time", ".", "NewTicker", "(", "time", ".", "Second", "*", "5", ")", "\n", "defer", "ticker", ".", "Stop", "(", ")", "\n\n", "var", "timestamp", "uint64", "\n", "va...
// pingRoutine sends ping packets to the server at regular intervals.
[ "pingRoutine", "sends", "ping", "packets", "to", "the", "server", "at", "regular", "intervals", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/client.go#L196-L224
150,974
layeh/gumble
gumble/client.go
readRoutine
func (c *Client) readRoutine() { c.disconnectEvent = DisconnectEvent{ Client: c, Type: DisconnectError, } for { pType, data, err := c.Conn.ReadPacket() if err != nil { break } if int(pType) < len(handlers) { handlers[pType](c, data) } } wasSynced := c.State() == StateSynced atomic.StoreUint32(&c.state, uint32(StateDisconnected)) close(c.end) if wasSynced { c.Config.Listeners.onDisconnect(&c.disconnectEvent) } }
go
func (c *Client) readRoutine() { c.disconnectEvent = DisconnectEvent{ Client: c, Type: DisconnectError, } for { pType, data, err := c.Conn.ReadPacket() if err != nil { break } if int(pType) < len(handlers) { handlers[pType](c, data) } } wasSynced := c.State() == StateSynced atomic.StoreUint32(&c.state, uint32(StateDisconnected)) close(c.end) if wasSynced { c.Config.Listeners.onDisconnect(&c.disconnectEvent) } }
[ "func", "(", "c", "*", "Client", ")", "readRoutine", "(", ")", "{", "c", ".", "disconnectEvent", "=", "DisconnectEvent", "{", "Client", ":", "c", ",", "Type", ":", "DisconnectError", ",", "}", "\n\n", "for", "{", "pType", ",", "data", ",", "err", ":=...
// readRoutine reads protocol buffer messages from the server.
[ "readRoutine", "reads", "protocol", "buffer", "messages", "from", "the", "server", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/client.go#L227-L249
150,975
layeh/gumble
gumble/client.go
RequestUserList
func (c *Client) RequestUserList() { packet := MumbleProto.UserList{} c.Conn.WriteProto(&packet) }
go
func (c *Client) RequestUserList() { packet := MumbleProto.UserList{} c.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "Client", ")", "RequestUserList", "(", ")", "{", "packet", ":=", "MumbleProto", ".", "UserList", "{", "}", "\n", "c", ".", "Conn", ".", "WriteProto", "(", "&", "packet", ")", "\n", "}" ]
// RequestUserList requests that the server's registered user list be sent to // the client.
[ "RequestUserList", "requests", "that", "the", "server", "s", "registered", "user", "list", "be", "sent", "to", "the", "client", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/client.go#L253-L256
150,976
layeh/gumble
gumble/client.go
RequestBanList
func (c *Client) RequestBanList() { packet := MumbleProto.BanList{ Query: proto.Bool(true), } c.Conn.WriteProto(&packet) }
go
func (c *Client) RequestBanList() { packet := MumbleProto.BanList{ Query: proto.Bool(true), } c.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "Client", ")", "RequestBanList", "(", ")", "{", "packet", ":=", "MumbleProto", ".", "BanList", "{", "Query", ":", "proto", ".", "Bool", "(", "true", ")", ",", "}", "\n", "c", ".", "Conn", ".", "WriteProto", "(", "&", "packet"...
// RequestBanList requests that the server's ban list be sent to the client.
[ "RequestBanList", "requests", "that", "the", "server", "s", "ban", "list", "be", "sent", "to", "the", "client", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/client.go#L259-L264
150,977
layeh/gumble
gumble/client.go
Disconnect
func (c *Client) Disconnect() error { if c.State() == StateDisconnected { return errors.New("gumble: client is already disconnected") } c.disconnectEvent.Type = DisconnectUser c.Conn.Close() return nil }
go
func (c *Client) Disconnect() error { if c.State() == StateDisconnected { return errors.New("gumble: client is already disconnected") } c.disconnectEvent.Type = DisconnectUser c.Conn.Close() return nil }
[ "func", "(", "c", "*", "Client", ")", "Disconnect", "(", ")", "error", "{", "if", "c", ".", "State", "(", ")", "==", "StateDisconnected", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "c", ".", "disconnectEvent", ".", ...
// Disconnect disconnects the client from the server.
[ "Disconnect", "disconnects", "the", "client", "from", "the", "server", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/client.go#L267-L274
150,978
layeh/gumble
gumble/client.go
Do
func (c *Client) Do(f func()) { c.volatile.RLock() defer c.volatile.RUnlock() f() }
go
func (c *Client) Do(f func()) { c.volatile.RLock() defer c.volatile.RUnlock() f() }
[ "func", "(", "c", "*", "Client", ")", "Do", "(", "f", "func", "(", ")", ")", "{", "c", ".", "volatile", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "volatile", ".", "RUnlock", "(", ")", "\n\n", "f", "(", ")", "\n", "}" ]
// Do executes f in a thread-safe manner. It ensures that Client and its // associated data will not be changed during the lifetime of the function // call.
[ "Do", "executes", "f", "in", "a", "thread", "-", "safe", "manner", ".", "It", "ensures", "that", "Client", "and", "its", "associated", "data", "will", "not", "be", "changed", "during", "the", "lifetime", "of", "the", "function", "call", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/client.go#L279-L284
150,979
layeh/gumble
gumble/ping.go
Ping
func Ping(address string, interval, timeout time.Duration) (*PingResponse, error) { if timeout < 0 { return nil, errors.New("gumble: timeout must be positive") } deadline := time.Now().Add(timeout) conn, err := net.DialTimeout("udp", address, timeout) if err != nil { return nil, err } defer conn.Close() conn.SetReadDeadline(deadline) var ( idsLock sync.Mutex ids = make(map[string]time.Time) ) buildSendPacket := func() { var packet [12]byte if _, err := rand.Read(packet[4:]); err != nil { return } id := string(packet[4:]) idsLock.Lock() ids[id] = time.Now() idsLock.Unlock() conn.Write(packet[:]) } if interval > 0 { end := make(chan struct{}) defer close(end) go func() { ticker := time.NewTicker(interval) defer ticker.Stop() for { select { case <-ticker.C: buildSendPacket() case <-end: return } } }() } buildSendPacket() for { var incoming [24]byte if _, err := io.ReadFull(conn, incoming[:]); err != nil { return nil, err } id := string(incoming[4:12]) idsLock.Lock() sendTime, ok := ids[id] idsLock.Unlock() if !ok { continue } return &PingResponse{ Address: conn.RemoteAddr().(*net.UDPAddr), Ping: time.Since(sendTime), Version: Version{ Version: binary.BigEndian.Uint32(incoming[0:]), }, ConnectedUsers: int(binary.BigEndian.Uint32(incoming[12:])), MaximumUsers: int(binary.BigEndian.Uint32(incoming[16:])), MaximumBitrate: int(binary.BigEndian.Uint32(incoming[20:])), }, nil } }
go
func Ping(address string, interval, timeout time.Duration) (*PingResponse, error) { if timeout < 0 { return nil, errors.New("gumble: timeout must be positive") } deadline := time.Now().Add(timeout) conn, err := net.DialTimeout("udp", address, timeout) if err != nil { return nil, err } defer conn.Close() conn.SetReadDeadline(deadline) var ( idsLock sync.Mutex ids = make(map[string]time.Time) ) buildSendPacket := func() { var packet [12]byte if _, err := rand.Read(packet[4:]); err != nil { return } id := string(packet[4:]) idsLock.Lock() ids[id] = time.Now() idsLock.Unlock() conn.Write(packet[:]) } if interval > 0 { end := make(chan struct{}) defer close(end) go func() { ticker := time.NewTicker(interval) defer ticker.Stop() for { select { case <-ticker.C: buildSendPacket() case <-end: return } } }() } buildSendPacket() for { var incoming [24]byte if _, err := io.ReadFull(conn, incoming[:]); err != nil { return nil, err } id := string(incoming[4:12]) idsLock.Lock() sendTime, ok := ids[id] idsLock.Unlock() if !ok { continue } return &PingResponse{ Address: conn.RemoteAddr().(*net.UDPAddr), Ping: time.Since(sendTime), Version: Version{ Version: binary.BigEndian.Uint32(incoming[0:]), }, ConnectedUsers: int(binary.BigEndian.Uint32(incoming[12:])), MaximumUsers: int(binary.BigEndian.Uint32(incoming[16:])), MaximumBitrate: int(binary.BigEndian.Uint32(incoming[20:])), }, nil } }
[ "func", "Ping", "(", "address", "string", ",", "interval", ",", "timeout", "time", ".", "Duration", ")", "(", "*", "PingResponse", ",", "error", ")", "{", "if", "timeout", "<", "0", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ...
// Ping sends a UDP ping packet to the given server. If interval is positive, // the packet is retransmitted at every interval. // // Returns a PingResponse and nil on success. The function will return nil and // an error if a valid response is not received after the given timeout.
[ "Ping", "sends", "a", "UDP", "ping", "packet", "to", "the", "given", "server", ".", "If", "interval", "is", "positive", "the", "packet", "is", "retransmitted", "at", "every", "interval", ".", "Returns", "a", "PingResponse", "and", "nil", "on", "success", "...
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/ping.go#L36-L108
150,980
layeh/gumble
gumble/contextaction.go
Trigger
func (c *ContextAction) Trigger() { packet := MumbleProto.ContextAction{ Action: &c.Name, } c.client.Conn.WriteProto(&packet) }
go
func (c *ContextAction) Trigger() { packet := MumbleProto.ContextAction{ Action: &c.Name, } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "ContextAction", ")", "Trigger", "(", ")", "{", "packet", ":=", "MumbleProto", ".", "ContextAction", "{", "Action", ":", "&", "c", ".", "Name", ",", "}", "\n", "c", ".", "client", ".", "Conn", ".", "WriteProto", "(", "&", "pa...
// Trigger will trigger the context action in the context of the server.
[ "Trigger", "will", "trigger", "the", "context", "action", "in", "the", "context", "of", "the", "server", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/contextaction.go#L32-L37
150,981
layeh/gumble
gumble/contextaction.go
TriggerUser
func (c *ContextAction) TriggerUser(user *User) { packet := MumbleProto.ContextAction{ Session: &user.Session, Action: &c.Name, } c.client.Conn.WriteProto(&packet) }
go
func (c *ContextAction) TriggerUser(user *User) { packet := MumbleProto.ContextAction{ Session: &user.Session, Action: &c.Name, } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "ContextAction", ")", "TriggerUser", "(", "user", "*", "User", ")", "{", "packet", ":=", "MumbleProto", ".", "ContextAction", "{", "Session", ":", "&", "user", ".", "Session", ",", "Action", ":", "&", "c", ".", "Name", ",", "}"...
// TriggerUser will trigger the context action in the context of the given // user.
[ "TriggerUser", "will", "trigger", "the", "context", "action", "in", "the", "context", "of", "the", "given", "user", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/contextaction.go#L41-L47
150,982
layeh/gumble
gumble/contextaction.go
TriggerChannel
func (c *ContextAction) TriggerChannel(channel *Channel) { packet := MumbleProto.ContextAction{ ChannelId: &channel.ID, Action: &c.Name, } c.client.Conn.WriteProto(&packet) }
go
func (c *ContextAction) TriggerChannel(channel *Channel) { packet := MumbleProto.ContextAction{ ChannelId: &channel.ID, Action: &c.Name, } c.client.Conn.WriteProto(&packet) }
[ "func", "(", "c", "*", "ContextAction", ")", "TriggerChannel", "(", "channel", "*", "Channel", ")", "{", "packet", ":=", "MumbleProto", ".", "ContextAction", "{", "ChannelId", ":", "&", "channel", ".", "ID", ",", "Action", ":", "&", "c", ".", "Name", "...
// TriggerChannel will trigger the context action in the context of the given // channel.
[ "TriggerChannel", "will", "trigger", "the", "context", "action", "in", "the", "context", "of", "the", "given", "channel", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/contextaction.go#L51-L57
150,983
layeh/gumble
gumble/bans.go
Add
func (b *BanList) Add(address net.IP, mask net.IPMask, reason string, duration time.Duration) *Ban { ban := &Ban{ Address: address, Mask: mask, Reason: reason, Duration: duration, } *b = append(*b, ban) return ban }
go
func (b *BanList) Add(address net.IP, mask net.IPMask, reason string, duration time.Duration) *Ban { ban := &Ban{ Address: address, Mask: mask, Reason: reason, Duration: duration, } *b = append(*b, ban) return ban }
[ "func", "(", "b", "*", "BanList", ")", "Add", "(", "address", "net", ".", "IP", ",", "mask", "net", ".", "IPMask", ",", "reason", "string", ",", "duration", "time", ".", "Duration", ")", "*", "Ban", "{", "ban", ":=", "&", "Ban", "{", "Address", "...
// Add creates a new ban list entry with the given parameters.
[ "Add", "creates", "a", "new", "ban", "list", "entry", "with", "the", "given", "parameters", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/bans.go#L18-L27
150,984
layeh/gumble
gumble/userlist.go
SetName
func (r *RegisteredUser) SetName(name string) { r.Name = name r.changed = true }
go
func (r *RegisteredUser) SetName(name string) { r.Name = name r.changed = true }
[ "func", "(", "r", "*", "RegisteredUser", ")", "SetName", "(", "name", "string", ")", "{", "r", ".", "Name", "=", "name", "\n", "r", ".", "changed", "=", "true", "\n", "}" ]
// SetName sets the new name for the user.
[ "SetName", "sets", "the", "new", "name", "for", "the", "user", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/userlist.go#L25-L28
150,985
layeh/gumble
gumble/userlist.go
ACLUser
func (r *RegisteredUser) ACLUser() *ACLUser { return &ACLUser{ UserID: r.UserID, Name: r.Name, } }
go
func (r *RegisteredUser) ACLUser() *ACLUser { return &ACLUser{ UserID: r.UserID, Name: r.Name, } }
[ "func", "(", "r", "*", "RegisteredUser", ")", "ACLUser", "(", ")", "*", "ACLUser", "{", "return", "&", "ACLUser", "{", "UserID", ":", "r", ".", "UserID", ",", "Name", ":", "r", ".", "Name", ",", "}", "\n", "}" ]
// ACLUser returns an ACLUser for the given registered user.
[ "ACLUser", "returns", "an", "ACLUser", "for", "the", "given", "registered", "user", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/userlist.go#L42-L47
150,986
layeh/gumble
gumble/audiolisteners.go
Attach
func (e *AudioListeners) Attach(listener AudioListener) Detacher { item := &audioEventItem{ parent: e, prev: e.tail, listener: listener, streams: make(map[*User]chan *AudioPacket), } if e.head == nil { e.head = item } if e.tail == nil { e.tail = item } else { e.tail.next = item } return item }
go
func (e *AudioListeners) Attach(listener AudioListener) Detacher { item := &audioEventItem{ parent: e, prev: e.tail, listener: listener, streams: make(map[*User]chan *AudioPacket), } if e.head == nil { e.head = item } if e.tail == nil { e.tail = item } else { e.tail.next = item } return item }
[ "func", "(", "e", "*", "AudioListeners", ")", "Attach", "(", "listener", "AudioListener", ")", "Detacher", "{", "item", ":=", "&", "audioEventItem", "{", "parent", ":", "e", ",", "prev", ":", "e", ".", "tail", ",", "listener", ":", "listener", ",", "st...
// Attach adds a new audio listener to the end of the current list of listeners.
[ "Attach", "adds", "a", "new", "audio", "listener", "to", "the", "end", "of", "the", "current", "list", "of", "listeners", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/audiolisteners.go#L30-L46
150,987
layeh/gumble
gumble/voicetarget.go
AddUser
func (v *VoiceTarget) AddUser(user *User) { v.users = append(v.users, user) }
go
func (v *VoiceTarget) AddUser(user *User) { v.users = append(v.users, user) }
[ "func", "(", "v", "*", "VoiceTarget", ")", "AddUser", "(", "user", "*", "User", ")", "{", "v", ".", "users", "=", "append", "(", "v", ".", "users", ",", "user", ")", "\n", "}" ]
// AddUser adds a user to the voice target.
[ "AddUser", "adds", "a", "user", "to", "the", "voice", "target", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/voicetarget.go#L38-L40
150,988
layeh/gumble
gumble/voicetarget.go
AddChannel
func (v *VoiceTarget) AddChannel(channel *Channel, recursive, links bool, group string) { v.channels = append(v.channels, &voiceTargetChannel{ channel: channel, links: links, recursive: recursive, group: group, }) }
go
func (v *VoiceTarget) AddChannel(channel *Channel, recursive, links bool, group string) { v.channels = append(v.channels, &voiceTargetChannel{ channel: channel, links: links, recursive: recursive, group: group, }) }
[ "func", "(", "v", "*", "VoiceTarget", ")", "AddChannel", "(", "channel", "*", "Channel", ",", "recursive", ",", "links", "bool", ",", "group", "string", ")", "{", "v", ".", "channels", "=", "append", "(", "v", ".", "channels", ",", "&", "voiceTargetCha...
// AddChannel adds a user to the voice target. If group is non-empty, only // users belonging to that ACL group will be targeted.
[ "AddChannel", "adds", "a", "user", "to", "the", "voice", "target", ".", "If", "group", "is", "non", "-", "empty", "only", "users", "belonging", "to", "that", "ACL", "group", "will", "be", "targeted", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/voicetarget.go#L44-L51
150,989
layeh/gumble
gumble/audiocodec.go
RegisterAudioCodec
func RegisterAudioCodec(id int, codec AudioCodec) { audioCodecsLock.Lock() defer audioCodecsLock.Unlock() if id < 0 || id >= len(audioCodecs) { panic("id out of range") } audioCodecs[id] = codec }
go
func RegisterAudioCodec(id int, codec AudioCodec) { audioCodecsLock.Lock() defer audioCodecsLock.Unlock() if id < 0 || id >= len(audioCodecs) { panic("id out of range") } audioCodecs[id] = codec }
[ "func", "RegisterAudioCodec", "(", "id", "int", ",", "codec", "AudioCodec", ")", "{", "audioCodecsLock", ".", "Lock", "(", ")", "\n", "defer", "audioCodecsLock", ".", "Unlock", "(", ")", "\n\n", "if", "id", "<", "0", "||", "id", ">=", "len", "(", "audi...
// RegisterAudioCodec registers an audio codec that can be used for encoding // and decoding outgoing and incoming audio data. The function panics if the // ID is invalid.
[ "RegisterAudioCodec", "registers", "an", "audio", "codec", "that", "can", "be", "used", "for", "encoding", "and", "decoding", "outgoing", "and", "incoming", "audio", "data", ".", "The", "function", "panics", "if", "the", "ID", "is", "invalid", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/audiocodec.go#L19-L27
150,990
layeh/gumble
gumble/user.go
SetTexture
func (u *User) SetTexture(texture []byte) { packet := MumbleProto.UserState{ Session: &u.Session, Texture: texture, } u.client.Conn.WriteProto(&packet) }
go
func (u *User) SetTexture(texture []byte) { packet := MumbleProto.UserState{ Session: &u.Session, Texture: texture, } u.client.Conn.WriteProto(&packet) }
[ "func", "(", "u", "*", "User", ")", "SetTexture", "(", "texture", "[", "]", "byte", ")", "{", "packet", ":=", "MumbleProto", ".", "UserState", "{", "Session", ":", "&", "u", ".", "Session", ",", "Texture", ":", "texture", ",", "}", "\n", "u", ".", ...
// SetTexture sets the user's texture.
[ "SetTexture", "sets", "the", "user", "s", "texture", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L55-L61
150,991
layeh/gumble
gumble/user.go
SetPrioritySpeaker
func (u *User) SetPrioritySpeaker(prioritySpeaker bool) { packet := MumbleProto.UserState{ Session: &u.Session, PrioritySpeaker: &prioritySpeaker, } u.client.Conn.WriteProto(&packet) }
go
func (u *User) SetPrioritySpeaker(prioritySpeaker bool) { packet := MumbleProto.UserState{ Session: &u.Session, PrioritySpeaker: &prioritySpeaker, } u.client.Conn.WriteProto(&packet) }
[ "func", "(", "u", "*", "User", ")", "SetPrioritySpeaker", "(", "prioritySpeaker", "bool", ")", "{", "packet", ":=", "MumbleProto", ".", "UserState", "{", "Session", ":", "&", "u", ".", "Session", ",", "PrioritySpeaker", ":", "&", "prioritySpeaker", ",", "}...
// SetPrioritySpeaker sets if the user is a priority speaker in the channel.
[ "SetPrioritySpeaker", "sets", "if", "the", "user", "is", "a", "priority", "speaker", "in", "the", "channel", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L64-L70
150,992
layeh/gumble
gumble/user.go
SetRecording
func (u *User) SetRecording(recording bool) { packet := MumbleProto.UserState{ Session: &u.Session, Recording: &recording, } u.client.Conn.WriteProto(&packet) }
go
func (u *User) SetRecording(recording bool) { packet := MumbleProto.UserState{ Session: &u.Session, Recording: &recording, } u.client.Conn.WriteProto(&packet) }
[ "func", "(", "u", "*", "User", ")", "SetRecording", "(", "recording", "bool", ")", "{", "packet", ":=", "MumbleProto", ".", "UserState", "{", "Session", ":", "&", "u", ".", "Session", ",", "Recording", ":", "&", "recording", ",", "}", "\n", "u", ".",...
// SetRecording sets if the user is recording audio.
[ "SetRecording", "sets", "if", "the", "user", "is", "recording", "audio", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L73-L79
150,993
layeh/gumble
gumble/user.go
Register
func (u *User) Register() { packet := MumbleProto.UserState{ Session: &u.Session, UserId: proto.Uint32(0), } u.client.Conn.WriteProto(&packet) }
go
func (u *User) Register() { packet := MumbleProto.UserState{ Session: &u.Session, UserId: proto.Uint32(0), } u.client.Conn.WriteProto(&packet) }
[ "func", "(", "u", "*", "User", ")", "Register", "(", ")", "{", "packet", ":=", "MumbleProto", ".", "UserState", "{", "Session", ":", "&", "u", ".", "Session", ",", "UserId", ":", "proto", ".", "Uint32", "(", "0", ")", ",", "}", "\n", "u", ".", ...
// Register will register the user with the server. If the client has // permission to do so, the user will shortly be given a UserID.
[ "Register", "will", "register", "the", "user", "with", "the", "server", ".", "If", "the", "client", "has", "permission", "to", "do", "so", "the", "user", "will", "shortly", "be", "given", "a", "UserID", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L89-L95
150,994
layeh/gumble
gumble/user.go
SetComment
func (u *User) SetComment(comment string) { packet := MumbleProto.UserState{ Session: &u.Session, Comment: &comment, } u.client.Conn.WriteProto(&packet) }
go
func (u *User) SetComment(comment string) { packet := MumbleProto.UserState{ Session: &u.Session, Comment: &comment, } u.client.Conn.WriteProto(&packet) }
[ "func", "(", "u", "*", "User", ")", "SetComment", "(", "comment", "string", ")", "{", "packet", ":=", "MumbleProto", ".", "UserState", "{", "Session", ":", "&", "u", ".", "Session", ",", "Comment", ":", "&", "comment", ",", "}", "\n", "u", ".", "cl...
// SetComment will set the user's comment to the given string. The user's // comment will be erased if the comment is set to the empty string.
[ "SetComment", "will", "set", "the", "user", "s", "comment", "to", "the", "given", "string", ".", "The", "user", "s", "comment", "will", "be", "erased", "if", "the", "comment", "is", "set", "to", "the", "empty", "string", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L99-L105
150,995
layeh/gumble
gumble/user.go
Move
func (u *User) Move(channel *Channel) { packet := MumbleProto.UserState{ Session: &u.Session, ChannelId: &channel.ID, } u.client.Conn.WriteProto(&packet) }
go
func (u *User) Move(channel *Channel) { packet := MumbleProto.UserState{ Session: &u.Session, ChannelId: &channel.ID, } u.client.Conn.WriteProto(&packet) }
[ "func", "(", "u", "*", "User", ")", "Move", "(", "channel", "*", "Channel", ")", "{", "packet", ":=", "MumbleProto", ".", "UserState", "{", "Session", ":", "&", "u", ".", "Session", ",", "ChannelId", ":", "&", "channel", ".", "ID", ",", "}", "\n", ...
// Move will move the user to the given channel.
[ "Move", "will", "move", "the", "user", "to", "the", "given", "channel", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L108-L114
150,996
layeh/gumble
gumble/user.go
Kick
func (u *User) Kick(reason string) { packet := MumbleProto.UserRemove{ Session: &u.Session, Reason: &reason, } u.client.Conn.WriteProto(&packet) }
go
func (u *User) Kick(reason string) { packet := MumbleProto.UserRemove{ Session: &u.Session, Reason: &reason, } u.client.Conn.WriteProto(&packet) }
[ "func", "(", "u", "*", "User", ")", "Kick", "(", "reason", "string", ")", "{", "packet", ":=", "MumbleProto", ".", "UserRemove", "{", "Session", ":", "&", "u", ".", "Session", ",", "Reason", ":", "&", "reason", ",", "}", "\n", "u", ".", "client", ...
// Kick will kick the user from the server.
[ "Kick", "will", "kick", "the", "user", "from", "the", "server", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L117-L123
150,997
layeh/gumble
gumble/user.go
Ban
func (u *User) Ban(reason string) { packet := MumbleProto.UserRemove{ Session: &u.Session, Reason: &reason, Ban: proto.Bool(true), } u.client.Conn.WriteProto(&packet) }
go
func (u *User) Ban(reason string) { packet := MumbleProto.UserRemove{ Session: &u.Session, Reason: &reason, Ban: proto.Bool(true), } u.client.Conn.WriteProto(&packet) }
[ "func", "(", "u", "*", "User", ")", "Ban", "(", "reason", "string", ")", "{", "packet", ":=", "MumbleProto", ".", "UserRemove", "{", "Session", ":", "&", "u", ".", "Session", ",", "Reason", ":", "&", "reason", ",", "Ban", ":", "proto", ".", "Bool",...
// Ban will ban the user from the server.
[ "Ban", "will", "ban", "the", "user", "from", "the", "server", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L126-L133
150,998
layeh/gumble
gumble/user.go
SetMuted
func (u *User) SetMuted(muted bool) { packet := MumbleProto.UserState{ Session: &u.Session, Mute: &muted, } u.client.Conn.WriteProto(&packet) }
go
func (u *User) SetMuted(muted bool) { packet := MumbleProto.UserState{ Session: &u.Session, Mute: &muted, } u.client.Conn.WriteProto(&packet) }
[ "func", "(", "u", "*", "User", ")", "SetMuted", "(", "muted", "bool", ")", "{", "packet", ":=", "MumbleProto", ".", "UserState", "{", "Session", ":", "&", "u", ".", "Session", ",", "Mute", ":", "&", "muted", ",", "}", "\n", "u", ".", "client", "....
// SetMuted sets whether the user can transmit audio or not.
[ "SetMuted", "sets", "whether", "the", "user", "can", "transmit", "audio", "or", "not", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L136-L142
150,999
layeh/gumble
gumble/user.go
SetSuppressed
func (u *User) SetSuppressed(supressed bool) { packet := MumbleProto.UserState{ Session: &u.Session, Suppress: &supressed, } u.client.Conn.WriteProto(&packet) }
go
func (u *User) SetSuppressed(supressed bool) { packet := MumbleProto.UserState{ Session: &u.Session, Suppress: &supressed, } u.client.Conn.WriteProto(&packet) }
[ "func", "(", "u", "*", "User", ")", "SetSuppressed", "(", "supressed", "bool", ")", "{", "packet", ":=", "MumbleProto", ".", "UserState", "{", "Session", ":", "&", "u", ".", "Session", ",", "Suppress", ":", "&", "supressed", ",", "}", "\n", "u", ".",...
// SetSuppressed sets whether the user is suppressed by the server or not.
[ "SetSuppressed", "sets", "whether", "the", "user", "is", "suppressed", "by", "the", "server", "or", "not", "." ]
1ea1159c495624266a4adea43580748fd0fc9c57
https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/user.go#L145-L151