Get Setup
This is a post in the
go_games series.
Other posts in this series:
- Jan 30, 2025 - Get Setup
Intro
This tutorial we will setup your Raylib-go dev environment and create a project which will produce a blank window. Then we continue in this series building on this project until we complete our first Raylib go game.
You can scroll down on awesome-go to the contents and find and click on game development or click this link
You can follow along on this tutorial and at the bottom of this post there are a few useful links including [A Video series to build a Animal Crossing style game] (https://www.youtube.com/watch?v=iWp-mCIQgMU&list=PLVotA8ycjnCsy30WQCwVU5RrZkt4lLgY5&index=1)
Install Go & Git
- Go to GO.DEV downloads follow the instructions to download and install for your system.
- get Git from Git-scm.com downloads
- install VSCode with the Go extension - you need to search for the extension from within the vscode application
then create the go/src/ folder from the terminal (windows users can type cmd from search) note the go folder may exist under your user home folder after installing go
mkdir go
cd go
mkdir src
cd src
mkdir mygame
cd mygame
echo "" > main.go
NOTE: Linux and macOS users would use cat not echo - and they would use thier terminal app not cmd
using a text editor like notepad or IDE like VSCode
- edit main.go and add the following (remove “”)
package main
import "fmt"
func main() {
fmt.Println("Hello, world")
}
We can run this short app using this terminal command
go run hello.go
great it should display “Hello, world” below our command we typed if all is well
you can now run the following to make a module and Build our code
go mod init example.com/mygame
go mod tidy
go build .
running the new exe will produce the same output
and initialize our git repository and make an initial commit
git init
git add .
git commit -m "initial commit"
Install Raylib
head over to raylib-go and follow their instructions.
Windows no cgo instructions:
We will use cgo another time, for now download raylib
-
click on the release title (i.e. RayLib 5.5 takes you to https://github.com/raysan5/raylib/releases/tag/5.5)
-
scroll down to the bottom of the page and select the zip file for your system
- Download the file
- open it (windows can look in zip files)
- go ito the various folders until you find the raylib.dll file
extract it and copy it to top level (root folder) of your project
Now type the following
go get github.com/gen2brain/raylib-go/raylib
This will add a pkg folder with the required files in their respective folders
now replace the contents of main.go with the following
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()
}
}
We need to fix the mod file and rebuild
go mod tidy
go build .
If you get the same results - congrats
if not check the instructions and requirements on the raylib-go site again. Still stuck try the 1st and 2nd videos from the series below
Links
A Video series to build a Animal Crossing style game
Mostly I start with these 4 sites
- go.dev
- github for awesome-go or awesome-go.com follow the game-development link
- raylib-go
- Raylib itself choose your platform