Modules
Hof & CUE Modules
Every hof generator is also a CUE module, and in fact, many of hof’s other features can be used from the module system.
“hof mod
” is the subcommand based on Go modules
for working with CUE modules and managing dependencies.
The logic and format is the same, with much code shared between the implementations.
Currently, while CUE is module aware and supports imports,
it does not yet have dependency management, but it will work the same as well.
This page has a brief overview. The commands will
be repeated when you need to run them on other pages.
hof mod
subcommands:
hof mod init cue github.com/user/repo
initializes a new modulehof mod vendor cue
fetches dependencies intocue.mod/pkg/...
The name of a module must be the same the git repository.
hof
talks directly to git repositiories and many of
hof
’s commands will accept repositories as input too.
The files and directories that make up a module:
cue.mods
is where dependencies and versions are set, you write this file.cue.sums
contains the checksums for all dependencies and is managed byhof mod
cue.mod/module.cue
denotes a CUE module and has a sinlge linecue.mod/pkg/...
is where the code for dependencies is located after fetching
Replace for local development
You can use hof mod
for generally managing CUE or Hof modules and dependencies.
In addition to setting, fetching, and validating dependencies,
you can use hof mod
to setup local development when working
with multiple CUE or Hof modules.
In your cue.mods
file, use the replace
directive just like you would in Go.
This will symlink any local replaces to point from the CUE vendor directory to the replacement directory. You can then develop CUE or hof code without having to copy or vendor upstream dependencies.