commit | 71eea242eecd3aa3af071967b3131a09e8e1a999 | [log] [tgz] |
---|---|---|
author | Keegan Carruthers-Smith <keegan.csmith@gmail.com> | Thu Nov 22 09:50:38 2018 +0200 |
committer | Han-Wen Nienhuys <hanwen@google.com> | Mon Dec 10 13:13:05 2018 +0000 |
tree | 708a63ce5c761180939a4f68a5167b514f92cc20 | |
parent | 9a634bb6f68d03c44475617e0aedfc55cf63a730 [diff] |
all: Resolve staticcheck failures In quite a few cases err was never used. I have just made it explicit that we don't check it, rather than handling the error. You may want to follow up and do the correct behaviour. > staticcheck -ignore '*:ST*' ./... build/e2e_test.go:163:3: the surrounding loop is unconditionally terminated (SA4004) cmd/zoekt-mirror-github/main.go:75:26: oauth2.NoContext is deprecated: Use context.Background() or context.TODO() instead. (SA1019) cmd/zoekt-mirror-github/main.go:184:18: this result of append is never used, except maybe in other appends (SA4010) cmd/zoekt-mirror-github/main.go:210:18: this result of append is never used, except maybe in other appends (SA4010) cmd/zoekt-repo-index/main.go:278:3: should replace loop with doc.Branches = append(doc.Branches, branches...) (S1011) cmd/zoekt-repo-index/main.go:322:11: this value of err is never used (SA4006) cmd/zoekt-webserver/main.go:242:6: should omit values from range; this loop is equivalent to `for range ...` (S1005) cmd/zoekt/main.go:120:10: this value of err is never used (SA4006) cmd/zoekt/main.go:121:7: should use time.Since instead of time.Now().Sub (S1012) ctags/json.go:96:5: should use bytes.Equal([]byte("(null)"), p.out.Bytes()) instead (S1004) gitindex/index.go:80:65: argument err is overwritten before first use (SA4009) gitindex/tree_test.go:100:9: this value of err is never used (SA4006) gitindex/tree_test.go:161:2: should merge variable declaration with assignment on next line (S1021) gitindex/tree_test.go:166:12: should use !bytes.Equal(bnameHash[:], entry.Hash[:]) instead (S1004) index_test.go:1200:52: should use !bytes.Equal(l, content) instead (S1004) matchiter.go:45:11: should use bytes.Equal(m.substrBytes, content[m.byteOffset : m.byteOffset+uint32(len(m.substrBytes))]) instead (S1004) shards/shards.go:140:19: should use time.Since instead of time.Now().Sub (S1012) shards/shards.go:210:23: should use time.Since instead of time.Now().Sub (S1012) shards/shards_test.go:209:6: should use bytes.Contains(f.Content, []byte{forbidden}) instead (S1003) shards/shards_test.go:212:6: should use bytes.Contains(f.Checksum, []byte{forbidden}) instead (S1003) shards/shards_test.go:217:7: should use bytes.Contains(l.Line, []byte{forbidden}) instead (S1003) web/server.go:299:5: should use time.Since instead of time.Now().Sub (S1012) web/server.go:341:12: should use time.Since instead of time.Now().Sub (S1012) web/server.go:380:12: should use time.Since instead of time.Now().Sub (S1012) Change-Id: I71e6a9af1963d1e23b05fe7d50036676f551a865
"Zoekt, en gij zult spinazie eten" - Jan Eertink ("seek, and ye shall eat spinach" - My primary school teacher)
This is a fast text search engine, intended for use with source code. (Pronunciation: roughly as you would pronounce “zooked” in English)
Downloading:
go get github.com/google/zoekt/
Indexing:
go install github.com/google/zoekt/cmd/zoekt-index $GOPATH/bin/zoekt-index .
Searching
go install github.com/google/zoekt/cmd/zoekt $GOPATH/bin/zoekt 'ngram f:READ'
Indexing git repositories:
go install github.com/google/zoekt/cmd/zoekt-git-index $GOPATH/bin/zoekt-git-index -branches master,stable-1.4 -prefix origin/ .
Indexing repo repositories:
go install github.com/google/zoekt/cmd/zoekt-{repo-index,mirror-gitiles} zoekt-mirror-gitiles -dest ~/repos/ https://gfiber.googlesource.com zoekt-repo-index \ -name gfiber \ -base_url https://gfiber.googlesource.com/ \ -manifest_repo ~/repos/gfiber.googlesource.com/manifests.git \ -repo_cache ~/repos \ -manifest_rev_prefix=refs/heads/ --rev_prefix= \ master:default_unrestricted.xml
Starting the web interface
go install github.com/google/zoekt/cmd/zoekt-webserver $GOPATH/bin/zoekt-webserver -listen :6070
A more organized installation on a Linux server should use a systemd unit file, eg.
[Unit] Description=zoekt webserver [Service] ExecStart=/zoekt/bin/zoekt-webserver -index /zoekt/index -listen :443 --ssl_cert /zoekt/etc/cert.pem --ssl_key /zoekt/etc/key.pem Restart=always [Install] WantedBy=default.target
Zoekt comes with a small service management program:
go install github.com/google/zoekt/cmd/zoekt-indexserver cat << EOF > config.json [{"GithubUser": "username"}, {"GitilesURL": "https://gerrit.googlesource.com", "Name": "zoekt" } ] EOF $GOPATH/bin/zoekt-server -mirror_config config.json
This will mirror all repos under ‘github.com/username’ as well as the ‘zoekt’ repository. It will index the repositories.
It takes care of fetching and indexing new data and cleaning up logfiles.
The webserver can be started from a standard service management framework, such as systemd.
It is recommended to install Universal ctags to improve ranking. See here for more information.
Thanks to Alexander Neubeck for coming up with this idea, and helping me flesh it out.
This is not an official Google product