THRIFT-5358: Add go.mod file to root directory
Client: go
This unblocks the development under go 1.16+, which starts to complain
when there's no go.mod file in any of the directories.
The current approach is certainly not the best solution ever, for
example it does not run the tests under lib/go/test/tests but copy them
into lib/go/test/gopath/src/sometest and run them there instead, but
those improvements can be done in the future in follow up PRs and this
should be a good enough first step to unblock developments.
diff --git a/lib/go/Makefile.am b/lib/go/Makefile.am
index 2971cfd..d7f9b27 100644
--- a/lib/go/Makefile.am
+++ b/lib/go/Makefile.am
@@ -31,13 +31,13 @@
@echo '##############################################################'
check-local:
- GOPATH=`pwd` $(GO) test -race ./thrift
+ $(GO) test -mod=mod -race ./thrift
clean-local:
$(RM) -rf pkg
all-local:
- GOPATH=`pwd` $(GO) build ./thrift
+ $(GO) build -mod=mod ./thrift
EXTRA_DIST = \
thrift \
diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am
index 4be652e..a5d0797 100644
--- a/lib/go/test/Makefile.am
+++ b/lib/go/test/Makefile.am
@@ -17,7 +17,7 @@
# under the License.
#
-THRIFTARGS = -out gopath/src/ --gen go:thrift_import=thrift$(COMPILER_EXTRAFLAG)
+THRIFTARGS = -out gopath/src/ --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/lib/go/test/gopath/src/$(COMPILER_EXTRAFLAG)
THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
# Thrift for GO has problems with complex map keys: THRIFT-2063
@@ -77,40 +77,37 @@
$(THRIFT) $(THRIFTARGS) -r DuplicateImportsTest.thrift
$(THRIFT) $(THRIFTARGS) EqualsTest.thrift
$(THRIFT) $(THRIFTARGS) ConflictArgNamesTest.thrift
- GOPATH=`pwd`/gopath $(GO) get github.com/golang/mock/gomock || true
- sed -i 's/\"context\"/\"golang.org\/x\/net\/context\"/g' gopath/src/github.com/golang/mock/gomock/controller.go || true
- GOPATH=`pwd`/gopath $(GO) get github.com/golang/mock/gomock
- ln -nfs ../../../thrift gopath/src/thrift
ln -nfs ../../tests gopath/src/tests
cp -r ./dontexportrwtest gopath/src
touch gopath
check: gopath
- GOPATH=`pwd`/gopath $(GO) build \
- includestest \
- binarykeytest \
- servicestest \
- typedeffieldtest \
- refannotationfieldstest \
- errortest \
- namestest \
- initialismstest \
- dontexportrwtest \
- ignoreinitialismstest \
- unionbinarytest \
- conflictnamespacetestsuperthing \
- conflict/context/conflict_service-remote \
- servicestest/container_test-remote \
- duplicateimportstest \
- equalstest \
- conflictargnamestest
- GOPATH=`pwd`/gopath $(GO) test thrift tests dontexportrwtest
+ $(GO) build -mod=mod \
+ ./gopath/src/includestest \
+ ./gopath/src/binarykeytest \
+ ./gopath/src/servicestest \
+ ./gopath/src/typedeffieldtest \
+ ./gopath/src/refannotationfieldstest \
+ ./gopath/src/errortest \
+ ./gopath/src/namestest \
+ ./gopath/src/initialismstest \
+ ./gopath/src/dontexportrwtest \
+ ./gopath/src/ignoreinitialismstest \
+ ./gopath/src/unionbinarytest \
+ ./gopath/src/conflictnamespacetestsuperthing \
+ ./gopath/src/conflict/context/conflict_service-remote \
+ ./gopath/src/servicestest/container_test-remote \
+ ./gopath/src/duplicateimportstest \
+ ./gopath/src/equalstest \
+ ./gopath/src/conflictargnamestest
+ $(GO) test -mod=mod github.com/apache/thrift/lib/go/thrift
+ $(GO) test -mod=mod ./gopath/src/tests ./gopath/src/dontexportrwtest
clean-local:
$(RM) -r gopath ThriftTest.thrift gen-go
client: stubs
- $(GO) run TestClient.go
+ $(GO) run -mod=mod TestClient.go
EXTRA_DIST = \
dontexportrwtest \
diff --git a/lib/go/test/fuzz/Makefile.am b/lib/go/test/fuzz/Makefile.am
index 41f8b45..1852c4a 100644
--- a/lib/go/test/fuzz/Makefile.am
+++ b/lib/go/test/fuzz/Makefile.am
@@ -18,19 +18,11 @@
#
gopathfuzz: $(THRIFT) fuzz.go
- $(THRIFT) -r --gen go ../../../../tutorial/tutorial.thrift
- GO111MODULE=on go mod init fuzz
- GO111MODULE=on cd gen-go/shared && go mod init shared
- GO111MODULE=on cd gen-go/tutorial && go mod init tutorial
- GO111MODULE=on go mod edit -replace shared=./gen-go/shared
- GO111MODULE=on go mod edit -replace tutorial=./gen-go/tutorial
- GO111MODULE=on cd ../../../../lib/go/thrift && go mod init github.com/apache/thrift/lib/go/thrift
- GO111MODULE=on go mod edit -replace github.com/apache/thrift/lib/go/thrift=../../../../lib/go/thrift
- GO111MODULE=on go mod tidy
+ $(THRIFT) -r --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/lib/go/test/fuzz/gen-go/$(COMPILER_EXTRAFLAG) ../../../../tutorial/tutorial.thrift
touch gopathfuzz
check: gopathfuzz
- go test -tags gofuzz
+ go test -mod=mod -tags gofuzz
clean-local:
$(RM) -r gopathfuzz gen-go
diff --git a/lib/go/test/fuzz/fuzz.go b/lib/go/test/fuzz/fuzz.go
index 388524c..69b3e4e 100644
--- a/lib/go/test/fuzz/fuzz.go
+++ b/lib/go/test/fuzz/fuzz.go
@@ -24,10 +24,10 @@
import (
"context"
"fmt"
- "shared"
"strconv"
- "tutorial"
+ "github.com/apache/thrift/lib/go/test/fuzz/gen-go/shared"
+ "github.com/apache/thrift/lib/go/test/fuzz/gen-go/tutorial"
"github.com/apache/thrift/lib/go/thrift"
)
diff --git a/lib/go/test/tests/binary_key_test.go b/lib/go/test/tests/binary_key_test.go
index aa96193..511c246 100644
--- a/lib/go/test/tests/binary_key_test.go
+++ b/lib/go/test/tests/binary_key_test.go
@@ -20,8 +20,9 @@
package tests
import (
- "binarykeytest"
"testing"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/binarykeytest"
)
func TestBinaryMapKeyGeneratesString(t *testing.T) {
diff --git a/lib/go/test/tests/client_error_test.go b/lib/go/test/tests/client_error_test.go
index 8d720ff..64339dc 100644
--- a/lib/go/test/tests/client_error_test.go
+++ b/lib/go/test/tests/client_error_test.go
@@ -22,11 +22,12 @@
import (
"context"
"errors"
- "errortest"
"testing"
- "thrift"
"github.com/golang/mock/gomock"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/errortest"
+ "github.com/apache/thrift/lib/go/thrift"
)
// TestCase: Comprehensive call and reply workflow in the client.
diff --git a/lib/go/test/tests/conflict_arg_names_test.go b/lib/go/test/tests/conflict_arg_names_test.go
index 9279151..b9049a1 100644
--- a/lib/go/test/tests/conflict_arg_names_test.go
+++ b/lib/go/test/tests/conflict_arg_names_test.go
@@ -20,7 +20,7 @@
package tests
import (
- "conflictargnamestest"
+ "github.com/apache/thrift/lib/go/test/gopath/src/conflictargnamestest"
)
// We just want to make sure that the conflictargnamestest package compiles.
diff --git a/lib/go/test/tests/encoding_json_test.go b/lib/go/test/tests/encoding_json_test.go
index 12d4566..cda8ad9 100644
--- a/lib/go/test/tests/encoding_json_test.go
+++ b/lib/go/test/tests/encoding_json_test.go
@@ -23,7 +23,8 @@
"encoding"
"encoding/json"
"testing"
- "thrifttest"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/thrifttest"
)
func TestEnumIsTextMarshaller(t *testing.T) {
diff --git a/lib/go/test/tests/equals_test.go b/lib/go/test/tests/equals_test.go
index deecb77..3bd14b6 100644
--- a/lib/go/test/tests/equals_test.go
+++ b/lib/go/test/tests/equals_test.go
@@ -20,9 +20,10 @@
package tests
import (
- "equalstest"
"strconv"
"testing"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/equalstest"
)
func TestEquals(t *testing.T) {
diff --git a/lib/go/test/tests/gotag_test.go b/lib/go/test/tests/gotag_test.go
index 4cbea56..b7ad17b 100644
--- a/lib/go/test/tests/gotag_test.go
+++ b/lib/go/test/tests/gotag_test.go
@@ -20,9 +20,10 @@
package tests
import (
- "gotagtest"
"reflect"
"testing"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/gotagtest"
)
func TestDefaultTag(t *testing.T) {
diff --git a/lib/go/test/tests/ignoreinitialisms_test.go b/lib/go/test/tests/ignoreinitialisms_test.go
index 3cd5f65..c7012dd 100644
--- a/lib/go/test/tests/ignoreinitialisms_test.go
+++ b/lib/go/test/tests/ignoreinitialisms_test.go
@@ -20,9 +20,10 @@
package tests
import (
- "ignoreinitialismstest"
"reflect"
"testing"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/ignoreinitialismstest"
)
func TestIgnoreInitialismsFlagIsHonoured(t *testing.T) {
diff --git a/lib/go/test/tests/initialisms_test.go b/lib/go/test/tests/initialisms_test.go
index 40923d2..e6b4f63 100644
--- a/lib/go/test/tests/initialisms_test.go
+++ b/lib/go/test/tests/initialisms_test.go
@@ -20,9 +20,10 @@
package tests
import (
- "initialismstest"
"reflect"
"testing"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/initialismstest"
)
func TestThatCommonInitialismsAreFixed(t *testing.T) {
diff --git a/lib/go/test/tests/multiplexed_protocol_test.go b/lib/go/test/tests/multiplexed_protocol_test.go
index 4fb6f4f..a5975b7 100644
--- a/lib/go/test/tests/multiplexed_protocol_test.go
+++ b/lib/go/test/tests/multiplexed_protocol_test.go
@@ -21,11 +21,12 @@
import (
"context"
- "multiplexedprotocoltest"
"net"
"testing"
- "thrift"
"time"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/multiplexedprotocoltest"
+ "github.com/apache/thrift/lib/go/thrift"
)
func FindAvailableTCPServerPort() net.Addr {
diff --git a/lib/go/test/tests/names_test.go b/lib/go/test/tests/names_test.go
index 90b63a3..5094bcb 100644
--- a/lib/go/test/tests/names_test.go
+++ b/lib/go/test/tests/names_test.go
@@ -20,9 +20,10 @@
package tests
import (
- "namestest"
"reflect"
"testing"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/namestest"
)
func TestThatAttributeNameSubstituionDoesNotOccur(t *testing.T) {
diff --git a/lib/go/test/tests/one_way_test.go b/lib/go/test/tests/one_way_test.go
index 010e3bb..295dc1f 100644
--- a/lib/go/test/tests/one_way_test.go
+++ b/lib/go/test/tests/one_way_test.go
@@ -23,10 +23,11 @@
"context"
"fmt"
"net"
- "onewaytest"
"testing"
- "thrift"
"time"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/onewaytest"
+ "github.com/apache/thrift/lib/go/thrift"
)
func findPort() net.Addr {
diff --git a/lib/go/test/tests/optional_fields_test.go b/lib/go/test/tests/optional_fields_test.go
index 7e240e6..39fb1b5 100644
--- a/lib/go/test/tests/optional_fields_test.go
+++ b/lib/go/test/tests/optional_fields_test.go
@@ -22,10 +22,12 @@
import (
"bytes"
"context"
- gomock "github.com/golang/mock/gomock"
- "optionalfieldstest"
"testing"
- "thrift"
+
+ "github.com/golang/mock/gomock"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/optionalfieldstest"
+ "github.com/apache/thrift/lib/go/thrift"
)
func TestIsSetReturnFalseOnCreation(t *testing.T) {
diff --git a/lib/go/test/tests/protocol_mock.go b/lib/go/test/tests/protocol_mock.go
index 793e4e1..1cdd4c3 100644
--- a/lib/go/test/tests/protocol_mock.go
+++ b/lib/go/test/tests/protocol_mock.go
@@ -24,7 +24,7 @@
import (
"context"
- thrift "thrift"
+ thrift "github.com/apache/thrift/lib/go/thrift"
gomock "github.com/golang/mock/gomock"
)
diff --git a/lib/go/test/tests/protocols_test.go b/lib/go/test/tests/protocols_test.go
index 9030e9d..351fe59 100644
--- a/lib/go/test/tests/protocols_test.go
+++ b/lib/go/test/tests/protocols_test.go
@@ -21,8 +21,9 @@
import (
"testing"
- "thrift"
- "thrifttest"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/thrifttest"
+ "github.com/apache/thrift/lib/go/thrift"
)
func RunSocketTestSuite(t *testing.T, protocolFactory thrift.TProtocolFactory,
diff --git a/lib/go/test/tests/required_fields_test.go b/lib/go/test/tests/required_fields_test.go
index 06e8560..da80f9b 100644
--- a/lib/go/test/tests/required_fields_test.go
+++ b/lib/go/test/tests/required_fields_test.go
@@ -21,11 +21,13 @@
import (
"context"
- "github.com/golang/mock/gomock"
- "optionalfieldstest"
- "requiredfieldtest"
"testing"
- "thrift"
+
+ "github.com/golang/mock/gomock"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/optionalfieldstest"
+ "github.com/apache/thrift/lib/go/test/gopath/src/requiredfieldtest"
+ "github.com/apache/thrift/lib/go/thrift"
)
func TestRequiredField_SucecssWhenSet(t *testing.T) {
diff --git a/lib/go/test/tests/struct_args_rets_test.go b/lib/go/test/tests/struct_args_rets_test.go
index 81e9b26..df6b746 100644
--- a/lib/go/test/tests/struct_args_rets_test.go
+++ b/lib/go/test/tests/struct_args_rets_test.go
@@ -20,7 +20,7 @@
package tests
import (
- st "servicestest"
+ st "github.com/apache/thrift/lib/go/test/gopath/src/servicestest"
)
//this function is never called, it will fail to compile if check is failed
diff --git a/lib/go/test/tests/thrifttest_driver.go b/lib/go/test/tests/thrifttest_driver.go
index 4fc5baa..b351295 100644
--- a/lib/go/test/tests/thrifttest_driver.go
+++ b/lib/go/test/tests/thrifttest_driver.go
@@ -22,7 +22,8 @@
import (
"reflect"
"testing"
- "thrifttest"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/thrifttest"
)
type ThriftTestDriver struct {
diff --git a/lib/go/test/tests/thrifttest_handler.go b/lib/go/test/tests/thrifttest_handler.go
index 7b115ec..419a18b 100644
--- a/lib/go/test/tests/thrifttest_handler.go
+++ b/lib/go/test/tests/thrifttest_handler.go
@@ -22,9 +22,10 @@
import (
"context"
"errors"
- "thrift"
- "thrifttest"
"time"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/thrifttest"
+ "github.com/apache/thrift/lib/go/thrift"
)
type SecondServiceHandler struct {
diff --git a/lib/go/test/tests/union_binary_test.go b/lib/go/test/tests/union_binary_test.go
index bdae2cb..3fe9d0e 100644
--- a/lib/go/test/tests/union_binary_test.go
+++ b/lib/go/test/tests/union_binary_test.go
@@ -21,9 +21,9 @@
import (
"testing"
- "unionbinarytest"
-)
+ "github.com/apache/thrift/lib/go/test/gopath/src/unionbinarytest"
+)
// See https://issues.apache.org/jira/browse/THRIFT-4573
func TestUnionBinary(t *testing.T) {
diff --git a/lib/go/test/tests/union_default_value_test.go b/lib/go/test/tests/union_default_value_test.go
index 2dcbf4e..a02569a 100644
--- a/lib/go/test/tests/union_default_value_test.go
+++ b/lib/go/test/tests/union_default_value_test.go
@@ -21,7 +21,8 @@
import (
"testing"
- "uniondefaultvaluetest"
+
+ "github.com/apache/thrift/lib/go/test/gopath/src/uniondefaultvaluetest"
)
func TestUnionDefaultValue(t *testing.T) {