@kjk1/

gobook template and or

Go

No description

fork
loading
Files
  • main.go

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.2114295621832436","path":"main.go","file":{"path":"main.go","content":{"asEncoding":{"base64":"cGFja2FnZSBtYWluCgppbXBvcnQgKAoJImxvZyIKCSJvcyIKCSJ0ZXh0L3RlbXBsYXRlIgopCgp0eXBlIERhdGEgc3RydWN0IHsKCVRydWUgIGJvb2wKCUZhbHNlIGJvb2wKfQoKLy8gOnNob3cgc3RhcnQKY29uc3QgdG1wbFN0ciA9IGBPcjogIHt7IGlmIG9yIC5UcnVlIC5GYWxzZSB9fXRydWV7eyBlbHNlIH19ZmFsc2V7eyBlbmQgfX0KQW5kOiB7eyBpZiBhbmQgLlRydWUgLkZhbHNlIH19dHJ1ZXt7IGVsc2UgfX1mYWxzZXt7IGVuZCB9fQpOb3Q6IHt7IGlmIG5vdCAuRmFsc2UgfX10cnVle3sgZWxzZSB9fWZhbHNle3sgZW5kIH19CmAKCi8vIDpzaG93IGVuZAoKZnVuYyBtYWluKCkgewoJLy8gOnNob3cgc3RhcnQKCXQgOj0gdGVtcGxhdGUuTXVzdCh0ZW1wbGF0ZS5OZXcoImFuZF9vcl9ub3QiKS5QYXJzZSh0bXBsU3RyKSkKCglkYXRhIDo9IERhdGF7VHJ1ZTogdHJ1ZSwgRmFsc2U6IGZhbHNlfQoKCWVyciA6PSB0LkV4ZWN1dGUob3MuU3Rkb3V0LCBkYXRhKQoJaWYgZXJyICE9IG5pbCB7CgkJbG9nLkZhdGFsZigidC5FeGVjdXRlKCkgZmFpbGVkIHdpdGggJyVzJ1xuIiwgZXJyKQoJfQoJLy8gOnNob3cgZW5kCn0="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main

import (
	"log"
	"os"
	"text/template"
)

type Data struct {
	True  bool
	False bool
}

// :show start
const tmplStr = `Or:  {{ if or .True .False }}true{{ else }}false{{ end }}
And: {{ if and .True .False }}true{{ else }}false{{ end }}
Not: {{ if not .False }}true{{ else }}false{{ end }}
`

// :show end

func main() {
	// :show start
	t := template.Must(template.New("and_or_not").Parse(tmplStr))

	data := Data{True: true, False: false}

	err := t.Execute(os.Stdout, data)
	if err != nil {
		log.Fatalf("t.Execute() failed with '%s'\n", err)
	}
	// :show end
}