Created
April 22, 2020 18:48
-
-
Save olehcambel/32c98aa6ace620bfd7e372ea50e42635 to your computer and use it in GitHub Desktop.
using union to merge 2 interfaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Reader interface { | |
Read(p []byte) (n int, err error) | |
Close() error | |
} | |
type Writer interface { | |
Write(p []byte) (n int, err error) | |
Close() error | |
} | |
// ReadWriter's methods are Read, Write, and Close. | |
type ReadWriter interface { | |
Reader // includes methods of Reader in ReadWriter's method set | |
Writer // includes methods of Writer in ReadWriter's method set | |
// Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment