Skip to content

v0.x: the scaffold's go.mod is edited in place

Spec 0200.

What changed

  • go.mod is edited, not re-rendered. The go.mod skeleton template and its manifest hash are gone. gtb generate project, regenerate project, enable, disable, set and attach open the file with x/mod/modfile, add what is missing and write it back. Your own require, exclude, retract and replace lines, comments and tidy's indirect lines survive every run.
  • Direct requirements are seeded. For each module the generated tree imports that the running gtb knows a version for (the framework at version.gtb, an estate toolkit module, anything in gtb's own build info), a require line is added when missing. A line already present is left at whatever version it holds.
  • An adapter line is dropped with its import. gtb disable gitlab removes the go/forge-gitlab line; only lines for modules the adapter tables can link are ever dropped.
  • --no-verify and a machine without Go keep every requirement. Before this, a regenerate with the toolchain absent left go.mod with no require block at all.
  • GTB_FRAMEWORK_REPLACE still adds the development replace, and unsetting it removes that replace on the next run. A replace you wrote yourself is not touched.

What to do

Nothing, for a project that regenerates on a machine with Go: tidy runs as before and the result is byte-identical to what it was. The first regenerate on an existing project adds no line that tidy had not already resolved.

A manifest written before this carries a go.mod hash entry that nothing reads now; it is dropped on the next regenerate.

Before

$ gtb regenerate project --no-verify
$ grep -c require go.mod
0

After

$ gtb regenerate project --no-verify
INFO go.mod: required module=gitlab.com/phpboyscout/go/forge-gitlab
$ grep -c require go.mod
2