Go, Wasm, & Bazel: A Blueprint for Hermetic, High-Performance Web Applications

11th November 2025

Rajiv Ranjan Singh

Naman Lakhwani

Agenda

2

Speaker - Rajiv Ranjan Singh

3

Speaker - Naman Lakhwani

4

What is WebAssembly?

5

Go and WebAssembly

6

Challenges with Go and WebAssembly

7

Solution with Bazel

8

Advantages of Bazel Builds over go build

9

Migration from go build to Bazel

Three files to create:

  1. MODULE.bazel - Downloads exact Go version
  2. BUILD.bazel - Defines build targets
  3. main.go - Your Go code (unchanged)

Keep: Your existing go.mod file

10

Migration from go build to Bazel

  1. MODULE.bazel
module(
    name = "bazelcon-2025",
    version = "1.0.0",
)

# Bazel dependencies
bazel_dep(name = "rules_go", version = "0.50.1")
bazel_dep(name = "gazelle", version = "0.39.1")

# Go SDK setup
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.23.4")

# Go dependencies
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps)
11

Migration from go build to Bazel

  1. BUILD.bazel
12

Migration from go build to Bazel

  1. main.go
package main

import (
    "fmt"
    "runtime"
)

func main() {
    fmt.Println("Hello, Bazel, WASM, and Go!")
    fmt.Printf("GOOS: %s, GOARCH: %s\n", runtime.GOOS, runtime.GOARCH)
}
13

Step 4: Build and Run

Build:

bazel build //:app
bazel build //:app-wasm

Run native:

$ ./bazel-bin/app_/app
Hello, Bazel, WASM, and Go!
GOOS: darwin, GOARCH: arm64

Run WASM:

$ wasmtime ./bazel-bin/app-wasm_/app-wasm
Hello, Bazel, WASM, and Go!
GOOS: wasip1, GOARCH: wasm
14

Future of Go and WebAssembly with Bazel

15

References

16

Thank you

Rajiv Ranjan Singh

Naman Lakhwani

Use the left and right arrow keys or click the left and right edges of the page to navigate between slides.
(Press 'H' or navigate to hide this message.)