[
https://issues.apache.org/jira/browse/THRIFT-5353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17286682#comment-17286682
]
Yuxuan Wang commented on THRIFT-5353:
-------------------------------------
This is indeed a behavior change between the compiler 0.13.0 and 0.14.0, I'm
not yet tracked down which change caused this change.
But your way of doing it is also not the best. This will be fixed if you add
"namespace go zipkincore" to zipkincore.thrift (I'd suggest you do that for all
the thrift files):
{code}
$ git diff
diff --git a/thrift/zipkincore.thrift b/thrift/zipkincore.thrift
index 5bc93d7..626c3c3 100644
--- a/thrift/zipkincore.thrift
+++ b/thrift/zipkincore.thrift
@@ -18,6 +18,7 @@ namespace rb Zipkin
namespace php Jaeger.Thrift.Agent.Zipkin
namespace netstd Jaeger.Thrift.Agent.Zipkin
namespace lua jaeger.thrift.agent
+namespace go zipkincore
{code}
And also the sed replacement you are doing in the Makefile
(https://github.com/jaegertracing/jaeger/blob/cc3c8e3231ea9bb8d6a4185ab634a3009a46be1b/Makefile#L462-L463)
is totally unnecessary if you just add
',package_prefix="$(JAEGER_IMPORT_PATH)/thrift-gen/"' to your THRIFT_GO_ARGS.
That's the proper way of handling the go import paths of thrift includes.
> Namespace from type is ignored in generated code
> ------------------------------------------------
>
> Key: THRIFT-5353
> URL: https://issues.apache.org/jira/browse/THRIFT-5353
> Project: Thrift
> Issue Type: Bug
> Components: Go - Compiler
> Reporter: Juraci Paixão Kröhling
> Priority: Critical
>
> When using the Go compiler 0.14 with the Thrift spec below, the generated
> function does not use the namespace, causing compilation issues.
>
> {code}
> include "jaeger.thrift"
> include "zipkincore.thrift"
> namespace cpp jaegertracing.agent.thrift
> namespace java io.jaegertracing.agent.thrift
> namespace php Jaeger.Thrift.Agent
> namespace netstd Jaeger.Thrift.Agent
> namespace lua jaeger.thrift.agent
> service Agent {
> oneway void emitZipkinBatch(1: list<zipkincore.Span> spans)
> oneway void emitBatch(1: jaeger.Batch batch)
> }
> {code}
> Here's an excerpt of the generated Go code for this service:
> {code}
> // Code generated by Thrift Compiler (0.14.0). DO NOT EDIT.
> package agent
> import(
> "bytes"
> "context"
> "fmt"
> "time"
> "github.com/apache/thrift/lib/go/thrift"
> "github.com/jaegertracing/jaeger/thrift-gen/jaeger"
> )
> // (needed to ensure safety because of naive import list construction.)
> var _ = thrift.ZERO
> var _ = fmt.Printf
> var _ = context.Background
> var _ = time.Now
> var _ = bytes.Equal
> var _ = jaeger.GoUnusedProtection__
> type Agent interface {
> // Parameters:
> // - Spans
> EmitZipkinBatch(ctx context.Context, spans []*Span) (err error)
> // Parameters:
> // - Batch
> EmitBatch(ctx context.Context, batch *jaeger.Batch) (err error)
> }
> {code}
> In previous versions like 0.13, this is how the generated code looks like:
> {code}
> // Autogenerated by Thrift Compiler (0.13.0)
> // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
> package agent
> import(
> "bytes"
> "context"
> "reflect"
> "fmt"
> "github.com/apache/thrift/lib/go/thrift"
> "github.com/jaegertracing/jaeger/thrift-gen/jaeger"
> "github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
> )
> // (needed to ensure safety because of naive import list construction.)
> var _ = thrift.ZERO
> var _ = fmt.Printf
> var _ = context.Background
> var _ = reflect.DeepEqual
> var _ = bytes.Equal
> var _ = jaeger.GoUnusedProtection__
> var _ = zipkincore.GoUnusedProtection__
> type Agent interface {
> // Parameters:
> // - Spans
> EmitZipkinBatch(ctx context.Context, spans []*zipkincore.Span) (err error)
> // Parameters:
> // - Batch
> EmitBatch(ctx context.Context, batch *jaeger.Batch) (err error)
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)