From 2f1efc973101f5e75ea64facebb105c13f561062 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sun, 4 Jun 2023 09:43:31 +0200 Subject: [PATCH] rename package common to lib --- config/config.go | 16 ++++++++-------- examples/demo/etc/etc.go | 4 ++-- common/common.go => lib/lib.go | 2 +- scopes.go | 14 +++++++------- testing/testing.go | 10 +++++----- tests/etc/etc.go | 4 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) rename common/common.go => lib/lib.go (99%) diff --git a/config/config.go b/config/config.go index 88b5d17..461c0f9 100644 --- a/config/config.go +++ b/config/config.go @@ -4,7 +4,7 @@ import ( "os" "strings" - "git.sr.ht/~cco/go-scopes/common" + "git.sr.ht/~cco/go-scopes/lib" ) type Cfg struct { @@ -12,34 +12,34 @@ type Cfg struct { ConfigFormat string } -func Start(ctx common.Context) { +func Start(ctx lib.Context) { } // definitions type Base struct { name string - starter common.StartFct - children []common.Config + starter lib.StartFct + children []lib.Config } func (cfg *Base) Name() string { return cfg.name } -func (cfg *Base) Starter() common.StartFct { +func (cfg *Base) Starter() lib.StartFct { return cfg.starter } -func (cfg *Base) Children() []common.Config { +func (cfg *Base) Children() []lib.Config { return cfg.children } -func (cfg *Base) Add(child common.Config) { +func (cfg *Base) Add(child lib.Config) { cfg.children = append(cfg.children, child) } -func MakeBase(name string, starter common.StartFct) *Base { +func MakeBase(name string, starter lib.StartFct) *Base { return &Base{ name: name, starter: starter, diff --git a/examples/demo/etc/etc.go b/examples/demo/etc/etc.go index 8cf868c..7663b51 100644 --- a/examples/demo/etc/etc.go +++ b/examples/demo/etc/etc.go @@ -2,11 +2,11 @@ package etc import ( "git.sr.ht/~cco/go-scopes" - "git.sr.ht/~cco/go-scopes/common" "git.sr.ht/~cco/go-scopes/config" + "git.sr.ht/~cco/go-scopes/lib" ) -func Config() common.Config { +func Config() lib.Config { ovr := Overrides().Use b := config.MakeBase cfg := scopes.Cfg{ diff --git a/common/common.go b/lib/lib.go similarity index 99% rename from common/common.go rename to lib/lib.go index de0ac12..d8032c7 100644 --- a/common/common.go +++ b/lib/lib.go @@ -1,4 +1,4 @@ -package common +package lib import ( stdlib_context "context" diff --git a/scopes.go b/scopes.go index 5923b9e..3c7ef66 100644 --- a/scopes.go +++ b/scopes.go @@ -6,8 +6,8 @@ import ( "os/signal" "syscall" - "git.sr.ht/~cco/go-scopes/common" "git.sr.ht/~cco/go-scopes/config" + "git.sr.ht/~cco/go-scopes/lib" ) type Cfg struct { @@ -16,11 +16,11 @@ type Cfg struct { Home string } -func Start(ctx common.Context) { - common.RunCtx(ctx, start) +func Start(ctx lib.Context) { + lib.RunCtx(ctx, start) } -func start(ctx common.Context) { +func start(ctx lib.Context) { defer ctx.Stop() for _, cfg := range ctx.Config().Children() { cctx := ctx.ChildContext(cfg) @@ -34,7 +34,7 @@ func start(ctx common.Context) { } } -func step(ctx common.Context, sig <-chan os.Signal) bool { +func step(ctx lib.Context, sig <-chan os.Signal) bool { select { case <-sig: fmt.Println("interrupted") @@ -54,8 +54,8 @@ func step(ctx common.Context, sig <-chan os.Signal) bool { // definitions -func RunApp(cfg common.Config) { - ctx := common.AppContext(cfg) +func RunApp(cfg lib.Config) { + ctx := lib.AppContext(cfg) cfg.Starter()(ctx) ctx.WaitGroup().Wait() } diff --git a/testing/testing.go b/testing/testing.go index 0a1700a..146433f 100644 --- a/testing/testing.go +++ b/testing/testing.go @@ -9,10 +9,10 @@ import ( "time" "git.sr.ht/~cco/go-scopes" - "git.sr.ht/~cco/go-scopes/common" + "git.sr.ht/~cco/go-scopes/lib" ) -func Start(ctx common.Context) { +func Start(ctx lib.Context) { scopes.Start(ctx) } @@ -22,7 +22,7 @@ type Map map[string]interface{} type T struct { Base *testing.T - Ctx common.Context + Ctx lib.Context } func MakeT(tbase *testing.T) *T { @@ -36,9 +36,9 @@ func SetUp(tbase *testing.T) *T { return t } -func SetUpApp(tbase *testing.T, cfg common.Config) *T { +func SetUpApp(tbase *testing.T, cfg lib.Config) *T { t := SetUp(tbase) - t.Ctx = common.AppContext(cfg) + t.Ctx = lib.AppContext(cfg) cfg.Starter()(t.Ctx) time.Sleep(100 * time.Millisecond) return t diff --git a/tests/etc/etc.go b/tests/etc/etc.go index 3ff9bea..536ec63 100644 --- a/tests/etc/etc.go +++ b/tests/etc/etc.go @@ -2,12 +2,12 @@ package etc import ( "git.sr.ht/~cco/go-scopes" - "git.sr.ht/~cco/go-scopes/common" "git.sr.ht/~cco/go-scopes/config" + "git.sr.ht/~cco/go-scopes/lib" "git.sr.ht/~cco/go-scopes/testing" ) -func Config() common.Config { +func Config() lib.Config { ovr := Overrides().Use b := config.MakeBase cfg := scopes.Cfg{