DEV Community

flisk
flisk

Posted on

Goose Lang 101: Install the Compiler and Print One Line

Part 2 of Goose lang and Flisk.sh 101. The Flisk CLI stays closed.

Goose is a whole-program compiler. It writes one C file and can run that C inside its own process through TinyCC. There is no package manager step and no go.mod.

Install a release, do not clone yet

Prebuilt compilers are on the releases page. Unpack one and put that directory on PATH. The compiler finds its standard library beside itself. Build cache goes under ~/.goose, or GOOSE_HOME if you set it.

On macOS, a downloaded archive will not run until you clear quarantine on the unpacked directory:

xattr -dr com.apple.quarantine /path/to/unpacked-goose
Enter fullscreen mode Exit fullscreen mode

Check you got the language, not the agent:

which goose
goose 2>&1 | head -n 20
Enter fullscreen mode Exit fullscreen mode

You want a compiler that accepts a .goose file. If the help text is about LLM providers, rename or remove that binary from PATH and open a new shell.

Linux, before the first run:

sudo apt-get install -y libc6-dev
# or: sudo dnf install glibc-devel
Enter fullscreen mode Exit fullscreen mode

macOS:

xcode-select --install
Enter fullscreen mode Exit fullscreen mode

goose build also needs a C compiler: gcc or clang on Linux and macOS, Visual Studio 2022 or clang on Windows. Threads cannot use the in-process TinyCC path. This part has no threads, so goose hello.goose is enough.

Hello

mkdir -p ~/src/goose-flisk-101 && cd ~/src/goose-flisk-101
Enter fullscreen mode Exit fullscreen mode

hello.goose:

fn main() {
    print("hello, goose");
}
Enter fullscreen mode Exit fullscreen mode

Run it in-process. No verb, or goose run, does the same thing. goose check only typechecks.

goose hello.goose
goose check hello.goose
Enter fullscreen mode Exit fullscreen mode

Expected:

hello, goose
Enter fullscreen mode Exit fullscreen mode

print takes any number of arguments, renders each, and writes one line. There is no format string.

fn main() {
    print("answer=", 42, " ratio=", 0.75, " yes=", 3 > 2);
}
Enter fullscreen mode Exit fullscreen mode

Build a binary with a name that is not goose

The compiler is already called goose. Name the program something else or the next part will call the compiler by accident.

goose build -o ./total hello.goose
./total
Enter fullscreen mode Exit fullscreen mode

goose build --dry-run hello.goose prints the C compile it would run. goose toolchain says which C compiler it found. Intermediates live under ~/.goose.

If goose build cannot find a C compiler, stop and install one. Do not switch to the AI-agent Goose to "fix the build."

Editor, optional

The release archive includes a VS Code extension. With the compiler on PATH:

code --install-extension vscode/goose-language.vsix
Enter fullscreen mode Exit fullscreen mode

goose lsp is the language server: diagnostics, hover, go to definition, completion, rename. Skip this if you are in a hurry. The terminal loop above is the 101.

What this part did not do

It did not listen on a port. It did not read PORT. It did not answer GET /health. Flisk cannot route a process that exits after one print. That is fine. Part 3 stays in the language. Part 4 starts a real HTTP service in a language Flisk already knows.

Official tour, when you want the long version: docs/tutorial.md in the Goose repo, and samples/01_tour.goose.

Top comments (0)