{"id":13413721,"url":"https://github.com/leaanthony/debme","last_synced_at":"2025-03-17T03:30:39.251Z","repository":{"id":57577132,"uuid":"358428672","full_name":"leaanthony/debme","owner":"leaanthony","description":"embed.FS wrapper providing additional functionality","archived":false,"fork":false,"pushed_at":"2021-06-06T02:03:03.000Z","size":26,"stargazers_count":33,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-27T17:16:41.785Z","etag":null,"topics":["golang"],"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/leaanthony.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}},"created_at":"2021-04-16T00:25:13.000Z","updated_at":"2024-12-09T22:15:52.000Z","dependencies_parsed_at":"2022-09-11T22:50:35.494Z","dependency_job_id":null,"html_url":"https://github.com/leaanthony/debme","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaanthony%2Fdebme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaanthony%2Fdebme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaanthony%2Fdebme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaanthony%2Fdebme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leaanthony","download_url":"https://codeload.github.com/leaanthony/debme/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841204,"owners_count":20356441,"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":["golang"],"created_at":"2024-07-30T20:01:47.403Z","updated_at":"2025-03-17T03:30:38.916Z","avatar_url":"https://github.com/leaanthony.png","language":"Go","funding_links":[],"categories":["Resource Embedding","嵌入的资源","Relational Databases"],"sub_categories":["HTTP Clients","HTTP客户端"],"readme":"\u003cp align=\"center\" style=\"text-align: center\"\u003e\n   \u003cimg src=\"logo.png\" width=\"50%\"\u003e\u003cbr/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n   \u003ccode\u003eembed.FS\u003c/code\u003e wrapper providing additional functionality\u003cbr/\u003e\u003cbr/\u003e\n   \u003ca href=\"https://github.com/leaanthony/debme/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg\"\u003e\u003c/a\u003e\n   \u003ca href=\"https://goreportcard.com/report/github.com/leaanthony/debme\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/leaanthony/debme\"/\u003e\u003c/a\u003e\n   \u003ca href=\"https://godoc.org/github.com/leaanthony/debme\"\u003e\u003cimg src=\"https://img.shields.io/badge/godoc-reference-blue.svg\"/\u003e\u003c/a\u003e\n   \u003ca href=\"https://www.codefactor.io/repository/github/leaanthony/debme\"\u003e\u003cimg src=\"https://www.codefactor.io/repository/github/leaanthony/debme/badge\" alt=\"CodeFactor\" /\u003e\u003c/a\u003e\n   \u003ca href=\"https://github.com/leaanthony/debme/issues\"\u003e\u003cimg src=\"https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat\" alt=\"CodeFactor\" /\u003e\u003c/a\u003e\n   \u003ca href=\"https://app.fossa.io/projects/git%2Bgithub.com%2Fleaanthony%2Fdebme?ref=badge_shield\" alt=\"FOSSA Status\"\u003e\u003cimg src=\"https://app.fossa.io/api/projects/git%2Bgithub.com%2Fleaanthony%2Fdebme.svg?type=shield\"/\u003e\u003c/a\u003e\n   \u003ca href=\"https://github.com/avelino/awesome-go\"\u003e\u003cimg src=\"https://awesome.re/mentioned-badge.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Features\n\n  * Get an `embed.FS` from an embedded subdirectory\n  * Handy `Copy(sourcePath, targetPath)` method to copy an embedded file to the filesystem\n  * 100% `embed.FS` compatible\n  * 100% code coverage\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"embed\"\n\t\"github.com/leaanthony/debme\"\n\t\"io/fs\"\n)\n\n// Example Filesystem:\n//\n// fixtures/\n// ├── test1\n// |   └── onefile.txt\n// └── test2\n//     └── inner\n//         ├── deeper\n//         |   └── three.txt\n//         ├── one.txt\n//         └── two.txt\n\n//go:embed fixtures\nvar fixtures embed.FS\n\nfunc main() {\n\troot, _ := debme.FS(fixtures, \"fixtures\")\n\n\t// Anchor to \"fixtures/test1\"\n\ttest1, _ := root.FS(\"test1\")\n\tfiles1, _ := test1.ReadDir(\".\")\n\n\tprintln(len(files1)) // 1\n\tprintln(files1[0].Name()) // \"onefile.txt\"\n\n\t// Anchor to \"fixtures/test2/inner\"\n\tinner, _ := root.FS(\"test2/inner\")\n\tone, _ := inner.ReadFile(\"one.txt\")\n\n\tprintln(string(one)) // \"1\"\n\n\t// Fully compatible FS\n\tfs.WalkDir(inner, \".\", func(path string, d fs.DirEntry, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tprintln(\"Path:\", path, \" Name:\", d.Name())\n\t\treturn nil\n\t})\n\n\t/*\n\t\tPath: .  Name: inner\n\t\tPath: deeper  Name: deeper\n\t\tPath: deeper/three.txt  Name: three.txt\n\t\tPath: one.txt  Name: one.txt\n\t\tPath: two.txt  Name: two.txt\n\t*/\n\t\n\t// Go deeper\n\tdeeper, _ := inner.FS(\"deeper\")\n\tdeeperFiles, _ := deeper.ReadDir(\".\")\n\n\tprintln(len(deeperFiles)) // 1\n\tprintln(files1[0].Name()) // \"three.txt\"\n\t\n\t// Copy files\n\terr := deeper.Copy(\"three.txt\", \"/path/to/target.txt\")\n}\n```\n\n## Why\n\nGo's new embed functionality is awesome! The only thing I found a little frustrating was the need to manage base paths.\nThis module was created out of the need to embed multiple templates in the [Wails](https://github.com/wailsapp/wails) CLI.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleaanthony%2Fdebme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleaanthony%2Fdebme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleaanthony%2Fdebme/lists"}