Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update math/rand to math/rand/v2 and support go 1.22 #20

Merged
merged 5 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22'

- name: Build
run: go build -v ./...
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ jobs:
goarch: ${{ matrix.goarch }}
project_path: "."
binary_name: "CloudflareWarpSpeedTest"
goversion: "1.20"
goversion: "1.22"
ldflags: "${{ env.LD_FLAGS }}"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ paru -S cloudflarewarpspeedtest-bin
```

#### Go Install
use go tool to install(go version <= 1.20)
use go tool to install(go version recommend 1.22)

```bash
go install github.com/peanut996/CloudflareWarpSpeedTest@latest
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ paru -S cloudflarewarpspeedtest-bin
```

#### Go Install
使用go官方工具链安装(go版本<=1.20)
使用go官方工具链安装(go版本推荐1.22)

```bash
go install github.com/peanut996/CloudflareWarpSpeedTest@latest
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module github.com/peanut996/CloudflareWarpSpeedTest

go 1.20
go 1.22

require (
github.com/cheggaaa/pb/v3 v3.1.4
golang.org/x/crypto v0.13.0
golang.org/x/text v0.14.0
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173
)

require golang.org/x/text v0.14.0

require (
github.com/BurntSushi/toml v1.4.0
github.com/VividCortex/ewma v1.2.0 // indirect
Expand All @@ -19,7 +19,6 @@ require (
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/nicksnyder/go-i18n/v2 v2.4.0
github.com/rivo/uniseg v0.2.0 // indirect
golang.org/x/crypto v0.13.0
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+D
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4=
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259 h1:TbRPT0HtzFP3Cno1zZo7yPzEEnfu8EjLfl6IU9VfqkQ=
gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259/go.mod h1:AVgIgHMwK63XvmAzWG9vLQ41YnVHN0du0tEC46fI7yY=
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func init() {
}

func main() {
task.InitRandSeed()
task.InitHandshakePacket()

fmt.Printf("CloudflareWarpSpeedTest\n\n")
Expand Down
9 changes: 2 additions & 7 deletions task/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package task
import (
"bufio"
"log"
"math/rand"
"math/rand/v2"
"net"
"os"
"strconv"
"strings"
"time"

i18n "github.com/peanut996/CloudflareWarpSpeedTest/locale"
)
Expand All @@ -20,10 +19,6 @@ var (
IPFile string
)

func InitRandSeed() {
rand.Seed(time.Now().UnixNano())
}

func isIPv4(ip string) bool {
return strings.Contains(ip, ".")
}
Expand All @@ -32,7 +27,7 @@ func randIPEndWith(num byte) byte {
if num == 0 { // 对于 /32 这种单独的 IP
return byte(0)
}
return byte(rand.Intn(int(num)))
return byte(rand.IntN(int(num)))
}

type IPRanges struct {
Expand Down