Skip to content

Commit

Permalink
fix: don’t import ftl twice if pubsub and something else requires ftl (
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e authored Jun 15, 2024
1 parent fc13221 commit bcf367c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
13 changes: 4 additions & 9 deletions go-runtime/compile/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ var scaffoldFuncs = scaffolder.FuncMap{
case *schema.Optional, *schema.Unit:
imports["github.com/TBD54566975/ftl/go-runtime/ftl"] = ""

case *schema.Topic:
if n.IsExported() {
imports["github.com/TBD54566975/ftl/go-runtime/ftl"] = ""
}
default:
}
return next()
Expand Down Expand Up @@ -368,15 +372,6 @@ var scaffoldFuncs = scaffolder.FuncMap{
}
return out
},
"needsFTLImport": func(m *schema.Module) bool {
for _, d := range m.Decls {
if topic, ok := d.(*schema.Topic); ok && topic.IsExported() {
// uses ftl.Topic(...) function calls
return true
}
}
return false
},
}

func schemaType(t schema.Type) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import (

"github.com/TBD54566975/ftl/go-runtime/ftl/reflection"
{{- end}}
{{- if $ | needsFTLImport }}

"github.com/TBD54566975/ftl/go-runtime/ftl"
{{- end}}
)

var _ = context.Background
Expand Down

0 comments on commit bcf367c

Please sign in to comment.