小编vin*_*iyo的帖子

获取Go/Golang当月的第一天和最后一天?

我想要获得当月的第一天和最后一天.您可以添加日期和小时但不是月份,我想从下个月减去一天以获得本月的最后一天.像这样的东西:

package main

import (
    "fmt"
    "time"
)

func main() {

    date := time.Now()
    nextMonth := date.Add(time.Month)
    LastDay := nextMonth.Add(-time.Hour * 24)

    fmt.Println(LastDay)

}
Run Code Online (Sandbox Code Playgroud)

time date go

19
推荐指数
6
解决办法
1万
查看次数

启用S​​SL后,Revel不会转发到端口443

我正在使用Revel作为一个小应用程序并添加了SSL.当我将配置更新为指向http.port = 443时,对端口80的请求将被拒绝而不是被转发.有没有办法在Revel框架上解决这个问题?谢谢.

# The port on which to listen.
http.port = 443

# Whether to use SSL or not.
http.ssl = true

# Path to an X509 certificate file, if using SSL.
http.sslcert = /root/go/src/saml/AlphaCerts/cert.crt

# Path to an X509 certificate key, if using SSL.
http.sslkey = /root/go/src/saml/star_home_com.key
Run Code Online (Sandbox Code Playgroud)

ssl go revel

3
推荐指数
1
解决办法
533
查看次数

Golang Json单值解析

在python中,你可以获取一个json对象并从中获取一个特定项而不声明一个结构,保存到一个结构然后获取像Go中的值.是否有一个包或更简单的方法来存储Go中的json特定值?

蟒蛇

res = res.json()
return res['results'][0] 
Run Code Online (Sandbox Code Playgroud)

type Quotes struct {
AskPrice string `json:"ask_price"`
}

quote := new(Quotes)
errJson := json.Unmarshal(content, &quote)
if errJson != nil {
    return "nil", fmt.Errorf("cannot read json body: %v", errJson)
}
Run Code Online (Sandbox Code Playgroud)

json go

2
推荐指数
1
解决办法
5451
查看次数

标签 统计

go ×3

date ×1

json ×1

revel ×1

ssl ×1

time ×1