Skip to content

Releases: goplus/gop

v1.3.8

01 Apr 18:22
fc516d8
Compare
Choose a tag to compare

What's Changed

documents:

features:

Important Updates in v1.3 (vs. v1.2)

Documentation:

  • Improved Go+ Mini Spec documentation. Go+ Mini Spec is a carefully designed language specification that represents the essence of Go+: providing a minimal but Turing-complete syntax set, while also representing the best practices of Go+ programming.

  • Auto-generated documentation for Go+ builtin functions. Go+'s builtin functions are far more extensive than Go's, which simplifies the expression of common tasks. Additionally, Go+'s basic types also have methods. For example, the string type has built-in common string operations. Among them, "123".int converts a string to an integer type; "get_table_name".split("_") splits a string into a list ["get", "table", "name"].

Language Features:

  • Goodbye to append, new syntax for adding elements to a list: the <- operator. The familiar a = append(a, v1, v2, ..., vN) for Go programmers now becomes the more intuitive a <- v1, v2, ..., vN. Connecting two lists is similar: previously a = append(a, b...), now a <- b....

  • Introduced for .. in to replace the previous for .. <-, making it more consistent with mainstream languages. The old for .. <- will still be supported, but after formatting the code with gop fmt, it will automatically convert <- to in.

  • Introduced numeric literals with units, such as 1s for 1 second. This allows us to use wait 0.5s instead of the previously verbose wait 0.5*time.Second, making the semantics more intuitive. It's worth noting that the meaning of numeric constants with units varies depending on the type of data. For example, in wait 1m, because the parameter is a time type, 1m means 1 minute. In step 1m, where the parameter type is distance, 1m means 1 meter.

  • Support for users to choose their own Go compiler, which can be specified in go.mod. Go+ currently supports the following Go compilers: go (Go's official compiler), llgo (maintained by the Go+ team), and tinygo (a Go compiler specifically for embedded environments). Currently, Go+ defaults to using go, but will default to llgo in the future. To initialize a module using llgo, simply execute the command gop mod init -llgo mymodule.

  • Support for importing C/C++ and Python libraries. Go+'s support for importing C/C++ and Python libraries is achieved through LLGo. Currently, the support for C/C++ libraries is quite mature, and we will provide automated tools to cover mainstream C/C++ libraries, eliminating the need for users to manually migrate C/C++ libraries to the Go world as with cgo. Go+'s support for Python libraries is still experimental and will be a focus in future versions of Go+.

  • Wasm support. Go+'s support for Wasm is achieved through LLGo. Wasm generated by LLGo will be smaller in size than Wasm compiled by the official Go compiler, and it still supports generating Wasm files when using cgo (the official Go compiler doesn't support Wasm when using cgo).

  • Built-in clone support for classfiles, making object cloning operations more efficient. Possible application scenarios: creating Handler instances for each new connection in a web framework. Before clone support, we typically needed to implement object cloning through the reflect mechanism, which not only made the code obscure but also introduced significant performance overhead.

  • Support for Domain Text Literals.

Built-in Functions:

  • Added the built-in function type as a replacement for reflect.TypeOf, used to view the type of an object.

  • Added the Capitalize method to string and []string types, used to capitalize the first letter of a string. For example: "hello".capitalize will result in the string "Hello", and ["hello", "world", "!"].capitalize will result in ["Hello", "World", "!"]. Converting a C-style variable x := "get_table_name" to camel case "GetTableName" only requires x.split("_").capitalize.join("").

Standard Libraries:

  • gop/tpl: a grammar-based language similar to EBNF (Extended Backus-Naur Form) that seamlessly integrates with Go+. It provides a more readable and maintainable approach to text processing while offering capabilities beyond what regular expressions can achieve. TPL is similar to yacc and bison. However, it's not a standalone tool but a domain text literal embedded in the Go+ language.

Full Changelog: v1.3.7...v1.3.8

v1.3.7

27 Mar 08:44
2bf4ec5
Compare
Choose a tag to compare

What's Changed

features:

changes:

ci & tools:

deps:

Full Changelog: v1.3.6...v1.3.7

v1.3.6

15 Mar 23:30
702e9cb
Compare
Choose a tag to compare

What's Changed

features:

changes:

deps:

  • build(deps): bump github.com/goplus/llgo from 0.9.9 to 0.10.0 by @dependabot in #2156

Full Changelog: v1.3.5...v1.3.6

v1.3.5

01 Mar 16:37
6ee6a0f
Compare
Choose a tag to compare

What's Changed

features:

documents:

changes:

Full Changelog: v1.3.1...v1.3.5

v1.3.1

22 Feb 01:27
a30942b
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.3.0...v1.3.1

v1.3.0

16 Feb 15:40
e919c9d
Compare
Choose a tag to compare

What's Changed

documents:

features:

changes:

deps:

ci & tools:

New Contributors

Full Changelog: v1.2.6...v1.3.0

v1.3.0-pre.2

06 Sep 00:31
370a8e4
Compare
Choose a tag to compare
v1.3.0-pre.2 Pre-release
Pre-release

highlights:

docs:

changes:

  • mod: rollback golang.org/x/tools v0.22.0 => v0.19.0 (#1966)
  • mod: github.com/goplus/llgo v0.9.7
  • cl: fix slicelit for assignStmt/returnStmt (#1959)
  • cl: fix compositeLit for assignStmt (#1960)
  • cl: fix compileCompositeLitEx struct for sliceLit/mapLit (#1961)

v1.3.0-pre.1

15 Jul 15:14
43ecd08
Compare
Choose a tag to compare
v1.3.0-pre.1 Pre-release
Pre-release

highlights:

features:

changes:

  • cl: GetFileClassType: fix isProj must check name is main (#1862)
  • cl: preloadFile ast.OverloadFuncDecl handle error (#1865)
  • cl: record def for ast.OverloadFuncDecl (#1866)
  • cl: Go+ overload func support pos (#1868)
  • cl: fix record ast.OverloadFuncDecl has funcLit only (#1869)
  • cl: support declared function in classfile's overload decl (#1875)
  • cl: _testgop (to be continued (#1888)
  • x/typesutil:modify info.Overloads to point to the overload decl (#1872)
  • gop/ast: fix (*ast.File).End check shadow no entry (#1860)
  • update env.MainVersion to 1.3 (#1928 #1930)
  • testdata => demo (#1920)
  • cmd/chore (#1885)
  • publish (docker): remove gopfmt from the baked Docker image (#1934)
  • publish (goreleaser): remove gopfmt (#1932)
  • make test: make cmd/TestInstallInNonGitRepo not affected by actual major.minor versions (#1937)
  • make test: fix cmd/TestInstallInNonGitRepo/install_with_VERSION_file (#1930)
  • goreleaser: remove gopfmt (#1932)
  • mod: github.com/goplus/gogen v1.16.0
  • mod: github.com/goplus/llgo v0.9.1
  • mod: github.com/goplus/mod v0.13.12
  • mod: golang.org/x/tools v0.22.0

v1.2.6

12 Apr 19:30
4fdc568
Compare
Choose a tag to compare

highlights:

  • Improve compilation speed through disk cache, especially under windows (#1827, gogen@v1.15.2).
  • Go+ now supports static methods. This allows Go+ classfile to provide "global functions", such as T.new or T.start, without introducing a separate file.
  • Times loop: for :N { ... }. Previously you had to use for range :N { ... }.
  • Pkgsite: Beta version of https://pkg.gop.dev/ is released.

features:

ci/cd tools:

  • official Docker image (#1819 #1841)
  • change build artifacts name (#1838)
  • cover Go 1.22 in test (#1836)
  • update macOS version to "macos-latest" (#1844)

changes:

  • gop: NewDefaultConf: useCacheFile param; conf.UpdateCache (#1827)
  • cl: compileExpr/compileExprLHS panic code error (#1832)
  • cl: correct anonymous overloaded function naming (#1833)
  • cl, printer: set astFnClassfname shadow and not to print (#1853)
  • cl, gop: export GetFileClassType (#1852)
  • cl: gmxProject.hasMain (#1817)
  • mod: github.com/goplus/c2go v0.7.26
  • mod: github.com/goplus/gogen v1.15.2
  • mod: github.com/goplus/mod v0.13.10
  • mod: github.com/qiniu/x v1.13.10

v1.2.5

09 Mar 15:05
f6596aa
Compare
Choose a tag to compare

highlights:

  • operator ${name}: You can customize the semantics of ${name}. For example, in .gsh classfile, ${name} means os.Getenv("<name>"), and in .yap classfile, ${name} means ctx.Param("<name>").
  • The web framework YAP released v0.8.0. It introduces YAP classfile v2 which is particularly simple and easy to use. See blow for details.

features:

  • classfile: generate gameClass.Main() (#1814)
  • classfile: this.Sprite.Main(...) or this.Game.MainEntry(...) (#1794)
  • classfile: this.Classfname() (#1794 #1797)
  • classfile: gsh exec (#1757)
  • cl: ${name} - operator Gop_Env (#1776 #1806 #1810)
  • cl: binaryOp ->, <> (#1763 #1764 #1766)
  • cl: compileCompositeLit: support type-inter for map (#1756)
  • cl: rec.Scope - record types scope (#1759 #1767 #1772 #1774)
  • cl: types record check selection/index expr is addressable (#1785 #1788)
  • cl: don't define GopPackage for main package (#1796)
  • cl: astFnClassfname, astEmptyEntrypoint (#1811 #1812)
  • format interface{}: rm newline (#1761 #1769 #1791)
  • x/typesutil: add conf.IgnoreFuncBodies (#1783)
  • x/typesutil: add conf.UpdateGoTypesOverload (#1793)
  • qiniu/x/stringutil (#1777 #1778 #1779)

ci/cd tools:

  • check goreleaser file lists (#1802)
  • ci: compatible with version difference of patch release (#1804 #1808)

changes:

  • rename github.com/goplus/gox => github.com/goplus/gogen (#1798)
  • cl: inMainPkg (#1789)
  • cl: isGoxTestFile (#1790)
  • cl: for..range body use vblock for new scope (#1760)
  • cl: gogen new api case/typeCase/commCase (#1762)
  • cl: commentStmt: fix ast.GenDecl pos (#1768)
  • cl: commentStmt: skip noPos (#1794)
  • cl: TestErrStringLit (#1799)
  • parser: fix StringLit extra check (#1782)
  • ast: walk add *IndexListExpr (#1773)
  • ast: fix forPhrase.end (#1775)
  • x/typesutil: check for need goinfo (#1784)
  • x/typesutil: TestTypeAndValue, TestConvErr (#1800)
  • mod: github.com/goplus/c2go v0.7.25
  • mod: github.com/goplus/gogen v1.15.1
  • mod: github.com/goplus/mod v0.13.9
  • mod: github.com/qiniu/x v1.13.9
  • mod: golang.org/x/tools v0.19.0

YAP released v0.8.0. It introducesYAP classfile v2 which is particularly simple and easy to use. Let’s compare YAP in Go, YAP classfile v1 and YAP classfile v2.

Router and Parameters

demo in Go (hello.go):

import "github.com/goplus/yap"

func main() {
	y := yap.New()
	y.GET("/", func(ctx *yap.Context) {
		ctx.TEXT(200, "text/html", `<html><body>Hello, YAP!</body></html>`)
	})
	y.GET("/p/:id", func(ctx *yap.Context) {
		ctx.JSON(200, yap.H{
			"id": ctx.Param("id"),
		})
	})
	y.Run("localhost:8080")
}

demo in YAP classfile v1 (main.yap):

get "/", ctx => {
	ctx.html `<html><body>Hello, YAP!</body></html>`
}
get "/p/:id", ctx => {
	ctx.json {
		"id": ctx.param("id"),
	}
}

run "localhost:8080"

demo in YAP classfile v2 (get.yap, get_p_#id.yap):

html `<html><body>Hello, YAP!</body></html>`
json {
	"id": ${id},
}

YAP Template

demo in Go (blog.go, article_yap.html):

import (
	"os"

	"github.com/goplus/yap"
)

y := yap.New(os.DirFS("."))

y.GET("/p/:id", func(ctx *yap.Context) {
	ctx.YAP(200, "article", yap.H{
		"id": ctx.Param("id"),
	})
})

y.Run(":8080")

demo in YAP classfile v1 (main.yap, article_yap.html):

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

run ":8888"

demo in YAP classfile v2 (get_p_#id.yap, article_yap.html):

yap "article", {
	"id": ${id},
}

See yap: Yet Another HTTP Web Framework for more details.