Code for this sample is in ./main.go.
Linux >= 5.6 is the only production environment we support. But for ease of development we also support macOS and Windows.
- Go >= 1.17
Additionally on Windows: you must install Zig
0.11.0 and set the
CC
environment variable to zig.exe cc
. Use the full path for
zig.exe
.
First, clone this repo and cd
into tigerbeetle/src/clients/go/samples/basic
.
Then, install the TigerBeetle client:
go mod init tbtest
go get github.com/tigerbeetle/tigerbeetle-go
Follow steps in the repo README to run TigerBeetle.
If you are not running on port localhost:3000
, set
the environment variable TB_ADDRESS
to the full
address of the TigerBeetle server you started.
Now you can run this sample:
go run main.go
Here's what this project does.
This project starts by creating two accounts (1
and 2
).
Then it transfers 10
of an amount from account 1
to
account 2
.
Then it fetches both accounts, checks they both exist, and
checks that account 1
has:
debits_posted = 10
- and
credits_posted = 0
And that account 2
has:
debits_posted= 0
- and
credits_posted = 10