Awesome Go

rebed

CategoryResource Embedding
SubcategoryResource Embedding
Stars0

Recreate folder structures and files from Go 1.16's `embed.FS` type

About rebed

rebed

codecov Build Status Go Report Card go.dev reference Awesome Sourcegraph

Recreate embedded filesystems from embed.FS type in current working directory.

Expose the files you've embedded in your binary so users can see and/or tinker with them. See where is this useful for an application example.

Install with (requires Go 1.16+)

go get -u github.com/soypat/rebed

Five actions available:


//go:embed someFS/*
var bdFS embed.FS

// Just replicate folder Structure
rebed.Tree(bdFS, "")

// Make empty files
rebed.Touch(bdFS, "")

// Recreate entire FS
rebed.Write(bdFS, "")

// Recreate FS without modifying existing files
rebed.Patch(bdFS, "")

// Runs Patch if no conflicting file is found, else error.
err := rebed.Create(bdFS, "")

/* Walk allows you operate on each file as you wish */

Where is this useful?

You could theoretically embed your web development assets folder and deploy it. The binary could run from the working directory folder generated by rebed and users could modify the assets and change the website's look (to do this run rebed.Patch to not overwrite modified files). If asset files are lost or the site breaks, running rebed.Write replaces all files with original ones.

Contributing

I'll look at issues and pull requests. Add a clear explanation when doing so!

Frequently Asked Questions

What is rebed?

rebed is a Resource Embedding library for the Go programming language. Recreate folder structures and files from Go 1.16's `embed.FS` type

How do I install rebed?

Install rebed with the Go module system using `go get soypat/rebed`. Check the repository for the current installation instructions.

What category does rebed belong to?

rebed is listed under Resource Embedding, specifically Resource Embedding.

← Back to Resource Embedding