A Go backend application, demonstrating different features of CrateDB. It uses both the HTTP, and the PostgreSQL wire protocol.
Both protocols are implementing the same functionality and are placed in
http.go
and postgresql.go
files.
The protocol can be selected using the corresponding command line flags
--http
or --postgresql
.
The Gin Web Framework is used for implementing the HTTP endpoints. For interacting with the database in PostgreSQL mode, the application uses the excellent pgx and pgxscan libraries. For generating unique IDs to be used as primary keys, the ksuid library is used.
The minimum required Go version is 1.18.
Install the application and its dependencies:
git clone https://github.com/crate/crate-sample-apps cd go-gin go build
This section describes how you can run the application.
To use HTTP protocol, please use:
go run . --http
To use PostgreSQL protocol, please use:
go run . --postgresql
Then, open the app:
open http://localhost:8080/
go get -t -u ./... go mod tidy