id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
137,500 | exoscale/egoscale | client.go | Paginate | func (client *Client) Paginate(g Listable, callback IterateItemFunc) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
client.PaginateWithContext(ctx, g, callback)
} | go | func (client *Client) Paginate(g Listable, callback IterateItemFunc) {
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
defer cancel()
client.PaginateWithContext(ctx, g, callback)
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"Paginate",
"(",
"g",
"Listable",
",",
"callback",
"IterateItemFunc",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"client",
".",
"Timeou... | // Paginate runs the ListCommand and paginates | [
"Paginate",
"runs",
"the",
"ListCommand",
"and",
"paginates"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L257-L262 |
137,501 | exoscale/egoscale | client.go | PaginateWithContext | func (client *Client) PaginateWithContext(ctx context.Context, g Listable, callback IterateItemFunc) {
req, err := g.ListRequest()
if err != nil {
callback(nil, err)
return
}
pageSize := client.PageSize
page := 1
for {
req.SetPage(page)
req.SetPageSize(pageSize)
resp, err := client.RequestWithContext... | go | func (client *Client) PaginateWithContext(ctx context.Context, g Listable, callback IterateItemFunc) {
req, err := g.ListRequest()
if err != nil {
callback(nil, err)
return
}
pageSize := client.PageSize
page := 1
for {
req.SetPage(page)
req.SetPageSize(pageSize)
resp, err := client.RequestWithContext... | [
"func",
"(",
"client",
"*",
"Client",
")",
"PaginateWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"Listable",
",",
"callback",
"IterateItemFunc",
")",
"{",
"req",
",",
"err",
":=",
"g",
".",
"ListRequest",
"(",
")",
"\n",
"if",
"err",
... | // PaginateWithContext runs the ListCommand as long as the ctx is valid | [
"PaginateWithContext",
"runs",
"the",
"ListCommand",
"as",
"long",
"as",
"the",
"ctx",
"is",
"valid"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L265-L314 |
137,502 | exoscale/egoscale | client.go | APIName | func (client *Client) APIName(command Command) string {
// This is due to a limitation of Go<=1.7
_, ok := command.(*AuthorizeSecurityGroupEgress)
_, okPtr := command.(AuthorizeSecurityGroupEgress)
if ok || okPtr {
return "authorizeSecurityGroupEgress"
}
info, err := info(command)
if err != nil {
panic(err)... | go | func (client *Client) APIName(command Command) string {
// This is due to a limitation of Go<=1.7
_, ok := command.(*AuthorizeSecurityGroupEgress)
_, okPtr := command.(AuthorizeSecurityGroupEgress)
if ok || okPtr {
return "authorizeSecurityGroupEgress"
}
info, err := info(command)
if err != nil {
panic(err)... | [
"func",
"(",
"client",
"*",
"Client",
")",
"APIName",
"(",
"command",
"Command",
")",
"string",
"{",
"// This is due to a limitation of Go<=1.7",
"_",
",",
"ok",
":=",
"command",
".",
"(",
"*",
"AuthorizeSecurityGroupEgress",
")",
"\n",
"_",
",",
"okPtr",
":="... | // APIName returns the name of the given command | [
"APIName",
"returns",
"the",
"name",
"of",
"the",
"given",
"command"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L317-L330 |
137,503 | exoscale/egoscale | client.go | APIDescription | func (client *Client) APIDescription(command Command) string {
info, err := info(command)
if err != nil {
return "*missing description*"
}
return info.Description
} | go | func (client *Client) APIDescription(command Command) string {
info, err := info(command)
if err != nil {
return "*missing description*"
}
return info.Description
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"APIDescription",
"(",
"command",
"Command",
")",
"string",
"{",
"info",
",",
"err",
":=",
"info",
"(",
"command",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
... | // APIDescription returns the description of the given command | [
"APIDescription",
"returns",
"the",
"description",
"of",
"the",
"given",
"command"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L333-L339 |
137,504 | exoscale/egoscale | client.go | Response | func (client *Client) Response(command Command) interface{} {
switch c := command.(type) {
case AsyncCommand:
return c.AsyncResponse()
default:
return command.Response()
}
} | go | func (client *Client) Response(command Command) interface{} {
switch c := command.(type) {
case AsyncCommand:
return c.AsyncResponse()
default:
return command.Response()
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"Response",
"(",
"command",
"Command",
")",
"interface",
"{",
"}",
"{",
"switch",
"c",
":=",
"command",
".",
"(",
"type",
")",
"{",
"case",
"AsyncCommand",
":",
"return",
"c",
".",
"AsyncResponse",
"(",
")",
... | // Response returns the response structure of the given command | [
"Response",
"returns",
"the",
"response",
"structure",
"of",
"the",
"given",
"command"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L342-L349 |
137,505 | exoscale/egoscale | client.go | TraceOn | func (client *Client) TraceOn() {
if _, ok := client.HTTPClient.Transport.(*traceTransport); !ok {
client.HTTPClient.Transport = &traceTransport{
transport: client.HTTPClient.Transport,
logger: client.Logger,
}
}
} | go | func (client *Client) TraceOn() {
if _, ok := client.HTTPClient.Transport.(*traceTransport); !ok {
client.HTTPClient.Transport = &traceTransport{
transport: client.HTTPClient.Transport,
logger: client.Logger,
}
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"TraceOn",
"(",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"client",
".",
"HTTPClient",
".",
"Transport",
".",
"(",
"*",
"traceTransport",
")",
";",
"!",
"ok",
"{",
"client",
".",
"HTTPClient",
".",
"Transport",
... | // TraceOn activates the HTTP tracer | [
"TraceOn",
"activates",
"the",
"HTTP",
"tracer"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L352-L359 |
137,506 | exoscale/egoscale | client.go | TraceOff | func (client *Client) TraceOff() {
if rt, ok := client.HTTPClient.Transport.(*traceTransport); ok {
client.HTTPClient.Transport = rt.transport
}
} | go | func (client *Client) TraceOff() {
if rt, ok := client.HTTPClient.Transport.(*traceTransport); ok {
client.HTTPClient.Transport = rt.transport
}
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"TraceOff",
"(",
")",
"{",
"if",
"rt",
",",
"ok",
":=",
"client",
".",
"HTTPClient",
".",
"Transport",
".",
"(",
"*",
"traceTransport",
")",
";",
"ok",
"{",
"client",
".",
"HTTPClient",
".",
"Transport",
"="... | // TraceOff deactivates the HTTP tracer | [
"TraceOff",
"deactivates",
"the",
"HTTP",
"tracer"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L362-L366 |
137,507 | exoscale/egoscale | client.go | RoundTrip | func (t *traceTransport) RoundTrip(req *http.Request) (*http.Response, error) {
if dump, err := httputil.DumpRequest(req, true); err == nil {
t.logger.Printf("%s", dump)
}
resp, err := t.transport.RoundTrip(req)
if err != nil {
return nil, err
}
if dump, err := httputil.DumpResponse(resp, true); err == nil ... | go | func (t *traceTransport) RoundTrip(req *http.Request) (*http.Response, error) {
if dump, err := httputil.DumpRequest(req, true); err == nil {
t.logger.Printf("%s", dump)
}
resp, err := t.transport.RoundTrip(req)
if err != nil {
return nil, err
}
if dump, err := httputil.DumpResponse(resp, true); err == nil ... | [
"func",
"(",
"t",
"*",
"traceTransport",
")",
"RoundTrip",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"if",
"dump",
",",
"err",
":=",
"httputil",
".",
"DumpRequest",
"(",
"req",
",",
"tr... | // RoundTrip executes a single HTTP transaction | [
"RoundTrip",
"executes",
"a",
"single",
"HTTP",
"transaction"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L375-L390 |
137,508 | exoscale/egoscale | client.go | MonotonicRetryStrategyFunc | func MonotonicRetryStrategyFunc(seconds int) RetryStrategyFunc {
return func(iteration int64) time.Duration {
return time.Duration(seconds) * time.Second
}
} | go | func MonotonicRetryStrategyFunc(seconds int) RetryStrategyFunc {
return func(iteration int64) time.Duration {
return time.Duration(seconds) * time.Second
}
} | [
"func",
"MonotonicRetryStrategyFunc",
"(",
"seconds",
"int",
")",
"RetryStrategyFunc",
"{",
"return",
"func",
"(",
"iteration",
"int64",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Duration",
"(",
"seconds",
")",
"*",
"time",
".",
"Second",
"\... | // MonotonicRetryStrategyFunc returns a function that waits for n seconds for each iteration | [
"MonotonicRetryStrategyFunc",
"returns",
"a",
"function",
"that",
"waits",
"for",
"n",
"seconds",
"for",
"each",
"iteration"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L393-L397 |
137,509 | exoscale/egoscale | client.go | FibonacciRetryStrategy | func FibonacciRetryStrategy(iteration int64) time.Duration {
var a, b, i, tmp int64
a = 0
b = 1
for i = 0; i < iteration; i++ {
tmp = a + b
a = b
b = tmp
}
return time.Duration(a) * time.Second
} | go | func FibonacciRetryStrategy(iteration int64) time.Duration {
var a, b, i, tmp int64
a = 0
b = 1
for i = 0; i < iteration; i++ {
tmp = a + b
a = b
b = tmp
}
return time.Duration(a) * time.Second
} | [
"func",
"FibonacciRetryStrategy",
"(",
"iteration",
"int64",
")",
"time",
".",
"Duration",
"{",
"var",
"a",
",",
"b",
",",
"i",
",",
"tmp",
"int64",
"\n",
"a",
"=",
"0",
"\n",
"b",
"=",
"1",
"\n",
"for",
"i",
"=",
"0",
";",
"i",
"<",
"iteration",... | // FibonacciRetryStrategy waits for an increasing amount of time following the Fibonacci sequence | [
"FibonacciRetryStrategy",
"waits",
"for",
"an",
"increasing",
"amount",
"of",
"time",
"following",
"the",
"Fibonacci",
"sequence"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/client.go#L400-L410 |
137,510 | exoscale/egoscale | virtual_machines.go | Delete | func (vm VirtualMachine) Delete(ctx context.Context, client *Client) error {
_, err := client.RequestWithContext(ctx, &DestroyVirtualMachine{
ID: vm.ID,
})
return err
} | go | func (vm VirtualMachine) Delete(ctx context.Context, client *Client) error {
_, err := client.RequestWithContext(ctx, &DestroyVirtualMachine{
ID: vm.ID,
})
return err
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"*",
"Client",
")",
"error",
"{",
"_",
",",
"err",
":=",
"client",
".",
"RequestWithContext",
"(",
"ctx",
",",
"&",
"DestroyVirtualMachine",
"{",
"I... | // Delete destroys the VM | [
"Delete",
"destroys",
"the",
"VM"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L112-L118 |
137,511 | exoscale/egoscale | virtual_machines.go | ListRequest | func (vm VirtualMachine) ListRequest() (ListCommand, error) {
// XXX: AffinityGroupID, SecurityGroupID
req := &ListVirtualMachines{
GroupID: vm.GroupID,
ID: vm.ID,
Name: vm.Name,
State: vm.State,
TemplateID: vm.TemplateID,
ZoneID: vm.ZoneID,
}
nic := vm.DefaultNic()
if nic !... | go | func (vm VirtualMachine) ListRequest() (ListCommand, error) {
// XXX: AffinityGroupID, SecurityGroupID
req := &ListVirtualMachines{
GroupID: vm.GroupID,
ID: vm.ID,
Name: vm.Name,
State: vm.State,
TemplateID: vm.TemplateID,
ZoneID: vm.ZoneID,
}
nic := vm.DefaultNic()
if nic !... | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"// XXX: AffinityGroupID, SecurityGroupID",
"req",
":=",
"&",
"ListVirtualMachines",
"{",
"GroupID",
":",
"vm",
".",
"GroupID",
",",
"ID",
":",
"vm",... | // ListRequest builds the ListVirtualMachines request | [
"ListRequest",
"builds",
"the",
"ListVirtualMachines",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L121-L143 |
137,512 | exoscale/egoscale | virtual_machines.go | DefaultNic | func (vm VirtualMachine) DefaultNic() *Nic {
for i, nic := range vm.Nic {
if nic.IsDefault {
return &vm.Nic[i]
}
}
return nil
} | go | func (vm VirtualMachine) DefaultNic() *Nic {
for i, nic := range vm.Nic {
if nic.IsDefault {
return &vm.Nic[i]
}
}
return nil
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"DefaultNic",
"(",
")",
"*",
"Nic",
"{",
"for",
"i",
",",
"nic",
":=",
"range",
"vm",
".",
"Nic",
"{",
"if",
"nic",
".",
"IsDefault",
"{",
"return",
"&",
"vm",
".",
"Nic",
"[",
"i",
"]",
"\n",
"}",
"\n"... | // DefaultNic returns the default nic | [
"DefaultNic",
"returns",
"the",
"default",
"nic"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L146-L154 |
137,513 | exoscale/egoscale | virtual_machines.go | IP | func (vm VirtualMachine) IP() *net.IP {
nic := vm.DefaultNic()
if nic != nil {
ip := nic.IPAddress
return &ip
}
return nil
} | go | func (vm VirtualMachine) IP() *net.IP {
nic := vm.DefaultNic()
if nic != nil {
ip := nic.IPAddress
return &ip
}
return nil
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"IP",
"(",
")",
"*",
"net",
".",
"IP",
"{",
"nic",
":=",
"vm",
".",
"DefaultNic",
"(",
")",
"\n",
"if",
"nic",
"!=",
"nil",
"{",
"ip",
":=",
"nic",
".",
"IPAddress",
"\n",
"return",
"&",
"ip",
"\n",
"}"... | // IP returns the default nic IP address | [
"IP",
"returns",
"the",
"default",
"nic",
"IP",
"address"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L157-L165 |
137,514 | exoscale/egoscale | virtual_machines.go | NicsByType | func (vm VirtualMachine) NicsByType(nicType string) []Nic {
nics := make([]Nic, 0)
for _, nic := range vm.Nic {
if nic.Type == nicType {
// XXX The API forgets to specify it
n := nic
n.VirtualMachineID = vm.ID
nics = append(nics, n)
}
}
return nics
} | go | func (vm VirtualMachine) NicsByType(nicType string) []Nic {
nics := make([]Nic, 0)
for _, nic := range vm.Nic {
if nic.Type == nicType {
// XXX The API forgets to specify it
n := nic
n.VirtualMachineID = vm.ID
nics = append(nics, n)
}
}
return nics
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"NicsByType",
"(",
"nicType",
"string",
")",
"[",
"]",
"Nic",
"{",
"nics",
":=",
"make",
"(",
"[",
"]",
"Nic",
",",
"0",
")",
"\n",
"for",
"_",
",",
"nic",
":=",
"range",
"vm",
".",
"Nic",
"{",
"if",
"n... | // NicsByType returns the corresponding interfaces base on the given type | [
"NicsByType",
"returns",
"the",
"corresponding",
"interfaces",
"base",
"on",
"the",
"given",
"type"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L168-L179 |
137,515 | exoscale/egoscale | virtual_machines.go | NicByNetworkID | func (vm VirtualMachine) NicByNetworkID(networkID UUID) *Nic {
for _, nic := range vm.Nic {
if nic.NetworkID.Equal(networkID) {
n := nic
n.VirtualMachineID = vm.ID
return &n
}
}
return nil
} | go | func (vm VirtualMachine) NicByNetworkID(networkID UUID) *Nic {
for _, nic := range vm.Nic {
if nic.NetworkID.Equal(networkID) {
n := nic
n.VirtualMachineID = vm.ID
return &n
}
}
return nil
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"NicByNetworkID",
"(",
"networkID",
"UUID",
")",
"*",
"Nic",
"{",
"for",
"_",
",",
"nic",
":=",
"range",
"vm",
".",
"Nic",
"{",
"if",
"nic",
".",
"NetworkID",
".",
"Equal",
"(",
"networkID",
")",
"{",
"n",
... | // NicByNetworkID returns the corresponding interface based on the given NetworkID
//
// A VM cannot be connected twice to a same network. | [
"NicByNetworkID",
"returns",
"the",
"corresponding",
"interface",
"based",
"on",
"the",
"given",
"NetworkID",
"A",
"VM",
"cannot",
"be",
"connected",
"twice",
"to",
"a",
"same",
"network",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L184-L193 |
137,516 | exoscale/egoscale | virtual_machines.go | NicByID | func (vm VirtualMachine) NicByID(nicID UUID) *Nic {
for _, nic := range vm.Nic {
if nic.ID.Equal(nicID) {
n := nic
n.VirtualMachineID = vm.ID
return &n
}
}
return nil
} | go | func (vm VirtualMachine) NicByID(nicID UUID) *Nic {
for _, nic := range vm.Nic {
if nic.ID.Equal(nicID) {
n := nic
n.VirtualMachineID = vm.ID
return &n
}
}
return nil
} | [
"func",
"(",
"vm",
"VirtualMachine",
")",
"NicByID",
"(",
"nicID",
"UUID",
")",
"*",
"Nic",
"{",
"for",
"_",
",",
"nic",
":=",
"range",
"vm",
".",
"Nic",
"{",
"if",
"nic",
".",
"ID",
".",
"Equal",
"(",
"nicID",
")",
"{",
"n",
":=",
"nic",
"\n",... | // NicByID returns the corresponding interface base on its ID | [
"NicByID",
"returns",
"the",
"corresponding",
"interface",
"base",
"on",
"its",
"ID"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/virtual_machines.go#L196-L206 |
137,517 | exoscale/egoscale | accounts.go | ListRequest | func (a Account) ListRequest() (ListCommand, error) {
return &ListAccounts{
ID: a.ID,
State: a.State,
}, nil
} | go | func (a Account) ListRequest() (ListCommand, error) {
return &ListAccounts{
ID: a.ID,
State: a.State,
}, nil
} | [
"func",
"(",
"a",
"Account",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"return",
"&",
"ListAccounts",
"{",
"ID",
":",
"a",
".",
"ID",
",",
"State",
":",
"a",
".",
"State",
",",
"}",
",",
"nil",
"\n",
"}"
] | // ListRequest builds the ListAccountsGroups request | [
"ListRequest",
"builds",
"the",
"ListAccountsGroups",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/accounts.go#L55-L60 |
137,518 | exoscale/egoscale | nics.go | ListRequest | func (nic Nic) ListRequest() (ListCommand, error) {
req := &ListNics{
VirtualMachineID: nic.VirtualMachineID,
NicID: nic.ID,
NetworkID: nic.NetworkID,
}
return req, nil
} | go | func (nic Nic) ListRequest() (ListCommand, error) {
req := &ListNics{
VirtualMachineID: nic.VirtualMachineID,
NicID: nic.ID,
NetworkID: nic.NetworkID,
}
return req, nil
} | [
"func",
"(",
"nic",
"Nic",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListNics",
"{",
"VirtualMachineID",
":",
"nic",
".",
"VirtualMachineID",
",",
"NicID",
":",
"nic",
".",
"ID",
",",
"NetworkID",
":",... | // ListRequest build a ListNics request from the given Nic | [
"ListRequest",
"build",
"a",
"ListNics",
"request",
"from",
"the",
"given",
"Nic"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/nics.go#L33-L41 |
137,519 | exoscale/egoscale | isos.go | ListRequest | func (iso ISO) ListRequest() (ListCommand, error) {
req := &ListISOs{
ID: iso.ID,
Name: iso.Name,
ZoneID: iso.ZoneID,
}
if iso.Bootable {
*req.Bootable = true
}
if iso.IsFeatured {
req.IsoFilter = "featured"
}
if iso.IsPublic {
*req.IsPublic = true
}
if iso.IsReady {
*req.IsReady = true
}
... | go | func (iso ISO) ListRequest() (ListCommand, error) {
req := &ListISOs{
ID: iso.ID,
Name: iso.Name,
ZoneID: iso.ZoneID,
}
if iso.Bootable {
*req.Bootable = true
}
if iso.IsFeatured {
req.IsoFilter = "featured"
}
if iso.IsPublic {
*req.IsPublic = true
}
if iso.IsReady {
*req.IsReady = true
}
... | [
"func",
"(",
"iso",
"ISO",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"req",
":=",
"&",
"ListISOs",
"{",
"ID",
":",
"iso",
".",
"ID",
",",
"Name",
":",
"iso",
".",
"Name",
",",
"ZoneID",
":",
"iso",
".",
"ZoneID",
... | // ListRequest produces the ListIsos command. | [
"ListRequest",
"produces",
"the",
"ListIsos",
"command",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/isos.go#L12-L36 |
137,520 | exoscale/egoscale | affinity_groups.go | ListRequest | func (ag AffinityGroup) ListRequest() (ListCommand, error) {
return &ListAffinityGroups{
ID: ag.ID,
Name: ag.Name,
}, nil
} | go | func (ag AffinityGroup) ListRequest() (ListCommand, error) {
return &ListAffinityGroups{
ID: ag.ID,
Name: ag.Name,
}, nil
} | [
"func",
"(",
"ag",
"AffinityGroup",
")",
"ListRequest",
"(",
")",
"(",
"ListCommand",
",",
"error",
")",
"{",
"return",
"&",
"ListAffinityGroups",
"{",
"ID",
":",
"ag",
".",
"ID",
",",
"Name",
":",
"ag",
".",
"Name",
",",
"}",
",",
"nil",
"\n",
"}"... | // ListRequest builds the ListAffinityGroups request | [
"ListRequest",
"builds",
"the",
"ListAffinityGroups",
"request"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/affinity_groups.go#L23-L28 |
137,521 | exoscale/egoscale | affinity_groups.go | Delete | func (ag AffinityGroup) Delete(ctx context.Context, client *Client) error {
if ag.ID == nil && ag.Name == "" {
return fmt.Errorf("an Affinity Group may only be deleted using ID or Name")
}
req := &DeleteAffinityGroup{}
if ag.ID != nil {
req.ID = ag.ID
} else {
req.Name = ag.Name
}
return client.BooleanR... | go | func (ag AffinityGroup) Delete(ctx context.Context, client *Client) error {
if ag.ID == nil && ag.Name == "" {
return fmt.Errorf("an Affinity Group may only be deleted using ID or Name")
}
req := &DeleteAffinityGroup{}
if ag.ID != nil {
req.ID = ag.ID
} else {
req.Name = ag.Name
}
return client.BooleanR... | [
"func",
"(",
"ag",
"AffinityGroup",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"*",
"Client",
")",
"error",
"{",
"if",
"ag",
".",
"ID",
"==",
"nil",
"&&",
"ag",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"... | // Delete removes the given Affinity Group | [
"Delete",
"removes",
"the",
"given",
"Affinity",
"Group"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/affinity_groups.go#L31-L45 |
137,522 | exoscale/egoscale | macaddress.go | MAC48 | func MAC48(a, b, c, d, e, f byte) MACAddress {
m := make(MACAddress, 6)
m[0] = a
m[1] = b
m[2] = c
m[3] = d
m[4] = e
m[5] = f
return m
} | go | func MAC48(a, b, c, d, e, f byte) MACAddress {
m := make(MACAddress, 6)
m[0] = a
m[1] = b
m[2] = c
m[3] = d
m[4] = e
m[5] = f
return m
} | [
"func",
"MAC48",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
",",
"f",
"byte",
")",
"MACAddress",
"{",
"m",
":=",
"make",
"(",
"MACAddress",
",",
"6",
")",
"\n",
"m",
"[",
"0",
"]",
"=",
"a",
"\n",
"m",
"[",
"1",
"]",
"=",
"b",
"\... | // MAC48 builds a MAC-48 MACAddress | [
"MAC48",
"builds",
"a",
"MAC",
"-",
"48",
"MACAddress"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/macaddress.go#L18-L27 |
137,523 | exoscale/egoscale | macaddress.go | MarshalJSON | func (mac MACAddress) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("%q", mac.String())), nil
} | go | func (mac MACAddress) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("%q", mac.String())), nil
} | [
"func",
"(",
"mac",
"MACAddress",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"mac",
".",
"String",
"(",
")",
")",
")",
",",
"nil",
... | // MarshalJSON converts the MAC Address to a string representation | [
"MarshalJSON",
"converts",
"the",
"MAC",
"Address",
"to",
"a",
"string",
"representation"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/macaddress.go#L46-L48 |
137,524 | exoscale/egoscale | macaddress.go | ParseMAC | func ParseMAC(s string) (MACAddress, error) {
hw, err := net.ParseMAC(s)
return (MACAddress)(hw), err
} | go | func ParseMAC(s string) (MACAddress, error) {
hw, err := net.ParseMAC(s)
return (MACAddress)(hw), err
} | [
"func",
"ParseMAC",
"(",
"s",
"string",
")",
"(",
"MACAddress",
",",
"error",
")",
"{",
"hw",
",",
"err",
":=",
"net",
".",
"ParseMAC",
"(",
"s",
")",
"\n",
"return",
"(",
"MACAddress",
")",
"(",
"hw",
")",
",",
"err",
"\n",
"}"
] | // ParseMAC converts a string into a MACAddress | [
"ParseMAC",
"converts",
"a",
"string",
"into",
"a",
"MACAddress"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/macaddress.go#L51-L54 |
137,525 | exoscale/egoscale | macaddress.go | MustParseMAC | func MustParseMAC(s string) MACAddress {
mac, err := ParseMAC(s)
if err != nil {
panic(err)
}
return mac
} | go | func MustParseMAC(s string) MACAddress {
mac, err := ParseMAC(s)
if err != nil {
panic(err)
}
return mac
} | [
"func",
"MustParseMAC",
"(",
"s",
"string",
")",
"MACAddress",
"{",
"mac",
",",
"err",
":=",
"ParseMAC",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"mac",
"\n",
"}"
] | // MustParseMAC acts like ParseMAC but panics if in case of an error | [
"MustParseMAC",
"acts",
"like",
"ParseMAC",
"but",
"panics",
"if",
"in",
"case",
"of",
"an",
"error"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/macaddress.go#L57-L63 |
137,526 | exoscale/egoscale | runstatus_maintenance.go | Match | func (maintenance RunstatusMaintenance) Match(other RunstatusMaintenance) bool {
if other.Title != "" && maintenance.Title == other.Title {
return true
}
if other.ID > 0 && maintenance.ID == other.ID {
return true
}
return false
} | go | func (maintenance RunstatusMaintenance) Match(other RunstatusMaintenance) bool {
if other.Title != "" && maintenance.Title == other.Title {
return true
}
if other.ID > 0 && maintenance.ID == other.ID {
return true
}
return false
} | [
"func",
"(",
"maintenance",
"RunstatusMaintenance",
")",
"Match",
"(",
"other",
"RunstatusMaintenance",
")",
"bool",
"{",
"if",
"other",
".",
"Title",
"!=",
"\"",
"\"",
"&&",
"maintenance",
".",
"Title",
"==",
"other",
".",
"Title",
"{",
"return",
"true",
... | // Match returns true if the other maintenance has got similarities with itself | [
"Match",
"returns",
"true",
"if",
"the",
"other",
"maintenance",
"has",
"got",
"similarities",
"with",
"itself"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_maintenance.go#L32-L42 |
137,527 | exoscale/egoscale | runstatus_maintenance.go | GetRunstatusMaintenance | func (client *Client) GetRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance) (*RunstatusMaintenance, error) {
if maintenance.URL != "" {
return client.getRunstatusMaintenance(ctx, maintenance.URL)
}
if maintenance.PageURL == "" {
return nil, fmt.Errorf("empty Page URL for %#v", maintenan... | go | func (client *Client) GetRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance) (*RunstatusMaintenance, error) {
if maintenance.URL != "" {
return client.getRunstatusMaintenance(ctx, maintenance.URL)
}
if maintenance.PageURL == "" {
return nil, fmt.Errorf("empty Page URL for %#v", maintenan... | [
"func",
"(",
"client",
"*",
"Client",
")",
"GetRunstatusMaintenance",
"(",
"ctx",
"context",
".",
"Context",
",",
"maintenance",
"RunstatusMaintenance",
")",
"(",
"*",
"RunstatusMaintenance",
",",
"error",
")",
"{",
"if",
"maintenance",
".",
"URL",
"!=",
"\"",... | // GetRunstatusMaintenance retrieves the details of a specific maintenance. | [
"GetRunstatusMaintenance",
"retrieves",
"the",
"details",
"of",
"a",
"specific",
"maintenance",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_maintenance.go#L76-L101 |
137,528 | exoscale/egoscale | runstatus_maintenance.go | ListRunstatusMaintenances | func (client *Client) ListRunstatusMaintenances(ctx context.Context, page RunstatusPage) ([]RunstatusMaintenance, error) {
if page.MaintenancesURL == "" {
return nil, fmt.Errorf("empty Maintenances URL for %#v", page)
}
results := make([]RunstatusMaintenance, 0)
var err error
client.PaginateRunstatusMaintenanc... | go | func (client *Client) ListRunstatusMaintenances(ctx context.Context, page RunstatusPage) ([]RunstatusMaintenance, error) {
if page.MaintenancesURL == "" {
return nil, fmt.Errorf("empty Maintenances URL for %#v", page)
}
results := make([]RunstatusMaintenance, 0)
var err error
client.PaginateRunstatusMaintenanc... | [
"func",
"(",
"client",
"*",
"Client",
")",
"ListRunstatusMaintenances",
"(",
"ctx",
"context",
".",
"Context",
",",
"page",
"RunstatusPage",
")",
"(",
"[",
"]",
"RunstatusMaintenance",
",",
"error",
")",
"{",
"if",
"page",
".",
"MaintenancesURL",
"==",
"\"",... | // ListRunstatusMaintenances returns the list of maintenances for the page. | [
"ListRunstatusMaintenances",
"returns",
"the",
"list",
"of",
"maintenances",
"for",
"the",
"page",
"."
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_maintenance.go#L117-L136 |
137,529 | exoscale/egoscale | runstatus_maintenance.go | PaginateRunstatusMaintenances | func (client *Client) PaginateRunstatusMaintenances(ctx context.Context, page RunstatusPage, callback func(*RunstatusMaintenance, error) bool) { // nolint: dupl
if page.MaintenancesURL == "" {
callback(nil, fmt.Errorf("empty Maintenances URL for %#v", page))
return
}
maintenancesURL := page.MaintenancesURL
for... | go | func (client *Client) PaginateRunstatusMaintenances(ctx context.Context, page RunstatusPage, callback func(*RunstatusMaintenance, error) bool) { // nolint: dupl
if page.MaintenancesURL == "" {
callback(nil, fmt.Errorf("empty Maintenances URL for %#v", page))
return
}
maintenancesURL := page.MaintenancesURL
for... | [
"func",
"(",
"client",
"*",
"Client",
")",
"PaginateRunstatusMaintenances",
"(",
"ctx",
"context",
".",
"Context",
",",
"page",
"RunstatusPage",
",",
"callback",
"func",
"(",
"*",
"RunstatusMaintenance",
",",
"error",
")",
"bool",
")",
"{",
"// nolint: dupl",
... | // PaginateRunstatusMaintenances paginate Maintenances | [
"PaginateRunstatusMaintenances",
"paginate",
"Maintenances"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_maintenance.go#L139-L170 |
137,530 | exoscale/egoscale | runstatus_maintenance.go | CreateRunstatusMaintenance | func (client *Client) CreateRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance) (*RunstatusMaintenance, error) {
if maintenance.PageURL == "" {
return nil, fmt.Errorf("empty Page URL for %#v", maintenance)
}
page, err := client.getRunstatusPage(ctx, maintenance.PageURL)
if err != nil {
... | go | func (client *Client) CreateRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance) (*RunstatusMaintenance, error) {
if maintenance.PageURL == "" {
return nil, fmt.Errorf("empty Page URL for %#v", maintenance)
}
page, err := client.getRunstatusPage(ctx, maintenance.PageURL)
if err != nil {
... | [
"func",
"(",
"client",
"*",
"Client",
")",
"CreateRunstatusMaintenance",
"(",
"ctx",
"context",
".",
"Context",
",",
"maintenance",
"RunstatusMaintenance",
")",
"(",
"*",
"RunstatusMaintenance",
",",
"error",
")",
"{",
"if",
"maintenance",
".",
"PageURL",
"==",
... | // CreateRunstatusMaintenance create runstatus Maintenance | [
"CreateRunstatusMaintenance",
"create",
"runstatus",
"Maintenance"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_maintenance.go#L173-L198 |
137,531 | exoscale/egoscale | runstatus_maintenance.go | DeleteRunstatusMaintenance | func (client *Client) DeleteRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance) error {
if maintenance.URL == "" {
return fmt.Errorf("empty URL for %#v", maintenance)
}
_, err := client.runstatusRequest(ctx, maintenance.URL, nil, "DELETE")
return err
} | go | func (client *Client) DeleteRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance) error {
if maintenance.URL == "" {
return fmt.Errorf("empty URL for %#v", maintenance)
}
_, err := client.runstatusRequest(ctx, maintenance.URL, nil, "DELETE")
return err
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"DeleteRunstatusMaintenance",
"(",
"ctx",
"context",
".",
"Context",
",",
"maintenance",
"RunstatusMaintenance",
")",
"error",
"{",
"if",
"maintenance",
".",
"URL",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Erro... | // DeleteRunstatusMaintenance delete runstatus Maintenance | [
"DeleteRunstatusMaintenance",
"delete",
"runstatus",
"Maintenance"
] | 4e527724b8225e8315d580accd1c4e860202d41b | https://github.com/exoscale/egoscale/blob/4e527724b8225e8315d580accd1c4e860202d41b/runstatus_maintenance.go#L201-L208 |
137,532 | nemosupremo/vault-gatekeeper | tlsutil.go | ListenAndServeTLS | func ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handler) error {
// From http.ListenAndServeTLS:
// https://github.com/golang/go/blob/release-branch.go1.10/src/net/http/server.go#L3000-L3003
server := &http.Server{Addr: addr, Handler: handler}
keypair, err := NewKeypairReloader(certFile, keyFil... | go | func ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handler) error {
// From http.ListenAndServeTLS:
// https://github.com/golang/go/blob/release-branch.go1.10/src/net/http/server.go#L3000-L3003
server := &http.Server{Addr: addr, Handler: handler}
keypair, err := NewKeypairReloader(certFile, keyFil... | [
"func",
"ListenAndServeTLS",
"(",
"addr",
",",
"certFile",
",",
"keyFile",
"string",
",",
"handler",
"http",
".",
"Handler",
")",
"error",
"{",
"// From http.ListenAndServeTLS:",
"// https://github.com/golang/go/blob/release-branch.go1.10/src/net/http/server.go#L3000-L3003",
"s... | // This works just like http.ListenAndServeTLS but certificates are loaded into
// a wrapper struct that reloads certificates from disk when a SIGHUP is
// received. | [
"This",
"works",
"just",
"like",
"http",
".",
"ListenAndServeTLS",
"but",
"certificates",
"are",
"loaded",
"into",
"a",
"wrapper",
"struct",
"that",
"reloads",
"certificates",
"from",
"disk",
"when",
"a",
"SIGHUP",
"is",
"received",
"."
] | d47c5055802338e8bb6d668bd36d1c330064d16e | https://github.com/nemosupremo/vault-gatekeeper/blob/d47c5055802338e8bb6d668bd36d1c330064d16e/tlsutil.go#L77-L90 |
137,533 | nemosupremo/vault-gatekeeper | usagestore/memory.go | NewInMemoryUsageStore | func NewInMemoryUsageStore() (UsageStore, error) {
m := &memoryStore{}
m.set = make(map[string]memEntry)
m.quit = make(chan struct{})
go m.garbageCollector()
return m, nil
} | go | func NewInMemoryUsageStore() (UsageStore, error) {
m := &memoryStore{}
m.set = make(map[string]memEntry)
m.quit = make(chan struct{})
go m.garbageCollector()
return m, nil
} | [
"func",
"NewInMemoryUsageStore",
"(",
")",
"(",
"UsageStore",
",",
"error",
")",
"{",
"m",
":=",
"&",
"memoryStore",
"{",
"}",
"\n",
"m",
".",
"set",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"memEntry",
")",
"\n",
"m",
".",
"quit",
"=",
"make",... | // NewInMemoryUsageStore creates a usage store backed by memory. This usage
// store is only appropriate for single instance gatekeeper deployments
// and should not be used for high availablility deployments. | [
"NewInMemoryUsageStore",
"creates",
"a",
"usage",
"store",
"backed",
"by",
"memory",
".",
"This",
"usage",
"store",
"is",
"only",
"appropriate",
"for",
"single",
"instance",
"gatekeeper",
"deployments",
"and",
"should",
"not",
"be",
"used",
"for",
"high",
"avail... | d47c5055802338e8bb6d668bd36d1c330064d16e | https://github.com/nemosupremo/vault-gatekeeper/blob/d47c5055802338e8bb6d668bd36d1c330064d16e/usagestore/memory.go#L24-L30 |
137,534 | nemosupremo/vault-gatekeeper | gatekeeper/cert.go | LoadCACert | func LoadCACert(path string) (*x509.CertPool, error) {
result := x509.NewCertPool()
if err := appendPEMCertsFromPath(result, path); err != nil {
return nil, err
}
return result, nil
} | go | func LoadCACert(path string) (*x509.CertPool, error) {
result := x509.NewCertPool()
if err := appendPEMCertsFromPath(result, path); err != nil {
return nil, err
}
return result, nil
} | [
"func",
"LoadCACert",
"(",
"path",
"string",
")",
"(",
"*",
"x509",
".",
"CertPool",
",",
"error",
")",
"{",
"result",
":=",
"x509",
".",
"NewCertPool",
"(",
")",
"\n",
"if",
"err",
":=",
"appendPEMCertsFromPath",
"(",
"result",
",",
"path",
")",
";",
... | // Loads the certificate from given path and creates a certificate pool from it. | [
"Loads",
"the",
"certificate",
"from",
"given",
"path",
"and",
"creates",
"a",
"certificate",
"pool",
"from",
"it",
"."
] | d47c5055802338e8bb6d668bd36d1c330064d16e | https://github.com/nemosupremo/vault-gatekeeper/blob/d47c5055802338e8bb6d668bd36d1c330064d16e/gatekeeper/cert.go#L12-L19 |
137,535 | nemosupremo/vault-gatekeeper | gatekeeper/cert.go | LoadCAPath | func LoadCAPath(path string) (*x509.CertPool, error) {
result := x509.NewCertPool()
// filepath.WalkFunc to traverse the directory structure, starting from input path
// attempting to load certs into result in the process
appendCerts := func(path string, info os.FileInfo, err error) error {
// cascade errors to ... | go | func LoadCAPath(path string) (*x509.CertPool, error) {
result := x509.NewCertPool()
// filepath.WalkFunc to traverse the directory structure, starting from input path
// attempting to load certs into result in the process
appendCerts := func(path string, info os.FileInfo, err error) error {
// cascade errors to ... | [
"func",
"LoadCAPath",
"(",
"path",
"string",
")",
"(",
"*",
"x509",
".",
"CertPool",
",",
"error",
")",
"{",
"result",
":=",
"x509",
".",
"NewCertPool",
"(",
")",
"\n\n",
"// filepath.WalkFunc to traverse the directory structure, starting from input path",
"// attempt... | // Loads the certificates present in the given directory or file and creates a
// certificate pool from it. Assumes that _only_ PEM formatted cert files
// are present in the given directory. The presence of other files will
// cause this to fail. | [
"Loads",
"the",
"certificates",
"present",
"in",
"the",
"given",
"directory",
"or",
"file",
"and",
"creates",
"a",
"certificate",
"pool",
"from",
"it",
".",
"Assumes",
"that",
"_only_",
"PEM",
"formatted",
"cert",
"files",
"are",
"present",
"in",
"the",
"giv... | d47c5055802338e8bb6d668bd36d1c330064d16e | https://github.com/nemosupremo/vault-gatekeeper/blob/d47c5055802338e8bb6d668bd36d1c330064d16e/gatekeeper/cert.go#L25-L57 |
137,536 | nemosupremo/vault-gatekeeper | scheduler/dcosee_mesos/mesos.go | NewMesosScheduler | func NewMesosScheduler(master string, uid string, privateKeyFile io.Reader) (scheduler.Scheduler, error) {
//Create the object
m := &mesosScheduler{
master: master,
uid: uid,
}
//Parse and validate the private key
if err := m.parsePrivateKey(privateKeyFile); err != nil {
return nil, err
}
//Build the ... | go | func NewMesosScheduler(master string, uid string, privateKeyFile io.Reader) (scheduler.Scheduler, error) {
//Create the object
m := &mesosScheduler{
master: master,
uid: uid,
}
//Parse and validate the private key
if err := m.parsePrivateKey(privateKeyFile); err != nil {
return nil, err
}
//Build the ... | [
"func",
"NewMesosScheduler",
"(",
"master",
"string",
",",
"uid",
"string",
",",
"privateKeyFile",
"io",
".",
"Reader",
")",
"(",
"scheduler",
".",
"Scheduler",
",",
"error",
")",
"{",
"//Create the object",
"m",
":=",
"&",
"mesosScheduler",
"{",
"master",
"... | //NewMesosScheduler creates the object for talking to mesos. In this case it
// will create the object to talk to DCOS EE Mesos which needs some authentication
// pieces setup | [
"NewMesosScheduler",
"creates",
"the",
"object",
"for",
"talking",
"to",
"mesos",
".",
"In",
"this",
"case",
"it",
"will",
"create",
"the",
"object",
"to",
"talk",
"to",
"DCOS",
"EE",
"Mesos",
"which",
"needs",
"some",
"authentication",
"pieces",
"setup"
] | d47c5055802338e8bb6d668bd36d1c330064d16e | https://github.com/nemosupremo/vault-gatekeeper/blob/d47c5055802338e8bb6d668bd36d1c330064d16e/scheduler/dcosee_mesos/mesos.go#L157-L208 |
137,537 | nemosupremo/vault-gatekeeper | scheduler/dcosee_mesos/mesos.go | parsePrivateKey | func (m *mesosScheduler) parsePrivateKey(privateKeyFile io.Reader) error {
//Read the Data from the private key file
data, err := ioutil.ReadAll(privateKeyFile)
if err != nil {
return err
}
//Parse the data in to the Private Key object
//If we need a password object for this we will have to use a different fun... | go | func (m *mesosScheduler) parsePrivateKey(privateKeyFile io.Reader) error {
//Read the Data from the private key file
data, err := ioutil.ReadAll(privateKeyFile)
if err != nil {
return err
}
//Parse the data in to the Private Key object
//If we need a password object for this we will have to use a different fun... | [
"func",
"(",
"m",
"*",
"mesosScheduler",
")",
"parsePrivateKey",
"(",
"privateKeyFile",
"io",
".",
"Reader",
")",
"error",
"{",
"//Read the Data from the private key file",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"privateKeyFile",
")",
"\n",
"if... | //Parse the private Key for the JWT | [
"Parse",
"the",
"private",
"Key",
"for",
"the",
"JWT"
] | d47c5055802338e8bb6d668bd36d1c330064d16e | https://github.com/nemosupremo/vault-gatekeeper/blob/d47c5055802338e8bb6d668bd36d1c330064d16e/scheduler/dcosee_mesos/mesos.go#L211-L233 |
137,538 | nemosupremo/vault-gatekeeper | scheduler/dcosee_mesos/mesos.go | createLoginToken | func (m *mesosScheduler) createLoginToken() ([]byte, error) {
// create a signer for rsa 256
sm := jwt.GetSigningMethod("RS256")
mc := jwt.MapClaims{}
t := jwt.NewWithClaims(sm, mc)
// set our claims
mc["uid"] = m.uid
// set the expire time
// see http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-20#... | go | func (m *mesosScheduler) createLoginToken() ([]byte, error) {
// create a signer for rsa 256
sm := jwt.GetSigningMethod("RS256")
mc := jwt.MapClaims{}
t := jwt.NewWithClaims(sm, mc)
// set our claims
mc["uid"] = m.uid
// set the expire time
// see http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-20#... | [
"func",
"(",
"m",
"*",
"mesosScheduler",
")",
"createLoginToken",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// create a signer for rsa 256",
"sm",
":=",
"jwt",
".",
"GetSigningMethod",
"(",
"\"",
"\"",
")",
"\n",
"mc",
":=",
"jwt",
".",
... | //Create the DCOS login token based on the private key and uid | [
"Create",
"the",
"DCOS",
"login",
"token",
"based",
"on",
"the",
"private",
"key",
"and",
"uid"
] | d47c5055802338e8bb6d668bd36d1c330064d16e | https://github.com/nemosupremo/vault-gatekeeper/blob/d47c5055802338e8bb6d668bd36d1c330064d16e/scheduler/dcosee_mesos/mesos.go#L236-L258 |
137,539 | nemosupremo/vault-gatekeeper | vault/unsealer/unsealer.go | Token | func (t TokenUnsealer) Token() (string, error) {
r, err := vault.Request{goreq.Request{
Uri: vault.Path("/v1/auth/token/lookup-self", ""),
MaxRedirects: 10,
RedirectHeaders: true,
}.WithHeader("X-Vault-Token", t.AuthToken)}.Do()
if err == nil {
defer r.Body.Close()
switch r.StatusCode {
ca... | go | func (t TokenUnsealer) Token() (string, error) {
r, err := vault.Request{goreq.Request{
Uri: vault.Path("/v1/auth/token/lookup-self", ""),
MaxRedirects: 10,
RedirectHeaders: true,
}.WithHeader("X-Vault-Token", t.AuthToken)}.Do()
if err == nil {
defer r.Body.Close()
switch r.StatusCode {
ca... | [
"func",
"(",
"t",
"TokenUnsealer",
")",
"Token",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"vault",
".",
"Request",
"{",
"goreq",
".",
"Request",
"{",
"Uri",
":",
"vault",
".",
"Path",
"(",
"\"",
"\"",
",",
"\"",
"... | // Retrieving a token with the TokenUnsealer checks that the token is still
// valid first. | [
"Retrieving",
"a",
"token",
"with",
"the",
"TokenUnsealer",
"checks",
"that",
"the",
"token",
"is",
"still",
"valid",
"first",
"."
] | d47c5055802338e8bb6d668bd36d1c330064d16e | https://github.com/nemosupremo/vault-gatekeeper/blob/d47c5055802338e8bb6d668bd36d1c330064d16e/vault/unsealer/unsealer.go#L29-L53 |
137,540 | docker/go-events | channel.go | NewChannel | func NewChannel(buffer int) *Channel {
return &Channel{
C: make(chan Event, buffer),
closed: make(chan struct{}),
}
} | go | func NewChannel(buffer int) *Channel {
return &Channel{
C: make(chan Event, buffer),
closed: make(chan struct{}),
}
} | [
"func",
"NewChannel",
"(",
"buffer",
"int",
")",
"*",
"Channel",
"{",
"return",
"&",
"Channel",
"{",
"C",
":",
"make",
"(",
"chan",
"Event",
",",
"buffer",
")",
",",
"closed",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"}"... | // NewChannel returns a channel. If buffer is zero, the channel is
// unbuffered. | [
"NewChannel",
"returns",
"a",
"channel",
".",
"If",
"buffer",
"is",
"zero",
"the",
"channel",
"is",
"unbuffered",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/channel.go#L21-L26 |
137,541 | docker/go-events | channel.go | Write | func (ch *Channel) Write(event Event) error {
select {
case ch.C <- event:
return nil
case <-ch.closed:
return ErrSinkClosed
}
} | go | func (ch *Channel) Write(event Event) error {
select {
case ch.C <- event:
return nil
case <-ch.closed:
return ErrSinkClosed
}
} | [
"func",
"(",
"ch",
"*",
"Channel",
")",
"Write",
"(",
"event",
"Event",
")",
"error",
"{",
"select",
"{",
"case",
"ch",
".",
"C",
"<-",
"event",
":",
"return",
"nil",
"\n",
"case",
"<-",
"ch",
".",
"closed",
":",
"return",
"ErrSinkClosed",
"\n",
"}... | // Write the event to the channel. Must be called in a separate goroutine from
// the listener. | [
"Write",
"the",
"event",
"to",
"the",
"channel",
".",
"Must",
"be",
"called",
"in",
"a",
"separate",
"goroutine",
"from",
"the",
"listener",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/channel.go#L35-L42 |
137,542 | docker/go-events | channel.go | Close | func (ch *Channel) Close() error {
ch.once.Do(func() {
close(ch.closed)
})
return nil
} | go | func (ch *Channel) Close() error {
ch.once.Do(func() {
close(ch.closed)
})
return nil
} | [
"func",
"(",
"ch",
"*",
"Channel",
")",
"Close",
"(",
")",
"error",
"{",
"ch",
".",
"once",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"close",
"(",
"ch",
".",
"closed",
")",
"\n",
"}",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Close the channel sink. | [
"Close",
"the",
"channel",
"sink",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/channel.go#L45-L51 |
137,543 | docker/go-events | broadcast.go | NewBroadcaster | func NewBroadcaster(sinks ...Sink) *Broadcaster {
b := Broadcaster{
sinks: sinks,
events: make(chan Event),
adds: make(chan configureRequest),
removes: make(chan configureRequest),
shutdown: make(chan struct{}),
closed: make(chan struct{}),
}
// Start the broadcaster
go b.run()
return &b
... | go | func NewBroadcaster(sinks ...Sink) *Broadcaster {
b := Broadcaster{
sinks: sinks,
events: make(chan Event),
adds: make(chan configureRequest),
removes: make(chan configureRequest),
shutdown: make(chan struct{}),
closed: make(chan struct{}),
}
// Start the broadcaster
go b.run()
return &b
... | [
"func",
"NewBroadcaster",
"(",
"sinks",
"...",
"Sink",
")",
"*",
"Broadcaster",
"{",
"b",
":=",
"Broadcaster",
"{",
"sinks",
":",
"sinks",
",",
"events",
":",
"make",
"(",
"chan",
"Event",
")",
",",
"adds",
":",
"make",
"(",
"chan",
"configureRequest",
... | // NewBroadcaster appends one or more sinks to the list of sinks. The
// broadcaster behavior will be affected by the properties of the sink.
// Generally, the sink should accept all messages and deal with reliability on
// its own. Use of EventQueue and RetryingSink should be used here. | [
"NewBroadcaster",
"appends",
"one",
"or",
"more",
"sinks",
"to",
"the",
"list",
"of",
"sinks",
".",
"The",
"broadcaster",
"behavior",
"will",
"be",
"affected",
"by",
"the",
"properties",
"of",
"the",
"sink",
".",
"Generally",
"the",
"sink",
"should",
"accept... | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/broadcast.go#L28-L42 |
137,544 | docker/go-events | broadcast.go | Add | func (b *Broadcaster) Add(sink Sink) error {
return b.configure(b.adds, sink)
} | go | func (b *Broadcaster) Add(sink Sink) error {
return b.configure(b.adds, sink)
} | [
"func",
"(",
"b",
"*",
"Broadcaster",
")",
"Add",
"(",
"sink",
"Sink",
")",
"error",
"{",
"return",
"b",
".",
"configure",
"(",
"b",
".",
"adds",
",",
"sink",
")",
"\n",
"}"
] | // Add the sink to the broadcaster.
//
// The provided sink must be comparable with equality. Typically, this just
// works with a regular pointer type. | [
"Add",
"the",
"sink",
"to",
"the",
"broadcaster",
".",
"The",
"provided",
"sink",
"must",
"be",
"comparable",
"with",
"equality",
".",
"Typically",
"this",
"just",
"works",
"with",
"a",
"regular",
"pointer",
"type",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/broadcast.go#L60-L62 |
137,545 | docker/go-events | broadcast.go | Remove | func (b *Broadcaster) Remove(sink Sink) error {
return b.configure(b.removes, sink)
} | go | func (b *Broadcaster) Remove(sink Sink) error {
return b.configure(b.removes, sink)
} | [
"func",
"(",
"b",
"*",
"Broadcaster",
")",
"Remove",
"(",
"sink",
"Sink",
")",
"error",
"{",
"return",
"b",
".",
"configure",
"(",
"b",
".",
"removes",
",",
"sink",
")",
"\n",
"}"
] | // Remove the provided sink. | [
"Remove",
"the",
"provided",
"sink",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/broadcast.go#L65-L67 |
137,546 | docker/go-events | queue.go | NewQueue | func NewQueue(dst Sink) *Queue {
eq := Queue{
dst: dst,
events: list.New(),
}
eq.cond = sync.NewCond(&eq.mu)
go eq.run()
return &eq
} | go | func NewQueue(dst Sink) *Queue {
eq := Queue{
dst: dst,
events: list.New(),
}
eq.cond = sync.NewCond(&eq.mu)
go eq.run()
return &eq
} | [
"func",
"NewQueue",
"(",
"dst",
"Sink",
")",
"*",
"Queue",
"{",
"eq",
":=",
"Queue",
"{",
"dst",
":",
"dst",
",",
"events",
":",
"list",
".",
"New",
"(",
")",
",",
"}",
"\n\n",
"eq",
".",
"cond",
"=",
"sync",
".",
"NewCond",
"(",
"&",
"eq",
"... | // NewQueue returns a queue to the provided Sink dst. | [
"NewQueue",
"returns",
"a",
"queue",
"to",
"the",
"provided",
"Sink",
"dst",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/queue.go#L22-L31 |
137,547 | docker/go-events | queue.go | Write | func (eq *Queue) Write(event Event) error {
eq.mu.Lock()
defer eq.mu.Unlock()
if eq.closed {
return ErrSinkClosed
}
eq.events.PushBack(event)
eq.cond.Signal() // signal waiters
return nil
} | go | func (eq *Queue) Write(event Event) error {
eq.mu.Lock()
defer eq.mu.Unlock()
if eq.closed {
return ErrSinkClosed
}
eq.events.PushBack(event)
eq.cond.Signal() // signal waiters
return nil
} | [
"func",
"(",
"eq",
"*",
"Queue",
")",
"Write",
"(",
"event",
"Event",
")",
"error",
"{",
"eq",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"eq",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"eq",
".",
"closed",
"{",
"return",
"ErrSink... | // Write accepts the events into the queue, only failing if the queue has
// been closed. | [
"Write",
"accepts",
"the",
"events",
"into",
"the",
"queue",
"only",
"failing",
"if",
"the",
"queue",
"has",
"been",
"closed",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/queue.go#L35-L47 |
137,548 | docker/go-events | queue.go | Close | func (eq *Queue) Close() error {
eq.mu.Lock()
defer eq.mu.Unlock()
if eq.closed {
return nil
}
// set closed flag
eq.closed = true
eq.cond.Signal() // signal flushes queue
eq.cond.Wait() // wait for signal from last flush
return eq.dst.Close()
} | go | func (eq *Queue) Close() error {
eq.mu.Lock()
defer eq.mu.Unlock()
if eq.closed {
return nil
}
// set closed flag
eq.closed = true
eq.cond.Signal() // signal flushes queue
eq.cond.Wait() // wait for signal from last flush
return eq.dst.Close()
} | [
"func",
"(",
"eq",
"*",
"Queue",
")",
"Close",
"(",
")",
"error",
"{",
"eq",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"eq",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"eq",
".",
"closed",
"{",
"return",
"nil",
"\n",
"}",
"\n\n"... | // Close shutsdown the event queue, flushing | [
"Close",
"shutsdown",
"the",
"event",
"queue",
"flushing"
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/queue.go#L50-L63 |
137,549 | docker/go-events | retry.go | NewRetryingSink | func NewRetryingSink(sink Sink, strategy RetryStrategy) *RetryingSink {
rs := &RetryingSink{
sink: sink,
strategy: strategy,
closed: make(chan struct{}),
}
return rs
} | go | func NewRetryingSink(sink Sink, strategy RetryStrategy) *RetryingSink {
rs := &RetryingSink{
sink: sink,
strategy: strategy,
closed: make(chan struct{}),
}
return rs
} | [
"func",
"NewRetryingSink",
"(",
"sink",
"Sink",
",",
"strategy",
"RetryStrategy",
")",
"*",
"RetryingSink",
"{",
"rs",
":=",
"&",
"RetryingSink",
"{",
"sink",
":",
"sink",
",",
"strategy",
":",
"strategy",
",",
"closed",
":",
"make",
"(",
"chan",
"struct",... | // NewRetryingSink returns a sink that will retry writes to a sink, backing
// off on failure. Parameters threshold and backoff adjust the behavior of the
// circuit breaker. | [
"NewRetryingSink",
"returns",
"a",
"sink",
"that",
"will",
"retry",
"writes",
"to",
"a",
"sink",
"backing",
"off",
"on",
"failure",
".",
"Parameters",
"threshold",
"and",
"backoff",
"adjust",
"the",
"behavior",
"of",
"the",
"circuit",
"breaker",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/retry.go#L28-L36 |
137,550 | docker/go-events | retry.go | NewBreaker | func NewBreaker(threshold int, backoff time.Duration) *Breaker {
return &Breaker{
threshold: threshold,
backoff: backoff,
}
} | go | func NewBreaker(threshold int, backoff time.Duration) *Breaker {
return &Breaker{
threshold: threshold,
backoff: backoff,
}
} | [
"func",
"NewBreaker",
"(",
"threshold",
"int",
",",
"backoff",
"time",
".",
"Duration",
")",
"*",
"Breaker",
"{",
"return",
"&",
"Breaker",
"{",
"threshold",
":",
"threshold",
",",
"backoff",
":",
"backoff",
",",
"}",
"\n",
"}"
] | // NewBreaker returns a breaker that will backoff after the threshold has been
// tripped. A Breaker is thread safe and may be shared by many goroutines. | [
"NewBreaker",
"returns",
"a",
"breaker",
"that",
"will",
"backoff",
"after",
"the",
"threshold",
"has",
"been",
"tripped",
".",
"A",
"Breaker",
"is",
"thread",
"safe",
"and",
"may",
"be",
"shared",
"by",
"many",
"goroutines",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/retry.go#L138-L143 |
137,551 | docker/go-events | retry.go | Proceed | func (b *Breaker) Proceed(event Event) time.Duration {
b.mu.Lock()
defer b.mu.Unlock()
if b.recent < b.threshold {
return 0
}
return b.last.Add(b.backoff).Sub(time.Now())
} | go | func (b *Breaker) Proceed(event Event) time.Duration {
b.mu.Lock()
defer b.mu.Unlock()
if b.recent < b.threshold {
return 0
}
return b.last.Add(b.backoff).Sub(time.Now())
} | [
"func",
"(",
"b",
"*",
"Breaker",
")",
"Proceed",
"(",
"event",
"Event",
")",
"time",
".",
"Duration",
"{",
"b",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"b",
".",
"recent",
"<",
... | // Proceed checks the failures against the threshold. | [
"Proceed",
"checks",
"the",
"failures",
"against",
"the",
"threshold",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/retry.go#L146-L155 |
137,552 | docker/go-events | retry.go | Success | func (b *Breaker) Success(event Event) {
b.mu.Lock()
defer b.mu.Unlock()
b.recent = 0
b.last = time.Time{}
} | go | func (b *Breaker) Success(event Event) {
b.mu.Lock()
defer b.mu.Unlock()
b.recent = 0
b.last = time.Time{}
} | [
"func",
"(",
"b",
"*",
"Breaker",
")",
"Success",
"(",
"event",
"Event",
")",
"{",
"b",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"b",
".",
"recent",
"=",
"0",
"\n",
"b",
".",
"last",
... | // Success resets the breaker. | [
"Success",
"resets",
"the",
"breaker",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/retry.go#L158-L164 |
137,553 | docker/go-events | retry.go | Failure | func (b *Breaker) Failure(event Event, err error) bool {
b.mu.Lock()
defer b.mu.Unlock()
b.recent++
b.last = time.Now().UTC()
return false // never drop events.
} | go | func (b *Breaker) Failure(event Event, err error) bool {
b.mu.Lock()
defer b.mu.Unlock()
b.recent++
b.last = time.Now().UTC()
return false // never drop events.
} | [
"func",
"(",
"b",
"*",
"Breaker",
")",
"Failure",
"(",
"event",
"Event",
",",
"err",
"error",
")",
"bool",
"{",
"b",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"b",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"b",
".",
"recent",
"++",
"... | // Failure records the failure and latest failure time. | [
"Failure",
"records",
"the",
"failure",
"and",
"latest",
"failure",
"time",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/retry.go#L167-L174 |
137,554 | docker/go-events | retry.go | Proceed | func (b *ExponentialBackoff) Proceed(event Event) time.Duration {
return b.backoff(atomic.LoadUint64(&b.failures))
} | go | func (b *ExponentialBackoff) Proceed(event Event) time.Duration {
return b.backoff(atomic.LoadUint64(&b.failures))
} | [
"func",
"(",
"b",
"*",
"ExponentialBackoff",
")",
"Proceed",
"(",
"event",
"Event",
")",
"time",
".",
"Duration",
"{",
"return",
"b",
".",
"backoff",
"(",
"atomic",
".",
"LoadUint64",
"(",
"&",
"b",
".",
"failures",
")",
")",
"\n",
"}"
] | // Proceed returns the next randomly bound exponential backoff time. | [
"Proceed",
"returns",
"the",
"next",
"randomly",
"bound",
"exponential",
"backoff",
"time",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/retry.go#L219-L221 |
137,555 | docker/go-events | retry.go | Failure | func (b *ExponentialBackoff) Failure(event Event, err error) bool {
atomic.AddUint64(&b.failures, 1)
return false
} | go | func (b *ExponentialBackoff) Failure(event Event, err error) bool {
atomic.AddUint64(&b.failures, 1)
return false
} | [
"func",
"(",
"b",
"*",
"ExponentialBackoff",
")",
"Failure",
"(",
"event",
"Event",
",",
"err",
"error",
")",
"bool",
"{",
"atomic",
".",
"AddUint64",
"(",
"&",
"b",
".",
"failures",
",",
"1",
")",
"\n",
"return",
"false",
"\n",
"}"
] | // Failure increments the failure counter. | [
"Failure",
"increments",
"the",
"failure",
"counter",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/retry.go#L229-L232 |
137,556 | docker/go-events | retry.go | backoff | func (b *ExponentialBackoff) backoff(failures uint64) time.Duration {
if failures <= 0 {
// proceed normally when there are no failures.
return 0
}
factor := b.config.Factor
if factor <= 0 {
factor = DefaultExponentialBackoffConfig.Factor
}
backoff := b.config.Base + factor*time.Duration(1<<(failures-1))
... | go | func (b *ExponentialBackoff) backoff(failures uint64) time.Duration {
if failures <= 0 {
// proceed normally when there are no failures.
return 0
}
factor := b.config.Factor
if factor <= 0 {
factor = DefaultExponentialBackoffConfig.Factor
}
backoff := b.config.Base + factor*time.Duration(1<<(failures-1))
... | [
"func",
"(",
"b",
"*",
"ExponentialBackoff",
")",
"backoff",
"(",
"failures",
"uint64",
")",
"time",
".",
"Duration",
"{",
"if",
"failures",
"<=",
"0",
"{",
"// proceed normally when there are no failures.",
"return",
"0",
"\n",
"}",
"\n\n",
"factor",
":=",
"b... | // backoff calculates the amount of time to wait based on the number of
// consecutive failures. | [
"backoff",
"calculates",
"the",
"amount",
"of",
"time",
"to",
"wait",
"based",
"on",
"the",
"number",
"of",
"consecutive",
"failures",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/retry.go#L236-L260 |
137,557 | docker/go-events | filter.go | NewFilter | func NewFilter(dst Sink, matcher Matcher) Sink {
return &Filter{dst: dst, matcher: matcher}
} | go | func NewFilter(dst Sink, matcher Matcher) Sink {
return &Filter{dst: dst, matcher: matcher}
} | [
"func",
"NewFilter",
"(",
"dst",
"Sink",
",",
"matcher",
"Matcher",
")",
"Sink",
"{",
"return",
"&",
"Filter",
"{",
"dst",
":",
"dst",
",",
"matcher",
":",
"matcher",
"}",
"\n",
"}"
] | // NewFilter returns a new filter that will send to events to dst that return
// true for Matcher. | [
"NewFilter",
"returns",
"a",
"new",
"filter",
"that",
"will",
"send",
"to",
"events",
"to",
"dst",
"that",
"return",
"true",
"for",
"Matcher",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/filter.go#L26-L28 |
137,558 | docker/go-events | filter.go | Write | func (f *Filter) Write(event Event) error {
if f.closed {
return ErrSinkClosed
}
if f.matcher.Match(event) {
return f.dst.Write(event)
}
return nil
} | go | func (f *Filter) Write(event Event) error {
if f.closed {
return ErrSinkClosed
}
if f.matcher.Match(event) {
return f.dst.Write(event)
}
return nil
} | [
"func",
"(",
"f",
"*",
"Filter",
")",
"Write",
"(",
"event",
"Event",
")",
"error",
"{",
"if",
"f",
".",
"closed",
"{",
"return",
"ErrSinkClosed",
"\n",
"}",
"\n\n",
"if",
"f",
".",
"matcher",
".",
"Match",
"(",
"event",
")",
"{",
"return",
"f",
... | // Write an event to the filter. | [
"Write",
"an",
"event",
"to",
"the",
"filter",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/filter.go#L31-L41 |
137,559 | docker/go-events | filter.go | Close | func (f *Filter) Close() error {
// TODO(stevvooe): Not all sinks should have Close.
if f.closed {
return nil
}
f.closed = true
return f.dst.Close()
} | go | func (f *Filter) Close() error {
// TODO(stevvooe): Not all sinks should have Close.
if f.closed {
return nil
}
f.closed = true
return f.dst.Close()
} | [
"func",
"(",
"f",
"*",
"Filter",
")",
"Close",
"(",
")",
"error",
"{",
"// TODO(stevvooe): Not all sinks should have Close.",
"if",
"f",
".",
"closed",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"f",
".",
"closed",
"=",
"true",
"\n",
"return",
"f",
".",
"d... | // Close the filter and allow no more events to pass through. | [
"Close",
"the",
"filter",
"and",
"allow",
"no",
"more",
"events",
"to",
"pass",
"through",
"."
] | 9461782956ad83b30282bf90e31fa6a70c255ba9 | https://github.com/docker/go-events/blob/9461782956ad83b30282bf90e31fa6a70c255ba9/filter.go#L44-L52 |
137,560 | pkg/math | uint8.go | MaxUint8N | func MaxUint8N(v ...uint8) uint8 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxUint8(v[0], v[1])
default:
l := len(v) / 2
return MaxUint8N(MaxUint8N(v[:l]...), MaxUint8N(v[l:]...))
}
} | go | func MaxUint8N(v ...uint8) uint8 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxUint8(v[0], v[1])
default:
l := len(v) / 2
return MaxUint8N(MaxUint8N(v[:l]...), MaxUint8N(v[l:]...))
}
} | [
"func",
"MaxUint8N",
"(",
"v",
"...",
"uint8",
")",
"uint8",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MaxUint8",
"(",
"v"... | // MaxUint8N returns the largest uint8 in the set provided.
// If no values are provided, MaxUint8 returns 0. | [
"MaxUint8N",
"returns",
"the",
"largest",
"uint8",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MaxUint8",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/uint8.go#L21-L33 |
137,561 | pkg/math | uint8.go | MinUint8N | func MinUint8N(v ...uint8) uint8 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinUint8(v[0], v[1])
default:
l := len(v) / 2
return MinUint8N(MinUint8N(v[:l]...), MinUint8N(v[l:]...))
}
} | go | func MinUint8N(v ...uint8) uint8 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinUint8(v[0], v[1])
default:
l := len(v) / 2
return MinUint8N(MinUint8N(v[:l]...), MinUint8N(v[l:]...))
}
} | [
"func",
"MinUint8N",
"(",
"v",
"...",
"uint8",
")",
"uint8",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MinUint8",
"(",
"v"... | // MinUint8N returns the smallest uint8 in the set provided.
// If no values are provided, MinUint8 returns 0. | [
"MinUint8N",
"returns",
"the",
"smallest",
"uint8",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MinUint8",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/uint8.go#L37-L49 |
137,562 | pkg/math | extra.go | MaxN | func MaxN(v ...int) int {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return Max(v[0], v[1])
default:
l := len(v) / 2
return MaxN(MaxN(v[:l]...), MaxN(v[l:]...))
}
} | go | func MaxN(v ...int) int {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return Max(v[0], v[1])
default:
l := len(v) / 2
return MaxN(MaxN(v[:l]...), MaxN(v[l:]...))
}
} | [
"func",
"MaxN",
"(",
"v",
"...",
"int",
")",
"int",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"Max",
"(",
"v",
"[",
"0"... | // MaxN returns the largest int in the set provided.
// If no values are provided, Max returns 0. | [
"MaxN",
"returns",
"the",
"largest",
"int",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"Max",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/extra.go#L21-L33 |
137,563 | pkg/math | extra.go | MinN | func MinN(v ...int) int {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return Min(v[0], v[1])
default:
l := len(v) / 2
return MinN(MinN(v[:l]...), MinN(v[l:]...))
}
} | go | func MinN(v ...int) int {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return Min(v[0], v[1])
default:
l := len(v) / 2
return MinN(MinN(v[:l]...), MinN(v[l:]...))
}
} | [
"func",
"MinN",
"(",
"v",
"...",
"int",
")",
"int",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"Min",
"(",
"v",
"[",
"0"... | // MinN returns the smallest int in the set provided.
// If no values are provided, Min returns 0. | [
"MinN",
"returns",
"the",
"smallest",
"int",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"Min",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/extra.go#L37-L49 |
137,564 | pkg/math | uint16.go | MaxUint16N | func MaxUint16N(v ...uint16) uint16 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxUint16(v[0], v[1])
default:
l := len(v) / 2
return MaxUint16N(MaxUint16N(v[:l]...), MaxUint16N(v[l:]...))
}
} | go | func MaxUint16N(v ...uint16) uint16 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxUint16(v[0], v[1])
default:
l := len(v) / 2
return MaxUint16N(MaxUint16N(v[:l]...), MaxUint16N(v[l:]...))
}
} | [
"func",
"MaxUint16N",
"(",
"v",
"...",
"uint16",
")",
"uint16",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MaxUint16",
"(",
... | // MaxUint16N returns the largest uint16 in the set provided.
// If no values are provided, MaxUint16 returns 0. | [
"MaxUint16N",
"returns",
"the",
"largest",
"uint16",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MaxUint16",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/uint16.go#L21-L33 |
137,565 | pkg/math | uint16.go | MinUint16N | func MinUint16N(v ...uint16) uint16 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinUint16(v[0], v[1])
default:
l := len(v) / 2
return MinUint16N(MinUint16N(v[:l]...), MinUint16N(v[l:]...))
}
} | go | func MinUint16N(v ...uint16) uint16 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinUint16(v[0], v[1])
default:
l := len(v) / 2
return MinUint16N(MinUint16N(v[:l]...), MinUint16N(v[l:]...))
}
} | [
"func",
"MinUint16N",
"(",
"v",
"...",
"uint16",
")",
"uint16",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MinUint16",
"(",
... | // MinUint16N returns the smallest uint16 in the set provided.
// If no values are provided, MinUint16 returns 0. | [
"MinUint16N",
"returns",
"the",
"smallest",
"uint16",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MinUint16",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/uint16.go#L37-L49 |
137,566 | pkg/math | int8.go | MaxInt8N | func MaxInt8N(v ...int8) int8 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxInt8(v[0], v[1])
default:
l := len(v) / 2
return MaxInt8N(MaxInt8N(v[:l]...), MaxInt8N(v[l:]...))
}
} | go | func MaxInt8N(v ...int8) int8 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxInt8(v[0], v[1])
default:
l := len(v) / 2
return MaxInt8N(MaxInt8N(v[:l]...), MaxInt8N(v[l:]...))
}
} | [
"func",
"MaxInt8N",
"(",
"v",
"...",
"int8",
")",
"int8",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MaxInt8",
"(",
"v",
... | // MaxInt8N returns the largest int8 in the set provided.
// If no values are provided, MaxInt8 returns 0. | [
"MaxInt8N",
"returns",
"the",
"largest",
"int8",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MaxInt8",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/int8.go#L21-L33 |
137,567 | pkg/math | int8.go | MinInt8N | func MinInt8N(v ...int8) int8 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinInt8(v[0], v[1])
default:
l := len(v) / 2
return MinInt8N(MinInt8N(v[:l]...), MinInt8N(v[l:]...))
}
} | go | func MinInt8N(v ...int8) int8 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinInt8(v[0], v[1])
default:
l := len(v) / 2
return MinInt8N(MinInt8N(v[:l]...), MinInt8N(v[l:]...))
}
} | [
"func",
"MinInt8N",
"(",
"v",
"...",
"int8",
")",
"int8",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MinInt8",
"(",
"v",
... | // MinInt8N returns the smallest int8 in the set provided.
// If no values are provided, MinInt8 returns 0. | [
"MinInt8N",
"returns",
"the",
"smallest",
"int8",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MinInt8",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/int8.go#L37-L49 |
137,568 | pkg/math | int64.go | MaxInt64N | func MaxInt64N(v ...int64) int64 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxInt64(v[0], v[1])
default:
l := len(v) / 2
return MaxInt64N(MaxInt64N(v[:l]...), MaxInt64N(v[l:]...))
}
} | go | func MaxInt64N(v ...int64) int64 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxInt64(v[0], v[1])
default:
l := len(v) / 2
return MaxInt64N(MaxInt64N(v[:l]...), MaxInt64N(v[l:]...))
}
} | [
"func",
"MaxInt64N",
"(",
"v",
"...",
"int64",
")",
"int64",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MaxInt64",
"(",
"v"... | // MaxInt64N returns the largest int64 in the set provided.
// If no values are provided, MaxInt64 returns 0. | [
"MaxInt64N",
"returns",
"the",
"largest",
"int64",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MaxInt64",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/int64.go#L21-L33 |
137,569 | pkg/math | int64.go | MinInt64N | func MinInt64N(v ...int64) int64 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinInt64(v[0], v[1])
default:
l := len(v) / 2
return MinInt64N(MinInt64N(v[:l]...), MinInt64N(v[l:]...))
}
} | go | func MinInt64N(v ...int64) int64 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinInt64(v[0], v[1])
default:
l := len(v) / 2
return MinInt64N(MinInt64N(v[:l]...), MinInt64N(v[l:]...))
}
} | [
"func",
"MinInt64N",
"(",
"v",
"...",
"int64",
")",
"int64",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MinInt64",
"(",
"v"... | // MinInt64N returns the smallest int64 in the set provided.
// If no values are provided, MinInt64 returns 0. | [
"MinInt64N",
"returns",
"the",
"smallest",
"int64",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MinInt64",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/int64.go#L37-L49 |
137,570 | pkg/math | uint.go | MaxUintN | func MaxUintN(v ...uint) uint {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxUint(v[0], v[1])
default:
l := len(v) / 2
return MaxUintN(MaxUintN(v[:l]...), MaxUintN(v[l:]...))
}
} | go | func MaxUintN(v ...uint) uint {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxUint(v[0], v[1])
default:
l := len(v) / 2
return MaxUintN(MaxUintN(v[:l]...), MaxUintN(v[l:]...))
}
} | [
"func",
"MaxUintN",
"(",
"v",
"...",
"uint",
")",
"uint",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MaxUint",
"(",
"v",
... | // MaxUintN returns the largest uint in the set provided.
// If no values are provided, MaxUint returns 0. | [
"MaxUintN",
"returns",
"the",
"largest",
"uint",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MaxUint",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/uint.go#L21-L33 |
137,571 | pkg/math | uint.go | MinUintN | func MinUintN(v ...uint) uint {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinUint(v[0], v[1])
default:
l := len(v) / 2
return MinUintN(MinUintN(v[:l]...), MinUintN(v[l:]...))
}
} | go | func MinUintN(v ...uint) uint {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinUint(v[0], v[1])
default:
l := len(v) / 2
return MinUintN(MinUintN(v[:l]...), MinUintN(v[l:]...))
}
} | [
"func",
"MinUintN",
"(",
"v",
"...",
"uint",
")",
"uint",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MinUint",
"(",
"v",
... | // MinUintN returns the smallest uint in the set provided.
// If no values are provided, MinUint returns 0. | [
"MinUintN",
"returns",
"the",
"smallest",
"uint",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MinUint",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/uint.go#L37-L49 |
137,572 | pkg/math | int32.go | MaxInt32N | func MaxInt32N(v ...int32) int32 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxInt32(v[0], v[1])
default:
l := len(v) / 2
return MaxInt32N(MaxInt32N(v[:l]...), MaxInt32N(v[l:]...))
}
} | go | func MaxInt32N(v ...int32) int32 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxInt32(v[0], v[1])
default:
l := len(v) / 2
return MaxInt32N(MaxInt32N(v[:l]...), MaxInt32N(v[l:]...))
}
} | [
"func",
"MaxInt32N",
"(",
"v",
"...",
"int32",
")",
"int32",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MaxInt32",
"(",
"v"... | // MaxInt32N returns the largest int32 in the set provided.
// If no values are provided, MaxInt32 returns 0. | [
"MaxInt32N",
"returns",
"the",
"largest",
"int32",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MaxInt32",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/int32.go#L21-L33 |
137,573 | pkg/math | int32.go | MinInt32N | func MinInt32N(v ...int32) int32 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinInt32(v[0], v[1])
default:
l := len(v) / 2
return MinInt32N(MinInt32N(v[:l]...), MinInt32N(v[l:]...))
}
} | go | func MinInt32N(v ...int32) int32 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinInt32(v[0], v[1])
default:
l := len(v) / 2
return MinInt32N(MinInt32N(v[:l]...), MinInt32N(v[l:]...))
}
} | [
"func",
"MinInt32N",
"(",
"v",
"...",
"int32",
")",
"int32",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MinInt32",
"(",
"v"... | // MinInt32N returns the smallest int32 in the set provided.
// If no values are provided, MinInt32 returns 0. | [
"MinInt32N",
"returns",
"the",
"smallest",
"int32",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MinInt32",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/int32.go#L37-L49 |
137,574 | pkg/math | int.go | MaxIntN | func MaxIntN(v ...int) int {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxInt(v[0], v[1])
default:
l := len(v) / 2
return MaxIntN(MaxIntN(v[:l]...), MaxIntN(v[l:]...))
}
} | go | func MaxIntN(v ...int) int {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxInt(v[0], v[1])
default:
l := len(v) / 2
return MaxIntN(MaxIntN(v[:l]...), MaxIntN(v[l:]...))
}
} | [
"func",
"MaxIntN",
"(",
"v",
"...",
"int",
")",
"int",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MaxInt",
"(",
"v",
"[",... | // MaxIntN returns the largest int in the set provided.
// If no values are provided, MaxInt returns 0. | [
"MaxIntN",
"returns",
"the",
"largest",
"int",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MaxInt",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/int.go#L21-L33 |
137,575 | pkg/math | int.go | MinIntN | func MinIntN(v ...int) int {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinInt(v[0], v[1])
default:
l := len(v) / 2
return MinIntN(MinIntN(v[:l]...), MinIntN(v[l:]...))
}
} | go | func MinIntN(v ...int) int {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinInt(v[0], v[1])
default:
l := len(v) / 2
return MinIntN(MinIntN(v[:l]...), MinIntN(v[l:]...))
}
} | [
"func",
"MinIntN",
"(",
"v",
"...",
"int",
")",
"int",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MinInt",
"(",
"v",
"[",... | // MinIntN returns the smallest int in the set provided.
// If no values are provided, MinInt returns 0. | [
"MinIntN",
"returns",
"the",
"smallest",
"int",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MinInt",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/int.go#L37-L49 |
137,576 | pkg/math | uint64.go | MaxUint64N | func MaxUint64N(v ...uint64) uint64 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxUint64(v[0], v[1])
default:
l := len(v) / 2
return MaxUint64N(MaxUint64N(v[:l]...), MaxUint64N(v[l:]...))
}
} | go | func MaxUint64N(v ...uint64) uint64 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxUint64(v[0], v[1])
default:
l := len(v) / 2
return MaxUint64N(MaxUint64N(v[:l]...), MaxUint64N(v[l:]...))
}
} | [
"func",
"MaxUint64N",
"(",
"v",
"...",
"uint64",
")",
"uint64",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MaxUint64",
"(",
... | // MaxUint64N returns the largest uint64 in the set provided.
// If no values are provided, MaxUint64 returns 0. | [
"MaxUint64N",
"returns",
"the",
"largest",
"uint64",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MaxUint64",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/uint64.go#L21-L33 |
137,577 | pkg/math | uint64.go | MinUint64N | func MinUint64N(v ...uint64) uint64 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinUint64(v[0], v[1])
default:
l := len(v) / 2
return MinUint64N(MinUint64N(v[:l]...), MinUint64N(v[l:]...))
}
} | go | func MinUint64N(v ...uint64) uint64 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinUint64(v[0], v[1])
default:
l := len(v) / 2
return MinUint64N(MinUint64N(v[:l]...), MinUint64N(v[l:]...))
}
} | [
"func",
"MinUint64N",
"(",
"v",
"...",
"uint64",
")",
"uint64",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MinUint64",
"(",
... | // MinUint64N returns the smallest uint64 in the set provided.
// If no values are provided, MinUint64 returns 0. | [
"MinUint64N",
"returns",
"the",
"smallest",
"uint64",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MinUint64",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/uint64.go#L37-L49 |
137,578 | pkg/math | uint32.go | MaxUint32N | func MaxUint32N(v ...uint32) uint32 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxUint32(v[0], v[1])
default:
l := len(v) / 2
return MaxUint32N(MaxUint32N(v[:l]...), MaxUint32N(v[l:]...))
}
} | go | func MaxUint32N(v ...uint32) uint32 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxUint32(v[0], v[1])
default:
l := len(v) / 2
return MaxUint32N(MaxUint32N(v[:l]...), MaxUint32N(v[l:]...))
}
} | [
"func",
"MaxUint32N",
"(",
"v",
"...",
"uint32",
")",
"uint32",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MaxUint32",
"(",
... | // MaxUint32N returns the largest uint32 in the set provided.
// If no values are provided, MaxUint32 returns 0. | [
"MaxUint32N",
"returns",
"the",
"largest",
"uint32",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MaxUint32",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/uint32.go#L21-L33 |
137,579 | pkg/math | uint32.go | MinUint32N | func MinUint32N(v ...uint32) uint32 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinUint32(v[0], v[1])
default:
l := len(v) / 2
return MinUint32N(MinUint32N(v[:l]...), MinUint32N(v[l:]...))
}
} | go | func MinUint32N(v ...uint32) uint32 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinUint32(v[0], v[1])
default:
l := len(v) / 2
return MinUint32N(MinUint32N(v[:l]...), MinUint32N(v[l:]...))
}
} | [
"func",
"MinUint32N",
"(",
"v",
"...",
"uint32",
")",
"uint32",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MinUint32",
"(",
... | // MinUint32N returns the smallest uint32 in the set provided.
// If no values are provided, MinUint32 returns 0. | [
"MinUint32N",
"returns",
"the",
"smallest",
"uint32",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MinUint32",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/uint32.go#L37-L49 |
137,580 | pkg/math | int16.go | MaxInt16N | func MaxInt16N(v ...int16) int16 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxInt16(v[0], v[1])
default:
l := len(v) / 2
return MaxInt16N(MaxInt16N(v[:l]...), MaxInt16N(v[l:]...))
}
} | go | func MaxInt16N(v ...int16) int16 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MaxInt16(v[0], v[1])
default:
l := len(v) / 2
return MaxInt16N(MaxInt16N(v[:l]...), MaxInt16N(v[l:]...))
}
} | [
"func",
"MaxInt16N",
"(",
"v",
"...",
"int16",
")",
"int16",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MaxInt16",
"(",
"v"... | // MaxInt16N returns the largest int16 in the set provided.
// If no values are provided, MaxInt16 returns 0. | [
"MaxInt16N",
"returns",
"the",
"largest",
"int16",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MaxInt16",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/int16.go#L21-L33 |
137,581 | pkg/math | int16.go | MinInt16N | func MinInt16N(v ...int16) int16 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinInt16(v[0], v[1])
default:
l := len(v) / 2
return MinInt16N(MinInt16N(v[:l]...), MinInt16N(v[l:]...))
}
} | go | func MinInt16N(v ...int16) int16 {
switch len(v) {
case 0:
return 0
case 1:
return v[0]
case 2:
return MinInt16(v[0], v[1])
default:
l := len(v) / 2
return MinInt16N(MinInt16N(v[:l]...), MinInt16N(v[l:]...))
}
} | [
"func",
"MinInt16N",
"(",
"v",
"...",
"int16",
")",
"int16",
"{",
"switch",
"len",
"(",
"v",
")",
"{",
"case",
"0",
":",
"return",
"0",
"\n",
"case",
"1",
":",
"return",
"v",
"[",
"0",
"]",
"\n",
"case",
"2",
":",
"return",
"MinInt16",
"(",
"v"... | // MinInt16N returns the smallest int16 in the set provided.
// If no values are provided, MinInt16 returns 0. | [
"MinInt16N",
"returns",
"the",
"smallest",
"int16",
"in",
"the",
"set",
"provided",
".",
"If",
"no",
"values",
"are",
"provided",
"MinInt16",
"returns",
"0",
"."
] | f2ed9e40e245cdeec72c4b642d27ed4553f90667 | https://github.com/pkg/math/blob/f2ed9e40e245cdeec72c4b642d27ed4553f90667/int16.go#L37-L49 |
137,582 | martinlindhe/base36 | base36.go | Encode | func Encode(value uint64) string {
var res [16]byte
var i int
for i = len(res) - 1; value != 0; i-- {
res[i] = base36[value%36]
value /= 36
}
return string(res[i+1:])
} | go | func Encode(value uint64) string {
var res [16]byte
var i int
for i = len(res) - 1; value != 0; i-- {
res[i] = base36[value%36]
value /= 36
}
return string(res[i+1:])
} | [
"func",
"Encode",
"(",
"value",
"uint64",
")",
"string",
"{",
"var",
"res",
"[",
"16",
"]",
"byte",
"\n",
"var",
"i",
"int",
"\n",
"for",
"i",
"=",
"len",
"(",
"res",
")",
"-",
"1",
";",
"value",
"!=",
"0",
";",
"i",
"--",
"{",
"res",
"[",
... | // Encode encodes a number to base36. | [
"Encode",
"encodes",
"a",
"number",
"to",
"base36",
"."
] | 7c6542dfbb41505111dde1f321eb5d5002f5fb88 | https://github.com/martinlindhe/base36/blob/7c6542dfbb41505111dde1f321eb5d5002f5fb88/base36.go#L35-L43 |
137,583 | martinlindhe/base36 | base36.go | Decode | func Decode(s string) uint64 {
res := uint64(0)
l := len(s) - 1
for idx := range s {
c := s[l-idx]
res += uint64(index[c]) * uint64(math.Pow(36, float64(idx)))
}
return res
} | go | func Decode(s string) uint64 {
res := uint64(0)
l := len(s) - 1
for idx := range s {
c := s[l-idx]
res += uint64(index[c]) * uint64(math.Pow(36, float64(idx)))
}
return res
} | [
"func",
"Decode",
"(",
"s",
"string",
")",
"uint64",
"{",
"res",
":=",
"uint64",
"(",
"0",
")",
"\n",
"l",
":=",
"len",
"(",
"s",
")",
"-",
"1",
"\n",
"for",
"idx",
":=",
"range",
"s",
"{",
"c",
":=",
"s",
"[",
"l",
"-",
"idx",
"]",
"\n",
... | // Decode decodes a base36-encoded string. | [
"Decode",
"decodes",
"a",
"base36",
"-",
"encoded",
"string",
"."
] | 7c6542dfbb41505111dde1f321eb5d5002f5fb88 | https://github.com/martinlindhe/base36/blob/7c6542dfbb41505111dde1f321eb5d5002f5fb88/base36.go#L46-L54 |
137,584 | martinlindhe/base36 | base36.go | DecodeToBytes | func DecodeToBytes(b string) []byte {
alphabet := string(base36)
answer := big.NewInt(0)
j := big.NewInt(1)
for i := len(b) - 1; i >= 0; i-- {
tmp := strings.IndexAny(alphabet, string(b[i]))
if tmp == -1 {
return []byte("")
}
idx := big.NewInt(int64(tmp))
tmp1 := big.NewInt(0)
tmp1.Mul(j, idx)
an... | go | func DecodeToBytes(b string) []byte {
alphabet := string(base36)
answer := big.NewInt(0)
j := big.NewInt(1)
for i := len(b) - 1; i >= 0; i-- {
tmp := strings.IndexAny(alphabet, string(b[i]))
if tmp == -1 {
return []byte("")
}
idx := big.NewInt(int64(tmp))
tmp1 := big.NewInt(0)
tmp1.Mul(j, idx)
an... | [
"func",
"DecodeToBytes",
"(",
"b",
"string",
")",
"[",
"]",
"byte",
"{",
"alphabet",
":=",
"string",
"(",
"base36",
")",
"\n",
"answer",
":=",
"big",
".",
"NewInt",
"(",
"0",
")",
"\n",
"j",
":=",
"big",
".",
"NewInt",
"(",
"1",
")",
"\n\n",
"for... | // DecodeToBytes decodes a base36 string to a byte slice, using alphabet. | [
"DecodeToBytes",
"decodes",
"a",
"base36",
"string",
"to",
"a",
"byte",
"slice",
"using",
"alphabet",
"."
] | 7c6542dfbb41505111dde1f321eb5d5002f5fb88 | https://github.com/martinlindhe/base36/blob/7c6542dfbb41505111dde1f321eb5d5002f5fb88/base36.go#L94-L125 |
137,585 | wsxiaoys/terminal | color/color.go | Colorize | func Colorize(x string) string {
attr := 0
fg := 39
bg := 49
for _, key := range x {
c, ok := codeMap[int(key)]
switch {
case !ok:
log.Printf("Wrong color syntax: %c", key)
case 0 <= c && c <= 8:
attr = c
case 30 <= c && c <= 37:
fg = c
case 40 <= c && c <= 47:
bg = c
case c == 60:
fg ... | go | func Colorize(x string) string {
attr := 0
fg := 39
bg := 49
for _, key := range x {
c, ok := codeMap[int(key)]
switch {
case !ok:
log.Printf("Wrong color syntax: %c", key)
case 0 <= c && c <= 8:
attr = c
case 30 <= c && c <= 37:
fg = c
case 40 <= c && c <= 47:
bg = c
case c == 60:
fg ... | [
"func",
"Colorize",
"(",
"x",
"string",
")",
"string",
"{",
"attr",
":=",
"0",
"\n",
"fg",
":=",
"39",
"\n",
"bg",
":=",
"49",
"\n\n",
"for",
"_",
",",
"key",
":=",
"range",
"x",
"{",
"c",
",",
"ok",
":=",
"codeMap",
"[",
"int",
"(",
"key",
"... | // Compile color syntax string like "rG" to escape code. | [
"Compile",
"color",
"syntax",
"string",
"like",
"rG",
"to",
"escape",
"code",
"."
] | 0940f3fc43a0ed42d04916b1c04578462c650b09 | https://github.com/wsxiaoys/terminal/blob/0940f3fc43a0ed42d04916b1c04578462c650b09/color/color.go#L79-L100 |
137,586 | wsxiaoys/terminal | color/color.go | compileColorSyntax | func compileColorSyntax(input, output *bytes.Buffer) {
i, _, err := input.ReadRune()
if err != nil {
// EOF got
log.Print("Parse failed on color syntax")
return
}
switch i {
default:
output.WriteString(Colorize(string(i)))
case '{':
color := bytes.NewBufferString("")
for {
i, _, err := input.ReadR... | go | func compileColorSyntax(input, output *bytes.Buffer) {
i, _, err := input.ReadRune()
if err != nil {
// EOF got
log.Print("Parse failed on color syntax")
return
}
switch i {
default:
output.WriteString(Colorize(string(i)))
case '{':
color := bytes.NewBufferString("")
for {
i, _, err := input.ReadR... | [
"func",
"compileColorSyntax",
"(",
"input",
",",
"output",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"i",
",",
"_",
",",
"err",
":=",
"input",
".",
"ReadRune",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// EOF got",
"log",
".",
"Print",
"(",
"\""... | // Handle state after meeting one '@' | [
"Handle",
"state",
"after",
"meeting",
"one"
] | 0940f3fc43a0ed42d04916b1c04578462c650b09 | https://github.com/wsxiaoys/terminal/blob/0940f3fc43a0ed42d04916b1c04578462c650b09/color/color.go#L103-L131 |
137,587 | wsxiaoys/terminal | color/color.go | compile | func compile(x string) string {
if x == "" {
return ""
}
input := bytes.NewBufferString(x)
output := bytes.NewBufferString("")
for {
i, _, err := input.ReadRune()
if err != nil {
break
}
switch i {
default:
output.WriteRune(i)
case EscapeChar:
compileColorSyntax(input, output)
}
}
retu... | go | func compile(x string) string {
if x == "" {
return ""
}
input := bytes.NewBufferString(x)
output := bytes.NewBufferString("")
for {
i, _, err := input.ReadRune()
if err != nil {
break
}
switch i {
default:
output.WriteRune(i)
case EscapeChar:
compileColorSyntax(input, output)
}
}
retu... | [
"func",
"compile",
"(",
"x",
"string",
")",
"string",
"{",
"if",
"x",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"input",
":=",
"bytes",
".",
"NewBufferString",
"(",
"x",
")",
"\n",
"output",
":=",
"bytes",
".",
"NewBufferString"... | // Compile the string and replace color syntax with concrete escape code. | [
"Compile",
"the",
"string",
"and",
"replace",
"color",
"syntax",
"with",
"concrete",
"escape",
"code",
"."
] | 0940f3fc43a0ed42d04916b1c04578462c650b09 | https://github.com/wsxiaoys/terminal/blob/0940f3fc43a0ed42d04916b1c04578462c650b09/color/color.go#L134-L155 |
137,588 | wsxiaoys/terminal | color/color.go | compileValues | func compileValues(a *[]interface{}) {
for i, x := range *a {
if str, ok := x.(string); ok {
(*a)[i] = compile(str)
}
}
} | go | func compileValues(a *[]interface{}) {
for i, x := range *a {
if str, ok := x.(string); ok {
(*a)[i] = compile(str)
}
}
} | [
"func",
"compileValues",
"(",
"a",
"*",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"for",
"i",
",",
"x",
":=",
"range",
"*",
"a",
"{",
"if",
"str",
",",
"ok",
":=",
"x",
".",
"(",
"string",
")",
";",
"ok",
"{",
"(",
"*",
"a",
")",
"[",
"i... | // Compile multiple values, only do compiling on string type. | [
"Compile",
"multiple",
"values",
"only",
"do",
"compiling",
"on",
"string",
"type",
"."
] | 0940f3fc43a0ed42d04916b1c04578462c650b09 | https://github.com/wsxiaoys/terminal/blob/0940f3fc43a0ed42d04916b1c04578462c650b09/color/color.go#L158-L164 |
137,589 | wsxiaoys/terminal | color/color.go | Print | func Print(a ...interface{}) (int, error) {
a = append(a, ResetCode)
compileValues(&a)
return fmt.Print(a...)
} | go | func Print(a ...interface{}) (int, error) {
a = append(a, ResetCode)
compileValues(&a)
return fmt.Print(a...)
} | [
"func",
"Print",
"(",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"error",
")",
"{",
"a",
"=",
"append",
"(",
"a",
",",
"ResetCode",
")",
"\n",
"compileValues",
"(",
"&",
"a",
")",
"\n",
"return",
"fmt",
".",
"Print",
"(",
"a",
"..... | // Similar to fmt.Print, will reset the color at the end. | [
"Similar",
"to",
"fmt",
".",
"Print",
"will",
"reset",
"the",
"color",
"at",
"the",
"end",
"."
] | 0940f3fc43a0ed42d04916b1c04578462c650b09 | https://github.com/wsxiaoys/terminal/blob/0940f3fc43a0ed42d04916b1c04578462c650b09/color/color.go#L167-L171 |
137,590 | wsxiaoys/terminal | color/color.go | Println | func Println(a ...interface{}) (int, error) {
a = append(a, ResetCode)
compileValues(&a)
return fmt.Println(a...)
} | go | func Println(a ...interface{}) (int, error) {
a = append(a, ResetCode)
compileValues(&a)
return fmt.Println(a...)
} | [
"func",
"Println",
"(",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"error",
")",
"{",
"a",
"=",
"append",
"(",
"a",
",",
"ResetCode",
")",
"\n",
"compileValues",
"(",
"&",
"a",
")",
"\n",
"return",
"fmt",
".",
"Println",
"(",
"a",
... | // Similar to fmt.Println, will reset the color at the end. | [
"Similar",
"to",
"fmt",
".",
"Println",
"will",
"reset",
"the",
"color",
"at",
"the",
"end",
"."
] | 0940f3fc43a0ed42d04916b1c04578462c650b09 | https://github.com/wsxiaoys/terminal/blob/0940f3fc43a0ed42d04916b1c04578462c650b09/color/color.go#L174-L178 |
137,591 | wsxiaoys/terminal | color/color.go | Printf | func Printf(format string, a ...interface{}) (int, error) {
format += ResetCode
format = compile(format)
return fmt.Printf(format, a...)
} | go | func Printf(format string, a ...interface{}) (int, error) {
format += ResetCode
format = compile(format)
return fmt.Printf(format, a...)
} | [
"func",
"Printf",
"(",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"error",
")",
"{",
"format",
"+=",
"ResetCode",
"\n",
"format",
"=",
"compile",
"(",
"format",
")",
"\n",
"return",
"fmt",
".",
"Printf",
"(",
... | // Similar to fmt.Printf, will reset the color at the end. | [
"Similar",
"to",
"fmt",
".",
"Printf",
"will",
"reset",
"the",
"color",
"at",
"the",
"end",
"."
] | 0940f3fc43a0ed42d04916b1c04578462c650b09 | https://github.com/wsxiaoys/terminal/blob/0940f3fc43a0ed42d04916b1c04578462c650b09/color/color.go#L181-L185 |
137,592 | wsxiaoys/terminal | color/color.go | Fprint | func Fprint(w io.Writer, a ...interface{}) (int, error) {
a = append(a, ResetCode)
compileValues(&a)
return fmt.Fprint(w, a...)
} | go | func Fprint(w io.Writer, a ...interface{}) (int, error) {
a = append(a, ResetCode)
compileValues(&a)
return fmt.Fprint(w, a...)
} | [
"func",
"Fprint",
"(",
"w",
"io",
".",
"Writer",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"error",
")",
"{",
"a",
"=",
"append",
"(",
"a",
",",
"ResetCode",
")",
"\n",
"compileValues",
"(",
"&",
"a",
")",
"\n",
"return",
"f... | // Similar to fmt.Fprint, will reset the color at the end. | [
"Similar",
"to",
"fmt",
".",
"Fprint",
"will",
"reset",
"the",
"color",
"at",
"the",
"end",
"."
] | 0940f3fc43a0ed42d04916b1c04578462c650b09 | https://github.com/wsxiaoys/terminal/blob/0940f3fc43a0ed42d04916b1c04578462c650b09/color/color.go#L188-L192 |
137,593 | wsxiaoys/terminal | color/color.go | Fprintf | func Fprintf(w io.Writer, format string, a ...interface{}) (int, error) {
format += ResetCode
format = compile(format)
return fmt.Fprintf(w, format, a...)
} | go | func Fprintf(w io.Writer, format string, a ...interface{}) (int, error) {
format += ResetCode
format = compile(format)
return fmt.Fprintf(w, format, a...)
} | [
"func",
"Fprintf",
"(",
"w",
"io",
".",
"Writer",
",",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"error",
")",
"{",
"format",
"+=",
"ResetCode",
"\n",
"format",
"=",
"compile",
"(",
"format",
")",
"\n",
"retu... | // Similar to fmt.Fprintf, will reset the color at the end. | [
"Similar",
"to",
"fmt",
".",
"Fprintf",
"will",
"reset",
"the",
"color",
"at",
"the",
"end",
"."
] | 0940f3fc43a0ed42d04916b1c04578462c650b09 | https://github.com/wsxiaoys/terminal/blob/0940f3fc43a0ed42d04916b1c04578462c650b09/color/color.go#L202-L206 |
137,594 | wsxiaoys/terminal | color/color.go | Sprint | func Sprint(a ...interface{}) string {
a = append(a, ResetCode)
compileValues(&a)
return fmt.Sprint(a...)
} | go | func Sprint(a ...interface{}) string {
a = append(a, ResetCode)
compileValues(&a)
return fmt.Sprint(a...)
} | [
"func",
"Sprint",
"(",
"a",
"...",
"interface",
"{",
"}",
")",
"string",
"{",
"a",
"=",
"append",
"(",
"a",
",",
"ResetCode",
")",
"\n",
"compileValues",
"(",
"&",
"a",
")",
"\n",
"return",
"fmt",
".",
"Sprint",
"(",
"a",
"...",
")",
"\n",
"}"
] | // Similar to fmt.Sprint, will reset the color at the end. | [
"Similar",
"to",
"fmt",
".",
"Sprint",
"will",
"reset",
"the",
"color",
"at",
"the",
"end",
"."
] | 0940f3fc43a0ed42d04916b1c04578462c650b09 | https://github.com/wsxiaoys/terminal/blob/0940f3fc43a0ed42d04916b1c04578462c650b09/color/color.go#L209-L213 |
137,595 | guelfey/go.dbus | conn.go | SystemBusPrivate | func SystemBusPrivate() (*Conn, error) {
address := os.Getenv("DBUS_SYSTEM_BUS_ADDRESS")
if address != "" {
return Dial(address)
}
return Dial(defaultSystemBusAddress)
} | go | func SystemBusPrivate() (*Conn, error) {
address := os.Getenv("DBUS_SYSTEM_BUS_ADDRESS")
if address != "" {
return Dial(address)
}
return Dial(defaultSystemBusAddress)
} | [
"func",
"SystemBusPrivate",
"(",
")",
"(",
"*",
"Conn",
",",
"error",
")",
"{",
"address",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"address",
"!=",
"\"",
"\"",
"{",
"return",
"Dial",
"(",
"address",
")",
"\n",
"}",
"\n",
"ret... | // SystemBusPrivate returns a new private connection to the system bus. | [
"SystemBusPrivate",
"returns",
"a",
"new",
"private",
"connection",
"to",
"the",
"system",
"bus",
"."
] | f6a3a2366cc39b8479cadc499d3c735fb10fbdda | https://github.com/guelfey/go.dbus/blob/f6a3a2366cc39b8479cadc499d3c735fb10fbdda/conn.go#L132-L138 |
137,596 | guelfey/go.dbus | conn.go | Dial | func Dial(address string) (*Conn, error) {
tr, err := getTransport(address)
if err != nil {
return nil, err
}
return newConn(tr)
} | go | func Dial(address string) (*Conn, error) {
tr, err := getTransport(address)
if err != nil {
return nil, err
}
return newConn(tr)
} | [
"func",
"Dial",
"(",
"address",
"string",
")",
"(",
"*",
"Conn",
",",
"error",
")",
"{",
"tr",
",",
"err",
":=",
"getTransport",
"(",
"address",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"ne... | // Dial establishes a new private connection to the message bus specified by address. | [
"Dial",
"establishes",
"a",
"new",
"private",
"connection",
"to",
"the",
"message",
"bus",
"specified",
"by",
"address",
"."
] | f6a3a2366cc39b8479cadc499d3c735fb10fbdda | https://github.com/guelfey/go.dbus/blob/f6a3a2366cc39b8479cadc499d3c735fb10fbdda/conn.go#L141-L147 |
137,597 | guelfey/go.dbus | conn.go | getSerial | func (conn *Conn) getSerial() uint32 {
conn.serialLck.Lock()
defer conn.serialLck.Unlock()
n := conn.nextSerial
for conn.serialUsed[n] {
n++
}
conn.serialUsed[n] = true
conn.nextSerial = n + 1
return n
} | go | func (conn *Conn) getSerial() uint32 {
conn.serialLck.Lock()
defer conn.serialLck.Unlock()
n := conn.nextSerial
for conn.serialUsed[n] {
n++
}
conn.serialUsed[n] = true
conn.nextSerial = n + 1
return n
} | [
"func",
"(",
"conn",
"*",
"Conn",
")",
"getSerial",
"(",
")",
"uint32",
"{",
"conn",
".",
"serialLck",
".",
"Lock",
"(",
")",
"\n",
"defer",
"conn",
".",
"serialLck",
".",
"Unlock",
"(",
")",
"\n",
"n",
":=",
"conn",
".",
"nextSerial",
"\n",
"for",... | // getSerial returns an unused serial. | [
"getSerial",
"returns",
"an",
"unused",
"serial",
"."
] | f6a3a2366cc39b8479cadc499d3c735fb10fbdda | https://github.com/guelfey/go.dbus/blob/f6a3a2366cc39b8479cadc499d3c735fb10fbdda/conn.go#L209-L219 |
137,598 | guelfey/go.dbus | conn.go | Names | func (conn *Conn) Names() []string {
conn.namesLck.RLock()
// copy the slice so it can't be modified
s := make([]string, len(conn.names))
copy(s, conn.names)
conn.namesLck.RUnlock()
return s
} | go | func (conn *Conn) Names() []string {
conn.namesLck.RLock()
// copy the slice so it can't be modified
s := make([]string, len(conn.names))
copy(s, conn.names)
conn.namesLck.RUnlock()
return s
} | [
"func",
"(",
"conn",
"*",
"Conn",
")",
"Names",
"(",
")",
"[",
"]",
"string",
"{",
"conn",
".",
"namesLck",
".",
"RLock",
"(",
")",
"\n",
"// copy the slice so it can't be modified",
"s",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"conn",
... | // Names returns the list of all names that are currently owned by this
// connection. The slice is always at least one element long, the first element
// being the unique name of the connection. | [
"Names",
"returns",
"the",
"list",
"of",
"all",
"names",
"that",
"are",
"currently",
"owned",
"by",
"this",
"connection",
".",
"The",
"slice",
"is",
"always",
"at",
"least",
"one",
"element",
"long",
"the",
"first",
"element",
"being",
"the",
"unique",
"na... | f6a3a2366cc39b8479cadc499d3c735fb10fbdda | https://github.com/guelfey/go.dbus/blob/f6a3a2366cc39b8479cadc499d3c735fb10fbdda/conn.go#L350-L357 |
137,599 | guelfey/go.dbus | conn.go | Object | func (conn *Conn) Object(dest string, path ObjectPath) *Object {
return &Object{conn, dest, path}
} | go | func (conn *Conn) Object(dest string, path ObjectPath) *Object {
return &Object{conn, dest, path}
} | [
"func",
"(",
"conn",
"*",
"Conn",
")",
"Object",
"(",
"dest",
"string",
",",
"path",
"ObjectPath",
")",
"*",
"Object",
"{",
"return",
"&",
"Object",
"{",
"conn",
",",
"dest",
",",
"path",
"}",
"\n",
"}"
] | // Object returns the object identified by the given destination name and path. | [
"Object",
"returns",
"the",
"object",
"identified",
"by",
"the",
"given",
"destination",
"name",
"and",
"path",
"."
] | f6a3a2366cc39b8479cadc499d3c735fb10fbdda | https://github.com/guelfey/go.dbus/blob/f6a3a2366cc39b8479cadc499d3c735fb10fbdda/conn.go#L360-L362 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.