// parsePkg will parse out the package name, how many go files it contains, and a go file
// name in the current directory.
parsePkg will parse out the package name, how many go files it contains, and a go file
name in the current directory.
// parsePkg will parse out the package name how many go files it contains and a go file // name in the current directory .
func parsePkg() (pkgName string, gofileCount int, mainGoFile string, err error) {
	err = filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
		gofile, err := filepath.Match("?*.go", path)
		if err != nil {
			return err
		}
		if !gofile {
			return nil
		}
		gofileCount++
		mainGoFile = path
		f, err := os.Open(path)
		if err != nil {
			return err
		}
		reader := bufio.NewReader(f)
		line, _, err := reader.ReadLine()
		if err != nil {
			return err
		}
		for reader.Buffered() != 0 {
			pkg := packageExp.FindStringSubmatch(string(line))
			if len(pkg) == 2 {
				pkgName = pkg[1]
				return nil
			}
			line, _, err = reader.ReadLine()
			if err != nil {
				return err
			}
		}
		return nil
	})
	return
}
func parsePkg ( ) ( pkgName string , gofileCount int , mainGoFile string , err error ) { err = filepath . Walk ( " " , func ( path string , info os . FileInfo , err error ) error { gofile , err := filepath . Match ( " " , path ) if err != nil { return err } if ! gofile { return nil } gofileCount ++ mainGoFile = path f , err := os . Open ( path ) if err != nil { return err } reader := bufio . NewReader ( f ) line , _ , err := reader . ReadLine ( ) if err != nil { return err } for reader . Buffered ( ) != 0 { pkg := packageExp . FindStringSubmatch ( string ( line ) ) if len ( pkg ) == 2 { pkgName = pkg [ 1 ] return nil } line , _ , err = reader . ReadLine ( ) if err != nil { return err } } return nil } ) return }
parsePkg will parse out the package name, how many go files it contains, and a go file
name in the current directory.
parsePkg will parse out the package name how many go files it contains and a go file name in the current directory .