Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0e34de8f
authored
Aug 26, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: replace pcopy with jinzhu/copier for deep copy functionality
parent
3e5bc637
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
14 deletions
+4
-14
common/copy.go
+3
-5
go.mod
+1
-9
go.sum
+0
-0
No files found.
common/copy.go
View file @
0e34de8f
...
@@ -2,7 +2,8 @@ package common
...
@@ -2,7 +2,8 @@ package common
import
(
import
(
"fmt"
"fmt"
"github.com/antlabs/pcopy"
"github.com/jinzhu/copier"
)
)
func
DeepCopy
[
T
any
](
src
*
T
)
(
*
T
,
error
)
{
func
DeepCopy
[
T
any
](
src
*
T
)
(
*
T
,
error
)
{
...
@@ -10,12 +11,9 @@ func DeepCopy[T any](src *T) (*T, error) {
...
@@ -10,12 +11,9 @@ func DeepCopy[T any](src *T) (*T, error) {
return
nil
,
fmt
.
Errorf
(
"copy source cannot be nil"
)
return
nil
,
fmt
.
Errorf
(
"copy source cannot be nil"
)
}
}
var
dst
T
var
dst
T
err
:=
pcopy
.
Copy
(
&
dst
,
src
)
err
:=
copier
.
CopyWithOption
(
&
dst
,
src
,
copier
.
Option
{
DeepCopy
:
true
,
IgnoreEmpty
:
false
}
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
&
dst
==
nil
{
return
nil
,
fmt
.
Errorf
(
"copy result cannot be nil"
)
}
return
&
dst
,
nil
return
&
dst
,
nil
}
}
go.mod
View file @
0e34de8f
...
@@ -23,6 +23,7 @@ require (
...
@@ -23,6 +23,7 @@ require (
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/uuid v1.6.0
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.0
github.com/gorilla/websocket v1.5.0
github.com/jinzhu/copier v0.4.0
github.com/joho/godotenv v1.5.1
github.com/joho/godotenv v1.5.1
github.com/pkg/errors v0.9.1
github.com/pkg/errors v0.9.1
github.com/pquerna/otp v1.5.0
github.com/pquerna/otp v1.5.0
...
@@ -44,11 +45,7 @@ require (
...
@@ -44,11 +45,7 @@ require (
)
)
require (
require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/anknown/darts v0.0.0-20151216065714-83ff685239e6 // indirect
github.com/anknown/darts v0.0.0-20151216065714-83ff685239e6 // indirect
github.com/antlabs/pcopy v0.1.5 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.2 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.2 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.2 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.2 // indirect
...
@@ -73,8 +70,6 @@ require (
...
@@ -73,8 +70,6 @@ require (
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/sessions v1.2.1 // indirect
github.com/gorilla/sessions v1.2.1 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
...
@@ -85,14 +80,11 @@ require (
...
@@ -85,14 +80,11 @@ require (
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
...
...
go.sum
View file @
0e34de8f
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment