Golang 使用 JSON unmarshal 数字到 interface{} 数字变成 float64 类型
由于 JSON 里的数字默认都会转成 Golang 的 float64 类型引起的,
使用 Golang 解析 JSON 格式数据时,若以 interface{} 接收数据,则会按照下列规则进行解析:
bool, for JSON booleans
float64, for JSON numbers
string, for JSON strings
[]interface{}, for JSON arrays
map[string]interface{}, for JSON objects
nil for JSON null 而浮点数打印时的默认规则是超过一定长度后会换成科学计数法打印。
因此,只要在打印时指定打印格式,或者(按照LZ示例里是整数的情况时),转换为整数打印
fmt.Println( int( a[“id”].(float64) ) ) // 将 “id” 键申明为 float64 类型,再转换为 int 型
fmt.Println(time.Now().Format(“2010-10-10 15:04:05”))
结果输出了
9060-60-60 11:11:36
这什么鬼
百度了一个
fmt.Println(time.Now().Format(“2006-01-02 15:04:05”))
这就输出正确了
2017-06-09 11:12:39
为什么呢,没有问题什么,因为go语言最自恋最贱,据说那个日期是GO语言的诞生时间,一定要用这个日期格式化
glide update
[ERROR] Error scanning conf: cannot find package “.” in:
/Users/didi/.glide/cache/conf
glide i 解决
glide install and I am stuck with a problem:
[ERROR] Error scanning gitlab.myfirm.ru/golang/rkn/events: cannot find package “.” in:
/Users/droot/.glide/cache/src/https-gitlab.myfirm.ru-golang-rkn/events
f master have foo package and someBranch have also bar package when you make glide install glide also cache git branches and give from cache master branch as default.
The solution is cd /Users/droot/.glide/cache/src/https-gitlab.myfirm.ru-golang-rkn/ and checkout cache branch git checkout someBranch
设置多个gopath
#!/bin/bash
curDir=pwd
GOPATH=${curDir}/vendor/:/Users/didi/PhpstormProjects/go/
echo $GOPATH
clang: error: unsupported option ‘-fopenmp’
make: *** [coxph.o] Error 1
ERROR: compilation failed for package ‘mgcv’
Mac os下安装xgboost 却少依赖
brew install clang-omp