2021-11-29 21:41:31 -03:00
# Build does not contain a main function
2022-05-03 05:48:55 -07:00
This usually happens if you're trying to build a library or if you didn't setup the `builds.main` section in your `.goreleaser.yaml` and your `main.go` is not in the root folder.
2021-11-29 21:41:31 -03:00
Here's an example error:
```sh
⨯ build failed after 0.11s error=build for foo does not contain a main function
Learn more at https://goreleaser.com/errors/no-main
```
## If you are building a library
Add something like this to your config:
```yaml
2021-12-23 01:52:01 +01:00
# .goreleaser.yaml
2021-11-29 21:41:31 -03:00
builds:
- skip: true
```
## If your `main.go` is not in the root folder
Add something like this to your config:
```yaml
2021-12-23 01:52:01 +01:00
# .goreleaser.yaml
2021-11-29 21:41:31 -03:00
builds:
- main: ./path/to/your/main/pkg/
```
For more info, check the [builds documentation ](/customization/build/ ).
2022-06-23 19:39:48 -06:00
## If you ran goreleaser outside the root of the project
Run goreleaser in the root of the project.
2023-01-20 23:47:08 -03:00
## If you are building in `plugin`, `c-shared` or `c-archive` build modes
You can set `no_main_check` to `true` :
```yaml
# .goreleaser.yaml
builds:
- main: ./path/...
buildmode: plugin
no_main_check: true
```
For more info, check the [builds documentation ](/customization/build/ ).