Skip to content

Instantly share code, notes, and snippets.

@vs9390
Last active September 6, 2023 09:24
Show Gist options
  • Save vs9390/3199fb8e1daf260c9594464cb219efba to your computer and use it in GitHub Desktop.
Save vs9390/3199fb8e1daf260c9594464cb219efba to your computer and use it in GitHub Desktop.
Facade Design Pattern Example in GO Lang
package main
import "fmt"
var db = map[string]string{
"[email protected]": "a",
"[email protected]": "b",
"[email protected]": "xxxxx sharma",
}
type database struct {
}
func (self *database) getNameByMail(mail string) string {
return db[mail]
}
type mdWriter struct {
}
func (self *mdWriter) title(title string) string {
return "# Welcome to " + title + "'s page!"
}
type PageMaker struct {
}
func (self *PageMaker) MakeWelcomePage(mail string) string {
database := database{}
writer := mdWriter{}
name := database.getNameByMail(mail)
page := writer.title(name)
return page
}
func main() {
pageMaker := PageMaker{}
fmt.Println(pageMaker.MakeWelcomePage("[email protected]"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment