Skip to content

Conversation

@minglumlu
Copy link
Member

CP-49707: Go SDK: Add JSON tag for structs

This aims to allow a Go SDK client to unmarshal JSON to Go structs with
the function in Go json pacakge instead of using Go SDK.

The unmarshalling in Go SDK contains two steps: JSON -> map -> struct.
This is because some special cases need to be handled explicitly.
But for sake of safety, this unmarshalling is not exposed to clients.

CP-49349: Go SDK: Append UTC timezone to unix timestamp

The date time in Go requires a date time with timezone info. But XAPI
may return a UNIX timestamp to clients.

This commit blindly adds a UTC timezone for UNIX timestamps returned
from XAPI server.

CP-49349: Go SDK: Allow spaces in special value of float type

Some special values of float standing in JSON are handled specifically.
This commit allows the special values contain spaces.

@minglumlu minglumlu requested a review from xueqingz May 31, 2024 06:51
@minglumlu minglumlu force-pushed the private/mingl/add_json_tag branch from 58136ec to 510acd8 Compare May 31, 2024 09:27
minglumlu added 4 commits May 31, 2024 17:48
This aims to allow a Go SDK client to unmarshal JSON to Go structs with
the function in Go json pacakge instead of using Go SDK.

The unmarshalling in Go SDK contains two steps: JSON -> map -> struct.
This is because some special cases need to be handled explicitly.
But for sake of safety, this unmarshalling is not exposed to clients.

Signed-off-by: Ming Lu <ming.lu@cloud.com>
The date time in Go requires a date time with timezone info. But XAPI
may return a UNIX timestamp to clients.

This commit blindly adds a UTC timezone for UNIX timestamps returned
from XAPI server.

Signed-off-by: Ming Lu <ming.lu@cloud.com>
Some special values of float standing in JSON are handled specifically.
This commit allows the special values contain spaces.

Signed-off-by: Ming Lu <ming.lu@cloud.com>
This check complains the struct json tag naming style. It expects the
Caml style, but Go SDK has to use Snake.

Signed-off-by: Ming Lu <ming.lu@cloud.com>
@minglumlu minglumlu force-pushed the private/mingl/add_json_tag branch from 510acd8 to 589ec0a Compare May 31, 2024 09:49
Copy link
Contributor

@xueqingz xueqingz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Go SDK changes, run XenRT test pass with 4014903 ~ 4014912 for Next, 4014913 ~ 4014922 for Yangtze.

@xueqingz xueqingz requested a review from xihuan-citrix May 31, 2024 10:09
@xueqingz xueqingz merged commit 5042fd9 into xapi-project:feature/go_sdk May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants