Skip to content
There’s a Go SDK that supports most functions to interact with Solana. The cookbook’s Go examples use its v2 module, github.com/solana-foundation/solana-go/v2. The repository moved from gagliardetto/solana-go; v1 keeps the github.com/gagliardetto/solana-go module path. If you’re using Anchor for your Solana programs, anchor-go generates a Go client from your IDL. The code it generates imports the v1 module (github.com/gagliardetto/solana-go), not v2.

​Installation

The latest v2 release needs Go 1.26 or later. Add the SDK to your module (run go mod init <module name> first in a new folder):
Terminal
After you add code that imports its packages, such as github.com/solana-foundation/solana-go/v2/rpc, run go mod tidy to record their dependencies. The cookbook’s Go examples are tested with v2.2.0.

​More Documentation

See the solana-go v2 README for installation details, migrating from v1, and examples.