github.com/goreleaser/goreleaser@v1.25.1/www/docs/errors/no-main.md (about)

     1  # Build does not contain a main function
     2  
     3  This usually happens if you're trying to build a library or if you didn't setup
     4  the `builds.main` section in your `.goreleaser.yaml` and your `main.go` is not
     5  in the root directory.
     6  
     7  Here's an example error:
     8  
     9  ```sh
    10     тип build failed after 0.11s error=build for foo does not contain a main function
    11  
    12  Learn more at https://goreleaser.com/errors/no-main
    13  ```
    14  
    15  ## If you are building a library
    16  
    17  Add something like this to your config:
    18  
    19  ```yaml
    20  # .goreleaser.yaml
    21  builds:
    22    - skip: true
    23  ```
    24  
    25  ## If your `main.go` is not in the root directory
    26  
    27  Add something like this to your config:
    28  
    29  ```yaml
    30  # .goreleaser.yaml
    31  builds:
    32    - main: ./path/to/your/main/pkg/
    33  ```
    34  
    35  For more info, check the [builds documentation](/customization/build/).
    36  
    37  ## If you ran goreleaser outside the root of the project
    38  
    39  Run goreleaser in the root of the project.
    40  
    41  ## If you are building in `plugin`, `c-shared` or `c-archive` build modes
    42  
    43  You can set `no_main_check` to `true`:
    44  
    45  ```yaml
    46  # .goreleaser.yaml
    47  builds:
    48    - main: ./path/...
    49      buildmode: plugin
    50      no_main_check: true
    51  ```
    52  
    53  For more info, check the [builds documentation](/customization/build/).