# marmot cgo (/docs/commands/cgo)

<!-- Generated by scripts/gen.mjs from `marmot cgo --help` and scripts/commands.mjs. Do not edit by hand. -->

Run cgo on the file's package and list each C function that the file calls, with its C prototype and how the call is made. A fast call is direct, because the C function calls nothing. A bracketed call releases the goroutine's P while C runs, because C may block or call back into Go. The list also shows the C types and variables that the file uses, with their Go definitions. It shows the file's //export functions as C sees them, and the package's #cgo flags. -go prints the file's Go code as marmot compiles it, -c its C wrappers.

```text title="Usage"
marmot cgo show FILE.go [flags]
```

## Examples [#examples]

```sh
marmot cgo show main.go
marmot cgo show -go db.go
marmot cgo show -json db.go
```

`marmot cgo show FILE.go` lists each C function that the file calls, with its C prototype and its
call path:

- **fast**: the C function calls nothing, so the call is direct.
- **bracketed**: the goroutine releases its P while C runs, because C can block or call back into Go.

It also shows the C types and variables that the file uses, its `//export` functions and the
`#cgo` flags of the package. `-go` prints the Go code that marmot compiles, and `-c` the C wrappers.

## Flags [#flags]

Flags take one dash or two: `-release` and `--release` are the same.

| Flag | Meaning |
| --- | --- |
| `-c` | print the file's C wrappers |
| `-color string` | color in human output: auto, always or never (NO_COLOR turns auto off) (default "auto") |
| `-go` | print the file's Go code as marmot compiles it |
| `-json` | machine readable output: JSON Lines on stderr (also $MARMOT_OUTPUT=json, and the default under coding agents) |

## Full help [#full-help]

```text title="marmot cgo --help"
Run cgo on the file's package and list each C function that the file calls, with its C prototype and how the call is made. A fast call is direct, because the C function calls nothing. A bracketed call releases the goroutine's P while C runs, because C may block or call back into Go. The list also shows the C types and variables that the file uses, with their Go definitions. It shows the file's //export functions as C sees them, and the package's #cgo flags. -go prints the file's Go code as marmot compiles it, -c its C wrappers.

Usage:
  marmot cgo show FILE.go [flags]

Examples:
marmot cgo show main.go
marmot cgo show -go db.go
marmot cgo show -json db.go

Flags:
      --c              print the file's C wrappers
      --color string   color in human output: auto, always or never (NO_COLOR turns auto off) (default "auto")
      --go             print the file's Go code as marmot compiles it
  -h, --help           help for cgo
      --json           machine readable output: JSON Lines on stderr (also $MARMOT_OUTPUT=json, and the default under coding agents)
```