Releases: goplus/gop
v1.3.8
What's Changed
documents:
- Go+ MiniSpec: by @xushiwei in #2211 #2214 #2221 #2222 #2226 #2227 #2228 #2233 #2234 #2235 #2237 #2239 #2240 #2241 #2242 #2243 #2245
- Go+ FullSpec: by @xushiwei in #2238 #2244 #2247
features:
- support gotypesalias by @visualfc in #2208
- gop/tpl: by @xushiwei in #2211 #2212 #2213 #2215 #2216 #2217 #2218 #2219 #2223 #2224 #2225 #2229 #2230 #2231 #2232 #2246
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 familiara = append(a, v1, v2, ..., vN)
for Go programmers now becomes the more intuitivea <- v1, v2, ..., vN
. Connecting two lists is similar: previouslya = append(a, b...)
, nowa <- b...
. -
Introduced
for .. in
to replace the previousfor .. <-
, making it more consistent with mainstream languages. The oldfor .. <-
will still be supported, but after formatting the code with gop fmt, it will automatically convert<-
toin
. -
Introduced numeric literals with units, such as
1s
for 1 second. This allows us to usewait 0.5s
instead of the previously verbosewait 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, inwait 1m
, because the parameter is a time type,1m
means 1 minute. Instep 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), andtinygo
(a Go compiler specifically for embedded environments). Currently, Go+ defaults to usinggo
, but will default tollgo
in the future. To initialize a module usingllgo
, simply execute the commandgop 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 forreflect.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 variablex := "get_table_name"
to camel case"GetTableName"
only requiresx.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
andbison
. 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
What's Changed
features:
- parser: ParseExprEx by @xushiwei in #2190
- gop/tpl: by @xushiwei #2184 #2185 #2186 #2187 #2188 #2189 #2191 #2192 #2193 #2195 #2196 #2199 #2200 #2201 #2202 #2203 #2205 #2206 #2207
changes:
- classfile: refactor Classfname, Classclone; ast: ClassFieldsDecl by @xushiwei in #2180
- demo: remove outdated stuff by @xushiwei in #2204
ci & tools:
deps:
- build(deps): bump github.com/goplus/gogen 1.16.9 by @dependabot in #2209
- build(deps): bump github.com/goplus/llgo 0.10.1 by @dependabot in #2194
Full Changelog: v1.3.6...v1.3.7
v1.3.6
What's Changed
features:
- for..in by @xushiwei in #2166
- domain-specific text: tpl, html, xml, json, csv, regexp, regexposix (#2143) by @xushiwei in #2158 #2161 #2168
- classfile support auto-generated clone by @xushiwei in #2178
- gop/tpl by @xushiwei in #2153 #2154 #2165
changes:
- cl: fix slice check type by @visualfc in #2155
- cl: fix mapLit to any by @visualfc in #2157
- cl: compileErrWrapExpr check callExpr by @visualfc in #2174
- parser: parse lambda exprs with invalid identifiers as
ast.BadExpr
by @aofei in #2170 - parser: shadowEntry by @xushiwei in #2163
- gop/ast: improve
Walk
with latestgo/ast.Walk
by @aofei in #2169 - gop/ast: File.End by @xushiwei in #2164
- x/typesutil: handle
gogen.BoundTypeError
with fallback error logic by @aofei in #2171 - replace interface{} => any by @xushiwei in #2176
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
What's Changed
features:
- type as builtin func (#2115) by @xushiwei in #2116
- domain-specific text literal (#1770 #2143) by @xushiwei in #2144 #2145
- gop/tpl by @xushiwei in #2131 #2132 #2133 #2134 #2135 #2136 #2137 #2138 #2139 #2140 #2141 #2142 #2146 #2148 #2149 #2150 #2151
- gop/ast/gopq by @xushiwei in #2118 #2119 #2128
documents:
- builtin doc: builtin/doc/builtin.gop
- gopbuiltingen by @xushiwei in #2117 #2120 #2121 #2123 #2124 #2125 #2127 #2129 #2130
changes:
Full Changelog: v1.3.1...v1.3.5
v1.3.1
v1.3.0
What's Changed
documents:
- Go+ Mini Spec by @xushiwei in #1943 #1944 #1945 #1946 #1947 #1948 #1950 #1952 #1955 #1956 #1968 #1969 #1970 #1971 #1972 #1974 #1976 #1977 #1980 #1981 #1982 #1983 #1984 #1985 #1986 #1987 #1989 #1992 #1993 #1994 #1995 #1996 #1997 #1999 #2001 #2004 #2006 #2013 #2017 #2018 #2019 #2021 #2022 #2024 #2026 #2027 #2028 #2031 #2033 #2034 #2035 #2037 #2038 #2039 #2040 #2041 #2042 #2043 #2044 #2045 #2046 #2047 #2048 #2049 #2050 #2051 #2052 #2053 #2054 #2058 #2059 #2062 #2064 #2067 #2082 #2083 #2084
- Go+ Full Spec by @xushiwei in #1957
- How Go+ simplifies Go's expressions by @xushiwei in #1941 #1942 #1953 #1957 #1973 #2036
features:
- number with unit (#2000) by @xushiwei in #2007 #2008 #2010 #2063
- string/stringslice: Capitalize by @xushiwei in #2073 #2074 #2075 #2076 #2077
- compileSendStmt: support slice append (#2107) by @xushiwei in #2108
- select Go compiler in go.mod by @xushiwei in #1917
- scanner.New & demo by @xushiwei in #2093
- gop: support -tags by @visualfc in #2071
- gop mod init -llgo: support AddRequire llgo by @xushiwei in #1926
- gop/format/formatutil: RearrangeFuncs if necessary by @xushiwei in #2070
- llgo: hello world by @xushiwei in #1876
- llgo: replace c2go => llgo by @xushiwei in #1877
- llgo: interface demo (implement error interface) by @xushiwei in #1889
- llgo: goroutine by @xushiwei in #1896
- llgo: defer by @xushiwei in #1898
- llgo: qsort by @xushiwei in #1901
- llgo: c/sqlite by @xushiwei in #1892
- llgo: c string literal by @xushiwei in #1905
- llgo: tetris by @xushiwei in #1906 #1907 #1908
- llgo: reflect by @xushiwei in #1909
- doc: calling C from Go+ by @xushiwei in #1880
- doc: support for C/C++ and Python by @xushiwei in #1925
- doc: c style string by @xushiwei in #1913
- llgo: c hello by @xushiwei in #1924
- llgo: c++ hello by @xushiwei in #1923
- cl: support python; TestPyCall by @xushiwei in #1878
- cl: PYSTRING: py"..." by @xushiwei in #1911
- pydemo: matrix by @xushiwei in #1879
- pyprint / pytensor by @xushiwei in #1902
- pymax by @xushiwei in #1903
- pyhello by @xushiwei in #1918
- demo: _tinygo by @xushiwei in #1921
- demo: rpncalc: Reverse Polish Notation Calc by @xushiwei in #2094
- demo: pseudo code by @xushiwei in #2095 #2098 #2103 #2104 #2105 #2106 #2109
changes:
- env: update MainVersion to 1.3 by @xushiwei in #1928 #1929
- ast: fix (*ast.File).End check shadow no entry by @visualfc in #1860
- cltest: by @xushiwei in #1884
- cltest.FromDir by @xushiwei in #1886
- cltest: spx by @xushiwei in #1887
- classfile: allow a work class to specify its project class by @xushiwei in #2061
- parser parseBranchStmt: allow goto as command name by @xushiwei in #2069
- parser: parser doc by @xushiwei in #2100
- cl: _testgop by @xushiwei in #1888
- cl: TestEmbedField by @visualfc in #2014
- cl: update gogen for overload check untyped args by @visualfc in #2030
- cl: update gogen for fix uptyped check by @visualfc in #2066
- cl: fix slicelit for assignStmt/returnStmt by @visualfc in #1959
- cl: fix compositeLit for assignStmt by @visualfc in #1960
- cl: fix compileCompositeLitEx struct for sliceLit/mapLit by @visualfc in #1961
- cl: fix compileCallArgs recover error for overloads by @visualfc in #1991
- cl.GetFileClassType: fix isProj must check name is main by @visualfc in #1862
- cl: preloadFile ast.OverloadFuncDecl handle error by @visualfc in #1865
- cl: record def for ast.OverloadFuncDecl by @visualfc in #1866
- cl: fix record ast.OverloadFuncDecl has funcLit only by @visualfc in #1869
- cl: Go+ overload func support pos by @visualfc in #1868
- cl: support declared function in classfile's overload decl by @luoliwoshang in #1875
- x/typesutil: modify info.Overloads to point to the overload decl by @luoliwoshang in #1872
- x/langserver: gengo use cache by @visualfc in #1861
- x/format: funcLitToLambdaExpr by @visualfc in #2086
- x/format: fmt.println => echo by @visualfc in #2088
- x/format: funclit to lambda doc by @visualfc in #2087
- x/format: mv funcLitToLambdaExpr => format.go by @xushiwei in #2089
- x/format: println => echo in README.md by @xushiwei in #2090
- testdata => demo by @xushiwei in #1920
- chore: fix function names by @writegr in #1863
- cmd/chore by @xushiwei in #1885
- mv .go => tool/.go by @xushiwei in #2080
deps:
- build(deps): bump github.com/fsnotify/fsnotify 1.8.0 by @dependabot in #2002
- build(deps): bump github.com/goplus/llgo 0.9.9 by @dependabot in #2056
- build(deps): bump github.com/goplus/gogen 1.16.6 by @dependabot in #2085
- build(deps): bump github.com/goplus/mod 0.13.17 by @dependabot in #2097
ci & tools:
- ci by @xushiwei in #1871 #1936
- ci: go1.19 by @xushiwei in #1883
- ci: go1.22 by @xushiwei in #2078
- ci: bump samuelmeuli/action-snapcraft from 2 to 3 by @dependabot in #2015
- codecov: bump codecov/codecov-action from 4 to 5 by @dependabot in #2016
- codecov: .github/codecov.yml by @xushiwei in #2079
- test: fix cmd/TestInstallInNonGitRepo/install_with_VERSION_file by @aofei in #1930
- test by @xushiwei in #1931
- test: make cmd/TestInstallInNonGitRepo not affected by actual major.minor versions by @aofei in #1937
- test: make cmd/TestInstallInNonGitRepo not affected by actual major.minor by @xushiwei in #1938
- goreleaser: remove gopfmt by @xushiwei in #1932 #1933
- goreleaser: bump .goreleaser.yaml to v2 by @aofei in #1935
- goreleaser: bump goreleaser-action from 5 to 6 by @dependabot in #1895
- docker: remove gopfmt from the baked Docker image by @aofei in #1934
- docker: extract artifacts from tarball when using GoReleaser by @aofei in #2032
New Contributors
Full Changelog: v1.2.6...v1.3.0
v1.3.0-pre.2
v1.3.0-pre.1
highlights:
- select Go compiler: support llgo (support for C/C++ and Python)
features:
- select Go compiler: support llgo (#1876 #1877 #1878 #1879 #1889 #1892 #1896 #1898 #1901 #1902 #1903 #1906 #1907 #1909)
- select Go compiler in go.mod (#1917 #1918 #1921 #1926)
- c string literal (#1905)
- python string literal (PYSTRING): py"..." (#1911)
- gop/cl/cltest (#1884 #1886 #1887)
- llgo demo: tetris (#1906 #1907 #1908)
- llgo demo: go/c/c++/python hello (#1923 #1924)
- x/langserver: gengo use cache (#1861)
- README: calling C from Go+ (#1880)
- README: c style string (#1913)
- README: support for C/C++ and Python (#1925)
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
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 usefor range :N { ... }
. - Pkgsite: Beta version of https://pkg.gop.dev/ is released.
features:
- static methods (#1848 #1849 #1850 #1857)
- for
RangeExpr
{ ... } (#1834) - cl: generic infer lambda expr (#1826)
- cl: record ast.OverloadFuncDecl (#1851)
- parser: MatrixLit (#1840 #1846)
- gop/doc.Transform (#1820 #1825)
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
highlights:
- operator
${name}
: You can customize the semantics of${name}
. For example, in .gsh classfile,${name}
meansos.Getenv("<name>")
, and in .yap classfile,${name}
meansctx.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.