package es import "github.com/elastic/go-elasticsearch/v7" type Es struct{ *EsConfig } type EsConfig struct { Address []string } type EsServer func(*EsConfig) *Es var esClient = new(elasticsearch.Client) func (this *Es) Run() { obj := elasticsearch.Config{ Addresses: this.Address, Username: "", Password: "", } var err error if esClient, err = elasticsearch.NewClient(obj); err != nil { panic("Elasticsearch Error " + err.Error()) } } func NewEs() EsServer { return func(config *EsConfig) *Es { return &Es{config} } }