Skip to content

Commit

Permalink
update to go 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
sagan committed Dec 7, 2023
1 parent 5957a73 commit ddf7e89
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package client
import (
"fmt"
"regexp"
"slices"
"strings"
"sync"

log "github.com/sirupsen/logrus"
"golang.org/x/exp/slices"

"github.com/sagan/ptool/config"
"github.com/sagan/ptool/util"
Expand Down
2 changes: 1 addition & 1 deletion client/qbittorrent/qbittorrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"net/textproto"
"net/url"
"reflect"
"slices"
"sort"
"strings"

log "github.com/sirupsen/logrus"
"golang.org/x/exp/slices"

"github.com/sagan/ptool/client"
"github.com/sagan/ptool/config"
Expand Down
2 changes: 1 addition & 1 deletion client/transmission/transmission.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"net/url"
"reflect"
"slices"
"strings"

"github.com/ettle/strcase"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/sagan/ptool/config"
"github.com/sagan/ptool/util"
log "github.com/sirupsen/logrus"
"golang.org/x/exp/slices"
)

type Client struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/clientctl/clientctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package clientctl

import (
"fmt"
"slices"
"strings"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"

"github.com/sagan/ptool/client"
"github.com/sagan/ptool/cmd"
Expand Down
4 changes: 3 additions & 1 deletion cmd/common/flags.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package common

import (
"slices"

"github.com/sagan/ptool/cmd"
"golang.org/x/exp/slices"
)

// "name", "size", "speed", "state", "time", "tracker", "none"
Expand Down Expand Up @@ -77,6 +78,7 @@ var pureFlags = []string{
"largest",
"lock-or-exit",
"newest",
"no-check",
"no-hr",
"no-paid",
"parameters",
Expand Down
42 changes: 23 additions & 19 deletions cmd/cookiecloud/importsites/importsites.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package importsites

import (
"fmt"
"slices"
"strings"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"

"github.com/sagan/ptool/cmd/cookiecloud"
"github.com/sagan/ptool/config"
Expand All @@ -17,6 +17,7 @@ import (

var (
doAction = false
noCheck = false
profile = ""
siteProxy = ""
siteUa = ""
Expand All @@ -38,6 +39,7 @@ Be aware that all existing comments in config file will be LOST when updating co

func init() {
command.Flags().BoolVarP(&doAction, "do", "", false, "Do update the config file without confirm. Be aware that all existing comments in config file will be LOST")
command.Flags().BoolVarP(&noCheck, "no-check", "", false, "Do not check the cookies validity before importing new sites")
command.Flags().StringVarP(&profile, "profile", "", "", "Comma-separated string, Set the used cookiecloud profile name(s). If not set, All cookiecloud profiles in config will be used")
command.Flags().StringVarP(&siteProxy, "site-proxy", "", "", "Set the proxy for imported sites")
command.Flags().StringVarP(&siteUa, "site-ua", "", "", "Set the user-agent for imported sites")
Expand Down Expand Up @@ -97,25 +99,27 @@ func importsites(cmd *cobra.Command, args []string) error {
}
newsiteconfig := &config.SiteConfigStruct{Type: tplname, Cookie: cookie,
Proxy: siteProxy, UserAgent: siteUa, Ja3: siteJa3}
siteInstance, err := site.CreateSiteInternal(tplname, newsiteconfig, config.Get())
if err != nil {
log.Debugf("New Site %s from cookiecloud %s is invalid (create instance error: %v",
tplname, cookiecloudData.Label, err)
continue
}
sitestatus, err := siteInstance.GetStatus()
if err != nil {
log.Debugf("New Site %s from cookiecloud %s is invalid (status error=%v)",
tplname, cookiecloudData.Label, err)
continue
}
if !sitestatus.IsOk() {
log.Debugf("New Site %s from cookiecloud %s is invalid (invalid status)",
tplname, cookiecloudData.Label)
continue
if !noCheck {
siteInstance, err := site.CreateSiteInternal(tplname, newsiteconfig, config.Get())
if err != nil {
log.Debugf("New Site %s from cookiecloud %s is invalid (create instance error: %v",
tplname, cookiecloudData.Label, err)
continue
}
sitestatus, err := siteInstance.GetStatus()
if err != nil {
log.Debugf("New Site %s from cookiecloud %s is invalid (status error=%v)",
tplname, cookiecloudData.Label, err)
continue
}
if !sitestatus.IsOk() {
log.Debugf("New Site %s from cookiecloud %s is invalid (invalid status)",
tplname, cookiecloudData.Label)
continue
}
log.Infof("✓✓New site %s from cookiecloud %s is valid (username: %s)",
tplname, cookiecloudData.Label, sitestatus.UserName)
}
log.Infof("✓✓New site %s from cookiecloud %s is valid (username: %s)",
tplname, cookiecloudData.Label, sitestatus.UserName)
sitename := ""
if config.GetSiteConfig(tplname) != nil {
i := 1
Expand Down
2 changes: 1 addition & 1 deletion cmd/cookiecloud/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package sync

import (
"fmt"
"slices"
"strings"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"

"github.com/sagan/ptool/cmd/cookiecloud"
"github.com/sagan/ptool/config"
Expand Down
2 changes: 1 addition & 1 deletion cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package cmd
import (
"errors"
"fmt"
"slices"

"github.com/spf13/cobra"
"golang.org/x/exp/slices"
)

// an enum of string type
Expand Down
2 changes: 1 addition & 1 deletion cmd/iyuu/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"encoding/json"
"fmt"
"net/url"
"slices"
"sort"
"strings"

log "github.com/sirupsen/logrus"
"golang.org/x/exp/slices"

"github.com/sagan/ptool/config"
"github.com/sagan/ptool/site"
Expand Down
2 changes: 1 addition & 1 deletion cmd/iyuu/xseed/xseed.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package xseed

import (
"fmt"
"slices"
"sort"
"strings"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"
"gorm.io/gorm/clause"

"github.com/sagan/ptool/client"
Expand Down
2 changes: 1 addition & 1 deletion cmd/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package status

import (
"fmt"
"slices"
"sort"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"

"github.com/sagan/ptool/client"
"github.com/sagan/ptool/cmd"
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"net/url"
"path"
"regexp"
"slices"
"strings"
"sync"

"github.com/gofrs/flock"
"github.com/jpillora/go-tld"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"golang.org/x/exp/slices"

"github.com/sagan/ptool/util"
)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/sagan/ptool

go 1.20
go 1.21

// workaround for some problem
replace github.com/hekmon/transmissionrpc/v2 => ./transmissionrpc
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/anacrolix/dht/v2 v2.19.2-0.20221121215055-066ad8494444 h1:8V0K09lrGoeT2KRJNOtspA7q+OMxGwQqK/Ug0IiaaRE=
github.com/anacrolix/dht/v2 v2.19.2-0.20221121215055-066ad8494444/go.mod h1:MctKM1HS5YYDb3F30NGJxLE+QPuqWoT5ReW/4jt8xew=
github.com/anacrolix/envpprof v0.0.0-20180404065416-323002cec2fa/go.mod h1:KgHhUaQMc8cC0+cEflSgCFNFbKwi5h54gqtVn8yhP7c=
github.com/anacrolix/envpprof v1.0.0/go.mod h1:KgHhUaQMc8cC0+cEflSgCFNFbKwi5h54gqtVn8yhP7c=
github.com/anacrolix/envpprof v1.1.0/go.mod h1:My7T5oSqVfEn4MD4Meczkw/f5lSIndGAKu/0SM/rkf4=
Expand Down Expand Up @@ -121,6 +122,7 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/ettle/strcase v0.1.1 h1:htFueZyVeE1XNnMEfbqp5r67qAN/4r6ya1ysq8Q+Zcw=
github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY=
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
Expand Down Expand Up @@ -188,6 +190,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
Expand All @@ -203,6 +206,7 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
Expand Down Expand Up @@ -257,9 +261,11 @@ github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
Expand Down Expand Up @@ -332,6 +338,7 @@ github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
Expand Down
2 changes: 1 addition & 1 deletion site/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"mime"
"net/http"
"net/url"
"slices"
"sync"

"github.com/sagan/ptool/config"
"github.com/sagan/ptool/ja3transport"
"github.com/sagan/ptool/util"
"golang.org/x/exp/slices"
)

type Torrent struct {
Expand Down
3 changes: 1 addition & 2 deletions site/tpl/tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ package tpl
// 除 Url 以外的所有 ***Url (例如 TorrentsUrl) 均应当使用相对路径

import (
"slices"
"sort"

"golang.org/x/exp/slices"

"github.com/sagan/ptool/config"
"github.com/sagan/ptool/site"
"github.com/sagan/ptool/util"
Expand Down
2 changes: 1 addition & 1 deletion util/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package util

import (
"reflect"
"slices"

"golang.org/x/exp/constraints"
"golang.org/x/exp/slices"
)

func CopyMap[T1 comparable, T2 any](m map[T1](T2)) map[T1](T2) {
Expand Down
2 changes: 1 addition & 1 deletion util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"os"
"path/filepath"
"reflect"
"slices"
"strings"
"time"

log "github.com/sirupsen/logrus"
"golang.org/x/exp/constraints"
"golang.org/x/exp/slices"
)

func String2Any(value string) (any, reflect.Kind) {
Expand Down

0 comments on commit ddf7e89

Please sign in to comment.