You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
Strategyè¨è¨ã®å¤±æ ååã§ãHTMLã¨ããã¹ãã§ã¬ãã¼ããåºåããã³ã¼ããæ¸ãã¾ããããã®ä¸ã§Formatter interfaceãå®ç¾©ãããã®å ·è±¡åã¨ãã¦PlainTextFormatter HTMLFormatterãå®ç¾©ããã¨ããStrategyãã¿ã¼ã³ãæ¡ç¨ãã¾ããã ããããæ°ã«ãªãç¹ãç¡ãã§ã¯ããã¾ããã package main import ( "fmt" ) type Formatter interface { OutputStart() OutputHead(text string) OutputBodyStart() OutputLine(line string) OutputBodyEnd() OutputEnd() } type Report struct { Title string Text []string Formatter Formatter
ä¾ï¼ã¬ãã¼ããåºåããã¯ã©ã¹ã ã¬ãã¼ããHTMLã§åºåããstruct*1ãä½ã£ãããªããä¸å¸ãããã¬ã¼ã³ããã¹ãã§ãåºåãã¦ããã¨è¨ããã¦ãã¾ãã¾ãããã¨ããããããã©ã¼ããããå¼æ°ã§æå®ããããã«ããã®ã§ããã»ã»ã» // template_method.1.go package main import ( "fmt" ) type Report struct { Title string Text []string } func (r *Report) OutputReport(format string) error { if format == "plain" { fmt.Printf("*** %s ***\n", r.Title) } else if format == "html" { fmt.Println("<html>") fmt.Println("<head>")
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}