replace

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustPreserveReplacementSource

func MustPreserveReplacementSource(err error) bool

MustPreserveReplacementSource 报告 wrapped/joined error 是否要求调用方保留 source。

func Replace

func Replace(sourcePath, targetPath string) error

Replace 用同平台的原子替换原语提交 sourcePath 到 targetPath。 具体实现由各平台文件负责;调用方必须先完成源文件写入与关闭。

func ReplaceFile

func ReplaceFile(sourcePath, targetPath string) error

ReplaceFile 用源文件替换目标路径;调用方应确保源文件已完整写入并关闭。

func ReplaceFileWithBackup

func ReplaceFileWithBackup(sourcePath, targetPath, _ string) error

ReplaceFileWithBackup 与 Windows 的 API 形状一致;非 Windows 的 rename 已原子替换目标, 不会产生旧文件备份。

func SyncParentDirectory

func SyncParentDirectory(path string) error

SyncParentDirectory 在替换提交后同步目标目录项。Windows 上由平台实现返回 可兑现的保证;调用方仍需处理返回的真实错误。

Types

type ReplacementSourcePreservationError

type ReplacementSourcePreservationError interface {
	error
	PreserveReplacementSource()
}

ReplacementSourcePreservationError 标记一次替换错误后的 source 仍是恢复材料。 调用方必须保留 source,直至人工或后续恢复流程完成。

type Result

type Result struct {
	Committed      bool
	PreserveSource bool
}

Result 描述 private-file 替换在返回错误时留下的文件状态。 Committed 表示 target 已经换成 source;PreserveSource 表示替换状态未决, source 仍是恢复材料,调用方不得将其当作普通失败临时文件删除。

func ReplacePrivateFile

func ReplacePrivateFile(sourcePath, targetPath string) (Result, error)

ReplacePrivateFile 使用本平台的 private-file 替换协议。

Jump to

Keyboard shortcuts

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