随笔分类 -  golang

golang学习
摘要:1,基本操作 package main //etcd操作 import ( "context" "fmt" "go.etcd.io/etcd/clientv3" "time" ) func main() { cli,err := clientv3.New(clientv3.Config{ Endpo 阅读全文
posted @ 2021-01-22 11:35 pebblecome 阅读(1627) 评论(0) 推荐(1)
摘要:直接上代码示例 package main import ( "bytes" "encoding/binary" "encoding/gob" "encoding/json" "encoding/xml" "fmt" "os" ) type Website struct { Name string ` 阅读全文
posted @ 2021-01-22 11:30 pebblecome 阅读(197) 评论(0) 推荐(0)
摘要://生产者 package main import ( "bufio" "fmt" "github.com/nsqio/go-nsq" "os" "strings" ) var producer *nsq.Producer //初始化生产者 func initProducer(str string) 阅读全文
posted @ 2021-01-22 11:28 pebblecome 阅读(110) 评论(0) 推荐(0)
摘要:linkin开发的,最初是设计用来解决公司内被的海量日志传输问题是分布式数据流平台,可以运行在单台服务器上,也可以在多态服务器上部署形成集群,它提供了发布和订阅的功能,使用者可以发送数据到kafka中,也可以从kafka中读取数据,kafka具有高吞吐,低延迟,高容错等特点 生产者往kafka发送数 阅读全文
posted @ 2021-01-22 11:25 pebblecome 阅读(78) 评论(0) 推荐(0)
摘要:直接上demo package main import ( "context" "fmt" limt "go.uber.org/ratelimit" "golang.org/x/time/rate" "github.com/juju/ratelimit" "time" ) func Demo1() 阅读全文
posted @ 2021-01-22 11:24 pebblecome 阅读(73) 评论(0) 推荐(0)
摘要:var wg sync.WaitGroup type Result struct { path string data [md5.Size]byte } func md5AllByWaitGroup(root string) (map[string][md5.Size]byte,error) { c 阅读全文
posted @ 2021-01-22 10:49 pebblecome 阅读(211) 评论(0) 推荐(0)
摘要:冒泡排序 func bubbleSort(arr []int) []int { length := len(arr) for i :=0;i<length;i++{ for j :=0;j<length-1-i;j++{ if arr[j] >arr[j+1]{ arr[j],arr[j+1] = 阅读全文
posted @ 2021-01-22 10:46 pebblecome 阅读(83) 评论(0) 推荐(0)
摘要:先下载redis的包 go get -u github.com/go-redis/redis/v8 代码实现 //redis import ( "context" "fmt" "github.com/go-redis/redis/v8" "time" ) var rdb *redis.Client 阅读全文
posted @ 2021-01-22 10:35 pebblecome 阅读(158) 评论(0) 推荐(0)
摘要:简单的邮件发送实现 const ( HOST = "smtp.163.com" SERVER_ADDR = "smtp.163.com:25" USER = "xxxxx@163.com" PASSWORD = "" ) type Email struct { to string "to" subj 阅读全文
posted @ 2021-01-22 10:26 pebblecome 阅读(297) 评论(0) 推荐(0)