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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
17,200 | hoisie/redis | redis.go | valueToString | func valueToString(v reflect.Value) (string, error) {
if !v.IsValid() {
return "null", nil
}
switch v.Kind() {
case reflect.Ptr:
return valueToString(reflect.Indirect(v))
case reflect.Interface:
return valueToString(v.Elem())
case reflect.Bool:
x := v.Bool()
... | go | func valueToString(v reflect.Value) (string, error) {
if !v.IsValid() {
return "null", nil
}
switch v.Kind() {
case reflect.Ptr:
return valueToString(reflect.Indirect(v))
case reflect.Interface:
return valueToString(v.Elem())
case reflect.Bool:
x := v.Bool()
... | [
"func",
"valueToString",
"(",
"v",
"reflect",
".",
"Value",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"!",
"v",
".",
"IsValid",
"(",
")",
"{",
"return",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n\n",
"switch",
"v",
".",
"Kind",
"(",
")",
"{... | //pretty much copy the json code from here. | [
"pretty",
"much",
"copy",
"the",
"json",
"code",
"from",
"here",
"."
] | b5c6e81454e0395c280f220d82a6854fd0fcf42e | https://github.com/hoisie/redis/blob/b5c6e81454e0395c280f220d82a6854fd0fcf42e/redis.go#L1068-L1113 |
17,201 | hoisie/redis | redis.go | Publish | func (client *Client) Publish(channel string, val []byte) error {
_, err := client.sendCommand("PUBLISH", channel, string(val))
if err != nil {
return err
}
return nil
} | go | func (client *Client) Publish(channel string, val []byte) error {
_, err := client.sendCommand("PUBLISH", channel, string(val))
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"client",
"*",
"Client",
")",
"Publish",
"(",
"channel",
"string",
",",
"val",
"[",
"]",
"byte",
")",
"error",
"{",
"_",
",",
"err",
":=",
"client",
".",
"sendCommand",
"(",
"\"",
"\"",
",",
"channel",
",",
"string",
"(",
"val",
")",
... | // Publish a message to a redis server. | [
"Publish",
"a",
"message",
"to",
"a",
"redis",
"server",
"."
] | b5c6e81454e0395c280f220d82a6854fd0fcf42e | https://github.com/hoisie/redis/blob/b5c6e81454e0395c280f220d82a6854fd0fcf42e/redis.go#L1404-L1410 |
17,202 | Luzifer/go-openssl | openssl.go | DigestSHA256Sum | func DigestSHA256Sum(data []byte) []byte {
h := sha256.New()
h.Write(data)
return h.Sum(nil)
} | go | func DigestSHA256Sum(data []byte) []byte {
h := sha256.New()
h.Write(data)
return h.Sum(nil)
} | [
"func",
"DigestSHA256Sum",
"(",
"data",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"h",
":=",
"sha256",
".",
"New",
"(",
")",
"\n",
"h",
".",
"Write",
"(",
"data",
")",
"\n",
"return",
"h",
".",
"Sum",
"(",
"nil",
")",
"\n",
"}"
] | // DigestSHA256Sum uses SHA256 digest to create the key which is the default behaviour since OpenSSL 1.1.0c | [
"DigestSHA256Sum",
"uses",
"SHA256",
"digest",
"to",
"create",
"the",
"key",
"which",
"is",
"the",
"default",
"behaviour",
"since",
"OpenSSL",
"1",
".",
"1",
".",
"0c"
] | 3eef5a5be8e50536ed727038b76dbaa9ac804279 | https://github.com/Luzifer/go-openssl/blob/3eef5a5be8e50536ed727038b76dbaa9ac804279/openssl.go#L61-L65 |
17,203 | Luzifer/go-openssl | openssl.go | EncryptBytes | func (o OpenSSL) EncryptBytes(passphrase string, plainData []byte, kdf DigestFunc) ([]byte, error) {
salt, err := o.GenerateSalt()
if err != nil {
return nil, err
}
return o.EncryptBytesWithSaltAndDigestFunc(passphrase, salt, plainData, kdf)
} | go | func (o OpenSSL) EncryptBytes(passphrase string, plainData []byte, kdf DigestFunc) ([]byte, error) {
salt, err := o.GenerateSalt()
if err != nil {
return nil, err
}
return o.EncryptBytesWithSaltAndDigestFunc(passphrase, salt, plainData, kdf)
} | [
"func",
"(",
"o",
"OpenSSL",
")",
"EncryptBytes",
"(",
"passphrase",
"string",
",",
"plainData",
"[",
"]",
"byte",
",",
"kdf",
"DigestFunc",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"salt",
",",
"err",
":=",
"o",
".",
"GenerateSalt",
"(",
... | // EncryptBytes encrypts a slice of bytes that are base64 encoded in a manner compatible to OpenSSL encryption
// functions using AES-256-CBC as encryption algorithm. This function generates
// a random salt on every execution. | [
"EncryptBytes",
"encrypts",
"a",
"slice",
"of",
"bytes",
"that",
"are",
"base64",
"encoded",
"in",
"a",
"manner",
"compatible",
"to",
"OpenSSL",
"encryption",
"functions",
"using",
"AES",
"-",
"256",
"-",
"CBC",
"as",
"encryption",
"algorithm",
".",
"This",
... | 3eef5a5be8e50536ed727038b76dbaa9ac804279 | https://github.com/Luzifer/go-openssl/blob/3eef5a5be8e50536ed727038b76dbaa9ac804279/openssl.go#L133-L140 |
17,204 | Luzifer/go-openssl | openssl.go | EncryptBinaryBytes | func (o OpenSSL) EncryptBinaryBytes(passphrase string, plainData []byte, kdf DigestFunc) ([]byte, error) {
salt, err := o.GenerateSalt()
if err != nil {
return nil, err
}
return o.EncryptBinaryBytesWithSaltAndDigestFunc(passphrase, salt, plainData, kdf)
} | go | func (o OpenSSL) EncryptBinaryBytes(passphrase string, plainData []byte, kdf DigestFunc) ([]byte, error) {
salt, err := o.GenerateSalt()
if err != nil {
return nil, err
}
return o.EncryptBinaryBytesWithSaltAndDigestFunc(passphrase, salt, plainData, kdf)
} | [
"func",
"(",
"o",
"OpenSSL",
")",
"EncryptBinaryBytes",
"(",
"passphrase",
"string",
",",
"plainData",
"[",
"]",
"byte",
",",
"kdf",
"DigestFunc",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"salt",
",",
"err",
":=",
"o",
".",
"GenerateSalt",
... | // EncryptBinaryBytes encrypts a slice of bytes in a manner compatible to OpenSSL encryption
// functions using AES-256-CBC as encryption algorithm. This function generates
// a random salt on every execution. | [
"EncryptBinaryBytes",
"encrypts",
"a",
"slice",
"of",
"bytes",
"in",
"a",
"manner",
"compatible",
"to",
"OpenSSL",
"encryption",
"functions",
"using",
"AES",
"-",
"256",
"-",
"CBC",
"as",
"encryption",
"algorithm",
".",
"This",
"function",
"generates",
"a",
"r... | 3eef5a5be8e50536ed727038b76dbaa9ac804279 | https://github.com/Luzifer/go-openssl/blob/3eef5a5be8e50536ed727038b76dbaa9ac804279/openssl.go#L145-L152 |
17,205 | Luzifer/go-openssl | openssl.go | MustGenerateSalt | func (o OpenSSL) MustGenerateSalt() []byte {
s, err := o.GenerateSalt()
if err != nil {
panic(err)
}
return s
} | go | func (o OpenSSL) MustGenerateSalt() []byte {
s, err := o.GenerateSalt()
if err != nil {
panic(err)
}
return s
} | [
"func",
"(",
"o",
"OpenSSL",
")",
"MustGenerateSalt",
"(",
")",
"[",
"]",
"byte",
"{",
"s",
",",
"err",
":=",
"o",
".",
"GenerateSalt",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"s",
"\n... | // MustGenerateSalt is a wrapper around GenerateSalt which will panic on an error.
// This allows you to use this function as a parameter to EncryptBytesWithSaltAndDigestFunc | [
"MustGenerateSalt",
"is",
"a",
"wrapper",
"around",
"GenerateSalt",
"which",
"will",
"panic",
"on",
"an",
"error",
".",
"This",
"allows",
"you",
"to",
"use",
"this",
"function",
"as",
"a",
"parameter",
"to",
"EncryptBytesWithSaltAndDigestFunc"
] | 3eef5a5be8e50536ed727038b76dbaa9ac804279 | https://github.com/Luzifer/go-openssl/blob/3eef5a5be8e50536ed727038b76dbaa9ac804279/openssl.go#L261-L267 |
17,206 | Luzifer/go-openssl | openssl.go | pkcs7Unpad | func (o OpenSSL) pkcs7Unpad(data []byte, blocklen int) ([]byte, error) {
if blocklen <= 0 {
return nil, fmt.Errorf("invalid blocklen %d", blocklen)
}
if len(data)%blocklen != 0 || len(data) == 0 {
return nil, fmt.Errorf("invalid data len %d", len(data))
}
padlen := int(data[len(data)-1])
if padlen > blocklen ... | go | func (o OpenSSL) pkcs7Unpad(data []byte, blocklen int) ([]byte, error) {
if blocklen <= 0 {
return nil, fmt.Errorf("invalid blocklen %d", blocklen)
}
if len(data)%blocklen != 0 || len(data) == 0 {
return nil, fmt.Errorf("invalid data len %d", len(data))
}
padlen := int(data[len(data)-1])
if padlen > blocklen ... | [
"func",
"(",
"o",
"OpenSSL",
")",
"pkcs7Unpad",
"(",
"data",
"[",
"]",
"byte",
",",
"blocklen",
"int",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"blocklen",
"<=",
"0",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
... | // pkcs7Unpad returns slice of the original data without padding. | [
"pkcs7Unpad",
"returns",
"slice",
"of",
"the",
"original",
"data",
"without",
"padding",
"."
] | 3eef5a5be8e50536ed727038b76dbaa9ac804279 | https://github.com/Luzifer/go-openssl/blob/3eef5a5be8e50536ed727038b76dbaa9ac804279/openssl.go#L284-L302 |
17,207 | vishvananda/netns | netns_linux.go | Setns | func Setns(ns NsHandle, nstype int) (err error) {
_, _, e1 := syscall.Syscall(SYS_SETNS, uintptr(ns), uintptr(nstype), 0)
if e1 != 0 {
err = e1
}
return
} | go | func Setns(ns NsHandle, nstype int) (err error) {
_, _, e1 := syscall.Syscall(SYS_SETNS, uintptr(ns), uintptr(nstype), 0)
if e1 != 0 {
err = e1
}
return
} | [
"func",
"Setns",
"(",
"ns",
"NsHandle",
",",
"nstype",
"int",
")",
"(",
"err",
"error",
")",
"{",
"_",
",",
"_",
",",
"e1",
":=",
"syscall",
".",
"Syscall",
"(",
"SYS_SETNS",
",",
"uintptr",
"(",
"ns",
")",
",",
"uintptr",
"(",
"nstype",
")",
","... | // Setns sets namespace using syscall. Note that this should be a method
// in syscall but it has not been added. | [
"Setns",
"sets",
"namespace",
"using",
"syscall",
".",
"Note",
"that",
"this",
"should",
"be",
"a",
"method",
"in",
"syscall",
"but",
"it",
"has",
"not",
"been",
"added",
"."
] | 13995c7128ccc8e51e9a6bd2b551020a27180abd | https://github.com/vishvananda/netns/blob/13995c7128ccc8e51e9a6bd2b551020a27180abd/netns_linux.go#L41-L47 |
17,208 | vishvananda/netns | netns_linux.go | New | func New() (ns NsHandle, err error) {
if err := syscall.Unshare(CLONE_NEWNET); err != nil {
return -1, err
}
return Get()
} | go | func New() (ns NsHandle, err error) {
if err := syscall.Unshare(CLONE_NEWNET); err != nil {
return -1, err
}
return Get()
} | [
"func",
"New",
"(",
")",
"(",
"ns",
"NsHandle",
",",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"syscall",
".",
"Unshare",
"(",
"CLONE_NEWNET",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"return",
"Get",... | // New creates a new network namespace and returns a handle to it. | [
"New",
"creates",
"a",
"new",
"network",
"namespace",
"and",
"returns",
"a",
"handle",
"to",
"it",
"."
] | 13995c7128ccc8e51e9a6bd2b551020a27180abd | https://github.com/vishvananda/netns/blob/13995c7128ccc8e51e9a6bd2b551020a27180abd/netns_linux.go#L56-L61 |
17,209 | vishvananda/netns | netns_linux.go | GetFromPath | func GetFromPath(path string) (NsHandle, error) {
fd, err := syscall.Open(path, syscall.O_RDONLY, 0)
if err != nil {
return -1, err
}
return NsHandle(fd), nil
} | go | func GetFromPath(path string) (NsHandle, error) {
fd, err := syscall.Open(path, syscall.O_RDONLY, 0)
if err != nil {
return -1, err
}
return NsHandle(fd), nil
} | [
"func",
"GetFromPath",
"(",
"path",
"string",
")",
"(",
"NsHandle",
",",
"error",
")",
"{",
"fd",
",",
"err",
":=",
"syscall",
".",
"Open",
"(",
"path",
",",
"syscall",
".",
"O_RDONLY",
",",
"0",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // GetFromPath gets a handle to a network namespace
// identified by the path | [
"GetFromPath",
"gets",
"a",
"handle",
"to",
"a",
"network",
"namespace",
"identified",
"by",
"the",
"path"
] | 13995c7128ccc8e51e9a6bd2b551020a27180abd | https://github.com/vishvananda/netns/blob/13995c7128ccc8e51e9a6bd2b551020a27180abd/netns_linux.go#L70-L76 |
17,210 | vishvananda/netns | netns_linux.go | GetFromThread | func GetFromThread(pid, tid int) (NsHandle, error) {
return GetFromPath(fmt.Sprintf("/proc/%d/task/%d/ns/net", pid, tid))
} | go | func GetFromThread(pid, tid int) (NsHandle, error) {
return GetFromPath(fmt.Sprintf("/proc/%d/task/%d/ns/net", pid, tid))
} | [
"func",
"GetFromThread",
"(",
"pid",
",",
"tid",
"int",
")",
"(",
"NsHandle",
",",
"error",
")",
"{",
"return",
"GetFromPath",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"pid",
",",
"tid",
")",
")",
"\n",
"}"
] | // GetFromThread gets a handle to the network namespace of a given pid and tid. | [
"GetFromThread",
"gets",
"a",
"handle",
"to",
"the",
"network",
"namespace",
"of",
"a",
"given",
"pid",
"and",
"tid",
"."
] | 13995c7128ccc8e51e9a6bd2b551020a27180abd | https://github.com/vishvananda/netns/blob/13995c7128ccc8e51e9a6bd2b551020a27180abd/netns_linux.go#L90-L92 |
17,211 | vishvananda/netns | netns_linux.go | GetFromDocker | func GetFromDocker(id string) (NsHandle, error) {
pid, err := getPidForContainer(id)
if err != nil {
return -1, err
}
return GetFromPid(pid)
} | go | func GetFromDocker(id string) (NsHandle, error) {
pid, err := getPidForContainer(id)
if err != nil {
return -1, err
}
return GetFromPid(pid)
} | [
"func",
"GetFromDocker",
"(",
"id",
"string",
")",
"(",
"NsHandle",
",",
"error",
")",
"{",
"pid",
",",
"err",
":=",
"getPidForContainer",
"(",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"1",
",",
"err",
"\n",
"}",
"\n",
"return... | // GetFromDocker gets a handle to the network namespace of a docker container.
// Id is prefixed matched against the running docker containers, so a short
// identifier can be used as long as it isn't ambiguous. | [
"GetFromDocker",
"gets",
"a",
"handle",
"to",
"the",
"network",
"namespace",
"of",
"a",
"docker",
"container",
".",
"Id",
"is",
"prefixed",
"matched",
"against",
"the",
"running",
"docker",
"containers",
"so",
"a",
"short",
"identifier",
"can",
"be",
"used",
... | 13995c7128ccc8e51e9a6bd2b551020a27180abd | https://github.com/vishvananda/netns/blob/13995c7128ccc8e51e9a6bd2b551020a27180abd/netns_linux.go#L97-L103 |
17,212 | vishvananda/netns | netns.go | Equal | func (ns NsHandle) Equal(other NsHandle) bool {
if ns == other {
return true
}
var s1, s2 syscall.Stat_t
if err := syscall.Fstat(int(ns), &s1); err != nil {
return false
}
if err := syscall.Fstat(int(other), &s2); err != nil {
return false
}
return (s1.Dev == s2.Dev) && (s1.Ino == s2.Ino)
} | go | func (ns NsHandle) Equal(other NsHandle) bool {
if ns == other {
return true
}
var s1, s2 syscall.Stat_t
if err := syscall.Fstat(int(ns), &s1); err != nil {
return false
}
if err := syscall.Fstat(int(other), &s2); err != nil {
return false
}
return (s1.Dev == s2.Dev) && (s1.Ino == s2.Ino)
} | [
"func",
"(",
"ns",
"NsHandle",
")",
"Equal",
"(",
"other",
"NsHandle",
")",
"bool",
"{",
"if",
"ns",
"==",
"other",
"{",
"return",
"true",
"\n",
"}",
"\n",
"var",
"s1",
",",
"s2",
"syscall",
".",
"Stat_t",
"\n",
"if",
"err",
":=",
"syscall",
".",
... | // Equal determines if two network handles refer to the same network
// namespace. This is done by comparing the device and inode that the
// file descriptors point to. | [
"Equal",
"determines",
"if",
"two",
"network",
"handles",
"refer",
"to",
"the",
"same",
"network",
"namespace",
".",
"This",
"is",
"done",
"by",
"comparing",
"the",
"device",
"and",
"inode",
"that",
"the",
"file",
"descriptors",
"point",
"to",
"."
] | 13995c7128ccc8e51e9a6bd2b551020a27180abd | https://github.com/vishvananda/netns/blob/13995c7128ccc8e51e9a6bd2b551020a27180abd/netns.go#L23-L35 |
17,213 | vishvananda/netns | netns.go | String | func (ns NsHandle) String() string {
var s syscall.Stat_t
if ns == -1 {
return "NS(None)"
}
if err := syscall.Fstat(int(ns), &s); err != nil {
return fmt.Sprintf("NS(%d: unknown)", ns)
}
return fmt.Sprintf("NS(%d: %d, %d)", ns, s.Dev, s.Ino)
} | go | func (ns NsHandle) String() string {
var s syscall.Stat_t
if ns == -1 {
return "NS(None)"
}
if err := syscall.Fstat(int(ns), &s); err != nil {
return fmt.Sprintf("NS(%d: unknown)", ns)
}
return fmt.Sprintf("NS(%d: %d, %d)", ns, s.Dev, s.Ino)
} | [
"func",
"(",
"ns",
"NsHandle",
")",
"String",
"(",
")",
"string",
"{",
"var",
"s",
"syscall",
".",
"Stat_t",
"\n",
"if",
"ns",
"==",
"-",
"1",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"err",
":=",
"syscall",
".",
"Fstat",
"(",
"int",
"... | // String shows the file descriptor number and its dev and inode. | [
"String",
"shows",
"the",
"file",
"descriptor",
"number",
"and",
"its",
"dev",
"and",
"inode",
"."
] | 13995c7128ccc8e51e9a6bd2b551020a27180abd | https://github.com/vishvananda/netns/blob/13995c7128ccc8e51e9a6bd2b551020a27180abd/netns.go#L38-L47 |
17,214 | onrik/ethrpc | helpers.go | ParseInt | func ParseInt(value string) (int, error) {
i, err := strconv.ParseInt(strings.TrimPrefix(value, "0x"), 16, 64)
if err != nil {
return 0, err
}
return int(i), nil
} | go | func ParseInt(value string) (int, error) {
i, err := strconv.ParseInt(strings.TrimPrefix(value, "0x"), 16, 64)
if err != nil {
return 0, err
}
return int(i), nil
} | [
"func",
"ParseInt",
"(",
"value",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"strings",
".",
"TrimPrefix",
"(",
"value",
",",
"\"",
"\"",
")",
",",
"16",
",",
"64",
")",
"\n",
"if",
... | // ParseInt parse hex string value to int | [
"ParseInt",
"parse",
"hex",
"string",
"value",
"to",
"int"
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/helpers.go#L11-L18 |
17,215 | onrik/ethrpc | helpers.go | ParseBigInt | func ParseBigInt(value string) (big.Int, error) {
i := big.Int{}
_, err := fmt.Sscan(value, &i)
return i, err
} | go | func ParseBigInt(value string) (big.Int, error) {
i := big.Int{}
_, err := fmt.Sscan(value, &i)
return i, err
} | [
"func",
"ParseBigInt",
"(",
"value",
"string",
")",
"(",
"big",
".",
"Int",
",",
"error",
")",
"{",
"i",
":=",
"big",
".",
"Int",
"{",
"}",
"\n",
"_",
",",
"err",
":=",
"fmt",
".",
"Sscan",
"(",
"value",
",",
"&",
"i",
")",
"\n\n",
"return",
... | // ParseBigInt parse hex string value to big.Int | [
"ParseBigInt",
"parse",
"hex",
"string",
"value",
"to",
"big",
".",
"Int"
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/helpers.go#L21-L26 |
17,216 | onrik/ethrpc | helpers.go | BigToHex | func BigToHex(bigInt big.Int) string {
if bigInt.BitLen() == 0 {
return "0x0"
}
return "0x" + strings.TrimPrefix(fmt.Sprintf("%x", bigInt.Bytes()), "0")
} | go | func BigToHex(bigInt big.Int) string {
if bigInt.BitLen() == 0 {
return "0x0"
}
return "0x" + strings.TrimPrefix(fmt.Sprintf("%x", bigInt.Bytes()), "0")
} | [
"func",
"BigToHex",
"(",
"bigInt",
"big",
".",
"Int",
")",
"string",
"{",
"if",
"bigInt",
".",
"BitLen",
"(",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"\"",
"\"",
"+",
"strings",
".",
"TrimPrefix",
"(",
"fmt",
".",
... | // BigToHex covert big.Int to hexadecimal representation | [
"BigToHex",
"covert",
"big",
".",
"Int",
"to",
"hexadecimal",
"representation"
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/helpers.go#L34-L40 |
17,217 | onrik/ethrpc | types.go | MarshalJSON | func (t T) MarshalJSON() ([]byte, error) {
params := map[string]interface{}{
"from": t.From,
}
if t.To != "" {
params["to"] = t.To
}
if t.Gas > 0 {
params["gas"] = IntToHex(t.Gas)
}
if t.GasPrice != nil {
params["gasPrice"] = BigToHex(*t.GasPrice)
}
if t.Value != nil {
params["value"] = BigToHex(*t.V... | go | func (t T) MarshalJSON() ([]byte, error) {
params := map[string]interface{}{
"from": t.From,
}
if t.To != "" {
params["to"] = t.To
}
if t.Gas > 0 {
params["gas"] = IntToHex(t.Gas)
}
if t.GasPrice != nil {
params["gasPrice"] = BigToHex(*t.GasPrice)
}
if t.Value != nil {
params["value"] = BigToHex(*t.V... | [
"func",
"(",
"t",
"T",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"params",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"t",
".",
"From",
",",
"}",
"\n",
"if",
"t",
".",
"T... | // MarshalJSON implements the json.Unmarshaler interface. | [
"MarshalJSON",
"implements",
"the",
"json",
".",
"Unmarshaler",
"interface",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/types.go#L43-L67 |
17,218 | onrik/ethrpc | ethrpc.go | New | func New(url string, options ...func(rpc *EthRPC)) *EthRPC {
rpc := &EthRPC{
url: url,
client: http.DefaultClient,
log: log.New(os.Stderr, "", log.LstdFlags),
}
for _, option := range options {
option(rpc)
}
return rpc
} | go | func New(url string, options ...func(rpc *EthRPC)) *EthRPC {
rpc := &EthRPC{
url: url,
client: http.DefaultClient,
log: log.New(os.Stderr, "", log.LstdFlags),
}
for _, option := range options {
option(rpc)
}
return rpc
} | [
"func",
"New",
"(",
"url",
"string",
",",
"options",
"...",
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
")",
"*",
"EthRPC",
"{",
"rpc",
":=",
"&",
"EthRPC",
"{",
"url",
":",
"url",
",",
"client",
":",
"http",
".",
"DefaultClient",
",",
"log",
":",
"l... | // New create new rpc client with given url | [
"New",
"create",
"new",
"rpc",
"client",
"with",
"given",
"url"
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L47-L58 |
17,219 | onrik/ethrpc | ethrpc.go | NewEthRPC | func NewEthRPC(url string, options ...func(rpc *EthRPC)) *EthRPC {
return New(url, options...)
} | go | func NewEthRPC(url string, options ...func(rpc *EthRPC)) *EthRPC {
return New(url, options...)
} | [
"func",
"NewEthRPC",
"(",
"url",
"string",
",",
"options",
"...",
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
")",
"*",
"EthRPC",
"{",
"return",
"New",
"(",
"url",
",",
"options",
"...",
")",
"\n",
"}"
] | // NewEthRPC create new rpc client with given url | [
"NewEthRPC",
"create",
"new",
"rpc",
"client",
"with",
"given",
"url"
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L61-L63 |
17,220 | onrik/ethrpc | ethrpc.go | Call | func (rpc *EthRPC) Call(method string, params ...interface{}) (json.RawMessage, error) {
request := ethRequest{
ID: 1,
JSONRPC: "2.0",
Method: method,
Params: params,
}
body, err := json.Marshal(request)
if err != nil {
return nil, err
}
response, err := rpc.client.Post(rpc.url, "application/js... | go | func (rpc *EthRPC) Call(method string, params ...interface{}) (json.RawMessage, error) {
request := ethRequest{
ID: 1,
JSONRPC: "2.0",
Method: method,
Params: params,
}
body, err := json.Marshal(request)
if err != nil {
return nil, err
}
response, err := rpc.client.Post(rpc.url, "application/js... | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"Call",
"(",
"method",
"string",
",",
"params",
"...",
"interface",
"{",
"}",
")",
"(",
"json",
".",
"RawMessage",
",",
"error",
")",
"{",
"request",
":=",
"ethRequest",
"{",
"ID",
":",
"1",
",",
"JSONRPC",
"... | // Call returns raw response of method call | [
"Call",
"returns",
"raw",
"response",
"of",
"method",
"call"
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L84-L125 |
17,221 | onrik/ethrpc | ethrpc.go | Web3ClientVersion | func (rpc *EthRPC) Web3ClientVersion() (string, error) {
var clientVersion string
err := rpc.call("web3_clientVersion", &clientVersion)
return clientVersion, err
} | go | func (rpc *EthRPC) Web3ClientVersion() (string, error) {
var clientVersion string
err := rpc.call("web3_clientVersion", &clientVersion)
return clientVersion, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"Web3ClientVersion",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"clientVersion",
"string",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"clientVersion",
")",
"\n",
"return",
... | // Web3ClientVersion returns the current client version. | [
"Web3ClientVersion",
"returns",
"the",
"current",
"client",
"version",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L133-L138 |
17,222 | onrik/ethrpc | ethrpc.go | NetVersion | func (rpc *EthRPC) NetVersion() (string, error) {
var version string
err := rpc.call("net_version", &version)
return version, err
} | go | func (rpc *EthRPC) NetVersion() (string, error) {
var version string
err := rpc.call("net_version", &version)
return version, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"NetVersion",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"version",
"string",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"version",
")",
"\n",
"return",
"version",
",",
... | // NetVersion returns the current network protocol version. | [
"NetVersion",
"returns",
"the",
"current",
"network",
"protocol",
"version",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L149-L154 |
17,223 | onrik/ethrpc | ethrpc.go | NetListening | func (rpc *EthRPC) NetListening() (bool, error) {
var listening bool
err := rpc.call("net_listening", &listening)
return listening, err
} | go | func (rpc *EthRPC) NetListening() (bool, error) {
var listening bool
err := rpc.call("net_listening", &listening)
return listening, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"NetListening",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"listening",
"bool",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"listening",
")",
"\n",
"return",
"listening",
",... | // NetListening returns true if client is actively listening for network connections. | [
"NetListening",
"returns",
"true",
"if",
"client",
"is",
"actively",
"listening",
"for",
"network",
"connections",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L157-L162 |
17,224 | onrik/ethrpc | ethrpc.go | EthProtocolVersion | func (rpc *EthRPC) EthProtocolVersion() (string, error) {
var protocolVersion string
err := rpc.call("eth_protocolVersion", &protocolVersion)
return protocolVersion, err
} | go | func (rpc *EthRPC) EthProtocolVersion() (string, error) {
var protocolVersion string
err := rpc.call("eth_protocolVersion", &protocolVersion)
return protocolVersion, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthProtocolVersion",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"protocolVersion",
"string",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"protocolVersion",
")",
"\n",
"return... | // EthProtocolVersion returns the current ethereum protocol version. | [
"EthProtocolVersion",
"returns",
"the",
"current",
"ethereum",
"protocol",
"version",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L175-L180 |
17,225 | onrik/ethrpc | ethrpc.go | EthSyncing | func (rpc *EthRPC) EthSyncing() (*Syncing, error) {
result, err := rpc.RawCall("eth_syncing")
if err != nil {
return nil, err
}
syncing := new(Syncing)
if bytes.Equal(result, []byte("false")) {
return syncing, nil
}
err = json.Unmarshal(result, syncing)
return syncing, err
} | go | func (rpc *EthRPC) EthSyncing() (*Syncing, error) {
result, err := rpc.RawCall("eth_syncing")
if err != nil {
return nil, err
}
syncing := new(Syncing)
if bytes.Equal(result, []byte("false")) {
return syncing, nil
}
err = json.Unmarshal(result, syncing)
return syncing, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthSyncing",
"(",
")",
"(",
"*",
"Syncing",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"rpc",
".",
"RawCall",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"er... | // EthSyncing returns an object with data about the sync status or false. | [
"EthSyncing",
"returns",
"an",
"object",
"with",
"data",
"about",
"the",
"sync",
"status",
"or",
"false",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L183-L194 |
17,226 | onrik/ethrpc | ethrpc.go | EthCoinbase | func (rpc *EthRPC) EthCoinbase() (string, error) {
var address string
err := rpc.call("eth_coinbase", &address)
return address, err
} | go | func (rpc *EthRPC) EthCoinbase() (string, error) {
var address string
err := rpc.call("eth_coinbase", &address)
return address, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthCoinbase",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"address",
"string",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"address",
")",
"\n",
"return",
"address",
",",
... | // EthCoinbase returns the client coinbase address | [
"EthCoinbase",
"returns",
"the",
"client",
"coinbase",
"address"
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L197-L202 |
17,227 | onrik/ethrpc | ethrpc.go | EthMining | func (rpc *EthRPC) EthMining() (bool, error) {
var mining bool
err := rpc.call("eth_mining", &mining)
return mining, err
} | go | func (rpc *EthRPC) EthMining() (bool, error) {
var mining bool
err := rpc.call("eth_mining", &mining)
return mining, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthMining",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"mining",
"bool",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"mining",
")",
"\n",
"return",
"mining",
",",
"err",
... | // EthMining returns true if client is actively mining new blocks. | [
"EthMining",
"returns",
"true",
"if",
"client",
"is",
"actively",
"mining",
"new",
"blocks",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L205-L210 |
17,228 | onrik/ethrpc | ethrpc.go | EthGasPrice | func (rpc *EthRPC) EthGasPrice() (big.Int, error) {
var response string
if err := rpc.call("eth_gasPrice", &response); err != nil {
return big.Int{}, err
}
return ParseBigInt(response)
} | go | func (rpc *EthRPC) EthGasPrice() (big.Int, error) {
var response string
if err := rpc.call("eth_gasPrice", &response); err != nil {
return big.Int{}, err
}
return ParseBigInt(response)
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGasPrice",
"(",
")",
"(",
"big",
".",
"Int",
",",
"error",
")",
"{",
"var",
"response",
"string",
"\n",
"if",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"response",
")",
";",
"err",
"... | // EthGasPrice returns the current price per gas in wei. | [
"EthGasPrice",
"returns",
"the",
"current",
"price",
"per",
"gas",
"in",
"wei",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L224-L231 |
17,229 | onrik/ethrpc | ethrpc.go | EthAccounts | func (rpc *EthRPC) EthAccounts() ([]string, error) {
accounts := []string{}
err := rpc.call("eth_accounts", &accounts)
return accounts, err
} | go | func (rpc *EthRPC) EthAccounts() ([]string, error) {
accounts := []string{}
err := rpc.call("eth_accounts", &accounts)
return accounts, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthAccounts",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"accounts",
":=",
"[",
"]",
"string",
"{",
"}",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"accounts",
")... | // EthAccounts returns a list of addresses owned by client. | [
"EthAccounts",
"returns",
"a",
"list",
"of",
"addresses",
"owned",
"by",
"client",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L234-L239 |
17,230 | onrik/ethrpc | ethrpc.go | EthBlockNumber | func (rpc *EthRPC) EthBlockNumber() (int, error) {
var response string
if err := rpc.call("eth_blockNumber", &response); err != nil {
return 0, err
}
return ParseInt(response)
} | go | func (rpc *EthRPC) EthBlockNumber() (int, error) {
var response string
if err := rpc.call("eth_blockNumber", &response); err != nil {
return 0, err
}
return ParseInt(response)
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthBlockNumber",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"response",
"string",
"\n",
"if",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"response",
")",
";",
"err",
"!=",
"nil",... | // EthBlockNumber returns the number of most recent block. | [
"EthBlockNumber",
"returns",
"the",
"number",
"of",
"most",
"recent",
"block",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L242-L249 |
17,231 | onrik/ethrpc | ethrpc.go | EthGetBalance | func (rpc *EthRPC) EthGetBalance(address, block string) (big.Int, error) {
var response string
if err := rpc.call("eth_getBalance", &response, address, block); err != nil {
return big.Int{}, err
}
return ParseBigInt(response)
} | go | func (rpc *EthRPC) EthGetBalance(address, block string) (big.Int, error) {
var response string
if err := rpc.call("eth_getBalance", &response, address, block); err != nil {
return big.Int{}, err
}
return ParseBigInt(response)
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetBalance",
"(",
"address",
",",
"block",
"string",
")",
"(",
"big",
".",
"Int",
",",
"error",
")",
"{",
"var",
"response",
"string",
"\n",
"if",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
... | // EthGetBalance returns the balance of the account of given address in wei. | [
"EthGetBalance",
"returns",
"the",
"balance",
"of",
"the",
"account",
"of",
"given",
"address",
"in",
"wei",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L252-L259 |
17,232 | onrik/ethrpc | ethrpc.go | EthGetStorageAt | func (rpc *EthRPC) EthGetStorageAt(data string, position int, tag string) (string, error) {
var result string
err := rpc.call("eth_getStorageAt", &result, data, IntToHex(position), tag)
return result, err
} | go | func (rpc *EthRPC) EthGetStorageAt(data string, position int, tag string) (string, error) {
var result string
err := rpc.call("eth_getStorageAt", &result, data, IntToHex(position), tag)
return result, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetStorageAt",
"(",
"data",
"string",
",",
"position",
"int",
",",
"tag",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"result",
"string",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",... | // EthGetStorageAt returns the value from a storage position at a given address. | [
"EthGetStorageAt",
"returns",
"the",
"value",
"from",
"a",
"storage",
"position",
"at",
"a",
"given",
"address",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L262-L267 |
17,233 | onrik/ethrpc | ethrpc.go | EthGetTransactionCount | func (rpc *EthRPC) EthGetTransactionCount(address, block string) (int, error) {
var response string
if err := rpc.call("eth_getTransactionCount", &response, address, block); err != nil {
return 0, err
}
return ParseInt(response)
} | go | func (rpc *EthRPC) EthGetTransactionCount(address, block string) (int, error) {
var response string
if err := rpc.call("eth_getTransactionCount", &response, address, block); err != nil {
return 0, err
}
return ParseInt(response)
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetTransactionCount",
"(",
"address",
",",
"block",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"response",
"string",
"\n\n",
"if",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
... | // EthGetTransactionCount returns the number of transactions sent from an address. | [
"EthGetTransactionCount",
"returns",
"the",
"number",
"of",
"transactions",
"sent",
"from",
"an",
"address",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L270-L278 |
17,234 | onrik/ethrpc | ethrpc.go | EthGetBlockTransactionCountByHash | func (rpc *EthRPC) EthGetBlockTransactionCountByHash(hash string) (int, error) {
var response string
if err := rpc.call("eth_getBlockTransactionCountByHash", &response, hash); err != nil {
return 0, err
}
return ParseInt(response)
} | go | func (rpc *EthRPC) EthGetBlockTransactionCountByHash(hash string) (int, error) {
var response string
if err := rpc.call("eth_getBlockTransactionCountByHash", &response, hash); err != nil {
return 0, err
}
return ParseInt(response)
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetBlockTransactionCountByHash",
"(",
"hash",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"response",
"string",
"\n\n",
"if",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"respons... | // EthGetBlockTransactionCountByHash returns the number of transactions in a block from a block matching the given block hash. | [
"EthGetBlockTransactionCountByHash",
"returns",
"the",
"number",
"of",
"transactions",
"in",
"a",
"block",
"from",
"a",
"block",
"matching",
"the",
"given",
"block",
"hash",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L281-L289 |
17,235 | onrik/ethrpc | ethrpc.go | EthGetBlockTransactionCountByNumber | func (rpc *EthRPC) EthGetBlockTransactionCountByNumber(number int) (int, error) {
var response string
if err := rpc.call("eth_getBlockTransactionCountByNumber", &response, IntToHex(number)); err != nil {
return 0, err
}
return ParseInt(response)
} | go | func (rpc *EthRPC) EthGetBlockTransactionCountByNumber(number int) (int, error) {
var response string
if err := rpc.call("eth_getBlockTransactionCountByNumber", &response, IntToHex(number)); err != nil {
return 0, err
}
return ParseInt(response)
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetBlockTransactionCountByNumber",
"(",
"number",
"int",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"response",
"string",
"\n\n",
"if",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"respon... | // EthGetBlockTransactionCountByNumber returns the number of transactions in a block from a block matching the given block | [
"EthGetBlockTransactionCountByNumber",
"returns",
"the",
"number",
"of",
"transactions",
"in",
"a",
"block",
"from",
"a",
"block",
"matching",
"the",
"given",
"block"
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L292-L300 |
17,236 | onrik/ethrpc | ethrpc.go | EthGetCode | func (rpc *EthRPC) EthGetCode(address, block string) (string, error) {
var code string
err := rpc.call("eth_getCode", &code, address, block)
return code, err
} | go | func (rpc *EthRPC) EthGetCode(address, block string) (string, error) {
var code string
err := rpc.call("eth_getCode", &code, address, block)
return code, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetCode",
"(",
"address",
",",
"block",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"code",
"string",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"code",
",",
"a... | // EthGetCode returns code at a given address. | [
"EthGetCode",
"returns",
"code",
"at",
"a",
"given",
"address",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L325-L330 |
17,237 | onrik/ethrpc | ethrpc.go | EthSendTransaction | func (rpc *EthRPC) EthSendTransaction(transaction T) (string, error) {
var hash string
err := rpc.call("eth_sendTransaction", &hash, transaction)
return hash, err
} | go | func (rpc *EthRPC) EthSendTransaction(transaction T) (string, error) {
var hash string
err := rpc.call("eth_sendTransaction", &hash, transaction)
return hash, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthSendTransaction",
"(",
"transaction",
"T",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"hash",
"string",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"hash",
",",
"transaction"... | // EthSendTransaction creates new message call transaction or a contract creation, if the data field contains code. | [
"EthSendTransaction",
"creates",
"new",
"message",
"call",
"transaction",
"or",
"a",
"contract",
"creation",
"if",
"the",
"data",
"field",
"contains",
"code",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L342-L347 |
17,238 | onrik/ethrpc | ethrpc.go | EthSendRawTransaction | func (rpc *EthRPC) EthSendRawTransaction(data string) (string, error) {
var hash string
err := rpc.call("eth_sendRawTransaction", &hash, data)
return hash, err
} | go | func (rpc *EthRPC) EthSendRawTransaction(data string) (string, error) {
var hash string
err := rpc.call("eth_sendRawTransaction", &hash, data)
return hash, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthSendRawTransaction",
"(",
"data",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"hash",
"string",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"hash",
",",
"data",
")... | // EthSendRawTransaction creates new message call transaction or a contract creation for signed transactions. | [
"EthSendRawTransaction",
"creates",
"new",
"message",
"call",
"transaction",
"or",
"a",
"contract",
"creation",
"for",
"signed",
"transactions",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L350-L355 |
17,239 | onrik/ethrpc | ethrpc.go | EthCall | func (rpc *EthRPC) EthCall(transaction T, tag string) (string, error) {
var data string
err := rpc.call("eth_call", &data, transaction, tag)
return data, err
} | go | func (rpc *EthRPC) EthCall(transaction T, tag string) (string, error) {
var data string
err := rpc.call("eth_call", &data, transaction, tag)
return data, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthCall",
"(",
"transaction",
"T",
",",
"tag",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"data",
"string",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"data",
","... | // EthCall executes a new message call immediately without creating a transaction on the block chain. | [
"EthCall",
"executes",
"a",
"new",
"message",
"call",
"immediately",
"without",
"creating",
"a",
"transaction",
"on",
"the",
"block",
"chain",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L358-L363 |
17,240 | onrik/ethrpc | ethrpc.go | EthEstimateGas | func (rpc *EthRPC) EthEstimateGas(transaction T) (int, error) {
var response string
err := rpc.call("eth_estimateGas", &response, transaction)
if err != nil {
return 0, err
}
return ParseInt(response)
} | go | func (rpc *EthRPC) EthEstimateGas(transaction T) (int, error) {
var response string
err := rpc.call("eth_estimateGas", &response, transaction)
if err != nil {
return 0, err
}
return ParseInt(response)
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthEstimateGas",
"(",
"transaction",
"T",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"response",
"string",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"response",
",",
"transaction... | // EthEstimateGas makes a call or transaction, which won't be added to the blockchain and returns the used gas, which can be used for estimating the used gas. | [
"EthEstimateGas",
"makes",
"a",
"call",
"or",
"transaction",
"which",
"won",
"t",
"be",
"added",
"to",
"the",
"blockchain",
"and",
"returns",
"the",
"used",
"gas",
"which",
"can",
"be",
"used",
"for",
"estimating",
"the",
"used",
"gas",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L366-L375 |
17,241 | onrik/ethrpc | ethrpc.go | EthGetBlockByHash | func (rpc *EthRPC) EthGetBlockByHash(hash string, withTransactions bool) (*Block, error) {
return rpc.getBlock("eth_getBlockByHash", withTransactions, hash, withTransactions)
} | go | func (rpc *EthRPC) EthGetBlockByHash(hash string, withTransactions bool) (*Block, error) {
return rpc.getBlock("eth_getBlockByHash", withTransactions, hash, withTransactions)
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetBlockByHash",
"(",
"hash",
"string",
",",
"withTransactions",
"bool",
")",
"(",
"*",
"Block",
",",
"error",
")",
"{",
"return",
"rpc",
".",
"getBlock",
"(",
"\"",
"\"",
",",
"withTransactions",
",",
"hash",
... | // EthGetBlockByHash returns information about a block by hash. | [
"EthGetBlockByHash",
"returns",
"information",
"about",
"a",
"block",
"by",
"hash",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L403-L405 |
17,242 | onrik/ethrpc | ethrpc.go | EthGetBlockByNumber | func (rpc *EthRPC) EthGetBlockByNumber(number int, withTransactions bool) (*Block, error) {
return rpc.getBlock("eth_getBlockByNumber", withTransactions, IntToHex(number), withTransactions)
} | go | func (rpc *EthRPC) EthGetBlockByNumber(number int, withTransactions bool) (*Block, error) {
return rpc.getBlock("eth_getBlockByNumber", withTransactions, IntToHex(number), withTransactions)
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetBlockByNumber",
"(",
"number",
"int",
",",
"withTransactions",
"bool",
")",
"(",
"*",
"Block",
",",
"error",
")",
"{",
"return",
"rpc",
".",
"getBlock",
"(",
"\"",
"\"",
",",
"withTransactions",
",",
"IntToH... | // EthGetBlockByNumber returns information about a block by block number. | [
"EthGetBlockByNumber",
"returns",
"information",
"about",
"a",
"block",
"by",
"block",
"number",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L408-L410 |
17,243 | onrik/ethrpc | ethrpc.go | EthGetTransactionByHash | func (rpc *EthRPC) EthGetTransactionByHash(hash string) (*Transaction, error) {
return rpc.getTransaction("eth_getTransactionByHash", hash)
} | go | func (rpc *EthRPC) EthGetTransactionByHash(hash string) (*Transaction, error) {
return rpc.getTransaction("eth_getTransactionByHash", hash)
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetTransactionByHash",
"(",
"hash",
"string",
")",
"(",
"*",
"Transaction",
",",
"error",
")",
"{",
"return",
"rpc",
".",
"getTransaction",
"(",
"\"",
"\"",
",",
"hash",
")",
"\n",
"}"
] | // EthGetTransactionByHash returns the information about a transaction requested by transaction hash. | [
"EthGetTransactionByHash",
"returns",
"the",
"information",
"about",
"a",
"transaction",
"requested",
"by",
"transaction",
"hash",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L420-L422 |
17,244 | onrik/ethrpc | ethrpc.go | EthGetTransactionByBlockHashAndIndex | func (rpc *EthRPC) EthGetTransactionByBlockHashAndIndex(blockHash string, transactionIndex int) (*Transaction, error) {
return rpc.getTransaction("eth_getTransactionByBlockHashAndIndex", blockHash, IntToHex(transactionIndex))
} | go | func (rpc *EthRPC) EthGetTransactionByBlockHashAndIndex(blockHash string, transactionIndex int) (*Transaction, error) {
return rpc.getTransaction("eth_getTransactionByBlockHashAndIndex", blockHash, IntToHex(transactionIndex))
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetTransactionByBlockHashAndIndex",
"(",
"blockHash",
"string",
",",
"transactionIndex",
"int",
")",
"(",
"*",
"Transaction",
",",
"error",
")",
"{",
"return",
"rpc",
".",
"getTransaction",
"(",
"\"",
"\"",
",",
"b... | // EthGetTransactionByBlockHashAndIndex returns information about a transaction by block hash and transaction index position. | [
"EthGetTransactionByBlockHashAndIndex",
"returns",
"information",
"about",
"a",
"transaction",
"by",
"block",
"hash",
"and",
"transaction",
"index",
"position",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L425-L427 |
17,245 | onrik/ethrpc | ethrpc.go | EthGetTransactionByBlockNumberAndIndex | func (rpc *EthRPC) EthGetTransactionByBlockNumberAndIndex(blockNumber, transactionIndex int) (*Transaction, error) {
return rpc.getTransaction("eth_getTransactionByBlockNumberAndIndex", IntToHex(blockNumber), IntToHex(transactionIndex))
} | go | func (rpc *EthRPC) EthGetTransactionByBlockNumberAndIndex(blockNumber, transactionIndex int) (*Transaction, error) {
return rpc.getTransaction("eth_getTransactionByBlockNumberAndIndex", IntToHex(blockNumber), IntToHex(transactionIndex))
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetTransactionByBlockNumberAndIndex",
"(",
"blockNumber",
",",
"transactionIndex",
"int",
")",
"(",
"*",
"Transaction",
",",
"error",
")",
"{",
"return",
"rpc",
".",
"getTransaction",
"(",
"\"",
"\"",
",",
"IntToHex"... | // EthGetTransactionByBlockNumberAndIndex returns information about a transaction by block number and transaction index position. | [
"EthGetTransactionByBlockNumberAndIndex",
"returns",
"information",
"about",
"a",
"transaction",
"by",
"block",
"number",
"and",
"transaction",
"index",
"position",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L430-L432 |
17,246 | onrik/ethrpc | ethrpc.go | EthGetTransactionReceipt | func (rpc *EthRPC) EthGetTransactionReceipt(hash string) (*TransactionReceipt, error) {
transactionReceipt := new(TransactionReceipt)
err := rpc.call("eth_getTransactionReceipt", transactionReceipt, hash)
if err != nil {
return nil, err
}
return transactionReceipt, nil
} | go | func (rpc *EthRPC) EthGetTransactionReceipt(hash string) (*TransactionReceipt, error) {
transactionReceipt := new(TransactionReceipt)
err := rpc.call("eth_getTransactionReceipt", transactionReceipt, hash)
if err != nil {
return nil, err
}
return transactionReceipt, nil
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetTransactionReceipt",
"(",
"hash",
"string",
")",
"(",
"*",
"TransactionReceipt",
",",
"error",
")",
"{",
"transactionReceipt",
":=",
"new",
"(",
"TransactionReceipt",
")",
"\n\n",
"err",
":=",
"rpc",
".",
"call"... | // EthGetTransactionReceipt returns the receipt of a transaction by transaction hash.
// Note That the receipt is not available for pending transactions. | [
"EthGetTransactionReceipt",
"returns",
"the",
"receipt",
"of",
"a",
"transaction",
"by",
"transaction",
"hash",
".",
"Note",
"That",
"the",
"receipt",
"is",
"not",
"available",
"for",
"pending",
"transactions",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L436-L445 |
17,247 | onrik/ethrpc | ethrpc.go | EthGetCompilers | func (rpc *EthRPC) EthGetCompilers() ([]string, error) {
compilers := []string{}
err := rpc.call("eth_getCompilers", &compilers)
return compilers, err
} | go | func (rpc *EthRPC) EthGetCompilers() ([]string, error) {
compilers := []string{}
err := rpc.call("eth_getCompilers", &compilers)
return compilers, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetCompilers",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"compilers",
":=",
"[",
"]",
"string",
"{",
"}",
"\n\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"compilers"... | // EthGetCompilers returns a list of available compilers in the client. | [
"EthGetCompilers",
"returns",
"a",
"list",
"of",
"available",
"compilers",
"in",
"the",
"client",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L448-L453 |
17,248 | onrik/ethrpc | ethrpc.go | EthNewFilter | func (rpc *EthRPC) EthNewFilter(params FilterParams) (string, error) {
var filterID string
err := rpc.call("eth_newFilter", &filterID, params)
return filterID, err
} | go | func (rpc *EthRPC) EthNewFilter(params FilterParams) (string, error) {
var filterID string
err := rpc.call("eth_newFilter", &filterID, params)
return filterID, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthNewFilter",
"(",
"params",
"FilterParams",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"filterID",
"string",
"\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"filterID",
",",
"params... | // EthNewFilter creates a new filter object. | [
"EthNewFilter",
"creates",
"a",
"new",
"filter",
"object",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L456-L460 |
17,249 | onrik/ethrpc | ethrpc.go | EthNewBlockFilter | func (rpc *EthRPC) EthNewBlockFilter() (string, error) {
var filterID string
err := rpc.call("eth_newBlockFilter", &filterID)
return filterID, err
} | go | func (rpc *EthRPC) EthNewBlockFilter() (string, error) {
var filterID string
err := rpc.call("eth_newBlockFilter", &filterID)
return filterID, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthNewBlockFilter",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"filterID",
"string",
"\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"filterID",
")",
"\n",
"return",
"filterID",
... | // EthNewBlockFilter creates a filter in the node, to notify when a new block arrives.
// To check if the state has changed, call EthGetFilterChanges. | [
"EthNewBlockFilter",
"creates",
"a",
"filter",
"in",
"the",
"node",
"to",
"notify",
"when",
"a",
"new",
"block",
"arrives",
".",
"To",
"check",
"if",
"the",
"state",
"has",
"changed",
"call",
"EthGetFilterChanges",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L464-L468 |
17,250 | onrik/ethrpc | ethrpc.go | EthNewPendingTransactionFilter | func (rpc *EthRPC) EthNewPendingTransactionFilter() (string, error) {
var filterID string
err := rpc.call("eth_newPendingTransactionFilter", &filterID)
return filterID, err
} | go | func (rpc *EthRPC) EthNewPendingTransactionFilter() (string, error) {
var filterID string
err := rpc.call("eth_newPendingTransactionFilter", &filterID)
return filterID, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthNewPendingTransactionFilter",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"filterID",
"string",
"\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"filterID",
")",
"\n",
"return",
... | // EthNewPendingTransactionFilter creates a filter in the node, to notify when new pending transactions arrive.
// To check if the state has changed, call EthGetFilterChanges. | [
"EthNewPendingTransactionFilter",
"creates",
"a",
"filter",
"in",
"the",
"node",
"to",
"notify",
"when",
"new",
"pending",
"transactions",
"arrive",
".",
"To",
"check",
"if",
"the",
"state",
"has",
"changed",
"call",
"EthGetFilterChanges",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L472-L476 |
17,251 | onrik/ethrpc | ethrpc.go | EthUninstallFilter | func (rpc *EthRPC) EthUninstallFilter(filterID string) (bool, error) {
var res bool
err := rpc.call("eth_uninstallFilter", &res, filterID)
return res, err
} | go | func (rpc *EthRPC) EthUninstallFilter(filterID string) (bool, error) {
var res bool
err := rpc.call("eth_uninstallFilter", &res, filterID)
return res, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthUninstallFilter",
"(",
"filterID",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"res",
"bool",
"\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
"&",
"res",
",",
"filterID",
")",
... | // EthUninstallFilter uninstalls a filter with given id. | [
"EthUninstallFilter",
"uninstalls",
"a",
"filter",
"with",
"given",
"id",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L479-L483 |
17,252 | onrik/ethrpc | ethrpc.go | EthGetFilterChanges | func (rpc *EthRPC) EthGetFilterChanges(filterID string) ([]Log, error) {
var logs = []Log{}
err := rpc.call("eth_getFilterChanges", &logs, filterID)
return logs, err
} | go | func (rpc *EthRPC) EthGetFilterChanges(filterID string) ([]Log, error) {
var logs = []Log{}
err := rpc.call("eth_getFilterChanges", &logs, filterID)
return logs, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetFilterChanges",
"(",
"filterID",
"string",
")",
"(",
"[",
"]",
"Log",
",",
"error",
")",
"{",
"var",
"logs",
"=",
"[",
"]",
"Log",
"{",
"}",
"\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
... | // EthGetFilterChanges polling method for a filter, which returns an array of logs which occurred since last poll. | [
"EthGetFilterChanges",
"polling",
"method",
"for",
"a",
"filter",
"which",
"returns",
"an",
"array",
"of",
"logs",
"which",
"occurred",
"since",
"last",
"poll",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L486-L490 |
17,253 | onrik/ethrpc | ethrpc.go | EthGetLogs | func (rpc *EthRPC) EthGetLogs(params FilterParams) ([]Log, error) {
var logs = []Log{}
err := rpc.call("eth_getLogs", &logs, params)
return logs, err
} | go | func (rpc *EthRPC) EthGetLogs(params FilterParams) ([]Log, error) {
var logs = []Log{}
err := rpc.call("eth_getLogs", &logs, params)
return logs, err
} | [
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"EthGetLogs",
"(",
"params",
"FilterParams",
")",
"(",
"[",
"]",
"Log",
",",
"error",
")",
"{",
"var",
"logs",
"=",
"[",
"]",
"Log",
"{",
"}",
"\n",
"err",
":=",
"rpc",
".",
"call",
"(",
"\"",
"\"",
",",
... | // EthGetLogs returns an array of all logs matching a given filter object. | [
"EthGetLogs",
"returns",
"an",
"array",
"of",
"all",
"logs",
"matching",
"a",
"given",
"filter",
"object",
"."
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/ethrpc.go#L500-L504 |
17,254 | onrik/ethrpc | options.go | WithHttpClient | func WithHttpClient(client httpClient) func(rpc *EthRPC) {
return func(rpc *EthRPC) {
rpc.client = client
}
} | go | func WithHttpClient(client httpClient) func(rpc *EthRPC) {
return func(rpc *EthRPC) {
rpc.client = client
}
} | [
"func",
"WithHttpClient",
"(",
"client",
"httpClient",
")",
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"{",
"return",
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"{",
"rpc",
".",
"client",
"=",
"client",
"\n",
"}",
"\n",
"}"
] | // WithHttpClient set custom http client | [
"WithHttpClient",
"set",
"custom",
"http",
"client"
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/options.go#L17-L21 |
17,255 | onrik/ethrpc | options.go | WithLogger | func WithLogger(l logger) func(rpc *EthRPC) {
return func(rpc *EthRPC) {
rpc.log = l
}
} | go | func WithLogger(l logger) func(rpc *EthRPC) {
return func(rpc *EthRPC) {
rpc.log = l
}
} | [
"func",
"WithLogger",
"(",
"l",
"logger",
")",
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"{",
"return",
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"{",
"rpc",
".",
"log",
"=",
"l",
"\n",
"}",
"\n",
"}"
] | // WithLogger set custom logger | [
"WithLogger",
"set",
"custom",
"logger"
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/options.go#L24-L28 |
17,256 | onrik/ethrpc | options.go | WithDebug | func WithDebug(enabled bool) func(rpc *EthRPC) {
return func(rpc *EthRPC) {
rpc.Debug = enabled
}
} | go | func WithDebug(enabled bool) func(rpc *EthRPC) {
return func(rpc *EthRPC) {
rpc.Debug = enabled
}
} | [
"func",
"WithDebug",
"(",
"enabled",
"bool",
")",
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"{",
"return",
"func",
"(",
"rpc",
"*",
"EthRPC",
")",
"{",
"rpc",
".",
"Debug",
"=",
"enabled",
"\n",
"}",
"\n",
"}"
] | // WithDebug set debug flag | [
"WithDebug",
"set",
"debug",
"flag"
] | 6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788 | https://github.com/onrik/ethrpc/blob/6b8e9c0e9a8ffd2154cd4470a6ffb4919885e788/options.go#L31-L35 |
17,257 | pborman/getopt | v2/generic.go | Flag | func Flag(v interface{}, short rune, helpvalue ...string) Option {
return CommandLine.long(v, "", short, helpvalue...)
} | go | func Flag(v interface{}, short rune, helpvalue ...string) Option {
return CommandLine.long(v, "", short, helpvalue...)
} | [
"func",
"Flag",
"(",
"v",
"interface",
"{",
"}",
",",
"short",
"rune",
",",
"helpvalue",
"...",
"string",
")",
"Option",
"{",
"return",
"CommandLine",
".",
"long",
"(",
"v",
",",
"\"",
"\"",
",",
"short",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // Flag is shorthand for CommandLine.Flag. | [
"Flag",
"is",
"shorthand",
"for",
"CommandLine",
".",
"Flag",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/generic.go#L19-L21 |
17,258 | pborman/getopt | v2/generic.go | FlagLong | func FlagLong(v interface{}, long string, short rune, helpvalue ...string) Option {
return CommandLine.long(v, long, short, helpvalue...)
} | go | func FlagLong(v interface{}, long string, short rune, helpvalue ...string) Option {
return CommandLine.long(v, long, short, helpvalue...)
} | [
"func",
"FlagLong",
"(",
"v",
"interface",
"{",
"}",
",",
"long",
"string",
",",
"short",
"rune",
",",
"helpvalue",
"...",
"string",
")",
"Option",
"{",
"return",
"CommandLine",
".",
"long",
"(",
"v",
",",
"long",
",",
"short",
",",
"helpvalue",
"...",... | // FlagLong is shorthand for CommandLine.LongFlag. | [
"FlagLong",
"is",
"shorthand",
"for",
"CommandLine",
".",
"LongFlag",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/generic.go#L24-L26 |
17,259 | pborman/getopt | v2/generic.go | Flag | func (s *Set) Flag(v interface{}, short rune, helpvalue ...string) Option {
return s.long(v, "", short, helpvalue...)
} | go | func (s *Set) Flag(v interface{}, short rune, helpvalue ...string) Option {
return s.long(v, "", short, helpvalue...)
} | [
"func",
"(",
"s",
"*",
"Set",
")",
"Flag",
"(",
"v",
"interface",
"{",
"}",
",",
"short",
"rune",
",",
"helpvalue",
"...",
"string",
")",
"Option",
"{",
"return",
"s",
".",
"long",
"(",
"v",
",",
"\"",
"\"",
",",
"short",
",",
"helpvalue",
"...",... | // Flag calls FlagLong with only a short flag name. | [
"Flag",
"calls",
"FlagLong",
"with",
"only",
"a",
"short",
"flag",
"name",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/generic.go#L29-L31 |
17,260 | pborman/getopt | v2/generic.go | genericValue | func genericValue(v Value) interface{} {
if g, ok := v.(*generic); ok {
return g.p
}
return nil
} | go | func genericValue(v Value) interface{} {
if g, ok := v.(*generic); ok {
return g.p
}
return nil
} | [
"func",
"genericValue",
"(",
"v",
"Value",
")",
"interface",
"{",
"}",
"{",
"if",
"g",
",",
"ok",
":=",
"v",
".",
"(",
"*",
"generic",
")",
";",
"ok",
"{",
"return",
"g",
".",
"p",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // genericValue returns the object underlying the generic Value v, or nil if v
// is not a generic Value. | [
"genericValue",
"returns",
"the",
"object",
"underlying",
"the",
"generic",
"Value",
"v",
"or",
"nil",
"if",
"v",
"is",
"not",
"a",
"generic",
"Value",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/generic.go#L84-L89 |
17,261 | pborman/getopt | uint64.go | Uint64 | func Uint64(name rune, value uint64, helpvalue ...string) *uint64 {
return CommandLine.Uint64(name, value, helpvalue...)
} | go | func Uint64(name rune, value uint64, helpvalue ...string) *uint64 {
return CommandLine.Uint64(name, value, helpvalue...)
} | [
"func",
"Uint64",
"(",
"name",
"rune",
",",
"value",
"uint64",
",",
"helpvalue",
"...",
"string",
")",
"*",
"uint64",
"{",
"return",
"CommandLine",
".",
"Uint64",
"(",
"name",
",",
"value",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // Uint64 creates an option that parses its value as a uint64. | [
"Uint64",
"creates",
"an",
"option",
"that",
"parses",
"its",
"value",
"as",
"a",
"uint64",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/uint64.go#L36-L38 |
17,262 | pborman/getopt | list.go | List | func List(name rune, helpvalue ...string) *[]string {
return CommandLine.List(name, helpvalue...)
} | go | func List(name rune, helpvalue ...string) *[]string {
return CommandLine.List(name, helpvalue...)
} | [
"func",
"List",
"(",
"name",
"rune",
",",
"helpvalue",
"...",
"string",
")",
"*",
"[",
"]",
"string",
"{",
"return",
"CommandLine",
".",
"List",
"(",
"name",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // List creates an option that returns a slice of strings. The parameters
// passed are converted from a comma seperated value list into a slice.
// Subsequent occurrences append to the list. | [
"List",
"creates",
"an",
"option",
"that",
"returns",
"a",
"slice",
"of",
"strings",
".",
"The",
"parameters",
"passed",
"are",
"converted",
"from",
"a",
"comma",
"seperated",
"value",
"list",
"into",
"a",
"slice",
".",
"Subsequent",
"occurrences",
"append",
... | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/list.go#L29-L31 |
17,263 | pborman/getopt | list.go | ListVar | func ListVar(p *[]string, name rune, helpvalue ...string) Option {
return CommandLine.ListVar(p, name, helpvalue...)
} | go | func ListVar(p *[]string, name rune, helpvalue ...string) Option {
return CommandLine.ListVar(p, name, helpvalue...)
} | [
"func",
"ListVar",
"(",
"p",
"*",
"[",
"]",
"string",
",",
"name",
"rune",
",",
"helpvalue",
"...",
"string",
")",
"Option",
"{",
"return",
"CommandLine",
".",
"ListVar",
"(",
"p",
",",
"name",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // ListVar creats a list option and places the values in p. If p is pointing
// to a list of values then those are considered the default values. The first
// time name is seen in the options the list will be set to list specified by
// the parameter to the option. Subsequent instances of the option will append
// t... | [
"ListVar",
"creats",
"a",
"list",
"option",
"and",
"places",
"the",
"values",
"in",
"p",
".",
"If",
"p",
"is",
"pointing",
"to",
"a",
"list",
"of",
"values",
"then",
"those",
"are",
"considered",
"the",
"default",
"values",
".",
"The",
"first",
"time",
... | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/list.go#L54-L56 |
17,264 | pborman/getopt | var.go | Var | func Var(p Value, name rune, helpvalue ...string) Option {
return CommandLine.VarLong(p, "", name, helpvalue...)
} | go | func Var(p Value, name rune, helpvalue ...string) Option {
return CommandLine.VarLong(p, "", name, helpvalue...)
} | [
"func",
"Var",
"(",
"p",
"Value",
",",
"name",
"rune",
",",
"helpvalue",
"...",
"string",
")",
"Option",
"{",
"return",
"CommandLine",
".",
"VarLong",
"(",
"p",
",",
"\"",
"\"",
",",
"name",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // Var creates an option of the specified name. The type and value of the option
// are represented by the first argument, of type Value, which typically holds a
// user-defined implementation of Value. All options are ultimately created
// as a Var. | [
"Var",
"creates",
"an",
"option",
"of",
"the",
"specified",
"name",
".",
"The",
"type",
"and",
"value",
"of",
"the",
"option",
"are",
"represented",
"by",
"the",
"first",
"argument",
"of",
"type",
"Value",
"which",
"typically",
"holds",
"a",
"user",
"-",
... | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/var.go#L24-L26 |
17,265 | pborman/getopt | uint16.go | Uint16 | func Uint16(name rune, value uint16, helpvalue ...string) *uint16 {
return CommandLine.Uint16(name, value, helpvalue...)
} | go | func Uint16(name rune, value uint16, helpvalue ...string) *uint16 {
return CommandLine.Uint16(name, value, helpvalue...)
} | [
"func",
"Uint16",
"(",
"name",
"rune",
",",
"value",
"uint16",
",",
"helpvalue",
"...",
"string",
")",
"*",
"uint16",
"{",
"return",
"CommandLine",
".",
"Uint16",
"(",
"name",
",",
"value",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // Uint16 creates an option that parses its value as an uint16. | [
"Uint16",
"creates",
"an",
"option",
"that",
"parses",
"its",
"value",
"as",
"an",
"uint16",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/uint16.go#L36-L38 |
17,266 | pborman/getopt | v2/list.go | List | func List(name rune, helpvalue ...string) *[]string {
p := []string{}
CommandLine.Flag(&p, name, helpvalue...)
return &p
} | go | func List(name rune, helpvalue ...string) *[]string {
p := []string{}
CommandLine.Flag(&p, name, helpvalue...)
return &p
} | [
"func",
"List",
"(",
"name",
"rune",
",",
"helpvalue",
"...",
"string",
")",
"*",
"[",
"]",
"string",
"{",
"p",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"CommandLine",
".",
"Flag",
"(",
"&",
"p",
",",
"name",
",",
"helpvalue",
"...",
")",
"\n",
... | // List creates an option that returns a slice of strings. The parameters
// passed are converted from a comma separated value list into a slice.
// Subsequent occurrences append to the list. | [
"List",
"creates",
"an",
"option",
"that",
"returns",
"a",
"slice",
"of",
"strings",
".",
"The",
"parameters",
"passed",
"are",
"converted",
"from",
"a",
"comma",
"separated",
"value",
"list",
"into",
"a",
"slice",
".",
"Subsequent",
"occurrences",
"append",
... | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/list.go#L10-L14 |
17,267 | pborman/getopt | int32.go | Int32 | func Int32(name rune, value int32, helpvalue ...string) *int32 {
return CommandLine.Int32(name, value, helpvalue...)
} | go | func Int32(name rune, value int32, helpvalue ...string) *int32 {
return CommandLine.Int32(name, value, helpvalue...)
} | [
"func",
"Int32",
"(",
"name",
"rune",
",",
"value",
"int32",
",",
"helpvalue",
"...",
"string",
")",
"*",
"int32",
"{",
"return",
"CommandLine",
".",
"Int32",
"(",
"name",
",",
"value",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // Int32 creates an option that parses its value as an int32. | [
"Int32",
"creates",
"an",
"option",
"that",
"parses",
"its",
"value",
"as",
"an",
"int32",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/int32.go#L36-L38 |
17,268 | pborman/getopt | v2/int.go | Int | func Int(name rune, value int, helpvalue ...string) *int {
return CommandLine.Int(name, value, helpvalue...)
} | go | func Int(name rune, value int, helpvalue ...string) *int {
return CommandLine.Int(name, value, helpvalue...)
} | [
"func",
"Int",
"(",
"name",
"rune",
",",
"value",
"int",
",",
"helpvalue",
"...",
"string",
")",
"*",
"int",
"{",
"return",
"CommandLine",
".",
"Int",
"(",
"name",
",",
"value",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // Int creates an option that parses its value as an integer. | [
"Int",
"creates",
"an",
"option",
"that",
"parses",
"its",
"value",
"as",
"an",
"integer",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/int.go#L8-L10 |
17,269 | pborman/getopt | v2/int.go | Int16 | func Int16(name rune, value int16, helpvalue ...string) *int16 {
return CommandLine.Int16(name, value, helpvalue...)
} | go | func Int16(name rune, value int16, helpvalue ...string) *int16 {
return CommandLine.Int16(name, value, helpvalue...)
} | [
"func",
"Int16",
"(",
"name",
"rune",
",",
"value",
"int16",
",",
"helpvalue",
"...",
"string",
")",
"*",
"int16",
"{",
"return",
"CommandLine",
".",
"Int16",
"(",
"name",
",",
"value",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // Int16 creates an option that parses its value as a 16 bit integer. | [
"Int16",
"creates",
"an",
"option",
"that",
"parses",
"its",
"value",
"as",
"a",
"16",
"bit",
"integer",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/int.go#L27-L29 |
17,270 | pborman/getopt | v2/int.go | Int64 | func Int64(name rune, value int64, helpvalue ...string) *int64 {
return CommandLine.Int64(name, value, helpvalue...)
} | go | func Int64(name rune, value int64, helpvalue ...string) *int64 {
return CommandLine.Int64(name, value, helpvalue...)
} | [
"func",
"Int64",
"(",
"name",
"rune",
",",
"value",
"int64",
",",
"helpvalue",
"...",
"string",
")",
"*",
"int64",
"{",
"return",
"CommandLine",
".",
"Int64",
"(",
"name",
",",
"value",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // Int64 creates an option that parses its value as a 64 bit integer. | [
"Int64",
"creates",
"an",
"option",
"that",
"parses",
"its",
"value",
"as",
"a",
"64",
"bit",
"integer",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/int.go#L65-L67 |
17,271 | pborman/getopt | v2/int.go | Uint | func Uint(name rune, value uint, helpvalue ...string) *uint {
return CommandLine.Uint(name, value, helpvalue...)
} | go | func Uint(name rune, value uint, helpvalue ...string) *uint {
return CommandLine.Uint(name, value, helpvalue...)
} | [
"func",
"Uint",
"(",
"name",
"rune",
",",
"value",
"uint",
",",
"helpvalue",
"...",
"string",
")",
"*",
"uint",
"{",
"return",
"CommandLine",
".",
"Uint",
"(",
"name",
",",
"value",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // Uint creates an option that parses its value as an unsigned integer. | [
"Uint",
"creates",
"an",
"option",
"that",
"parses",
"its",
"value",
"as",
"an",
"unsigned",
"integer",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/int.go#L84-L86 |
17,272 | pborman/getopt | v2/int.go | Uint32 | func Uint32(name rune, value uint32, helpvalue ...string) *uint32 {
return CommandLine.Uint32(name, value, helpvalue...)
} | go | func Uint32(name rune, value uint32, helpvalue ...string) *uint32 {
return CommandLine.Uint32(name, value, helpvalue...)
} | [
"func",
"Uint32",
"(",
"name",
"rune",
",",
"value",
"uint32",
",",
"helpvalue",
"...",
"string",
")",
"*",
"uint32",
"{",
"return",
"CommandLine",
".",
"Uint32",
"(",
"name",
",",
"value",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // Uint32 creates an option that parses its value as a 32 bit unsigned integer. | [
"Uint32",
"creates",
"an",
"option",
"that",
"parses",
"its",
"value",
"as",
"a",
"32",
"bit",
"unsigned",
"integer",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/int.go#L122-L124 |
17,273 | pborman/getopt | v2/getopt.go | PrintUsage | func (s *Set) PrintUsage(w io.Writer) {
parts := make([]string, 2, 4)
parts[0] = "Usage:"
parts[1] = s.program
if usage := s.UsageLine(); usage != "" {
parts = append(parts, usage)
}
if s.parameters != "" {
parts = append(parts, s.parameters)
}
fmt.Fprintln(w, strings.Join(parts, " "))
s.PrintOptions(w)
} | go | func (s *Set) PrintUsage(w io.Writer) {
parts := make([]string, 2, 4)
parts[0] = "Usage:"
parts[1] = s.program
if usage := s.UsageLine(); usage != "" {
parts = append(parts, usage)
}
if s.parameters != "" {
parts = append(parts, s.parameters)
}
fmt.Fprintln(w, strings.Join(parts, " "))
s.PrintOptions(w)
} | [
"func",
"(",
"s",
"*",
"Set",
")",
"PrintUsage",
"(",
"w",
"io",
".",
"Writer",
")",
"{",
"parts",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"2",
",",
"4",
")",
"\n",
"parts",
"[",
"0",
"]",
"=",
"\"",
"\"",
"\n",
"parts",
"[",
"1",
"]",
... | // PrintUsage prints the usage line and set of options of set S to w. | [
"PrintUsage",
"prints",
"the",
"usage",
"line",
"and",
"set",
"of",
"options",
"of",
"set",
"S",
"to",
"w",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/getopt.go#L229-L241 |
17,274 | pborman/getopt | v2/getopt.go | UsageLine | func (s *Set) UsageLine() string {
sort.Sort(s.options)
flags := ""
// Build up the list of short flag names and also compute
// how to display the option in the longer help listing.
// We also keep track of the longest option usage string
// that is no more than HelpColumn-3 bytes (at which point
// we use two... | go | func (s *Set) UsageLine() string {
sort.Sort(s.options)
flags := ""
// Build up the list of short flag names and also compute
// how to display the option in the longer help listing.
// We also keep track of the longest option usage string
// that is no more than HelpColumn-3 bytes (at which point
// we use two... | [
"func",
"(",
"s",
"*",
"Set",
")",
"UsageLine",
"(",
")",
"string",
"{",
"sort",
".",
"Sort",
"(",
"s",
".",
"options",
")",
"\n",
"flags",
":=",
"\"",
"\"",
"\n\n",
"// Build up the list of short flag names and also compute",
"// how to display the option in the ... | // UsageLine returns the usage line for the set s. The set's program name and
// parameters, if any, are not included. | [
"UsageLine",
"returns",
"the",
"usage",
"line",
"for",
"the",
"set",
"s",
".",
"The",
"set",
"s",
"program",
"name",
"and",
"parameters",
"if",
"any",
"are",
"not",
"included",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/getopt.go#L245-L300 |
17,275 | pborman/getopt | v2/getopt.go | breakup | func breakup(s string, max int) []string {
var a []string
for {
// strip leading spaces
for len(s) > 0 && s[0] == ' ' {
s = s[1:]
}
// If the option is no longer than the max just return it
if len(s) <= max {
if len(s) != 0 {
a = append(a, s)
}
return a
}
x := max
for s[x] != ' ' {
... | go | func breakup(s string, max int) []string {
var a []string
for {
// strip leading spaces
for len(s) > 0 && s[0] == ' ' {
s = s[1:]
}
// If the option is no longer than the max just return it
if len(s) <= max {
if len(s) != 0 {
a = append(a, s)
}
return a
}
x := max
for s[x] != ' ' {
... | [
"func",
"breakup",
"(",
"s",
"string",
",",
"max",
"int",
")",
"[",
"]",
"string",
"{",
"var",
"a",
"[",
"]",
"string",
"\n\n",
"for",
"{",
"// strip leading spaces",
"for",
"len",
"(",
"s",
")",
">",
"0",
"&&",
"s",
"[",
"0",
"]",
"==",
"' '",
... | // breakup breaks s up into strings no longer than max bytes. | [
"breakup",
"breaks",
"s",
"up",
"into",
"strings",
"no",
"longer",
"than",
"max",
"bytes",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/getopt.go#L374-L410 |
17,276 | pborman/getopt | v2/getopt.go | Parse | func (s *Set) Parse(args []string) {
if err := s.Getopt(args, nil); err != nil {
fmt.Fprintln(stderr, err)
s.usage()
exit(1)
}
} | go | func (s *Set) Parse(args []string) {
if err := s.Getopt(args, nil); err != nil {
fmt.Fprintln(stderr, err)
s.usage()
exit(1)
}
} | [
"func",
"(",
"s",
"*",
"Set",
")",
"Parse",
"(",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"err",
":=",
"s",
".",
"Getopt",
"(",
"args",
",",
"nil",
")",
";",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintln",
"(",
"stderr",
",",
"err",
")",
... | // Parse uses Getopt to parse args using the options set for s. The first
// element of args is used to assign the program for s if it is not yet set. On
// error, Parse displays the error message as well as a usage message on
// standard error and then exits the program. | [
"Parse",
"uses",
"Getopt",
"to",
"parse",
"args",
"using",
"the",
"options",
"set",
"for",
"s",
".",
"The",
"first",
"element",
"of",
"args",
"is",
"used",
"to",
"assign",
"the",
"program",
"for",
"s",
"if",
"it",
"is",
"not",
"yet",
"set",
".",
"On"... | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/getopt.go#L416-L422 |
17,277 | pborman/getopt | getopt.go | PrintUsage | func (s *Set) PrintUsage(w io.Writer) {
sort.Sort(s.options)
flags := ""
// Build up the list of short flag names and also compute
// how to display the option in the longer help listing.
// We also keep track of the longest option usage string
// that is no more than HelpColumn-3 bytes (at which point
// we us... | go | func (s *Set) PrintUsage(w io.Writer) {
sort.Sort(s.options)
flags := ""
// Build up the list of short flag names and also compute
// how to display the option in the longer help listing.
// We also keep track of the longest option usage string
// that is no more than HelpColumn-3 bytes (at which point
// we us... | [
"func",
"(",
"s",
"*",
"Set",
")",
"PrintUsage",
"(",
"w",
"io",
".",
"Writer",
")",
"{",
"sort",
".",
"Sort",
"(",
"s",
".",
"options",
")",
"\n",
"flags",
":=",
"\"",
"\"",
"\n\n",
"// Build up the list of short flag names and also compute",
"// how to dis... | // PrintUsage prints the usage of the program to w. | [
"PrintUsage",
"prints",
"the",
"usage",
"of",
"the",
"program",
"to",
"w",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/getopt.go#L242-L301 |
17,278 | pborman/getopt | v2/set.go | New | func New() *Set {
s := &Set{
shortOptions: make(map[rune]*option),
longOptions: make(map[string]*option),
parameters: "[parameters ...]",
}
s.usage = func() {
s.PrintUsage(stderr)
}
return s
} | go | func New() *Set {
s := &Set{
shortOptions: make(map[rune]*option),
longOptions: make(map[string]*option),
parameters: "[parameters ...]",
}
s.usage = func() {
s.PrintUsage(stderr)
}
return s
} | [
"func",
"New",
"(",
")",
"*",
"Set",
"{",
"s",
":=",
"&",
"Set",
"{",
"shortOptions",
":",
"make",
"(",
"map",
"[",
"rune",
"]",
"*",
"option",
")",
",",
"longOptions",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"option",
")",
",",
"para... | // New returns a newly created option set. | [
"New",
"returns",
"a",
"newly",
"created",
"option",
"set",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/set.go#L52-L63 |
17,279 | pborman/getopt | v2/set.go | Visit | func (s *Set) Visit(fn func(Option)) {
sort.Sort(s.options)
for _, opt := range s.options {
if opt.count > 0 {
fn(opt)
}
}
} | go | func (s *Set) Visit(fn func(Option)) {
sort.Sort(s.options)
for _, opt := range s.options {
if opt.count > 0 {
fn(opt)
}
}
} | [
"func",
"(",
"s",
"*",
"Set",
")",
"Visit",
"(",
"fn",
"func",
"(",
"Option",
")",
")",
"{",
"sort",
".",
"Sort",
"(",
"s",
".",
"options",
")",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"s",
".",
"options",
"{",
"if",
"opt",
".",
"count",... | // Visit visits the options in s in lexicographical order, calling fn
// for each. It visits only those options that have been set. | [
"Visit",
"visits",
"the",
"options",
"in",
"s",
"in",
"lexicographical",
"order",
"calling",
"fn",
"for",
"each",
".",
"It",
"visits",
"only",
"those",
"options",
"that",
"have",
"been",
"set",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/set.go#L259-L266 |
17,280 | pborman/getopt | v2/set.go | VisitAll | func (s *Set) VisitAll(fn func(Option)) {
sort.Sort(s.options)
for _, opt := range s.options {
fn(opt)
}
} | go | func (s *Set) VisitAll(fn func(Option)) {
sort.Sort(s.options)
for _, opt := range s.options {
fn(opt)
}
} | [
"func",
"(",
"s",
"*",
"Set",
")",
"VisitAll",
"(",
"fn",
"func",
"(",
"Option",
")",
")",
"{",
"sort",
".",
"Sort",
"(",
"s",
".",
"options",
")",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"s",
".",
"options",
"{",
"fn",
"(",
"opt",
")",
... | // VisitAll visits the command-line flags in lexicographical order, calling fn
// for each. It visits all flags, even those not set. | [
"VisitAll",
"visits",
"the",
"command",
"-",
"line",
"flags",
"in",
"lexicographical",
"order",
"calling",
"fn",
"for",
"each",
".",
"It",
"visits",
"all",
"flags",
"even",
"those",
"not",
"set",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/set.go#L274-L279 |
17,281 | pborman/getopt | string.go | String | func String(name rune, value string, helpvalue ...string) *string {
return CommandLine.String(name, value, helpvalue...)
} | go | func String(name rune, value string, helpvalue ...string) *string {
return CommandLine.String(name, value, helpvalue...)
} | [
"func",
"String",
"(",
"name",
"rune",
",",
"value",
"string",
",",
"helpvalue",
"...",
"string",
")",
"*",
"string",
"{",
"return",
"CommandLine",
".",
"String",
"(",
"name",
",",
"value",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // String returns a value option that stores is value as a string. The
// initial value of the string is passed in value. | [
"String",
"returns",
"a",
"value",
"option",
"that",
"stores",
"is",
"value",
"as",
"a",
"string",
".",
"The",
"initial",
"value",
"of",
"the",
"string",
"is",
"passed",
"in",
"value",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/string.go#L20-L22 |
17,282 | pborman/getopt | v2/var.go | init | func init() {
pc, _, _, ok := runtime.Caller(0)
if !ok {
return
}
f := runtime.FuncForPC(pc)
if f == nil {
return
}
thisPackage = f.Name()
x := strings.LastIndex(thisPackage, "/")
if x < 0 {
return
}
y := strings.Index(thisPackage[x:], ".")
if y < 0 {
return
}
// thisPackage includes the trailing ... | go | func init() {
pc, _, _, ok := runtime.Caller(0)
if !ok {
return
}
f := runtime.FuncForPC(pc)
if f == nil {
return
}
thisPackage = f.Name()
x := strings.LastIndex(thisPackage, "/")
if x < 0 {
return
}
y := strings.Index(thisPackage[x:], ".")
if y < 0 {
return
}
// thisPackage includes the trailing ... | [
"func",
"init",
"(",
")",
"{",
"pc",
",",
"_",
",",
"_",
",",
"ok",
":=",
"runtime",
".",
"Caller",
"(",
"0",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
"}",
"\n",
"f",
":=",
"runtime",
".",
"FuncForPC",
"(",
"pc",
")",
"\n",
"if",
"f... | // init initializes thisPackage to our full package with the trailing .
// included. | [
"init",
"initializes",
"thisPackage",
"to",
"our",
"full",
"package",
"with",
"the",
"trailing",
".",
"included",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/var.go#L32-L52 |
17,283 | pborman/getopt | v2/var.go | calledFrom | func calledFrom() string {
for i := 2; ; i++ {
pc, file, line, ok := runtime.Caller(i)
if !ok {
return ""
}
if !strings.HasSuffix(file, "_test.go") {
f := runtime.FuncForPC(pc)
if f != nil && strings.HasPrefix(f.Name(), thisPackage) {
continue
}
}
return fmt.Sprintf("%s:%d", file, line)
}
... | go | func calledFrom() string {
for i := 2; ; i++ {
pc, file, line, ok := runtime.Caller(i)
if !ok {
return ""
}
if !strings.HasSuffix(file, "_test.go") {
f := runtime.FuncForPC(pc)
if f != nil && strings.HasPrefix(f.Name(), thisPackage) {
continue
}
}
return fmt.Sprintf("%s:%d", file, line)
}
... | [
"func",
"calledFrom",
"(",
")",
"string",
"{",
"for",
"i",
":=",
"2",
";",
";",
"i",
"++",
"{",
"pc",
",",
"file",
",",
"line",
",",
"ok",
":=",
"runtime",
".",
"Caller",
"(",
"i",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
... | // calledFrom returns a string containing the file and linenumber of the first
// stack frame above us that is not part of this package and is not a test.
// This is used to determine where a flag was initialized. | [
"calledFrom",
"returns",
"a",
"string",
"containing",
"the",
"file",
"and",
"linenumber",
"of",
"the",
"first",
"stack",
"frame",
"above",
"us",
"that",
"is",
"not",
"part",
"of",
"this",
"package",
"and",
"is",
"not",
"a",
"test",
".",
"This",
"is",
"us... | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/var.go#L57-L71 |
17,284 | pborman/getopt | error.go | unknownOption | func unknownOption(name interface{}) *Error {
i := &Error{ErrorCode: UnknownOption}
switch n := name.(type) {
case rune:
if n == '-' {
i.Name = "-"
} else {
i.Name = "-" + string(n)
}
case string:
i.Name = "--" + n
}
i.Err = fmt.Errorf("unknown option: %s", i.Name)
return i
} | go | func unknownOption(name interface{}) *Error {
i := &Error{ErrorCode: UnknownOption}
switch n := name.(type) {
case rune:
if n == '-' {
i.Name = "-"
} else {
i.Name = "-" + string(n)
}
case string:
i.Name = "--" + n
}
i.Err = fmt.Errorf("unknown option: %s", i.Name)
return i
} | [
"func",
"unknownOption",
"(",
"name",
"interface",
"{",
"}",
")",
"*",
"Error",
"{",
"i",
":=",
"&",
"Error",
"{",
"ErrorCode",
":",
"UnknownOption",
"}",
"\n",
"switch",
"n",
":=",
"name",
".",
"(",
"type",
")",
"{",
"case",
"rune",
":",
"if",
"n"... | // unknownOption returns an Error indicating an unknown option was
// encountered. | [
"unknownOption",
"returns",
"an",
"Error",
"indicating",
"an",
"unknown",
"option",
"was",
"encountered",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/error.go#L47-L61 |
17,285 | pborman/getopt | error.go | missingArg | func missingArg(o Option) *Error {
return &Error{
ErrorCode: MissingParameter,
Name: o.Name(),
Err: fmt.Errorf("missing parameter for %s", o.Name()),
}
} | go | func missingArg(o Option) *Error {
return &Error{
ErrorCode: MissingParameter,
Name: o.Name(),
Err: fmt.Errorf("missing parameter for %s", o.Name()),
}
} | [
"func",
"missingArg",
"(",
"o",
"Option",
")",
"*",
"Error",
"{",
"return",
"&",
"Error",
"{",
"ErrorCode",
":",
"MissingParameter",
",",
"Name",
":",
"o",
".",
"Name",
"(",
")",
",",
"Err",
":",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"o",
"... | // missingArg returns an Error inidicating option o was not passed
// a required paramter. | [
"missingArg",
"returns",
"an",
"Error",
"inidicating",
"option",
"o",
"was",
"not",
"passed",
"a",
"required",
"paramter",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/error.go#L65-L71 |
17,286 | pborman/getopt | error.go | extraArg | func extraArg(o Option, value string) *Error {
return &Error{
ErrorCode: ExtraParameter,
Name: o.Name(),
Parameter: value,
Err: fmt.Errorf("unexpected parameter passed to %s: %q", o.Name(), value),
}
} | go | func extraArg(o Option, value string) *Error {
return &Error{
ErrorCode: ExtraParameter,
Name: o.Name(),
Parameter: value,
Err: fmt.Errorf("unexpected parameter passed to %s: %q", o.Name(), value),
}
} | [
"func",
"extraArg",
"(",
"o",
"Option",
",",
"value",
"string",
")",
"*",
"Error",
"{",
"return",
"&",
"Error",
"{",
"ErrorCode",
":",
"ExtraParameter",
",",
"Name",
":",
"o",
".",
"Name",
"(",
")",
",",
"Parameter",
":",
"value",
",",
"Err",
":",
... | // extraArg returns an Error inidicating option o was passed the
// unexpected paramter value. | [
"extraArg",
"returns",
"an",
"Error",
"inidicating",
"option",
"o",
"was",
"passed",
"the",
"unexpected",
"paramter",
"value",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/error.go#L75-L82 |
17,287 | pborman/getopt | error.go | setError | func setError(o Option, value string, err error) *Error {
return &Error{
ErrorCode: Invalid,
Name: o.Name(),
Parameter: value,
Err: err,
}
} | go | func setError(o Option, value string, err error) *Error {
return &Error{
ErrorCode: Invalid,
Name: o.Name(),
Parameter: value,
Err: err,
}
} | [
"func",
"setError",
"(",
"o",
"Option",
",",
"value",
"string",
",",
"err",
"error",
")",
"*",
"Error",
"{",
"return",
"&",
"Error",
"{",
"ErrorCode",
":",
"Invalid",
",",
"Name",
":",
"o",
".",
"Name",
"(",
")",
",",
"Parameter",
":",
"value",
","... | // setError returns an Error inidicating option o and the specified
// error while setting it to value. | [
"setError",
"returns",
"an",
"Error",
"inidicating",
"option",
"o",
"and",
"the",
"specified",
"error",
"while",
"setting",
"it",
"to",
"value",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/error.go#L86-L93 |
17,288 | pborman/getopt | enum.go | Enum | func Enum(name rune, values []string, helpvalue ...string) *string {
return CommandLine.Enum(name, values, helpvalue...)
} | go | func Enum(name rune, values []string, helpvalue ...string) *string {
return CommandLine.Enum(name, values, helpvalue...)
} | [
"func",
"Enum",
"(",
"name",
"rune",
",",
"values",
"[",
"]",
"string",
",",
"helpvalue",
"...",
"string",
")",
"*",
"string",
"{",
"return",
"CommandLine",
".",
"Enum",
"(",
"name",
",",
"values",
",",
"helpvalue",
"...",
")",
"\n",
"}"
] | // Enum creates an option that can only be set to one of the enumerated strings
// passed in values. Passing nil or an empty slice results in an option that
// will always fail. | [
"Enum",
"creates",
"an",
"option",
"that",
"can",
"only",
"be",
"set",
"to",
"one",
"of",
"the",
"enumerated",
"strings",
"passed",
"in",
"values",
".",
"Passing",
"nil",
"or",
"an",
"empty",
"slice",
"results",
"in",
"an",
"option",
"that",
"will",
"alw... | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/enum.go#L32-L34 |
17,289 | pborman/getopt | v2/duration.go | Duration | func Duration(name rune, value time.Duration, helpvalue ...string) *time.Duration {
CommandLine.FlagLong(&value, "", name, helpvalue...)
return &value
} | go | func Duration(name rune, value time.Duration, helpvalue ...string) *time.Duration {
CommandLine.FlagLong(&value, "", name, helpvalue...)
return &value
} | [
"func",
"Duration",
"(",
"name",
"rune",
",",
"value",
"time",
".",
"Duration",
",",
"helpvalue",
"...",
"string",
")",
"*",
"time",
".",
"Duration",
"{",
"CommandLine",
".",
"FlagLong",
"(",
"&",
"value",
",",
"\"",
"\"",
",",
"name",
",",
"helpvalue"... | // Duration creates an option that parses its value as a time.Duration. | [
"Duration",
"creates",
"an",
"option",
"that",
"parses",
"its",
"value",
"as",
"a",
"time",
".",
"Duration",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/v2/duration.go#L10-L13 |
17,290 | pborman/getopt | option.go | sortName | func (o *option) sortName() string {
if o.short != 0 {
return string(o.short) + o.long
}
return o.long[:1] + o.long
} | go | func (o *option) sortName() string {
if o.short != 0 {
return string(o.short) + o.long
}
return o.long[:1] + o.long
} | [
"func",
"(",
"o",
"*",
"option",
")",
"sortName",
"(",
")",
"string",
"{",
"if",
"o",
".",
"short",
"!=",
"0",
"{",
"return",
"string",
"(",
"o",
".",
"short",
")",
"+",
"o",
".",
"long",
"\n",
"}",
"\n",
"return",
"o",
".",
"long",
"[",
":",... | // sortName returns the name to sort the option on. | [
"sortName",
"returns",
"the",
"name",
"to",
"sort",
"the",
"option",
"on",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/option.go#L109-L114 |
17,291 | pborman/getopt | option.go | Reset | func (o *option) Reset() {
o.isLong = false
o.count = 0
o.value.Set(o.defval, o)
} | go | func (o *option) Reset() {
o.isLong = false
o.count = 0
o.value.Set(o.defval, o)
} | [
"func",
"(",
"o",
"*",
"option",
")",
"Reset",
"(",
")",
"{",
"o",
".",
"isLong",
"=",
"false",
"\n",
"o",
".",
"count",
"=",
"0",
"\n",
"o",
".",
"value",
".",
"Set",
"(",
"o",
".",
"defval",
",",
"o",
")",
"\n",
"}"
] | // Reset rests an option so that it appears it has not yet been seen. | [
"Reset",
"rests",
"an",
"option",
"so",
"that",
"it",
"appears",
"it",
"has",
"not",
"yet",
"been",
"seen",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/option.go#L138-L142 |
17,292 | pborman/getopt | option.go | AddOption | func (s *Set) AddOption(o Option) {
opt := o.(*option)
for _, eopt := range s.options {
if opt == eopt {
return
}
}
if opt.short != 0 {
if oo, ok := s.shortOptions[opt.short]; ok {
fmt.Fprintf(stderr, "%s: -%c already declared at %s\n", opt.where, opt.short, oo.where)
exit(1)
}
s.shortOptions[opt... | go | func (s *Set) AddOption(o Option) {
opt := o.(*option)
for _, eopt := range s.options {
if opt == eopt {
return
}
}
if opt.short != 0 {
if oo, ok := s.shortOptions[opt.short]; ok {
fmt.Fprintf(stderr, "%s: -%c already declared at %s\n", opt.where, opt.short, oo.where)
exit(1)
}
s.shortOptions[opt... | [
"func",
"(",
"s",
"*",
"Set",
")",
"AddOption",
"(",
"o",
"Option",
")",
"{",
"opt",
":=",
"o",
".",
"(",
"*",
"option",
")",
"\n",
"for",
"_",
",",
"eopt",
":=",
"range",
"s",
".",
"options",
"{",
"if",
"opt",
"==",
"eopt",
"{",
"return",
"\... | // AddOption add the option o to set s if o is not already in set s. | [
"AddOption",
"add",
"the",
"option",
"o",
"to",
"set",
"s",
"if",
"o",
"is",
"not",
"already",
"in",
"set",
"s",
"."
] | ee0cd42419d3adee9239dbd1c375717fe482dac7 | https://github.com/pborman/getopt/blob/ee0cd42419d3adee9239dbd1c375717fe482dac7/option.go#L171-L193 |
17,293 | micro/go-rcache | options.go | WithTTL | func WithTTL(t time.Duration) Option {
return func(o *Options) {
o.TTL = t
}
} | go | func WithTTL(t time.Duration) Option {
return func(o *Options) {
o.TTL = t
}
} | [
"func",
"WithTTL",
"(",
"t",
"time",
".",
"Duration",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"TTL",
"=",
"t",
"\n",
"}",
"\n",
"}"
] | // WithTTL sets the cache TTL | [
"WithTTL",
"sets",
"the",
"cache",
"TTL"
] | 2c4d7ce6742999be1708c70a3638f2c0ce28f2cd | https://github.com/micro/go-rcache/blob/2c4d7ce6742999be1708c70a3638f2c0ce28f2cd/options.go#L8-L12 |
17,294 | micro/go-rcache | rcache.go | isValid | func (c *cache) isValid(services []*registry.Service, ttl time.Time) bool {
// no services exist
if len(services) == 0 {
return false
}
// ttl is invalid
if ttl.IsZero() {
return false
}
// time since ttl is longer than timeout
if time.Since(ttl) > c.opts.TTL {
return false
}
// ok
return true
} | go | func (c *cache) isValid(services []*registry.Service, ttl time.Time) bool {
// no services exist
if len(services) == 0 {
return false
}
// ttl is invalid
if ttl.IsZero() {
return false
}
// time since ttl is longer than timeout
if time.Since(ttl) > c.opts.TTL {
return false
}
// ok
return true
} | [
"func",
"(",
"c",
"*",
"cache",
")",
"isValid",
"(",
"services",
"[",
"]",
"*",
"registry",
".",
"Service",
",",
"ttl",
"time",
".",
"Time",
")",
"bool",
"{",
"// no services exist",
"if",
"len",
"(",
"services",
")",
"==",
"0",
"{",
"return",
"false... | // isValid checks if the service is valid | [
"isValid",
"checks",
"if",
"the",
"service",
"is",
"valid"
] | 2c4d7ce6742999be1708c70a3638f2c0ce28f2cd | https://github.com/micro/go-rcache/blob/2c4d7ce6742999be1708c70a3638f2c0ce28f2cd/rcache.go#L53-L71 |
17,295 | micro/go-rcache | rcache.go | cp | func (c *cache) cp(current []*registry.Service) []*registry.Service {
var services []*registry.Service
for _, service := range current {
// copy service
s := new(registry.Service)
*s = *service
// copy nodes
var nodes []*registry.Node
for _, node := range service.Nodes {
n := new(registry.Node)
*n... | go | func (c *cache) cp(current []*registry.Service) []*registry.Service {
var services []*registry.Service
for _, service := range current {
// copy service
s := new(registry.Service)
*s = *service
// copy nodes
var nodes []*registry.Node
for _, node := range service.Nodes {
n := new(registry.Node)
*n... | [
"func",
"(",
"c",
"*",
"cache",
")",
"cp",
"(",
"current",
"[",
"]",
"*",
"registry",
".",
"Service",
")",
"[",
"]",
"*",
"registry",
".",
"Service",
"{",
"var",
"services",
"[",
"]",
"*",
"registry",
".",
"Service",
"\n\n",
"for",
"_",
",",
"ser... | // cp copies a service. Because we're caching handing back pointers would
// create a race condition, so we do this instead its fast enough | [
"cp",
"copies",
"a",
"service",
".",
"Because",
"we",
"re",
"caching",
"handing",
"back",
"pointers",
"would",
"create",
"a",
"race",
"condition",
"so",
"we",
"do",
"this",
"instead",
"its",
"fast",
"enough"
] | 2c4d7ce6742999be1708c70a3638f2c0ce28f2cd | https://github.com/micro/go-rcache/blob/2c4d7ce6742999be1708c70a3638f2c0ce28f2cd/rcache.go#L84-L115 |
17,296 | micro/go-rcache | rcache.go | run | func (c *cache) run(service string) {
// set watcher
c.Lock()
c.watched[service] = true
c.Unlock()
// delete watcher on exit
defer func() {
c.Lock()
delete(c.watched, service)
c.Unlock()
}()
var a, b int
for {
// exit early if already dead
if c.quit() {
return
}
// jitter before starting
... | go | func (c *cache) run(service string) {
// set watcher
c.Lock()
c.watched[service] = true
c.Unlock()
// delete watcher on exit
defer func() {
c.Lock()
delete(c.watched, service)
c.Unlock()
}()
var a, b int
for {
// exit early if already dead
if c.quit() {
return
}
// jitter before starting
... | [
"func",
"(",
"c",
"*",
"cache",
")",
"run",
"(",
"service",
"string",
")",
"{",
"// set watcher",
"c",
".",
"Lock",
"(",
")",
"\n",
"c",
".",
"watched",
"[",
"service",
"]",
"=",
"true",
"\n",
"c",
".",
"Unlock",
"(",
")",
"\n\n",
"// delete watche... | // run starts the cache watcher loop
// it creates a new watcher if there's a problem | [
"run",
"starts",
"the",
"cache",
"watcher",
"loop",
"it",
"creates",
"a",
"new",
"watcher",
"if",
"there",
"s",
"a",
"problem"
] | 2c4d7ce6742999be1708c70a3638f2c0ce28f2cd | https://github.com/micro/go-rcache/blob/2c4d7ce6742999be1708c70a3638f2c0ce28f2cd/rcache.go#L284-L357 |
17,297 | micro/go-rcache | rcache.go | watch | func (c *cache) watch(w registry.Watcher) error {
defer w.Stop()
// manage this loop
go func() {
// wait for exit
<-c.exit
w.Stop()
}()
for {
res, err := w.Next()
if err != nil {
return err
}
c.update(res)
}
} | go | func (c *cache) watch(w registry.Watcher) error {
defer w.Stop()
// manage this loop
go func() {
// wait for exit
<-c.exit
w.Stop()
}()
for {
res, err := w.Next()
if err != nil {
return err
}
c.update(res)
}
} | [
"func",
"(",
"c",
"*",
"cache",
")",
"watch",
"(",
"w",
"registry",
".",
"Watcher",
")",
"error",
"{",
"defer",
"w",
".",
"Stop",
"(",
")",
"\n\n",
"// manage this loop",
"go",
"func",
"(",
")",
"{",
"// wait for exit",
"<-",
"c",
".",
"exit",
"\n",
... | // watch loops the next event and calls update
// it returns if there's an error | [
"watch",
"loops",
"the",
"next",
"event",
"and",
"calls",
"update",
"it",
"returns",
"if",
"there",
"s",
"an",
"error"
] | 2c4d7ce6742999be1708c70a3638f2c0ce28f2cd | https://github.com/micro/go-rcache/blob/2c4d7ce6742999be1708c70a3638f2c0ce28f2cd/rcache.go#L361-L378 |
17,298 | micro/go-rcache | rcache.go | New | func New(r registry.Registry, opts ...Option) Cache {
rand.Seed(time.Now().UnixNano())
options := Options{
TTL: DefaultTTL,
}
for _, o := range opts {
o(&options)
}
return &cache{
Registry: r,
opts: options,
watched: make(map[string]bool),
cache: make(map[string][]*registry.Service),
ttls:... | go | func New(r registry.Registry, opts ...Option) Cache {
rand.Seed(time.Now().UnixNano())
options := Options{
TTL: DefaultTTL,
}
for _, o := range opts {
o(&options)
}
return &cache{
Registry: r,
opts: options,
watched: make(map[string]bool),
cache: make(map[string][]*registry.Service),
ttls:... | [
"func",
"New",
"(",
"r",
"registry",
".",
"Registry",
",",
"opts",
"...",
"Option",
")",
"Cache",
"{",
"rand",
".",
"Seed",
"(",
"time",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
")",
"\n",
"options",
":=",
"Options",
"{",
"TTL",
":",
"Def... | // New returns a new cache | [
"New",
"returns",
"a",
"new",
"cache"
] | 2c4d7ce6742999be1708c70a3638f2c0ce28f2cd | https://github.com/micro/go-rcache/blob/2c4d7ce6742999be1708c70a3638f2c0ce28f2cd/rcache.go#L410-L428 |
17,299 | cloudfoundry-community/go-cfclient | appevents.go | ListAppEvents | func (c *Client) ListAppEvents(eventType string) ([]AppEventEntity, error) {
return c.ListAppEventsByQuery(eventType, nil)
} | go | func (c *Client) ListAppEvents(eventType string) ([]AppEventEntity, error) {
return c.ListAppEventsByQuery(eventType, nil)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListAppEvents",
"(",
"eventType",
"string",
")",
"(",
"[",
"]",
"AppEventEntity",
",",
"error",
")",
"{",
"return",
"c",
".",
"ListAppEventsByQuery",
"(",
"eventType",
",",
"nil",
")",
"\n",
"}"
] | // ListAppEvents returns all app events based on eventType | [
"ListAppEvents",
"returns",
"all",
"app",
"events",
"based",
"on",
"eventType"
] | f136f9222381e2fea5099f62e4b751dcb660ff82 | https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/appevents.go#L110-L112 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.