Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Feature: Make streams implement the existing Go io interfaces.

Đang mở
#9 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
go
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu bằng cách xác định các kiểu StreamReader và StreamWriter được tạo cho stream và đọc các thao tác stream hiện có của chúng. Kiểm tra cách các kiểu này hiện xử lý việc đọc, ghi và đóng, sau đó xác minh rằng chúng triển khai các interface io.Reader, io.Writer, io.ReadCloser và io.WriteCloser, đồng thời có thể được truyền vào bộ mã hóa JSON được hiển thị trong issue.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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<u8> the types should implement the following:

// 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:

// Create stream
tx, rx := foo.MakeStreamU8()

// Encode json
err := son.NewEncoder(tx).Encode(map[string]string{
    "foo": "bar",
})
...
Ngôn ngữ chính
Go
Star
0
Fork
7
Merge trung bình
7 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bytecodealliance/go-pkg

Tất cả issue của bytecodealliance/go-pkg

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.