From 816de185e3f97bd5a3de2333e89d181231615e8d Mon Sep 17 00:00:00 2001 From: Elijah Duffy Date: Wed, 11 Jun 2025 18:39:29 -0700 Subject: [PATCH] expose ModuleFn type --- go.mod | 3 +++ go.sum | 4 +++- module.go | 12 ++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index a850a4e..6d8d15c 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,9 @@ require github.com/stretchr/testify v1.10.0 require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 713a0b4..88191dc 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,12 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/module.go b/module.go index a6e2323..0a70322 100644 --- a/module.go +++ b/module.go @@ -10,8 +10,8 @@ import ( // ErrModuleNotFound is returned when a module is not found in the lifecycle. var ErrModuleNotFound = errors.New("module not found") -// moduleFn is a function type for module setup and teardown functions. -type moduleFn func(*Module) error +// ModuleFn is a function type for module setup and teardown functions. +type ModuleFn func(*Module) error // GenericModule is an interface that allows modules to be extended with custom // functionality, as the module can return a pointer to the underlying Module. @@ -26,8 +26,8 @@ type Module struct { lifecycle *Lifecycle // lifecycle is the parent lifecycle this module belongs to logger *slog.Logger name string - setup moduleFn - teardown moduleFn + setup ModuleFn + teardown ModuleFn depends []string loaded bool // loaded indicates if the module has been set up } @@ -35,9 +35,9 @@ type Module struct { // ModuleOpts contains user-exposed options when defining a module. type ModuleOpts struct { // Setup is the setup function for the module. - Setup moduleFn + Setup ModuleFn // Teardown is the teardown function for the module. - Teardown moduleFn + Teardown ModuleFn // Depends is a list of modules that this module depends on. Each entry must // be the exact name of a module registered in the lifecycle. Depends []string