Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributions Welcome License Test Go Report Card codecov Go Reference

embeddedfs

The embeddedfs package reads files and renders templates from an embedded file system.

Usage

Assuming you have the following directory structure:

.
├── main.go
└── myresources
    └── mytemplate.tmpl

And mytemplate.tmpl defined as follows:

Name: {{ .Name }}

Then the following code will produce out.yaml with the content Name: Bob:

//go:embed resources/*
var resources embed.FS

func main() {
    e := embeddedfs.NewEmbeddedFS("myresources", resources)
    args := map[string]interface{}{
        "Name": "Bob",
    }
    if err := e.RenderTemplate(args, "", "mytemplate.tmpl", "out.yaml"); err != nil {
        return fmt.Errorf("failed to render my template: %w", err)
    }
}

About

Read files and render templates from an embedded file system.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages