Skip to main content

Requirements

The Square Go SDK requires:
  • Go version 1.18 or higher
  • A Square account with API credentials
The SDK is built with Go 1.21 but maintains compatibility with Go 1.18+. If you’re using Go modules (recommended), the toolchain will handle version requirements automatically.

Install the SDK

1

Add the SDK to your project

Run the following command in your project directory to install the Square Go SDK:
go get github.com/square/square-go-sdk
This will download the latest version of the SDK and add it to your go.mod file.
2

Verify the installation

After installation, your go.mod file should include an entry similar to:
require github.com/square/square-go-sdk/v3 v3.x.x
The SDK uses semantic versioning, and the /v3 path indicates you’re using version 3 of the SDK.
3

Import the SDK in your code

Import the necessary packages in your Go files:
import (
    "github.com/square/square-go-sdk"
    squareclient "github.com/square/square-go-sdk/client"
    "github.com/square/square-go-sdk/option"
)

Package Structure

The Square Go SDK is organized into several packages:
  • github.com/square/square-go-sdk - Core types and models
  • github.com/square/square-go-sdk/client - Main client for API access
  • github.com/square/square-go-sdk/option - Request configuration options
  • github.com/square/square-go-sdk/payments - Payments API client
  • github.com/square/square-go-sdk/customers - Customers API client
  • github.com/square/square-go-sdk/orders - Orders API client
  • And many more for each Square API resource…
Most use cases only require importing the main square, squareclient, and option packages. Resource-specific packages are automatically available through the main client.

Version Management

Installing a Specific Version

To install a specific version of the SDK:
go get github.com/square/[email protected]

Updating to the Latest Version

To update to the latest version:
go get -u github.com/square/square-go-sdk

Checking Your Current Version

View your installed version in the go.mod file or run:
go list -m github.com/square/square-go-sdk/v3

Dependencies

The SDK has minimal external dependencies:
  • github.com/google/uuid - For generating unique identifiers
  • Standard Go libraries
All dependencies are managed automatically through Go modules.

Next Steps

Quickstart

Create your first payment in under 5 minutes

Authentication

Learn how to configure API credentials
Make sure you have obtained your Square API credentials from the Square Developer Dashboard before proceeding to the quickstart.

Build docs developers (and LLMs) love