Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build module without verbs with a subpackage that has verbs #2148

Closed
matt2e opened this issue Jul 24, 2024 · 0 comments · Fixed by #2170
Closed

Unable to build module without verbs with a subpackage that has verbs #2148

matt2e opened this issue Jul 24, 2024 · 0 comments · Fixed by #2170
Assignees
Labels

Comments

@matt2e
Copy link
Collaborator

matt2e commented Jul 24, 2024

Summary:

  • Create a module, but don't define any verbs in it
  • Create a subpackage in that module and define a verb
  • Building the module will fail because main.go imports the module package but then doesn't use it

Detailed example:

Screenshot 2024-07-24 at 11 44 34 AM

outer.go:

package outer

import "ftl/outer/inner"

//ftl:data export
type Event struct {
	Value inner.EchoResponse
}

inner.go:

package inner

import (
	"context"
	"fmt"

	"github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK.
)

//ftl:data export
type EchoRequest struct {
	Name ftl.Option[string] `json:"name"`
}

//ftl:data export
type EchoResponse struct {
	Message string `json:"message"`
}

//ftl:verb export
func Echo(ctx context.Context, req EchoRequest) (EchoResponse, error) {
	return EchoResponse{Message: fmt.Sprintf("Hello, %s!", req.Name.Default("anonymous"))}, nil
}

Building this module generates .ftl/go/main/main.go:

// Code generated by FTL. DO NOT EDIT.
package main

import (
	"context"

	"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect"
	"github.com/TBD54566975/ftl/common/plugin"
	"github.com/TBD54566975/ftl/go-runtime/server"

	"ftl/outer"
	"ftl/outer/inner"
)

func main() {
	verbConstructor := server.NewUserVerbServer("outer",
		server.HandleCall(inner.Echo),
	)
	plugin.Start(context.Background(), "outer", verbConstructor, ftlv1connect.VerbServiceName, ftlv1connect.NewVerbServiceHandler)
}

Which results in the error:
./main.go:11:2: "ftl/outer" imported and not used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants