{"id":21275685,"url":"https://github.com/halimath/fsx","last_synced_at":"2025-03-15T13:13:42.448Z","repository":{"id":206077941,"uuid":"587398124","full_name":"halimath/fsx","owner":"halimath","description":"Extended file system abstraction for golang","archived":false,"fork":false,"pushed_at":"2024-03-04T09:05:41.000Z","size":77,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T03:27:26.472Z","etag":null,"topics":["filesystem","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halimath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2023-01-10T16:55:13.000Z","updated_at":"2023-11-07T14:30:38.000Z","dependencies_parsed_at":"2024-03-02T20:24:14.834Z","dependency_job_id":"206b04c4-049e-45fe-8f13-0c27b83081cf","html_url":"https://github.com/halimath/fsx","commit_stats":null,"previous_names":["halimath/fsx"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Ffsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Ffsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Ffsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Ffsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halimath","download_url":"https://codeload.github.com/halimath/fsx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243732303,"owners_count":20338839,"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","go","golang"],"created_at":"2024-11-21T09:36:09.884Z","updated_at":"2025-03-15T13:13:42.426Z","avatar_url":"https://github.com/halimath.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fsx\n\nExtended filesystem abstractions for golang!\n\n# About\n\n`fsx` provides a package that extends the [`io/fs`](https://pkg.go.dev/io/fs) package from the standard\nlibrary with functionality to create and modify files and directories. \n\nThe package defines an interface `fsx.FS` that embeds `fs.FS` and adds methods to modify files and\ndirectories. Those methods have been modeled after the corresponding functions from the `os` package. In\naddition an interface `fsx.File` embeds `fs.File` and adds methods found on `os.File` type.\n\nSimilar to `fs`, which defines additional interfaces for implementations that provide specific functionality\n(i.e. to read a directory, such as `fs.ReadDirFS`) this package defines extra interfaces for operations like\n\n* create file\n* write file\n* create symlink\n* remove file\n* remove dir\n\n# Installation \n\n```shell\ngo get github.com/halimath/fsx\n```\n\n# Usage examples\n\n## `osfs`\n\nThe following example demonstrates how to use the `osfs` subpackage which\nprovides `fsx` compatible abstractions using the `os` package to access\nfiles and directories from the local fs.\n\n```go\n// Create a temporary directory to use as a root\ndir, err := os.MkdirTemp(\"\", \"fsx_example_*\")\nif err != nil {\n    panic(err)\n}\n// Make sure the directory is removed at the end of the test.\ndefer os.RemoveAll(dir)\n\n// Create a fsx.FS using the temp dir.\nfsys := osfs.DirFS(dir)\n\n// Create a file inside the fsys.\nf, err := fsx.Create(fsys, \"test.md\")\nif err != nil {\n    panic(err)\n}\n\n// Write some content to the file.\nif _, err := f.Write([]byte(\"# fsx example test\\n\\nThis is just an example.\")); err != nil {\n    panic(err)\n}\n\nif err := f.Close(); err != nil {\n    panic(err)\n}\n\n// Create a symlink inside the fsys\nif err := fsys.Symlink(\"test.md\", \"README.md\"); err != nil {\n    panic(err)\n}\n\n// Now try to read the symlinked file using os functions.\ncontent, err := os.ReadFile(filepath.Join(dir, \"README.md\"))\nif err != nil {\n    panic(err)\n}\n```\n\n## `memfs`\n\nThe subpackage `memfs` provides an in-memory implementation of `fsx` \ninterfaces.\n\n```go\n// Create a fsx.FS using the temp dir.\nfsys := memfs.New()\n\n// Create a file inside the fsys.\nf, err := fsx.Create(fsys, \"test.md\")\nif err != nil {\n    panic(err)\n}\n\n// Write some content to the file.\nif _, err := f.Write([]byte(\"# fsx example test\\n\\nThis is just an example.\")); err != nil {\n    panic(err)\n}\n\nif err := f.Close(); err != nil {\n    panic(err)\n}\n\n// Create a symlink inside the fsys\nif err := fsys.Symlink(\"test.md\", \"README.md\"); err != nil {\n    panic(err)\n}\n\n// Now try to read the symlinked file using fs.ReadFile\ncontent, err := fs.ReadFile(fsys, \"README.md\")\nif err != nil {\n    panic(err)\n}\n```\n\n# License\n\nCopyright 2023 Alexander Metzner.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalimath%2Ffsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalimath%2Ffsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalimath%2Ffsx/lists"}