Skip to content

Instantly share code, notes, and snippets.

@JohnStarich
Last active February 16, 2022 05:59
Show Gist options
  • Save JohnStarich/819c39cf5a9def02ccf369e7aeaec0cc to your computer and use it in GitHub Desktop.
Save JohnStarich/819c39cf5a9def02ccf369e7aeaec0cc to your computer and use it in GitHub Desktop.
HackpadFS article – Base Go interfaces
type FS interface {
Open(name string) (File, error)
}
type File interface {
Stat() (FileInfo, error)
Read(p []byte) (int, error)
Close() error
}
type FileInfo interface {
Name() string
Size() int64
Mode() FileMode
ModTime() time.Time
IsDir() bool
Sys() interface{}
}
type DirEntry interface {
Name() string
IsDir() bool
Type() FileMode
Info() (FileInfo, error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment