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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
29,200 | gopasspw/gopass | pkg/action/list.go | redirectPager | func redirectPager(ctx context.Context, subtree tree.Tree) (io.Writer, *bytes.Buffer) {
if ctxutil.IsNoPager(ctx) {
return stdout, nil
}
rows, _ := termutil.GetTermsize()
if rows <= 0 {
return stdout, nil
}
if subtree == nil || subtree.Len() < rows {
return stdout, nil
}
color.NoColor = true
buf := &byte... | go | func redirectPager(ctx context.Context, subtree tree.Tree) (io.Writer, *bytes.Buffer) {
if ctxutil.IsNoPager(ctx) {
return stdout, nil
}
rows, _ := termutil.GetTermsize()
if rows <= 0 {
return stdout, nil
}
if subtree == nil || subtree.Len() < rows {
return stdout, nil
}
color.NoColor = true
buf := &byte... | [
"func",
"redirectPager",
"(",
"ctx",
"context",
".",
"Context",
",",
"subtree",
"tree",
".",
"Tree",
")",
"(",
"io",
".",
"Writer",
",",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"if",
"ctxutil",
".",
"IsNoPager",
"(",
"ctx",
")",
"{",
"return",
"stdout... | // redirectPager returns a redirected io.Writer if the output would exceed
// the terminal size | [
"redirectPager",
"returns",
"a",
"redirected",
"io",
".",
"Writer",
"if",
"the",
"output",
"would",
"exceed",
"the",
"terminal",
"size"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/list.go#L90-L104 |
29,201 | gopasspw/gopass | pkg/action/list.go | listAll | func (s *Action) listAll(ctx context.Context, l tree.Tree, limit int, flat, folders bool) error {
if flat {
listOver := l.List
if folders {
listOver = l.ListFolders
}
for _, e := range listOver(limit) {
fmt.Fprintln(stdout, e)
}
return nil
}
// we may need to redirect stdout for the pager support
... | go | func (s *Action) listAll(ctx context.Context, l tree.Tree, limit int, flat, folders bool) error {
if flat {
listOver := l.List
if folders {
listOver = l.ListFolders
}
for _, e := range listOver(limit) {
fmt.Fprintln(stdout, e)
}
return nil
}
// we may need to redirect stdout for the pager support
... | [
"func",
"(",
"s",
"*",
"Action",
")",
"listAll",
"(",
"ctx",
"context",
".",
"Context",
",",
"l",
"tree",
".",
"Tree",
",",
"limit",
"int",
",",
"flat",
",",
"folders",
"bool",
")",
"error",
"{",
"if",
"flat",
"{",
"listOver",
":=",
"l",
".",
"Li... | // listAll will unconditionally list all entries, used if no filter is given | [
"listAll",
"will",
"unconditionally",
"list",
"all",
"entries",
"used",
"if",
"no",
"filter",
"is",
"given"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/list.go#L107-L129 |
29,202 | gopasspw/gopass | pkg/action/list.go | pager | func (s *Action) pager(ctx context.Context, buf io.Reader) error {
pager := os.Getenv("PAGER")
if pager == "" {
fmt.Fprintln(stdout, buf)
return nil
}
args, err := shellquote.Split(pager)
if err != nil {
return errors.Wrapf(err, "failed to split pager command")
}
cmd := exec.CommandContext(ctx, args[0], ... | go | func (s *Action) pager(ctx context.Context, buf io.Reader) error {
pager := os.Getenv("PAGER")
if pager == "" {
fmt.Fprintln(stdout, buf)
return nil
}
args, err := shellquote.Split(pager)
if err != nil {
return errors.Wrapf(err, "failed to split pager command")
}
cmd := exec.CommandContext(ctx, args[0], ... | [
"func",
"(",
"s",
"*",
"Action",
")",
"pager",
"(",
"ctx",
"context",
".",
"Context",
",",
"buf",
"io",
".",
"Reader",
")",
"error",
"{",
"pager",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"pager",
"==",
"\"",
"\"",
"{",
"fmt... | // pager invokes the default pager with the given content | [
"pager",
"invokes",
"the",
"default",
"pager",
"with",
"the",
"given",
"content"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/list.go#L132-L150 |
29,203 | gopasspw/gopass | pkg/termutil/termutil_others.go | GetTermsize | func GetTermsize() (int, int) {
ts := termSize{}
ret, _, _ := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(syscall.Stdin),
uintptr(syscall.TIOCGWINSZ),
uintptr(unsafe.Pointer(&ts)),
)
if int(ret) == -1 {
return -1, -1
}
return int(ts.Rows), int(ts.Cols)
} | go | func GetTermsize() (int, int) {
ts := termSize{}
ret, _, _ := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(syscall.Stdin),
uintptr(syscall.TIOCGWINSZ),
uintptr(unsafe.Pointer(&ts)),
)
if int(ret) == -1 {
return -1, -1
}
return int(ts.Rows), int(ts.Cols)
} | [
"func",
"GetTermsize",
"(",
")",
"(",
"int",
",",
"int",
")",
"{",
"ts",
":=",
"termSize",
"{",
"}",
"\n",
"ret",
",",
"_",
",",
"_",
":=",
"syscall",
".",
"Syscall",
"(",
"syscall",
".",
"SYS_IOCTL",
",",
"uintptr",
"(",
"syscall",
".",
"Stdin",
... | // GetTermsize returns the size of the current terminal | [
"GetTermsize",
"returns",
"the",
"size",
"of",
"the",
"current",
"terminal"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/termutil/termutil_others.go#L18-L30 |
29,204 | gopasspw/gopass | pkg/backend/strings.go | CryptoBackends | func CryptoBackends() []string {
bes := make([]string, 0, len(cryptoNameToBackendMap))
for k := range cryptoNameToBackendMap {
bes = append(bes, k)
}
sort.Strings(bes)
return bes
} | go | func CryptoBackends() []string {
bes := make([]string, 0, len(cryptoNameToBackendMap))
for k := range cryptoNameToBackendMap {
bes = append(bes, k)
}
sort.Strings(bes)
return bes
} | [
"func",
"CryptoBackends",
"(",
")",
"[",
"]",
"string",
"{",
"bes",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"cryptoNameToBackendMap",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"cryptoNameToBackendMap",
"{",
"bes",
"=",
"appen... | // CryptoBackends returns the list of registered crypto backends. | [
"CryptoBackends",
"returns",
"the",
"list",
"of",
"registered",
"crypto",
"backends",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/strings.go#L27-L34 |
29,205 | gopasspw/gopass | pkg/backend/strings.go | RCSBackends | func RCSBackends() []string {
bes := make([]string, 0, len(rcsNameToBackendMap))
for k := range rcsNameToBackendMap {
bes = append(bes, k)
}
sort.Strings(bes)
return bes
} | go | func RCSBackends() []string {
bes := make([]string, 0, len(rcsNameToBackendMap))
for k := range rcsNameToBackendMap {
bes = append(bes, k)
}
sort.Strings(bes)
return bes
} | [
"func",
"RCSBackends",
"(",
")",
"[",
"]",
"string",
"{",
"bes",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"rcsNameToBackendMap",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"rcsNameToBackendMap",
"{",
"bes",
"=",
"append",
"("... | // RCSBackends returns the list of registered RCS backends. | [
"RCSBackends",
"returns",
"the",
"list",
"of",
"registered",
"RCS",
"backends",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/strings.go#L37-L44 |
29,206 | gopasspw/gopass | pkg/backend/strings.go | StorageBackends | func StorageBackends() []string {
bes := make([]string, 0, len(storageNameToBackendMap))
for k := range storageNameToBackendMap {
bes = append(bes, k)
}
sort.Strings(bes)
return bes
} | go | func StorageBackends() []string {
bes := make([]string, 0, len(storageNameToBackendMap))
for k := range storageNameToBackendMap {
bes = append(bes, k)
}
sort.Strings(bes)
return bes
} | [
"func",
"StorageBackends",
"(",
")",
"[",
"]",
"string",
"{",
"bes",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"storageNameToBackendMap",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"storageNameToBackendMap",
"{",
"bes",
"=",
"ap... | // StorageBackends returns the list of registered storage backends. | [
"StorageBackends",
"returns",
"the",
"list",
"of",
"registered",
"storage",
"backends",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/strings.go#L47-L54 |
29,207 | gopasspw/gopass | pkg/store/root/move.go | Copy | func (r *Store) Copy(ctx context.Context, from, to string) error {
return r.move(ctx, from, to, false)
} | go | func (r *Store) Copy(ctx context.Context, from, to string) error {
return r.move(ctx, from, to, false)
} | [
"func",
"(",
"r",
"*",
"Store",
")",
"Copy",
"(",
"ctx",
"context",
".",
"Context",
",",
"from",
",",
"to",
"string",
")",
"error",
"{",
"return",
"r",
".",
"move",
"(",
"ctx",
",",
"from",
",",
"to",
",",
"false",
")",
"\n",
"}"
] | // Copy will copy one entry to another location. Multi-store copies are
// supported. Each entry has to be decoded and encoded for the destination
// to make sure it's encrypted for the right set of recipients. | [
"Copy",
"will",
"copy",
"one",
"entry",
"to",
"another",
"location",
".",
"Multi",
"-",
"store",
"copies",
"are",
"supported",
".",
"Each",
"entry",
"has",
"to",
"be",
"decoded",
"and",
"encoded",
"for",
"the",
"destination",
"to",
"make",
"sure",
"it",
... | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/move.go#L19-L21 |
29,208 | gopasspw/gopass | pkg/store/root/move.go | Move | func (r *Store) Move(ctx context.Context, from, to string) error {
return r.move(ctx, from, to, true)
} | go | func (r *Store) Move(ctx context.Context, from, to string) error {
return r.move(ctx, from, to, true)
} | [
"func",
"(",
"r",
"*",
"Store",
")",
"Move",
"(",
"ctx",
"context",
".",
"Context",
",",
"from",
",",
"to",
"string",
")",
"error",
"{",
"return",
"r",
".",
"move",
"(",
"ctx",
",",
"from",
",",
"to",
",",
"true",
")",
"\n",
"}"
] | // Move will move one entry from one location to another. Cross-store moves are
// supported. Moving an entry will decode it from the old location, encode it
// for the destination store with the right set of recipients and remove it
// from the old location afterwards. | [
"Move",
"will",
"move",
"one",
"entry",
"from",
"one",
"location",
"to",
"another",
".",
"Cross",
"-",
"store",
"moves",
"are",
"supported",
".",
"Moving",
"an",
"entry",
"will",
"decode",
"it",
"from",
"the",
"old",
"location",
"encode",
"it",
"for",
"t... | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/move.go#L27-L29 |
29,209 | gopasspw/gopass | pkg/backend/storage/fs/store.go | Get | func (s *Store) Get(ctx context.Context, name string) ([]byte, error) {
path := filepath.Join(s.path, filepath.Clean(name))
out.Debug(ctx, "fs.Get(%s) - %s", name, path)
return ioutil.ReadFile(path)
} | go | func (s *Store) Get(ctx context.Context, name string) ([]byte, error) {
path := filepath.Join(s.path, filepath.Clean(name))
out.Debug(ctx, "fs.Get(%s) - %s", name, path)
return ioutil.ReadFile(path)
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"path",
":=",
"filepath",
".",
"Join",
"(",
"s",
".",
"path",
",",
"filepath",
".",
"C... | // Get retrieves the named content | [
"Get",
"retrieves",
"the",
"named",
"content"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/fs/store.go#L35-L39 |
29,210 | gopasspw/gopass | pkg/backend/storage/fs/store.go | Set | func (s *Store) Set(ctx context.Context, name string, value []byte) error {
filename := filepath.Join(s.path, filepath.Clean(name))
filedir := filepath.Dir(filename)
if !fsutil.IsDir(filedir) {
if err := os.MkdirAll(filedir, 0700); err != nil {
return err
}
}
out.Debug(ctx, "fs.Set(%s) - %s", name, filepath... | go | func (s *Store) Set(ctx context.Context, name string, value []byte) error {
filename := filepath.Join(s.path, filepath.Clean(name))
filedir := filepath.Dir(filename)
if !fsutil.IsDir(filedir) {
if err := os.MkdirAll(filedir, 0700); err != nil {
return err
}
}
out.Debug(ctx, "fs.Set(%s) - %s", name, filepath... | [
"func",
"(",
"s",
"*",
"Store",
")",
"Set",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"value",
"[",
"]",
"byte",
")",
"error",
"{",
"filename",
":=",
"filepath",
".",
"Join",
"(",
"s",
".",
"path",
",",
"filepath",
".",
"... | // Set writes the given content | [
"Set",
"writes",
"the",
"given",
"content"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/fs/store.go#L42-L52 |
29,211 | gopasspw/gopass | pkg/backend/storage/fs/store.go | Delete | func (s *Store) Delete(ctx context.Context, name string) error {
path := filepath.Join(s.path, filepath.Clean(name))
out.Debug(ctx, "fs.Delete(%s) - %s", name, path)
if err := os.Remove(path); err != nil {
return err
}
return s.removeEmptyParentDirectories(path)
} | go | func (s *Store) Delete(ctx context.Context, name string) error {
path := filepath.Join(s.path, filepath.Clean(name))
out.Debug(ctx, "fs.Delete(%s) - %s", name, path)
if err := os.Remove(path); err != nil {
return err
}
return s.removeEmptyParentDirectories(path)
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"error",
"{",
"path",
":=",
"filepath",
".",
"Join",
"(",
"s",
".",
"path",
",",
"filepath",
".",
"Clean",
"(",
"name",
")",
")",
"\... | // Delete removes the named entity | [
"Delete",
"removes",
"the",
"named",
"entity"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/fs/store.go#L55-L64 |
29,212 | gopasspw/gopass | pkg/backend/storage/fs/store.go | removeEmptyParentDirectories | func (s *Store) removeEmptyParentDirectories(path string) error {
parent := filepath.Dir(path)
if relpath, err := filepath.Rel(s.path, parent); err != nil {
return err
} else if strings.HasPrefix(relpath, ".") {
return nil
}
err := os.Remove(parent)
switch {
case err == nil:
return s.removeEmptyParentDir... | go | func (s *Store) removeEmptyParentDirectories(path string) error {
parent := filepath.Dir(path)
if relpath, err := filepath.Rel(s.path, parent); err != nil {
return err
} else if strings.HasPrefix(relpath, ".") {
return nil
}
err := os.Remove(parent)
switch {
case err == nil:
return s.removeEmptyParentDir... | [
"func",
"(",
"s",
"*",
"Store",
")",
"removeEmptyParentDirectories",
"(",
"path",
"string",
")",
"error",
"{",
"parent",
":=",
"filepath",
".",
"Dir",
"(",
"path",
")",
"\n\n",
"if",
"relpath",
",",
"err",
":=",
"filepath",
".",
"Rel",
"(",
"s",
".",
... | // Deletes all empty parent directories up to the store root | [
"Deletes",
"all",
"empty",
"parent",
"directories",
"up",
"to",
"the",
"store",
"root"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/fs/store.go#L67-L86 |
29,213 | gopasspw/gopass | pkg/backend/storage/fs/store.go | Exists | func (s *Store) Exists(ctx context.Context, name string) bool {
path := filepath.Join(s.path, filepath.Clean(name))
out.Debug(ctx, "fs.Exists(%s) - %s", name, path)
return fsutil.IsFile(path)
} | go | func (s *Store) Exists(ctx context.Context, name string) bool {
path := filepath.Join(s.path, filepath.Clean(name))
out.Debug(ctx, "fs.Exists(%s) - %s", name, path)
return fsutil.IsFile(path)
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Exists",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"path",
":=",
"filepath",
".",
"Join",
"(",
"s",
".",
"path",
",",
"filepath",
".",
"Clean",
"(",
"name",
")",
")",
"\n... | // Exists checks if the named entity exists | [
"Exists",
"checks",
"if",
"the",
"named",
"entity",
"exists"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/fs/store.go#L89-L93 |
29,214 | gopasspw/gopass | pkg/backend/storage/fs/store.go | List | func (s *Store) List(ctx context.Context, prefix string) ([]string, error) {
prefix = strings.TrimPrefix(prefix, "/")
out.Debug(ctx, "fs.List(%s)", prefix)
files := make([]string, 0, 100)
if err := filepath.Walk(s.path, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if ... | go | func (s *Store) List(ctx context.Context, prefix string) ([]string, error) {
prefix = strings.TrimPrefix(prefix, "/")
out.Debug(ctx, "fs.List(%s)", prefix)
files := make([]string, 0, 100)
if err := filepath.Walk(s.path, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if ... | [
"func",
"(",
"s",
"*",
"Store",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"prefix",
"=",
"strings",
".",
"TrimPrefix",
"(",
"prefix",
",",
"\"",
"\"",
")",
"... | // List returns a list of all entities | [
"List",
"returns",
"a",
"list",
"of",
"all",
"entities"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/fs/store.go#L96-L124 |
29,215 | gopasspw/gopass | pkg/backend/storage/fs/store.go | IsDir | func (s *Store) IsDir(ctx context.Context, name string) bool {
path := filepath.Join(s.path, filepath.Clean(name))
isDir := fsutil.IsDir(path)
out.Debug(ctx, "fs.Isdir(%s) - %s -> %t", name, path, isDir)
return isDir
} | go | func (s *Store) IsDir(ctx context.Context, name string) bool {
path := filepath.Join(s.path, filepath.Clean(name))
isDir := fsutil.IsDir(path)
out.Debug(ctx, "fs.Isdir(%s) - %s -> %t", name, path, isDir)
return isDir
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"IsDir",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"path",
":=",
"filepath",
".",
"Join",
"(",
"s",
".",
"path",
",",
"filepath",
".",
"Clean",
"(",
"name",
")",
")",
"\n"... | // IsDir returns true if the named entity is a directory | [
"IsDir",
"returns",
"true",
"if",
"the",
"named",
"entity",
"is",
"a",
"directory"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/fs/store.go#L127-L132 |
29,216 | gopasspw/gopass | pkg/backend/storage/fs/store.go | Prune | func (s *Store) Prune(ctx context.Context, prefix string) error {
path := filepath.Join(s.path, filepath.Clean(prefix))
out.Debug(ctx, "fs.Prune(%s) - %s", prefix, path)
return os.RemoveAll(path)
} | go | func (s *Store) Prune(ctx context.Context, prefix string) error {
path := filepath.Join(s.path, filepath.Clean(prefix))
out.Debug(ctx, "fs.Prune(%s) - %s", prefix, path)
return os.RemoveAll(path)
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Prune",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"error",
"{",
"path",
":=",
"filepath",
".",
"Join",
"(",
"s",
".",
"path",
",",
"filepath",
".",
"Clean",
"(",
"prefix",
")",
")",
... | // Prune removes a named directory | [
"Prune",
"removes",
"a",
"named",
"directory"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/fs/store.go#L135-L139 |
29,217 | gopasspw/gopass | pkg/agent/agent.go | New | func New(dir string) *Agent {
a := &Agent{
socket: filepath.Join(dir, ".gopass-agent.sock"),
cache: &cache{
ttl: time.Hour,
maxTTL: 24 * time.Hour,
},
pinentry: func() (piner, error) {
return pinentry.New()
},
}
mux := http.NewServeMux()
mux.HandleFunc("/ping", a.servePing)
mux.HandleFunc("/p... | go | func New(dir string) *Agent {
a := &Agent{
socket: filepath.Join(dir, ".gopass-agent.sock"),
cache: &cache{
ttl: time.Hour,
maxTTL: 24 * time.Hour,
},
pinentry: func() (piner, error) {
return pinentry.New()
},
}
mux := http.NewServeMux()
mux.HandleFunc("/ping", a.servePing)
mux.HandleFunc("/p... | [
"func",
"New",
"(",
"dir",
"string",
")",
"*",
"Agent",
"{",
"a",
":=",
"&",
"Agent",
"{",
"socket",
":",
"filepath",
".",
"Join",
"(",
"dir",
",",
"\"",
"\"",
")",
",",
"cache",
":",
"&",
"cache",
"{",
"ttl",
":",
"time",
".",
"Hour",
",",
"... | // New creates a new agent | [
"New",
"creates",
"a",
"new",
"agent"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/agent/agent.go#L38-L58 |
29,218 | gopasspw/gopass | pkg/agent/agent.go | ListenAndServe | func (a *Agent) ListenAndServe(ctx context.Context) error {
out.Debug(ctx, "Trying to listen on %s", a.socket)
lis, err := net.Listen("unix", a.socket)
if err == nil {
return a.server.Serve(lis)
}
out.Debug(ctx, "Failed to listen on %s: %s", a.socket, err)
if err := client.New(filepath.Dir(a.socket)).Ping(ctx)... | go | func (a *Agent) ListenAndServe(ctx context.Context) error {
out.Debug(ctx, "Trying to listen on %s", a.socket)
lis, err := net.Listen("unix", a.socket)
if err == nil {
return a.server.Serve(lis)
}
out.Debug(ctx, "Failed to listen on %s: %s", a.socket, err)
if err := client.New(filepath.Dir(a.socket)).Ping(ctx)... | [
"func",
"(",
"a",
"*",
"Agent",
")",
"ListenAndServe",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"a",
".",
"socket",
")",
"\n",
"lis",
",",
"err",
":=",
"net",
".",
"Listen",
... | // ListenAndServe starts listening and blocks | [
"ListenAndServe",
"starts",
"listening",
"and",
"blocks"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/agent/agent.go#L69-L89 |
29,219 | golang/oauth2 | internal/token.go | lookupAuthStyle | func lookupAuthStyle(tokenURL string) (style AuthStyle, ok bool) {
authStyleCache.Lock()
defer authStyleCache.Unlock()
style, ok = authStyleCache.m[tokenURL]
return
} | go | func lookupAuthStyle(tokenURL string) (style AuthStyle, ok bool) {
authStyleCache.Lock()
defer authStyleCache.Unlock()
style, ok = authStyleCache.m[tokenURL]
return
} | [
"func",
"lookupAuthStyle",
"(",
"tokenURL",
"string",
")",
"(",
"style",
"AuthStyle",
",",
"ok",
"bool",
")",
"{",
"authStyleCache",
".",
"Lock",
"(",
")",
"\n",
"defer",
"authStyleCache",
".",
"Unlock",
"(",
")",
"\n",
"style",
",",
"ok",
"=",
"authStyl... | // lookupAuthStyle reports which auth style we last used with tokenURL
// when calling RetrieveToken and whether we have ever done so. | [
"lookupAuthStyle",
"reports",
"which",
"auth",
"style",
"we",
"last",
"used",
"with",
"tokenURL",
"when",
"calling",
"RetrieveToken",
"and",
"whether",
"we",
"have",
"ever",
"done",
"so",
"."
] | 9f3314589c9a9136388751d9adae6b0ed400978a | https://github.com/golang/oauth2/blob/9f3314589c9a9136388751d9adae6b0ed400978a/internal/token.go#L134-L139 |
29,220 | golang/oauth2 | internal/token.go | setAuthStyle | func setAuthStyle(tokenURL string, v AuthStyle) {
authStyleCache.Lock()
defer authStyleCache.Unlock()
if authStyleCache.m == nil {
authStyleCache.m = make(map[string]AuthStyle)
}
authStyleCache.m[tokenURL] = v
} | go | func setAuthStyle(tokenURL string, v AuthStyle) {
authStyleCache.Lock()
defer authStyleCache.Unlock()
if authStyleCache.m == nil {
authStyleCache.m = make(map[string]AuthStyle)
}
authStyleCache.m[tokenURL] = v
} | [
"func",
"setAuthStyle",
"(",
"tokenURL",
"string",
",",
"v",
"AuthStyle",
")",
"{",
"authStyleCache",
".",
"Lock",
"(",
")",
"\n",
"defer",
"authStyleCache",
".",
"Unlock",
"(",
")",
"\n",
"if",
"authStyleCache",
".",
"m",
"==",
"nil",
"{",
"authStyleCache... | // setAuthStyle adds an entry to authStyleCache, documented above. | [
"setAuthStyle",
"adds",
"an",
"entry",
"to",
"authStyleCache",
"documented",
"above",
"."
] | 9f3314589c9a9136388751d9adae6b0ed400978a | https://github.com/golang/oauth2/blob/9f3314589c9a9136388751d9adae6b0ed400978a/internal/token.go#L142-L149 |
29,221 | golang/oauth2 | hipchat/hipchat.go | ServerEndpoint | func ServerEndpoint(host string) oauth2.Endpoint {
return oauth2.Endpoint{
AuthURL: "https://" + host + "/users/authorize",
TokenURL: "https://" + host + "/v2/oauth/token",
}
} | go | func ServerEndpoint(host string) oauth2.Endpoint {
return oauth2.Endpoint{
AuthURL: "https://" + host + "/users/authorize",
TokenURL: "https://" + host + "/v2/oauth/token",
}
} | [
"func",
"ServerEndpoint",
"(",
"host",
"string",
")",
"oauth2",
".",
"Endpoint",
"{",
"return",
"oauth2",
".",
"Endpoint",
"{",
"AuthURL",
":",
"\"",
"\"",
"+",
"host",
"+",
"\"",
"\"",
",",
"TokenURL",
":",
"\"",
"\"",
"+",
"host",
"+",
"\"",
"\"",
... | // ServerEndpoint returns a new oauth2.Endpoint for a HipChat Server instance
// running on the given domain or host. | [
"ServerEndpoint",
"returns",
"a",
"new",
"oauth2",
".",
"Endpoint",
"for",
"a",
"HipChat",
"Server",
"instance",
"running",
"on",
"the",
"given",
"domain",
"or",
"host",
"."
] | 9f3314589c9a9136388751d9adae6b0ed400978a | https://github.com/golang/oauth2/blob/9f3314589c9a9136388751d9adae6b0ed400978a/hipchat/hipchat.go#L24-L29 |
29,222 | golang/oauth2 | clientcredentials/clientcredentials.go | Token | func (c *Config) Token(ctx context.Context) (*oauth2.Token, error) {
return c.TokenSource(ctx).Token()
} | go | func (c *Config) Token(ctx context.Context) (*oauth2.Token, error) {
return c.TokenSource(ctx).Token()
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Token",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"oauth2",
".",
"Token",
",",
"error",
")",
"{",
"return",
"c",
".",
"TokenSource",
"(",
"ctx",
")",
".",
"Token",
"(",
")",
"\n",
"}"
] | // Token uses client credentials to retrieve a token.
//
// The provided context optionally controls which HTTP client is used. See the oauth2.HTTPClient variable. | [
"Token",
"uses",
"client",
"credentials",
"to",
"retrieve",
"a",
"token",
".",
"The",
"provided",
"context",
"optionally",
"controls",
"which",
"HTTP",
"client",
"is",
"used",
".",
"See",
"the",
"oauth2",
".",
"HTTPClient",
"variable",
"."
] | 9f3314589c9a9136388751d9adae6b0ed400978a | https://github.com/golang/oauth2/blob/9f3314589c9a9136388751d9adae6b0ed400978a/clientcredentials/clientcredentials.go#L55-L57 |
29,223 | golang/oauth2 | jws/jws.go | EncodeWithSigner | func EncodeWithSigner(header *Header, c *ClaimSet, sg Signer) (string, error) {
head, err := header.encode()
if err != nil {
return "", err
}
cs, err := c.encode()
if err != nil {
return "", err
}
ss := fmt.Sprintf("%s.%s", head, cs)
sig, err := sg([]byte(ss))
if err != nil {
return "", err
}
return fm... | go | func EncodeWithSigner(header *Header, c *ClaimSet, sg Signer) (string, error) {
head, err := header.encode()
if err != nil {
return "", err
}
cs, err := c.encode()
if err != nil {
return "", err
}
ss := fmt.Sprintf("%s.%s", head, cs)
sig, err := sg([]byte(ss))
if err != nil {
return "", err
}
return fm... | [
"func",
"EncodeWithSigner",
"(",
"header",
"*",
"Header",
",",
"c",
"*",
"ClaimSet",
",",
"sg",
"Signer",
")",
"(",
"string",
",",
"error",
")",
"{",
"head",
",",
"err",
":=",
"header",
".",
"encode",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // EncodeWithSigner encodes a header and claim set with the provided signer. | [
"EncodeWithSigner",
"encodes",
"a",
"header",
"and",
"claim",
"set",
"with",
"the",
"provided",
"signer",
"."
] | 9f3314589c9a9136388751d9adae6b0ed400978a | https://github.com/golang/oauth2/blob/9f3314589c9a9136388751d9adae6b0ed400978a/jws/jws.go#L137-L152 |
29,224 | golang/oauth2 | jws/jws.go | Verify | func Verify(token string, key *rsa.PublicKey) error {
parts := strings.Split(token, ".")
if len(parts) != 3 {
return errors.New("jws: invalid token received, token must have 3 parts")
}
signedContent := parts[0] + "." + parts[1]
signatureString, err := base64.RawURLEncoding.DecodeString(parts[2])
if err != nil... | go | func Verify(token string, key *rsa.PublicKey) error {
parts := strings.Split(token, ".")
if len(parts) != 3 {
return errors.New("jws: invalid token received, token must have 3 parts")
}
signedContent := parts[0] + "." + parts[1]
signatureString, err := base64.RawURLEncoding.DecodeString(parts[2])
if err != nil... | [
"func",
"Verify",
"(",
"token",
"string",
",",
"key",
"*",
"rsa",
".",
"PublicKey",
")",
"error",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"token",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"3",
"{",
"return",
"er... | // Verify tests whether the provided JWT token's signature was produced by the private key
// associated with the supplied public key. | [
"Verify",
"tests",
"whether",
"the",
"provided",
"JWT",
"token",
"s",
"signature",
"was",
"produced",
"by",
"the",
"private",
"key",
"associated",
"with",
"the",
"supplied",
"public",
"key",
"."
] | 9f3314589c9a9136388751d9adae6b0ed400978a | https://github.com/golang/oauth2/blob/9f3314589c9a9136388751d9adae6b0ed400978a/jws/jws.go#L167-L182 |
29,225 | golang/oauth2 | jira/jira.go | sign | func sign(key string, claims *ClaimSet) (string, error) {
b, err := json.Marshal(defaultHeader)
if err != nil {
return "", err
}
header := base64.RawURLEncoding.EncodeToString(b)
jsonClaims, err := json.Marshal(claims)
if err != nil {
return "", err
}
encodedClaims := strings.TrimRight(base64.URLEncoding.E... | go | func sign(key string, claims *ClaimSet) (string, error) {
b, err := json.Marshal(defaultHeader)
if err != nil {
return "", err
}
header := base64.RawURLEncoding.EncodeToString(b)
jsonClaims, err := json.Marshal(claims)
if err != nil {
return "", err
}
encodedClaims := strings.TrimRight(base64.URLEncoding.E... | [
"func",
"sign",
"(",
"key",
"string",
",",
"claims",
"*",
"ClaimSet",
")",
"(",
"string",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"defaultHeader",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
... | // Sign the claim set with the shared secret
// Result to be sent as assertion | [
"Sign",
"the",
"claim",
"set",
"with",
"the",
"shared",
"secret",
"Result",
"to",
"be",
"sent",
"as",
"assertion"
] | 9f3314589c9a9136388751d9adae6b0ed400978a | https://github.com/golang/oauth2/blob/9f3314589c9a9136388751d9adae6b0ed400978a/jira/jira.go#L147-L167 |
29,226 | facebookarchive/grace | gracenet/net.go | activeListeners | func (n *Net) activeListeners() ([]net.Listener, error) {
n.mutex.Lock()
defer n.mutex.Unlock()
ls := make([]net.Listener, len(n.active))
copy(ls, n.active)
return ls, nil
} | go | func (n *Net) activeListeners() ([]net.Listener, error) {
n.mutex.Lock()
defer n.mutex.Unlock()
ls := make([]net.Listener, len(n.active))
copy(ls, n.active)
return ls, nil
} | [
"func",
"(",
"n",
"*",
"Net",
")",
"activeListeners",
"(",
")",
"(",
"[",
"]",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"n",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"n",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"ls",
":... | // activeListeners returns a snapshot copy of the active listeners. | [
"activeListeners",
"returns",
"a",
"snapshot",
"copy",
"of",
"the",
"active",
"listeners",
"."
] | 75cf19382434e82df4dd84953f566b8ad23d6e9e | https://github.com/facebookarchive/grace/blob/75cf19382434e82df4dd84953f566b8ad23d6e9e/gracenet/net.go#L172-L178 |
29,227 | facebookarchive/grace | gracenet/net.go | StartProcess | func (n *Net) StartProcess() (int, error) {
listeners, err := n.activeListeners()
if err != nil {
return 0, err
}
// Extract the fds from the listeners.
files := make([]*os.File, len(listeners))
for i, l := range listeners {
files[i], err = l.(filer).File()
if err != nil {
return 0, err
}
defer file... | go | func (n *Net) StartProcess() (int, error) {
listeners, err := n.activeListeners()
if err != nil {
return 0, err
}
// Extract the fds from the listeners.
files := make([]*os.File, len(listeners))
for i, l := range listeners {
files[i], err = l.(filer).File()
if err != nil {
return 0, err
}
defer file... | [
"func",
"(",
"n",
"*",
"Net",
")",
"StartProcess",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"listeners",
",",
"err",
":=",
"n",
".",
"activeListeners",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\... | // StartProcess starts a new process passing it the active listeners. It
// doesn't fork, but starts a new process using the same environment and
// arguments as when it was originally started. This allows for a newly
// deployed binary to be started. It returns the pid of the newly started
// process when successful. | [
"StartProcess",
"starts",
"a",
"new",
"process",
"passing",
"it",
"the",
"active",
"listeners",
".",
"It",
"doesn",
"t",
"fork",
"but",
"starts",
"a",
"new",
"process",
"using",
"the",
"same",
"environment",
"and",
"arguments",
"as",
"when",
"it",
"was",
"... | 75cf19382434e82df4dd84953f566b8ad23d6e9e | https://github.com/facebookarchive/grace/blob/75cf19382434e82df4dd84953f566b8ad23d6e9e/gracenet/net.go#L206-L248 |
29,228 | facebookarchive/grace | gracehttp/http.go | ServeWithOptions | func ServeWithOptions(servers []*http.Server, options ...option) error {
a := newApp(servers)
for _, opt := range options {
opt(a)
}
return a.run()
} | go | func ServeWithOptions(servers []*http.Server, options ...option) error {
a := newApp(servers)
for _, opt := range options {
opt(a)
}
return a.run()
} | [
"func",
"ServeWithOptions",
"(",
"servers",
"[",
"]",
"*",
"http",
".",
"Server",
",",
"options",
"...",
"option",
")",
"error",
"{",
"a",
":=",
"newApp",
"(",
"servers",
")",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"options",
"{",
"opt",
"(",
... | // ServeWithOptions does the same as Serve, but takes a set of options to
// configure the app struct. | [
"ServeWithOptions",
"does",
"the",
"same",
"as",
"Serve",
"but",
"takes",
"a",
"set",
"of",
"options",
"to",
"configure",
"the",
"app",
"struct",
"."
] | 75cf19382434e82df4dd84953f566b8ad23d6e9e | https://github.com/facebookarchive/grace/blob/75cf19382434e82df4dd84953f566b8ad23d6e9e/gracehttp/http.go#L181-L187 |
29,229 | facebookarchive/grace | gracehttp/http.go | pprintAddr | func pprintAddr(listeners []net.Listener) []byte {
var out bytes.Buffer
for i, l := range listeners {
if i != 0 {
fmt.Fprint(&out, ", ")
}
fmt.Fprint(&out, l.Addr())
}
return out.Bytes()
} | go | func pprintAddr(listeners []net.Listener) []byte {
var out bytes.Buffer
for i, l := range listeners {
if i != 0 {
fmt.Fprint(&out, ", ")
}
fmt.Fprint(&out, l.Addr())
}
return out.Bytes()
} | [
"func",
"pprintAddr",
"(",
"listeners",
"[",
"]",
"net",
".",
"Listener",
")",
"[",
"]",
"byte",
"{",
"var",
"out",
"bytes",
".",
"Buffer",
"\n",
"for",
"i",
",",
"l",
":=",
"range",
"listeners",
"{",
"if",
"i",
"!=",
"0",
"{",
"fmt",
".",
"Fprin... | // Used for pretty printing addresses. | [
"Used",
"for",
"pretty",
"printing",
"addresses",
"."
] | 75cf19382434e82df4dd84953f566b8ad23d6e9e | https://github.com/facebookarchive/grace/blob/75cf19382434e82df4dd84953f566b8ad23d6e9e/gracehttp/http.go#L206-L215 |
29,230 | google/btree | btree.go | freeNode | func (f *FreeList) freeNode(n *node) (out bool) {
f.mu.Lock()
if len(f.freelist) < cap(f.freelist) {
f.freelist = append(f.freelist, n)
out = true
}
f.mu.Unlock()
return
} | go | func (f *FreeList) freeNode(n *node) (out bool) {
f.mu.Lock()
if len(f.freelist) < cap(f.freelist) {
f.freelist = append(f.freelist, n)
out = true
}
f.mu.Unlock()
return
} | [
"func",
"(",
"f",
"*",
"FreeList",
")",
"freeNode",
"(",
"n",
"*",
"node",
")",
"(",
"out",
"bool",
")",
"{",
"f",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",
"len",
"(",
"f",
".",
"freelist",
")",
"<",
"cap",
"(",
"f",
".",
"freelist",
"... | // freeNode adds the given node to the list, returning true if it was added
// and false if it was discarded. | [
"freeNode",
"adds",
"the",
"given",
"node",
"to",
"the",
"list",
"returning",
"true",
"if",
"it",
"was",
"added",
"and",
"false",
"if",
"it",
"was",
"discarded",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L108-L116 |
29,231 | google/btree | btree.go | NewWithFreeList | func NewWithFreeList(degree int, f *FreeList) *BTree {
if degree <= 1 {
panic("bad degree")
}
return &BTree{
degree: degree,
cow: ©OnWriteContext{freelist: f},
}
} | go | func NewWithFreeList(degree int, f *FreeList) *BTree {
if degree <= 1 {
panic("bad degree")
}
return &BTree{
degree: degree,
cow: ©OnWriteContext{freelist: f},
}
} | [
"func",
"NewWithFreeList",
"(",
"degree",
"int",
",",
"f",
"*",
"FreeList",
")",
"*",
"BTree",
"{",
"if",
"degree",
"<=",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"BTree",
"{",
"degree",
":",
"degree",
",",
"cow",
... | // NewWithFreeList creates a new B-Tree that uses the given node free list. | [
"NewWithFreeList",
"creates",
"a",
"new",
"B",
"-",
"Tree",
"that",
"uses",
"the",
"given",
"node",
"free",
"list",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L132-L140 |
29,232 | google/btree | btree.go | truncate | func (s *items) truncate(index int) {
var toClear items
*s, toClear = (*s)[:index], (*s)[index:]
for len(toClear) > 0 {
toClear = toClear[copy(toClear, nilItems):]
}
} | go | func (s *items) truncate(index int) {
var toClear items
*s, toClear = (*s)[:index], (*s)[index:]
for len(toClear) > 0 {
toClear = toClear[copy(toClear, nilItems):]
}
} | [
"func",
"(",
"s",
"*",
"items",
")",
"truncate",
"(",
"index",
"int",
")",
"{",
"var",
"toClear",
"items",
"\n",
"*",
"s",
",",
"toClear",
"=",
"(",
"*",
"s",
")",
"[",
":",
"index",
"]",
",",
"(",
"*",
"s",
")",
"[",
"index",
":",
"]",
"\n... | // truncate truncates this instance at index so that it contains only the
// first index items. index must be less than or equal to length. | [
"truncate",
"truncates",
"this",
"instance",
"at",
"index",
"so",
"that",
"it",
"contains",
"only",
"the",
"first",
"index",
"items",
".",
"index",
"must",
"be",
"less",
"than",
"or",
"equal",
"to",
"length",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L176-L182 |
29,233 | google/btree | btree.go | find | func (s items) find(item Item) (index int, found bool) {
i := sort.Search(len(s), func(i int) bool {
return item.Less(s[i])
})
if i > 0 && !s[i-1].Less(item) {
return i - 1, true
}
return i, false
} | go | func (s items) find(item Item) (index int, found bool) {
i := sort.Search(len(s), func(i int) bool {
return item.Less(s[i])
})
if i > 0 && !s[i-1].Less(item) {
return i - 1, true
}
return i, false
} | [
"func",
"(",
"s",
"items",
")",
"find",
"(",
"item",
"Item",
")",
"(",
"index",
"int",
",",
"found",
"bool",
")",
"{",
"i",
":=",
"sort",
".",
"Search",
"(",
"len",
"(",
"s",
")",
",",
"func",
"(",
"i",
"int",
")",
"bool",
"{",
"return",
"ite... | // find returns the index where the given item should be inserted into this
// list. 'found' is true if the item already exists in the list at the given
// index. | [
"find",
"returns",
"the",
"index",
"where",
"the",
"given",
"item",
"should",
"be",
"inserted",
"into",
"this",
"list",
".",
"found",
"is",
"true",
"if",
"the",
"item",
"already",
"exists",
"in",
"the",
"list",
"at",
"the",
"given",
"index",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L187-L195 |
29,234 | google/btree | btree.go | truncate | func (s *children) truncate(index int) {
var toClear children
*s, toClear = (*s)[:index], (*s)[index:]
for len(toClear) > 0 {
toClear = toClear[copy(toClear, nilChildren):]
}
} | go | func (s *children) truncate(index int) {
var toClear children
*s, toClear = (*s)[:index], (*s)[index:]
for len(toClear) > 0 {
toClear = toClear[copy(toClear, nilChildren):]
}
} | [
"func",
"(",
"s",
"*",
"children",
")",
"truncate",
"(",
"index",
"int",
")",
"{",
"var",
"toClear",
"children",
"\n",
"*",
"s",
",",
"toClear",
"=",
"(",
"*",
"s",
")",
"[",
":",
"index",
"]",
",",
"(",
"*",
"s",
")",
"[",
"index",
":",
"]",... | // truncate truncates this instance at index so that it contains only the
// first index children. index must be less than or equal to length. | [
"truncate",
"truncates",
"this",
"instance",
"at",
"index",
"so",
"that",
"it",
"contains",
"only",
"the",
"first",
"index",
"children",
".",
"index",
"must",
"be",
"less",
"than",
"or",
"equal",
"to",
"length",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L231-L237 |
29,235 | google/btree | btree.go | maybeSplitChild | func (n *node) maybeSplitChild(i, maxItems int) bool {
if len(n.children[i].items) < maxItems {
return false
}
first := n.mutableChild(i)
item, second := first.split(maxItems / 2)
n.items.insertAt(i, item)
n.children.insertAt(i+1, second)
return true
} | go | func (n *node) maybeSplitChild(i, maxItems int) bool {
if len(n.children[i].items) < maxItems {
return false
}
first := n.mutableChild(i)
item, second := first.split(maxItems / 2)
n.items.insertAt(i, item)
n.children.insertAt(i+1, second)
return true
} | [
"func",
"(",
"n",
"*",
"node",
")",
"maybeSplitChild",
"(",
"i",
",",
"maxItems",
"int",
")",
"bool",
"{",
"if",
"len",
"(",
"n",
".",
"children",
"[",
"i",
"]",
".",
"items",
")",
"<",
"maxItems",
"{",
"return",
"false",
"\n",
"}",
"\n",
"first"... | // maybeSplitChild checks if a child should be split, and if so splits it.
// Returns whether or not a split occurred. | [
"maybeSplitChild",
"checks",
"if",
"a",
"child",
"should",
"be",
"split",
"and",
"if",
"so",
"splits",
"it",
".",
"Returns",
"whether",
"or",
"not",
"a",
"split",
"occurred",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L294-L303 |
29,236 | google/btree | btree.go | get | func (n *node) get(key Item) Item {
i, found := n.items.find(key)
if found {
return n.items[i]
} else if len(n.children) > 0 {
return n.children[i].get(key)
}
return nil
} | go | func (n *node) get(key Item) Item {
i, found := n.items.find(key)
if found {
return n.items[i]
} else if len(n.children) > 0 {
return n.children[i].get(key)
}
return nil
} | [
"func",
"(",
"n",
"*",
"node",
")",
"get",
"(",
"key",
"Item",
")",
"Item",
"{",
"i",
",",
"found",
":=",
"n",
".",
"items",
".",
"find",
"(",
"key",
")",
"\n",
"if",
"found",
"{",
"return",
"n",
".",
"items",
"[",
"i",
"]",
"\n",
"}",
"els... | // get finds the given key in the subtree and returns it. | [
"get",
"finds",
"the",
"given",
"key",
"in",
"the",
"subtree",
"and",
"returns",
"it",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L336-L344 |
29,237 | google/btree | btree.go | min | func min(n *node) Item {
if n == nil {
return nil
}
for len(n.children) > 0 {
n = n.children[0]
}
if len(n.items) == 0 {
return nil
}
return n.items[0]
} | go | func min(n *node) Item {
if n == nil {
return nil
}
for len(n.children) > 0 {
n = n.children[0]
}
if len(n.items) == 0 {
return nil
}
return n.items[0]
} | [
"func",
"min",
"(",
"n",
"*",
"node",
")",
"Item",
"{",
"if",
"n",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"for",
"len",
"(",
"n",
".",
"children",
")",
">",
"0",
"{",
"n",
"=",
"n",
".",
"children",
"[",
"0",
"]",
"\n",
"}",
... | // min returns the first item in the subtree. | [
"min",
"returns",
"the",
"first",
"item",
"in",
"the",
"subtree",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L347-L358 |
29,238 | google/btree | btree.go | max | func max(n *node) Item {
if n == nil {
return nil
}
for len(n.children) > 0 {
n = n.children[len(n.children)-1]
}
if len(n.items) == 0 {
return nil
}
return n.items[len(n.items)-1]
} | go | func max(n *node) Item {
if n == nil {
return nil
}
for len(n.children) > 0 {
n = n.children[len(n.children)-1]
}
if len(n.items) == 0 {
return nil
}
return n.items[len(n.items)-1]
} | [
"func",
"max",
"(",
"n",
"*",
"node",
")",
"Item",
"{",
"if",
"n",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"for",
"len",
"(",
"n",
".",
"children",
")",
">",
"0",
"{",
"n",
"=",
"n",
".",
"children",
"[",
"len",
"(",
"n",
".",
... | // max returns the last item in the subtree. | [
"max",
"returns",
"the",
"last",
"item",
"in",
"the",
"subtree",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L361-L372 |
29,239 | google/btree | btree.go | remove | func (n *node) remove(item Item, minItems int, typ toRemove) Item {
var i int
var found bool
switch typ {
case removeMax:
if len(n.children) == 0 {
return n.items.pop()
}
i = len(n.items)
case removeMin:
if len(n.children) == 0 {
return n.items.removeAt(0)
}
i = 0
case removeItem:
i, found = n... | go | func (n *node) remove(item Item, minItems int, typ toRemove) Item {
var i int
var found bool
switch typ {
case removeMax:
if len(n.children) == 0 {
return n.items.pop()
}
i = len(n.items)
case removeMin:
if len(n.children) == 0 {
return n.items.removeAt(0)
}
i = 0
case removeItem:
i, found = n... | [
"func",
"(",
"n",
"*",
"node",
")",
"remove",
"(",
"item",
"Item",
",",
"minItems",
"int",
",",
"typ",
"toRemove",
")",
"Item",
"{",
"var",
"i",
"int",
"\n",
"var",
"found",
"bool",
"\n",
"switch",
"typ",
"{",
"case",
"removeMax",
":",
"if",
"len",... | // remove removes an item from the subtree rooted at this node. | [
"remove",
"removes",
"an",
"item",
"from",
"the",
"subtree",
"rooted",
"at",
"this",
"node",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L384-L430 |
29,240 | google/btree | btree.go | Delete | func (t *BTree) Delete(item Item) Item {
return t.deleteItem(item, removeItem)
} | go | func (t *BTree) Delete(item Item) Item {
return t.deleteItem(item, removeItem)
} | [
"func",
"(",
"t",
"*",
"BTree",
")",
"Delete",
"(",
"item",
"Item",
")",
"Item",
"{",
"return",
"t",
".",
"deleteItem",
"(",
"item",
",",
"removeItem",
")",
"\n",
"}"
] | // Delete removes an item equal to the passed in item from the tree, returning
// it. If no such item exists, returns nil. | [
"Delete",
"removes",
"an",
"item",
"equal",
"to",
"the",
"passed",
"in",
"item",
"from",
"the",
"tree",
"returning",
"it",
".",
"If",
"no",
"such",
"item",
"exists",
"returns",
"nil",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L711-L713 |
29,241 | google/btree | btree.go | AscendRange | func (t *BTree) AscendRange(greaterOrEqual, lessThan Item, iterator ItemIterator) {
if t.root == nil {
return
}
t.root.iterate(ascend, greaterOrEqual, lessThan, true, false, iterator)
} | go | func (t *BTree) AscendRange(greaterOrEqual, lessThan Item, iterator ItemIterator) {
if t.root == nil {
return
}
t.root.iterate(ascend, greaterOrEqual, lessThan, true, false, iterator)
} | [
"func",
"(",
"t",
"*",
"BTree",
")",
"AscendRange",
"(",
"greaterOrEqual",
",",
"lessThan",
"Item",
",",
"iterator",
"ItemIterator",
")",
"{",
"if",
"t",
".",
"root",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"t",
".",
"root",
".",
"iterate",
"(",... | // AscendRange calls the iterator for every value in the tree within the range
// [greaterOrEqual, lessThan), until iterator returns false. | [
"AscendRange",
"calls",
"the",
"iterator",
"for",
"every",
"value",
"in",
"the",
"tree",
"within",
"the",
"range",
"[",
"greaterOrEqual",
"lessThan",
")",
"until",
"iterator",
"returns",
"false",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L746-L751 |
29,242 | google/btree | btree.go | AscendLessThan | func (t *BTree) AscendLessThan(pivot Item, iterator ItemIterator) {
if t.root == nil {
return
}
t.root.iterate(ascend, nil, pivot, false, false, iterator)
} | go | func (t *BTree) AscendLessThan(pivot Item, iterator ItemIterator) {
if t.root == nil {
return
}
t.root.iterate(ascend, nil, pivot, false, false, iterator)
} | [
"func",
"(",
"t",
"*",
"BTree",
")",
"AscendLessThan",
"(",
"pivot",
"Item",
",",
"iterator",
"ItemIterator",
")",
"{",
"if",
"t",
".",
"root",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"t",
".",
"root",
".",
"iterate",
"(",
"ascend",
",",
"nil"... | // AscendLessThan calls the iterator for every value in the tree within the range
// [first, pivot), until iterator returns false. | [
"AscendLessThan",
"calls",
"the",
"iterator",
"for",
"every",
"value",
"in",
"the",
"tree",
"within",
"the",
"range",
"[",
"first",
"pivot",
")",
"until",
"iterator",
"returns",
"false",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L755-L760 |
29,243 | google/btree | btree.go | DescendRange | func (t *BTree) DescendRange(lessOrEqual, greaterThan Item, iterator ItemIterator) {
if t.root == nil {
return
}
t.root.iterate(descend, lessOrEqual, greaterThan, true, false, iterator)
} | go | func (t *BTree) DescendRange(lessOrEqual, greaterThan Item, iterator ItemIterator) {
if t.root == nil {
return
}
t.root.iterate(descend, lessOrEqual, greaterThan, true, false, iterator)
} | [
"func",
"(",
"t",
"*",
"BTree",
")",
"DescendRange",
"(",
"lessOrEqual",
",",
"greaterThan",
"Item",
",",
"iterator",
"ItemIterator",
")",
"{",
"if",
"t",
".",
"root",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"t",
".",
"root",
".",
"iterate",
"("... | // DescendRange calls the iterator for every value in the tree within the range
// [lessOrEqual, greaterThan), until iterator returns false. | [
"DescendRange",
"calls",
"the",
"iterator",
"for",
"every",
"value",
"in",
"the",
"tree",
"within",
"the",
"range",
"[",
"lessOrEqual",
"greaterThan",
")",
"until",
"iterator",
"returns",
"false",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L782-L787 |
29,244 | google/btree | btree.go | DescendGreaterThan | func (t *BTree) DescendGreaterThan(pivot Item, iterator ItemIterator) {
if t.root == nil {
return
}
t.root.iterate(descend, nil, pivot, false, false, iterator)
} | go | func (t *BTree) DescendGreaterThan(pivot Item, iterator ItemIterator) {
if t.root == nil {
return
}
t.root.iterate(descend, nil, pivot, false, false, iterator)
} | [
"func",
"(",
"t",
"*",
"BTree",
")",
"DescendGreaterThan",
"(",
"pivot",
"Item",
",",
"iterator",
"ItemIterator",
")",
"{",
"if",
"t",
".",
"root",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"t",
".",
"root",
".",
"iterate",
"(",
"descend",
",",
... | // DescendGreaterThan calls the iterator for every value in the tree within
// the range (pivot, last], until iterator returns false. | [
"DescendGreaterThan",
"calls",
"the",
"iterator",
"for",
"every",
"value",
"in",
"the",
"tree",
"within",
"the",
"range",
"(",
"pivot",
"last",
"]",
"until",
"iterator",
"returns",
"false",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L800-L805 |
29,245 | google/btree | btree.go | Get | func (t *BTree) Get(key Item) Item {
if t.root == nil {
return nil
}
return t.root.get(key)
} | go | func (t *BTree) Get(key Item) Item {
if t.root == nil {
return nil
}
return t.root.get(key)
} | [
"func",
"(",
"t",
"*",
"BTree",
")",
"Get",
"(",
"key",
"Item",
")",
"Item",
"{",
"if",
"t",
".",
"root",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"t",
".",
"root",
".",
"get",
"(",
"key",
")",
"\n",
"}"
] | // Get looks for the key item in the tree, returning it. It returns nil if
// unable to find that item. | [
"Get",
"looks",
"for",
"the",
"key",
"item",
"in",
"the",
"tree",
"returning",
"it",
".",
"It",
"returns",
"nil",
"if",
"unable",
"to",
"find",
"that",
"item",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L818-L823 |
29,246 | google/btree | btree.go | Has | func (t *BTree) Has(key Item) bool {
return t.Get(key) != nil
} | go | func (t *BTree) Has(key Item) bool {
return t.Get(key) != nil
} | [
"func",
"(",
"t",
"*",
"BTree",
")",
"Has",
"(",
"key",
"Item",
")",
"bool",
"{",
"return",
"t",
".",
"Get",
"(",
"key",
")",
"!=",
"nil",
"\n",
"}"
] | // Has returns true if the given key is in the tree. | [
"Has",
"returns",
"true",
"if",
"the",
"given",
"key",
"is",
"in",
"the",
"tree",
"."
] | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L836-L838 |
29,247 | google/btree | btree.go | reset | func (n *node) reset(c *copyOnWriteContext) bool {
for _, child := range n.children {
if !child.reset(c) {
return false
}
}
return c.freeNode(n) != ftFreelistFull
} | go | func (n *node) reset(c *copyOnWriteContext) bool {
for _, child := range n.children {
if !child.reset(c) {
return false
}
}
return c.freeNode(n) != ftFreelistFull
} | [
"func",
"(",
"n",
"*",
"node",
")",
"reset",
"(",
"c",
"*",
"copyOnWriteContext",
")",
"bool",
"{",
"for",
"_",
",",
"child",
":=",
"range",
"n",
".",
"children",
"{",
"if",
"!",
"child",
".",
"reset",
"(",
"c",
")",
"{",
"return",
"false",
"\n",... | // reset returns a subtree to the freelist. It breaks out immediately if the
// freelist is full, since the only benefit of iterating is to fill that
// freelist up. Returns true if parent reset call should continue. | [
"reset",
"returns",
"a",
"subtree",
"to",
"the",
"freelist",
".",
"It",
"breaks",
"out",
"immediately",
"if",
"the",
"freelist",
"is",
"full",
"since",
"the",
"only",
"benefit",
"of",
"iterating",
"is",
"to",
"fill",
"that",
"freelist",
"up",
".",
"Returns... | 20236160a414454a9c64b6c8829381c6f4bddcaa | https://github.com/google/btree/blob/20236160a414454a9c64b6c8829381c6f4bddcaa/btree.go#L875-L882 |
29,248 | kshvakov/clickhouse | lib/column/ip.go | Scan | func (ip *IP) Scan(value interface{}) (err error) {
switch v := value.(type) {
case []byte:
if len(v) == 4 || len(v) == 16 {
*ip = IP(v)
} else {
err = errInvalidScanValue
}
case string:
if len(v) == 4 || len(v) == 16 {
*ip = IP([]byte(v))
} else {
err = errInvalidScanValue
}
default:
err ... | go | func (ip *IP) Scan(value interface{}) (err error) {
switch v := value.(type) {
case []byte:
if len(v) == 4 || len(v) == 16 {
*ip = IP(v)
} else {
err = errInvalidScanValue
}
case string:
if len(v) == 4 || len(v) == 16 {
*ip = IP([]byte(v))
} else {
err = errInvalidScanValue
}
default:
err ... | [
"func",
"(",
"ip",
"*",
"IP",
")",
"Scan",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"switch",
"v",
":=",
"value",
".",
"(",
"type",
")",
"{",
"case",
"[",
"]",
"byte",
":",
"if",
"len",
"(",
"v",
")",
"==",
"... | // Scan implements the driver.Valuer interface, json field interface | [
"Scan",
"implements",
"the",
"driver",
".",
"Valuer",
"interface",
"json",
"field",
"interface"
] | 04847609e9ba2f114bdd435bc78e6c816a4ef5c1 | https://github.com/kshvakov/clickhouse/blob/04847609e9ba2f114bdd435bc78e6c816a4ef5c1/lib/column/ip.go#L50-L68 |
29,249 | kshvakov/clickhouse | lib/cityhash102/cityhash.go | hashLen17to32 | func hashLen17to32(s []byte, length uint32) uint64 {
var a = fetch64(s) * k1
var b = fetch64(s[8:])
var c = fetch64(s[length-8:]) * k2
var d = fetch64(s[length-16:]) * k0
return hashLen16(rotate64(a-b, 43)+rotate64(c, 30)+d,
a+rotate64(b^k3, 20)-c+uint64(length))
} | go | func hashLen17to32(s []byte, length uint32) uint64 {
var a = fetch64(s) * k1
var b = fetch64(s[8:])
var c = fetch64(s[length-8:]) * k2
var d = fetch64(s[length-16:]) * k0
return hashLen16(rotate64(a-b, 43)+rotate64(c, 30)+d,
a+rotate64(b^k3, 20)-c+uint64(length))
} | [
"func",
"hashLen17to32",
"(",
"s",
"[",
"]",
"byte",
",",
"length",
"uint32",
")",
"uint64",
"{",
"var",
"a",
"=",
"fetch64",
"(",
"s",
")",
"*",
"k1",
"\n",
"var",
"b",
"=",
"fetch64",
"(",
"s",
"[",
"8",
":",
"]",
")",
"\n",
"var",
"c",
"="... | // This probably works well for 16-byte strings as well, but it may be overkill | [
"This",
"probably",
"works",
"well",
"for",
"16",
"-",
"byte",
"strings",
"as",
"well",
"but",
"it",
"may",
"be",
"overkill"
] | 04847609e9ba2f114bdd435bc78e6c816a4ef5c1 | https://github.com/kshvakov/clickhouse/blob/04847609e9ba2f114bdd435bc78e6c816a4ef5c1/lib/cityhash102/cityhash.go#L151-L159 |
29,250 | kshvakov/clickhouse | lib/binary/compress_writer.go | NewCompressWriter | func NewCompressWriter(w io.Writer) *compressWriter {
p := &compressWriter{writer: w}
p.data = make([]byte, BlockMaxSize, BlockMaxSize)
zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize
p.zdata = make([]byte, zlen, zlen)
return p
} | go | func NewCompressWriter(w io.Writer) *compressWriter {
p := &compressWriter{writer: w}
p.data = make([]byte, BlockMaxSize, BlockMaxSize)
zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize
p.zdata = make([]byte, zlen, zlen)
return p
} | [
"func",
"NewCompressWriter",
"(",
"w",
"io",
".",
"Writer",
")",
"*",
"compressWriter",
"{",
"p",
":=",
"&",
"compressWriter",
"{",
"writer",
":",
"w",
"}",
"\n",
"p",
".",
"data",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"BlockMaxSize",
",",
"BlockM... | // NewCompressWriter wrap the io.Writer | [
"NewCompressWriter",
"wrap",
"the",
"io",
".",
"Writer"
] | 04847609e9ba2f114bdd435bc78e6c816a4ef5c1 | https://github.com/kshvakov/clickhouse/blob/04847609e9ba2f114bdd435bc78e6c816a4ef5c1/lib/binary/compress_writer.go#L24-L31 |
29,251 | kshvakov/clickhouse | lib/column/uuid.go | xtob | func xtob(x1, x2 byte) (byte, bool) {
b1 := xvalues[x1]
b2 := xvalues[x2]
return (b1 << 4) | b2, b1 != 255 && b2 != 255
} | go | func xtob(x1, x2 byte) (byte, bool) {
b1 := xvalues[x1]
b2 := xvalues[x2]
return (b1 << 4) | b2, b1 != 255 && b2 != 255
} | [
"func",
"xtob",
"(",
"x1",
",",
"x2",
"byte",
")",
"(",
"byte",
",",
"bool",
")",
"{",
"b1",
":=",
"xvalues",
"[",
"x1",
"]",
"\n",
"b2",
":=",
"xvalues",
"[",
"x2",
"]",
"\n",
"return",
"(",
"b1",
"<<",
"4",
")",
"|",
"b2",
",",
"b1",
"!="... | // xtob converts hex characters x1 and x2 into a byte. | [
"xtob",
"converts",
"hex",
"characters",
"x1",
"and",
"x2",
"into",
"a",
"byte",
"."
] | 04847609e9ba2f114bdd435bc78e6c816a4ef5c1 | https://github.com/kshvakov/clickhouse/blob/04847609e9ba2f114bdd435bc78e6c816a4ef5c1/lib/column/uuid.go#L126-L130 |
29,252 | kshvakov/clickhouse | word_matcher.go | newMatcher | func newMatcher(needle string) *wordMatcher {
return &wordMatcher{word: []rune(strings.ToUpper(needle)),
position: 0}
} | go | func newMatcher(needle string) *wordMatcher {
return &wordMatcher{word: []rune(strings.ToUpper(needle)),
position: 0}
} | [
"func",
"newMatcher",
"(",
"needle",
"string",
")",
"*",
"wordMatcher",
"{",
"return",
"&",
"wordMatcher",
"{",
"word",
":",
"[",
"]",
"rune",
"(",
"strings",
".",
"ToUpper",
"(",
"needle",
")",
")",
",",
"position",
":",
"0",
"}",
"\n",
"}"
] | // newMatcher returns matcher for word needle | [
"newMatcher",
"returns",
"matcher",
"for",
"word",
"needle"
] | 04847609e9ba2f114bdd435bc78e6c816a4ef5c1 | https://github.com/kshvakov/clickhouse/blob/04847609e9ba2f114bdd435bc78e6c816a4ef5c1/word_matcher.go#L15-L18 |
29,253 | kshvakov/clickhouse | lib/binary/compress_reader.go | NewCompressReader | func NewCompressReader(r io.Reader) *compressReader {
p := &compressReader{
reader: r,
header: make([]byte, HeaderSize),
}
p.data = make([]byte, BlockMaxSize, BlockMaxSize)
zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize
p.zdata = make([]byte, zlen, zlen)
p.pos = len(p.data)
return p
} | go | func NewCompressReader(r io.Reader) *compressReader {
p := &compressReader{
reader: r,
header: make([]byte, HeaderSize),
}
p.data = make([]byte, BlockMaxSize, BlockMaxSize)
zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize
p.zdata = make([]byte, zlen, zlen)
p.pos = len(p.data)
return p
} | [
"func",
"NewCompressReader",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"compressReader",
"{",
"p",
":=",
"&",
"compressReader",
"{",
"reader",
":",
"r",
",",
"header",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"HeaderSize",
")",
",",
"}",
"\n",
"p",
... | // NewCompressReader wrap the io.Reader | [
"NewCompressReader",
"wrap",
"the",
"io",
".",
"Reader"
] | 04847609e9ba2f114bdd435bc78e6c816a4ef5c1 | https://github.com/kshvakov/clickhouse/blob/04847609e9ba2f114bdd435bc78e6c816a4ef5c1/lib/binary/compress_reader.go#L26-L38 |
29,254 | kshvakov/clickhouse | tls_config.go | RegisterTLSConfig | func RegisterTLSConfig(key string, config *tls.Config) error {
tlsConfigLock.Lock()
if tlsConfigRegistry == nil {
tlsConfigRegistry = make(map[string]*tls.Config)
}
tlsConfigRegistry[key] = config
tlsConfigLock.Unlock()
return nil
} | go | func RegisterTLSConfig(key string, config *tls.Config) error {
tlsConfigLock.Lock()
if tlsConfigRegistry == nil {
tlsConfigRegistry = make(map[string]*tls.Config)
}
tlsConfigRegistry[key] = config
tlsConfigLock.Unlock()
return nil
} | [
"func",
"RegisterTLSConfig",
"(",
"key",
"string",
",",
"config",
"*",
"tls",
".",
"Config",
")",
"error",
"{",
"tlsConfigLock",
".",
"Lock",
"(",
")",
"\n",
"if",
"tlsConfigRegistry",
"==",
"nil",
"{",
"tlsConfigRegistry",
"=",
"make",
"(",
"map",
"[",
... | // RegisterTLSConfig registers a custom tls.Config to be used with sql.Open. | [
"RegisterTLSConfig",
"registers",
"a",
"custom",
"tls",
".",
"Config",
"to",
"be",
"used",
"with",
"sql",
".",
"Open",
"."
] | 04847609e9ba2f114bdd435bc78e6c816a4ef5c1 | https://github.com/kshvakov/clickhouse/blob/04847609e9ba2f114bdd435bc78e6c816a4ef5c1/tls_config.go#L17-L26 |
29,255 | takama/daemon | examples/myservice.go | acceptConnection | func acceptConnection(listener net.Listener, listen chan<- net.Conn) {
for {
conn, err := listener.Accept()
if err != nil {
continue
}
listen <- conn
}
} | go | func acceptConnection(listener net.Listener, listen chan<- net.Conn) {
for {
conn, err := listener.Accept()
if err != nil {
continue
}
listen <- conn
}
} | [
"func",
"acceptConnection",
"(",
"listener",
"net",
".",
"Listener",
",",
"listen",
"chan",
"<-",
"net",
".",
"Conn",
")",
"{",
"for",
"{",
"conn",
",",
"err",
":=",
"listener",
".",
"Accept",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"continue"... | // Accept a client connection and collect it in a channel | [
"Accept",
"a",
"client",
"connection",
"and",
"collect",
"it",
"in",
"a",
"channel"
] | aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e | https://github.com/takama/daemon/blob/aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e/examples/myservice.go#L96-L104 |
29,256 | takama/daemon | daemon_freebsd.go | isEnabled | func (bsd *bsdRecord) isEnabled() (bool, error) {
rcConf, err := os.Open("/etc/rc.conf")
if err != nil {
fmt.Println("Error opening file:", err)
return false, err
}
defer rcConf.Close()
rcData, _ := ioutil.ReadAll(rcConf)
r, _ := regexp.Compile(`.*` + bsd.name + `_enable="YES".*`)
v := string(r.Find(rcData))... | go | func (bsd *bsdRecord) isEnabled() (bool, error) {
rcConf, err := os.Open("/etc/rc.conf")
if err != nil {
fmt.Println("Error opening file:", err)
return false, err
}
defer rcConf.Close()
rcData, _ := ioutil.ReadAll(rcConf)
r, _ := regexp.Compile(`.*` + bsd.name + `_enable="YES".*`)
v := string(r.Find(rcData))... | [
"func",
"(",
"bsd",
"*",
"bsdRecord",
")",
"isEnabled",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"rcConf",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"\"",
... | // Is a service is enabled | [
"Is",
"a",
"service",
"is",
"enabled"
] | aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e | https://github.com/takama/daemon/blob/aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e/daemon_freebsd.go#L37-L58 |
29,257 | takama/daemon | daemon_darwin.go | checkRunning | func (darwin *darwinRecord) checkRunning() (string, bool) {
output, err := exec.Command("launchctl", "list", darwin.name).Output()
if err == nil {
if matched, err := regexp.MatchString(darwin.name, string(output)); err == nil && matched {
reg := regexp.MustCompile("PID\" = ([0-9]+);")
data := reg.FindStringSu... | go | func (darwin *darwinRecord) checkRunning() (string, bool) {
output, err := exec.Command("launchctl", "list", darwin.name).Output()
if err == nil {
if matched, err := regexp.MatchString(darwin.name, string(output)); err == nil && matched {
reg := regexp.MustCompile("PID\" = ([0-9]+);")
data := reg.FindStringSu... | [
"func",
"(",
"darwin",
"*",
"darwinRecord",
")",
"checkRunning",
"(",
")",
"(",
"string",
",",
"bool",
")",
"{",
"output",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"darwin",
".",
"name",
")",
".",
"Output",
... | // Check service is running | [
"Check",
"service",
"is",
"running"
] | aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e | https://github.com/takama/daemon/blob/aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e/daemon_darwin.go#L49-L63 |
29,258 | takama/daemon | daemon_windows.go | execPath | func execPath() (string, error) {
var n uint32
b := make([]uint16, syscall.MAX_PATH)
size := uint32(len(b))
r0, _, e1 := syscall.MustLoadDLL(
"kernel32.dll",
).MustFindProc(
"GetModuleFileNameW",
).Call(0, uintptr(unsafe.Pointer(&b[0])), uintptr(size))
n = uint32(r0)
if n == 0 {
return "", e1
}
return ... | go | func execPath() (string, error) {
var n uint32
b := make([]uint16, syscall.MAX_PATH)
size := uint32(len(b))
r0, _, e1 := syscall.MustLoadDLL(
"kernel32.dll",
).MustFindProc(
"GetModuleFileNameW",
).Call(0, uintptr(unsafe.Pointer(&b[0])), uintptr(size))
n = uint32(r0)
if n == 0 {
return "", e1
}
return ... | [
"func",
"execPath",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"n",
"uint32",
"\n",
"b",
":=",
"make",
"(",
"[",
"]",
"uint16",
",",
"syscall",
".",
"MAX_PATH",
")",
"\n",
"size",
":=",
"uint32",
"(",
"len",
"(",
"b",
")",
")",
"\n... | // Get executable path | [
"Get",
"executable",
"path"
] | aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e | https://github.com/takama/daemon/blob/aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e/daemon_windows.go#L202-L217 |
29,259 | takama/daemon | daemon_windows.go | getWindowsError | func getWindowsError(inputError error) error {
if exiterr, ok := inputError.(*exec.ExitError); ok {
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
if sysErr, ok := WinErrCode[status.ExitStatus()]; ok {
return errors.New(fmt.Sprintf("\n %s: %s \n %s", sysErr.Title, sysErr.Description, sysErr.Action)... | go | func getWindowsError(inputError error) error {
if exiterr, ok := inputError.(*exec.ExitError); ok {
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
if sysErr, ok := WinErrCode[status.ExitStatus()]; ok {
return errors.New(fmt.Sprintf("\n %s: %s \n %s", sysErr.Title, sysErr.Description, sysErr.Action)... | [
"func",
"getWindowsError",
"(",
"inputError",
"error",
")",
"error",
"{",
"if",
"exiterr",
",",
"ok",
":=",
"inputError",
".",
"(",
"*",
"exec",
".",
"ExitError",
")",
";",
"ok",
"{",
"if",
"status",
",",
"ok",
":=",
"exiterr",
".",
"Sys",
"(",
")",
... | // Get windows error | [
"Get",
"windows",
"error"
] | aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e | https://github.com/takama/daemon/blob/aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e/daemon_windows.go#L220-L230 |
29,260 | takama/daemon | daemon_windows.go | getWindowsServiceStateFromUint32 | func getWindowsServiceStateFromUint32(state svc.State) string {
switch state {
case svc.Stopped:
return "SERVICE_STOPPED"
case svc.StartPending:
return "SERVICE_START_PENDING"
case svc.StopPending:
return "SERVICE_STOP_PENDING"
case svc.Running:
return "SERVICE_RUNNING"
case svc.ContinuePending:
return ... | go | func getWindowsServiceStateFromUint32(state svc.State) string {
switch state {
case svc.Stopped:
return "SERVICE_STOPPED"
case svc.StartPending:
return "SERVICE_START_PENDING"
case svc.StopPending:
return "SERVICE_STOP_PENDING"
case svc.Running:
return "SERVICE_RUNNING"
case svc.ContinuePending:
return ... | [
"func",
"getWindowsServiceStateFromUint32",
"(",
"state",
"svc",
".",
"State",
")",
"string",
"{",
"switch",
"state",
"{",
"case",
"svc",
".",
"Stopped",
":",
"return",
"\"",
"\"",
"\n",
"case",
"svc",
".",
"StartPending",
":",
"return",
"\"",
"\"",
"\n",
... | // Get windows service state | [
"Get",
"windows",
"service",
"state"
] | aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e | https://github.com/takama/daemon/blob/aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e/daemon_windows.go#L233-L251 |
29,261 | takama/daemon | helper.go | executablePath | func executablePath(name string) (string, error) {
if path, err := exec.LookPath(name); err == nil {
if _, err := os.Stat(path); err == nil {
return path, nil
}
}
return os.Executable()
} | go | func executablePath(name string) (string, error) {
if path, err := exec.LookPath(name); err == nil {
if _, err := os.Stat(path); err == nil {
return path, nil
}
}
return os.Executable()
} | [
"func",
"executablePath",
"(",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"path",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
"name",
")",
";",
"err",
"==",
"nil",
"{",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
... | // Lookup path for executable file | [
"Lookup",
"path",
"for",
"executable",
"file"
] | aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e | https://github.com/takama/daemon/blob/aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e/helper.go#L49-L56 |
29,262 | takama/daemon | helper.go | checkPrivileges | func checkPrivileges() (bool, error) {
if output, err := exec.Command("id", "-g").Output(); err == nil {
if gid, parseErr := strconv.ParseUint(strings.TrimSpace(string(output)), 10, 32); parseErr == nil {
if gid == 0 {
return true, nil
}
return false, ErrRootPrivileges
}
}
return false, ErrUnsuppor... | go | func checkPrivileges() (bool, error) {
if output, err := exec.Command("id", "-g").Output(); err == nil {
if gid, parseErr := strconv.ParseUint(strings.TrimSpace(string(output)), 10, 32); parseErr == nil {
if gid == 0 {
return true, nil
}
return false, ErrRootPrivileges
}
}
return false, ErrUnsuppor... | [
"func",
"checkPrivileges",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"output",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Output",
"(",
")",
";",
"err",
"==",
"nil",
"{",
"if",
"gid",
",",
... | // Check root rights to use system service | [
"Check",
"root",
"rights",
"to",
"use",
"system",
"service"
] | aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e | https://github.com/takama/daemon/blob/aa76b0035d1239b7bb3ae1bd84cd88ef2e0a1f1e/helper.go#L59-L70 |
29,263 | docker/docker-credential-helpers | client/command.go | NewShellProgramFuncWithEnv | func NewShellProgramFuncWithEnv(name string, env *map[string]string) ProgramFunc {
return func(args ...string) Program {
return &Shell{cmd: createProgramCmdRedirectErr(name, args, env)}
}
} | go | func NewShellProgramFuncWithEnv(name string, env *map[string]string) ProgramFunc {
return func(args ...string) Program {
return &Shell{cmd: createProgramCmdRedirectErr(name, args, env)}
}
} | [
"func",
"NewShellProgramFuncWithEnv",
"(",
"name",
"string",
",",
"env",
"*",
"map",
"[",
"string",
"]",
"string",
")",
"ProgramFunc",
"{",
"return",
"func",
"(",
"args",
"...",
"string",
")",
"Program",
"{",
"return",
"&",
"Shell",
"{",
"cmd",
":",
"cre... | // NewShellProgramFuncWithEnv creates programs that are executed in a Shell with environment variables | [
"NewShellProgramFuncWithEnv",
"creates",
"programs",
"that",
"are",
"executed",
"in",
"a",
"Shell",
"with",
"environment",
"variables"
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/client/command.go#L25-L29 |
29,264 | docker/docker-credential-helpers | client/command.go | Input | func (s *Shell) Input(in io.Reader) {
s.cmd.Stdin = in
} | go | func (s *Shell) Input(in io.Reader) {
s.cmd.Stdin = in
} | [
"func",
"(",
"s",
"*",
"Shell",
")",
"Input",
"(",
"in",
"io",
".",
"Reader",
")",
"{",
"s",
".",
"cmd",
".",
"Stdin",
"=",
"in",
"\n",
"}"
] | // Input sets the input to send to a remote credentials helper. | [
"Input",
"sets",
"the",
"input",
"to",
"send",
"to",
"a",
"remote",
"credentials",
"helper",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/client/command.go#L54-L56 |
29,265 | docker/docker-credential-helpers | client/client.go | isValidCredsMessage | func isValidCredsMessage(msg string) error {
if credentials.IsCredentialsMissingServerURLMessage(msg) {
return credentials.NewErrCredentialsMissingServerURL()
}
if credentials.IsCredentialsMissingUsernameMessage(msg) {
return credentials.NewErrCredentialsMissingUsername()
}
return nil
} | go | func isValidCredsMessage(msg string) error {
if credentials.IsCredentialsMissingServerURLMessage(msg) {
return credentials.NewErrCredentialsMissingServerURL()
}
if credentials.IsCredentialsMissingUsernameMessage(msg) {
return credentials.NewErrCredentialsMissingUsername()
}
return nil
} | [
"func",
"isValidCredsMessage",
"(",
"msg",
"string",
")",
"error",
"{",
"if",
"credentials",
".",
"IsCredentialsMissingServerURLMessage",
"(",
"msg",
")",
"{",
"return",
"credentials",
".",
"NewErrCredentialsMissingServerURL",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"c... | // isValidCredsMessage checks if 'msg' contains invalid credentials error message.
// It returns whether the logs are free of invalid credentials errors and the error if it isn't.
// error values can be errCredentialsMissingServerURL or errCredentialsMissingUsername. | [
"isValidCredsMessage",
"checks",
"if",
"msg",
"contains",
"invalid",
"credentials",
"error",
"message",
".",
"It",
"returns",
"whether",
"the",
"logs",
"are",
"free",
"of",
"invalid",
"credentials",
"errors",
"and",
"the",
"error",
"if",
"it",
"isn",
"t",
".",... | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/client/client.go#L15-L25 |
29,266 | docker/docker-credential-helpers | client/client.go | Store | func Store(program ProgramFunc, creds *credentials.Credentials) error {
cmd := program("store")
buffer := new(bytes.Buffer)
if err := json.NewEncoder(buffer).Encode(creds); err != nil {
return err
}
cmd.Input(buffer)
out, err := cmd.Output()
if err != nil {
t := strings.TrimSpace(string(out))
if isValid... | go | func Store(program ProgramFunc, creds *credentials.Credentials) error {
cmd := program("store")
buffer := new(bytes.Buffer)
if err := json.NewEncoder(buffer).Encode(creds); err != nil {
return err
}
cmd.Input(buffer)
out, err := cmd.Output()
if err != nil {
t := strings.TrimSpace(string(out))
if isValid... | [
"func",
"Store",
"(",
"program",
"ProgramFunc",
",",
"creds",
"*",
"credentials",
".",
"Credentials",
")",
"error",
"{",
"cmd",
":=",
"program",
"(",
"\"",
"\"",
")",
"\n\n",
"buffer",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"if",
"err",
... | // Store uses an external program to save credentials. | [
"Store",
"uses",
"an",
"external",
"program",
"to",
"save",
"credentials",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/client/client.go#L28-L49 |
29,267 | docker/docker-credential-helpers | client/client.go | Get | func Get(program ProgramFunc, serverURL string) (*credentials.Credentials, error) {
cmd := program("get")
cmd.Input(strings.NewReader(serverURL))
out, err := cmd.Output()
if err != nil {
t := strings.TrimSpace(string(out))
if credentials.IsErrCredentialsNotFoundMessage(t) {
return nil, credentials.NewErrCr... | go | func Get(program ProgramFunc, serverURL string) (*credentials.Credentials, error) {
cmd := program("get")
cmd.Input(strings.NewReader(serverURL))
out, err := cmd.Output()
if err != nil {
t := strings.TrimSpace(string(out))
if credentials.IsErrCredentialsNotFoundMessage(t) {
return nil, credentials.NewErrCr... | [
"func",
"Get",
"(",
"program",
"ProgramFunc",
",",
"serverURL",
"string",
")",
"(",
"*",
"credentials",
".",
"Credentials",
",",
"error",
")",
"{",
"cmd",
":=",
"program",
"(",
"\"",
"\"",
")",
"\n",
"cmd",
".",
"Input",
"(",
"strings",
".",
"NewReader... | // Get executes an external program to get the credentials from a native store. | [
"Get",
"executes",
"an",
"external",
"program",
"to",
"get",
"the",
"credentials",
"from",
"a",
"native",
"store",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/client/client.go#L52-L80 |
29,268 | docker/docker-credential-helpers | client/client.go | Erase | func Erase(program ProgramFunc, serverURL string) error {
cmd := program("erase")
cmd.Input(strings.NewReader(serverURL))
out, err := cmd.Output()
if err != nil {
t := strings.TrimSpace(string(out))
if isValidErr := isValidCredsMessage(t); isValidErr != nil {
err = isValidErr
}
return fmt.Errorf("error... | go | func Erase(program ProgramFunc, serverURL string) error {
cmd := program("erase")
cmd.Input(strings.NewReader(serverURL))
out, err := cmd.Output()
if err != nil {
t := strings.TrimSpace(string(out))
if isValidErr := isValidCredsMessage(t); isValidErr != nil {
err = isValidErr
}
return fmt.Errorf("error... | [
"func",
"Erase",
"(",
"program",
"ProgramFunc",
",",
"serverURL",
"string",
")",
"error",
"{",
"cmd",
":=",
"program",
"(",
"\"",
"\"",
")",
"\n",
"cmd",
".",
"Input",
"(",
"strings",
".",
"NewReader",
"(",
"serverURL",
")",
")",
"\n",
"out",
",",
"e... | // Erase executes a program to remove the server credentials from the native store. | [
"Erase",
"executes",
"a",
"program",
"to",
"remove",
"the",
"server",
"credentials",
"from",
"the",
"native",
"store",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/client/client.go#L83-L98 |
29,269 | docker/docker-credential-helpers | client/client.go | List | func List(program ProgramFunc) (map[string]string, error) {
cmd := program("list")
cmd.Input(strings.NewReader("unused"))
out, err := cmd.Output()
if err != nil {
t := strings.TrimSpace(string(out))
if isValidErr := isValidCredsMessage(t); isValidErr != nil {
err = isValidErr
}
return nil, fmt.Errorf("... | go | func List(program ProgramFunc) (map[string]string, error) {
cmd := program("list")
cmd.Input(strings.NewReader("unused"))
out, err := cmd.Output()
if err != nil {
t := strings.TrimSpace(string(out))
if isValidErr := isValidCredsMessage(t); isValidErr != nil {
err = isValidErr
}
return nil, fmt.Errorf("... | [
"func",
"List",
"(",
"program",
"ProgramFunc",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"cmd",
":=",
"program",
"(",
"\"",
"\"",
")",
"\n",
"cmd",
".",
"Input",
"(",
"strings",
".",
"NewReader",
"(",
"\"",
"\"",
")",
... | // List executes a program to list server credentials in the native store. | [
"List",
"executes",
"a",
"program",
"to",
"list",
"server",
"credentials",
"in",
"the",
"native",
"store",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/client/client.go#L101-L121 |
29,270 | docker/docker-credential-helpers | osxkeychain/osxkeychain_darwin.go | Delete | func (h Osxkeychain) Delete(serverURL string) error {
s, err := splitServer(serverURL)
if err != nil {
return err
}
defer freeServer(s)
errMsg := C.keychain_delete(s)
if errMsg != nil {
defer C.free(unsafe.Pointer(errMsg))
return errors.New(C.GoString(errMsg))
}
return nil
} | go | func (h Osxkeychain) Delete(serverURL string) error {
s, err := splitServer(serverURL)
if err != nil {
return err
}
defer freeServer(s)
errMsg := C.keychain_delete(s)
if errMsg != nil {
defer C.free(unsafe.Pointer(errMsg))
return errors.New(C.GoString(errMsg))
}
return nil
} | [
"func",
"(",
"h",
"Osxkeychain",
")",
"Delete",
"(",
"serverURL",
"string",
")",
"error",
"{",
"s",
",",
"err",
":=",
"splitServer",
"(",
"serverURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"freeServer",
... | // Delete removes credentials from the keychain. | [
"Delete",
"removes",
"credentials",
"from",
"the",
"keychain",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/osxkeychain/osxkeychain_darwin.go#L54-L68 |
29,271 | docker/docker-credential-helpers | osxkeychain/osxkeychain_darwin.go | List | func (h Osxkeychain) List() (map[string]string, error) {
credsLabelC := C.CString(credentials.CredsLabel)
defer C.free(unsafe.Pointer(credsLabelC))
var pathsC **C.char
defer C.free(unsafe.Pointer(pathsC))
var acctsC **C.char
defer C.free(unsafe.Pointer(acctsC))
var listLenC C.uint
errMsg := C.keychain_list(cre... | go | func (h Osxkeychain) List() (map[string]string, error) {
credsLabelC := C.CString(credentials.CredsLabel)
defer C.free(unsafe.Pointer(credsLabelC))
var pathsC **C.char
defer C.free(unsafe.Pointer(pathsC))
var acctsC **C.char
defer C.free(unsafe.Pointer(acctsC))
var listLenC C.uint
errMsg := C.keychain_list(cre... | [
"func",
"(",
"h",
"Osxkeychain",
")",
"List",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"credsLabelC",
":=",
"C",
".",
"CString",
"(",
"credentials",
".",
"CredsLabel",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"u... | // List returns the stored URLs and corresponding usernames. | [
"List",
"returns",
"the",
"stored",
"URLs",
"and",
"corresponding",
"usernames",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/osxkeychain/osxkeychain_darwin.go#L102-L138 |
29,272 | docker/docker-credential-helpers | credentials/credentials.go | isValid | func (c *Credentials) isValid() (bool, error) {
if len(c.ServerURL) == 0 {
return false, NewErrCredentialsMissingServerURL()
}
if len(c.Username) == 0 {
return false, NewErrCredentialsMissingUsername()
}
return true, nil
} | go | func (c *Credentials) isValid() (bool, error) {
if len(c.ServerURL) == 0 {
return false, NewErrCredentialsMissingServerURL()
}
if len(c.Username) == 0 {
return false, NewErrCredentialsMissingUsername()
}
return true, nil
} | [
"func",
"(",
"c",
"*",
"Credentials",
")",
"isValid",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"len",
"(",
"c",
".",
"ServerURL",
")",
"==",
"0",
"{",
"return",
"false",
",",
"NewErrCredentialsMissingServerURL",
"(",
")",
"\n",
"}",
"\n\n... | // isValid checks the integrity of Credentials object such that no credentials lack
// a server URL or a username.
// It returns whether the credentials are valid and the error if it isn't.
// error values can be errCredentialsMissingServerURL or errCredentialsMissingUsername | [
"isValid",
"checks",
"the",
"integrity",
"of",
"Credentials",
"object",
"such",
"that",
"no",
"credentials",
"lack",
"a",
"server",
"URL",
"or",
"a",
"username",
".",
"It",
"returns",
"whether",
"the",
"credentials",
"are",
"valid",
"and",
"the",
"error",
"i... | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/credentials/credentials.go#L24-L34 |
29,273 | docker/docker-credential-helpers | credentials/credentials.go | HandleCommand | func HandleCommand(helper Helper, key string, in io.Reader, out io.Writer) error {
switch key {
case "store":
return Store(helper, in)
case "get":
return Get(helper, in, out)
case "erase":
return Erase(helper, in)
case "list":
return List(helper, out)
case "version":
return PrintVersion(out)
}
return ... | go | func HandleCommand(helper Helper, key string, in io.Reader, out io.Writer) error {
switch key {
case "store":
return Store(helper, in)
case "get":
return Get(helper, in, out)
case "erase":
return Erase(helper, in)
case "list":
return List(helper, out)
case "version":
return PrintVersion(out)
}
return ... | [
"func",
"HandleCommand",
"(",
"helper",
"Helper",
",",
"key",
"string",
",",
"in",
"io",
".",
"Reader",
",",
"out",
"io",
".",
"Writer",
")",
"error",
"{",
"switch",
"key",
"{",
"case",
"\"",
"\"",
":",
"return",
"Store",
"(",
"helper",
",",
"in",
... | // HandleCommand uses a helper and a key to run a credential action. | [
"HandleCommand",
"uses",
"a",
"helper",
"and",
"a",
"key",
"to",
"run",
"a",
"credential",
"action",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/credentials/credentials.go#L68-L82 |
29,274 | docker/docker-credential-helpers | credentials/credentials.go | Store | func Store(helper Helper, reader io.Reader) error {
scanner := bufio.NewScanner(reader)
buffer := new(bytes.Buffer)
for scanner.Scan() {
buffer.Write(scanner.Bytes())
}
if err := scanner.Err(); err != nil && err != io.EOF {
return err
}
var creds Credentials
if err := json.NewDecoder(buffer).Decode(&cred... | go | func Store(helper Helper, reader io.Reader) error {
scanner := bufio.NewScanner(reader)
buffer := new(bytes.Buffer)
for scanner.Scan() {
buffer.Write(scanner.Bytes())
}
if err := scanner.Err(); err != nil && err != io.EOF {
return err
}
var creds Credentials
if err := json.NewDecoder(buffer).Decode(&cred... | [
"func",
"Store",
"(",
"helper",
"Helper",
",",
"reader",
"io",
".",
"Reader",
")",
"error",
"{",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"reader",
")",
"\n\n",
"buffer",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"for",
"scanner",
... | // Store uses a helper and an input reader to save credentials.
// The reader must contain the JSON serialization of a Credentials struct. | [
"Store",
"uses",
"a",
"helper",
"and",
"an",
"input",
"reader",
"to",
"save",
"credentials",
".",
"The",
"reader",
"must",
"contain",
"the",
"JSON",
"serialization",
"of",
"a",
"Credentials",
"struct",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/credentials/credentials.go#L86-L108 |
29,275 | docker/docker-credential-helpers | credentials/credentials.go | Get | func Get(helper Helper, reader io.Reader, writer io.Writer) error {
scanner := bufio.NewScanner(reader)
buffer := new(bytes.Buffer)
for scanner.Scan() {
buffer.Write(scanner.Bytes())
}
if err := scanner.Err(); err != nil && err != io.EOF {
return err
}
serverURL := strings.TrimSpace(buffer.String())
if l... | go | func Get(helper Helper, reader io.Reader, writer io.Writer) error {
scanner := bufio.NewScanner(reader)
buffer := new(bytes.Buffer)
for scanner.Scan() {
buffer.Write(scanner.Bytes())
}
if err := scanner.Err(); err != nil && err != io.EOF {
return err
}
serverURL := strings.TrimSpace(buffer.String())
if l... | [
"func",
"Get",
"(",
"helper",
"Helper",
",",
"reader",
"io",
".",
"Reader",
",",
"writer",
"io",
".",
"Writer",
")",
"error",
"{",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"reader",
")",
"\n\n",
"buffer",
":=",
"new",
"(",
"bytes",
".",
"Buf... | // Get retrieves the credentials for a given server url.
// The reader must contain the server URL to search.
// The writer is used to write the JSON serialization of the credentials. | [
"Get",
"retrieves",
"the",
"credentials",
"for",
"a",
"given",
"server",
"url",
".",
"The",
"reader",
"must",
"contain",
"the",
"server",
"URL",
"to",
"search",
".",
"The",
"writer",
"is",
"used",
"to",
"write",
"the",
"JSON",
"serialization",
"of",
"the",... | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/credentials/credentials.go#L113-L148 |
29,276 | docker/docker-credential-helpers | credentials/credentials.go | Erase | func Erase(helper Helper, reader io.Reader) error {
scanner := bufio.NewScanner(reader)
buffer := new(bytes.Buffer)
for scanner.Scan() {
buffer.Write(scanner.Bytes())
}
if err := scanner.Err(); err != nil && err != io.EOF {
return err
}
serverURL := strings.TrimSpace(buffer.String())
if len(serverURL) ==... | go | func Erase(helper Helper, reader io.Reader) error {
scanner := bufio.NewScanner(reader)
buffer := new(bytes.Buffer)
for scanner.Scan() {
buffer.Write(scanner.Bytes())
}
if err := scanner.Err(); err != nil && err != io.EOF {
return err
}
serverURL := strings.TrimSpace(buffer.String())
if len(serverURL) ==... | [
"func",
"Erase",
"(",
"helper",
"Helper",
",",
"reader",
"io",
".",
"Reader",
")",
"error",
"{",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"reader",
")",
"\n\n",
"buffer",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"for",
"scanner",
... | // Erase removes credentials from the store.
// The reader must contain the server URL to remove. | [
"Erase",
"removes",
"credentials",
"from",
"the",
"store",
".",
"The",
"reader",
"must",
"contain",
"the",
"server",
"URL",
"to",
"remove",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/credentials/credentials.go#L152-L170 |
29,277 | docker/docker-credential-helpers | credentials/credentials.go | List | func List(helper Helper, writer io.Writer) error {
accts, err := helper.List()
if err != nil {
return err
}
return json.NewEncoder(writer).Encode(accts)
} | go | func List(helper Helper, writer io.Writer) error {
accts, err := helper.List()
if err != nil {
return err
}
return json.NewEncoder(writer).Encode(accts)
} | [
"func",
"List",
"(",
"helper",
"Helper",
",",
"writer",
"io",
".",
"Writer",
")",
"error",
"{",
"accts",
",",
"err",
":=",
"helper",
".",
"List",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"json",
"... | //List returns all the serverURLs of keys in
//the OS store as a list of strings | [
"List",
"returns",
"all",
"the",
"serverURLs",
"of",
"keys",
"in",
"the",
"OS",
"store",
"as",
"a",
"list",
"of",
"strings"
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/credentials/credentials.go#L174-L180 |
29,278 | docker/docker-credential-helpers | credentials/credentials.go | PrintVersion | func PrintVersion(writer io.Writer) error {
fmt.Fprintln(writer, Version)
return nil
} | go | func PrintVersion(writer io.Writer) error {
fmt.Fprintln(writer, Version)
return nil
} | [
"func",
"PrintVersion",
"(",
"writer",
"io",
".",
"Writer",
")",
"error",
"{",
"fmt",
".",
"Fprintln",
"(",
"writer",
",",
"Version",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | //PrintVersion outputs the current version. | [
"PrintVersion",
"outputs",
"the",
"current",
"version",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/credentials/credentials.go#L183-L186 |
29,279 | docker/docker-credential-helpers | wincred/wincred_windows.go | Add | func (h Wincred) Add(creds *credentials.Credentials) error {
credsLabels := []byte(credentials.CredsLabel)
g := winc.NewGenericCredential(creds.ServerURL)
g.UserName = creds.Username
g.CredentialBlob = []byte(creds.Secret)
g.Persist = winc.PersistLocalMachine
g.Attributes = []winc.CredentialAttribute{{Keyword: "l... | go | func (h Wincred) Add(creds *credentials.Credentials) error {
credsLabels := []byte(credentials.CredsLabel)
g := winc.NewGenericCredential(creds.ServerURL)
g.UserName = creds.Username
g.CredentialBlob = []byte(creds.Secret)
g.Persist = winc.PersistLocalMachine
g.Attributes = []winc.CredentialAttribute{{Keyword: "l... | [
"func",
"(",
"h",
"Wincred",
")",
"Add",
"(",
"creds",
"*",
"credentials",
".",
"Credentials",
")",
"error",
"{",
"credsLabels",
":=",
"[",
"]",
"byte",
"(",
"credentials",
".",
"CredsLabel",
")",
"\n",
"g",
":=",
"winc",
".",
"NewGenericCredential",
"("... | // Add adds new credentials to the windows credentials manager. | [
"Add",
"adds",
"new",
"credentials",
"to",
"the",
"windows",
"credentials",
"manager",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/wincred/wincred_windows.go#L17-L26 |
29,280 | docker/docker-credential-helpers | wincred/wincred_windows.go | Delete | func (h Wincred) Delete(serverURL string) error {
g, err := winc.GetGenericCredential(serverURL)
if g == nil {
return nil
}
if err != nil {
return err
}
return g.Delete()
} | go | func (h Wincred) Delete(serverURL string) error {
g, err := winc.GetGenericCredential(serverURL)
if g == nil {
return nil
}
if err != nil {
return err
}
return g.Delete()
} | [
"func",
"(",
"h",
"Wincred",
")",
"Delete",
"(",
"serverURL",
"string",
")",
"error",
"{",
"g",
",",
"err",
":=",
"winc",
".",
"GetGenericCredential",
"(",
"serverURL",
")",
"\n",
"if",
"g",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
... | // Delete removes credentials from the windows credentials manager. | [
"Delete",
"removes",
"credentials",
"from",
"the",
"windows",
"credentials",
"manager",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/wincred/wincred_windows.go#L29-L38 |
29,281 | docker/docker-credential-helpers | wincred/wincred_windows.go | Get | func (h Wincred) Get(serverURL string) (string, string, error) {
target, err := getTarget(serverURL)
if err != nil {
return "", "", err
} else if target == "" {
return "", "", credentials.NewErrCredentialsNotFound()
}
g, _ := winc.GetGenericCredential(target)
if g == nil {
return "", "", credentials.NewErr... | go | func (h Wincred) Get(serverURL string) (string, string, error) {
target, err := getTarget(serverURL)
if err != nil {
return "", "", err
} else if target == "" {
return "", "", credentials.NewErrCredentialsNotFound()
}
g, _ := winc.GetGenericCredential(target)
if g == nil {
return "", "", credentials.NewErr... | [
"func",
"(",
"h",
"Wincred",
")",
"Get",
"(",
"serverURL",
"string",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"target",
",",
"err",
":=",
"getTarget",
"(",
"serverURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"... | // Get retrieves credentials from the windows credentials manager. | [
"Get",
"retrieves",
"credentials",
"from",
"the",
"windows",
"credentials",
"manager",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/wincred/wincred_windows.go#L41-L62 |
29,282 | docker/docker-credential-helpers | wincred/wincred_windows.go | List | func (h Wincred) List() (map[string]string, error) {
creds, err := winc.List()
if err != nil {
return nil, err
}
resp := make(map[string]string)
for i := range creds {
attrs := creds[i].Attributes
for _, attr := range attrs {
if strings.Compare(attr.Keyword, "label") == 0 &&
bytes.Compare(attr.Value,... | go | func (h Wincred) List() (map[string]string, error) {
creds, err := winc.List()
if err != nil {
return nil, err
}
resp := make(map[string]string)
for i := range creds {
attrs := creds[i].Attributes
for _, attr := range attrs {
if strings.Compare(attr.Keyword, "label") == 0 &&
bytes.Compare(attr.Value,... | [
"func",
"(",
"h",
"Wincred",
")",
"List",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"creds",
",",
"err",
":=",
"winc",
".",
"List",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // List returns the stored URLs and corresponding usernames for a given credentials label. | [
"List",
"returns",
"the",
"stored",
"URLs",
"and",
"corresponding",
"usernames",
"for",
"a",
"given",
"credentials",
"label",
"."
] | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/wincred/wincred_windows.go#L130-L150 |
29,283 | docker/docker-credential-helpers | pass/pass_linux.go | listPassDir | func listPassDir(args ...string) ([]os.FileInfo, error) {
passDir := getPassDir()
p := path.Join(append([]string{passDir, PASS_FOLDER}, args...)...)
contents, err := ioutil.ReadDir(p)
if err != nil {
if os.IsNotExist(err) {
return []os.FileInfo{}, nil
}
return nil, err
}
return contents, nil
} | go | func listPassDir(args ...string) ([]os.FileInfo, error) {
passDir := getPassDir()
p := path.Join(append([]string{passDir, PASS_FOLDER}, args...)...)
contents, err := ioutil.ReadDir(p)
if err != nil {
if os.IsNotExist(err) {
return []os.FileInfo{}, nil
}
return nil, err
}
return contents, nil
} | [
"func",
"listPassDir",
"(",
"args",
"...",
"string",
")",
"(",
"[",
"]",
"os",
".",
"FileInfo",
",",
"error",
")",
"{",
"passDir",
":=",
"getPassDir",
"(",
")",
"\n",
"p",
":=",
"path",
".",
"Join",
"(",
"append",
"(",
"[",
"]",
"string",
"{",
"p... | // listPassDir lists all the contents of a directory in the password store.
// Pass uses fancy unicode to emit stuff to stdout, so rather than try
// and parse this, let's just look at the directory structure instead. | [
"listPassDir",
"lists",
"all",
"the",
"contents",
"of",
"a",
"directory",
"in",
"the",
"password",
"store",
".",
"Pass",
"uses",
"fancy",
"unicode",
"to",
"emit",
"stuff",
"to",
"stdout",
"so",
"rather",
"than",
"try",
"and",
"parse",
"this",
"let",
"s",
... | beda055c573157c4cea5c7f5fe8bec04e9061b19 | https://github.com/docker/docker-credential-helpers/blob/beda055c573157c4cea5c7f5fe8bec04e9061b19/pass/pass_linux.go#L115-L128 |
29,284 | stianeikeland/go-rpio | rpio.go | WritePin | func WritePin(pin Pin, state State) {
p := uint8(pin)
// Set register, 7 / 8 depending on bank
// Clear register, 10 / 11 depending on bank
setReg := p/32 + 7
clearReg := p/32 + 10
memlock.Lock()
if state == Low {
gpioMem[clearReg] = 1 << (p & 31)
} else {
gpioMem[setReg] = 1 << (p & 31)
}
memlock.Unlo... | go | func WritePin(pin Pin, state State) {
p := uint8(pin)
// Set register, 7 / 8 depending on bank
// Clear register, 10 / 11 depending on bank
setReg := p/32 + 7
clearReg := p/32 + 10
memlock.Lock()
if state == Low {
gpioMem[clearReg] = 1 << (p & 31)
} else {
gpioMem[setReg] = 1 << (p & 31)
}
memlock.Unlo... | [
"func",
"WritePin",
"(",
"pin",
"Pin",
",",
"state",
"State",
")",
"{",
"p",
":=",
"uint8",
"(",
"pin",
")",
"\n\n",
"// Set register, 7 / 8 depending on bank",
"// Clear register, 10 / 11 depending on bank",
"setReg",
":=",
"p",
"/",
"32",
"+",
"7",
"\n",
"clea... | // WritePin sets a given pin High or Low
// by setting the clear or set registers respectively | [
"WritePin",
"sets",
"a",
"given",
"pin",
"High",
"or",
"Low",
"by",
"setting",
"the",
"clear",
"or",
"set",
"registers",
"respectively"
] | a36b96d0b1a40b37017d64875275e7e6312408c7 | https://github.com/stianeikeland/go-rpio/blob/a36b96d0b1a40b37017d64875275e7e6312408c7/rpio.go#L319-L335 |
29,285 | stianeikeland/go-rpio | rpio.go | ReadPin | func ReadPin(pin Pin) State {
// Input level register offset (13 / 14 depending on bank)
levelReg := uint8(pin)/32 + 13
if (gpioMem[levelReg] & (1 << uint8(pin&31))) != 0 {
return High
}
return Low
} | go | func ReadPin(pin Pin) State {
// Input level register offset (13 / 14 depending on bank)
levelReg := uint8(pin)/32 + 13
if (gpioMem[levelReg] & (1 << uint8(pin&31))) != 0 {
return High
}
return Low
} | [
"func",
"ReadPin",
"(",
"pin",
"Pin",
")",
"State",
"{",
"// Input level register offset (13 / 14 depending on bank)",
"levelReg",
":=",
"uint8",
"(",
"pin",
")",
"/",
"32",
"+",
"13",
"\n\n",
"if",
"(",
"gpioMem",
"[",
"levelReg",
"]",
"&",
"(",
"1",
"<<",
... | // ReadPin reads the state of a pin | [
"ReadPin",
"reads",
"the",
"state",
"of",
"a",
"pin"
] | a36b96d0b1a40b37017d64875275e7e6312408c7 | https://github.com/stianeikeland/go-rpio/blob/a36b96d0b1a40b37017d64875275e7e6312408c7/rpio.go#L338-L347 |
29,286 | stianeikeland/go-rpio | rpio.go | Close | func Close() error {
EnableIRQs(irqsBackup) // Return IRQs to state where it was before - just to be nice
memlock.Lock()
defer memlock.Unlock()
for _, mem8 := range [][]uint8{gpioMem8, clkMem8, pwmMem8, spiMem8, intrMem8} {
if err := syscall.Munmap(mem8); err != nil {
return err
}
}
return nil
} | go | func Close() error {
EnableIRQs(irqsBackup) // Return IRQs to state where it was before - just to be nice
memlock.Lock()
defer memlock.Unlock()
for _, mem8 := range [][]uint8{gpioMem8, clkMem8, pwmMem8, spiMem8, intrMem8} {
if err := syscall.Munmap(mem8); err != nil {
return err
}
}
return nil
} | [
"func",
"Close",
"(",
")",
"error",
"{",
"EnableIRQs",
"(",
"irqsBackup",
")",
"// Return IRQs to state where it was before - just to be nice",
"\n\n",
"memlock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"memlock",
".",
"Unlock",
"(",
")",
"\n",
"for",
"_",
",",
... | // Close unmaps GPIO memory | [
"Close",
"unmaps",
"GPIO",
"memory"
] | a36b96d0b1a40b37017d64875275e7e6312408c7 | https://github.com/stianeikeland/go-rpio/blob/a36b96d0b1a40b37017d64875275e7e6312408c7/rpio.go#L702-L713 |
29,287 | stianeikeland/go-rpio | spi.go | SpiReceive | func SpiReceive(n int) []byte {
data := make([]byte, n, n)
SpiExchange(data)
return data
} | go | func SpiReceive(n int) []byte {
data := make([]byte, n, n)
SpiExchange(data)
return data
} | [
"func",
"SpiReceive",
"(",
"n",
"int",
")",
"[",
"]",
"byte",
"{",
"data",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"n",
",",
"n",
")",
"\n",
"SpiExchange",
"(",
"data",
")",
"\n",
"return",
"data",
"\n",
"}"
] | // SpiReceive receives n bytes from slave.
//
// Note that n zeroed bytes are send to slave as side effect. | [
"SpiReceive",
"receives",
"n",
"bytes",
"from",
"slave",
".",
"Note",
"that",
"n",
"zeroed",
"bytes",
"are",
"send",
"to",
"slave",
"as",
"side",
"effect",
"."
] | a36b96d0b1a40b37017d64875275e7e6312408c7 | https://github.com/stianeikeland/go-rpio/blob/a36b96d0b1a40b37017d64875275e7e6312408c7/spi.go#L124-L128 |
29,288 | hashicorp/go-memdb | txn.go | readableIndex | func (txn *Txn) readableIndex(table, index string) *iradix.Txn {
// Look for existing transaction
if txn.write && txn.modified != nil {
key := tableIndex{table, index}
exist, ok := txn.modified[key]
if ok {
return exist
}
}
// Create a read transaction
path := indexPath(table, index)
raw, _ := txn.roo... | go | func (txn *Txn) readableIndex(table, index string) *iradix.Txn {
// Look for existing transaction
if txn.write && txn.modified != nil {
key := tableIndex{table, index}
exist, ok := txn.modified[key]
if ok {
return exist
}
}
// Create a read transaction
path := indexPath(table, index)
raw, _ := txn.roo... | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"readableIndex",
"(",
"table",
",",
"index",
"string",
")",
"*",
"iradix",
".",
"Txn",
"{",
"// Look for existing transaction",
"if",
"txn",
".",
"write",
"&&",
"txn",
".",
"modified",
"!=",
"nil",
"{",
"key",
":=",
... | // readableIndex returns a transaction usable for reading the given
// index in a table. If a write transaction is in progress, we may need
// to use an existing modified txn. | [
"readableIndex",
"returns",
"a",
"transaction",
"usable",
"for",
"reading",
"the",
"given",
"index",
"in",
"a",
"table",
".",
"If",
"a",
"write",
"transaction",
"is",
"in",
"progress",
"we",
"may",
"need",
"to",
"use",
"an",
"existing",
"modified",
"txn",
... | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L42-L57 |
29,289 | hashicorp/go-memdb | txn.go | writableIndex | func (txn *Txn) writableIndex(table, index string) *iradix.Txn {
if txn.modified == nil {
txn.modified = make(map[tableIndex]*iradix.Txn)
}
// Look for existing transaction
key := tableIndex{table, index}
exist, ok := txn.modified[key]
if ok {
return exist
}
// Start a new transaction
path := indexPath(t... | go | func (txn *Txn) writableIndex(table, index string) *iradix.Txn {
if txn.modified == nil {
txn.modified = make(map[tableIndex]*iradix.Txn)
}
// Look for existing transaction
key := tableIndex{table, index}
exist, ok := txn.modified[key]
if ok {
return exist
}
// Start a new transaction
path := indexPath(t... | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"writableIndex",
"(",
"table",
",",
"index",
"string",
")",
"*",
"iradix",
".",
"Txn",
"{",
"if",
"txn",
".",
"modified",
"==",
"nil",
"{",
"txn",
".",
"modified",
"=",
"make",
"(",
"map",
"[",
"tableIndex",
"]"... | // writableIndex returns a transaction usable for modifying the
// given index in a table. | [
"writableIndex",
"returns",
"a",
"transaction",
"usable",
"for",
"modifying",
"the",
"given",
"index",
"in",
"a",
"table",
"."
] | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L61-L86 |
29,290 | hashicorp/go-memdb | txn.go | Abort | func (txn *Txn) Abort() {
// Noop for a read transaction
if !txn.write {
return
}
// Check if already aborted or committed
if txn.rootTxn == nil {
return
}
// Clear the txn
txn.rootTxn = nil
txn.modified = nil
// Release the writer lock since this is invalid
txn.db.writer.Unlock()
} | go | func (txn *Txn) Abort() {
// Noop for a read transaction
if !txn.write {
return
}
// Check if already aborted or committed
if txn.rootTxn == nil {
return
}
// Clear the txn
txn.rootTxn = nil
txn.modified = nil
// Release the writer lock since this is invalid
txn.db.writer.Unlock()
} | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"Abort",
"(",
")",
"{",
"// Noop for a read transaction",
"if",
"!",
"txn",
".",
"write",
"{",
"return",
"\n",
"}",
"\n\n",
"// Check if already aborted or committed",
"if",
"txn",
".",
"rootTxn",
"==",
"nil",
"{",
"retur... | // Abort is used to cancel this transaction.
// This is a noop for read transactions. | [
"Abort",
"is",
"used",
"to",
"cancel",
"this",
"transaction",
".",
"This",
"is",
"a",
"noop",
"for",
"read",
"transactions",
"."
] | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L90-L107 |
29,291 | hashicorp/go-memdb | txn.go | Commit | func (txn *Txn) Commit() {
// Noop for a read transaction
if !txn.write {
return
}
// Check if already aborted or committed
if txn.rootTxn == nil {
return
}
// Commit each sub-transaction scoped to (table, index)
for key, subTxn := range txn.modified {
path := indexPath(key.Table, key.Index)
final := ... | go | func (txn *Txn) Commit() {
// Noop for a read transaction
if !txn.write {
return
}
// Check if already aborted or committed
if txn.rootTxn == nil {
return
}
// Commit each sub-transaction scoped to (table, index)
for key, subTxn := range txn.modified {
path := indexPath(key.Table, key.Index)
final := ... | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"Commit",
"(",
")",
"{",
"// Noop for a read transaction",
"if",
"!",
"txn",
".",
"write",
"{",
"return",
"\n",
"}",
"\n\n",
"// Check if already aborted or committed",
"if",
"txn",
".",
"rootTxn",
"==",
"nil",
"{",
"retu... | // Commit is used to finalize this transaction.
// This is a noop for read transactions. | [
"Commit",
"is",
"used",
"to",
"finalize",
"this",
"transaction",
".",
"This",
"is",
"a",
"noop",
"for",
"read",
"transactions",
"."
] | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L111-L154 |
29,292 | hashicorp/go-memdb | txn.go | Delete | func (txn *Txn) Delete(table string, obj interface{}) error {
if !txn.write {
return fmt.Errorf("cannot delete in read-only transaction")
}
// Get the table schema
tableSchema, ok := txn.db.schema.Tables[table]
if !ok {
return fmt.Errorf("invalid table '%s'", table)
}
// Get the primary ID of the object
i... | go | func (txn *Txn) Delete(table string, obj interface{}) error {
if !txn.write {
return fmt.Errorf("cannot delete in read-only transaction")
}
// Get the table schema
tableSchema, ok := txn.db.schema.Tables[table]
if !ok {
return fmt.Errorf("invalid table '%s'", table)
}
// Get the primary ID of the object
i... | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"Delete",
"(",
"table",
"string",
",",
"obj",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"!",
"txn",
".",
"write",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Get the... | // Delete is used to delete a single object from the given table
// This object must already exist in the table | [
"Delete",
"is",
"used",
"to",
"delete",
"a",
"single",
"object",
"from",
"the",
"given",
"table",
"This",
"object",
"must",
"already",
"exist",
"in",
"the",
"table"
] | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L273-L336 |
29,293 | hashicorp/go-memdb | txn.go | DeletePrefix | func (txn *Txn) DeletePrefix(table string, prefix_index string, prefix string) (bool, error) {
if !txn.write {
return false, fmt.Errorf("cannot delete in read-only transaction")
}
if !strings.HasSuffix(prefix_index, "_prefix") {
return false, fmt.Errorf("Index name for DeletePrefix must be a prefix index, Got %... | go | func (txn *Txn) DeletePrefix(table string, prefix_index string, prefix string) (bool, error) {
if !txn.write {
return false, fmt.Errorf("cannot delete in read-only transaction")
}
if !strings.HasSuffix(prefix_index, "_prefix") {
return false, fmt.Errorf("Index name for DeletePrefix must be a prefix index, Got %... | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"DeletePrefix",
"(",
"table",
"string",
",",
"prefix_index",
"string",
",",
"prefix",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"!",
"txn",
".",
"write",
"{",
"return",
"false",
",",
"fmt",
".",
... | // DeletePrefix is used to delete an entire subtree based on a prefix.
// The given index must be a prefix index, and will be used to perform a scan and enumerate the set of objects to delete.
// These will be removed from all other indexes, and then a special prefix operation will delete the objects from the given ind... | [
"DeletePrefix",
"is",
"used",
"to",
"delete",
"an",
"entire",
"subtree",
"based",
"on",
"a",
"prefix",
".",
"The",
"given",
"index",
"must",
"be",
"a",
"prefix",
"index",
"and",
"will",
"be",
"used",
"to",
"perform",
"a",
"scan",
"and",
"enumerate",
"the... | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L342-L426 |
29,294 | hashicorp/go-memdb | txn.go | DeleteAll | func (txn *Txn) DeleteAll(table, index string, args ...interface{}) (int, error) {
if !txn.write {
return 0, fmt.Errorf("cannot delete in read-only transaction")
}
// Get all the objects
iter, err := txn.Get(table, index, args...)
if err != nil {
return 0, err
}
// Put them into a slice so there are no saf... | go | func (txn *Txn) DeleteAll(table, index string, args ...interface{}) (int, error) {
if !txn.write {
return 0, fmt.Errorf("cannot delete in read-only transaction")
}
// Get all the objects
iter, err := txn.Get(table, index, args...)
if err != nil {
return 0, err
}
// Put them into a slice so there are no saf... | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"DeleteAll",
"(",
"table",
",",
"index",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"!",
"txn",
".",
"write",
"{",
"return",
"0",
",",
"fmt",
".",
"Er... | // DeleteAll is used to delete all the objects in a given table
// matching the constraints on the index | [
"DeleteAll",
"is",
"used",
"to",
"delete",
"all",
"the",
"objects",
"in",
"a",
"given",
"table",
"matching",
"the",
"constraints",
"on",
"the",
"index"
] | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L430-L462 |
29,295 | hashicorp/go-memdb | txn.go | FirstWatch | func (txn *Txn) FirstWatch(table, index string, args ...interface{}) (<-chan struct{}, interface{}, error) {
// Get the index value
indexSchema, val, err := txn.getIndexValue(table, index, args...)
if err != nil {
return nil, nil, err
}
// Get the index itself
indexTxn := txn.readableIndex(table, indexSchema.N... | go | func (txn *Txn) FirstWatch(table, index string, args ...interface{}) (<-chan struct{}, interface{}, error) {
// Get the index value
indexSchema, val, err := txn.getIndexValue(table, index, args...)
if err != nil {
return nil, nil, err
}
// Get the index itself
indexTxn := txn.readableIndex(table, indexSchema.N... | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"FirstWatch",
"(",
"table",
",",
"index",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"<-",
"chan",
"struct",
"{",
"}",
",",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// Get the index valu... | // FirstWatch is used to return the first matching object for
// the given constraints on the index along with the watch channel | [
"FirstWatch",
"is",
"used",
"to",
"return",
"the",
"first",
"matching",
"object",
"for",
"the",
"given",
"constraints",
"on",
"the",
"index",
"along",
"with",
"the",
"watch",
"channel"
] | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L466-L490 |
29,296 | hashicorp/go-memdb | txn.go | First | func (txn *Txn) First(table, index string, args ...interface{}) (interface{}, error) {
_, val, err := txn.FirstWatch(table, index, args...)
return val, err
} | go | func (txn *Txn) First(table, index string, args ...interface{}) (interface{}, error) {
_, val, err := txn.FirstWatch(table, index, args...)
return val, err
} | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"First",
"(",
"table",
",",
"index",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"_",
",",
"val",
",",
"err",
":=",
"txn",
".",
"FirstWatch",
... | // First is used to return the first matching object for
// the given constraints on the index | [
"First",
"is",
"used",
"to",
"return",
"the",
"first",
"matching",
"object",
"for",
"the",
"given",
"constraints",
"on",
"the",
"index"
] | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L494-L497 |
29,297 | hashicorp/go-memdb | txn.go | getIndexValue | func (txn *Txn) getIndexValue(table, index string, args ...interface{}) (*IndexSchema, []byte, error) {
// Get the table schema
tableSchema, ok := txn.db.schema.Tables[table]
if !ok {
return nil, nil, fmt.Errorf("invalid table '%s'", table)
}
// Check for a prefix scan
prefixScan := false
if strings.HasSuffix... | go | func (txn *Txn) getIndexValue(table, index string, args ...interface{}) (*IndexSchema, []byte, error) {
// Get the table schema
tableSchema, ok := txn.db.schema.Tables[table]
if !ok {
return nil, nil, fmt.Errorf("invalid table '%s'", table)
}
// Check for a prefix scan
prefixScan := false
if strings.HasSuffix... | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"getIndexValue",
"(",
"table",
",",
"index",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"*",
"IndexSchema",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Get the table schema",
"tableSchema",
... | // getIndexValue is used to get the IndexSchema and the value
// used to scan the index given the parameters. This handles prefix based
// scans when the index has the "_prefix" suffix. The index must support
// prefix iteration. | [
"getIndexValue",
"is",
"used",
"to",
"get",
"the",
"IndexSchema",
"and",
"the",
"value",
"used",
"to",
"scan",
"the",
"index",
"given",
"the",
"parameters",
".",
"This",
"handles",
"prefix",
"based",
"scans",
"when",
"the",
"index",
"has",
"the",
"_prefix",
... | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L536-L582 |
29,298 | hashicorp/go-memdb | txn.go | Get | func (txn *Txn) Get(table, index string, args ...interface{}) (ResultIterator, error) {
// Get the index value to scan
indexSchema, val, err := txn.getIndexValue(table, index, args...)
if err != nil {
return nil, err
}
// Get the index itself
indexTxn := txn.readableIndex(table, indexSchema.Name)
indexRoot :=... | go | func (txn *Txn) Get(table, index string, args ...interface{}) (ResultIterator, error) {
// Get the index value to scan
indexSchema, val, err := txn.getIndexValue(table, index, args...)
if err != nil {
return nil, err
}
// Get the index itself
indexTxn := txn.readableIndex(table, indexSchema.Name)
indexRoot :=... | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"Get",
"(",
"table",
",",
"index",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"ResultIterator",
",",
"error",
")",
"{",
"// Get the index value to scan",
"indexSchema",
",",
"val",
",",
"err",
":="... | // Get is used to construct a ResultIterator over all the
// rows that match the given constraints of an index. | [
"Get",
"is",
"used",
"to",
"construct",
"a",
"ResultIterator",
"over",
"all",
"the",
"rows",
"that",
"match",
"the",
"given",
"constraints",
"of",
"an",
"index",
"."
] | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L593-L616 |
29,299 | hashicorp/go-memdb | txn.go | Defer | func (txn *Txn) Defer(fn func()) {
txn.after = append(txn.after, fn)
} | go | func (txn *Txn) Defer(fn func()) {
txn.after = append(txn.after, fn)
} | [
"func",
"(",
"txn",
"*",
"Txn",
")",
"Defer",
"(",
"fn",
"func",
"(",
")",
")",
"{",
"txn",
".",
"after",
"=",
"append",
"(",
"txn",
".",
"after",
",",
"fn",
")",
"\n",
"}"
] | // Defer is used to push a new arbitrary function onto a stack which
// gets called when a transaction is committed and finished. Deferred
// functions are called in LIFO order, and only invoked at the end of
// write transactions. | [
"Defer",
"is",
"used",
"to",
"push",
"a",
"new",
"arbitrary",
"function",
"onto",
"a",
"stack",
"which",
"gets",
"called",
"when",
"a",
"transaction",
"is",
"committed",
"and",
"finished",
".",
"Deferred",
"functions",
"are",
"called",
"in",
"LIFO",
"order",... | 10278d3759e27502b741e52c7d8115d892e7723a | https://github.com/hashicorp/go-memdb/blob/10278d3759e27502b741e52c7d8115d892e7723a/txn.go#L622-L624 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.