v1.7.3 GitLab

Feature flags for Go, without a SaaS

twrs is a small feature flag library. No external service, no network calls on the hot path: just rules, evaluated locally.

Get started View on GitLab
$ go get gitlab.com/twrshq/twrs@latest
Go · Go 1.24+
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"gitlab.com/twrshq/twrs"
)

func main() {
	ctx := context.Background()

	f, err := twrs.New(twrs.Options{
		Path:           "flags.yaml",
		ReloadInterval: 10 * time.Second,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	ok, err := f.Enabled(ctx, "new-checkout", "u_1842")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(ok)

	v, err := f.Variant(ctx, "search-ranking", "u_1842")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(v)
}

Safe defaults

If a flag is missing or malformed, the default you passed in code wins.

Percentage rollouts

Enable a flag for 5% of users and widen it as you gain confidence. Users stay in their bucket.

Tiny

A single file of rules and a few hundred lines of code.

Local evaluation

Flags are evaluated in-process in microseconds. Nothing leaves your servers.

Hot reload

Change the flag file and running processes pick it up within seconds.