Skip to main content

Requirements

  • Go 1.21 or higher
  • Go modules enabled (default in Go 1.16+)

Install via go get

The easiest way to install the Switchport SDK is using go get:
go get github.com/switchport-ai/switchport-go

Add to go.mod

Alternatively, add it directly to your go.mod file:
require github.com/switchport-ai/switchport-go v0.1.0
Then run:
go mod tidy

Verify Installation

Verify that the SDK is installed correctly:
package main

import (
	"fmt"

	"github.com/switchport-ai/switchport-go/switchport"
)

func main() {
	client, err := switchport.NewClient("sp_test_key")
	if err != nil {
		panic(err)
	}
	fmt.Printf("Switchport client initialized successfully\n")
}

Dependencies

The Switchport Go SDK has zero external dependencies - it uses only the Go standard library:
  • net/http - For HTTP requests to the Switchport API
  • encoding/json - For JSON encoding/decoding
  • time - For timestamp handling
  • errors - For error handling
This minimal dependency footprint ensures compatibility and reduces the risk of dependency conflicts.

Upgrading

To upgrade to the latest version:
go get -u github.com/switchport-ai/switchport-go
Or update to a specific version:
go get github.com/switchport-ai/switchport-go@v0.2.0

Using with Go Workspaces

If you’re using Go workspaces (Go 1.18+), the SDK works seamlessly:
# Initialize workspace
go work init

# Add your module
go work use .

# Install switchport
go get github.com/switchport-ai/switchport-go

Troubleshooting

Module Cache Issues

If you encounter module cache issues, try clearing the cache:
go clean -modcache
go get github.com/switchport-ai/switchport-go

Go Version Issues

Make sure you’re using Go 1.21 or higher:
go version
If you need to update Go, visit go.dev/dl.

Import Path Issues

Make sure you’re importing from the correct path:
import "github.com/switchport-ai/switchport-go/switchport"
Note the /switchport subpackage at the end.

Next Steps

Authentication

Set up your API key and authenticate