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
|
---|---|---|---|---|---|---|---|---|---|---|---|
16,700 |
drone/drone-go
|
drone/client.go
|
Verify
|
func (c *client) Verify(owner, name, file string) error {
in := struct {
Data string `json:"data"`
}{Data: file}
uri := fmt.Sprintf(pathVerify, c.addr, owner, name)
return c.post(uri, &in, nil)
}
|
go
|
func (c *client) Verify(owner, name, file string) error {
in := struct {
Data string `json:"data"`
}{Data: file}
uri := fmt.Sprintf(pathVerify, c.addr, owner, name)
return c.post(uri, &in, nil)
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"Verify",
"(",
"owner",
",",
"name",
",",
"file",
"string",
")",
"error",
"{",
"in",
":=",
"struct",
"{",
"Data",
"string",
"`json:\"data\"`",
"\n",
"}",
"{",
"Data",
":",
"file",
"}",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathVerify",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
")",
"\n",
"return",
"c",
".",
"post",
"(",
"uri",
",",
"&",
"in",
",",
"nil",
")",
"\n",
"}"
] |
// Verify verifies the yaml signature.
|
[
"Verify",
"verifies",
"the",
"yaml",
"signature",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L342-L348
|
16,701 |
drone/drone-go
|
drone/client.go
|
Encrypt
|
func (c *client) Encrypt(owner, name string, secret *Secret) (string, error) {
out := struct {
Data string `json:"data"`
}{}
uri := fmt.Sprintf(pathEncryptSecret, c.addr, owner, name)
err := c.post(uri, secret, &out)
return out.Data, err
}
|
go
|
func (c *client) Encrypt(owner, name string, secret *Secret) (string, error) {
out := struct {
Data string `json:"data"`
}{}
uri := fmt.Sprintf(pathEncryptSecret, c.addr, owner, name)
err := c.post(uri, secret, &out)
return out.Data, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"Encrypt",
"(",
"owner",
",",
"name",
"string",
",",
"secret",
"*",
"Secret",
")",
"(",
"string",
",",
"error",
")",
"{",
"out",
":=",
"struct",
"{",
"Data",
"string",
"`json:\"data\"`",
"\n",
"}",
"{",
"}",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathEncryptSecret",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
")",
"\n",
"err",
":=",
"c",
".",
"post",
"(",
"uri",
",",
"secret",
",",
"&",
"out",
")",
"\n",
"return",
"out",
".",
"Data",
",",
"err",
"\n",
"}"
] |
// Encrypt returns an encrypted secret.
|
[
"Encrypt",
"returns",
"an",
"encrypted",
"secret",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L351-L358
|
16,702 |
drone/drone-go
|
drone/client.go
|
Secret
|
func (c *client) Secret(owner, name, secret string) (*Secret, error) {
out := new(Secret)
uri := fmt.Sprintf(pathRepoSecret, c.addr, owner, name, secret)
err := c.get(uri, out)
return out, err
}
|
go
|
func (c *client) Secret(owner, name, secret string) (*Secret, error) {
out := new(Secret)
uri := fmt.Sprintf(pathRepoSecret, c.addr, owner, name, secret)
err := c.get(uri, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"Secret",
"(",
"owner",
",",
"name",
",",
"secret",
"string",
")",
"(",
"*",
"Secret",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Secret",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathRepoSecret",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
",",
"secret",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// Secret returns a secret by name.
|
[
"Secret",
"returns",
"a",
"secret",
"by",
"name",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L361-L366
|
16,703 |
drone/drone-go
|
drone/client.go
|
SecretList
|
func (c *client) SecretList(owner string, name string) ([]*Secret, error) {
var out []*Secret
uri := fmt.Sprintf(pathRepoSecrets, c.addr, owner, name)
err := c.get(uri, &out)
return out, err
}
|
go
|
func (c *client) SecretList(owner string, name string) ([]*Secret, error) {
var out []*Secret
uri := fmt.Sprintf(pathRepoSecrets, c.addr, owner, name)
err := c.get(uri, &out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"SecretList",
"(",
"owner",
"string",
",",
"name",
"string",
")",
"(",
"[",
"]",
"*",
"Secret",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"*",
"Secret",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathRepoSecrets",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"&",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// SecretList returns a list of all repository secrets.
|
[
"SecretList",
"returns",
"a",
"list",
"of",
"all",
"repository",
"secrets",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L369-L374
|
16,704 |
drone/drone-go
|
drone/client.go
|
SecretCreate
|
func (c *client) SecretCreate(owner, name string, in *Secret) (*Secret, error) {
out := new(Secret)
uri := fmt.Sprintf(pathRepoSecrets, c.addr, owner, name)
err := c.post(uri, in, out)
return out, err
}
|
go
|
func (c *client) SecretCreate(owner, name string, in *Secret) (*Secret, error) {
out := new(Secret)
uri := fmt.Sprintf(pathRepoSecrets, c.addr, owner, name)
err := c.post(uri, in, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"SecretCreate",
"(",
"owner",
",",
"name",
"string",
",",
"in",
"*",
"Secret",
")",
"(",
"*",
"Secret",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Secret",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathRepoSecrets",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
")",
"\n",
"err",
":=",
"c",
".",
"post",
"(",
"uri",
",",
"in",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// SecretCreate creates a secret.
|
[
"SecretCreate",
"creates",
"a",
"secret",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L377-L382
|
16,705 |
drone/drone-go
|
drone/client.go
|
SecretUpdate
|
func (c *client) SecretUpdate(owner, name string, in *Secret) (*Secret, error) {
out := new(Secret)
uri := fmt.Sprintf(pathRepoSecret, c.addr, owner, name, in.Name)
err := c.patch(uri, in, out)
return out, err
}
|
go
|
func (c *client) SecretUpdate(owner, name string, in *Secret) (*Secret, error) {
out := new(Secret)
uri := fmt.Sprintf(pathRepoSecret, c.addr, owner, name, in.Name)
err := c.patch(uri, in, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"SecretUpdate",
"(",
"owner",
",",
"name",
"string",
",",
"in",
"*",
"Secret",
")",
"(",
"*",
"Secret",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Secret",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathRepoSecret",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
",",
"in",
".",
"Name",
")",
"\n",
"err",
":=",
"c",
".",
"patch",
"(",
"uri",
",",
"in",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// SecretUpdate updates a secret.
|
[
"SecretUpdate",
"updates",
"a",
"secret",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L385-L390
|
16,706 |
drone/drone-go
|
drone/client.go
|
SecretDelete
|
func (c *client) SecretDelete(owner, name, secret string) error {
uri := fmt.Sprintf(pathRepoSecret, c.addr, owner, name, secret)
return c.delete(uri)
}
|
go
|
func (c *client) SecretDelete(owner, name, secret string) error {
uri := fmt.Sprintf(pathRepoSecret, c.addr, owner, name, secret)
return c.delete(uri)
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"SecretDelete",
"(",
"owner",
",",
"name",
",",
"secret",
"string",
")",
"error",
"{",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathRepoSecret",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
",",
"secret",
")",
"\n",
"return",
"c",
".",
"delete",
"(",
"uri",
")",
"\n",
"}"
] |
// SecretDelete deletes a secret.
|
[
"SecretDelete",
"deletes",
"a",
"secret",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L393-L396
|
16,707 |
drone/drone-go
|
drone/client.go
|
OrgSecret
|
func (c *client) OrgSecret(namespace, name string) (*Secret, error) {
out := new(Secret)
uri := fmt.Sprintf(pathSecretsName, c.addr, namespace, name)
err := c.get(uri, &out)
return out, err
}
|
go
|
func (c *client) OrgSecret(namespace, name string) (*Secret, error) {
out := new(Secret)
uri := fmt.Sprintf(pathSecretsName, c.addr, namespace, name)
err := c.get(uri, &out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"OrgSecret",
"(",
"namespace",
",",
"name",
"string",
")",
"(",
"*",
"Secret",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Secret",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathSecretsName",
",",
"c",
".",
"addr",
",",
"namespace",
",",
"name",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"&",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// OrgSecret returns a secret by name.
|
[
"OrgSecret",
"returns",
"a",
"secret",
"by",
"name",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L399-L404
|
16,708 |
drone/drone-go
|
drone/client.go
|
OrgSecretList
|
func (c *client) OrgSecretList(namespace string) ([]*Secret, error) {
var out []*Secret
uri := fmt.Sprintf(pathSecretsNamespace, c.addr, namespace)
err := c.get(uri, &out)
return out, err
}
|
go
|
func (c *client) OrgSecretList(namespace string) ([]*Secret, error) {
var out []*Secret
uri := fmt.Sprintf(pathSecretsNamespace, c.addr, namespace)
err := c.get(uri, &out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"OrgSecretList",
"(",
"namespace",
"string",
")",
"(",
"[",
"]",
"*",
"Secret",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"*",
"Secret",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathSecretsNamespace",
",",
"c",
".",
"addr",
",",
"namespace",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"&",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// OrgSecretList returns a list of all repository secrets.
|
[
"OrgSecretList",
"returns",
"a",
"list",
"of",
"all",
"repository",
"secrets",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L407-L412
|
16,709 |
drone/drone-go
|
drone/client.go
|
OrgSecretListAll
|
func (c *client) OrgSecretListAll() ([]*Secret, error) {
var out []*Secret
uri := fmt.Sprintf(pathSecrets, c.addr)
err := c.get(uri, &out)
return out, err
}
|
go
|
func (c *client) OrgSecretListAll() ([]*Secret, error) {
var out []*Secret
uri := fmt.Sprintf(pathSecrets, c.addr)
err := c.get(uri, &out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"OrgSecretListAll",
"(",
")",
"(",
"[",
"]",
"*",
"Secret",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"*",
"Secret",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathSecrets",
",",
"c",
".",
"addr",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"&",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// OrgSecretListAll returns a list of all repository secrets.
|
[
"OrgSecretListAll",
"returns",
"a",
"list",
"of",
"all",
"repository",
"secrets",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L415-L420
|
16,710 |
drone/drone-go
|
drone/client.go
|
OrgSecretCreate
|
func (c *client) OrgSecretCreate(namespace string, in *Secret) (*Secret, error) {
out := new(Secret)
uri := fmt.Sprintf(pathSecretsNamespace, c.addr, namespace)
err := c.post(uri, in, out)
return out, err
}
|
go
|
func (c *client) OrgSecretCreate(namespace string, in *Secret) (*Secret, error) {
out := new(Secret)
uri := fmt.Sprintf(pathSecretsNamespace, c.addr, namespace)
err := c.post(uri, in, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"OrgSecretCreate",
"(",
"namespace",
"string",
",",
"in",
"*",
"Secret",
")",
"(",
"*",
"Secret",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Secret",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathSecretsNamespace",
",",
"c",
".",
"addr",
",",
"namespace",
")",
"\n",
"err",
":=",
"c",
".",
"post",
"(",
"uri",
",",
"in",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// OrgSecretCreate creates a registry.
|
[
"OrgSecretCreate",
"creates",
"a",
"registry",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L423-L428
|
16,711 |
drone/drone-go
|
drone/client.go
|
OrgSecretDelete
|
func (c *client) OrgSecretDelete(namespace, name string) error {
uri := fmt.Sprintf(pathSecretsName, c.addr, namespace, name)
return c.delete(uri)
}
|
go
|
func (c *client) OrgSecretDelete(namespace, name string) error {
uri := fmt.Sprintf(pathSecretsName, c.addr, namespace, name)
return c.delete(uri)
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"OrgSecretDelete",
"(",
"namespace",
",",
"name",
"string",
")",
"error",
"{",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathSecretsName",
",",
"c",
".",
"addr",
",",
"namespace",
",",
"name",
")",
"\n",
"return",
"c",
".",
"delete",
"(",
"uri",
")",
"\n",
"}"
] |
// OrgSecretDelete deletes a secret.
|
[
"OrgSecretDelete",
"deletes",
"a",
"secret",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L439-L442
|
16,712 |
drone/drone-go
|
drone/client.go
|
Cron
|
func (c *client) Cron(owner, name, cron string) (*Cron, error) {
out := new(Cron)
uri := fmt.Sprintf(pathCron, c.addr, owner, name, cron)
err := c.get(uri, out)
return out, err
}
|
go
|
func (c *client) Cron(owner, name, cron string) (*Cron, error) {
out := new(Cron)
uri := fmt.Sprintf(pathCron, c.addr, owner, name, cron)
err := c.get(uri, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"Cron",
"(",
"owner",
",",
"name",
",",
"cron",
"string",
")",
"(",
"*",
"Cron",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Cron",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathCron",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
",",
"cron",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// Cron returns a cronjob by name.
|
[
"Cron",
"returns",
"a",
"cronjob",
"by",
"name",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L445-L450
|
16,713 |
drone/drone-go
|
drone/client.go
|
CronList
|
func (c *client) CronList(owner string, name string) ([]*Cron, error) {
var out []*Cron
uri := fmt.Sprintf(pathCrons, c.addr, owner, name)
err := c.get(uri, &out)
return out, err
}
|
go
|
func (c *client) CronList(owner string, name string) ([]*Cron, error) {
var out []*Cron
uri := fmt.Sprintf(pathCrons, c.addr, owner, name)
err := c.get(uri, &out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"CronList",
"(",
"owner",
"string",
",",
"name",
"string",
")",
"(",
"[",
"]",
"*",
"Cron",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"*",
"Cron",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathCrons",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"&",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// CronList returns a list of all repository cronjobs.
|
[
"CronList",
"returns",
"a",
"list",
"of",
"all",
"repository",
"cronjobs",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L453-L458
|
16,714 |
drone/drone-go
|
drone/client.go
|
CronCreate
|
func (c *client) CronCreate(owner, name string, in *Cron) (*Cron, error) {
out := new(Cron)
uri := fmt.Sprintf(pathCrons, c.addr, owner, name)
err := c.post(uri, in, out)
return out, err
}
|
go
|
func (c *client) CronCreate(owner, name string, in *Cron) (*Cron, error) {
out := new(Cron)
uri := fmt.Sprintf(pathCrons, c.addr, owner, name)
err := c.post(uri, in, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"CronCreate",
"(",
"owner",
",",
"name",
"string",
",",
"in",
"*",
"Cron",
")",
"(",
"*",
"Cron",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Cron",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathCrons",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
")",
"\n",
"err",
":=",
"c",
".",
"post",
"(",
"uri",
",",
"in",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// CronCreate creates a cronjob.
|
[
"CronCreate",
"creates",
"a",
"cronjob",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L461-L466
|
16,715 |
drone/drone-go
|
drone/client.go
|
CronUpdate
|
func (c *client) CronUpdate(owner, name, cron string, in *CronPatch) (*Cron, error) {
out := new(Cron)
uri := fmt.Sprintf(pathCron, c.addr, owner, name, cron)
err := c.patch(uri, in, out)
return out, err
}
|
go
|
func (c *client) CronUpdate(owner, name, cron string, in *CronPatch) (*Cron, error) {
out := new(Cron)
uri := fmt.Sprintf(pathCron, c.addr, owner, name, cron)
err := c.patch(uri, in, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"CronUpdate",
"(",
"owner",
",",
"name",
",",
"cron",
"string",
",",
"in",
"*",
"CronPatch",
")",
"(",
"*",
"Cron",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Cron",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathCron",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
",",
"cron",
")",
"\n",
"err",
":=",
"c",
".",
"patch",
"(",
"uri",
",",
"in",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// CronDisable disables a cronjob.
|
[
"CronDisable",
"disables",
"a",
"cronjob",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L469-L474
|
16,716 |
drone/drone-go
|
drone/client.go
|
CronDelete
|
func (c *client) CronDelete(owner, name, cron string) error {
uri := fmt.Sprintf(pathCron, c.addr, owner, name, cron)
return c.delete(uri)
}
|
go
|
func (c *client) CronDelete(owner, name, cron string) error {
uri := fmt.Sprintf(pathCron, c.addr, owner, name, cron)
return c.delete(uri)
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"CronDelete",
"(",
"owner",
",",
"name",
",",
"cron",
"string",
")",
"error",
"{",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathCron",
",",
"c",
".",
"addr",
",",
"owner",
",",
"name",
",",
"cron",
")",
"\n",
"return",
"c",
".",
"delete",
"(",
"uri",
")",
"\n",
"}"
] |
// CronDelete deletes a cronjob.
|
[
"CronDelete",
"deletes",
"a",
"cronjob",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L477-L480
|
16,717 |
drone/drone-go
|
drone/client.go
|
Queue
|
func (c *client) Queue() ([]*Stage, error) {
var out []*Stage
uri := fmt.Sprintf(pathQueue, c.addr)
err := c.get(uri, &out)
return out, err
}
|
go
|
func (c *client) Queue() ([]*Stage, error) {
var out []*Stage
uri := fmt.Sprintf(pathQueue, c.addr)
err := c.get(uri, &out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"Queue",
"(",
")",
"(",
"[",
"]",
"*",
"Stage",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"*",
"Stage",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathQueue",
",",
"c",
".",
"addr",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"&",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// Queue returns a list of enqueued builds.
|
[
"Queue",
"returns",
"a",
"list",
"of",
"enqueued",
"builds",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L483-L488
|
16,718 |
drone/drone-go
|
drone/client.go
|
QueueResume
|
func (c *client) QueueResume() error {
uri := fmt.Sprintf(pathQueue, c.addr)
err := c.post(uri, nil, nil)
return err
}
|
go
|
func (c *client) QueueResume() error {
uri := fmt.Sprintf(pathQueue, c.addr)
err := c.post(uri, nil, nil)
return err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"QueueResume",
"(",
")",
"error",
"{",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathQueue",
",",
"c",
".",
"addr",
")",
"\n",
"err",
":=",
"c",
".",
"post",
"(",
"uri",
",",
"nil",
",",
"nil",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
// QueueResume resumes queue operations.
|
[
"QueueResume",
"resumes",
"queue",
"operations",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L491-L495
|
16,719 |
drone/drone-go
|
drone/client.go
|
QueuePause
|
func (c *client) QueuePause() error {
uri := fmt.Sprintf(pathQueue, c.addr)
err := c.delete(uri)
return err
}
|
go
|
func (c *client) QueuePause() error {
uri := fmt.Sprintf(pathQueue, c.addr)
err := c.delete(uri)
return err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"QueuePause",
"(",
")",
"error",
"{",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathQueue",
",",
"c",
".",
"addr",
")",
"\n",
"err",
":=",
"c",
".",
"delete",
"(",
"uri",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
// QueuePause pauses queue operations.
|
[
"QueuePause",
"pauses",
"queue",
"operations",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L498-L502
|
16,720 |
drone/drone-go
|
drone/client.go
|
Node
|
func (c *client) Node(name string) (*Node, error) {
out := new(Node)
uri := fmt.Sprintf(pathNode, c.addr, name)
err := c.get(uri, out)
return out, err
}
|
go
|
func (c *client) Node(name string) (*Node, error) {
out := new(Node)
uri := fmt.Sprintf(pathNode, c.addr, name)
err := c.get(uri, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"Node",
"(",
"name",
"string",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Node",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathNode",
",",
"c",
".",
"addr",
",",
"name",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// Node returns a node by name.
|
[
"Node",
"returns",
"a",
"node",
"by",
"name",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L505-L510
|
16,721 |
drone/drone-go
|
drone/client.go
|
NodeList
|
func (c *client) NodeList() ([]*Node, error) {
var out []*Node
uri := fmt.Sprintf(pathNodes, c.addr)
err := c.get(uri, &out)
return out, err
}
|
go
|
func (c *client) NodeList() ([]*Node, error) {
var out []*Node
uri := fmt.Sprintf(pathNodes, c.addr)
err := c.get(uri, &out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"NodeList",
"(",
")",
"(",
"[",
"]",
"*",
"Node",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"*",
"Node",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathNodes",
",",
"c",
".",
"addr",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"&",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// NodeList returns a list of all nodes.
|
[
"NodeList",
"returns",
"a",
"list",
"of",
"all",
"nodes",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L513-L518
|
16,722 |
drone/drone-go
|
drone/client.go
|
NodeCreate
|
func (c *client) NodeCreate(in *Node) (*Node, error) {
out := new(Node)
uri := fmt.Sprintf(pathNodes, c.addr)
err := c.post(uri, in, out)
return out, err
}
|
go
|
func (c *client) NodeCreate(in *Node) (*Node, error) {
out := new(Node)
uri := fmt.Sprintf(pathNodes, c.addr)
err := c.post(uri, in, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"NodeCreate",
"(",
"in",
"*",
"Node",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Node",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathNodes",
",",
"c",
".",
"addr",
")",
"\n",
"err",
":=",
"c",
".",
"post",
"(",
"uri",
",",
"in",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// NodeCreate creates a node.
|
[
"NodeCreate",
"creates",
"a",
"node",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L521-L526
|
16,723 |
drone/drone-go
|
drone/client.go
|
NodeDelete
|
func (c *client) NodeDelete(name string) error {
uri := fmt.Sprintf(pathNode, c.addr, name)
return c.delete(uri)
}
|
go
|
func (c *client) NodeDelete(name string) error {
uri := fmt.Sprintf(pathNode, c.addr, name)
return c.delete(uri)
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"NodeDelete",
"(",
"name",
"string",
")",
"error",
"{",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathNode",
",",
"c",
".",
"addr",
",",
"name",
")",
"\n",
"return",
"c",
".",
"delete",
"(",
"uri",
")",
"\n",
"}"
] |
// NodeDelete deletes a node.
|
[
"NodeDelete",
"deletes",
"a",
"node",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L529-L532
|
16,724 |
drone/drone-go
|
drone/client.go
|
NodeUpdate
|
func (c *client) NodeUpdate(name string, in *NodePatch) (*Node, error) {
out := new(Node)
uri := fmt.Sprintf(pathNode, c.addr, name)
err := c.patch(uri, in, out)
return out, err
}
|
go
|
func (c *client) NodeUpdate(name string, in *NodePatch) (*Node, error) {
out := new(Node)
uri := fmt.Sprintf(pathNode, c.addr, name)
err := c.patch(uri, in, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"NodeUpdate",
"(",
"name",
"string",
",",
"in",
"*",
"NodePatch",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Node",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathNode",
",",
"c",
".",
"addr",
",",
"name",
")",
"\n",
"err",
":=",
"c",
".",
"patch",
"(",
"uri",
",",
"in",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// NodeUpdate updates a node.
|
[
"NodeUpdate",
"updates",
"a",
"node",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L535-L540
|
16,725 |
drone/drone-go
|
drone/client.go
|
Server
|
func (c *client) Server(name string) (*Server, error) {
out := new(Server)
uri := fmt.Sprintf(pathServer, c.addr, name)
err := c.get(uri, &out)
return out, err
}
|
go
|
func (c *client) Server(name string) (*Server, error) {
out := new(Server)
uri := fmt.Sprintf(pathServer, c.addr, name)
err := c.get(uri, &out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"Server",
"(",
"name",
"string",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Server",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathServer",
",",
"c",
".",
"addr",
",",
"name",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"&",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
//
// autoscaler
//
// Server returns the named servers details.
|
[
"autoscaler",
"Server",
"returns",
"the",
"named",
"servers",
"details",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L547-L552
|
16,726 |
drone/drone-go
|
drone/client.go
|
ServerList
|
func (c *client) ServerList() ([]*Server, error) {
var out []*Server
uri := fmt.Sprintf(pathServers, c.addr)
err := c.get(uri, &out)
return out, err
}
|
go
|
func (c *client) ServerList() ([]*Server, error) {
var out []*Server
uri := fmt.Sprintf(pathServers, c.addr)
err := c.get(uri, &out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"ServerList",
"(",
")",
"(",
"[",
"]",
"*",
"Server",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"*",
"Server",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathServers",
",",
"c",
".",
"addr",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"&",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// ServerList returns a list of all active build servers.
|
[
"ServerList",
"returns",
"a",
"list",
"of",
"all",
"active",
"build",
"servers",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L555-L560
|
16,727 |
drone/drone-go
|
drone/client.go
|
ServerCreate
|
func (c *client) ServerCreate() (*Server, error) {
out := new(Server)
uri := fmt.Sprintf(pathServers, c.addr)
err := c.post(uri, nil, out)
return out, err
}
|
go
|
func (c *client) ServerCreate() (*Server, error) {
out := new(Server)
uri := fmt.Sprintf(pathServers, c.addr)
err := c.post(uri, nil, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"ServerCreate",
"(",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Server",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathServers",
",",
"c",
".",
"addr",
")",
"\n",
"err",
":=",
"c",
".",
"post",
"(",
"uri",
",",
"nil",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// ServerCreate creates a new server.
|
[
"ServerCreate",
"creates",
"a",
"new",
"server",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L563-L568
|
16,728 |
drone/drone-go
|
drone/client.go
|
ServerDelete
|
func (c *client) ServerDelete(name string) error {
uri := fmt.Sprintf(pathServer, c.addr, name)
return c.delete(uri)
}
|
go
|
func (c *client) ServerDelete(name string) error {
uri := fmt.Sprintf(pathServer, c.addr, name)
return c.delete(uri)
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"ServerDelete",
"(",
"name",
"string",
")",
"error",
"{",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathServer",
",",
"c",
".",
"addr",
",",
"name",
")",
"\n",
"return",
"c",
".",
"delete",
"(",
"uri",
")",
"\n",
"}"
] |
// ServerDelete terminates a server.
|
[
"ServerDelete",
"terminates",
"a",
"server",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L571-L574
|
16,729 |
drone/drone-go
|
drone/client.go
|
AutoscalePause
|
func (c *client) AutoscalePause() error {
uri := fmt.Sprintf(pathScalerPause, c.addr)
return c.post(uri, nil, nil)
}
|
go
|
func (c *client) AutoscalePause() error {
uri := fmt.Sprintf(pathScalerPause, c.addr)
return c.post(uri, nil, nil)
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"AutoscalePause",
"(",
")",
"error",
"{",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathScalerPause",
",",
"c",
".",
"addr",
")",
"\n",
"return",
"c",
".",
"post",
"(",
"uri",
",",
"nil",
",",
"nil",
")",
"\n",
"}"
] |
// AutoscalePause pauses the autoscaler.
|
[
"AutoscalePause",
"pauses",
"the",
"autoscaler",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L577-L580
|
16,730 |
drone/drone-go
|
drone/client.go
|
AutoscaleResume
|
func (c *client) AutoscaleResume() error {
uri := fmt.Sprintf(pathScalerResume, c.addr)
return c.post(uri, nil, nil)
}
|
go
|
func (c *client) AutoscaleResume() error {
uri := fmt.Sprintf(pathScalerResume, c.addr)
return c.post(uri, nil, nil)
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"AutoscaleResume",
"(",
")",
"error",
"{",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathScalerResume",
",",
"c",
".",
"addr",
")",
"\n",
"return",
"c",
".",
"post",
"(",
"uri",
",",
"nil",
",",
"nil",
")",
"\n",
"}"
] |
// AutoscaleResume resumes the autoscaler.
|
[
"AutoscaleResume",
"resumes",
"the",
"autoscaler",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L583-L586
|
16,731 |
drone/drone-go
|
drone/client.go
|
AutoscaleVersion
|
func (c *client) AutoscaleVersion() (*Version, error) {
out := new(Version)
uri := fmt.Sprintf(pathVersion, c.addr)
err := c.get(uri, out)
return out, err
}
|
go
|
func (c *client) AutoscaleVersion() (*Version, error) {
out := new(Version)
uri := fmt.Sprintf(pathVersion, c.addr)
err := c.get(uri, out)
return out, err
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"AutoscaleVersion",
"(",
")",
"(",
"*",
"Version",
",",
"error",
")",
"{",
"out",
":=",
"new",
"(",
"Version",
")",
"\n",
"uri",
":=",
"fmt",
".",
"Sprintf",
"(",
"pathVersion",
",",
"c",
".",
"addr",
")",
"\n",
"err",
":=",
"c",
".",
"get",
"(",
"uri",
",",
"out",
")",
"\n",
"return",
"out",
",",
"err",
"\n",
"}"
] |
// AutoscaleVersion resumes the autoscaler.
|
[
"AutoscaleVersion",
"resumes",
"the",
"autoscaler",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L589-L594
|
16,732 |
drone/drone-go
|
drone/client.go
|
get
|
func (c *client) get(rawurl string, out interface{}) error {
return c.do(rawurl, "GET", nil, out)
}
|
go
|
func (c *client) get(rawurl string, out interface{}) error {
return c.do(rawurl, "GET", nil, out)
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"get",
"(",
"rawurl",
"string",
",",
"out",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"c",
".",
"do",
"(",
"rawurl",
",",
"\"",
"\"",
",",
"nil",
",",
"out",
")",
"\n",
"}"
] |
//
// http request helper functions
//
// helper function for making an http GET request.
|
[
"http",
"request",
"helper",
"functions",
"helper",
"function",
"for",
"making",
"an",
"http",
"GET",
"request",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L601-L603
|
16,733 |
drone/drone-go
|
drone/client.go
|
post
|
func (c *client) post(rawurl string, in, out interface{}) error {
return c.do(rawurl, "POST", in, out)
}
|
go
|
func (c *client) post(rawurl string, in, out interface{}) error {
return c.do(rawurl, "POST", in, out)
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"post",
"(",
"rawurl",
"string",
",",
"in",
",",
"out",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"c",
".",
"do",
"(",
"rawurl",
",",
"\"",
"\"",
",",
"in",
",",
"out",
")",
"\n",
"}"
] |
// helper function for making an http POST request.
|
[
"helper",
"function",
"for",
"making",
"an",
"http",
"POST",
"request",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L606-L608
|
16,734 |
drone/drone-go
|
drone/client.go
|
delete
|
func (c *client) delete(rawurl string) error {
return c.do(rawurl, "DELETE", nil, nil)
}
|
go
|
func (c *client) delete(rawurl string) error {
return c.do(rawurl, "DELETE", nil, nil)
}
|
[
"func",
"(",
"c",
"*",
"client",
")",
"delete",
"(",
"rawurl",
"string",
")",
"error",
"{",
"return",
"c",
".",
"do",
"(",
"rawurl",
",",
"\"",
"\"",
",",
"nil",
",",
"nil",
")",
"\n",
"}"
] |
// helper function for making an http DELETE request.
|
[
"helper",
"function",
"for",
"making",
"an",
"http",
"DELETE",
"request",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L616-L618
|
16,735 |
drone/drone-go
|
drone/client.go
|
mapValues
|
func mapValues(params map[string]string) url.Values {
values := url.Values{}
for key, val := range params {
values.Add(key, val)
}
return values
}
|
go
|
func mapValues(params map[string]string) url.Values {
values := url.Values{}
for key, val := range params {
values.Add(key, val)
}
return values
}
|
[
"func",
"mapValues",
"(",
"params",
"map",
"[",
"string",
"]",
"string",
")",
"url",
".",
"Values",
"{",
"values",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"for",
"key",
",",
"val",
":=",
"range",
"params",
"{",
"values",
".",
"Add",
"(",
"key",
",",
"val",
")",
"\n",
"}",
"\n",
"return",
"values",
"\n",
"}"
] |
// mapValues converts a map to url.Values
|
[
"mapValues",
"converts",
"a",
"map",
"to",
"url",
".",
"Values"
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/drone/client.go#L667-L673
|
16,736 |
drone/drone-go
|
plugin/webhook/client.go
|
Client
|
func Client(endpoint, secret string, skipverify bool) Plugin {
client := client.New(endpoint, secret, skipverify)
client.Accept = V1
return &pluginClient{
client: client,
}
}
|
go
|
func Client(endpoint, secret string, skipverify bool) Plugin {
client := client.New(endpoint, secret, skipverify)
client.Accept = V1
return &pluginClient{
client: client,
}
}
|
[
"func",
"Client",
"(",
"endpoint",
",",
"secret",
"string",
",",
"skipverify",
"bool",
")",
"Plugin",
"{",
"client",
":=",
"client",
".",
"New",
"(",
"endpoint",
",",
"secret",
",",
"skipverify",
")",
"\n",
"client",
".",
"Accept",
"=",
"V1",
"\n",
"return",
"&",
"pluginClient",
"{",
"client",
":",
"client",
",",
"}",
"\n",
"}"
] |
// Client returns a new plugin client.
|
[
"Client",
"returns",
"a",
"new",
"plugin",
"client",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/plugin/webhook/client.go#L24-L30
|
16,737 |
drone/drone-go
|
plugin/internal/aesgcm/aesgcm.go
|
Decrypt
|
func Decrypt(ciphertext []byte, key *[32]byte) (plaintext []byte, err error) {
block, err := aes.NewCipher(key[:])
if err != nil {
return nil, err
}
gcm, err := cipher.NewGCM(block)
if err != nil {
return nil, err
}
if len(ciphertext) < gcm.NonceSize() {
return nil, errors.New("malformed ciphertext")
}
return gcm.Open(nil,
ciphertext[:gcm.NonceSize()],
ciphertext[gcm.NonceSize():],
nil,
)
}
|
go
|
func Decrypt(ciphertext []byte, key *[32]byte) (plaintext []byte, err error) {
block, err := aes.NewCipher(key[:])
if err != nil {
return nil, err
}
gcm, err := cipher.NewGCM(block)
if err != nil {
return nil, err
}
if len(ciphertext) < gcm.NonceSize() {
return nil, errors.New("malformed ciphertext")
}
return gcm.Open(nil,
ciphertext[:gcm.NonceSize()],
ciphertext[gcm.NonceSize():],
nil,
)
}
|
[
"func",
"Decrypt",
"(",
"ciphertext",
"[",
"]",
"byte",
",",
"key",
"*",
"[",
"32",
"]",
"byte",
")",
"(",
"plaintext",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"block",
",",
"err",
":=",
"aes",
".",
"NewCipher",
"(",
"key",
"[",
":",
"]",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"gcm",
",",
"err",
":=",
"cipher",
".",
"NewGCM",
"(",
"block",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"ciphertext",
")",
"<",
"gcm",
".",
"NonceSize",
"(",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"gcm",
".",
"Open",
"(",
"nil",
",",
"ciphertext",
"[",
":",
"gcm",
".",
"NonceSize",
"(",
")",
"]",
",",
"ciphertext",
"[",
"gcm",
".",
"NonceSize",
"(",
")",
":",
"]",
",",
"nil",
",",
")",
"\n",
"}"
] |
// Decrypt decrypts the raw, unencoded cihpertext with the provided key.
|
[
"Decrypt",
"decrypts",
"the",
"raw",
"unencoded",
"cihpertext",
"with",
"the",
"provided",
"key",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/plugin/internal/aesgcm/aesgcm.go#L52-L72
|
16,738 |
drone/drone-go
|
plugin/internal/aesgcm/aesgcm.go
|
Key
|
func Key(s string) (*[32]byte, error) {
if len(s) < 32 {
return nil, errInvalidKeyLength
}
var key [32]byte
copy(key[:], []byte(s))
return &key, nil
}
|
go
|
func Key(s string) (*[32]byte, error) {
if len(s) < 32 {
return nil, errInvalidKeyLength
}
var key [32]byte
copy(key[:], []byte(s))
return &key, nil
}
|
[
"func",
"Key",
"(",
"s",
"string",
")",
"(",
"*",
"[",
"32",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"s",
")",
"<",
"32",
"{",
"return",
"nil",
",",
"errInvalidKeyLength",
"\n",
"}",
"\n",
"var",
"key",
"[",
"32",
"]",
"byte",
"\n",
"copy",
"(",
"key",
"[",
":",
"]",
",",
"[",
"]",
"byte",
"(",
"s",
")",
")",
"\n",
"return",
"&",
"key",
",",
"nil",
"\n",
"}"
] |
// Key returns an encryption key.
|
[
"Key",
"returns",
"an",
"encryption",
"key",
"."
] |
618e4496482ebbcc8e0a32499e0a550b1a9c7b98
|
https://github.com/drone/drone-go/blob/618e4496482ebbcc8e0a32499e0a550b1a9c7b98/plugin/internal/aesgcm/aesgcm.go#L75-L82
|
16,739 |
dimfeld/httptreemux
|
group.go
|
NewGroup
|
func (g *Group) NewGroup(path string) *Group {
if len(path) < 1 {
panic("Group path must not be empty")
}
checkPath(path)
path = g.path + path
//Don't want trailing slash as all sub-paths start with slash
if path[len(path)-1] == '/' {
path = path[:len(path)-1]
}
return &Group{path, g.mux}
}
|
go
|
func (g *Group) NewGroup(path string) *Group {
if len(path) < 1 {
panic("Group path must not be empty")
}
checkPath(path)
path = g.path + path
//Don't want trailing slash as all sub-paths start with slash
if path[len(path)-1] == '/' {
path = path[:len(path)-1]
}
return &Group{path, g.mux}
}
|
[
"func",
"(",
"g",
"*",
"Group",
")",
"NewGroup",
"(",
"path",
"string",
")",
"*",
"Group",
"{",
"if",
"len",
"(",
"path",
")",
"<",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"checkPath",
"(",
"path",
")",
"\n",
"path",
"=",
"g",
".",
"path",
"+",
"path",
"\n",
"//Don't want trailing slash as all sub-paths start with slash",
"if",
"path",
"[",
"len",
"(",
"path",
")",
"-",
"1",
"]",
"==",
"'/'",
"{",
"path",
"=",
"path",
"[",
":",
"len",
"(",
"path",
")",
"-",
"1",
"]",
"\n",
"}",
"\n",
"return",
"&",
"Group",
"{",
"path",
",",
"g",
".",
"mux",
"}",
"\n",
"}"
] |
// Add a sub-group to this group
|
[
"Add",
"a",
"sub",
"-",
"group",
"to",
"this",
"group"
] |
a454a10de4a11f751681a0914461ab9e98c2a3ff
|
https://github.com/dimfeld/httptreemux/blob/a454a10de4a11f751681a0914461ab9e98c2a3ff/group.go#L15-L27
|
16,740 |
dimfeld/httptreemux
|
router.go
|
Lookup
|
func (t *TreeMux) Lookup(w http.ResponseWriter, r *http.Request) (LookupResult, bool) {
if t.SafeAddRoutesWhileRunning {
// In concurrency safe mode, we acquire a read lock on the mutex for any access.
// This is optional to avoid potential performance loss in high-usage scenarios.
t.mutex.RLock()
}
result, found := t.lookup(w, r)
if t.SafeAddRoutesWhileRunning {
t.mutex.RUnlock()
}
return result, found
}
|
go
|
func (t *TreeMux) Lookup(w http.ResponseWriter, r *http.Request) (LookupResult, bool) {
if t.SafeAddRoutesWhileRunning {
// In concurrency safe mode, we acquire a read lock on the mutex for any access.
// This is optional to avoid potential performance loss in high-usage scenarios.
t.mutex.RLock()
}
result, found := t.lookup(w, r)
if t.SafeAddRoutesWhileRunning {
t.mutex.RUnlock()
}
return result, found
}
|
[
"func",
"(",
"t",
"*",
"TreeMux",
")",
"Lookup",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"LookupResult",
",",
"bool",
")",
"{",
"if",
"t",
".",
"SafeAddRoutesWhileRunning",
"{",
"// In concurrency safe mode, we acquire a read lock on the mutex for any access.",
"// This is optional to avoid potential performance loss in high-usage scenarios.",
"t",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"}",
"\n\n",
"result",
",",
"found",
":=",
"t",
".",
"lookup",
"(",
"w",
",",
"r",
")",
"\n\n",
"if",
"t",
".",
"SafeAddRoutesWhileRunning",
"{",
"t",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"result",
",",
"found",
"\n",
"}"
] |
// Lookup performs a lookup without actually serving the request or mutating the request or response.
// The return values are a LookupResult and a boolean. The boolean will be true when a handler
// was found or the lookup resulted in a redirect which will point to a real handler. It is false
// for requests which would result in a `StatusNotFound` or `StatusMethodNotAllowed`.
//
// Regardless of the returned boolean's value, the LookupResult may be passed to ServeLookupResult
// to be served appropriately.
|
[
"Lookup",
"performs",
"a",
"lookup",
"without",
"actually",
"serving",
"the",
"request",
"or",
"mutating",
"the",
"request",
"or",
"response",
".",
"The",
"return",
"values",
"are",
"a",
"LookupResult",
"and",
"a",
"boolean",
".",
"The",
"boolean",
"will",
"be",
"true",
"when",
"a",
"handler",
"was",
"found",
"or",
"the",
"lookup",
"resulted",
"in",
"a",
"redirect",
"which",
"will",
"point",
"to",
"a",
"real",
"handler",
".",
"It",
"is",
"false",
"for",
"requests",
"which",
"would",
"result",
"in",
"a",
"StatusNotFound",
"or",
"StatusMethodNotAllowed",
".",
"Regardless",
"of",
"the",
"returned",
"boolean",
"s",
"value",
"the",
"LookupResult",
"may",
"be",
"passed",
"to",
"ServeLookupResult",
"to",
"be",
"served",
"appropriately",
"."
] |
a454a10de4a11f751681a0914461ab9e98c2a3ff
|
https://github.com/dimfeld/httptreemux/blob/a454a10de4a11f751681a0914461ab9e98c2a3ff/router.go#L213-L227
|
16,741 |
dimfeld/httptreemux
|
router.go
|
ServeLookupResult
|
func (t *TreeMux) ServeLookupResult(w http.ResponseWriter, r *http.Request, lr LookupResult) {
if lr.handler == nil {
if lr.StatusCode == http.StatusMethodNotAllowed && lr.leafHandler != nil {
if t.SafeAddRoutesWhileRunning {
t.mutex.RLock()
}
t.MethodNotAllowedHandler(w, r, lr.leafHandler)
if t.SafeAddRoutesWhileRunning {
t.mutex.RUnlock()
}
} else {
t.NotFoundHandler(w, r)
}
} else {
r = t.setDefaultRequestContext(r)
lr.handler(w, r, lr.params)
}
}
|
go
|
func (t *TreeMux) ServeLookupResult(w http.ResponseWriter, r *http.Request, lr LookupResult) {
if lr.handler == nil {
if lr.StatusCode == http.StatusMethodNotAllowed && lr.leafHandler != nil {
if t.SafeAddRoutesWhileRunning {
t.mutex.RLock()
}
t.MethodNotAllowedHandler(w, r, lr.leafHandler)
if t.SafeAddRoutesWhileRunning {
t.mutex.RUnlock()
}
} else {
t.NotFoundHandler(w, r)
}
} else {
r = t.setDefaultRequestContext(r)
lr.handler(w, r, lr.params)
}
}
|
[
"func",
"(",
"t",
"*",
"TreeMux",
")",
"ServeLookupResult",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"lr",
"LookupResult",
")",
"{",
"if",
"lr",
".",
"handler",
"==",
"nil",
"{",
"if",
"lr",
".",
"StatusCode",
"==",
"http",
".",
"StatusMethodNotAllowed",
"&&",
"lr",
".",
"leafHandler",
"!=",
"nil",
"{",
"if",
"t",
".",
"SafeAddRoutesWhileRunning",
"{",
"t",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"}",
"\n\n",
"t",
".",
"MethodNotAllowedHandler",
"(",
"w",
",",
"r",
",",
"lr",
".",
"leafHandler",
")",
"\n\n",
"if",
"t",
".",
"SafeAddRoutesWhileRunning",
"{",
"t",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"t",
".",
"NotFoundHandler",
"(",
"w",
",",
"r",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"r",
"=",
"t",
".",
"setDefaultRequestContext",
"(",
"r",
")",
"\n",
"lr",
".",
"handler",
"(",
"w",
",",
"r",
",",
"lr",
".",
"params",
")",
"\n",
"}",
"\n",
"}"
] |
// ServeLookupResult serves a request, given a lookup result from the Lookup function.
|
[
"ServeLookupResult",
"serves",
"a",
"request",
"given",
"a",
"lookup",
"result",
"from",
"the",
"Lookup",
"function",
"."
] |
a454a10de4a11f751681a0914461ab9e98c2a3ff
|
https://github.com/dimfeld/httptreemux/blob/a454a10de4a11f751681a0914461ab9e98c2a3ff/router.go#L230-L249
|
16,742 |
dimfeld/httptreemux
|
router.go
|
MethodNotAllowedHandler
|
func MethodNotAllowedHandler(w http.ResponseWriter, r *http.Request,
methods map[string]HandlerFunc) {
for m := range methods {
w.Header().Add("Allow", m)
}
w.WriteHeader(http.StatusMethodNotAllowed)
}
|
go
|
func MethodNotAllowedHandler(w http.ResponseWriter, r *http.Request,
methods map[string]HandlerFunc) {
for m := range methods {
w.Header().Add("Allow", m)
}
w.WriteHeader(http.StatusMethodNotAllowed)
}
|
[
"func",
"MethodNotAllowedHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"methods",
"map",
"[",
"string",
"]",
"HandlerFunc",
")",
"{",
"for",
"m",
":=",
"range",
"methods",
"{",
"w",
".",
"Header",
"(",
")",
".",
"Add",
"(",
"\"",
"\"",
",",
"m",
")",
"\n",
"}",
"\n\n",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusMethodNotAllowed",
")",
"\n",
"}"
] |
// MethodNotAllowedHandler is the default handler for TreeMux.MethodNotAllowedHandler,
// which is called for patterns that match, but do not have a handler installed for the
// requested method. It simply writes the status code http.StatusMethodNotAllowed and fills
// in the `Allow` header value appropriately.
|
[
"MethodNotAllowedHandler",
"is",
"the",
"default",
"handler",
"for",
"TreeMux",
".",
"MethodNotAllowedHandler",
"which",
"is",
"called",
"for",
"patterns",
"that",
"match",
"but",
"do",
"not",
"have",
"a",
"handler",
"installed",
"for",
"the",
"requested",
"method",
".",
"It",
"simply",
"writes",
"the",
"status",
"code",
"http",
".",
"StatusMethodNotAllowed",
"and",
"fills",
"in",
"the",
"Allow",
"header",
"value",
"appropriately",
"."
] |
a454a10de4a11f751681a0914461ab9e98c2a3ff
|
https://github.com/dimfeld/httptreemux/blob/a454a10de4a11f751681a0914461ab9e98c2a3ff/router.go#L275-L283
|
16,743 |
dimfeld/httptreemux
|
panichandler.go
|
SimplePanicHandler
|
func SimplePanicHandler(w http.ResponseWriter, r *http.Request, err interface{}) {
w.WriteHeader(http.StatusInternalServerError)
}
|
go
|
func SimplePanicHandler(w http.ResponseWriter, r *http.Request, err interface{}) {
w.WriteHeader(http.StatusInternalServerError)
}
|
[
"func",
"SimplePanicHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"err",
"interface",
"{",
"}",
")",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusInternalServerError",
")",
"\n",
"}"
] |
// SimplePanicHandler just returns error 500.
|
[
"SimplePanicHandler",
"just",
"returns",
"error",
"500",
"."
] |
a454a10de4a11f751681a0914461ab9e98c2a3ff
|
https://github.com/dimfeld/httptreemux/blob/a454a10de4a11f751681a0914461ab9e98c2a3ff/panichandler.go#L14-L16
|
16,744 |
dimfeld/httptreemux
|
context.go
|
NewContextGroup
|
func (cg *ContextGroup) NewContextGroup(path string) *ContextGroup {
return &ContextGroup{cg.group.NewGroup(path)}
}
|
go
|
func (cg *ContextGroup) NewContextGroup(path string) *ContextGroup {
return &ContextGroup{cg.group.NewGroup(path)}
}
|
[
"func",
"(",
"cg",
"*",
"ContextGroup",
")",
"NewContextGroup",
"(",
"path",
"string",
")",
"*",
"ContextGroup",
"{",
"return",
"&",
"ContextGroup",
"{",
"cg",
".",
"group",
".",
"NewGroup",
"(",
"path",
")",
"}",
"\n",
"}"
] |
// NewContextGroup adds a child context group to its path.
|
[
"NewContextGroup",
"adds",
"a",
"child",
"context",
"group",
"to",
"its",
"path",
"."
] |
a454a10de4a11f751681a0914461ab9e98c2a3ff
|
https://github.com/dimfeld/httptreemux/blob/a454a10de4a11f751681a0914461ab9e98c2a3ff/context.go#L40-L42
|
16,745 |
dimfeld/httptreemux
|
context.go
|
ContextParams
|
func ContextParams(ctx context.Context) map[string]string {
if p, ok := ctx.Value(paramsContextKey).(map[string]string); ok {
return p
}
return map[string]string{}
}
|
go
|
func ContextParams(ctx context.Context) map[string]string {
if p, ok := ctx.Value(paramsContextKey).(map[string]string); ok {
return p
}
return map[string]string{}
}
|
[
"func",
"ContextParams",
"(",
"ctx",
"context",
".",
"Context",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"if",
"p",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"paramsContextKey",
")",
".",
"(",
"map",
"[",
"string",
"]",
"string",
")",
";",
"ok",
"{",
"return",
"p",
"\n",
"}",
"\n",
"return",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"}"
] |
// ContextParams returns the params map associated with the given context if one exists. Otherwise, an empty map is returned.
|
[
"ContextParams",
"returns",
"the",
"params",
"map",
"associated",
"with",
"the",
"given",
"context",
"if",
"one",
"exists",
".",
"Otherwise",
"an",
"empty",
"map",
"is",
"returned",
"."
] |
a454a10de4a11f751681a0914461ab9e98c2a3ff
|
https://github.com/dimfeld/httptreemux/blob/a454a10de4a11f751681a0914461ab9e98c2a3ff/context.go#L106-L111
|
16,746 |
dimfeld/httptreemux
|
context.go
|
AddParamsToContext
|
func AddParamsToContext(ctx context.Context, params map[string]string) context.Context {
return context.WithValue(ctx, paramsContextKey, params)
}
|
go
|
func AddParamsToContext(ctx context.Context, params map[string]string) context.Context {
return context.WithValue(ctx, paramsContextKey, params)
}
|
[
"func",
"AddParamsToContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"map",
"[",
"string",
"]",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"paramsContextKey",
",",
"params",
")",
"\n",
"}"
] |
// AddParamsToContext inserts a parameters map into a context using
// the package's internal context key. Clients of this package should
// really only use this for unit tests.
|
[
"AddParamsToContext",
"inserts",
"a",
"parameters",
"map",
"into",
"a",
"context",
"using",
"the",
"package",
"s",
"internal",
"context",
"key",
".",
"Clients",
"of",
"this",
"package",
"should",
"really",
"only",
"use",
"this",
"for",
"unit",
"tests",
"."
] |
a454a10de4a11f751681a0914461ab9e98c2a3ff
|
https://github.com/dimfeld/httptreemux/blob/a454a10de4a11f751681a0914461ab9e98c2a3ff/context.go#L116-L118
|
16,747 |
dimfeld/httptreemux
|
treemux_17.go
|
NewContextMux
|
func NewContextMux() *ContextMux {
mux := New()
cg := mux.UsingContext()
return &ContextMux{
TreeMux: mux,
ContextGroup: cg,
}
}
|
go
|
func NewContextMux() *ContextMux {
mux := New()
cg := mux.UsingContext()
return &ContextMux{
TreeMux: mux,
ContextGroup: cg,
}
}
|
[
"func",
"NewContextMux",
"(",
")",
"*",
"ContextMux",
"{",
"mux",
":=",
"New",
"(",
")",
"\n",
"cg",
":=",
"mux",
".",
"UsingContext",
"(",
")",
"\n\n",
"return",
"&",
"ContextMux",
"{",
"TreeMux",
":",
"mux",
",",
"ContextGroup",
":",
"cg",
",",
"}",
"\n",
"}"
] |
// NewContextMux returns a TreeMux preconfigured to work with standard http
// Handler functions and context objects.
|
[
"NewContextMux",
"returns",
"a",
"TreeMux",
"preconfigured",
"to",
"work",
"with",
"standard",
"http",
"Handler",
"functions",
"and",
"context",
"objects",
"."
] |
a454a10de4a11f751681a0914461ab9e98c2a3ff
|
https://github.com/dimfeld/httptreemux/blob/a454a10de4a11f751681a0914461ab9e98c2a3ff/treemux_17.go#L102-L110
|
16,748 |
naoina/toml
|
parse.go
|
Parse
|
func Parse(data []byte) (*ast.Table, error) {
d := &parseState{p: &tomlParser{Buffer: string(data)}}
d.init()
if err := d.parse(); err != nil {
return nil, err
}
return d.p.toml.table, nil
}
|
go
|
func Parse(data []byte) (*ast.Table, error) {
d := &parseState{p: &tomlParser{Buffer: string(data)}}
d.init()
if err := d.parse(); err != nil {
return nil, err
}
return d.p.toml.table, nil
}
|
[
"func",
"Parse",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"*",
"ast",
".",
"Table",
",",
"error",
")",
"{",
"d",
":=",
"&",
"parseState",
"{",
"p",
":",
"&",
"tomlParser",
"{",
"Buffer",
":",
"string",
"(",
"data",
")",
"}",
"}",
"\n",
"d",
".",
"init",
"(",
")",
"\n\n",
"if",
"err",
":=",
"d",
".",
"parse",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"d",
".",
"p",
".",
"toml",
".",
"table",
",",
"nil",
"\n",
"}"
] |
// Parse returns an AST representation of TOML.
// The toplevel is represented by a table.
|
[
"Parse",
"returns",
"an",
"AST",
"representation",
"of",
"TOML",
".",
"The",
"toplevel",
"is",
"represented",
"by",
"a",
"table",
"."
] |
9fafd69674167c06933b1787ae235618431ce87f
|
https://github.com/naoina/toml/blob/9fafd69674167c06933b1787ae235618431ce87f/parse.go#L23-L32
|
16,749 |
naoina/toml
|
decode.go
|
NewDecoder
|
func (cfg *Config) NewDecoder(r io.Reader) *Decoder {
return &Decoder{r, cfg}
}
|
go
|
func (cfg *Config) NewDecoder(r io.Reader) *Decoder {
return &Decoder{r, cfg}
}
|
[
"func",
"(",
"cfg",
"*",
"Config",
")",
"NewDecoder",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Decoder",
"{",
"return",
"&",
"Decoder",
"{",
"r",
",",
"cfg",
"}",
"\n",
"}"
] |
// NewDecoder returns a new Decoder that reads from r.
// Note that it reads all from r before parsing it.
|
[
"NewDecoder",
"returns",
"a",
"new",
"Decoder",
"that",
"reads",
"from",
"r",
".",
"Note",
"that",
"it",
"reads",
"all",
"from",
"r",
"before",
"parsing",
"it",
"."
] |
9fafd69674167c06933b1787ae235618431ce87f
|
https://github.com/naoina/toml/blob/9fafd69674167c06933b1787ae235618431ce87f/decode.go#L69-L71
|
16,750 |
naoina/toml
|
decode.go
|
Decode
|
func (d *Decoder) Decode(v interface{}) error {
b, err := ioutil.ReadAll(d.r)
if err != nil {
return err
}
return d.cfg.Unmarshal(b, v)
}
|
go
|
func (d *Decoder) Decode(v interface{}) error {
b, err := ioutil.ReadAll(d.r)
if err != nil {
return err
}
return d.cfg.Unmarshal(b, v)
}
|
[
"func",
"(",
"d",
"*",
"Decoder",
")",
"Decode",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"d",
".",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"d",
".",
"cfg",
".",
"Unmarshal",
"(",
"b",
",",
"v",
")",
"\n",
"}"
] |
// Decode parses the TOML data from its input and stores it in the value pointed to by v.
// See the documentation for Unmarshal for details about the conversion of TOML into a Go value.
|
[
"Decode",
"parses",
"the",
"TOML",
"data",
"from",
"its",
"input",
"and",
"stores",
"it",
"in",
"the",
"value",
"pointed",
"to",
"by",
"v",
".",
"See",
"the",
"documentation",
"for",
"Unmarshal",
"for",
"details",
"about",
"the",
"conversion",
"of",
"TOML",
"into",
"a",
"Go",
"value",
"."
] |
9fafd69674167c06933b1787ae235618431ce87f
|
https://github.com/naoina/toml/blob/9fafd69674167c06933b1787ae235618431ce87f/decode.go#L75-L81
|
16,751 |
naoina/toml
|
decode.go
|
unmarshalTableOrValue
|
func unmarshalTableOrValue(cfg *Config, rv reflect.Value, av interface{}) error {
if (rv.Kind() != reflect.Ptr && rv.Kind() != reflect.Map) || rv.IsNil() {
return &invalidUnmarshalError{rv.Type()}
}
rv = indirect(rv)
switch av.(type) {
case *ast.KeyValue, *ast.Table, []*ast.Table:
if err := unmarshalField(cfg, rv, av); err != nil {
return lineError(fieldLineNumber(av), err)
}
return nil
case ast.Value:
return setValue(cfg, rv, av.(ast.Value))
default:
panic(fmt.Sprintf("BUG: unhandled AST node type %T", av))
}
}
|
go
|
func unmarshalTableOrValue(cfg *Config, rv reflect.Value, av interface{}) error {
if (rv.Kind() != reflect.Ptr && rv.Kind() != reflect.Map) || rv.IsNil() {
return &invalidUnmarshalError{rv.Type()}
}
rv = indirect(rv)
switch av.(type) {
case *ast.KeyValue, *ast.Table, []*ast.Table:
if err := unmarshalField(cfg, rv, av); err != nil {
return lineError(fieldLineNumber(av), err)
}
return nil
case ast.Value:
return setValue(cfg, rv, av.(ast.Value))
default:
panic(fmt.Sprintf("BUG: unhandled AST node type %T", av))
}
}
|
[
"func",
"unmarshalTableOrValue",
"(",
"cfg",
"*",
"Config",
",",
"rv",
"reflect",
".",
"Value",
",",
"av",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"(",
"rv",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Ptr",
"&&",
"rv",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Map",
")",
"||",
"rv",
".",
"IsNil",
"(",
")",
"{",
"return",
"&",
"invalidUnmarshalError",
"{",
"rv",
".",
"Type",
"(",
")",
"}",
"\n",
"}",
"\n",
"rv",
"=",
"indirect",
"(",
"rv",
")",
"\n\n",
"switch",
"av",
".",
"(",
"type",
")",
"{",
"case",
"*",
"ast",
".",
"KeyValue",
",",
"*",
"ast",
".",
"Table",
",",
"[",
"]",
"*",
"ast",
".",
"Table",
":",
"if",
"err",
":=",
"unmarshalField",
"(",
"cfg",
",",
"rv",
",",
"av",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"lineError",
"(",
"fieldLineNumber",
"(",
"av",
")",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"case",
"ast",
".",
"Value",
":",
"return",
"setValue",
"(",
"cfg",
",",
"rv",
",",
"av",
".",
"(",
"ast",
".",
"Value",
")",
")",
"\n",
"default",
":",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"av",
")",
")",
"\n",
"}",
"\n",
"}"
] |
// used for UnmarshalerRec.
|
[
"used",
"for",
"UnmarshalerRec",
"."
] |
9fafd69674167c06933b1787ae235618431ce87f
|
https://github.com/naoina/toml/blob/9fafd69674167c06933b1787ae235618431ce87f/decode.go#L125-L142
|
16,752 |
naoina/toml
|
encode.go
|
Encode
|
func (e *Encoder) Encode(v interface{}) error {
var (
buf = &tableBuf{typ: ast.TableTypeNormal}
rv = reflect.ValueOf(v)
err error
)
for rv.Kind() == reflect.Ptr {
if rv.IsNil() {
return &marshalNilError{rv.Type()}
}
rv = rv.Elem()
}
switch rv.Kind() {
case reflect.Struct:
err = buf.structFields(e.cfg, rv)
case reflect.Map:
err = buf.mapFields(e.cfg, rv)
case reflect.Interface:
return e.Encode(rv.Interface())
default:
err = &marshalTableError{rv.Type()}
}
if err != nil {
return err
}
return buf.writeTo(e.w, "")
}
|
go
|
func (e *Encoder) Encode(v interface{}) error {
var (
buf = &tableBuf{typ: ast.TableTypeNormal}
rv = reflect.ValueOf(v)
err error
)
for rv.Kind() == reflect.Ptr {
if rv.IsNil() {
return &marshalNilError{rv.Type()}
}
rv = rv.Elem()
}
switch rv.Kind() {
case reflect.Struct:
err = buf.structFields(e.cfg, rv)
case reflect.Map:
err = buf.mapFields(e.cfg, rv)
case reflect.Interface:
return e.Encode(rv.Interface())
default:
err = &marshalTableError{rv.Type()}
}
if err != nil {
return err
}
return buf.writeTo(e.w, "")
}
|
[
"func",
"(",
"e",
"*",
"Encoder",
")",
"Encode",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"(",
"buf",
"=",
"&",
"tableBuf",
"{",
"typ",
":",
"ast",
".",
"TableTypeNormal",
"}",
"\n",
"rv",
"=",
"reflect",
".",
"ValueOf",
"(",
"v",
")",
"\n",
"err",
"error",
"\n",
")",
"\n\n",
"for",
"rv",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Ptr",
"{",
"if",
"rv",
".",
"IsNil",
"(",
")",
"{",
"return",
"&",
"marshalNilError",
"{",
"rv",
".",
"Type",
"(",
")",
"}",
"\n",
"}",
"\n",
"rv",
"=",
"rv",
".",
"Elem",
"(",
")",
"\n",
"}",
"\n\n",
"switch",
"rv",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Struct",
":",
"err",
"=",
"buf",
".",
"structFields",
"(",
"e",
".",
"cfg",
",",
"rv",
")",
"\n",
"case",
"reflect",
".",
"Map",
":",
"err",
"=",
"buf",
".",
"mapFields",
"(",
"e",
".",
"cfg",
",",
"rv",
")",
"\n",
"case",
"reflect",
".",
"Interface",
":",
"return",
"e",
".",
"Encode",
"(",
"rv",
".",
"Interface",
"(",
")",
")",
"\n",
"default",
":",
"err",
"=",
"&",
"marshalTableError",
"{",
"rv",
".",
"Type",
"(",
")",
"}",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"buf",
".",
"writeTo",
"(",
"e",
".",
"w",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
// Encode writes the TOML of v to the stream.
// See the documentation for Marshal for details about the conversion of Go values to TOML.
|
[
"Encode",
"writes",
"the",
"TOML",
"of",
"v",
"to",
"the",
"stream",
".",
"See",
"the",
"documentation",
"for",
"Marshal",
"for",
"details",
"about",
"the",
"conversion",
"of",
"Go",
"values",
"to",
"TOML",
"."
] |
9fafd69674167c06933b1787ae235618431ce87f
|
https://github.com/naoina/toml/blob/9fafd69674167c06933b1787ae235618431ce87f/encode.go#L63-L91
|
16,753 |
assembla/cony
|
consumer.go
|
NewConsumer
|
func NewConsumer(q *Queue, opts ...ConsumerOpt) *Consumer {
c := &Consumer{
q: q,
deliveries: make(chan amqp.Delivery),
errs: make(chan error, 100),
stop: make(chan struct{}),
}
for _, o := range opts {
o(c)
}
return c
}
|
go
|
func NewConsumer(q *Queue, opts ...ConsumerOpt) *Consumer {
c := &Consumer{
q: q,
deliveries: make(chan amqp.Delivery),
errs: make(chan error, 100),
stop: make(chan struct{}),
}
for _, o := range opts {
o(c)
}
return c
}
|
[
"func",
"NewConsumer",
"(",
"q",
"*",
"Queue",
",",
"opts",
"...",
"ConsumerOpt",
")",
"*",
"Consumer",
"{",
"c",
":=",
"&",
"Consumer",
"{",
"q",
":",
"q",
",",
"deliveries",
":",
"make",
"(",
"chan",
"amqp",
".",
"Delivery",
")",
",",
"errs",
":",
"make",
"(",
"chan",
"error",
",",
"100",
")",
",",
"stop",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"opts",
"{",
"o",
"(",
"c",
")",
"\n",
"}",
"\n",
"return",
"c",
"\n",
"}"
] |
// NewConsumer Consumer's constructor
|
[
"NewConsumer",
"Consumer",
"s",
"constructor"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/consumer.go#L98-L109
|
16,754 |
assembla/cony
|
consumer.go
|
AutoTag
|
func AutoTag() ConsumerOpt {
return func(c *Consumer) {
host, _ := os.Hostname()
tag := fmt.Sprintf(c.q.Name+"-pid-%d@%s", os.Getpid(), host)
Tag(tag)(c)
}
}
|
go
|
func AutoTag() ConsumerOpt {
return func(c *Consumer) {
host, _ := os.Hostname()
tag := fmt.Sprintf(c.q.Name+"-pid-%d@%s", os.Getpid(), host)
Tag(tag)(c)
}
}
|
[
"func",
"AutoTag",
"(",
")",
"ConsumerOpt",
"{",
"return",
"func",
"(",
"c",
"*",
"Consumer",
")",
"{",
"host",
",",
"_",
":=",
"os",
".",
"Hostname",
"(",
")",
"\n",
"tag",
":=",
"fmt",
".",
"Sprintf",
"(",
"c",
".",
"q",
".",
"Name",
"+",
"\"",
"\"",
",",
"os",
".",
"Getpid",
"(",
")",
",",
"host",
")",
"\n",
"Tag",
"(",
"tag",
")",
"(",
"c",
")",
"\n",
"}",
"\n",
"}"
] |
// AutoTag set automatically generated tag like this
// fmt.Sprintf(QueueName+"-pid-%d@%s", os.Getpid(), os.Hostname())
|
[
"AutoTag",
"set",
"automatically",
"generated",
"tag",
"like",
"this",
"fmt",
".",
"Sprintf",
"(",
"QueueName",
"+",
"-",
"pid",
"-",
"%d"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/consumer.go#L127-L133
|
16,755 |
assembla/cony
|
publisher.go
|
Cancel
|
func (p *Publisher) Cancel() {
p.m.Lock()
defer p.m.Unlock()
if !p.dead {
close(p.stop)
p.dead = true
}
}
|
go
|
func (p *Publisher) Cancel() {
p.m.Lock()
defer p.m.Unlock()
if !p.dead {
close(p.stop)
p.dead = true
}
}
|
[
"func",
"(",
"p",
"*",
"Publisher",
")",
"Cancel",
"(",
")",
"{",
"p",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"!",
"p",
".",
"dead",
"{",
"close",
"(",
"p",
".",
"stop",
")",
"\n",
"p",
".",
"dead",
"=",
"true",
"\n",
"}",
"\n",
"}"
] |
// Cancel this publisher
|
[
"Cancel",
"this",
"publisher"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/publisher.go#L80-L88
|
16,756 |
assembla/cony
|
publisher.go
|
NewPublisher
|
func NewPublisher(exchange string, key string, opts ...PublisherOpt) *Publisher {
p := &Publisher{
exchange: exchange,
key: key,
pubChan: make(chan publishMaybeErr),
stop: make(chan struct{}),
}
for _, o := range opts {
o(p)
}
return p
}
|
go
|
func NewPublisher(exchange string, key string, opts ...PublisherOpt) *Publisher {
p := &Publisher{
exchange: exchange,
key: key,
pubChan: make(chan publishMaybeErr),
stop: make(chan struct{}),
}
for _, o := range opts {
o(p)
}
return p
}
|
[
"func",
"NewPublisher",
"(",
"exchange",
"string",
",",
"key",
"string",
",",
"opts",
"...",
"PublisherOpt",
")",
"*",
"Publisher",
"{",
"p",
":=",
"&",
"Publisher",
"{",
"exchange",
":",
"exchange",
",",
"key",
":",
"key",
",",
"pubChan",
":",
"make",
"(",
"chan",
"publishMaybeErr",
")",
",",
"stop",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"opts",
"{",
"o",
"(",
"p",
")",
"\n",
"}",
"\n",
"return",
"p",
"\n",
"}"
] |
// NewPublisher is a Publisher constructor
|
[
"NewPublisher",
"is",
"a",
"Publisher",
"constructor"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/publisher.go#L120-L131
|
16,757 |
assembla/cony
|
publisher.go
|
PublishingTemplate
|
func PublishingTemplate(t amqp.Publishing) PublisherOpt {
return func(p *Publisher) {
p.tmpl = t
}
}
|
go
|
func PublishingTemplate(t amqp.Publishing) PublisherOpt {
return func(p *Publisher) {
p.tmpl = t
}
}
|
[
"func",
"PublishingTemplate",
"(",
"t",
"amqp",
".",
"Publishing",
")",
"PublisherOpt",
"{",
"return",
"func",
"(",
"p",
"*",
"Publisher",
")",
"{",
"p",
".",
"tmpl",
"=",
"t",
"\n",
"}",
"\n",
"}"
] |
// PublishingTemplate Publisher's functional option. Provide template
// amqp.Publishing and save typing.
|
[
"PublishingTemplate",
"Publisher",
"s",
"functional",
"option",
".",
"Provide",
"template",
"amqp",
".",
"Publishing",
"and",
"save",
"typing",
"."
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/publisher.go#L135-L139
|
16,758 |
assembla/cony
|
declaration.go
|
DeclareQueue
|
func DeclareQueue(q *Queue) Declaration {
name := q.Name
return func(c Declarer) error {
q.Name = name
realQ, err := c.QueueDeclare(q.Name,
q.Durable,
q.AutoDelete,
q.Exclusive,
false,
q.Args,
)
q.l.Lock()
q.Name = realQ.Name
q.l.Unlock()
return err
}
}
|
go
|
func DeclareQueue(q *Queue) Declaration {
name := q.Name
return func(c Declarer) error {
q.Name = name
realQ, err := c.QueueDeclare(q.Name,
q.Durable,
q.AutoDelete,
q.Exclusive,
false,
q.Args,
)
q.l.Lock()
q.Name = realQ.Name
q.l.Unlock()
return err
}
}
|
[
"func",
"DeclareQueue",
"(",
"q",
"*",
"Queue",
")",
"Declaration",
"{",
"name",
":=",
"q",
".",
"Name",
"\n",
"return",
"func",
"(",
"c",
"Declarer",
")",
"error",
"{",
"q",
".",
"Name",
"=",
"name",
"\n",
"realQ",
",",
"err",
":=",
"c",
".",
"QueueDeclare",
"(",
"q",
".",
"Name",
",",
"q",
".",
"Durable",
",",
"q",
".",
"AutoDelete",
",",
"q",
".",
"Exclusive",
",",
"false",
",",
"q",
".",
"Args",
",",
")",
"\n",
"q",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"q",
".",
"Name",
"=",
"realQ",
".",
"Name",
"\n",
"q",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"}"
] |
// DeclareQueue is a way to declare AMQP queue
|
[
"DeclareQueue",
"is",
"a",
"way",
"to",
"declare",
"AMQP",
"queue"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/declaration.go#L16-L32
|
16,759 |
assembla/cony
|
declaration.go
|
DeclareExchange
|
func DeclareExchange(e Exchange) Declaration {
return func(c Declarer) error {
return c.ExchangeDeclare(e.Name,
e.Kind,
e.Durable,
e.AutoDelete,
false,
false,
e.Args,
)
}
}
|
go
|
func DeclareExchange(e Exchange) Declaration {
return func(c Declarer) error {
return c.ExchangeDeclare(e.Name,
e.Kind,
e.Durable,
e.AutoDelete,
false,
false,
e.Args,
)
}
}
|
[
"func",
"DeclareExchange",
"(",
"e",
"Exchange",
")",
"Declaration",
"{",
"return",
"func",
"(",
"c",
"Declarer",
")",
"error",
"{",
"return",
"c",
".",
"ExchangeDeclare",
"(",
"e",
".",
"Name",
",",
"e",
".",
"Kind",
",",
"e",
".",
"Durable",
",",
"e",
".",
"AutoDelete",
",",
"false",
",",
"false",
",",
"e",
".",
"Args",
",",
")",
"\n",
"}",
"\n",
"}"
] |
// DeclareExchange is a way to declare AMQP exchange
|
[
"DeclareExchange",
"is",
"a",
"way",
"to",
"declare",
"AMQP",
"exchange"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/declaration.go#L35-L46
|
16,760 |
assembla/cony
|
declaration.go
|
DeclareBinding
|
func DeclareBinding(b Binding) Declaration {
return func(c Declarer) error {
return c.QueueBind(b.Queue.Name,
b.Key,
b.Exchange.Name,
false,
b.Args,
)
}
}
|
go
|
func DeclareBinding(b Binding) Declaration {
return func(c Declarer) error {
return c.QueueBind(b.Queue.Name,
b.Key,
b.Exchange.Name,
false,
b.Args,
)
}
}
|
[
"func",
"DeclareBinding",
"(",
"b",
"Binding",
")",
"Declaration",
"{",
"return",
"func",
"(",
"c",
"Declarer",
")",
"error",
"{",
"return",
"c",
".",
"QueueBind",
"(",
"b",
".",
"Queue",
".",
"Name",
",",
"b",
".",
"Key",
",",
"b",
".",
"Exchange",
".",
"Name",
",",
"false",
",",
"b",
".",
"Args",
",",
")",
"\n",
"}",
"\n",
"}"
] |
// DeclareBinding is a way to declare AMQP binding between AMQP queue and exchange
|
[
"DeclareBinding",
"is",
"a",
"way",
"to",
"declare",
"AMQP",
"binding",
"between",
"AMQP",
"queue",
"and",
"exchange"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/declaration.go#L49-L58
|
16,761 |
assembla/cony
|
backoff.go
|
Backoff
|
func (b BackoffPolicy) Backoff(n int) time.Duration {
if n >= len(b.ms) {
n = len(b.ms) - 1
}
return time.Duration(jitter(b.ms[n])) * time.Millisecond
}
|
go
|
func (b BackoffPolicy) Backoff(n int) time.Duration {
if n >= len(b.ms) {
n = len(b.ms) - 1
}
return time.Duration(jitter(b.ms[n])) * time.Millisecond
}
|
[
"func",
"(",
"b",
"BackoffPolicy",
")",
"Backoff",
"(",
"n",
"int",
")",
"time",
".",
"Duration",
"{",
"if",
"n",
">=",
"len",
"(",
"b",
".",
"ms",
")",
"{",
"n",
"=",
"len",
"(",
"b",
".",
"ms",
")",
"-",
"1",
"\n",
"}",
"\n\n",
"return",
"time",
".",
"Duration",
"(",
"jitter",
"(",
"b",
".",
"ms",
"[",
"n",
"]",
")",
")",
"*",
"time",
".",
"Millisecond",
"\n",
"}"
] |
// Backoff implements Backoffer
|
[
"Backoff",
"implements",
"Backoffer"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/backoff.go#L24-L30
|
16,762 |
assembla/cony
|
client.go
|
Consume
|
func (c *Client) Consume(cons *Consumer) {
c.l.Lock()
defer c.l.Unlock()
c.consumers[cons] = struct{}{}
if ch, err := c.channel(); err == nil {
go cons.serve(c, ch)
}
}
|
go
|
func (c *Client) Consume(cons *Consumer) {
c.l.Lock()
defer c.l.Unlock()
c.consumers[cons] = struct{}{}
if ch, err := c.channel(); err == nil {
go cons.serve(c, ch)
}
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"Consume",
"(",
"cons",
"*",
"Consumer",
")",
"{",
"c",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"consumers",
"[",
"cons",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"if",
"ch",
",",
"err",
":=",
"c",
".",
"channel",
"(",
")",
";",
"err",
"==",
"nil",
"{",
"go",
"cons",
".",
"serve",
"(",
"c",
",",
"ch",
")",
"\n",
"}",
"\n",
"}"
] |
// Consume used to declare consumers
|
[
"Consume",
"used",
"to",
"declare",
"consumers"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/client.go#L56-L63
|
16,763 |
assembla/cony
|
client.go
|
Publish
|
func (c *Client) Publish(pub *Publisher) {
c.l.Lock()
defer c.l.Unlock()
c.publishers[pub] = struct{}{}
if ch, err := c.channel(); err == nil {
go pub.serve(c, ch)
}
}
|
go
|
func (c *Client) Publish(pub *Publisher) {
c.l.Lock()
defer c.l.Unlock()
c.publishers[pub] = struct{}{}
if ch, err := c.channel(); err == nil {
go pub.serve(c, ch)
}
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"Publish",
"(",
"pub",
"*",
"Publisher",
")",
"{",
"c",
".",
"l",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"l",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"publishers",
"[",
"pub",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"if",
"ch",
",",
"err",
":=",
"c",
".",
"channel",
"(",
")",
";",
"err",
"==",
"nil",
"{",
"go",
"pub",
".",
"serve",
"(",
"c",
",",
"ch",
")",
"\n",
"}",
"\n",
"}"
] |
// Publish used to declare publishers
|
[
"Publish",
"used",
"to",
"declare",
"publishers"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/client.go#L72-L79
|
16,764 |
assembla/cony
|
client.go
|
Close
|
func (c *Client) Close() {
atomic.StoreInt32(&c.run, noRun) // c.run = false
conn, _ := c.conn.Load().(*amqp.Connection)
if conn != nil {
conn.Close()
}
c.conn.Store((*amqp.Connection)(nil))
}
|
go
|
func (c *Client) Close() {
atomic.StoreInt32(&c.run, noRun) // c.run = false
conn, _ := c.conn.Load().(*amqp.Connection)
if conn != nil {
conn.Close()
}
c.conn.Store((*amqp.Connection)(nil))
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"Close",
"(",
")",
"{",
"atomic",
".",
"StoreInt32",
"(",
"&",
"c",
".",
"run",
",",
"noRun",
")",
"// c.run = false",
"\n",
"conn",
",",
"_",
":=",
"c",
".",
"conn",
".",
"Load",
"(",
")",
".",
"(",
"*",
"amqp",
".",
"Connection",
")",
"\n",
"if",
"conn",
"!=",
"nil",
"{",
"conn",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"c",
".",
"conn",
".",
"Store",
"(",
"(",
"*",
"amqp",
".",
"Connection",
")",
"(",
"nil",
")",
")",
"\n",
"}"
] |
// Close shutdown the client
|
[
"Close",
"shutdown",
"the",
"client"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/client.go#L100-L107
|
16,765 |
assembla/cony
|
client.go
|
NewClient
|
func NewClient(opts ...ClientOpt) *Client {
c := &Client{
run: run,
declarations: make([]Declaration, 0),
consumers: make(map[*Consumer]struct{}),
publishers: make(map[*Publisher]struct{}),
errs: make(chan error, 100),
blocking: make(chan amqp.Blocking, 10),
}
for _, o := range opts {
o(c)
}
return c
}
|
go
|
func NewClient(opts ...ClientOpt) *Client {
c := &Client{
run: run,
declarations: make([]Declaration, 0),
consumers: make(map[*Consumer]struct{}),
publishers: make(map[*Publisher]struct{}),
errs: make(chan error, 100),
blocking: make(chan amqp.Blocking, 10),
}
for _, o := range opts {
o(c)
}
return c
}
|
[
"func",
"NewClient",
"(",
"opts",
"...",
"ClientOpt",
")",
"*",
"Client",
"{",
"c",
":=",
"&",
"Client",
"{",
"run",
":",
"run",
",",
"declarations",
":",
"make",
"(",
"[",
"]",
"Declaration",
",",
"0",
")",
",",
"consumers",
":",
"make",
"(",
"map",
"[",
"*",
"Consumer",
"]",
"struct",
"{",
"}",
")",
",",
"publishers",
":",
"make",
"(",
"map",
"[",
"*",
"Publisher",
"]",
"struct",
"{",
"}",
")",
",",
"errs",
":",
"make",
"(",
"chan",
"error",
",",
"100",
")",
",",
"blocking",
":",
"make",
"(",
"chan",
"amqp",
".",
"Blocking",
",",
"10",
")",
",",
"}",
"\n\n",
"for",
"_",
",",
"o",
":=",
"range",
"opts",
"{",
"o",
"(",
"c",
")",
"\n",
"}",
"\n",
"return",
"c",
"\n",
"}"
] |
// NewClient initializes new Client
|
[
"NewClient",
"initializes",
"new",
"Client"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/client.go#L232-L246
|
16,766 |
assembla/cony
|
client.go
|
BlockingChan
|
func BlockingChan(blockingChan chan amqp.Blocking) ClientOpt {
return func(c *Client) {
c.blocking = blockingChan
}
}
|
go
|
func BlockingChan(blockingChan chan amqp.Blocking) ClientOpt {
return func(c *Client) {
c.blocking = blockingChan
}
}
|
[
"func",
"BlockingChan",
"(",
"blockingChan",
"chan",
"amqp",
".",
"Blocking",
")",
"ClientOpt",
"{",
"return",
"func",
"(",
"c",
"*",
"Client",
")",
"{",
"c",
".",
"blocking",
"=",
"blockingChan",
"\n",
"}",
"\n",
"}"
] |
// BlockingChan is a functional option, used to initialize blocking reporting
// channel in client code, maintaining control over buffering, used in
// `NewClient` constructor
|
[
"BlockingChan",
"is",
"a",
"functional",
"option",
"used",
"to",
"initialize",
"blocking",
"reporting",
"channel",
"in",
"client",
"code",
"maintaining",
"control",
"over",
"buffering",
"used",
"in",
"NewClient",
"constructor"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/client.go#L280-L284
|
16,767 |
assembla/cony
|
client.go
|
Config
|
func Config(config amqp.Config) ClientOpt {
return func(c *Client) {
c.config = config
}
}
|
go
|
func Config(config amqp.Config) ClientOpt {
return func(c *Client) {
c.config = config
}
}
|
[
"func",
"Config",
"(",
"config",
"amqp",
".",
"Config",
")",
"ClientOpt",
"{",
"return",
"func",
"(",
"c",
"*",
"Client",
")",
"{",
"c",
".",
"config",
"=",
"config",
"\n",
"}",
"\n",
"}"
] |
// Config is a functional option, used to setup extended amqp configuration
|
[
"Config",
"is",
"a",
"functional",
"option",
"used",
"to",
"setup",
"extended",
"amqp",
"configuration"
] |
dd62697b0adb9adfda8589520cb85f4cbc2361f1
|
https://github.com/assembla/cony/blob/dd62697b0adb9adfda8589520cb85f4cbc2361f1/client.go#L287-L291
|
16,768 |
toorop/gin-logrus
|
logger.go
|
Logger
|
func Logger(log *logrus.Logger) gin.HandlerFunc {
hostname, err := os.Hostname()
if err != nil {
hostname = "unknow"
}
return func(c *gin.Context) {
// other handler can change c.Path so:
path := c.Request.URL.Path
start := time.Now()
c.Next()
stop := time.Since(start)
latency := int(math.Ceil(float64(stop.Nanoseconds()) / 1000000.0))
statusCode := c.Writer.Status()
clientIP := c.ClientIP()
clientUserAgent := c.Request.UserAgent()
referer := c.Request.Referer()
dataLength := c.Writer.Size()
if dataLength < 0 {
dataLength = 0
}
entry := logrus.NewEntry(log).WithFields(logrus.Fields{
"hostname": hostname,
"statusCode": statusCode,
"latency": latency, // time to process
"clientIP": clientIP,
"method": c.Request.Method,
"path": path,
"referer": referer,
"dataLength": dataLength,
"userAgent": clientUserAgent,
})
if len(c.Errors) > 0 {
entry.Error(c.Errors.ByType(gin.ErrorTypePrivate).String())
} else {
msg := fmt.Sprintf("%s - %s [%s] \"%s %s\" %d %d \"%s\" \"%s\" (%dms)", clientIP, hostname, time.Now().Format(timeFormat), c.Request.Method, path, statusCode, dataLength, referer, clientUserAgent, latency)
if statusCode > 499 {
entry.Error(msg)
} else if statusCode > 399 {
entry.Warn(msg)
} else {
entry.Info(msg)
}
}
}
}
|
go
|
func Logger(log *logrus.Logger) gin.HandlerFunc {
hostname, err := os.Hostname()
if err != nil {
hostname = "unknow"
}
return func(c *gin.Context) {
// other handler can change c.Path so:
path := c.Request.URL.Path
start := time.Now()
c.Next()
stop := time.Since(start)
latency := int(math.Ceil(float64(stop.Nanoseconds()) / 1000000.0))
statusCode := c.Writer.Status()
clientIP := c.ClientIP()
clientUserAgent := c.Request.UserAgent()
referer := c.Request.Referer()
dataLength := c.Writer.Size()
if dataLength < 0 {
dataLength = 0
}
entry := logrus.NewEntry(log).WithFields(logrus.Fields{
"hostname": hostname,
"statusCode": statusCode,
"latency": latency, // time to process
"clientIP": clientIP,
"method": c.Request.Method,
"path": path,
"referer": referer,
"dataLength": dataLength,
"userAgent": clientUserAgent,
})
if len(c.Errors) > 0 {
entry.Error(c.Errors.ByType(gin.ErrorTypePrivate).String())
} else {
msg := fmt.Sprintf("%s - %s [%s] \"%s %s\" %d %d \"%s\" \"%s\" (%dms)", clientIP, hostname, time.Now().Format(timeFormat), c.Request.Method, path, statusCode, dataLength, referer, clientUserAgent, latency)
if statusCode > 499 {
entry.Error(msg)
} else if statusCode > 399 {
entry.Warn(msg)
} else {
entry.Info(msg)
}
}
}
}
|
[
"func",
"Logger",
"(",
"log",
"*",
"logrus",
".",
"Logger",
")",
"gin",
".",
"HandlerFunc",
"{",
"hostname",
",",
"err",
":=",
"os",
".",
"Hostname",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"hostname",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"func",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"{",
"// other handler can change c.Path so:",
"path",
":=",
"c",
".",
"Request",
".",
"URL",
".",
"Path",
"\n",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"c",
".",
"Next",
"(",
")",
"\n",
"stop",
":=",
"time",
".",
"Since",
"(",
"start",
")",
"\n",
"latency",
":=",
"int",
"(",
"math",
".",
"Ceil",
"(",
"float64",
"(",
"stop",
".",
"Nanoseconds",
"(",
")",
")",
"/",
"1000000.0",
")",
")",
"\n",
"statusCode",
":=",
"c",
".",
"Writer",
".",
"Status",
"(",
")",
"\n",
"clientIP",
":=",
"c",
".",
"ClientIP",
"(",
")",
"\n",
"clientUserAgent",
":=",
"c",
".",
"Request",
".",
"UserAgent",
"(",
")",
"\n",
"referer",
":=",
"c",
".",
"Request",
".",
"Referer",
"(",
")",
"\n",
"dataLength",
":=",
"c",
".",
"Writer",
".",
"Size",
"(",
")",
"\n",
"if",
"dataLength",
"<",
"0",
"{",
"dataLength",
"=",
"0",
"\n",
"}",
"\n\n",
"entry",
":=",
"logrus",
".",
"NewEntry",
"(",
"log",
")",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"\"",
"\"",
":",
"hostname",
",",
"\"",
"\"",
":",
"statusCode",
",",
"\"",
"\"",
":",
"latency",
",",
"// time to process",
"\"",
"\"",
":",
"clientIP",
",",
"\"",
"\"",
":",
"c",
".",
"Request",
".",
"Method",
",",
"\"",
"\"",
":",
"path",
",",
"\"",
"\"",
":",
"referer",
",",
"\"",
"\"",
":",
"dataLength",
",",
"\"",
"\"",
":",
"clientUserAgent",
",",
"}",
")",
"\n\n",
"if",
"len",
"(",
"c",
".",
"Errors",
")",
">",
"0",
"{",
"entry",
".",
"Error",
"(",
"c",
".",
"Errors",
".",
"ByType",
"(",
"gin",
".",
"ErrorTypePrivate",
")",
".",
"String",
"(",
")",
")",
"\n",
"}",
"else",
"{",
"msg",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\"",
",",
"clientIP",
",",
"hostname",
",",
"time",
".",
"Now",
"(",
")",
".",
"Format",
"(",
"timeFormat",
")",
",",
"c",
".",
"Request",
".",
"Method",
",",
"path",
",",
"statusCode",
",",
"dataLength",
",",
"referer",
",",
"clientUserAgent",
",",
"latency",
")",
"\n",
"if",
"statusCode",
">",
"499",
"{",
"entry",
".",
"Error",
"(",
"msg",
")",
"\n",
"}",
"else",
"if",
"statusCode",
">",
"399",
"{",
"entry",
".",
"Warn",
"(",
"msg",
")",
"\n",
"}",
"else",
"{",
"entry",
".",
"Info",
"(",
"msg",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// Logger is the logrus logger handler
|
[
"Logger",
"is",
"the",
"logrus",
"logger",
"handler"
] |
8887861896bb12c1d88aff1a93536f1a42226c29
|
https://github.com/toorop/gin-logrus/blob/8887861896bb12c1d88aff1a93536f1a42226c29/logger.go#L22-L68
|
16,769 |
RobotsAndPencils/go-saml
|
authnrequest.go
|
GetAuthnRequest
|
func (s *ServiceProviderSettings) GetAuthnRequest() *AuthnRequest {
r := NewAuthnRequest()
r.AssertionConsumerServiceURL = s.AssertionConsumerServiceURL
r.Destination = s.IDPSSOURL
r.Issuer.Url = s.IDPSSODescriptorURL
r.Signature.KeyInfo.X509Data.X509Certificate.Cert = s.PublicCert()
if !s.SPSignRequest {
r.SAMLSIG = ""
r.Signature = nil
}
return r
}
|
go
|
func (s *ServiceProviderSettings) GetAuthnRequest() *AuthnRequest {
r := NewAuthnRequest()
r.AssertionConsumerServiceURL = s.AssertionConsumerServiceURL
r.Destination = s.IDPSSOURL
r.Issuer.Url = s.IDPSSODescriptorURL
r.Signature.KeyInfo.X509Data.X509Certificate.Cert = s.PublicCert()
if !s.SPSignRequest {
r.SAMLSIG = ""
r.Signature = nil
}
return r
}
|
[
"func",
"(",
"s",
"*",
"ServiceProviderSettings",
")",
"GetAuthnRequest",
"(",
")",
"*",
"AuthnRequest",
"{",
"r",
":=",
"NewAuthnRequest",
"(",
")",
"\n",
"r",
".",
"AssertionConsumerServiceURL",
"=",
"s",
".",
"AssertionConsumerServiceURL",
"\n",
"r",
".",
"Destination",
"=",
"s",
".",
"IDPSSOURL",
"\n",
"r",
".",
"Issuer",
".",
"Url",
"=",
"s",
".",
"IDPSSODescriptorURL",
"\n",
"r",
".",
"Signature",
".",
"KeyInfo",
".",
"X509Data",
".",
"X509Certificate",
".",
"Cert",
"=",
"s",
".",
"PublicCert",
"(",
")",
"\n\n",
"if",
"!",
"s",
".",
"SPSignRequest",
"{",
"r",
".",
"SAMLSIG",
"=",
"\"",
"\"",
"\n",
"r",
".",
"Signature",
"=",
"nil",
"\n",
"}",
"\n\n",
"return",
"r",
"\n",
"}"
] |
// GetSignedAuthnRequest returns a singed XML document that represents a AuthnRequest SAML document
|
[
"GetSignedAuthnRequest",
"returns",
"a",
"singed",
"XML",
"document",
"that",
"represents",
"a",
"AuthnRequest",
"SAML",
"document"
] |
fb13cb52a46b55a9f20e6d497658dd494c7c1ef1
|
https://github.com/RobotsAndPencils/go-saml/blob/fb13cb52a46b55a9f20e6d497658dd494c7c1ef1/authnrequest.go#L84-L97
|
16,770 |
RobotsAndPencils/go-saml
|
authnrequest.go
|
GetAuthnRequestURL
|
func GetAuthnRequestURL(baseURL string, b64XML string, state string) (string, error) {
u, err := url.Parse(baseURL)
if err != nil {
return "", err
}
q := u.Query()
q.Add("SAMLRequest", b64XML)
q.Add("RelayState", state)
u.RawQuery = q.Encode()
return u.String(), nil
}
|
go
|
func GetAuthnRequestURL(baseURL string, b64XML string, state string) (string, error) {
u, err := url.Parse(baseURL)
if err != nil {
return "", err
}
q := u.Query()
q.Add("SAMLRequest", b64XML)
q.Add("RelayState", state)
u.RawQuery = q.Encode()
return u.String(), nil
}
|
[
"func",
"GetAuthnRequestURL",
"(",
"baseURL",
"string",
",",
"b64XML",
"string",
",",
"state",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"baseURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"q",
":=",
"u",
".",
"Query",
"(",
")",
"\n",
"q",
".",
"Add",
"(",
"\"",
"\"",
",",
"b64XML",
")",
"\n",
"q",
".",
"Add",
"(",
"\"",
"\"",
",",
"state",
")",
"\n",
"u",
".",
"RawQuery",
"=",
"q",
".",
"Encode",
"(",
")",
"\n",
"return",
"u",
".",
"String",
"(",
")",
",",
"nil",
"\n",
"}"
] |
// GetAuthnRequestURL generate a URL for the AuthnRequest to the IdP with the SAMLRequst parameter encoded
|
[
"GetAuthnRequestURL",
"generate",
"a",
"URL",
"for",
"the",
"AuthnRequest",
"to",
"the",
"IdP",
"with",
"the",
"SAMLRequst",
"parameter",
"encoded"
] |
fb13cb52a46b55a9f20e6d497658dd494c7c1ef1
|
https://github.com/RobotsAndPencils/go-saml/blob/fb13cb52a46b55a9f20e6d497658dd494c7c1ef1/authnrequest.go#L100-L111
|
16,771 |
RobotsAndPencils/go-saml
|
util/loadCertificate.go
|
LoadCertificate
|
func LoadCertificate(certPath string) (string, error) {
b, err := ioutil.ReadFile(certPath)
if err != nil {
return "", err
}
cert := string(b)
re := regexp.MustCompile("---(.*)CERTIFICATE(.*)---")
cert = re.ReplaceAllString(cert, "")
cert = strings.Trim(cert, " \n")
cert = strings.Replace(cert, "\n", "", -1)
return cert, nil
}
|
go
|
func LoadCertificate(certPath string) (string, error) {
b, err := ioutil.ReadFile(certPath)
if err != nil {
return "", err
}
cert := string(b)
re := regexp.MustCompile("---(.*)CERTIFICATE(.*)---")
cert = re.ReplaceAllString(cert, "")
cert = strings.Trim(cert, " \n")
cert = strings.Replace(cert, "\n", "", -1)
return cert, nil
}
|
[
"func",
"LoadCertificate",
"(",
"certPath",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"certPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"cert",
":=",
"string",
"(",
"b",
")",
"\n\n",
"re",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"",
"\"",
")",
"\n",
"cert",
"=",
"re",
".",
"ReplaceAllString",
"(",
"cert",
",",
"\"",
"\"",
")",
"\n",
"cert",
"=",
"strings",
".",
"Trim",
"(",
"cert",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"cert",
"=",
"strings",
".",
"Replace",
"(",
"cert",
",",
"\"",
"\\n",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n\n",
"return",
"cert",
",",
"nil",
"\n",
"}"
] |
// LoadCertificate from file system
|
[
"LoadCertificate",
"from",
"file",
"system"
] |
fb13cb52a46b55a9f20e6d497658dd494c7c1ef1
|
https://github.com/RobotsAndPencils/go-saml/blob/fb13cb52a46b55a9f20e6d497658dd494c7c1ef1/util/loadCertificate.go#L10-L23
|
16,772 |
RobotsAndPencils/go-saml
|
util/id.go
|
ID
|
func ID() string {
u, err := uuid.NewV4()
if err != nil {
panic(err)
}
return "_" + u.String()
}
|
go
|
func ID() string {
u, err := uuid.NewV4()
if err != nil {
panic(err)
}
return "_" + u.String()
}
|
[
"func",
"ID",
"(",
")",
"string",
"{",
"u",
",",
"err",
":=",
"uuid",
".",
"NewV4",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"+",
"u",
".",
"String",
"(",
")",
"\n",
"}"
] |
// UUID generate a new V4 UUID
|
[
"UUID",
"generate",
"a",
"new",
"V4",
"UUID"
] |
fb13cb52a46b55a9f20e6d497658dd494c7c1ef1
|
https://github.com/RobotsAndPencils/go-saml/blob/fb13cb52a46b55a9f20e6d497658dd494c7c1ef1/util/id.go#L6-L12
|
16,773 |
RobotsAndPencils/go-saml
|
authnresponse.go
|
AddAttribute
|
func (r *Response) AddAttribute(name, value string) {
r.Assertion.AttributeStatement.Attributes = append(r.Assertion.AttributeStatement.Attributes, Attribute{
XMLName: xml.Name{
Local: "saml:Attribute",
},
Name: name,
NameFormat: "urn:oasis:names:tc:SAML:2.0:attrname-format:basic",
AttributeValues: []AttributeValue{
{
XMLName: xml.Name{
Local: "saml:AttributeValue",
},
Type: "xs:string",
Value: value,
},
},
})
}
|
go
|
func (r *Response) AddAttribute(name, value string) {
r.Assertion.AttributeStatement.Attributes = append(r.Assertion.AttributeStatement.Attributes, Attribute{
XMLName: xml.Name{
Local: "saml:Attribute",
},
Name: name,
NameFormat: "urn:oasis:names:tc:SAML:2.0:attrname-format:basic",
AttributeValues: []AttributeValue{
{
XMLName: xml.Name{
Local: "saml:AttributeValue",
},
Type: "xs:string",
Value: value,
},
},
})
}
|
[
"func",
"(",
"r",
"*",
"Response",
")",
"AddAttribute",
"(",
"name",
",",
"value",
"string",
")",
"{",
"r",
".",
"Assertion",
".",
"AttributeStatement",
".",
"Attributes",
"=",
"append",
"(",
"r",
".",
"Assertion",
".",
"AttributeStatement",
".",
"Attributes",
",",
"Attribute",
"{",
"XMLName",
":",
"xml",
".",
"Name",
"{",
"Local",
":",
"\"",
"\"",
",",
"}",
",",
"Name",
":",
"name",
",",
"NameFormat",
":",
"\"",
"\"",
",",
"AttributeValues",
":",
"[",
"]",
"AttributeValue",
"{",
"{",
"XMLName",
":",
"xml",
".",
"Name",
"{",
"Local",
":",
"\"",
"\"",
",",
"}",
",",
"Type",
":",
"\"",
"\"",
",",
"Value",
":",
"value",
",",
"}",
",",
"}",
",",
"}",
")",
"\n",
"}"
] |
// AddAttribute add strong attribute to the Response
|
[
"AddAttribute",
"add",
"strong",
"attribute",
"to",
"the",
"Response"
] |
fb13cb52a46b55a9f20e6d497658dd494c7c1ef1
|
https://github.com/RobotsAndPencils/go-saml/blob/fb13cb52a46b55a9f20e6d497658dd494c7c1ef1/authnresponse.go#L259-L276
|
16,774 |
RobotsAndPencils/go-saml
|
authnresponse.go
|
GetAttribute
|
func (r *Response) GetAttribute(name string) string {
for _, attr := range r.Assertion.AttributeStatement.Attributes {
if attr.Name == name || attr.FriendlyName == name {
return attr.AttributeValues[0].Value
}
}
return ""
}
|
go
|
func (r *Response) GetAttribute(name string) string {
for _, attr := range r.Assertion.AttributeStatement.Attributes {
if attr.Name == name || attr.FriendlyName == name {
return attr.AttributeValues[0].Value
}
}
return ""
}
|
[
"func",
"(",
"r",
"*",
"Response",
")",
"GetAttribute",
"(",
"name",
"string",
")",
"string",
"{",
"for",
"_",
",",
"attr",
":=",
"range",
"r",
".",
"Assertion",
".",
"AttributeStatement",
".",
"Attributes",
"{",
"if",
"attr",
".",
"Name",
"==",
"name",
"||",
"attr",
".",
"FriendlyName",
"==",
"name",
"{",
"return",
"attr",
".",
"AttributeValues",
"[",
"0",
"]",
".",
"Value",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
// GetAttribute by Name or by FriendlyName. Return blank string if not found
|
[
"GetAttribute",
"by",
"Name",
"or",
"by",
"FriendlyName",
".",
"Return",
"blank",
"string",
"if",
"not",
"found"
] |
fb13cb52a46b55a9f20e6d497658dd494c7c1ef1
|
https://github.com/RobotsAndPencils/go-saml/blob/fb13cb52a46b55a9f20e6d497658dd494c7c1ef1/authnresponse.go#L352-L359
|
16,775 |
RobotsAndPencils/go-saml
|
xmlsec.go
|
SignRequest
|
func SignRequest(xml string, privateKeyPath string) (string, error) {
return sign(xml, privateKeyPath, xmlRequestID)
}
|
go
|
func SignRequest(xml string, privateKeyPath string) (string, error) {
return sign(xml, privateKeyPath, xmlRequestID)
}
|
[
"func",
"SignRequest",
"(",
"xml",
"string",
",",
"privateKeyPath",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"sign",
"(",
"xml",
",",
"privateKeyPath",
",",
"xmlRequestID",
")",
"\n",
"}"
] |
// SignRequest sign a SAML 2.0 AuthnRequest
// `privateKeyPath` must be a path on the filesystem, xmlsec1 is run out of process
// through `exec`
|
[
"SignRequest",
"sign",
"a",
"SAML",
"2",
".",
"0",
"AuthnRequest",
"privateKeyPath",
"must",
"be",
"a",
"path",
"on",
"the",
"filesystem",
"xmlsec1",
"is",
"run",
"out",
"of",
"process",
"through",
"exec"
] |
fb13cb52a46b55a9f20e6d497658dd494c7c1ef1
|
https://github.com/RobotsAndPencils/go-saml/blob/fb13cb52a46b55a9f20e6d497658dd494c7c1ef1/xmlsec.go#L19-L21
|
16,776 |
RobotsAndPencils/go-saml
|
xmlsec.go
|
SignResponse
|
func SignResponse(xml string, privateKeyPath string) (string, error) {
return sign(xml, privateKeyPath, xmlResponseID)
}
|
go
|
func SignResponse(xml string, privateKeyPath string) (string, error) {
return sign(xml, privateKeyPath, xmlResponseID)
}
|
[
"func",
"SignResponse",
"(",
"xml",
"string",
",",
"privateKeyPath",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"sign",
"(",
"xml",
",",
"privateKeyPath",
",",
"xmlResponseID",
")",
"\n",
"}"
] |
// SignResponse sign a SAML 2.0 Response
// `privateKeyPath` must be a path on the filesystem, xmlsec1 is run out of process
// through `exec`
|
[
"SignResponse",
"sign",
"a",
"SAML",
"2",
".",
"0",
"Response",
"privateKeyPath",
"must",
"be",
"a",
"path",
"on",
"the",
"filesystem",
"xmlsec1",
"is",
"run",
"out",
"of",
"process",
"through",
"exec"
] |
fb13cb52a46b55a9f20e6d497658dd494c7c1ef1
|
https://github.com/RobotsAndPencils/go-saml/blob/fb13cb52a46b55a9f20e6d497658dd494c7c1ef1/xmlsec.go#L26-L28
|
16,777 |
RobotsAndPencils/go-saml
|
xmlsec.go
|
VerifyResponseSignature
|
func VerifyResponseSignature(xml string, publicCertPath string) error {
return verify(xml, publicCertPath, xmlResponseID)
}
|
go
|
func VerifyResponseSignature(xml string, publicCertPath string) error {
return verify(xml, publicCertPath, xmlResponseID)
}
|
[
"func",
"VerifyResponseSignature",
"(",
"xml",
"string",
",",
"publicCertPath",
"string",
")",
"error",
"{",
"return",
"verify",
"(",
"xml",
",",
"publicCertPath",
",",
"xmlResponseID",
")",
"\n",
"}"
] |
// VerifyResponseSignature verify signature of a SAML 2.0 Response document
// `publicCertPath` must be a path on the filesystem, xmlsec1 is run out of process
// through `exec`
|
[
"VerifyResponseSignature",
"verify",
"signature",
"of",
"a",
"SAML",
"2",
".",
"0",
"Response",
"document",
"publicCertPath",
"must",
"be",
"a",
"path",
"on",
"the",
"filesystem",
"xmlsec1",
"is",
"run",
"out",
"of",
"process",
"through",
"exec"
] |
fb13cb52a46b55a9f20e6d497658dd494c7c1ef1
|
https://github.com/RobotsAndPencils/go-saml/blob/fb13cb52a46b55a9f20e6d497658dd494c7c1ef1/xmlsec.go#L69-L71
|
16,778 |
RobotsAndPencils/go-saml
|
xmlsec.go
|
VerifyRequestSignature
|
func VerifyRequestSignature(xml string, publicCertPath string) error {
return verify(xml, publicCertPath, xmlRequestID)
}
|
go
|
func VerifyRequestSignature(xml string, publicCertPath string) error {
return verify(xml, publicCertPath, xmlRequestID)
}
|
[
"func",
"VerifyRequestSignature",
"(",
"xml",
"string",
",",
"publicCertPath",
"string",
")",
"error",
"{",
"return",
"verify",
"(",
"xml",
",",
"publicCertPath",
",",
"xmlRequestID",
")",
"\n",
"}"
] |
// VerifyRequestSignature verify signature of a SAML 2.0 AuthnRequest document
// `publicCertPath` must be a path on the filesystem, xmlsec1 is run out of process
// through `exec`
|
[
"VerifyRequestSignature",
"verify",
"signature",
"of",
"a",
"SAML",
"2",
".",
"0",
"AuthnRequest",
"document",
"publicCertPath",
"must",
"be",
"a",
"path",
"on",
"the",
"filesystem",
"xmlsec1",
"is",
"run",
"out",
"of",
"process",
"through",
"exec"
] |
fb13cb52a46b55a9f20e6d497658dd494c7c1ef1
|
https://github.com/RobotsAndPencils/go-saml/blob/fb13cb52a46b55a9f20e6d497658dd494c7c1ef1/xmlsec.go#L76-L78
|
16,779 |
mozillazg/request
|
request.go
|
Head
|
func Head(url string, a *Args) (resp *Response, err error) {
resp, err = newRequest("HEAD", url, a)
return
}
|
go
|
func Head(url string, a *Args) (resp *Response, err error) {
resp, err = newRequest("HEAD", url, a)
return
}
|
[
"func",
"Head",
"(",
"url",
"string",
",",
"a",
"*",
"Args",
")",
"(",
"resp",
"*",
"Response",
",",
"err",
"error",
")",
"{",
"resp",
",",
"err",
"=",
"newRequest",
"(",
"\"",
"\"",
",",
"url",
",",
"a",
")",
"\n",
"return",
"\n",
"}"
] |
// Head issues a HEAD to the specified URL.
//
// Caller should close resp.Body when done reading from it.
|
[
"Head",
"issues",
"a",
"HEAD",
"to",
"the",
"specified",
"URL",
".",
"Caller",
"should",
"close",
"resp",
".",
"Body",
"when",
"done",
"reading",
"from",
"it",
"."
] |
f66876a1e3667af79d0cafa29a14ab7e667588ac
|
https://github.com/mozillazg/request/blob/f66876a1e3667af79d0cafa29a14ab7e667588ac/request.go#L203-L206
|
16,780 |
mozillazg/request
|
request.go
|
Reset
|
func (req *Request) Reset() {
req.Headers = map[string]string{}
for k, v := range DefaultHeaders {
req.Headers[k] = v
}
req.Cookies = nil
req.Data = nil
req.Params = nil
req.Files = nil
req.Json = nil
req.Proxy = ""
req.BasicAuth = BasicAuth{}
req.Body = nil
return
}
|
go
|
func (req *Request) Reset() {
req.Headers = map[string]string{}
for k, v := range DefaultHeaders {
req.Headers[k] = v
}
req.Cookies = nil
req.Data = nil
req.Params = nil
req.Files = nil
req.Json = nil
req.Proxy = ""
req.BasicAuth = BasicAuth{}
req.Body = nil
return
}
|
[
"func",
"(",
"req",
"*",
"Request",
")",
"Reset",
"(",
")",
"{",
"req",
".",
"Headers",
"=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"DefaultHeaders",
"{",
"req",
".",
"Headers",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"req",
".",
"Cookies",
"=",
"nil",
"\n",
"req",
".",
"Data",
"=",
"nil",
"\n",
"req",
".",
"Params",
"=",
"nil",
"\n",
"req",
".",
"Files",
"=",
"nil",
"\n",
"req",
".",
"Json",
"=",
"nil",
"\n",
"req",
".",
"Proxy",
"=",
"\"",
"\"",
"\n",
"req",
".",
"BasicAuth",
"=",
"BasicAuth",
"{",
"}",
"\n",
"req",
".",
"Body",
"=",
"nil",
"\n",
"return",
"\n",
"}"
] |
// Reset all fields to default values
|
[
"Reset",
"all",
"fields",
"to",
"default",
"values"
] |
f66876a1e3667af79d0cafa29a14ab7e667588ac
|
https://github.com/mozillazg/request/blob/f66876a1e3667af79d0cafa29a14ab7e667588ac/request.go#L346-L360
|
16,781 |
mozillazg/request
|
response.go
|
Json
|
func (resp *Response) Json() (*simplejson.Json, error) {
b, err := resp.Content()
if err != nil {
return nil, err
}
return simplejson.NewJson(b)
}
|
go
|
func (resp *Response) Json() (*simplejson.Json, error) {
b, err := resp.Content()
if err != nil {
return nil, err
}
return simplejson.NewJson(b)
}
|
[
"func",
"(",
"resp",
"*",
"Response",
")",
"Json",
"(",
")",
"(",
"*",
"simplejson",
".",
"Json",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"resp",
".",
"Content",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"simplejson",
".",
"NewJson",
"(",
"b",
")",
"\n",
"}"
] |
// Json return Response Body as simplejson.Json
|
[
"Json",
"return",
"Response",
"Body",
"as",
"simplejson",
".",
"Json"
] |
f66876a1e3667af79d0cafa29a14ab7e667588ac
|
https://github.com/mozillazg/request/blob/f66876a1e3667af79d0cafa29a14ab7e667588ac/response.go#L21-L27
|
16,782 |
mozillazg/request
|
response.go
|
Text
|
func (resp *Response) Text() (string, error) {
b, err := resp.Content()
s := string(b)
return s, err
}
|
go
|
func (resp *Response) Text() (string, error) {
b, err := resp.Content()
s := string(b)
return s, err
}
|
[
"func",
"(",
"resp",
"*",
"Response",
")",
"Text",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"resp",
".",
"Content",
"(",
")",
"\n",
"s",
":=",
"string",
"(",
"b",
")",
"\n",
"return",
"s",
",",
"err",
"\n",
"}"
] |
// Text return Response Body as string
|
[
"Text",
"return",
"Response",
"Body",
"as",
"string"
] |
f66876a1e3667af79d0cafa29a14ab7e667588ac
|
https://github.com/mozillazg/request/blob/f66876a1e3667af79d0cafa29a14ab7e667588ac/response.go#L59-L63
|
16,783 |
mozillazg/request
|
response.go
|
URL
|
func (resp *Response) URL() (*url.URL, error) {
u := resp.Request.URL
switch resp.StatusCode {
case http.StatusMovedPermanently, http.StatusFound,
http.StatusSeeOther, http.StatusTemporaryRedirect:
location, err := resp.Location()
if err != nil {
return nil, err
}
u = u.ResolveReference(location)
}
return u, nil
}
|
go
|
func (resp *Response) URL() (*url.URL, error) {
u := resp.Request.URL
switch resp.StatusCode {
case http.StatusMovedPermanently, http.StatusFound,
http.StatusSeeOther, http.StatusTemporaryRedirect:
location, err := resp.Location()
if err != nil {
return nil, err
}
u = u.ResolveReference(location)
}
return u, nil
}
|
[
"func",
"(",
"resp",
"*",
"Response",
")",
"URL",
"(",
")",
"(",
"*",
"url",
".",
"URL",
",",
"error",
")",
"{",
"u",
":=",
"resp",
".",
"Request",
".",
"URL",
"\n",
"switch",
"resp",
".",
"StatusCode",
"{",
"case",
"http",
".",
"StatusMovedPermanently",
",",
"http",
".",
"StatusFound",
",",
"http",
".",
"StatusSeeOther",
",",
"http",
".",
"StatusTemporaryRedirect",
":",
"location",
",",
"err",
":=",
"resp",
".",
"Location",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"u",
"=",
"u",
".",
"ResolveReference",
"(",
"location",
")",
"\n",
"}",
"\n",
"return",
"u",
",",
"nil",
"\n",
"}"
] |
// URL return finally request url
|
[
"URL",
"return",
"finally",
"request",
"url"
] |
f66876a1e3667af79d0cafa29a14ab7e667588ac
|
https://github.com/mozillazg/request/blob/f66876a1e3667af79d0cafa29a14ab7e667588ac/response.go#L81-L93
|
16,784 |
matm/gocov-html
|
cov/report.go
|
addPackage
|
func (r *report) addPackage(p *gocov.Package) {
i := sort.Search(len(r.packages), func(i int) bool {
return r.packages[i].Name >= p.Name
})
if i < len(r.packages) && r.packages[i].Name == p.Name {
r.packages[i].Accumulate(p)
} else {
head := r.packages[:i]
tail := append([]*gocov.Package{p}, r.packages[i:]...)
r.packages = append(head, tail...)
}
}
|
go
|
func (r *report) addPackage(p *gocov.Package) {
i := sort.Search(len(r.packages), func(i int) bool {
return r.packages[i].Name >= p.Name
})
if i < len(r.packages) && r.packages[i].Name == p.Name {
r.packages[i].Accumulate(p)
} else {
head := r.packages[:i]
tail := append([]*gocov.Package{p}, r.packages[i:]...)
r.packages = append(head, tail...)
}
}
|
[
"func",
"(",
"r",
"*",
"report",
")",
"addPackage",
"(",
"p",
"*",
"gocov",
".",
"Package",
")",
"{",
"i",
":=",
"sort",
".",
"Search",
"(",
"len",
"(",
"r",
".",
"packages",
")",
",",
"func",
"(",
"i",
"int",
")",
"bool",
"{",
"return",
"r",
".",
"packages",
"[",
"i",
"]",
".",
"Name",
">=",
"p",
".",
"Name",
"\n",
"}",
")",
"\n",
"if",
"i",
"<",
"len",
"(",
"r",
".",
"packages",
")",
"&&",
"r",
".",
"packages",
"[",
"i",
"]",
".",
"Name",
"==",
"p",
".",
"Name",
"{",
"r",
".",
"packages",
"[",
"i",
"]",
".",
"Accumulate",
"(",
"p",
")",
"\n",
"}",
"else",
"{",
"head",
":=",
"r",
".",
"packages",
"[",
":",
"i",
"]",
"\n",
"tail",
":=",
"append",
"(",
"[",
"]",
"*",
"gocov",
".",
"Package",
"{",
"p",
"}",
",",
"r",
".",
"packages",
"[",
"i",
":",
"]",
"...",
")",
"\n",
"r",
".",
"packages",
"=",
"append",
"(",
"head",
",",
"tail",
"...",
")",
"\n",
"}",
"\n",
"}"
] |
// AddPackage adds a package's coverage information to the report.
|
[
"AddPackage",
"adds",
"a",
"package",
"s",
"coverage",
"information",
"to",
"the",
"report",
"."
] |
f6dd0fd0ebc7c8cff8b24c0a585caeef250627a3
|
https://github.com/matm/gocov-html/blob/f6dd0fd0ebc7c8cff8b24c0a585caeef250627a3/cov/report.go#L95-L106
|
16,785 |
matm/gocov-html
|
cov/report.go
|
printReport
|
func printReport(w io.Writer, r *report) {
css := defaultCSS
if len(r.stylesheet) > 0 {
css = fmt.Sprintf("<link rel=\"stylesheet\" href=\"%s\" />", r.stylesheet)
}
fmt.Fprintf(w, htmlHeader, css)
reportPackages := make(reportPackageList, len(r.packages))
for i, pkg := range r.packages {
reportPackages[i] = buildReportPackage(pkg)
}
if len(reportPackages) == 0 {
fmt.Fprintf(w, "<p>no test files in package.</p>")
fmt.Fprintf(w, htmlFooter)
return
}
summaryPackage := reportPackages[0]
fmt.Fprintf(w, "<div id=\"about\">Generated on %s with <a href=\"%s\">gocov-html</a></div>",
time.Now().Format(time.RFC822Z), ProjectUrl)
if len(reportPackages) > 1 {
summaryPackage = printReportOverview(w, reportPackages)
}
w = tabwriter.NewWriter(w, 0, 8, 0, '\t', 0)
for _, rp := range reportPackages {
printPackage(w, r, rp)
fmt.Fprintln(w)
}
printReportSummary(w, summaryPackage)
fmt.Fprintf(w, htmlFooter)
}
|
go
|
func printReport(w io.Writer, r *report) {
css := defaultCSS
if len(r.stylesheet) > 0 {
css = fmt.Sprintf("<link rel=\"stylesheet\" href=\"%s\" />", r.stylesheet)
}
fmt.Fprintf(w, htmlHeader, css)
reportPackages := make(reportPackageList, len(r.packages))
for i, pkg := range r.packages {
reportPackages[i] = buildReportPackage(pkg)
}
if len(reportPackages) == 0 {
fmt.Fprintf(w, "<p>no test files in package.</p>")
fmt.Fprintf(w, htmlFooter)
return
}
summaryPackage := reportPackages[0]
fmt.Fprintf(w, "<div id=\"about\">Generated on %s with <a href=\"%s\">gocov-html</a></div>",
time.Now().Format(time.RFC822Z), ProjectUrl)
if len(reportPackages) > 1 {
summaryPackage = printReportOverview(w, reportPackages)
}
w = tabwriter.NewWriter(w, 0, 8, 0, '\t', 0)
for _, rp := range reportPackages {
printPackage(w, r, rp)
fmt.Fprintln(w)
}
printReportSummary(w, summaryPackage)
fmt.Fprintf(w, htmlFooter)
}
|
[
"func",
"printReport",
"(",
"w",
"io",
".",
"Writer",
",",
"r",
"*",
"report",
")",
"{",
"css",
":=",
"defaultCSS",
"\n",
"if",
"len",
"(",
"r",
".",
"stylesheet",
")",
">",
"0",
"{",
"css",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\"",
",",
"r",
".",
"stylesheet",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"htmlHeader",
",",
"css",
")",
"\n\n",
"reportPackages",
":=",
"make",
"(",
"reportPackageList",
",",
"len",
"(",
"r",
".",
"packages",
")",
")",
"\n",
"for",
"i",
",",
"pkg",
":=",
"range",
"r",
".",
"packages",
"{",
"reportPackages",
"[",
"i",
"]",
"=",
"buildReportPackage",
"(",
"pkg",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"reportPackages",
")",
"==",
"0",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"htmlFooter",
")",
"\n",
"return",
"\n\n",
"}",
"\n",
"summaryPackage",
":=",
"reportPackages",
"[",
"0",
"]",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\"",
",",
"time",
".",
"Now",
"(",
")",
".",
"Format",
"(",
"time",
".",
"RFC822Z",
")",
",",
"ProjectUrl",
")",
"\n",
"if",
"len",
"(",
"reportPackages",
")",
">",
"1",
"{",
"summaryPackage",
"=",
"printReportOverview",
"(",
"w",
",",
"reportPackages",
")",
"\n",
"}",
"\n\n",
"w",
"=",
"tabwriter",
".",
"NewWriter",
"(",
"w",
",",
"0",
",",
"8",
",",
"0",
",",
"'\\t'",
",",
"0",
")",
"\n",
"for",
"_",
",",
"rp",
":=",
"range",
"reportPackages",
"{",
"printPackage",
"(",
"w",
",",
"r",
",",
"rp",
")",
"\n",
"fmt",
".",
"Fprintln",
"(",
"w",
")",
"\n",
"}",
"\n\n",
"printReportSummary",
"(",
"w",
",",
"summaryPackage",
")",
"\n\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"htmlFooter",
")",
"\n",
"}"
] |
// PrintReport prints a coverage report to the given writer.
|
[
"PrintReport",
"prints",
"a",
"coverage",
"report",
"to",
"the",
"given",
"writer",
"."
] |
f6dd0fd0ebc7c8cff8b24c0a585caeef250627a3
|
https://github.com/matm/gocov-html/blob/f6dd0fd0ebc7c8cff8b24c0a585caeef250627a3/cov/report.go#L151-L185
|
16,786 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
NewClient
|
func NewClient(machines []string) *Client {
config := Config{
// default timeout is one second
DialTimeout: time.Second,
}
client := &Client{
Cluster: NewCluster(machines),
Config: config,
}
client.initHTTPClient()
return client
}
|
go
|
func NewClient(machines []string) *Client {
config := Config{
// default timeout is one second
DialTimeout: time.Second,
}
client := &Client{
Cluster: NewCluster(machines),
Config: config,
}
client.initHTTPClient()
return client
}
|
[
"func",
"NewClient",
"(",
"machines",
"[",
"]",
"string",
")",
"*",
"Client",
"{",
"config",
":=",
"Config",
"{",
"// default timeout is one second",
"DialTimeout",
":",
"time",
".",
"Second",
",",
"}",
"\n\n",
"client",
":=",
"&",
"Client",
"{",
"Cluster",
":",
"NewCluster",
"(",
"machines",
")",
",",
"Config",
":",
"config",
",",
"}",
"\n\n",
"client",
".",
"initHTTPClient",
"(",
")",
"\n",
"return",
"client",
"\n",
"}"
] |
// NewClient create a basic client that is configured to be used
// with the given machine list.
|
[
"NewClient",
"create",
"a",
"basic",
"client",
"that",
"is",
"configured",
"to",
"be",
"used",
"with",
"the",
"given",
"machine",
"list",
"."
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L58-L71
|
16,787 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
NewTLSClient
|
func NewTLSClient(machines []string, cert string, key string, caCerts []string) (*Client, error) {
// overwrite the default machine to use https
if len(machines) == 0 {
machines = []string{"https://127.0.0.1:4001"}
}
config := Config{
// default timeout is one second
DialTimeout: time.Second,
CertFile: cert,
KeyFile: key,
CaCertFile: make([]string, 0),
}
client := &Client{
Cluster: NewCluster(machines),
Config: config,
}
err := client.initHTTPSClient(cert, key)
if err != nil {
return nil, err
}
for _, caCert := range caCerts {
if err := client.AddRootCA(caCert); err != nil {
return nil, err
}
}
return client, nil
}
|
go
|
func NewTLSClient(machines []string, cert string, key string, caCerts []string) (*Client, error) {
// overwrite the default machine to use https
if len(machines) == 0 {
machines = []string{"https://127.0.0.1:4001"}
}
config := Config{
// default timeout is one second
DialTimeout: time.Second,
CertFile: cert,
KeyFile: key,
CaCertFile: make([]string, 0),
}
client := &Client{
Cluster: NewCluster(machines),
Config: config,
}
err := client.initHTTPSClient(cert, key)
if err != nil {
return nil, err
}
for _, caCert := range caCerts {
if err := client.AddRootCA(caCert); err != nil {
return nil, err
}
}
return client, nil
}
|
[
"func",
"NewTLSClient",
"(",
"machines",
"[",
"]",
"string",
",",
"cert",
"string",
",",
"key",
"string",
",",
"caCerts",
"[",
"]",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"// overwrite the default machine to use https",
"if",
"len",
"(",
"machines",
")",
"==",
"0",
"{",
"machines",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n\n",
"config",
":=",
"Config",
"{",
"// default timeout is one second",
"DialTimeout",
":",
"time",
".",
"Second",
",",
"CertFile",
":",
"cert",
",",
"KeyFile",
":",
"key",
",",
"CaCertFile",
":",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
",",
"}",
"\n\n",
"client",
":=",
"&",
"Client",
"{",
"Cluster",
":",
"NewCluster",
"(",
"machines",
")",
",",
"Config",
":",
"config",
",",
"}",
"\n\n",
"err",
":=",
"client",
".",
"initHTTPSClient",
"(",
"cert",
",",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"caCert",
":=",
"range",
"caCerts",
"{",
"if",
"err",
":=",
"client",
".",
"AddRootCA",
"(",
"caCert",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"client",
",",
"nil",
"\n",
"}"
] |
// NewTLSClient create a basic client with TLS configuration
|
[
"NewTLSClient",
"create",
"a",
"basic",
"client",
"with",
"TLS",
"configuration"
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L74-L104
|
16,788 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
NewClientFromFile
|
func NewClientFromFile(fpath string) (*Client, error) {
fi, err := os.Open(fpath)
if err != nil {
return nil, err
}
defer func() {
if err := fi.Close(); err != nil {
panic(err)
}
}()
return NewClientFromReader(fi)
}
|
go
|
func NewClientFromFile(fpath string) (*Client, error) {
fi, err := os.Open(fpath)
if err != nil {
return nil, err
}
defer func() {
if err := fi.Close(); err != nil {
panic(err)
}
}()
return NewClientFromReader(fi)
}
|
[
"func",
"NewClientFromFile",
"(",
"fpath",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"fi",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"fpath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
":=",
"fi",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"return",
"NewClientFromReader",
"(",
"fi",
")",
"\n",
"}"
] |
// NewClientFromFile creates a client from a given file path.
// The given file is expected to use the JSON format.
|
[
"NewClientFromFile",
"creates",
"a",
"client",
"from",
"a",
"given",
"file",
"path",
".",
"The",
"given",
"file",
"is",
"expected",
"to",
"use",
"the",
"JSON",
"format",
"."
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L108-L121
|
16,789 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
NewClientFromReader
|
func NewClientFromReader(reader io.Reader) (*Client, error) {
c := new(Client)
b, err := ioutil.ReadAll(reader)
if err != nil {
return nil, err
}
err = json.Unmarshal(b, c)
if err != nil {
return nil, err
}
if c.Config.CertFile == "" {
c.initHTTPClient()
} else {
err = c.initHTTPSClient(c.Config.CertFile, c.Config.KeyFile)
}
if err != nil {
return nil, err
}
for _, caCert := range c.Config.CaCertFile {
if err := c.AddRootCA(caCert); err != nil {
return nil, err
}
}
return c, nil
}
|
go
|
func NewClientFromReader(reader io.Reader) (*Client, error) {
c := new(Client)
b, err := ioutil.ReadAll(reader)
if err != nil {
return nil, err
}
err = json.Unmarshal(b, c)
if err != nil {
return nil, err
}
if c.Config.CertFile == "" {
c.initHTTPClient()
} else {
err = c.initHTTPSClient(c.Config.CertFile, c.Config.KeyFile)
}
if err != nil {
return nil, err
}
for _, caCert := range c.Config.CaCertFile {
if err := c.AddRootCA(caCert); err != nil {
return nil, err
}
}
return c, nil
}
|
[
"func",
"NewClientFromReader",
"(",
"reader",
"io",
".",
"Reader",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"c",
":=",
"new",
"(",
"Client",
")",
"\n\n",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"reader",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"b",
",",
"c",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"c",
".",
"Config",
".",
"CertFile",
"==",
"\"",
"\"",
"{",
"c",
".",
"initHTTPClient",
"(",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"c",
".",
"initHTTPSClient",
"(",
"c",
".",
"Config",
".",
"CertFile",
",",
"c",
".",
"Config",
".",
"KeyFile",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"caCert",
":=",
"range",
"c",
".",
"Config",
".",
"CaCertFile",
"{",
"if",
"err",
":=",
"c",
".",
"AddRootCA",
"(",
"caCert",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"c",
",",
"nil",
"\n",
"}"
] |
// NewClientFromReader creates a Client configured from a given reader.
// The configuration is expected to use the JSON format.
|
[
"NewClientFromReader",
"creates",
"a",
"Client",
"configured",
"from",
"a",
"given",
"reader",
".",
"The",
"configuration",
"is",
"expected",
"to",
"use",
"the",
"JSON",
"format",
"."
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L125-L154
|
16,790 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
SetTransport
|
func (c *Client) SetTransport(tr *http.Transport) {
c.httpClient.Transport = tr
}
|
go
|
func (c *Client) SetTransport(tr *http.Transport) {
c.httpClient.Transport = tr
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"SetTransport",
"(",
"tr",
"*",
"http",
".",
"Transport",
")",
"{",
"c",
".",
"httpClient",
".",
"Transport",
"=",
"tr",
"\n",
"}"
] |
// Override the Client's HTTP Transport object
|
[
"Override",
"the",
"Client",
"s",
"HTTP",
"Transport",
"object"
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L157-L159
|
16,791 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
initHTTPClient
|
func (c *Client) initHTTPClient() {
tr := &http.Transport{
Dial: c.dial,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
}
c.httpClient = &http.Client{Transport: tr}
}
|
go
|
func (c *Client) initHTTPClient() {
tr := &http.Transport{
Dial: c.dial,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
}
c.httpClient = &http.Client{Transport: tr}
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"initHTTPClient",
"(",
")",
"{",
"tr",
":=",
"&",
"http",
".",
"Transport",
"{",
"Dial",
":",
"c",
".",
"dial",
",",
"TLSClientConfig",
":",
"&",
"tls",
".",
"Config",
"{",
"InsecureSkipVerify",
":",
"true",
",",
"}",
",",
"}",
"\n",
"c",
".",
"httpClient",
"=",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
"tr",
"}",
"\n",
"}"
] |
// initHTTPClient initializes a HTTP client for eureka client
|
[
"initHTTPClient",
"initializes",
"a",
"HTTP",
"client",
"for",
"eureka",
"client"
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L162-L170
|
16,792 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
initHTTPSClient
|
func (c *Client) initHTTPSClient(cert, key string) error {
if cert == "" || key == "" {
return errors.New("Require both cert and key path")
}
tlsCert, err := tls.LoadX509KeyPair(cert, key)
if err != nil {
return err
}
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{tlsCert},
InsecureSkipVerify: true,
}
tr := &http.Transport{
TLSClientConfig: tlsConfig,
Dial: c.dial,
}
c.httpClient = &http.Client{Transport: tr}
return nil
}
|
go
|
func (c *Client) initHTTPSClient(cert, key string) error {
if cert == "" || key == "" {
return errors.New("Require both cert and key path")
}
tlsCert, err := tls.LoadX509KeyPair(cert, key)
if err != nil {
return err
}
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{tlsCert},
InsecureSkipVerify: true,
}
tr := &http.Transport{
TLSClientConfig: tlsConfig,
Dial: c.dial,
}
c.httpClient = &http.Client{Transport: tr}
return nil
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"initHTTPSClient",
"(",
"cert",
",",
"key",
"string",
")",
"error",
"{",
"if",
"cert",
"==",
"\"",
"\"",
"||",
"key",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"tlsCert",
",",
"err",
":=",
"tls",
".",
"LoadX509KeyPair",
"(",
"cert",
",",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"tlsConfig",
":=",
"&",
"tls",
".",
"Config",
"{",
"Certificates",
":",
"[",
"]",
"tls",
".",
"Certificate",
"{",
"tlsCert",
"}",
",",
"InsecureSkipVerify",
":",
"true",
",",
"}",
"\n\n",
"tr",
":=",
"&",
"http",
".",
"Transport",
"{",
"TLSClientConfig",
":",
"tlsConfig",
",",
"Dial",
":",
"c",
".",
"dial",
",",
"}",
"\n\n",
"c",
".",
"httpClient",
"=",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
"tr",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// initHTTPClient initializes a HTTPS client for eureka client
|
[
"initHTTPClient",
"initializes",
"a",
"HTTPS",
"client",
"for",
"eureka",
"client"
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L173-L195
|
16,793 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
SetDialTimeout
|
func (c *Client) SetDialTimeout(d time.Duration) {
c.Config.DialTimeout = d
}
|
go
|
func (c *Client) SetDialTimeout(d time.Duration) {
c.Config.DialTimeout = d
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"SetDialTimeout",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"c",
".",
"Config",
".",
"DialTimeout",
"=",
"d",
"\n",
"}"
] |
// Sets the DialTimeout value
|
[
"Sets",
"the",
"DialTimeout",
"value"
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L198-L200
|
16,794 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
AddRootCA
|
func (c *Client) AddRootCA(caCert string) error {
if c.httpClient == nil {
return errors.New("Client has not been initialized yet!")
}
certBytes, err := ioutil.ReadFile(caCert)
if err != nil {
return err
}
tr, ok := c.httpClient.Transport.(*http.Transport)
if !ok {
panic("AddRootCA(): Transport type assert should not fail")
}
if tr.TLSClientConfig.RootCAs == nil {
caCertPool := x509.NewCertPool()
ok = caCertPool.AppendCertsFromPEM(certBytes)
if ok {
tr.TLSClientConfig.RootCAs = caCertPool
}
tr.TLSClientConfig.InsecureSkipVerify = false
} else {
ok = tr.TLSClientConfig.RootCAs.AppendCertsFromPEM(certBytes)
}
if !ok {
err = errors.New("Unable to load caCert")
}
c.Config.CaCertFile = append(c.Config.CaCertFile, caCert)
return err
}
|
go
|
func (c *Client) AddRootCA(caCert string) error {
if c.httpClient == nil {
return errors.New("Client has not been initialized yet!")
}
certBytes, err := ioutil.ReadFile(caCert)
if err != nil {
return err
}
tr, ok := c.httpClient.Transport.(*http.Transport)
if !ok {
panic("AddRootCA(): Transport type assert should not fail")
}
if tr.TLSClientConfig.RootCAs == nil {
caCertPool := x509.NewCertPool()
ok = caCertPool.AppendCertsFromPEM(certBytes)
if ok {
tr.TLSClientConfig.RootCAs = caCertPool
}
tr.TLSClientConfig.InsecureSkipVerify = false
} else {
ok = tr.TLSClientConfig.RootCAs.AppendCertsFromPEM(certBytes)
}
if !ok {
err = errors.New("Unable to load caCert")
}
c.Config.CaCertFile = append(c.Config.CaCertFile, caCert)
return err
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"AddRootCA",
"(",
"caCert",
"string",
")",
"error",
"{",
"if",
"c",
".",
"httpClient",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"certBytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"caCert",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"tr",
",",
"ok",
":=",
"c",
".",
"httpClient",
".",
"Transport",
".",
"(",
"*",
"http",
".",
"Transport",
")",
"\n\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"tr",
".",
"TLSClientConfig",
".",
"RootCAs",
"==",
"nil",
"{",
"caCertPool",
":=",
"x509",
".",
"NewCertPool",
"(",
")",
"\n",
"ok",
"=",
"caCertPool",
".",
"AppendCertsFromPEM",
"(",
"certBytes",
")",
"\n",
"if",
"ok",
"{",
"tr",
".",
"TLSClientConfig",
".",
"RootCAs",
"=",
"caCertPool",
"\n",
"}",
"\n",
"tr",
".",
"TLSClientConfig",
".",
"InsecureSkipVerify",
"=",
"false",
"\n",
"}",
"else",
"{",
"ok",
"=",
"tr",
".",
"TLSClientConfig",
".",
"RootCAs",
".",
"AppendCertsFromPEM",
"(",
"certBytes",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"ok",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"c",
".",
"Config",
".",
"CaCertFile",
"=",
"append",
"(",
"c",
".",
"Config",
".",
"CaCertFile",
",",
"caCert",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
// AddRootCA adds a root CA cert for the eureka client
|
[
"AddRootCA",
"adds",
"a",
"root",
"CA",
"cert",
"for",
"the",
"eureka",
"client"
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L203-L236
|
16,795 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
SetCluster
|
func (c *Client) SetCluster(machines []string) bool {
success := c.internalSyncCluster(machines)
return success
}
|
go
|
func (c *Client) SetCluster(machines []string) bool {
success := c.internalSyncCluster(machines)
return success
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"SetCluster",
"(",
"machines",
"[",
"]",
"string",
")",
"bool",
"{",
"success",
":=",
"c",
".",
"internalSyncCluster",
"(",
"machines",
")",
"\n",
"return",
"success",
"\n",
"}"
] |
// SetCluster updates cluster information using the given machine list.
|
[
"SetCluster",
"updates",
"cluster",
"information",
"using",
"the",
"given",
"machine",
"list",
"."
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L239-L242
|
16,796 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
internalSyncCluster
|
func (c *Client) internalSyncCluster(machines []string) bool {
for _, machine := range machines {
httpPath := c.createHttpPath(machine, "machines")
resp, err := c.httpClient.Get(httpPath)
if err != nil {
// try another machine in the cluster
continue
} else {
b, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
// try another machine in the cluster
continue
}
// update Machines List
c.Cluster.updateFromStr(string(b))
// update leader
// the first one in the machine list is the leader
c.Cluster.switchLeader(0)
logger.Debug("sync.machines " + strings.Join(c.Cluster.Machines, ", "))
return true
}
}
return false
}
|
go
|
func (c *Client) internalSyncCluster(machines []string) bool {
for _, machine := range machines {
httpPath := c.createHttpPath(machine, "machines")
resp, err := c.httpClient.Get(httpPath)
if err != nil {
// try another machine in the cluster
continue
} else {
b, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
// try another machine in the cluster
continue
}
// update Machines List
c.Cluster.updateFromStr(string(b))
// update leader
// the first one in the machine list is the leader
c.Cluster.switchLeader(0)
logger.Debug("sync.machines " + strings.Join(c.Cluster.Machines, ", "))
return true
}
}
return false
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"internalSyncCluster",
"(",
"machines",
"[",
"]",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"machine",
":=",
"range",
"machines",
"{",
"httpPath",
":=",
"c",
".",
"createHttpPath",
"(",
"machine",
",",
"\"",
"\"",
")",
"\n",
"resp",
",",
"err",
":=",
"c",
".",
"httpClient",
".",
"Get",
"(",
"httpPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// try another machine in the cluster",
"continue",
"\n",
"}",
"else",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"resp",
".",
"Body",
")",
"\n",
"resp",
".",
"Body",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// try another machine in the cluster",
"continue",
"\n",
"}",
"\n\n",
"// update Machines List",
"c",
".",
"Cluster",
".",
"updateFromStr",
"(",
"string",
"(",
"b",
")",
")",
"\n\n",
"// update leader",
"// the first one in the machine list is the leader",
"c",
".",
"Cluster",
".",
"switchLeader",
"(",
"0",
")",
"\n\n",
"logger",
".",
"Debug",
"(",
"\"",
"\"",
"+",
"strings",
".",
"Join",
"(",
"c",
".",
"Cluster",
".",
"Machines",
",",
"\"",
"\"",
")",
")",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] |
// internalSyncCluster syncs cluster information using the given machine list.
|
[
"internalSyncCluster",
"syncs",
"cluster",
"information",
"using",
"the",
"given",
"machine",
"list",
"."
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L254-L281
|
16,797 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
createHttpPath
|
func (c *Client) createHttpPath(serverName string, _path string) string {
u, err := url.Parse(serverName)
if err != nil {
panic(err)
}
u.Path = path.Join(u.Path, _path)
if u.Scheme == "" {
u.Scheme = "http"
}
return u.String()
}
|
go
|
func (c *Client) createHttpPath(serverName string, _path string) string {
u, err := url.Parse(serverName)
if err != nil {
panic(err)
}
u.Path = path.Join(u.Path, _path)
if u.Scheme == "" {
u.Scheme = "http"
}
return u.String()
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"createHttpPath",
"(",
"serverName",
"string",
",",
"_path",
"string",
")",
"string",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"serverName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"u",
".",
"Path",
"=",
"path",
".",
"Join",
"(",
"u",
".",
"Path",
",",
"_path",
")",
"\n\n",
"if",
"u",
".",
"Scheme",
"==",
"\"",
"\"",
"{",
"u",
".",
"Scheme",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"u",
".",
"String",
"(",
")",
"\n",
"}"
] |
// createHttpPath creates a complete HTTP URL.
// serverName should contain both the host name and a port number, if any.
|
[
"createHttpPath",
"creates",
"a",
"complete",
"HTTP",
"URL",
".",
"serverName",
"should",
"contain",
"both",
"the",
"host",
"name",
"and",
"a",
"port",
"number",
"if",
"any",
"."
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L285-L297
|
16,798 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
dial
|
func (c *Client) dial(network, addr string) (net.Conn, error) {
conn, err := net.DialTimeout(network, addr, c.Config.DialTimeout)
if err != nil {
return nil, err
}
tcpConn, ok := conn.(*net.TCPConn)
if !ok {
return nil, errors.New("Failed type-assertion of net.Conn as *net.TCPConn")
}
// Keep TCP alive to check whether or not the remote machine is down
if err = tcpConn.SetKeepAlive(true); err != nil {
return nil, err
}
if err = tcpConn.SetKeepAlivePeriod(time.Second); err != nil {
return nil, err
}
return tcpConn, nil
}
|
go
|
func (c *Client) dial(network, addr string) (net.Conn, error) {
conn, err := net.DialTimeout(network, addr, c.Config.DialTimeout)
if err != nil {
return nil, err
}
tcpConn, ok := conn.(*net.TCPConn)
if !ok {
return nil, errors.New("Failed type-assertion of net.Conn as *net.TCPConn")
}
// Keep TCP alive to check whether or not the remote machine is down
if err = tcpConn.SetKeepAlive(true); err != nil {
return nil, err
}
if err = tcpConn.SetKeepAlivePeriod(time.Second); err != nil {
return nil, err
}
return tcpConn, nil
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"dial",
"(",
"network",
",",
"addr",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"conn",
",",
"err",
":=",
"net",
".",
"DialTimeout",
"(",
"network",
",",
"addr",
",",
"c",
".",
"Config",
".",
"DialTimeout",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"tcpConn",
",",
"ok",
":=",
"conn",
".",
"(",
"*",
"net",
".",
"TCPConn",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Keep TCP alive to check whether or not the remote machine is down",
"if",
"err",
"=",
"tcpConn",
".",
"SetKeepAlive",
"(",
"true",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"tcpConn",
".",
"SetKeepAlivePeriod",
"(",
"time",
".",
"Second",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"tcpConn",
",",
"nil",
"\n",
"}"
] |
// dial attempts to open a TCP connection to the provided address, explicitly
// enabling keep-alives with a one-second interval.
|
[
"dial",
"attempts",
"to",
"open",
"a",
"TCP",
"connection",
"to",
"the",
"provided",
"address",
"explicitly",
"enabling",
"keep",
"-",
"alives",
"with",
"a",
"one",
"-",
"second",
"interval",
"."
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L301-L322
|
16,799 |
ArthurHlt/go-eureka-client
|
eureka/client.go
|
MarshalJSON
|
func (c *Client) MarshalJSON() ([]byte, error) {
b, err := json.Marshal(struct {
Config Config `json:"config"`
Cluster *Cluster `json:"cluster"`
}{
Config: c.Config,
Cluster: c.Cluster,
})
if err != nil {
return nil, err
}
return b, nil
}
|
go
|
func (c *Client) MarshalJSON() ([]byte, error) {
b, err := json.Marshal(struct {
Config Config `json:"config"`
Cluster *Cluster `json:"cluster"`
}{
Config: c.Config,
Cluster: c.Cluster,
})
if err != nil {
return nil, err
}
return b, nil
}
|
[
"func",
"(",
"c",
"*",
"Client",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"struct",
"{",
"Config",
"Config",
"`json:\"config\"`",
"\n",
"Cluster",
"*",
"Cluster",
"`json:\"cluster\"`",
"\n",
"}",
"{",
"Config",
":",
"c",
".",
"Config",
",",
"Cluster",
":",
"c",
".",
"Cluster",
",",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] |
// MarshalJSON implements the Marshaller interface
// as defined by the standard JSON package.
|
[
"MarshalJSON",
"implements",
"the",
"Marshaller",
"interface",
"as",
"defined",
"by",
"the",
"standard",
"JSON",
"package",
"."
] |
2f75174c63cf789d5de665a83b42680dfe2e088f
|
https://github.com/ArthurHlt/go-eureka-client/blob/2f75174c63cf789d5de665a83b42680dfe2e088f/eureka/client.go#L326-L340
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.