Unknown field Username in struct literal of type elasticsearch.Config

Can any one help me with these errors:

server/modules/securityonion/soelastic.go:46:5: unknown field Username in struct literal of type elasticsearch.Config
server/modules/securityonion/soelastic.go:47:5: unknown field Password in struct literal of type elasticsearch.Config
server/modules/securityonion/soelastic.go:58:27: elastic.esConfig.Password undefined (type elasticsearch.Config has no field or method Password)
server/modules/securityonion/soelastic.go:66:34: elastic.esConfig.Username undefined (type elasticsearch.Config has no field or method Username)

Here is the block of code for debugging:

  type SoElastic struct {
  esConfig              elasticsearch.Config
  esClient              *elasticsearch.Client
  timeShiftMs   int
}

func NewSoElastic() *SoElastic {
  return &SoElastic{}
}

func (elastic *SoElastic) Init(host string, user string, pass string, verifyCert bool, timeShiftMs int) error {
  hosts := make([]string, 1)
  elastic.timeShiftMs = timeShiftMs
  hosts[0] = host
  elastic.esConfig = elasticsearch.Config {
    Addresses: hosts,
    Username: user,
    Password: pass, 
    Transport: &http.Transport{
      MaxIdleConnsPerHost:   10,
      ResponseHeaderTimeout: time.Second,
      DialContext:           (&net.Dialer{Timeout: time.Second}).DialContext,
      TLSClientConfig: &tls.Config{
        InsecureSkipVerify: !verifyCert,
      },
    },
  }
  maskedPassword := "*****"
  if len(elastic.esConfig.Password) == 0 {
    maskedPassword = ""
  }

  esClient, err := elasticsearch.NewClient(elastic.esConfig)
  fields := log.Fields {
    "InsecureSkipVerify": !verifyCert,
    "Host": hosts[0],
    "Username": elastic.esConfig.Username,
    "Password": maskedPassword,
  }

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.