Backend building block written in Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
bg bg: Implement BG func Jan 2, 2019
cache Add util funcs Dec 27, 2018
config Refactor: Remove ctx/app package Dec 26, 2018
context context: Implement Shipment Dec 31, 2018
example Remove ctx package Jan 2, 2019
log log: Add JoinFields func Dec 28, 2018
net net/grpc: Support client/server-side streaming RPC Jan 3, 2019
stats Add util funcs Dec 27, 2018
testing testing: Randomise port sequencer Dec 31, 2018
tracing net: Fix journey KV Dec 29, 2018
.gitignore Implement job scheduler Apr 6, 2018
Gopkg.lock net/pubsub: Implement PubSub Jan 2, 2019
Gopkg.toml dep: Fix deps Dec 26, 2018
Makefile Remove ctx package Jan 2, 2019 Remove ctx package Jan 2, 2019

lego CircleCI Go Report Card FOSSA Status


People don't buy painting, they buy painted walls.

Go is gaining popularity at exponential speed, but adopting the language to build web applications at the early stage of a company can be challenging due to the lack of ready-to-use tools. LEGO has been solving that problem with a framework that contains the tools required to build robust distributed services. LEGO made most of the decisions for you, so that you can focus on bringing more values to your products.


1. Grow with the product
2. Defer decisions
3. Not for everyone

1. Grow with the product

LEGO is a framework designed to grow with developers from the first service to multiple resilient microservices at decent scale.

2. Defer decisions

Making technical decisions can be needlessly time consuming, especially at the early stage of a product development. That is the reason why LEGO made a lot of these decisions for you and as trivial as possible. That means you won't be locked-in into a specific vendor technology.

3. Not for everyone

Even though LEGO can grow with your product, it does not necessarily mean that it is the right choice for you. LEGO primarily solves Stairlin's problems and may discard very important problems in your product. Nevertheless, LEGO is open to new ideas and contributions as long as they are consistent with our philosophy.


Start a simple HTTP server

$ git clone
$ cd lego/example
$ CONFIG_URI=file://${PWD}/config.toml go run http_server.go

Send a request

$ curl -v


Simple HTTP server

This code creates a LEGO instance and attach and HTTP handler to it with one route /ping.

package main

import (


var (
	version = "dirty"
	date    = "now"

type Config struct {
	Foo string `toml:"foo"`

func main() {
	// Create lego
	appConfig := &Config{}
	app, err := lego.New("demo", appConfig)
	if err != nil {
		return errors.Wrap(err, "error initialising lego")
	app.Config().Version = version

	// Register HTTP handler
	httpServer := http.NewServer()
	httpServer.HandleFunc("/ping", http.GET, Ping)
		Name:   "http.demo",
		Host:   os.Getenv("IP"),
		Port:   8080,
		Server: httpServer,
		Tags:   []string{"http"},

	// Start serving requests
	err = app.Serve()
	if err != nil {
		fmt.Println("Problem serving requests", err)

// Ping handler example
func Ping(ctx context.Context, w http.ResponseWriter, r *http.Request) {
	log.Trace(ctx, "", "Simple request", log.String("ua", r.HTTP.UserAgent()))


Example of a configuration file

node = "$HOSTNAME"
version = "1.1"

  timeout_ms = 1000
  allow_context = false

  address = "localhost:7500"
  dc = "local"



  foo = "bar"


FOSSA Status