Go is gaining momentum, with projects that have large codebases in older languages like C looking to it to provide a modern, productive development experience without sacrificing performance. However, Go apps tend to be written in Go - while cgo exists to reuse libraries written in languages like C, which introduces limitations such as requiring a C toolchain for building, the possibility for incompatibilities with different libc versions, and limited platform/cross-compilation support. Indeed, many popular Go applications are built with cgo disabled to ensure broad usability.
Luckily, many native libraries can be compiled to WebAssembly and run with the pure Go WebAssembly runtime, wazero. This means the code can be compiled once with no external dependencies like libc, and executed in any Go application, regardless of cgo support. This presentation will give an overview of what WebAssembly is, how to compile legacy codebases into WebAssembly for use in Go, and will present some case studies of a few libraries, with insights into tradeoffs of wrapping vs rewriting. At the end of the presentation, you’ll be able to tell your colleagues, still hesitant about jumping from C to Go, that they can try it out without losing access to their existing code.
From GopherCon 2023: https://www.gophercon.com/agenda/speakers/3058151