json.Marshal(struct) returns “{}”

You need to export the fields in TestObject by capitalizing the first letter in the field name. Change kind to Kind and so on. type TestObject struct { Kind string `json:”kind”` Id string `json:”id,omitempty”` Name string `json:”name”` Email string `json:”email”` } The encoding/json package and similar packages ignore unexported fields. The `json:”…”` strings that follow … Read more

Is it possible to get all arguments of a function as single object inside that function?

For modern Javascript or Typescript: class Foo { reallyCoolMethodISwear(…args) { return args.length; } } function reallyCoolFunction(i, …args) { return args[i]; } const allHailTheLambda = (…args) => { return args.constructor == Array; }; const x = new Foo().reallyCoolMethodISwear(0, 1, 2, 3, 4); const y = reallyCoolFunction(3, 0, 1, 2, 3, 4, 5, 6); const z = … Read more

What is the difference between Serialization and Marshaling?

Marshaling and serialization are loosely synonymous in the context of remote procedure call, but semantically different as a matter of intent. In particular, marshaling is about getting parameters from here to there, while serialization is about copying structured data to or from a primitive form such as a byte stream. In this sense, serialization is … Read more

tech