Skip to content

Commit 6c283fb

Browse files
committed
refactor: 将弃用的 reflect.Ptr 改为 reflect.Pointer
1 parent 0fdc6ff commit 6c283fb

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

.github/workflows/go.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@ name: Go
22
on: [push, pull_request]
33

44
jobs:
5-
65
test:
76
name: Test
87
runs-on: ${{ matrix.os }}
98

109
strategy:
1110
matrix:
1211
os: [ubuntu-latest, macOS-latest, windows-latest]
13-
go: ['1.18.x', '1.25.x']
12+
go: ["1.18.x", "1.25.x"]
1413

1514
steps:
16-
1715
- name: Check out code into the Go module directory
18-
uses: actions/checkout@v4
16+
uses: actions/checkout@v6
1917

2018
- name: Set up Go ${{ matrix.go }}
21-
uses: actions/setup-go@v5
19+
uses: actions/setup-go@v6
2220
with:
2321
go-version: ${{ matrix.go }}
2422
id: go

conv_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2014-2024 caixw
1+
// SPDX-FileCopyrightText: 2014-2026 caixw
22
//
33
// SPDX-License-Identifier: MIT
44

obj.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2014-2024 caixw
1+
// SPDX-FileCopyrightText: 2014-2026 caixw
22
//
33
// SPDX-License-Identifier: MIT
44

@@ -21,7 +21,7 @@ func defaultFieldConvert(src string) string { return src }
2121
// 将 obj 对象转换成 map[string]any 格式的数据
2222
func obj2Map(obj any, maps map[string]any, conv FieldConvert) error {
2323
objVal := reflect.ValueOf(obj)
24-
for objVal.Kind() == reflect.Ptr { // 如果是指针,则获取指向的对象
24+
for objVal.Kind() == reflect.Pointer { // 如果是指针,则获取指向的对象
2525
objVal = objVal.Elem()
2626
}
2727

@@ -42,7 +42,7 @@ func obj2Map(obj any, maps map[string]any, conv FieldConvert) error {
4242
switch {
4343
case fieldType.Anonymous: // 匿名字段
4444
err = obj2Map(fieldVal.Interface(), maps, conv)
45-
case fieldType.Type.Kind() == reflect.Ptr: // 如果是指针,就获取指针指向的元素
45+
case fieldType.Type.Kind() == reflect.Pointer: // 如果是指针,就获取指针指向的元素
4646
fieldVal = fieldVal.Elem()
4747
fallthrough
4848
case fieldType.Type.Kind() == reflect.Struct: // 嵌套类型
@@ -135,7 +135,7 @@ func Map2Obj(src any, dest any, conv FieldConvert) error {
135135
// 对 map2Obj 各个参数的检测,并返回正确的值或是错误信息。
136136
func map2ObjCheck(src any, dest any, conv FieldConvert) (srcVal reflect.Value, destVal reflect.Value, fun FieldConvert, err error) {
137137
destVal = reflect.ValueOf(dest)
138-
if destVal.Kind() != reflect.Ptr {
138+
if destVal.Kind() != reflect.Pointer {
139139
err = fmt.Errorf("conv: dest 必须为一个 struct 对象的指针,实际类型为[%v]", destVal.Type())
140140
return
141141
}
@@ -148,7 +148,7 @@ func map2ObjCheck(src any, dest any, conv FieldConvert) (srcVal reflect.Value, d
148148

149149
srcVal = reflect.ValueOf(src)
150150

151-
if srcVal.Kind() == reflect.Ptr { // src有可能是个map指针,需要转换成map对象
151+
if srcVal.Kind() == reflect.Pointer { // src有可能是个map指针,需要转换成map对象
152152
srcVal = srcVal.Elem()
153153
}
154154

value.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2014-2024 caixw
1+
// SPDX-FileCopyrightText: 2014-2026 caixw
22
//
33
// SPDX-License-Identifier: MIT
44

@@ -18,7 +18,7 @@ import (
1818
func Value(source any, target reflect.Value) error {
1919
kind := target.Kind()
2020

21-
for kind == reflect.Ptr {
21+
for kind == reflect.Pointer {
2222
target = target.Elem()
2323
kind = target.Kind()
2424
}

0 commit comments

Comments
 (0)