Skip to content

Commit

Permalink
report error not panic
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Aug 26, 2014
1 parent 0d59765 commit 4a15c0f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions gorazor/cases/import.gohtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
@{
import "strconv"
import "now"
import ("strconv")
import ("now")
import "this"
import (
"hello"
"huhu"
)
)

}
Expand Down
3 changes: 2 additions & 1 deletion gorazor/gogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ func (cp *Compiler) visitFirstBLK(blk *Ast) {
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "", "package main\n"+first, parser.ImportsOnly)
if err != nil {
panic(err)
fmt.Println(err)
os.Exit(1)
} else {
for _, s := range f.Imports {
v := s.Path.Value
Expand Down
3 changes: 3 additions & 0 deletions gorazor/test/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package cases

import (
"bytes"
"hello"
"huhu"
"now"
"strconv"
"this"
)

func Import() string {
Expand Down

0 comments on commit 4a15c0f

Please sign in to comment.