-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefcase.go
43 lines (33 loc) · 925 Bytes
/
defcase.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
package defcase
import (
"github.com/go-shafaq/defcase/internal"
)
type DefCase interface {
SetCase(tag, pkgPath string, case_ Case)
GetCase(tag, pkgPath string) Case
Convert(tag, pkgPath, name string) string
Converter(tag, pkgPath string) func(name string) string
}
var public DefCase = New()
func Get() DefCase {
return public
}
func New() DefCase {
return &defCase{tagNode: internal.NewPkgNode()}
}
type defCase struct {
tagNode *internal.PkgNode
}
func (d *defCase) SetCase(tag, pkgPath string, case_ Case) {
d.tagNode.SetCase(tag, pkgPath, case_)
}
func (d *defCase) GetCase(tag, pkgPath string) Case {
return d.tagNode.GetCase(tag, pkgPath)
}
func (d *defCase) Convert(tag, pkgPath, name string) string {
converter := d.Converter(tag, pkgPath)
return converter(name)
}
func (d *defCase) Converter(tag, pkgPath string) func(name string) string {
return d.tagNode.GetCase(tag, pkgPath).GetFunc()
}