Problem: strings.Title is deprecated
Solution: use golang.org/x/text/cases instead
This commit is contained in:
parent
179955dbc7
commit
a2f04e4d6e
1
go.mod
1
go.mod
|
@ -13,5 +13,6 @@ require (
|
|||
github.com/pkg/errors v0.9.1
|
||||
github.com/stretchr/testify v1.7.0
|
||||
golang.org/x/net v0.0.0-20211013171255-e13a2654a71e
|
||||
golang.org/x/text v0.3.7
|
||||
willnorris.com/go/microformats v1.1.0
|
||||
)
|
||||
|
|
1
go.sum
1
go.sum
|
@ -1234,6 +1234,7 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
|
|
@ -5,8 +5,10 @@ import (
|
|||
"encoding/xml"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
func parseRSS1(data []byte) (*Feed, error) {
|
||||
|
@ -29,6 +31,8 @@ func parseRSS1(data []byte) (*Feed, error) {
|
|||
out.Description = channel.Description
|
||||
out.Link = channel.Link
|
||||
out.Image = channel.Image.Image()
|
||||
|
||||
titleCaser := cases.Title(language.English)
|
||||
if channel.MinsToLive != 0 {
|
||||
sort.Ints(channel.SkipHours)
|
||||
next := time.Now().Add(time.Duration(channel.MinsToLive) * time.Minute)
|
||||
|
@ -41,7 +45,7 @@ func parseRSS1(data []byte) (*Feed, error) {
|
|||
for trying {
|
||||
trying = false
|
||||
for _, day := range channel.SkipDays {
|
||||
if strings.Title(day) == next.Weekday().String() {
|
||||
if titleCaser.String(day) == next.Weekday().String() {
|
||||
next.Add(time.Duration(24-next.Hour()) * time.Hour)
|
||||
trying = true
|
||||
break
|
||||
|
|
|
@ -5,8 +5,10 @@ import (
|
|||
"encoding/xml"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
func parseRSS2(data []byte) (*Feed, error) {
|
||||
|
@ -38,6 +40,7 @@ func parseRSS2(data []byte) (*Feed, error) {
|
|||
|
||||
out.Image = channel.Image.Image()
|
||||
if channel.MinsToLive != 0 {
|
||||
titleCaser := cases.Title(language.English)
|
||||
sort.Ints(channel.SkipHours)
|
||||
next := time.Now().Add(time.Duration(channel.MinsToLive) * time.Minute)
|
||||
for _, hour := range channel.SkipHours {
|
||||
|
@ -49,7 +52,7 @@ func parseRSS2(data []byte) (*Feed, error) {
|
|||
for trying {
|
||||
trying = false
|
||||
for _, day := range channel.SkipDays {
|
||||
if strings.Title(day) == next.Weekday().String() {
|
||||
if titleCaser.String(day) == next.Weekday().String() {
|
||||
next.Add(time.Duration(24-next.Hour()) * time.Hour)
|
||||
trying = true
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue
Block a user