Skip to content
/ go-yarn Public

Embeddable filesystem mapped key-string store. Ideal for embedding code like sql, lua, et al.

License

Notifications You must be signed in to change notification settings

omeid/go-yarn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDoc Coverage Status Build Status

Yarn

Filesystem mapped key-string store. Ideal for embedding code like sql.

Why?

Because programming in string literals sucks.

Lack of syntax highlighting, auto-completion, and other helpful tools when writing SQL or other programming languages make the task tedious and error prone, Yarn is here to help you pull your SQL strings into *.sql files and other code in appropriate files so you can use the right tools when coding.

Documentation

See the GoDoc

Example

package main

import (
	"log"
	"net/http"

	"github.com/omeid/go-yarn"
)

var sqls = yarn.Must(http.Dir("./sqls"), "*.sql")

func main() {
	sqls.MustHave("users_table.sql", "query_all.sql", "query_user.sql") //Panics otherwise.

    //Or the following if you're into that sort of stuff.
    /*
  	err := sqls.Has("users_table.sql", "query_all.sql", "query_user.sql")
	if err != nil {
		log.Fatal(err)
	}
    */

	res, err := sql.Exec(sqls.Must("users_table.sql"), params...)
	//Just deal with it.
}

Moar Files to ship, Smack That, you say?

Don't worry.
I hate complicated stuff too and there is a reason Yarn is using a Virtual Filesystem, http.FileSystem namely, to allow embedding!
You can simply use go-resources to embed all your sql and other codes files,

Make sure you read the "Live" development of resources section for friction-free development.

Catalog

If you prefer to use a single file with chunks of code (e.g sql statements, lua functions, or so forth), please see the catalog pacakge.

Contributing

Please consider opening an issue first, or just send a pull request. :)

Credits

See Contributors.
Inspired by smotes/purse.

LICENSE

MIT.

About

Embeddable filesystem mapped key-string store. Ideal for embedding code like sql, lua, et al.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages