Files
go-kit/pkg/application/application.go
Jan Tytgat 624e329778
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 36s
Base application setup
Signed-off-by: Jan Tytgat <jan.tytgat@corelayer.eu>
2025-04-15 16:09:38 +02:00

39 lines
581 B
Go

package application
import (
"context"
"fmt"
"github.com/spf13/cobra"
)
type Application interface {
Start(ctx context.Context) error
Shutdown() error
}
func New(c Config) (Application, error) {
var cmd *cobra.Command
var err error
if cmd, err = c.getRootCommand(); err != nil {
return nil, err
}
return &application{
cmd: cmd,
}, nil
}
type application struct {
cmd *cobra.Command
}
func (a *application) Start(ctx context.Context) error {
return a.cmd.ExecuteContext(ctx)
}
func (a *application) Shutdown() error {
fmt.Println("Shutdown")
return nil
}