Skip to content

Commit

Permalink
chore: 更新 assert 至 v4
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Feb 28, 2024
1 parent bd6843c commit d741f42
Show file tree
Hide file tree
Showing 27 changed files with 81 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
go: ['1.17.x', '1.21.x']
go: ['1.17.x', '1.22.x']

steps:

Expand Down
2 changes: 2 additions & 0 deletions cmd/fetch/build.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package main
Expand Down
2 changes: 2 additions & 0 deletions cmd/fetch/collector.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package main
Expand Down
2 changes: 2 additions & 0 deletions cmd/fetch/fetch.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package main
Expand Down
14 changes: 7 additions & 7 deletions cmd/fetch/go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module github.com/issue9/cnregion/cmd/fetch

go 1.21
go 1.22

require (
github.com/gocolly/colly/v2 v2.1.0
github.com/issue9/cmdopt v0.13.0
github.com/issue9/cnregion v1.2022.0
github.com/issue9/errwrap v0.3.1
github.com/issue9/sliceutil v0.15.0
github.com/issue9/term/v3 v3.2.5
github.com/issue9/cmdopt v0.13.1
github.com/issue9/cnregion v1.2023.0
github.com/issue9/errwrap v0.3.2
github.com/issue9/sliceutil v0.15.1
github.com/issue9/term/v3 v3.2.6
)

require (
Expand All @@ -24,7 +24,7 @@ require (
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/temoto/robotstxt v1.1.2 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.6.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
Expand Down
24 changes: 12 additions & 12 deletions cmd/fetch/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/issue9/assert/v3 v3.1.0 h1:oxLFXS7QnBKI4lB31pRoYO96yErkWAJtR7iv+LNjAPg=
github.com/issue9/assert/v3 v3.1.0/go.mod h1:yft/uaskRpwQTyBT3n1zRl91SR1wNlO4fLZHzOa4bdM=
github.com/issue9/cmdopt v0.13.0 h1:mLaa7R94a6MbCf+1GIt4YgFDW6fdt/nnL0AjgKgf8jQ=
github.com/issue9/cmdopt v0.13.0/go.mod h1:l//IcugcBwX+vCc2KrgC4ylU6rEzhjQyxno7hWoLCDE=
github.com/issue9/errwrap v0.3.1 h1:8g4lYJaGnoiXyZ1oZyH/7zPDGgw5RNiE9Q6ri9kE6Z8=
github.com/issue9/errwrap v0.3.1/go.mod h1:HLR0e5iimd2aJXM9YrThOsRj3/6lMtk77lVp7zyvJ4E=
github.com/issue9/sliceutil v0.15.0 h1:E6Xnl3FY5h0ZGNzyx1VEFAfGdParaq/BkX1QQR0uFwI=
github.com/issue9/sliceutil v0.15.0/go.mod h1:n9meV7AamDhmehOBuV4GrxW3yw7O1cZmLx3Xizg1bps=
github.com/issue9/term/v3 v3.2.5 h1:kAC5ynwTiqe/63E3JAV2Cb7eVxVno+L7VsmYgJyyLw0=
github.com/issue9/term/v3 v3.2.5/go.mod h1:Qm0PvOTggMvZUEsAmpiBr/uBaq5Qh/w4LQJcvznfAjc=
github.com/issue9/assert/v4 v4.1.1 h1:OhPE8SB8n/qZCNGLQa+6MQtr/B3oON0JAVj68k8jJlc=
github.com/issue9/assert/v4 v4.1.1/go.mod h1:v7qDRXi7AsaZZNh8eAK2rkLJg5/clztqQGA1DRv9Lv4=
github.com/issue9/cmdopt v0.13.1 h1:VA/Hgd92NBbZyHjZx1xcRCMhoc+XjI1LWhiuZkOZ0VU=
github.com/issue9/cmdopt v0.13.1/go.mod h1:7lnF45Ush0boi4/nDjeSDYV5lZfoOzp3jm+biJr0f4g=
github.com/issue9/errwrap v0.3.2 h1:7KEme9Pfe75M+sIMcPCn/DV90wjnOcRbO4DXVAHj3Fw=
github.com/issue9/errwrap v0.3.2/go.mod h1:KcCLuUGiffjooLCUjL89r1cyO8/HT/VRcQrneO53N3A=
github.com/issue9/sliceutil v0.15.1 h1:mV1VlQSO5E8sh2ab6pypLg7TdgGZlDb30E8quli01xY=
github.com/issue9/sliceutil v0.15.1/go.mod h1:ldun6sT4/bOJxuMtOXhtc6P7GCwE7L+avV86HNks7qk=
github.com/issue9/term/v3 v3.2.6 h1:+8sdVdT2GM3OoebNMd5wdt0bswJ1TBukK6HloKgoW3o=
github.com/issue9/term/v3 v3.2.6/go.mod h1:OCUgzwgKUbcHrlRyxQATPaYfNtNbWs17yzkogMpPIjA=
github.com/jawher/mow.cli v1.1.0/go.mod h1:aNaQlc7ozF3vw6IJ2dHjp2ZFiA4ozMIYY6PyuRJwlUg=
github.com/kennygrant/sanitize v1.2.4 h1:gN25/otpP5vAsO2djbMhF/LQX6R7+O1TB4yv8NzpJ3o=
github.com/kennygrant/sanitize v1.2.4/go.mod h1:LGsjYYtgxbetdg5owWB2mpgUL6e2nfw2eObZ0u0qvak=
Expand Down Expand Up @@ -119,8 +119,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
Expand Down
2 changes: 2 additions & 0 deletions cmd/fetch/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package main
Expand Down
2 changes: 2 additions & 0 deletions cnregion.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

// Package cnregion 中国区域划分代码
Expand Down
2 changes: 2 additions & 0 deletions data/embed.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package data
Expand Down
4 changes: 3 additions & 1 deletion data/embed_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package data

import (
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"
)

func TestEmbed(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions db/db.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

// Package db 提供区域数据文件的相关操作
Expand Down
4 changes: 3 additions & 1 deletion db/db_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package db
Expand All @@ -7,7 +9,7 @@ import (
"path/filepath"
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"

"github.com/issue9/cnregion/id"
"github.com/issue9/cnregion/version"
Expand Down
2 changes: 2 additions & 0 deletions db/region.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package db
Expand Down
4 changes: 3 additions & 1 deletion db/region_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package db

import (
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"

"github.com/issue9/cnregion/id"
)
Expand Down
2 changes: 2 additions & 0 deletions db/search.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package db
Expand Down
4 changes: 3 additions & 1 deletion db/search_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package db
Expand All @@ -7,7 +9,7 @@ import (
"strings"
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"

"github.com/issue9/cnregion/id"
)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/issue9/cnregion
go 1.17

require (
github.com/issue9/assert/v3 v3.1.0
github.com/issue9/errwrap v0.3.1
github.com/issue9/assert/v4 v4.1.1
github.com/issue9/errwrap v0.3.2
)
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
github.com/issue9/assert/v3 v3.0.0/go.mod h1:yft/uaskRpwQTyBT3n1zRl91SR1wNlO4fLZHzOa4bdM=
github.com/issue9/assert/v3 v3.1.0 h1:oxLFXS7QnBKI4lB31pRoYO96yErkWAJtR7iv+LNjAPg=
github.com/issue9/assert/v3 v3.1.0/go.mod h1:yft/uaskRpwQTyBT3n1zRl91SR1wNlO4fLZHzOa4bdM=
github.com/issue9/errwrap v0.3.1 h1:8g4lYJaGnoiXyZ1oZyH/7zPDGgw5RNiE9Q6ri9kE6Z8=
github.com/issue9/errwrap v0.3.1/go.mod h1:HLR0e5iimd2aJXM9YrThOsRj3/6lMtk77lVp7zyvJ4E=
github.com/issue9/assert/v4 v4.1.1 h1:OhPE8SB8n/qZCNGLQa+6MQtr/B3oON0JAVj68k8jJlc=
github.com/issue9/assert/v4 v4.1.1/go.mod h1:v7qDRXi7AsaZZNh8eAK2rkLJg5/clztqQGA1DRv9Lv4=
github.com/issue9/errwrap v0.3.2 h1:7KEme9Pfe75M+sIMcPCn/DV90wjnOcRbO4DXVAHj3Fw=
github.com/issue9/errwrap v0.3.2/go.mod h1:KcCLuUGiffjooLCUjL89r1cyO8/HT/VRcQrneO53N3A=
11 changes: 7 additions & 4 deletions id/id.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

// Package id 针对 ID 的一些操作函数
Expand Down Expand Up @@ -54,7 +56,8 @@ func Split(id string) (province, city, county, town, village string) {

// SplitFilter 将 id 按区域进行划分且过滤掉零值的区域
//
// 330312123000 => 33 03 12 123
// 330312123000 => 33 03 12 123
//
// 如果传递的是零值,则返回空数组。
func SplitFilter(id string) []string {
province, city, county, town, village := Split(id)
Expand All @@ -73,16 +76,16 @@ func filterZero(id ...string) []string {

// Parent 获取 id 的上一级行政区域的 ID
//
// 330312123456 => 330312123
// 330312123456 => 330312123
func Parent(id string) string {
list := SplitFilter(id)
return strings.Join(list[:len(list)-1], "")
}

// Prefix 获取 ID 的非零前缀
//
// 330312123456 => 330312123456
// 330312123000 => 330312123
// 330312123456 => 330312123456
// 330312123000 => 330312123
func Prefix(id string) string {
return strings.Join(SplitFilter(id), "")
}
Expand Down
4 changes: 3 additions & 1 deletion id/id_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package id

import (
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"
)

func TestSplit(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions region.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package cnregion
Expand Down
2 changes: 2 additions & 0 deletions region_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package cnregion
Expand Down
2 changes: 2 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package cnregion
Expand Down
2 changes: 2 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

// Package version 提供版本的相关信息
Expand Down
4 changes: 3 additions & 1 deletion version/version_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package version

import (
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"
)

func TestAll(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion version_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2021-2024 caixw
//
// SPDX-License-Identifier: MIT

package cnregion
Expand All @@ -6,7 +8,7 @@ import (
"os"
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"

"github.com/issue9/cnregion/id"
"github.com/issue9/cnregion/version"
Expand Down

0 comments on commit d741f42

Please sign in to comment.