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
81d8d7b7
Commit
81d8d7b7
authored
Aug 10, 2023
by
Michael Yang
Browse files
fix could not convert int
parent
be889b2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
api/types.go
api/types.go
+7
-5
No files found.
api/types.go
View file @
81d8d7b7
...
@@ -218,13 +218,15 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
...
@@ -218,13 +218,15 @@ func (opts *Options) FromMap(m map[string]interface{}) error {
if
field
.
IsValid
()
&&
field
.
CanSet
()
{
if
field
.
IsValid
()
&&
field
.
CanSet
()
{
switch
field
.
Kind
()
{
switch
field
.
Kind
()
{
case
reflect
.
Int
:
case
reflect
.
Int
:
// when JSON unmarshals numbers, it uses float64 by default, not int
switch
t
:=
val
.
(
type
)
{
val
,
ok
:=
val
.
(
float64
)
case
int64
:
if
!
ok
{
field
.
SetInt
(
t
)
case
float64
:
// when JSON unmarshals numbers, it uses float64, not int
field
.
SetInt
(
int64
(
t
))
default
:
log
.
Printf
(
"could not convert model parmeter %v to int, skipped"
,
key
)
log
.
Printf
(
"could not convert model parmeter %v to int, skipped"
,
key
)
continue
}
}
field
.
SetInt
(
int64
(
val
))
case
reflect
.
Bool
:
case
reflect
.
Bool
:
val
,
ok
:=
val
.
(
bool
)
val
,
ok
:=
val
.
(
bool
)
if
!
ok
{
if
!
ok
{
...
...
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