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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
stripe/stripe-go | customer/client.go | Update | func (c Client) Update(id string, params *stripe.CustomerParams) (*stripe.Customer, error) {
path := stripe.FormatURLPath("/v1/customers/%s", id)
cust := &stripe.Customer{}
err := c.B.Call(http.MethodPost, path, c.Key, params, cust)
return cust, err
} | go | func (c Client) Update(id string, params *stripe.CustomerParams) (*stripe.Customer, error) {
path := stripe.FormatURLPath("/v1/customers/%s", id)
cust := &stripe.Customer{}
err := c.B.Call(http.MethodPost, path, c.Key, params, cust)
return cust, err
} | [
"func",
"(",
"c",
"Client",
")",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"CustomerParams",
")",
"(",
"*",
"stripe",
".",
"Customer",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",... | // Update updates a customer's properties. | [
"Update",
"updates",
"a",
"customer",
"s",
"properties",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/customer/client.go#L48-L53 | train |
stripe/stripe-go | customer/client.go | Del | func Del(id string, params *stripe.CustomerParams) (*stripe.Customer, error) {
return getC().Del(id, params)
} | go | func Del(id string, params *stripe.CustomerParams) (*stripe.Customer, error) {
return getC().Del(id, params)
} | [
"func",
"Del",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"CustomerParams",
")",
"(",
"*",
"stripe",
".",
"Customer",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Del",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Del removes a customer. | [
"Del",
"removes",
"a",
"customer",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/customer/client.go#L56-L58 | train |
stripe/stripe-go | paymentsource/client.go | New | func New(params *stripe.CustomerSourceParams) (*stripe.PaymentSource, error) {
return getC().New(params)
} | go | func New(params *stripe.CustomerSourceParams) (*stripe.PaymentSource, error) {
return getC().New(params)
} | [
"func",
"New",
"(",
"params",
"*",
"stripe",
".",
"CustomerSourceParams",
")",
"(",
"*",
"stripe",
".",
"PaymentSource",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"New",
"(",
"params",
")",
"\n",
"}"
] | // New creates a new source for a customer. | [
"New",
"creates",
"a",
"new",
"source",
"for",
"a",
"customer",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/paymentsource/client.go#L19-L21 | train |
stripe/stripe-go | creditnote.go | UnmarshalJSON | func (i *CreditNote) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type note CreditNote
var v note
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = CreditNote(v)
return nil
} | go | func (i *CreditNote) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type note CreditNote
var v note
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = CreditNote(v)
return nil
} | [
"func",
"(",
"i",
"*",
"CreditNote",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
... | // UnmarshalJSON handles deserialization of a CreditNote.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"CreditNote",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/creditnote.go#L89-L103 | train |
stripe/stripe-go | bitcointransaction.go | UnmarshalJSON | func (bt *BitcoinTransaction) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
bt.ID = id
return nil
}
type bitcoinTransaction BitcoinTransaction
var v bitcoinTransaction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*bt = BitcoinTransaction(v)
return nil
} | go | func (bt *BitcoinTransaction) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
bt.ID = id
return nil
}
type bitcoinTransaction BitcoinTransaction
var v bitcoinTransaction
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*bt = BitcoinTransaction(v)
return nil
} | [
"func",
"(",
"bt",
"*",
"BitcoinTransaction",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"bt",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n... | // UnmarshalJSON handles deserialization of a BitcoinTransaction.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"BitcoinTransaction",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/bitcointransaction.go#L35-L49 | train |
stripe/stripe-go | invoice.go | UnmarshalJSON | func (i *Invoice) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type invoice Invoice
var v invoice
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = Invoice(v)
return nil
} | go | func (i *Invoice) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type invoice Invoice
var v invoice
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = Invoice(v)
return nil
} | [
"func",
"(",
"i",
"*",
"Invoice",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"... | // UnmarshalJSON handles deserialization of an Invoice.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"Invoice",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/invoice.go#L340-L354 | train |
stripe/stripe-go | params.go | AppendTo | func (v ExtraValues) AppendTo(body *form.Values, keyParts []string) {
for k, vs := range v.Values {
for _, v := range vs {
body.Add(form.FormatKey(append(keyParts, k)), v)
}
}
} | go | func (v ExtraValues) AppendTo(body *form.Values, keyParts []string) {
for k, vs := range v.Values {
for _, v := range vs {
body.Add(form.FormatKey(append(keyParts, k)), v)
}
}
} | [
"func",
"(",
"v",
"ExtraValues",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"for",
"k",
",",
"vs",
":=",
"range",
"v",
".",
"Values",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"vs",
... | // AppendTo implements custom form encoding for extra parameter values. | [
"AppendTo",
"implements",
"custom",
"form",
"encoding",
"for",
"extra",
"parameter",
"values",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L37-L43 | train |
stripe/stripe-go | params.go | AddFilter | func (f *Filters) AddFilter(key, op, value string) {
filter := &filter{Key: key, Op: op, Val: value}
f.f = append(f.f, filter)
} | go | func (f *Filters) AddFilter(key, op, value string) {
filter := &filter{Key: key, Op: op, Val: value}
f.f = append(f.f, filter)
} | [
"func",
"(",
"f",
"*",
"Filters",
")",
"AddFilter",
"(",
"key",
",",
"op",
",",
"value",
"string",
")",
"{",
"filter",
":=",
"&",
"filter",
"{",
"Key",
":",
"key",
",",
"Op",
":",
"op",
",",
"Val",
":",
"value",
"}",
"\n",
"f",
".",
"f",
"=",... | // AddFilter adds a new filter with a given key, op and value. | [
"AddFilter",
"adds",
"a",
"new",
"filter",
"with",
"a",
"given",
"key",
"op",
"and",
"value",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L51-L54 | train |
stripe/stripe-go | params.go | AppendTo | func (f Filters) AppendTo(body *form.Values, keyParts []string) {
if len(f.f) > 0 {
for _, v := range f.f {
if len(v.Op) > 0 {
body.Add(form.FormatKey(append(keyParts, v.Key, v.Op)), v.Val)
} else {
body.Add(form.FormatKey(append(keyParts, v.Key)), v.Val)
}
}
}
} | go | func (f Filters) AppendTo(body *form.Values, keyParts []string) {
if len(f.f) > 0 {
for _, v := range f.f {
if len(v.Op) > 0 {
body.Add(form.FormatKey(append(keyParts, v.Key, v.Op)), v.Val)
} else {
body.Add(form.FormatKey(append(keyParts, v.Key)), v.Val)
}
}
}
} | [
"func",
"(",
"f",
"Filters",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"f",
".",
"f",
")",
">",
"0",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"f",
".",
"f",
"... | // AppendTo implements custom form encoding for filters. | [
"AppendTo",
"implements",
"custom",
"form",
"encoding",
"for",
"filters",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L57-L67 | train |
stripe/stripe-go | params.go | ToParams | func (p *ListParams) ToParams() *Params {
return &Params{
Context: p.Context,
StripeAccount: p.StripeAccount,
}
} | go | func (p *ListParams) ToParams() *Params {
return &Params{
Context: p.Context,
StripeAccount: p.StripeAccount,
}
} | [
"func",
"(",
"p",
"*",
"ListParams",
")",
"ToParams",
"(",
")",
"*",
"Params",
"{",
"return",
"&",
"Params",
"{",
"Context",
":",
"p",
".",
"Context",
",",
"StripeAccount",
":",
"p",
".",
"StripeAccount",
",",
"}",
"\n",
"}"
] | // ToParams converts a ListParams to a Params by moving over any fields that
// have valid targets in the new type. This is useful because fields in
// Params can be injected directly into an http.Request while generally
// ListParams is only used to build a set of parameters. | [
"ToParams",
"converts",
"a",
"ListParams",
"to",
"a",
"Params",
"by",
"moving",
"over",
"any",
"fields",
"that",
"have",
"valid",
"targets",
"in",
"the",
"new",
"type",
".",
"This",
"is",
"useful",
"because",
"fields",
"in",
"Params",
"can",
"be",
"injecte... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L139-L144 | train |
stripe/stripe-go | params.go | AddExtra | func (p *Params) AddExtra(key, value string) {
if p.Extra == nil {
p.Extra = &ExtraValues{Values: make(url.Values)}
}
p.Extra.Add(key, value)
} | go | func (p *Params) AddExtra(key, value string) {
if p.Extra == nil {
p.Extra = &ExtraValues{Values: make(url.Values)}
}
p.Extra.Add(key, value)
} | [
"func",
"(",
"p",
"*",
"Params",
")",
"AddExtra",
"(",
"key",
",",
"value",
"string",
")",
"{",
"if",
"p",
".",
"Extra",
"==",
"nil",
"{",
"p",
".",
"Extra",
"=",
"&",
"ExtraValues",
"{",
"Values",
":",
"make",
"(",
"url",
".",
"Values",
")",
"... | // AddExtra adds a new arbitrary key-value pair to the request data | [
"AddExtra",
"adds",
"a",
"new",
"arbitrary",
"key",
"-",
"value",
"pair",
"to",
"the",
"request",
"data"
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L188-L194 | train |
stripe/stripe-go | params.go | AddMetadata | func (p *Params) AddMetadata(key, value string) {
if p.Metadata == nil {
p.Metadata = make(map[string]string)
}
p.Metadata[key] = value
} | go | func (p *Params) AddMetadata(key, value string) {
if p.Metadata == nil {
p.Metadata = make(map[string]string)
}
p.Metadata[key] = value
} | [
"func",
"(",
"p",
"*",
"Params",
")",
"AddMetadata",
"(",
"key",
",",
"value",
"string",
")",
"{",
"if",
"p",
".",
"Metadata",
"==",
"nil",
"{",
"p",
".",
"Metadata",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"}",
"\n\n",
... | // AddMetadata adds a new key-value pair to the Metadata. | [
"AddMetadata",
"adds",
"a",
"new",
"key",
"-",
"value",
"pair",
"to",
"the",
"Metadata",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L197-L203 | train |
stripe/stripe-go | params.go | NewIdempotencyKey | func NewIdempotencyKey() string {
now := time.Now().UnixNano()
buf := make([]byte, 4)
rand.Read(buf)
return fmt.Sprintf("%v_%v", now, base64.URLEncoding.EncodeToString(buf)[:6])
} | go | func NewIdempotencyKey() string {
now := time.Now().UnixNano()
buf := make([]byte, 4)
rand.Read(buf)
return fmt.Sprintf("%v_%v", now, base64.URLEncoding.EncodeToString(buf)[:6])
} | [
"func",
"NewIdempotencyKey",
"(",
")",
"string",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
"\n",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n",
"rand",
".",
"Read",
"(",
"buf",
")",
"\n",
"retu... | //
// Public functions
//
// NewIdempotencyKey generates a new idempotency key that
// can be used on a request. | [
"Public",
"functions",
"NewIdempotencyKey",
"generates",
"a",
"new",
"idempotency",
"key",
"that",
"can",
"be",
"used",
"on",
"a",
"request",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/params.go#L254-L259 | train |
stripe/stripe-go | iter.go | Next | func (it *Iter) Next() bool {
if len(it.values) == 0 && it.meta.HasMore && !it.listParams.Single {
// determine if we're moving forward or backwards in paging
if it.listParams.EndingBefore != nil {
it.listParams.EndingBefore = String(listItemID(it.cur))
it.formValues.Set(EndingBefore, *it.listParams.EndingBefore)
} else {
it.listParams.StartingAfter = String(listItemID(it.cur))
it.formValues.Set(StartingAfter, *it.listParams.StartingAfter)
}
it.getPage()
}
if len(it.values) == 0 {
return false
}
it.cur = it.values[0]
it.values = it.values[1:]
return true
} | go | func (it *Iter) Next() bool {
if len(it.values) == 0 && it.meta.HasMore && !it.listParams.Single {
// determine if we're moving forward or backwards in paging
if it.listParams.EndingBefore != nil {
it.listParams.EndingBefore = String(listItemID(it.cur))
it.formValues.Set(EndingBefore, *it.listParams.EndingBefore)
} else {
it.listParams.StartingAfter = String(listItemID(it.cur))
it.formValues.Set(StartingAfter, *it.listParams.StartingAfter)
}
it.getPage()
}
if len(it.values) == 0 {
return false
}
it.cur = it.values[0]
it.values = it.values[1:]
return true
} | [
"func",
"(",
"it",
"*",
"Iter",
")",
"Next",
"(",
")",
"bool",
"{",
"if",
"len",
"(",
"it",
".",
"values",
")",
"==",
"0",
"&&",
"it",
".",
"meta",
".",
"HasMore",
"&&",
"!",
"it",
".",
"listParams",
".",
"Single",
"{",
"// determine if we're movin... | // Next advances the Iter to the next item in the list,
// which will then be available
// through the Current method.
// It returns false when the iterator stops
// at the end of the list. | [
"Next",
"advances",
"the",
"Iter",
"to",
"the",
"next",
"item",
"in",
"the",
"list",
"which",
"will",
"then",
"be",
"available",
"through",
"the",
"Current",
"method",
".",
"It",
"returns",
"false",
"when",
"the",
"iterator",
"stops",
"at",
"the",
"end",
... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/iter.go#L55-L73 | train |
stripe/stripe-go | iter.go | GetIter | func GetIter(container ListParamsContainer, query Query) *Iter {
var listParams *ListParams
formValues := &form.Values{}
if container != nil {
reflectValue := reflect.ValueOf(container)
// See the comment on Call in stripe.go.
if reflectValue.Kind() == reflect.Ptr && !reflectValue.IsNil() {
listParams = container.GetListParams()
form.AppendTo(formValues, container)
}
}
if listParams == nil {
listParams = &ListParams{}
}
iter := &Iter{
formValues: formValues,
listParams: *listParams,
query: query,
}
iter.getPage()
return iter
} | go | func GetIter(container ListParamsContainer, query Query) *Iter {
var listParams *ListParams
formValues := &form.Values{}
if container != nil {
reflectValue := reflect.ValueOf(container)
// See the comment on Call in stripe.go.
if reflectValue.Kind() == reflect.Ptr && !reflectValue.IsNil() {
listParams = container.GetListParams()
form.AppendTo(formValues, container)
}
}
if listParams == nil {
listParams = &ListParams{}
}
iter := &Iter{
formValues: formValues,
listParams: *listParams,
query: query,
}
iter.getPage()
return iter
} | [
"func",
"GetIter",
"(",
"container",
"ListParamsContainer",
",",
"query",
"Query",
")",
"*",
"Iter",
"{",
"var",
"listParams",
"*",
"ListParams",
"\n",
"formValues",
":=",
"&",
"form",
".",
"Values",
"{",
"}",
"\n\n",
"if",
"container",
"!=",
"nil",
"{",
... | //
// Public functions
//
// GetIter returns a new Iter for a given query and its options. | [
"Public",
"functions",
"GetIter",
"returns",
"a",
"new",
"Iter",
"for",
"a",
"given",
"query",
"and",
"its",
"options",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/iter.go#L93-L119 | train |
stripe/stripe-go | orderreturn.go | UnmarshalJSON | func (r *OrderReturn) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type orderReturn OrderReturn
var v orderReturn
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = OrderReturn(v)
return nil
} | go | func (r *OrderReturn) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type orderReturn OrderReturn
var v orderReturn
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = OrderReturn(v)
return nil
} | [
"func",
"(",
"r",
"*",
"OrderReturn",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"r",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",... | // UnmarshalJSON handles deserialization of an OrderReturn.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"OrderReturn",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/orderreturn.go#L35-L49 | train |
stripe/stripe-go | charge.go | SetSource | func (p *ChargeParams) SetSource(sp interface{}) error {
source, err := SourceParamsFor(sp)
p.Source = source
return err
} | go | func (p *ChargeParams) SetSource(sp interface{}) error {
source, err := SourceParamsFor(sp)
p.Source = source
return err
} | [
"func",
"(",
"p",
"*",
"ChargeParams",
")",
"SetSource",
"(",
"sp",
"interface",
"{",
"}",
")",
"error",
"{",
"source",
",",
"err",
":=",
"SourceParamsFor",
"(",
"sp",
")",
"\n",
"p",
".",
"Source",
"=",
"source",
"\n",
"return",
"err",
"\n",
"}"
] | // SetSource adds valid sources to a ChargeParams object,
// returning an error for unsupported sources. | [
"SetSource",
"adds",
"valid",
"sources",
"to",
"a",
"ChargeParams",
"object",
"returning",
"an",
"error",
"for",
"unsupported",
"sources",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/charge.go#L112-L116 | train |
stripe/stripe-go | charge.go | UnmarshalJSON | func (c *Charge) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type charge Charge
var v charge
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Charge(v)
return nil
} | go | func (c *Charge) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type charge Charge
var v charge
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = Charge(v)
return nil
} | [
"func",
"(",
"c",
"*",
"Charge",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\... | // UnmarshalJSON handles deserialization of a charge.
// This custom unmarshaling is needed because the resulting
// property may be an ID or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"charge",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"ID",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/charge.go#L475-L489 | train |
stripe/stripe-go | charge.go | UnmarshalJSON | func (c *ChargeOutcomeRule) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type chargeOutcomeRule ChargeOutcomeRule
var v chargeOutcomeRule
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = ChargeOutcomeRule(v)
return nil
} | go | func (c *ChargeOutcomeRule) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
c.ID = id
return nil
}
type chargeOutcomeRule ChargeOutcomeRule
var v chargeOutcomeRule
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*c = ChargeOutcomeRule(v)
return nil
} | [
"func",
"(",
"c",
"*",
"ChargeOutcomeRule",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"c",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
... | // UnmarshalJSON handles deserialization of a ChargeOutcomeRule.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"ChargeOutcomeRule",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded"... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/charge.go#L536-L550 | train |
stripe/stripe-go | product/client.go | Get | func (c Client) Get(id string, params *stripe.ProductParams) (*stripe.Product, error) {
path := stripe.FormatURLPath("/v1/products/%s", id)
p := &stripe.Product{}
err := c.B.Call(http.MethodGet, path, c.Key, params, p)
return p, err
} | go | func (c Client) Get(id string, params *stripe.ProductParams) (*stripe.Product, error) {
path := stripe.FormatURLPath("/v1/products/%s", id)
p := &stripe.Product{}
err := c.B.Call(http.MethodGet, path, c.Key, params, p)
return p, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ProductParams",
")",
"(",
"*",
"stripe",
".",
"Product",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"i... | // Get returns the details of a product. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"product",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/product/client.go#L47-L52 | train |
stripe/stripe-go | product/client.go | Del | func Del(id string, params *stripe.ProductParams) (*stripe.Product, error) {
return getC().Del(id, params)
} | go | func Del(id string, params *stripe.ProductParams) (*stripe.Product, error) {
return getC().Del(id, params)
} | [
"func",
"Del",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ProductParams",
")",
"(",
"*",
"stripe",
".",
"Product",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Del",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Del deletes a product | [
"Del",
"deletes",
"a",
"product"
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/product/client.go#L75-L77 | train |
stripe/stripe-go | issuing_authorization.go | UnmarshalJSON | func (i *IssuingAuthorization) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingAuthorization IssuingAuthorization
var v issuingAuthorization
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingAuthorization(v)
return nil
} | go | func (i *IssuingAuthorization) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type issuingAuthorization IssuingAuthorization
var v issuingAuthorization
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = IssuingAuthorization(v)
return nil
} | [
"func",
"(",
"i",
"*",
"IssuingAuthorization",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"i",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n... | // UnmarshalJSON handles deserialization of an IssuingAuthorization.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"IssuingAuthorization",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expan... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/issuing_authorization.go#L154-L168 | train |
stripe/stripe-go | account.go | AppendTo | func (p *PayoutScheduleParams) AppendTo(body *form.Values, keyParts []string) {
if BoolValue(p.DelayDaysMinimum) {
body.Add(form.FormatKey(append(keyParts, "delay_days")), "minimum")
}
} | go | func (p *PayoutScheduleParams) AppendTo(body *form.Values, keyParts []string) {
if BoolValue(p.DelayDaysMinimum) {
body.Add(form.FormatKey(append(keyParts, "delay_days")), "minimum")
}
} | [
"func",
"(",
"p",
"*",
"PayoutScheduleParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"BoolValue",
"(",
"p",
".",
"DelayDaysMinimum",
")",
"{",
"body",
".",
"Add",
"(",
"form",
"... | // AppendTo implements custom encoding logic for PayoutScheduleParams
// so that we can send a special value for `delay_days` field if needed. | [
"AppendTo",
"implements",
"custom",
"encoding",
"logic",
"for",
"PayoutScheduleParams",
"so",
"that",
"we",
"can",
"send",
"a",
"special",
"value",
"for",
"delay_days",
"field",
"if",
"needed",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account.go#L183-L187 | train |
stripe/stripe-go | account.go | AppendTo | func (p *AccountExternalAccountParams) AppendTo(body *form.Values, keyParts []string) {
if p.Token != nil {
body.Add(form.FormatKey(keyParts), StringValue(p.Token))
} else {
body.Add(form.FormatKey(append(keyParts, "object")), "bank_account")
}
} | go | func (p *AccountExternalAccountParams) AppendTo(body *form.Values, keyParts []string) {
if p.Token != nil {
body.Add(form.FormatKey(keyParts), StringValue(p.Token))
} else {
body.Add(form.FormatKey(append(keyParts, "object")), "bank_account")
}
} | [
"func",
"(",
"p",
"*",
"AccountExternalAccountParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"p",
".",
"Token",
"!=",
"nil",
"{",
"body",
".",
"Add",
"(",
"form",
".",
"FormatKe... | // AppendTo implements custom encoding logic for AccountExternalAccountParams
// so that we can send the special required `object` field up along with the
// other specified parameters or the token value. | [
"AppendTo",
"implements",
"custom",
"encoding",
"logic",
"for",
"AccountExternalAccountParams",
"so",
"that",
"we",
"can",
"send",
"the",
"special",
"required",
"object",
"field",
"up",
"along",
"with",
"the",
"other",
"specified",
"parameters",
"or",
"the",
"toke... | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account.go#L256-L262 | train |
stripe/stripe-go | account.go | UnmarshalJSON | func (a *Account) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
a.ID = id
return nil
}
type account Account
var v account
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*a = Account(v)
return nil
} | go | func (a *Account) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
a.ID = id
return nil
}
type account Account
var v account
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*a = Account(v)
return nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"a",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"... | // UnmarshalJSON handles deserialization of an account.
// This custom unmarshaling is needed because the resulting
// property may be an ID or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"an",
"account",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"ID",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account.go#L399-L413 | train |
stripe/stripe-go | account.go | UnmarshalJSON | func (ea *ExternalAccount) UnmarshalJSON(data []byte) error {
type externalAccount ExternalAccount
var v externalAccount
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*ea = ExternalAccount(v)
switch ea.Type {
case ExternalAccountTypeBankAccount:
err = json.Unmarshal(data, &ea.BankAccount)
case ExternalAccountTypeCard:
err = json.Unmarshal(data, &ea.Card)
}
return err
} | go | func (ea *ExternalAccount) UnmarshalJSON(data []byte) error {
type externalAccount ExternalAccount
var v externalAccount
if err := json.Unmarshal(data, &v); err != nil {
return err
}
var err error
*ea = ExternalAccount(v)
switch ea.Type {
case ExternalAccountTypeBankAccount:
err = json.Unmarshal(data, &ea.BankAccount)
case ExternalAccountTypeCard:
err = json.Unmarshal(data, &ea.Card)
}
return err
} | [
"func",
"(",
"ea",
"*",
"ExternalAccount",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"type",
"externalAccount",
"ExternalAccount",
"\n",
"var",
"v",
"externalAccount",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"d... | // UnmarshalJSON implements Unmarshaler.UnmarshalJSON. | [
"UnmarshalJSON",
"implements",
"Unmarshaler",
".",
"UnmarshalJSON",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/account.go#L448-L466 | train |
stripe/stripe-go | review.go | UnmarshalJSON | func (r *Review) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type review Review
var v review
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Review(v)
return nil
} | go | func (r *Review) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type review Review
var v review
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Review(v)
return nil
} | [
"func",
"(",
"r",
"*",
"Review",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"r",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\... | // UnmarshalJSON handles deserialization of a Review.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Review",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/review.go#L57-L71 | train |
stripe/stripe-go | transfer.go | UnmarshalJSON | func (t *Transfer) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
t.ID = id
return nil
}
type transfer Transfer
var v transfer
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*t = Transfer(v)
return nil
} | go | func (t *Transfer) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
t.ID = id
return nil
}
type transfer Transfer
var v transfer
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*t = Transfer(v)
return nil
} | [
"func",
"(",
"t",
"*",
"Transfer",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"t",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
... | // UnmarshalJSON handles deserialization of a Transfer.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Transfer",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/transfer.go#L77-L91 | train |
stripe/stripe-go | transfer.go | UnmarshalJSON | func (d *TransferDestination) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
d.ID = id
return nil
}
type transferDestination TransferDestination
var v transferDestination
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*d = TransferDestination(v)
return json.Unmarshal(data, &d.Account)
} | go | func (d *TransferDestination) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
d.ID = id
return nil
}
type transferDestination TransferDestination
var v transferDestination
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*d = TransferDestination(v)
return json.Unmarshal(data, &d.Account)
} | [
"func",
"(",
"d",
"*",
"TransferDestination",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"d",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n"... | // UnmarshalJSON handles deserialization of a TransferDestination.
// This custom unmarshaling is needed because the specific
// type of destination it refers to is specified in the JSON | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"TransferDestination",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"specific",
"type",
"of",
"destination",
"it",
"refers",
"to",
"is",
"specified",
"in",
"the",
"JSON"
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/transfer.go#L96-L110 | train |
stripe/stripe-go | invoice/client.go | Pay | func Pay(id string, params *stripe.InvoicePayParams) (*stripe.Invoice, error) {
return getC().Pay(id, params)
} | go | func Pay(id string, params *stripe.InvoicePayParams) (*stripe.Invoice, error) {
return getC().Pay(id, params)
} | [
"func",
"Pay",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"InvoicePayParams",
")",
"(",
"*",
"stripe",
".",
"Invoice",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Pay",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Pay pays an invoice. | [
"Pay",
"pays",
"an",
"invoice",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/invoice/client.go#L56-L58 | train |
stripe/stripe-go | invoice/client.go | Update | func Update(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) {
return getC().Update(id, params)
} | go | func Update(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) {
return getC().Update(id, params)
} | [
"func",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"InvoiceParams",
")",
"(",
"*",
"stripe",
".",
"Invoice",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Update",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Update updates an invoice. | [
"Update",
"updates",
"an",
"invoice",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/invoice/client.go#L69-L71 | train |
stripe/stripe-go | invoice/client.go | ListLines | func (c Client) ListLines(listParams *stripe.InvoiceLineListParams) *LineIter {
path := stripe.FormatURLPath("/v1/invoices/%s/lines", stripe.StringValue(listParams.ID))
return &LineIter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.InvoiceLineList{}
err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list)
ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}
return ret, list.ListMeta, err
})}
} | go | func (c Client) ListLines(listParams *stripe.InvoiceLineListParams) *LineIter {
path := stripe.FormatURLPath("/v1/invoices/%s/lines", stripe.StringValue(listParams.ID))
return &LineIter{stripe.GetIter(listParams, func(p *stripe.Params, b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.InvoiceLineList{}
err := c.B.CallRaw(http.MethodGet, path, c.Key, b, p, list)
ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
ret[i] = v
}
return ret, list.ListMeta, err
})}
} | [
"func",
"(",
"c",
"Client",
")",
"ListLines",
"(",
"listParams",
"*",
"stripe",
".",
"InvoiceLineListParams",
")",
"*",
"LineIter",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"stripe",
".",
"StringValue",
"(",
"listParams",
".... | // ListLines returns a list of line items on an invoice. | [
"ListLines",
"returns",
"a",
"list",
"of",
"line",
"items",
"on",
"an",
"invoice",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/invoice/client.go#L119-L132 | train |
stripe/stripe-go | invoice/client.go | FinalizeInvoice | func FinalizeInvoice(id string, params *stripe.InvoiceFinalizeParams) (*stripe.Invoice, error) {
return getC().FinalizeInvoice(id, params)
} | go | func FinalizeInvoice(id string, params *stripe.InvoiceFinalizeParams) (*stripe.Invoice, error) {
return getC().FinalizeInvoice(id, params)
} | [
"func",
"FinalizeInvoice",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"InvoiceFinalizeParams",
")",
"(",
"*",
"stripe",
".",
"Invoice",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"FinalizeInvoice",
"(",
"id",
",",
"params",
")"... | // FinalizeInvoice finalizes an invoice. | [
"FinalizeInvoice",
"finalizes",
"an",
"invoice",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/invoice/client.go#L135-L137 | train |
stripe/stripe-go | invoice/client.go | MarkUncollectible | func MarkUncollectible(id string, params *stripe.InvoiceMarkUncollectibleParams) (*stripe.Invoice, error) {
return getC().MarkUncollectible(id, params)
} | go | func MarkUncollectible(id string, params *stripe.InvoiceMarkUncollectibleParams) (*stripe.Invoice, error) {
return getC().MarkUncollectible(id, params)
} | [
"func",
"MarkUncollectible",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"InvoiceMarkUncollectibleParams",
")",
"(",
"*",
"stripe",
".",
"Invoice",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"MarkUncollectible",
"(",
"id",
",",
"p... | // MarkUncollectible marks an invoice as uncollectible. | [
"MarkUncollectible",
"marks",
"an",
"invoice",
"as",
"uncollectible",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/invoice/client.go#L148-L150 | train |
stripe/stripe-go | invoice/client.go | SendInvoice | func SendInvoice(id string, params *stripe.InvoiceSendParams) (*stripe.Invoice, error) {
return getC().SendInvoice(id, params)
} | go | func SendInvoice(id string, params *stripe.InvoiceSendParams) (*stripe.Invoice, error) {
return getC().SendInvoice(id, params)
} | [
"func",
"SendInvoice",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"InvoiceSendParams",
")",
"(",
"*",
"stripe",
".",
"Invoice",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"SendInvoice",
"(",
"id",
",",
"params",
")",
"\n",
... | // SendInvoice sends an invoice. | [
"SendInvoice",
"sends",
"an",
"invoice",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/invoice/client.go#L161-L163 | train |
stripe/stripe-go | subschedule/client.go | Cancel | func Cancel(id string, params *stripe.SubscriptionScheduleCancelParams) (*stripe.SubscriptionSchedule, error) {
return getC().Cancel(id, params)
} | go | func Cancel(id string, params *stripe.SubscriptionScheduleCancelParams) (*stripe.SubscriptionSchedule, error) {
return getC().Cancel(id, params)
} | [
"func",
"Cancel",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"SubscriptionScheduleCancelParams",
")",
"(",
"*",
"stripe",
".",
"SubscriptionSchedule",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Cancel",
"(",
"id",
",",
"params",... | // Cancel removes a subscription schedule. | [
"Cancel",
"removes",
"a",
"subscription",
"schedule",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/subschedule/client.go#L18-L20 | train |
stripe/stripe-go | subschedule/client.go | Update | func Update(id string, params *stripe.SubscriptionScheduleParams) (*stripe.SubscriptionSchedule, error) {
return getC().Update(id, params)
} | go | func Update(id string, params *stripe.SubscriptionScheduleParams) (*stripe.SubscriptionSchedule, error) {
return getC().Update(id, params)
} | [
"func",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"SubscriptionScheduleParams",
")",
"(",
"*",
"stripe",
".",
"SubscriptionSchedule",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Update",
"(",
"id",
",",
"params",
")"... | // Update updates a subscription schedule's properties. | [
"Update",
"updates",
"a",
"subscription",
"schedule",
"s",
"properties",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/subschedule/client.go#L90-L92 | train |
stripe/stripe-go | refund/client.go | Get | func (c Client) Get(id string, params *stripe.RefundParams) (*stripe.Refund, error) {
path := stripe.FormatURLPath("/v1/refunds/%s", id)
refund := &stripe.Refund{}
err := c.B.Call(http.MethodGet, path, c.Key, params, refund)
return refund, err
} | go | func (c Client) Get(id string, params *stripe.RefundParams) (*stripe.Refund, error) {
path := stripe.FormatURLPath("/v1/refunds/%s", id)
refund := &stripe.Refund{}
err := c.B.Call(http.MethodGet, path, c.Key, params, refund)
return refund, err
} | [
"func",
"(",
"c",
"Client",
")",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"RefundParams",
")",
"(",
"*",
"stripe",
".",
"Refund",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
",",
"id"... | // Get returns the details of a refund. | [
"Get",
"returns",
"the",
"details",
"of",
"a",
"refund",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/refund/client.go#L35-L40 | train |
stripe/stripe-go | refund/client.go | Update | func Update(id string, params *stripe.RefundParams) (*stripe.Refund, error) {
return getC().Update(id, params)
} | go | func Update(id string, params *stripe.RefundParams) (*stripe.Refund, error) {
return getC().Update(id, params)
} | [
"func",
"Update",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"RefundParams",
")",
"(",
"*",
"stripe",
".",
"Refund",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Update",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Update updates a refund's properties. | [
"Update",
"updates",
"a",
"refund",
"s",
"properties",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/refund/client.go#L43-L45 | train |
stripe/stripe-go | plan.go | AppendTo | func (p *PlanTierParams) AppendTo(body *form.Values, keyParts []string) {
if BoolValue(p.UpToInf) {
body.Add(form.FormatKey(append(keyParts, "up_to")), "inf")
} else {
body.Add(form.FormatKey(append(keyParts, "up_to")), strconv.FormatInt(Int64Value(p.UpTo), 10))
}
} | go | func (p *PlanTierParams) AppendTo(body *form.Values, keyParts []string) {
if BoolValue(p.UpToInf) {
body.Add(form.FormatKey(append(keyParts, "up_to")), "inf")
} else {
body.Add(form.FormatKey(append(keyParts, "up_to")), strconv.FormatInt(Int64Value(p.UpTo), 10))
}
} | [
"func",
"(",
"p",
"*",
"PlanTierParams",
")",
"AppendTo",
"(",
"body",
"*",
"form",
".",
"Values",
",",
"keyParts",
"[",
"]",
"string",
")",
"{",
"if",
"BoolValue",
"(",
"p",
".",
"UpToInf",
")",
"{",
"body",
".",
"Add",
"(",
"form",
".",
"FormatKe... | // AppendTo implements custom up_to serialisation logic for tiers configuration | [
"AppendTo",
"implements",
"custom",
"up_to",
"serialisation",
"logic",
"for",
"tiers",
"configuration"
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/plan.go#L159-L165 | train |
stripe/stripe-go | plan.go | UnmarshalJSON | func (s *Plan) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type plan Plan
var v plan
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = Plan(v)
return nil
} | go | func (s *Plan) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
s.ID = id
return nil
}
type plan Plan
var v plan
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*s = Plan(v)
return nil
} | [
"func",
"(",
"s",
"*",
"Plan",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"id",
",",
"ok",
":=",
"ParseID",
"(",
"data",
")",
";",
"ok",
"{",
"s",
".",
"ID",
"=",
"id",
"\n",
"return",
"nil",
"\n",
"}",
"\n\... | // UnmarshalJSON handles deserialization of a Plan.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded. | [
"UnmarshalJSON",
"handles",
"deserialization",
"of",
"a",
"Plan",
".",
"This",
"custom",
"unmarshaling",
"is",
"needed",
"because",
"the",
"resulting",
"property",
"may",
"be",
"an",
"id",
"or",
"the",
"full",
"struct",
"if",
"it",
"was",
"expanded",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/plan.go#L182-L196 | train |
stripe/stripe-go | invoiceitem/client.go | Del | func (c Client) Del(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) {
path := stripe.FormatURLPath("/v1/invoiceitems/%s", id)
ii := &stripe.InvoiceItem{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, ii)
return ii, err
} | go | func (c Client) Del(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) {
path := stripe.FormatURLPath("/v1/invoiceitems/%s", id)
ii := &stripe.InvoiceItem{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, ii)
return ii, err
} | [
"func",
"(",
"c",
"Client",
")",
"Del",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"InvoiceItemParams",
")",
"(",
"*",
"stripe",
".",
"InvoiceItem",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"",
"... | // Del removes an invoice item. | [
"Del",
"removes",
"an",
"invoice",
"item",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/invoiceitem/client.go#L61-L66 | train |
stripe/stripe-go | applepaydomain/client.go | Get | func Get(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
return getC().Get(id, params)
} | go | func Get(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
return getC().Get(id, params)
} | [
"func",
"Get",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ApplePayDomainParams",
")",
"(",
"*",
"stripe",
".",
"ApplePayDomain",
",",
"error",
")",
"{",
"return",
"getC",
"(",
")",
".",
"Get",
"(",
"id",
",",
"params",
")",
"\n",
"}"
] | // Get retrieves an Apple Pay domain. | [
"Get",
"retrieves",
"an",
"Apple",
"Pay",
"domain",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/applepaydomain/client.go#L30-L32 | train |
stripe/stripe-go | applepaydomain/client.go | Del | func (c Client) Del(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
path := stripe.FormatURLPath("/v1/apple_pay/domains/%s", id)
domain := &stripe.ApplePayDomain{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, domain)
return domain, err
} | go | func (c Client) Del(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
path := stripe.FormatURLPath("/v1/apple_pay/domains/%s", id)
domain := &stripe.ApplePayDomain{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, domain)
return domain, err
} | [
"func",
"(",
"c",
"Client",
")",
"Del",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ApplePayDomainParams",
")",
"(",
"*",
"stripe",
".",
"ApplePayDomain",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"... | // Del removes an Apple Pay domain. | [
"Del",
"removes",
"an",
"Apple",
"Pay",
"domain",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/applepaydomain/client.go#L48-L53 | train |
stripe/stripe-go | log.go | Warnf | func (l *LeveledLogger) Warnf(format string, v ...interface{}) {
if l.Level >= LevelWarn {
fmt.Fprintf(l.stderr(), "[WARN] "+format+"\n", v...)
}
} | go | func (l *LeveledLogger) Warnf(format string, v ...interface{}) {
if l.Level >= LevelWarn {
fmt.Fprintf(l.stderr(), "[WARN] "+format+"\n", v...)
}
} | [
"func",
"(",
"l",
"*",
"LeveledLogger",
")",
"Warnf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"l",
".",
"Level",
">=",
"LevelWarn",
"{",
"fmt",
".",
"Fprintf",
"(",
"l",
".",
"stderr",
"(",
")",
",",
"\"",... | // Warnf logs a warning message using Printf conventions. | [
"Warnf",
"logs",
"a",
"warning",
"message",
"using",
"Printf",
"conventions",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/log.go#L123-L127 | train |
faiface/beep | effects/pan.go | Stream | func (p *Pan) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = p.Streamer.Stream(samples)
switch {
case p.Pan < 0:
for i := range samples[:n] {
r := samples[i][1]
samples[i][0] += -p.Pan * r
samples[i][1] -= -p.Pan * r
}
case p.Pan > 0:
for i := range samples[:n] {
l := samples[i][0]
samples[i][0] -= p.Pan * l
samples[i][1] += p.Pan * l
}
}
return n, ok
} | go | func (p *Pan) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = p.Streamer.Stream(samples)
switch {
case p.Pan < 0:
for i := range samples[:n] {
r := samples[i][1]
samples[i][0] += -p.Pan * r
samples[i][1] -= -p.Pan * r
}
case p.Pan > 0:
for i := range samples[:n] {
l := samples[i][0]
samples[i][0] -= p.Pan * l
samples[i][1] += p.Pan * l
}
}
return n, ok
} | [
"func",
"(",
"p",
"*",
"Pan",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"n",
",",
"ok",
"=",
"p",
".",
"Streamer",
".",
"Stream",
"(",
"samples",
")",
"\n",
"switch",... | // Stream streams the wrapped Streamer balanced by Pan. | [
"Stream",
"streams",
"the",
"wrapped",
"Streamer",
"balanced",
"by",
"Pan",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/effects/pan.go#L14-L31 | train |
faiface/beep | resample.go | ResampleRatio | func ResampleRatio(quality int, ratio float64, s Streamer) *Resampler {
if quality < 1 || 64 < quality {
panic(fmt.Errorf("resample: invalid quality: %d", quality))
}
return &Resampler{
s: s,
ratio: ratio,
first: true,
buf1: make([][2]float64, 512),
buf2: make([][2]float64, 512),
pts: make([]point, quality*2),
off: 0,
pos: 0,
}
} | go | func ResampleRatio(quality int, ratio float64, s Streamer) *Resampler {
if quality < 1 || 64 < quality {
panic(fmt.Errorf("resample: invalid quality: %d", quality))
}
return &Resampler{
s: s,
ratio: ratio,
first: true,
buf1: make([][2]float64, 512),
buf2: make([][2]float64, 512),
pts: make([]point, quality*2),
off: 0,
pos: 0,
}
} | [
"func",
"ResampleRatio",
"(",
"quality",
"int",
",",
"ratio",
"float64",
",",
"s",
"Streamer",
")",
"*",
"Resampler",
"{",
"if",
"quality",
"<",
"1",
"||",
"64",
"<",
"quality",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"quality"... | // ResampleRatio is same as Resample, except it takes the ratio of the old and the new sample rate,
// specifically, the old sample rate divided by the new sample rate. Aside from correcting the
// sample rate, this can be used to change the speed of the audio. For example, resampling at the
// ratio of 2 and playing at the original sample rate will cause doubled speed in playback. | [
"ResampleRatio",
"is",
"same",
"as",
"Resample",
"except",
"it",
"takes",
"the",
"ratio",
"of",
"the",
"old",
"and",
"the",
"new",
"sample",
"rate",
"specifically",
"the",
"old",
"sample",
"rate",
"divided",
"by",
"the",
"new",
"sample",
"rate",
".",
"Asid... | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/resample.go#L43-L57 | train |
faiface/beep | resample.go | Stream | func (r *Resampler) Stream(samples [][2]float64) (n int, ok bool) {
// if it's the first time, we need to fill buf2 with initial data, buf1 remains zeroed
if r.first {
sn, _ := r.s.Stream(r.buf2)
r.buf2 = r.buf2[:sn]
r.first = false
}
// we start resampling, sample by sample
for len(samples) > 0 {
again:
for c := range samples[0] {
// calculate the current position in the original data
j := float64(r.pos) * r.ratio
// find quality*2 closest samples to j and translate them to points for interpolation
for pi := range r.pts {
// calculate the index of one of the closest samples
k := int(j) + pi - len(r.pts)/2 + 1
var y float64
switch {
// the sample is in buf1
case k < r.off:
y = r.buf1[len(r.buf1)+k-r.off][c]
// the sample is in buf2
case k < r.off+len(r.buf2):
y = r.buf2[k-r.off][c]
// the sample is beyond buf2, so we need to load new data
case k >= r.off+len(r.buf2):
// we load into buf1
sn, _ := r.s.Stream(r.buf1)
// this condition happens when the original Streamer got
// drained and j is after the end of the
// original data
if int(j) >= r.off+len(r.buf2)+sn {
return n, n > 0
}
// this condition happens when the original Streamer got
// drained and this one of the closest samples is after the
// end of the original data
if k >= r.off+len(r.buf2)+sn {
y = 0
break
}
// otherwise everything is fine, we swap buffers and start
// calculating the sample again
r.off += len(r.buf2)
r.buf1 = r.buf1[:sn]
r.buf1, r.buf2 = r.buf2, r.buf1
goto again
}
r.pts[pi] = point{float64(k), y}
}
// calculate the resampled sample using polynomial interpolation from the
// quality*2 closest samples
samples[0][c] = lagrange(r.pts, j)
}
samples = samples[1:]
n++
r.pos++
}
return n, true
} | go | func (r *Resampler) Stream(samples [][2]float64) (n int, ok bool) {
// if it's the first time, we need to fill buf2 with initial data, buf1 remains zeroed
if r.first {
sn, _ := r.s.Stream(r.buf2)
r.buf2 = r.buf2[:sn]
r.first = false
}
// we start resampling, sample by sample
for len(samples) > 0 {
again:
for c := range samples[0] {
// calculate the current position in the original data
j := float64(r.pos) * r.ratio
// find quality*2 closest samples to j and translate them to points for interpolation
for pi := range r.pts {
// calculate the index of one of the closest samples
k := int(j) + pi - len(r.pts)/2 + 1
var y float64
switch {
// the sample is in buf1
case k < r.off:
y = r.buf1[len(r.buf1)+k-r.off][c]
// the sample is in buf2
case k < r.off+len(r.buf2):
y = r.buf2[k-r.off][c]
// the sample is beyond buf2, so we need to load new data
case k >= r.off+len(r.buf2):
// we load into buf1
sn, _ := r.s.Stream(r.buf1)
// this condition happens when the original Streamer got
// drained and j is after the end of the
// original data
if int(j) >= r.off+len(r.buf2)+sn {
return n, n > 0
}
// this condition happens when the original Streamer got
// drained and this one of the closest samples is after the
// end of the original data
if k >= r.off+len(r.buf2)+sn {
y = 0
break
}
// otherwise everything is fine, we swap buffers and start
// calculating the sample again
r.off += len(r.buf2)
r.buf1 = r.buf1[:sn]
r.buf1, r.buf2 = r.buf2, r.buf1
goto again
}
r.pts[pi] = point{float64(k), y}
}
// calculate the resampled sample using polynomial interpolation from the
// quality*2 closest samples
samples[0][c] = lagrange(r.pts, j)
}
samples = samples[1:]
n++
r.pos++
}
return n, true
} | [
"func",
"(",
"r",
"*",
"Resampler",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"// if it's the first time, we need to fill buf2 with initial data, buf1 remains zeroed",
"if",
"r",
".",
... | // Stream streams the original audio resampled according to the current ratio. | [
"Stream",
"streams",
"the",
"original",
"audio",
"resampled",
"according",
"to",
"the",
"current",
"ratio",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/resample.go#L73-L137 | train |
faiface/beep | resample.go | SetRatio | func (r *Resampler) SetRatio(ratio float64) {
r.pos = int(float64(r.pos) * r.ratio / ratio)
r.ratio = ratio
} | go | func (r *Resampler) SetRatio(ratio float64) {
r.pos = int(float64(r.pos) * r.ratio / ratio)
r.ratio = ratio
} | [
"func",
"(",
"r",
"*",
"Resampler",
")",
"SetRatio",
"(",
"ratio",
"float64",
")",
"{",
"r",
".",
"pos",
"=",
"int",
"(",
"float64",
"(",
"r",
".",
"pos",
")",
"*",
"r",
".",
"ratio",
"/",
"ratio",
")",
"\n",
"r",
".",
"ratio",
"=",
"ratio",
... | // SetRatio sets the resampling ratio. This does not cause any glitches in the stream. | [
"SetRatio",
"sets",
"the",
"resampling",
"ratio",
".",
"This",
"does",
"not",
"cause",
"any",
"glitches",
"in",
"the",
"stream",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/resample.go#L150-L153 | train |
faiface/beep | ctrl.go | Stream | func (c *Ctrl) Stream(samples [][2]float64) (n int, ok bool) {
if c.Streamer == nil {
return 0, false
}
if c.Paused {
for i := range samples {
samples[i] = [2]float64{}
}
return len(samples), true
}
return c.Streamer.Stream(samples)
} | go | func (c *Ctrl) Stream(samples [][2]float64) (n int, ok bool) {
if c.Streamer == nil {
return 0, false
}
if c.Paused {
for i := range samples {
samples[i] = [2]float64{}
}
return len(samples), true
}
return c.Streamer.Stream(samples)
} | [
"func",
"(",
"c",
"*",
"Ctrl",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"if",
"c",
".",
"Streamer",
"==",
"nil",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
... | // Stream streams the wrapped Streamer, if not nil. If the Streamer is nil, Ctrl acts as drained.
// When paused, Ctrl streams silence. | [
"Stream",
"streams",
"the",
"wrapped",
"Streamer",
"if",
"not",
"nil",
".",
"If",
"the",
"Streamer",
"is",
"nil",
"Ctrl",
"acts",
"as",
"drained",
".",
"When",
"paused",
"Ctrl",
"streams",
"silence",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/ctrl.go#L33-L44 | train |
faiface/beep | ctrl.go | Err | func (c *Ctrl) Err() error {
if c.Streamer == nil {
return nil
}
return c.Streamer.Err()
} | go | func (c *Ctrl) Err() error {
if c.Streamer == nil {
return nil
}
return c.Streamer.Err()
} | [
"func",
"(",
"c",
"*",
"Ctrl",
")",
"Err",
"(",
")",
"error",
"{",
"if",
"c",
".",
"Streamer",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"c",
".",
"Streamer",
".",
"Err",
"(",
")",
"\n",
"}"
] | // Err returns the error of the wrapped Streamer, if not nil. | [
"Err",
"returns",
"the",
"error",
"of",
"the",
"wrapped",
"Streamer",
"if",
"not",
"nil",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/ctrl.go#L47-L52 | train |
faiface/beep | buffer.go | D | func (sr SampleRate) D(n int) time.Duration {
return time.Second * time.Duration(n) / time.Duration(sr)
} | go | func (sr SampleRate) D(n int) time.Duration {
return time.Second * time.Duration(n) / time.Duration(sr)
} | [
"func",
"(",
"sr",
"SampleRate",
")",
"D",
"(",
"n",
"int",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Second",
"*",
"time",
".",
"Duration",
"(",
"n",
")",
"/",
"time",
".",
"Duration",
"(",
"sr",
")",
"\n",
"}"
] | // D returns the duration of n samples. | [
"D",
"returns",
"the",
"duration",
"of",
"n",
"samples",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L13-L15 | train |
faiface/beep | buffer.go | N | func (sr SampleRate) N(d time.Duration) int {
return int(d * time.Duration(sr) / time.Second)
} | go | func (sr SampleRate) N(d time.Duration) int {
return int(d * time.Duration(sr) / time.Second)
} | [
"func",
"(",
"sr",
"SampleRate",
")",
"N",
"(",
"d",
"time",
".",
"Duration",
")",
"int",
"{",
"return",
"int",
"(",
"d",
"*",
"time",
".",
"Duration",
"(",
"sr",
")",
"/",
"time",
".",
"Second",
")",
"\n",
"}"
] | // N returns the number of samples that last for d duration. | [
"N",
"returns",
"the",
"number",
"of",
"samples",
"that",
"last",
"for",
"d",
"duration",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L18-L20 | train |
faiface/beep | buffer.go | NewBuffer | func NewBuffer(f Format) *Buffer {
return &Buffer{f: f, tmp: make([]byte, f.Width())}
} | go | func NewBuffer(f Format) *Buffer {
return &Buffer{f: f, tmp: make([]byte, f.Width())}
} | [
"func",
"NewBuffer",
"(",
"f",
"Format",
")",
"*",
"Buffer",
"{",
"return",
"&",
"Buffer",
"{",
"f",
":",
"f",
",",
"tmp",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"f",
".",
"Width",
"(",
")",
")",
"}",
"\n",
"}"
] | // NewBuffer creates a new empty Buffer which stores samples in the provided format. | [
"NewBuffer",
"creates",
"a",
"new",
"empty",
"Buffer",
"which",
"stores",
"samples",
"in",
"the",
"provided",
"format",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L171-L173 | train |
faiface/beep | buffer.go | Len | func (b *Buffer) Len() int {
return len(b.data) / b.f.Width()
} | go | func (b *Buffer) Len() int {
return len(b.data) / b.f.Width()
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Len",
"(",
")",
"int",
"{",
"return",
"len",
"(",
"b",
".",
"data",
")",
"/",
"b",
".",
"f",
".",
"Width",
"(",
")",
"\n",
"}"
] | // Len returns the number of samples currently in the Buffer. | [
"Len",
"returns",
"the",
"number",
"of",
"samples",
"currently",
"in",
"the",
"Buffer",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L181-L183 | train |
faiface/beep | buffer.go | Pop | func (b *Buffer) Pop(n int) {
b.data = b.data[n:]
} | go | func (b *Buffer) Pop(n int) {
b.data = b.data[n:]
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Pop",
"(",
"n",
"int",
")",
"{",
"b",
".",
"data",
"=",
"b",
".",
"data",
"[",
"n",
":",
"]",
"\n",
"}"
] | // Pop removes n samples from the beginning of the Buffer.
//
// Existing Streamers are not affected. | [
"Pop",
"removes",
"n",
"samples",
"from",
"the",
"beginning",
"of",
"the",
"Buffer",
".",
"Existing",
"Streamers",
"are",
"not",
"affected",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L188-L190 | train |
faiface/beep | buffer.go | Append | func (b *Buffer) Append(s Streamer) {
var samples [512][2]float64
for {
n, ok := s.Stream(samples[:])
if !ok {
break
}
for _, sample := range samples[:n] {
b.f.EncodeSigned(b.tmp, sample)
b.data = append(b.data, b.tmp...)
}
}
} | go | func (b *Buffer) Append(s Streamer) {
var samples [512][2]float64
for {
n, ok := s.Stream(samples[:])
if !ok {
break
}
for _, sample := range samples[:n] {
b.f.EncodeSigned(b.tmp, sample)
b.data = append(b.data, b.tmp...)
}
}
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Append",
"(",
"s",
"Streamer",
")",
"{",
"var",
"samples",
"[",
"512",
"]",
"[",
"2",
"]",
"float64",
"\n",
"for",
"{",
"n",
",",
"ok",
":=",
"s",
".",
"Stream",
"(",
"samples",
"[",
":",
"]",
")",
"\n",... | // Append adds all audio data from the given Streamer to the end of the Buffer.
//
// The Streamer will be drained when this method finishes. | [
"Append",
"adds",
"all",
"audio",
"data",
"from",
"the",
"given",
"Streamer",
"to",
"the",
"end",
"of",
"the",
"Buffer",
".",
"The",
"Streamer",
"will",
"be",
"drained",
"when",
"this",
"method",
"finishes",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L195-L207 | train |
faiface/beep | mp3/decode.go | Decode | func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err error) {
defer func() {
if err != nil {
err = errors.Wrap(err, "mp3")
}
}()
d, err := gomp3.NewDecoder(rc)
if err != nil {
return nil, beep.Format{}, err
}
format = beep.Format{
SampleRate: beep.SampleRate(d.SampleRate()),
NumChannels: gomp3NumChannels,
Precision: gomp3Precision,
}
return &decoder{rc, d, format, 0, nil}, format, nil
} | go | func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err error) {
defer func() {
if err != nil {
err = errors.Wrap(err, "mp3")
}
}()
d, err := gomp3.NewDecoder(rc)
if err != nil {
return nil, beep.Format{}, err
}
format = beep.Format{
SampleRate: beep.SampleRate(d.SampleRate()),
NumChannels: gomp3NumChannels,
Precision: gomp3Precision,
}
return &decoder{rc, d, format, 0, nil}, format, nil
} | [
"func",
"Decode",
"(",
"rc",
"io",
".",
"ReadCloser",
")",
"(",
"s",
"beep",
".",
"StreamSeekCloser",
",",
"format",
"beep",
".",
"Format",
",",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
... | // Decode takes a ReadCloser containing audio data in MP3 format and returns a StreamSeekCloser,
// which streams that audio. The Seek method will panic if rc is not io.Seeker.
//
// Do not close the supplied ReadSeekCloser, instead, use the Close method of the returned
// StreamSeekCloser when you want to release the resources. | [
"Decode",
"takes",
"a",
"ReadCloser",
"containing",
"audio",
"data",
"in",
"MP3",
"format",
"and",
"returns",
"a",
"StreamSeekCloser",
"which",
"streams",
"that",
"audio",
".",
"The",
"Seek",
"method",
"will",
"panic",
"if",
"rc",
"is",
"not",
"io",
".",
"... | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/mp3/decode.go#L24-L40 | train |
faiface/beep | effects/gain.go | Stream | func (g *Gain) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = g.Streamer.Stream(samples)
for i := range samples[:n] {
samples[i][0] *= 1 + g.Gain
samples[i][1] *= 1 + g.Gain
}
return n, ok
} | go | func (g *Gain) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = g.Streamer.Stream(samples)
for i := range samples[:n] {
samples[i][0] *= 1 + g.Gain
samples[i][1] *= 1 + g.Gain
}
return n, ok
} | [
"func",
"(",
"g",
"*",
"Gain",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"n",
",",
"ok",
"=",
"g",
".",
"Streamer",
".",
"Stream",
"(",
"samples",
")",
"\n",
"for",
... | // Stream streams the wrapped Streamer amplified by Gain. | [
"Stream",
"streams",
"the",
"wrapped",
"Streamer",
"amplified",
"by",
"Gain",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/effects/gain.go#L16-L23 | train |
faiface/beep | streamers.go | Silence | func Silence(num int) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if num == 0 {
return 0, false
}
if 0 < num && num < len(samples) {
samples = samples[:num]
}
for i := range samples {
samples[i] = [2]float64{}
}
if num > 0 {
num -= len(samples)
}
return len(samples), true
})
} | go | func Silence(num int) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if num == 0 {
return 0, false
}
if 0 < num && num < len(samples) {
samples = samples[:num]
}
for i := range samples {
samples[i] = [2]float64{}
}
if num > 0 {
num -= len(samples)
}
return len(samples), true
})
} | [
"func",
"Silence",
"(",
"num",
"int",
")",
"Streamer",
"{",
"return",
"StreamerFunc",
"(",
"func",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"if",
"num",
"==",
"0",
"{",
"return",
"0",
... | // Silence returns a Streamer which streams num samples of silence. If num is negative, silence is
// streamed forever. | [
"Silence",
"returns",
"a",
"Streamer",
"which",
"streams",
"num",
"samples",
"of",
"silence",
".",
"If",
"num",
"is",
"negative",
"silence",
"is",
"streamed",
"forever",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/streamers.go#L5-L21 | train |
faiface/beep | streamers.go | Callback | func Callback(f func()) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if f != nil {
f()
f = nil
}
return 0, false
})
} | go | func Callback(f func()) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if f != nil {
f()
f = nil
}
return 0, false
})
} | [
"func",
"Callback",
"(",
"f",
"func",
"(",
")",
")",
"Streamer",
"{",
"return",
"StreamerFunc",
"(",
"func",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"if",
"f",
"!=",
"nil",
"{",
"f"... | // Callback returns a Streamer, which does not stream any samples, but instead calls f the first
// time its Stream method is called. | [
"Callback",
"returns",
"a",
"Streamer",
"which",
"does",
"not",
"stream",
"any",
"samples",
"but",
"instead",
"calls",
"f",
"the",
"first",
"time",
"its",
"Stream",
"method",
"is",
"called",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/streamers.go#L25-L33 | train |
faiface/beep | streamers.go | Iterate | func Iterate(g func() Streamer) Streamer {
var (
s Streamer
first = true
)
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if first {
s = g()
first = false
}
if s == nil {
return 0, false
}
for len(samples) > 0 {
if s == nil {
break
}
sn, sok := s.Stream(samples)
if !sok {
s = g()
}
samples = samples[sn:]
n += sn
}
return n, true
})
} | go | func Iterate(g func() Streamer) Streamer {
var (
s Streamer
first = true
)
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if first {
s = g()
first = false
}
if s == nil {
return 0, false
}
for len(samples) > 0 {
if s == nil {
break
}
sn, sok := s.Stream(samples)
if !sok {
s = g()
}
samples = samples[sn:]
n += sn
}
return n, true
})
} | [
"func",
"Iterate",
"(",
"g",
"func",
"(",
")",
"Streamer",
")",
"Streamer",
"{",
"var",
"(",
"s",
"Streamer",
"\n",
"first",
"=",
"true",
"\n",
")",
"\n",
"return",
"StreamerFunc",
"(",
"func",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")... | // Iterate returns a Streamer which successively streams Streamers obtains by calling the provided g
// function. The streaming stops when g returns nil.
//
// Iterate does not propagate errors from the generated Streamers. | [
"Iterate",
"returns",
"a",
"Streamer",
"which",
"successively",
"streams",
"Streamers",
"obtains",
"by",
"calling",
"the",
"provided",
"g",
"function",
".",
"The",
"streaming",
"stops",
"when",
"g",
"returns",
"nil",
".",
"Iterate",
"does",
"not",
"propagate",
... | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/streamers.go#L39-L65 | train |
faiface/beep | flac/decode.go | Decode | func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err error) {
d := decoder{rc: rc}
defer func() { // hacky way to always close rc if an error occurred
if err != nil {
d.rc.Close()
}
}()
d.stream, err = flac.New(rc)
if err != nil {
return nil, beep.Format{}, errors.Wrap(err, "flac")
}
format = beep.Format{
SampleRate: beep.SampleRate(d.stream.Info.SampleRate),
NumChannels: int(d.stream.Info.NChannels),
Precision: int(d.stream.Info.BitsPerSample / 8),
}
return &d, format, nil
} | go | func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err error) {
d := decoder{rc: rc}
defer func() { // hacky way to always close rc if an error occurred
if err != nil {
d.rc.Close()
}
}()
d.stream, err = flac.New(rc)
if err != nil {
return nil, beep.Format{}, errors.Wrap(err, "flac")
}
format = beep.Format{
SampleRate: beep.SampleRate(d.stream.Info.SampleRate),
NumChannels: int(d.stream.Info.NChannels),
Precision: int(d.stream.Info.BitsPerSample / 8),
}
return &d, format, nil
} | [
"func",
"Decode",
"(",
"rc",
"io",
".",
"ReadCloser",
")",
"(",
"s",
"beep",
".",
"StreamSeekCloser",
",",
"format",
"beep",
".",
"Format",
",",
"err",
"error",
")",
"{",
"d",
":=",
"decoder",
"{",
"rc",
":",
"rc",
"}",
"\n",
"defer",
"func",
"(",
... | // Decode takes a ReadCloser containing audio data in FLAC format and returns a StreamSeekCloser,
// which streams that audio. The Seek method will panic if rc is not io.Seeker.
//
// Do not close the supplied ReadSeekCloser, instead, use the Close method of the returned
// StreamSeekCloser when you want to release the resources. | [
"Decode",
"takes",
"a",
"ReadCloser",
"containing",
"audio",
"data",
"in",
"FLAC",
"format",
"and",
"returns",
"a",
"StreamSeekCloser",
"which",
"streams",
"that",
"audio",
".",
"The",
"Seek",
"method",
"will",
"panic",
"if",
"rc",
"is",
"not",
"io",
".",
... | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/flac/decode.go#L17-L34 | train |
faiface/beep | mixer.go | Add | func (m *Mixer) Add(s ...Streamer) {
m.streamers = append(m.streamers, s...)
} | go | func (m *Mixer) Add(s ...Streamer) {
m.streamers = append(m.streamers, s...)
} | [
"func",
"(",
"m",
"*",
"Mixer",
")",
"Add",
"(",
"s",
"...",
"Streamer",
")",
"{",
"m",
".",
"streamers",
"=",
"append",
"(",
"m",
".",
"streamers",
",",
"s",
"...",
")",
"\n",
"}"
] | // Add adds Streamers to the Mixer. | [
"Add",
"adds",
"Streamers",
"to",
"the",
"Mixer",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/mixer.go#L15-L17 | train |
faiface/beep | interface.go | Stream | func (sf StreamerFunc) Stream(samples [][2]float64) (n int, ok bool) {
return sf(samples)
} | go | func (sf StreamerFunc) Stream(samples [][2]float64) (n int, ok bool) {
return sf(samples)
} | [
"func",
"(",
"sf",
"StreamerFunc",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"return",
"sf",
"(",
"samples",
")",
"\n",
"}"
] | // Stream calls the wrapped streaming function. | [
"Stream",
"calls",
"the",
"wrapped",
"streaming",
"function",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/interface.go#L99-L101 | train |
faiface/beep | speaker/speaker.go | Init | func Init(sampleRate beep.SampleRate, bufferSize int) error {
mu.Lock()
defer mu.Unlock()
if player != nil {
done <- struct{}{}
player.Close()
context.Close()
}
mixer = beep.Mixer{}
numBytes := bufferSize * 4
samples = make([][2]float64, bufferSize)
buf = make([]byte, numBytes)
var err error
context, err = oto.NewContext(int(sampleRate), 2, 2, numBytes)
if err != nil {
return errors.Wrap(err, "failed to initialize speaker")
}
player = context.NewPlayer()
done = make(chan struct{})
go func() {
for {
select {
default:
update()
case <-done:
return
}
}
}()
return nil
} | go | func Init(sampleRate beep.SampleRate, bufferSize int) error {
mu.Lock()
defer mu.Unlock()
if player != nil {
done <- struct{}{}
player.Close()
context.Close()
}
mixer = beep.Mixer{}
numBytes := bufferSize * 4
samples = make([][2]float64, bufferSize)
buf = make([]byte, numBytes)
var err error
context, err = oto.NewContext(int(sampleRate), 2, 2, numBytes)
if err != nil {
return errors.Wrap(err, "failed to initialize speaker")
}
player = context.NewPlayer()
done = make(chan struct{})
go func() {
for {
select {
default:
update()
case <-done:
return
}
}
}()
return nil
} | [
"func",
"Init",
"(",
"sampleRate",
"beep",
".",
"SampleRate",
",",
"bufferSize",
"int",
")",
"error",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"player",
"!=",
"nil",
"{",
"done",
"<-",
"struct",
... | // Init initializes audio playback through speaker. Must be called before using this package.
//
// The bufferSize argument specifies the number of samples of the speaker's buffer. Bigger
// bufferSize means lower CPU usage and more reliable playback. Lower bufferSize means better
// responsiveness and less delay. | [
"Init",
"initializes",
"audio",
"playback",
"through",
"speaker",
".",
"Must",
"be",
"called",
"before",
"using",
"this",
"package",
".",
"The",
"bufferSize",
"argument",
"specifies",
"the",
"number",
"of",
"samples",
"of",
"the",
"speaker",
"s",
"buffer",
"."... | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/speaker/speaker.go#L27-L64 | train |
faiface/beep | speaker/speaker.go | Play | func Play(s ...beep.Streamer) {
mu.Lock()
mixer.Add(s...)
mu.Unlock()
} | go | func Play(s ...beep.Streamer) {
mu.Lock()
mixer.Add(s...)
mu.Unlock()
} | [
"func",
"Play",
"(",
"s",
"...",
"beep",
".",
"Streamer",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"mixer",
".",
"Add",
"(",
"s",
"...",
")",
"\n",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Play starts playing all provided Streamers through the speaker. | [
"Play",
"starts",
"playing",
"all",
"provided",
"Streamers",
"through",
"the",
"speaker",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/speaker/speaker.go#L80-L84 | train |
faiface/beep | speaker/speaker.go | update | func update() {
mu.Lock()
mixer.Stream(samples)
mu.Unlock()
for i := range samples {
for c := range samples[i] {
val := samples[i][c]
if val < -1 {
val = -1
}
if val > +1 {
val = +1
}
valInt16 := int16(val * (1<<15 - 1))
low := byte(valInt16)
high := byte(valInt16 >> 8)
buf[i*4+c*2+0] = low
buf[i*4+c*2+1] = high
}
}
player.Write(buf)
} | go | func update() {
mu.Lock()
mixer.Stream(samples)
mu.Unlock()
for i := range samples {
for c := range samples[i] {
val := samples[i][c]
if val < -1 {
val = -1
}
if val > +1 {
val = +1
}
valInt16 := int16(val * (1<<15 - 1))
low := byte(valInt16)
high := byte(valInt16 >> 8)
buf[i*4+c*2+0] = low
buf[i*4+c*2+1] = high
}
}
player.Write(buf)
} | [
"func",
"update",
"(",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"mixer",
".",
"Stream",
"(",
"samples",
")",
"\n",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"i",
":=",
"range",
"samples",
"{",
"for",
"c",
":=",
"range",
"samples",
"[",
... | // update pulls new data from the playing Streamers and sends it to the speaker. Blocks until the
// data is sent and started playing. | [
"update",
"pulls",
"new",
"data",
"from",
"the",
"playing",
"Streamers",
"and",
"sends",
"it",
"to",
"the",
"speaker",
".",
"Blocks",
"until",
"the",
"data",
"is",
"sent",
"and",
"started",
"playing",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/speaker/speaker.go#L95-L118 | train |
faiface/beep | effects/volume.go | Stream | func (v *Volume) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = v.Streamer.Stream(samples)
gain := 0.0
if !v.Silent {
gain = math.Pow(v.Base, v.Volume)
}
for i := range samples[:n] {
samples[i][0] *= gain
samples[i][1] *= gain
}
return n, ok
} | go | func (v *Volume) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = v.Streamer.Stream(samples)
gain := 0.0
if !v.Silent {
gain = math.Pow(v.Base, v.Volume)
}
for i := range samples[:n] {
samples[i][0] *= gain
samples[i][1] *= gain
}
return n, ok
} | [
"func",
"(",
"v",
"*",
"Volume",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"n",
",",
"ok",
"=",
"v",
".",
"Streamer",
".",
"Stream",
"(",
"samples",
")",
"\n",
"gain"... | // Stream streams the wrapped Streamer with volume adjusted according to Base, Volume and Silent
// fields. | [
"Stream",
"streams",
"the",
"wrapped",
"Streamer",
"with",
"volume",
"adjusted",
"according",
"to",
"Base",
"Volume",
"and",
"Silent",
"fields",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/effects/volume.go#L30-L41 | train |
faiface/beep | compositors.go | Take | func Take(num int, s Streamer) Streamer {
return &take{
s: s,
remains: num,
}
} | go | func Take(num int, s Streamer) Streamer {
return &take{
s: s,
remains: num,
}
} | [
"func",
"Take",
"(",
"num",
"int",
",",
"s",
"Streamer",
")",
"Streamer",
"{",
"return",
"&",
"take",
"{",
"s",
":",
"s",
",",
"remains",
":",
"num",
",",
"}",
"\n",
"}"
] | // Take returns a Streamer which streams at most num samples from s.
//
// The returned Streamer propagates s's errors through Err. | [
"Take",
"returns",
"a",
"Streamer",
"which",
"streams",
"at",
"most",
"num",
"samples",
"from",
"s",
".",
"The",
"returned",
"Streamer",
"propagates",
"s",
"s",
"errors",
"through",
"Err",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/compositors.go#L6-L11 | train |
faiface/beep | compositors.go | Loop | func Loop(count int, s StreamSeeker) Streamer {
return &loop{
s: s,
remains: count,
}
} | go | func Loop(count int, s StreamSeeker) Streamer {
return &loop{
s: s,
remains: count,
}
} | [
"func",
"Loop",
"(",
"count",
"int",
",",
"s",
"StreamSeeker",
")",
"Streamer",
"{",
"return",
"&",
"loop",
"{",
"s",
":",
"s",
",",
"remains",
":",
"count",
",",
"}",
"\n",
"}"
] | // Loop takes a StreamSeeker and plays it count times. If count is negative, s is looped infinitely.
//
// The returned Streamer propagates s's errors. | [
"Loop",
"takes",
"a",
"StreamSeeker",
"and",
"plays",
"it",
"count",
"times",
".",
"If",
"count",
"is",
"negative",
"s",
"is",
"looped",
"infinitely",
".",
"The",
"returned",
"Streamer",
"propagates",
"s",
"s",
"errors",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/compositors.go#L38-L43 | train |
faiface/beep | compositors.go | Seq | func Seq(s ...Streamer) Streamer {
i := 0
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
for i < len(s) && len(samples) > 0 {
sn, sok := s[i].Stream(samples)
samples = samples[sn:]
n, ok = n+sn, ok || sok
if !sok {
i++
}
}
return n, ok
})
} | go | func Seq(s ...Streamer) Streamer {
i := 0
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
for i < len(s) && len(samples) > 0 {
sn, sok := s[i].Stream(samples)
samples = samples[sn:]
n, ok = n+sn, ok || sok
if !sok {
i++
}
}
return n, ok
})
} | [
"func",
"Seq",
"(",
"s",
"...",
"Streamer",
")",
"Streamer",
"{",
"i",
":=",
"0",
"\n",
"return",
"StreamerFunc",
"(",
"func",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"for",
"i",
"<... | // Seq takes zero or more Streamers and returns a Streamer which streams them one by one without pauses.
//
// Seq does not propagate errors from the Streamers. | [
"Seq",
"takes",
"zero",
"or",
"more",
"Streamers",
"and",
"returns",
"a",
"Streamer",
"which",
"streams",
"them",
"one",
"by",
"one",
"without",
"pauses",
".",
"Seq",
"does",
"not",
"propagate",
"errors",
"from",
"the",
"Streamers",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/compositors.go#L82-L95 | train |
faiface/beep | compositors.go | Mix | func Mix(s ...Streamer) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
var tmp [512][2]float64
for len(samples) > 0 {
toStream := len(tmp)
if toStream > len(samples) {
toStream = len(samples)
}
// clear the samples
for i := range samples[:toStream] {
samples[i] = [2]float64{}
}
snMax := 0 // max number of streamed samples in this iteration
for _, st := range s {
// mix the stream
sn, sok := st.Stream(tmp[:toStream])
if sn > snMax {
snMax = sn
}
ok = ok || sok
for i := range tmp[:sn] {
samples[i][0] += tmp[i][0]
samples[i][1] += tmp[i][1]
}
}
n += snMax
if snMax < len(tmp) {
break
}
samples = samples[snMax:]
}
return n, ok
})
} | go | func Mix(s ...Streamer) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
var tmp [512][2]float64
for len(samples) > 0 {
toStream := len(tmp)
if toStream > len(samples) {
toStream = len(samples)
}
// clear the samples
for i := range samples[:toStream] {
samples[i] = [2]float64{}
}
snMax := 0 // max number of streamed samples in this iteration
for _, st := range s {
// mix the stream
sn, sok := st.Stream(tmp[:toStream])
if sn > snMax {
snMax = sn
}
ok = ok || sok
for i := range tmp[:sn] {
samples[i][0] += tmp[i][0]
samples[i][1] += tmp[i][1]
}
}
n += snMax
if snMax < len(tmp) {
break
}
samples = samples[snMax:]
}
return n, ok
})
} | [
"func",
"Mix",
"(",
"s",
"...",
"Streamer",
")",
"Streamer",
"{",
"return",
"StreamerFunc",
"(",
"func",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"var",
"tmp",
"[",
"512",
"]",
"[",
... | // Mix takes zero or more Streamers and returns a Streamer which streams them mixed together.
//
// Mix does not propagate errors from the Streamers. | [
"Mix",
"takes",
"zero",
"or",
"more",
"Streamers",
"and",
"returns",
"a",
"Streamer",
"which",
"streams",
"them",
"mixed",
"together",
".",
"Mix",
"does",
"not",
"propagate",
"errors",
"from",
"the",
"Streamers",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/compositors.go#L100-L139 | train |
faiface/beep | compositors.go | Dup | func Dup(s Streamer) (t, u Streamer) {
var tBuf, uBuf [][2]float64
return &dup{&tBuf, &uBuf, s}, &dup{&uBuf, &tBuf, s}
} | go | func Dup(s Streamer) (t, u Streamer) {
var tBuf, uBuf [][2]float64
return &dup{&tBuf, &uBuf, s}, &dup{&uBuf, &tBuf, s}
} | [
"func",
"Dup",
"(",
"s",
"Streamer",
")",
"(",
"t",
",",
"u",
"Streamer",
")",
"{",
"var",
"tBuf",
",",
"uBuf",
"[",
"]",
"[",
"2",
"]",
"float64",
"\n",
"return",
"&",
"dup",
"{",
"&",
"tBuf",
",",
"&",
"uBuf",
",",
"s",
"}",
",",
"&",
"du... | // Dup returns two Streamers which both stream the same data as the original s. The two Streamers
// can't be used concurrently without synchronization. | [
"Dup",
"returns",
"two",
"Streamers",
"which",
"both",
"stream",
"the",
"same",
"data",
"as",
"the",
"original",
"s",
".",
"The",
"two",
"Streamers",
"can",
"t",
"be",
"used",
"concurrently",
"without",
"synchronization",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/compositors.go#L143-L146 | train |
mattn/go-gtk | gdkpixbuf/gdkpixbuf.go | NewPixbufFromData | func NewPixbufFromData(pbd PixbufData) *Pixbuf {
gpixbuf := C.gdk_pixbuf_new_from_data(
C.to_gucharptr(unsafe.Pointer(&pbd.Data[0])),
C.GdkColorspace(pbd.Colorspace),
gbool(pbd.HasAlpha),
C.int(pbd.BitsPerSample),
C.int(pbd.Width),
C.int(pbd.Height),
C.int(pbd.RowStride),
nil, nil)
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}
} | go | func NewPixbufFromData(pbd PixbufData) *Pixbuf {
gpixbuf := C.gdk_pixbuf_new_from_data(
C.to_gucharptr(unsafe.Pointer(&pbd.Data[0])),
C.GdkColorspace(pbd.Colorspace),
gbool(pbd.HasAlpha),
C.int(pbd.BitsPerSample),
C.int(pbd.Width),
C.int(pbd.Height),
C.int(pbd.RowStride),
nil, nil)
return &Pixbuf{
GdkPixbuf: &GdkPixbuf{gpixbuf},
GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
}
} | [
"func",
"NewPixbufFromData",
"(",
"pbd",
"PixbufData",
")",
"*",
"Pixbuf",
"{",
"gpixbuf",
":=",
"C",
".",
"gdk_pixbuf_new_from_data",
"(",
"C",
".",
"to_gucharptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"pbd",
".",
"Data",
"[",
"0",
"]",
")",
")",
... | // NewPixbufFromData creates a Pixbuf from image data in a byte array | [
"NewPixbufFromData",
"creates",
"a",
"Pixbuf",
"from",
"image",
"data",
"in",
"a",
"byte",
"array"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gdkpixbuf/gdkpixbuf.go#L155-L169 | train |
mattn/go-gtk | gdkpixbuf/gdkpixbuf.go | Save | func (p *Pixbuf) Save(filename, savetype string, options ...string) *glib.Error {
if len(options)%2 != 0 {
argumentPanic("Save options must be even (key and value)")
}
pfilename := C.CString(filename)
defer cfree(pfilename)
psavetype := C.CString(savetype)
defer cfree(psavetype)
klen := len(options) / 2
keys := C.makeCstrv(C.int(klen + 1))
vals := C.makeCstrv(C.int(klen + 1))
for i := 0; i < klen; i++ {
C.setCstr(keys, C.int(i), C.CString(options[2*i]))
C.setCstr(vals, C.int(i), C.CString(options[2*i+1]))
}
C.setCstr(keys, C.int(klen), nil)
C.setCstr(vals, C.int(klen), nil)
defer func() {
for i := 0; i < klen; i++ {
cfree(C.getCstr(keys, C.int(i)))
cfree(C.getCstr(vals, C.int(i)))
}
C.freeCstrv(keys)
C.freeCstrv(vals)
}()
var err *C.GError
C.gdk_pixbuf_savev(p.GPixbuf, pfilename, psavetype, keys, vals, &err)
if err != nil {
return glib.ErrorFromNative(unsafe.Pointer(err))
}
return nil
} | go | func (p *Pixbuf) Save(filename, savetype string, options ...string) *glib.Error {
if len(options)%2 != 0 {
argumentPanic("Save options must be even (key and value)")
}
pfilename := C.CString(filename)
defer cfree(pfilename)
psavetype := C.CString(savetype)
defer cfree(psavetype)
klen := len(options) / 2
keys := C.makeCstrv(C.int(klen + 1))
vals := C.makeCstrv(C.int(klen + 1))
for i := 0; i < klen; i++ {
C.setCstr(keys, C.int(i), C.CString(options[2*i]))
C.setCstr(vals, C.int(i), C.CString(options[2*i+1]))
}
C.setCstr(keys, C.int(klen), nil)
C.setCstr(vals, C.int(klen), nil)
defer func() {
for i := 0; i < klen; i++ {
cfree(C.getCstr(keys, C.int(i)))
cfree(C.getCstr(vals, C.int(i)))
}
C.freeCstrv(keys)
C.freeCstrv(vals)
}()
var err *C.GError
C.gdk_pixbuf_savev(p.GPixbuf, pfilename, psavetype, keys, vals, &err)
if err != nil {
return glib.ErrorFromNative(unsafe.Pointer(err))
}
return nil
} | [
"func",
"(",
"p",
"*",
"Pixbuf",
")",
"Save",
"(",
"filename",
",",
"savetype",
"string",
",",
"options",
"...",
"string",
")",
"*",
"glib",
".",
"Error",
"{",
"if",
"len",
"(",
"options",
")",
"%",
"2",
"!=",
"0",
"{",
"argumentPanic",
"(",
"\"",
... | // gdk_pixbuf_get_byte_length
// gdk_pixbuf_get_option
// File saving | [
"gdk_pixbuf_get_byte_length",
"gdk_pixbuf_get_option",
"File",
"saving"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gdkpixbuf/gdkpixbuf.go#L368-L402 | train |
mattn/go-gtk | glib/glib.go | toSlice | func toSlice(ar **C.gchar) []string {
result := make([]string, 0)
for i := 0; ; i++ {
str := C.GoString(C.to_charptr(*ar))
if str == "" {
break
}
result = append(result, str)
*ar = C.next_string(*ar)
}
return result
} | go | func toSlice(ar **C.gchar) []string {
result := make([]string, 0)
for i := 0; ; i++ {
str := C.GoString(C.to_charptr(*ar))
if str == "" {
break
}
result = append(result, str)
*ar = C.next_string(*ar)
}
return result
} | [
"func",
"toSlice",
"(",
"ar",
"*",
"*",
"C",
".",
"gchar",
")",
"[",
"]",
"string",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"for",
"i",
":=",
"0",
";",
";",
"i",
"++",
"{",
"str",
":=",
"C",
".",
"GoString... | // converts a C string array to a Go string slice | [
"converts",
"a",
"C",
"string",
"array",
"to",
"a",
"Go",
"string",
"slice"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/glib/glib.go#L73-L84 | train |
mattn/go-gtk | gio/gio.go | NewGFileForPath | func NewGFileForPath(filename string) *GFile {
ptrFilename := C.CString(filename)
defer cfree(ptrFilename)
return &GFile{C.g_file_new_for_path(ptrFilename)}
} | go | func NewGFileForPath(filename string) *GFile {
ptrFilename := C.CString(filename)
defer cfree(ptrFilename)
return &GFile{C.g_file_new_for_path(ptrFilename)}
} | [
"func",
"NewGFileForPath",
"(",
"filename",
"string",
")",
"*",
"GFile",
"{",
"ptrFilename",
":=",
"C",
".",
"CString",
"(",
"filename",
")",
"\n",
"defer",
"cfree",
"(",
"ptrFilename",
")",
"\n\n",
"return",
"&",
"GFile",
"{",
"C",
".",
"g_file_new_for_pa... | // NewGFileForPath is g_file_new_for_path | [
"NewGFileForPath",
"is",
"g_file_new_for_path"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gio/gio.go#L25-L30 | train |
mattn/go-gtk | gio/gio.go | NewGFileForURI | func NewGFileForURI(uriFilename string) *GFile {
ptrFilename := C.CString(uriFilename)
defer cfree(ptrFilename)
return &GFile{C.g_file_new_for_uri(ptrFilename)}
} | go | func NewGFileForURI(uriFilename string) *GFile {
ptrFilename := C.CString(uriFilename)
defer cfree(ptrFilename)
return &GFile{C.g_file_new_for_uri(ptrFilename)}
} | [
"func",
"NewGFileForURI",
"(",
"uriFilename",
"string",
")",
"*",
"GFile",
"{",
"ptrFilename",
":=",
"C",
".",
"CString",
"(",
"uriFilename",
")",
"\n",
"defer",
"cfree",
"(",
"ptrFilename",
")",
"\n\n",
"return",
"&",
"GFile",
"{",
"C",
".",
"g_file_new_f... | // NewGFileForURI is g_file_new_for_uri | [
"NewGFileForURI",
"is",
"g_file_new_for_uri"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gio/gio.go#L33-L38 | train |
mattn/go-gtk | gio/gio.go | QueryInfo | func (f *GFile) QueryInfo(attributes string, flags GFileQueryInfoFlags) (*GFileInfo, error) {
ptr := C.CString(attributes)
defer cfree(ptr)
var gerror *C.GError
gfileinfo := C.g_file_query_info(
f.GFile,
ptr,
C.GFileQueryInfoFlags(flags),
nil, // nil is GCancellable, not yet implemented
&gerror,
)
if gerror != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(gerror))
}
return &GFileInfo{gfileinfo}, nil
} | go | func (f *GFile) QueryInfo(attributes string, flags GFileQueryInfoFlags) (*GFileInfo, error) {
ptr := C.CString(attributes)
defer cfree(ptr)
var gerror *C.GError
gfileinfo := C.g_file_query_info(
f.GFile,
ptr,
C.GFileQueryInfoFlags(flags),
nil, // nil is GCancellable, not yet implemented
&gerror,
)
if gerror != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(gerror))
}
return &GFileInfo{gfileinfo}, nil
} | [
"func",
"(",
"f",
"*",
"GFile",
")",
"QueryInfo",
"(",
"attributes",
"string",
",",
"flags",
"GFileQueryInfoFlags",
")",
"(",
"*",
"GFileInfo",
",",
"error",
")",
"{",
"ptr",
":=",
"C",
".",
"CString",
"(",
"attributes",
")",
"\n",
"defer",
"cfree",
"(... | // QueryInfo is g_file_query_info | [
"QueryInfo",
"is",
"g_file_query_info"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gio/gio.go#L48-L66 | train |
mattn/go-gtk | gio/gio.go | GetPath | func (f *GFile) GetPath() string {
return gostring(gstring(C.g_file_get_path(f.GFile)))
} | go | func (f *GFile) GetPath() string {
return gostring(gstring(C.g_file_get_path(f.GFile)))
} | [
"func",
"(",
"f",
"*",
"GFile",
")",
"GetPath",
"(",
")",
"string",
"{",
"return",
"gostring",
"(",
"gstring",
"(",
"C",
".",
"g_file_get_path",
"(",
"f",
".",
"GFile",
")",
")",
")",
"\n",
"}"
] | // GetPath is `g_file_get_path`, return real, absolute, canonical path. It might contain symlinks. | [
"GetPath",
"is",
"g_file_get_path",
"return",
"real",
"absolute",
"canonical",
"path",
".",
"It",
"might",
"contain",
"symlinks",
"."
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gio/gio.go#L69-L71 | train |
mattn/go-gtk | gtk/gtk.go | stringArray2Native | func stringArray2Native(ss []string) **C.gchar {
css := C.make_strings(C.int(len(ss) + 1))
for i, s := range ss {
ptr := C.CString(s)
C.set_string(css, C.int(i), gstring(ptr))
}
C.set_string(css, C.int(len(ss)), nil)
return css
} | go | func stringArray2Native(ss []string) **C.gchar {
css := C.make_strings(C.int(len(ss) + 1))
for i, s := range ss {
ptr := C.CString(s)
C.set_string(css, C.int(i), gstring(ptr))
}
C.set_string(css, C.int(len(ss)), nil)
return css
} | [
"func",
"stringArray2Native",
"(",
"ss",
"[",
"]",
"string",
")",
"*",
"*",
"C",
".",
"gchar",
"{",
"css",
":=",
"C",
".",
"make_strings",
"(",
"C",
".",
"int",
"(",
"len",
"(",
"ss",
")",
"+",
"1",
")",
")",
"\n",
"for",
"i",
",",
"s",
":=",... | // use C.g_strfreev to free the result | [
"use",
"C",
".",
"g_strfreev",
"to",
"free",
"the",
"result"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L250-L258 | train |
mattn/go-gtk | gtk/gtk.go | Init | func Init(args *[]string) {
if args != nil {
argc := C.int(len(*args))
argv := C.make_strings(argc)
defer C.destroy_strings(argv)
for i, arg := range *args {
cstr := C.CString(arg)
C.set_string(argv, C.int(i), (*C.gchar)(cstr))
}
C.gtk_init((*C.int)(unsafe.Pointer(&argc)),
(***C.char)(unsafe.Pointer(&argv)))
unhandled := make([]string, argc)
for i := 0; i < int(argc); i++ {
cstr := C.get_string(argv, C.int(i))
unhandled[i] = C.GoString((*C.char)(cstr))
C.free(unsafe.Pointer(cstr))
}
*args = unhandled
} else {
C.gtk_init(nil, nil)
}
} | go | func Init(args *[]string) {
if args != nil {
argc := C.int(len(*args))
argv := C.make_strings(argc)
defer C.destroy_strings(argv)
for i, arg := range *args {
cstr := C.CString(arg)
C.set_string(argv, C.int(i), (*C.gchar)(cstr))
}
C.gtk_init((*C.int)(unsafe.Pointer(&argc)),
(***C.char)(unsafe.Pointer(&argv)))
unhandled := make([]string, argc)
for i := 0; i < int(argc); i++ {
cstr := C.get_string(argv, C.int(i))
unhandled[i] = C.GoString((*C.char)(cstr))
C.free(unsafe.Pointer(cstr))
}
*args = unhandled
} else {
C.gtk_init(nil, nil)
}
} | [
"func",
"Init",
"(",
"args",
"*",
"[",
"]",
"string",
")",
"{",
"if",
"args",
"!=",
"nil",
"{",
"argc",
":=",
"C",
".",
"int",
"(",
"len",
"(",
"*",
"args",
")",
")",
"\n",
"argv",
":=",
"C",
".",
"make_strings",
"(",
"argc",
")",
"\n",
"defe... | // gtk_disable_setlocale
// gtk_get_default_language
// gtk_parse_args | [
"gtk_disable_setlocale",
"gtk_get_default_language",
"gtk_parse_args"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L274-L298 | train |
mattn/go-gtk | gtk/gtk.go | AcceleratorParse | func AcceleratorParse(accelerator string) (uint, gdk.ModifierType) {
ptrn := C.CString(accelerator)
defer cfree(ptrn)
var key C.guint
var mods C.GdkModifierType
C.gtk_accelerator_parse(gstring(ptrn), &key, &mods)
return uint(key), gdk.ModifierType(mods)
} | go | func AcceleratorParse(accelerator string) (uint, gdk.ModifierType) {
ptrn := C.CString(accelerator)
defer cfree(ptrn)
var key C.guint
var mods C.GdkModifierType
C.gtk_accelerator_parse(gstring(ptrn), &key, &mods)
return uint(key), gdk.ModifierType(mods)
} | [
"func",
"AcceleratorParse",
"(",
"accelerator",
"string",
")",
"(",
"uint",
",",
"gdk",
".",
"ModifierType",
")",
"{",
"ptrn",
":=",
"C",
".",
"CString",
"(",
"accelerator",
")",
"\n",
"defer",
"cfree",
"(",
"ptrn",
")",
"\n\n",
"var",
"key",
"C",
".",... | // gtk_accel_group_connect
// gtk_accel_group_connect_by_path
// gtk_accel_group_disconnect
// gtk_accel_group_disconnect_key
// gtk_accel_group_query
// gtk_accel_group_activate
// gtk_accel_group_lock
// gtk_accel_group_unlock
// gtk_accel_group_from_accel_closure
// gtk_accel_groups_activate
// gtk_accel_groups_from_object
// gtk_accel_group_find
// gtk_accelerator_valid
// Parse string representing an accelerator
// and return the key code and the modifier masks. | [
"gtk_accel_group_connect",
"gtk_accel_group_connect_by_path",
"gtk_accel_group_disconnect",
"gtk_accel_group_disconnect_key",
"gtk_accel_group_query",
"gtk_accel_group_activate",
"gtk_accel_group_lock",
"gtk_accel_group_unlock",
"gtk_accel_group_from_accel_closure",
"gtk_accel_groups_activate",
... | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L370-L378 | train |
mattn/go-gtk | gtk/gtk.go | LookupByGIcon | func (it *IconTheme) LookupByGIcon(icon *gio.GIcon, width int) *IconInfo {
return &IconInfo{C.gtk_icon_theme_lookup_by_gicon(
it.GtkIconTheme,
(*C.GIcon)(unsafe.Pointer(icon.GIcon)),
gint(width),
C.GtkIconLookupFlags(IconLookupUseBuiltin),
)}
} | go | func (it *IconTheme) LookupByGIcon(icon *gio.GIcon, width int) *IconInfo {
return &IconInfo{C.gtk_icon_theme_lookup_by_gicon(
it.GtkIconTheme,
(*C.GIcon)(unsafe.Pointer(icon.GIcon)),
gint(width),
C.GtkIconLookupFlags(IconLookupUseBuiltin),
)}
} | [
"func",
"(",
"it",
"*",
"IconTheme",
")",
"LookupByGIcon",
"(",
"icon",
"*",
"gio",
".",
"GIcon",
",",
"width",
"int",
")",
"*",
"IconInfo",
"{",
"return",
"&",
"IconInfo",
"{",
"C",
".",
"gtk_icon_theme_lookup_by_gicon",
"(",
"it",
".",
"GtkIconTheme",
... | // gtk_icon_theme_lookup_icon
// gtk_icon_theme_choose_icon
// gtk_icon_theme_lookup_by_gicon | [
"gtk_icon_theme_lookup_icon",
"gtk_icon_theme_choose_icon",
"gtk_icon_theme_lookup_by_gicon"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L605-L613 | train |
mattn/go-gtk | gtk/gtk.go | LoadIcon | func (ii *IconInfo) LoadIcon() (*gdkpixbuf.GdkPixbuf, error) {
var gerror *C.GError
pixbuf := C.gtk_icon_info_load_icon(ii.GtkIconInfo, &gerror)
if gerror != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(gerror))
}
return gdkpixbuf.NewGdkPixbuf(unsafe.Pointer(pixbuf)), nil
} | go | func (ii *IconInfo) LoadIcon() (*gdkpixbuf.GdkPixbuf, error) {
var gerror *C.GError
pixbuf := C.gtk_icon_info_load_icon(ii.GtkIconInfo, &gerror)
if gerror != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(gerror))
}
return gdkpixbuf.NewGdkPixbuf(unsafe.Pointer(pixbuf)), nil
} | [
"func",
"(",
"ii",
"*",
"IconInfo",
")",
"LoadIcon",
"(",
")",
"(",
"*",
"gdkpixbuf",
".",
"GdkPixbuf",
",",
"error",
")",
"{",
"var",
"gerror",
"*",
"C",
".",
"GError",
"\n",
"pixbuf",
":=",
"C",
".",
"gtk_icon_info_load_icon",
"(",
"ii",
".",
"GtkI... | // gtk_icon_info_copy
// gtk_icon_info_free
// gtk_icon_info_new_for_pixbuf
// gtk_icon_info_get_base_size
// gtk_icon_info_get_filename
// gtk_icon_info_get_builtin_pixbuf
// gtk_icon_info_load_icon | [
"gtk_icon_info_copy",
"gtk_icon_info_free",
"gtk_icon_info_new_for_pixbuf",
"gtk_icon_info_get_base_size",
"gtk_icon_info_get_filename",
"gtk_icon_info_get_builtin_pixbuf",
"gtk_icon_info_load_icon"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L634-L643 | train |
mattn/go-gtk | gtk/gtk.go | ToGObject | func (s *Settings) ToGObject() *glib.GObject {
return &glib.GObject{unsafe.Pointer(s.GSettings)}
} | go | func (s *Settings) ToGObject() *glib.GObject {
return &glib.GObject{unsafe.Pointer(s.GSettings)}
} | [
"func",
"(",
"s",
"*",
"Settings",
")",
"ToGObject",
"(",
")",
"*",
"glib",
".",
"GObject",
"{",
"return",
"&",
"glib",
".",
"GObject",
"{",
"unsafe",
".",
"Pointer",
"(",
"s",
".",
"GSettings",
")",
"}",
"\n",
"}"
] | // gtk_settings_install_property
// gtk_settings_install_property_parser
// gtk_rc_property_parse_color
// gtk_rc_property_parse_enum
// gtk_rc_property_parse_flags
// gtk_rc_property_parse_requisition
// gtk_rc_property_parse_border
// gtk_settings_set_property_value | [
"gtk_settings_install_property",
"gtk_settings_install_property_parser",
"gtk_rc_property_parse_color",
"gtk_rc_property_parse_enum",
"gtk_rc_property_parse_flags",
"gtk_rc_property_parse_requisition",
"gtk_rc_property_parse_border",
"gtk_settings_set_property_value"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L913-L915 | train |
mattn/go-gtk | gtk/gtk.go | GetHasSeparator | func (v *Dialog) GetHasSeparator() bool {
deprecated_since(2, 22, 0, "gtk_dialog_get_has_separator()")
return gobool(C.gtk_dialog_get_has_separator(DIALOG(v)))
} | go | func (v *Dialog) GetHasSeparator() bool {
deprecated_since(2, 22, 0, "gtk_dialog_get_has_separator()")
return gobool(C.gtk_dialog_get_has_separator(DIALOG(v)))
} | [
"func",
"(",
"v",
"*",
"Dialog",
")",
"GetHasSeparator",
"(",
")",
"bool",
"{",
"deprecated_since",
"(",
"2",
",",
"22",
",",
"0",
",",
"\"",
"\"",
")",
"\n",
"return",
"gobool",
"(",
"C",
".",
"gtk_dialog_get_has_separator",
"(",
"DIALOG",
"(",
"v",
... | // gtk_dialog_add_buttons
// gtk_dialog_add_action_widget
//Deprecated since 2.22. | [
"gtk_dialog_add_buttons",
"gtk_dialog_add_action_widget",
"Deprecated",
"since",
"2",
".",
"22",
"."
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1257-L1260 | train |
mattn/go-gtk | gtk/gtk.go | SetHasSeparator | func (v *Dialog) SetHasSeparator(f bool) {
deprecated_since(2, 22, 0, "gtk_dialog_set_has_separator()")
C.gtk_dialog_set_has_separator(DIALOG(v), gbool(f))
} | go | func (v *Dialog) SetHasSeparator(f bool) {
deprecated_since(2, 22, 0, "gtk_dialog_set_has_separator()")
C.gtk_dialog_set_has_separator(DIALOG(v), gbool(f))
} | [
"func",
"(",
"v",
"*",
"Dialog",
")",
"SetHasSeparator",
"(",
"f",
"bool",
")",
"{",
"deprecated_since",
"(",
"2",
",",
"22",
",",
"0",
",",
"\"",
"\"",
")",
"\n",
"C",
".",
"gtk_dialog_set_has_separator",
"(",
"DIALOG",
"(",
"v",
")",
",",
"gbool",
... | //Deprecated since 2.22. | [
"Deprecated",
"since",
"2",
".",
"22",
"."
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1263-L1266 | train |
mattn/go-gtk | gtk/gtk.go | GetVBox | func (v *Dialog) GetVBox() *VBox {
return &VBox{Box{Container{Widget{C._gtk_dialog_get_vbox(v.GWidget)}}}}
} | go | func (v *Dialog) GetVBox() *VBox {
return &VBox{Box{Container{Widget{C._gtk_dialog_get_vbox(v.GWidget)}}}}
} | [
"func",
"(",
"v",
"*",
"Dialog",
")",
"GetVBox",
"(",
")",
"*",
"VBox",
"{",
"return",
"&",
"VBox",
"{",
"Box",
"{",
"Container",
"{",
"Widget",
"{",
"C",
".",
"_gtk_dialog_get_vbox",
"(",
"v",
".",
"GWidget",
")",
"}",
"}",
"}",
"}",
"\n",
"}"
] | // gtk_alternative_dialog_button_order
// gtk_dialog_set_alternative_button_order
// gtk_dialog_set_alternative_button_order_from_array | [
"gtk_alternative_dialog_button_order",
"gtk_dialog_set_alternative_button_order",
"gtk_dialog_set_alternative_button_order_from_array"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1296-L1298 | train |
mattn/go-gtk | gtk/gtk.go | SetDefault | func (v *Window) SetDefault(w *Widget) {
C.gtk_window_set_default(WINDOW(v), w.GWidget)
} | go | func (v *Window) SetDefault(w *Widget) {
C.gtk_window_set_default(WINDOW(v), w.GWidget)
} | [
"func",
"(",
"v",
"*",
"Window",
")",
"SetDefault",
"(",
"w",
"*",
"Widget",
")",
"{",
"C",
".",
"gtk_window_set_default",
"(",
"WINDOW",
"(",
"v",
")",
",",
"w",
".",
"GWidget",
")",
"\n",
"}"
] | // gtk_window_add_mnemonic
// gtk_window_remove_mnemonic
// gtk_window_mnemonic_activate
// gtk_window_activate_key
// gtk_window_propagate_key_event
// gtk_window_get_focus
// gtk_window_set_focus
// gtk_window_get_default_widget | [
"gtk_window_add_mnemonic",
"gtk_window_remove_mnemonic",
"gtk_window_mnemonic_activate",
"gtk_window_activate_key",
"gtk_window_propagate_key_event",
"gtk_window_get_focus",
"gtk_window_set_focus",
"gtk_window_get_default_widget"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1502-L1504 | train |
mattn/go-gtk | gtk/gtk.go | GetDefaultSize | func (v *Window) GetDefaultSize() (width int, height int) {
var cwidth, cheight C.gint
C.gtk_window_get_default_size(WINDOW(v), &cwidth, &cheight)
return int(cwidth), int(cheight)
} | go | func (v *Window) GetDefaultSize() (width int, height int) {
var cwidth, cheight C.gint
C.gtk_window_get_default_size(WINDOW(v), &cwidth, &cheight)
return int(cwidth), int(cheight)
} | [
"func",
"(",
"v",
"*",
"Window",
")",
"GetDefaultSize",
"(",
")",
"(",
"width",
"int",
",",
"height",
"int",
")",
"{",
"var",
"cwidth",
",",
"cheight",
"C",
".",
"gint",
"\n",
"C",
".",
"gtk_window_get_default_size",
"(",
"WINDOW",
"(",
"v",
")",
","... | // gtk_window_set_focus_on_map
// gtk_window_set_startup_id
// gtk_window_set_role
// gtk_window_get_decorated
// gtk_window_get_deletable
// gtk_window_get_default_icon_list
// gtk_window_get_default_icon_name | [
"gtk_window_set_focus_on_map",
"gtk_window_set_startup_id",
"gtk_window_set_role",
"gtk_window_get_decorated",
"gtk_window_get_deletable",
"gtk_window_get_default_icon_list",
"gtk_window_get_default_icon_name"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1588-L1592 | train |
mattn/go-gtk | gtk/gtk.go | SetIcon | func (v *Window) SetIcon(icon *gdkpixbuf.Pixbuf) {
C.gtk_window_set_icon(WINDOW(v), (*C.GdkPixbuf)(unsafe.Pointer(icon.GPixbuf)))
} | go | func (v *Window) SetIcon(icon *gdkpixbuf.Pixbuf) {
C.gtk_window_set_icon(WINDOW(v), (*C.GdkPixbuf)(unsafe.Pointer(icon.GPixbuf)))
} | [
"func",
"(",
"v",
"*",
"Window",
")",
"SetIcon",
"(",
"icon",
"*",
"gdkpixbuf",
".",
"Pixbuf",
")",
"{",
"C",
".",
"gtk_window_set_icon",
"(",
"WINDOW",
"(",
"v",
")",
",",
"(",
"*",
"C",
".",
"GdkPixbuf",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
... | // gtk_window_set_default_icon_list
// gtk_window_set_default_icon
// gtk_window_set_default_icon_from_file
// gtk_window_set_default_icon_name | [
"gtk_window_set_default_icon_list",
"gtk_window_set_default_icon",
"gtk_window_set_default_icon_from_file",
"gtk_window_set_default_icon_name"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1667-L1669 | train |
mattn/go-gtk | gtk/gtk.go | ForwardSearch | func (v *TextIter) ForwardSearch(str string, flags TextSearchFlags, start *TextIter, end *TextIter, limit *TextIter) bool {
cstr := C.CString(str)
defer cfree(cstr)
return gobool(C.gtk_text_iter_forward_search(&v.GTextIter, gstring(cstr), C.GtkTextSearchFlags(flags),
&start.GTextIter, &end.GTextIter, &limit.GTextIter))
} | go | func (v *TextIter) ForwardSearch(str string, flags TextSearchFlags, start *TextIter, end *TextIter, limit *TextIter) bool {
cstr := C.CString(str)
defer cfree(cstr)
return gobool(C.gtk_text_iter_forward_search(&v.GTextIter, gstring(cstr), C.GtkTextSearchFlags(flags),
&start.GTextIter, &end.GTextIter, &limit.GTextIter))
} | [
"func",
"(",
"v",
"*",
"TextIter",
")",
"ForwardSearch",
"(",
"str",
"string",
",",
"flags",
"TextSearchFlags",
",",
"start",
"*",
"TextIter",
",",
"end",
"*",
"TextIter",
",",
"limit",
"*",
"TextIter",
")",
"bool",
"{",
"cstr",
":=",
"C",
".",
"CStrin... | // gtk_text_iter_forward_line
// gtk_text_iter_backward_line
// gtk_text_iter_forward_lines
// gtk_text_iter_backward_lines
// gtk_text_iter_forward_word_ends
// gtk_text_iter_backward_word_starts
// gtk_text_iter_forward_word_end
// gtk_text_iter_backward_word_start
// gtk_text_iter_forward_cursor_position
// gtk_text_iter_backward_cursor_position
// gtk_text_iter_forward_cursor_positions
// gtk_text_iter_backward_cursor_positions
// gtk_text_iter_backward_sentence_start
// gtk_text_iter_backward_sentence_starts
// gtk_text_iter_forward_sentence_end
// gtk_text_iter_forward_sentence_ends
// gtk_text_iter_forward_visible_word_ends
// gtk_text_iter_backward_visible_word_starts
// gtk_text_iter_forward_visible_word_end
// gtk_text_iter_backward_visible_word_start
// gtk_text_iter_forward_visible_cursor_position
// gtk_text_iter_backward_visible_cursor_position
// gtk_text_iter_forward_visible_cursor_positions
// gtk_text_iter_backward_visible_cursor_positions
// gtk_text_iter_forward_visible_line
// gtk_text_iter_backward_visible_line
// gtk_text_iter_forward_visible_lines
// gtk_text_iter_backward_visible_lines
// gtk_text_iter_set_offset
// gtk_text_iter_set_line
// gtk_text_iter_set_line_offset
// gtk_text_iter_set_line_index
// gtk_text_iter_set_visible_line_index
// gtk_text_iter_set_visible_line_offset
// gtk_text_iter_forward_to_end
// gtk_text_iter_forward_to_line_end
// gtk_text_iter_forward_to_tag_toggle
// gtk_text_iter_backward_to_tag_toggle
// gtk_text_iter_forward_find_char
// gtk_text_iter_backward_find_char | [
"gtk_text_iter_forward_line",
"gtk_text_iter_backward_line",
"gtk_text_iter_forward_lines",
"gtk_text_iter_backward_lines",
"gtk_text_iter_forward_word_ends",
"gtk_text_iter_backward_word_starts",
"gtk_text_iter_forward_word_end",
"gtk_text_iter_backward_word_start",
"gtk_text_iter_forward_cursor_po... | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L3964-L3969 | train |
mattn/go-gtk | gtk/gtk.go | Assign | func (v *TextIter) Assign(iter *TextIter) {
C._gtk_text_iter_assign(&v.GTextIter, &iter.GTextIter)
} | go | func (v *TextIter) Assign(iter *TextIter) {
C._gtk_text_iter_assign(&v.GTextIter, &iter.GTextIter)
} | [
"func",
"(",
"v",
"*",
"TextIter",
")",
"Assign",
"(",
"iter",
"*",
"TextIter",
")",
"{",
"C",
".",
"_gtk_text_iter_assign",
"(",
"&",
"v",
".",
"GTextIter",
",",
"&",
"iter",
".",
"GTextIter",
")",
"\n",
"}"
] | // gtk_text_iter_equal
// gtk_text_iter_compare
// gtk_text_iter_in_range
// gtk_text_iter_order | [
"gtk_text_iter_equal",
"gtk_text_iter_compare",
"gtk_text_iter_in_range",
"gtk_text_iter_order"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L3983-L3985 | train |
mattn/go-gtk | gtk/gtk.go | GetSelectionBounds | func (v *TextBuffer) GetSelectionBounds(be, en *TextIter) bool {
return gobool(C.gtk_text_buffer_get_selection_bounds(v.GTextBuffer, &be.GTextIter, &en.GTextIter))
} | go | func (v *TextBuffer) GetSelectionBounds(be, en *TextIter) bool {
return gobool(C.gtk_text_buffer_get_selection_bounds(v.GTextBuffer, &be.GTextIter, &en.GTextIter))
} | [
"func",
"(",
"v",
"*",
"TextBuffer",
")",
"GetSelectionBounds",
"(",
"be",
",",
"en",
"*",
"TextIter",
")",
"bool",
"{",
"return",
"gobool",
"(",
"C",
".",
"gtk_text_buffer_get_selection_bounds",
"(",
"v",
".",
"GTextBuffer",
",",
"&",
"be",
".",
"GTextIte... | // gtk_text_buffer_paste_clipboard
// gtk_text_buffer_copy_clipboard
// gtk_text_buffer_cut_clipboard | [
"gtk_text_buffer_paste_clipboard",
"gtk_text_buffer_copy_clipboard",
"gtk_text_buffer_cut_clipboard"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L4283-L4285 | train |
mattn/go-gtk | gtk/gtk.go | RemoveColumn | func (v *TreeView) RemoveColumn(c *TreeViewColumn) int {
return int(C.gtk_tree_view_remove_column(TREE_VIEW(v), c.GTreeViewColumn))
} | go | func (v *TreeView) RemoveColumn(c *TreeViewColumn) int {
return int(C.gtk_tree_view_remove_column(TREE_VIEW(v), c.GTreeViewColumn))
} | [
"func",
"(",
"v",
"*",
"TreeView",
")",
"RemoveColumn",
"(",
"c",
"*",
"TreeViewColumn",
")",
"int",
"{",
"return",
"int",
"(",
"C",
".",
"gtk_tree_view_remove_column",
"(",
"TREE_VIEW",
"(",
"v",
")",
",",
"c",
".",
"GTreeViewColumn",
")",
")",
"\n",
... | // Remove column from TreeView and return number of existing columns | [
"Remove",
"column",
"from",
"TreeView",
"and",
"return",
"number",
"of",
"existing",
"columns"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L5217-L5219 | train |
mattn/go-gtk | gtk/gtk.go | GetActiveText | func (v *ComboBox) GetActiveText() string {
deprecated_since(2, 24, 0, "gtk_combo_box_get_active_text()")
return gostring(C.gtk_combo_box_get_active_text(COMBO_BOX(v)))
} | go | func (v *ComboBox) GetActiveText() string {
deprecated_since(2, 24, 0, "gtk_combo_box_get_active_text()")
return gostring(C.gtk_combo_box_get_active_text(COMBO_BOX(v)))
} | [
"func",
"(",
"v",
"*",
"ComboBox",
")",
"GetActiveText",
"(",
")",
"string",
"{",
"deprecated_since",
"(",
"2",
",",
"24",
",",
"0",
",",
"\"",
"\"",
")",
"\n",
"return",
"gostring",
"(",
"C",
".",
"gtk_combo_box_get_active_text",
"(",
"COMBO_BOX",
"(",
... | //Deprecated since 2.24. Use GtkComboBoxText or, if combo box contains an entry,
// get text directly from GtkEntry. | [
"Deprecated",
"since",
"2",
".",
"24",
".",
"Use",
"GtkComboBoxText",
"or",
"if",
"combo",
"box",
"contains",
"an",
"entry",
"get",
"text",
"directly",
"from",
"GtkEntry",
"."
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L6156-L6159 | train |
mattn/go-gtk | gtk/gtk.go | SetAddTearoffs | func (v *ComboBox) SetAddTearoffs(add_tearoffs bool) {
C.gtk_combo_box_set_add_tearoffs(COMBO_BOX(v), gbool(add_tearoffs))
} | go | func (v *ComboBox) SetAddTearoffs(add_tearoffs bool) {
C.gtk_combo_box_set_add_tearoffs(COMBO_BOX(v), gbool(add_tearoffs))
} | [
"func",
"(",
"v",
"*",
"ComboBox",
")",
"SetAddTearoffs",
"(",
"add_tearoffs",
"bool",
")",
"{",
"C",
".",
"gtk_combo_box_set_add_tearoffs",
"(",
"COMBO_BOX",
"(",
"v",
")",
",",
"gbool",
"(",
"add_tearoffs",
")",
")",
"\n",
"}"
] | // gtk_combo_box_get_popup_accessible
// gtk_combo_box_get_row_separator_func
// gtk_combo_box_set_row_separator_func | [
"gtk_combo_box_get_popup_accessible",
"gtk_combo_box_get_row_separator_func",
"gtk_combo_box_set_row_separator_func"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L6173-L6175 | train |
mattn/go-gtk | gtk/gtk.go | SetGroup | func (v *RadioMenuItem) SetGroup(group *glib.SList) {
C.gtk_radio_menu_item_set_group(RADIO_MENU_ITEM(v), gslist(group))
} | go | func (v *RadioMenuItem) SetGroup(group *glib.SList) {
C.gtk_radio_menu_item_set_group(RADIO_MENU_ITEM(v), gslist(group))
} | [
"func",
"(",
"v",
"*",
"RadioMenuItem",
")",
"SetGroup",
"(",
"group",
"*",
"glib",
".",
"SList",
")",
"{",
"C",
".",
"gtk_radio_menu_item_set_group",
"(",
"RADIO_MENU_ITEM",
"(",
"v",
")",
",",
"gslist",
"(",
"group",
")",
")",
"\n",
"}"
] | // gtk_radio_menu_item_new_with_mnemonic
// gtk_radio_menu_item_new_from_widget
// gtk_radio_menu_item_new_with_label_from_widget
// gtk_radio_menu_item_new_with_mnemonic_from_widget
// gtk_radio_menu_item_group | [
"gtk_radio_menu_item_new_with_mnemonic",
"gtk_radio_menu_item_new_from_widget",
"gtk_radio_menu_item_new_with_label_from_widget",
"gtk_radio_menu_item_new_with_mnemonic_from_widget",
"gtk_radio_menu_item_group"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L6606-L6608 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.