Help us shape the future of Go! Take the 2026 Go Developer Survey

copy

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: MIT Imports: 4 Imported by: 1,320

README

copy

Build Status codecov GoDoc Go Report Card

copy copies directories recursively.

Example:

err := Copy("your/directory", "your/directory.copy")

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	OnSymlink: func(string) SymlinkAction {
		return Shallow
	},
	Skip: func(string) bool {
		return false
	},
}

DefaultOptions by default.

Functions

func Copy

func Copy(src, dest string, opt ...Options) error

Copy copies src to dest, doesn't matter if src is a directory or a file.

Example
err := Copy("testdata/example", "testdata.copy/example")
fmt.Println("Error:", err)
info, _ := os.Stat("testdata.copy/example")
fmt.Println("IsDir:", info.IsDir())
Output:
Error: <nil>
IsDir: true

Types

type Options added in v1.1.0

type Options struct {
	// OnSymlink can specify what to do on symlink
	OnSymlink func(p string) SymlinkAction
	// Skip can specify which files should be skipped
	Skip func(src string) bool
}

Options specifies optional actions on copying.

type SymlinkAction added in v1.1.0

type SymlinkAction int

SymlinkAction represents what to do on symlink.

const (
	// Deep creates hard-copy of contents.
	Deep SymlinkAction = iota
	// Shallow creates new symlink to the dest of symlink.
	Shallow
	// Skip does nothing with symlink.
	Skip
)

Jump to

Keyboard shortcuts

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