Timestamp struct used in models.go seems incoherent with the used date format

Aperta
#26 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@skb1129 ci sta già lavorando.

Dal 19/7/2026.

  • #126 di @skb1129 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
go
Ambito
api

Direzione di ricerca

Leggi getstream-go/models.go e getstream/rfc3339.go, iniziando dai metodi Timestamp MarshalJSON e UnmarshalJSON. Confronta il loro input previsto con il formato del timestamp mostrato nell’issue e verifica il comportamento usando un payload di evento rappresentativo. Il lavoro è completato quando le date degli eventi possono essere deserializzate in modo coerente con il formato documentato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hi guys, I’m implementing a webhook handler that listens to GetStream Call events. To ease events payload unmarshaling, I’m trying to use the events structs in getstream-go/models.go.
But it seems that the date type Timestamp is not coherent with the date format sent by Getstream in the events payloads.

type Timestamp struct {
	Time *time.Time
}

func (t Timestamp) MarshalJSON() ([]byte, error) {
	return json.Marshal(t.Time)
}

func (t *Timestamp) UnmarshalJSON(data []byte) error {
	strData := string(data)
	if strData == "null" {
		return nil
	}

	ns, err := strconv.ParseInt(strData, 10, 64)
	if err != nil {
		return fmt.Errorf("failed to parse timestamp: %w", err)
	}

	utcT := time.Unix(0, ns).UTC()
	t.Time = &utcT
	return nil
}

With this implementation from getstream/rfc3339.go, the date format should be something like « 1739803521 » but the GetStream events payload contains the dates in that format: « 2025-02-13T16:45:22.746736895Z ».
So the UnmarshalJSON method can’t be used right away.

Is it the expected behavior?

Lingua principale
Go
Stelle
8
Fork
3
Merge medio
29m
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di GetStream/getstream-go

Tutte le issue di GetStream/getstream-go

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.