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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
28,300
google/zoekt
query/parse.go
parseOperators
func parseOperators(in []Q) (Q, error) { top := &Or{} cur := &And{} seenOr := false for _, q := range in { if _, ok := q.(*orOperator); ok { seenOr = true if len(cur.Children) == 0 { return nil, fmt.Errorf("query: OR operator should have operand") } top.Children = append(top.Children, cur) cur...
go
func parseOperators(in []Q) (Q, error) { top := &Or{} cur := &And{} seenOr := false for _, q := range in { if _, ok := q.(*orOperator); ok { seenOr = true if len(cur.Children) == 0 { return nil, fmt.Errorf("query: OR operator should have operand") } top.Children = append(top.Children, cur) cur...
[ "func", "parseOperators", "(", "in", "[", "]", "Q", ")", "(", "Q", ",", "error", ")", "{", "top", ":=", "&", "Or", "{", "}", "\n", "cur", ":=", "&", "And", "{", "}", "\n\n", "seenOr", ":=", "false", "\n", "for", "_", ",", "q", ":=", "range", ...
// parseOperators interprets the orOperator in a list of queries.
[ "parseOperators", "interprets", "the", "orOperator", "in", "a", "list", "of", "queries", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L223-L246
28,301
google/zoekt
query/parse.go
parseExprList
func parseExprList(in []byte) ([]Q, int, error) { b := in[:] var qs []Q for len(b) > 0 { for len(b) > 0 && isSpace(b[0]) { b = b[1:] } tok, _ := nextToken(b) if tok != nil && tok.Type == tokParenClose { break } else if tok != nil && tok.Type == tokOr { qs = append(qs, &orOperator{}) b = b[len(t...
go
func parseExprList(in []byte) ([]Q, int, error) { b := in[:] var qs []Q for len(b) > 0 { for len(b) > 0 && isSpace(b[0]) { b = b[1:] } tok, _ := nextToken(b) if tok != nil && tok.Type == tokParenClose { break } else if tok != nil && tok.Type == tokOr { qs = append(qs, &orOperator{}) b = b[len(t...
[ "func", "parseExprList", "(", "in", "[", "]", "byte", ")", "(", "[", "]", "Q", ",", "int", ",", "error", ")", "{", "b", ":=", "in", "[", ":", "]", "\n", "var", "qs", "[", "]", "Q", "\n", "for", "len", "(", "b", ")", ">", "0", "{", "for", ...
// parseExprList parses a list of query expressions. It is the // workhorse of the Parse function.
[ "parseExprList", "parses", "a", "list", "of", "query", "expressions", ".", "It", "is", "the", "workhorse", "of", "the", "Parse", "function", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L250-L295
28,302
google/zoekt
query/parse.go
nextToken
func nextToken(in []byte) (*token, error) { left := in[:] parenCount := 0 var cur token if len(left) == 0 { return nil, nil } if left[0] == '-' { return &token{ Type: tokNegate, Text: []byte{'-'}, Input: in[:1], }, nil } foundSpace := false loop: for len(left) > 0 { c := left[0] switch ...
go
func nextToken(in []byte) (*token, error) { left := in[:] parenCount := 0 var cur token if len(left) == 0 { return nil, nil } if left[0] == '-' { return &token{ Type: tokNegate, Text: []byte{'-'}, Input: in[:1], }, nil } foundSpace := false loop: for len(left) > 0 { c := left[0] switch ...
[ "func", "nextToken", "(", "in", "[", "]", "byte", ")", "(", "*", "token", ",", "error", ")", "{", "left", ":=", "in", "[", ":", "]", "\n", "parenCount", ":=", "0", "\n", "var", "cur", "token", "\n", "if", "len", "(", "left", ")", "==", "0", "...
// nextToken returns the next token from the given input.
[ "nextToken", "returns", "the", "next", "token", "from", "the", "given", "input", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L393-L471
28,303
google/zoekt
gitindex/repocache.go
NewRepoCache
func NewRepoCache(dir string) *RepoCache { return &RepoCache{ baseDir: dir, repos: make(map[string]*git.Repository), } }
go
func NewRepoCache(dir string) *RepoCache { return &RepoCache{ baseDir: dir, repos: make(map[string]*git.Repository), } }
[ "func", "NewRepoCache", "(", "dir", "string", ")", "*", "RepoCache", "{", "return", "&", "RepoCache", "{", "baseDir", ":", "dir", ",", "repos", ":", "make", "(", "map", "[", "string", "]", "*", "git", ".", "Repository", ")", ",", "}", "\n", "}" ]
// NewRepoCache creates a new RepoCache rooted at the given directory.
[ "NewRepoCache", "creates", "a", "new", "RepoCache", "rooted", "at", "the", "given", "directory", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/repocache.go#L37-L42
28,304
google/zoekt
gitindex/repocache.go
Path
func Path(baseDir string, name string) string { key := repoKeyStr(name) return filepath.Join(baseDir, key) }
go
func Path(baseDir string, name string) string { key := repoKeyStr(name) return filepath.Join(baseDir, key) }
[ "func", "Path", "(", "baseDir", "string", ",", "name", "string", ")", "string", "{", "key", ":=", "repoKeyStr", "(", "name", ")", "\n", "return", "filepath", ".", "Join", "(", "baseDir", ",", "key", ")", "\n", "}" ]
// Path returns the absolute path of the bare repository.
[ "Path", "returns", "the", "absolute", "path", "of", "the", "bare", "repository", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/repocache.go#L56-L59
28,305
google/zoekt
gitindex/repocache.go
Open
func (rc *RepoCache) Open(u *url.URL) (*git.Repository, error) { dir := rc.Path(u) rc.reposMu.Lock() defer rc.reposMu.Unlock() key := repoKey(u) r := rc.repos[key] if r != nil { return r, nil } repo, err := git.PlainOpen(dir) if err == nil { rc.repos[key] = repo } return repo, err }
go
func (rc *RepoCache) Open(u *url.URL) (*git.Repository, error) { dir := rc.Path(u) rc.reposMu.Lock() defer rc.reposMu.Unlock() key := repoKey(u) r := rc.repos[key] if r != nil { return r, nil } repo, err := git.PlainOpen(dir) if err == nil { rc.repos[key] = repo } return repo, err }
[ "func", "(", "rc", "*", "RepoCache", ")", "Open", "(", "u", "*", "url", ".", "URL", ")", "(", "*", "git", ".", "Repository", ",", "error", ")", "{", "dir", ":=", "rc", ".", "Path", "(", "u", ")", "\n", "rc", ".", "reposMu", ".", "Lock", "(", ...
// Open opens a git repository. The cache retains a pointer to the // repository.
[ "Open", "opens", "a", "git", "repository", ".", "The", "cache", "retains", "a", "pointer", "to", "the", "repository", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/repocache.go#L68-L84
28,306
google/zoekt
gitindex/repocache.go
ListRepos
func ListRepos(baseDir string, u *url.URL) ([]string, error) { key := filepath.Join(u.Host, u.Path) var paths []string walk := func(path string, info os.FileInfo, err error) error { if err != nil { return err } if !info.IsDir() { return nil } if strings.HasSuffix(path, ".git") && !strings.HasSuffix(...
go
func ListRepos(baseDir string, u *url.URL) ([]string, error) { key := filepath.Join(u.Host, u.Path) var paths []string walk := func(path string, info os.FileInfo, err error) error { if err != nil { return err } if !info.IsDir() { return nil } if strings.HasSuffix(path, ".git") && !strings.HasSuffix(...
[ "func", "ListRepos", "(", "baseDir", "string", ",", "u", "*", "url", ".", "URL", ")", "(", "[", "]", "string", ",", "error", ")", "{", "key", ":=", "filepath", ".", "Join", "(", "u", ".", "Host", ",", "u", ".", "Path", ")", "\n\n", "var", "path...
// ListRepos returns paths to repos on disk that start with the given // URL prefix. The paths are relative to baseDir, and typically // include a ".git" suffix.
[ "ListRepos", "returns", "paths", "to", "repos", "on", "disk", "that", "start", "with", "the", "given", "URL", "prefix", ".", "The", "paths", "are", "relative", "to", "baseDir", "and", "typically", "include", "a", ".", "git", "suffix", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/repocache.go#L89-L117
28,307
google/zoekt
cmd/zoekt-mirror-gitiles/cgit.go
getCGitRepos
func getCGitRepos(u *url.URL, filter func(string) bool) (map[string]*crawlTarget, error) { c, err := normalizedGet(u) if err != nil { return nil, err } pages := map[string]*crawlTarget{} for _, m := range cgitRepoEntryRE.FindAllSubmatch(c, -1) { nm := strings.TrimSuffix(string(m[1]), ".git") if !filter(nm)...
go
func getCGitRepos(u *url.URL, filter func(string) bool) (map[string]*crawlTarget, error) { c, err := normalizedGet(u) if err != nil { return nil, err } pages := map[string]*crawlTarget{} for _, m := range cgitRepoEntryRE.FindAllSubmatch(c, -1) { nm := strings.TrimSuffix(string(m[1]), ".git") if !filter(nm)...
[ "func", "getCGitRepos", "(", "u", "*", "url", ".", "URL", ",", "filter", "func", "(", "string", ")", "bool", ")", "(", "map", "[", "string", "]", "*", "crawlTarget", ",", "error", ")", "{", "c", ",", "err", ":=", "normalizedGet", "(", "u", ")", "...
// getCGitRepos finds repo names from the CGit index page hosted at // URL `u`.
[ "getCGitRepos", "finds", "repo", "names", "from", "the", "CGit", "index", "page", "hosted", "at", "URL", "u", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-mirror-gitiles/cgit.go#L54-L93
28,308
google/zoekt
indexfile_linux.go
NewIndexFile
func NewIndexFile(f *os.File) (IndexFile, error) { defer f.Close() fi, err := f.Stat() if err != nil { return nil, err } sz := fi.Size() if sz >= maxUInt32 { return nil, fmt.Errorf("file %s too large: %d", f.Name(), sz) } r := &mmapedIndexFile{ name: f.Name(), size: uint32(sz), } rounded := (r.size...
go
func NewIndexFile(f *os.File) (IndexFile, error) { defer f.Close() fi, err := f.Stat() if err != nil { return nil, err } sz := fi.Size() if sz >= maxUInt32 { return nil, fmt.Errorf("file %s too large: %d", f.Name(), sz) } r := &mmapedIndexFile{ name: f.Name(), size: uint32(sz), } rounded := (r.size...
[ "func", "NewIndexFile", "(", "f", "*", "os", ".", "File", ")", "(", "IndexFile", ",", "error", ")", "{", "defer", "f", ".", "Close", "(", ")", "\n\n", "fi", ",", "err", ":=", "f", ".", "Stat", "(", ")", "\n", "if", "err", "!=", "nil", "{", "r...
// NewIndexFile returns a new index file. The index file takes // ownership of the passed in file, and may close it.
[ "NewIndexFile", "returns", "a", "new", "index", "file", ".", "The", "index", "file", "takes", "ownership", "of", "the", "passed", "in", "file", "and", "may", "close", "it", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/indexfile_linux.go#L50-L74
28,309
google/zoekt
gitindex/filter.go
Include
func (f *Filter) Include(name string) bool { if f.inc != nil { if !f.inc.MatchString(name) { return false } } if f.exc != nil { if f.exc.MatchString(name) { return false } } return true }
go
func (f *Filter) Include(name string) bool { if f.inc != nil { if !f.inc.MatchString(name) { return false } } if f.exc != nil { if f.exc.MatchString(name) { return false } } return true }
[ "func", "(", "f", "*", "Filter", ")", "Include", "(", "name", "string", ")", "bool", "{", "if", "f", ".", "inc", "!=", "nil", "{", "if", "!", "f", ".", "inc", ".", "MatchString", "(", "name", ")", "{", "return", "false", "\n", "}", "\n", "}", ...
// Include returns true if the name passes the filter.
[ "Include", "returns", "true", "if", "the", "name", "passes", "the", "filter", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/filter.go#L25-L37
28,310
google/zoekt
gitindex/filter.go
NewFilter
func NewFilter(includeRegex, excludeRegex string) (*Filter, error) { f := &Filter{} var err error if includeRegex != "" { f.inc, err = regexp.Compile(includeRegex) if err != nil { return nil, err } } if excludeRegex != "" { f.exc, err = regexp.Compile(excludeRegex) if err != nil { return nil, err ...
go
func NewFilter(includeRegex, excludeRegex string) (*Filter, error) { f := &Filter{} var err error if includeRegex != "" { f.inc, err = regexp.Compile(includeRegex) if err != nil { return nil, err } } if excludeRegex != "" { f.exc, err = regexp.Compile(excludeRegex) if err != nil { return nil, err ...
[ "func", "NewFilter", "(", "includeRegex", ",", "excludeRegex", "string", ")", "(", "*", "Filter", ",", "error", ")", "{", "f", ":=", "&", "Filter", "{", "}", "\n", "var", "err", "error", "\n", "if", "includeRegex", "!=", "\"", "\"", "{", "f", ".", ...
// NewFilter creates a new filter.
[ "NewFilter", "creates", "a", "new", "filter", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/filter.go#L40-L58
28,311
google/zoekt
matchiter.go
matchContent
func (m *candidateMatch) matchContent(content []byte) bool { if m.caseSensitive { comp := bytes.Equal(m.substrBytes, content[m.byteOffset:m.byteOffset+uint32(len(m.substrBytes))]) m.byteMatchSz = uint32(len(m.substrBytes)) return comp } else { // It is tempting to try a simple ASCII based // comparison if ...
go
func (m *candidateMatch) matchContent(content []byte) bool { if m.caseSensitive { comp := bytes.Equal(m.substrBytes, content[m.byteOffset:m.byteOffset+uint32(len(m.substrBytes))]) m.byteMatchSz = uint32(len(m.substrBytes)) return comp } else { // It is tempting to try a simple ASCII based // comparison if ...
[ "func", "(", "m", "*", "candidateMatch", ")", "matchContent", "(", "content", "[", "]", "byte", ")", "bool", "{", "if", "m", ".", "caseSensitive", "{", "comp", ":=", "bytes", ".", "Equal", "(", "m", ".", "substrBytes", ",", "content", "[", "m", ".", ...
// Matches content against the substring, and populates byteMatchSz on success
[ "Matches", "content", "against", "the", "substring", "and", "populates", "byteMatchSz", "on", "success" ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/matchiter.go#L43-L61
28,312
google/zoekt
eval.go
gatherBranches
func (d *indexData) gatherBranches(docID uint32, mt matchTree, known map[matchTree]bool) []string { foundBranchQuery := false var branches []string visitMatches(mt, known, func(mt matchTree) { bq, ok := mt.(*branchQueryMatchTree) if ok { foundBranchQuery = true branches = append(branches, d.branchName...
go
func (d *indexData) gatherBranches(docID uint32, mt matchTree, known map[matchTree]bool) []string { foundBranchQuery := false var branches []string visitMatches(mt, known, func(mt matchTree) { bq, ok := mt.(*branchQueryMatchTree) if ok { foundBranchQuery = true branches = append(branches, d.branchName...
[ "func", "(", "d", "*", "indexData", ")", "gatherBranches", "(", "docID", "uint32", ",", "mt", "matchTree", ",", "known", "map", "[", "matchTree", "]", "bool", ")", "[", "]", "string", "{", "foundBranchQuery", ":=", "false", "\n", "var", "branches", "[", ...
// gatherBranches returns a list of branch names.
[ "gatherBranches", "returns", "a", "list", "of", "branch", "names", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/eval.go#L366-L391
28,313
google/zoekt
gitindex/clone.go
CloneRepo
func CloneRepo(destDir, name, cloneURL string, settings map[string]string) (string, error) { parent := filepath.Join(destDir, filepath.Dir(name)) if err := os.MkdirAll(parent, 0755); err != nil { return "", err } repoDest := filepath.Join(parent, filepath.Base(name)+".git") if _, err := os.Lstat(repoDest); err ...
go
func CloneRepo(destDir, name, cloneURL string, settings map[string]string) (string, error) { parent := filepath.Join(destDir, filepath.Dir(name)) if err := os.MkdirAll(parent, 0755); err != nil { return "", err } repoDest := filepath.Join(parent, filepath.Base(name)+".git") if _, err := os.Lstat(repoDest); err ...
[ "func", "CloneRepo", "(", "destDir", ",", "name", ",", "cloneURL", "string", ",", "settings", "map", "[", "string", "]", "string", ")", "(", "string", ",", "error", ")", "{", "parent", ":=", "filepath", ".", "Join", "(", "destDir", ",", "filepath", "."...
// CloneRepo clones one repository, adding the given config // settings. It returns the bare repo directory. The `name` argument // determines where the repo is stored relative to `destDir`. Returns // the directory of the repository.
[ "CloneRepo", "clones", "one", "repository", "adding", "the", "given", "config", "settings", ".", "It", "returns", "the", "bare", "repo", "directory", ".", "The", "name", "argument", "determines", "where", "the", "repo", "is", "stored", "relative", "to", "destD...
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/clone.go#L30-L68
28,314
google/zoekt
build/builder.go
HashOptions
func (o *Options) HashOptions() string { hasher := sha1.New() hasher.Write([]byte(o.CTags)) hasher.Write([]byte(fmt.Sprintf("%t", o.CTagsMustSucceed))) hasher.Write([]byte(fmt.Sprintf("%d", o.SizeMax))) hasher.Write([]byte(fmt.Sprintf("%q", o.LargeFiles))) return fmt.Sprintf("%x", hasher.Sum(nil)) }
go
func (o *Options) HashOptions() string { hasher := sha1.New() hasher.Write([]byte(o.CTags)) hasher.Write([]byte(fmt.Sprintf("%t", o.CTagsMustSucceed))) hasher.Write([]byte(fmt.Sprintf("%d", o.SizeMax))) hasher.Write([]byte(fmt.Sprintf("%q", o.LargeFiles))) return fmt.Sprintf("%x", hasher.Sum(nil)) }
[ "func", "(", "o", "*", "Options", ")", "HashOptions", "(", ")", "string", "{", "hasher", ":=", "sha1", ".", "New", "(", ")", "\n\n", "hasher", ".", "Write", "(", "[", "]", "byte", "(", "o", ".", "CTags", ")", ")", "\n", "hasher", ".", "Write", ...
// HashOptions creates a hash of the options that affect an index.
[ "HashOptions", "creates", "a", "hash", "of", "the", "options", "that", "affect", "an", "index", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L84-L93
28,315
google/zoekt
build/builder.go
SetDefaults
func (o *Options) SetDefaults() { if o.CTags == "" { ctags, err := exec.LookPath("universal-ctags") if err == nil { o.CTags = ctags } } if o.CTags == "" { ctags, err := exec.LookPath("ctags-exuberant") if err == nil { o.CTags = ctags } } if o.Parallelism == 0 { o.Parallelism = 1 } if o.SizeM...
go
func (o *Options) SetDefaults() { if o.CTags == "" { ctags, err := exec.LookPath("universal-ctags") if err == nil { o.CTags = ctags } } if o.CTags == "" { ctags, err := exec.LookPath("ctags-exuberant") if err == nil { o.CTags = ctags } } if o.Parallelism == 0 { o.Parallelism = 1 } if o.SizeM...
[ "func", "(", "o", "*", "Options", ")", "SetDefaults", "(", ")", "{", "if", "o", ".", "CTags", "==", "\"", "\"", "{", "ctags", ",", "err", ":=", "exec", ".", "LookPath", "(", "\"", "\"", ")", "\n", "if", "err", "==", "nil", "{", "o", ".", "CTa...
// SetDefaults sets reasonable default options.
[ "SetDefaults", "sets", "reasonable", "default", "options", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L123-L153
28,316
google/zoekt
build/builder.go
shardName
func (o *Options) shardName(n int) string { abs := url.QueryEscape(o.RepositoryDescription.Name) if len(abs) > 200 { abs = abs[:200] + hashString(abs)[:8] } return filepath.Join(o.IndexDir, fmt.Sprintf("%s_v%d.%05d.zoekt", abs, zoekt.IndexFormatVersion, n)) }
go
func (o *Options) shardName(n int) string { abs := url.QueryEscape(o.RepositoryDescription.Name) if len(abs) > 200 { abs = abs[:200] + hashString(abs)[:8] } return filepath.Join(o.IndexDir, fmt.Sprintf("%s_v%d.%05d.zoekt", abs, zoekt.IndexFormatVersion, n)) }
[ "func", "(", "o", "*", "Options", ")", "shardName", "(", "n", "int", ")", "string", "{", "abs", ":=", "url", ".", "QueryEscape", "(", "o", ".", "RepositoryDescription", ".", "Name", ")", "\n", "if", "len", "(", "abs", ")", ">", "200", "{", "abs", ...
// ShardName returns the name the given index shard.
[ "ShardName", "returns", "the", "name", "the", "given", "index", "shard", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L162-L169
28,317
google/zoekt
build/builder.go
IndexVersions
func (o *Options) IndexVersions() []zoekt.RepositoryBranch { fn := o.shardName(0) f, err := os.Open(fn) if err != nil { return nil } iFile, err := zoekt.NewIndexFile(f) if err != nil { return nil } defer iFile.Close() repo, index, err := zoekt.ReadMetadata(iFile) if err != nil { return nil } if in...
go
func (o *Options) IndexVersions() []zoekt.RepositoryBranch { fn := o.shardName(0) f, err := os.Open(fn) if err != nil { return nil } iFile, err := zoekt.NewIndexFile(f) if err != nil { return nil } defer iFile.Close() repo, index, err := zoekt.ReadMetadata(iFile) if err != nil { return nil } if in...
[ "func", "(", "o", "*", "Options", ")", "IndexVersions", "(", ")", "[", "]", "zoekt", ".", "RepositoryBranch", "{", "fn", ":=", "o", ".", "shardName", "(", "0", ")", "\n\n", "f", ",", "err", ":=", "os", ".", "Open", "(", "fn", ")", "\n", "if", "...
// IndexVersions returns the versions as present in the index, for // implementing incremental indexing.
[ "IndexVersions", "returns", "the", "versions", "as", "present", "in", "the", "index", "for", "implementing", "incremental", "indexing", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L173-L201
28,318
google/zoekt
build/builder.go
IgnoreSizeMax
func (o *Options) IgnoreSizeMax(name string) bool { for _, pattern := range o.LargeFiles { pattern = strings.TrimSpace(pattern) m, _ := filepath.Match(pattern, name) if m { return true } } return false }
go
func (o *Options) IgnoreSizeMax(name string) bool { for _, pattern := range o.LargeFiles { pattern = strings.TrimSpace(pattern) m, _ := filepath.Match(pattern, name) if m { return true } } return false }
[ "func", "(", "o", "*", "Options", ")", "IgnoreSizeMax", "(", "name", "string", ")", "bool", "{", "for", "_", ",", "pattern", ":=", "range", "o", ".", "LargeFiles", "{", "pattern", "=", "strings", ".", "TrimSpace", "(", "pattern", ")", "\n", "m", ",",...
// IgnoreSizeMax determines whether the max size should be ignored.
[ "IgnoreSizeMax", "determines", "whether", "the", "max", "size", "should", "be", "ignored", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L204-L214
28,319
google/zoekt
build/builder.go
NewBuilder
func NewBuilder(opts Options) (*Builder, error) { opts.SetDefaults() if opts.RepositoryDescription.Name == "" { return nil, fmt.Errorf("builder: must set Name") } b := &Builder{ opts: opts, throttle: make(chan int, opts.Parallelism), finishedShards: map[string]string{}, } if b.opts.CTags...
go
func NewBuilder(opts Options) (*Builder, error) { opts.SetDefaults() if opts.RepositoryDescription.Name == "" { return nil, fmt.Errorf("builder: must set Name") } b := &Builder{ opts: opts, throttle: make(chan int, opts.Parallelism), finishedShards: map[string]string{}, } if b.opts.CTags...
[ "func", "NewBuilder", "(", "opts", "Options", ")", "(", "*", "Builder", ",", "error", ")", "{", "opts", ".", "SetDefaults", "(", ")", "\n", "if", "opts", ".", "RepositoryDescription", ".", "Name", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", "...
// NewBuilder creates a new Builder instance.
[ "NewBuilder", "creates", "a", "new", "Builder", "instance", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L217-L246
28,320
google/zoekt
build/builder.go
AddFile
func (b *Builder) AddFile(name string, content []byte) error { return b.Add(zoekt.Document{Name: name, Content: content}) }
go
func (b *Builder) AddFile(name string, content []byte) error { return b.Add(zoekt.Document{Name: name, Content: content}) }
[ "func", "(", "b", "*", "Builder", ")", "AddFile", "(", "name", "string", ",", "content", "[", "]", "byte", ")", "error", "{", "return", "b", ".", "Add", "(", "zoekt", ".", "Document", "{", "Name", ":", "name", ",", "Content", ":", "content", "}", ...
// AddFile is a convenience wrapper for the Add method
[ "AddFile", "is", "a", "convenience", "wrapper", "for", "the", "Add", "method" ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L249-L251
28,321
google/zoekt
build/builder.go
Finish
func (b *Builder) Finish() error { b.flush() b.building.Wait() if b.buildError != nil { for tmp := range b.finishedShards { os.Remove(tmp) } return b.buildError } for tmp, final := range b.finishedShards { if err := os.Rename(tmp, final); err != nil { b.buildError = err } } if b.nextShardNum >...
go
func (b *Builder) Finish() error { b.flush() b.building.Wait() if b.buildError != nil { for tmp := range b.finishedShards { os.Remove(tmp) } return b.buildError } for tmp, final := range b.finishedShards { if err := os.Rename(tmp, final); err != nil { b.buildError = err } } if b.nextShardNum >...
[ "func", "(", "b", "*", "Builder", ")", "Finish", "(", ")", "error", "{", "b", ".", "flush", "(", ")", "\n", "b", ".", "building", ".", "Wait", "(", ")", "\n\n", "if", "b", ".", "buildError", "!=", "nil", "{", "for", "tmp", ":=", "range", "b", ...
// Finish creates a last shard from the buffered documents, and clears // stale shards from previous runs
[ "Finish", "creates", "a", "last", "shard", "from", "the", "buffered", "documents", "and", "clears", "stale", "shards", "from", "previous", "runs" ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/build/builder.go#L276-L297
28,322
google/zoekt
shards/shards.go
NewDirectorySearcher
func NewDirectorySearcher(dir string) (zoekt.Searcher, error) { ss := newShardedSearcher(int64(runtime.NumCPU())) tl := &throttledLoader{ ss: ss, throttle: make(chan struct{}, runtime.NumCPU()), } _, err := NewDirectoryWatcher(dir, tl) if err != nil { return nil, err } return ss, nil }
go
func NewDirectorySearcher(dir string) (zoekt.Searcher, error) { ss := newShardedSearcher(int64(runtime.NumCPU())) tl := &throttledLoader{ ss: ss, throttle: make(chan struct{}, runtime.NumCPU()), } _, err := NewDirectoryWatcher(dir, tl) if err != nil { return nil, err } return ss, nil }
[ "func", "NewDirectorySearcher", "(", "dir", "string", ")", "(", "zoekt", ".", "Searcher", ",", "error", ")", "{", "ss", ":=", "newShardedSearcher", "(", "int64", "(", "runtime", ".", "NumCPU", "(", ")", ")", ")", "\n", "tl", ":=", "&", "throttledLoader",...
// NewDirectorySearcher returns a searcher instance that loads all // shards corresponding to a glob into memory.
[ "NewDirectorySearcher", "returns", "a", "searcher", "instance", "that", "loads", "all", "shards", "corresponding", "to", "a", "glob", "into", "memory", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/shards/shards.go#L61-L73
28,323
google/zoekt
shards/shards.go
Close
func (ss *shardedSearcher) Close() { ss.lock(context.Background()) defer ss.unlock() for _, s := range ss.shards { s.Close() } }
go
func (ss *shardedSearcher) Close() { ss.lock(context.Background()) defer ss.unlock() for _, s := range ss.shards { s.Close() } }
[ "func", "(", "ss", "*", "shardedSearcher", ")", "Close", "(", ")", "{", "ss", ".", "lock", "(", "context", ".", "Background", "(", ")", ")", "\n", "defer", "ss", ".", "unlock", "(", ")", "\n", "for", "_", ",", "s", ":=", "range", "ss", ".", "sh...
// Close closes references to open files. It may be called only once.
[ "Close", "closes", "references", "to", "open", "files", ".", "It", "may", "be", "called", "only", "once", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/shards/shards.go#L102-L108
28,324
google/zoekt
shards/shards.go
getShards
func (s *shardedSearcher) getShards() []rankedShard { var res []rankedShard for _, sh := range s.shards { res = append(res, sh) } // TODO: precompute this. sort.Slice(res, func(i, j int) bool { return res[i].rank > res[j].rank }) return res }
go
func (s *shardedSearcher) getShards() []rankedShard { var res []rankedShard for _, sh := range s.shards { res = append(res, sh) } // TODO: precompute this. sort.Slice(res, func(i, j int) bool { return res[i].rank > res[j].rank }) return res }
[ "func", "(", "s", "*", "shardedSearcher", ")", "getShards", "(", ")", "[", "]", "rankedShard", "{", "var", "res", "[", "]", "rankedShard", "\n", "for", "_", ",", "sh", ":=", "range", "s", ".", "shards", "{", "res", "=", "append", "(", "res", ",", ...
// getShards returns the currently loaded shards. The shards must be // accessed under a rlock call. The shards are sorted by decreasing // rank.
[ "getShards", "returns", "the", "currently", "loaded", "shards", ".", "The", "shards", "must", "be", "accessed", "under", "a", "rlock", "call", ".", "The", "shards", "are", "sorted", "by", "decreasing", "rank", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/shards/shards.go#L322-L332
28,325
google/zoekt
gitindex/index.go
RepoModTime
func RepoModTime(dir string) (time.Time, error) { var last time.Time refDir := filepath.Join(dir, "refs") if _, err := os.Lstat(refDir); err == nil { if err := filepath.Walk(refDir, func(name string, fi os.FileInfo, err error) error { if !fi.IsDir() && last.Before(fi.ModTime()) { last = fi.ModTime() ...
go
func RepoModTime(dir string) (time.Time, error) { var last time.Time refDir := filepath.Join(dir, "refs") if _, err := os.Lstat(refDir); err == nil { if err := filepath.Walk(refDir, func(name string, fi os.FileInfo, err error) error { if !fi.IsDir() && last.Before(fi.ModTime()) { last = fi.ModTime() ...
[ "func", "RepoModTime", "(", "dir", "string", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "var", "last", "time", ".", "Time", "\n", "refDir", ":=", "filepath", ".", "Join", "(", "dir", ",", "\"", "\"", ")", "\n", "if", "_", ",", "err", ...
// RepoModTime returns the time of last fetch of a git repository.
[ "RepoModTime", "returns", "the", "time", "of", "last", "fetch", "of", "a", "git", "repository", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/index.go#L45-L68
28,326
google/zoekt
gitindex/index.go
setTemplates
func setTemplates(repo *zoekt.Repository, u *url.URL, typ string) error { repo.URL = u.String() switch typ { case "gitiles": /// eg. https://gerrit.googlesource.com/gitiles/+/master/tools/run_dev.sh#20 repo.CommitURLTemplate = u.String() + "/+/{{.Version}}" repo.FileURLTemplate = u.String() + "/+/{{.Version}}/...
go
func setTemplates(repo *zoekt.Repository, u *url.URL, typ string) error { repo.URL = u.String() switch typ { case "gitiles": /// eg. https://gerrit.googlesource.com/gitiles/+/master/tools/run_dev.sh#20 repo.CommitURLTemplate = u.String() + "/+/{{.Version}}" repo.FileURLTemplate = u.String() + "/+/{{.Version}}/...
[ "func", "setTemplates", "(", "repo", "*", "zoekt", ".", "Repository", ",", "u", "*", "url", ".", "URL", ",", "typ", "string", ")", "error", "{", "repo", ".", "URL", "=", "u", ".", "String", "(", ")", "\n", "switch", "typ", "{", "case", "\"", "\""...
// setTemplates fills in URL templates for known git hosting // sites.
[ "setTemplates", "fills", "in", "URL", "templates", "for", "known", "git", "hosting", "sites", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/index.go#L111-L154
28,327
google/zoekt
gitindex/index.go
getCommit
func getCommit(repo *git.Repository, prefix, ref string) (*object.Commit, error) { sha1, err := repo.ResolveRevision(plumbing.Revision(ref)) // ref might be a branch name (e.g. "master") add branch prefix and try again. if err != nil { sha1, err = repo.ResolveRevision(plumbing.Revision(filepath.Join(prefix, ref)))...
go
func getCommit(repo *git.Repository, prefix, ref string) (*object.Commit, error) { sha1, err := repo.ResolveRevision(plumbing.Revision(ref)) // ref might be a branch name (e.g. "master") add branch prefix and try again. if err != nil { sha1, err = repo.ResolveRevision(plumbing.Revision(filepath.Join(prefix, ref)))...
[ "func", "getCommit", "(", "repo", "*", "git", ".", "Repository", ",", "prefix", ",", "ref", "string", ")", "(", "*", "object", ".", "Commit", ",", "error", ")", "{", "sha1", ",", "err", ":=", "repo", ".", "ResolveRevision", "(", "plumbing", ".", "Rev...
// getCommit returns a tree object for the given reference.
[ "getCommit", "returns", "a", "tree", "object", "for", "the", "given", "reference", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/index.go#L157-L172
28,328
google/zoekt
gitindex/index.go
SetTemplatesFromOrigin
func SetTemplatesFromOrigin(desc *zoekt.Repository, u *url.URL) error { desc.Name = filepath.Join(u.Host, strings.TrimSuffix(u.Path, ".git")) if strings.HasSuffix(u.Host, ".googlesource.com") { return setTemplates(desc, u, "gitiles") } else if u.Host == "github.com" { u.Path = strings.TrimSuffix(u.Path, ".git")...
go
func SetTemplatesFromOrigin(desc *zoekt.Repository, u *url.URL) error { desc.Name = filepath.Join(u.Host, strings.TrimSuffix(u.Path, ".git")) if strings.HasSuffix(u.Host, ".googlesource.com") { return setTemplates(desc, u, "gitiles") } else if u.Host == "github.com" { u.Path = strings.TrimSuffix(u.Path, ".git")...
[ "func", "SetTemplatesFromOrigin", "(", "desc", "*", "zoekt", ".", "Repository", ",", "u", "*", "url", ".", "URL", ")", "error", "{", "desc", ".", "Name", "=", "filepath", ".", "Join", "(", "u", ".", "Host", ",", "strings", ".", "TrimSuffix", "(", "u"...
// SetTemplates fills in templates based on the origin URL.
[ "SetTemplates", "fills", "in", "templates", "based", "on", "the", "origin", "URL", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/index.go#L273-L284
28,329
google/zoekt
matchtree.go
prepare
func (t *bruteForceMatchTree) prepare(doc uint32) { t.docID = doc t.firstDone = true }
go
func (t *bruteForceMatchTree) prepare(doc uint32) { t.docID = doc t.firstDone = true }
[ "func", "(", "t", "*", "bruteForceMatchTree", ")", "prepare", "(", "doc", "uint32", ")", "{", "t", ".", "docID", "=", "doc", "\n", "t", ".", "firstDone", "=", "true", "\n", "}" ]
// all prepare methods
[ "all", "prepare", "methods" ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/matchtree.go#L146-L149
28,330
google/zoekt
ctags/parse.go
Parse
func Parse(in string) (*Entry, error) { fields := strings.Split(in, "\t") e := Entry{} if len(fields) < 3 { return nil, fmt.Errorf("too few fields: %q", in) } e.Sym = fields[0] e.Path = fields[1] lstr := fields[2] if len(lstr) < 2 { return nil, fmt.Errorf("got %q for linenum field", lstr) } l, err := ...
go
func Parse(in string) (*Entry, error) { fields := strings.Split(in, "\t") e := Entry{} if len(fields) < 3 { return nil, fmt.Errorf("too few fields: %q", in) } e.Sym = fields[0] e.Path = fields[1] lstr := fields[2] if len(lstr) < 2 { return nil, fmt.Errorf("got %q for linenum field", lstr) } l, err := ...
[ "func", "Parse", "(", "in", "string", ")", "(", "*", "Entry", ",", "error", ")", "{", "fields", ":=", "strings", ".", "Split", "(", "in", ",", "\"", "\\t", "\"", ")", "\n", "e", ":=", "Entry", "{", "}", "\n\n", "if", "len", "(", "fields", ")", ...
// Parse parses a single line of exuberant "ctags -n" output.
[ "Parse", "parses", "a", "single", "line", "of", "exuberant", "ctags", "-", "n", "output", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/ctags/parse.go#L36-L73
28,331
google/zoekt
query/query.go
Map
func Map(q Q, f func(q Q) Q) Q { switch s := q.(type) { case *And: q = &And{Children: mapQueryList(s.Children, f)} case *Or: q = &Or{Children: mapQueryList(s.Children, f)} case *Not: q = &Not{Child: Map(s.Child, f)} } return f(q) }
go
func Map(q Q, f func(q Q) Q) Q { switch s := q.(type) { case *And: q = &And{Children: mapQueryList(s.Children, f)} case *Or: q = &Or{Children: mapQueryList(s.Children, f)} case *Not: q = &Not{Child: Map(s.Child, f)} } return f(q) }
[ "func", "Map", "(", "q", "Q", ",", "f", "func", "(", "q", "Q", ")", "Q", ")", "Q", "{", "switch", "s", ":=", "q", ".", "(", "type", ")", "{", "case", "*", "And", ":", "q", "=", "&", "And", "{", "Children", ":", "mapQueryList", "(", "s", "...
// Map runs f over the q.
[ "Map", "runs", "f", "over", "the", "q", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/query.go#L346-L356
28,332
google/zoekt
query/query.go
VisitAtoms
func VisitAtoms(q Q, v func(q Q)) { Map(q, func(iQ Q) Q { switch iQ.(type) { case *And: case *Or: case *Not: default: v(iQ) } return iQ }) }
go
func VisitAtoms(q Q, v func(q Q)) { Map(q, func(iQ Q) Q { switch iQ.(type) { case *And: case *Or: case *Not: default: v(iQ) } return iQ }) }
[ "func", "VisitAtoms", "(", "q", "Q", ",", "v", "func", "(", "q", "Q", ")", ")", "{", "Map", "(", "q", ",", "func", "(", "iQ", "Q", ")", "Q", "{", "switch", "iQ", ".", "(", "type", ")", "{", "case", "*", "And", ":", "case", "*", "Or", ":",...
// VisitAtoms runs `v` on all atom queries within `q`.
[ "VisitAtoms", "runs", "v", "on", "all", "atom", "queries", "within", "q", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/query.go#L383-L394
28,333
google/zoekt
indexbuilder.go
ContentSize
func (b *IndexBuilder) ContentSize() uint32 { // Add the name too so we don't skip building index if we have // lots of empty files. return b.contentPostings.endByte + b.namePostings.endByte }
go
func (b *IndexBuilder) ContentSize() uint32 { // Add the name too so we don't skip building index if we have // lots of empty files. return b.contentPostings.endByte + b.namePostings.endByte }
[ "func", "(", "b", "*", "IndexBuilder", ")", "ContentSize", "(", ")", "uint32", "{", "// Add the name too so we don't skip building index if we have", "// lots of empty files.", "return", "b", ".", "contentPostings", ".", "endByte", "+", "b", ".", "namePostings", ".", ...
// ContentSize returns the number of content bytes so far ingested.
[ "ContentSize", "returns", "the", "number", "of", "content", "bytes", "so", "far", "ingested", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/indexbuilder.go#L186-L190
28,334
google/zoekt
indexbuilder.go
NewIndexBuilder
func NewIndexBuilder(r *Repository) (*IndexBuilder, error) { b := &IndexBuilder{ contentPostings: newPostingsBuilder(), namePostings: newPostingsBuilder(), languageMap: map[string]byte{}, } if r == nil { r = &Repository{} } if err := b.setRepository(r); err != nil { return nil, err } return b, ...
go
func NewIndexBuilder(r *Repository) (*IndexBuilder, error) { b := &IndexBuilder{ contentPostings: newPostingsBuilder(), namePostings: newPostingsBuilder(), languageMap: map[string]byte{}, } if r == nil { r = &Repository{} } if err := b.setRepository(r); err != nil { return nil, err } return b, ...
[ "func", "NewIndexBuilder", "(", "r", "*", "Repository", ")", "(", "*", "IndexBuilder", ",", "error", ")", "{", "b", ":=", "&", "IndexBuilder", "{", "contentPostings", ":", "newPostingsBuilder", "(", ")", ",", "namePostings", ":", "newPostingsBuilder", "(", "...
// NewIndexBuilder creates a fresh IndexBuilder. The passed in // Repository contains repo metadata, and may be set to nil.
[ "NewIndexBuilder", "creates", "a", "fresh", "IndexBuilder", ".", "The", "passed", "in", "Repository", "contains", "repo", "metadata", "and", "may", "be", "set", "to", "nil", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/indexbuilder.go#L194-L208
28,335
google/zoekt
indexbuilder.go
AddFile
func (b *IndexBuilder) AddFile(name string, content []byte) error { return b.Add(Document{Name: name, Content: content}) }
go
func (b *IndexBuilder) AddFile(name string, content []byte) error { return b.Add(Document{Name: name, Content: content}) }
[ "func", "(", "b", "*", "IndexBuilder", ")", "AddFile", "(", "name", "string", ",", "content", "[", "]", "byte", ")", "error", "{", "return", "b", ".", "Add", "(", "Document", "{", "Name", ":", "name", ",", "Content", ":", "content", "}", ")", "\n",...
// AddFile is a convenience wrapper for Add
[ "AddFile", "is", "a", "convenience", "wrapper", "for", "Add" ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/indexbuilder.go#L271-L273
28,336
google/zoekt
indexbuilder.go
CheckText
func CheckText(content []byte) error { if len(content) == 0 { return nil } if len(content) < ngramSize { return fmt.Errorf("file size smaller than %d", ngramSize) } trigrams := map[ngram]struct{}{} var cur [3]rune byteCount := 0 for len(content) > 0 { if content[0] == 0 { return fmt.Errorf("binary d...
go
func CheckText(content []byte) error { if len(content) == 0 { return nil } if len(content) < ngramSize { return fmt.Errorf("file size smaller than %d", ngramSize) } trigrams := map[ngram]struct{}{} var cur [3]rune byteCount := 0 for len(content) > 0 { if content[0] == 0 { return fmt.Errorf("binary d...
[ "func", "CheckText", "(", "content", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "content", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "content", ")", "<", "ngramSize", "{", "return", "fmt", ".", "Errorf",...
// CheckText returns a reason why the given contents are probably not source texts.
[ "CheckText", "returns", "a", "reason", "why", "the", "given", "contents", "are", "probably", "not", "source", "texts", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/indexbuilder.go#L278-L313
28,337
google/zoekt
read.go
ReadMetadata
func ReadMetadata(inf IndexFile) (*Repository, *IndexMetadata, error) { rd := &reader{r: inf} var toc indexTOC if err := rd.readTOC(&toc); err != nil { return nil, nil, err } var md IndexMetadata if err := rd.readJSON(&md, &toc.metaData); err != nil { return nil, nil, err } var repo Repository if err := ...
go
func ReadMetadata(inf IndexFile) (*Repository, *IndexMetadata, error) { rd := &reader{r: inf} var toc indexTOC if err := rd.readTOC(&toc); err != nil { return nil, nil, err } var md IndexMetadata if err := rd.readJSON(&md, &toc.metaData); err != nil { return nil, nil, err } var repo Repository if err := ...
[ "func", "ReadMetadata", "(", "inf", "IndexFile", ")", "(", "*", "Repository", ",", "*", "IndexMetadata", ",", "error", ")", "{", "rd", ":=", "&", "reader", "{", "r", ":", "inf", "}", "\n", "var", "toc", "indexTOC", "\n", "if", "err", ":=", "rd", "....
// ReadMetadata returns the metadata of index shard without reading // the index data. The IndexFile is not closed.
[ "ReadMetadata", "returns", "the", "metadata", "of", "index", "shard", "without", "reading", "the", "index", "data", ".", "The", "IndexFile", "is", "not", "closed", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/read.go#L364-L382
28,338
google/zoekt
gitindex/tree.go
subURL
func (w *repoWalker) subURL(relURL string) (*url.URL, error) { if w.repoURL == nil { return nil, fmt.Errorf("no URL for base repo") } if strings.HasPrefix(relURL, "../") { u := *w.repoURL u.Path = path.Join(u.Path, relURL) return &u, nil } return url.Parse(relURL) }
go
func (w *repoWalker) subURL(relURL string) (*url.URL, error) { if w.repoURL == nil { return nil, fmt.Errorf("no URL for base repo") } if strings.HasPrefix(relURL, "../") { u := *w.repoURL u.Path = path.Join(u.Path, relURL) return &u, nil } return url.Parse(relURL) }
[ "func", "(", "w", "*", "repoWalker", ")", "subURL", "(", "relURL", "string", ")", "(", "*", "url", ".", "URL", ",", "error", ")", "{", "if", "w", ".", "repoURL", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")"...
// subURL returns the URL for a submodule.
[ "subURL", "returns", "the", "URL", "for", "a", "submodule", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/tree.go#L52-L63
28,339
google/zoekt
gitindex/tree.go
newRepoWalker
func newRepoWalker(r *git.Repository, repoURL string, repoCache *RepoCache) *repoWalker { u, _ := url.Parse(repoURL) return &repoWalker{ repo: r, repoURL: u, tree: map[fileKey]BlobLocation{}, repoCache: repoCache, subRepoVersions: m...
go
func newRepoWalker(r *git.Repository, repoURL string, repoCache *RepoCache) *repoWalker { u, _ := url.Parse(repoURL) return &repoWalker{ repo: r, repoURL: u, tree: map[fileKey]BlobLocation{}, repoCache: repoCache, subRepoVersions: m...
[ "func", "newRepoWalker", "(", "r", "*", "git", ".", "Repository", ",", "repoURL", "string", ",", "repoCache", "*", "RepoCache", ")", "*", "repoWalker", "{", "u", ",", "_", ":=", "url", ".", "Parse", "(", "repoURL", ")", "\n", "return", "&", "repoWalker...
// newRepoWalker creates a new repoWalker.
[ "newRepoWalker", "creates", "a", "new", "repoWalker", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/tree.go#L66-L76
28,340
google/zoekt
gitindex/tree.go
parseModuleMap
func (rw *repoWalker) parseModuleMap(t *object.Tree) error { modEntry, _ := t.File(".gitmodules") if modEntry != nil { c, err := blobContents(&modEntry.Blob) if err != nil { return err } mods, err := ParseGitModules(c) if err != nil { return err } rw.submodules = map[string]*SubmoduleEntry{} for...
go
func (rw *repoWalker) parseModuleMap(t *object.Tree) error { modEntry, _ := t.File(".gitmodules") if modEntry != nil { c, err := blobContents(&modEntry.Blob) if err != nil { return err } mods, err := ParseGitModules(c) if err != nil { return err } rw.submodules = map[string]*SubmoduleEntry{} for...
[ "func", "(", "rw", "*", "repoWalker", ")", "parseModuleMap", "(", "t", "*", "object", ".", "Tree", ")", "error", "{", "modEntry", ",", "_", ":=", "t", ".", "File", "(", "\"", "\"", ")", "\n", "if", "modEntry", "!=", "nil", "{", "c", ",", "err", ...
// parseModuleMap initializes rw.submodules.
[ "parseModuleMap", "initializes", "rw", ".", "submodules", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/tree.go#L79-L96
28,341
google/zoekt
gitindex/tree.go
TreeToFiles
func TreeToFiles(r *git.Repository, t *object.Tree, repoURL string, repoCache *RepoCache) (map[fileKey]BlobLocation, map[string]plumbing.Hash, error) { rw := newRepoWalker(r, repoURL, repoCache) if err := rw.parseModuleMap(t); err != nil { return nil, nil, err } tw := object.NewTreeWalker(t, true, make(map[plu...
go
func TreeToFiles(r *git.Repository, t *object.Tree, repoURL string, repoCache *RepoCache) (map[fileKey]BlobLocation, map[string]plumbing.Hash, error) { rw := newRepoWalker(r, repoURL, repoCache) if err := rw.parseModuleMap(t); err != nil { return nil, nil, err } tw := object.NewTreeWalker(t, true, make(map[plu...
[ "func", "TreeToFiles", "(", "r", "*", "git", ".", "Repository", ",", "t", "*", "object", ".", "Tree", ",", "repoURL", "string", ",", "repoCache", "*", "RepoCache", ")", "(", "map", "[", "fileKey", "]", "BlobLocation", ",", "map", "[", "string", "]", ...
// TreeToFiles fetches the blob SHA1s for a tree. If repoCache is // non-nil, recurse into submodules. In addition, it returns a mapping // that indicates in which repo each SHA1 can be found.
[ "TreeToFiles", "fetches", "the", "blob", "SHA1s", "for", "a", "tree", ".", "If", "repoCache", "is", "non", "-", "nil", "recurse", "into", "submodules", ".", "In", "addition", "it", "returns", "a", "mapping", "that", "indicates", "in", "which", "repo", "eac...
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/tree.go#L101-L121
28,342
google/zoekt
cmd/zoekt-archive-index/main.go
stripComponents
func stripComponents(path string, count int) string { for i := 0; path != "" && i < count; i++ { i := strings.Index(path, "/") if i < 0 { return "" } path = path[i+1:] } return path }
go
func stripComponents(path string, count int) string { for i := 0; path != "" && i < count; i++ { i := strings.Index(path, "/") if i < 0 { return "" } path = path[i+1:] } return path }
[ "func", "stripComponents", "(", "path", "string", ",", "count", "int", ")", "string", "{", "for", "i", ":=", "0", ";", "path", "!=", "\"", "\"", "&&", "i", "<", "count", ";", "i", "++", "{", "i", ":=", "strings", ".", "Index", "(", "path", ",", ...
// stripComponents removes the specified number of leading path // elements. Pathnames with fewer elements will return the empty string.
[ "stripComponents", "removes", "the", "specified", "number", "of", "leading", "path", "elements", ".", "Pathnames", "with", "fewer", "elements", "will", "return", "the", "empty", "string", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-archive-index/main.go#L29-L38
28,343
google/zoekt
cmd/zoekt-archive-index/archive.go
openArchive
func openArchive(u string) (Archive, error) { var ( r io.Reader closer io.Closer ) if strings.HasPrefix(u, "https://") || strings.HasPrefix(u, "http://") { resp, err := http.Get(u) if err != nil { return nil, err } if resp.StatusCode < 200 || resp.StatusCode >= 300 { b, err := ioutil.ReadAll(...
go
func openArchive(u string) (Archive, error) { var ( r io.Reader closer io.Closer ) if strings.HasPrefix(u, "https://") || strings.HasPrefix(u, "http://") { resp, err := http.Get(u) if err != nil { return nil, err } if resp.StatusCode < 200 || resp.StatusCode >= 300 { b, err := ioutil.ReadAll(...
[ "func", "openArchive", "(", "u", "string", ")", "(", "Archive", ",", "error", ")", "{", "var", "(", "r", "io", ".", "Reader", "\n", "closer", "io", ".", "Closer", "\n", ")", "\n\n", "if", "strings", ".", "HasPrefix", "(", "u", ",", "\"", "\"", ")...
// openArchive opens the tar at the URL or filepath u. Also supported is tgz // files over http.
[ "openArchive", "opens", "the", "tar", "at", "the", "URL", "or", "filepath", "u", ".", "Also", "supported", "is", "tgz", "files", "over", "http", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-archive-index/archive.go#L60-L107
28,344
google/zoekt
cmd/zoekt-repo-index/main.go
iterateManifest
func iterateManifest(mf *manifest.Manifest, baseURL url.URL, revPrefix string, cache *gitindex.RepoCache) (map[fileKey]gitindex.BlobLocation, map[string]plumbing.Hash, error) { allFiles := map[fileKey]gitindex.BlobLocation{} allVersions := map[string]plumbing.Hash{} for _, p := range mf.Project { rev := mf.Proje...
go
func iterateManifest(mf *manifest.Manifest, baseURL url.URL, revPrefix string, cache *gitindex.RepoCache) (map[fileKey]gitindex.BlobLocation, map[string]plumbing.Hash, error) { allFiles := map[fileKey]gitindex.BlobLocation{} allVersions := map[string]plumbing.Hash{} for _, p := range mf.Project { rev := mf.Proje...
[ "func", "iterateManifest", "(", "mf", "*", "manifest", ".", "Manifest", ",", "baseURL", "url", ".", "URL", ",", "revPrefix", "string", ",", "cache", "*", "gitindex", ".", "RepoCache", ")", "(", "map", "[", "fileKey", "]", "gitindex", ".", "BlobLocation", ...
// iterateManifest constructs a complete tree from the given Manifest.
[ "iterateManifest", "constructs", "a", "complete", "tree", "from", "the", "given", "Manifest", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-repo-index/main.go#L325-L380
28,345
google/zoekt
ctags/json.go
NewParser
func NewParser(bin string) (Parser, error) { if strings.Contains(bin, "universal-ctags") { // todo: restart, parallelization. proc, err := newProcess(bin) if err != nil { return nil, err } return &lockedParser{p: proc}, nil } log.Fatal("not implemented") return nil, nil }
go
func NewParser(bin string) (Parser, error) { if strings.Contains(bin, "universal-ctags") { // todo: restart, parallelization. proc, err := newProcess(bin) if err != nil { return nil, err } return &lockedParser{p: proc}, nil } log.Fatal("not implemented") return nil, nil }
[ "func", "NewParser", "(", "bin", "string", ")", "(", "Parser", ",", "error", ")", "{", "if", "strings", ".", "Contains", "(", "bin", ",", "\"", "\"", ")", "{", "// todo: restart, parallelization.", "proc", ",", "err", ":=", "newProcess", "(", "bin", ")",...
// NewParser creates a parser that is implemented by the given // universal-ctags binary. The parser is safe for concurrent use.
[ "NewParser", "creates", "a", "parser", "that", "is", "implemented", "by", "the", "given", "universal", "-", "ctags", "binary", ".", "The", "parser", "is", "safe", "for", "concurrent", "use", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/ctags/json.go#L207-L219
28,346
google/zoekt
contentprovider.go
setDocument
func (p *contentProvider) setDocument(docID uint32) { fileStart := p.id.boundaries[docID] p.idx = docID p.fileSize = p.id.boundaries[docID+1] - fileStart p._nl = nil p._sects = nil p._data = nil }
go
func (p *contentProvider) setDocument(docID uint32) { fileStart := p.id.boundaries[docID] p.idx = docID p.fileSize = p.id.boundaries[docID+1] - fileStart p._nl = nil p._sects = nil p._data = nil }
[ "func", "(", "p", "*", "contentProvider", ")", "setDocument", "(", "docID", "uint32", ")", "{", "fileStart", ":=", "p", ".", "id", ".", "boundaries", "[", "docID", "]", "\n\n", "p", ".", "idx", "=", "docID", "\n", "p", ".", "fileSize", "=", "p", "....
// setDocument skips to the given document.
[ "setDocument", "skips", "to", "the", "given", "document", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/contentprovider.go#L44-L53
28,347
google/zoekt
query/regexp.go
RegexpToQuery
func RegexpToQuery(r *syntax.Regexp, minTextSize int) Q { q := regexpToQueryRecursive(r, minTextSize) q = Simplify(q) return q }
go
func RegexpToQuery(r *syntax.Regexp, minTextSize int) Q { q := regexpToQueryRecursive(r, minTextSize) q = Simplify(q) return q }
[ "func", "RegexpToQuery", "(", "r", "*", "syntax", ".", "Regexp", ",", "minTextSize", "int", ")", "Q", "{", "q", ":=", "regexpToQueryRecursive", "(", "r", ",", "minTextSize", ")", "\n", "q", "=", "Simplify", "(", "q", ")", "\n", "return", "q", "\n", "...
// RegexpToQuery tries to distill a substring search query that // matches a superset of the regexp.
[ "RegexpToQuery", "tries", "to", "distill", "a", "substring", "search", "query", "that", "matches", "a", "superset", "of", "the", "regexp", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/regexp.go#L48-L52
28,348
google/zoekt
cmd/zoekt-indexserver/main.go
periodicFetch
func periodicFetch(repoDir, indexDir string, opts *Options, pendingRepos chan<- string) { t := time.NewTicker(opts.fetchInterval) for { repos, err := gitindex.FindGitRepos(repoDir) if err != nil { log.Println(err) continue } if len(repos) == 0 { log.Printf("no repos found under %s", repoDir) } /...
go
func periodicFetch(repoDir, indexDir string, opts *Options, pendingRepos chan<- string) { t := time.NewTicker(opts.fetchInterval) for { repos, err := gitindex.FindGitRepos(repoDir) if err != nil { log.Println(err) continue } if len(repos) == 0 { log.Printf("no repos found under %s", repoDir) } /...
[ "func", "periodicFetch", "(", "repoDir", ",", "indexDir", "string", ",", "opts", "*", "Options", ",", "pendingRepos", "chan", "<-", "string", ")", "{", "t", ":=", "time", ".", "NewTicker", "(", "opts", ".", "fetchInterval", ")", "\n", "for", "{", "repos"...
// periodicFetch runs git-fetch every once in a while. Results are // posted on pendingRepos.
[ "periodicFetch", "runs", "git", "-", "fetch", "every", "once", "in", "a", "while", ".", "Results", "are", "posted", "on", "pendingRepos", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-indexserver/main.go#L95-L124
28,349
google/zoekt
cmd/zoekt-indexserver/main.go
fetchGitRepo
func fetchGitRepo(dir string) bool { cmd := exec.Command("git", "--git-dir", dir, "fetch", "origin") outBuf := &bytes.Buffer{} errBuf := &bytes.Buffer{} // Prevent prompting cmd.Stdin = &bytes.Buffer{} cmd.Stderr = errBuf cmd.Stdout = outBuf if err := cmd.Run(); err != nil { log.Printf("command %s failed: %v...
go
func fetchGitRepo(dir string) bool { cmd := exec.Command("git", "--git-dir", dir, "fetch", "origin") outBuf := &bytes.Buffer{} errBuf := &bytes.Buffer{} // Prevent prompting cmd.Stdin = &bytes.Buffer{} cmd.Stderr = errBuf cmd.Stdout = outBuf if err := cmd.Run(); err != nil { log.Printf("command %s failed: %v...
[ "func", "fetchGitRepo", "(", "dir", "string", ")", "bool", "{", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "dir", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "outBuf", ":=", "&", "bytes", ".", "Buffer", "{", "}...
// fetchGitRepo runs git-fetch, and returns true if there was an // update.
[ "fetchGitRepo", "runs", "git", "-", "fetch", "and", "returns", "true", "if", "there", "was", "an", "update", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-indexserver/main.go#L128-L144
28,350
google/zoekt
cmd/zoekt-indexserver/main.go
indexPendingRepos
func indexPendingRepos(indexDir, repoDir string, opts *Options, repos <-chan string) { for dir := range repos { args := []string{ "-require_ctags", fmt.Sprintf("-parallelism=%d", opts.cpuCount), "-repo_cache", repoDir, "-index", indexDir, "-incremental", } args = append(args, opts.indexFlags...) ...
go
func indexPendingRepos(indexDir, repoDir string, opts *Options, repos <-chan string) { for dir := range repos { args := []string{ "-require_ctags", fmt.Sprintf("-parallelism=%d", opts.cpuCount), "-repo_cache", repoDir, "-index", indexDir, "-incremental", } args = append(args, opts.indexFlags...) ...
[ "func", "indexPendingRepos", "(", "indexDir", ",", "repoDir", "string", ",", "opts", "*", "Options", ",", "repos", "<-", "chan", "string", ")", "{", "for", "dir", ":=", "range", "repos", "{", "args", ":=", "[", "]", "string", "{", "\"", "\"", ",", "f...
// indexPendingRepos consumes the directories on the repos channel and // indexes them, sequentially.
[ "indexPendingRepos", "consumes", "the", "directories", "on", "the", "repos", "channel", "and", "indexes", "them", "sequentially", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-indexserver/main.go#L148-L162
28,351
google/zoekt
cmd/zoekt-indexserver/main.go
deleteLogs
func deleteLogs(logDir string, maxAge time.Duration) { fs, err := filepath.Glob(filepath.Join(logDir, "*")) if err != nil { log.Fatalf("filepath.Glob(%s): %v", logDir, err) } threshold := time.Now().Add(-maxAge) for _, fn := range fs { if fi, err := os.Lstat(fn); err == nil && fi.ModTime().Before(threshold) {...
go
func deleteLogs(logDir string, maxAge time.Duration) { fs, err := filepath.Glob(filepath.Join(logDir, "*")) if err != nil { log.Fatalf("filepath.Glob(%s): %v", logDir, err) } threshold := time.Now().Add(-maxAge) for _, fn := range fs { if fi, err := os.Lstat(fn); err == nil && fi.ModTime().Before(threshold) {...
[ "func", "deleteLogs", "(", "logDir", "string", ",", "maxAge", "time", ".", "Duration", ")", "{", "fs", ",", "err", ":=", "filepath", ".", "Glob", "(", "filepath", ".", "Join", "(", "logDir", ",", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil"...
// deleteLogs deletes old logs.
[ "deleteLogs", "deletes", "old", "logs", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-indexserver/main.go#L165-L177
28,352
google/zoekt
cmd/zoekt-indexserver/main.go
deleteIfOrphan
func deleteIfOrphan(repoDir string, fn string) error { f, err := os.Open(fn) if err != nil { return nil } defer f.Close() ifile, err := zoekt.NewIndexFile(f) if err != nil { return nil } defer ifile.Close() repo, _, err := zoekt.ReadMetadata(ifile) if err != nil { return nil } _, err = os.Stat(repo...
go
func deleteIfOrphan(repoDir string, fn string) error { f, err := os.Open(fn) if err != nil { return nil } defer f.Close() ifile, err := zoekt.NewIndexFile(f) if err != nil { return nil } defer ifile.Close() repo, _, err := zoekt.ReadMetadata(ifile) if err != nil { return nil } _, err = os.Stat(repo...
[ "func", "deleteIfOrphan", "(", "repoDir", "string", ",", "fn", "string", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "fn", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n", "defer", "f", ".", "Close...
// Delete the shard if its corresponding git repo can't be found.
[ "Delete", "the", "shard", "if", "its", "corresponding", "git", "repo", "can", "t", "be", "found", "." ]
3493be98f11f3ca46cdb973a968f09f7cacc645d
https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/cmd/zoekt-indexserver/main.go#L188-L213
28,353
derekparker/trie
trie.go
New
func New() *Trie { return &Trie{ root: &Node{children: make(map[rune]*Node), depth: 0}, size: 0, } }
go
func New() *Trie { return &Trie{ root: &Node{children: make(map[rune]*Node), depth: 0}, size: 0, } }
[ "func", "New", "(", ")", "*", "Trie", "{", "return", "&", "Trie", "{", "root", ":", "&", "Node", "{", "children", ":", "make", "(", "map", "[", "rune", "]", "*", "Node", ")", ",", "depth", ":", "0", "}", ",", "size", ":", "0", ",", "}", "\n...
// Creates a new Trie with an initialized root Node.
[ "Creates", "a", "new", "Trie", "with", "an", "initialized", "root", "Node", "." ]
1ce4922c7ad906a094c6298977755068ba76ad31
https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L38-L43
28,354
derekparker/trie
trie.go
Find
func (t *Trie) Find(key string) (*Node, bool) { node := findNode(t.Root(), []rune(key)) if node == nil { return nil, false } node, ok := node.Children()[nul] if !ok || !node.term { return nil, false } return node, true }
go
func (t *Trie) Find(key string) (*Node, bool) { node := findNode(t.Root(), []rune(key)) if node == nil { return nil, false } node, ok := node.Children()[nul] if !ok || !node.term { return nil, false } return node, true }
[ "func", "(", "t", "*", "Trie", ")", "Find", "(", "key", "string", ")", "(", "*", "Node", ",", "bool", ")", "{", "node", ":=", "findNode", "(", "t", ".", "Root", "(", ")", ",", "[", "]", "rune", "(", "key", ")", ")", "\n", "if", "node", "=="...
// Finds and returns meta data associated // with `key`.
[ "Finds", "and", "returns", "meta", "data", "associated", "with", "key", "." ]
1ce4922c7ad906a094c6298977755068ba76ad31
https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L78-L90
28,355
derekparker/trie
trie.go
Remove
func (t *Trie) Remove(key string) { var ( i int rs = []rune(key) node = findNode(t.Root(), []rune(key)) ) t.mu.Lock() defer t.mu.Unlock() t.size-- for n := node.Parent(); n != nil; n = n.Parent() { i++ if len(n.Children()) > 1 { r := rs[len(rs)-i] n.RemoveChild(r) break } } }
go
func (t *Trie) Remove(key string) { var ( i int rs = []rune(key) node = findNode(t.Root(), []rune(key)) ) t.mu.Lock() defer t.mu.Unlock() t.size-- for n := node.Parent(); n != nil; n = n.Parent() { i++ if len(n.Children()) > 1 { r := rs[len(rs)-i] n.RemoveChild(r) break } } }
[ "func", "(", "t", "*", "Trie", ")", "Remove", "(", "key", "string", ")", "{", "var", "(", "i", "int", "\n", "rs", "=", "[", "]", "rune", "(", "key", ")", "\n", "node", "=", "findNode", "(", "t", ".", "Root", "(", ")", ",", "[", "]", "rune",...
// Removes a key from the trie, ensuring that // all bitmasks up to root are appropriately recalculated.
[ "Removes", "a", "key", "from", "the", "trie", "ensuring", "that", "all", "bitmasks", "up", "to", "root", "are", "appropriately", "recalculated", "." ]
1ce4922c7ad906a094c6298977755068ba76ad31
https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L99-L118
28,356
derekparker/trie
trie.go
FuzzySearch
func (t Trie) FuzzySearch(pre string) []string { keys := fuzzycollect(t.Root(), []rune(pre)) sort.Sort(ByKeys(keys)) return keys }
go
func (t Trie) FuzzySearch(pre string) []string { keys := fuzzycollect(t.Root(), []rune(pre)) sort.Sort(ByKeys(keys)) return keys }
[ "func", "(", "t", "Trie", ")", "FuzzySearch", "(", "pre", "string", ")", "[", "]", "string", "{", "keys", ":=", "fuzzycollect", "(", "t", ".", "Root", "(", ")", ",", "[", "]", "rune", "(", "pre", ")", ")", "\n", "sort", ".", "Sort", "(", "ByKey...
// Performs a fuzzy search against the keys in the trie.
[ "Performs", "a", "fuzzy", "search", "against", "the", "keys", "in", "the", "trie", "." ]
1ce4922c7ad906a094c6298977755068ba76ad31
https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L126-L130
28,357
derekparker/trie
trie.go
PrefixSearch
func (t Trie) PrefixSearch(pre string) []string { node := findNode(t.Root(), []rune(pre)) if node == nil { return nil } return collect(node) }
go
func (t Trie) PrefixSearch(pre string) []string { node := findNode(t.Root(), []rune(pre)) if node == nil { return nil } return collect(node) }
[ "func", "(", "t", "Trie", ")", "PrefixSearch", "(", "pre", "string", ")", "[", "]", "string", "{", "node", ":=", "findNode", "(", "t", ".", "Root", "(", ")", ",", "[", "]", "rune", "(", "pre", ")", ")", "\n", "if", "node", "==", "nil", "{", "...
// Performs a prefix search against the keys in the trie.
[ "Performs", "a", "prefix", "search", "against", "the", "keys", "in", "the", "trie", "." ]
1ce4922c7ad906a094c6298977755068ba76ad31
https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L133-L140
28,358
derekparker/trie
trie.go
NewChild
func (n *Node) NewChild(val rune, bitmask uint64, meta interface{}, term bool) *Node { node := &Node{ val: val, mask: bitmask, term: term, meta: meta, parent: n, children: make(map[rune]*Node), depth: n.depth + 1, } n.children[val] = node n.mask |= bitmask return node }
go
func (n *Node) NewChild(val rune, bitmask uint64, meta interface{}, term bool) *Node { node := &Node{ val: val, mask: bitmask, term: term, meta: meta, parent: n, children: make(map[rune]*Node), depth: n.depth + 1, } n.children[val] = node n.mask |= bitmask return node }
[ "func", "(", "n", "*", "Node", ")", "NewChild", "(", "val", "rune", ",", "bitmask", "uint64", ",", "meta", "interface", "{", "}", ",", "term", "bool", ")", "*", "Node", "{", "node", ":=", "&", "Node", "{", "val", ":", "val", ",", "mask", ":", "...
// Creates and returns a pointer to a new child for the node.
[ "Creates", "and", "returns", "a", "pointer", "to", "a", "new", "child", "for", "the", "node", "." ]
1ce4922c7ad906a094c6298977755068ba76ad31
https://github.com/derekparker/trie/blob/1ce4922c7ad906a094c6298977755068ba76ad31/trie.go#L143-L156
28,359
tidwall/sjson
sjson.go
appendStringify
func appendStringify(buf []byte, s string) []byte { if mustMarshalString(s) { b, _ := jsongo.Marshal(s) return append(buf, b...) } buf = append(buf, '"') buf = append(buf, s...) buf = append(buf, '"') return buf }
go
func appendStringify(buf []byte, s string) []byte { if mustMarshalString(s) { b, _ := jsongo.Marshal(s) return append(buf, b...) } buf = append(buf, '"') buf = append(buf, s...) buf = append(buf, '"') return buf }
[ "func", "appendStringify", "(", "buf", "[", "]", "byte", ",", "s", "string", ")", "[", "]", "byte", "{", "if", "mustMarshalString", "(", "s", ")", "{", "b", ",", "_", ":=", "jsongo", ".", "Marshal", "(", "s", ")", "\n", "return", "append", "(", "...
// appendStringify makes a json string and appends to buf.
[ "appendStringify", "makes", "a", "json", "string", "and", "appends", "to", "buf", "." ]
25fb082a20e29e83fb7b7ef5f5919166aad1f084
https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L119-L128
28,360
tidwall/sjson
sjson.go
appendBuild
func appendBuild(buf []byte, array bool, paths []pathResult, raw string, stringify bool) []byte { if !array { buf = appendStringify(buf, paths[0].part) buf = append(buf, ':') } if len(paths) > 1 { n, numeric := atoui(paths[1]) if numeric || (!paths[1].force && paths[1].part == "-1") { buf = append(buf, '...
go
func appendBuild(buf []byte, array bool, paths []pathResult, raw string, stringify bool) []byte { if !array { buf = appendStringify(buf, paths[0].part) buf = append(buf, ':') } if len(paths) > 1 { n, numeric := atoui(paths[1]) if numeric || (!paths[1].force && paths[1].part == "-1") { buf = append(buf, '...
[ "func", "appendBuild", "(", "buf", "[", "]", "byte", ",", "array", "bool", ",", "paths", "[", "]", "pathResult", ",", "raw", "string", ",", "stringify", "bool", ")", "[", "]", "byte", "{", "if", "!", "array", "{", "buf", "=", "appendStringify", "(", ...
// appendBuild builds a json block from a json path.
[ "appendBuild", "builds", "a", "json", "block", "from", "a", "json", "path", "." ]
25fb082a20e29e83fb7b7ef5f5919166aad1f084
https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L131-L157
28,361
tidwall/sjson
sjson.go
atoui
func atoui(r pathResult) (n int, ok bool) { if r.force { return 0, false } for i := 0; i < len(r.part); i++ { if r.part[i] < '0' || r.part[i] > '9' { return 0, false } n = n*10 + int(r.part[i]-'0') } return n, true }
go
func atoui(r pathResult) (n int, ok bool) { if r.force { return 0, false } for i := 0; i < len(r.part); i++ { if r.part[i] < '0' || r.part[i] > '9' { return 0, false } n = n*10 + int(r.part[i]-'0') } return n, true }
[ "func", "atoui", "(", "r", "pathResult", ")", "(", "n", "int", ",", "ok", "bool", ")", "{", "if", "r", ".", "force", "{", "return", "0", ",", "false", "\n", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "r", ".", "part", ")",...
// atoui does a rip conversion of string -> unigned int.
[ "atoui", "does", "a", "rip", "conversion", "of", "string", "-", ">", "unigned", "int", "." ]
25fb082a20e29e83fb7b7ef5f5919166aad1f084
https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L160-L171
28,362
tidwall/sjson
sjson.go
appendRepeat
func appendRepeat(buf []byte, s string, n int) []byte { for i := 0; i < n; i++ { buf = append(buf, s...) } return buf }
go
func appendRepeat(buf []byte, s string, n int) []byte { for i := 0; i < n; i++ { buf = append(buf, s...) } return buf }
[ "func", "appendRepeat", "(", "buf", "[", "]", "byte", ",", "s", "string", ",", "n", "int", ")", "[", "]", "byte", "{", "for", "i", ":=", "0", ";", "i", "<", "n", ";", "i", "++", "{", "buf", "=", "append", "(", "buf", ",", "s", "...", ")", ...
// appendRepeat repeats string "n" times and appends to buf.
[ "appendRepeat", "repeats", "string", "n", "times", "and", "appends", "to", "buf", "." ]
25fb082a20e29e83fb7b7ef5f5919166aad1f084
https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L174-L179
28,363
tidwall/sjson
sjson.go
trim
func trim(s string) string { for len(s) > 0 { if s[0] <= ' ' { s = s[1:] continue } break } for len(s) > 0 { if s[len(s)-1] <= ' ' { s = s[:len(s)-1] continue } break } return s }
go
func trim(s string) string { for len(s) > 0 { if s[0] <= ' ' { s = s[1:] continue } break } for len(s) > 0 { if s[len(s)-1] <= ' ' { s = s[:len(s)-1] continue } break } return s }
[ "func", "trim", "(", "s", "string", ")", "string", "{", "for", "len", "(", "s", ")", ">", "0", "{", "if", "s", "[", "0", "]", "<=", "' '", "{", "s", "=", "s", "[", "1", ":", "]", "\n", "continue", "\n", "}", "\n", "break", "\n", "}", "\n"...
// trim does a rip trim
[ "trim", "does", "a", "rip", "trim" ]
25fb082a20e29e83fb7b7ef5f5919166aad1f084
https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L182-L198
28,364
tidwall/sjson
sjson.go
deleteTailItem
func deleteTailItem(buf []byte) ([]byte, bool) { loop: for i := len(buf) - 1; i >= 0; i-- { // look for either a ',',':','[' switch buf[i] { case '[': return buf, true case ',': return buf[:i], false case ':': // delete tail string i-- for ; i >= 0; i-- { if buf[i] == '"' { i-- f...
go
func deleteTailItem(buf []byte) ([]byte, bool) { loop: for i := len(buf) - 1; i >= 0; i-- { // look for either a ',',':','[' switch buf[i] { case '[': return buf, true case ',': return buf[:i], false case ':': // delete tail string i-- for ; i >= 0; i-- { if buf[i] == '"' { i-- f...
[ "func", "deleteTailItem", "(", "buf", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "bool", ")", "{", "loop", ":", "for", "i", ":=", "len", "(", "buf", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "// look for either a ',',':','[...
// deleteTailItem deletes the previous key or comma.
[ "deleteTailItem", "deletes", "the", "previous", "key", "or", "comma", "." ]
25fb082a20e29e83fb7b7ef5f5919166aad1f084
https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L201-L241
28,365
tidwall/sjson
sjson.go
SetRaw
func SetRaw(json, path, value string) (string, error) { return SetRawOptions(json, path, value, nil) }
go
func SetRaw(json, path, value string) (string, error) { return SetRawOptions(json, path, value, nil) }
[ "func", "SetRaw", "(", "json", ",", "path", ",", "value", "string", ")", "(", "string", ",", "error", ")", "{", "return", "SetRawOptions", "(", "json", ",", "path", ",", "value", ",", "nil", ")", "\n", "}" ]
// SetRaw sets a raw json value for the specified path. // This function works the same as Set except that the value is set as a // raw block of json. This allows for setting premarshalled json objects.
[ "SetRaw", "sets", "a", "raw", "json", "value", "for", "the", "specified", "path", ".", "This", "function", "works", "the", "same", "as", "Set", "except", "that", "the", "value", "is", "set", "as", "a", "raw", "block", "of", "json", ".", "This", "allows...
25fb082a20e29e83fb7b7ef5f5919166aad1f084
https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L446-L448
28,366
tidwall/sjson
sjson.go
SetRawOptions
func SetRawOptions(json, path, value string, opts *Options) (string, error) { var optimistic bool if opts != nil { optimistic = opts.Optimistic } res, err := set(json, path, value, false, false, optimistic, false) if err == errNoChange { return json, nil } return string(res), err }
go
func SetRawOptions(json, path, value string, opts *Options) (string, error) { var optimistic bool if opts != nil { optimistic = opts.Optimistic } res, err := set(json, path, value, false, false, optimistic, false) if err == errNoChange { return json, nil } return string(res), err }
[ "func", "SetRawOptions", "(", "json", ",", "path", ",", "value", "string", ",", "opts", "*", "Options", ")", "(", "string", ",", "error", ")", "{", "var", "optimistic", "bool", "\n", "if", "opts", "!=", "nil", "{", "optimistic", "=", "opts", ".", "Op...
// SetRawOptions sets a raw json value for the specified path with options. // This furnction works the same as SetOptions except that the value is set // as a raw block of json. This allows for setting premarshalled json objects.
[ "SetRawOptions", "sets", "a", "raw", "json", "value", "for", "the", "specified", "path", "with", "options", ".", "This", "furnction", "works", "the", "same", "as", "SetOptions", "except", "that", "the", "value", "is", "set", "as", "a", "raw", "block", "of"...
25fb082a20e29e83fb7b7ef5f5919166aad1f084
https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L453-L463
28,367
tidwall/sjson
sjson.go
Delete
func Delete(json, path string) (string, error) { return Set(json, path, dtype{}) }
go
func Delete(json, path string) (string, error) { return Set(json, path, dtype{}) }
[ "func", "Delete", "(", "json", ",", "path", "string", ")", "(", "string", ",", "error", ")", "{", "return", "Set", "(", "json", ",", "path", ",", "dtype", "{", "}", ")", "\n", "}" ]
// Delete deletes a value from json for the specified path.
[ "Delete", "deletes", "a", "value", "from", "json", "for", "the", "specified", "path", "." ]
25fb082a20e29e83fb7b7ef5f5919166aad1f084
https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L475-L477
28,368
tidwall/sjson
sjson.go
DeleteBytes
func DeleteBytes(json []byte, path string) ([]byte, error) { return SetBytes(json, path, dtype{}) }
go
func DeleteBytes(json []byte, path string) ([]byte, error) { return SetBytes(json, path, dtype{}) }
[ "func", "DeleteBytes", "(", "json", "[", "]", "byte", ",", "path", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "SetBytes", "(", "json", ",", "path", ",", "dtype", "{", "}", ")", "\n", "}" ]
// DeleteBytes deletes a value from json for the specified path.
[ "DeleteBytes", "deletes", "a", "value", "from", "json", "for", "the", "specified", "path", "." ]
25fb082a20e29e83fb7b7ef5f5919166aad1f084
https://github.com/tidwall/sjson/blob/25fb082a20e29e83fb7b7ef5f5919166aad1f084/sjson.go#L480-L482
28,369
SebastiaanKlippert/go-wkhtmltopdf
wkhtmltopdf.go
NewPageReader
func NewPageReader(input io.Reader) *PageReader { return &PageReader{ Input: input, PageOptions: NewPageOptions(), } }
go
func NewPageReader(input io.Reader) *PageReader { return &PageReader{ Input: input, PageOptions: NewPageOptions(), } }
[ "func", "NewPageReader", "(", "input", "io", ".", "Reader", ")", "*", "PageReader", "{", "return", "&", "PageReader", "{", "Input", ":", "input", ",", "PageOptions", ":", "NewPageOptions", "(", ")", ",", "}", "\n", "}" ]
// NewPageReader creates a new PageReader from an io.Reader
[ "NewPageReader", "creates", "a", "new", "PageReader", "from", "an", "io", ".", "Reader" ]
72a7793efd38728796273861bb27d590cc33d9d4
https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L99-L104
28,370
SebastiaanKlippert/go-wkhtmltopdf
wkhtmltopdf.go
Args
func (po *PageOptions) Args() []string { return append(append([]string{}, po.pageOptions.Args()...), po.headerAndFooterOptions.Args()...) }
go
func (po *PageOptions) Args() []string { return append(append([]string{}, po.pageOptions.Args()...), po.headerAndFooterOptions.Args()...) }
[ "func", "(", "po", "*", "PageOptions", ")", "Args", "(", ")", "[", "]", "string", "{", "return", "append", "(", "append", "(", "[", "]", "string", "{", "}", ",", "po", ".", "pageOptions", ".", "Args", "(", ")", "...", ")", ",", "po", ".", "head...
// Args returns the argument slice
[ "Args", "returns", "the", "argument", "slice" ]
72a7793efd38728796273861bb27d590cc33d9d4
https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L119-L121
28,371
SebastiaanKlippert/go-wkhtmltopdf
wkhtmltopdf.go
Args
func (pdfg *PDFGenerator) Args() []string { args := append([]string{}, pdfg.globalOptions.Args()...) args = append(args, pdfg.outlineOptions.Args()...) if pdfg.Cover.Input != "" { args = append(args, "cover") args = append(args, pdfg.Cover.Input) args = append(args, pdfg.Cover.pageOptions.Args()...) } if pdf...
go
func (pdfg *PDFGenerator) Args() []string { args := append([]string{}, pdfg.globalOptions.Args()...) args = append(args, pdfg.outlineOptions.Args()...) if pdfg.Cover.Input != "" { args = append(args, "cover") args = append(args, pdfg.Cover.Input) args = append(args, pdfg.Cover.pageOptions.Args()...) } if pdf...
[ "func", "(", "pdfg", "*", "PDFGenerator", ")", "Args", "(", ")", "[", "]", "string", "{", "args", ":=", "append", "(", "[", "]", "string", "{", "}", ",", "pdfg", ".", "globalOptions", ".", "Args", "(", ")", "...", ")", "\n", "args", "=", "append"...
//Args returns the commandline arguments as a string slice
[ "Args", "returns", "the", "commandline", "arguments", "as", "a", "string", "slice" ]
72a7793efd38728796273861bb27d590cc33d9d4
https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L164-L188
28,372
SebastiaanKlippert/go-wkhtmltopdf
wkhtmltopdf.go
AddPage
func (pdfg *PDFGenerator) AddPage(p page) { pdfg.pages = append(pdfg.pages, p) }
go
func (pdfg *PDFGenerator) AddPage(p page) { pdfg.pages = append(pdfg.pages, p) }
[ "func", "(", "pdfg", "*", "PDFGenerator", ")", "AddPage", "(", "p", "page", ")", "{", "pdfg", ".", "pages", "=", "append", "(", "pdfg", ".", "pages", ",", "p", ")", "\n", "}" ]
// AddPage adds a new input page to the document. // A page is an input HTML page, it can span multiple pages in the output document. // It is a Page when read from file or URL or a PageReader when read from memory.
[ "AddPage", "adds", "a", "new", "input", "page", "to", "the", "document", ".", "A", "page", "is", "an", "input", "HTML", "page", "it", "can", "span", "multiple", "pages", "in", "the", "output", "document", ".", "It", "is", "a", "Page", "when", "read", ...
72a7793efd38728796273861bb27d590cc33d9d4
https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L198-L200
28,373
SebastiaanKlippert/go-wkhtmltopdf
wkhtmltopdf.go
WriteFile
func (pdfg *PDFGenerator) WriteFile(filename string) error { return ioutil.WriteFile(filename, pdfg.Bytes(), 0666) }
go
func (pdfg *PDFGenerator) WriteFile(filename string) error { return ioutil.WriteFile(filename, pdfg.Bytes(), 0666) }
[ "func", "(", "pdfg", "*", "PDFGenerator", ")", "WriteFile", "(", "filename", "string", ")", "error", "{", "return", "ioutil", ".", "WriteFile", "(", "filename", ",", "pdfg", ".", "Bytes", "(", ")", ",", "0666", ")", "\n", "}" ]
// WriteFile writes the contents of the output buffer to a file
[ "WriteFile", "writes", "the", "contents", "of", "the", "output", "buffer", "to", "a", "file" ]
72a7793efd38728796273861bb27d590cc33d9d4
https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L230-L232
28,374
SebastiaanKlippert/go-wkhtmltopdf
wkhtmltopdf.go
findPath
func (pdfg *PDFGenerator) findPath() error { const exe = "wkhtmltopdf" pdfg.binPath = GetPath() if pdfg.binPath != "" { // wkhtmltopdf has already already found, return return nil } exeDir, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { return err } path, err := exec.LookPath(filepath.Join(...
go
func (pdfg *PDFGenerator) findPath() error { const exe = "wkhtmltopdf" pdfg.binPath = GetPath() if pdfg.binPath != "" { // wkhtmltopdf has already already found, return return nil } exeDir, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { return err } path, err := exec.LookPath(filepath.Join(...
[ "func", "(", "pdfg", "*", "PDFGenerator", ")", "findPath", "(", ")", "error", "{", "const", "exe", "=", "\"", "\"", "\n", "pdfg", ".", "binPath", "=", "GetPath", "(", ")", "\n", "if", "pdfg", ".", "binPath", "!=", "\"", "\"", "{", "// wkhtmltopdf has...
//findPath finds the path to wkhtmltopdf by //- first looking in the current dir //- looking in the PATH and PATHEXT environment dirs //- using the WKHTMLTOPDF_PATH environment dir //The path is cached, meaning you can not change the location of wkhtmltopdf in //a running program once it has been found
[ "findPath", "finds", "the", "path", "to", "wkhtmltopdf", "by", "-", "first", "looking", "in", "the", "current", "dir", "-", "looking", "in", "the", "PATH", "and", "PATHEXT", "environment", "dirs", "-", "using", "the", "WKHTMLTOPDF_PATH", "environment", "dir", ...
72a7793efd38728796273861bb27d590cc33d9d4
https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L240-L274
28,375
SebastiaanKlippert/go-wkhtmltopdf
wkhtmltopdf.go
NewPDFGenerator
func NewPDFGenerator() (*PDFGenerator, error) { pdfg := &PDFGenerator{ globalOptions: newGlobalOptions(), outlineOptions: newOutlineOptions(), Cover: cover{ pageOptions: newPageOptions(), }, TOC: toc{ allTocOptions: allTocOptions{ tocOptions: newTocOptions(), pageOptions: newPageOptions(), ...
go
func NewPDFGenerator() (*PDFGenerator, error) { pdfg := &PDFGenerator{ globalOptions: newGlobalOptions(), outlineOptions: newOutlineOptions(), Cover: cover{ pageOptions: newPageOptions(), }, TOC: toc{ allTocOptions: allTocOptions{ tocOptions: newTocOptions(), pageOptions: newPageOptions(), ...
[ "func", "NewPDFGenerator", "(", ")", "(", "*", "PDFGenerator", ",", "error", ")", "{", "pdfg", ":=", "&", "PDFGenerator", "{", "globalOptions", ":", "newGlobalOptions", "(", ")", ",", "outlineOptions", ":", "newOutlineOptions", "(", ")", ",", "Cover", ":", ...
// NewPDFGenerator returns a new PDFGenerator struct with all options created and // checks if wkhtmltopdf can be found on the system
[ "NewPDFGenerator", "returns", "a", "new", "PDFGenerator", "struct", "with", "all", "options", "created", "and", "checks", "if", "wkhtmltopdf", "can", "be", "found", "on", "the", "system" ]
72a7793efd38728796273861bb27d590cc33d9d4
https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/wkhtmltopdf.go#L316-L332
28,376
SebastiaanKlippert/go-wkhtmltopdf
json.go
ToJSON
func (pdfg *PDFGenerator) ToJSON() ([]byte, error) { jpdf := &jsonPDFGenerator{ TOC: pdfg.TOC, Cover: pdfg.Cover, GlobalOptions: pdfg.globalOptions, OutlineOptions: pdfg.outlineOptions, } for _, p := range pdfg.pages { jp := jsonPage{ InputFile: p.InputFile(), } switch tp := p...
go
func (pdfg *PDFGenerator) ToJSON() ([]byte, error) { jpdf := &jsonPDFGenerator{ TOC: pdfg.TOC, Cover: pdfg.Cover, GlobalOptions: pdfg.globalOptions, OutlineOptions: pdfg.outlineOptions, } for _, p := range pdfg.pages { jp := jsonPage{ InputFile: p.InputFile(), } switch tp := p...
[ "func", "(", "pdfg", "*", "PDFGenerator", ")", "ToJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "jpdf", ":=", "&", "jsonPDFGenerator", "{", "TOC", ":", "pdfg", ".", "TOC", ",", "Cover", ":", "pdfg", ".", "Cover", ",", "GlobalOptio...
// ToJSON creates JSON of the complete representation of the PDFGenerator. // It also saves all pages, for a PageReader page, the content is stored as a Base64 string in the JSON.
[ "ToJSON", "creates", "JSON", "of", "the", "complete", "representation", "of", "the", "PDFGenerator", ".", "It", "also", "saves", "all", "pages", "for", "a", "PageReader", "page", "the", "content", "is", "stored", "as", "a", "Base64", "string", "in", "the", ...
72a7793efd38728796273861bb27d590cc33d9d4
https://github.com/SebastiaanKlippert/go-wkhtmltopdf/blob/72a7793efd38728796273861bb27d590cc33d9d4/json.go#L28-L57
28,377
matcornic/hermes
examples/main.go
send
func send(smtpConfig smtpAuthentication, options sendOptions, htmlBody string, txtBody string) error { if smtpConfig.Server == "" { return errors.New("SMTP server config is empty") } if smtpConfig.Port == 0 { return errors.New("SMTP port config is empty") } if smtpConfig.SMTPUser == "" { return errors.New(...
go
func send(smtpConfig smtpAuthentication, options sendOptions, htmlBody string, txtBody string) error { if smtpConfig.Server == "" { return errors.New("SMTP server config is empty") } if smtpConfig.Port == 0 { return errors.New("SMTP port config is empty") } if smtpConfig.SMTPUser == "" { return errors.New(...
[ "func", "send", "(", "smtpConfig", "smtpAuthentication", ",", "options", "sendOptions", ",", "htmlBody", "string", ",", "txtBody", "string", ")", "error", "{", "if", "smtpConfig", ".", "Server", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "...
// send sends the email
[ "send", "sends", "the", "email" ]
2f49bb14de85f0ec4940c93252d0e3289a59d5bd
https://github.com/matcornic/hermes/blob/2f49bb14de85f0ec4940c93252d0e3289a59d5bd/examples/main.go#L136-L177
28,378
matcornic/hermes
hermes.go
ToHTML
func (c Markdown) ToHTML() template.HTML { return template.HTML(blackfriday.Run([]byte(string(c)))) }
go
func (c Markdown) ToHTML() template.HTML { return template.HTML(blackfriday.Run([]byte(string(c)))) }
[ "func", "(", "c", "Markdown", ")", "ToHTML", "(", ")", "template", ".", "HTML", "{", "return", "template", ".", "HTML", "(", "blackfriday", ".", "Run", "(", "[", "]", "byte", "(", "string", "(", "c", ")", ")", ")", ")", "\n", "}" ]
// ToHTML converts Markdown to HTML
[ "ToHTML", "converts", "Markdown", "to", "HTML" ]
2f49bb14de85f0ec4940c93252d0e3289a59d5bd
https://github.com/matcornic/hermes/blob/2f49bb14de85f0ec4940c93252d0e3289a59d5bd/hermes.go#L76-L78
28,379
matcornic/hermes
hermes.go
setDefaultHermesValues
func setDefaultHermesValues(h *Hermes) error { defaultTextDirection := TDLeftToRight defaultHermes := Hermes{ Theme: new(Default), TextDirection: defaultTextDirection, Product: Product{ Name: "Hermes", Copyright: "Copyright © 2019 Hermes. All rights reserved.", TroubleText: "If you’re ...
go
func setDefaultHermesValues(h *Hermes) error { defaultTextDirection := TDLeftToRight defaultHermes := Hermes{ Theme: new(Default), TextDirection: defaultTextDirection, Product: Product{ Name: "Hermes", Copyright: "Copyright © 2019 Hermes. All rights reserved.", TroubleText: "If you’re ...
[ "func", "setDefaultHermesValues", "(", "h", "*", "Hermes", ")", "error", "{", "defaultTextDirection", ":=", "TDLeftToRight", "\n", "defaultHermes", ":=", "Hermes", "{", "Theme", ":", "new", "(", "Default", ")", ",", "TextDirection", ":", "defaultTextDirection", ...
// default values of the engine
[ "default", "values", "of", "the", "engine" ]
2f49bb14de85f0ec4940c93252d0e3289a59d5bd
https://github.com/matcornic/hermes/blob/2f49bb14de85f0ec4940c93252d0e3289a59d5bd/hermes.go#L138-L159
28,380
matcornic/hermes
hermes.go
GenerateHTML
func (h *Hermes) GenerateHTML(email Email) (string, error) { err := setDefaultHermesValues(h) if err != nil { return "", err } return h.generateTemplate(email, h.Theme.HTMLTemplate()) }
go
func (h *Hermes) GenerateHTML(email Email) (string, error) { err := setDefaultHermesValues(h) if err != nil { return "", err } return h.generateTemplate(email, h.Theme.HTMLTemplate()) }
[ "func", "(", "h", "*", "Hermes", ")", "GenerateHTML", "(", "email", "Email", ")", "(", "string", ",", "error", ")", "{", "err", ":=", "setDefaultHermesValues", "(", "h", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\...
// GenerateHTML generates the email body from data to an HTML Reader // This is for modern email clients
[ "GenerateHTML", "generates", "the", "email", "body", "from", "data", "to", "an", "HTML", "Reader", "This", "is", "for", "modern", "email", "clients" ]
2f49bb14de85f0ec4940c93252d0e3289a59d5bd
https://github.com/matcornic/hermes/blob/2f49bb14de85f0ec4940c93252d0e3289a59d5bd/hermes.go#L163-L169
28,381
matcornic/hermes
hermes.go
GeneratePlainText
func (h *Hermes) GeneratePlainText(email Email) (string, error) { err := setDefaultHermesValues(h) if err != nil { return "", err } template, err := h.generateTemplate(email, h.Theme.PlainTextTemplate()) if err != nil { return "", err } return html2text.FromString(template, html2text.Options{PrettyTables: tr...
go
func (h *Hermes) GeneratePlainText(email Email) (string, error) { err := setDefaultHermesValues(h) if err != nil { return "", err } template, err := h.generateTemplate(email, h.Theme.PlainTextTemplate()) if err != nil { return "", err } return html2text.FromString(template, html2text.Options{PrettyTables: tr...
[ "func", "(", "h", "*", "Hermes", ")", "GeneratePlainText", "(", "email", "Email", ")", "(", "string", ",", "error", ")", "{", "err", ":=", "setDefaultHermesValues", "(", "h", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err",...
// GeneratePlainText generates the email body from data // This is for old email clients
[ "GeneratePlainText", "generates", "the", "email", "body", "from", "data", "This", "is", "for", "old", "email", "clients" ]
2f49bb14de85f0ec4940c93252d0e3289a59d5bd
https://github.com/matcornic/hermes/blob/2f49bb14de85f0ec4940c93252d0e3289a59d5bd/hermes.go#L173-L183
28,382
jordan-wright/email
pool.go
Send
func (p *Pool) Send(e *Email, timeout time.Duration) (err error) { start := time.Now() c := p.get(timeout) if c == nil { return p.failedToGet(start) } defer func() { p.maybeReplace(err, c) }() recipients, err := addressLists(e.To, e.Cc, e.Bcc) if err != nil { return } msg, err := e.Bytes() if err !=...
go
func (p *Pool) Send(e *Email, timeout time.Duration) (err error) { start := time.Now() c := p.get(timeout) if c == nil { return p.failedToGet(start) } defer func() { p.maybeReplace(err, c) }() recipients, err := addressLists(e.To, e.Cc, e.Bcc) if err != nil { return } msg, err := e.Bytes() if err !=...
[ "func", "(", "p", "*", "Pool", ")", "Send", "(", "e", "*", "Email", ",", "timeout", "time", ".", "Duration", ")", "(", "err", "error", ")", "{", "start", ":=", "time", ".", "Now", "(", ")", "\n", "c", ":=", "p", ".", "get", "(", "timeout", ")...
// Send sends an email via a connection pulled from the Pool. The timeout may // be <0 to indicate no timeout. Otherwise reaching the timeout will produce // and error building a connection that occurred while we were waiting, or // otherwise ErrTimeout.
[ "Send", "sends", "an", "email", "via", "a", "connection", "pulled", "from", "the", "Pool", ".", "The", "timeout", "may", "be", "<0", "to", "indicate", "no", "timeout", ".", "Otherwise", "reaching", "the", "timeout", "will", "produce", "and", "error", "buil...
3ea4d25e7cf84fe656d10353672a0eba4b919b6d
https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/pool.go#L266-L312
28,383
jordan-wright/email
pool.go
Close
func (p *Pool) Close() { close(p.closing) for p.created > 0 { c := <-p.clients c.Quit() p.dec() } }
go
func (p *Pool) Close() { close(p.closing) for p.created > 0 { c := <-p.clients c.Quit() p.dec() } }
[ "func", "(", "p", "*", "Pool", ")", "Close", "(", ")", "{", "close", "(", "p", ".", "closing", ")", "\n\n", "for", "p", ".", "created", ">", "0", "{", "c", ":=", "<-", "p", ".", "clients", "\n", "c", ".", "Quit", "(", ")", "\n", "p", ".", ...
// Close immediately changes the pool's state so no new connections will be // created, then gets and closes the existing ones as they become available.
[ "Close", "immediately", "changes", "the", "pool", "s", "state", "so", "no", "new", "connections", "will", "be", "created", "then", "gets", "and", "closes", "the", "existing", "ones", "as", "they", "become", "available", "." ]
3ea4d25e7cf84fe656d10353672a0eba4b919b6d
https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/pool.go#L344-L352
28,384
jordan-wright/email
email.go
Read
func (tr trimReader) Read(buf []byte) (int, error) { n, err := tr.rd.Read(buf) t := bytes.TrimLeftFunc(buf[:n], unicode.IsSpace) n = copy(buf, t) return n, err }
go
func (tr trimReader) Read(buf []byte) (int, error) { n, err := tr.rd.Read(buf) t := bytes.TrimLeftFunc(buf[:n], unicode.IsSpace) n = copy(buf, t) return n, err }
[ "func", "(", "tr", "trimReader", ")", "Read", "(", "buf", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "n", ",", "err", ":=", "tr", ".", "rd", ".", "Read", "(", "buf", ")", "\n", "t", ":=", "bytes", ".", "TrimLeftFunc", "(", "bu...
// Read trims off any unicode whitespace from the originating reader
[ "Read", "trims", "off", "any", "unicode", "whitespace", "from", "the", "originating", "reader" ]
3ea4d25e7cf84fe656d10353672a0eba4b919b6d
https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L74-L79
28,385
jordan-wright/email
email.go
NewEmailFromReader
func NewEmailFromReader(r io.Reader) (*Email, error) { e := NewEmail() s := trimReader{rd: r} tp := textproto.NewReader(bufio.NewReader(s)) // Parse the main headers hdrs, err := tp.ReadMIMEHeader() if err != nil { return e, err } // Set the subject, to, cc, bcc, and from for h, v := range hdrs { switch { ...
go
func NewEmailFromReader(r io.Reader) (*Email, error) { e := NewEmail() s := trimReader{rd: r} tp := textproto.NewReader(bufio.NewReader(s)) // Parse the main headers hdrs, err := tp.ReadMIMEHeader() if err != nil { return e, err } // Set the subject, to, cc, bcc, and from for h, v := range hdrs { switch { ...
[ "func", "NewEmailFromReader", "(", "r", "io", ".", "Reader", ")", "(", "*", "Email", ",", "error", ")", "{", "e", ":=", "NewEmail", "(", ")", "\n", "s", ":=", "trimReader", "{", "rd", ":", "r", "}", "\n", "tp", ":=", "textproto", ".", "NewReader", ...
// NewEmailFromReader reads a stream of bytes from an io.Reader, r, // and returns an email struct containing the parsed data. // This function expects the data in RFC 5322 format.
[ "NewEmailFromReader", "reads", "a", "stream", "of", "bytes", "from", "an", "io", ".", "Reader", "r", "and", "returns", "an", "email", "struct", "containing", "the", "parsed", "data", ".", "This", "function", "expects", "the", "data", "in", "RFC", "5322", "...
3ea4d25e7cf84fe656d10353672a0eba4b919b6d
https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L84-L136
28,386
jordan-wright/email
email.go
Attach
func (e *Email) Attach(r io.Reader, filename string, c string) (a *Attachment, err error) { var buffer bytes.Buffer if _, err = io.Copy(&buffer, r); err != nil { return } at := &Attachment{ Filename: filename, Header: textproto.MIMEHeader{}, Content: buffer.Bytes(), } // Get the Content-Type to be used...
go
func (e *Email) Attach(r io.Reader, filename string, c string) (a *Attachment, err error) { var buffer bytes.Buffer if _, err = io.Copy(&buffer, r); err != nil { return } at := &Attachment{ Filename: filename, Header: textproto.MIMEHeader{}, Content: buffer.Bytes(), } // Get the Content-Type to be used...
[ "func", "(", "e", "*", "Email", ")", "Attach", "(", "r", "io", ".", "Reader", ",", "filename", "string", ",", "c", "string", ")", "(", "a", "*", "Attachment", ",", "err", "error", ")", "{", "var", "buffer", "bytes", ".", "Buffer", "\n", "if", "_"...
// Attach is used to attach content from an io.Reader to the email. // Required parameters include an io.Reader, the desired filename for the attachment, and the Content-Type // The function will return the created Attachment for reference, as well as nil for the error, if successful.
[ "Attach", "is", "used", "to", "attach", "content", "from", "an", "io", ".", "Reader", "to", "the", "email", ".", "Required", "parameters", "include", "an", "io", ".", "Reader", "the", "desired", "filename", "for", "the", "attachment", "and", "the", "Conten...
3ea4d25e7cf84fe656d10353672a0eba4b919b6d
https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L209-L231
28,387
jordan-wright/email
email.go
AttachFile
func (e *Email) AttachFile(filename string) (a *Attachment, err error) { f, err := os.Open(filename) if err != nil { return } defer f.Close() ct := mime.TypeByExtension(filepath.Ext(filename)) basename := filepath.Base(filename) return e.Attach(f, basename, ct) }
go
func (e *Email) AttachFile(filename string) (a *Attachment, err error) { f, err := os.Open(filename) if err != nil { return } defer f.Close() ct := mime.TypeByExtension(filepath.Ext(filename)) basename := filepath.Base(filename) return e.Attach(f, basename, ct) }
[ "func", "(", "e", "*", "Email", ")", "AttachFile", "(", "filename", "string", ")", "(", "a", "*", "Attachment", ",", "err", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", ...
// AttachFile is used to attach content to the email. // It attempts to open the file referenced by filename and, if successful, creates an Attachment. // This Attachment is then appended to the slice of Email.Attachments. // The function will then return the Attachment for reference, as well as nil for the error, if s...
[ "AttachFile", "is", "used", "to", "attach", "content", "to", "the", "email", ".", "It", "attempts", "to", "open", "the", "file", "referenced", "by", "filename", "and", "if", "successful", "creates", "an", "Attachment", ".", "This", "Attachment", "is", "then"...
3ea4d25e7cf84fe656d10353672a0eba4b919b6d
https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L237-L247
28,388
jordan-wright/email
email.go
msgHeaders
func (e *Email) msgHeaders() (textproto.MIMEHeader, error) { res := make(textproto.MIMEHeader, len(e.Headers)+4) if e.Headers != nil { for _, h := range []string{"Reply-To", "To", "Cc", "From", "Subject", "Date", "Message-Id", "MIME-Version"} { if v, ok := e.Headers[h]; ok { res[h] = v } } } // Set he...
go
func (e *Email) msgHeaders() (textproto.MIMEHeader, error) { res := make(textproto.MIMEHeader, len(e.Headers)+4) if e.Headers != nil { for _, h := range []string{"Reply-To", "To", "Cc", "From", "Subject", "Date", "Message-Id", "MIME-Version"} { if v, ok := e.Headers[h]; ok { res[h] = v } } } // Set he...
[ "func", "(", "e", "*", "Email", ")", "msgHeaders", "(", ")", "(", "textproto", ".", "MIMEHeader", ",", "error", ")", "{", "res", ":=", "make", "(", "textproto", ".", "MIMEHeader", ",", "len", "(", "e", ".", "Headers", ")", "+", "4", ")", "\n", "i...
// msgHeaders merges the Email's various fields and custom headers together in a // standards compliant way to create a MIMEHeader to be used in the resulting // message. It does not alter e.Headers. // // "e"'s fields To, Cc, From, Subject will be used unless they are present in // e.Headers. Unless set in e.Headers, ...
[ "msgHeaders", "merges", "the", "Email", "s", "various", "fields", "and", "custom", "headers", "together", "in", "a", "standards", "compliant", "way", "to", "create", "a", "MIMEHeader", "to", "be", "used", "in", "the", "resulting", "message", ".", "It", "does...
3ea4d25e7cf84fe656d10353672a0eba4b919b6d
https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L255-L300
28,389
jordan-wright/email
email.go
parseSender
func (e *Email) parseSender() (string, error) { if e.Sender != "" { sender, err := mail.ParseAddress(e.Sender) if err != nil { return "", err } return sender.Address, nil } else { from, err := mail.ParseAddress(e.From) if err != nil { return "", err } return from.Address, nil } }
go
func (e *Email) parseSender() (string, error) { if e.Sender != "" { sender, err := mail.ParseAddress(e.Sender) if err != nil { return "", err } return sender.Address, nil } else { from, err := mail.ParseAddress(e.From) if err != nil { return "", err } return from.Address, nil } }
[ "func", "(", "e", "*", "Email", ")", "parseSender", "(", ")", "(", "string", ",", "error", ")", "{", "if", "e", ".", "Sender", "!=", "\"", "\"", "{", "sender", ",", "err", ":=", "mail", ".", "ParseAddress", "(", "e", ".", "Sender", ")", "\n", "...
// Select and parse an SMTP envelope sender address. Choose Email.Sender if set, or fallback to Email.From.
[ "Select", "and", "parse", "an", "SMTP", "envelope", "sender", "address", ".", "Choose", "Email", ".", "Sender", "if", "set", "or", "fallback", "to", "Email", ".", "From", "." ]
3ea4d25e7cf84fe656d10353672a0eba4b919b6d
https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L439-L453
28,390
jordan-wright/email
email.go
SendWithTLS
func (e *Email) SendWithTLS(addr string, a smtp.Auth, t *tls.Config) error { // Merge the To, Cc, and Bcc fields to := make([]string, 0, len(e.To)+len(e.Cc)+len(e.Bcc)) to = append(append(append(to, e.To...), e.Cc...), e.Bcc...) for i := 0; i < len(to); i++ { addr, err := mail.ParseAddress(to[i]) if err != nil ...
go
func (e *Email) SendWithTLS(addr string, a smtp.Auth, t *tls.Config) error { // Merge the To, Cc, and Bcc fields to := make([]string, 0, len(e.To)+len(e.Cc)+len(e.Bcc)) to = append(append(append(to, e.To...), e.Cc...), e.Bcc...) for i := 0; i < len(to); i++ { addr, err := mail.ParseAddress(to[i]) if err != nil ...
[ "func", "(", "e", "*", "Email", ")", "SendWithTLS", "(", "addr", "string", ",", "a", "smtp", ".", "Auth", ",", "t", "*", "tls", ".", "Config", ")", "error", "{", "// Merge the To, Cc, and Bcc fields", "to", ":=", "make", "(", "[", "]", "string", ",", ...
// SendWithTLS sends an email with an optional TLS config. // This is helpful if you need to connect to a host that is used an untrusted // certificate.
[ "SendWithTLS", "sends", "an", "email", "with", "an", "optional", "TLS", "config", ".", "This", "is", "helpful", "if", "you", "need", "to", "connect", "to", "a", "host", "that", "is", "used", "an", "untrusted", "certificate", "." ]
3ea4d25e7cf84fe656d10353672a0eba4b919b6d
https://github.com/jordan-wright/email/blob/3ea4d25e7cf84fe656d10353672a0eba4b919b6d/email.go#L458-L530
28,391
kata-containers/agent
namespace.go
setupPersistentNs
func setupPersistentNs(namespaceType nsType) (*namespace, error) { err := os.MkdirAll(persistentNsDir, 0755) if err != nil { return nil, err } // Create an empty file at the mount point. nsPath := filepath.Join(persistentNsDir, string(namespaceType)) mountFd, err := os.Create(nsPath) if err != nil { retur...
go
func setupPersistentNs(namespaceType nsType) (*namespace, error) { err := os.MkdirAll(persistentNsDir, 0755) if err != nil { return nil, err } // Create an empty file at the mount point. nsPath := filepath.Join(persistentNsDir, string(namespaceType)) mountFd, err := os.Create(nsPath) if err != nil { retur...
[ "func", "setupPersistentNs", "(", "namespaceType", "nsType", ")", "(", "*", "namespace", ",", "error", ")", "{", "err", ":=", "os", ".", "MkdirAll", "(", "persistentNsDir", ",", "0755", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "e...
// setupPersistentNs creates persistent namespace without switchin to it. // Note, pid namespaces cannot be persisted.
[ "setupPersistentNs", "creates", "persistent", "namespace", "without", "switchin", "to", "it", ".", "Note", "pid", "namespaces", "cannot", "be", "persisted", "." ]
629f90f9ff2065509d46192325e6409bdaacef79
https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/namespace.go#L49-L106
28,392
kata-containers/agent
protocols/mockserver/mockserver.go
NewMockServer
func NewMockServer() *grpc.Server { mock := &mockServer{} serv := grpc.NewServer() pb.RegisterAgentServiceServer(serv, mock) pb.RegisterHealthServer(serv, mock) return serv }
go
func NewMockServer() *grpc.Server { mock := &mockServer{} serv := grpc.NewServer() pb.RegisterAgentServiceServer(serv, mock) pb.RegisterHealthServer(serv, mock) return serv }
[ "func", "NewMockServer", "(", ")", "*", "grpc", ".", "Server", "{", "mock", ":=", "&", "mockServer", "{", "}", "\n", "serv", ":=", "grpc", ".", "NewServer", "(", ")", "\n", "pb", ".", "RegisterAgentServiceServer", "(", "serv", ",", "mock", ")", "\n", ...
// NewMockServer creates a new gRPC server
[ "NewMockServer", "creates", "a", "new", "gRPC", "server" ]
629f90f9ff2065509d46192325e6409bdaacef79
https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/mockserver/mockserver.go#L51-L58
28,393
kata-containers/agent
cgroup.go
getAvailableCpusetList
func getAvailableCpusetList(cpusetReq string) (string, error) { cpusetGuest, err := getCpusetGuest() if err != nil { return "", err } cpusetListReq, err := parsers.ParseUintList(cpusetReq) if err != nil { return "", err } cpusetGuestList, err := parsers.ParseUintList(cpusetGuest) if err != nil { return...
go
func getAvailableCpusetList(cpusetReq string) (string, error) { cpusetGuest, err := getCpusetGuest() if err != nil { return "", err } cpusetListReq, err := parsers.ParseUintList(cpusetReq) if err != nil { return "", err } cpusetGuestList, err := parsers.ParseUintList(cpusetGuest) if err != nil { return...
[ "func", "getAvailableCpusetList", "(", "cpusetReq", "string", ")", "(", "string", ",", "error", ")", "{", "cpusetGuest", ",", "err", ":=", "getCpusetGuest", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n...
// Return the best match for cpuset list in the guest. // The runtime caller may apply cpuset for specific CPUs in the host. // The CPUs may not exist on the guest as they are hotplugged based // on cpu and qouta. // This function return a working cpuset to apply on the guest.
[ "Return", "the", "best", "match", "for", "cpuset", "list", "in", "the", "guest", ".", "The", "runtime", "caller", "may", "apply", "cpuset", "for", "specific", "CPUs", "in", "the", "host", ".", "The", "CPUs", "may", "not", "exist", "on", "the", "guest", ...
629f90f9ff2065509d46192325e6409bdaacef79
https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/cgroup.go#L32-L65
28,394
kata-containers/agent
protocols/grpc/utils.go
OCItoGRPC
func OCItoGRPC(ociSpec *specs.Spec) (*Spec, error) { s := &Spec{} err := copyStruct(s, ociSpec) return s, err }
go
func OCItoGRPC(ociSpec *specs.Spec) (*Spec, error) { s := &Spec{} err := copyStruct(s, ociSpec) return s, err }
[ "func", "OCItoGRPC", "(", "ociSpec", "*", "specs", ".", "Spec", ")", "(", "*", "Spec", ",", "error", ")", "{", "s", ":=", "&", "Spec", "{", "}", "\n\n", "err", ":=", "copyStruct", "(", "s", ",", "ociSpec", ")", "\n\n", "return", "s", ",", "err", ...
// OCItoGRPC converts an OCI specification to its gRPC representation
[ "OCItoGRPC", "converts", "an", "OCI", "specification", "to", "its", "gRPC", "representation" ]
629f90f9ff2065509d46192325e6409bdaacef79
https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L234-L240
28,395
kata-containers/agent
protocols/grpc/utils.go
GRPCtoOCI
func GRPCtoOCI(grpcSpec *Spec) (*specs.Spec, error) { s := &specs.Spec{} err := copyStruct(s, grpcSpec) return s, err }
go
func GRPCtoOCI(grpcSpec *Spec) (*specs.Spec, error) { s := &specs.Spec{} err := copyStruct(s, grpcSpec) return s, err }
[ "func", "GRPCtoOCI", "(", "grpcSpec", "*", "Spec", ")", "(", "*", "specs", ".", "Spec", ",", "error", ")", "{", "s", ":=", "&", "specs", ".", "Spec", "{", "}", "\n\n", "err", ":=", "copyStruct", "(", "s", ",", "grpcSpec", ")", "\n\n", "return", "...
// GRPCtoOCI converts a gRPC specification back into an OCI representation
[ "GRPCtoOCI", "converts", "a", "gRPC", "specification", "back", "into", "an", "OCI", "representation" ]
629f90f9ff2065509d46192325e6409bdaacef79
https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L243-L249
28,396
kata-containers/agent
protocols/grpc/utils.go
ProcessOCItoGRPC
func ProcessOCItoGRPC(ociProcess *specs.Process) (*Process, error) { s := &Process{} err := copyStruct(s, ociProcess) return s, err }
go
func ProcessOCItoGRPC(ociProcess *specs.Process) (*Process, error) { s := &Process{} err := copyStruct(s, ociProcess) return s, err }
[ "func", "ProcessOCItoGRPC", "(", "ociProcess", "*", "specs", ".", "Process", ")", "(", "*", "Process", ",", "error", ")", "{", "s", ":=", "&", "Process", "{", "}", "\n\n", "err", ":=", "copyStruct", "(", "s", ",", "ociProcess", ")", "\n\n", "return", ...
// ProcessOCItoGRPC converts an OCI process specification into its gRPC // representation
[ "ProcessOCItoGRPC", "converts", "an", "OCI", "process", "specification", "into", "its", "gRPC", "representation" ]
629f90f9ff2065509d46192325e6409bdaacef79
https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L253-L259
28,397
kata-containers/agent
protocols/grpc/utils.go
ProcessGRPCtoOCI
func ProcessGRPCtoOCI(grpcProcess *Process) (*specs.Process, error) { s := &specs.Process{} err := copyStruct(s, grpcProcess) return s, err }
go
func ProcessGRPCtoOCI(grpcProcess *Process) (*specs.Process, error) { s := &specs.Process{} err := copyStruct(s, grpcProcess) return s, err }
[ "func", "ProcessGRPCtoOCI", "(", "grpcProcess", "*", "Process", ")", "(", "*", "specs", ".", "Process", ",", "error", ")", "{", "s", ":=", "&", "specs", ".", "Process", "{", "}", "\n\n", "err", ":=", "copyStruct", "(", "s", ",", "grpcProcess", ")", "...
// ProcessGRPCtoOCI converts a gRPC specification back into an OCI // representation
[ "ProcessGRPCtoOCI", "converts", "a", "gRPC", "specification", "back", "into", "an", "OCI", "representation" ]
629f90f9ff2065509d46192325e6409bdaacef79
https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L263-L269
28,398
kata-containers/agent
protocols/grpc/utils.go
ResourcesOCItoGRPC
func ResourcesOCItoGRPC(ociResources *specs.LinuxResources) (*LinuxResources, error) { s := &LinuxResources{} err := copyStruct(s, ociResources) return s, err }
go
func ResourcesOCItoGRPC(ociResources *specs.LinuxResources) (*LinuxResources, error) { s := &LinuxResources{} err := copyStruct(s, ociResources) return s, err }
[ "func", "ResourcesOCItoGRPC", "(", "ociResources", "*", "specs", ".", "LinuxResources", ")", "(", "*", "LinuxResources", ",", "error", ")", "{", "s", ":=", "&", "LinuxResources", "{", "}", "\n\n", "err", ":=", "copyStruct", "(", "s", ",", "ociResources", "...
// ResourcesOCItoGRPC converts an OCI LinuxResources specification into its gRPC // representation
[ "ResourcesOCItoGRPC", "converts", "an", "OCI", "LinuxResources", "specification", "into", "its", "gRPC", "representation" ]
629f90f9ff2065509d46192325e6409bdaacef79
https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L273-L279
28,399
kata-containers/agent
protocols/grpc/utils.go
ResourcesGRPCtoOCI
func ResourcesGRPCtoOCI(grpcResources *LinuxResources) (*specs.LinuxResources, error) { s := &specs.LinuxResources{} err := copyStruct(s, grpcResources) return s, err }
go
func ResourcesGRPCtoOCI(grpcResources *LinuxResources) (*specs.LinuxResources, error) { s := &specs.LinuxResources{} err := copyStruct(s, grpcResources) return s, err }
[ "func", "ResourcesGRPCtoOCI", "(", "grpcResources", "*", "LinuxResources", ")", "(", "*", "specs", ".", "LinuxResources", ",", "error", ")", "{", "s", ":=", "&", "specs", ".", "LinuxResources", "{", "}", "\n\n", "err", ":=", "copyStruct", "(", "s", ",", ...
// ResourcesGRPCtoOCI converts an gRPC LinuxResources specification into its OCI // representation
[ "ResourcesGRPCtoOCI", "converts", "an", "gRPC", "LinuxResources", "specification", "into", "its", "OCI", "representation" ]
629f90f9ff2065509d46192325e6409bdaacef79
https://github.com/kata-containers/agent/blob/629f90f9ff2065509d46192325e6409bdaacef79/protocols/grpc/utils.go#L283-L289