You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by yu...@apache.org on 2021/03/24 20:32:29 UTC

[thrift] branch master updated: THRIFT-5358: Add go.mod file to root directory

This is an automated email from the ASF dual-hosted git repository.

yuxuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new b71f11e  THRIFT-5358: Add go.mod file to root directory
b71f11e is described below

commit b71f11e251a711604cea8caad7d493ea57fe8a8f
Author: Yuxuan 'fishy' Wang <yu...@reddit.com>
AuthorDate: Mon Mar 22 15:01:00 2021 -0700

    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.
---
 build/docker/README.md                         |  2 +-
 build/docker/ubuntu-bionic/Dockerfile          |  4 +--
 build/docker/ubuntu-disco/Dockerfile           |  4 +--
 build/docker/ubuntu-xenial/Dockerfile          |  4 +--
 go.mod                                         |  5 +++
 go.sum                                         | 14 ++++++++
 lib/go/Makefile.am                             |  4 +--
 lib/go/test/Makefile.am                        | 47 ++++++++++++--------------
 lib/go/test/fuzz/Makefile.am                   | 12 ++-----
 lib/go/test/fuzz/fuzz.go                       |  4 +--
 lib/go/test/tests/binary_key_test.go           |  3 +-
 lib/go/test/tests/client_error_test.go         |  5 +--
 lib/go/test/tests/conflict_arg_names_test.go   |  2 +-
 lib/go/test/tests/encoding_json_test.go        |  3 +-
 lib/go/test/tests/equals_test.go               |  3 +-
 lib/go/test/tests/gotag_test.go                |  3 +-
 lib/go/test/tests/ignoreinitialisms_test.go    |  3 +-
 lib/go/test/tests/initialisms_test.go          |  3 +-
 lib/go/test/tests/multiplexed_protocol_test.go |  5 +--
 lib/go/test/tests/names_test.go                |  3 +-
 lib/go/test/tests/one_way_test.go              |  5 +--
 lib/go/test/tests/optional_fields_test.go      |  8 +++--
 lib/go/test/tests/protocol_mock.go             |  2 +-
 lib/go/test/tests/protocols_test.go            |  5 +--
 lib/go/test/tests/required_fields_test.go      | 10 +++---
 lib/go/test/tests/struct_args_rets_test.go     |  2 +-
 lib/go/test/tests/thrifttest_driver.go         |  3 +-
 lib/go/test/tests/thrifttest_handler.go        |  5 +--
 lib/go/test/tests/union_binary_test.go         |  4 +--
 lib/go/test/tests/union_default_value_test.go  |  3 +-
 test/go/Makefile.am                            | 14 +++-----
 test/go/genmock.sh                             | 21 +++++-------
 test/go/src/bin/stress/main.go                 |  5 +--
 test/go/src/bin/testclient/main.go             | 11 +++---
 test/go/src/bin/testserver/main.go             |  5 +--
 test/go/src/common/client.go                   |  5 +--
 test/go/src/common/clientserver_test.go        |  9 ++---
 test/go/src/common/context_test.go             |  3 +-
 test/go/src/common/printing_handler.go         |  9 ++---
 test/go/src/common/server.go                   |  5 +--
 test/go/src/common/simple_handler.go           |  7 ++--
 tutorial/go/Makefile.am                        | 24 +++++--------
 tutorial/go/src/client.go                      |  2 +-
 tutorial/go/src/handler.go                     |  5 +--
 tutorial/go/src/main.go                        |  3 +-
 tutorial/go/src/server.go                      |  5 +--
 46 files changed, 169 insertions(+), 144 deletions(-)

diff --git a/build/docker/README.md b/build/docker/README.md
index 4ee57d1..44e30b0 100644
--- a/build/docker/README.md
+++ b/build/docker/README.md
@@ -178,7 +178,7 @@ Last updated: October 1, 2017
 | dart      | 2.0.0         | 2.4.0         |       |
 | delphi    |               |               | Not in CI |
 | erlang    | 18.3          | 22.0          |       |
-| go        | 1.14.14       | 1.15.7        |       |
+| go        | 1.15.10       | 1.16.2        |       |
 | haxe      | 3.2.1         | 3.4.4         | THRIFT-4352: avoid 3.4.2 |
 | java      | 1.8.0_191     | 11.0.3        |       |
 | js        | Node.js 6.17.1, V8 5.1.281.111, npm 3.10.10 | Node.js 10.18.0, V8 6.8.275.32, npm 6.13.4 |     |
diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile
index 699ae50..98f2607 100644
--- a/build/docker/ubuntu-bionic/Dockerfile
+++ b/build/docker/ubuntu-bionic/Dockerfile
@@ -140,9 +140,9 @@ RUN apt-get install -y --no-install-recommends \
       libglib2.0-dev
 
 # golang
-ENV GOLANG_VERSION 1.15.7
+ENV GOLANG_VERSION 1.16.2
 ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
-ENV GOLANG_DOWNLOAD_SHA256 0d142143794721bb63ce6c8a6180c4062bcf8ef4715e7d6d6609f3a8282629b3
+ENV GOLANG_DOWNLOAD_SHA256 542e936b19542e62679766194364f45141fde55169db2d8d01046555ca9eb4b8
 RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \
       echo "$GOLANG_DOWNLOAD_SHA256  golang.tar.gz" | sha256sum -c - && \
             tar -C /usr/local -xzf golang.tar.gz && \
diff --git a/build/docker/ubuntu-disco/Dockerfile b/build/docker/ubuntu-disco/Dockerfile
index dd2df42..2c3166f 100644
--- a/build/docker/ubuntu-disco/Dockerfile
+++ b/build/docker/ubuntu-disco/Dockerfile
@@ -140,9 +140,9 @@ RUN apt-get install -y --no-install-recommends \
       libglib2.0-dev
 
 # golang
-ENV GOLANG_VERSION 1.15.7
+ENV GOLANG_VERSION 1.16.2
 ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
-ENV GOLANG_DOWNLOAD_SHA256 0d142143794721bb63ce6c8a6180c4062bcf8ef4715e7d6d6609f3a8282629b3
+ENV GOLANG_DOWNLOAD_SHA256 542e936b19542e62679766194364f45141fde55169db2d8d01046555ca9eb4b8
 RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \
       echo "$GOLANG_DOWNLOAD_SHA256  golang.tar.gz" | sha256sum -c - && \
             tar -C /usr/local -xzf golang.tar.gz && \
diff --git a/build/docker/ubuntu-xenial/Dockerfile b/build/docker/ubuntu-xenial/Dockerfile
index bc66786..1184458 100644
--- a/build/docker/ubuntu-xenial/Dockerfile
+++ b/build/docker/ubuntu-xenial/Dockerfile
@@ -137,9 +137,9 @@ RUN apt-get install -y --no-install-recommends \
       libglib2.0-dev
 
 # golang
-ENV GOLANG_VERSION 1.14.14
+ENV GOLANG_VERSION 1.15.10
 ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
-ENV GOLANG_DOWNLOAD_SHA256 6f1354c9040d65d1622b451f43c324c1e5197aa9242d00c5a117d0e2625f3e0d
+ENV GOLANG_DOWNLOAD_SHA256 4aa1267517df32f2bf1cc3d55dfc27d0c6b2c2b0989449c96dd19273ccca051d
 RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \
       echo "$GOLANG_DOWNLOAD_SHA256  golang.tar.gz" | sha256sum -c - && \
       tar -C /usr/local -xzf golang.tar.gz && \
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..474ec99
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,5 @@
+module github.com/apache/thrift
+
+go 1.15
+
+require github.com/golang/mock v1.5.0
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..646b11a
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,14 @@
+github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
+github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
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 @@ install:
 	@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 @@ gopath: $(THRIFT) $(THRIFTTEST) \
 	$(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 @@ package fuzz
 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 @@ package tests
 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 @@ import (
 	"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 @@ package tests
 
 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 @@ import (
 	"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 @@ package tests
 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 @@ package tests
 
 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 @@ package tests
 
 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 @@ package tests
 
 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 @@ package tests
 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 @@ package tests
 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 @@ package tests
 
 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 @@ package tests
 
 import (
 	"testing"
-	"uniondefaultvaluetest"
+
+	"github.com/apache/thrift/lib/go/test/gopath/src/uniondefaultvaluetest"
 )
 
 func TestUnionDefaultValue(t *testing.T) {
diff --git a/test/go/Makefile.am b/test/go/Makefile.am
index eae153c..d7db957 100644
--- a/test/go/Makefile.am
+++ b/test/go/Makefile.am
@@ -19,7 +19,7 @@
 
 BUILT_SOURCES = gopath
 
-THRIFTCMD = $(THRIFT) -out src/gen --gen go:thrift_import=thrift$(COMPILER_EXTRAFLAG)
+THRIFTCMD = $(THRIFT) -out src/gen --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/test/go/src/gen/$(COMPILER_EXTRAFLAG)
 THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
 
 precross: bin/testclient bin/testserver
@@ -34,20 +34,16 @@ gopath: $(THRIFT) ThriftTest.thrift
 	mkdir -p src/gen
 	$(THRIFTCMD) ThriftTest.thrift
 	$(THRIFTCMD) ../StressTest.thrift
-	GOPATH=`pwd` $(GO) get github.com/golang/mock/gomock || true
-	sed -i 's/\"context\"/\"golang.org\/x\/net\/context\"/g' src/github.com/golang/mock/gomock/controller.go || true
-	GOPATH=`pwd` $(GO) get github.com/golang/mock/gomock
-	ln -nfs ../../../lib/go/thrift src/thrift
 	touch gopath
 
 bin/testclient: gopath
-	GOPATH=`pwd` $(GO) install bin/testclient
+	GOPATH=`pwd` $(GO) install -mod=mod ./src/bin/testclient
 
 bin/testserver: gopath
-	GOPATH=`pwd` $(GO) install bin/testserver
+	GOPATH=`pwd` $(GO) install -mod=mod ./src/bin/testserver
 
 bin/stress: gopath
-	GOPATH=`pwd` $(GO) install bin/stress
+	GOPATH=`pwd` $(GO) install -mod=mod ./src/bin/stress
 
 clean-local:
 	$(RM) -r src/gen src/github.com/golang src/thrift bin pkg gopath ThriftTest.thrift
@@ -55,7 +51,7 @@ clean-local:
 check_PROGRAMS: bin/testclient bin/testserver bin/stress
 
 check: gopath genmock
-	GOPATH=`pwd` $(GO) test -v common/...
+	$(GO) test -mod=mod -v ./src/common/...
 
 genmock: gopath
 	sh genmock.sh
diff --git a/test/go/genmock.sh b/test/go/genmock.sh
index 3ba41b9..bccfdf3 100644
--- a/test/go/genmock.sh
+++ b/test/go/genmock.sh
@@ -1,15 +1,12 @@
 #!/bin/sh
+
 set -e
 
-export GOPATH=`pwd`
-export GOBIN=`pwd`/bin
-export GO111MODULE=off
-
-mkdir -p src/github.com/golang/mock
-cd src/github.com/golang
-curl -fsSL https://github.com/golang/mock/archive/v1.2.0.tar.gz -o mock.tar.gz
-tar -xzvf mock.tar.gz -C mock --strip-components=1
-cd mock/mockgen
-go install .
-cd ../../../../../
-bin/mockgen -destination=src/common/mock_handler.go -package=common gen/thrifttest ThriftTest
+export GOPATH=$(mktemp -d -t gopath-XXXXXXXXXX)
+
+# TODO: Once we dropped support to go 1.15, add "@v1.5.0" suffix to go install
+GO111MODULE=on go install -mod=mod github.com/golang/mock/mockgen
+
+`go env GOPATH`/bin/mockgen -build_flags "-mod=mod" -destination=src/common/mock_handler.go -package=common github.com/apache/thrift/test/go/src/gen/thrifttest ThriftTest
+
+rm -Rf $GOPATH
diff --git a/test/go/src/bin/stress/main.go b/test/go/src/bin/stress/main.go
index f2e0f20..3ff0a39 100644
--- a/test/go/src/bin/stress/main.go
+++ b/test/go/src/bin/stress/main.go
@@ -23,7 +23,6 @@ import (
 	"context"
 	"flag"
 	"fmt"
-	"gen/stress"
 	"log"
 	_ "net/http/pprof"
 	"os"
@@ -31,8 +30,10 @@ import (
 	"runtime/pprof"
 	"sync"
 	"sync/atomic"
-	"thrift"
 	"time"
+
+	"github.com/apache/thrift/lib/go/thrift"
+	"github.com/apache/thrift/test/go/src/gen/stress"
 )
 
 var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to this file")
diff --git a/test/go/src/bin/testclient/main.go b/test/go/src/bin/testclient/main.go
index 4357ee8..39ee95b 100644
--- a/test/go/src/bin/testclient/main.go
+++ b/test/go/src/bin/testclient/main.go
@@ -20,13 +20,14 @@
 package main
 
 import (
-	"common"
 	"context"
 	"flag"
-	"gen/thrifttest"
 	t "log"
 	"reflect"
-	"thrift"
+
+	"github.com/apache/thrift/lib/go/thrift"
+	"github.com/apache/thrift/test/go/src/common"
+	"github.com/apache/thrift/test/go/src/gen/thrifttest"
 )
 
 var host = flag.String("host", "localhost", "Host to connect")
@@ -50,8 +51,8 @@ func main() {
 }
 
 var rmapmap = map[int32]map[int32]int32{
-	-4: map[int32]int32{-4: -4, -3: -3, -2: -2, -1: -1},
-	4:  map[int32]int32{4: 4, 3: 3, 2: 2, 1: 1},
+	-4: {-4: -4, -3: -3, -2: -2, -1: -1},
+	4:  {4: 4, 3: 3, 2: 2, 1: 1},
 }
 
 var xxs = &thrifttest.Xtruct{
diff --git a/test/go/src/bin/testserver/main.go b/test/go/src/bin/testserver/main.go
index 6fc1185..d4bd8b4 100644
--- a/test/go/src/bin/testserver/main.go
+++ b/test/go/src/bin/testserver/main.go
@@ -20,12 +20,13 @@
 package main
 
 import (
-	"common"
 	"flag"
 	"fmt"
 	"log"
 	"net/http"
-	"thrift"
+
+	"github.com/apache/thrift/lib/go/thrift"
+	"github.com/apache/thrift/test/go/src/common"
 )
 
 var host = flag.String("host", "localhost", "Host to connect")
diff --git a/test/go/src/common/client.go b/test/go/src/common/client.go
index ed820ae..15973d8 100644
--- a/test/go/src/common/client.go
+++ b/test/go/src/common/client.go
@@ -24,9 +24,10 @@ import (
 	"crypto/tls"
 	"flag"
 	"fmt"
-	"gen/thrifttest"
 	"net/http"
-	"thrift"
+
+	"github.com/apache/thrift/lib/go/thrift"
+	"github.com/apache/thrift/test/go/src/gen/thrifttest"
 )
 
 var debugClientProtocol bool
diff --git a/test/go/src/common/clientserver_test.go b/test/go/src/common/clientserver_test.go
index 9f93c4c..d5e3c43 100644
--- a/test/go/src/common/clientserver_test.go
+++ b/test/go/src/common/clientserver_test.go
@@ -22,13 +22,14 @@ package common
 import (
 	"context"
 	"errors"
-	"gen/thrifttest"
 	"reflect"
 	"sync"
 	"testing"
-	"thrift"
 
 	"github.com/golang/mock/gomock"
+
+	"github.com/apache/thrift/lib/go/thrift"
+	"github.com/apache/thrift/test/go/src/gen/thrifttest"
 )
 
 type test_unit struct {
@@ -84,8 +85,8 @@ func doUnit(t *testing.T, unit *test_unit) {
 }
 
 var rmapmap = map[int32]map[int32]int32{
-	-4: map[int32]int32{-4: -4, -3: -3, -2: -2, -1: -1},
-	4:  map[int32]int32{4: 4, 3: 3, 2: 2, 1: 1},
+	-4: {-4: -4, -3: -3, -2: -2, -1: -1},
+	4:  {4: 4, 3: 3, 2: 2, 1: 1},
 }
 
 var xxs = &thrifttest.Xtruct{
diff --git a/test/go/src/common/context_test.go b/test/go/src/common/context_test.go
index e64dbb9..3e21a54 100644
--- a/test/go/src/common/context_test.go
+++ b/test/go/src/common/context_test.go
@@ -28,8 +28,9 @@ import (
 	"os"
 	"syscall"
 	"testing"
-	"thrift"
 	"time"
+
+	"github.com/apache/thrift/lib/go/thrift"
 )
 
 type slowHttpHandler struct{}
diff --git a/test/go/src/common/printing_handler.go b/test/go/src/common/printing_handler.go
index 2b22d0c..d91dde4 100644
--- a/test/go/src/common/printing_handler.go
+++ b/test/go/src/common/printing_handler.go
@@ -24,8 +24,9 @@ import (
 	"encoding/hex"
 	"errors"
 	"fmt"
-	. "gen/thrifttest"
 	"time"
+
+	. "github.com/apache/thrift/test/go/src/gen/thrifttest"
 )
 
 var PrintingHandler = &printingHandler{}
@@ -192,7 +193,7 @@ func (p *printingHandler) TestStringMap(ctx context.Context, thing map[string]st
 func (p *printingHandler) TestSet(ctx context.Context, thing []int32) (r []int32, err error) {
 	fmt.Printf("testSet({")
 	first := true
-	for k, _ := range thing {
+	for k := range thing {
 		if first {
 			first = false
 		} else {
@@ -256,8 +257,8 @@ func (p *printingHandler) TestMapMap(ctx context.Context, hello int32) (r map[in
 	fmt.Printf("testMapMap(%d)\n", hello)
 
 	r = map[int32]map[int32]int32{
-		-4: map[int32]int32{-4: -4, -3: -3, -2: -2, -1: -1},
-		4:  map[int32]int32{4: 4, 3: 3, 2: 2, 1: 1},
+		-4: {-4: -4, -3: -3, -2: -2, -1: -1},
+		4:  {4: 4, 3: 3, 2: 2, 1: 1},
 	}
 	return
 }
diff --git a/test/go/src/common/server.go b/test/go/src/common/server.go
index c6674ae..6e3a5d3 100644
--- a/test/go/src/common/server.go
+++ b/test/go/src/common/server.go
@@ -24,8 +24,9 @@ import (
 	"crypto/tls"
 	"flag"
 	"fmt"
-	"gen/thrifttest"
-	"thrift"
+
+	"github.com/apache/thrift/lib/go/thrift"
+	"github.com/apache/thrift/test/go/src/gen/thrifttest"
 )
 
 var (
diff --git a/test/go/src/common/simple_handler.go b/test/go/src/common/simple_handler.go
index 0c9463d..971f17e 100644
--- a/test/go/src/common/simple_handler.go
+++ b/test/go/src/common/simple_handler.go
@@ -21,8 +21,9 @@ package common
 
 import (
 	"errors"
-	. "gen/thrifttest"
 	"time"
+
+	. "github.com/apache/thrift/test/go/src/gen/thrifttest"
 )
 
 var SimpleHandler = &simpleHandler{}
@@ -96,8 +97,8 @@ func (p *simpleHandler) TestTypedef(thing UserId) (r UserId, err error) {
 func (p *simpleHandler) TestMapMap(hello int32) (r map[int32]map[int32]int32, err error) {
 
 	r = map[int32]map[int32]int32{
-		-4: map[int32]int32{-4: -4, -3: -3, -2: -2, -1: -1},
-		4:  map[int32]int32{4: 4, 3: 3, 2: 2, 1: 1},
+		-4: {-4: -4, -3: -3, -2: -2, -1: -1},
+		4:  {4: 4, 3: 3, 2: 2, 1: 1},
 	}
 	return
 }
diff --git a/tutorial/go/Makefile.am b/tutorial/go/Makefile.am
index bd57d65..ed108fd 100644
--- a/tutorial/go/Makefile.am
+++ b/tutorial/go/Makefile.am
@@ -18,36 +18,30 @@
 #
 
 gen-go/tutorial/calculator.go gen-go/shared/shared_service.go: $(top_srcdir)/tutorial/tutorial.thrift
-	$(THRIFT) --gen go$(COMPILER_EXTRAFLAG) -r $<
+	$(THRIFT) --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/tutorial/go/gen-go/$(COMPILER_EXTRAFLAG) -r $<
 
 all-local: gen-go/tutorial/calculator.go
 
-check: src/github.com/apache/thrift/lib/go/thrift thirdparty-dep
-	$(THRIFT) -r --gen go$(COMPILER_EXTRAFLAG) $(top_srcdir)/tutorial/tutorial.thrift
-	cp -r gen-go/* src/
-	GOPATH=`pwd` $(GO) build -o go-tutorial ./src
-	GOPATH=`pwd` $(GO) build -o calculator-remote src/tutorial/calculator-remote/calculator-remote.go
-
-src/github.com/apache/thrift/lib/go/thrift:
-	mkdir -p src/github.com/apache/thrift/lib/go
-	ln -sf $(realpath $(top_srcdir)/lib/go/thrift) src/github.com/apache/thrift/lib/go/thrift
+check: thirdparty-dep all
+	$(GO) build -mod=mod -o go-tutorial ./src
+	$(GO) build -mod=mod -o calculator-remote ./gen-go/tutorial/calculator-remote/calculator-remote.go
 
 thirdparty-dep:
 
 tutorialserver: all
-	GOPATH=`pwd` $(GO) run src/*.go -server=true
+	$(GO) run -mod=mod src/*.go -server=true
 
 tutorialclient: all
-	GOPATH=`pwd` $(GO) run src/*.go
+	$(GO) run -mod=mod src/*.go
 
 tutorialsecureserver: all
-	GOPATH=`pwd` $(GO) run src/*.go -server=true -secure=true
+	$(GO) run -mod=mod src/*.go -server=true -secure=true
 
 tutorialsecureclient: all
-	GOPATH=`pwd` $(GO) run src/*.go -secure=true
+	$(GO) run -mod=mod src/*.go -secure=true
 
 clean-local:
-	$(RM) -r gen-* src/shared src/tutorial src/git.apache.org go-tutorial calculator-remote
+	$(RM) -r gen-* go-tutorial calculator-remote
 
 EXTRA_DIST = \
 	src/client.go \
diff --git a/tutorial/go/src/client.go b/tutorial/go/src/client.go
index 319ca3e..8776f9c 100644
--- a/tutorial/go/src/client.go
+++ b/tutorial/go/src/client.go
@@ -23,9 +23,9 @@ import (
 	"context"
 	"crypto/tls"
 	"fmt"
-	"tutorial"
 
 	"github.com/apache/thrift/lib/go/thrift"
+	"github.com/apache/thrift/tutorial/go/gen-go/tutorial"
 )
 
 var defaultCtx = context.Background()
diff --git a/tutorial/go/src/handler.go b/tutorial/go/src/handler.go
index 5c0eed0..7645fc2 100644
--- a/tutorial/go/src/handler.go
+++ b/tutorial/go/src/handler.go
@@ -22,9 +22,10 @@ package main
 import (
 	"context"
 	"fmt"
-	"shared"
 	"strconv"
-	"tutorial"
+
+	"github.com/apache/thrift/tutorial/go/gen-go/shared"
+	"github.com/apache/thrift/tutorial/go/gen-go/tutorial"
 )
 
 type CalculatorHandler struct {
diff --git a/tutorial/go/src/main.go b/tutorial/go/src/main.go
index 7730d7b..afac6bb 100644
--- a/tutorial/go/src/main.go
+++ b/tutorial/go/src/main.go
@@ -22,8 +22,9 @@ package main
 import (
 	"flag"
 	"fmt"
-	"github.com/apache/thrift/lib/go/thrift"
 	"os"
+
+	"github.com/apache/thrift/lib/go/thrift"
 )
 
 func Usage() {
diff --git a/tutorial/go/src/server.go b/tutorial/go/src/server.go
index 95708eb..1171ca6 100644
--- a/tutorial/go/src/server.go
+++ b/tutorial/go/src/server.go
@@ -22,8 +22,9 @@ package main
 import (
 	"crypto/tls"
 	"fmt"
+
 	"github.com/apache/thrift/lib/go/thrift"
-	"tutorial"
+	"github.com/apache/thrift/tutorial/go/gen-go/tutorial"
 )
 
 func runServer(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string, secure bool) error {
@@ -40,7 +41,7 @@ func runServer(transportFactory thrift.TTransportFactory, protocolFactory thrift
 	} else {
 		transport, err = thrift.NewTServerSocket(addr)
 	}
-	
+
 	if err != nil {
 		return err
 	}