Closed ricardoalcantara closed 1 year ago
lol i like this little dig in the docs This extra level of encoding is sometimes used when communicating with JavaScript programs:
so i already accounted for this problem a couple times writing StringOr<type>
types which will sort of standardize this problem in the library. the string option is a valid solution but i liked to write some of the error checking around empty values and things cause the proxmox api can be a bit sketchy on typing sometimes... maybe you want to add a StringOrFLoat32
and just use that?
This time I tested the case where the field is empty too, so at least it's no breaking anymore. Since it's not working at the moment I would just set ,string
in the end so I could keep move on my project. I am new to GoLang to suggest more elaborate solution, I have been working with it for 3 months :) .
If you are okay with this simple solution for now, I don't mind creating a new PR later.
[Edit] I also noticed that all other float variables are float64, only the one I changed is float32, so even to calculation I have to make some casts, so my suggestion is also change CPULimit to float64 together in this change, what do you think about that?
that's exactly what i was going to do, i started a StringOrFloat64 already... ill get a PR up and cut a new alpha release
so just an FYI... i tested the ,string
idea and for the most part it was a mess and expected the value to always be a string and for some reason couldn't account for an empty string which was weird. the idea on the Or types was to be able to do both because I had found some APIs that were returning 1234
and another API returning a "1234"
when ultimately the struct and I wanted to reuse my structs. this is just go minutia you probably don't care about but i promise you it's an interesting problem to solve!
Thanks for your effort,I am eager to see that StringOrFloat64 implementation so I also could learn something new with it.
it's not as exciting as you might think :D ill merge and cut a new alpha soon
Yes it is, I learned a lot with your pull request, I will remember it forever xD, thanks.
I forgot to specify that it would came from string.
https://$PROXMOX_NODE_IP:8006/api2/json/nodes/$PROXMOX_NODE_NAME/qemu/$VMID/config
I actually didn't know about that, I learned if from here https://stackoverflow.com/a/9573928
I should have mapped something like this
This time I actually tested, sorry for the trouble!