
go语言
多多岛的小火车
从事大数据可视化工作,在空间大数据处理、分析、应用展示等方面有一定的研究
展开
-
go语言开发常见问题
1.CreateProcess failed with error 216 创建进程失败,应该是main这个入口文件的问题。 检查包名。发现问题,IDE自动将包名导成了当前的目录名(模块) 修改包名,改成main2.可见性规则Go语言中,使用大小写来决定该常量、变量、类型、接口、结构或函数是否可以被外部包所调用。函数名首字母小写即为 private :func getId()...原创 2018-06-27 18:16:32 · 418 阅读 · 0 评论 -
go实现rest服务解析
目标:解析百度交通拥堵道路排名的服务,并转成自己格式的服务func RoadRank(cityCode string) (*StatisticResult, error) { if cityCode == "" { return nil, errors.New("参数cityCode为空") } url := fmt.Sprintf(`http://j...原创 2018-07-10 19:33:45 · 673 阅读 · 0 评论 -
go实现mongodb查询
实现目标:根据条件,查询符合条件的mongodb中的记录func ParkInfoModel(city string, provinnce string, district string) ([]interface{}, error) { match := bson.M{} if city != "" { match["city"] = city }...原创 2018-07-10 19:36:39 · 1799 阅读 · 0 评论 -
go实现kafka推送
kafka生产者package pusherimport ( "encoding/json" "parkingEasy/g" "sync" "strings" "time" "github.com/Shopify/sarama" "github.com/astaxie/beego")var (原创 2018-07-10 20:00:01 · 1572 阅读 · 0 评论 -
go定时器使用
两个定时器,一个5s 定时执行一次,一个10s定时执行一次func startTimer() { t1 := time.NewTimer(time.Second * 5) t2 := time.NewTimer(time.Second * 10) for { select { case <-t1.C: pr...原创 2018-07-10 20:07:25 · 1466 阅读 · 0 评论 -
go defer延迟函数使用
A “defer” statement invokes a function whose execution is deferred to the moment the surrounding function returns, either because the surrounding function executed a return statement, reached the end ...转载 2018-07-11 10:44:51 · 271 阅读 · 0 评论 -
go init函数使用
Go里面有两个保留的函数:init函数(能够应用于所有的package)和main函数(只能应用于package main)。这两个函数在定义时不能有任何的参数和返回值。虽然一个package里面可以写任意多个init函数,但这无论是对于可读性还是以后的可维护性来说,我们都强烈建议用户在一个package中每个文件只写一个init函数。Go程序会自动调用init()和main(),所以你不需要...转载 2018-07-11 11:37:04 · 625 阅读 · 0 评论 -
go mongodb 模糊查询
根据某一个字段的关键字,查询mgo中的信息func GetOrdersByCity(city string)([]ParkingOrderModel,error){ query:=bson.M{"car_num" :bson.M{"$regex":city, "$options": "$i"}} var data []ParkingOrderModel expr:=f...原创 2018-07-12 16:46:19 · 4144 阅读 · 1 评论