diff --git a/etcdctl/ctlv3/command/elect_command.go b/etcdctl/ctlv3/command/elect_command.go index 19ab05af9..74216f3e6 100644 --- a/etcdctl/ctlv3/command/elect_command.go +++ b/etcdctl/ctlv3/command/elect_command.go @@ -18,6 +18,7 @@ import ( "errors" "os" "os/signal" + "syscall" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" @@ -73,7 +74,7 @@ func observe(c *clientv3.Client, election string) error { donec := make(chan struct{}) sigc := make(chan os.Signal, 1) - signal.Notify(sigc, os.Interrupt, os.Kill) + signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM) go func() { <-sigc cancel() @@ -107,7 +108,7 @@ func campaign(c *clientv3.Client, election string, prop string) error { donec := make(chan struct{}) sigc := make(chan os.Signal, 1) - signal.Notify(sigc, os.Interrupt, os.Kill) + signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM) go func() { <-sigc cancel() diff --git a/etcdctl/ctlv3/command/lock_command.go b/etcdctl/ctlv3/command/lock_command.go index 148edaa9e..2e55c49df 100644 --- a/etcdctl/ctlv3/command/lock_command.go +++ b/etcdctl/ctlv3/command/lock_command.go @@ -18,6 +18,7 @@ import ( "errors" "os" "os/signal" + "syscall" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" @@ -57,7 +58,7 @@ func lockUntilSignal(c *clientv3.Client, lockname string) error { // unlock in case of ordinary shutdown donec := make(chan struct{}) sigc := make(chan os.Signal, 1) - signal.Notify(sigc, os.Interrupt, os.Kill) + signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM) go func() { <-sigc cancel() diff --git a/main_test.go b/main_test.go index 0f5dfb983..371ff1d0a 100644 --- a/main_test.go +++ b/main_test.go @@ -29,7 +29,7 @@ func TestMain(t *testing.T) { } notifier := make(chan os.Signal, 1) - signal.Notify(notifier, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL) + signal.Notify(notifier, syscall.SIGINT, syscall.SIGTERM) go main() <-notifier } diff --git a/pkg/netutil/netutil_test.go b/pkg/netutil/netutil_test.go index 1ce0c5736..c8d9f7994 100644 --- a/pkg/netutil/netutil_test.go +++ b/pkg/netutil/netutil_test.go @@ -150,7 +150,10 @@ func TestURLsEqual(t *testing.T) { "second.com": "10.0.11.2", } resolveTCPAddr = func(network, addr string) (*net.TCPAddr, error) { - host, port, err := net.SplitHostPort(addr) + host, port, herr := net.SplitHostPort(addr) + if herr != nil { + return nil, herr + } if _, ok := hostm[host]; !ok { return nil, errors.New("cannot resolve host.") } diff --git a/test b/test index b0cd5a102..325cde746 100755 --- a/test +++ b/test @@ -250,16 +250,15 @@ function fmt_pass { if which gosimple >/dev/null; then echo "Checking gosimple..." gosimpleResult=`gosimple ${STATIC_ANALYSIS_PATHS} 2>&1 || true` - if [ ! -n "${gosimpleResult}" ]; then - continue - fi - # TODO: resolve these after go1.8 migration - SIMPLE_CHECK_MASK="S(1024)" - if egrep -v "$SIMPLE_CHECK_MASK" "${gosimpleResult}"; then - echo -e "gosimple checking ${path} failed:\n${gosimpleResult}" - exit 255 - else - echo -e "gosimple warning:\n${gosimpleResult}" + if [ -n "${gosimpleResult}" ]; then + # TODO: resolve these after go1.8 migration + SIMPLE_CHECK_MASK="S(1024)" + if echo "${gosimpleResult}" | egrep -v "$SIMPLE_CHECK_MASK"; then + echo -e "gosimple checking ${path} failed:\n${gosimpleResult}" + exit 255 + else + echo -e "gosimple warning:\n${gosimpleResult}" + fi fi else echo "Skipping gosimple..." @@ -279,17 +278,17 @@ function fmt_pass { if which staticcheck >/dev/null; then echo "Checking staticcheck..." staticcheckResult=`staticcheck ${STATIC_ANALYSIS_PATHS} 2>&1 || true` - if [ ! -n "${staticcheckResult}" ]; then - continue - fi - # TODO: resolve these after go1.8 migration - # See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck - STATIC_CHECK_MASK="SA(1016|1019|2002)" - if egrep -v "$STATIC_CHECK_MASK" "${staticcheckResult}"; then - echo -e "staticcheck checking ${path} failed:\n${staticcheckResult}" - exit 255 - else - echo -e "staticcheck warning:\n${staticcheckResult}" + if [ -n "${staticcheckResult}" ]; then + # TODO: resolve these after go1.8 migration + # See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck + STATIC_CHECK_MASK="SA(1019|2002)" + if echo "${staticcheckResult}" | egrep -v "$STATIC_CHECK_MASK"; then + echo -e "staticcheck checking ${path} failed:\n${staticcheckResult}" + exit 255 + else + suppressed=`echo "${staticcheckResult}" | sed 's/ /\n/g' | grep "(SA" | sort | uniq -c` + echo -e "staticcheck suppressed warnings:\n${suppressed}" + fi fi else echo "Skipping staticcheck..."