FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
oasdiff/diff/string_map_diff.go at main · oasdiff/oasdiff · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
oasdiff
/
oasdiff
Public
Notifications
You must be signed in to change notification settings
Fork
105
Star
1.3k
Code
Issues
51
Pull requests
5
Discussions
Actions
Projects
Security and quality
2
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
oasdiff
/
diff
/
string_map_diff.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (50 loc) · 1.41 KB
Breadcrumbs
oasdiff
/
diff
/
string_map_diff.go
Copy path
File metadata and controls
62 lines (50 loc) · 1.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package
diff
// StringMapDiff describes the changes between a pair of string maps
type
StringMapDiff
struct
{
Added
[]
string
`json:"added,omitempty" yaml:"added,omitempty"`
Deleted
[]
string
`json:"deleted,omitempty" yaml:"deleted,omitempty"`
Modified
ModifiedKeys
`json:"modified,omitempty" yaml:"modified,omitempty"`
}
// ModifiedKeys maps keys to their respective diffs
type
ModifiedKeys
map
[
string
]
*
ValueDiff
func
newStringMapDiffDiff
()
*
StringMapDiff
{
return
&
StringMapDiff
{
Added
: []
string
{},
Deleted
: []
string
{},
Modified
:
ModifiedKeys
{},
}
}
// Empty indicates whether a change was found in this element
func
(
diff
*
StringMapDiff
)
Empty
()
bool
{
if
diff
==
nil
{
return
true
}
return
len
(
diff
.
Added
)
==
0
&&
len
(
diff
.
Deleted
)
==
0
&&
len
(
diff
.
Modified
)
==
0
}
func
getStringMapDiff
(
strings1
,
strings2
map
[
string
]
string
)
*
StringMapDiff
{
diff
:=
getStringMapDiffInternal
(
strings1
,
strings2
)
if
diff
.
Empty
() {
return
nil
}
return
diff
}
func
getStringMapDiffInternal
(
strings1
,
strings2
map
[
string
]
string
)
*
StringMapDiff
{
result
:=
newStringMapDiffDiff
()
for
k1
,
v1
:=
range
strings1
{
if
v2
,
ok
:=
strings2
[
k1
];
ok
{
if
v1
!=
v2
{
result
.
Modified
[
k1
]
=
getValueDiff
(
v1
,
v2
)
}
}
else
{
result
.
Deleted
=
append
(
result
.
Deleted
,
k1
)
}
}
for
k2
:=
range
strings2
{
if
_
,
ok
:=
strings1
[
k2
];
!
ok
{
result
.
Added
=
append
(
result
.
Added
,
k2
)
}
}
return
result
}
Back
|
FazBrowse Home
|
New Git URL