Skip to content

Commit

Permalink
allow for nulls to be registered with gorilla schema
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Feb 3, 2017
1 parent 661865a commit d1188ad
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
59 changes: 59 additions & 0 deletions nulls/schema.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package nulls

import "reflect"

type register func(interface{}, func(string) reflect.Value)

// RegisterWithSchema allows for the nulls package to be used with http://www.gorillatoolkit.org/pkg/schema#Converter
func RegisterWithSchema(reg register) {
reg(String{}, func(s string) reflect.Value {
ns := String{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Bool{}, func(s string) reflect.Value {
ns := Bool{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(ByteSlice{}, func(s string) reflect.Value {
ns := ByteSlice{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Float32{}, func(s string) reflect.Value {
ns := Float32{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Float64{}, func(s string) reflect.Value {
ns := Float64{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Int{}, func(s string) reflect.Value {
ns := Int{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Int32{}, func(s string) reflect.Value {
ns := Int32{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Int64{}, func(s string) reflect.Value {
ns := Int64{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(Time{}, func(s string) reflect.Value {
ns := Time{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
reg(UInt32{}, func(s string) reflect.Value {
ns := UInt32{}
ns.Scan(s)
return reflect.ValueOf(ns)
})
}
2 changes: 1 addition & 1 deletion soda/cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package cmd

const Version = "3.11.1"
const Version = "3.11.2"

0 comments on commit d1188ad

Please sign in to comment.