From 57f94c3c040ca95c6c543f54a4740a792957d5a2 Mon Sep 17 00:00:00 2001 From: caoyingjunz Date: Sun, 13 Aug 2023 11:08:43 +0800 Subject: [PATCH 1/2] Add decorator demo --- practise/decorator-practise.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 practise/decorator-practise.go diff --git a/practise/decorator-practise.go b/practise/decorator-practise.go new file mode 100644 index 0000000..606fad7 --- /dev/null +++ b/practise/decorator-practise.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" +) + +func TestA(a, b string, f func()) { + fmt.Println(a) + f() + fmt.Println(b) +} + +func main() { + TestA("before", "end", func() { + fmt.Println("中间执行") + }) +} From 91240b280e90217bddbc9be289644e27b92422a7 Mon Sep 17 00:00:00 2001 From: caoyingjunz Date: Sun, 13 Aug 2023 11:16:45 +0800 Subject: [PATCH 2/2] add --- practise/template-practise/template/template.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/practise/template-practise/template/template.go b/practise/template-practise/template/template.go index d2c7248..533a2d8 100644 --- a/practise/template-practise/template/template.go +++ b/practise/template-practise/template/template.go @@ -7,9 +7,11 @@ kind: Service metadata: name: {{ .UserName }} spec: +{{- if gt (len .Emails) 0 }} emails: {{- range .Emails }} - {{ . }} +{{- end }} {{- end }} selector: {{- with .Friends }}