Less compiler for golang
Switch branches/tags
Nothing to show
Clone or download
Latest commit 9f04009 Aug 21, 2017
Failed to load latest commit information.
assets/less-go Move js to assets Dec 8, 2015
lessc lessc fix Dec 10, 2015
.gitignore Update gitignore Dec 8, 2015
.travis.yml Update .travis.yml Dec 10, 2015
LICENSE Initial commit Dec 8, 2015
README.md Update README.md Aug 21, 2017
assets.go CLI and API Dec 8, 2015
less.go Return error when render error Dec 8, 2015
less_test.go Test passed Dec 10, 2015



THIS PROJECT IS NO LONGER MAINTAINED, feel free to fork and use as boilerplate for further usages

Build Status

Less compiler for Golang

Builds CSS using original Less compiler and Duktape embeddable Javascript engine


This project is a work-in-progress, we accept pull requests.


    go get github.com/kib357/less-go

Command Line usage

    cd $GOPATH/src/github.com/kib357/less-go/lessc
    go get
    go build
    ./lessc --input="inputFile" --output="outputFile"
    ./lessc -i inputFile -o outputFile


    ./lessc --input="./styles.less" --output="./styles.css"
    ./lessc -i styles.less -o styles.css

More about usage you can see in cli help:

    ./lessc -h

Programmatic usage

    import "github.com/kib357/less-go"

    func main() {
        err := less.RenderFile("./styles.less", "./styles.css", map[string]interface{}{"compress": true})

Function reference

RenderFile(input, output string, mods ...map[string]interface{}) error

Renders Less and generates output CSS.

SetReader(customReader Reader)

    type Reader interface {
	    ReadFile(string) ([]byte, error)

Sets a custom reader for .less files. You can use it to replace standard input from file system to another. Example:

    type LessReader struct{}

    var lessFiles = map[string][]byte{"styles": []byte{".class { width: (1 + 1) }"}}

    func (LessReader) ReadFile(path string) ([]byte, error) {
	    lessFile, ok := lessFiles[path]
        if !ok {
            return "", errors.New("path not found")
        return lessFile, nil

    func main() {

SetWriter(customWriter Writer)

    type Writer interface {
	    WriteFile(string, []byte, os.FileMode) error

Analogue of custom reader, but for output CSS.

Current limitations

Because of using C Javascript engine, cross compilation not supported. Not tested on Windows.

CLI interface doesnt support options