[GH-ISSUE #59] Use of StringOrUint/64 #10

Closed
opened 2026-03-03 14:44:38 +03:00 by kerem · 3 comments
Owner

Originally created by @earentir on GitHub (May 6, 2023).
Original GitHub issue: https://github.com/luthermonson/go-proxmox/issues/59

Wouldn't it be easier to always convert to the Uint64 type ?

Originally created by @earentir on GitHub (May 6, 2023). Original GitHub issue: https://github.com/luthermonson/go-proxmox/issues/59 Wouldn't it be easier to always convert to the Uint64 type ?
kerem closed this issue 2026-03-03 14:44:38 +03:00
Author
Owner

@luthermonson commented on GitHub (May 8, 2023):

welp you would think so... but the API was returning 1234 and "1234" and interchanged them a lot so I opted for this method so you know what you were getting and normalized the proxmox api in the client. I'm open for other suggestions....

<!-- gh-comment-id:1537757670 --> @luthermonson commented on GitHub (May 8, 2023): welp you would think so... but the API was returning 1234 and "1234" and interchanged them a lot so I opted for this method so you know what you were getting and normalized the proxmox api in the client. I'm open for other suggestions....
Author
Owner

@earentir commented on GitHub (May 8, 2023):

I have seen the API making funny replies but I assume on most fields it would always be an int type, maybe just force the output per case ? if an int is expected then check before and cast as int etc.

<!-- gh-comment-id:1537843120 --> @earentir commented on GitHub (May 8, 2023): I have seen the API making funny replies but I assume on most fields it would always be an int type, maybe just force the output per case ? if an int is expected then check before and cast as int etc.
Author
Owner

@luthermonson commented on GitHub (May 8, 2023):

that's what this does. this makes it so you dont have to make a custom unmarshaller for each type with a Uint64 that might accidently send a string but instead one unmarshaller for a StringOrUint64 takes care of your problem. When I wrote it at the time I couldn't think of anything better and thinking again about it... i can't think of anything better :/

<!-- gh-comment-id:1538731331 --> @luthermonson commented on GitHub (May 8, 2023): that's what this does. this makes it so you dont have to make a custom unmarshaller for each type with a Uint64 that might accidently send a string but instead one unmarshaller for a StringOrUint64 takes care of your problem. When I wrote it at the time I couldn't think of anything better and thinking again about it... i can't think of anything better :/
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-proxmox#10
No description provided.