Go SDK upgrade (v0.x to v1.0)
Learn how to upgrade to v1.0 of the Knock Go SDK.
Basic changes#
Client initialization#
The new SDK uses updated configuration methods:
What's new in v1.0#
The v1.0 SDK brings significant improvements to type safety, error handling, and developer experience.
Strong type system#
The new SDK uses field wrappers to distinguish between zero values and unset fields:
Auto-pagination#
Iterate through paginated resources without manual page management:
Enhanced error handling#
Get detailed error information with better debugging utilities:
Request options#
Configure requests with flexible per-request options:
Raw JSON access#
Access raw JSON data for advanced use cases:
Breaking changes#
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.
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.
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.
Error handling#
Error types and handling mechanisms have changed significantly. The new SDK provides more detailed error information and better debugging utilities.
Pagination#
The new SDK introduces cursor-based pagination with auto-pagination helpers.
Common operations#
Need help?#
If you run into any issues during your migration, reach out to our support team or open an issue on GitHub.