Hey @Cowboy127 – Great question, this has now been clarified in the docs!
For Encore apps you don’t write a main function, because Encore automatically generates it for you to initialize all your infrastructure resources when the application starts up. You just define each service as a Go package with an API definition. (See docs)
If you want to customize the service initialization behavior, you can use a service struct. (See docs)
So for your existing project, if it’s a single service application you can simply rename the main function to something else. Just make sure to define at least 1 API endpoint in the service in order for Encore to understand that it should be created as a service.
E.g. hello.go would look like this, and Encore will create this as a service (hello) with an API endpoint (Ping).
package hello // service name
//encore:api public
func Ping(ctx context.Context, params *PingParams) (*PingResponse, error) {
msg := fmt.Sprintf("Hello, %s!", params.Name)
return &PingResponse{Message: msg}, nil
}