diff --git a/govc/cluster/rule/ls.go b/govc/cluster/rule/ls.go index 0d37a8a45..d163ceaa8 100644 --- a/govc/cluster/rule/ls.go +++ b/govc/cluster/rule/ls.go @@ -77,7 +77,7 @@ func (cmd *ls) Run(ctx context.Context, f *flag.FlagSet) error { ruleTypeInfo := GetExtendedClusterRuleInfo(g).ruleType res = append(res, fmt.Sprintf("%s (%s)", ruleName, ruleTypeInfo)) } else { - res = append(res, fmt.Sprintf("%s", ruleName)) + res = append(res, ruleName) } } } else { diff --git a/govc/dvs/portgroup/info.go b/govc/dvs/portgroup/info.go index 31fdff1a1..10997d533 100644 --- a/govc/dvs/portgroup/info.go +++ b/govc/dvs/portgroup/info.go @@ -102,11 +102,12 @@ type infoResult struct { func printPort(port types.BaseDvsIpPort) string { if port != nil { - switch port.(type) { + switch portType := port.(type) { case *types.DvsSingleIpPort: - return fmt.Sprintf("%d", port.(*types.DvsSingleIpPort).PortNumber) + return fmt.Sprintf("%d", portType.PortNumber) case *types.DvsIpPortRange: - return fmt.Sprintf("%d-%d", port.(*types.DvsIpPortRange).StartPortNumber, port.(*types.DvsIpPortRange).EndPortNumber) + return fmt.Sprintf("%d-%d", portType.StartPortNumber, + portType.EndPortNumber) } } return "Any" @@ -116,7 +117,7 @@ func printAddress(address types.BaseIpAddress) string { if address != nil { switch (address).(type) { case *types.SingleIp: - return fmt.Sprintf("%s", address.(*types.SingleIp).Address) + return address.(*types.SingleIp).Address case *types.IpRange: return fmt.Sprintf("%s/%d", address.(*types.IpRange).AddressPrefix, address.(*types.IpRange).PrefixLength) } diff --git a/govc/object/collect.go b/govc/object/collect.go index 816ce7e50..1bf436ed9 100644 --- a/govc/object/collect.go +++ b/govc/object/collect.go @@ -413,7 +413,6 @@ func (cmd *collect) Run(ctx context.Context, f *flag.FlagSet) error { if matches > 0 { return true } - return false } diff --git a/govc/vm/network/add.go b/govc/vm/network/add.go index ba5e17712..66f0aa1f4 100644 --- a/govc/vm/network/add.go +++ b/govc/vm/network/add.go @@ -74,8 +74,8 @@ func (cmd *add) Run(ctx context.Context, f *flag.FlagSet) error { if f.NArg() > 0 { err = cmd.NetworkFlag.Set(f.Arg(0)) if err != nil { - return errors.New(fmt.Sprintf("couldn't set specified network %v", - err)) + return fmt.Errorf("couldn't set specified network %v", + err) } } diff --git a/govc/vm/network/change.go b/govc/vm/network/change.go index ea5540a27..aa1cf459e 100644 --- a/govc/vm/network/change.go +++ b/govc/vm/network/change.go @@ -87,8 +87,8 @@ func (cmd *change) Run(ctx context.Context, f *flag.FlagSet) error { if f.NArg() > 1 { err = cmd.NetworkFlag.Set(f.Arg(1)) if err != nil { - return errors.New(fmt.Sprintf("couldn't set specified network %v", - err)) + return fmt.Errorf("couldn't set specified network %v", + err) } } diff --git a/object/diagnostic_manager.go b/object/diagnostic_manager.go index 5baf1ad90..026dc1cb5 100644 --- a/object/diagnostic_manager.go +++ b/object/diagnostic_manager.go @@ -71,10 +71,8 @@ func (m DiagnosticManager) GenerateLogBundles(ctx context.Context, includeDefaul IncludeDefault: includeDefault, } - if host != nil { - for _, h := range host { - req.Host = append(req.Host, h.Reference()) - } + for _, h := range host { + req.Host = append(req.Host, h.Reference()) } res, err := methods.GenerateLogBundles_Task(ctx, m.c, &req) diff --git a/simulator/host_datastore_browser.go b/simulator/host_datastore_browser.go index 6dd5a9956..a882c9b44 100644 --- a/simulator/host_datastore_browser.go +++ b/simulator/host_datastore_browser.go @@ -128,12 +128,13 @@ func (s *searchDatastore) queryMatch(file os.FileInfo) bool { } case *types.VmDiskFileQuery: if ext == ".vmdk" { - if strings.HasSuffix(name, "-flat.vmdk") { - // only matches the descriptor, not the backing file(s) - return false - } + // if strings.HasSuffix(name, "-flat.vmdk") { + // // only matches the descriptor, not the backing file(s) + // return false + //} // TODO: check Filter and Details fields - return true + //return true + return !strings.HasSuffix(name, "-flat.vmdk") } case *types.VmLogFileQuery: if ext == ".log" { diff --git a/test/functional/helper.go b/test/functional/helper.go index 306192638..8f38279c0 100644 --- a/test/functional/helper.go +++ b/test/functional/helper.go @@ -115,7 +115,7 @@ func (h *Helper) LocalDatastores(ctx context.Context, cr *object.ComputeResource switch i := mds.Info.(type) { case *types.VmfsDatastoreInfo: - if i.Vmfs.Local != nil && *i.Vmfs.Local == true { + if i.Vmfs.Local != nil && *i.Vmfs.Local { break } default: diff --git a/toolbox/process_test.go b/toolbox/process_test.go index 4896eb3e3..b846666bf 100644 --- a/toolbox/process_test.go +++ b/toolbox/process_test.go @@ -226,9 +226,7 @@ func TestEscapeXML(t *testing.T) { func TestProcessError(t *testing.T) { fault := errors.New("fail") - var err error - - err = &ProcessError{Err: fault} + var err error = &ProcessError{Err: fault} if err.Error() != fault.Error() { t.Fatal() diff --git a/toolbox/vix/protocol.go b/toolbox/vix/protocol.go index c15c45983..2709098f0 100644 --- a/toolbox/vix/protocol.go +++ b/toolbox/vix/protocol.go @@ -816,7 +816,7 @@ func (c *UserCredentialNamePassword) UnmarshalBinary(data []byte) error { return err } - str, err := base64.StdEncoding.DecodeString(string(buf.Bytes())) + str, err := base64.StdEncoding.DecodeString(buf.String()) if err != nil { return err } diff --git a/units/size_test.go b/units/size_test.go index 14772887b..9815d2329 100644 --- a/units/size_test.go +++ b/units/size_test.go @@ -17,7 +17,6 @@ limitations under the License. package units import ( - "fmt" "math" "testing" ) @@ -31,8 +30,7 @@ func TestMB(t *testing.T) { } func TestTenMB(t *testing.T) { - b := ByteSize(10 * 1024 * 1024) - actual := fmt.Sprintf("%s", b) + actual := ByteSize(10 * 1024 * 1024).String() expected := "10.0MB" if actual != expected { t.Errorf("Expected '%v' but got '%v'", expected, actual) diff --git a/vapi/library/finder/finder.go b/vapi/library/finder/finder.go index d3e1ae348..45da02011 100644 --- a/vapi/library/finder/finder.go +++ b/vapi/library/finder/finder.go @@ -71,9 +71,7 @@ func (f *Finder) find(ctx context.Context, ipath string) ([]FindResult, error) { } // Get the argument and remove any leading separator characters. - if strings.HasPrefix(ipath, "/") { - ipath = ipath[1:] - } + ipath = strings.TrimPrefix(ipath, "/") // Tokenize the path into its distinct parts. parts := strings.Split(ipath, "/")