forked from gobuffalo/pop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow for nulls to be registered with gorilla schema
- Loading branch information
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |