https://github.com/liweiyi88/dummyfile
Create a fixed-size dummy file with random contents
https://github.com/liweiyi88/dummyfile
dummy dummy-files go golang
Last synced: over 1 year ago
JSON representation
Create a fixed-size dummy file with random contents
- Host: GitHub
- URL: https://github.com/liweiyi88/dummyfile
- Owner: liweiyi88
- License: mit
- Created: 2023-01-29T10:04:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-29T11:37:46.000Z (over 3 years ago)
- Last Synced: 2025-01-22T07:18:35.220Z (over 1 year ago)
- Topics: dummy, dummy-files, go, golang
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://godoc.org/github.com/liweiyi88/dummyfile)

[](https://codecov.io/gh/liweiyi88/dummyfile)
[](https://goreportcard.com/report/github.com/liweiyi88/dummyfile)
[](https://github.com/liweiyi88/dummyfile/blob/main/LICENSE.md)
Dummyfile is a cli tool/package for creating a fixed-size dummy file with random contents.
## Usage
### Install as package
`go get -u github.com/liweiyi88/dummyfile/dummyfile`
Then use it in your code
```
import "github.com/liweiyi88/dummyfile/dummyfile"
func main() {
file, err := os.Create(path)
if err != nil {
return fmt.Errorf("failed to create dummy file: %v", err)
}
defer func() {
err := file.Close()
if err != nil {
log.Printf("failed to close file: %s", file.Name())
}
}()
// as the Create method accepts the io.Writer.
// you have the flexibility to test not only the file but any io.Writer.
err := dummyfile.Create(file, 100*dummyfile.GB)
//....
}
```
### Install as binary
`dummyfile` binaries are available in https://github.com/liweiyi88/dummyfile/releases. Use the latest version of the binary that is suitable to your OS.
After downloading the binary and move it to the folder that is in your $PATH env var (e.g. `/usr/local/bin/dummyfile`), give it executable permissions (e.g. `sudo chmod +x /usr/local/bin/dummyfile`). Then you should be able to run it:
```
$ dummyfile /path/to/dummy.txt --size 100gb
```