Repository: goplus/gop
Pull request #990 (2021-11-30 13:48:51)

merge gop/env/execgo => gop/x/gopmod


Patch:
diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index b541ff26..00000000
--- a/.gitattributes
+++ /dev/null
@@ -1,5 +0,0 @@
-*.expect text eol=lf
-*.golden text eol=lf
-
-*.gop text eol=lf
-*.go text eol=lf
\ No newline at end of file
diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml
deleted file mode 100644
index f2406b3b..00000000
--- a/.github/workflows/release-build.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-name: Release Build
-
-on:
-  push:
-    tags:
-      - "v*.*.*"
-
-jobs:
-  build:
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout@v2
-
-    - name: Checkout tag
-      run: |
-        git fetch --depth=1 origin +refs/tags/*:refs/tags/*
-        tag_name="${GITHUB_REF##*/}"
-        echo Current tag: $tag_name
-        git checkout $tag_name
-        echo "TAG_NAME=${tag_name}" >> $GITHUB_ENV
-
-    - name: Set up Go
-      uses: actions/setup-go@v2
-      with:
-        go-version: 1.17
-
-    - name: Build
-      run: |
-        make release-all -j$(nproc)
-
-    - name: Release
-      uses: svenstaro/upload-release-action@v2
-      with:
-        repo_token: ${{ secrets.GITHUB_TOKEN }}
-        tag: ${{ env.TAG_NAME }}
-        file: ./gop-*.zip
-        file_glob: true
-        prerelease: true
\ No newline at end of file
diff --git a/Makefile b/Makefile
deleted file mode 100644
index bce14f8a..00000000
--- a/Makefile
+++ /dev/null
@@ -1,119 +0,0 @@
-NAME := gop
-PACKAGE_NAME := github.com/goplus/gop
-RELEASE_VERSION := `git describe --tags`
-COMMIT := `git rev-parse --short HEAD`
-BUILD_DATE := `date -u +"%Y-%m-%d_%H-%M-%S"`
-
-PLATFORM := linux
-BUILD_DIR=.
-BUILD_ROOT_DIR := build-dir
-BUILD_LDFLAGS := -X 'github.com/goplus/gop/env.buildDate=$(BUILD_DATE)'
-BUILD_LDFLAGS +=  -X '$(PACKAGE_NAME).buildCommit=$(COMMIT)'
-BUILD_LDFLAGS +=  -X '$(PACKAGE_NAME).buildVersion=$(RELEASE_VERSION)'
-
-EXE_SUFFIX=
-
-.PHONY: clean all
-all:
-	cd cmd; go install -v ./...
-
-clean:
-	rm -rf $(BUILD_ROOT_DIR)
-	rm -f *.zip
-	rm -f gop gopfmt
-
-
-release:
-  # the release action expects the generated binaries placed in the path where make runs.
-  # Refer: https://github.com/marketplace/actions/go-release-binaries
-	CGO_ENABLED=0 go build -o $(BUILD_DIR)/gop$(EXE_SUFFIX) -ldflags "$(BUILD_LDFLAGS)" github.com/goplus/gop/cmd/gop
-	CGO_ENABLED=0 go build -o $(BUILD_DIR)/gopfmt$(EXE_SUFFIX) -ldflags "$(BUILD_LDFLAGS)" github.com/goplus/gop/cmd/gopfmt
-
-gop:
-	mkdir -p $(BUILD_DIR)
-	$(MAKE) release
-
-release-all: darwin-amd64.zip darwin-arm64.zip linux-386.zip linux-amd64.zip \
-	linux-arm.zip linux-armv5.zip linux-armv6.zip linux-armv7.zip linux-armv8.zip \
-	linux-mips-softfloat.zip linux-mips-hardfloat.zip linux-mipsle-softfloat.zip linux-mipsle-hardfloat.zip \
-	linux-mips64.zip linux-mips64le.zip freebsd-386.zip freebsd-amd64.zip \
-	windows-386.zip windows-amd64.zip windows-arm.zip windows-armv6.zip windows-armv7.zip windows-arm64.zip
-
-%.zip: %
-	@echo "Building $(NAME)-$(RELEASE_VERSION)-$@"
-	@mkdir -p $(BUILD_ROOT_DIR)/$</bin
-	
-	@rm -f $(NAME)-$(RELEASE_VERSION)-$@
-	@cd $(BUILD_ROOT_DIR)/$</ && zip -r ../../$(NAME)-$(RELEASE_VERSION)-$@ bin
-	@zip -dur $(NAME)-$(RELEASE_VERSION)-$@ builtin go.mod go.sum LICENSE README*.md
-	@echo "$(NAME)-$(RELEASE_VERSION)-$@ Done"
-	
-
-darwin-amd64:
-	$(MAKE) GOARCH=amd64 GOOS=darwin BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-darwin-arm64:
-	$(MAKE) GOARCH=arm64 GOOS=darwin BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-386:
-	$(MAKE) GOARCH=386 GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-amd64:
-	$(MAKE) GOARCH=amd64 GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-arm:
-	$(MAKE) GOARCH=arm GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-armv5:
-	$(MAKE) GOARCH=arm GOOS=linux GOARM=5 BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-armv6:
-	$(MAKE) GOARCH=arm GOOS=linux GOARM=6 BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-armv7:
-	$(MAKE) GOARCH=arm GOOS=linux GOARM=7 BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-armv8:
-	$(MAKE) GOARCH=arm64 GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-mips-softfloat:
-	$(MAKE) GOARCH=mips GOMIPS=softfloat GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-mips-hardfloat:
-	$(MAKE) GOARCH=mips GOMIPS=hardfloat GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-mipsle-softfloat:
-	$(MAKE) GOARCH=mipsle GOMIPS=softfloat GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-mipsle-hardfloat:
-	$(MAKE) GOARCH=mipsle GOMIPS=hardfloat GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-mips64:
-	$(MAKE) GOARCH=mips64 GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-linux-mips64le:
-	$(MAKE) GOARCH=mips64le GOOS=linux BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-freebsd-386:
-	$(MAKE) GOARCH=386 GOOS=freebsd BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-freebsd-amd64:
-	$(MAKE) GOARCH=amd64 GOOS=freebsd BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-windows-386:
-	$(MAKE) GOARCH=386 GOOS=windows EXE_SUFFIX=.exe BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-windows-amd64:
-	$(MAKE) GOARCH=amd64 GOOS=windows EXE_SUFFIX=.exe BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-windows-arm:
-	$(MAKE) GOARCH=arm GOOS=windows EXE_SUFFIX=.exe BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-windows-armv6:
-	$(MAKE) GOARCH=arm GOOS=windows EXE_SUFFIX=.exe GOARM=6 BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-windows-armv7:
-	$(MAKE) GOARCH=arm GOOS=windows EXE_SUFFIX=.exe GOARM=7 BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
-
-windows-arm64:
-	$(MAKE) GOARCH=arm64 GOOS=windows EXE_SUFFIX=.exe BUILD_DIR=$(BUILD_ROOT_DIR)/$@/bin release
\ No newline at end of file
diff --git a/README.md b/README.md
index 6df130a6..369fcfdd 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ For now, we suggest you install Go+ from source code.
 git clone https://github.com/goplus/gop.git
 cd gop
 
-# On mac/linux run:
+# On linux run:
 ./all.bash
 # On Windows run:
 all.bat
diff --git a/README_zh.md b/README_zh.md
index 93c1f8a0..03734118 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -7,11 +7,11 @@
 [![Tutorials](https://img.shields.io/badge/tutorial-Go+-blue.svg)](https://tutorial.goplus.org/)
 [![Playground](https://img.shields.io/badge/playground-Go+-blue.svg)](https://play.goplus.org/)
 [![VSCode](https://img.shields.io/badge/vscode-Go+-teal.svg)](https://github.com/gopcode/vscode-goplus)
-[![Readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87-teal.svg)](https://github.com/goplus/gop/blob/main/README.md)
+[![Readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87-teal.svg)](https://github.com/goplus/gop/blob/main/README_zh.md)
 
--   **对于工程领域而言** ：意味着大家将会使用一门简单、易学、好用的编程语言。
--   **对于 STEM 教育而言** ：掌握一门可能会在将来工作中用到的工程语言将大有裨益。
--   **对于数据科学家而言** ：意味着你们将和工程师使用同一种语言进行合作和交流。
+* **对于工程领域而言** ：意味着大家将会使用一门简单、易学、好用的编程语言。
+* **对于 STEM 教育而言** ：掌握一门可能会在将来工作中用到的工程语言将大有裨益。
+* **对于数据科学家而言** ：意味着你们将和工程师使用同一种语言进行合作和交流。
 
 ## 如何安装 Go+?
 
@@ -20,15 +20,9 @@
 ```bash
 git clone https://github.com/goplus/gop.git
 cd gop
-
-# On linux run:
 ./all.bash
-# On Windows run:
-all.bat
 ```
 
-实际上， `all.bash` 和 `all.bat` 内部都会执行 `go run cmd/install.go`
-
 ## 代码风格（很重要）
 
 -   [https://tutorial.goplus.org/hello-world](https://tutorial.goplus.org/hello-world)
@@ -39,7 +33,7 @@ all.bat
 
 -   一种静态类型语言。
 -   完全兼容 [Go 语言](https://github.com/golang/go) 。
--   类似脚本语言的风格，代码比 Go 更易读。
+-   脚本化的风格，以及比 Go 更易读的数据科学代码。
 
 例如，以下是合法的 Go+ 源代码：
 
diff --git a/cl/compile.go b/cl/compile.go
index 4bf51367..5c150ebc 100644
--- a/cl/compile.go
+++ b/cl/compile.go
@@ -560,15 +560,6 @@ func preloadFile(p *gox.Package, parent *pkgCtx, file string, f *ast.File, targe
 				}
 				for _, v := range specs {
 					spec := v.(*ast.ValueSpec)
-					if spec.Type == nil {
-						pos := ctx.Position(v.Pos())
-						ctx.handleCodeErrorf(&pos, "missing field type in class file")
-						continue
-					}
-					if len(spec.Values) > 0 {
-						pos := ctx.Position(v.Pos())
-						ctx.handleCodeErrorf(&pos, "cannot assign value to field in class file")
-					}
 					typ := toType(ctx, spec.Type)
 					for _, name := range spec.Names {
 						flds = append(flds, types.NewField(name.Pos(), pkg, name.Name, typ, false))
diff --git a/cmd/gorun/gorun.go b/cmd/gorun/gorun.go
index 904c0079..7a712e14 100644
--- a/cmd/gorun/gorun.go
+++ b/cmd/gorun/gorun.go
@@ -45,13 +45,13 @@ func (p *goFile) GenGo(outFile string) error {
 }
 
 func main() {
-	if len(os.Args) != 2 {
-		fmt.Fprint(os.Stderr, "Usage: gorun <file.go>\n\n")
+	if len(os.Args) < 2 {
+		fmt.Fprint(os.Stderr, "Usage: gorun <file.go> [switch ...]\n\n")
 		return
 	}
 	goProj := newGoProj(os.Args[1])
 	ctx := gopmod.New("")
-	cmd := ctx.GoCommand("run", goProj)
+	cmd := ctx.GoCommand("run", goProj, os.Args[2:]...)
 	cmd.Stdin = os.Stdin
 	cmd.Stdout = os.Stdout
 	cmd.Stderr = os.Stderr
diff --git a/cmd/internal/clean/clean.go b/cmd/internal/clean/clean.go
index e0e896b2..cac9e97b 100644
--- a/cmd/internal/clean/clean.go
+++ b/cmd/internal/clean/clean.go
@@ -18,13 +18,12 @@ package clean
 
 import (
 	"fmt"
+	"github.com/qiniu/x/log"
 	"io/ioutil"
 	"os"
 	"path/filepath"
 	"strings"
 
-	"github.com/qiniu/x/log"
-
 	"github.com/goplus/gop/cmd/internal/base"
 )
 
@@ -84,7 +83,7 @@ func removeGopDir(dir string) {
 
 // -----------------------------------------------------------------------------
 
-// Cmd - gop clean
+// Cmd - gop build
 var Cmd = &base.Command{
 	UsageLine: "gop clean [-v] <gopSrcDir>",
 	Short:     "Clean all Go+ auto generated files",
diff --git a/cmd/internal/env/env.go b/cmd/internal/env/env.go
index bc502bab..1bba50ff 100644
--- a/cmd/internal/env/env.go
+++ b/cmd/internal/env/env.go
@@ -74,23 +74,10 @@ func runCmd(_ *base.Command, args []string) {
 	gopEnv["GOPMOD"], _ = env.GOPMOD("")
 	gopEnv["HOME"] = env.HOME()
 
+	onlyValues := false
 	vars := flag.Args()
-
-	outputEnvVars(gopEnv, vars, *envJson)
-}
-
-func outputEnvVars(gopEnv map[string]interface{}, vars []string, outputJson bool) {
-	onlyValues := true
-
-	if len(vars) == 0 {
-		onlyValues = false
-
-		vars = make([]string, 0, len(gopEnv))
-		for k := range gopEnv {
-			vars = append(vars, k)
-		}
-		sort.Strings(vars)
-	} else {
+	if len(vars) > 0 {
+		onlyValues = true
 		newEnv := make(map[string]interface{})
 		for _, v := range vars {
 			if value, ok := gopEnv[v]; ok {
@@ -102,6 +89,10 @@ func outputEnvVars(gopEnv map[string]interface{}, vars []string, outputJson bool
 		gopEnv = newEnv
 	}
 
+	outputEnvVars(gopEnv, onlyValues, *envJson)
+}
+
+func outputEnvVars(gopEnv map[string]interface{}, onlyValues bool, outputJson bool) {
 	if outputJson {
 		b, err := json.Marshal(gopEnv)
 		if err != nil {
@@ -109,10 +100,15 @@ func outputEnvVars(gopEnv map[string]interface{}, vars []string, outputJson bool
 		}
 
 		var out bytes.Buffer
-		json.Indent(&out, b, "", "\t")
+		json.Indent(&out, b, "", "  ")
 		fmt.Println(out.String())
 	} else {
-		for _, k := range vars {
+		keys := make([]string, 0, len(gopEnv))
+		for k := range gopEnv {
+			keys = append(keys, k)
+		}
+		sort.Strings(keys)
+		for _, k := range keys {
 			v := gopEnv[k]
 			if onlyValues {
 				fmt.Printf("%v\n", v)
diff --git a/cmd/internal/modload/modload.go b/cmd/internal/modload/modload.go
index cd30b4c1..ece6af3e 100644
--- a/cmd/internal/modload/modload.go
+++ b/cmd/internal/modload/modload.go
@@ -219,9 +219,6 @@ func CreateModFile(modPath string) {
 
 func Load() {
 	LoadModFile()
-	if modRoot == "" {
-		return
-	}
 	SyncGoMod()
 	if classModFile != nil && classModFile.Classfile != nil {
 		gengo.RegisterPkgFlags(classModFile.Classfile.ProjExt, gengo.PkgFlagGmx)
@@ -263,9 +260,6 @@ func fixGoVersion(fixed *bool) gomodfile.VersionFixer {
 // -mod wasn't set explicitly and automatic vendoring should be enabled.
 func LoadModFile() {
 	Init()
-	if modRoot == "" {
-		return
-	}
 	// If gop.mod does not exist, then modroot does not exist,
 	// and if go.mod exists then a copy of go.mod will be synchronized to gop.mod
 	gopmod := GopModFilePath()
diff --git a/env/execgo/gocmd.go b/x/gopmod/gocmd.go
similarity index 60%
rename from env/execgo/gocmd.go
rename to x/gopmod/gocmd.go
index 98db6b14..6d47e0ec 100644
--- a/env/execgo/gocmd.go
+++ b/x/gopmod/gocmd.go
@@ -1,8 +1,9 @@
-package execgo
+package gopmod
 
 import (
 	"fmt"
 	"os/exec"
+	"path/filepath"
 
 	"github.com/goplus/gop/env"
 )
@@ -33,15 +34,37 @@ func LoadFlags() string {
 
 // -----------------------------------------------------------------------------
 
-func Command(op string, source string, args ...string) *exec.Cmd {
-	exargs := make([]string, 1, len(args)+4)
-	exargs[0] = op
-	exargs = appendLdflags(exargs, op)
-	exargs = append(exargs, args...)
-	if source != "" {
-		exargs = append(exargs, source)
+type GoCmd struct {
+	*exec.Cmd
+	after func() error
+}
+
+func (p GoCmd) Run() error {
+	if err := p.Cmd.Run(); err != nil {
+		return err
+	}
+	return p.after()
+}
+
+func goCommand(dir, op string, t *goTarget, args ...string) (ret GoCmd) {
+	exargs := make([]string, 1, len(args)+6)
+	exargs[0] = op                     // 1
+	exargs = appendLdflags(exargs, op) // 2
+	if op == "run" && t.defctx {       // 2
+		afterDir := dir
+		dir, _ = filepath.Split(t.goFile)
+		exargs[0] = "build"
+		exargs = append(exargs, "-o", t.outFile)
+		ret.after = func() error {
+			return runCommand(afterDir, t.outFile, args...)
+		}
+	} else {
+		exargs = append(exargs, args...) // len(args)
 	}
-	return exec.Command("go", exargs...)
+	exargs = append(exargs, t.goFile) // 1
+	ret.Cmd = exec.Command("go", exargs...)
+	ret.Cmd.Dir = dir
+	return
 }
 
 func appendLdflags(exargs []string, op string) []string {
diff --git a/x/gopmod/gopmod.go b/x/gopmod/gopmod.go
index 0583ef57..7153b5fb 100644
--- a/x/gopmod/gopmod.go
+++ b/x/gopmod/gopmod.go
@@ -27,14 +27,13 @@ import (
 	"strings"
 
 	"github.com/goplus/gop/env"
-	"github.com/goplus/gop/env/execgo"
 )
 
 // -----------------------------------------------------------------------------
 
 type Source interface {
 	Fingerp() [20]byte // source code fingerprint
-	IsDirty(outFile string, temp bool) bool
+	IsDirty(outFile string, defctx bool) bool
 	GenGo(outFile string) error
 }
 
@@ -45,8 +44,9 @@ type Project struct {
 }
 
 type Context struct {
-	GOPMOD string
-	defctx bool
+	modfile string
+	dir     string
+	defctx  bool
 }
 
 func New(dir string) *Context {
@@ -59,44 +59,44 @@ func New(dir string) *Context {
 		}
 		defctx = true
 	}
-	return &Context{GOPMOD: modfile, defctx: defctx}
+	return &Context{modfile: modfile, dir: dir, defctx: defctx}
 }
 
-func (p *Context) GoCommand(op string, src *Project, args ...string) *exec.Cmd {
-	file := p.goFile(src)
-	cmd := execgo.Command(op, file, args...)
-	cmd.Dir, _ = filepath.Split(file)
-	return cmd
-}
-
-func (p *Context) outFile(src *Project) (outFile string, temp bool) {
-	if p.defctx {
-		hash := src.Fingerp()
-		fname := src.FriendlyFname
-		if !strings.HasSuffix(fname, ".go") {
-			fname += ".go"
-		}
-		dir, _ := filepath.Split(p.GOPMOD)
-		outFile = dir + "/g" + base64.RawURLEncoding.EncodeToString(hash[:]) + fname
-		temp = true
-	} else {
-		outFile = src.AutoGenFile
-	}
-	return
-}
-
-func (p *Context) goFile(src *Project) string {
-	outFile, temp := p.outFile(src)
-	if src.IsDirty(outFile, temp) {
-		if temp {
-			dir, _ := filepath.Split(outFile)
+func (p *Context) GoCommand(op string, src *Project, args ...string) GoCmd {
+	out := p.out(src)
+	if src.IsDirty(out.goFile, p.defctx) {
+		if p.defctx {
+			dir, _ := filepath.Split(out.goFile)
 			os.Mkdir(dir, 0755)
 		}
-		if err := src.GenGo(outFile); err != nil {
+		if err := src.GenGo(out.goFile); err != nil {
 			log.Panicln(err)
 		}
 	}
-	return outFile
+	return goCommand(p.dir, op, &out, args...)
+}
+
+type goTarget struct {
+	goFile  string
+	outFile string
+	defctx  bool
+}
+
+func (p *Context) out(src *Project) (ret goTarget) {
+	hash := src.Fingerp()
+	fname := src.FriendlyFname
+	if !strings.HasSuffix(fname, ".go") {
+		fname += ".go"
+	}
+	dir, _ := filepath.Split(p.modfile)
+	ret.outFile = dir + "/g" + base64.RawURLEncoding.EncodeToString(hash[:])
+	ret.defctx = p.defctx
+	if ret.defctx {
+		ret.goFile = ret.outFile + fname
+	} else {
+		ret.goFile = src.AutoGenFile
+	}
+	return
 }
 
 // -----------------------------------------------------------------------------
@@ -124,7 +124,7 @@ replace (
 
 func genGomodFile(modfile string) {
 	var buf bytes.Buffer
-	fmt.Fprintf(&buf, gomodFormat, execgo.GOPVERSION, execgo.GOPROOT)
+	fmt.Fprintf(&buf, gomodFormat, GOPVERSION, GOPROOT)
 	err := os.WriteFile(modfile, buf.Bytes(), 0666)
 	if err != nil {
 		log.Panicln(err)
@@ -139,13 +139,7 @@ func genDummyProject(dir string) {
 }
 
 func execCommand(dir, command string, args ...string) {
-	cmd := exec.Command(command, args...)
-	cmd.Stdin = os.Stdin
-	cmd.Stdout = os.Stdout
-	cmd.Stderr = os.Stderr
-	cmd.Env = os.Environ()
-	cmd.Dir = dir
-	err := cmd.Run()
+	err := runCommand(dir, command, args...)
 	if err != nil {
 		switch e := err.(type) {
 		case *exec.ExitError:
@@ -156,6 +150,16 @@ func execCommand(dir, command string, args ...string) {
 	}
 }
 
+func runCommand(dir, command string, args ...string) error {
+	cmd := exec.Command(command, args...)
+	cmd.Stdin = os.Stdin
+	cmd.Stdout = os.Stdout
+	cmd.Stderr = os.Stderr
+	cmd.Env = os.Environ()
+	cmd.Dir = dir
+	return cmd.Run()
+}
+
 func genDefaultGopMod(modfile string) {
 	dir, _ := filepath.Split(modfile)
 	dummy := dir + "/dummy"


Test patch:
diff --git a/cl/compile_spx_test.go b/cl/compile_spx_test.go
index 04b20236..db874b23 100644
--- a/cl/compile_spx_test.go
+++ b/cl/compile_spx_test.go
@@ -73,50 +73,6 @@ func gopSpxTestEx(t *testing.T, gmx, spxcode, expected, gmxfile, spxfile string)
 	}
 }
 
-func gopSpxErrorTestEx(t *testing.T, msg, gmx, spxcode, gmxfile, spxfile string) {
-	fs := newTwoFileFS("/foo", spxfile, spxcode, gmxfile, gmx)
-	pkgs, err := parser.ParseFSDir(gblFset, fs, "/foo", nil, 0)
-	if err != nil {
-		scanner.PrintError(os.Stderr, err)
-		t.Fatal("ParseFSDir:", err)
-	}
-	conf := *baseConf.Ensure()
-	conf.NoFileLine = false
-	conf.WorkingDir = "/foo"
-	conf.TargetDir = "/foo"
-	bar := pkgs["main"]
-	_, err = cl.NewPackage("", bar, &conf)
-	if err == nil {
-		t.Fatal("no error?")
-	}
-	if ret := err.Error(); ret != msg {
-		t.Fatalf("\nError: \"%s\"\nExpected: \"%s\"\n", ret, msg)
-	}
-}
-
-func TestSpxError(t *testing.T) {
-	gopSpxErrorTestEx(t, `./Game.tgmx:4:2: cannot assign value to field in class file`, `
-var (
-	Kai Kai
-	userScore int = 100
-)
-`, `
-println "hi"
-`, "Game.tgmx", "Kai.tspx")
-
-	gopSpxErrorTestEx(t, `./Kai.tspx:3:2: missing field type in class file`, `
-var (
-	Kai Kai
-	userScore int
-)
-`, `
-var (
-	id = 100
-)
-println "hi"
-`, "Game.tgmx", "Kai.tspx")
-}
-
 func TestSpxBasic(t *testing.T) {
 	gopSpxTestEx(t, `
 func onInit() {
diff --git a/parser/parserdir_test.go b/parser/parserdir_test.go
index 4c59d526..6f264154 100644
--- a/parser/parserdir_test.go
+++ b/parser/parserdir_test.go
@@ -22,6 +22,7 @@ import (
 	"os"
 	"path"
 	"reflect"
+	"runtime"
 	"strings"
 	"testing"
 
@@ -121,6 +122,9 @@ func TestParseGo(t *testing.T) {
 }
 
 func TestFromTestdata(t *testing.T) {
+	if runtime.GOOS == "windows" {
+		return // TODO: how to pass this testcase in windows
+	}
 	sel := ""
 	dir, err := os.Getwd()
 	if err != nil {
diff --git a/printer/gop_test.go b/printer/gop_test.go
index 13cd9703..aa776a31 100644
--- a/printer/gop_test.go
+++ b/printer/gop_test.go
@@ -21,6 +21,7 @@ import (
 	"io/ioutil"
 	"os"
 	"path/filepath"
+	"runtime"
 	"testing"
 
 	"github.com/goplus/gop/ast"
@@ -117,6 +118,9 @@ func testFrom(t *testing.T, fpath string) {
 }
 
 func TestFromTestdata(t *testing.T) {
+	if runtime.GOOS == "windows" {
+		return // TODO: how to pass this testcase in windows
+	}
 	dir, err := os.Getwd()
 	if err != nil {
 		t.Fatal("Getwd failed:", err)
@@ -135,6 +139,9 @@ func TestFromTestdata(t *testing.T) {
 }
 
 func TestFromParse(t *testing.T) {
+	if runtime.GOOS == "windows" {
+		return // TODO: how to pass this testcase in windows
+	}
 	dir, err := os.Getwd()
 	if err != nil {
 		t.Fatal("Getwd failed:", err)
diff --git a/x/mod/modfile/read_test.go b/x/mod/modfile/read_test.go
index 054013a9..c278ef07 100644
--- a/x/mod/modfile/read_test.go
+++ b/x/mod/modfile/read_test.go
@@ -23,6 +23,7 @@ import (
 	"os/exec"
 	"path/filepath"
 	"reflect"
+	"runtime"
 	"strings"
 	"testing"
 )
@@ -30,6 +31,9 @@ import (
 // Test that reading and then writing the golden files
 // does not change their output.
 func TestPrintGolden(t *testing.T) {
+	if runtime.GOOS == "windows" {
+		return // TODO: how to pass this testcase in windows
+	}
 	outs, err := filepath.Glob("testdata/*.golden")
 	if err != nil {
 		t.Fatal(err)
@@ -150,6 +154,9 @@ func TestParseLax(t *testing.T) {
 // and printed and parsed again, we get the same parse tree
 // both times.
 func TestPrintParse(t *testing.T) {
+	if runtime.GOOS == "windows" {
+		return // TODO: how to pass this testcase in windows
+	}
 	outs, err := filepath.Glob("testdata/*")
 	if err != nil {
 		t.Fatal(err)