github goplus/gop v1.2.1

latest releases: v1.3.0-pre.2, v1.3.0-pre.1, v1.2.6...
9 months ago

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.

Don't miss a new gop release

NewReleases is sending notifications on new releases.