From c9a6ded3195f51cdf73228b121e57a300a91ca7c Mon Sep 17 00:00:00 2001 From: Nikita Kryuchkov Date: Mon, 1 Jun 2020 22:07:25 +0300 Subject: [PATCH] Format imports --- Makefile | 16 +++++++++------- cmd/skywire-cli/commands/mdisc/root.go | 3 +-- cmd/skywire-cli/commands/rtfind/root.go | 7 +++---- cmd/skywire-cli/commands/visor/gen-config.go | 5 ++--- cmd/skywire-visor/commands/root.go | 2 +- pkg/app/appevent/mock_rpc_client.go | 4 ++-- pkg/app/appserver/mock_proc_manager.go | 4 ++-- pkg/app/appserver/mock_rpc_ingress_client.go | 5 ++--- pkg/app/appserver/rpc_ingress_client_test.go | 6 ++---- pkg/hypervisor/user_manager.go | 3 +-- pkg/router/mock_router.go | 1 - pkg/router/router_test.go | 3 +-- pkg/setup/config.go | 4 ++-- pkg/setup/node_test.go | 9 +++------ pkg/snet/network.go | 10 +++++----- pkg/snet/network_test.go | 3 +-- pkg/snet/stcp/handshake.go | 5 ++--- pkg/snet/stcph/handshake.go | 5 ++--- pkg/snet/stcpr/handshake.go | 5 ++--- pkg/transport/discovery_test.go | 3 +-- pkg/transport/entry_test.go | 3 +-- pkg/transport/manager.go | 8 ++++---- pkg/transport/manager_test.go | 9 ++++----- pkg/visor/rpc_test.go | 7 +++---- pkg/visor/visor.go | 5 ++--- 25 files changed, 58 insertions(+), 77 deletions(-) diff --git a/Makefile b/Makefile index 60aa47ff3..19a4e92d1 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ .DEFAULT_GOAL := help -.PHONY : check lint install-linters dep test -.PHONY : build clean install format bin -.PHONY : host-apps bin +.PHONY : check lint install-linters dep test +.PHONY : build clean install format bin +.PHONY : host-apps bin .PHONY : run stop config -.PHONY : docker-image docker-clean docker-network -.PHONY : docker-apps docker-bin docker-volume -.PHONY : docker-run docker-stop +.PHONY : docker-image docker-clean docker-network +.PHONY : docker-apps docker-bin docker-volume +.PHONY : docker-run docker-stop VERSION := $(shell git describe) @@ -113,15 +113,17 @@ install-linters: ## Install linters # However, they suggest `curl ... | bash` which we should not do # ${OPTS} go get -u github.com/golangci/golangci-lint/cmd/golangci-lint ${OPTS} go get -u golang.org/x/tools/cmd/goimports + ${OPTS} go get -u github.com/incu6us/goimports-reviser tidy: ## Tidies and vendors dependencies. ${OPTS} go mod tidy -v ${OPTS} go mod vendor -v -format: tidy ## Formats the code. Must have goimports installed (use make install-linters). +format: tidy ## Formats the code. Must have goimports and goimports-reviser installed (use make install-linters). ${OPTS} goimports -w -local ${PROJECT_BASE} ./pkg ${OPTS} goimports -w -local ${PROJECT_BASE} ./cmd ${OPTS} goimports -w -local ${PROJECT_BASE} ./internal + find . -type f -name '*.go' -not -path "./vendor/*" -exec goimports-reviser -project-name ${PROJECT_BASE} -file-path {} \; dep: ## Sorts dependencies ${OPTS} go mod vendor -v diff --git a/cmd/skywire-cli/commands/mdisc/root.go b/cmd/skywire-cli/commands/mdisc/root.go index fdfe55dcc..8b3a83afc 100644 --- a/cmd/skywire-cli/commands/mdisc/root.go +++ b/cmd/skywire-cli/commands/mdisc/root.go @@ -7,12 +7,11 @@ import ( "text/tabwriter" "time" - "github.com/SkycoinProject/skywire-mainnet/pkg/skyenv" - "github.com/SkycoinProject/dmsg/disc" "github.com/spf13/cobra" "github.com/SkycoinProject/skywire-mainnet/cmd/skywire-cli/internal" + "github.com/SkycoinProject/skywire-mainnet/pkg/skyenv" ) var mdAddr string diff --git a/cmd/skywire-cli/commands/rtfind/root.go b/cmd/skywire-cli/commands/rtfind/root.go index be2b90fa2..3de558517 100644 --- a/cmd/skywire-cli/commands/rtfind/root.go +++ b/cmd/skywire-cli/commands/rtfind/root.go @@ -4,15 +4,14 @@ import ( "fmt" "time" - "github.com/SkycoinProject/skywire-mainnet/pkg/routefinder/rfclient" - "github.com/SkycoinProject/skywire-mainnet/pkg/routing" - "github.com/SkycoinProject/skywire-mainnet/pkg/skyenv" - "github.com/SkycoinProject/dmsg/cipher" "github.com/spf13/cobra" "golang.org/x/net/context" "github.com/SkycoinProject/skywire-mainnet/cmd/skywire-cli/internal" + "github.com/SkycoinProject/skywire-mainnet/pkg/routefinder/rfclient" + "github.com/SkycoinProject/skywire-mainnet/pkg/routing" + "github.com/SkycoinProject/skywire-mainnet/pkg/skyenv" ) var frAddr string diff --git a/cmd/skywire-cli/commands/visor/gen-config.go b/cmd/skywire-cli/commands/visor/gen-config.go index 8992b870e..4a79c68ce 100644 --- a/cmd/skywire-cli/commands/visor/gen-config.go +++ b/cmd/skywire-cli/commands/visor/gen-config.go @@ -6,13 +6,12 @@ import ( "os" "path/filepath" + "github.com/SkycoinProject/dmsg/cipher" "github.com/SkycoinProject/skycoin/src/util/logging" "github.com/sirupsen/logrus" + "github.com/spf13/cobra" "github.com/SkycoinProject/skywire-mainnet/pkg/visor/visorconfig" - - "github.com/SkycoinProject/dmsg/cipher" - "github.com/spf13/cobra" ) func init() { diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index c8a96e4e7..75a587380 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -6,7 +6,7 @@ import ( "io" "io/ioutil" "net/http" - _ "net/http/pprof" //nolint:gosec // https://golang.org/doc/diagnostics.html#profiling + _ "net/http/pprof" // nolint:gosec // https://golang.org/doc/diagnostics.html#profiling "os" "github.com/SkycoinProject/dmsg/buildinfo" diff --git a/pkg/app/appevent/mock_rpc_client.go b/pkg/app/appevent/mock_rpc_client.go index 9ec94adee..c73a4321e 100644 --- a/pkg/app/appevent/mock_rpc_client.go +++ b/pkg/app/appevent/mock_rpc_client.go @@ -5,9 +5,9 @@ package appevent import ( context "context" - appcommon "github.com/SkycoinProject/skywire-mainnet/pkg/app/appcommon" - mock "github.com/stretchr/testify/mock" + + appcommon "github.com/SkycoinProject/skywire-mainnet/pkg/app/appcommon" ) // MockRPCClient is an autogenerated mock type for the RPCClient type diff --git a/pkg/app/appserver/mock_proc_manager.go b/pkg/app/appserver/mock_proc_manager.go index 2c88d240e..1d0553b62 100644 --- a/pkg/app/appserver/mock_proc_manager.go +++ b/pkg/app/appserver/mock_proc_manager.go @@ -3,11 +3,11 @@ package appserver import ( + net "net" + mock "github.com/stretchr/testify/mock" appcommon "github.com/SkycoinProject/skywire-mainnet/pkg/app/appcommon" - - net "net" ) // MockProcManager is an autogenerated mock type for the ProcManager type diff --git a/pkg/app/appserver/mock_rpc_ingress_client.go b/pkg/app/appserver/mock_rpc_ingress_client.go index 55593bf90..f7e767de8 100644 --- a/pkg/app/appserver/mock_rpc_ingress_client.go +++ b/pkg/app/appserver/mock_rpc_ingress_client.go @@ -3,13 +3,12 @@ package appserver import ( + time "time" + mock "github.com/stretchr/testify/mock" appnet "github.com/SkycoinProject/skywire-mainnet/pkg/app/appnet" - routing "github.com/SkycoinProject/skywire-mainnet/pkg/routing" - - time "time" ) // MockRPCIngressClient is an autogenerated mock type for the RPCIngressClient type diff --git a/pkg/app/appserver/rpc_ingress_client_test.go b/pkg/app/appserver/rpc_ingress_client_test.go index 6b7201ee5..83c6c735f 100644 --- a/pkg/app/appserver/rpc_ingress_client_test.go +++ b/pkg/app/appserver/rpc_ingress_client_test.go @@ -9,18 +9,16 @@ import ( "testing" "time" - "github.com/SkycoinProject/skywire-mainnet/internal/testhelpers" - "github.com/SkycoinProject/dmsg" "github.com/SkycoinProject/dmsg/cipher" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "golang.org/x/net/nettest" + "github.com/SkycoinProject/skywire-mainnet/internal/testhelpers" + "github.com/SkycoinProject/skywire-mainnet/pkg/app/appcommon" "github.com/SkycoinProject/skywire-mainnet/pkg/app/appnet" "github.com/SkycoinProject/skywire-mainnet/pkg/routing" - - "github.com/SkycoinProject/skywire-mainnet/pkg/app/appcommon" ) func TestRPCClient_Dial(t *testing.T) { diff --git a/pkg/hypervisor/user_manager.go b/pkg/hypervisor/user_manager.go index df708751e..5d713a467 100644 --- a/pkg/hypervisor/user_manager.go +++ b/pkg/hypervisor/user_manager.go @@ -9,10 +9,9 @@ import ( "sync" "time" + "github.com/SkycoinProject/dmsg/httputil" "github.com/google/uuid" "github.com/gorilla/securecookie" - - "github.com/SkycoinProject/dmsg/httputil" ) const ( diff --git a/pkg/router/mock_router.go b/pkg/router/mock_router.go index c9246630f..56e5aef61 100644 --- a/pkg/router/mock_router.go +++ b/pkg/router/mock_router.go @@ -6,7 +6,6 @@ import ( context "context" cipher "github.com/SkycoinProject/dmsg/cipher" - mock "github.com/stretchr/testify/mock" routing "github.com/SkycoinProject/skywire-mainnet/pkg/routing" diff --git a/pkg/router/router_test.go b/pkg/router/router_test.go index 3b1513d20..1eb901595 100644 --- a/pkg/router/router_test.go +++ b/pkg/router/router_test.go @@ -10,12 +10,11 @@ import ( "testing" "time" - "github.com/sirupsen/logrus" - "github.com/SkycoinProject/dmsg" "github.com/SkycoinProject/dmsg/cipher" "github.com/SkycoinProject/skycoin/src/util/logging" "github.com/google/uuid" + "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/setup/config.go b/pkg/setup/config.go index 17add5995..36349076d 100644 --- a/pkg/setup/config.go +++ b/pkg/setup/config.go @@ -3,9 +3,9 @@ package setup import ( "time" - "github.com/SkycoinProject/skywire-mainnet/pkg/snet" - "github.com/SkycoinProject/dmsg/cipher" + + "github.com/SkycoinProject/skywire-mainnet/pkg/snet" ) //go:generate readmegen -n Config -o ./README.md ./config.go diff --git a/pkg/setup/node_test.go b/pkg/setup/node_test.go index 78a047810..bbf6bb586 100644 --- a/pkg/setup/node_test.go +++ b/pkg/setup/node_test.go @@ -12,12 +12,6 @@ import ( "testing" "time" - "github.com/SkycoinProject/skywire-mainnet/pkg/setup/setupclient" - - "github.com/SkycoinProject/skywire-mainnet/internal/testhelpers" - - "github.com/SkycoinProject/skywire-mainnet/pkg/snet/snettest" - "github.com/SkycoinProject/dmsg" "github.com/SkycoinProject/dmsg/cipher" "github.com/SkycoinProject/skycoin/src/util/logging" @@ -25,10 +19,13 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + "github.com/SkycoinProject/skywire-mainnet/internal/testhelpers" "github.com/SkycoinProject/skywire-mainnet/pkg/metrics" "github.com/SkycoinProject/skywire-mainnet/pkg/router" "github.com/SkycoinProject/skywire-mainnet/pkg/routing" + "github.com/SkycoinProject/skywire-mainnet/pkg/setup/setupclient" "github.com/SkycoinProject/skywire-mainnet/pkg/skyenv" + "github.com/SkycoinProject/skywire-mainnet/pkg/snet/snettest" ) func TestMain(m *testing.M) { diff --git a/pkg/snet/network.go b/pkg/snet/network.go index cd7a8e67b..819c28d19 100644 --- a/pkg/snet/network.go +++ b/pkg/snet/network.go @@ -9,16 +9,16 @@ import ( "sync" "time" + "github.com/SkycoinProject/dmsg" + "github.com/SkycoinProject/dmsg/cipher" + "github.com/SkycoinProject/dmsg/disc" + "github.com/SkycoinProject/skycoin/src/util/logging" + "github.com/SkycoinProject/skywire-mainnet/pkg/app/appevent" "github.com/SkycoinProject/skywire-mainnet/pkg/snet/arclient" "github.com/SkycoinProject/skywire-mainnet/pkg/snet/stcp" "github.com/SkycoinProject/skywire-mainnet/pkg/snet/stcph" "github.com/SkycoinProject/skywire-mainnet/pkg/snet/stcpr" - - "github.com/SkycoinProject/dmsg" - "github.com/SkycoinProject/dmsg/cipher" - "github.com/SkycoinProject/dmsg/disc" - "github.com/SkycoinProject/skycoin/src/util/logging" ) var log = logging.MustGetLogger("snet") diff --git a/pkg/snet/network_test.go b/pkg/snet/network_test.go index f8a87b180..8a4f590fa 100644 --- a/pkg/snet/network_test.go +++ b/pkg/snet/network_test.go @@ -3,10 +3,9 @@ package snet import ( "testing" - "github.com/stretchr/testify/require" - "github.com/SkycoinProject/dmsg" "github.com/SkycoinProject/dmsg/cipher" + "github.com/stretchr/testify/require" ) func TestDisassembleAddr(t *testing.T) { diff --git a/pkg/snet/stcp/handshake.go b/pkg/snet/stcp/handshake.go index a67ec670b..03725816d 100644 --- a/pkg/snet/stcp/handshake.go +++ b/pkg/snet/stcp/handshake.go @@ -9,11 +9,10 @@ import ( "net" "time" - cipher2 "github.com/SkycoinProject/skycoin/src/cipher" - "github.com/SkycoinProject/skycoin/src/util/logging" - "github.com/SkycoinProject/dmsg" "github.com/SkycoinProject/dmsg/cipher" + cipher2 "github.com/SkycoinProject/skycoin/src/cipher" + "github.com/SkycoinProject/skycoin/src/util/logging" ) var log = logging.MustGetLogger("stcp") diff --git a/pkg/snet/stcph/handshake.go b/pkg/snet/stcph/handshake.go index 50a6ac5cb..a170d5d5a 100644 --- a/pkg/snet/stcph/handshake.go +++ b/pkg/snet/stcph/handshake.go @@ -9,11 +9,10 @@ import ( "net" "time" - cipher2 "github.com/SkycoinProject/skycoin/src/cipher" - "github.com/SkycoinProject/skycoin/src/util/logging" - "github.com/SkycoinProject/dmsg" "github.com/SkycoinProject/dmsg/cipher" + cipher2 "github.com/SkycoinProject/skycoin/src/cipher" + "github.com/SkycoinProject/skycoin/src/util/logging" ) var log = logging.MustGetLogger("stcph") diff --git a/pkg/snet/stcpr/handshake.go b/pkg/snet/stcpr/handshake.go index 6300b456b..9b93fc338 100644 --- a/pkg/snet/stcpr/handshake.go +++ b/pkg/snet/stcpr/handshake.go @@ -9,11 +9,10 @@ import ( "net" "time" - cipher2 "github.com/SkycoinProject/skycoin/src/cipher" - "github.com/SkycoinProject/skycoin/src/util/logging" - "github.com/SkycoinProject/dmsg" "github.com/SkycoinProject/dmsg/cipher" + cipher2 "github.com/SkycoinProject/skycoin/src/cipher" + "github.com/SkycoinProject/skycoin/src/util/logging" ) var log = logging.MustGetLogger("stcpr") diff --git a/pkg/transport/discovery_test.go b/pkg/transport/discovery_test.go index 0d9a810b6..2b509d98b 100644 --- a/pkg/transport/discovery_test.go +++ b/pkg/transport/discovery_test.go @@ -4,9 +4,8 @@ import ( "context" "testing" - "github.com/stretchr/testify/require" - "github.com/SkycoinProject/dmsg/cipher" + "github.com/stretchr/testify/require" "github.com/SkycoinProject/skywire-mainnet/pkg/transport" ) diff --git a/pkg/transport/entry_test.go b/pkg/transport/entry_test.go index e279b5378..53659761f 100644 --- a/pkg/transport/entry_test.go +++ b/pkg/transport/entry_test.go @@ -4,9 +4,8 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/assert" - "github.com/SkycoinProject/dmsg/cipher" + "github.com/stretchr/testify/assert" "github.com/SkycoinProject/skywire-mainnet/pkg/transport" ) diff --git a/pkg/transport/manager.go b/pkg/transport/manager.go index 9c6f3a691..4c1df3642 100644 --- a/pkg/transport/manager.go +++ b/pkg/transport/manager.go @@ -9,14 +9,14 @@ import ( "sync" "time" + "github.com/SkycoinProject/dmsg/cipher" + "github.com/SkycoinProject/skycoin/src/util/logging" + "github.com/google/uuid" + "github.com/SkycoinProject/skywire-mainnet/pkg/routing" "github.com/SkycoinProject/skywire-mainnet/pkg/skyenv" "github.com/SkycoinProject/skywire-mainnet/pkg/snet" "github.com/SkycoinProject/skywire-mainnet/pkg/snet/snettest" - - "github.com/SkycoinProject/dmsg/cipher" - "github.com/SkycoinProject/skycoin/src/util/logging" - "github.com/google/uuid" ) // ManagerConfig configures a Manager. diff --git a/pkg/transport/manager_test.go b/pkg/transport/manager_test.go index da682e436..0e7566c97 100644 --- a/pkg/transport/manager_test.go +++ b/pkg/transport/manager_test.go @@ -9,16 +9,15 @@ import ( "testing" "time" + "github.com/SkycoinProject/dmsg" + "github.com/SkycoinProject/dmsg/cipher" "github.com/SkycoinProject/skycoin/src/util/logging" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/SkycoinProject/skywire-mainnet/pkg/routing" "github.com/SkycoinProject/skywire-mainnet/pkg/snet/snettest" "github.com/SkycoinProject/skywire-mainnet/pkg/transport" - - "github.com/SkycoinProject/dmsg" - "github.com/SkycoinProject/dmsg/cipher" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) var masterLogger *logging.MasterLogger diff --git a/pkg/visor/rpc_test.go b/pkg/visor/rpc_test.go index f72d6d181..d16ebe362 100644 --- a/pkg/visor/rpc_test.go +++ b/pkg/visor/rpc_test.go @@ -6,14 +6,13 @@ import ( "testing" "time" - "github.com/SkycoinProject/skywire-mainnet/pkg/visor/visorconfig" - - "github.com/SkycoinProject/skywire-mainnet/pkg/transport" - "github.com/SkycoinProject/dmsg/cipher" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/SkycoinProject/skywire-mainnet/pkg/transport" + "github.com/SkycoinProject/skywire-mainnet/pkg/visor/visorconfig" ) func baseConfig(t *testing.T) *visorconfig.V1 { diff --git a/pkg/visor/visor.go b/pkg/visor/visor.go index 82b2be7ea..b375a81f0 100644 --- a/pkg/visor/visor.go +++ b/pkg/visor/visor.go @@ -12,13 +12,11 @@ import ( "syscall" "time" - "github.com/SkycoinProject/skywire-mainnet/pkg/app/appevent" - "github.com/SkycoinProject/skywire-mainnet/pkg/visor/visorconfig" - "github.com/SkycoinProject/dmsg/cipher" "github.com/SkycoinProject/skycoin/src/util/logging" "github.com/sirupsen/logrus" + "github.com/SkycoinProject/skywire-mainnet/pkg/app/appevent" "github.com/SkycoinProject/skywire-mainnet/pkg/app/appserver" "github.com/SkycoinProject/skywire-mainnet/pkg/app/launcher" "github.com/SkycoinProject/skywire-mainnet/pkg/restart" @@ -27,6 +25,7 @@ import ( "github.com/SkycoinProject/skywire-mainnet/pkg/snet" "github.com/SkycoinProject/skywire-mainnet/pkg/transport" "github.com/SkycoinProject/skywire-mainnet/pkg/util/updater" + "github.com/SkycoinProject/skywire-mainnet/pkg/visor/visorconfig" ) var (