learn-bazel

Repository Archived

Repository moved to https://github.com/wissensalt/golang-bazel-monorepo

This project is a tutorial on using Bazel for building and managing Go projects. It provides step-by-step instructions on installing the necessary dependencies, such as Golang, Bazel, Bazelisk, and Gazelle. The README also includes commands for building and running the binary for different applications within the project. Additionally, it recommends installing Go Version Manager for managing different versions of Go. The tutorial aims to help developers understand and utilize Bazel effectively in their Go projects.

Deps:

Install Bazel

brew install bazel

Install Bazelisk

go get github.com/bazelbuild/bazelisk

Install Gazelle

go get github.com/bazelbuild/bazel-gazelle

Build Binary

  bazel build //...

build.png

Run Binary for app-one

  bazel run //apps/app-one

run-app-one.png

Run Binary for app-two

  bazel run //apps/app-two

run-app-two.png

Add Dependencies for app-one

cd apps/app-one
go get <dependency>
cd ../../
bazel run //:gazelle-update-repo-one
bazel build //...

gazelle-update-repo

Issues

If you find any issue, and it is taking too much time to resolve, run following command to clean all bazel generated files and caches

bazel clean --expunge

Recommendations

  bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)