specifying go build main package location

my main.go file is located in cmd/main.go
apparently the flyctl returns an error stating that it could not find the main file with the package main
I may want to specify something like this go build -o /layers/paketo-buildpacks_go-build/targets/bin -buildmode pie -trimpath cmd/main.go
that’s the only thing that breaks the build.

I don’t know much about the fly.toml, perhaps there are configurations/documentations about it, then let me know
fyi: default auto-generated fly.toml is used

Paketo Buildpack for Go Build 2.0.3
  Executing build process
    Running 'go build -o /layers/paketo-buildpacks_go-build/targets/bin -buildmode pie -trimpath .'
failed to execute 'go build': exit status 1
      Failed after 72ms
        go: no main packages to build

I encountered the same problem as you.
I fixed it as per the following documentation: https://paketo.io/docs/howto/go

You need to specify the directory with BP_GO_BUILD_IMPORT_PATH flag where the required imports are located. In this case ‘cmd’.
If the problem persists. Try with the other build flags in the documentation above.

[build]
   builder = "paketobuildpacks/builder:base"
   buildpacks = ["gcr.io/paketo-buildpacks/go"]
  
   [build.args]
     BP_GO_BUILD_IMPORT_PATH="cmd"
2 Likes