Skip to content

Instantly share code, notes, and snippets.

@arriqaaq
Created January 27, 2023 09:31
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 arriqaaq/3300ce1274d58bfa4c52bf435f372a00 to your computer and use it in GitHub Desktop.
Save arriqaaq/3300ce1274d58bfa4c52bf435f372a00 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type LegacyPrinter struct {
}
func (l *LegacyPrinter) Print(s string) {
fmt.Println(s)
}
type Printer interface {
PrintStored() string
}
type PrinterAdapter struct {
LegacyPrinter
}
func (p *PrinterAdapter) PrintStored() string {
return "Adapted"
}
func main() {
adapter := &PrinterAdapter{}
fmt.Println(adapter.PrintStored())
adapter.Print("Hello World!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment