Home

Awesome

<div align="center"> <p></p> <p> <img width="80" src="https://goplus.org/favicon.svg"> </p> <h1>The Go+ Programming Language</h1>

goplus.org | Docs | Go+ vs. Go | Tutorials | Playground | iGo+ Playground | Contributing & compiler design

</div> <div align="center"> <!-- [![VSCode](https://img.shields.io/badge/vscode-Go+-teal.svg)](https://github.com/gopcode/vscode-goplus) [![Discord](https://img.shields.io/discord/983646982100897802?label=Discord&logo=discord&logoColor=white)](https://discord.gg/mYjWCJDcAr) [![Interpreter](https://img.shields.io/badge/interpreter-iGo+-seagreen.svg)](https://github.com/goplus/igop) -->

Build Status Go Report Card Coverage Status GitHub release Discord

</div>

Our vision is to enable everyone to become a builder of the digital world.

Easy to learn

Ready for large projects

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

For more details, see Quick Start.

Key Features of Go+

How Go+ simplifies Go's expressions

Different from the function call style of most languages, Go+ recommends command style code:

println "Hello world"

To emphasize our preference for command style, we introduce echo as an alias for println:

echo "Hello world"

For more discussion on coding style, see https://tutorial.goplus.org/hello-world.

Code style is just the first step. We have made many efforts to make the code more intuitive and closer to natural language expression. These include:

Go codeGo+ codeNote
package main<br><br>import "fmt"<br><br>func main() {<br>    fmt.Println("Hi")<br>}import "fmt"<br><br>fmt.Println("Hi")<br>Program structure: Go+ allows omitting package main and func main
fmt.Println("Hi")echo("Hi")More builtin functions: It simplifies the expression of the most common tasks
fmt.Println("Hi")echo "Hi"Command-line style code: It reduces the number of parentheses in the code as much as possible, making it closer to natural language
a := []int{1, 2, 3}a := [1, 2, 3]List literals
a := map[string]int{<br>    "Monday": 1,<br>    "Tuesday": 2,<br>}a := {<br>    "Monday": 1,<br>    "Tuesday": 2,<br>}Mapping literals
OnStart(func() {<br>    ...<br>})onStart => {<br>    ...<br>}Lambda expressions
type Rect struct {<br>    Width  float64<br>    Height float64<br>}<br><br>func (this *Rect) Area() float64 { <br>    return this.Width * this.Height<br>}var (<br>    Width  float64<br>    Height float64<br>)<br><br>func Area() float64 { <br>    return Width * Height<br>}Go+ Classfiles: We can express OOP with global variables and functions.

For more details, see The Go+ Mini Specification.

Importing C/C++ and Python libraries

Go+ can choose different Go compilers as its underlying support. Currently known supported Go compilers include:

Currently, Go+ defaults to using go as its underlying support, but in the future, it will be llgo.

LLGo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python. It aims to expand the boundaries of Go/Go+, providing limitless possibilities such as:

If you wish to use llgo, specify the -llgo flag when initializing a Go+ module:

gop mod init -llgo YourModulePath

This will generate a go.mod file with the following contents (It may vary slightly depending on the versions of local Go+ and LLGo):

module YourModulePath

go 1.21 // llgo 1.0

require github.com/goplus/llgo v0.9.8

Based on LLGo, Go+ can import libraries written in C/C++ and Python.

Here is an example (see chello) of printing Hello world using C's printf:

import "c"

c.printf c"Hello world\n"

Here, c"Hello world\n" is a syntax supported by Go+, representing a null-terminated C-style string.

To run this example, you can:

cd YourModulePath  # set work directory to your module
gop mod tidy       # for generating go.sum file
gop run .

And here is an example (see pyhello) of printing Hello world using Python's print:

import "py/std"

std.print py"Hello world"

Here, py"Hello world" is a syntax supported by Go+, representing a Python string.

Here are more examples of Go+ calling C/C++ and Python libraries:

To find out more about LLGo/Go+'s support for C/C++ and Python in detail, please refer to homepage of llgo.

Go+ Classfiles

One language can change the whole world.
Go+ is a "DSL" for all domains.

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 see some Go+ classfiles.

yap: Yet Another HTTP Web Framework

This classfile has the file suffix .yap.

Create a file named get.yap with the following content:

html `<html><body>Hello, YAP!</body></html>`

Execute the following commands:

gop mod init hello
gop get github.com/goplus/yap@latest
gop mod tidy
gop run .

A simplest web program is running now. At this time, if you visit http://localhost:8080, you will get:

Hello, YAP!

YAP uses filenames to define routes. get.yap's route is get "/" (GET homepage), and get_p_#id.yap's route is get "/p/:id" (In fact, the filename can also be get_p_:id.yap, but it is not recommended because : is not allowed to exist in filenames under Windows).

Let's create a file named get_p_#id.yap with the following content:

json {
	"id": ${id},
}

Execute gop run . and visit http://localhost:8080/p/123, you will get:

{"id": "123"}

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

spx: A Go+ 2D Game Engine

Screen Shot1 Screen Shot2

Through this example you can learn how to implement dialogues between multiple actors.

Here are some codes in Kai.spx:

onStart => {
	say "Where do you come from?", 2
	broadcast "1"
}

onMsg "2", => {
	say "What's the climate like in your country?", 3
	broadcast "3"
}

We call onStart and onMsg to listen events. onStart is called when the program is started. And onMsg is called when someone calls broadcast to broadcast a message.

When the program starts, Kai says Where do you come from?, and then broadcasts the message 1. Who will recieve this message? Let's see codes in Jaime.spx:

onMsg "1", => {
	say "I come from England.", 2
	broadcast "2"
}

Yes, Jaime recieves the message 1 and says I come from England.. Then he broadcasts the message 2. Kai recieves it and says What's the climate like in your country?.

The following procedures are very similar. In this way you can implement dialogues between multiple actors.

See spx: A Go+ 2D Game Engine for more details.

gsh: Go+ DevOps Tools

Yes, now you can write shell script in Go+. It supports all shell commands.

Let's create a file named example.gsh and write the following code:

mkdir "testgsh"

Don't need a go.mod file, just enter gop run ./example.gsh directly to run.

See gsh: Go+ DevOps Tools for more details.

How to install

Note: Requires go1.19 or later

on Windows

winget install goplus.gop

on Debian/Ubuntu

sudo bash -c ' echo "deb [trusted=yes] https://pkgs.goplus.org/apt/ /" > /etc/apt/sources.list.d/goplus.list'
sudo apt update
sudo apt install gop

on RedHat/CentOS/Fedora

sudo bash -c 'echo -e "[goplus]\nname=Go+ Repo\nbaseurl=https://pkgs.goplus.org/yum/\nenabled=1\ngpgcheck=0" > /etc/yum.repos.d/goplus.repo'
sudo yum install gop

on macOS/Linux (Homebrew)

Install via brew

$ brew install goplus

from source code

git clone https://github.com/goplus/gop.git
cd gop

# On mac/linux run:
./all.bash
# On Windows run:
all.bat

Go+ Applications

2D Games powered by Go+

Web Programming

DevOps Tools

Data Processing

IDE Plugins

Contributing

The Go+ project welcomes all contributors. We appreciate your help!

For more details, see Contributing & compiler design.

Give a Star! ⭐

If you like or are using Go+ to learn or start your projects, please give it a star. Thanks!