Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

TTL errors when trying to unmarshal because tile38 returns a float not an int #58

@lugomateo

Description

@lugomateo

After setting an object's expiration, calling TTL on the object causes an error:
json: cannot unmarshal number 0.174668 into Go struct field .ttl of type int

Calling TTL directly on the tile38-cli, looks like tile38 returns a float (instead of an int)
{"ok":true,"ttl":0.174668,"elapsed":"7.359µs"}

should be a super quick fix, something like this:

func (ks *Keys) TTL(key, objectID string) (float64, error) {
	var resp struct {
		TTL float64 `json:"ttl"`
	}

	err := ks.client.jExecute(&resp, "TTL", key, objectID)
	if err != nil {
		return -1, err
	}

	return resp.TTL, nil
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions