Skip to content

Instantly share code, notes, and snippets.

@vs9390
Last active September 6, 2023 09:24
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 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{
"a@a.com": "a",
"b@b.com": "b",
"xxxxx@gmail.com": "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("vs9390@gmail.com"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment