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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
142,800 | Bandwidth/go-bandwidth | applications.go | GetApplication | func (api *Client) GetApplication(id string) (*Application, error) {
result, _, err := api.makeRequest(http.MethodGet, fmt.Sprintf("%s/%s", api.concatUserPath(applicationsPath), id), &Application{})
if err != nil {
return nil, err
}
return result.(*Application), nil
} | go | func (api *Client) GetApplication(id string) (*Application, error) {
result, _, err := api.makeRequest(http.MethodGet, fmt.Sprintf("%s/%s", api.concatUserPath(applicationsPath), id), &Application{})
if err != nil {
return nil, err
}
return result.(*Application), nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetApplication",
"(",
"id",
"string",
")",
"(",
"*",
"Application",
",",
"error",
")",
"{",
"result",
",",
"_",
",",
"err",
":=",
"api",
".",
"makeRequest",
"(",
"http",
".",
"MethodGet",
",",
"fmt",
".",
"S... | // GetApplication returns an user's application
// It returns Application instance or error | [
"GetApplication",
"returns",
"an",
"user",
"s",
"application",
"It",
"returns",
"Application",
"instance",
"or",
"error"
] | 76d8de5eeb96d25cf550d4f57fcdc152061f2568 | https://github.com/Bandwidth/go-bandwidth/blob/76d8de5eeb96d25cf550d4f57fcdc152061f2568/applications.go#L69-L75 |
142,801 | Bandwidth/go-bandwidth | applications.go | UpdateApplication | func (api *Client) UpdateApplication(id string, changedData *ApplicationData) error {
_, _, err := api.makeRequest(http.MethodPost, fmt.Sprintf("%s/%s", api.concatUserPath(applicationsPath), id), nil, changedData)
return err
} | go | func (api *Client) UpdateApplication(id string, changedData *ApplicationData) error {
_, _, err := api.makeRequest(http.MethodPost, fmt.Sprintf("%s/%s", api.concatUserPath(applicationsPath), id), nil, changedData)
return err
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"UpdateApplication",
"(",
"id",
"string",
",",
"changedData",
"*",
"ApplicationData",
")",
"error",
"{",
"_",
",",
"_",
",",
"err",
":=",
"api",
".",
"makeRequest",
"(",
"http",
".",
"MethodPost",
",",
"fmt",
"."... | // UpdateApplication makes changes to an application
// It returns error object | [
"UpdateApplication",
"makes",
"changes",
"to",
"an",
"application",
"It",
"returns",
"error",
"object"
] | 76d8de5eeb96d25cf550d4f57fcdc152061f2568 | https://github.com/Bandwidth/go-bandwidth/blob/76d8de5eeb96d25cf550d4f57fcdc152061f2568/applications.go#L79-L82 |
142,802 | Bandwidth/go-bandwidth | applications.go | DeleteApplication | func (api *Client) DeleteApplication(id string) error {
_, _, err := api.makeRequest(http.MethodDelete, fmt.Sprintf("%s/%s", api.concatUserPath(applicationsPath), id))
return err
} | go | func (api *Client) DeleteApplication(id string) error {
_, _, err := api.makeRequest(http.MethodDelete, fmt.Sprintf("%s/%s", api.concatUserPath(applicationsPath), id))
return err
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"DeleteApplication",
"(",
"id",
"string",
")",
"error",
"{",
"_",
",",
"_",
",",
"err",
":=",
"api",
".",
"makeRequest",
"(",
"http",
".",
"MethodDelete",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ap... | // DeleteApplication permanently deletes an application
// It returns error object | [
"DeleteApplication",
"permanently",
"deletes",
"an",
"application",
"It",
"returns",
"error",
"object"
] | 76d8de5eeb96d25cf550d4f57fcdc152061f2568 | https://github.com/Bandwidth/go-bandwidth/blob/76d8de5eeb96d25cf550d4f57fcdc152061f2568/applications.go#L86-L89 |
142,803 | Bandwidth/go-bandwidth | phoneNumbers.go | GetPhoneNumbers | func (api *Client) GetPhoneNumbers(query ...*GetPhoneNumbersQuery) ([]*PhoneNumber, error) {
var options *GetPhoneNumbersQuery
if len(query) > 0 {
options = query[0]
}
result, _, err := api.makeRequest(http.MethodGet, api.concatUserPath(phoneNumbersPath), &[]*PhoneNumber{}, options)
if err != nil {
return nil,... | go | func (api *Client) GetPhoneNumbers(query ...*GetPhoneNumbersQuery) ([]*PhoneNumber, error) {
var options *GetPhoneNumbersQuery
if len(query) > 0 {
options = query[0]
}
result, _, err := api.makeRequest(http.MethodGet, api.concatUserPath(phoneNumbersPath), &[]*PhoneNumber{}, options)
if err != nil {
return nil,... | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetPhoneNumbers",
"(",
"query",
"...",
"*",
"GetPhoneNumbersQuery",
")",
"(",
"[",
"]",
"*",
"PhoneNumber",
",",
"error",
")",
"{",
"var",
"options",
"*",
"GetPhoneNumbersQuery",
"\n",
"if",
"len",
"(",
"query",
"... | // GetPhoneNumbers returns a list of your numbers
// It returns list of PhoneNumber instances or error | [
"GetPhoneNumbers",
"returns",
"a",
"list",
"of",
"your",
"numbers",
"It",
"returns",
"list",
"of",
"PhoneNumber",
"instances",
"or",
"error"
] | 76d8de5eeb96d25cf550d4f57fcdc152061f2568 | https://github.com/Bandwidth/go-bandwidth/blob/76d8de5eeb96d25cf550d4f57fcdc152061f2568/phoneNumbers.go#L61-L71 |
142,804 | Bandwidth/go-bandwidth | phoneNumbers.go | CreatePhoneNumber | func (api *Client) CreatePhoneNumber(data *CreatePhoneNumberData) (string, error) {
_, headers, err := api.makeRequest(http.MethodPost, api.concatUserPath(phoneNumbersPath), nil, data)
if err != nil {
return "", err
}
return getIDFromLocationHeader(headers), nil
} | go | func (api *Client) CreatePhoneNumber(data *CreatePhoneNumberData) (string, error) {
_, headers, err := api.makeRequest(http.MethodPost, api.concatUserPath(phoneNumbersPath), nil, data)
if err != nil {
return "", err
}
return getIDFromLocationHeader(headers), nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"CreatePhoneNumber",
"(",
"data",
"*",
"CreatePhoneNumberData",
")",
"(",
"string",
",",
"error",
")",
"{",
"_",
",",
"headers",
",",
"err",
":=",
"api",
".",
"makeRequest",
"(",
"http",
".",
"MethodPost",
",",
"... | // CreatePhoneNumber creates a new phone number
// It returns ID of created phone number or error | [
"CreatePhoneNumber",
"creates",
"a",
"new",
"phone",
"number",
"It",
"returns",
"ID",
"of",
"created",
"phone",
"number",
"or",
"error"
] | 76d8de5eeb96d25cf550d4f57fcdc152061f2568 | https://github.com/Bandwidth/go-bandwidth/blob/76d8de5eeb96d25cf550d4f57fcdc152061f2568/phoneNumbers.go#L75-L81 |
142,805 | Bandwidth/go-bandwidth | phoneNumbers.go | GetPhoneNumber | func (api *Client) GetPhoneNumber(idOrNumber string) (*PhoneNumber, error) {
result, _, err := api.makeRequest(http.MethodGet, fmt.Sprintf("%s/%s", api.concatUserPath(phoneNumbersPath), url.QueryEscape(idOrNumber)), &PhoneNumber{})
if err != nil {
return nil, err
}
return result.(*PhoneNumber), nil
} | go | func (api *Client) GetPhoneNumber(idOrNumber string) (*PhoneNumber, error) {
result, _, err := api.makeRequest(http.MethodGet, fmt.Sprintf("%s/%s", api.concatUserPath(phoneNumbersPath), url.QueryEscape(idOrNumber)), &PhoneNumber{})
if err != nil {
return nil, err
}
return result.(*PhoneNumber), nil
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"GetPhoneNumber",
"(",
"idOrNumber",
"string",
")",
"(",
"*",
"PhoneNumber",
",",
"error",
")",
"{",
"result",
",",
"_",
",",
"err",
":=",
"api",
".",
"makeRequest",
"(",
"http",
".",
"MethodGet",
",",
"fmt",
"... | // GetPhoneNumber returns information for phone number by id or number
// It returns instance of PhoneNumber or error | [
"GetPhoneNumber",
"returns",
"information",
"for",
"phone",
"number",
"by",
"id",
"or",
"number",
"It",
"returns",
"instance",
"of",
"PhoneNumber",
"or",
"error"
] | 76d8de5eeb96d25cf550d4f57fcdc152061f2568 | https://github.com/Bandwidth/go-bandwidth/blob/76d8de5eeb96d25cf550d4f57fcdc152061f2568/phoneNumbers.go#L85-L91 |
142,806 | Bandwidth/go-bandwidth | phoneNumbers.go | UpdatePhoneNumber | func (api *Client) UpdatePhoneNumber(idOrNumber string, data *UpdatePhoneNumberData) error {
_, _, err := api.makeRequest(http.MethodPost, fmt.Sprintf("%s/%s", api.concatUserPath(phoneNumbersPath), url.QueryEscape(idOrNumber)), nil, data)
return err
} | go | func (api *Client) UpdatePhoneNumber(idOrNumber string, data *UpdatePhoneNumberData) error {
_, _, err := api.makeRequest(http.MethodPost, fmt.Sprintf("%s/%s", api.concatUserPath(phoneNumbersPath), url.QueryEscape(idOrNumber)), nil, data)
return err
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"UpdatePhoneNumber",
"(",
"idOrNumber",
"string",
",",
"data",
"*",
"UpdatePhoneNumberData",
")",
"error",
"{",
"_",
",",
"_",
",",
"err",
":=",
"api",
".",
"makeRequest",
"(",
"http",
".",
"MethodPost",
",",
"fmt"... | // UpdatePhoneNumber makes changes to your number
// It returns error object | [
"UpdatePhoneNumber",
"makes",
"changes",
"to",
"your",
"number",
"It",
"returns",
"error",
"object"
] | 76d8de5eeb96d25cf550d4f57fcdc152061f2568 | https://github.com/Bandwidth/go-bandwidth/blob/76d8de5eeb96d25cf550d4f57fcdc152061f2568/phoneNumbers.go#L95-L98 |
142,807 | Bandwidth/go-bandwidth | phoneNumbers.go | DeletePhoneNumber | func (api *Client) DeletePhoneNumber(id string) error {
_, _, err := api.makeRequest(http.MethodDelete, fmt.Sprintf("%s/%s", api.concatUserPath(phoneNumbersPath), id))
return err
} | go | func (api *Client) DeletePhoneNumber(id string) error {
_, _, err := api.makeRequest(http.MethodDelete, fmt.Sprintf("%s/%s", api.concatUserPath(phoneNumbersPath), id))
return err
} | [
"func",
"(",
"api",
"*",
"Client",
")",
"DeletePhoneNumber",
"(",
"id",
"string",
")",
"error",
"{",
"_",
",",
"_",
",",
"err",
":=",
"api",
".",
"makeRequest",
"(",
"http",
".",
"MethodDelete",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ap... | // DeletePhoneNumber removes a phone number
// It returns error object | [
"DeletePhoneNumber",
"removes",
"a",
"phone",
"number",
"It",
"returns",
"error",
"object"
] | 76d8de5eeb96d25cf550d4f57fcdc152061f2568 | https://github.com/Bandwidth/go-bandwidth/blob/76d8de5eeb96d25cf550d4f57fcdc152061f2568/phoneNumbers.go#L102-L105 |
142,808 | dgryski/go-bitstream | bitstream.go | NewReader | func NewReader(r io.Reader) *BitReader {
b := new(BitReader)
b.r = r
return b
} | go | func NewReader(r io.Reader) *BitReader {
b := new(BitReader)
b.r = r
return b
} | [
"func",
"NewReader",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"BitReader",
"{",
"b",
":=",
"new",
"(",
"BitReader",
")",
"\n",
"b",
".",
"r",
"=",
"r",
"\n",
"return",
"b",
"\n",
"}"
] | // NewReader returns a BitReader that returns a single bit at a time from 'r' | [
"NewReader",
"returns",
"a",
"BitReader",
"that",
"returns",
"a",
"single",
"bit",
"at",
"a",
"time",
"from",
"r"
] | 3522498ce2c8ea06df73e55df58edfbfb33cfdd6 | https://github.com/dgryski/go-bitstream/blob/3522498ce2c8ea06df73e55df58edfbfb33cfdd6/bitstream.go#L33-L37 |
142,809 | dgryski/go-bitstream | bitstream.go | ReadBit | func (b *BitReader) ReadBit() (Bit, error) {
if b.count == 0 {
if n, err := b.r.Read(b.b[:]); n != 1 || (err != nil && err != io.EOF) {
return Zero, err
}
b.count = 8
}
b.count--
d := (b.b[0] & 0x80)
b.b[0] <<= 1
return d != 0, nil
} | go | func (b *BitReader) ReadBit() (Bit, error) {
if b.count == 0 {
if n, err := b.r.Read(b.b[:]); n != 1 || (err != nil && err != io.EOF) {
return Zero, err
}
b.count = 8
}
b.count--
d := (b.b[0] & 0x80)
b.b[0] <<= 1
return d != 0, nil
} | [
"func",
"(",
"b",
"*",
"BitReader",
")",
"ReadBit",
"(",
")",
"(",
"Bit",
",",
"error",
")",
"{",
"if",
"b",
".",
"count",
"==",
"0",
"{",
"if",
"n",
",",
"err",
":=",
"b",
".",
"r",
".",
"Read",
"(",
"b",
".",
"b",
"[",
":",
"]",
")",
... | // ReadBit returns the next bit from the stream, reading a new byte from the underlying reader if required. | [
"ReadBit",
"returns",
"the",
"next",
"bit",
"from",
"the",
"stream",
"reading",
"a",
"new",
"byte",
"from",
"the",
"underlying",
"reader",
"if",
"required",
"."
] | 3522498ce2c8ea06df73e55df58edfbfb33cfdd6 | https://github.com/dgryski/go-bitstream/blob/3522498ce2c8ea06df73e55df58edfbfb33cfdd6/bitstream.go#L40-L51 |
142,810 | dgryski/go-bitstream | bitstream.go | NewWriter | func NewWriter(w io.Writer) *BitWriter {
b := new(BitWriter)
b.w = w
b.count = 8
return b
} | go | func NewWriter(w io.Writer) *BitWriter {
b := new(BitWriter)
b.w = w
b.count = 8
return b
} | [
"func",
"NewWriter",
"(",
"w",
"io",
".",
"Writer",
")",
"*",
"BitWriter",
"{",
"b",
":=",
"new",
"(",
"BitWriter",
")",
"\n",
"b",
".",
"w",
"=",
"w",
"\n",
"b",
".",
"count",
"=",
"8",
"\n",
"return",
"b",
"\n",
"}"
] | // NewWriter returns a BitWriter that buffers bits and write the resulting bytes to 'w' | [
"NewWriter",
"returns",
"a",
"BitWriter",
"that",
"buffers",
"bits",
"and",
"write",
"the",
"resulting",
"bytes",
"to",
"w"
] | 3522498ce2c8ea06df73e55df58edfbfb33cfdd6 | https://github.com/dgryski/go-bitstream/blob/3522498ce2c8ea06df73e55df58edfbfb33cfdd6/bitstream.go#L54-L59 |
142,811 | dgryski/go-bitstream | bitstream.go | WriteBit | func (b *BitWriter) WriteBit(bit Bit) error {
if bit {
b.b[0] |= 1 << (b.count - 1)
}
b.count--
if b.count == 0 {
if n, err := b.w.Write(b.b[:]); n != 1 || err != nil {
return err
}
b.b[0] = 0
b.count = 8
}
return nil
} | go | func (b *BitWriter) WriteBit(bit Bit) error {
if bit {
b.b[0] |= 1 << (b.count - 1)
}
b.count--
if b.count == 0 {
if n, err := b.w.Write(b.b[:]); n != 1 || err != nil {
return err
}
b.b[0] = 0
b.count = 8
}
return nil
} | [
"func",
"(",
"b",
"*",
"BitWriter",
")",
"WriteBit",
"(",
"bit",
"Bit",
")",
"error",
"{",
"if",
"bit",
"{",
"b",
".",
"b",
"[",
"0",
"]",
"|=",
"1",
"<<",
"(",
"b",
".",
"count",
"-",
"1",
")",
"\n",
"}",
"\n\n",
"b",
".",
"count",
"--",
... | // WriteBit writes a single bit to the stream, writing a new byte to 'w' if required. | [
"WriteBit",
"writes",
"a",
"single",
"bit",
"to",
"the",
"stream",
"writing",
"a",
"new",
"byte",
"to",
"w",
"if",
"required",
"."
] | 3522498ce2c8ea06df73e55df58edfbfb33cfdd6 | https://github.com/dgryski/go-bitstream/blob/3522498ce2c8ea06df73e55df58edfbfb33cfdd6/bitstream.go#L71-L88 |
142,812 | dgryski/go-bitstream | bitstream.go | WriteByte | func (b *BitWriter) WriteByte(byt byte) error {
// fill up b.b with b.count bits from byt
b.b[0] |= byt >> (8 - b.count)
if n, err := b.w.Write(b.b[:]); n != 1 || err != nil {
return err
}
b.b[0] = byt << b.count
return nil
} | go | func (b *BitWriter) WriteByte(byt byte) error {
// fill up b.b with b.count bits from byt
b.b[0] |= byt >> (8 - b.count)
if n, err := b.w.Write(b.b[:]); n != 1 || err != nil {
return err
}
b.b[0] = byt << b.count
return nil
} | [
"func",
"(",
"b",
"*",
"BitWriter",
")",
"WriteByte",
"(",
"byt",
"byte",
")",
"error",
"{",
"// fill up b.b with b.count bits from byt",
"b",
".",
"b",
"[",
"0",
"]",
"|=",
"byt",
">>",
"(",
"8",
"-",
"b",
".",
"count",
")",
"\n\n",
"if",
"n",
",",
... | // WriteByte writes a single byte to the stream, regardless of alignment | [
"WriteByte",
"writes",
"a",
"single",
"byte",
"to",
"the",
"stream",
"regardless",
"of",
"alignment"
] | 3522498ce2c8ea06df73e55df58edfbfb33cfdd6 | https://github.com/dgryski/go-bitstream/blob/3522498ce2c8ea06df73e55df58edfbfb33cfdd6/bitstream.go#L91-L102 |
142,813 | dgryski/go-bitstream | bitstream.go | ReadByte | func (b *BitReader) ReadByte() (byte, error) {
if b.count == 0 {
n, err := b.r.Read(b.b[:])
if n != 1 || (err != nil && err != io.EOF) {
b.b[0] = 0
return b.b[0], err
}
// mask io.EOF for the last byte
if err == io.EOF {
err = nil
}
return b.b[0], err
}
byt := b.b[0]
var n int
var err err... | go | func (b *BitReader) ReadByte() (byte, error) {
if b.count == 0 {
n, err := b.r.Read(b.b[:])
if n != 1 || (err != nil && err != io.EOF) {
b.b[0] = 0
return b.b[0], err
}
// mask io.EOF for the last byte
if err == io.EOF {
err = nil
}
return b.b[0], err
}
byt := b.b[0]
var n int
var err err... | [
"func",
"(",
"b",
"*",
"BitReader",
")",
"ReadByte",
"(",
")",
"(",
"byte",
",",
"error",
")",
"{",
"if",
"b",
".",
"count",
"==",
"0",
"{",
"n",
",",
"err",
":=",
"b",
".",
"r",
".",
"Read",
"(",
"b",
".",
"b",
"[",
":",
"]",
")",
"\n",
... | // ReadByte reads a single byte from the stream, regardless of alignment | [
"ReadByte",
"reads",
"a",
"single",
"byte",
"from",
"the",
"stream",
"regardless",
"of",
"alignment"
] | 3522498ce2c8ea06df73e55df58edfbfb33cfdd6 | https://github.com/dgryski/go-bitstream/blob/3522498ce2c8ea06df73e55df58edfbfb33cfdd6/bitstream.go#L105-L134 |
142,814 | dgryski/go-bitstream | bitstream.go | ReadBits | func (b *BitReader) ReadBits(nbits int) (uint64, error) {
var u uint64
for nbits >= 8 {
byt, err := b.ReadByte()
if err != nil {
return 0, err
}
u = (u << 8) | uint64(byt)
nbits -= 8
}
var err error
for nbits > 0 && err != io.EOF {
byt, err := b.ReadBit()
if err != nil {
return 0, err
}
... | go | func (b *BitReader) ReadBits(nbits int) (uint64, error) {
var u uint64
for nbits >= 8 {
byt, err := b.ReadByte()
if err != nil {
return 0, err
}
u = (u << 8) | uint64(byt)
nbits -= 8
}
var err error
for nbits > 0 && err != io.EOF {
byt, err := b.ReadBit()
if err != nil {
return 0, err
}
... | [
"func",
"(",
"b",
"*",
"BitReader",
")",
"ReadBits",
"(",
"nbits",
"int",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"var",
"u",
"uint64",
"\n\n",
"for",
"nbits",
">=",
"8",
"{",
"byt",
",",
"err",
":=",
"b",
".",
"ReadByte",
"(",
")",
"\n",
"... | // ReadBits reads nbits from the stream | [
"ReadBits",
"reads",
"nbits",
"from",
"the",
"stream"
] | 3522498ce2c8ea06df73e55df58edfbfb33cfdd6 | https://github.com/dgryski/go-bitstream/blob/3522498ce2c8ea06df73e55df58edfbfb33cfdd6/bitstream.go#L137-L165 |
142,815 | dgryski/go-bitstream | bitstream.go | Flush | func (b *BitWriter) Flush(bit Bit) error {
for b.count != 8 {
err := b.WriteBit(bit)
if err != nil {
return err
}
}
return nil
} | go | func (b *BitWriter) Flush(bit Bit) error {
for b.count != 8 {
err := b.WriteBit(bit)
if err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"b",
"*",
"BitWriter",
")",
"Flush",
"(",
"bit",
"Bit",
")",
"error",
"{",
"for",
"b",
".",
"count",
"!=",
"8",
"{",
"err",
":=",
"b",
".",
"WriteBit",
"(",
"bit",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // Flush empties the currently in-process byte by filling it with 'bit'. | [
"Flush",
"empties",
"the",
"currently",
"in",
"-",
"process",
"byte",
"by",
"filling",
"it",
"with",
"bit",
"."
] | 3522498ce2c8ea06df73e55df58edfbfb33cfdd6 | https://github.com/dgryski/go-bitstream/blob/3522498ce2c8ea06df73e55df58edfbfb33cfdd6/bitstream.go#L168-L178 |
142,816 | dgryski/go-bitstream | bitstream.go | WriteBits | func (b *BitWriter) WriteBits(u uint64, nbits int) error {
u <<= (64 - uint(nbits))
for nbits >= 8 {
byt := byte(u >> 56)
err := b.WriteByte(byt)
if err != nil {
return err
}
u <<= 8
nbits -= 8
}
for nbits > 0 {
err := b.WriteBit((u >> 63) == 1)
if err != nil {
return err
}
u <<= 1
nbit... | go | func (b *BitWriter) WriteBits(u uint64, nbits int) error {
u <<= (64 - uint(nbits))
for nbits >= 8 {
byt := byte(u >> 56)
err := b.WriteByte(byt)
if err != nil {
return err
}
u <<= 8
nbits -= 8
}
for nbits > 0 {
err := b.WriteBit((u >> 63) == 1)
if err != nil {
return err
}
u <<= 1
nbit... | [
"func",
"(",
"b",
"*",
"BitWriter",
")",
"WriteBits",
"(",
"u",
"uint64",
",",
"nbits",
"int",
")",
"error",
"{",
"u",
"<<=",
"(",
"64",
"-",
"uint",
"(",
"nbits",
")",
")",
"\n",
"for",
"nbits",
">=",
"8",
"{",
"byt",
":=",
"byte",
"(",
"u",
... | // WriteBits writes the nbits least significant bits of u, most-significant-bit first. | [
"WriteBits",
"writes",
"the",
"nbits",
"least",
"significant",
"bits",
"of",
"u",
"most",
"-",
"significant",
"-",
"bit",
"first",
"."
] | 3522498ce2c8ea06df73e55df58edfbfb33cfdd6 | https://github.com/dgryski/go-bitstream/blob/3522498ce2c8ea06df73e55df58edfbfb33cfdd6/bitstream.go#L181-L203 |
142,817 | dgryski/go-bitstream | bitstream.go | Reset | func (b *BitReader) Reset(r io.Reader) {
b.r = r
b.b[0] = 0x00
b.count = 0
} | go | func (b *BitReader) Reset(r io.Reader) {
b.r = r
b.b[0] = 0x00
b.count = 0
} | [
"func",
"(",
"b",
"*",
"BitReader",
")",
"Reset",
"(",
"r",
"io",
".",
"Reader",
")",
"{",
"b",
".",
"r",
"=",
"r",
"\n",
"b",
".",
"b",
"[",
"0",
"]",
"=",
"0x00",
"\n",
"b",
".",
"count",
"=",
"0",
"\n",
"}"
] | // Reset replaces the underlying io.Reader with the provided reader and resets
// all interal state to its zero value, allowing for reuse of the BitReader
// without additional allocations | [
"Reset",
"replaces",
"the",
"underlying",
"io",
".",
"Reader",
"with",
"the",
"provided",
"reader",
"and",
"resets",
"all",
"interal",
"state",
"to",
"its",
"zero",
"value",
"allowing",
"for",
"reuse",
"of",
"the",
"BitReader",
"without",
"additional",
"alloca... | 3522498ce2c8ea06df73e55df58edfbfb33cfdd6 | https://github.com/dgryski/go-bitstream/blob/3522498ce2c8ea06df73e55df58edfbfb33cfdd6/bitstream.go#L208-L212 |
142,818 | dgryski/go-bitstream | bitstream.go | Reset | func (b *BitWriter) Reset(w io.Writer) {
b.w = w
b.b[0] = 0x00
b.count = 8
} | go | func (b *BitWriter) Reset(w io.Writer) {
b.w = w
b.b[0] = 0x00
b.count = 8
} | [
"func",
"(",
"b",
"*",
"BitWriter",
")",
"Reset",
"(",
"w",
"io",
".",
"Writer",
")",
"{",
"b",
".",
"w",
"=",
"w",
"\n",
"b",
".",
"b",
"[",
"0",
"]",
"=",
"0x00",
"\n",
"b",
".",
"count",
"=",
"8",
"\n",
"}"
] | // Reset replaces the underlying io.Writer with the provided writer and resets
// all internal state to its initial value allowing for reuse of the BitWriter
// without additional allocations | [
"Reset",
"replaces",
"the",
"underlying",
"io",
".",
"Writer",
"with",
"the",
"provided",
"writer",
"and",
"resets",
"all",
"internal",
"state",
"to",
"its",
"initial",
"value",
"allowing",
"for",
"reuse",
"of",
"the",
"BitWriter",
"without",
"additional",
"al... | 3522498ce2c8ea06df73e55df58edfbfb33cfdd6 | https://github.com/dgryski/go-bitstream/blob/3522498ce2c8ea06df73e55df58edfbfb33cfdd6/bitstream.go#L217-L221 |
142,819 | multiformats/go-multibase | base2.go | binaryEncodeToString | func binaryEncodeToString(src []byte) string {
dst := make([]byte, len(src)*8)
encodeBinary(dst, src)
return string(dst)
} | go | func binaryEncodeToString(src []byte) string {
dst := make([]byte, len(src)*8)
encodeBinary(dst, src)
return string(dst)
} | [
"func",
"binaryEncodeToString",
"(",
"src",
"[",
"]",
"byte",
")",
"string",
"{",
"dst",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"src",
")",
"*",
"8",
")",
"\n",
"encodeBinary",
"(",
"dst",
",",
"src",
")",
"\n",
"return",
"string",
... | // binaryEncodeToString takes an array of bytes and returns
// multibase binary representation | [
"binaryEncodeToString",
"takes",
"an",
"array",
"of",
"bytes",
"and",
"returns",
"multibase",
"binary",
"representation"
] | d63641945dc1749baa23686ad0564ad63fef0493 | https://github.com/multiformats/go-multibase/blob/d63641945dc1749baa23686ad0564ad63fef0493/base2.go#L11-L15 |
142,820 | multiformats/go-multibase | base2.go | encodeBinary | func encodeBinary(dst []byte, src []byte) {
for i, b := range src {
for j := 0; j < 8; j++ {
if b&(1<<uint(7-j)) == 0 {
dst[i*8+j] = '0'
} else {
dst[i*8+j] = '1'
}
}
}
} | go | func encodeBinary(dst []byte, src []byte) {
for i, b := range src {
for j := 0; j < 8; j++ {
if b&(1<<uint(7-j)) == 0 {
dst[i*8+j] = '0'
} else {
dst[i*8+j] = '1'
}
}
}
} | [
"func",
"encodeBinary",
"(",
"dst",
"[",
"]",
"byte",
",",
"src",
"[",
"]",
"byte",
")",
"{",
"for",
"i",
",",
"b",
":=",
"range",
"src",
"{",
"for",
"j",
":=",
"0",
";",
"j",
"<",
"8",
";",
"j",
"++",
"{",
"if",
"b",
"&",
"(",
"1",
"<<",... | // encodeBinary takes the src and dst bytes and converts each
// byte to their binary rep using power reduction method | [
"encodeBinary",
"takes",
"the",
"src",
"and",
"dst",
"bytes",
"and",
"converts",
"each",
"byte",
"to",
"their",
"binary",
"rep",
"using",
"power",
"reduction",
"method"
] | d63641945dc1749baa23686ad0564ad63fef0493 | https://github.com/multiformats/go-multibase/blob/d63641945dc1749baa23686ad0564ad63fef0493/base2.go#L19-L29 |
142,821 | multiformats/go-multibase | base2.go | decodeBinaryString | func decodeBinaryString(s string) ([]byte, error) {
if len(s)&7 != 0 {
// prepend the padding
s = strings.Repeat("0", 8-len(s)&7) + s
}
data := make([]byte, len(s)>>3)
for i, dstIndex := 0, 0; i < len(s); i = i + 8 {
value, err := strconv.ParseInt(s[i:i+8], 2, 0)
if err != nil {
return nil, fmt.Errorf(... | go | func decodeBinaryString(s string) ([]byte, error) {
if len(s)&7 != 0 {
// prepend the padding
s = strings.Repeat("0", 8-len(s)&7) + s
}
data := make([]byte, len(s)>>3)
for i, dstIndex := 0, 0; i < len(s); i = i + 8 {
value, err := strconv.ParseInt(s[i:i+8], 2, 0)
if err != nil {
return nil, fmt.Errorf(... | [
"func",
"decodeBinaryString",
"(",
"s",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"s",
")",
"&",
"7",
"!=",
"0",
"{",
"// prepend the padding",
"s",
"=",
"strings",
".",
"Repeat",
"(",
"\"",
"\"",
",",
"8",
"... | // decodeBinaryString takes multibase binary representation
// and returns a byte array | [
"decodeBinaryString",
"takes",
"multibase",
"binary",
"representation",
"and",
"returns",
"a",
"byte",
"array"
] | d63641945dc1749baa23686ad0564ad63fef0493 | https://github.com/multiformats/go-multibase/blob/d63641945dc1749baa23686ad0564ad63fef0493/base2.go#L33-L52 |
142,822 | libp2p/go-sockaddr | sockaddr.go | SockaddrToAny | func SockaddrToAny(sa sockaddrnet.Sockaddr) (*sockaddrnet.RawSockaddrAny, Socklen, error) {
return sockaddrToAny(sa)
} | go | func SockaddrToAny(sa sockaddrnet.Sockaddr) (*sockaddrnet.RawSockaddrAny, Socklen, error) {
return sockaddrToAny(sa)
} | [
"func",
"SockaddrToAny",
"(",
"sa",
"sockaddrnet",
".",
"Sockaddr",
")",
"(",
"*",
"sockaddrnet",
".",
"RawSockaddrAny",
",",
"Socklen",
",",
"error",
")",
"{",
"return",
"sockaddrToAny",
"(",
"sa",
")",
"\n",
"}"
] | // SockaddrToAny converts a Sockaddr into a RawSockaddrAny
// The implementation is platform dependent. | [
"SockaddrToAny",
"converts",
"a",
"Sockaddr",
"into",
"a",
"RawSockaddrAny",
"The",
"implementation",
"is",
"platform",
"dependent",
"."
] | 52957a0228cc3d7606fa619c7dde49ba1f1ebbb8 | https://github.com/libp2p/go-sockaddr/blob/52957a0228cc3d7606fa619c7dde49ba1f1ebbb8/sockaddr.go#L16-L18 |
142,823 | libp2p/go-sockaddr | net/net.go | NetAddrToSockaddr | func NetAddrToSockaddr(addr net.Addr) Sockaddr {
switch addr := addr.(type) {
case *net.IPAddr:
return IPAddrToSockaddr(addr)
case *net.TCPAddr:
return TCPAddrToSockaddr(addr)
case *net.UDPAddr:
return UDPAddrToSockaddr(addr)
case *net.UnixAddr:
sa, _ := UnixAddrToSockaddr(addr)
return sa
default:
ret... | go | func NetAddrToSockaddr(addr net.Addr) Sockaddr {
switch addr := addr.(type) {
case *net.IPAddr:
return IPAddrToSockaddr(addr)
case *net.TCPAddr:
return TCPAddrToSockaddr(addr)
case *net.UDPAddr:
return UDPAddrToSockaddr(addr)
case *net.UnixAddr:
sa, _ := UnixAddrToSockaddr(addr)
return sa
default:
ret... | [
"func",
"NetAddrToSockaddr",
"(",
"addr",
"net",
".",
"Addr",
")",
"Sockaddr",
"{",
"switch",
"addr",
":=",
"addr",
".",
"(",
"type",
")",
"{",
"case",
"*",
"net",
".",
"IPAddr",
":",
"return",
"IPAddrToSockaddr",
"(",
"addr",
")",
"\n",
"case",
"*",
... | // NetAddrToSockaddr converts a net.Addr to a Sockaddr.
// Returns nil if the input is invalid or conversion is not possible. | [
"NetAddrToSockaddr",
"converts",
"a",
"net",
".",
"Addr",
"to",
"a",
"Sockaddr",
".",
"Returns",
"nil",
"if",
"the",
"input",
"is",
"invalid",
"or",
"conversion",
"is",
"not",
"possible",
"."
] | 52957a0228cc3d7606fa619c7dde49ba1f1ebbb8 | https://github.com/libp2p/go-sockaddr/blob/52957a0228cc3d7606fa619c7dde49ba1f1ebbb8/net/net.go#L99-L113 |
142,824 | libp2p/go-sockaddr | net/net.go | IPAddrToSockaddr | func IPAddrToSockaddr(addr *net.IPAddr) Sockaddr {
return IPAndZoneToSockaddr(addr.IP, addr.Zone)
} | go | func IPAddrToSockaddr(addr *net.IPAddr) Sockaddr {
return IPAndZoneToSockaddr(addr.IP, addr.Zone)
} | [
"func",
"IPAddrToSockaddr",
"(",
"addr",
"*",
"net",
".",
"IPAddr",
")",
"Sockaddr",
"{",
"return",
"IPAndZoneToSockaddr",
"(",
"addr",
".",
"IP",
",",
"addr",
".",
"Zone",
")",
"\n",
"}"
] | // IPAddrToSockaddr converts a net.IPAddr to a Sockaddr.
// Returns nil if conversion fails. | [
"IPAddrToSockaddr",
"converts",
"a",
"net",
".",
"IPAddr",
"to",
"a",
"Sockaddr",
".",
"Returns",
"nil",
"if",
"conversion",
"fails",
"."
] | 52957a0228cc3d7606fa619c7dde49ba1f1ebbb8 | https://github.com/libp2p/go-sockaddr/blob/52957a0228cc3d7606fa619c7dde49ba1f1ebbb8/net/net.go#L145-L147 |
142,825 | libp2p/go-sockaddr | net/net.go | TCPAddrToSockaddr | func TCPAddrToSockaddr(addr *net.TCPAddr) Sockaddr {
sa := IPAndZoneToSockaddr(addr.IP, addr.Zone)
switch sa := sa.(type) {
case *SockaddrInet4:
sa.Port = addr.Port
return sa
case *SockaddrInet6:
sa.Port = addr.Port
return sa
default:
return nil
}
} | go | func TCPAddrToSockaddr(addr *net.TCPAddr) Sockaddr {
sa := IPAndZoneToSockaddr(addr.IP, addr.Zone)
switch sa := sa.(type) {
case *SockaddrInet4:
sa.Port = addr.Port
return sa
case *SockaddrInet6:
sa.Port = addr.Port
return sa
default:
return nil
}
} | [
"func",
"TCPAddrToSockaddr",
"(",
"addr",
"*",
"net",
".",
"TCPAddr",
")",
"Sockaddr",
"{",
"sa",
":=",
"IPAndZoneToSockaddr",
"(",
"addr",
".",
"IP",
",",
"addr",
".",
"Zone",
")",
"\n",
"switch",
"sa",
":=",
"sa",
".",
"(",
"type",
")",
"{",
"case"... | // TCPAddrToSockaddr converts a net.TCPAddr to a Sockaddr.
// Returns nil if conversion fails. | [
"TCPAddrToSockaddr",
"converts",
"a",
"net",
".",
"TCPAddr",
"to",
"a",
"Sockaddr",
".",
"Returns",
"nil",
"if",
"conversion",
"fails",
"."
] | 52957a0228cc3d7606fa619c7dde49ba1f1ebbb8 | https://github.com/libp2p/go-sockaddr/blob/52957a0228cc3d7606fa619c7dde49ba1f1ebbb8/net/net.go#L151-L163 |
142,826 | libp2p/go-sockaddr | net/net.go | UDPAddrToSockaddr | func UDPAddrToSockaddr(addr *net.UDPAddr) Sockaddr {
sa := IPAndZoneToSockaddr(addr.IP, addr.Zone)
switch sa := sa.(type) {
case *SockaddrInet4:
sa.Port = addr.Port
return sa
case *SockaddrInet6:
sa.Port = addr.Port
return sa
default:
return nil
}
} | go | func UDPAddrToSockaddr(addr *net.UDPAddr) Sockaddr {
sa := IPAndZoneToSockaddr(addr.IP, addr.Zone)
switch sa := sa.(type) {
case *SockaddrInet4:
sa.Port = addr.Port
return sa
case *SockaddrInet6:
sa.Port = addr.Port
return sa
default:
return nil
}
} | [
"func",
"UDPAddrToSockaddr",
"(",
"addr",
"*",
"net",
".",
"UDPAddr",
")",
"Sockaddr",
"{",
"sa",
":=",
"IPAndZoneToSockaddr",
"(",
"addr",
".",
"IP",
",",
"addr",
".",
"Zone",
")",
"\n",
"switch",
"sa",
":=",
"sa",
".",
"(",
"type",
")",
"{",
"case"... | // UDPAddrToSockaddr converts a net.UDPAddr to a Sockaddr.
// Returns nil if conversion fails. | [
"UDPAddrToSockaddr",
"converts",
"a",
"net",
".",
"UDPAddr",
"to",
"a",
"Sockaddr",
".",
"Returns",
"nil",
"if",
"conversion",
"fails",
"."
] | 52957a0228cc3d7606fa619c7dde49ba1f1ebbb8 | https://github.com/libp2p/go-sockaddr/blob/52957a0228cc3d7606fa619c7dde49ba1f1ebbb8/net/net.go#L167-L179 |
142,827 | libp2p/go-sockaddr | net/net.go | SockaddrToIPAddr | func SockaddrToIPAddr(sa Sockaddr) *net.IPAddr {
ip, zone := SockaddrToIPAndZone(sa)
switch sa.(type) {
case *SockaddrInet4:
return &net.IPAddr{IP: ip}
case *SockaddrInet6:
return &net.IPAddr{IP: ip, Zone: zone}
}
return nil
} | go | func SockaddrToIPAddr(sa Sockaddr) *net.IPAddr {
ip, zone := SockaddrToIPAndZone(sa)
switch sa.(type) {
case *SockaddrInet4:
return &net.IPAddr{IP: ip}
case *SockaddrInet6:
return &net.IPAddr{IP: ip, Zone: zone}
}
return nil
} | [
"func",
"SockaddrToIPAddr",
"(",
"sa",
"Sockaddr",
")",
"*",
"net",
".",
"IPAddr",
"{",
"ip",
",",
"zone",
":=",
"SockaddrToIPAndZone",
"(",
"sa",
")",
"\n",
"switch",
"sa",
".",
"(",
"type",
")",
"{",
"case",
"*",
"SockaddrInet4",
":",
"return",
"&",
... | // SockaddrToIPAddr converts a Sockaddr to a net.IPAddr
// Returns nil if conversion fails. | [
"SockaddrToIPAddr",
"converts",
"a",
"Sockaddr",
"to",
"a",
"net",
".",
"IPAddr",
"Returns",
"nil",
"if",
"conversion",
"fails",
"."
] | 52957a0228cc3d7606fa619c7dde49ba1f1ebbb8 | https://github.com/libp2p/go-sockaddr/blob/52957a0228cc3d7606fa619c7dde49ba1f1ebbb8/net/net.go#L221-L230 |
142,828 | libp2p/go-sockaddr | net/net.go | SockaddrToTCPAddr | func SockaddrToTCPAddr(sa Sockaddr) *net.TCPAddr {
ip, zone := SockaddrToIPAndZone(sa)
switch sa := sa.(type) {
case *SockaddrInet4:
return &net.TCPAddr{IP: ip, Port: sa.Port}
case *SockaddrInet6:
return &net.TCPAddr{IP: ip, Port: sa.Port, Zone: zone}
}
return nil
} | go | func SockaddrToTCPAddr(sa Sockaddr) *net.TCPAddr {
ip, zone := SockaddrToIPAndZone(sa)
switch sa := sa.(type) {
case *SockaddrInet4:
return &net.TCPAddr{IP: ip, Port: sa.Port}
case *SockaddrInet6:
return &net.TCPAddr{IP: ip, Port: sa.Port, Zone: zone}
}
return nil
} | [
"func",
"SockaddrToTCPAddr",
"(",
"sa",
"Sockaddr",
")",
"*",
"net",
".",
"TCPAddr",
"{",
"ip",
",",
"zone",
":=",
"SockaddrToIPAndZone",
"(",
"sa",
")",
"\n",
"switch",
"sa",
":=",
"sa",
".",
"(",
"type",
")",
"{",
"case",
"*",
"SockaddrInet4",
":",
... | // SockaddrToTCPAddr converts a Sockaddr to a net.TCPAddr
// Returns nil if conversion fails. | [
"SockaddrToTCPAddr",
"converts",
"a",
"Sockaddr",
"to",
"a",
"net",
".",
"TCPAddr",
"Returns",
"nil",
"if",
"conversion",
"fails",
"."
] | 52957a0228cc3d7606fa619c7dde49ba1f1ebbb8 | https://github.com/libp2p/go-sockaddr/blob/52957a0228cc3d7606fa619c7dde49ba1f1ebbb8/net/net.go#L234-L243 |
142,829 | libp2p/go-sockaddr | net/net.go | SockaddrToUDPAddr | func SockaddrToUDPAddr(sa Sockaddr) *net.UDPAddr {
ip, zone := SockaddrToIPAndZone(sa)
switch sa := sa.(type) {
case *SockaddrInet4:
return &net.UDPAddr{IP: ip, Port: sa.Port}
case *SockaddrInet6:
return &net.UDPAddr{IP: ip, Port: sa.Port, Zone: zone}
}
return nil
} | go | func SockaddrToUDPAddr(sa Sockaddr) *net.UDPAddr {
ip, zone := SockaddrToIPAndZone(sa)
switch sa := sa.(type) {
case *SockaddrInet4:
return &net.UDPAddr{IP: ip, Port: sa.Port}
case *SockaddrInet6:
return &net.UDPAddr{IP: ip, Port: sa.Port, Zone: zone}
}
return nil
} | [
"func",
"SockaddrToUDPAddr",
"(",
"sa",
"Sockaddr",
")",
"*",
"net",
".",
"UDPAddr",
"{",
"ip",
",",
"zone",
":=",
"SockaddrToIPAndZone",
"(",
"sa",
")",
"\n",
"switch",
"sa",
":=",
"sa",
".",
"(",
"type",
")",
"{",
"case",
"*",
"SockaddrInet4",
":",
... | // SockaddrToUDPAddr converts a Sockaddr to a net.UDPAddr
// Returns nil if conversion fails. | [
"SockaddrToUDPAddr",
"converts",
"a",
"Sockaddr",
"to",
"a",
"net",
".",
"UDPAddr",
"Returns",
"nil",
"if",
"conversion",
"fails",
"."
] | 52957a0228cc3d7606fa619c7dde49ba1f1ebbb8 | https://github.com/libp2p/go-sockaddr/blob/52957a0228cc3d7606fa619c7dde49ba1f1ebbb8/net/net.go#L247-L256 |
142,830 | lileio/pubsub | middleware/defaults/defaults.go | MiddlewareWithRecovery | func MiddlewareWithRecovery(fn recover.RecoveryHandlerFunc) []pubsub.Middleware {
return []pubsub.Middleware{
logrus.Middleware{},
prometheus.Middleware{},
opentracing.Middleware{},
audit.Middleware{},
recover.Middleware{RecoveryHandlerFunc: fn},
}
} | go | func MiddlewareWithRecovery(fn recover.RecoveryHandlerFunc) []pubsub.Middleware {
return []pubsub.Middleware{
logrus.Middleware{},
prometheus.Middleware{},
opentracing.Middleware{},
audit.Middleware{},
recover.Middleware{RecoveryHandlerFunc: fn},
}
} | [
"func",
"MiddlewareWithRecovery",
"(",
"fn",
"recover",
".",
"RecoveryHandlerFunc",
")",
"[",
"]",
"pubsub",
".",
"Middleware",
"{",
"return",
"[",
"]",
"pubsub",
".",
"Middleware",
"{",
"logrus",
".",
"Middleware",
"{",
"}",
",",
"prometheus",
".",
"Middlew... | // MiddlewareWithRecovery returns the default middleware but allows
// you to inject a function for dealing with panics | [
"MiddlewareWithRecovery",
"returns",
"the",
"default",
"middleware",
"but",
"allows",
"you",
"to",
"inject",
"a",
"function",
"for",
"dealing",
"with",
"panics"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/middleware/defaults/defaults.go#L23-L31 |
142,831 | lileio/pubsub | middleware/logrus/logrus.go | PublisherMsgInterceptor | func (o Middleware) PublisherMsgInterceptor(serviceName string, next pubsub.PublishHandler) pubsub.PublishHandler {
return func(ctx context.Context, topic string, m *pubsub.Msg) error {
start := time.Now()
err := next(ctx, topic, m)
elapsed := time.Now().Sub(start)
fields := logrus.Fields{
"component": "pu... | go | func (o Middleware) PublisherMsgInterceptor(serviceName string, next pubsub.PublishHandler) pubsub.PublishHandler {
return func(ctx context.Context, topic string, m *pubsub.Msg) error {
start := time.Now()
err := next(ctx, topic, m)
elapsed := time.Now().Sub(start)
fields := logrus.Fields{
"component": "pu... | [
"func",
"(",
"o",
"Middleware",
")",
"PublisherMsgInterceptor",
"(",
"serviceName",
"string",
",",
"next",
"pubsub",
".",
"PublishHandler",
")",
"pubsub",
".",
"PublishHandler",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"topic",
"strin... | // PublisherMsgInterceptor adds logging to the publisher | [
"PublisherMsgInterceptor",
"adds",
"logging",
"to",
"the",
"publisher"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/middleware/logrus/logrus.go#L64-L89 |
142,832 | lileio/pubsub | middleware/opentracing/opentracing.go | SubscribeInterceptor | func (o Middleware) SubscribeInterceptor(opts pubsub.HandlerOptions, next pubsub.MsgHandler) pubsub.MsgHandler {
return func(ctx context.Context, m pubsub.Msg) error {
var tracer = o.Tracer
if tracer == nil {
tracer = opentracing.GlobalTracer()
}
spanContext, err := tracer.Extract(
opentracing.TextMap,
... | go | func (o Middleware) SubscribeInterceptor(opts pubsub.HandlerOptions, next pubsub.MsgHandler) pubsub.MsgHandler {
return func(ctx context.Context, m pubsub.Msg) error {
var tracer = o.Tracer
if tracer == nil {
tracer = opentracing.GlobalTracer()
}
spanContext, err := tracer.Extract(
opentracing.TextMap,
... | [
"func",
"(",
"o",
"Middleware",
")",
"SubscribeInterceptor",
"(",
"opts",
"pubsub",
".",
"HandlerOptions",
",",
"next",
"pubsub",
".",
"MsgHandler",
")",
"pubsub",
".",
"MsgHandler",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"m",
"... | // SubscribeInterceptor returns a subscriber middleware with opentracing | [
"SubscribeInterceptor",
"returns",
"a",
"subscriber",
"middleware",
"with",
"opentracing"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/middleware/opentracing/opentracing.go#L35-L67 |
142,833 | lileio/pubsub | middleware/opentracing/opentracing.go | PublisherMsgInterceptor | func (o Middleware) PublisherMsgInterceptor(serviceName string, next pubsub.PublishHandler) pubsub.PublishHandler {
return func(ctx context.Context, topic string, m *pubsub.Msg) error {
var tracer = o.Tracer
if tracer == nil {
tracer = opentracing.GlobalTracer()
}
span := spanFromContext(ctx, tracer, topic... | go | func (o Middleware) PublisherMsgInterceptor(serviceName string, next pubsub.PublishHandler) pubsub.PublishHandler {
return func(ctx context.Context, topic string, m *pubsub.Msg) error {
var tracer = o.Tracer
if tracer == nil {
tracer = opentracing.GlobalTracer()
}
span := spanFromContext(ctx, tracer, topic... | [
"func",
"(",
"o",
"Middleware",
")",
"PublisherMsgInterceptor",
"(",
"serviceName",
"string",
",",
"next",
"pubsub",
".",
"PublishHandler",
")",
"pubsub",
".",
"PublishHandler",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"topic",
"strin... | // PublisherMsgInterceptor inserts opentracing headers into an outgoing msg | [
"PublisherMsgInterceptor",
"inserts",
"opentracing",
"headers",
"into",
"an",
"outgoing",
"msg"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/middleware/opentracing/opentracing.go#L70-L97 |
142,834 | ejholmes/cloudwatch | cloudwatch.go | NewGroup | func NewGroup(group string, client *cloudwatchlogs.CloudWatchLogs) *Group {
return &Group{
group: group,
client: client,
}
} | go | func NewGroup(group string, client *cloudwatchlogs.CloudWatchLogs) *Group {
return &Group{
group: group,
client: client,
}
} | [
"func",
"NewGroup",
"(",
"group",
"string",
",",
"client",
"*",
"cloudwatchlogs",
".",
"CloudWatchLogs",
")",
"*",
"Group",
"{",
"return",
"&",
"Group",
"{",
"group",
":",
"group",
",",
"client",
":",
"client",
",",
"}",
"\n",
"}"
] | // NewGroup returns a new Group instance. | [
"NewGroup",
"returns",
"a",
"new",
"Group",
"instance",
"."
] | c2bae568a25431c6c82170dd18361a478bd1f1b5 | https://github.com/ejholmes/cloudwatch/blob/c2bae568a25431c6c82170dd18361a478bd1f1b5/cloudwatch.go#L38-L43 |
142,835 | ejholmes/cloudwatch | cloudwatch.go | Create | func (g *Group) Create(stream string) (io.Writer, error) {
if _, err := g.client.CreateLogStream(&cloudwatchlogs.CreateLogStreamInput{
LogGroupName: &g.group,
LogStreamName: &stream,
}); err != nil {
return nil, err
}
return NewWriter(g.group, stream, g.client), nil
} | go | func (g *Group) Create(stream string) (io.Writer, error) {
if _, err := g.client.CreateLogStream(&cloudwatchlogs.CreateLogStreamInput{
LogGroupName: &g.group,
LogStreamName: &stream,
}); err != nil {
return nil, err
}
return NewWriter(g.group, stream, g.client), nil
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"Create",
"(",
"stream",
"string",
")",
"(",
"io",
".",
"Writer",
",",
"error",
")",
"{",
"if",
"_",
",",
"err",
":=",
"g",
".",
"client",
".",
"CreateLogStream",
"(",
"&",
"cloudwatchlogs",
".",
"CreateLogStreamI... | // Create creates a log stream in the group and returns an io.Writer for it. | [
"Create",
"creates",
"a",
"log",
"stream",
"in",
"the",
"group",
"and",
"returns",
"an",
"io",
".",
"Writer",
"for",
"it",
"."
] | c2bae568a25431c6c82170dd18361a478bd1f1b5 | https://github.com/ejholmes/cloudwatch/blob/c2bae568a25431c6c82170dd18361a478bd1f1b5/cloudwatch.go#L46-L55 |
142,836 | ejholmes/cloudwatch | cloudwatch.go | Open | func (g *Group) Open(stream string) (io.Reader, error) {
return NewReader(g.group, stream, g.client), nil
} | go | func (g *Group) Open(stream string) (io.Reader, error) {
return NewReader(g.group, stream, g.client), nil
} | [
"func",
"(",
"g",
"*",
"Group",
")",
"Open",
"(",
"stream",
"string",
")",
"(",
"io",
".",
"Reader",
",",
"error",
")",
"{",
"return",
"NewReader",
"(",
"g",
".",
"group",
",",
"stream",
",",
"g",
".",
"client",
")",
",",
"nil",
"\n",
"}"
] | // Open returns an io.Reader to read from the log stream. | [
"Open",
"returns",
"an",
"io",
".",
"Reader",
"to",
"read",
"from",
"the",
"log",
"stream",
"."
] | c2bae568a25431c6c82170dd18361a478bd1f1b5 | https://github.com/ejholmes/cloudwatch/blob/c2bae568a25431c6c82170dd18361a478bd1f1b5/cloudwatch.go#L58-L60 |
142,837 | ejholmes/cloudwatch | writer.go | Write | func (w *Writer) Write(b []byte) (int, error) {
if w.closed {
return 0, io.ErrClosedPipe
}
if w.err != nil {
return 0, w.err
}
return w.buffer(b)
} | go | func (w *Writer) Write(b []byte) (int, error) {
if w.closed {
return 0, io.ErrClosedPipe
}
if w.err != nil {
return 0, w.err
}
return w.buffer(b)
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Write",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"w",
".",
"closed",
"{",
"return",
"0",
",",
"io",
".",
"ErrClosedPipe",
"\n",
"}",
"\n\n",
"if",
"w",
".",
"err",
"!=",... | // Write takes b, and creates cloudwatch log events for each individual line.
// If Flush returns an error, subsequent calls to Write will fail. | [
"Write",
"takes",
"b",
"and",
"creates",
"cloudwatch",
"log",
"events",
"for",
"each",
"individual",
"line",
".",
"If",
"Flush",
"returns",
"an",
"error",
"subsequent",
"calls",
"to",
"Write",
"will",
"fail",
"."
] | c2bae568a25431c6c82170dd18361a478bd1f1b5 | https://github.com/ejholmes/cloudwatch/blob/c2bae568a25431c6c82170dd18361a478bd1f1b5/writer.go#L53-L63 |
142,838 | ejholmes/cloudwatch | writer.go | start | func (w *Writer) start() error {
for {
// Exit if the stream is closed.
if w.closed {
return nil
}
<-w.throttle
if err := w.Flush(); err != nil {
return err
}
}
} | go | func (w *Writer) start() error {
for {
// Exit if the stream is closed.
if w.closed {
return nil
}
<-w.throttle
if err := w.Flush(); err != nil {
return err
}
}
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"start",
"(",
")",
"error",
"{",
"for",
"{",
"// Exit if the stream is closed.",
"if",
"w",
".",
"closed",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"<-",
"w",
".",
"throttle",
"\n",
"if",
"err",
":=",
"w",
".",
... | // starts continously flushing the buffered events. | [
"starts",
"continously",
"flushing",
"the",
"buffered",
"events",
"."
] | c2bae568a25431c6c82170dd18361a478bd1f1b5 | https://github.com/ejholmes/cloudwatch/blob/c2bae568a25431c6c82170dd18361a478bd1f1b5/writer.go#L66-L78 |
142,839 | ejholmes/cloudwatch | writer.go | Flush | func (w *Writer) Flush() error {
w.Lock()
defer w.Unlock()
events := w.events.drain()
// No events to flush.
if len(events) == 0 {
return nil
}
w.err = w.flush(events)
return w.err
} | go | func (w *Writer) Flush() error {
w.Lock()
defer w.Unlock()
events := w.events.drain()
// No events to flush.
if len(events) == 0 {
return nil
}
w.err = w.flush(events)
return w.err
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Flush",
"(",
")",
"error",
"{",
"w",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"Unlock",
"(",
")",
"\n\n",
"events",
":=",
"w",
".",
"events",
".",
"drain",
"(",
")",
"\n\n",
"// No events to flush.",
... | // Flush flushes the events that are currently buffered. | [
"Flush",
"flushes",
"the",
"events",
"that",
"are",
"currently",
"buffered",
"."
] | c2bae568a25431c6c82170dd18361a478bd1f1b5 | https://github.com/ejholmes/cloudwatch/blob/c2bae568a25431c6c82170dd18361a478bd1f1b5/writer.go#L88-L101 |
142,840 | ejholmes/cloudwatch | writer.go | flush | func (w *Writer) flush(events []*cloudwatchlogs.InputLogEvent) error {
resp, err := w.client.PutLogEvents(&cloudwatchlogs.PutLogEventsInput{
LogEvents: events,
LogGroupName: w.group,
LogStreamName: w.stream,
SequenceToken: w.sequenceToken,
})
if err != nil {
return err
}
if resp.RejectedLogEventsIn... | go | func (w *Writer) flush(events []*cloudwatchlogs.InputLogEvent) error {
resp, err := w.client.PutLogEvents(&cloudwatchlogs.PutLogEventsInput{
LogEvents: events,
LogGroupName: w.group,
LogStreamName: w.stream,
SequenceToken: w.sequenceToken,
})
if err != nil {
return err
}
if resp.RejectedLogEventsIn... | [
"func",
"(",
"w",
"*",
"Writer",
")",
"flush",
"(",
"events",
"[",
"]",
"*",
"cloudwatchlogs",
".",
"InputLogEvent",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"w",
".",
"client",
".",
"PutLogEvents",
"(",
"&",
"cloudwatchlogs",
".",
"PutLogEventsInput... | // flush flashes a slice of log events. This method should be called
// sequentially to ensure that the sequence token is updated properly. | [
"flush",
"flashes",
"a",
"slice",
"of",
"log",
"events",
".",
"This",
"method",
"should",
"be",
"called",
"sequentially",
"to",
"ensure",
"that",
"the",
"sequence",
"token",
"is",
"updated",
"properly",
"."
] | c2bae568a25431c6c82170dd18361a478bd1f1b5 | https://github.com/ejholmes/cloudwatch/blob/c2bae568a25431c6c82170dd18361a478bd1f1b5/writer.go#L105-L124 |
142,841 | ejholmes/cloudwatch | writer.go | buffer | func (w *Writer) buffer(b []byte) (int, error) {
r := bufio.NewReader(bytes.NewReader(b))
var (
n int
eof bool
)
for !eof {
b, err := r.ReadBytes('\n')
if err != nil {
if err == io.EOF {
eof = true
} else {
break
}
}
if len(b) == 0 {
continue
}
w.events.add(&cloudwatchlogs.... | go | func (w *Writer) buffer(b []byte) (int, error) {
r := bufio.NewReader(bytes.NewReader(b))
var (
n int
eof bool
)
for !eof {
b, err := r.ReadBytes('\n')
if err != nil {
if err == io.EOF {
eof = true
} else {
break
}
}
if len(b) == 0 {
continue
}
w.events.add(&cloudwatchlogs.... | [
"func",
"(",
"w",
"*",
"Writer",
")",
"buffer",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"r",
":=",
"bufio",
".",
"NewReader",
"(",
"bytes",
".",
"NewReader",
"(",
"b",
")",
")",
"\n\n",
"var",
"(",
"n",
"int",
"\n... | // buffer splits up b into individual log events and inserts them into the
// buffer. | [
"buffer",
"splits",
"up",
"b",
"into",
"individual",
"log",
"events",
"and",
"inserts",
"them",
"into",
"the",
"buffer",
"."
] | c2bae568a25431c6c82170dd18361a478bd1f1b5 | https://github.com/ejholmes/cloudwatch/blob/c2bae568a25431c6c82170dd18361a478bd1f1b5/writer.go#L128-L159 |
142,842 | lileio/pubsub | kafka/kafka.go | Publish | func (p *Provider) Publish(ctx context.Context, topic string, m *pubsub.Msg) error {
w, err := p.writerForTopic(ctx, topic)
if err != nil {
return err
}
u1, err := uuid.NewV1()
if err != nil {
return err
}
return w.WriteMessages(ctx, kafka.Message{
Key: u1.Bytes(),
Value: m.Data,
})
} | go | func (p *Provider) Publish(ctx context.Context, topic string, m *pubsub.Msg) error {
w, err := p.writerForTopic(ctx, topic)
if err != nil {
return err
}
u1, err := uuid.NewV1()
if err != nil {
return err
}
return w.WriteMessages(ctx, kafka.Message{
Key: u1.Bytes(),
Value: m.Data,
})
} | [
"func",
"(",
"p",
"*",
"Provider",
")",
"Publish",
"(",
"ctx",
"context",
".",
"Context",
",",
"topic",
"string",
",",
"m",
"*",
"pubsub",
".",
"Msg",
")",
"error",
"{",
"w",
",",
"err",
":=",
"p",
".",
"writerForTopic",
"(",
"ctx",
",",
"topic",
... | // Publish publishes a message to Kafka with a uuid as the key | [
"Publish",
"publishes",
"a",
"message",
"to",
"Kafka",
"with",
"a",
"uuid",
"as",
"the",
"key"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/kafka/kafka.go#L37-L52 |
142,843 | lileio/pubsub | noop.go | Publish | func (np NoopProvider) Publish(ctx context.Context, topic string, m *Msg) error {
return nil
} | go | func (np NoopProvider) Publish(ctx context.Context, topic string, m *Msg) error {
return nil
} | [
"func",
"(",
"np",
"NoopProvider",
")",
"Publish",
"(",
"ctx",
"context",
".",
"Context",
",",
"topic",
"string",
",",
"m",
"*",
"Msg",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // Publish does nothing | [
"Publish",
"does",
"nothing"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/noop.go#L11-L13 |
142,844 | lileio/pubsub | middleware/pubsubzap/zap.go | DefaultLogger | func DefaultLogger() *zap.Logger {
config := zap.NewDevelopmentConfig()
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
logger, _ := config.Build()
return logger
} | go | func DefaultLogger() *zap.Logger {
config := zap.NewDevelopmentConfig()
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
logger, _ := config.Build()
return logger
} | [
"func",
"DefaultLogger",
"(",
")",
"*",
"zap",
".",
"Logger",
"{",
"config",
":=",
"zap",
".",
"NewDevelopmentConfig",
"(",
")",
"\n",
"config",
".",
"EncoderConfig",
".",
"EncodeLevel",
"=",
"zapcore",
".",
"CapitalColorLevelEncoder",
"\n",
"logger",
",",
"... | // DefaultLogger creates the default, minimal setup if a no logger is passed
// to the middleware when setup | [
"DefaultLogger",
"creates",
"the",
"default",
"minimal",
"setup",
"if",
"a",
"no",
"logger",
"is",
"passed",
"to",
"the",
"middleware",
"when",
"setup"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/middleware/pubsubzap/zap.go#L16-L21 |
142,845 | lileio/pubsub | middleware/audit/audit.go | SubscribeInterceptor | func (o Middleware) SubscribeInterceptor(opts pubsub.HandlerOptions, next pubsub.MsgHandler) pubsub.MsgHandler {
return func(ctx context.Context, m pubsub.Msg) error {
ctx = context.WithValue(ctx, "x-audit-user", m.Metadata["x-audit-user"])
ctx = metadata.NewIncomingContext(ctx, metadata.New(m.Metadata))
return ... | go | func (o Middleware) SubscribeInterceptor(opts pubsub.HandlerOptions, next pubsub.MsgHandler) pubsub.MsgHandler {
return func(ctx context.Context, m pubsub.Msg) error {
ctx = context.WithValue(ctx, "x-audit-user", m.Metadata["x-audit-user"])
ctx = metadata.NewIncomingContext(ctx, metadata.New(m.Metadata))
return ... | [
"func",
"(",
"o",
"Middleware",
")",
"SubscribeInterceptor",
"(",
"opts",
"pubsub",
".",
"HandlerOptions",
",",
"next",
"pubsub",
".",
"MsgHandler",
")",
"pubsub",
".",
"MsgHandler",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"m",
"... | // SubscribeInterceptor returns a subscriber middleware with context of an audit user | [
"SubscribeInterceptor",
"returns",
"a",
"subscriber",
"middleware",
"with",
"context",
"of",
"an",
"audit",
"user"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/middleware/audit/audit.go#L14-L20 |
142,846 | lileio/pubsub | middleware/audit/audit.go | PublisherMsgInterceptor | func (o Middleware) PublisherMsgInterceptor(serviceName string, next pubsub.PublishHandler) pubsub.PublishHandler {
return func(ctx context.Context, topic string, m *pubsub.Msg) error {
var user string
audit, ok := ctx.Value("x-audit-user").(string)
if ok && audit != "" {
user = audit
}
md, ok := metadat... | go | func (o Middleware) PublisherMsgInterceptor(serviceName string, next pubsub.PublishHandler) pubsub.PublishHandler {
return func(ctx context.Context, topic string, m *pubsub.Msg) error {
var user string
audit, ok := ctx.Value("x-audit-user").(string)
if ok && audit != "" {
user = audit
}
md, ok := metadat... | [
"func",
"(",
"o",
"Middleware",
")",
"PublisherMsgInterceptor",
"(",
"serviceName",
"string",
",",
"next",
"pubsub",
".",
"PublishHandler",
")",
"pubsub",
".",
"PublishHandler",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"topic",
"strin... | // PublisherMsgInterceptor inserts audit user into pubsub metadata | [
"PublisherMsgInterceptor",
"inserts",
"audit",
"user",
"into",
"pubsub",
"metadata"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/middleware/audit/audit.go#L23-L41 |
142,847 | lileio/pubsub | publish.go | Publish | func (c *Client) Publish(ctx context.Context, topic string, msg interface{}, isJSON bool) error {
var b []byte
var err error
if isJSON {
b, err = json.Marshal(msg)
} else {
b, err = proto.Marshal(msg.(proto.Message))
}
if err != nil {
return err
}
m := &Msg{Data: b}
mw := chainPublisherMiddleware(c.Mi... | go | func (c *Client) Publish(ctx context.Context, topic string, msg interface{}, isJSON bool) error {
var b []byte
var err error
if isJSON {
b, err = json.Marshal(msg)
} else {
b, err = proto.Marshal(msg.(proto.Message))
}
if err != nil {
return err
}
m := &Msg{Data: b}
mw := chainPublisherMiddleware(c.Mi... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Publish",
"(",
"ctx",
"context",
".",
"Context",
",",
"topic",
"string",
",",
"msg",
"interface",
"{",
"}",
",",
"isJSON",
"bool",
")",
"error",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n",
"var",
"err",
"error",
... | // Publish published on the client | [
"Publish",
"published",
"on",
"the",
"client"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/publish.go#L11-L30 |
142,848 | lileio/pubsub | google/google.go | NewGoogleCloud | func NewGoogleCloud(projectID string) (*GoogleCloud, error) {
c, err := pubsub.NewClient(context.Background(), projectID)
if err != nil {
return nil, err
}
return &GoogleCloud{
client: c,
topics: map[string]*pubsub.Topic{},
subs: map[string]context.CancelFunc{},
}, nil
} | go | func NewGoogleCloud(projectID string) (*GoogleCloud, error) {
c, err := pubsub.NewClient(context.Background(), projectID)
if err != nil {
return nil, err
}
return &GoogleCloud{
client: c,
topics: map[string]*pubsub.Topic{},
subs: map[string]context.CancelFunc{},
}, nil
} | [
"func",
"NewGoogleCloud",
"(",
"projectID",
"string",
")",
"(",
"*",
"GoogleCloud",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"pubsub",
".",
"NewClient",
"(",
"context",
".",
"Background",
"(",
")",
",",
"projectID",
")",
"\n",
"if",
"err",
"!=",
... | // NewGoogleCloud creates a new GoogleCloud instace for a project | [
"NewGoogleCloud",
"creates",
"a",
"new",
"GoogleCloud",
"instace",
"for",
"a",
"project"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/google/google.go#L31-L42 |
142,849 | lileio/pubsub | google/google.go | Publish | func (g *GoogleCloud) Publish(ctx context.Context, topic string, m *ps.Msg) error {
t, err := g.getTopic(topic)
if err != nil {
return err
}
logr.WithCtx(ctx).Debug("Google Pubsub: Publishing")
res := t.Publish(context.Background(), &pubsub.Message{
Data: m.Data,
Attributes: m.Metadata,
})
_, err =... | go | func (g *GoogleCloud) Publish(ctx context.Context, topic string, m *ps.Msg) error {
t, err := g.getTopic(topic)
if err != nil {
return err
}
logr.WithCtx(ctx).Debug("Google Pubsub: Publishing")
res := t.Publish(context.Background(), &pubsub.Message{
Data: m.Data,
Attributes: m.Metadata,
})
_, err =... | [
"func",
"(",
"g",
"*",
"GoogleCloud",
")",
"Publish",
"(",
"ctx",
"context",
".",
"Context",
",",
"topic",
"string",
",",
"m",
"*",
"ps",
".",
"Msg",
")",
"error",
"{",
"t",
",",
"err",
":=",
"g",
".",
"getTopic",
"(",
"topic",
")",
"\n",
"if",
... | // Publish implements Publish | [
"Publish",
"implements",
"Publish"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/google/google.go#L45-L65 |
142,850 | lileio/pubsub | google/google.go | Shutdown | func (g *GoogleCloud) Shutdown() {
g.shutdown = true
var wg sync.WaitGroup
for k, v := range g.subs {
wg.Add(1)
logrus.Infof("Shutting down sub for %s", k)
go func(c context.CancelFunc) {
c()
wg.Done()
}(v)
}
wg.Wait()
return
} | go | func (g *GoogleCloud) Shutdown() {
g.shutdown = true
var wg sync.WaitGroup
for k, v := range g.subs {
wg.Add(1)
logrus.Infof("Shutting down sub for %s", k)
go func(c context.CancelFunc) {
c()
wg.Done()
}(v)
}
wg.Wait()
return
} | [
"func",
"(",
"g",
"*",
"GoogleCloud",
")",
"Shutdown",
"(",
")",
"{",
"g",
".",
"shutdown",
"=",
"true",
"\n\n",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"g",
".",
"subs",
"{",
"wg",
".",
"Add",
"(",
"1"... | // Shutdown shuts down all subscribers gracefully | [
"Shutdown",
"shuts",
"down",
"all",
"subscribers",
"gracefully"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/google/google.go#L73-L87 |
142,851 | lileio/pubsub | middleware/recover/recover.go | PublisherMsgInterceptor | func (o Middleware) PublisherMsgInterceptor(serviceName string, next pubsub.PublishHandler) pubsub.PublishHandler {
return func(ctx context.Context, topic string, m *pubsub.Msg) (err error) {
defer func() {
if r := recover(); r != nil {
err = recoverFrom(r, "pubsub: publish error", o.RecoveryHandlerFunc)
}... | go | func (o Middleware) PublisherMsgInterceptor(serviceName string, next pubsub.PublishHandler) pubsub.PublishHandler {
return func(ctx context.Context, topic string, m *pubsub.Msg) (err error) {
defer func() {
if r := recover(); r != nil {
err = recoverFrom(r, "pubsub: publish error", o.RecoveryHandlerFunc)
}... | [
"func",
"(",
"o",
"Middleware",
")",
"PublisherMsgInterceptor",
"(",
"serviceName",
"string",
",",
"next",
"pubsub",
".",
"PublishHandler",
")",
"pubsub",
".",
"PublishHandler",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"topic",
"strin... | // PublisherMsgInterceptor adds recovery to the publisher | [
"PublisherMsgInterceptor",
"adds",
"recovery",
"to",
"the",
"publisher"
] | 74fcc131056faa31364bcdc6c208effd13133fad | https://github.com/lileio/pubsub/blob/74fcc131056faa31364bcdc6c208effd13133fad/middleware/recover/recover.go#L32-L42 |
142,852 | multiplay/go-ts3 | notification.go | RegisterChannel | func (c *Client) RegisterChannel(id uint) error {
_, err := c.ExecCmd(NewCmd("servernotifyregister").WithArgs(
NewArg("event", ChannelEvents),
NewArg("id", id),
))
return err
} | go | func (c *Client) RegisterChannel(id uint) error {
_, err := c.ExecCmd(NewCmd("servernotifyregister").WithArgs(
NewArg("event", ChannelEvents),
NewArg("id", id),
))
return err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"RegisterChannel",
"(",
"id",
"uint",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
"\"",
")",
".",
"WithArgs",
"(",
"NewArg",
"(",
"\"",
"\"",
",",
"ChannelEvents",
... | // RegisterChannel registers for channel event notifications.
//
// It's not possible to subscribe to multiple channels.
// To receive events for all channels the id can be set to 0. | [
"RegisterChannel",
"registers",
"for",
"channel",
"event",
"notifications",
".",
"It",
"s",
"not",
"possible",
"to",
"subscribe",
"to",
"multiple",
"channels",
".",
"To",
"receive",
"events",
"for",
"all",
"channels",
"the",
"id",
"can",
"be",
"set",
"to",
"... | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/notification.go#L74-L80 |
142,853 | multiplay/go-ts3 | basic_cmds.go | Login | func (c *Client) Login(user, passwd string) error {
_, err := c.ExecCmd(NewCmd("login").WithArgs(
NewArg("client_login_name", user),
NewArg("client_login_password", passwd)),
)
return err
} | go | func (c *Client) Login(user, passwd string) error {
_, err := c.ExecCmd(NewCmd("login").WithArgs(
NewArg("client_login_name", user),
NewArg("client_login_password", passwd)),
)
return err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Login",
"(",
"user",
",",
"passwd",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
"\"",
")",
".",
"WithArgs",
"(",
"NewArg",
"(",
"\"",
"\"",
",",
"user... | // Login authenticates with the server. | [
"Login",
"authenticates",
"with",
"the",
"server",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/basic_cmds.go#L4-L10 |
142,854 | multiplay/go-ts3 | basic_cmds.go | Version | func (c *Client) Version() (*Version, error) {
v := &Version{}
if _, err := c.ExecCmd(NewCmd("version").WithResponse(v)); err != nil {
return nil, err
}
return v, nil
} | go | func (c *Client) Version() (*Version, error) {
v := &Version{}
if _, err := c.ExecCmd(NewCmd("version").WithResponse(v)); err != nil {
return nil, err
}
return v, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Version",
"(",
")",
"(",
"*",
"Version",
",",
"error",
")",
"{",
"v",
":=",
"&",
"Version",
"{",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"c",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
"\"",
")",
".",
"... | // Version returns version information. | [
"Version",
"returns",
"version",
"information",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/basic_cmds.go#L26-L33 |
142,855 | multiplay/go-ts3 | basic_cmds.go | Use | func (c *Client) Use(id int) error {
_, err := c.ExecCmd(NewCmd("use").WithArgs(NewArg("sid", id)))
return err
} | go | func (c *Client) Use(id int) error {
_, err := c.ExecCmd(NewCmd("use").WithArgs(NewArg("sid", id)))
return err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Use",
"(",
"id",
"int",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
"\"",
")",
".",
"WithArgs",
"(",
"NewArg",
"(",
"\"",
"\"",
",",
"id",
")",
")",
")",
"\... | // Use selects a virtual server by id. | [
"Use",
"selects",
"a",
"virtual",
"server",
"by",
"id",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/basic_cmds.go#L36-L39 |
142,856 | multiplay/go-ts3 | basic_cmds.go | UsePort | func (c *Client) UsePort(port int) error {
_, err := c.ExecCmd(NewCmd("use").WithArgs(NewArg("port", port)))
return err
} | go | func (c *Client) UsePort(port int) error {
_, err := c.ExecCmd(NewCmd("use").WithArgs(NewArg("port", port)))
return err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UsePort",
"(",
"port",
"int",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
"\"",
")",
".",
"WithArgs",
"(",
"NewArg",
"(",
"\"",
"\"",
",",
"port",
")",
")",
"... | // UsePort selects a virtual server by port. | [
"UsePort",
"selects",
"a",
"virtual",
"server",
"by",
"port",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/basic_cmds.go#L42-L45 |
142,857 | multiplay/go-ts3 | basic_cmds.go | Whoami | func (c *Client) Whoami() (*ConnectionInfo, error) {
i := &ConnectionInfo{}
if _, err := c.ExecCmd(NewCmd("whoami").WithResponse(&i)); err != nil {
return nil, err
}
return i, nil
} | go | func (c *Client) Whoami() (*ConnectionInfo, error) {
i := &ConnectionInfo{}
if _, err := c.ExecCmd(NewCmd("whoami").WithResponse(&i)); err != nil {
return nil, err
}
return i, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Whoami",
"(",
")",
"(",
"*",
"ConnectionInfo",
",",
"error",
")",
"{",
"i",
":=",
"&",
"ConnectionInfo",
"{",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"c",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
"\"",
")... | // Whoami returns information about the current connection including the currently selected virtual server. | [
"Whoami",
"returns",
"information",
"about",
"the",
"current",
"connection",
"including",
"the",
"currently",
"selected",
"virtual",
"server",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/basic_cmds.go#L63-L70 |
142,858 | multiplay/go-ts3 | basic_cmds.go | ClientUpdate | func (c *Client) ClientUpdate(properties ...CmdArg) error {
_, err := c.ExecCmd(NewCmd("clientupdate").WithArgs(properties...))
return err
} | go | func (c *Client) ClientUpdate(properties ...CmdArg) error {
_, err := c.ExecCmd(NewCmd("clientupdate").WithArgs(properties...))
return err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ClientUpdate",
"(",
"properties",
"...",
"CmdArg",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
"\"",
")",
".",
"WithArgs",
"(",
"properties",
"...",
")",
")",
"\n",... | // ClientUpdate changes properties of the client to a given value. | [
"ClientUpdate",
"changes",
"properties",
"of",
"the",
"client",
"to",
"a",
"given",
"value",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/basic_cmds.go#L82-L85 |
142,859 | multiplay/go-ts3 | basic_cmds.go | SetNick | func (c *Client) SetNick(nick string) error {
return c.ClientUpdate(NewArg(ClientNickname, nick))
} | go | func (c *Client) SetNick(nick string) error {
return c.ClientUpdate(NewArg(ClientNickname, nick))
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetNick",
"(",
"nick",
"string",
")",
"error",
"{",
"return",
"c",
".",
"ClientUpdate",
"(",
"NewArg",
"(",
"ClientNickname",
",",
"nick",
")",
")",
"\n",
"}"
] | // SetNick sets the clients nickname. | [
"SetNick",
"sets",
"the",
"clients",
"nickname",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/basic_cmds.go#L88-L90 |
142,860 | multiplay/go-ts3 | basic_cmds.go | SetTalker | func (c *Client) SetTalker(val bool) error {
return c.ClientUpdate(NewArg(ClientIsTalker, val))
} | go | func (c *Client) SetTalker(val bool) error {
return c.ClientUpdate(NewArg(ClientIsTalker, val))
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetTalker",
"(",
"val",
"bool",
")",
"error",
"{",
"return",
"c",
".",
"ClientUpdate",
"(",
"NewArg",
"(",
"ClientIsTalker",
",",
"val",
")",
")",
"\n",
"}"
] | // SetTalker sets whether the client is able to talk. | [
"SetTalker",
"sets",
"whether",
"the",
"client",
"is",
"able",
"to",
"talk",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/basic_cmds.go#L93-L95 |
142,861 | multiplay/go-ts3 | basic_cmds.go | SetDescription | func (c *Client) SetDescription(description string) error {
return c.ClientUpdate(NewArg(ClientDescription, description))
} | go | func (c *Client) SetDescription(description string) error {
return c.ClientUpdate(NewArg(ClientDescription, description))
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetDescription",
"(",
"description",
"string",
")",
"error",
"{",
"return",
"c",
".",
"ClientUpdate",
"(",
"NewArg",
"(",
"ClientDescription",
",",
"description",
")",
")",
"\n",
"}"
] | // SetDescription sets the clients description. | [
"SetDescription",
"sets",
"the",
"clients",
"description",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/basic_cmds.go#L98-L100 |
142,862 | multiplay/go-ts3 | basic_cmds.go | SetChannelCommander | func (c *Client) SetChannelCommander(val bool) error {
return c.ClientUpdate(NewArg(ClientIsChannelCommander, val))
} | go | func (c *Client) SetChannelCommander(val bool) error {
return c.ClientUpdate(NewArg(ClientIsChannelCommander, val))
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetChannelCommander",
"(",
"val",
"bool",
")",
"error",
"{",
"return",
"c",
".",
"ClientUpdate",
"(",
"NewArg",
"(",
"ClientIsChannelCommander",
",",
"val",
")",
")",
"\n",
"}"
] | // SetChannelCommander sets whether the client is a channel commander. | [
"SetChannelCommander",
"sets",
"whether",
"the",
"client",
"is",
"a",
"channel",
"commander",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/basic_cmds.go#L103-L105 |
142,863 | multiplay/go-ts3 | basic_cmds.go | SetIcon | func (c *Client) SetIcon(id int) error {
return c.ClientUpdate(NewArg(ClientIconID, id))
} | go | func (c *Client) SetIcon(id int) error {
return c.ClientUpdate(NewArg(ClientIconID, id))
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetIcon",
"(",
"id",
"int",
")",
"error",
"{",
"return",
"c",
".",
"ClientUpdate",
"(",
"NewArg",
"(",
"ClientIconID",
",",
"id",
")",
")",
"\n",
"}"
] | // SetIcon sets the clients icon based on the CRC32 checksum. | [
"SetIcon",
"sets",
"the",
"clients",
"icon",
"based",
"on",
"the",
"CRC32",
"checksum",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/basic_cmds.go#L108-L110 |
142,864 | multiplay/go-ts3 | server_cmds.go | List | func (s *ServerMethods) List(options ...string) (servers []*Server, err error) {
var extended bool
for i, o := range options {
if o == ExtendedServerList {
options = append(options[:i], options[i+1:]...)
extended = true
}
}
if _, err = s.ExecCmd(NewCmd("serverlist").WithOptions(options...).WithResponse(&... | go | func (s *ServerMethods) List(options ...string) (servers []*Server, err error) {
var extended bool
for i, o := range options {
if o == ExtendedServerList {
options = append(options[:i], options[i+1:]...)
extended = true
}
}
if _, err = s.ExecCmd(NewCmd("serverlist").WithOptions(options...).WithResponse(&... | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"List",
"(",
"options",
"...",
"string",
")",
"(",
"servers",
"[",
"]",
"*",
"Server",
",",
"err",
"error",
")",
"{",
"var",
"extended",
"bool",
"\n",
"for",
"i",
",",
"o",
":=",
"range",
"options",
"{",... | // List lists virtual servers.
// In addition to the options supported by the Teamspeak 3 query protocol it also supports the ExtendedServerList option.
// If ExtendedServerList is specified in options then each server returned contain extended server information as returned by Info. | [
"List",
"lists",
"virtual",
"servers",
".",
"In",
"addition",
"to",
"the",
"options",
"supported",
"by",
"the",
"Teamspeak",
"3",
"query",
"protocol",
"it",
"also",
"supports",
"the",
"ExtendedServerList",
"option",
".",
"If",
"ExtendedServerList",
"is",
"specif... | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L134-L176 |
142,865 | multiplay/go-ts3 | server_cmds.go | IDGetByPort | func (s *ServerMethods) IDGetByPort(port uint16) (int, error) {
r := struct {
ID int `ms:"server_id"`
}{}
_, err := s.ExecCmd(NewCmd("serveridgetbyport").WithArgs(NewArg("virtualserver_port", port)).WithResponse(&r))
return r.ID, err
} | go | func (s *ServerMethods) IDGetByPort(port uint16) (int, error) {
r := struct {
ID int `ms:"server_id"`
}{}
_, err := s.ExecCmd(NewCmd("serveridgetbyport").WithArgs(NewArg("virtualserver_port", port)).WithResponse(&r))
return r.ID, err
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"IDGetByPort",
"(",
"port",
"uint16",
")",
"(",
"int",
",",
"error",
")",
"{",
"r",
":=",
"struct",
"{",
"ID",
"int",
"`ms:\"server_id\"`",
"\n",
"}",
"{",
"}",
"\n",
"_",
",",
"err",
":=",
"s",
".",
"... | // IDGetByPort returns the database id of the virtual server running on UDP port. | [
"IDGetByPort",
"returns",
"the",
"database",
"id",
"of",
"the",
"virtual",
"server",
"running",
"on",
"UDP",
"port",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L179-L185 |
142,866 | multiplay/go-ts3 | server_cmds.go | Info | func (s *ServerMethods) Info() (*Server, error) {
r := &Server{}
if _, err := s.ExecCmd(NewCmd("serverinfo").WithResponse(&r)); err != nil {
return nil, err
}
return r, nil
} | go | func (s *ServerMethods) Info() (*Server, error) {
r := &Server{}
if _, err := s.ExecCmd(NewCmd("serverinfo").WithResponse(&r)); err != nil {
return nil, err
}
return r, nil
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"Info",
"(",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"r",
":=",
"&",
"Server",
"{",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"s",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
"\"",
")",
".",
... | // Info returns detailed configuration information about the selected server. | [
"Info",
"returns",
"detailed",
"configuration",
"information",
"about",
"the",
"selected",
"server",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L188-L195 |
142,867 | multiplay/go-ts3 | server_cmds.go | InstanceInfo | func (s *ServerMethods) InstanceInfo() (*Instance, error) {
r := &Instance{}
if _, err := s.ExecCmd(NewCmd("instanceinfo").WithResponse(&r)); err != nil {
return nil, err
}
return r, nil
} | go | func (s *ServerMethods) InstanceInfo() (*Instance, error) {
r := &Instance{}
if _, err := s.ExecCmd(NewCmd("instanceinfo").WithResponse(&r)); err != nil {
return nil, err
}
return r, nil
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"InstanceInfo",
"(",
")",
"(",
"*",
"Instance",
",",
"error",
")",
"{",
"r",
":=",
"&",
"Instance",
"{",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"s",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
"\"",
"... | // InstanceInfo returns detailed information about the selected instance. | [
"InstanceInfo",
"returns",
"detailed",
"information",
"about",
"the",
"selected",
"instance",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L198-L205 |
142,868 | multiplay/go-ts3 | server_cmds.go | ServerConnectionInfo | func (s *ServerMethods) ServerConnectionInfo() (*ServerConnectionInfo, error) {
r := &ServerConnectionInfo{}
if _, err := s.ExecCmd(NewCmd("serverrequestconnectioninfo").WithResponse(&r)); err != nil {
return nil, err
}
return r, nil
} | go | func (s *ServerMethods) ServerConnectionInfo() (*ServerConnectionInfo, error) {
r := &ServerConnectionInfo{}
if _, err := s.ExecCmd(NewCmd("serverrequestconnectioninfo").WithResponse(&r)); err != nil {
return nil, err
}
return r, nil
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"ServerConnectionInfo",
"(",
")",
"(",
"*",
"ServerConnectionInfo",
",",
"error",
")",
"{",
"r",
":=",
"&",
"ServerConnectionInfo",
"{",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"s",
".",
"ExecCmd",
"(",
"New... | // ServerConnectionInfo returns detailed bandwidth and transfer information about the selected instance. | [
"ServerConnectionInfo",
"returns",
"detailed",
"bandwidth",
"and",
"transfer",
"information",
"about",
"the",
"selected",
"instance",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L208-L216 |
142,869 | multiplay/go-ts3 | server_cmds.go | Edit | func (s *ServerMethods) Edit(args ...CmdArg) error {
_, err := s.ExecCmd(NewCmd("serveredit").WithArgs(args...))
return err
} | go | func (s *ServerMethods) Edit(args ...CmdArg) error {
_, err := s.ExecCmd(NewCmd("serveredit").WithArgs(args...))
return err
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"Edit",
"(",
"args",
"...",
"CmdArg",
")",
"error",
"{",
"_",
",",
"err",
":=",
"s",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
"\"",
")",
".",
"WithArgs",
"(",
"args",
"...",
")",
")",
"\n",
"return",
... | // Edit changes the selected virtual servers configuration using the given args. | [
"Edit",
"changes",
"the",
"selected",
"virtual",
"servers",
"configuration",
"using",
"the",
"given",
"args",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L219-L222 |
142,870 | multiplay/go-ts3 | server_cmds.go | Delete | func (s *ServerMethods) Delete(id int) error {
_, err := s.ExecCmd(NewCmd("serverdelete").WithArgs(NewArg("sid", id)))
return err
} | go | func (s *ServerMethods) Delete(id int) error {
_, err := s.ExecCmd(NewCmd("serverdelete").WithArgs(NewArg("sid", id)))
return err
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"Delete",
"(",
"id",
"int",
")",
"error",
"{",
"_",
",",
"err",
":=",
"s",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
"\"",
")",
".",
"WithArgs",
"(",
"NewArg",
"(",
"\"",
"\"",
",",
"id",
")",
")",
... | // Delete deletes the virtual server specified by id.
// Only virtual server in a stopped state can be deleted. | [
"Delete",
"deletes",
"the",
"virtual",
"server",
"specified",
"by",
"id",
".",
"Only",
"virtual",
"server",
"in",
"a",
"stopped",
"state",
"can",
"be",
"deleted",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L226-L229 |
142,871 | multiplay/go-ts3 | server_cmds.go | Create | func (s *ServerMethods) Create(name string, args ...CmdArg) (*CreatedServer, error) {
r := &CreatedServer{}
args = append(args, NewArg("virtualserver_name", name))
if _, err := s.ExecCmd(NewCmd("servercreate").WithArgs(args...).WithResponse(r)); err != nil {
return nil, err
}
return r, nil
} | go | func (s *ServerMethods) Create(name string, args ...CmdArg) (*CreatedServer, error) {
r := &CreatedServer{}
args = append(args, NewArg("virtualserver_name", name))
if _, err := s.ExecCmd(NewCmd("servercreate").WithArgs(args...).WithResponse(r)); err != nil {
return nil, err
}
return r, nil
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"Create",
"(",
"name",
"string",
",",
"args",
"...",
"CmdArg",
")",
"(",
"*",
"CreatedServer",
",",
"error",
")",
"{",
"r",
":=",
"&",
"CreatedServer",
"{",
"}",
"\n",
"args",
"=",
"append",
"(",
"args",
... | // Create creates a new virtual server using the given properties and returns
// its ID, port and initial administrator privilege key.
// If virtualserver_port arg is not specified, the server will use the first unused
// UDP port. | [
"Create",
"creates",
"a",
"new",
"virtual",
"server",
"using",
"the",
"given",
"properties",
"and",
"returns",
"its",
"ID",
"port",
"and",
"initial",
"administrator",
"privilege",
"key",
".",
"If",
"virtualserver_port",
"arg",
"is",
"not",
"specified",
"the",
... | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L242-L250 |
142,872 | multiplay/go-ts3 | server_cmds.go | GroupList | func (s *ServerMethods) GroupList() ([]*Group, error) {
var groups []*Group
if _, err := s.ExecCmd(NewCmd("servergrouplist").WithResponse(&groups)); err != nil {
return nil, err
}
return groups, nil
} | go | func (s *ServerMethods) GroupList() ([]*Group, error) {
var groups []*Group
if _, err := s.ExecCmd(NewCmd("servergrouplist").WithResponse(&groups)); err != nil {
return nil, err
}
return groups, nil
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"GroupList",
"(",
")",
"(",
"[",
"]",
"*",
"Group",
",",
"error",
")",
"{",
"var",
"groups",
"[",
"]",
"*",
"Group",
"\n",
"if",
"_",
",",
"err",
":=",
"s",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"\"",
... | // GroupList returns a list of available groups for the selected server. | [
"GroupList",
"returns",
"a",
"list",
"of",
"available",
"groups",
"for",
"the",
"selected",
"server",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L279-L286 |
142,873 | multiplay/go-ts3 | server_cmds.go | ChannelList | func (s *ServerMethods) ChannelList() ([]*Channel, error) {
var channels []*Channel
if _, err := s.ExecCmd(NewCmd("channellist").WithResponse(&channels)); err != nil {
return nil, err
}
return channels, nil
} | go | func (s *ServerMethods) ChannelList() ([]*Channel, error) {
var channels []*Channel
if _, err := s.ExecCmd(NewCmd("channellist").WithResponse(&channels)); err != nil {
return nil, err
}
return channels, nil
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"ChannelList",
"(",
")",
"(",
"[",
"]",
"*",
"Channel",
",",
"error",
")",
"{",
"var",
"channels",
"[",
"]",
"*",
"Channel",
"\n",
"if",
"_",
",",
"err",
":=",
"s",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
... | // ChannelList returns a list of channels for the selected server. | [
"ChannelList",
"returns",
"a",
"list",
"of",
"channels",
"for",
"the",
"selected",
"server",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L299-L306 |
142,874 | multiplay/go-ts3 | server_cmds.go | PrivilegeKeyList | func (s *ServerMethods) PrivilegeKeyList() ([]*PrivilegeKey, error) {
var keys []*PrivilegeKey
if _, err := s.ExecCmd(NewCmd("privilegekeylist").WithResponse(&keys)); err != nil {
return nil, err
}
return keys, nil
} | go | func (s *ServerMethods) PrivilegeKeyList() ([]*PrivilegeKey, error) {
var keys []*PrivilegeKey
if _, err := s.ExecCmd(NewCmd("privilegekeylist").WithResponse(&keys)); err != nil {
return nil, err
}
return keys, nil
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"PrivilegeKeyList",
"(",
")",
"(",
"[",
"]",
"*",
"PrivilegeKey",
",",
"error",
")",
"{",
"var",
"keys",
"[",
"]",
"*",
"PrivilegeKey",
"\n",
"if",
"_",
",",
"err",
":=",
"s",
".",
"ExecCmd",
"(",
"NewCm... | // PrivilegeKeyList returns a list of available privilege keys for the selected server,
// including their type and group IDs. | [
"PrivilegeKeyList",
"returns",
"a",
"list",
"of",
"available",
"privilege",
"keys",
"for",
"the",
"selected",
"server",
"including",
"their",
"type",
"and",
"group",
"IDs",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L320-L327 |
142,875 | multiplay/go-ts3 | server_cmds.go | PrivilegeKeyAdd | func (s *ServerMethods) PrivilegeKeyAdd(ttype, id1, id2 int, options ...CmdArg) (string, error) {
t := struct {
Token string
}{}
options = append(options, NewArg("tokentype", ttype), NewArg("tokenid1", id1), NewArg("tokenid2", id2))
_, err := s.ExecCmd(NewCmd("privilegekeylist").WithArgs(options...).WithResponse(... | go | func (s *ServerMethods) PrivilegeKeyAdd(ttype, id1, id2 int, options ...CmdArg) (string, error) {
t := struct {
Token string
}{}
options = append(options, NewArg("tokentype", ttype), NewArg("tokenid1", id1), NewArg("tokenid2", id2))
_, err := s.ExecCmd(NewCmd("privilegekeylist").WithArgs(options...).WithResponse(... | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"PrivilegeKeyAdd",
"(",
"ttype",
",",
"id1",
",",
"id2",
"int",
",",
"options",
"...",
"CmdArg",
")",
"(",
"string",
",",
"error",
")",
"{",
"t",
":=",
"struct",
"{",
"Token",
"string",
"\n",
"}",
"{",
"... | // PrivilegeKeyAdd creates a new privilege token to the selected server and returns it.
// If tokentype is set to 0, the ID specified with id1 will be a server group ID.
// Otherwise, id1 is used as a channel group ID and you need to provide a valid channel ID using id2. | [
"PrivilegeKeyAdd",
"creates",
"a",
"new",
"privilege",
"token",
"to",
"the",
"selected",
"server",
"and",
"returns",
"it",
".",
"If",
"tokentype",
"is",
"set",
"to",
"0",
"the",
"ID",
"specified",
"with",
"id1",
"will",
"be",
"a",
"server",
"group",
"ID",
... | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L332-L339 |
142,876 | multiplay/go-ts3 | server_cmds.go | ClientList | func (s *ServerMethods) ClientList() ([]*OnlineClient, error) {
var clients []*OnlineClient
if _, err := s.ExecCmd(NewCmd("clientlist").WithResponse(&clients)); err != nil {
return nil, err
}
return clients, nil
} | go | func (s *ServerMethods) ClientList() ([]*OnlineClient, error) {
var clients []*OnlineClient
if _, err := s.ExecCmd(NewCmd("clientlist").WithResponse(&clients)); err != nil {
return nil, err
}
return clients, nil
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"ClientList",
"(",
")",
"(",
"[",
"]",
"*",
"OnlineClient",
",",
"error",
")",
"{",
"var",
"clients",
"[",
"]",
"*",
"OnlineClient",
"\n",
"if",
"_",
",",
"err",
":=",
"s",
".",
"ExecCmd",
"(",
"NewCmd",... | // ClientList returns a list of online clients. | [
"ClientList",
"returns",
"a",
"list",
"of",
"online",
"clients",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L352-L358 |
142,877 | multiplay/go-ts3 | server_cmds.go | ClientDBList | func (s *ServerMethods) ClientDBList() ([]*DBClient, error) {
var dbclients []*DBClient
if _, err := s.ExecCmd(NewCmd("clientdblist").WithResponse(&dbclients)); err != nil {
return nil, err
}
return dbclients, nil
} | go | func (s *ServerMethods) ClientDBList() ([]*DBClient, error) {
var dbclients []*DBClient
if _, err := s.ExecCmd(NewCmd("clientdblist").WithResponse(&dbclients)); err != nil {
return nil, err
}
return dbclients, nil
} | [
"func",
"(",
"s",
"*",
"ServerMethods",
")",
"ClientDBList",
"(",
")",
"(",
"[",
"]",
"*",
"DBClient",
",",
"error",
")",
"{",
"var",
"dbclients",
"[",
"]",
"*",
"DBClient",
"\n",
"if",
"_",
",",
"err",
":=",
"s",
".",
"ExecCmd",
"(",
"NewCmd",
"... | // ClientDBList returns a list of client identities known by the server. | [
"ClientDBList",
"returns",
"a",
"list",
"of",
"client",
"identities",
"known",
"by",
"the",
"server",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/server_cmds.go#L371-L377 |
142,878 | multiplay/go-ts3 | cmd.go | WithArgs | func (c *Cmd) WithArgs(args ...CmdArg) *Cmd {
c.args = args
return c
} | go | func (c *Cmd) WithArgs(args ...CmdArg) *Cmd {
c.args = args
return c
} | [
"func",
"(",
"c",
"*",
"Cmd",
")",
"WithArgs",
"(",
"args",
"...",
"CmdArg",
")",
"*",
"Cmd",
"{",
"c",
".",
"args",
"=",
"args",
"\n",
"return",
"c",
"\n",
"}"
] | // WithArgs sets the command Args. | [
"WithArgs",
"sets",
"the",
"command",
"Args",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/cmd.go#L22-L25 |
142,879 | multiplay/go-ts3 | cmd.go | WithOptions | func (c *Cmd) WithOptions(options ...string) *Cmd {
c.options = options
return c
} | go | func (c *Cmd) WithOptions(options ...string) *Cmd {
c.options = options
return c
} | [
"func",
"(",
"c",
"*",
"Cmd",
")",
"WithOptions",
"(",
"options",
"...",
"string",
")",
"*",
"Cmd",
"{",
"c",
".",
"options",
"=",
"options",
"\n",
"return",
"c",
"\n",
"}"
] | // WithOptions sets the command Options. | [
"WithOptions",
"sets",
"the",
"command",
"Options",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/cmd.go#L28-L31 |
142,880 | multiplay/go-ts3 | cmd.go | NewArg | func NewArg(key string, val interface{}) *Arg {
switch val {
case false:
val = "0"
case true:
val = "1"
}
return &Arg{key: key, val: fmt.Sprint(val)}
} | go | func NewArg(key string, val interface{}) *Arg {
switch val {
case false:
val = "0"
case true:
val = "1"
}
return &Arg{key: key, val: fmt.Sprint(val)}
} | [
"func",
"NewArg",
"(",
"key",
"string",
",",
"val",
"interface",
"{",
"}",
")",
"*",
"Arg",
"{",
"switch",
"val",
"{",
"case",
"false",
":",
"val",
"=",
"\"",
"\"",
"\n",
"case",
"true",
":",
"val",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"... | // NewArg returns a new Arg with key val. | [
"NewArg",
"returns",
"a",
"new",
"Arg",
"with",
"key",
"val",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/cmd.go#L102-L110 |
142,881 | multiplay/go-ts3 | cmd.go | ArgString | func (a *Arg) ArgString() string {
return fmt.Sprintf("%v=%v", encoder.Replace(a.key), encoder.Replace(a.val))
} | go | func (a *Arg) ArgString() string {
return fmt.Sprintf("%v=%v", encoder.Replace(a.key), encoder.Replace(a.val))
} | [
"func",
"(",
"a",
"*",
"Arg",
")",
"ArgString",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"encoder",
".",
"Replace",
"(",
"a",
".",
"key",
")",
",",
"encoder",
".",
"Replace",
"(",
"a",
".",
"val",
")",
")"... | // ArgString implements CmdArg | [
"ArgString",
"implements",
"CmdArg"
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/cmd.go#L113-L115 |
142,882 | multiplay/go-ts3 | helpers.go | DecodeResponse | func DecodeResponse(lines []string, v interface{}) error {
if len(lines) > 1 {
return NewInvalidResponseError("too many lines", lines)
} else if len(lines) == 0 {
return NewInvalidResponseError("no lines", lines)
}
input := make(map[string]interface{})
value := reflect.ValueOf(v)
var slice reflect.Value
var... | go | func DecodeResponse(lines []string, v interface{}) error {
if len(lines) > 1 {
return NewInvalidResponseError("too many lines", lines)
} else if len(lines) == 0 {
return NewInvalidResponseError("no lines", lines)
}
input := make(map[string]interface{})
value := reflect.ValueOf(v)
var slice reflect.Value
var... | [
"func",
"DecodeResponse",
"(",
"lines",
"[",
"]",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"len",
"(",
"lines",
")",
">",
"1",
"{",
"return",
"NewInvalidResponseError",
"(",
"\"",
"\"",
",",
"lines",
")",
"\n",
"}",
"else",... | // DecodeResponse decodes a response into a struct. | [
"DecodeResponse",
"decodes",
"a",
"response",
"into",
"a",
"struct",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/helpers.go#L53-L105 |
142,883 | multiplay/go-ts3 | helpers.go | decodeMap | func decodeMap(d map[string]interface{}, r interface{}) error {
cfg := &mapstructure.DecoderConfig{
WeaklyTypedInput: true,
TagName: "ms",
Result: r,
DecodeHook: timeHookFunc,
}
dec, err := mapstructure.NewDecoder(cfg)
if err != nil {
return err
}
return dec.Decode(d)
} | go | func decodeMap(d map[string]interface{}, r interface{}) error {
cfg := &mapstructure.DecoderConfig{
WeaklyTypedInput: true,
TagName: "ms",
Result: r,
DecodeHook: timeHookFunc,
}
dec, err := mapstructure.NewDecoder(cfg)
if err != nil {
return err
}
return dec.Decode(d)
} | [
"func",
"decodeMap",
"(",
"d",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"r",
"interface",
"{",
"}",
")",
"error",
"{",
"cfg",
":=",
"&",
"mapstructure",
".",
"DecoderConfig",
"{",
"WeaklyTypedInput",
":",
"true",
",",
"TagName",
":",
"\""... | // decodeMap decodes input into r. | [
"decodeMap",
"decodes",
"input",
"into",
"r",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/helpers.go#L108-L120 |
142,884 | multiplay/go-ts3 | helpers.go | decodeSlice | func decodeSlice(elemType reflect.Type, slice reflect.Value, input map[string]interface{}) error {
var v reflect.Value
if elemType.Kind() == reflect.Ptr {
v = reflect.New(elemType.Elem())
} else {
v = reflect.New(elemType)
}
if !v.CanInterface() {
return fmt.Errorf("can't interface %#v", v)
}
if err := d... | go | func decodeSlice(elemType reflect.Type, slice reflect.Value, input map[string]interface{}) error {
var v reflect.Value
if elemType.Kind() == reflect.Ptr {
v = reflect.New(elemType.Elem())
} else {
v = reflect.New(elemType)
}
if !v.CanInterface() {
return fmt.Errorf("can't interface %#v", v)
}
if err := d... | [
"func",
"decodeSlice",
"(",
"elemType",
"reflect",
".",
"Type",
",",
"slice",
"reflect",
".",
"Value",
",",
"input",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"v",
"reflect",
".",
"Value",
"\n",
"if",
"elemType",
".",
... | // decodeSlice decodes input into slice. | [
"decodeSlice",
"decodes",
"input",
"into",
"slice",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/helpers.go#L123-L145 |
142,885 | multiplay/go-ts3 | helpers.go | timeHookFunc | func timeHookFunc(from reflect.Type, to reflect.Type, data interface{}) (interface{}, error) {
// Decode time.Time
if to == timeType {
var timeInt int64
switch from.Kind() {
case reflect.Int:
timeInt = int64(data.(int))
case reflect.String:
var err error
timeInt, err = strconv.ParseInt(data.(string)... | go | func timeHookFunc(from reflect.Type, to reflect.Type, data interface{}) (interface{}, error) {
// Decode time.Time
if to == timeType {
var timeInt int64
switch from.Kind() {
case reflect.Int:
timeInt = int64(data.(int))
case reflect.String:
var err error
timeInt, err = strconv.ParseInt(data.(string)... | [
"func",
"timeHookFunc",
"(",
"from",
"reflect",
".",
"Type",
",",
"to",
"reflect",
".",
"Type",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// Decode time.Time",
"if",
"to",
"==",
"timeType",
"{",
"var"... | // timeHookFunc supports decoding to time | [
"timeHookFunc",
"supports",
"decoding",
"to",
"time"
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/helpers.go#L150-L172 |
142,886 | multiplay/go-ts3 | errors.go | NewError | func NewError(matches []string) *Error {
e := &Error{Msg: Decode(matches[2])}
var err error
if e.ID, err = strconv.Atoi(matches[1]); err != nil {
// This should be impossible given it matched \d+ in the regexp.
e.ID = -1
}
if rem := strings.TrimSpace(matches[3]); rem != "" {
e.Details = make(map[string]int... | go | func NewError(matches []string) *Error {
e := &Error{Msg: Decode(matches[2])}
var err error
if e.ID, err = strconv.Atoi(matches[1]); err != nil {
// This should be impossible given it matched \d+ in the regexp.
e.ID = -1
}
if rem := strings.TrimSpace(matches[3]); rem != "" {
e.Details = make(map[string]int... | [
"func",
"NewError",
"(",
"matches",
"[",
"]",
"string",
")",
"*",
"Error",
"{",
"e",
":=",
"&",
"Error",
"{",
"Msg",
":",
"Decode",
"(",
"matches",
"[",
"2",
"]",
")",
"}",
"\n\n",
"var",
"err",
"error",
"\n",
"if",
"e",
".",
"ID",
",",
"err",
... | // NewError returns a new Error parsed from TeamSpeak 3 server response. | [
"NewError",
"returns",
"a",
"new",
"Error",
"parsed",
"from",
"TeamSpeak",
"3",
"server",
"response",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/errors.go#L34-L57 |
142,887 | multiplay/go-ts3 | errors.go | NewInvalidResponseError | func NewInvalidResponseError(reason string, lines []string) *InvalidResponseError {
return &InvalidResponseError{Reason: reason, Data: lines}
} | go | func NewInvalidResponseError(reason string, lines []string) *InvalidResponseError {
return &InvalidResponseError{Reason: reason, Data: lines}
} | [
"func",
"NewInvalidResponseError",
"(",
"reason",
"string",
",",
"lines",
"[",
"]",
"string",
")",
"*",
"InvalidResponseError",
"{",
"return",
"&",
"InvalidResponseError",
"{",
"Reason",
":",
"reason",
",",
"Data",
":",
"lines",
"}",
"\n",
"}"
] | // NewInvalidResponseError returns a new InvalidResponseError from lines. | [
"NewInvalidResponseError",
"returns",
"a",
"new",
"InvalidResponseError",
"from",
"lines",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/errors.go#L73-L75 |
142,888 | multiplay/go-ts3 | client.go | KeepAlive | func KeepAlive(keepAlive time.Duration) func(*Client) error {
return func(c *Client) error {
c.keepAlive = keepAlive
return nil
}
} | go | func KeepAlive(keepAlive time.Duration) func(*Client) error {
return func(c *Client) error {
c.keepAlive = keepAlive
return nil
}
} | [
"func",
"KeepAlive",
"(",
"keepAlive",
"time",
".",
"Duration",
")",
"func",
"(",
"*",
"Client",
")",
"error",
"{",
"return",
"func",
"(",
"c",
"*",
"Client",
")",
"error",
"{",
"c",
".",
"keepAlive",
"=",
"keepAlive",
"\n",
"return",
"nil",
"\n",
"}... | // KeepAlive sets the keepAlive interval. | [
"KeepAlive",
"sets",
"the",
"keepAlive",
"interval",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/client.go#L73-L78 |
142,889 | multiplay/go-ts3 | client.go | NotificationBuffer | func NotificationBuffer(size int) func(*Client) error {
return func(c *Client) error {
c.notifyBufSize = size
return nil
}
} | go | func NotificationBuffer(size int) func(*Client) error {
return func(c *Client) error {
c.notifyBufSize = size
return nil
}
} | [
"func",
"NotificationBuffer",
"(",
"size",
"int",
")",
"func",
"(",
"*",
"Client",
")",
"error",
"{",
"return",
"func",
"(",
"c",
"*",
"Client",
")",
"error",
"{",
"c",
".",
"notifyBufSize",
"=",
"size",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // NotificationBuffer sets the notification buffer size. | [
"NotificationBuffer",
"sets",
"the",
"notification",
"buffer",
"size",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/client.go#L81-L86 |
142,890 | multiplay/go-ts3 | client.go | NewClient | func NewClient(addr string, options ...func(c *Client) error) (*Client, error) {
if !strings.Contains(addr, ":") {
addr = fmt.Sprintf("%v:%v", addr, DefaultPort)
}
c := &Client{
timeout: DefaultTimeout,
keepAlive: DefaultKeepAlive,
buf: make([]byte, startBufSize),
maxBufSize: MaxPar... | go | func NewClient(addr string, options ...func(c *Client) error) (*Client, error) {
if !strings.Contains(addr, ":") {
addr = fmt.Sprintf("%v:%v", addr, DefaultPort)
}
c := &Client{
timeout: DefaultTimeout,
keepAlive: DefaultKeepAlive,
buf: make([]byte, startBufSize),
maxBufSize: MaxPar... | [
"func",
"NewClient",
"(",
"addr",
"string",
",",
"options",
"...",
"func",
"(",
"c",
"*",
"Client",
")",
"error",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"if",
"!",
"strings",
".",
"Contains",
"(",
"addr",
",",
"\"",
"\"",
")",
"{",
"add... | // NewClient returns a new TeamSpeak 3 client connected to addr. | [
"NewClient",
"returns",
"a",
"new",
"TeamSpeak",
"3",
"client",
"connected",
"to",
"addr",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/client.go#L105-L170 |
142,891 | multiplay/go-ts3 | client.go | messageHandler | func (c *Client) messageHandler() {
for {
if c.scanner.Scan() {
line := c.scanner.Text()
if line == "error id=0 msg=ok" {
c.err <- nil
} else if matches := respTrailerRe.FindStringSubmatch(line); len(matches) == 4 {
c.err <- NewError(matches)
} else if strings.Index(line, "notify") == 0 {
if ... | go | func (c *Client) messageHandler() {
for {
if c.scanner.Scan() {
line := c.scanner.Text()
if line == "error id=0 msg=ok" {
c.err <- nil
} else if matches := respTrailerRe.FindStringSubmatch(line); len(matches) == 4 {
c.err <- NewError(matches)
} else if strings.Index(line, "notify") == 0 {
if ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"messageHandler",
"(",
")",
"{",
"for",
"{",
"if",
"c",
".",
"scanner",
".",
"Scan",
"(",
")",
"{",
"line",
":=",
"c",
".",
"scanner",
".",
"Text",
"(",
")",
"\n",
"if",
"line",
"==",
"\"",
"\"",
"{",
"c"... | // messageHandler scans incoming lines and handles them accordingly. | [
"messageHandler",
"scans",
"incoming",
"lines",
"and",
"handles",
"them",
"accordingly",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/client.go#L173-L201 |
142,892 | multiplay/go-ts3 | client.go | workHandler | func (c *Client) workHandler() {
for {
select {
case w := <-c.work:
c.process(w)
case <-time.After(c.keepAlive):
c.process(keepAliveData)
case <-c.disconnect:
return
}
}
} | go | func (c *Client) workHandler() {
for {
select {
case w := <-c.work:
c.process(w)
case <-time.After(c.keepAlive):
c.process(keepAliveData)
case <-c.disconnect:
return
}
}
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"workHandler",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"w",
":=",
"<-",
"c",
".",
"work",
":",
"c",
".",
"process",
"(",
"w",
")",
"\n",
"case",
"<-",
"time",
".",
"After",
"(",
"c",
".",
"keepA... | // workHandler handles commands and keepAlive messages. | [
"workHandler",
"handles",
"commands",
"and",
"keepAlive",
"messages",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/client.go#L204-L215 |
142,893 | multiplay/go-ts3 | client.go | Exec | func (c *Client) Exec(cmd string) ([]string, error) {
return c.ExecCmd(NewCmd(cmd))
} | go | func (c *Client) Exec(cmd string) ([]string, error) {
return c.ExecCmd(NewCmd(cmd))
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Exec",
"(",
"cmd",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"ExecCmd",
"(",
"NewCmd",
"(",
"cmd",
")",
")",
"\n",
"}"
] | // Exec executes cmd on the server and returns the response. | [
"Exec",
"executes",
"cmd",
"on",
"the",
"server",
"and",
"returns",
"the",
"response",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/client.go#L227-L229 |
142,894 | multiplay/go-ts3 | client.go | ExecCmd | func (c *Client) ExecCmd(cmd *Cmd) ([]string, error) {
if !c.IsConnected() {
return nil, ErrNotConnected
}
c.work <- cmd.String()
select {
case err := <-c.err:
if err != nil {
return nil, err
}
case <-time.After(c.timeout):
return nil, ErrTimeout
}
res := c.res
c.res = nil
if cmd.response != ni... | go | func (c *Client) ExecCmd(cmd *Cmd) ([]string, error) {
if !c.IsConnected() {
return nil, ErrNotConnected
}
c.work <- cmd.String()
select {
case err := <-c.err:
if err != nil {
return nil, err
}
case <-time.After(c.timeout):
return nil, ErrTimeout
}
res := c.res
c.res = nil
if cmd.response != ni... | [
"func",
"(",
"c",
"*",
"Client",
")",
"ExecCmd",
"(",
"cmd",
"*",
"Cmd",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"!",
"c",
".",
"IsConnected",
"(",
")",
"{",
"return",
"nil",
",",
"ErrNotConnected",
"\n",
"}",
"\n\n",
"c",
"... | // ExecCmd executes cmd on the server and returns the response. | [
"ExecCmd",
"executes",
"cmd",
"on",
"the",
"server",
"and",
"returns",
"the",
"response",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/client.go#L232-L258 |
142,895 | multiplay/go-ts3 | client.go | scanErr | func (c *Client) scanErr() error {
if err := c.scanner.Err(); err != nil {
return err
}
return io.ErrUnexpectedEOF
} | go | func (c *Client) scanErr() error {
if err := c.scanner.Err(); err != nil {
return err
}
return io.ErrUnexpectedEOF
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"scanErr",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"scanner",
".",
"Err",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"io",
".",
"ErrUnexpectedEOF",
"\n",
... | // scanError returns the error from the scanner if non-nil,
// `io.ErrUnexpectedEOF` otherwise. | [
"scanError",
"returns",
"the",
"error",
"from",
"the",
"scanner",
"if",
"non",
"-",
"nil",
"io",
".",
"ErrUnexpectedEOF",
"otherwise",
"."
] | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/client.go#L286-L291 |
142,896 | multiplay/go-ts3 | scanner.go | ScanLines | func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {
if atEOF && len(data) == 0 {
return 0, nil, nil
}
if i := strings.Index(string(data), "\n\r"); i >= 0 {
// We have a full end-of-line terminated line.
return i + 2, data[0:i], nil
}
// If we're at EOF, we have a final, non-ter... | go | func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {
if atEOF && len(data) == 0 {
return 0, nil, nil
}
if i := strings.Index(string(data), "\n\r"); i >= 0 {
// We have a full end-of-line terminated line.
return i + 2, data[0:i], nil
}
// If we're at EOF, we have a final, non-ter... | [
"func",
"ScanLines",
"(",
"data",
"[",
"]",
"byte",
",",
"atEOF",
"bool",
")",
"(",
"advance",
"int",
",",
"token",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"if",
"atEOF",
"&&",
"len",
"(",
"data",
")",
"==",
"0",
"{",
"return",
"0",
",... | // ScanLines is a split function for a bytes.Scanner that returns each line of
// text, stripped of any trailing end-of-line marker. The returned line may
// be empty. The end-of-line marker is one newline followed by a carriage return.
// In regular expression notation, it is `\n\r`.
// The last non-empty line of inpu... | [
"ScanLines",
"is",
"a",
"split",
"function",
"for",
"a",
"bytes",
".",
"Scanner",
"that",
"returns",
"each",
"line",
"of",
"text",
"stripped",
"of",
"any",
"trailing",
"end",
"-",
"of",
"-",
"line",
"marker",
".",
"The",
"returned",
"line",
"may",
"be",
... | 78271a6b12b2ecc73d8617271533f7a837049c68 | https://github.com/multiplay/go-ts3/blob/78271a6b12b2ecc73d8617271533f7a837049c68/scanner.go#L12-L29 |
142,897 | codahale/chacha20 | chacha20.go | NewWithRounds | func NewWithRounds(key []byte, nonce []byte, rounds uint8) (cipher.Stream, error) {
if len(key) != KeySize {
return nil, ErrInvalidKey
}
if len(nonce) != NonceSize {
return nil, ErrInvalidNonce
}
if (rounds != 8) && (rounds != 12) && (rounds != 20) {
return nil, ErrInvalidRounds
}
s := new(stream)
s.in... | go | func NewWithRounds(key []byte, nonce []byte, rounds uint8) (cipher.Stream, error) {
if len(key) != KeySize {
return nil, ErrInvalidKey
}
if len(nonce) != NonceSize {
return nil, ErrInvalidNonce
}
if (rounds != 8) && (rounds != 12) && (rounds != 20) {
return nil, ErrInvalidRounds
}
s := new(stream)
s.in... | [
"func",
"NewWithRounds",
"(",
"key",
"[",
"]",
"byte",
",",
"nonce",
"[",
"]",
"byte",
",",
"rounds",
"uint8",
")",
"(",
"cipher",
".",
"Stream",
",",
"error",
")",
"{",
"if",
"len",
"(",
"key",
")",
"!=",
"KeySize",
"{",
"return",
"nil",
",",
"E... | // NewWithRounds creates and returns a new cipher.Stream just like New but
// the rounds number of 8, 12, or 20 can be specified. | [
"NewWithRounds",
"creates",
"and",
"returns",
"a",
"new",
"cipher",
".",
"Stream",
"just",
"like",
"New",
"but",
"the",
"rounds",
"number",
"of",
"8",
"12",
"or",
"20",
"can",
"be",
"specified",
"."
] | ec07b4f69a3f70b1dd2a8ad77230deb1ba5d6953 | https://github.com/codahale/chacha20/blob/ec07b4f69a3f70b1dd2a8ad77230deb1ba5d6953/chacha20.go#L57-L75 |
142,898 | codahale/chacha20 | chacha20.go | NewXChaChaWithRounds | func NewXChaChaWithRounds(key []byte, nonce []byte, rounds uint8) (cipher.Stream, error) {
if len(key) != KeySize {
return nil, ErrInvalidKey
}
if len(nonce) != XNonceSize {
return nil, ErrInvalidXNonce
}
if (rounds != 8) && (rounds != 12) && (rounds != 20) {
return nil, ErrInvalidRounds
}
s := new(stre... | go | func NewXChaChaWithRounds(key []byte, nonce []byte, rounds uint8) (cipher.Stream, error) {
if len(key) != KeySize {
return nil, ErrInvalidKey
}
if len(nonce) != XNonceSize {
return nil, ErrInvalidXNonce
}
if (rounds != 8) && (rounds != 12) && (rounds != 20) {
return nil, ErrInvalidRounds
}
s := new(stre... | [
"func",
"NewXChaChaWithRounds",
"(",
"key",
"[",
"]",
"byte",
",",
"nonce",
"[",
"]",
"byte",
",",
"rounds",
"uint8",
")",
"(",
"cipher",
".",
"Stream",
",",
"error",
")",
"{",
"if",
"len",
"(",
"key",
")",
"!=",
"KeySize",
"{",
"return",
"nil",
",... | // NewXChaChaWithRounds creates and returns a new cipher.Stream just like
// NewXChaCha but the rounds number of 8, 12, or 20 can be specified. | [
"NewXChaChaWithRounds",
"creates",
"and",
"returns",
"a",
"new",
"cipher",
".",
"Stream",
"just",
"like",
"NewXChaCha",
"but",
"the",
"rounds",
"number",
"of",
"8",
"12",
"or",
"20",
"can",
"be",
"specified",
"."
] | ec07b4f69a3f70b1dd2a8ad77230deb1ba5d6953 | https://github.com/codahale/chacha20/blob/ec07b4f69a3f70b1dd2a8ad77230deb1ba5d6953/chacha20.go#L87-L118 |
142,899 | codahale/chacha20 | chacha20.go | init | func init() {
x := uint32(0x04030201)
y := [4]byte{0x1, 0x2, 0x3, 0x4}
bigEndian = *(*[4]byte)(unsafe.Pointer(&x)) != y
} | go | func init() {
x := uint32(0x04030201)
y := [4]byte{0x1, 0x2, 0x3, 0x4}
bigEndian = *(*[4]byte)(unsafe.Pointer(&x)) != y
} | [
"func",
"init",
"(",
")",
"{",
"x",
":=",
"uint32",
"(",
"0x04030201",
")",
"\n",
"y",
":=",
"[",
"4",
"]",
"byte",
"{",
"0x1",
",",
"0x2",
",",
"0x3",
",",
"0x4",
"}",
"\n",
"bigEndian",
"=",
"*",
"(",
"*",
"[",
"4",
"]",
"byte",
")",
"(",... | // Do some up-front bookkeeping on what sort of CPU we're using. ChaCha20 treats
// its state as a little-endian byte array when it comes to generating the
// keystream, which allows for a zero-copy approach to the core transform. On
// big-endian architectures, we have to take a hit to reverse the bytes. | [
"Do",
"some",
"up",
"-",
"front",
"bookkeeping",
"on",
"what",
"sort",
"of",
"CPU",
"we",
"re",
"using",
".",
"ChaCha20",
"treats",
"its",
"state",
"as",
"a",
"little",
"-",
"endian",
"byte",
"array",
"when",
"it",
"comes",
"to",
"generating",
"the",
"... | ec07b4f69a3f70b1dd2a8ad77230deb1ba5d6953 | https://github.com/codahale/chacha20/blob/ec07b4f69a3f70b1dd2a8ad77230deb1ba5d6953/chacha20.go#L231-L235 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.