![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
GO
debugkernel
这个作者很懒,什么都没留下…
展开
-
go语言下的包名和目录名的对应关系
话不多说,看代码:目录结构如下,顶层文件test.go,有两个子目录,pp和pd。├── pd│ └── pa.go├── pp│ └── pa.go└── test.gotest.go的内容如下:package mainimport ( "fmt" "pp" pd "pd")func main(){ fmt.Prin...原创 2019-01-21 22:48:28 · 3628 阅读 · 2 评论 -
go语言下的RPC代码示例,基于开源项目rpcx
server端,提供远程计算服务:package mainimport "context"import "github.com/smallnest/rpcx/server"type Args struct { A int B int}type Reply struct { C int}type Arith intfunc (t *Arith)...原创 2019-01-22 11:34:37 · 1414 阅读 · 0 评论 -
Go语言下的多态
文章节选自《Go语言实战》多态现在了解了接口和方法集背后的机制,最后来看一个展示接口的多态行为的例子,如代码所示。01 // 这个示例程序使用接口展示多态行为02 package main0304 import (05 "fmt"06 )0708 // notifier 是一个定义了09 // 通知类行为的接口10 type notifier interface {...转载 2019-02-02 18:29:04 · 713 阅读 · 0 评论 -
go的数组子串改变会影响父串
func main() { a := []byte{1, 5, 3, 6, 58} //a := [...]byte{1, 5, 3, 6, 58} fmt.Println(a) b := a[2:4] fmt.Println(b) b[0] = 66 fmt.Println(a) fmt.Println(b)}结果如下:test$ go run test.go[...原创 2019-04-12 11:52:24 · 75 阅读 · 0 评论 -
基于golang的ES入门教程
插入索引:package mainimport ( "context" "fmt" "github.com/olivere/elastic")func main(){ Client, err := elastic.NewClient(elastic.SetURL("http://192.168.7.6:9200")) fmt.Println(Client, err) n...原创 2019-04-22 15:54:20 · 2124 阅读 · 1 评论