Dependencies and generated code

Go dependency management

We use Go modules to manage Go dependencies in this repository.

Codegen

The Sourcegraph repository relies on code generation triggered by go generate. Code generation is used for a variety of tasks:

  • generating code for mocking interfaces
  • generate wrappers for interfaces (e.g., ./server/internal/middleware/* packages)
  • pack app templates and assets into binaries

To generate everything, just run:

sg generate

Note: Sometimes, there are erroneous diffs. This occurs for a fewreasons, none of which are legitimate (i.e., they are tech debt itemswe need to address):

  • The codegen tools might emit code that depends on system configuration,such as the system timezone or packages you have in your GOPATH. Weneed to submit PRs to the tools to eliminate these issues.
  • You might have existing but gitignored files that the codegen toolsread on your disk that other developers don't have. (This occurs forapp assets especially.)

If you think a diff is erroneous, don't commit it. Add a tech debtitem to the issue tracker and assign the person who you think isresponsible (or ask).