{"id":16431842,"url":"https://github.com/coreybutler/go-fsutil","last_synced_at":"2025-03-23T08:31:40.802Z","repository":{"id":57501469,"uuid":"203450139","full_name":"coreybutler/go-fsutil","owner":"coreybutler","description":"A light abstraction for common file system functions.","archived":false,"fork":false,"pushed_at":"2024-03-11T21:44:14.000Z","size":55,"stargazers_count":15,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T18:57:51.683Z","etag":null,"topics":["filesystem","filesystem-library","filesystem-utils","fsutil"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coreybutler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["coreybutler"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-08-20T20:33:03.000Z","updated_at":"2025-01-10T19:00:00.000Z","dependencies_parsed_at":"2024-03-11T21:30:19.138Z","dependency_job_id":null,"html_url":"https://github.com/coreybutler/go-fsutil","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreybutler%2Fgo-fsutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreybutler%2Fgo-fsutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreybutler%2Fgo-fsutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreybutler%2Fgo-fsutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coreybutler","download_url":"https://codeload.github.com/coreybutler/go-fsutil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245078067,"owners_count":20557274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filesystem","filesystem-library","filesystem-utils","fsutil"],"created_at":"2024-10-11T08:32:58.421Z","updated_at":"2025-03-23T08:31:39.984Z","avatar_url":"https://github.com/coreybutler.png","language":"Go","funding_links":["https://github.com/sponsors/coreybutler"],"categories":[],"sub_categories":[],"readme":"# fsutil\n\nThis cross-platform go module provides a lightweight abstraction of common file system methods:\n\n- `Touch(path string)`: Like the Unix [touch command](https://en.wikipedia.org/wiki/Touch_(command)). Returns a string with the absolute path of the file/directory.\n- `Mkdirp(path string)`: Like the Unix [mkdir -p](https://en.wikipedia.org/wiki/Mkdir) command. Returns a string with the absolute path of the directory.\n- `Exists(path string)`: Returns a boolean indicating `true` if the path exists and `false` if it does not.\n- `Abs(path string)`: Returns the absolute path as a string. Unlike the native [filepath.Abs](https://golang.org/pkg/path/filepath/#Abs), this method always returns a string (and only a string, no error). This method does not depend on the existence of the directory. Relative paths are always resolved from the current working directory.\n- `Clean(path string)`: This method ensures an empty directory exists at the specified path.\n- `IsFile(path string)`: Returns a boolean value indicating `true` if the path resolves to a file and `false` if it does not.\n- `IsDirectory(path string)`: Returns a boolean value indicating `true` if the path resolves to a directory and `false` if it does not.\n- `IsSymlink(path string) bool`: Determines if a path is a symbolic link.\n- `ReadTextFile(path string)`: Reads a text file and returns a _string_.\n- `WriteTextFile(path string, content string, \u003cos.FileMode\u003e)`: Writes a text file from a _string_. Optionally accepts a file mode.\n- `IsReadable(path string) bool`: Determines whether the path is readable.\n- `IsWritable(path string) bool`: Determines whether the path is writable.\n- `IsExecutable(path string) bool`: Determines whether the path has execute permissions.\n- `ByteSize(path string)`: Determines the size (in bytes) of a file or directory.\n- `Size(path string, decimalPlaces int)`: A \"pretty\" label for the size of a file or directory. For example, `3.14MB`.\n- `FormatSize(size int64, decimalPlaces int)`: Pretty-print the byte size, i.e. `3.14MB`.\n- `Copy(source string, target string, ignoreErrors ...bool) error`: Copy a file/directory contents. Ignores symlinks. Optionally specify `true` as the last argument to ignore errors.\n- `Move(source string, target string, ignoreErrors ...bool) error`: Move a file/directory contents. Ignores symlinks. Optionally specify `true` as the last argument to ignore errors.\n- `Unzip(source string, target string) error`: Unzip a file into the target directory.\n- `Zip(source string, target string) error`: Zip a file/directory into the target directory/filename.\n\n## Example\n\n```go\npackage main\n\nimport (\n  \"github.com/coreybutler/go-fsutil\"\n)\n\nfunc main() {\n  fsutil.Touch(\"./path/to/test.txt\")\n}\n```\n\nThe code above would create an empty file called `test.txt` in `\u003c\u003ccurrent working directory\u003e\u003e/path/to`. If the directory does not exist, it will be created.\n\n---\n\nFor complete details, see the [Godoc](https://godoc.org/github.com/coreybutler/go-fsutil). Examples are available in the [test files](https://github.com/coreybutler/go-fsutil/blob/master/fsutil_test.go).\n\n## Notice\n\nThis API is stable, but subject to additions. I work on it whenever a \"common file system need\" comes up in other projects. As a result, the `1.0.X` release cycle will continue to receive new feature additions until I consider the API \"well-defined\". This deviates a tiny bit from traditional semantic versioning, because new \"features\" are being added in patch releases.\n\nUpon the release of a `1.1.0` version, the API will be considered \"well-defined\" and will adhere more strictly to semantic versioning practices.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoreybutler%2Fgo-fsutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoreybutler%2Fgo-fsutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoreybutler%2Fgo-fsutil/lists"}