copy

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 9 Imported by: 0

README

copy

Simple copy module for go applications, which allows to create copies of files and folders.

Available options

  • Force: re-writes destination if it is already exists.
  • ContentOnly: copies only source folder content without creating root folder in destination.
  • WithMove: removes source after copying process is finished.
  • WithBufferSize: allows to set custom buffer size for file copy. If provided size <= 0, then default 4096 will be used.
  • RevertOnErr: removes destination file if there was an error during copy process.
  • WithHash: calculates hash of the copied files for client's use.
Paths processing

If you need to copy file with the same name to destination, you need to add trailing slash at the destination path, since it will consider the last path element as the file name. The file name might be the same as the source file or a new custom one.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentOnly

func ContentOnly(o *options)

ContentOnly copies only source folder content without creating root folder in destination.

func Copy

func Copy(ctx context.Context, src, dst string, opts ...optFunc) error

Copy copies source file/folder to destination with given options.

func Force

func Force(o *options)

Force re-writes destination if it is already exists.

func RevertOnErr added in v1.2.0

func RevertOnErr(o *options)

RevertOnErr removes destination file if there was an error during copy process.

func WithBufferSize added in v1.2.0

func WithBufferSize(size int) optFunc

WithBufferSize allows to set custom buffer size for file copy. If provided size <= 0, then default will be used.

func WithHash added in v1.3.0

func WithHash(h hash.Hash) optFunc

WithHash calculates hash of the copied file(s).

Note: if hash is not nil, it guarantee the copied file(s) will be read. Might increase total execution time.

func WithMove added in v1.2.0

func WithMove(o *options)

WithMove removes source after copying process is finished.

Types

type Options added in v1.3.1

type Options []optFunc

Type to create custom slices of copy options.

Jump to

Keyboard shortcuts

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