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
13 files changed
tree: 708a63ce5c761180939a4f68a5167b514f92cc20
  1. build/
  2. cmd/
  3. ctags/
  4. doc/
  5. gitindex/
  6. query/
  7. shards/
  8. web/
  9. .gitignore
  10. all.bash
  11. api.go
  12. bits.go
  13. bits_test.go
  14. build-deploy.sh
  15. contentprovider.go
  16. CONTRIBUTING
  17. eval.go
  18. go.mod
  19. go.sum
  20. hititer.go
  21. index_test.go
  22. indexbuilder.go
  23. indexdata.go
  24. indexfile.go
  25. indexfile_linux.go
  26. LICENSE
  27. matchiter.go
  28. matchtree.go
  29. read.go
  30. read_test.go
  31. README.md
  32. section.go
  33. section_test.go
  34. toc.go
  35. write.go
README.md
"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)

INSTRUCTIONS

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

SEARCH SERVICE

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.

SYMBOL SEARCH

It is recommended to install Universal ctags to improve ranking. See here for more information.

ACKNOWLEDGEMENTS

Thanks to Alexander Neubeck for coming up with this idea, and helping me flesh it out.

DISCLAIMER

This is not an official Google product