Skip to content

Commit 226426f

Browse files
committed
Update to Go 1.11 beta 3 and notes about minimal module awareness
This commit updates the README to include Go 1.11 beta 3. We also add a few notes about "minimal module awareness" that has been included in Go 1.10.3 and 1.9.7. Unfortunately, the `dep` tool is still on its way to implement that. * [Minimal module awareness in Go 1.10.3 and Go 1.9.7](https://go.googlesource.com/go/+/d4e21288e444d3ffd30d1a0737f15ea3fc3b8ad9) * [Tracking implementation of "minimal module awareness" in dep](golang/dep#1963)
1 parent d36bf12 commit 226426f

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

README.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,40 @@
33
Go 1.11 comes with modules support. This repository is a testbed
44
for modules support.
55

6-
In a nutshell:
6+
To use this package with Go 1.11 (beta3 as of now), do:
77

88
```
9-
$ go version
10-
go version go1.11beta2 darwin/amd64
9+
$ go get golang.org/dl/go1.11beta3
10+
$ go1.11beta3 download
11+
$ go1.11beta3 version
12+
go version go1.11beta3 darwin/amd64
1113
$ cat go.mod
1214
module github/elastic-with-go-modules
1315
1416
require github.com/olivere/elastic/v6 v6.1.27
15-
$ go build
17+
$ go1.11beta3 build
1618
go: finding github.com/olivere/elastic/v6 v6.1.27
1719
go: downloading github.com/olivere/elastic/v6 v6.1.27
1820
$ ./elastic-with-go-modules
19-
Connection succeeded
20-
Elasticsearch version 6.3.2
21+
Go version is go1.11beta3
22+
Connecting to Elasticsearch succeeded and we're talking to version 6.3.2
23+
```
24+
25+
To do the same with Go 1.10.3, do:
26+
2127
```
28+
$ go version
29+
go version go1.10.3 darwin/amd64
30+
$ go get -v ./...
31+
$ go build
32+
$ ./elastic-with-go-modules
33+
Go version is go1.10.3
34+
Connecting to Elasticsearch succeeded and we're talking to version 6.3.2
35+
```
36+
37+
Notice that you *must* use Go 1.10.3 (or Go 1.9.7) because limited module support has only been [introduced in those versions](https://go.googlesource.com/go/+/d4e21288e444d3ffd30d1a0737f15ea3fc3b8ad9). Earlier versions of Go wouldn't find the import path `"github.com/olivere/elastic/v6"`.
38+
39+
Unfortunately, tools like [`dep`](https://github.com/golang/dep) don't support this either as of writing this. Follow [#1962](https://github.com/golang/dep/issues/1962) and [this PR](https://github.com/golang/dep/pull/1963) to watch progress on "minimal module awareness".
2240

2341
## License
2442

main.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
"flag"
1717
"fmt"
1818
"log"
19+
"os"
20+
"runtime"
1921

2022
elastic "github.com/olivere/elastic/v6"
2123
)
@@ -32,18 +34,21 @@ func main() {
3234
*url = "http://127.0.0.1:9200"
3335
}
3436

37+
fmt.Printf("Go version is %s\n", runtime.Version())
38+
3539
// Create an Elasticsearch client
40+
fmt.Print("Connecting to Elasticsearch ")
3641
client, err := elastic.NewClient(elastic.SetURL(*url), elastic.SetSniff(*sniff))
3742
if err != nil {
38-
log.Fatal(err)
43+
fmt.Printf("failed: %v", err)
44+
os.Exit(1)
3945
}
40-
41-
// Just a status message
42-
fmt.Println("Connection succeeded")
46+
fmt.Print("succeeded ")
4347

4448
version, err := client.ElasticsearchVersion(*url)
4549
if err != nil {
46-
log.Fatal(err)
50+
fmt.Printf("but couldn't retrieve version: %v", err)
51+
os.Exit(1)
4752
}
48-
fmt.Printf("Elasticsearch version %s\n", version)
53+
fmt.Printf("and we're talking to version %s\n", version)
4954
}

0 commit comments

Comments
 (0)