Last active
May 22, 2018 10:25
-
-
Save koron/af0504265fd3188ee395c5bc9570a255 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 a | |
type Printer struct { | |
} | |
func NewPrinter() *Printer { | |
return &Printer{} | |
} | |
func (p *Printer) Print(s string) {} |
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 a2 | |
type TestPrinter struct {} | |
// printer for test. | |
func (p *TestPrinter) Print(s string) {} |
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 b | |
type Printer interface { | |
Print(s string) | |
} | |
func DoWithPrinter(p Printer) { | |
p.Print("Hello") | |
p.Print("World") | |
} |
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 ( | |
"a" | |
"a2" | |
"b" | |
) | |
func main() { | |
b.DoWithPrinter(a.NewPrinter()) | |
// for test | |
//b.DoWithPrinter(&a2.TestPrinter{}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment