Filesystem mapped key-string store. Ideal for embedding code like sql.
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.
See the GoDoc
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.
}
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.
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.
Please consider opening an issue first, or just send a pull request. :)
See Contributors.
Inspired by smotes/purse.
MIT.