Skip to content

CA-430573: Use int64 in Go SDK - #7232

Open
xueqingz wants to merge 1 commit into
xapi-project:masterfrom
xueqingz:private/xueqingz/CA-430573
Open

CA-430573: Use int64 in Go SDK#7232
xueqingz wants to merge 1 commit into
xapi-project:masterfrom
xueqingz:private/xueqingz/CA-430573

Conversation

@xueqingz

Copy link
Copy Markdown
Contributor

No description provided.

@xueqingz

Copy link
Copy Markdown
Contributor Author

SDK test pass on XenRT job 4718034, 4718035.

@xueqingz
xueqingz force-pushed the private/xueqingz/CA-430573 branch from cb43a3f to 7c325ed Compare August 20, 2026 06:26
return
}
strValue := fmt.Sprintf("%v", input)
floatValue, err := strconv.ParseFloat(strValue, 64)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we want an int64 in line 55, should we have first tried to use ParseInt here and then ParseFloat only if the former fails?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, good point, let me update.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it again, here the input is the data time, like :

"20220101T123045" 
"20220101T123045Z"
"20220101T123045+03"
"20220101T123045+0300"
"20220101T123045+03:00"
"20220101T123045.123"
"20220101T123045.123Z"
"20220101T123045.123+03
"20220101T123045.123+0300"
"20220101T123045.123+03:00"
"20220101T12:30:45"
"20220101T12:30:45Z"
"20220101T12:30:45+03"
"20220101T12:30:45+0300"
"20220101T12:30:45+03:00"
...

so mostly the value is parse by value, err = time.Parse(timeFormat, strValue).
The epoch value is int64-valued, but it never arrives as a parseable integer string. Over JSON-RPC, a JSON number decodes to Go float64 (Go's encoding/json always uses float64 for numbers into interface{}.) ParseInt can't read "1.7e+09", so ParseFloat is the correct primary parser and the separate int parse adds nothing.
So I prefer to keep the origin changes.

Comment thread ocaml/sdk-gen/go/test_data/time_convert.go
@xueqingz
xueqingz force-pushed the private/xueqingz/CA-430573 branch 2 times, most recently from bcd6f8e to 0f40e47 Compare August 21, 2026 09:55
Signed-off-by: Sola.Zhang <Sola.Zhang@cloud.com>
@xueqingz
xueqingz force-pushed the private/xueqingz/CA-430573 branch from 0f40e47 to 63e63d3 Compare August 21, 2026 10:25
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.

2 participants