Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
5da33b0b
Commit
5da33b0b
authored
1 year ago
by
ensiouel
Browse files
Options
Downloads
Patches
Plain Diff
в функцию Set добавлена проверка data на nil
parent
46aaa748
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/data/data.go
+6
-0
6 additions, 0 deletions
pkg/data/data.go
pkg/data/data_test.go
+6
-0
6 additions, 0 deletions
pkg/data/data_test.go
with
12 additions
and
0 deletions
pkg/data/data.go
+
6
−
0
View file @
5da33b0b
...
...
@@ -9,6 +9,8 @@ import (
const
DefaultFieldDelimiter
=
"."
var
ErrDataIsNil
=
errors
.
New
(
"data is nil"
)
type
DeleteValueType
struct
{}
var
DeleteValue
DeleteValueType
...
...
@@ -169,6 +171,10 @@ func getPath(field string, delim ...string) []string {
}
func
Set
(
field
string
,
data
,
value
any
,
delim
...
string
)
error
{
if
data
==
nil
{
return
ErrDataIsNil
}
return
set
(
getPath
(
field
,
delim
...
),
data
,
value
)
}
...
...
This diff is collapsed.
Click to expand it.
pkg/data/data_test.go
+
6
−
0
View file @
5da33b0b
...
...
@@ -316,6 +316,12 @@ func TestSet(t *testing.T) {
[]
any
{(
map
[
string
]
any
)(
nil
),
map
[
string
]
any
{
"b"
:
"2"
}},
assert
.
Error
,
},
{
"Set object to nil data"
,
args
{
"a"
,
nil
,
"1"
},
nil
,
assert
.
Error
,
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
Semyon Krestyaninov
@krestyaninov
mentioned in commit
248bb0b8
·
1 year ago
mentioned in commit
248bb0b8
mentioned in commit 248bb0b82f89a6bf316e92031006e7d63a604e2f
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment