Golang/Go+ interpreter. Base on igop v0.27.1
-
Run the Golang WITHOUT Golang compiler(150MB+)
-
Only 14MB after built and UPX -9
-
Go+ script file,
-
Golang file
-
Golang project
-
Golang project in an archive file of
*.tar.gz
,*.tar.xz
, ... -
Support shebang line, like
#!/usr/bin/bash
-
Go1.18~1.22 generics
-
main.go
in the subdirectory -
*.asm
file support
- Run golang files
- Execute code
- REPL
- Run as shell file
gos <PATH>
[-V | --debug]
-- <arguments>
Run a Go+ script, or a Golang project
Type | Default | ||
---|---|---|---|
<PATH> | String | File of Golang+ script, "*.gop". Directory of Golang project. |
|
-V --debug |
Boolean | false | Print the debug information. |
-- <arguments> | arguments for script. Be read os.Args in the script. |
Advanced options
-
--vendor
: The path of Golang dependency packages.gos run . --vendor=/path/to/vendor
-
-I | --import <NAME=PATH>
: The package to be imported.gos run . -I mathex=/path/to/mathx -I json2=/path/to/json2
-
-p | --plugin <path>
: (Only for linux)Load the "*.so" of golang plugingos run . --plugin /path/to/plugin1.so --plugin /path/to/plugin2.so
Run a file with *.gop
、*.go
.go
must bepackage main
and includesfunc main()
Run
gos /path/to/file.gop
Run in the working directory
cd /path/to
gos file.gop
With arguments
gos file.gop -- --abc 123 --def
- Must be
package main
and Onefunc main()
in the working directory - The
gop
file implicitly contains afunc main()
, which is why only onegop
file is allowed.
/path/to/
- func.go
- func.gop
- main.go
Run
gos /path/to/examples/example3
Run in the working directory
cd /path/to/examples/example3
gos .
With arguments
gos . -- --abc 123 --def
- No allowed
*.gop
go.mod
MUST be in the working directoryvendor/modules.txt
MUST be in the working directory, if you need 3rd-party modules
/path/to
- main.go
- func/
- func.go
- go.mod
- vensor/ <--- if you need 3rd-party modules
- modules.txt
A packaging of project
Supported archive format. When it runs, it'll actually be extract to examples/__FILE_NAME__
- tar.gz
- tar.bzip2
- tar.xz
- zip
- tar
Run an archive
gos examples/example5.tar.gz
With arguments
gos examples2/2.go -- --abc 123 --def
gos
[-s | --script <code>]
[--debug]
-- <script arguments>
Execute script code from StdIn or the argument of "--script"
Type | Default | ||
---|---|---|---|
-V --debug |
false | Print the debug information. | |
-s --script <code> |
String | The Golang/Go+ script as string | |
-- <arguments> | arguments for script. Be read os.Args in the script. |
gos < example2/1.gop
cat example2/1.gop | gos
echo "i := 1+2; println(i)" | gos
printf "i := 1+2 \n println(i)" | gos
$ gos -s "i := 1+2; println(i)"
Use
;
(semicolons) instead of carriage returns
gos repl
A Go+ Read Eval Print Loop
Online: https://repl.goplus.org/
Shebang line:
script.sh
///usr/bin/true; exec /usr/bin/gos -- "$0" "$@"
import "os"
import "fmt"
fmt.Printf("%v", os.Args)
The first two lines are important
Run
$ chmod +x ./script.sh
$ ./scrpit.sh --argument1 --argument2
$ sh ./script.sh --argument1 --argument2
[./script.sh.gop --argument1 --argument2]
go install github.com/goplus/igop/cmd/qexp@latest
cd pkgs
qexp -outdir . -filename go_export github.com/inconshreveable/mousetrap github.com/spf13/pflag github.com/spf13/cobra go.uber.org/multierr gopkg.in/yaml.v3 github.com/pkg/errors
cd ..
go build