
Go语言代码块示例
代码块示例
CrazyDemo
这个作者很懒,什么都没留下…
展开
-
Go语言ini文件操作
目录结构config.ini内容[kafka]address=127.0.0.1:9092chan_max_siz = 100000[etcd]address=127.0.0.1:2379timeOut=5collect_log_key=/logagent/%s/collect_configconfig.go内容package conftype Ap...原创 2020-01-26 14:13:09 · 500 阅读 · 1 评论 -
tail的简单应用
package mainimport ( "fmt" "github.com/hpcloud/tail" "time")func main() { filename := "./my.log" config := tail.Config{ ReOpen: true, // 重新打开 Follow: ...原创 2020-01-15 16:43:20 · 314 阅读 · 0 评论 -
kafka简单示例
package mainimport ( "fmt" "github.com/Shopify/sarama" //v1.19.0)// 基于sarama第三方库开发的kafka clientfunc main() { config := sarama.NewConfig() // tail包使用 config.Producer.RequiredAcks = sarama.Wa...原创 2020-01-15 16:43:01 · 622 阅读 · 0 评论 -
获取本机ip代码示例
import ( "fmt" "net" "strings")func GetOutBoundIP() (ip string, err error) { conn, err := net.Dial("udp", "8.8.8.8:80") if err != nil { return } defer conn.Close() localAddr := conn.Loca...原创 2020-01-15 16:42:26 · 370 阅读 · 0 评论