Skip to content

Instantly share code, notes, and snippets.

@koron
Last active May 22, 2018 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koron/af0504265fd3188ee395c5bc9570a255 to your computer and use it in GitHub Desktop.
Save koron/af0504265fd3188ee395c5bc9570a255 to your computer and use it in GitHub Desktop.
package a
type Printer struct {
}
func NewPrinter() *Printer {
return &Printer{}
}
func (p *Printer) Print(s string) {}
package a2
type TestPrinter struct {}
// printer for test.
func (p *TestPrinter) Print(s string) {}
package b
type Printer interface {
Print(s string)
}
func DoWithPrinter(p Printer) {
p.Print("Hello")
p.Print("World")
}
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