Home

Awesome

Mewn

<h2>This project is now being archived due to native embed functionality now available in Go</h2>

A zero dependency asset embedder for Go.

Go Report Card GoDoc CodeFactor Generic badge Generic badge Generic badge

About

Mewn is perhaps the easiest way to embed assets in a Go program. Here is an example:

package main

import (
	"fmt"

	"github.com/leaanthony/mewn"
)

func main() {
	myTest := mewn.String("./assets/hello.txt")
	fmt.Println(myTest)
}

If compiled with go build, this example will read hello.txt from disk. If compiled with mewn build, it will embed the assets into the resultant binary.

Installation

go get github.com/leaanthony/mewn/cmd/mewn

Usage

Import mewn at the top of your file github.com/leaanthony/mewn then use the simple API to load assets:

Groups

To bundle a whole directory, simply declare a group like this:

myGroup := mewn.Group("./path/to/dir")

From this point you can use the same methods above, but on the group:

myAsset := myGroup.String("file.txt")

Groups also have the following method:

Mewn cli command

The mewn command does 3 things:

For the build and pack subcommands, any other cli parameters will be passed on to go build.

Caveats

This project was built for simple embedding of assets and as such, there are a number of things to consider when choosing whether or not to use it.

Bug reports are very welcome! Almost as much as PRs to fix them!

What does 'Mewn' mean?

Mewn (MEH-OON as fast as you can say it, not meee-oon) is the Welsh word for "in".

Why go for a crazy Welsh name?

Well, it stands out as a project name (practically zero name clashes) and is one of the oldest and coolest languages in Europe (which I'm lucky enough to speak). JRR Tolkien was obsessed with Welsh. So much so, he based the Middle Earth Elvish language "Sindarin" on it and there's strong evidence he based LOTR on Welsh mythology. It's also associated with Red Dragons, weirdly loved by the Bundesliga football team FC Schalke and it's on Duolingo, so why not give it a go 😉.

Inspiration

Heavy inspiration was drawn from packr by the awesome Mark Bates. The scope of what I needed was far narrower than the packr project, thus Mewn was born. If Mewn doesn't fulfil your needs, it's likely that packr will.