features:
- cl: TypeAsParamsFunc/Method (#1706 goplus/gox#367)
- cl: FuncAlias (#1705 #1719 #1722 #1729)
- cl: InitGopPkg optimization (#1715 goplus/gox#333)
- cl: gox.GeneratedHeader set to Go+ (#1717)
- cl: TestYaptest use Gopo_xxx to make it more friendly (#1718 #1720)
- gop go/build/install/test/run: share importer (#1727 #1728 #1731)
- gengo: saveWithGopMod (#1721)
- gengo: support convert go+ files into go code (#1704)
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.