# Getting started

Source: https://libtmux.org/en/go/latest/guides/getting-started/

> Run a complete program with this language library.

Use the [`tmux`](<https://libtmux.org/en/go/latest/reference/#tmux>) package to create sessions, send input and read pane output from Go.
The [complete capture program](https://libtmux.org/en/go/latest/examples/capture-pane-output/) includes
imports, its entry point, project files, dependency setup and a run command.

## Run the smallest thing that proves it works

Open that example in an empty directory and save the files using their displayed
names. Its setup pins the library revision that was used to execute the program.
It needs tmux on `PATH` and the native tools named on the example page.

The program creates a private server, sends a command, waits for the complete
line `libtmux capture ready`, then cleans up. A timeout or command failure is
reported. It does not need an existing tmux session.

## What just happened

[`Pane.Capture`](<https://libtmux.org/en/go/latest/reference/tmux-pane-capture/>) takes a [`tmux.CapturePaneRequest`](<https://libtmux.org/en/go/latest/reference/tmux-capturepanerequest/>). Use `Start` and [`End`](<https://libtmux.org/en/go/latest/reference/tmux-capturepanerequest-end/>) to choose
a range; [`tmux.CaptureBoundary`](<https://libtmux.org/en/go/latest/reference/tmux-captureboundary/>) reaches the corresponding history or screen
boundary. The complete program reads the visible screen, compares full lines
and stops when its context expires.

## Connect to an existing server

Use the [complete attach program](https://libtmux.org/en/go/latest/guides/attaching-to-tmux/) to select an existing
socket and find the `work` session. That example leaves tmux running; its
launcher owns setup and cleanup for trying it safely.

## Create and inspect the hierarchy

The [complete hierarchy programs](https://libtmux.org/en/go/latest/concepts/server-session-window-pane/)
create a session, add a window, split a pane and list the resulting objects.
They also show how captured records differ from a fresh read after a rename.

## Where to go next

[Sending keys](https://libtmux.org/en/go/latest/guides/sending-keys/) explains input, and
[Capturing output](https://libtmux.org/en/go/latest/guides/capturing-output/) explains completion.
[Querying and filtering](https://libtmux.org/en/go/latest/guides/querying-and-filtering/) selects a target.
