# Getting started (/docs/getting-started)

This page assumes marmot is installed and `marmot doctor` reports no problems. If not, see
[Install](/docs/install).

## Build and run [#build-and-run]

marmot works on any Go module. Make one:

```sh
mkdir hello && cd hello
go mod init hello
```

```go title="main.go"
package main

import "fmt"

func main() {
	name := "marmot"
	fmt.Println("hello,", name)
}
```

Run it, then build an executable. The commands are the go command's, with `marmot` in front:

<Tabs items={["marmot","go"]}>
<Tab value="marmot">
```sh
marmot run main.go
marmot build -o hello .
./hello
```
</Tab>

<Tab value="go">
```sh
go run main.go
go build -o hello .
./hello
```
</Tab>
</Tabs>

The first build compiles the standard library packages the program uses and caches them, so
later builds are fast. For the binary you ship, use release mode:

```sh
marmot build -release -o hello .
```

## Read an error [#read-an-error]

Change `Println` to `Printn` and build again. marmot shows the source, marks the exact span,
says what is wrong there, and suggests a fix:

<Shot name="error-short" alt="marmot build: error M0002, undefined fmt.Printn, with help: use fmt.Println and a diff" />

The fix is marked `check it` because it is a guess based on the name. `marmot fix -all` applies
it; plain `marmot fix` applies only fixes that are always safe, such as removing an unused
import. `marmot explain M0002` describes the error with an example.

Errors that involve more than one place point at each of them:

<Shot name="error-interface" alt="marmot build: error M0014, Square does not implement Shape, with labels on the interface, the method with a pointer receiver and the assignment, and a fix that adds &" />

## Test [#test]

`marmot test` runs package tests like `go test`. On a terminal each failure comes first, at the
line of its `t.Error` or `t.Fatal`:

<Shot name="test" alt="marmot test showing a failing test at the line of its t.Errorf, then every test with its status and time" />

## Next [#next]

- [Build modes](/docs/build-modes): dev and release, and what each is for.
- [Commands](/docs/commands): every command, with its flags.
- [Diagnostics](/docs/diagnostics): human, plain and JSON output, and every error code.