go语言doc文档操作 golang操作word

golang elasticsearch 文档操作(CRUD) --- 2022-04-02

本节主要介绍go语言对Elasticsearch文档的基础操作:创建、查询、更新、删除。

创新互联主营资兴网站建设的网络公司,主营网站建设方案,重庆APP开发公司,资兴h5重庆小程序开发搭建,资兴网站营销推广欢迎资兴等地区企业咨询

为了方便演示文档的CRUD操作,我们先定义索引的struct结构

根据文档ID,查询文档

通过多个Id批量查询文档,对应ES的multi get

根据id更新文档

支持批量更新文档内容

提示: 复杂查询条件,请参考 go es查询用法

windows 怎么编译 go语言

1、解压压缩包到go工作目录,如解压到E:\opensource\go\go,解压后的目录结构如下:

E:\opensource\go\go

├─api

├─bin

│ ├─go.exe

│ ├─godoc.exe

│ └─gofmt.exe

├─doc

├─include

├─lib

├─misc

├─pkg

├─src

└─test

2、增加环境变量GOROOT,取值为上面的go工作目录

3、Path环境变量中添加";%GOROOT%\bin",以便能够直接调用go命令来编译go代码,至此go编译环境就配置好了

注:如果不想手动设置系统环境变量,也可下载go启动环境批处理附件,

修改goenv.bat文件中的GOROOT值为上面的go工作目录后直接双击该bat文件,go编译环境变量即设置完成。

4、测试go编译环境,启动一个cmd窗口,直接输入go,看到下面的提示就是搭建成功了

E:\opensource\go\gogo

Go is a tool for managing Go source code.

Usage:

go command [arguments]

The commands are:

build compile packages and dependencies

clean remove object files

doc run godoc on package sources

env print Go environment information

fix run go tool fix on packages

fmt run gofmt on package sources

get download and install packages and dependencies

install compile and install packages and dependencies

list list packages

run compile and run Go program

test test packages

tool run specified go tool

version print Go version

vet run go tool vet on packages

Use "go help [command]" for more information about a command.

Additional help topics:

gopath GOPATH environment variable

packages description of package lists

remote remote import path syntax

testflag description of testing flags

testfunc description of testing functions

Use "go help [topic]" for more information about that topic.

5、编译helloworld测试程序,go语言包中test目录带有helloworld.go测试程序,源码见"附一 helloworld.go",

直接调用"go build helloworld.go"就生成了"helloworld.exe"可执行程序,运行一下这个程序看到了我们期望的hello,wolrd。

E:\opensource\go\go\testgo build helloworld.go

E:\opensource\go\go\testhelloworld.exe

hello, world

E:\opensource\go\go\test

附一 helloworld.go

// cmpout

// Copyright 2009 The Go Authors. All rights reserved.

// Use of this source code is governed by a BSD-style

// license that can be found in the LICENSE file.

// Test that we can do page 1 of the C book.

package main

func main() {

print("hello, world\n")

}

go语言命令行打印清除

命令如下:

直接在终端中输入gohelp即可显示所有的go命令以及相应命令功能简介,主要有下面这些:

build:编译包和依赖;clean:移除对象文件;doc:显示包或者符号的文档;env:打印go的环境信息;bug:启动错误报告;fix:运行gotoolfix;fmt:运行gofmt进行格式化;generate:从processingsource生成go文件

get:下载并安装包和依赖;install:编译并安装包和依赖;list:列出包;run:编译并运行go程序;test:运行测试;tool:运行go提供的工具;version:显示go的版本;vet:运行gotoolvet;命令的使用方式为:gocommand[args],除此之外,可以使用gohelp;来显示指定命令的更多帮助信息。;在运行gohelp时,不仅仅打印了这些命令的基本信息,还给出了一些概念的帮助信息:;c:Go和c的相互调用;buildmode:构建模式的描述;filetype:文件类型;gopath:GOPATH环境变量

environment:环境变量;importpath:导入路径语法;packages:包列表的描述;testflag:测试符号描述;testfunc:测试函数描述等。


当前文章:go语言doc文档操作 golang操作word
当前URL:http://bzwzjz.com/article/ddghdjp.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 公司网站建设 网站制作公司 宜宾网站设计 成都网站建设 定制网站建设多少钱 成都网站建设 LED网站设计方案 手机网站建设套餐 网站建设公司 成都网站制作公司 成都网站建设 成都网站制作 网站制作 高端定制网站设计 网站设计公司 成都网站建设 成都网站设计公司 成都网站制作 营销型网站建设 企业手机网站建设 成都h5网站建设 成都网站设计