golang
慕斯炖蘑菇
向往自由,追求卓越。
展开
-
Gin 全局 Basic Auth
Gin 全局 Basic Auth网上一堆都是莫名其妙的写法package mainimport ( "github.com/gin-gonic/gin" "log")func AuthMiddleware() gin.HandlerFunc { return func(c *gin.Context) { username, password, status := c.Request.BasicAuth() errMsg := "The authentication is fai原创 2020-06-05 16:40:50 · 713 阅读 · 0 评论 -
golang ping
import ( "github.com/sparrc/go-ping" "time")func main(){ pinger, err := ping.NewPinger("www.baidu.com") if err != nil { log.Println(err.Error()) return } pinger.Count = 3 pinger.Timeout ...原创 2020-03-11 16:30:05 · 263 阅读 · 0 评论 -
Golang telnet 端口
golang 查看端口是否连通func tcpGather(ip string, ports []string) map[string]string { // 检查 emqx 1883, 8083, 8080, 18083 端口 results := make(map[string]string) for _, port := range ports { address := net...原创 2020-01-07 11:22:29 · 1357 阅读 · 0 评论 -
使用 go 连接和查询postgresql
Content:使用go来查询postgressql Example:/* 使用go查询postgres 数据库 Mousse 2018.8.22.00-->KM*/package mainimport ( "database/sql" "fmt" _ "github.com/lib/pq")const ( host ...原创 2018-08-22 00:30:28 · 4154 阅读 · 2 评论 -
golang 不同方式插入postgres比较
golang 不同方式插入postgres比较 Description:常规插入: 28.855439529s事物循环插入: 15.848329755spg copy 插入: 37.207166msExample:package mainimport ( "database/sql" "fmt" _ "github.com/lib/pq" "time" "...原创 2018-10-29 15:21:35 · 1440 阅读 · 0 评论