bytecodealliance / bytecodealliance/go-pkg
Feature: Make streams implement the existing Go io interfaces.
- Lingua principale
- Go
- Stelle
- 0
- Fork
- 6
- Merge medio
- 1h 24m
- PR unite (30g)
- 2
Descrizione
# Description
In order to make bindings more Go idiomatic we should make streams implement the `io.Reader`, `io.Writer` and `io.Closer` interfaces. This would enable more seamless integration with existing Go functions.
### Example
For the following wit type `stream` the types should implement the following:
```go
// StreamReader implements io.ReadCloser
var _ io.ReadCloser = (*witTypes.StreamReader[uint8])(nil)
// io.ReadCloser
type ReadCloser interface {
Read(p []byte) (n int, err error)
Close() error
}
// StreamWriter implements io.WriteCloser
var _ io.WriteCloser = (*witTypes.StreamWriter[uint8])(nil)
// io.WriteCloser
type WriteCloser interface {
Write(p []byte) (n int, err error)
Close() error
}
```
This would allow you to for example, encode json straight onto the stream:
```go
// Create stream
tx, rx := foo.MakeStreamU8()
// Encode json
err := son.NewEncoder(tx).Encode(map[string]string{
"foo": "bar",
})
...
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia individuando i tipi StreamReader e StreamWriter generati per stream e leggi le operazioni di stream esistenti. Controlla come questi tipi gestiscono attualmente la lettura, la scrittura e la chiusura, quindi verifica che soddisfino le interfacce io.Reader, io.Writer, io.ReadCloser e io.WriteCloser e che possano essere passati all’encoder JSON mostrato nell’issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- go
- Ambito
- api
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 68/100