Skip to content

Commit

Permalink
fix: golangci-lint error
Browse files Browse the repository at this point in the history
Signed-off-by: PoAn Yang <[email protected]>
  • Loading branch information
FrankYang0529 authored and derekbit committed Apr 26, 2024
1 parent 220a127 commit 9a8e1a4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 22 deletions.
8 changes: 6 additions & 2 deletions pkg/jsonrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ func (c *Client) SendMsgWithTimeout(method string, params interface{}, timeout t
// For debug purpose
stdenc := json.NewEncoder(os.Stdin)
stdenc.SetIndent("", "\t")
stdenc.Encode(msg)
stdenc.Encode(&resp)
if encodeErr := stdenc.Encode(msg); encodeErr != nil {
logrus.WithError(encodeErr).Warn("failed to encode the request message")
}
if encodeErr := stdenc.Encode(&resp); encodeErr != nil {
logrus.WithError(encodeErr).Warn("failed to encode the response message")
}
}()

marshaledParams, err := json.Marshal(msg.Params)
Expand Down
3 changes: 2 additions & 1 deletion pkg/spdk/spdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func (s *TestSuite) TestSPDKBasic(c *C) {
c.Assert(err, IsNil)

// Do blindly cleanup
spdkCli.DeleteDevice(defaultDeviceName, defaultDeviceName)
err = spdkCli.DeleteDevice(defaultDeviceName, defaultDeviceName)
c.Assert(err, IsNil)

bdevAioName, lvsName, lvsUUID, err := spdkCli.AddDevice(defaultDevicePath, defaultDeviceName, types.MiB)
c.Assert(err, IsNil)
Expand Down
4 changes: 0 additions & 4 deletions pkg/spdk/types/bdev.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ type BdevGetBdevsRequest struct {
Timeout uint64 `json:"timeout,omitempty"`
}

type BdevGetBdevsResponse struct {
bdevs []BdevInfo
}

type BdevLvolFragmap struct {
ClusterSize uint64 `json:"cluster_size"`
NumClusters uint64 `json:"num_clusters"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func DetectDevice(path string, executor *commonNs.Executor) (*KernelDevice, erro
return nil, fmt.Errorf("invalid major:minor %s for device %s with path %s", dev.Nvme.Name, f[1], path)
}
}
break
break // nolint:staticcheck
}
if dev == nil {
return nil, fmt.Errorf("failed to get device with path %s", path)
Expand Down
16 changes: 2 additions & 14 deletions scripts/validate
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,8 @@ PACKAGES="$(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u |
echo Running: go vet
go vet ${PACKAGES}

if [ ! -z "${DRONE_REPO}" ] && [ ! -z "${DRONE_PULL_REQUEST}" ]; then
wget https://github.com/$DRONE_REPO/pull/$DRONE_PULL_REQUEST.patch
echo "Running: golangci-lint run --new-from-patch=${DRONE_PULL_REQUEST}.patch"
golangci-lint run --new-from-patch="${DRONE_PULL_REQUEST}.patch"
rm "${DRONE_PULL_REQUEST}.patch"
elif [ ! -z "${DRONE_COMMIT_REF}" ]; then
echo "Running: golangci-lint run --new-from-rev=${DRONE_COMMIT_REF}"
golangci-lint run --new-from-rev=${DRONE_COMMIT_REF}
else
git symbolic-ref -q HEAD && REV="origin/HEAD" || REV="HEAD^"
headSHA=$(git rev-parse --short=12 ${REV})
echo "Running: golangci-lint run --new-from-rev=${headSHA}"
golangci-lint run --new-from-rev=${headSHA}
fi
echo "Running: golangci-lint"
golangci-lint run --timeout=5m

echo Running: go fmt
test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)"

0 comments on commit 9a8e1a4

Please sign in to comment.