Created
November 1, 2015 06:41
-
-
Save nodirt/da80ef7c12d67b9ab8d2 to your computer and use it in GitHub Desktop.
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
| // Package better is a better implementation of log.Logger | |
| package better | |
| type Logger struct { | |
| } | |
| func (l *Logger) Print(v ...interface{}) { | |
| //.... | |
| } | |
| // other methods |
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
| package main | |
| import ( | |
| "better" | |
| "log" | |
| ) | |
| // Logger is a subset of log.Logger methods that we need. | |
| type MyLogger interface { | |
| Print(v ...interface{}) | |
| } | |
| func do(l MyLogger) { | |
| l.Print("doing...") | |
| } | |
| func main() { | |
| do(log.New(os.Stdout, "", 0)) | |
| do(&better.Logger{}) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment