8000 Distinguishing unprovided values from provided zero values · Issue #20 · antihax/goesi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Distinguishing unprovided values from provided zero values #20
Open
@ISE-Admin

Description

@ISE-Admin

I'm having an issue with loading public contracts using the ContractsApi.GetContractsPublicRegionId function.

For optional arguments (e.g. the "reward" field from the corresponding ESI endpoint), is there any way to distinguish between a field that wasn't provided (e.g. a contract that doesn't have a "reward" field, such as an item exchange), vs. a contract where that field was provided, but has a zero value (e.g. a courier contract where the reward is 0)?

I know I could do a conditional check based on the Type_ field of the resulting GetContractsPublicRegionId200Ok struct, and only check the Reward field if it's a contract of type courier, but that's a lot of switch statements over a lot of endpoints.

The conventional Go way to do this would be for these structs to use pointer type for the optional fields, which would be nil if they weren't provided in the ESI response.
@antihax

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0