• Stars
    star
    559
  • Rank 76,616 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Go copy directory recursively

copy

Go Reference Actions Status codecov License: MIT FOSSA Status CodeQL Go Report Card GitHub tag (latest SemVer) Docker Test Vagrant Test GopherJS Go WASM

copy copies directories recursively.

Example Usage

package main

import (
	"fmt"
	cp "github.com/otiai10/copy"
)

func main() {
	err := cp.Copy("your/src", "your/dest")
	fmt.Println(err) // nil
}

Advanced Usage

// Options specifies optional actions on copying.
type Options struct {

	// OnSymlink can specify what to do on symlink
	OnSymlink func(src string) SymlinkAction

	// OnDirExists can specify what to do when there is a directory already existing in destination.
	OnDirExists func(src, dest string) DirExistsAction

	// OnError can let users decide how to handle errors (e.g., you can suppress specific error).
	OnError func(src, dest, string, err error) error

	// Skip can specify which files should be skipped
	Skip func(srcinfo os.FileInfo, src, dest string) (bool, error)

	// RenameDestination can rename destination.
	// If not set, nil, it does nothing.
	RenameDestination func(src, dest string) (string, error)

	// PermissionControl can control permission of
	// every entry.
	// When you want to add permission 0222, do like
	//
	//		PermissionControl = AddPermission(0222)
	//
	// or if you even don't want to touch permission,
	//
	//		PermissionControl = DoNothing
	//
	// By default, PermissionControl = PreservePermission
	PermissionControl PermissionControlFunc

	// Sync file after copy.
	// Useful in case when file must be on the disk
	// (in case crash happens, for example),
	// at the expense of some performance penalty
	Sync bool

	// Preserve the atime and the mtime of the entries
	// On linux we can preserve only up to 1 millisecond accuracy
	PreserveTimes bool

	// Preserve the uid and the gid of all entries.
	PreserveOwner bool

	// The byte size of the buffer to use for copying files.
	// If zero, the internal default buffer of 32KB is used.
	// See https://golang.org/pkg/io/#CopyBuffer for more information.
	CopyBufferSize uint

	// If you want to add some limitation on reading src file,
	// you can wrap the src and provide new reader,
	// such as `RateLimitReader` in the test case.
	WrapReader func(src io.Reader) io.Reader

	// If given, copy.Copy refers to this fs.FS instead of the OS filesystem.
	// e.g., You can use embed.FS to copy files from embedded filesystem.
	FS fs.FS

	// NumOfWorkers represents the number of workers used for
	// concurrent copying contents of directories.
	// If 0 or 1, it does not use goroutine for copying directories.
	// Please refer to https://pkg.go.dev/golang.org/x/sync/semaphore for more details.
	NumOfWorkers int64

	// PreferConcurrent is a function to determine whether or not
	// to use goroutine for copying contents of directories.
	// If PreferConcurrent is nil, which is default, it does concurrent
	// copying for all directories.
	// If NumOfWorkers is 0 or 1, this function will be ignored.
	PreferConcurrent func(srcdir, destdir string) (bool, error)
}
// For example...
opt := Options{
	Skip: func(info os.FileInfo, src, dest string) (bool, error) {
		return strings.HasSuffix(src, ".git"), nil
	},
}
err := Copy("your/directory", "your/directory.copy", opt)

Issues

License

FOSSA Status

More Repositories

1

gosseract

Go package for OCR (Optical Character Recognition), by using Tesseract C++ library
Go
2,221
star
2

ocrserver

A simple OCR API server, seriously easy to be deployed by Docker, on Heroku as well
Go
613
star
3

amesh

みんなだいすき東京アメッシュ!
Go
367
star
4

openaigo

OpenAI GPT3/3.5 and GPT4 ChatGPT API Client Library for Go, simple, less dependencies, and well-tested
Go
243
star
5

chrome-extension-es6-import

Example for Chrome . Extension ES6 Import
JavaScript
97
star
6

opengraph

Open Graph Parser for Go
Go
59
star
7

lookpath

The minimum and most straightforward way to check if command exists and where the executable is, without spawning child_process.
TypeScript
56
star
8

chomex

Chrome Extension Messaging Routing Kit / Promisify Chrome Messaging / LocalStorage Object Mapper
TypeScript
44
star
9

mint

The very minimum assertion for Golang testing framework.
Go
30
star
10

hotsub

Command line tool to run batch jobs concurrently with ETL framework on AWS or other cloud computing resources
Go
30
star
11

chant

Chat Application written in Go, using Firebase, working on GAE/Go, easy to deploy
Go
25
star
12

web-push-notification-sample

Web Push Notification Sample for both Server and Client
JavaScript
25
star
13

gat

Graphical cat. Render image on your terminal.
Go
23
star
14

cwl.go

CWL (and input file) parser for Golang, used by github.com/otiai10/yacle
Go
21
star
15

twistream

Simple Twitter Streaming API for Golang. #golang
Go
19
star
16

yacle

Yet Another CWL Engine by Golang
Go
18
star
17

gh-dependents

Just a web crawler to collect dependents of a GitHub repository.
Go
17
star
18

dataviper

Data Profiling and Basic Quality Assessment tool, for the very beginning phase of your project.
Python
17
star
19

ternary

Golang ternary expression ⛳
Go
14
star
20

demado

JavaScript
14
star
21

rodeo

Simple Redis Client for Golang
Go
13
star
22

giffy

Create Animated GIF from PNGs, JPEGs and, of course, GIFs
Go
13
star
23

amesh-bot

Slackでameshって言うとアメッシュの画像出すbot。 https://github.com/otiai10/amesh をライブラリとして利用したアプリケーション実装のひとつの例。
Go
12
star
24

too.js

Combine multiple commands' stream, keep all foreground and kill all in one Ctrl+C
TypeScript
11
star
25

marmoset

The very minimum web toolkit, less than framework
Go
11
star
26

yt2mp3

Download YouTube and convert to mp3
Go
11
star
27

curr

__FILE__, __DIR__, __FUNCTION__, __LINE__ for Golang
Go
11
star
28

fresh-youtube

View component and controller of YouTube Player API, for fresh framework.
TypeScript
10
star
29

colorchat

The very simple example of chat application written in Go, just by using standard package to handle WebSocket.
Go
9
star
30

ingoose

Simple IdnexedDB driver for browser application, with Mongoose like API.
TypeScript
8
star
31

botw

Create a twitter bot easily
Go
8
star
32

escalgo

[WIP] Elasticsearch Query DSL for Golang
Go
7
star
33

chromestorm

ORM for Chrome Extension with `chrome.storage` API
TypeScript
5
star
34

electron-playground

JavaScript
5
star
35

daap

Use Docker as a process, with hijacking Stdout/Stderr
Go
5
star
36

primes

Find primes, factorize numbers and reduce fractions by Golang.
Go
5
star
37

cf-chat-bridge

Bridge communication between LINE and Slack, by using Google Cloud Functions
TypeScript
5
star
38

TubeVj

にゃーん
TypeScript
4
star
39

firebase-messaging-sample

Firebase Cloud Messaging Sample
JavaScript
4
star
40

jstorm

JavaScript Storage ORM (Object-Relational Mapper) for LocalStorage and Chrome Storage API
TypeScript
4
star
41

mockrize

Create RESTful Mock API server, based on repository folder structures.
TypeScript
3
star
42

good

Early Return for Elixir
Elixir
3
star
43

DesignPattern.java

恥ずかしいことも質問していい勉強会
Java
3
star
44

homebrew-tap

My published homebrew packages
Ruby
3
star
45

log-kcwidget

ocrのlog
Go
3
star
46

otiai10.github.io

github.io
HTML
3
star
47

webm2mp4

Convert WebM to MP4
JavaScript
3
star
48

gcp-sdk-go-sandbox

Go
3
star
49

localstorm

ORM (Object-Relation Mapper) for LocalStorage of your browsers.
TypeScript
3
star
50

prisc

プリスク!は超簡単にウェブページのスクショが撮れるChrome拡張です
TypeScript
3
star
51

mammut

Yet Another Mastodon API Client
TypeScript
3
star
52

docker-tesseract

Docker image with compiling Tesseract-OCR for specific version on demand
Shell
3
star
53

hisyotan

ぼくだけの秘書たん
Ruby
2
star
54

urisql

Go
2
star
55

goapis

Yet another Web API Client library for Go
Go
2
star
56

cigger

Command line client to Trigger CI services
Go
2
star
57

delayload.js

delayload
2
star
58

spell

Command line string parser for Go.
Go
2
star
59

totsuzen

> 突然の死 < やるやつ。もう何番煎じやねん、っていうね。
Go
2
star
60

crescentjs

JavaScript images Binarization/Comparsion 🌘
JavaScript
2
star
61

ojisan.py

アサカツおじさん
JavaScript
2
star
62

gdcdl-workflow

Dockerfile
2
star
63

react-examples

http://otiai10.github.io/react-examples
JavaScript
2
star
64

gohome

働いたら負け
Go
2
star
65

syobocal

いくつになってもしょぼかるにはお世話になっております
Go
2
star
66

youtube-dl-docker

https://cloud.docker.com/repository/docker/otiai10/youtube-dl
Dockerfile
2
star
67

ios-travis-ci-example

iOS CI Example with TravisCI
Swift
1
star
68

backlog

Backlog
1
star
69

twit.tap

とりあえずつくってみた。99%がクライアントで出来てます
JavaScript
1
star
70

cachely

Golang HTTP response cache, with the same interface of http package
Go
1
star
71

fizzbuzz

なくていい
Go
1
star
72

react-text-anchorize

Replace `foo` to `<a>foo</a>` of inner text with RegExp
JavaScript
1
star
73

gcpx

Go
1
star
74

hellohttp

Rust
1
star
75

goavcodec

Go
1
star
76

docker-nfs

NFS client / server images for Docker
1
star
77

jma

Yet another weather forecast API client in Japan
Go
1
star
78

minimum.revel

revelのminimumサーバ
Go
1
star
79

ripple-css-animation

Ripple CSS Animation
CSS
1
star
80

dotfiles

dotfiles
Vim Script
1
star
81

speedweary

speedweary
Objective-C
1
star
82

jsonindent

Golang JSON Indent Encoder with io.Writer
Go
1
star
83

teitokuClock

提督の懐中時計
TypeScript
1
star
84

iPushKanColleWidget

iPushKanColleWidget 通知支援艦隊
Objective-C
1
star
85

MiniBuddy

Swift
1
star
86

gdc-client

1
star
87

conway-app-go

Conway's Game of Life in Go
Go
1
star
88

aws-sdk-go-sandbox

Go
1
star
89

gae-go-sandbox

Go
1
star
90

yaml2json

Go
1
star
91

soundhook

soundhook 開発バージョン => http://dev.soundhook.net
CSS
1
star
92

hello-go-wasm

Go
1
star
93

twick

https://chrome.google.com/webstore/detail/twick/fmdoehgidpmnkhakgkljpnlaccliemdf
HTML
1
star
94

tplize

Embed template to your CLI binary as Go map variable, supporting `go:generate`.
Go
1
star
95

IncrementalSearch

JavaScript Incremental Search small kit.
TypeScript
1
star