ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - leaanthony/debme: embed.FS wrapper providing additional functionality
embed.FS wrapper providing additional functionality - leaanthony/debme
Visit Site

GitHub - leaanthony/debme: embed.FS wrapper providing additional functionality

GitHub - leaanthony/debme: embed.FS wrapper providing additional functionality

Features

  • Get an embed.FS from an embedded subdirectory
  • Handy Copy(sourcePath, targetPath) method to copy an embedded file to the filesystem
  • 100% embed.FS compatible
  • 100% code coverage

Example

package main

import (
	"embed"
	"github.com/leaanthony/debme"
	"io/fs"
)

// Example Filesystem:
//
// fixtures/
// ├── test1
// |   └── onefile.txt
// └── test2
//     └── inner
//         ├── deeper
//         |   └── three.txt
//         ├── one.txt
//         └── two.txt

//go:embed fixtures
var fixtures embed.FS

func main() {
	root, _ := debme.FS(fixtures, "fixtures")

	// Anchor to "fixtures/test1"
	test1, _ := root.FS("test1")
	files1, _ := test1.ReadDir(".")

	println(len(files1)) // 1
	println(files1[0].Name()) // "onefile.txt"

	// Anchor to "fixtures/test2/inner"
	inner, _ := root.FS("test2/inner")
	one, _ := inner.ReadFile("one.txt")

	println(string(one)) // "1"

	// Fully compatible FS
	fs.WalkDir(inner, ".", func(path string, d fs.DirEntry, err error) error {
		if err != nil {
			return err
		}
		println("Path:", path, " Name:", d.Name())
		return nil
	})

	/*
		Path: .  Name: inner
		Path: deeper  Name: deeper
		Path: deeper/three.txt  Name: three.txt
		Path: one.txt  Name: one.txt
		Path: two.txt  Name: two.txt
	*/
	
	// Go deeper
	deeper, _ := inner.FS("deeper")
	deeperFiles, _ := deeper.ReadDir(".")

	println(len(deeperFiles)) // 1
	println(files1[0].Name()) // "three.txt"
	
	// Copy files
	err := deeper.Copy("three.txt", "/path/to/target.txt")
}

Why

Go's new embed functionality is awesome! The only thing I found a little frustrating was the need to manage base paths. This module was created out of the need to embed multiple templates in the Wails CLI.

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory