商君

导航

随笔分类 -  Go语言基础

Go语言基础知识
Go 字符串连接+=与strings.Join性能对比
摘要:Go字符串连接 对于字符串的连接大致有两种方式: 1、通过+号连接 go func StrPlus1(a []string) string { var s, sep string for i := 0; i 阅读全文

posted @ 2018-12-10 19:52 漫步者01 阅读(9188) 评论(0) 推荐(1)

Go 包管理工具--glide
摘要:网上有一篇解释glide比较好的文章:https://my.oschina.net/u/553243/blog/1475626 在命令行中输入glide shell $glide NAME: glide Vendor Package Management for your Go projects. 阅读全文

posted @ 2018-11-05 15:53 漫步者01 阅读(219) 评论(0) 推荐(0)

Go-struct
摘要:1、struct说明 2、使用struct实现二叉树 go package main import "fmt" //二叉树定义 type tree struct { value int left, right tree } //堆排 func Sort(values []int) { var roo 阅读全文

posted @ 2018-10-31 15:10 漫步者01 阅读(101) 评论(0) 推荐(0)

go-json处理的问题
摘要:1、通过Decoder来解析json串 go package main import ( "encoding/json" "fmt" "io" "log" "strings" ) func main() { const jsonStream = ` {"Name":"Ed","Text":"Knoc 阅读全文

posted @ 2018-10-30 19:24 漫步者01 阅读(452) 评论(0) 推荐(0)

Go断言
摘要:golang的语言中提供了断言的功能。golang中的所有程序都实现了interface{}的接口,这意味着,所有的类型如string,int,int64甚至是自定义的struct类型都就此拥有了interface{}的接口,这种做法和java中的Object类型比较类似。那么在一个数据通过func 阅读全文

posted @ 2018-10-30 11:38 漫步者01 阅读(372) 评论(0) 推荐(0)