-
Notifications
You must be signed in to change notification settings - Fork 0
/
imports.go
54 lines (43 loc) · 1.44 KB
/
imports.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 renderer
import "github.com/sirkon/gogh"
// NewImports для конструктора рендерера.
func NewImports(imp *gogh.Imports) *Imports {
return &Imports{
imp: imp,
}
}
// Imports is an extension of gogh.Imports to provide some frequently
// used imports.
type Imports struct {
imp *gogh.Imports
}
// Add to implement gogh.Importer
func (i *Imports) Add(pkgpath string) *gogh.ImportAliasControl {
return i.imp.Add(pkgpath)
}
// Module to implement gogh.Importer
func (i *Imports) Module(relpath string) *gogh.ImportAliasControl {
return i.imp.Module(relpath)
}
// Imports дto implement gogh.Importer
func (i *Imports) Imports() *gogh.Imports {
return i.imp
}
// Errors structured errors package. It is github.com/sirkon/errors
// by default. The value can be overrided
func (i *Imports) Errors() *gogh.ImportAliasControl {
return i.imp.Add(structuredErrorsPkgPath)
}
// Binary импорт пакета binary из стандартной библиотеки.
func (i *Imports) Binary() *gogh.ImportAliasControl {
return i.imp.Add("encoding/binary")
}
// Unsafe импорт пакета unsafe из стандартной библиотеки.
func (i *Imports) Unsafe() *gogh.ImportAliasControl {
return i.imp.Add("unsafe")
}
// Varsize импорт пакета github.com/sirkon/varsize.
func (i *Imports) Varsize() *gogh.ImportAliasControl {
return i.imp.Add("github.com/sirkon/varsize")
}
var _ gogh.Importer = &Imports{}