A project by Petar Maymounkov.

Download, build and install

The Circuit comprises a library of Go packages and a set of command-line programs. Installing the circuit on your development machine amounts to compiling the included command-line utilities. This is covered here.


  1. Build the Go compiler
  2. Download the Circuit sources
  3. Build Apache Zookeeper
  4. Build the Circuit Toolkit

Build the Go compiler

The first thing you would need to do is install the Go compiler from source (as opposed to using a pre-packaged binary). We prefer installation from source, because if you are planning on deploying production circuit applications, it is imperative to know how to fetch and use specific revisions or branches of the Go toolchain.

The circuit requires any go1.1.1-compatible release branch of the Go toolchain.

For your convenience, we include a self-contained recipe how to build Go from the source:

  1. Clone the Go source tree:
    % cd ~
    % hg clone -u go1.1.1 https://code.google.com/p/go
    This will fetch the Go repo and place it into ~/go. You can use any location of your choice—just make sure this is reflected accordingly in the next step.
  2. Set the environment variable GOROOT to point to the local clone of the Go repo:
    % export GOROOT=$HOME/go
  3. Build and install the Go compiler:
    % cd $GOROOT/src
    % ./all.bash
  4. The previous step will install all resulting binaries in $GOROOT/bin. You should put this directory in your path:
    % export PATH=$GOROOT/bin:$PATH

Download the circuit sources

  1. Let $GOCIRCUIT be the location where you would like to place the circuit project.

    	% hg clone -u release https://code.google.com/p/gocircuit $GOCIRCUIT
  2. Add the circuit project to your GOPATH environment variable

Build Apache Zookeeper

The circuit uses Apache Zookeeper, and so compiling the circuit requires access to the C include and library files of the Zookeeper driver. However these files are produced, we assign the environment variable ZKINCLUDE the path to the directory containing the include files, and the variable ZKLIB the path to the directory containing the library files. There are three ways to install the Zookeeper C driver.

If you are using a 64-bit OS X

For convenience, the circuit distribution includes a compiled Zookeeper C driver for 64-bit OS X platforms. To use it, just set

% export ZKINCLUDE=$GOCIRCUIT/misc/starter-kit-osx/zookeeper/include
% export ZKLIB=$GOCIRCUIT/misc/starter-kit-osx/zookeeper/lib

If you are using a 64-bit Linux

A compiled Zookeeper C driver for 64-bit Linux platforms is also included in the circuit distribution. To use it, set

% export ZKINCLUDE=$GOCIRCUIT/misc/starter-kit-linux/zookeeper/include
% export ZKLIB=$GOCIRCUIT/misc/starter-kit-linux/zookeeper/lib


Download and build the Zookeeper C driver from source, following these instructions:
  1. Download the Zookeeper sources:
    % cd /tmp
    % wget http://www.gtlib.gatech.edu/pub/apache/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz
    % tar xzf zookeeper-3.4.5.tar.gz
  2. Build and install Zookeeper, where $PREFIX here is the location where you would like to place the installation,
  3. % cd zookeeper-3.4.5/src/c
    % ./configure --prefix=$PREFIX
    % make && make install
  4. Set environment variables:
    % export ZKINCLUDE=$PREFIX/include/zookeeper
    % export ZKLIB=$PREFIX/lib

Build the circuit toolkit

  1. Inform the cgo compiler how to find the Zookeeper include files and to statically link in the Zookeeper library:
    % export CGO_CFLAGS="-I$ZKINCLUDE"
    % export CGO_LDFLAGS="$ZKLIB/libzookeeper_mt.a"
  2. Build and install all circuit command-line tools:
    % cd $GOCIRCUIT/src/circuit/cmd
    % go install ./...

    This step will instruct the Go compiler to build and install all circuit commands in $GOCIRCUIT/bin. Add this directory to your $PATH

    % export PATH=$PATH:$GOCIRCUIT/bin

Place all environment variables created during all previous steps into your startup scripts.

You are done!