Skip to content

Commit

Permalink
Merge pull request #1699 from goplus/main
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
xushiwei authored Feb 1, 2024
2 parents 5db9564 + b3dae2d commit df880bb
Show file tree
Hide file tree
Showing 25 changed files with 1,753 additions and 884 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,20 @@ jobs:
args: release --clean -p 4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
WINGET_PKGS_PRIVATE_KEY: ${{ secrets.WINGET_PKGS_PRIVATE_KEY }}

- name: Upload deb/rpm to Fury.io
run: |
for file in dist/*.{deb,rpm}
do
echo "Uploading $file to Fury.io"
curl -sS -F package=@$file https://[email protected]/goplus/
CODE=`curl --write-out '%{http_code}' --output /dev/null -sS -F package=@$file https://[email protected]/$GITHUB_REPOSITORY_OWNER/`
if [ "$CODE" != "200" ]; then
echo "Upload failed with code $CODE"
exit 1
fi
done
env:
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ winget:
license: Apache-2.0
skip_upload: false
release_notes: "{{.Changelog}}"
release_notes_url: "https://github.com/goplus/gop/releases/tag/v{{.Version}}"
release_notes_url: "https://github.com/{{ .Env.GITHUB_REPOSITORY_OWNER }}/gop/releases/tag/v{{.Version}}"
dependencies:
- package_identifier: GoLang.Go
minimum_version: 1.18.0
Expand All @@ -105,7 +105,7 @@ winget:
name: winget-pkgs
branch: "{{.ProjectName}}-v{{.Version}}"
git:
url: "[email protected]:goplus/winget-pkgs.git"
url: "[email protected]:{{ .Env.GITHUB_REPOSITORY_OWNER }}/winget-pkgs.git"
private_key: "{{ .Env.WINGET_PKGS_PRIVATE_KEY }}"
pull_request:
enabled: true
Expand Down
43 changes: 35 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@

</div>

Our vision is to **enable everyone to create production-level applications**.

#### Easy to learn

* Simple and easy to understand
* Smaller syntax set than Python in best practices

#### Ready for large projects

* Derived from Go and easy to build large projects from its good engineering foundation

The Go+ programming language is designed for engineering, STEM education, and data science.

* **For engineering**: working in the simplest language that can be mastered by children.
Expand All @@ -33,13 +44,27 @@ The Go+ programming language is designed for engineering, STEM education, and da
For more details, see [Quick Start](doc/docs.md).


## 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. See [Go+ Classfiles](doc/classfile.md).


## Key Features of Go+

* A static typed language.
* The simplest engineering language that can be mastered by children (script-like style).
* Performance: as fast as Go (Go+'s main backend compiles to human-readable Go).
* Fully compatible with [Go](https://github.com/golang/go) and can mix Go/Go+ code in the same package (see [Go/Go+ hybrid programming](doc/docs.md#gogo-hybrid-programming)).
* No DSL (Domain Specific Language) support, but it's Specific Domain Friendly (see [DSL vs. SDF](doc/dsl-vs-sdf.md)).
* No DSL (Domain Specific Language) support, but SDF ([Specific Domain Friendliness](doc/classfile.md)).
* Support Go code generation (main backend) and [bytecode backend](https://github.com/goplus/igop) (REPL: see [iGo+](https://repl.goplus.org/)).
* [Simplest way to interaction with C](doc/docs.md#calling-c-from-go) (cgo is supported but not recommended).
* [Powerful built-in data processing capabilities](doc/docs.md#data-processing).
Expand All @@ -49,12 +74,6 @@ For more details, see [Quick Start](doc/docs.md).

### on Windows

```sh
winget install goplus
```

Or

```sh
winget install goplus.gop
```
Expand All @@ -74,7 +93,7 @@ sudo bash -c 'echo -e "[goplus]\nname=Go+ Repo\nbaseurl=https://pkgs.goplus.org/
sudo yum install gop
```

### on macOS/Linux(Homebrew)
### on macOS/Linux (Homebrew)

Install via [brew](https://brew.sh/)

Expand Down Expand Up @@ -110,6 +129,14 @@ all.bat
* [Gobang](https://github.com/xushiwei/Gobang)
* [Dinosaur](https://github.com/xushiwei/Dinosaur)

### HTTP Web Framework

* [yap: Yet Another Go/Go+ HTTP Web Framework](https://github.com/goplus/yap)

### HTTP Test

* [yaptest: HTTP Test Framework](https://github.com/goplus/yap/tree/main/ytest)

### DevOps tools

* [Go+ DevOps Tools](https://github.com/goplus/gop/blob/main/doc/dsl-vs-sdf.md#demo-go-devops-tools)
Expand Down
15 changes: 15 additions & 0 deletions cl/classfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type gmxProject struct {
schedStmts []goast.Stmt // nil or len(scheds) == 2 (delayload)
pkgImps []gox.PkgRef
pkgPaths []string
autoimps map[string]pkgImp // auto-import statement in gop.mod
hasScheds bool
gameIsPtr bool
isTest bool
Expand Down Expand Up @@ -99,6 +100,20 @@ func loadClass(ctx *pkgCtx, pkg *gox.Package, file string, f *ast.File, conf *Co
p.pkgImps[i] = pkg.Import(pkgPath)
}

if len(gt.Import) > 0 {
autoimps := make(map[string]pkgImp)
for _, imp := range gt.Import {
pkgi := pkg.Import(imp.Path)
name := imp.Name
if name == "" {
name = pkgi.Types.Name()
}
pkgName := types.NewPkgName(token.NoPos, pkg.Types, name, pkgi.Types)
autoimps[name] = pkgImp{pkgi, pkgName}
}
p.autoimps = autoimps
}

spx := p.pkgImps[0]
if gt.Class != "" {
p.game, p.gameIsPtr = spxRef(spx, gt.Class)
Expand Down
15 changes: 10 additions & 5 deletions cl/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"sort"
"strconv"
"strings"
_ "unsafe"

"github.com/goplus/gop/ast"
"github.com/goplus/gop/ast/fromgo"
Expand Down Expand Up @@ -366,6 +365,7 @@ type blockCtx struct {
pkg *gox.Package
cb *gox.CodeBuilder
imports map[string]pkgImp
autoimps map[string]pkgImp
lookups []gox.PkgRef
clookups []cpackages.PkgRef
tlookup *typeParamLookup
Expand All @@ -388,6 +388,9 @@ func (bc *blockCtx) recorder() *typesRecorder {

func (bc *blockCtx) findImport(name string) (pi pkgImp, ok bool) {
pi, ok = bc.imports[name]
if !ok && bc.autoimps != nil {
pi, ok = bc.autoimps[name]
}
return
}

Expand Down Expand Up @@ -630,9 +633,6 @@ func isOverloadFunc(name string) bool {
return n > 3 && name[n-3:n-1] == "__"
}

//go:linkname initThisGopPkg github.com/goplus/gox.initThisGopPkg
func initThisGopPkg(pkg *types.Package)

func initGopPkg(ctx *pkgCtx, pkg *gox.Package, gopSyms map[string]bool) {
for name, f := range ctx.syms {
if gopSyms[name] {
Expand All @@ -654,7 +654,7 @@ func initGopPkg(ctx *pkgCtx, pkg *gox.Package, gopSyms map[string]bool) {
if pkg.Types.Scope().Lookup(gopPackage) == nil {
pkg.Types.Scope().Insert(types.NewConst(token.NoPos, pkg.Types, gopPackage, types.Typ[types.UntypedBool], constant.MakeBool(true)))
}
initThisGopPkg(pkg.Types)
gox.InitThisGopPkg(pkg.Types)
}

func getEntrypoint(f *ast.File) string {
Expand Down Expand Up @@ -730,6 +730,7 @@ func preloadGopFile(p *gox.Package, ctx *blockCtx, file string, f *ast.File, con
} else {
c := parent.classes[f]
proj, ctx.proj = c.proj, c.proj
ctx.autoimps = proj.autoimps
classType = c.tname
if isGoxTestFile(c.ext) { // test classfile
testType = c.tname
Expand Down Expand Up @@ -832,6 +833,10 @@ func preloadGopFile(p *gox.Package, ctx *blockCtx, file string, f *ast.File, con
}
parent.tylds = append(parent.tylds, ld)
}

// bugfix: see TestGopxNoFunc
parent.lbinames = append(parent.lbinames, classType)

ctx.classRecv = &ast.FieldList{List: []*ast.Field{{
Names: []*ast.Ident{
{Name: "this"},
Expand Down
Loading

0 comments on commit df880bb

Please sign in to comment.