|
type Blob struct { |
|
io.ReadWriteSeeker |
|
io.ReaderAt |
|
io.WriterAt |
|
io.Closer |
This code defines a struct with fields named ReadWriteSeeker, ReaderAt, WriterAt, and Closer which are never used. Notably, Blob itself implements the functions required by these interfaces. If Blob was an interface this syntax would mean that whatever implements Blob must have the methods in the listed interfaces, but written as a struct this syntax defines four separate fields in the struct itself. This appears to be a mistake.
Here's a playground example that shows this: https://go.dev/play/p/Hr0SlKqYhV9
To require that a struct Blob implements the required interfaces, one can use the "interface guards" pattern like this:
var _ io.ReadWriteSeeker = &Blob{}
var _ io.ReaderAt = &Blob{}
var _ io.WriterAt = &Blob{}
var _ io.Closer = &Blob{}
sqlite/blob.go
Lines 81 to 85 in 6c1d4ad
This code defines a struct with fields named
ReadWriteSeeker,ReaderAt,WriterAt, andCloserwhich are never used. Notably,Blobitself implements the functions required by these interfaces. IfBlobwas an interface this syntax would mean that whatever implementsBlobmust have the methods in the listed interfaces, but written as a struct this syntax defines four separate fields in the struct itself. This appears to be a mistake.Here's a playground example that shows this: https://go.dev/play/p/Hr0SlKqYhV9
To require that a struct
Blobimplements the required interfaces, one can use the "interface guards" pattern like this: