Skip to content

v1.2.1

Compare
Choose a tag to compare
@xushiwei xushiwei released this 12 Feb 11:13
· 269 commits to v1.2 since this release
3717421

highlights:

  • The compilation speed of Go+ has been improved a lot. Compiling the complete Go+ tutorials (github.com/goplus/tutorial) has been increased by 50 times, and compiling all examples from the spx repository (github.com/goplus/spx) is also 10x faster.

features:

ci/cd tools:

  • ci: skip publish prerelease (#1712)

changes:

  • parser: ParseFSFiles fix: support SaveAbsFile flag (#1724)
  • cl: classfile: sorted workers (#1723)
  • scanner: fix ... insertSemi (#1707 #1708 #1709)

Go+ Classfiles

Rob Pike once said that if he could only introduce one feature to Go, he would choose interface instead of goroutine. classfile is as important to Go+ as interface is to Go.

In the design philosophy of Go+, we do not recommend DSL (Domain Specific Language). But SDF (Specific Domain Friendliness) is very important. The Go+ philosophy about SDF is:

Don't define a language for specific domain.
Abstract domain knowledge for it.

Go+ introduces classfile to abstract domain knowledge.

Sound a bit abstract? Let's take web programming as an example. First let us initialize a hello project:

gop mod init hello

Then we have it reference a classfile called yap as the HTTP Web Framework:

gop get github.com/goplus/yap@latest

We can use it to implement a static file server:

static "/foo", FS("public")
static "/"    # Equivalent to static "/", FS("static")

run ":8080"

We can also add the ability to handle dynamic GET/POST requests:

static "/foo", FS("public")
static "/"    # Equivalent to static "/", FS("static")

get "/p/:id", ctx => {
	ctx.json {
		"id": ctx.param("id"),
	}
}

run ":8080"

Save this code to hello_yap.gox file and execute:

mkdir -p yap/static yap/public    # Static resources can be placed in these directories
gop mod tidy
gop run .

A simplest web program is running now. At this time, if you visit http://localhost:8080/p/123, you will get:

{"id":"123"}

Why is yap so easy to use? How does it do it? Click here to learn more about the Go+ Classfiles mechanism and YAP HTTP Web Framework.