Installation¶
Getting started with Goose is simple. It is designed to work seamlessly with Go modules.
Prerequisites¶
Before installing Goose, ensure you have the following installed:
- Go 1.18 or higher (Required for Generics support)
- MongoDB 4.0 or higher (For full feature support like transactions)
Go Version
Goose uses Go Generics extensively to provide type-safe models and queries. You must use Go 1.18+ to use Goose.
Installing Goose¶
Run the following command in your project directory to install the goose package:
This will download the Goose package and its dependencies (including the official go.mongodb.org/mongo-driver).
Importing Goose¶
Once installed, you can import Goose into your Go files:
You will often need to use the official MongoDB bson primitives alongside Goose:
import (
"github.com/devsamahd/goose"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
Next Steps¶
Now that you have Goose installed, proceed to the Quick Start guide to build your first Goose application!