Sylwester Lachiewicz created THRIFT-6388:
--------------------------------------------
Summary: Go generator writes an invalid package name for an IDL
file whose name contains a hyphen
Key: THRIFT-6388
URL: https://issues.apache.org/jira/browse/THRIFT-6388
Project: Thrift
Issue Type: Bug
Components: Go - Compiler
Reporter: Sylwester Lachiewicz
Without a {{namespace go}}, the Go generator names the package after the IDL
file. When the file name contains a hyphen, the package name is not a valid Go
identifier. The compiler still exits 0:
{noformat}
$ cat a-b.thrift
struct S { 1: i32 x }
$ thrift --gen go a-b.thrift; echo $?
0
$ head -3 gen-go/a-b/a-b.go | tail -1
package a-b
$ gofmt -l gen-go
gen-go/a-b/GoUnusedProtection__.go:3:10: expected ';', found '-'
{noformat}
Apache Accumulo's
[compaction-coordinator.thrift|https://github.com/apache/accumulo/blob/main/core/src/main/thrift/compaction-coordinator.thrift]
declares namespaces for java and cpp only and hits this. Reproduced on master.
The generator could replace characters that are not valid in a Go identifier
with {{_}}, as other generators do for reserved words. Alternatively it could
fail with an error that points at {{namespace go}}. Either is better than
exiting 0 with code that does not compile.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)