Documentation menu

SDKs

Go SDK

The official Wayline SDK for Go: Go 1.22+. Standard library only. context.Context on every call.

Install

pkg.go.dev
go get github.com/wayline/wayline-go

Quickstart

Set WAYLINE_API_KEY to a test key (see the Quickstart), then:

Go
package main

import (
	"context"
	"fmt"
	"os"

	"github.com/wayline/wayline-go"
)

func main() {
	client := wayline.NewClient(os.Getenv("WAYLINE_API_KEY"))
	d, err := client.Distance(context.Background(), wayline.DistanceRequest{
		Origin:      wayline.LatLng{Lat: 23.7925, Lng: 90.4078},
		Destination: wayline.LatLng{Lat: 23.733, Lng: 90.4172},
		Units:       wayline.Imperial,
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(d.DistanceMeters, d.DurationSeconds)
}

Errors

Non-2xx responses raise a typed error after retries are exhausted. Branch on code — the full list is in the error reference.

Error handling
var apiErr *wayline.Error
if errors.As(err, &apiErr) {
	fmt.Println(apiErr.Code, apiErr.Status, apiErr.RequestID)
}

Configuration

OptionDefaultDescription
API keyWAYLINE_API_KEYYour live or test key. Never logged.
Base URLhttps://api.wayline.cloudOverride for staging or a proxy.
Timeout30 secondsPer attempt.
Max retries3For 429 and 5xx, with exponential backoff + jitter, honoring Retry-After.

Source and releases

Package: github.com/wayline/wayline-go on pkg.go.dev. Source: packages/sdk-go. Versions follow semantic versioning; see the CHANGELOG in the package and our product changelog.

Was this page helpful?