Skip to content
immudb docker run -d --net host -it --name immudb codenotary/immudb:latest

Go Samples

This section includes sample applications using immudb in Go.

Although the applications are simple, they will provide fully functional samples to demonstrate how to write an application using immudb.

Hello Immutable World#

The classical Hello World sample adapted to immudb.

This simple application is using the official immudb go sdk to connect, store and retrieve key-value data from immudb server.

The full source code of this sample can be found at Hello Immutable World .

Prerequisites#

In order to run this sample, immudb server must be already running. This step is quite simple and it’s described at Running immudb .

Building and running the sample app#

To build and run the sample application, simply clone the Hello Immutable World and run:

1go mod tidy
2go build
3./hello-immutable-world

The sample application will run and display an output similar to

1Sucessfully set a verified entry: ('hello', 'immutable world') @ tx 1
2Sucessfully got verified entry: ('hello', 'immutable world') @ tx 1

WebApp using SQL#

The purpose of this sample application is to demonstrate the use of immudb using Go standard APIs for SQL .

This sample was written taking as a basis the tutorial Building a simple app with Go and PostgreSQL . We followed the same application structure even though the source code is different to show how immudb and PostgreSQL can be used in analogy.

The full source code of this sample can be found at WebApp using SQL

Screenshot of the Go web application querying immudb with SQL

Prerequisites#

In order to run this sample, immudb server must be already running. This step is quite simple and it’s described at Running immudb .

Building and running the sample app#

To build and run the sample application, simply clone the sample repository and run:

1go mod tidy
2go build
3./immudb-todo-webapp

The sample application should be up and running now. The port 3000 is used by default unless a different one is specified using PORT environment variable e.g. PORT=3001 ./immudb-todo-webapp

Tip

Database initialization statements might be stored in an external file as in this sample sql initialization script .

Command line app using SQL#

A simple reminder console app that stores all data in immudb.

As in the previous sample, the purpose of this sample application is to demonstrate the use of immudb using Go standard APIs for SQL .

The full source code of this sample can be found at Console sample using SQL .

Prerequisites#

In order to run this sample, immudb server must be already running. This step is quite simple and it’s described at Running immudb .

Building and running the sample app#

To build and run the sample application, simply clone the Console sample using SQL and run:

1go mod tidy
2go build
3./immudb-reminder-app

The sample application should be up and running now.

Additionally, this sample application provides a simple way to specify connection settings. run ./immudb-reminder-app -h to display all the available flags.

 1Usage of ./immudb-reminder-app:
 2  -addr string
 3        IP address of immudb server (default "localhost")
 4  -db string
 5        Name of the database to use (default "defaultdb")
 6  -pass string
 7        Password for authenticating to immudb (default "immudb")
 8  -port string
 9        Port number of immudb server (default "3322")
10  -user string
11        Username for authenticating to immudb (default "immudb")

Tip

Additional samples can be found at immudb client samples repository .

Edit this page on GitHub Last updated