Help us shape the future of Go! Take the 2026 Go Developer Survey

mod

package
v1.0.85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const GameFeaturesDirName = "GameFeatures"

GameFeaturesDirName is the subdirectory of Mods that the game loads game feature plugins from. A game feature mod placed alongside the ordinary mods is simply never loaded.

Variables

View Source
var ErrNilMods = errors.New("syncmods payload has no mods list; refusing to uninstall every mod")

ErrNilMods is returned for a syncmods payload with no mods field at all.

nil and an explicit empty slice are NOT interchangeable, exactly as in the backend's agentmod.DeleteAbsent:

  • lf.Mods == nil means the payload was absent, null, or {} — a malformed task. Executing it would put every mod on disk into plan.Remove and uninstall the lot on what is really a bug or a truncated message. Refuse it.
  • lf.Mods == []v2.ModLock{} (non-nil, empty) means the backend resolved the set and it is genuinely empty — the user removed their last mod. That is a real outcome and MUST still wipe the Mods directory, or the last mod could never be removed.

Do not "simplify" this to a len() check: the two look identical there and mean opposite things.

Functions

func ExtractArchive

func ExtractArchive(modFilePath string, modDirectory string) error

func FindModsOnDisk

func FindModsOnDisk() []types.InstalledMod

func InstallModArchive added in v1.0.84

func InstallModArchive(modFilePath string, modReference string) error

The GameFeature flag lives in the .uplugin inside the archive, so the target directory is not known until the archive has been unpacked. Extract to a staging directory first, read the manifest, then move it into place.

func IsGameFeatureMod added in v1.0.84

func IsGameFeatureMod(modDirectory string, modReference string) (bool, error)

IsGameFeatureMod reads the GameFeature flag out of an unpacked mod's manifest.

func ReportOnDisk added in v1.0.84

func ReportOnDisk() []v2.InstalledMod

ReportOnDisk is the unconditional truth about the Mods directory, reported once on subscribe so a mod deleted by hand is noticed rather than believed installed forever.

func Sync added in v1.0.84

func Sync(ctx context.Context, lf v2.Lockfile, progress func(int32, string)) ([]v2.InstalledMod, error)

Sync brings the Mods directory to the lockfile's desired state and returns what it ended up with. The caller holds serverlock.

On failure it returns the report ALONGSIDE the error whenever it has already begun touching the disk: mods installed before the failing one are really on disk at their new version, and if the caller reported nothing the backend would keep believing the pre-sync installed-set until the next reconnect.

func UninstallMod

func UninstallMod(modReference string) error

func WriteModConfigFile added in v1.0.84

func WriteModConfigFile(modReference string, modConfig string) error

Types

type SyncPlan added in v1.0.84

type SyncPlan struct {
	Install []v2.ModLock
	Remove  []string
	Configs map[string]string
}

SyncPlan is what a sync will do. It is computed before anything is touched, so an empty plan short-circuits the whole task.

func PlanSync added in v1.0.84

func PlanSync(onDisk []types.InstalledMod, lf v2.Lockfile) SyncPlan

PlanSync diffs the Mods directory against the lockfile.

It is pure and separate from the execution so the no-op case — the one that makes at-least-once delivery safe — can be tested without a disk.

func (SyncPlan) IsEmpty added in v1.0.84

func (p SyncPlan) IsEmpty() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL