Last active
September 6, 2023 09:24
-
-
Save vs9390/3199fb8e1daf260c9594464cb219efba to your computer and use it in GitHub Desktop.
Facade Design Pattern Example in GO Lang
This file contains 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 "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