update

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package update attempts to replace an existing file with updated data. If the existing file does not exist then it is created with the new data. If the file exists nut the data is unchanged then no action is taken. If the data has changed and the force flag is true then the file is updated. If force is not true then confirmation is sought (providing a difference output if requested.)

Index

Constants

View Source
const (
	ConfirmMsg = "Confirm overwrite of: %s\n" +
		"(Y to overwrite; [N/n] to Cancel; [R/r] to review)? "
	ConfirmCancelled = "Overwrite cancelled\n\n"
	ConfirmUnknown   = "Unknown response: '%s'\n\n"
)

Overwrite messages.

Variables

View Source
var (
	ErrInvalidFileType = errors.New("invalid file type")
	ErrFileUpdate      = errors.New("error updating file")
)

Exported errors.

Functions

func IsUpToDate

func IsUpToDate() bool

IsUpToDate returns the cumulative result of all processing. Any write causes upToDate to be set to false.

func ResetUpToDate

func ResetUpToDate()

ResetUpToDate sets the upToData flag to true.

Types

type Result

type Result int

Result indicates the action taken by the update of a file.

const (
	Unchanged Result = iota
	Created
	Cancelled
	Updated
	Failed
)

Results.

func File

func File(
	fPath string, force, checkUpToDate bool, data string, perm os.FileMode,
) (Result, error)

File creates or replaces an existing file with the provided data and file permissions if and only if it has changed. If changed and force is not true then a message asking for confirmation is presented giving an opportunity to review the changes.

Jump to

Keyboard shortcuts

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