摘要: 使用第三方模块 "github.com/hpcloud/tail" 初始化Tail指针 package logtail import ( "fmt" "github.com/hpcloud/tail" ) var ( tailObj *tail.Tail ) func Init(path strin 阅读全文
posted @ 2022-05-25 22:18 SpecialSpeculator 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 依赖第三方包 "github.com/Shopify/sarama" 1.初始化异步生产者对象 package kafka import ( "fmt" "github.com/Shopify/sarama" ) var ( producer sarama.AsyncProducer ) func 阅读全文
posted @ 2022-05-25 22:14 SpecialSpeculator 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 1.解析ini配置文件 config.ini [kafka] address=127.0.0.1:9092 topic=web_log [logtail] path=./my.log 对应的结构体 package conf type KafkaConfig struct { Address []st 阅读全文
posted @ 2022-05-25 22:11 SpecialSpeculator 阅读(211) 评论(0) 推荐(0) 编辑