From d6db19ed200955c628a4be21f931f6c4fee8987c Mon Sep 17 00:00:00 2001 From: tanjunchen <2799194073@qq.com> Date: Tue, 29 Oct 2019 13:54:27 +0800 Subject: [PATCH] fix-up staticcheck problems --- node-authorizer/cmd/node-authorizer/server.go | 2 +- node-authorizer/pkg/authorizers/aws/verifier.go | 4 ++-- node-authorizer/pkg/server/admission.go | 2 +- upup/pkg/fi/cloudup/alitasks/vpc.go | 2 +- upup/pkg/fi/cloudup/aliup/ali_cloud.go | 2 +- upup/pkg/fi/cloudup/awstasks/helper.go | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/node-authorizer/cmd/node-authorizer/server.go b/node-authorizer/cmd/node-authorizer/server.go index 4696b225f0..40f70eb94a 100644 --- a/node-authorizer/cmd/node-authorizer/server.go +++ b/node-authorizer/cmd/node-authorizer/server.go @@ -155,7 +155,7 @@ func actionServerCommand(ctx *cli.Context) error { // waitForCertificates is responsible for waiting for the certificates to appear func waitForCertificates(files []string, timeout time.Duration) error { - doneCh := make(chan struct{}, 0) + doneCh := make(chan struct{}) go func() { expires := time.Now().Add(timeout) diff --git a/node-authorizer/pkg/authorizers/aws/verifier.go b/node-authorizer/pkg/authorizers/aws/verifier.go index d684aba2ff..7dbadcfa66 100644 --- a/node-authorizer/pkg/authorizers/aws/verifier.go +++ b/node-authorizer/pkg/authorizers/aws/verifier.go @@ -49,8 +49,8 @@ func NewVerifier() (server.Verifier, error) { // Verify is responsible for build a identification document func (a *awsNodeVerifier) VerifyIdentity(ctx context.Context) ([]byte, error) { - errs := make(chan error, 0) - doneCh := make(chan []byte, 0) + errs := make(chan error) + doneCh := make(chan []byte) go func() { encoded, err := func() ([]byte, error) { diff --git a/node-authorizer/pkg/server/admission.go b/node-authorizer/pkg/server/admission.go index 438bb1e7d5..69f9d9a808 100644 --- a/node-authorizer/pkg/server/admission.go +++ b/node-authorizer/pkg/server/admission.go @@ -35,7 +35,7 @@ var ( // authorizeNodeRequest is responsible for handling the incoming authorization request func (n *NodeAuthorizer) authorizeNodeRequest(ctx context.Context, request *NodeRegistration) error { - doneCh := make(chan error, 0) + doneCh := make(chan error) // @step: create a context to run under ctx, cancel := context.WithTimeout(ctx, n.config.AuthorizationTimeout) diff --git a/upup/pkg/fi/cloudup/alitasks/vpc.go b/upup/pkg/fi/cloudup/alitasks/vpc.go index 1ee3d4d559..2db5ffedc7 100644 --- a/upup/pkg/fi/cloudup/alitasks/vpc.go +++ b/upup/pkg/fi/cloudup/alitasks/vpc.go @@ -79,7 +79,7 @@ func (e *VPC) Find(c *fi.Context) (*VPC, error) { } } - if vpcs == nil || len(vpcs) == 0 { + if len(vpcs) == 0 { return nil, nil } diff --git a/upup/pkg/fi/cloudup/aliup/ali_cloud.go b/upup/pkg/fi/cloudup/aliup/ali_cloud.go index 123f02d41f..567e40b816 100644 --- a/upup/pkg/fi/cloudup/aliup/ali_cloud.go +++ b/upup/pkg/fi/cloudup/aliup/ali_cloud.go @@ -328,7 +328,7 @@ func ZoneToVSwitchID(VPCID string, zones []string, vswitchIDs []string) (map[str return res, fmt.Errorf("error describing VPC: %v", err) } - if vpc == nil || len(vpc) == 0 { + if len(vpc) == 0 { return res, fmt.Errorf("VPC %q not found", VPCID) } diff --git a/upup/pkg/fi/cloudup/awstasks/helper.go b/upup/pkg/fi/cloudup/awstasks/helper.go index 360723fd1d..178f4a482e 100644 --- a/upup/pkg/fi/cloudup/awstasks/helper.go +++ b/upup/pkg/fi/cloudup/awstasks/helper.go @@ -42,7 +42,7 @@ func buildEphemeralDevices(cloud awsup.AWSCloud, machineType string) (map[string // buildAdditionalDevices is responsible for creating additional volumes in this lc func buildAdditionalDevices(volumes []*BlockDeviceMapping) (map[string]*BlockDeviceMapping, error) { - devices := make(map[string]*BlockDeviceMapping, 0) + devices := make(map[string]*BlockDeviceMapping) // @step: iterate the volumes and create devices from them for _, x := range volumes {