Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
c84bbf1d
Unverified
Commit
c84bbf1d
authored
Aug 17, 2023
by
Michael Yang
Committed by
GitHub
Aug 17, 2023
Browse files
Merge pull request #376 from jmorganca/mxyng/from-map-ignore-nil
ignore nil map values
parents
cbf725a9
f723bf08
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
api/types.go
api/types.go
+4
-0
No files found.
api/types.go
View file @
c84bbf1d
...
@@ -216,6 +216,10 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
...
@@ -216,6 +216,10 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
if
opt
,
ok
:=
jsonOpts
[
key
];
ok
{
if
opt
,
ok
:=
jsonOpts
[
key
];
ok
{
field
:=
valueOpts
.
FieldByName
(
opt
.
Name
)
field
:=
valueOpts
.
FieldByName
(
opt
.
Name
)
if
field
.
IsValid
()
&&
field
.
CanSet
()
{
if
field
.
IsValid
()
&&
field
.
CanSet
()
{
if
val
==
nil
{
continue
}
switch
field
.
Kind
()
{
switch
field
.
Kind
()
{
case
reflect
.
Int
:
case
reflect
.
Int
:
switch
t
:=
val
.
(
type
)
{
switch
t
:=
val
.
(
type
)
{
...
...
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