schmorrison / Zoho

Golang API for Zoho services
MIT License
35 stars 34 forks source link

Bugs in zoho.Time and crm.SingleLine marshalling #24

Closed rollulus closed 3 years ago

rollulus commented 3 years ago

Not affecting me, but I ran into it while creating my PR, and I thought that you might wanted to know this. In the following snippet:


// UnmarshalJSON is the json unmarshalling function for Time internal type
func (t *Time) UnmarshalJSON(b []byte) error {
    s := strings.Trim(string(b), "\"")
    if s == "null" {
        blank := Time(time.Time{})
        t = &blank
        return nil
    }
    pTime, err := time.Parse(zohoTimeLayout, s)
    if err == nil {
        ref := Time(pTime)
        t = &ref
    }
    return err
}

t = &blank and t = &ref are ineffective. It has no effect to modify the receiver t. It does have effect to modify the value to which the receiver points. That would make e.g. *t = blank and *t = ref.

schmorrison commented 3 years ago

Good catch. That stuff was done at the tail of a sprint a couple years ago I think. I don't believe I am using those types in the packages at all.

BTW thanks for the PR