/slurp

Building with Go, easier than a slurp.

Primary LanguageGoMIT LicenseMIT

Heads up! This is pre-release software.

GoDoc

Slurp

Building with Go, easier than a slurp.

Slurp is a Gulp.js inspired build toolkit designed with idiomatic Go Pipelines and following principles:

  • Convention over configuration
  • Explicit is better than implicit.
  • Do one thing. Do it well.
  • ...

Why?

The tale of Gulp, Go, Go Templates, CSS, CoffeeScript, and minifiaction and building assets should go here.

Slurp is made of two integral parts:

1. The Toolkit

The slurp toolkit provides a task harness that you can register tasks and dependencies, you can then run these tasks with slurp runner.

A task is any function that accepts a pointer to slurp.C (Slurp Context) and returns an error.
The Context provides logging functions. it may be extended in the future.

b.Task("example-task", []string{"list", "of", "dependency", "tasks"},

  func(c *slurp.C) error {
    c.Info("Hello from example-task!")
  },

)

Following the Convention Over Configuration paradigm, slurps provides you with a collection of nimble tools to instrument a pipeline.

A pipeline is created by a source stage and typically piped to subsequent transformation stages and a final destination stage.

Currently Slurp provides two source stages slurp/stages/fs and slurp/stages/web that provide access to file-system and http source respectively.

b.Task("example-task-with-pipeline", nil , func(c *slurp.C) error {
    //Read .tpl files from frontend/template.
    return fs.Src(c, "frontend/template/*.tpl").Pipe(
      //Compile them.
      template.HTML(c, TemplateData),
      //Write the result to disk.
      fs.Dest(c, "./public"),
    ).Wait() //Wait for all to finish.
})

or the same code shorter

b.Task("example-task-with-pipeline", nil , func(c *slurp.C) error {
    //Read .tpl files from frontend/template.
    return fs.Src(c, "frontend/template/*.tpl").Then(
      //Compile them.
      template.HTML(c, TemplateData),
      //Write the result to disk.
      fs.Dest(c, "./public"),
      )
})

and another example,

// Download deps.
b.Task("deps", nil, func(c *slurp.C) error {
    return web.Get(c,
      "https://github.com/twbs/bootstrap/archive/v3.3.2.zip",
      "https://github.com/FortAwesome/Font-Awesome/archive/v4.3.0.zip",
    ).Then(
      archive.Unzip(c),
      fs.Dest(c, "./frontend/libs/"),
    )

})

Currently the following stages are provided with Slurp:

No 3rd party dependency, just standard library.

You can find more at slurp-contrib. gin, gcss, ace, watch, resources (embed), and livereload to name a few.

2. The Runner (cmd/slurp)

This is a cli tool that runs and help you compile your builders. It is go get’able and you can install with:

 $ go get -u -v github.com/omeid/slurp/cmd/slurp  # get it.

Slurp uses the Slurp build tag. That is, it passes -tags=slurp to go tooling when building or running your project, this allows decoupling of build and project code. This means you can use Go tools just like you're used to, even if your project has a slurp file.

Somewhat similar to go test Slurp expects a Slurp(*slurp.Build) function from your project, this is typically put in a file with the // +build slurp build tag.

Demo

demo

Contributing

Please see Contributing

Examples

LICENSE

MIT.