blob: 1d4cbe9458c1ad6bff74737ef6c084820ec53190 [file] [log] [blame] [view]
Serge Bazanskibb7db922020-04-30 12:43:10 +02001Go dependency managment
2=======================
3
Serge Bazanskiee4bfdb2022-04-06 15:30:52 +02004Status: managed by [Gazelle](https://github.com/bazelbuild/bazel-gazelle).
Serge Bazanskibb7db922020-04-30 12:43:10 +02005
Serge Bazanskiee4bfdb2022-04-06 15:30:52 +02006
7 .--------.
8 | go.mod |------------.
9 '--------' |
Tim Windelschmidte5e90a82024-07-17 23:46:22 +020010 | go mod tidy |
Serge Bazanskiee4bfdb2022-04-06 15:30:52 +020011 V |
12 .--------. |
13 | go.sum |-----------.|
14 '--------' |
Serge Bazanskiee4bfdb2022-04-06 15:30:52 +020015 | bazel run //:gazelle
16 V
17 .----------------.
18 | **/BUILD.bazel |.
19 '----------------'|
20 '----------------'
21 | bazel build //...
22 V
23 .-----------------.
24 | build artifacts |
25 '-----------------'
26
27Updating and adding new dependencies
28------------------------------------
29
30Add a Go dependency to your code, then:
31
32 $ go mod tidy
Serge Bazanskiee4bfdb2022-04-06 15:30:52 +020033
Serge Bazanskifdc3a242022-04-06 15:56:38 +020034All generated sources (eg. protobuf stubs) that are usually built by Bazel are invisible to go(mod)-based tooling. To get around this, we place `gomod-generated-placeholder.go` files in package directories that would otherwise contain generated files. These are ignored by Gazelle (and thus by Bazel builds) but not by go(mod)-based tooling.
Serge Bazanskiee4bfdb2022-04-06 15:30:52 +020035
36Regenerating BUILDfiles
37-----------------------
38
39 $ bazel run //:gazelle