1
2
3
4
5
6
7 package types2_test
8
9 import (
10 gcimporter "cmd/compile/internal/importer"
11 "cmd/compile/internal/types2"
12 "io"
13 )
14
15 func defaultImporter() types2.Importer {
16 return &gcimports{
17 packages: make(map[string]*types2.Package),
18 }
19 }
20
21 type gcimports struct {
22 packages map[string]*types2.Package
23 lookup func(path string) (io.ReadCloser, error)
24 }
25
26 func (m *gcimports) Import(path string) (*types2.Package, error) {
27 return m.ImportFrom(path, "" , 0)
28 }
29
30 func (m *gcimports) ImportFrom(path, srcDir string, mode types2.ImportMode) (*types2.Package, error) {
31 if mode != 0 {
32 panic("mode must be 0")
33 }
34 return gcimporter.Import(m.packages, path, srcDir, m.lookup)
35 }
36
View as plain text