diff --git a/build/check.js b/build/check.js index 35c6bb925fd674388623903353d3a92701b5bcbb..891458b6cdbf8fc7187449a13998608eb15f5fe3 100644 --- a/build/check.js +++ b/build/check.js @@ -28,7 +28,7 @@ import path from 'path'; import through from 'through2'; import conf from './conf'; -import {gofmtCommand} from './gocommand'; +import {goimportsCommand} from './gocommand'; /** HTML beautifier from js-beautify package */ const htmlBeautify = beautify.html; @@ -126,10 +126,10 @@ gulp.task('format-html', function() { }); /** - * Formats all project's Go files using gofmt. + * Formats all project's Go files using goimports tool. */ gulp.task('format-go', function(doneFn) { - gofmtCommand( + goimportsCommand( [ '-w', path.relative(conf.paths.base, conf.paths.backendSrc), diff --git a/build/gocommand.js b/build/gocommand.js index 60df3fe00c5d6f1b350f8ea5dc2252e35a334575..b24ae1c8447cad0b77357dd9e1cf979d6da4fae0 100644 --- a/build/gocommand.js +++ b/build/gocommand.js @@ -55,15 +55,15 @@ export default function goCommand(args, doneFn, envOverride) { } /** - * Spawns a Gofmt process after making sure all Go prerequisites are present. + * Spawns a goimports process after making sure all Go prerequisites are present. * * @param {!Array} args - Arguments of the go command. * @param {function(?Error=)} doneFn - Callback. * @param {!Object=} [envOverride] optional environment variables overrides map. */ -export function gofmtCommand(args, doneFn, envOverride) { +export function goimportsCommand(args, doneFn, envOverride) { checkPrerequisites() - .then(() => spawnGofmtProcess(args, envOverride)) + .then(() => spawnGoimportsProcess(args, envOverride)) .then(doneFn) .fail((error) => doneFn(error)); } @@ -205,13 +205,13 @@ function spawnGoProcess(args, envOverride) { } /** - * Spawns gofmt process. + * Spawns goimports process. * Promises an error if the go command process fails. * * @param {!Array} args - Arguments of the go command. * @param {!Object=} [envOverride] optional environment variables overrides map. * @return {Q.Promise} A promise object. */ -function spawnGofmtProcess(args, envOverride) { - return spawnProcess('gofmt', args, envOverride); +function spawnGoimportsProcess(args, envOverride) { + return spawnProcess('goimports', args, envOverride); } diff --git a/docs/devel/getting-started.md b/docs/devel/getting-started.md index 4aed8f040d77e56e5ea1dd4e4ba5fb398945a890..19f8e345ac8fc924339322da669a997c7376f3df 100644 --- a/docs/devel/getting-started.md +++ b/docs/devel/getting-started.md @@ -173,7 +173,7 @@ $ gulp check-javascript-format Before committing any changes, please link/copy the pre-commit hook into your .git directory. This will keep you from accidentally committing non formatted code. -The hook requires gofmt to be in your PATH. +The hook requires goimports to be in your PATH. ```shell cd /.git/hooks/ diff --git a/hooks/pre-commit b/hooks/pre-commit index 94b37e03f7234bfad55cffbbd2d3edb10a03a1ef..a7ae3bb80d1bc79777c58e7243a9d073dc1020b2 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -5,7 +5,7 @@ readonly red=$(tput bold; tput setaf 1) readonly green=$(tput bold; tput setaf 2) exit_code=0 -gofmt_available=false +goimports_available=false gulp_available=false # Pre checks @@ -20,13 +20,13 @@ else fi echo "${reset}" -echo -ne "Checking if gofmt is available in your PATH... " -if ! OUT=$(which gofmt 2>&1); then +echo -ne "Checking if goimports is available in your PATH... " +if ! OUT=$(which goimports 2>&1); then echo "${red}ERROR!" - echo "Please add gofmt to your PATH" + echo "Please add goimports to your PATH" exit_code=1 else - gofmt_available=true + goimports_available=true echo "${green}OK" fi @@ -44,15 +44,15 @@ if ${gulp_available}; then fi fi -if ${gofmt_available}; then +if ${goimports_available}; then echo "${reset}" echo -ne "Checking go files formatting... " - unformatted=$(gofmt -l src/app/backend) + unformatted=$(goimports -l src/app/backend) if [ ! -z "$unformatted" ]; then echo "${red}ERROR!" echo "There is an issue with file formatting." echo "To format go files run:" - echo " gofmt -w src/app/backend" + echo " goimports -w src/app/backend" exit_code=1 else echo "${green}OK" diff --git a/src/app/backend/client/manager.go b/src/app/backend/client/manager.go index 5b3a9eb675e2d4d4a634d7b525e1ae40ebd1ce58..96ca3724506a9f72a407c62c827b660ce508a210 100644 --- a/src/app/backend/client/manager.go +++ b/src/app/backend/client/manager.go @@ -20,7 +20,7 @@ import ( "log" "strings" - "github.com/emicklei/go-restful" + restful "github.com/emicklei/go-restful" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" diff --git a/src/app/backend/client/manager_test.go b/src/app/backend/client/manager_test.go index 6410ea7f2c6f47225672c42edadc9234a928b504..90a8c321155f0e9f6b5bffb848a58ebe97f5f0fe 100644 --- a/src/app/backend/client/manager_test.go +++ b/src/app/backend/client/manager_test.go @@ -18,7 +18,7 @@ import ( "net/http" "testing" - "github.com/emicklei/go-restful" + restful "github.com/emicklei/go-restful" ) func TestNewClientManager(t *testing.T) { diff --git a/src/app/backend/handler/apihandler.go b/src/app/backend/handler/apihandler.go index 3f74feb7ce7056d8d531699a5a7cdb3f0d139ecc..f03781aafd8ea7eebf07faf668a5eea9f42bfbfc 100644 --- a/src/app/backend/handler/apihandler.go +++ b/src/app/backend/handler/apihandler.go @@ -20,7 +20,7 @@ import ( "strconv" "strings" - "github.com/emicklei/go-restful" + restful "github.com/emicklei/go-restful" "github.com/kubernetes/dashboard/src/app/backend/api" "github.com/kubernetes/dashboard/src/app/backend/client" "github.com/kubernetes/dashboard/src/app/backend/integration" diff --git a/src/app/backend/handler/apihandler_test.go b/src/app/backend/handler/apihandler_test.go index 4bb790f6d7dd13babd3adfb3b55c88522ca6316e..14ccce0a20d2cb6ead42bdb98837af6f2bea1a47 100644 --- a/src/app/backend/handler/apihandler_test.go +++ b/src/app/backend/handler/apihandler_test.go @@ -22,7 +22,7 @@ import ( "reflect" "strings" - "github.com/emicklei/go-restful" + restful "github.com/emicklei/go-restful" "github.com/kubernetes/dashboard/src/app/backend/client" ) diff --git a/src/app/backend/handler/filter.go b/src/app/backend/handler/filter.go index 28722ddac79087cbd4fcb4a56f4fbc5d0b9bcffe..1981910522b5e37c64a81cfa63af2c098c2b9671 100644 --- a/src/app/backend/handler/filter.go +++ b/src/app/backend/handler/filter.go @@ -23,7 +23,7 @@ import ( "strings" "time" - "github.com/emicklei/go-restful" + restful "github.com/emicklei/go-restful" "github.com/kubernetes/dashboard/src/app/backend/client" "golang.org/x/net/xsrftoken" utilnet "k8s.io/apimachinery/pkg/util/net" diff --git a/src/app/backend/integration/handler.go b/src/app/backend/integration/handler.go index 08d0bf0bdc9faabb3cb88d7f5ffa0e489a2cfaf2..06b1c4dd1891c66739ee6ffb3993f9ab3ed26519 100644 --- a/src/app/backend/integration/handler.go +++ b/src/app/backend/integration/handler.go @@ -17,7 +17,7 @@ package integration import ( "net/http" - "github.com/emicklei/go-restful" + restful "github.com/emicklei/go-restful" "github.com/kubernetes/dashboard/src/app/backend/integration/api" ) diff --git a/src/app/backend/integration/handler_test.go b/src/app/backend/integration/handler_test.go index 07657184e76e9e89b91c0a0ac547ebdb71ee7ed8..70ca1350c508e05efc7453324ee5b7906b87841b 100644 --- a/src/app/backend/integration/handler_test.go +++ b/src/app/backend/integration/handler_test.go @@ -17,7 +17,7 @@ package integration import ( "testing" - "github.com/emicklei/go-restful" + restful "github.com/emicklei/go-restful" ) func TestIntegrationHandler_Install(t *testing.T) {