- 首页
- 专栏
-
golng 使用postgres数据库
```go package main import ( "fmt" "log" "time" "github.com/go-xorm/xorm" _ "github.com/lib/pq" ) var engine *xorm.Engine func main() { } func init() { psqlInfo := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s...
-
golang redis连接池的使用
````golang package main import ( "encoding/json" "errors" "fmt" "time" "github.com/garyburd/redigo/redis" ) const ( RedisURL = "redis://*****:6379" redisMaxIdle = 3 //最大空闲连接数 redisIdleTimeoutSec = 240 //最...
-
解决golang https请求提示x509: certificate signed by unknown authority
Golang https请求发生错误 ` x509: certificate signed by unknown authority ` ### 重点: 引入"crypto/tls" ````golang import ( "crypto/tls" "log" "net/http" ) func get(url string, headers map[string]string) *http.Response { tr := &http.Transport{ ...
-
gin web框架解决跨域问题
<pre><code> func Cors() gin.HandlerFunc { return func(c *gin.Context) { method := c.Request.Method if method == "OPTIONS" { c.JSON(http.StatusOK, "Options Request!") } origin := c.Request.Header.Get("Origin") var headerKeys []...