improve type conversion for gdb

This commit is contained in:
John 2019-09-03 00:06:24 +08:00
parent acd5e72f6c
commit e2906fba0b
5 changed files with 25 additions and 7 deletions

View File

@ -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()
}

View File

@ -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":

View File

@ -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