[[installation]]
== Installation

To install the 8.x version of the client, add the package to your `go.mod` file:

[source,text]
------------------------------------
require github.com/elastic/go-elasticsearch/v8 8.5
------------------------------------

Or, clone the repository:

[source,text]
------------------------------------
git clone --branch 8.5 https://github.com/elastic/go-elasticsearch.git $GOPATH/src/github
------------------------------------

To install another version, modify the path or the branch name accordingly. The 
client major versions correspond to the {es} major versions.

You can find a complete example of installation below:

[source,text]
------------------------------------
mkdir my-elasticsearch-app && cd my-elasticsearch-app

cat > go.mod <<-END
  module my-elasticsearch-app

  require github.com/elastic/go-elasticsearch/v8 main
END

cat > main.go <<-END
  package main

  import (
    "log"

    "github.com/elastic/go-elasticsearch/v8"
  )

  func main() {
    es, _ := elasticsearch.NewDefaultClient()
    log.Println(elasticsearch.Version)
    log.Println(es.Info())
  }
END

go run main.go
------------------------------------


[discrete]
=== {es} Version Compatibility

The language clients are forward compatible; meaning that the clients support
communicating with greater or equal minor versions of {es} without breaking. It
does not mean that the clients automatically support new features of newer
{es} versions; it is only possible after a release of a new client version. For
example, a 8.12 client version won't automatically support the new features of
the 8.13 version of {es}, the 8.13 client version is required for that. {es}
language clients are only backwards compatible with default distributions and
without guarantees made.

|===
| Elasticsearch Version | Elasticsearch-Go Branch | Supported

| main                  | main                      | 
| 8.x                   | 8.x                       | 8.x
| 7.x                   | 7.x                       | 7.17
|===
