/
register.go
54 lines (50 loc) · 1.38 KB
/
register.go
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
package shared
import (
"text/template"
pgs "github.com/lyft/protoc-gen-star"
pgsgo "github.com/lyft/protoc-gen-star/lang/go"
)
func Register(tpl *template.Template, params pgs.Parameters) {
fn := Func{
Context: pgsgo.InitContext(params),
}
tpl.Funcs(map[string]interface{}{
"cmt": pgs.C80,
"render": Render(tpl),
"disabled": Disabled,
"ignored": Ignored,
"required": RequiredOneOf,
"context": RulesContext,
"has": Has,
"needs": Needs,
//
"pkg": fn.PackageName,
"typ": fn.Type,
"name": fn.Name,
"optional": fn.Optional,
"accessor": fn.Accessor,
"err": fn.Error,
"errname": fn.ErrorName,
"errIdx": fn.ErrorIdx,
"errCause": fn.ErrorCause,
"errIdxCause": fn.ErrorIdxCause,
"lookup": fn.Lookup,
"lit": fn.Lit,
"isBytes": fn.IsBytes,
"byteStr": fn.ByteStr,
"oneof": fn.OneOfTypeName,
"inType": fn.InType,
"inKey": fn.InKey,
"durGt": fn.DurationGt,
"durLit": fn.DurationLit,
"durStr": fn.DurationStr,
"tsGt": fn.TimestampGt,
"tsLit": fn.TimestampLit,
"tsStr": fn.TimestampStr,
"unwrap": fn.Unwrap,
"msgTyp": fn.MessageType,
"externalEnums": fn.ExternalEnums,
"enumPackages": fn.EnumPackages,
"snakeCase": fn.SnakeCase,
})
}