The intention is to keep to repo root clean while the list of packages
is slowly growing.
Additionally, a bunch of small (~30 LoC) files in the repo root is
merged into a single maddy.go file, for the same reason.
Most of the internal code is moved into the internal/ directory. Go
toolchain will make it impossible to import these packages from external
applications.
Some packages are renamed and moved into the pkg/ directory in the root.
According to https://github.com/golang-standards/project-layout this is
the de-facto standard to place "library code that's ok to use by
external applications" in.
To clearly define the purpose of top-level directories, README.md files
are added to each.
To support unusual configuration syntax, endpoint modules (imap, smtp,
etc) relied on rather awkward code using modName+instName+aliases as
arguments. This commit replaces old handling with use of special
signature similar to inlineArgs introduced in 1edd031.
Endpoint modules are placed in a separate 'registry' and use
different initialization callback signature for simplicity. This makes
them inaccessible for other modules, though they are not supposed to be
anyway.
Endpoint modules are initialized before other modules. This allows
detecting unused configuration blocks by checking for modules
that were not lazily initalized after endpoint initialization.
This relies on endpoint modules being essentially "roots" of
instances dependency tree.
Idea of "semantical module names" is completely dropped now and so
HACKING.md is updated to not mention it.
Root package now contains only initialization code and 'dummy' module.
Each module now got its own package. Module packages are grouped by
their main purpose (storage/, target/, auth/, etc). Shared code is
placed in these "group" packages.
Parser for module references in config is moved into config/module.
Code shared by tests (mock modules, etc) is placed in testutils.
This allows more readable configuration files without additional
explanations in cases where a single module is used for multiple
purposes.
Also cleans up certain problems with modules that rely on block
names having certain semantics (e.g. endpoint modules).
This allows modules to reference each other during initialization
independently of configuration blocks order.
Also this allows us to initialize default modules in a more clean way.
All configuration directives now use underscores instead of dashes for
consistency with Caddy conventions.
Disallow defining multiple module instances with implicit name.
Remove global module.WaitGroup and add as field where it is necessary
(endpoint modules).
buf.Reset() and use rewind Reader in SMTP pipeline.
Rename several entities in code (NewModule => FuncNewModule, CfgTreeNode
=> Node, etc).
Also fix several warnings from linters.