1 Star 1 Fork 0

宇宙蒙面侠X/github.com-olivere-elastic

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.11 KB
一键复制 编辑 原始数据 按行查看 历史
Oliver Eilhard 提交于 2018-08-28 11:21 . Remove /v6 from import path
// Copyright 2012-present Oliver Eilhard. All rights reserved.
// Use of this source code is governed by a MIT-license.
// See http://olivere.mit-license.org/license.txt for details.
// Connect simply connects to Elasticsearch, but uses Go modules
// as introduced with Go 1.11.
//
// Example
//
//
// GO111MODULE=on go run main.go -url=http://127.0.0.1:9200 -sniff=false
//
package main
import (
"flag"
"fmt"
"log"
"github.com/olivere/elastic" // <- should end with /v6, but missing due to compatibility reasons
)
func main() {
var (
url = flag.String("url", "http://localhost:9200", "Elasticsearch URL")
sniff = flag.Bool("sniff", true, "Enable or disable sniffing")
)
flag.Parse()
log.SetFlags(0)
if *url == "" {
*url = "http://127.0.0.1:9200"
}
// Create an Elasticsearch client
client, err := elastic.NewClient(elastic.SetURL(*url), elastic.SetSniff(*sniff))
if err != nil {
log.Fatal(err)
}
// Just a status message
fmt.Println("Connection succeeded")
version, err := client.ElasticsearchVersion(*url)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Elasticsearch version %s\n", version)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/awol2010ex/github.com-olivere-elastic.git
git@gitee.com:awol2010ex/github.com-olivere-elastic.git
awol2010ex
github.com-olivere-elastic
github.com-olivere-elastic
v6.2.6

搜索帮助

0d507c66 1850385 C8b1a773 1850385