raylib-go is a free, open source gaming project written in C and released under Zlib. It has 2,553 GitHub stars, 210 forks and 8 open issues, and was last pushed 2 months ago. On this registry it ranks #48 of 67 tracked projects in Gaming, with 5 head-to-head comparisons available.

What is raylib-go?

raylib-go is a set of Go bindings for raylib, the small C library for enjoying videogames programming, intended for Go developers who want to build 2D and 3D games, graphical tools and experiments in Go without hand-writing cgo glue.

What it is

raylib-go wraps raylib's API in an importable Go package, github.com/gen2brain/raylib-go/raylib, conventionally imported as rl. The raylib C source code is included in the repository and compiled together with the bindings, so the package does not depend on a separately installed system copy of raylib. The project lives on GitHub at gen2brain/raylib-go under the Miscellaneous / Gaming category, carries the Zlib licence, and is tagged with the topics android, game-engine, golang, raylib, rpi and video-game. Documentation is published on GoDoc alongside badges for build status, Go Report Card and the examples directory.

The concrete problem it solves is the boundary between Go and C. raylib is a C library, so a Go programmer who wants a window, a render loop, input handling or audio either writes cgo bindings by hand or drives the C API through manual glue. raylib-go supplies that layer as a maintained Go module that follows the upstream C API, and it also offers a route that avoids cgo entirely, so the same package works in projects built with CGO_ENABLED=0.

Key capabilities

  • The core window and drawing loop is exposed as Go functions, as in the README example: rl.InitWindow, rl.SetTargetFPS(60), rl.BeginDrawing, rl.ClearBackground, rl.DrawText and rl.WindowShouldClose.
  • The raylib C source is vendored and compiled with the bindings; the README notes that the first build can take a few minutes.
  • A purego mode without cgo works on Linux, macOS, Windows and FreeBSD, with raylib shared libraries (.dll, .so, .dylib) already embedded for Linux, macOS and Windows on arm64 and amd64; 32-bit is not supported.
  • Embedding can be turned off with the build tag raylib_no_embed or the environment variable RAYLIB_NO_EMBED=1.
  • Backends and GL versions are chosen with build tags: sdl, sdl3, rgfw, drm (Linux native DRM, including Raspberry Pi 4), x11, wayland, noaudio, opengl43, opengl21, opengl11, es2 and experimental es3.
  • Reference material includes GoDoc documentation, the raylib cheatsheet linked from the README, and a browsable examples tree.
  • Platform samples cover Android (examples/others/android/example), and web bindings are available through the separate Raylib-Go-Wasm project, described as largely compatible with this repository.

Who uses it and how

  • Go developers building small games, prototypes and graphical tools that should stay inside ordinary Go modules and go build workflows.
  • Embedded and single-board targets: the drm tag builds for Linux native DRM mode, explicitly including Raspberry Pi 4 and similar devices.
  • Linux desktop users who need to pin a display stack, choosing x11 or wayland under the GLFW backend, or swapping to an sdl, sdl3 or rgfw backend.
  • Projects that need to run without a C toolchain, using the purego path on Linux, macOS, Windows or FreeBSD, and projects that need audio disabled via noaudio.
  • Android builds following the in-repository example, and browser targets that delegate to Raylib-Go-Wasm.

Getting started

Install with go get -v -u github.com/gen2brain/raylib-go/raylib. For cgo builds, install the platform prerequisites first: the GL, X11, Xcursor, Xrandr, Xinerama, Wayland and xkbcommon development packages on Ubuntu or Fedora, Xcode or Command Line Tools on macOS, and a C compiler such as Mingw-w64 or TDM-GCC on Windows.

How it compares

Among the projects the facts name, raylib-go is a binding rather than an engine of its own: it sits directly on top of the raylib C library and tracks its API, so the choice is less about features than about whether raylib's model fits. For browser output the facts point to Raylib-Go-Wasm as a related but separate project, described as largely compatible with this repository.

When to use it — and when not to

A self-hoster or team adopting it must operate a Go toolchain plus, on the cgo path, a C compiler and the platform graphics and windowing development packages; the purego path removes the compiler but not the architecture limits, since 32-bit is unsupported there. It is a poor fit for anyone expecting a full engine with an editor or scene tooling, and the es3 backend is flagged as experimental. The honest caveats are modest: the first build compiles raylib from source and can take several minutes, and web export requires a different repository rather than this one.

project readme (upstream, from github) — read inline

logo

raylib-go

Build Status GoDoc Go Report Card Examples

Golang bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

raylib C source code is included and compiled together with bindings. Note that the first build can take a few minutes.

It is also possible to use raylib-go without cgo (see requirements below).

Requirements

cgo
Ubuntu
apt-get install libgl1-mesa-dev libxi-dev libxcursor-dev libxrandr-dev libxinerama-dev libwayland-dev libxkbcommon-dev
Fedora
dnf install mesa-libGL-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel wayland-devel libxkbcommon-devel
macOS

On macOS, you need Xcode or Command Line Tools for Xcode (if you have brew installed, you already have this).

Windows

On Windows you need C compiler, like Mingw-w64 or TDM-GCC. You can also build binary in MSYS2 shell.

To remove console window, build with -ldflags "-H=windowsgui".

Android

Android example.

Wasm

For web bindings, refer to Raylib-Go-Wasm; it should be largely compatible with this repository.

purego (without cgo, i.e. CGO_ENABLED=0)

You can use raylib-go on Linux, macOS, Windows and FreeBSD without the need of cgo. 32-bit is not supported.

The shared libraries (.dll, .so, .dylib) of raylib are already embedded for Linux arm64/amd64, macOS arm64/amd64 and Windows arm64/amd64. The build tag raylib_no_embed or the environment variable RAYLIB_NO_EMBED=1 can disable this feature.

Installation

go get -v -u github.com/gen2brain/raylib-go/raylib

Build tags

  • drm - build for Linux native DRM mode, including Raspberry Pi 4 and other devices (PLATFORM_DRM)
  • sdl - build for SDL backend (PLATFORM_DESKTOP_SDL)
  • sdl3 - build for SDL3 backend (PLATFORM_DESKTOP_SDL3)
  • rgfw - build for RGFW backend (PLATFORM_DESKTOP_RGFW)
  • noaudio - disables audio functions
  • opengl43 - uses OpenGL 4.3 backend
  • opengl21 - uses OpenGL 2.1 backend (default is 3.3 on desktop)
  • opengl11 - uses OpenGL 1.1 backend (pseudo OpenGL 1.1 style)
  • es2 - uses OpenGL ES 2.0 backend (can be used to link against Google's ANGLE)
  • es3 - experimental support for OpenGL ES 3.0
  • x11 - force X11 compatibility mode on Wayland (PLATFORM_DESKTOP/GLFW)
  • wayland - force Wayland only mode (PLATFORM_DESKTOP/GLFW)
  • raylib_no_embed - doesn't embed the pre-build shared libraries (only applies to purego version)

Documentation

Documentation on GoDoc. Also check raylib cheatsheet. If you have problems or need assistance there is an active community in the #raylib-go channel of the Raylib Discord Server that can help.

Example

package main

import rl "github.com/gen2brain/raylib-go/raylib"

func main() {
  rl.InitWindow(800, 450, "raylib [core] example - basic window")
  defer rl.CloseWindow()

  rl.SetTargetFPS(60)

  for !rl.WindowShouldClose() {
    rl.BeginDrawing()

    rl.ClearBackground(rl.RayWhite)
    rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LightGray)

    rl.EndDrawing()
  }
}

Check more examples organized by raylib modules.

Cross-compile (on Linux with cgo)

To cross-compile for Windows install MinGW toolchain.

$ CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -ldflags "-s -w"
$ file basic_window.exe
basic_window.exe: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows, 11 sections

$ CGO_ENABLED=1 CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build -ldflags "-s -w"
$ file basic_window.exe
basic_window.exe: PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows, 9 sections

To cross-compile for macOS install OSXCross toolchain.

$ CGO_ENABLED=1 CC=x86_64-apple-darwin21.1-clang GOOS=darwin GOARCH=amd64 go build -ldflags "-linkmode external -s -w '-extldflags=-mmacosx-version-min=10.15'"
$ file basic_window
basic_window: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL>

$ CGO_ENABLED=1 CC=aarch64-apple-darwin21.1-clang GOOS=darwin GOARCH=arm64 go build -ldflags "-linkmode external -s -w '-extldflags=-mmacosx-version-min=12.0.0'"
$ file basic_window
basic_window: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>

License

raylib-go is licensed under an unmodified zlib/libpng license. View LICENSE.

Frequently asked questions

Is raylib-go free to use?

raylib-go is open source under the Zlib licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does raylib-go do?

Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

What is raylib-go written in?

raylib-go is primarily written in C. Its source is publicly available at https://github.com/gen2brain/raylib-go, and it has 2,553 GitHub stars.