Skip to content

Release v0.7.1

Compare
Choose a tag to compare
@xushiwei xushiwei released this 12 Jul 16:07
c80ac57

Organization & Repo

Move github.com/qiniu/goplus to github.com/goplus/gop.
Move github.com/qiniu/goplus-www to github.com/goplus/www.
Move github.com/qiniu/goplus-play to github.com/goplusjs/play.

Thanks contribution of astaxie (astaxie@goplus.org), visualfc (visualfc@goplus.org).

Commands

gop run         # Run a Go+ program
gop go [-test]  # Convert Go+ packages into Go packages. If -test specified, it tests related packages.
gop fmt         # Format Go+ packages
gop export      # Export Go packages for Go+ programs

gop run (ie. qrun)

Run <gopSrcDir|gopSrcFile> as a Go+ script.

Usage: gop run [-asm -quiet -debug -prof] <gopSrcDir|gopSrcFile>
  -asm
    	generates `asm` code of Go+ bytecode backend
  -debug
    	print debug information
  -prof
    	do profile and generate profile report
  -quiet
    	don't generate any compiling stage log

Here are some examples:

gop run <gopSrcDir|gopSrcFile>        # gop run <gopSrcDir | gopSrcFile>
gop run -asm <gopSrcDir|gopSrcFile>   # generates `asm` code of Go+ bytecode backend
gop run -quiet <gopSrcDir|gopSrcFile> # don't generate any compiling stage log
gop run -debug <gopSrcDir|gopSrcFile> # print debug information
gop run -prof <gopSrcDir|gopSrcFile>  # do profile and generate profile report

gop fmt (ie. qfmt)

Format Go+ packages.

Usage: gop fmt [-w] [path ...]
  -w	write result to (source) file instead of stdout

gop export (ie. qexp)

Generate a Go+ package that wraps a Go package automatically.

Usage: gop export [-outdir <outRootDir>] <goPkgPath>
  -outdir string
    	optional set export lib path, default is $GoPlusRoot/lib path.

gop go (ie. qgo)

Convert all Go+ packages under into Go packages, recursively.

Usage: gop go [-test] <gopSrcDir>
  -test
    	test Go+ package

Here are some examples:

gop go <gopSrcDir> # gop go <gopSrcDir>
gop go -test <gopSrcDir>

Note:

  • gop go -test <gopSrcDir> converts Go+ packages into Go packages, and for every package, it call go run <gopPkgDir>/gop_autogen.go and gop run -quiet <gopPkgDir> to compare their outputs. If their outputs aren't equal, the test case fails.

Simplify test cases

import (
	"math/big"
	"testing"

	"github.com/goplus/gop/cl/cltest"
)

func TestMake(t *testing.T) {
	cltest.Expect(t, `
		a := make([]int, 0, 4)
		a = append(a, [1, 2, 3]...)
		println(a)
	`,
		"[1 2 3]\n",
	)
}

func TestPanic(t *testing.T) {
	cltest.Expect(t,
		`panic("Helo")`, "", "Helo",
	)
}

func TestRational(t *testing.T) {
	cltest.Call(t, `
		a := 3/4r
		x := a + 5/7r
		x
	`).Equal(big.NewRat(41, 28))
}

See https://github.com/qiniu/x/wiki/How-to-write-a-TestCase.

Go+ related packages

Import Go packages

  • variables read/write

Thanks contribution of visualfc (visualfc@goplus.org).

Builtin

  • copy

Thanks contribution of JessonChan (chendongpo@goplus.org).

IDE Plugins

Thanks contribution of go-wyvern (wuxinyi@goplus.org).

Go+ Badges

Hacker News Playground VSCode

Contributing

Where can you start?

  • Issues
  • Issues
  • Issues
  • TODOs

Misc

  • Simplify test cases of cl/expr_test.go.
  • Deduplicate code in package token/scanner.

Thanks contribution of wangkuiyi (wangyi@goplus.org), tsingbx.