yiigo - Golang常用優秀庫封裝,用於API、WEB和爬蟲開發
來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。[yiigo](https://github.com/IIInsomnia/yiigo)===Go常用優秀庫封裝,用於API、WEB和爬蟲開發## 特點* 支援多 [MySQL](https://github.com/jmoiron/sqlx) 串連* 支援多 [mongo](http://labix.org/mgo) 串連* 支援多 [redis](https://github.com/garyburd/redigo) 串連* 採用 [zap](https://github.com/uber-go/zap) 日誌記錄* 採用 [toml](https://github.com/pelletier/go-toml) 設定檔* 採用 [glide](https://glide.sh) 管理依賴包* 支援 [gomail](https://github.com/go-gomail/gomail) 郵件發送* 支援爬蟲類比登入## 擷取```shell# 初始化glide init# 擷取 yiigoglide get github.com/iiinsomnia/yiigo```## 使用#### 1、import yiigo```gopackage mainimport "github.com/iiinsomnia/yiigo"func main() { // 啟用 mysql、mongo、redis err := yiigo.Bootstrap(true, true, true) if err != nil { yiigo.Logger.Panic(err.Error()) } // coding...}```#### 2、resolve dependencies```shell# 擷取 yiigo 所需依賴包glide update```## 文檔* [API Reference](https://godoc.org/github.com/IIInsomnia/yiigo)* [Example](https://github.com/IIInsomnia/yiigo-example)## 說明* 在 `main.go` 所在目錄建立 `env.toml` 設定檔,具體配置可以參考 `env.toml.example`* `MySQL`、`mongo`、`redis` 多串連配置參考 `env.toml.example` 中的多資料庫配置部分(注釋部分)* `golang.org` 上 `go get` 不下來的庫,可以在這裡[擷取](https://github.com/golang)* 如爬蟲不需要類比登入,則只需要使用 [goquery](https://github.com/PuerkitoBio/goquery) 即可529 次點擊