diff --git a/.github/workflows/generate-and-build-sdks.yml b/.github/workflows/generate-and-build-sdks.yml index 87046d45d17..1e19032fa56 100644 --- a/.github/workflows/generate-and-build-sdks.yml +++ b/.github/workflows/generate-and-build-sdks.yml @@ -65,7 +65,6 @@ jobs: path: | _build/install/default/share/go/* !_build/install/default/share/go/dune - !_build/install/default/share/go/**/*_test.go # sdk-ci runs some Go unit tests. # This setting ensures that SDK date time diff --git a/.github/workflows/go-ci/action.yml b/.github/workflows/go-ci/action.yml index 30bcbfee923..c1b2df7f1e1 100644 --- a/.github/workflows/go-ci/action.yml +++ b/.github/workflows/go-ci/action.yml @@ -14,11 +14,6 @@ runs: working-directory: ${{ github.workspace }}/_build/install/default/share/go/src args: --config=${{ github.workspace }}/.golangci.yml - - name: Run Go Tests - shell: bash - working-directory: ${{ github.workspace }}/_build/install/default/share/go/src - run: go test -v - - name: Run CI for Go SDK shell: bash run: | diff --git a/ocaml/sdk-gen/component-test/jsonrpc-client/go/datetime_test.go b/ocaml/sdk-gen/component-test/jsonrpc-client/go/datetime_test.go new file mode 100644 index 00000000000..24277eb736e --- /dev/null +++ b/ocaml/sdk-gen/component-test/jsonrpc-client/go/datetime_test.go @@ -0,0 +1,67 @@ +package componenttest + +import ( + "testing" + "time" + + "xenapi" +) + +func TestDateDeserialization(t *testing.T) { + utc := time.UTC + plus3 := time.FixedZone("", 3*60*60) + vmRef := xenapi.VMRef("OpaqueRef:datetime") + + cases := []struct { + testID string + want time.Time + }{ + // no dashes, no colons + {"xapi-24/datetime_01", time.Date(2022, 1, 1, 12, 30, 45, 0, utc)}, + {"xapi-24/datetime_02", time.Date(2022, 1, 1, 12, 30, 45, 0, utc)}, + {"xapi-24/datetime_03", time.Date(2022, 1, 1, 12, 30, 45, 0, plus3)}, + {"xapi-24/datetime_04", time.Date(2022, 1, 1, 12, 30, 45, 0, plus3)}, + {"xapi-24/datetime_05", time.Date(2022, 1, 1, 12, 30, 45, 0, plus3)}, + {"xapi-24/datetime_06", time.Date(2022, 1, 1, 12, 30, 45, 123000000, utc)}, + {"xapi-24/datetime_07", time.Date(2022, 1, 1, 12, 30, 45, 123000000, utc)}, + {"xapi-24/datetime_08", time.Date(2022, 1, 1, 12, 30, 45, 123000000, plus3)}, + {"xapi-24/datetime_09", time.Date(2022, 1, 1, 12, 30, 45, 123000000, plus3)}, + {"xapi-24/datetime_10", time.Date(2022, 1, 1, 12, 30, 45, 123000000, plus3)}, + // no dashes, with colons + {"xapi-24/datetime_11", time.Date(2022, 1, 1, 12, 30, 45, 0, utc)}, + {"xapi-24/datetime_12", time.Date(2022, 1, 1, 12, 30, 45, 0, utc)}, + {"xapi-24/datetime_13", time.Date(2022, 1, 1, 12, 30, 45, 0, plus3)}, + {"xapi-24/datetime_14", time.Date(2022, 1, 1, 12, 30, 45, 0, plus3)}, + {"xapi-24/datetime_15", time.Date(2022, 1, 1, 12, 30, 45, 0, plus3)}, + {"xapi-24/datetime_16", time.Date(2022, 1, 1, 12, 30, 45, 123000000, utc)}, + {"xapi-24/datetime_17", time.Date(2022, 1, 1, 12, 30, 45, 123000000, utc)}, + {"xapi-24/datetime_18", time.Date(2022, 1, 1, 12, 30, 45, 123000000, plus3)}, + {"xapi-24/datetime_19", time.Date(2022, 1, 1, 12, 30, 45, 123000000, plus3)}, + {"xapi-24/datetime_20", time.Date(2022, 1, 1, 12, 30, 45, 123000000, plus3)}, + // dashes and colons + {"xapi-24/datetime_21", time.Date(2022, 1, 1, 12, 30, 45, 0, utc)}, + {"xapi-24/datetime_22", time.Date(2022, 1, 1, 12, 30, 45, 0, utc)}, + {"xapi-24/datetime_23", time.Date(2022, 1, 1, 12, 30, 45, 0, plus3)}, + {"xapi-24/datetime_24", time.Date(2022, 1, 1, 12, 30, 45, 0, plus3)}, + {"xapi-24/datetime_25", time.Date(2022, 1, 1, 12, 30, 45, 0, plus3)}, + {"xapi-24/datetime_26", time.Date(2022, 1, 1, 12, 30, 45, 123000000, utc)}, + {"xapi-24/datetime_27", time.Date(2022, 1, 1, 12, 30, 45, 123000000, utc)}, + {"xapi-24/datetime_28", time.Date(2022, 1, 1, 12, 30, 45, 123000000, plus3)}, + } + + for _, c := range cases { + t.Run(c.testID, func(t *testing.T) { + session, err := GetSession(c.testID) + if err != nil { + t.Fatalf("GetSession(%s): %v", c.testID, err) + } + got, err := xenapi.VM.GetSnapshotTime(session, vmRef) + if err != nil { + t.Fatalf("GetSnapshotTime(%s): %v", c.testID, err) + } + if !c.want.Equal(got) { + t.Fatalf("%s: expected %v, got %v", c.testID, c.want, got) + } + }) + } +} diff --git a/ocaml/sdk-gen/component-test/spec/xapi-24/datetime.json b/ocaml/sdk-gen/component-test/spec/xapi-24/datetime.json new file mode 100644 index 00000000000..a5197fedb15 --- /dev/null +++ b/ocaml/sdk-gen/component-test/spec/xapi-24/datetime.json @@ -0,0 +1,30 @@ +{ + "xapi-24/datetime_01": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T123045" } } }, + "xapi-24/datetime_02": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T123045Z" } } }, + "xapi-24/datetime_03": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T123045+03" } } }, + "xapi-24/datetime_04": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T123045+0300" } } }, + "xapi-24/datetime_05": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T123045+03:00" } } }, + "xapi-24/datetime_06": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T123045.123" } } }, + "xapi-24/datetime_07": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T123045.123Z" } } }, + "xapi-24/datetime_08": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T123045.123+03" } } }, + "xapi-24/datetime_09": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T123045.123+0300" } } }, + "xapi-24/datetime_10": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T123045.123+03:00" } } }, + "xapi-24/datetime_11": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T12:30:45" } } }, + "xapi-24/datetime_12": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T12:30:45Z" } } }, + "xapi-24/datetime_13": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T12:30:45+03" } } }, + "xapi-24/datetime_14": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T12:30:45+0300" } } }, + "xapi-24/datetime_15": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T12:30:45+03:00" } } }, + "xapi-24/datetime_16": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T12:30:45.123" } } }, + "xapi-24/datetime_17": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T12:30:45.123Z" } } }, + "xapi-24/datetime_18": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T12:30:45.123+03" } } }, + "xapi-24/datetime_19": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T12:30:45.123+0300" } } }, + "xapi-24/datetime_20": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "20220101T12:30:45.123+03:00" } } }, + "xapi-24/datetime_21": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "2022-01-01T12:30:45" } } }, + "xapi-24/datetime_22": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "2022-01-01T12:30:45Z" } } }, + "xapi-24/datetime_23": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "2022-01-01T12:30:45+03" } } }, + "xapi-24/datetime_24": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "2022-01-01T12:30:45+0300" } } }, + "xapi-24/datetime_25": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "2022-01-01T12:30:45+03:00" } } }, + "xapi-24/datetime_26": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "2022-01-01T12:30:45.123" } } }, + "xapi-24/datetime_27": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "2022-01-01T12:30:45.123Z" } } }, + "xapi-24/datetime_28": { "method": ["VM.get_snapshot_time"], "params": { "VM.get_snapshot_time": ["", "OpaqueRef:datetime"] }, "expected_result": { "VM.get_snapshot_time": { "result": "2022-01-01T12:30:45.123+03" } } } +} diff --git a/ocaml/sdk-gen/go/autogen/src/convert_test.go b/ocaml/sdk-gen/go/autogen/src/convert_test.go deleted file mode 100644 index 48dabc82898..00000000000 --- a/ocaml/sdk-gen/go/autogen/src/convert_test.go +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) Cloud Software Group, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package xenapi_test - -import ( - "testing" - "time" - - "go/xenapi" -) - -func TestDateDeseralization(t *testing.T) { - dates := map[string]time.Time{ - // no dashes, no colons - "20220101T123045": time.Date(2022, 1, 1, 12, 30, 45, 0, time.UTC), - "20220101T123045Z": time.Date(2022, 1, 1, 12, 30, 45, 0, time.UTC), - "20220101T123045+03": time.Date(2022, 1, 1, 12, 30, 45, 0, time.FixedZone("", 3*60*60)), // +03 timezone - "20220101T123045+0300": time.Date(2022, 1, 1, 12, 30, 45, 0, time.FixedZone("", 3*60*60)), - "20220101T123045+03:00": time.Date(2022, 1, 1, 12, 30, 45, 0, time.FixedZone("", 3*60*60)), - - "20220101T123045.123": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.UTC), - "20220101T123045.123Z": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.UTC), - "20220101T123045.123+03": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.FixedZone("", 3*60*60)), - "20220101T123045.123+0300": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.FixedZone("", 3*60*60)), - "20220101T123045.123+03:00": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.FixedZone("", 3*60*60)), - - // no dashes, with colons - "20220101T12:30:45": time.Date(2022, 1, 1, 12, 30, 45, 0, time.UTC), - "20220101T12:30:45Z": time.Date(2022, 1, 1, 12, 30, 45, 0, time.UTC), - "20220101T12:30:45+03": time.Date(2022, 1, 1, 12, 30, 45, 0, time.FixedZone("", 3*60*60)), - "20220101T12:30:45+0300": time.Date(2022, 1, 1, 12, 30, 45, 0, time.FixedZone("", 3*60*60)), - "20220101T12:30:45+03:00": time.Date(2022, 1, 1, 12, 30, 45, 0, time.FixedZone("", 3*60*60)), - - "20220101T12:30:45.123": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.UTC), - "20220101T12:30:45.123Z": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.UTC), - "20220101T12:30:45.123+03": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.FixedZone("", 3*60*60)), - "20220101T12:30:45.123+0300": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.FixedZone("", 3*60*60)), - "20220101T12:30:45.123+03:00": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.FixedZone("", 3*60*60)), - - // dashes and colons - "2022-01-01T12:30:45": time.Date(2022, 1, 1, 12, 30, 45, 0, time.UTC), - "2022-01-01T12:30:45Z": time.Date(2022, 1, 1, 12, 30, 45, 0, time.UTC), - "2022-01-01T12:30:45+03": time.Date(2022, 1, 1, 12, 30, 45, 0, time.FixedZone("", 3*60*60)), - "2022-01-01T12:30:45+0300": time.Date(2022, 1, 1, 12, 30, 45, 0, time.FixedZone("", 3*60*60)), - "2022-01-01T12:30:45+03:00": time.Date(2022, 1, 1, 12, 30, 45, 0, time.FixedZone("", 3*60*60)), - - "2022-01-01T12:30:45.123": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.UTC), - "2022-01-01T12:30:45.123Z": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.UTC), - "2022-01-01T12:30:45.123+03": time.Date(2022, 1, 1, 12, 30, 45, 123000000, time.FixedZone("", 3*60*60)), - } - for input, expected := range dates { - t.Run("Input:"+input, func(t *testing.T) { - result, err := xenapi.DeserializeTime("", input) - if err == nil { - matching := expected.Equal(result) - if !matching { - t.Fatalf(`Failed to find match for '%s'`, input) - } - } else { - t.Fatalf(`Failed to find match for '%s'`, input) - } - }) - } -} diff --git a/ocaml/sdk-gen/go/autogen/src/export_test.go b/ocaml/sdk-gen/go/autogen/src/export_test.go deleted file mode 100644 index 5dbdbeb47e3..00000000000 --- a/ocaml/sdk-gen/go/autogen/src/export_test.go +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Cloud Software Group, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// This file contains exports of private functions specifically for testing purposes. -// It allows test code to access and verify the behavior of internal functions within the `xenapi` package. - -package xenapi - -// DeserializeTime is a private function that deserializes a time value. -// It is exported for testing to allow verification of its functionality. -var DeserializeTime = deserializeTime diff --git a/ocaml/sdk-gen/go/gen_go_helper.ml b/ocaml/sdk-gen/go/gen_go_helper.ml index 9269acc1357..a02483f9ea1 100644 --- a/ocaml/sdk-gen/go/gen_go_helper.ml +++ b/ocaml/sdk-gen/go/gen_go_helper.ml @@ -131,7 +131,7 @@ module Json = struct | SecretString | String -> ("string", StringMap.empty) | Int -> - ("int", StringMap.empty) + ("int64", StringMap.empty) | Float -> ("float64", StringMap.empty) | Bool -> @@ -721,7 +721,7 @@ module Convert = struct | SecretString | String -> Simple {func_suffix= "String"; value_ty= "string"} | Int -> - Int {func_suffix= "Int"; value_ty= "int"} + Int {func_suffix= "Int"; value_ty= "int64"} | Float -> Float {func_suffix= "Float"; value_ty= "float64"} | Bool -> diff --git a/ocaml/sdk-gen/go/templates/APIVersions.mustache b/ocaml/sdk-gen/go/templates/APIVersions.mustache index 6c25e5a7035..5a2036d6aa0 100644 --- a/ocaml/sdk-gen/go/templates/APIVersions.mustache +++ b/ocaml/sdk-gen/go/templates/APIVersions.mustache @@ -33,7 +33,7 @@ var APIVersionMap = map[string]APIVersion{ "APIVersionUnknown": APIVersionUnknown, } -func GetAPIVersion(major int, minor int) APIVersion { +func GetAPIVersion(major int64, minor int64) APIVersion { versionName := fmt.Sprintf("APIVersion%d_%d", major, minor) apiVersion, ok := APIVersionMap[versionName] if !ok { diff --git a/ocaml/sdk-gen/go/templates/ConvertInt.mustache b/ocaml/sdk-gen/go/templates/ConvertInt.mustache index dbc7cf37c56..c4010f45004 100644 --- a/ocaml/sdk-gen/go/templates/ConvertInt.mustache +++ b/ocaml/sdk-gen/go/templates/ConvertInt.mustache @@ -12,11 +12,11 @@ func deserialize{{func_name_suffix}}(context string, input interface{}) (value { return } strValue := fmt.Sprintf("%v", input) - value, err = strconv.Atoi(strValue) + value, err = strconv.ParseInt(strValue, 10, 64) if err != nil { floatValue, err1 := strconv.ParseFloat(strValue, 64) if err1 == nil { - return int(floatValue), nil + return int64(floatValue), nil } } return diff --git a/ocaml/sdk-gen/go/templates/ConvertTime.mustache b/ocaml/sdk-gen/go/templates/ConvertTime.mustache index d6f0e2a63d5..07031b03743 100644 --- a/ocaml/sdk-gen/go/templates/ConvertTime.mustache +++ b/ocaml/sdk-gen/go/templates/ConvertTime.mustache @@ -52,8 +52,7 @@ func deserialize{{func_name_suffix}}(context string, input interface{}) (value { } return } - unixTimestamp, err := strconv.ParseInt(strconv.Itoa(int(floatValue)), 10, 64) - value = time.Unix(unixTimestamp, 0).UTC() + value = time.Unix(int64(floatValue), 0).UTC() return } diff --git a/ocaml/sdk-gen/go/templates/Record.mustache b/ocaml/sdk-gen/go/templates/Record.mustache index 8b10dc04ab7..172e507b591 100644 --- a/ocaml/sdk-gen/go/templates/Record.mustache +++ b/ocaml/sdk-gen/go/templates/Record.mustache @@ -11,9 +11,9 @@ type {{name}}Ref string type RecordInterface interface{} type EventBatch struct { - Token string `json:"token,omitempty"` - ValidRefCounts map[string]int `json:"validRefCounts,omitempty"` - Events []EventRecord `json:"events,omitempty"` + Token string `json:"token,omitempty"` + ValidRefCounts map[string]int64 `json:"validRefCounts,omitempty"` + Events []EventRecord `json:"events,omitempty"` } {{/event}} diff --git a/ocaml/sdk-gen/go/test_data/api_versions.go b/ocaml/sdk-gen/go/test_data/api_versions.go index b82411d5413..8819d9e5200 100644 --- a/ocaml/sdk-gen/go/test_data/api_versions.go +++ b/ocaml/sdk-gen/go/test_data/api_versions.go @@ -33,7 +33,7 @@ var APIVersionMap = map[string]APIVersion{ "APIVersionUnknown": APIVersionUnknown, } -func GetAPIVersion(major int, minor int) APIVersion { +func GetAPIVersion(major int64, minor int64) APIVersion { versionName := fmt.Sprintf("APIVersion%d_%d", major, minor) apiVersion, ok := APIVersionMap[versionName] if !ok { diff --git a/ocaml/sdk-gen/go/test_data/int_convert.go b/ocaml/sdk-gen/go/test_data/int_convert.go index 0688dffa600..33459b8a6dd 100644 --- a/ocaml/sdk-gen/go/test_data/int_convert.go +++ b/ocaml/sdk-gen/go/test_data/int_convert.go @@ -1,19 +1,19 @@ -func serializeInt(context string, value int) (int, error) { +func serializeInt(context string, value int64) (int64, error) { _ = context return value, nil } -func deserializeInt(context string, input interface{}) (value int, err error) { +func deserializeInt(context string, input interface{}) (value int64, err error) { _ = context if input == nil { return } strValue := fmt.Sprintf("%v", input) - value, err = strconv.Atoi(strValue) + value, err = strconv.ParseInt(strValue, 10, 64) if err != nil { floatValue, err1 := strconv.ParseFloat(strValue, 64) if err1 == nil { - return int(floatValue), nil + return int64(floatValue), nil } } return diff --git a/ocaml/sdk-gen/go/test_data/time_convert.go b/ocaml/sdk-gen/go/test_data/time_convert.go index d9d5483d5b3..b52a1153ba0 100644 --- a/ocaml/sdk-gen/go/test_data/time_convert.go +++ b/ocaml/sdk-gen/go/test_data/time_convert.go @@ -49,8 +49,7 @@ func deserializeTime(context string, input interface{}) (value time.Time, err er } return } - unixTimestamp, err := strconv.ParseInt(strconv.Itoa(int(floatValue)), 10, 64) - value = time.Unix(unixTimestamp, 0).UTC() + value = time.Unix(int64(floatValue), 0).UTC() return } diff --git a/ocaml/sdk-gen/go/test_gen_go.ml b/ocaml/sdk-gen/go/test_gen_go.ml index 8683099ff2c..690550dec00 100644 --- a/ocaml/sdk-gen/go/test_gen_go.ml +++ b/ocaml/sdk-gen/go/test_gen_go.ml @@ -682,7 +682,7 @@ let simple_type_convert : Mustache.Json.t = let int_convert : Mustache.Json.t = let array = - [`O [("func_name_suffix", `String "Int"); ("type", `String "int")]] + [`O [("func_name_suffix", `String "Int"); ("type", `String "int64")]] in `O [("serialize", `A array); ("deserialize", `A array)] @@ -1506,7 +1506,7 @@ module StringOfTyWithEnumsTest = struct verify "option" verify_option (ty, enums) let verify_map (ty, enums) = - ty = "map[int]UpdateSync" + ty = "map[int64]UpdateSync" && enums = StringMap.singleton "UpdateSync" enum_lst let test_map () =