内容简介:方式一:brew install go方式二:官网下载推荐这种方式,可以选择尽量新的版本,默认安装路径为/usr/local/go,然后设置path
go语言环境搭建
sdk
方式一:brew install go
方式二:官网下载 golang
推荐这种方式,可以选择尽量新的版本,默认安装路径为/usr/local/go,然后设置path
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
GOPATH默认为~/go,也可以设置export GOPATH=你想设置的目录,多个用冒号隔开,windows用分号
ps:记得source
image
ide
方式一:golang
方式二:idea
但是笔者认为都是同一家族的,只想安装插件,所以选择idea。
如果已经安装,请查看当前idea的版本, 注意要求idea的版本不低于2017.3 ,因为低版本没有对 go 的插件支持
如果已经安装了老的版本,可以再到官网下载 Download IntelliJ IDEA: The Java IDE for Professional Developers by JetBrains 安装个新的,共用同一份设置,两者并存,笔者就是这么做的,哈哈。
image
安装go插件
方式一:通过idea找到插件之后,点击install按钮,安装完然后重启
image
方式二:通过官网下载 Go - Plugins | JetBrains 插件包
记得要找支持自己idea版本的插件下载到本地,笔者根据自己idea的版本选择的182最新的版本
image
然后idea安装下载的插件然后重启
image
python2
brew install python@2
virtualenv
pip install virtualenv
beats
git clone 源码
mkdir -p ${GOPATH}/src/github.com/elastic
cd ${GOPATH}/src/github.com/elastic
git clone https://github.com/elastic/beats.git
make
cd 到某个模块
make collect
make update
make
然后会在本目录生成一个可执行文件
image
开发--processor
第一步:新增目录与代码文件
image
package add_processor
import (
"fmt"
"strings"
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/processors"
)
type filter struct {
Fields []string
}
func init() {
processors.RegisterPlugin("add_processor", newProcessor)
}
func newProcessor(c *common.Config) (processors.Processor, error) {
config := struct {
Fields []string `config:"fields"`
}{}
err := c.Unpack(&config)
if err != nil {
return nil, fmt.Errorf("fail to unpack the add_processor configuration: %s", err)
}
f := &filter{Fields: config.Fields}
return f, nil
}
func (f *filter) Run(event *beat.Event) (*beat.Event, error) {
//code
return event, nil
}
func (f *filter) String() string {
var fields []string
for i := 0; i < len(f.Fields); i++ {
fields = append(fields, f.Fields[i])
}
return "bloom_filter=" + strings.Join(fields, ", ")
}
第三步:增加配置项
文件位置:filebeat/beater/filebeat.go
import中增加刚刚新建的processor目录
_ "github.com/elastic/beats/filebeat/processor/add_processor"
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Four
Scott Galloway / Portfolio / 2017-10-3 / USD 28.00
NEW YORK TIMES BESTSELLER USA TODAY BESTSELLER Amazon, Apple, Facebook, and Google are the four most influential companies on the planet. Just about everyone thinks they know how they got there.......一起来看看 《The Four》 这本书的介绍吧!