# README
= Go microservice framework
image:https://img.shields.io/github/checks-status/itbasis/go-service/main[GitHub branch checks state] image:https://img.shields.io/github/go-mod/go-version/itbasis/go-service[GitHub go.mod Go version] image:https://img.shields.io/badge/godoc-reference-blue.svg[link=https://pkg.go.dev/github.com/itbasis/go-service] image:https://img.shields.io/github/v/tag/itbasis/go-service[GitHub tag (with filter)] https://codecov.io/gh/itbasis/go-service[image:https://codecov.io/gh/itbasis/go-service/graph/badge.svg?token=GCqCXxG0xL[codecov]] https://goreportcard.com/report/github.com/itbasis/go-hashtag[image:https://goreportcard.com/badge/github.com/itbasis/go-hashtag[Go Report Card]]
Possibilities:
// suppress inspection "AsciiDocLinkResolve"
. Running a link:https://gin-gonic.com/[gin] based HTTP/REST server ( see link:config.go#L10[config] )
// suppress inspection "AsciiDocLinkResolve"
. Running a gRPC server with metrics for Prometheus (see link:config.go#L14[config] and link:https://github.com/grpc-ecosystem/go-grpc-middleware/blob/main/providers/prometheus/options.go[options])
. Working with the database via link:https://gorm.io/[GORM] with support for database migration via link:https://pressly.github.io/goose/[Goose] with the ability to specify migration files from the file system or via embed.FS
. Using the link:https://github.com/go-co-op/gocron[gocron] task scheduler
. Different log output format based on link:https://github.com/uber-go/zap[Zap], depending on the launch environment - launch in container or not
. Getting settings via link:https://github.com/caarlos0/env[environment] variables
== Configuration files
. link:config.go[]
. link:db/config.go[] - more details in the link:db/README.adoc[]
To read the configuration from the environment, it is recommended to use the method link:https://github.com/itbasis/go-core-utils/blob/main/env-reader.go[`ReadEnvConfig()`]
== TODO
see link:TODO.adoc[]
== Examples
.Minimum code configuration to run [source,go]
func main() { _ := NewServiceWithEnvironment(context.Background(), zap.NewProductionConfig()).Run() }
.Configuration with the transfer of migration scripts for database migration via Embedded FS [source,go]
import "embed"
//go:embed folder/*.sql var embedMigrations embed.FS
func main(){ _ := NewServiceWithEnvironment(context.Background(), zap.NewProductionConfig()). InitDB(&embedMigrations). Run() }
alternative: [source,go]
import "embed"
//go:embed folder/*.sql var embedMigrations embed.FS
func main(){ srv := NewServiceWithEnvironment(context.Background(), zap.NewProductionConfig()) gormDB := srv.GetGormWithEmbeddedMigrations(&embedMigrations)
srv.Run()
}
.Specifying custom metrics for Prometheus for gRPC server [source,go]
import grpcPrometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"