Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InsertJsonSample1 ¶
InsertJsonSample1 is interface{}突っ込んだら、雑にJsonにしてくれたりしないかなと思ったけど、ダメだった panic: spanner: code = "InvalidArgument", desc = "client doesn't support type *main.JsonBody"
Example ¶
何も考えずにinterface{}を突っ込んでみて、無理ですと言われている図
package main import ( "context" "fmt" "github.com/sinmetal/til/spanner/jsontype" ) func main() { ctx := context.Background() if err := jsontype.InsertJsonSample1(ctx); err != nil { fmt.Println(err.Error()) } }
Output: spanner: code = "InvalidArgument", desc = "client doesn't support type *jsontype.JsonBody"
func InsertJsonSample2 ¶
InsertJsonSample1 is interface{}突っ込んだら、雑にJsonにしてくれたりしないかなと思ったけど、ダメだった panic: spanner: code = "InvalidArgument", desc = "client doesn't support type *main.JsonBody"
Example ¶
[]byteにjsonを突っ込んでみて、やっぱりダメですと言われる図
package main import ( "context" "fmt" "github.com/sinmetal/til/spanner/jsontype" ) func main() { ctx := context.Background() if err := jsontype.InsertJsonSample2(ctx); err != nil { fmt.Println(err.Error()) } }
Output: spanner: code = "FailedPrecondition", desc = "Invalid value for column Json in table JsonSample: Expected JSON."
func InsertJsonSample3 ¶
InsertJsonSample1 is interface{}突っ込んだら、雑にJsonにしてくれたりしないかなと思ったけど、ダメだった panic: spanner: code = "InvalidArgument", desc = "client doesn't support type *main.JsonBody"
Example ¶
spanner.NullJSONを使った図
package main import ( "context" "fmt" "github.com/sinmetal/til/spanner/jsontype" ) func main() { ctx := context.Background() if err := jsontype.InsertJsonSample3(ctx); err != nil { fmt.Println(err.Error()) } }
Output: jsontype.Entity{ID:"sample", Json:spanner.NullJSON{Value:map[string]interface {}{"Count":100, "Date":"2021-08-30T13:00:00Z", "ID":"helloJson"}, Valid:true}}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.