Home Stuff to do with go

Go package: tidyhtml

I wrote a package for Go that makes HTML neat and tidy.

What it does is turns something like this:

<!doctype html>
<html lang="en">
<head>
<title>demo</title>
</head>
<body>
<div><h1>this is a demo</h1>
<p>
ok
</p>
<div><span>this will do</span></div></div>
</body></html>

…into this vision:

<!doctype html>
<html lang="en">
<html>
    <head>
        <title>demo</title>
    </head>
    <body>
        <div>
            <h1>this is a demo</h1>
            <p>ok</p>
            <div>
                <span>this will do</span>
            </div>
        </div>
    </body>
</html>

Now, if somebody views the page source on this website (I think this must happen all the time) then all of the indentation and whitespace will look pretty neat. Phew!

Remake: a watcher tool for Make

I like using Make for my projects, even though I don’t understand some of the design decisions ($< > $@, naturally). Still, it’s installed everywhere and it does a pretty good job. But it doesn’t run automatically, and that is a problem.

There are other build systems and ways to automate make, but I wanted something that would:

  • watch and restart builds
  • work with Make
  • work with any target in any Makefile
  • require no setup/configuration
  • have no command line arguments to forget

So I created Remake with all of that in mind. Instead of running make [target] you run remake [target], and that’s it.

For example, if you have a Makefile like this:

app: $(wildcard *.go)
    go build

http: app $(wildcard templates/*)
    app -http

test: $(wildcard *.go)
    go test

You could run remake http, edit some files, and it would automatically restart the server. You could also run remake test to automatically run tests after each change. Or you could run remake http test to do both.

I have a few ideas for improvements but it’s already pretty handy. It’s available on GitHub so check it out there.