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 ¶
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 ¶
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.
Types ¶
type Result ¶
type Result int
Result indicates the action taken by the update of a file.
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.