Developer tools
Migration guides
Go 1.0

Go SDK upgrade (v0.x to v1.0)

This guide will help you upgrade from the previous Knock Go SDK to the new v1.0 Go SDK.

Basic Changes

Client Initialization

New Features in v1.0

  1. Strong Type System: Improved type safety with field wrappers

  2. Auto-pagination: Easily iterate through paginated resources

  3. Enhanced Error Handling: Better error types with detailed information

  4. Request Options: More flexible configuration for requests

  5. Raw JSON Access: Access raw JSON data for advanced use cases

Breaking Changes

  1. Request Parameter Style:

    • The new SDK wraps all request parameters with param.Field using helpers like knock.F() to distinguish between zero values and unset fields
  2. Method Signatures:

    • Most methods now take IDs as positional parameters, followed by a params struct
    • The new SDK spreads parameters across the method signature for better readability
  3. Type System:

    • The new SDK uses a strong type system with special wrapper types
    • Field values need to be wrapped with knock.F() to be included in requests
    • Union types are used for parameters that can have multiple types
  4. Error Handling:

    • Error types and handling mechanisms have changed significantly
    • The new SDK provides more detailed error information and better debugging utilities
  5. Pagination:

    • The new SDK introduces cursor-based pagination with auto-pagination helpers

Common Operations

Triggering Workflows

Old SDK:

New SDK:

Identifying Users

Old SDK:

New SDK:

Working with Objects

Old SDK:

New SDK:

Support

If you encounter any issues during migration, please reach out to our support team or open an issue on GitHub.