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/

相關文章
相關標籤/搜索