Categorycodeberg.org/anaseto/goal
repositorypackage
1.4.0
Repository: https://codeberg.org/anaseto/goal.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

Goal

Goal is an embeddable array programming language with a bytecode interpreter, written in Go. The command line intepreter can execute scripts or run in interactive mode. Goal shines the most in common scripting tasks, like handling columnar data or text processing. It is also suitable for exploratory programming.

Install

To install the command line interpreter, you only need to have the go compiler installed (Go 1.22 or later required). There are no extra dependencies.

You can then build the intepreter with:

go build ./cmd/goal

You should now have a working goal executable in the current directory. Use the --help option for command-line usage.

Running goal without arguments opens the REPL. For a better experience using the REPL with the usual keyboard shortcuts, you can install the readline wrapper rlwrap program and then use instead rlwrap goal. The rlwrap program is available as a package on most systems.

SIMD optimization. On amd64, various operations will use vectorized SIMD assembly implementations by default, requiring SSE CPU extensions up to SSE4.2, representing a subset of the available instructions when GOAMD64 is set to v2. You may disable those optimizations by passing the -tags nosse4 option to the build command.

Extensions. The default build only includes the os extension package. The -tags full option enables all standard extension packages (including extra math functions). For more fine-grained control, see instructions in cmd/goal directory.

Links

Examples

Aside from the examples found in the documentation, there are various places with code written in Goal:

  • The examples directory contains AoC solutions and a few other short scripts.
  • The lib directory contains various library utilities. You might want to add it to the GOALLIB environment variable to simplify import paths.
  • The testdata/scripts directory contains various example scripts used in regression testing; they come along an expected result after a /RESULT: comment.
  • The scripts directory contains a few code generation scripts.

Here's how a Goal script looks like:

/ Handle command-line arguments: script name + optional file.
(2<#ARGS)and:error"USAGE: goal wordstats.goal [file]"
/ Read STDIN or filename given by last argument; lowercase everything.
src:_ 'read?[1=#ARGS;STDIN;*|ARGS]
/ Get all words (Unicode letters + dashes).
words:rx/[\p{L}-]+/[src;-1]
/ Print number of words; number of distinct words; five most frequent words.
say(#words;#dw:?words;5@!>dw!=%words)

See the tutorial for detailed explanations on a similar example with syntax highlighting!

Tooling

  • ari: interactive programming environment built on top of Goal with a dedicated SQL mode (by @semperos).
  • goal2html: html markup generation for Goal source.
  • gw: derived interpreter with sqlite support (by @bleedsa).
  • jupyter kernel for Goal (by @semperos).
  • vim-goal : vim files for Goal.

Community

Contribute

User testing and bug reports are welcome! Feel free to open an issue, send a pull request, or send a patch by email.

See the implementation notes to get started about the internals. You might want to check problems.md and old issues before submitting a new issue.