example

command
v0.0.85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package main provides practical runnable examples for bootstrapping GoForge servers from the config module.

Gin example:

srv, err := serverGin.CreateApp()
if err != nil {
	panic(err)
}

api := serverGin.GetRoute("/api/v1")
api.GET("/hello", func(c *gin.Context) {
	c.JSON(200, gin.H{"message": "ok"})
})

serverGin.Start(srv)

gRPC example:

srv := serverGRPC.NewIConfig(nil, nil)

if err := srv.Register(func(r grpc.ServiceRegistrar) {
	pb.RegisterGreeterServer(r, greeterServer{})
}); err != nil {
	panic(err)
}

if err := srv.Serve(); err != nil {
	panic(err)
}

To run the executable examples in this file:

GoForge_EXAMPLE_SERVER=gin go run ./cmd/example

or:

GoForge_EXAMPLE_SERVER=grpc go run ./cmd/example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL