Overview
All helper functions follow a consistent pattern:- Constructor functions (e.g.,
Bool,String) create pointers from values - Value functions (e.g.,
BoolValue,StringValue) safely dereference pointers with default values
Boolean Helpers
Bool
BoolValue
false if the pointer is nil.
Example:
String Helpers
String
Stringf
fmt.Sprintf.
Example:
StringValue
"" (empty string) if the pointer is nil.
Example:
Integer Helpers
Int
IntValue
0 if the pointer is nil.
Example:
Float Helpers
Float64
Float64Value
0.00 if the pointer is nil.
Example:
Time Helpers
Time
TimeValue
time.Time{}) if the pointer is nil.
Example:
Common Use Cases
Creating Resources
When creating resources, use the constructor functions to set optional fields:Reading Resources
When reading resources, use the value functions or the safe getter methods:Conditional Logic
Check for nil pointers before using value functions:Best Practices
-
Use constructor functions for optional fields: Always use
auth0.String(),auth0.Bool(), etc., when setting optional fields -
Prefer safe getters over value functions: The SDK provides auto-generated safe getter methods (e.g.,
GetName()) that are preferred over manual value functions - Check for nil when needed: For conditional logic, check if the pointer is nil before dereferencing
-
Use Stringf for formatted strings: When you need to format strings, use
auth0.Stringf()instead of manually formatting and wrapping
See Also
- Request Options - Configure individual API requests
- Error Types - Handle API errors