[GH-ISSUE #3283] using Go client, api.Duration is not interpreted correctly #27783

Closed
opened 2026-04-22 05:22:00 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @jackielii on GitHub (Mar 21, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/3283

What is the issue?

Using this simple test function we'll see without Marshal it won't get interpreted correctly:

import 	ollama "github.com/jmorganca/ollama/api"

func TestMarshal(t *testing.T) {
	d := &ollama.Duration{Duration: -1}
	b, err := json.Marshal(d)
	require.NoError(t, err)
	println(string(b))

	var d2 ollama.Duration
	err = json.Unmarshal(b, &d2)
	require.NoError(t, err)
	spew.Dump(d2)
}

We get:

=== RUN   TestMarshal
{"Duration":-1}
(api.Duration) 5m0s

What did you expect to see?

d2 should be maxInt

Steps to reproduce

see above test

Are there any recent changes that introduced the issue?

N/A

OS

No response

Architecture

No response

Platform

No response

Ollama version

No response

GPU

No response

GPU info

No response

CPU

No response

Other software

No response

Originally created by @jackielii on GitHub (Mar 21, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/3283 ### What is the issue? Using this simple test function we'll see without Marshal it won't get interpreted correctly: ```go import ollama "github.com/jmorganca/ollama/api" func TestMarshal(t *testing.T) { d := &ollama.Duration{Duration: -1} b, err := json.Marshal(d) require.NoError(t, err) println(string(b)) var d2 ollama.Duration err = json.Unmarshal(b, &d2) require.NoError(t, err) spew.Dump(d2) } ``` We get: ``` === RUN TestMarshal {"Duration":-1} (api.Duration) 5m0s ``` ### What did you expect to see? d2 should be maxInt ### Steps to reproduce see above test ### Are there any recent changes that introduced the issue? N/A ### OS _No response_ ### Architecture _No response_ ### Platform _No response_ ### Ollama version _No response_ ### GPU _No response_ ### GPU info _No response_ ### CPU _No response_ ### Other software _No response_
GiteaMirror added the bug label 2026-04-22 05:22:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#27783