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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
package jen
// Lit renders a literal. Lit supports only built-in types (bool, string, int, complex128, float64,
// float32, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, uintptr and complex64).
// Passing any other type will panic.
func Lit(v interface{}) *Statement {
return newStatement().Lit(v)
}
// Lit renders a literal. Lit supports only built-in types (bool, string, int, complex128, float64,
// float32, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, uintptr and complex64).
// Passing any other type will panic.
func (g *Group) Lit(v interface{}) *Statement {
s := Lit(v)
g.items = append(g.items, s)
return s
}
// Lit renders a literal. Lit supports only built-in types (bool, string, int, complex128, float64,
// float32, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, uintptr and complex64).
// Passing any other type will panic.
func (s *Statement) Lit(v interface{}) *Statement {
t := token{
typ: literalToken,
content: v,
}
*s = append(*s, t)
return s
}
// LitFunc renders a literal. LitFunc generates the value to render by executing the provided
// function. LitFunc supports only built-in types (bool, string, int, complex128, float64, float32,
// int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, uintptr and complex64).
// Returning any other type will panic.
func LitFunc(f func() interface{}) *Statement {
return newStatement().LitFunc(f)
}
// LitFunc renders a literal. LitFunc generates the value to render by executing the provided
// function. LitFunc supports only built-in types (bool, string, int, complex128, float64, float32,
// int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, uintptr and complex64).
// Returning any other type will panic.
func (g *Group) LitFunc(f func() interface{}) *Statement {
s := LitFunc(f)
g.items = append(g.items, s)
return s
}
// LitFunc renders a literal. LitFunc generates the value to render by executing the provided
// function. LitFunc supports only built-in types (bool, string, int, complex128, float64, float32,
// int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, uintptr and complex64).
// Returning any other type will panic.
func (s *Statement) LitFunc(f func() interface{}) *Statement {
t := token{
typ: literalToken,
content: f(),
}
*s = append(*s, t)
return s
}
// LitRune renders a rune literal.
func LitRune(v rune) *Statement {
return newStatement().LitRune(v)
}
// LitRune renders a rune literal.
func (g *Group) LitRune(v rune) *Statement {
s := LitRune(v)
g.items = append(g.items, s)
return s
}
// LitRune renders a rune literal.
func (s *Statement) LitRune(v rune) *Statement {
t := token{
typ: literalRuneToken,
content: v,
}
*s = append(*s, t)
return s
}
// LitRuneFunc renders a rune literal. LitRuneFunc generates the value to
// render by executing the provided function.
func LitRuneFunc(f func() rune) *Statement {
return newStatement().LitRuneFunc(f)
}
// LitRuneFunc renders a rune literal. LitRuneFunc generates the value to
// render by executing the provided function.
func (g *Group) LitRuneFunc(f func() rune) *Statement {
s := LitRuneFunc(f)
g.items = append(g.items, s)
return s
}
// LitRuneFunc renders a rune literal. LitRuneFunc generates the value to
// render by executing the provided function.
func (s *Statement) LitRuneFunc(f func() rune) *Statement {
t := token{
typ: literalRuneToken,
content: f(),
}
*s = append(*s, t)
return s
}
// LitByte renders a byte literal.
func LitByte(v byte) *Statement {
return newStatement().LitByte(v)
}
// LitByte renders a byte literal.
func (g *Group) LitByte(v byte) *Statement {
s := LitByte(v)
g.items = append(g.items, s)
return s
}
// LitByte renders a byte literal.
func (s *Statement) LitByte(v byte) *Statement {
t := token{
typ: literalByteToken,
content: v,
}
*s = append(*s, t)
return s
}
// LitByteFunc renders a byte literal. LitByteFunc generates the value to
// render by executing the provided function.
func LitByteFunc(f func() byte) *Statement {
return newStatement().LitByteFunc(f)
}
// LitByteFunc renders a byte literal. LitByteFunc generates the value to
// render by executing the provided function.
func (g *Group) LitByteFunc(f func() byte) *Statement {
s := LitByteFunc(f)
g.items = append(g.items, s)
return s
}
// LitByteFunc renders a byte literal. LitByteFunc generates the value to
// render by executing the provided function.
func (s *Statement) LitByteFunc(f func() byte) *Statement {
t := token{
typ: literalByteToken,
content: f(),
}
*s = append(*s, t)
return s
}
|