Releases: gofr-dev/gofr-cli
v0.8.1
v0.8.0
Release v0.8.0
🚀 Features
🔹 Store Layer Generator
A powerful new CLI tool that automatically generates type-safe GoFr store layer code from YAML configuration files, dramatically reducing boilerplate and ensuring consistent database access patterns.
- YAML-Driven Code Generation: Define your data access layer using simple, declarative YAML configurations
- Type-Safe Store Methods: Automatically generates strongly-typed methods for database operations (SELECT, INSERT, UPDATE, DELETE)
- GoFr Context Integration: Generated code properly integrates with GoFr's context for observability and datasource management
- Model Generation: Create Go structs with proper tags for database and JSON serialization
- Multiple Return Types: Supports single records, multiple records, counts, and custom return types
- Store Registry: Auto-generates a registry for managing multiple stores in your application
- Commands:
gofr store init- Initialize a new store.yaml configurationgofr store generate- Generate store code from configuration
- Developer Productivity: Eliminates repetitive data access code, allowing developers to focus on business logic
- Comprehensive Testing: Includes extensive test coverage with 1,140+ lines of tests ensuring reliability
Example workflow:
# 1. Initialize configuration
gofr store init
# 2. Define your store in store.yaml
# stores:
# - name: "user"
# queries:
# - name: "GetUserByID"
# sql: "SELECT id, name FROM users WHERE id = ?"
# type: "select"
# returns: "single"
# 3. Generate code
gofr store generateGenerated code includes:
- Interface definitions for each store
- Type-safe implementation methods
- Model structs with proper tags
- Store registry for easy access
Refer to the comprehensive Store Generator README for detailed configuration options and usage examples.
🔧 Enhancements
🔹 Enhanced Google Protobuf Type Support
Significantly improved gRPC wrapper generation with comprehensive support for all Google Protobuf well-known types.
- Complete Type Mapping: Added support for 40+ Google Protobuf types including:
google.protobuf.Any,google.protobuf.Duration,google.protobuf.Timestampgoogle.protobuf.Struct,google.protobuf.FieldMask,google.protobuf.Empty- All descriptor types (
FileDescriptorProto,MethodDescriptorProto, etc.) - All wrapper types (
Int64Value,StringValue,BoolValue, etc.) - Type and API proto definitions
- Automatic Import Resolution: Intelligently resolves and imports the correct Go packages for protobuf types.
- Better Code Generation: Generated gRPC wrappers now properly handle complex protobuf messages with nested Google types.
- Enhanced Type Safety: Ensures type-safe conversions between protobuf and Go types in generated code.
🛠️ Fixes
🔹 Migration Function Naming Convention
Fixed the gofr migrate command to generate idiomatic Go function names following CamelCase convention.
- Issue: The migrate command was generating function names exactly as provided (e.g.,
create_employee_table), which violated Go naming conventions - Fix: Automatically converts migration names from snake_case or kebab-case to camelCase
- Impact: Generated migration functions now follow Go best practices and maintain consistency with the rest of the codebase
- Example:
# Command: gofr migrate create -name=create_employee_table # Before (v0.7.1): function create_employee_table() # After (v0.8.0): function createEmployeeTable()
- Backward Compatible: Existing migrations are detected and handled correctly regardless of naming format
v0.7.1
v0.7.1
🔧 Fixes
1. Preserve Existing Mappings in all.go During Migration Generation
The migrate command previously overwrote the all.go file completely, causing renamed or manually modified entries to be lost. This fix updates the behavior to ensure a safer and non-destructive migration experience.
🔧 New Behavior:
- Existing mappings in
all.goare left unchanged. - Renamed migration files do not cause all.go to be overwritten.
- Only new migration files—identified by timestamp-based filenames not yet present—are appended to
all.go.
This fix ensures reliable migration file management without disrupting existing mappings or manual edits.
v0.7.0
Release v0.7.0
🚀 Feature
gRPC Streaming Support
-
Added comprehensive support for all gRPC streaming types:
- Server-side streaming
- Client-side streaming
- Bidirectional streaming
-
Generated code includes proper instrumentation for streaming methods with built-in observability for streaming calls including metrics and tracing
-
Refer to the official documentation & examples to know more about implementing gRPC streaming services and clients with GoFr.
v0.6.0
Release v0.6.0
🚀 Improvements
Configurable gRPC Client Connections
- gRPC client connections in GoFr are now more flexible!
- Users can now pass custom
DialOptionswhen setting up gRPC clients, enabling advanced use cases like setting interceptors, timeouts, TLS credentials, and more. - The newly generated gRPC client template has been updated to support variadic parameters, making it easy to plug in additional configurations.
📖 Learn how to use this feature through our official docs: Customizing gRPC Clients with DialOptions
🛠 Fixes
1. Duplicate Generated Definitions in gRPC Services
- Previously, gRPC services using the same message types across different services led to duplicated and conflicting code in the generated client package. GoFr-CLI now handles message types independently, ensuring clean and conflict-free code generation.
v0.5.0
Release v0.5.0
🚀 Features
-
Default HealthChecks for gRPC Servers:
-
All newly generated gRPC servers now come with default HealthChecks implemented.
-
This ensures that the server's health status can be monitored out of the box without additional configuration.
-
-
Cross-Server Health Monitoring:
-
All generated gRPC clients now include default methods to check the health of other gRPC servers.
-
This enhancement facilitates better inter-service communication and improves reliability in distributed systems.
-
For more details, refer to the official documentation and explore the examples' repo.
v0.4.0
Release v0.4.0
🚀 Features
Built-in Metrics for gRPC Services
GoFr now includes in-built metrics for all gRPC server executions and interservice gRPC calls. We automatically capture metrics to measure the response time of gRPC server/clients.
-
gRPC Server Registration
-
Use the
gofr wrap grpc server -proto=<path/to/proto/file>to generate the GoFr's gRPC handlers. -
Simplify the registration of a gRPC server using the
Register{ServiceName}ServerWithGofrmethod:func main(){ app := gofr.New() {packageName}.Register{ServiceName}ServerWithGofr(app, &packageName.{ServiceName}GoFrServer{}) app.Run() }
-
-
gRPC Client Registration
-
Use the
gofr wrap grpc client -proto=<path/to/proto/file>to generate the GoFr's gRPC client. -
Easily create and register gRPC clients with the
New{ServiceName}GoFrClientmethod:func main(){ app:= gofr.New() gRPCClient, err := {clientPackage}.New{serviceName}GoFrClient(app.Config.Get("GRPC_SERVER_HOST", app.Metrics())) if err != nil { app.Logger().Errorf("Failed to create gRPC client: %v", err) return } app.Run() }
-
Use the registered client to make interservice gRPC calls.
-
Refer to the official documentation & examples to know more.
🛠️ Fixes & Improvements
- Enhanced gRPC Logging
- Improved logs for interservice gRPC calls, now including:
- Trace ID: For better tracking of distributed requests.
- Status Code: Logs the response status of gRPC calls for easy debugging and issue resolution.
- Improved logs for interservice gRPC calls, now including:
v0.3.0
GoFr CLI v0.3.0
Feature:
Enable Interservice gRPC Call Tracing
The gofr wrap grpc client command generates gRPC handlers and servers with GoFr's context support. This change ensures clarity in the command's role and functionality.
Command Syntax:
gofr wrap grpc client --proto=<path_to_your_proto_file>The {serviceName}_client.go file is auto-generated in the same directory as that of your proto file. It should not be modified.
Example:
After generating the {serviceName}_client.go in file, you can register and access the gRPC service as follows:
func main() {
app := gofr.New()
// Create a gRPC client for the Hello service
helloGRPCClient, err := {clientPackage}.NewHelloGoFrClient(app.Config.Get("GRPC_SERVER_HOST"))
if err != nil {
app.Logger().Errorf("Failed to create Hello gRPC client: %v", err)
return
}
greetHandler := NewGreetHandler(helloGRPCClient)
// Register HTTP endpoint for Hello service
app.GET("/hello", greetHandler.Hello)
// Run the application
app.Run()
}Calling the registered gRPC Service :
The generated service can be accessed as follows:
type GreetHandler struct {
helloGRPCClient client.HelloGoFrClient
}
func NewGreetHandler(helloClient client.HelloGoFrClient) *GreetHandler {
return &GreetHandler{
helloGRPCClient: helloClient,
}
}
func (g GreetHandler) Hello(ctx *gofr.Context) (interface{}, error) {
// Make a gRPC call to the Hello service
helloResponse, err := g.helloGRPCClient.SayHello(ctx, &client.HelloRequest{Name: userName})
if err != nil {
return nil, err
}
return helloResponse, nil
}Fixes & Improvements
-
Command Update:
- The command
gofr wrap grpchas been changed togofr wrap grpc serverto better reflect its purpose of generating gRPC handlers and servers with GoFr's context support. - The argument remains unchanged:
--proto=<path_to_your_proto_file>.
- The command
-
GoFr-CLI Documentation Update:
- The GoFr-CLI README now provides a comprehensive guide to all available commands, serving as the one-stop solution for understanding GoFr-CLI functionality.
v0.2.1
Release Notes
🛠️ Fixes
-
Use snakecase for file names for files generated for gRPC Handlers
Thegofr wrap grpccommand now follows standardized file naming conventions by generating files in snake_case.Based on
{serviceName}.pb.goand{serviceName}_grpc.pb.go, the command now creates{serviceName}_gofr.goand{serviceName}_server.gofor improved consistency and alignment with best practices.To know how to set up gRPC GoFr Handlers using our cli refer: setting up gRPC Handlers
v0.2.0
GoFr CLI v0.2.0
gofr Context Support for gRPC Handlers
The gofr wrap grpc command introduces seamless integration of gofr's context in gRPC handlers.
Command:
gofr wrap grpc
- Flags
-proto=<path_to_the_proto_file>
Generated Files:
- Example Structure of
{serviceName}Server.gofile {serviceName}.gofr.go(auto-generated; do not modify)
{serviceName}Server.go File:
package hello
import "gofr.dev/pkg/gofr"
// Register the gRPC service in main.go:
// hello.RegisterHelloServerWithGofr(app, &grpc.HelloGoFrServer{})
type HelloGoFrServer struct {}
func (s *HelloGoFrServer) SayHello(ctx *gofr.Context) (any, error) {
// Optionally bind request payload
// var request HelloRequest
// if err := ctx.Bind(&request); err != nil {
// return nil, err
// }
return &HelloResponse{}, nil
} Extend HelloGoFrServer as needed for your gofr application.