Repository: goplus/gop
Pull request #1490 (2023-10-24 03:54:11)

ast: FuncDecl.Shadow


Patch:
diff --git a/ast/ast.go b/ast/ast.go
index dbac1db0..f0b48953 100644
--- a/ast/ast.go
+++ b/ast/ast.go
@@ -1059,6 +1059,7 @@ type (
 		Type     *FuncType     // function signature: parameters, results, and position of "func" keyword
 		Body     *BlockStmt    // function body; or nil for external (non-Go) function
 		Operator bool          // is operator or not
+		Shadow   bool          // is a shadow entry
 	}
 )
 
diff --git a/ast/walk.go b/ast/walk.go
index ba6f4ff1..3cdc64e9 100644
--- a/ast/walk.go
+++ b/ast/walk.go
@@ -345,14 +345,16 @@ func Walk(v Visitor, node Node) {
 		}
 
 	case *FuncDecl:
-		if n.Doc != nil {
-			Walk(v, n.Doc)
-		}
-		if n.Recv != nil {
-			Walk(v, n.Recv)
+		if !n.Shadow { // not a shadow entry
+			if n.Doc != nil {
+				Walk(v, n.Doc)
+			}
+			if n.Recv != nil {
+				Walk(v, n.Recv)
+			}
+			Walk(v, n.Name)
+			Walk(v, n.Type)
 		}
-		Walk(v, n.Name)
-		Walk(v, n.Type)
 		if n.Body != nil {
 			Walk(v, n.Body)
 		}
diff --git a/go.mod b/go.mod
index 02909846..446d101b 100644
--- a/go.mod
+++ b/go.mod
@@ -3,9 +3,9 @@ module github.com/goplus/gop
 go 1.18
 
 require (
-	github.com/fsnotify/fsnotify v1.7.0
+	github.com/fsnotify/fsnotify v1.6.0
 	github.com/goplus/c2go v0.7.16
-	github.com/goplus/gox v1.12.2-0.20231023222557-3d1b2e0a7dbf
+	github.com/goplus/gox v1.12.2-0.20231020202641-5f657ff4e754
 	github.com/goplus/mod v0.11.8-0.20231019172744-da5848421263
 	github.com/qiniu/x v1.13.1
 	golang.org/x/tools v0.14.0
diff --git a/go.sum b/go.sum
index 5d8db683..d808e945 100644
--- a/go.sum
+++ b/go.sum
@@ -1,14 +1,14 @@
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
-github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
+github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
+github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 github.com/goplus/c2go v0.7.16 h1:B9jRNNytoq7yDBQOZSm2qENQhRQMfNhgOea5XHWNUnI=
 github.com/goplus/c2go v0.7.16/go.mod h1:XODEFX2PeEEJXNLLdykWeZgMSaKJ51fVm+C9IM3FxNQ=
 github.com/goplus/gox v1.12.1/go.mod h1:wymoQJ7ydd42cTlaXb4wNbvn4LlKjR+j8PZehI7v1zQ=
-github.com/goplus/gox v1.12.2-0.20231023222557-3d1b2e0a7dbf h1:gQNKxSMyYDdOFNpfqZfWjVZE5q/MsZmqn2rJ3U+OvA8=
-github.com/goplus/gox v1.12.2-0.20231023222557-3d1b2e0a7dbf/go.mod h1:Ek1YIy3wRaZ1i0DD2XG29i3r5AFdhcOradK0/GGs1YQ=
+github.com/goplus/gox v1.12.2-0.20231020202641-5f657ff4e754 h1:uuXDqFfg4RhmHD7slw15hzwVQtJ51CsdcZn6gQtve/E=
+github.com/goplus/gox v1.12.2-0.20231020202641-5f657ff4e754/go.mod h1:Ek1YIy3wRaZ1i0DD2XG29i3r5AFdhcOradK0/GGs1YQ=
 github.com/goplus/mod v0.11.5/go.mod h1:NDC5E+XOT8vcJCMjqKhLDJHTHX7lyVN4Vbfi2U7dBhs=
 github.com/goplus/mod v0.11.8-0.20231019172744-da5848421263 h1:PE0HveOss5mai9pa52L4/ZvVqZtltogJ9rIUIsdlG/I=
 github.com/goplus/mod v0.11.8-0.20231019172744-da5848421263/go.mod h1:yl2QncBKTdXk+8UaNsdo4u2zSpGEJYA5JKjgD3K2h00=
@@ -51,6 +51,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/parser/parser.go b/parser/parser.go
index 43bb6efe..6a9100d9 100644
--- a/parser/parser.go
+++ b/parser/parser.go
@@ -3668,7 +3668,8 @@ func (p *parser) parseGlobalStmts(sync map[token.Token]bool, pos token.Pos, stmt
 			Func:   pos,
 			Params: &ast.FieldList{},
 		},
-		Body: &ast.BlockStmt{List: list},
+		Body:   &ast.BlockStmt{List: list},
+		Shadow: true,
 	}
 	p.shadowEntry = f
 	return f


Test patch:
diff --git a/cl/compile_c2go_test.go b/cl/compile_c2go_test.go
index 8bf5199c..c20edcc9 100644
--- a/cl/compile_c2go_test.go
+++ b/cl/compile_c2go_test.go
@@ -35,8 +35,8 @@ C.printf C"Hello, world!\n"
 `, `package main
 
 import (
-	"github.com/goplus/gop/cl/internal/libc"
-	"unsafe"
+	libc "github.com/goplus/gop/cl/internal/libc"
+	unsafe "unsafe"
 )
 
 func main() {
@@ -53,8 +53,8 @@ C.printf C"Hello, world!\n"
 `, `package main
 
 import (
-	"github.com/goplus/gop/cl/internal/libc"
-	"unsafe"
+	libc "github.com/goplus/gop/cl/internal/libc"
+	unsafe "unsafe"
 )
 
 func main() {
@@ -71,8 +71,8 @@ C.printf C"Hello, world!\n"
 `, `package main
 
 import (
-	"github.com/goplus/gop/cl/internal/libc"
-	"unsafe"
+	libc "github.com/goplus/gop/cl/internal/libc"
+	unsafe "unsafe"
 )
 
 func main() {
diff --git a/cl/compile_spx_test.go b/cl/compile_spx_test.go
index 28e0fd71..1fe31d87 100644
--- a/cl/compile_spx_test.go
+++ b/cl/compile_spx_test.go
@@ -164,7 +164,7 @@ func onMsg(msg string) {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 type Game struct {
 	*spx.MyGame
@@ -211,8 +211,8 @@ func onInit() {
 `, ``, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx"
+	fmt "fmt"
+	spx "github.com/goplus/gop/cl/internal/spx"
 )
 
 const Foo = 1
@@ -248,8 +248,8 @@ func onInit() {
 `, `package main
 
 import (
-	"github.com/goplus/gop/cl/internal/spx"
-	"math"
+	spx "github.com/goplus/gop/cl/internal/spx"
+	math "math"
 )
 
 type Game struct {
@@ -301,7 +301,7 @@ func onCloned() {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 type Game struct {
 	*spx.MyGame
@@ -341,8 +341,8 @@ println "Hi"
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx"
+	fmt "fmt"
+	spx "github.com/goplus/gop/cl/internal/spx"
 )
 
 var x float64 = spx.Rand__1(1.2)
@@ -378,8 +378,8 @@ func onMsg(msg string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx2"
+	fmt "fmt"
+	spx2 "github.com/goplus/gop/cl/internal/spx2"
 )
 
 type Game struct {
@@ -410,8 +410,8 @@ func onMsg(msg string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx2"
+	fmt "fmt"
+	spx2 "github.com/goplus/gop/cl/internal/spx2"
 )
 
 type Game struct {
@@ -442,8 +442,8 @@ func onMsg(msg string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx2"
+	fmt "fmt"
+	spx2 "github.com/goplus/gop/cl/internal/spx2"
 )
 
 type Dog struct {
@@ -472,7 +472,7 @@ func TestSpxMainEntry(t *testing.T) {
 `, `
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx2"
+import spx2 "github.com/goplus/gop/cl/internal/spx2"
 
 type Game struct {
 	spx2.Game
@@ -491,7 +491,7 @@ var (
 `, `
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx2"
+import spx2 "github.com/goplus/gop/cl/internal/spx2"
 
 type Game struct {
 	spx2.Game
@@ -525,8 +525,8 @@ func onMsg(msg string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx2"
+	fmt "fmt"
+	spx2 "github.com/goplus/gop/cl/internal/spx2"
 )
 
 type Game struct {
@@ -566,7 +566,7 @@ func onMsg(msg string) {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 type Game struct {
 	*spx.MyGame
@@ -624,7 +624,7 @@ func onCloned() {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 type info struct {
 	x int
@@ -672,7 +672,7 @@ func onMsg(msg string) {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 type Game struct {
 	*spx.MyGame
@@ -705,8 +705,8 @@ func onMsg(msg string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx"
+	fmt "fmt"
+	spx "github.com/goplus/gop/cl/internal/spx"
 )
 
 type Game struct {
diff --git a/cl/compile_test.go b/cl/compile_test.go
index 3a54eeb8..eceb1c45 100644
--- a/cl/compile_test.go
+++ b/cl/compile_test.go
@@ -153,10 +153,10 @@ for line <- open("foo.txt")! {
 `, `package main
 
 import (
-	"fmt"
-	"os"
-	"github.com/goplus/gop/builtin/iox"
-	"github.com/qiniu/x/errors"
+	fmt "fmt"
+	os "os"
+	iox "github.com/goplus/gop/builtin/iox"
+	errors "github.com/qiniu/x/errors"
 )
 
 func main() {
@@ -190,9 +190,9 @@ for line <- os.Stdin {
 `, `package main
 
 import (
-	"fmt"
-	"os"
-	"github.com/goplus/gop/builtin/iox"
+	fmt "fmt"
+	os "os"
+	iox "github.com/goplus/gop/builtin/iox"
 )
 
 func main() {
@@ -220,9 +220,9 @@ for line <- lines(r) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/builtin/iox"
-	"io"
+	fmt "fmt"
+	iox "github.com/goplus/gop/builtin/iox"
+	io "io"
 )
 
 var r io.Reader
@@ -294,7 +294,7 @@ type T struct{}
 println(&T{},&Point{10,20})
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type T struct {
 }
@@ -311,7 +311,7 @@ for i <- :10, i%3 == 0 {
 	println i
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 0; i < 10; i += 1 {
@@ -334,7 +334,7 @@ d := fvec([])
 println a, b, c, d
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type fvec []float64
 type foo float64
@@ -538,8 +538,8 @@ println "The Go+ Language for", fields.join(", ")
 `, `package main
 
 import (
-	"fmt"
-	"strings"
+	fmt "fmt"
+	strings "strings"
 )
 
 func main() {
@@ -555,7 +555,7 @@ p := println
 p "Hello world"
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	p := fmt.Println
@@ -921,8 +921,8 @@ func main() {
 }`, `package main
 
 import (
-	"fmt"
-	"github.com/qiniu/x/errors"
+	fmt "fmt"
+	errors "github.com/qiniu/x/errors"
 )
 
 func t() (int, int, error) {
@@ -955,7 +955,7 @@ func main() {
 	t()!
 }`, `package main
 
-import "github.com/qiniu/x/errors"
+import errors "github.com/qiniu/x/errors"
 
 func t() error {
 	return nil
@@ -998,7 +998,7 @@ func (a *A) String() string {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type AA interface {
 	String() string
@@ -1043,7 +1043,7 @@ func (a *A) String() string {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type AA interface {
 	String() string
@@ -1084,7 +1084,7 @@ func main() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	{
@@ -1136,7 +1136,7 @@ func main() {
 var i int
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println(i)
@@ -1179,7 +1179,7 @@ func main() {
 var i = 100
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println(i)
@@ -1199,7 +1199,7 @@ func main() {
 	println(n)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	v := []uint64{2, 3, 5}
@@ -1224,7 +1224,7 @@ func consume(xchg chan int) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func consume(xchg chan int) {
 	select {
@@ -1397,7 +1397,7 @@ func main() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type Shape interface {
 	Area() float64
@@ -1442,7 +1442,7 @@ type BigInt struct {
 	*big.Int
 }`, `package main
 
-import "math/big"
+import big "math/big"
 
 type BigInt struct {
 	*big.Int
@@ -1462,10 +1462,10 @@ func foo(script string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/ast/goptest"
-	"github.com/qiniu/x/errors"
-	"github.com/goplus/gop/ast/gopq"
+	fmt "fmt"
+	goptest "github.com/goplus/gop/ast/goptest"
+	errors "github.com/qiniu/x/errors"
+	gopq "github.com/goplus/gop/ast/gopq"
 )
 
 func foo(script string) {
@@ -1496,10 +1496,10 @@ func foo(script string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/ast/goptest"
-	"github.com/qiniu/x/errors"
-	"github.com/goplus/gop/ast/gopq"
+	fmt "fmt"
+	goptest "github.com/goplus/gop/ast/goptest"
+	errors "github.com/qiniu/x/errors"
+	gopq "github.com/goplus/gop/ast/gopq"
 )
 
 func foo(script string) {
@@ -1528,8 +1528,8 @@ func add(x, y string) (int, error) {
 `, `package main
 
 import (
-	"strconv"
-	"github.com/qiniu/x/errors"
+	strconv "strconv"
+	errors "github.com/qiniu/x/errors"
 )
 
 func add(x string, y string) (int, error) {
@@ -1569,7 +1569,7 @@ func addSafe(x, y string) int {
 }
 `, `package main
 
-import "strconv"
+import strconv "strconv"
 
 func addSafe(x string, y string) int {
 	return func() (_gop_ret int) {
@@ -1597,8 +1597,8 @@ var ret int = println("Hi")!
 `, `package main
 
 import (
-	"fmt"
-	"github.com/qiniu/x/errors"
+	fmt "fmt"
+	errors "github.com/qiniu/x/errors"
 )
 
 var ret int = func() (_gop_ret int) {
@@ -1622,7 +1622,7 @@ func mkdir(name string) error {
 mkdir! "foo"
 `, `package main
 
-import "github.com/qiniu/x/errors"
+import errors "github.com/qiniu/x/errors"
 
 func mkdir(name string) error {
 	return nil
@@ -1650,7 +1650,7 @@ func foo() (func(), error) {
 foo()!()
 `, `package main
 
-import "github.com/qiniu/x/errors"
+import errors "github.com/qiniu/x/errors"
 
 func foo() (func(), error) {
 	return nil, nil
@@ -1699,7 +1699,7 @@ var x, y uint128
 var z uint128 = x + y
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x, y ng.Uint128
 var z ng.Uint128 = x.Gop_Add__1(y)
@@ -1712,7 +1712,7 @@ var x, y int128
 var z int128 = x + y
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x, y ng.Int128
 var z ng.Int128 = x.Gop_Add__1(y)
@@ -1725,7 +1725,7 @@ var x, y bigint
 var z bigint = x + y
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x, y ng.Bigint
 var z ng.Bigint = x.Gop_Add(y)
@@ -1738,8 +1738,8 @@ var x = 1r
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 var x = ng.Bigint_Init__1(big.NewInt(1))
@@ -1751,7 +1751,7 @@ func TestUint128Lit(t *testing.T) {
 var x uint128 = 1
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x ng.Uint128 = ng.Uint128_Init__0(1)
 `)
@@ -1762,7 +1762,7 @@ func TestInt128Lit(t *testing.T) {
 var x int128 = 1
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x ng.Int128 = ng.Int128_Init__0(1)
 `)
@@ -1774,8 +1774,8 @@ var x = 1/2r
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 var x = ng.Bigrat_Init__2(big.NewRat(1, 2))
@@ -1788,8 +1788,8 @@ var x = 3 + 1/2r
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 var x = ng.Bigrat_Init__2(big.NewRat(7, 2))
@@ -1805,8 +1805,8 @@ var z = 100 + y
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 var x = ng.Bigrat_Init__2(big.NewRat(7, 2))
@@ -1919,7 +1919,7 @@ var x bigint
 x += 3
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x ng.Bigint
 
@@ -1936,8 +1936,8 @@ x *= 2
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 func main() {
@@ -1954,8 +1954,8 @@ x *= 2r
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 func main() {
@@ -2228,7 +2228,7 @@ go println("Hi")
 defer println("Go+")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	go fmt.Println("Hi")
@@ -2248,7 +2248,7 @@ for {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	a := []float64{1, 3.4, 5}
@@ -2285,7 +2285,7 @@ for range a {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	a := []float64{1, 3.4, 5}
@@ -2323,7 +2323,7 @@ for k, v := range new(foo) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type foo struct {
 }
@@ -2351,7 +2351,7 @@ for v <- new(foo) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type foo struct {
 }
@@ -2386,7 +2386,7 @@ for k, v <- new(foo) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type fooIter struct {
 }
@@ -2422,7 +2422,7 @@ func (p *foo) Gop_Enum(c func(val string)) {
 println([v for v <- new(foo)])
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type foo struct {
 }
@@ -2473,7 +2473,7 @@ for k, v <- newFoo() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type fooIter struct {
 	data *foo
@@ -2522,7 +2522,7 @@ for i, x <- [1, 3, 5, 7, 11, 13, 17] {
 println("sum(5,7,11,13,17):", sum)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	sum := 0
@@ -2693,7 +2693,7 @@ x := [[a, b] for a <- arr, a < b for b <- arr, b > 2]
 println("x:", x)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	arr := []float64{1, 2, 3, 4.1, 5, 6}
@@ -2799,8 +2799,8 @@ println("x:", x)
 `, `package main
 
 import (
-	"fmt"
-	"strings"
+	fmt "fmt"
+	strings "strings"
 )
 
 func main() {
@@ -2823,7 +2823,7 @@ func bar(p pfoo) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type foo struct {
 	req int
@@ -2852,7 +2852,7 @@ a.B = "Hi"
 flag.Usage = nil
 `, `package main
 
-import "flag"
+import flag "flag"
 
 func main() {
 	a := &struct {
@@ -2912,7 +2912,7 @@ func (M) Bar() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type M int
 
@@ -2959,7 +2959,7 @@ var d = -a       // TODO: -a have no return value!
 var e = a!=b
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type foo struct {
 }
@@ -2993,7 +2993,7 @@ var e = a.Gop_NE(b)
 func TestCmdlineNoEOL(t *testing.T) {
 	gopClTest(t, `println "Hi"`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Hi")
@@ -3008,7 +3008,7 @@ func main() {
 	fmt.println "Hi"
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Hi")
@@ -3022,7 +3022,7 @@ func TestDotImport(t *testing.T) {
 var a = round(1.2)
 `, `package main
 
-import "math"
+import math "math"
 
 var a = math.Round(1.2)
 `)
@@ -3034,7 +3034,7 @@ func TestLocalImport(t *testing.T) {
 var a = spx.TestIntValue
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 var a = spx.TestIntValue
 `)
@@ -3069,7 +3069,7 @@ func TestAnonymousImport(t *testing.T) {
 printf("Hello Go+\n")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Hello")
@@ -3108,7 +3108,7 @@ func main() {
 	fmt.Println("Hi")
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	const (
@@ -3133,7 +3133,7 @@ if t := false; t {
 println("x:", x)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	x := 0
@@ -3173,7 +3173,7 @@ default:
 println("x:", x)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	x := 0
@@ -3214,7 +3214,7 @@ default:
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	v := "Hello"
@@ -3246,7 +3246,7 @@ label:
 	}
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	a := []float64{1, 3.4, 5}
@@ -3273,7 +3273,7 @@ func main() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func foo(format string, args ...interface {
 }) (int, error) {
@@ -3311,7 +3311,7 @@ func(v string) {
 }("Hello")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	func(v string) {
@@ -3452,7 +3452,7 @@ Do => {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func Do(func()) {
 }
@@ -3621,7 +3621,7 @@ func bar(foo func(string, ...interface{}) (int, error)) {
 bar(fmt.Printf)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func bar(foo func(string, ...interface {
 }) (int, error)) {
@@ -3658,8 +3658,8 @@ fmt.Println(printf("Hello, %v\n", "Go+"))
 `, `package main
 
 import (
-	"fmt"
-	"strings"
+	fmt "fmt"
+	strings "strings"
 )
 
 func foo(x string) string {
@@ -3687,7 +3687,7 @@ func TestFuncCall(t *testing.T) {
 
 fmt.Println("Hello")`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Hello")
@@ -3705,7 +3705,7 @@ func foo(args ...interface{}) {
 func main() {
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func foo(args ...interface {
 }) {
@@ -3728,7 +3728,7 @@ func foo(args ...interface{}) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	foo("Hello", 123)
@@ -3764,7 +3764,7 @@ func TestAssignUnderscore(t *testing.T) {
 _, err := log.Println("Hello")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	_, err := fmt.Println("Hello")
@@ -3811,8 +3811,8 @@ println(rmap)
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/gop-in-go/foo"
+	fmt "fmt"
+	foo "github.com/goplus/gop/cl/internal/gop-in-go/foo"
 )
 
 func main() {
@@ -3857,8 +3857,8 @@ func New() Result {
 `, `package main
 
 import (
-	"reflect"
-	"testing"
+	reflect "reflect"
+	testing "testing"
 )
 
 type Repo struct {
@@ -3902,7 +3902,7 @@ for i $ :10 {
 	println(i)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 0; i < 10; i += 1 {
@@ -3915,7 +3915,7 @@ for i $ 1:10:3 {
 	println(i)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 1; i < 10; i += 3 {
@@ -3931,7 +3931,7 @@ for i $ 1:10:2 {
 	println(i)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 1; i < 10; i += 2 {
@@ -3947,7 +3947,7 @@ for i $ 1:10 {
 	println(i)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 1; i < 10; i += 1 {
@@ -3963,7 +3963,7 @@ for i $ :10:2 {
 	println(i)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 0; i < 10; i += 2 {
@@ -3979,7 +3979,7 @@ for range :10 {
 	println("Hi")
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for _gop_k := 0; _gop_k < 10; _gop_k += 1 {
@@ -3995,7 +3995,7 @@ for _ <- :10 {
 	println("Hi")
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for _gop_k := 0; _gop_k < 10; _gop_k += 1 {
@@ -4011,8 +4011,8 @@ println [x for x <- 0:3:1]
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/builtin"
+	fmt "fmt"
+	builtin "github.com/goplus/gop/builtin"
 )
 
 func main() {
@@ -4058,7 +4058,7 @@ func TestRangeExpr8(t *testing.T) {
 	}
 	`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type T struct {
 }
@@ -4102,7 +4102,7 @@ func TestRangeExpr9(t *testing.T) {
 	}
 	`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type T struct {
 }
@@ -4158,7 +4158,7 @@ func TestNoEntrypoint(t *testing.T) {
 	gopClTest(t, `println("init")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("init")
@@ -4168,7 +4168,7 @@ func main() {
 println("init")
 `, `package bar
 
-import "fmt"
+import fmt "fmt"
 
 func init() {
 	fmt.Println("init")
@@ -4192,7 +4192,7 @@ println []
 println {}
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println([]interface {
@@ -4216,7 +4216,7 @@ type Point struct {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type Point struct {
 	X int
@@ -4239,7 +4239,7 @@ println "hello"
 println("hello")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Print()
@@ -4258,7 +4258,7 @@ var a any = 100
 println(a)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 var a interface {
 } = 100
@@ -4285,7 +4285,7 @@ func test() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func test() {
 	fmt.Println("hello")
@@ -4300,7 +4300,7 @@ func main() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("hello")
@@ -4313,7 +4313,7 @@ func TestCommandNotExpr(t *testing.T) {
 println !true
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println(false)
@@ -4324,7 +4324,7 @@ a := true
 println !a
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	a := true
@@ -4335,7 +4335,7 @@ func main() {
 println !func() bool { return true }()
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println(!func() bool {
@@ -4389,7 +4389,7 @@ var (
 func test(){}
 `, `package main
 
-import "bytes"
+import bytes "bytes"
 
 type Rect struct {
 	bytes.Buffer
@@ -4406,7 +4406,7 @@ var (
 func test(){}
 `, `package main
 
-import "bytes"
+import bytes "bytes"
 
 type Rect struct {
 	*bytes.Buffer
@@ -4425,7 +4425,7 @@ var (
 func test(){}
 `, `package main
 
-import "bytes"
+import bytes "bytes"
 
 type Rect struct {
 	*bytes.Buffer `+"`spec:\"buffer\"`"+`
@@ -4493,7 +4493,7 @@ n.onKey ["a"],nil,key => {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/overload/foo"
+import foo "github.com/goplus/gop/cl/internal/overload/foo"
 
 type Mesh struct {
 }
diff --git a/cl/outline/cl/compile_spx_test.go b/cl/outline/cl/compile_spx_test.go
index a4d381b1..583afaf9 100644
--- a/cl/outline/cl/compile_spx_test.go
+++ b/cl/outline/cl/compile_spx_test.go
@@ -163,7 +163,7 @@ func onMsg(msg string) {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 type Game struct {
 	*spx.MyGame
@@ -208,8 +208,8 @@ func onInit() {
 `, ``, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx"
+	fmt "fmt"
+	spx "github.com/goplus/gop/cl/internal/spx"
 )
 
 type bar struct {
@@ -249,8 +249,8 @@ func onInit() {
 `, `package main
 
 import (
-	"github.com/goplus/gop/cl/internal/spx"
-	"math"
+	spx "github.com/goplus/gop/cl/internal/spx"
+	math "math"
 )
 
 type Game struct {
@@ -300,7 +300,7 @@ func onCloned() {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 type Game struct {
 	*spx.MyGame
@@ -340,8 +340,8 @@ println "Hi"
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx"
+	fmt "fmt"
+	spx "github.com/goplus/gop/cl/internal/spx"
 )
 
 type Kai struct {
@@ -377,8 +377,8 @@ func onMsg(msg string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx2"
+	fmt "fmt"
+	spx2 "github.com/goplus/gop/cl/internal/spx2"
 )
 
 type Game struct {
@@ -407,8 +407,8 @@ func onMsg(msg string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx2"
+	fmt "fmt"
+	spx2 "github.com/goplus/gop/cl/internal/spx2"
 )
 
 type Game struct {
@@ -437,8 +437,8 @@ func onMsg(msg string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx2"
+	fmt "fmt"
+	spx2 "github.com/goplus/gop/cl/internal/spx2"
 )
 
 type Dog struct {
@@ -465,7 +465,7 @@ func TestSpxMainEntry(t *testing.T) {
 `, `
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx2"
+import spx2 "github.com/goplus/gop/cl/internal/spx2"
 
 type Game struct {
 	spx2.Game
@@ -488,7 +488,7 @@ var (
 `, `
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx2"
+import spx2 "github.com/goplus/gop/cl/internal/spx2"
 
 type Game struct {
 	spx2.Game
@@ -522,8 +522,8 @@ func onMsg(msg string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx2"
+	fmt "fmt"
+	spx2 "github.com/goplus/gop/cl/internal/spx2"
 )
 
 type Game struct {
@@ -563,7 +563,7 @@ func onMsg(msg string) {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 type Game struct {
 	*spx.MyGame
@@ -619,7 +619,7 @@ func onCloned() {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 type Game struct {
 	*spx.MyGame
@@ -667,7 +667,7 @@ func onMsg(msg string) {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 type Game struct {
 	*spx.MyGame
@@ -698,8 +698,8 @@ func onMsg(msg string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx"
+	fmt "fmt"
+	spx "github.com/goplus/gop/cl/internal/spx"
 )
 
 type Game struct {
diff --git a/cl/outline/cl/compile_test.go b/cl/outline/cl/compile_test.go
index 52fd5dc4..87dd7447 100644
--- a/cl/outline/cl/compile_test.go
+++ b/cl/outline/cl/compile_test.go
@@ -157,10 +157,10 @@ for line <- open("foo.txt")! {
 `, `package main
 
 import (
-	"fmt"
-	"os"
-	"github.com/goplus/gop/builtin/iox"
-	"github.com/qiniu/x/errors"
+	fmt "fmt"
+	os "os"
+	iox "github.com/goplus/gop/builtin/iox"
+	errors "github.com/qiniu/x/errors"
 )
 
 func main() {
@@ -194,9 +194,9 @@ for line <- os.Stdin {
 `, `package main
 
 import (
-	"fmt"
-	"os"
-	"github.com/goplus/gop/builtin/iox"
+	fmt "fmt"
+	os "os"
+	iox "github.com/goplus/gop/builtin/iox"
 )
 
 func main() {
@@ -224,9 +224,9 @@ for line <- lines(r) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/builtin/iox"
-	"io"
+	fmt "fmt"
+	iox "github.com/goplus/gop/builtin/iox"
+	io "io"
 )
 
 var r io.Reader
@@ -298,7 +298,7 @@ type T struct{}
 println(&T{},&Point{10,20})
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type T struct {
 }
@@ -315,7 +315,7 @@ for i <- :10, i%3 == 0 {
 	println i
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 0; i < 10; i += 1 {
@@ -338,7 +338,7 @@ d := fvec([])
 println a, b, c, d
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type fvec []float64
 type foo float64
@@ -542,8 +542,8 @@ println "The Go+ Language for", fields.join(", ")
 `, `package main
 
 import (
-	"fmt"
-	"strings"
+	fmt "fmt"
+	strings "strings"
 )
 
 func main() {
@@ -559,7 +559,7 @@ p := println
 p "Hello world"
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	p := fmt.Println
@@ -927,8 +927,8 @@ func main() {
 }`, `package main
 
 import (
-	"fmt"
-	"github.com/qiniu/x/errors"
+	fmt "fmt"
+	errors "github.com/qiniu/x/errors"
 )
 
 func t() (int, int, error) {
@@ -961,7 +961,7 @@ func main() {
 	t()!
 }`, `package main
 
-import "github.com/qiniu/x/errors"
+import errors "github.com/qiniu/x/errors"
 
 func t() error {
 	return nil
@@ -1004,7 +1004,7 @@ func (a *A) String() string {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type AA interface {
 	String() string
@@ -1049,7 +1049,7 @@ func (a *A) String() string {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type AA interface {
 	String() string
@@ -1090,7 +1090,7 @@ func main() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	{
@@ -1159,7 +1159,7 @@ func main() {
 var i int
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 var i int
 
@@ -1202,7 +1202,7 @@ func main() {
 var i = 100
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 var i = 100
 
@@ -1222,7 +1222,7 @@ func main() {
 	println(n)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	v := []uint64{2, 3, 5}
@@ -1247,7 +1247,7 @@ func consume(xchg chan int) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func consume(xchg chan int) {
 	select {
@@ -1420,7 +1420,7 @@ func main() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type Shape interface {
 	Area() float64
@@ -1465,7 +1465,7 @@ type BigInt struct {
 	*big.Int
 }`, `package main
 
-import "math/big"
+import big "math/big"
 
 type BigInt struct {
 	*big.Int
@@ -1485,10 +1485,10 @@ func foo(script string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/ast/goptest"
-	"github.com/qiniu/x/errors"
-	"github.com/goplus/gop/ast/gopq"
+	fmt "fmt"
+	goptest "github.com/goplus/gop/ast/goptest"
+	errors "github.com/qiniu/x/errors"
+	gopq "github.com/goplus/gop/ast/gopq"
 )
 
 func foo(script string) {
@@ -1519,10 +1519,10 @@ func foo(script string) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/ast/goptest"
-	"github.com/qiniu/x/errors"
-	"github.com/goplus/gop/ast/gopq"
+	fmt "fmt"
+	goptest "github.com/goplus/gop/ast/goptest"
+	errors "github.com/qiniu/x/errors"
+	gopq "github.com/goplus/gop/ast/gopq"
 )
 
 func foo(script string) {
@@ -1551,8 +1551,8 @@ func add(x, y string) (int, error) {
 `, `package main
 
 import (
-	"strconv"
-	"github.com/qiniu/x/errors"
+	strconv "strconv"
+	errors "github.com/qiniu/x/errors"
 )
 
 func add(x string, y string) (int, error) {
@@ -1592,7 +1592,7 @@ func addSafe(x, y string) int {
 }
 `, `package main
 
-import "strconv"
+import strconv "strconv"
 
 func addSafe(x string, y string) int {
 	return func() (_gop_ret int) {
@@ -1620,8 +1620,8 @@ var ret int = println("Hi")!
 `, `package main
 
 import (
-	"fmt"
-	"github.com/qiniu/x/errors"
+	fmt "fmt"
+	errors "github.com/qiniu/x/errors"
 )
 
 var ret int = func() (_gop_ret int) {
@@ -1645,7 +1645,7 @@ func mkdir(name string) error {
 mkdir! "foo"
 `, `package main
 
-import "github.com/qiniu/x/errors"
+import errors "github.com/qiniu/x/errors"
 
 func mkdir(name string) error {
 	return nil
@@ -1673,7 +1673,7 @@ func foo() (func(), error) {
 foo()!()
 `, `package main
 
-import "github.com/qiniu/x/errors"
+import errors "github.com/qiniu/x/errors"
 
 func foo() (func(), error) {
 	return nil, nil
@@ -1722,7 +1722,7 @@ var x, y uint128
 var z uint128 = x + y
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x, y ng.Uint128
 var z ng.Uint128 = x.Gop_Add__1(y)
@@ -1735,7 +1735,7 @@ var x, y int128
 var z int128 = x + y
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x, y ng.Int128
 var z ng.Int128 = x.Gop_Add__1(y)
@@ -1748,7 +1748,7 @@ var x, y bigint
 var z bigint = x + y
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x, y ng.Bigint
 var z ng.Bigint = x.Gop_Add(y)
@@ -1761,8 +1761,8 @@ var x = 1r
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 var x = ng.Bigint_Init__1(big.NewInt(1))
@@ -1774,7 +1774,7 @@ func TestUint128Lit(t *testing.T) {
 var x uint128 = 1
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x ng.Uint128 = ng.Uint128_Init__0(1)
 `)
@@ -1785,7 +1785,7 @@ func TestInt128Lit(t *testing.T) {
 var x int128 = 1
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x ng.Int128 = ng.Int128_Init__0(1)
 `)
@@ -1797,8 +1797,8 @@ var x = 1/2r
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 var x = ng.Bigrat_Init__2(big.NewRat(1, 2))
@@ -1811,8 +1811,8 @@ var x = 3 + 1/2r
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 var x = ng.Bigrat_Init__2(big.NewRat(7, 2))
@@ -1828,8 +1828,8 @@ var z = 100 + y
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 var x = ng.Bigrat_Init__2(big.NewRat(7, 2))
@@ -1942,7 +1942,7 @@ var x bigint
 x += 3
 `, `package main
 
-import "github.com/goplus/gop/builtin/ng"
+import ng "github.com/goplus/gop/builtin/ng"
 
 var x ng.Bigint
 
@@ -1959,8 +1959,8 @@ x *= 2
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 func main() {
@@ -1977,8 +1977,8 @@ x *= 2r
 `, `package main
 
 import (
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 func main() {
@@ -2251,7 +2251,7 @@ go println("Hi")
 defer println("Go+")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	go fmt.Println("Hi")
@@ -2271,7 +2271,7 @@ for {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	a := []float64{1, 3.4, 5}
@@ -2308,7 +2308,7 @@ for range a {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	a := []float64{1, 3.4, 5}
@@ -2346,7 +2346,7 @@ for k, v := range new(foo) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type foo struct {
 }
@@ -2374,7 +2374,7 @@ for v <- new(foo) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type foo struct {
 }
@@ -2409,7 +2409,7 @@ for k, v <- new(foo) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type fooIter struct {
 }
@@ -2445,7 +2445,7 @@ func (p *foo) Gop_Enum(c func(val string)) {
 println([v for v <- new(foo)])
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type foo struct {
 }
@@ -2496,7 +2496,7 @@ for k, v <- newFoo() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type fooIter struct {
 	data *foo
@@ -2545,7 +2545,7 @@ for i, x <- [1, 3, 5, 7, 11, 13, 17] {
 println("sum(5,7,11,13,17):", sum)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	sum := 0
@@ -2716,7 +2716,7 @@ x := [[a, b] for a <- arr, a < b for b <- arr, b > 2]
 println("x:", x)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	arr := []float64{1, 2, 3, 4.1, 5, 6}
@@ -2822,8 +2822,8 @@ println("x:", x)
 `, `package main
 
 import (
-	"fmt"
-	"strings"
+	fmt "fmt"
+	strings "strings"
 )
 
 func main() {
@@ -2846,7 +2846,7 @@ func bar(p pfoo) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type foo struct {
 	req int
@@ -2875,7 +2875,7 @@ a.B = "Hi"
 flag.Usage = nil
 `, `package main
 
-import "flag"
+import flag "flag"
 
 func main() {
 	a := &struct {
@@ -2935,7 +2935,7 @@ func (M) Bar() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type M int
 
@@ -2982,7 +2982,7 @@ var d = -a       // TODO: -a have no return value!
 var e = a!=b
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type foo struct {
 }
@@ -3016,7 +3016,7 @@ func (a foo) Gop_NE(b foo) bool {
 func TestCmdlineNoEOL(t *testing.T) {
 	gopClTest(t, `println "Hi"`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Hi")
@@ -3031,7 +3031,7 @@ func main() {
 	fmt.println "Hi"
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Hi")
@@ -3045,7 +3045,7 @@ func TestDotImport(t *testing.T) {
 var a = round(1.2)
 `, `package main
 
-import "math"
+import math "math"
 
 var a = math.Round(1.2)
 `)
@@ -3057,7 +3057,7 @@ func TestLocalImport(t *testing.T) {
 var a = spx.TestIntValue
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/spx"
+import spx "github.com/goplus/gop/cl/internal/spx"
 
 var a = spx.TestIntValue
 `)
@@ -3092,7 +3092,7 @@ func TestAnonymousImport(t *testing.T) {
 printf("Hello Go+\n")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Hello")
@@ -3131,7 +3131,7 @@ func main() {
 	fmt.Println("Hi")
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	const (
@@ -3156,7 +3156,7 @@ if t := false; t {
 println("x:", x)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	x := 0
@@ -3196,7 +3196,7 @@ default:
 println("x:", x)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	x := 0
@@ -3237,7 +3237,7 @@ default:
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	v := "Hello"
@@ -3269,7 +3269,7 @@ label:
 	}
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	a := []float64{1, 3.4, 5}
@@ -3296,7 +3296,7 @@ func main() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func foo(format string, args ...interface {
 }) (int, error) {
@@ -3334,7 +3334,7 @@ func(v string) {
 }("Hello")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	func(v string) {
@@ -3475,7 +3475,7 @@ Do => {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func Do(func()) {
 }
@@ -3644,7 +3644,7 @@ func bar(foo func(string, ...interface{}) (int, error)) {
 bar(fmt.Printf)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func bar(foo func(string, ...interface {
 }) (int, error)) {
@@ -3681,8 +3681,8 @@ fmt.Println(printf("Hello, %v\n", "Go+"))
 `, `package main
 
 import (
-	"fmt"
-	"strings"
+	fmt "fmt"
+	strings "strings"
 )
 
 func foo(x string) string {
@@ -3710,7 +3710,7 @@ func TestFuncCall(t *testing.T) {
 
 fmt.Println("Hello")`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Hello")
@@ -3728,7 +3728,7 @@ func foo(args ...interface{}) {
 func main() {
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func foo(args ...interface {
 }) {
@@ -3751,7 +3751,7 @@ func foo(args ...interface{}) {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	foo("Hello", 123)
@@ -3787,7 +3787,7 @@ func TestAssignUnderscore(t *testing.T) {
 _, err := log.Println("Hello")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	_, err := fmt.Println("Hello")
@@ -3838,8 +3838,8 @@ println(rmap)
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/gop-in-go/foo"
+	fmt "fmt"
+	foo "github.com/goplus/gop/cl/internal/gop-in-go/foo"
 )
 
 func main() {
@@ -3884,8 +3884,8 @@ func New() Result {
 `, `package main
 
 import (
-	"reflect"
-	"testing"
+	reflect "reflect"
+	testing "testing"
 )
 
 type Repo struct {
@@ -3929,7 +3929,7 @@ for i $ :10 {
 	println(i)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 0; i < 10; i += 1 {
@@ -3942,7 +3942,7 @@ for i $ 1:10:3 {
 	println(i)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 1; i < 10; i += 3 {
@@ -3958,7 +3958,7 @@ for i $ 1:10:2 {
 	println(i)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 1; i < 10; i += 2 {
@@ -3974,7 +3974,7 @@ for i $ 1:10 {
 	println(i)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 1; i < 10; i += 1 {
@@ -3990,7 +3990,7 @@ for i $ :10:2 {
 	println(i)
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for i := 0; i < 10; i += 2 {
@@ -4006,7 +4006,7 @@ for range :10 {
 	println("Hi")
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for _gop_k := 0; _gop_k < 10; _gop_k += 1 {
@@ -4022,7 +4022,7 @@ for _ <- :10 {
 	println("Hi")
 }`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	for _gop_k := 0; _gop_k < 10; _gop_k += 1 {
@@ -4038,8 +4038,8 @@ println [x for x <- 0:3:1]
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/builtin"
+	fmt "fmt"
+	builtin "github.com/goplus/gop/builtin"
 )
 
 func main() {
@@ -4085,7 +4085,7 @@ func TestRangeExpr8(t *testing.T) {
 	}
 	`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type T struct {
 }
@@ -4129,7 +4129,7 @@ func TestRangeExpr9(t *testing.T) {
 	}
 	`, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type T struct {
 }
@@ -4185,7 +4185,7 @@ func TestNoEntrypoint(t *testing.T) {
 	gopClTest(t, `println("init")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("init")
@@ -4195,7 +4195,7 @@ func main() {
 println("init")
 `, `package bar
 
-import "fmt"
+import fmt "fmt"
 
 func init() {
 	fmt.Println("init")
@@ -4219,7 +4219,7 @@ println []
 println {}
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println([]interface {
@@ -4243,7 +4243,7 @@ type Point struct {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type Point struct {
 	X int
@@ -4266,7 +4266,7 @@ println "hello"
 println("hello")
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Print()
@@ -4285,7 +4285,7 @@ var a any = 100
 println(a)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 var a interface {
 } = 100
@@ -4312,7 +4312,7 @@ func test() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func test() {
 	fmt.Println("hello")
@@ -4327,7 +4327,7 @@ func main() {
 }
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("hello")
@@ -4340,7 +4340,7 @@ func TestCommandNotExpr(t *testing.T) {
 println !true
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println(false)
@@ -4351,7 +4351,7 @@ a := true
 println !a
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	a := true
@@ -4362,7 +4362,7 @@ func main() {
 println !func() bool { return true }()
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println(!func() bool {
@@ -4416,7 +4416,7 @@ var (
 func test(){}
 `, `package main
 
-import "bytes"
+import bytes "bytes"
 
 type Rect struct {
 	bytes.Buffer
@@ -4433,7 +4433,7 @@ var (
 func test(){}
 `, `package main
 
-import "bytes"
+import bytes "bytes"
 
 type Rect struct {
 	*bytes.Buffer
@@ -4452,7 +4452,7 @@ var (
 func test(){}
 `, `package main
 
-import "bytes"
+import bytes "bytes"
 
 type Rect struct {
 	*bytes.Buffer `+"`spec:\"buffer\"`"+`
@@ -4520,7 +4520,7 @@ n.onKey ["a"],nil,key => {
 }
 `, `package main
 
-import "github.com/goplus/gop/cl/internal/overload/foo"
+import foo "github.com/goplus/gop/cl/internal/overload/foo"
 
 type Mesh struct {
 }
diff --git a/cl/outline/cl/typeparams_test.go b/cl/outline/cl/typeparams_test.go
index 644e084f..bb0a47f0 100644
--- a/cl/outline/cl/typeparams_test.go
+++ b/cl/outline/cl/typeparams_test.go
@@ -161,7 +161,7 @@ v3.Append([1,2,3,4]...)
 v3.Append2([1,2,3,4]...)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type DataString = Data[string]
 type SliceString = Slice[[]string, string]
diff --git a/cl/typeparams_test.go b/cl/typeparams_test.go
index c700ce1d..a35f9369 100644
--- a/cl/typeparams_test.go
+++ b/cl/typeparams_test.go
@@ -166,7 +166,7 @@ v3.Append([1,2,3,4]...)
 v3.Append2([1,2,3,4]...)
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type DataString = Data[string]
 type SliceString = Slice[[]string, string]
diff --git a/x/build/_testdata/hello/hello.expect b/x/build/_testdata/hello/hello.expect
index 13b98bf6..e62ecea4 100644
--- a/x/build/_testdata/hello/hello.expect
+++ b/x/build/_testdata/hello/hello.expect
@@ -1,6 +1,6 @@
 package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Go+")
diff --git a/x/build/_testdata/multi/multi.expect b/x/build/_testdata/multi/multi.expect
index e2243eb6..9eb31ec2 100644
--- a/x/build/_testdata/multi/multi.expect
+++ b/x/build/_testdata/multi/multi.expect
@@ -1,6 +1,6 @@
 package main
 
-import "fmt"
+import fmt "fmt"
 
 type BaseClass struct {
 	x int
diff --git a/x/build/_testdata/pkg/pkg.expect b/x/build/_testdata/pkg/pkg.expect
index 54ec8242..e71e8cb8 100644
--- a/x/build/_testdata/pkg/pkg.expect
+++ b/x/build/_testdata/pkg/pkg.expect
@@ -1,6 +1,6 @@
 package pkg
 
-import "fmt"
+import fmt "fmt"
 
 func Hello() {
 	fmt.Println("Go+")
diff --git a/x/build/build_test.go b/x/build/build_test.go
index cb867bd2..a677214e 100644
--- a/x/build/build_test.go
+++ b/x/build/build_test.go
@@ -84,7 +84,7 @@ println "Go+"
 `
 	var expect = `package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Go+")
@@ -108,7 +108,7 @@ func TestGox(t *testing.T) {
 println "Go+"
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type Rect struct {
 }
@@ -130,7 +130,7 @@ type Buffer struct {
 println "Go+"
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type Buffer struct {
 	buf []byte
@@ -157,7 +157,7 @@ type Buffer struct {
 println "Go+"
 `, `package main
 
-import "fmt"
+import fmt "fmt"
 
 type Buffer struct {
 	buf []byte
@@ -183,8 +183,8 @@ println "Go+"
 `, `package main
 
 import (
-	"fmt"
-	"bytes"
+	fmt "fmt"
+	bytes "bytes"
 )
 
 type Rect struct {
@@ -208,8 +208,8 @@ println "Go+"
 `, `package main
 
 import (
-	"fmt"
-	"bytes"
+	fmt "fmt"
+	bytes "bytes"
 )
 
 type Rect struct {
@@ -232,9 +232,9 @@ println a+1/2r
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/builtin/ng"
-	"math/big"
+	fmt "fmt"
+	ng "github.com/goplus/gop/builtin/ng"
+	big "math/big"
 )
 
 func main() {
@@ -256,9 +256,9 @@ for line <- lines(r) {
 `, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/builtin/iox"
-	"io"
+	fmt "fmt"
+	iox "github.com/goplus/gop/builtin/iox"
+	io "io"
 )
 
 var r io.Reader
@@ -299,9 +299,9 @@ println addSafe("10", "abc")
 `, `package main
 
 import (
-	"fmt"
-	"strconv"
-	"github.com/qiniu/x/errors"
+	fmt "fmt"
+	strconv "strconv"
+	errors "github.com/qiniu/x/errors"
 )
 
 func add(x string, y string) (int, error) {
@@ -367,8 +367,8 @@ func TestSpx(t *testing.T) {
 	gopClTestEx(t, "main.tspx", `println "hi"`, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx"
+	fmt "fmt"
+	spx "github.com/goplus/gop/cl/internal/spx"
 )
 
 type MyGame struct {
@@ -385,8 +385,8 @@ func main() {
 	gopClTestEx(t, "Cat.tspx", `println "hi"`, `package main
 
 import (
-	"fmt"
-	"github.com/goplus/gop/cl/internal/spx"
+	fmt "fmt"
+	spx "github.com/goplus/gop/cl/internal/spx"
 )
 
 type Cat struct {
@@ -441,7 +441,7 @@ func TestFromTestdata(t *testing.T) {
 func TestFS(t *testing.T) {
 	var expect = []byte(`package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Go+")
@@ -459,7 +459,7 @@ func main() {
 func TestAst(t *testing.T) {
 	var expect = []byte(`package main
 
-import "fmt"
+import fmt "fmt"
 
 func main() {
 	fmt.Println("Go+")