golang经常使用模块介绍

golang模块

1、命令行库Cobra


Cobra提供简单的接口来建立强大的现代化CLI接口,好比git与go工具。
Cobra同时也是一个程序, 用于建立CLI程序

https://www.jianshu.com/p/7abe7cff5384

html

2、client-go


Client-go是kubernetes官方发布的调用K8S API的golang语言包,能够用来开发K8S的管理服务、监控服务,配合前端展现,就能够开发出一款定制化的、可视化的管理或监控工具。目前最新版本为7.0,对应K8S的版本为1.10,访问连接:https://github.com/kubernetes/client-go

https://www.cnblogs.com/leejack/p/9525878.html前端

3、hugo

Hugo是由Go语言实现的静态网站生成器。简单、易用、高效、易扩展、快速部署。

http://www.gohugo.org/
https://gohugo.io/

git

4、kubernetes 从入门到实践


https://www.kancloud.cn/huyipow/kubernetesgithub

5、jsonpatch能够找到两个json字符串的区别,而后把区别发给前端,避免全量传输

example:golang

package main

import (
    "fmt"
    "github.com/mattbaird/jsonpatch"
)

var simpleA = `{"a":100, "b":200, "c":"hello"}`
var simpleB = `{"a":100, "b":200, "c":"goodbye"}`

func main() {
    patch, e := jsonpatch.CreatePatch([]byte(simpleA), []byte(simpleB))
    if e != nil {
        fmt.Printf("Error creating JSON patch:%v", e)
        return
    }
    for _, operation := range patch {
        fmt.Printf("%s\n", operation.Json())
    }
}


https://github.com/mattbaird/jsonpatch

数据库

6、使用golang操做kafka:sarama及其扩展sarama-cluster

又由于sarama不支持consumer group,因而又使用了sarama cluster

文档:
https://godoc.org/github.com/bsm/sarama-cluster
https://godoc.org/github.com/Shopify/sarama
示例:https://github.com/bsm/sarama-cluster

https://studygolang.com/articles/8942

加载证书的示例:https://dev.to/davidsbond/golang-implementing-kafka-consumers-using-sarama-cluster-4fko

只消费一次的示例:https://blog.csdn.net/jeffrey11223/article/details/81436747

编程

7、ssh

文档:https://godoc.org/golang.org/x/crypto/ssh#example-Client-Listen
代码:https://github.com/golang/crypto
https://www.jianshu.com/p/7d315f8551ad

json

八、errors错误处理接口

https://godoc.org/github.com/pkg/errors#example-New

segmentfault

九、Protocol相似于json,能够在多个语音之间传输

ProtoBuf: 是一套完整的 IDL(接口描述语言),出自Google,基于 C++ 进行的实现,开发人员能够根据 ProtoBuf 的语言规范生成多种编程语言(Golang、Python、Java 等)的接口代码
protobuf是Google开发出来的一个语言无关、平台无关的数据序列化工具,在rpc或tcp通讯等不少场景均可以使用。通俗来说,若是客户端和服务端使用的是不一样的语言,那么在服务端定义一个数据结构,经过protobuf转化为字节流,再传送到客户端解码,就能够获得对应的数据结构
https://segmentfault.com/a/1190000009277748
https://www.jianshu.com/p/1a3f1c3031b5
https://segmentfault.com/a/1190000010477733
https://github.com/golang/protobuf后端

十、goole的rpc:grpc

https://github.com/grpc/grpc-go
https://grpc.io/docs/quickstart/go.html
https://grpc.io/docs/tutorials/basic/go.html
https://doc.oschina.net/grpc?t=60133
https://segmentfault.com/a/1190000016328212
https://www.jianshu.com/p/506c7c5f72be
https://www.jianshu.com/p/774b38306c30

十一、golang的上下文管理context:

应用场景:在 Go http 包的 Server 中,每个请求在都有一个对应的goroutine去处理。请求处理函数一般会启动额外的goroutine用来访问后端服务,好比数据库和 RPC 服务。用来处理一个请求的goroutine一般须要访问一些与请求特定的数据,好比终端用户的身份认证信息、验证相关的 token、请求的截止时间。当一个请求被取消或超时时,全部用来处理该请求的goroutine都应该迅速退出,而后系统才能释放这些goroutine占用的资源
https://www.jianshu.com/p/d24bf8b6c869
https://zhuanlan.zhihu.com/p/34417106
https://deepzz.com/post/golang-context-package-notes.html
https://segmentfault.com/a/1190000006744213
https://juejin.im/post/5a6873fef265da3e317e55b6

十二、文件上传下载:sftp

https://github.com/pkg/sftphttps://godoc.org/github.com/pkg/sftp#pkg-exampleshttp://www.01happy.com/golang-transfer-remote-file/

相关文章
相关标签/搜索