Level 0 /

Setup & Tooling

Gopher has just received the commission to build the Baton Junction commuter rail. The permits are approved, the land is surveyed, and the tools are laid out. Before a single piece of track can be laid, it is time to set up the construction site.

Setup & Tooling

Gopher says

Welcome to Baton Junction! I’m Gopher, and I’ll be your guide as you learn Go by building a C1 Baton connector. First stop: getting your tools set up.

In baton-junction, we sync users, groups, and roles from a REST API using the C1 Baton SDK. Everything you learn here applies directly to building connectors.

Installing Go

Download Go from go.dev/dl and follow the installer for your OS. Verify it works:

go version

You should see something like go version go1.25.2 darwin/arm64. The exact version and platform will vary.

The Module File

Every Go project starts with a go.mod file. It declares the project’s identity and its dependencies - similar to Python’s pyproject.toml or Node’s package.json.

When you start a new Go project, you initialize the project (which creates the module file) with go mod init:

go mod init example/baton-junction

The command writes the first version of go.mod for your project. In baton-junction, it establishes the module path and the minimum Go version:

Here’s the baton-junction module file, stripped to its essentials:

keywordmodule path (project identity)minimum Go version
module example/baton-junction

go 1.25.2

The module path is how other Go code refers to this project. In baton connectors, this is a GitHub URL like github.com/conductorone/baton-okta.

Project Structure

Go projects follow a conventional layout. Here’s how baton-junction is organized:

entry pointlibrary packagesmodule config
baton-junction/
    cmd/baton-junction/main.go     the executable
    pkg/
        client/                    HTTP client, API calls, models
        config/                    CLI configuration
        connector/                 core connector logic
    go.mod                      module definition
    go.sum                      dependency checksums

cmd/ contains entry points. Each subdirectory compiles to a separate binary. pkg/ contains library code, grouped by responsibility.

Quick Quiz

Time to test what you’ve learned. Type the Go command that answers each question.

What command creates a new go.mod file for a project?

What command runs all tests in a project recursively?

What command compiles your project into a binary?

Gopher says

Your tools are ready and your project is structured. You know how go.mod defines a module, how cmd/ and pkg/ organize code, and where everything lives in a Baton connector.

In baton-junction, this layout is the same one used across baton connectors in the C1 ecosystem. Once you know where things go, you can navigate any connector.

Next: types and variables!

Explore the related connector code files

Next Lesson

Types & Variables

Continue