v1.17.2 - Database Defaults and MongoDB Fixes โ
Release Date: February 1, 2026
Version 1.17.2 addresses critical issues with database initialization and MongoDB code generation. This release changes the default database to SQLite for a better out-of-the-box experience and fixes code generation bugs that caused compilation errors with MongoDB projects.
๐ฏ Highlights โ
- SQLite is now the default database - Zero-configuration setup for new projects
- MongoDB code generation fixed - No more GORM imports in MongoDB projects
- Better developer experience - Get started faster without external dependencies
๐ Bug Fixes โ
Default Database Changed to SQLite โ
Issue: The default database was PostgreSQL, requiring users to install and configure a PostgreSQL server even for simple projects or learning.
Fix: Changed the default database to SQLite, which:
- Requires no external database server
- Works out of the box with zero configuration
- Perfect for development, testing, and prototyping
- Creates a simple
.dbfile in your project - Still allows switching to any other database via
--databaseflag
Before:
goca init myproject --module github.com/user/myproject
# Would default to PostgreSQL, requiring DB setupAfter:
goca init myproject --module github.com/user/myproject
# Now defaults to SQLite - works immediately!Using other databases:
# PostgreSQL
goca init myproject --module github.com/user/myproject --database postgres
# MongoDB
goca init myproject --module github.com/user/myproject --database mongodb
# MySQL
goca init myproject --module github.com/user/myproject --database mysql
# And more: sqlserver, dynamodb, elasticsearchMongoDB Code Generation Fixed โ
Issue: When creating a project with MongoDB, the generated code incorrectly:
- Imported both GORM and MongoDB driver
- Used
*gorm.DBinstead of*mongo.Client - Called
gorm.Open()instead ofmongo.Connect() - Added GORM dependencies to go.mod
- Result: Projects didn't compile - multiple undefined errors
Example of errors:
"go.mongodb.org/mongo-driver/mongo/options" imported and not used
undefined: gorm
undefined: mongo.OpenFix: Complete rewrite of MongoDB initialization:
- Created dedicated
createMongoDBMainGo()function - Uses
*mongo.Clientfor MongoDB connections - Proper MongoDB driver imports only
- Correct
mongo.Connect()andclient.Ping()usage - go.mod only includes
go.mongodb.org/mongo-driver - Health checks adapted for MongoDB
- Graceful shutdown with client disconnection
Generated MongoDB code now:
import (
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/mongo/readpref"
// NO gorm imports!
)
var (
mongoClient *mongo.Client // Correct type!
)
func connectToMongoDB(cfg *config.Config) (*mongo.Client, error) {
clientOptions := options.Client().ApplyURI(dsn)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
client, err := mongo.Connect(ctx, clientOptions)
// ... proper MongoDB connection
}๐งช Testing โ
Added comprehensive test coverage for database initialization:
TestInitDefaultDatabase โ
- Verifies SQLite is the default when no
--databaseflag is provided - Checks
.goca.yamlcontainstype: "sqlite" - Validates
go.modhasgorm.io/driver/sqlite
TestInitMongoDBNoGorm โ
- Ensures MongoDB projects use mongo-driver
- Verifies GORM is NOT imported
- Confirms
*mongo.Clienttype is used - Validates go.mod has correct dependencies
๐ Test Results โ
All database initialization tests passing:
- โ Default database (SQLite)
- โ PostgreSQL (no regression)
- โ MySQL (no regression)
- โ MongoDB (fixed)
- โ SQL Server (no regression)
๐ Migration Guide โ
For Existing Projects โ
No changes required! This only affects new project initialization.
If you want to update an existing project:
To SQLite (from PostgreSQL):
- Update
.goca.yaml: Changedatabase.typeto"sqlite" - Update
go.mod: Replace postgres driver with sqlitebashgo get gorm.io/driver/sqlite go mod tidy - Update connection string in
.envor config
MongoDB projects created before v1.17.2: If you have a non-compiling MongoDB project, regenerate it:
goca init myproject-fixed --module github.com/user/myproject --database mongodb
# Copy your business logic to the new projectFor New Projects โ
Just use the defaults!
goca init myproject --module github.com/user/myproject
cd myproject
go mod tidy
go run cmd/server/main.go
# Works immediately with SQLite!๐ฆ Installation โ
Update to v1.17.2:
go install github.com/sazardev/goca@v1.17.2Verify installation:
goca version
# Output: v1.17.2๐ Related Issues โ
- Issue #42: MongoDB projects fail to compile
- Issue #43: Default database should be SQLite for easier onboarding
๐ Complete Changes โ
Changed:
- Default database from
postgrestosqlite - MongoDB code generation to use mongo-driver correctly
Added:
createMongoDBMainGo()function for MongoDB-specific code- Placeholder functions for DynamoDB and Elasticsearch
- Comprehensive database initialization tests
Fixed:
- MongoDB projects now compile successfully
- No more mixed GORM/MongoDB imports
- Proper mongo.Client usage in MongoDB projects
๐ Contributors โ
Thank you to everyone who reported these issues and helped improve Goca!
๐ Resources โ
View on GitHub โข Download โข Report Issue