Пример #1
0
func NewFilePackage(filename string) (*PackageView, error) {
	p := new(PackageView)
	p.fset = token.NewFileSet()
	file, err := parser.ParseFile(p.fset, filename, nil, 0)
	if err != nil {
		return nil, err
	}
	p.pdoc = doc.NewFileDoc(file, true)
	return p, nil
}
Пример #2
0
func NewFilePackageSource(filename string, f *os.File) (*PackageView, error) {
	src, err := ioutil.ReadAll(f)
	if err != nil {
		return nil, err
	}
	p := new(PackageView)
	p.fset = token.NewFileSet()
	file, err := parser.ParseFile(p.fset, filename, src, 0)
	if err != nil {
		return nil, err
	}
	p.pdoc = doc.NewFileDoc(file, true)
	return p, nil
}