Skip to content

Commit

Permalink
make types a go module (#461)
Browse files Browse the repository at this point in the history
* make types a go module

* update go mod to use types

* removing test for types for now

* add different folder for mod packages
  • Loading branch information
shrimalmadhur authored Dec 12, 2022
1 parent 255864d commit 8ea45ef
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ GOLINES_CMD=golines
GOVERALLS_INSTALL=go install github.com/mattn/goveralls@latest
GOVERALLS_CMD=goveralls
GOLINT_CMD=go run golang.org/x/lint/golint
GO_PACKAGES=./asserter/... ./fetcher/... ./types/... ./client/... ./server/... \
GO_PACKAGES=./asserter/... ./fetcher/... ./client/... ./server/... \
./parser/... ./syncer/... ./reconciler/... ./keys/... \
./statefulsyncer/... ./storage/... ./utils/... ./constructor/... ./errors/...

GO_MOD_PACKAGES=./types/...
GO_FOLDERS=$(shell echo ${GO_PACKAGES} | sed -e "s/\.\///g" | sed -e "s/\/\.\.\.//g")
GO_MOD_FOLDERS=$(shell echo ${GO_MOD_PACKAGES} | sed -e "s/\.\///g" | sed -e "s/\/\.\.\.//g")
TEST_SCRIPT=go test ${GO_PACKAGES}
LINT_SETTINGS=golint,misspell,gocyclo,gocritic,whitespace,goconst,gocognit,bodyclose,unconvert,lll,unparam

Expand All @@ -43,6 +46,7 @@ fix-imports:

check-comments:
${GOLINT_CMD} -set_exit_status ${GO_FOLDERS} .
${GOLINT_CMD} -set_exit_status ${GO_MOD_FOLDERS} .

lint-examples:
cd examples; \
Expand Down Expand Up @@ -79,6 +83,7 @@ check-license:
shorten-lines:
${GOLINES_INSTALL}
${GOLINES_CMD} -w --shorten-comments ${GO_FOLDERS} examples
${GOLINES_CMD} -w --shorten-comments ${GO_MOD_FOLDERS}

shellcheck:
shellcheck codegen.sh
Expand Down
4 changes: 4 additions & 0 deletions codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ do
rm "types/${type}.go" && cp "templates/${type}.txt" "types/${type}.go";
done

cp "templates/go.mod.types" "types/go.mod"
cd types && go get ./...
cd ..

# Format client generated code
FORMAT_GEN="gofmt -w /local/types; gofmt -w /local/client; gofmt -w /local/server"
GOLANG_VERSION=1.18
Expand Down
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module github.com/coinbase/rosetta-sdk-go

go 1.18

require github.com/coinbase/rosetta-sdk-go/types v0.0.0

replace github.com/coinbase/rosetta-sdk-go/types => ./types

require (
github.com/DataDog/zstd v1.5.2
github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6
Expand All @@ -13,7 +17,6 @@ require (
github.com/fatih/color v1.13.0
github.com/gorilla/mux v1.8.0
github.com/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77
github.com/mitchellh/mapstructure v1.4.3
github.com/neilotoole/errgroup v0.1.6
github.com/segmentio/fasthash v1.0.3
github.com/stretchr/testify v1.7.2
Expand All @@ -38,6 +41,7 @@ require (
github.com/klauspost/compress v1.12.3 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.1.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/neilotoole/errgroup v0.1.6 h1:PODGqPXdT5BC/zCYIMoTrwV+ujKcW+gBXM6Ye9Ve3R8=
github.com/neilotoole/errgroup v0.1.6/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
3 changes: 3 additions & 0 deletions templates/go.mod.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/coinbase/rosetta-sdk-go/types

go 1.18
5 changes: 5 additions & 0 deletions types/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/coinbase/rosetta-sdk-go/types

go 1.18

require github.com/mitchellh/mapstructure v1.5.0
2 changes: 2 additions & 0 deletions types/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=

0 comments on commit 8ea45ef

Please sign in to comment.