Skip to content

Commit 89b5331

Browse files
committed
Fix gocritic emptyStringTest issues
See, $ golangci-lint run --disable-all --enable=gocritic --skip-dirs vim25/xml --config ./.golangci.yml | grep emptyStringTest find/finder.go:256:5: emptyStringTest: replace `len(path) == 0` with `path == ""` (gocritic) govc/datastore/ls.go:204:8: emptyStringTest: replace `len(p) != 0` with `p != ""` (gocritic)
1 parent 63ba923 commit 89b5331

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

client_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestNewClient(t *testing.T) {
4646
if err != nil {
4747
return err
4848
}
49-
if len(x.Name) == 0 {
49+
if x.Name == "" {
5050
return errors.New("empty response")
5151
}
5252
return nil

find/finder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func (f *Finder) managedObjectList(ctx context.Context, path string, tl bool, in
253253
fn = f.dcReference
254254
}
255255

256-
if len(path) == 0 {
256+
if path == "" {
257257
path = "."
258258
}
259259

govc/datastore/ls.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (o *listOutput) add(r types.HostDatastoreBrowserSearchResults) {
201201
}
202202

203203
for _, p := range path {
204-
if len(p) != 0 && p[0] == '.' {
204+
if p != "" && p[0] == '.' {
205205
return
206206
}
207207
}

object/datastore_path.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type DatastorePath struct {
3131
// FromString parses a datastore path.
3232
// Returns true if the path could be parsed, false otherwise.
3333
func (p *DatastorePath) FromString(s string) bool {
34-
if len(s) == 0 {
34+
if s == "" {
3535
return false
3636
}
3737

0 commit comments

Comments
 (0)