From e8353cb46e9f5e71f9b76f55d6bf59530b7f98ef Mon Sep 17 00:00:00 2001 From: Yuxuan 'fishy' Wang Date: Fri, 28 Oct 2022 10:29:25 -0700 Subject: Use multi-module to cleanup top level go.mod Client: go The go library itself does not have any third-party dependencies. We have one third party dependency from the test code, which kind of polluted from top-level go.mod file to the users of thrift go library. We previous tried to clean that up by creating go.mod file at lib/go/thrift, which caused issues to the release process and thus reverted. Use multi-module to separate tests requiring mock to their own modules so that we can keep the top-level go.mod file clean. Also some minor fixes on the github actions go workflow. --- lib/go/Makefile.am | 6 +++--- lib/go/test/Makefile.am | 14 +++++--------- lib/go/test/fuzz/Makefile.am | 2 +- lib/go/test/go.mod | 10 ++++++++++ lib/go/test/go.sum | 25 +++++++++++++++++++++++++ lib/go/test/tests/thrifttest_handler.go | 4 ++++ 6 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 lib/go/test/go.mod create mode 100644 lib/go/test/go.sum (limited to 'lib') diff --git a/lib/go/Makefile.am b/lib/go/Makefile.am index 06399f5f4..18b6b75f4 100644 --- a/lib/go/Makefile.am +++ b/lib/go/Makefile.am @@ -39,14 +39,14 @@ install: # NOTE: We have to disable stdmethods in go vet until # https://github.com/golang/go/issues/52445 is fixed. check-local: - $(GO) vet -mod=mod -stdmethods=false github.com/apache/thrift/lib/go/thrift - $(GO) test -mod=mod -race ./thrift + $(GO) vet -stdmethods=false github.com/apache/thrift/lib/go/thrift + $(GO) test -race ./thrift clean-local: $(RM) -rf pkg all-local: - $(GO) build $(GOBUILDEXTRA) -mod=mod ./thrift + $(GO) build $(GOBUILDEXTRA) ./thrift EXTRA_DIST = \ thrift \ diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am index b9c00d969..663b42e89 100644 --- a/lib/go/test/Makefile.am +++ b/lib/go/test/Makefile.am @@ -17,16 +17,12 @@ # under the License. # -if GOVERSION_GE_118 GOBUILDEXTRA = -buildvcs=false -else -GOBUILDEXTRA = -endif THRIFT_GO_ARGS_BASE = thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/lib/go/test/gopath/src/ THRIFTARGS = -out gopath/src/ --gen go:$(THRIFT_GO_ARGS_BASE)$(COMPILER_EXTRAFLAG) -THRIFTTEST = $(top_srcdir)/test/v0.16/ThriftTest.thrift +THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift THRIFTARGS_SKIP_REMOTE = -out gopath/src/ --gen go:skip_remote,$(THRIFT_GO_ARGS_BASE)$(COMPILER_EXTRAFLAG) @@ -105,7 +101,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \ touch gopath check: gopath - $(GO) build $(GOBUILDEXTRA) -mod=mod \ + $(GO) build $(GOBUILDEXTRA) \ ./gopath/src/includestest \ ./gopath/src/binarykeytest \ ./gopath/src/servicestest \ @@ -126,14 +122,14 @@ check: gopath ./gopath/src/processormiddlewaretest \ ./gopath/src/clientmiddlewareexceptiontest \ ./gopath/src/validatetest - $(GO) test -mod=mod github.com/apache/thrift/lib/go/thrift - $(GO) test -mod=mod ./gopath/src/tests ./gopath/src/dontexportrwtest + $(GO) test github.com/apache/thrift/lib/go/thrift + $(GO) test ./gopath/src/tests ./gopath/src/dontexportrwtest clean-local: $(RM) -r gopath ThriftTest.thrift gen-go client: stubs - $(GO) run -mod=mod TestClient.go + $(GO) run TestClient.go EXTRA_DIST = \ dontexportrwtest \ diff --git a/lib/go/test/fuzz/Makefile.am b/lib/go/test/fuzz/Makefile.am index a8a810255..56f138a7e 100644 --- a/lib/go/test/fuzz/Makefile.am +++ b/lib/go/test/fuzz/Makefile.am @@ -24,7 +24,7 @@ gopathfuzz: $(THRIFT) fuzz.go touch gopathfuzz check: gopathfuzz - go test -mod=mod -tags gofuzz + go test -tags gofuzz clean-local: $(RM) -r gopathfuzz gen-go diff --git a/lib/go/test/go.mod b/lib/go/test/go.mod new file mode 100644 index 000000000..37814e060 --- /dev/null +++ b/lib/go/test/go.mod @@ -0,0 +1,10 @@ +module github.com/apache/thrift/lib/go/test + +go 1.18 + +require ( + github.com/apache/thrift v0.0.0-00010101000000-000000000000 + github.com/golang/mock v1.6.0 +) + +replace github.com/apache/thrift => ../../../ diff --git a/lib/go/test/go.sum b/lib/go/test/go.sum new file mode 100644 index 000000000..d0671277e --- /dev/null +++ b/lib/go/test/go.sum @@ -0,0 +1,25 @@ +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +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.4.2/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/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/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/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +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= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/lib/go/test/tests/thrifttest_handler.go b/lib/go/test/tests/thrifttest_handler.go index 419a18b44..f46f5495d 100644 --- a/lib/go/test/tests/thrifttest_handler.go +++ b/lib/go/test/tests/thrifttest_handler.go @@ -82,6 +82,10 @@ func (p *ThriftTestHandler) TestBinary(ctx context.Context, thing []byte) (r []b return thing, nil } +func (p *ThriftTestHandler) TestUuid(ctx context.Context, thing thrift.Tuuid) (r thrift.Tuuid, err error) { + return thing, nil +} + func (p *ThriftTestHandler) TestStruct(ctx context.Context, thing *thrifttest.Xtruct) (r *thrifttest.Xtruct, err error) { return thing, nil } -- cgit v1.2.1