Skip to content

Commit b86800a

Browse files
committed
add cmd go-ast
1 parent 4e48065 commit b86800a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

code/go-ast/go-ast.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/xhd2015/go-coverage/code"
8+
)
9+
10+
func main() {
11+
args := os.Args
12+
if len(args) < 2 {
13+
// ioutil.ReadAll(os.Stdin)
14+
fmt.Printf("requires file\n")
15+
os.Exit(1)
16+
}
17+
file := args[1]
18+
19+
_, ast, _, err := code.ParseFile(file)
20+
if err != nil {
21+
fmt.Printf("parsing: %v", err)
22+
os.Exit(1)
23+
}
24+
25+
// get log
26+
code.Clean(ast, code.CleanOpts{
27+
Log: true,
28+
LogIndent: 4,
29+
})
30+
}

0 commit comments

Comments
 (0)