lock

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package lock reads and writes platformgo.lock: what platformgo has actually applied to a project.

platformgo.yaml says what the project wants; the lock says what it got. The difference between the two is what lets apply remove the files of a module that is no longer declared, so taking a module out never needs manual cleanup.

Index

Constants

View Source
const FileName = "platformgo.lock"

FileName is the lock file in the project root.

Variables

This section is empty.

Functions

func Marshal

func Marshal(l Lock) ([]byte, error)

Marshal renders the lock as it is stored.

func SafePath

func SafePath(path string) bool

SafePath reports whether a recorded path stays inside the project: the lock is a file in the repository, and a path like ../../etc must never be deleted because of it.

func Write

func Write(dir string, l Lock) error

Write stores the lock. The content is sorted, so the file only changes when what has been applied changes.

Types

type Diff

type Diff struct {
	AddedModules   []string
	RemovedModules []string
	StaleFiles     []string // generated before and no longer generated
}

Diff is what changes between two locks.

func Compare

func Compare(applied, wanted Lock) Diff

Compare returns the difference between the applied lock and the wanted one.

func (Diff) Empty

func (d Diff) Empty() bool

Empty reports whether nothing changes.

type Lock

type Lock struct {
	Platform  string   `yaml:"platform"`  // platform version the project was last applied with
	Modules   []string `yaml:"modules"`   // enabled modules
	Generated []string `yaml:"generated"` // files owned by generation
}

Lock is the content of platformgo.lock.

func Read

func Read(dir string) (Lock, error)

Read loads the lock of a project. A project without a lock has an empty one: it has never been applied, which is what a project created before locks looks like.

Jump to

Keyboard shortcuts

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