Skip to content

Commit

Permalink
Groundbreaking commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm committed May 6, 2021
1 parent 658e781 commit 2edc8b1
Show file tree
Hide file tree
Showing 62 changed files with 1,366 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
os: [ windows-latest, ubuntu-latest, macos-latest ]
go-version: [ 1.15.x, 1.16.x ]
runs-on: ${{ matrix.os }}
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
/vendor

*.coverprofile
/resources/test
10 changes: 10 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ linters:
- ifshort
- testpackage
- gci
- unconvert

issues:
exclude-use-default: false
Expand All @@ -45,3 +46,12 @@ issues:
- funlen
- dupl
path: "_test.go"

- linters:
- gomnd
- goconst
- goerr113
- noctx
- funlen
- dupl
path: "example_test.go"
73 changes: 58 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# @nhatthm/{name}

<!--
[![GitHub Releases](https://img.shields.io/github/v/release/nhatthm/{name})](https://github.com/nhatthm/{name}/releases/latest)
[![Build Status](https://github.com/nhatthm/{name}/actions/workflows/test.yaml/badge.svg)](https://github.com/nhatthm/{name}/actions/workflows/test.yaml)
[![codecov](https://codecov.io/gh/nhatthm/{name}/branch/master/graph/badge.svg?token=eTdAgDE2vR)](https://codecov.io/gh/nhatthm/{name})
[![Go Report Card](https://goreportcard.com/badge/github.com/nhatthm/{name})](https://goreportcard.com/report/github.com/nhatthm/{name})
[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/github.com/nhatthm/{name})
# `aferocopy`

[![GitHub Releases](https://img.shields.io/github/v/release/nhatthm/aferocopy)](https://github.com/nhatthm/aferocopy/releases/latest)
[![Build Status](https://github.com/nhatthm/aferocopy/actions/workflows/test.yaml/badge.svg)](https://github.com/nhatthm/aferocopy/actions/workflows/test.yaml)
[![codecov](https://codecov.io/gh/nhatthm/aferocopy/branch/master/graph/badge.svg?token=eTdAgDE2vR)](https://codecov.io/gh/nhatthm/aferocopy)
[![Go Report Card](https://goreportcard.com/badge/github.com/nhatthm/aferocopy)](https://goreportcard.com/report/github.com/nhatthm/aferocopy)
[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/github.com/nhatthm/aferocopy)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)
-->

TBD
`aferocopy` copies directories recursively using [spf13/afero](https://github.com/spf13/afero)

The idea and logic is ported from [otiai10/copy](https://github.com/otiai10/copy)

## Prerequisites

Expand All @@ -18,16 +18,59 @@ TBD
## Install

```bash
go get github.com/nhatthm/{name}
go get github.com/nhatthm/aferocopy
```

## Usage

TBD

## Examples
```go
err := aferpcopy.Copy("your/directory", "your/directory.copy")
```
## Advanced Usage

```go
// Options specifies optional actions on copying.
type Options struct {
// Source filesystem. Default is afero.NewOsFs().
SrcFs afero.Fs

// Source filesystem. Default is Options.SrcFs.
DestFs afero.Fs

// 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

// Skip can specify which files should be skipped
Skip func(src string) (bool, error)

// AddPermission to every entities,
// NO MORE THAN 0777
AddPermission os.FileMode

// 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
}
```

TBA
```go
// For example...
opt := Options{
Skip: func(src string) (bool, error) {
return strings.HasSuffix(src, ".git"), nil
},
}
err := Copy("your/directory", "your/directory.copy", opt)
```

## Donation

Expand Down
Loading

0 comments on commit 2edc8b1

Please sign in to comment.