From bcf367c3b6c7b6b79a464043237ffadb528621fb Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Sat, 15 Jun 2024 15:30:21 +1000 Subject: [PATCH] =?UTF-8?q?fix:=20don=E2=80=99t=20import=20ftl=20twice=20i?= =?UTF-8?q?f=20pubsub=20and=20something=20else=20requires=20ftl=20(#1795)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #1794 --- go-runtime/compile/build.go | 13 ++++--------- .../external_module.go.tmpl | 4 ---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/go-runtime/compile/build.go b/go-runtime/compile/build.go index bb7bc75ee5..0a98a235f9 100644 --- a/go-runtime/compile/build.go +++ b/go-runtime/compile/build.go @@ -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() @@ -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 { diff --git a/go-runtime/compile/external-module-template/_ftl/go/modules/{{ range .NonMainModules }}{{ push .Name . }}{{ end }}/external_module.go.tmpl b/go-runtime/compile/external-module-template/_ftl/go/modules/{{ range .NonMainModules }}{{ push .Name . }}{{ end }}/external_module.go.tmpl index 06ce2d82b0..a7c7c1b2de 100644 --- a/go-runtime/compile/external-module-template/_ftl/go/modules/{{ range .NonMainModules }}{{ push .Name . }}{{ end }}/external_module.go.tmpl +++ b/go-runtime/compile/external-module-template/_ftl/go/modules/{{ range .NonMainModules }}{{ push .Name . }}{{ end }}/external_module.go.tmpl @@ -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