Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ linters:
- testpackage # makes you use a separate _test package
- decorder # checks declaration order and count of types, constants, variables and functions
- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- tagliatelle # checks the struct tags
- godox # detects FIXME, TODO and other comment keywords
- gci # controls golang package import order and makes it always deterministic
- tagalign # checks that struct tags are well aligned
Expand All @@ -78,6 +77,7 @@ linters:


## disabled
#- tagliatelle # checks the struct tags
#- goconst # finds repeated strings that could be replaced by a constant
#- gochecknoglobals # checks that no global variables exist
#- gocyclo # computes and checks the cyclomatic complexity of functions
Expand Down
10 changes: 7 additions & 3 deletions ocaml/sdk-gen/go/autogen/src/jsonrpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"net/http"
"net/url"
"os"
"regexp"
"strings"
"time"
)
Expand Down Expand Up @@ -66,9 +67,12 @@ func (client *rpcClient) newRequest(ctx context.Context, req interface{}) (*http

func convertUnhandledJSONData(jsonBytes []byte) []byte {
jsonString := string(jsonBytes)
jsonString = strings.ReplaceAll(jsonString, ":Infinity", ":\"+Inf\"")
jsonString = strings.ReplaceAll(jsonString, ":-Infinity", ":\"-Inf\"")
jsonString = strings.ReplaceAll(jsonString, ":NaN", ":\"NaN\"")
re := regexp.MustCompile(`:[ ]*-Infinity`)
jsonString = re.ReplaceAllString(jsonString, `:"-Inf"`)
re = regexp.MustCompile(`:[ +]*Infinity`)
jsonString = re.ReplaceAllString(jsonString, `:"+Inf"`)
re = regexp.MustCompile(`:[ ]*NaN`)
jsonString = re.ReplaceAllString(jsonString, `:"NaN"`)

return []byte(jsonString)
}
Expand Down
2 changes: 2 additions & 0 deletions ocaml/sdk-gen/go/gen_go_helper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ module Json = struct
`O
[
("name", `String (concat_and_convert field))
; ("json_name", `String (String.concat "_" field.full_name))
; ("description", `String (String.trim field.field_description))
; ("type", `String ty)
]
Expand Down Expand Up @@ -217,6 +218,7 @@ module Json = struct
`O
[
("name", `String "Snapshot")
; ("json_name", `String "snapshot")
; ( "description"
, `String
"The record of the database object that was added, changed or \
Expand Down
4 changes: 2 additions & 2 deletions ocaml/sdk-gen/go/templates/ConvertTime.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ 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)
value = time.Unix(unixTimestamp, 0).UTC()

return
}

{{/deserialize}}
{{/deserialize}}
10 changes: 5 additions & 5 deletions ocaml/sdk-gen/go/templates/Record.mustache
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type {{name}}Record struct {
{{#fields}}
//{{#description}} {{.}}{{/description}}
{{name}} {{type}}
{{name}} {{type}} `json:"{{json_name}},omitempty"`
{{/fields}}
}

Expand All @@ -11,9 +11,9 @@ type {{name}}Ref string
type RecordInterface interface{}

type EventBatch struct {
Token string
ValidRefCounts map[string]int
Events []EventRecord
Token string `json:"token,omitempty"`
ValidRefCounts map[string]int `json:"validRefCounts,omitempty"`
Events []EventRecord `json:"events,omitempty"`
}

{{/event}}
Expand All @@ -40,4 +40,4 @@ func NewSession(opts *ClientOpts) *Session {
type {{name_internal}} struct{}

var {{name}} {{name_internal}}
{{/session}}
{{/session}}
6 changes: 3 additions & 3 deletions ocaml/sdk-gen/go/test_data/record.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type SessionRecord struct {
// Unique identifier/object reference
UUID string
UUID string `json:"uuid,omitempty"`
// Currently connected host
ThisHost HostRef
ThisHost HostRef `json:"thishost,omitempty"`
}

type SessionRef string
Expand All @@ -21,4 +21,4 @@ func NewSession(opts *ClientOpts) *Session {
session.client = client

return &session
}
}
4 changes: 2 additions & 2 deletions ocaml/sdk-gen/go/test_data/time_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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)
value = time.Unix(unixTimestamp, 0).UTC()

return
}
}
9 changes: 7 additions & 2 deletions ocaml/sdk-gen/go/test_gen_go.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ let schema_check keys checker members =
compare_keys keys keys' && List.for_all checker members

let verify_field_member = function
| "name", `String _ | "description", `String _ | "type", `String _ ->
| "name", `String _
| "description", `String _
| "type", `String _
| "json_name", `String _ ->
true
| _ ->
false

let field_keys = ["name"; "description"; "type"]
let field_keys = ["name"; "description"; "type"; "json_name"]

let verify_field = function
| `O members ->
Expand Down Expand Up @@ -558,12 +561,14 @@ let record : Mustache.Json.t =
`O
[
("name", `String "UUID")
; ("json_name", `String "uuid")
; ("description", `String "Unique identifier/object reference")
; ("type", `String "string")
]
; `O
[
("name", `String "ThisHost")
; ("json_name", `String "thishost")
; ("description", `String "Currently connected host")
; ("type", `String "HostRef")
]
Expand Down