mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 03:07:45 +08:00
improve type conversion for gdb
This commit is contained in:
parent
acd5e72f6c
commit
e2906fba0b
@ -1,13 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/internal/utilbytes"
|
||||
"os"
|
||||
|
||||
"github.com/olekukonko/tablewriter"
|
||||
)
|
||||
|
||||
func main() {
|
||||
b := []byte{48, 49, 50, 51, 52, 53}
|
||||
fmt.Println(string(b))
|
||||
fmt.Println([]byte("\xff\xff"))
|
||||
fmt.Printf(utilbytes.Export(b))
|
||||
data := [][]string{
|
||||
[]string{"1/1/2014", "Domain name", "2233", "$10.98"},
|
||||
[]string{"1/1/2014", "January Hosting", "2233", "$54.95"},
|
||||
[]string{"1/4/2014", "February Hosting", "2233", "$51.00"},
|
||||
[]string{"1/4/2014", "February Extra Bandwidth", "2233", "$30.00"},
|
||||
}
|
||||
|
||||
table := tablewriter.NewWriter(os.Stdout)
|
||||
table.SetBorder(false)
|
||||
table.SetRowLine(false)
|
||||
table.SetColumnSeparator("")
|
||||
table.AppendBulk(data)
|
||||
table.Render()
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/text/gstr"
|
||||
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
|
||||
"github.com/gogf/gf/encoding/gbinary"
|
||||
@ -27,9 +29,15 @@ func (bs *dbBase) convertValue(fieldValue []byte, fieldType string) interface{}
|
||||
return fieldValue
|
||||
|
||||
case "int", "tinyint", "small_int", "medium_int":
|
||||
if gstr.ContainsI(fieldType, "unsigned") {
|
||||
gconv.Uint(string(fieldValue))
|
||||
}
|
||||
return gconv.Int(string(fieldValue))
|
||||
|
||||
case "big_int":
|
||||
if gstr.ContainsI(fieldType, "unsigned") {
|
||||
gconv.Uint64(string(fieldValue))
|
||||
}
|
||||
return gconv.Int64(string(fieldValue))
|
||||
|
||||
case "float", "double", "decimal":
|
||||
|
@ -41,7 +41,7 @@ func GetContent(file ...string) string {
|
||||
return configs.Get(name)
|
||||
}
|
||||
|
||||
// RemoveConfig removes the global configuration with specified group.
|
||||
// RemoveConfig removes the global configuration with specified <file>.
|
||||
// If <name> is not passed, it removes configuration of the default group name.
|
||||
func RemoveConfig(file ...string) {
|
||||
name := DEFAULT_CONFIG_FILE
|
||||
|
Loading…
Reference in New Issue
Block a user