THRIFT-5685: Revert "THRIFT-5601: Fix forward typedef in go compiler"

This reverts commit b39370ec3bc96d201bbc82fbde136f98ae605ed1, and also
adds a test case for THRIFT-5685.
diff --git a/lib/go/test/ForwardTypedef.thrift b/lib/go/test/ForwardType.thrift
similarity index 85%
rename from lib/go/test/ForwardTypedef.thrift
rename to lib/go/test/ForwardType.thrift
index 4266b7a..0433c97 100644
--- a/lib/go/test/ForwardTypedef.thrift
+++ b/lib/go/test/ForwardType.thrift
@@ -17,17 +17,14 @@
  * under the License.
  */
 
-// https://issues.apache.org/jira/browse/THRIFT-5601
+// https://issues.apache.org/jira/browse/THRIFT-5685
 
-namespace go forwardtypedef
+namespace go forwardtypetest
 
 struct Struct {
-  1: optional Def foo
-  2: optional Exc bar
+  1: optional Exc foo
 }
 
-typedef i32 Def
-
 exception Exc {
   1: optional i32 code
 }
diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am
index c255a8e..cb8928b 100644
--- a/lib/go/test/Makefile.am
+++ b/lib/go/test/Makefile.am
@@ -62,7 +62,7 @@
 				ProcessorMiddlewareTest.thrift \
 				ClientMiddlewareExceptionTest.thrift \
 				ValidateTest.thrift \
-				ForwardTypedef.thrift
+				ForwardType.thrift
 	mkdir -p gopath/src
 	grep -v list.*map.*list.*map $(THRIFTTEST) | grep -v 'set<Insanity>' > ThriftTest.thrift
 	$(THRIFT) $(THRIFTARGS) -r IncludesTest.thrift
@@ -97,7 +97,7 @@
 	$(THRIFT) $(THRIFTARGS_SKIP_REMOTE) ProcessorMiddlewareTest.thrift
 	$(THRIFT) $(THRIFTARGS) ClientMiddlewareExceptionTest.thrift
 	$(THRIFT) $(THRIFTARGS) ValidateTest.thrift
-	$(THRIFT) $(THRIFTARGS) ForwardTypedef.thrift
+	$(THRIFT) $(THRIFTARGS) ForwardType.thrift
 	ln -nfs ../../tests gopath/src/tests
 	cp -r ./dontexportrwtest gopath/src
 	touch gopath
@@ -124,7 +124,7 @@
 				./gopath/src/processormiddlewaretest \
 				./gopath/src/clientmiddlewareexceptiontest \
 				./gopath/src/validatetest \
-				./gopath/src/forwardtypedef
+				./gopath/src/forwardtypetest
 	$(GO) test github.com/apache/thrift/lib/go/thrift
 	$(GO) test ./gopath/src/tests ./gopath/src/dontexportrwtest
 
@@ -155,6 +155,7 @@
 	DuplicateImportsTest.thrift \
 	ErrorTest.thrift \
 	EqualsTest.thrift \
+	ForwardType.thrift \
 	GoTagTest.thrift \
 	IgnoreInitialismsTest.thrift \
 	IncludesTest.thrift \
diff --git a/lib/go/test/ForwardTypedef.thrift b/lib/go/test/tests/forwardtype_test.go
similarity index 62%
copy from lib/go/test/ForwardTypedef.thrift
copy to lib/go/test/tests/forwardtype_test.go
index 4266b7a..99b7890 100644
--- a/lib/go/test/ForwardTypedef.thrift
+++ b/lib/go/test/tests/forwardtype_test.go
@@ -17,17 +17,25 @@
  * under the License.
  */
 
-// https://issues.apache.org/jira/browse/THRIFT-5601
+package tests
 
-namespace go forwardtypedef
+import (
+	"testing"
 
-struct Struct {
-  1: optional Def foo
-  2: optional Exc bar
-}
+	"github.com/apache/thrift/lib/go/test/gopath/src/forwardtypetest"
+	"github.com/apache/thrift/lib/go/thrift"
+)
 
-typedef i32 Def
+func TestForwardType(t *testing.T) {
+	// See https://issues.apache.org/jira/browse/THRIFT-5685
 
-exception Exc {
-  1: optional i32 code
+	const code = int32(1)
+	foo := &forwardtypetest.Struct{
+		Foo: &forwardtypetest.Exc{
+			Code: thrift.Pointer(code),
+		},
+	}
+	if got, want := foo.GetFoo().GetCode(), code; got != want {
+		t.Errorf("code got %v want %v", got, want)
+	}
 }