diff --git a/cmd/dominator/main.go b/cmd/dominator/main.go index d89131db..f41828e6 100644 --- a/cmd/dominator/main.go +++ b/cmd/dominator/main.go @@ -101,7 +101,7 @@ func main() { logger.Fatalln(err) } } - rlim := syscall.Rlimit{*fdLimit, *fdLimit} + rlim := syscall.Rlimit{Cur: *fdLimit, Max: *fdLimit} if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim); err != nil { fmt.Fprintf(os.Stderr, "Cannot set FD limit\t%s\n", err) os.Exit(1) diff --git a/cmd/hyper-control/getUpdates.go b/cmd/hyper-control/getUpdates.go index d81e317a..ec4741d1 100644 --- a/cmd/hyper-control/getUpdates.go +++ b/cmd/hyper-control/getUpdates.go @@ -70,7 +70,6 @@ func getUpdatesOnFleetManager(fleetManager string, return err } } - return nil } func getUpdatesOnHypervisor(hypervisor string, logger log.DebugLogger) error { @@ -94,5 +93,4 @@ func getUpdatesOnHypervisor(hypervisor string, logger log.DebugLogger) error { return err } } - return nil } diff --git a/cmd/hyper-control/installerShell.go b/cmd/hyper-control/installerShell.go index 71684fe8..0cd49acf 100644 --- a/cmd/hyper-control/installerShell.go +++ b/cmd/hyper-control/installerShell.go @@ -82,5 +82,4 @@ func installerShell(hostname string, logger log.DebugLogger) error { } } } - return nil } diff --git a/cmd/imagetool/addImagesub.go b/cmd/imagetool/addImagesub.go index be40ebce..d9b467f6 100644 --- a/cmd/imagetool/addImagesub.go +++ b/cmd/imagetool/addImagesub.go @@ -78,7 +78,7 @@ func copyMissingObjects(fs *filesystem.FileSystem, imageSClient *srpc.Client, objectClient *objectclient.ObjectClient, subName string) error { // Check to see which objects are in the objectserver. hashes := make([]hash.Hash, 0, fs.NumRegularInodes) - for hash, _ := range fs.HashToInodesTable() { + for hash := range fs.HashToInodesTable() { hashes = append(hashes, hash) } objectSizes, err := objectClient.CheckObjects(hashes) diff --git a/cmd/vm-control/traceMetadata.go b/cmd/vm-control/traceMetadata.go index c298babe..7898263d 100644 --- a/cmd/vm-control/traceMetadata.go +++ b/cmd/vm-control/traceMetadata.go @@ -71,7 +71,6 @@ func doTraceMetadata(client *srpc.Client, ipAddr net.IP, logger.Print(line) } } - return nil } func maybeWatchVm(client *srpc.Client, hypervisor string, ipAddr net.IP, diff --git a/dom/herd/sub.go b/dom/herd/sub.go index de10d026..e45a115c 100644 --- a/dom/herd/sub.go +++ b/dom/herd/sub.go @@ -260,7 +260,6 @@ func (sub *Sub) processFileUpdates() bool { return haveUpdates } } - return haveUpdates } func (sub *Sub) poll(srpcClient *srpc.Client, previousStatus subStatus) { diff --git a/dom/lib/buildUpdateRequest_test.go b/dom/lib/buildUpdateRequest_test.go index dad9c096..db6584a1 100644 --- a/dom/lib/buildUpdateRequest_test.go +++ b/dom/lib/buildUpdateRequest_test.go @@ -302,7 +302,7 @@ func testDataDirectory0() *filesystem.FileSystem { }, DirectoryInode: filesystem.DirectoryInode{ EntryList: []*filesystem.DirectoryEntry{ - &filesystem.DirectoryEntry{ + { Name: "dir0", InodeNumber: 1, }, @@ -319,11 +319,11 @@ func testDataDirectory01() *filesystem.FileSystem { }, DirectoryInode: filesystem.DirectoryInode{ EntryList: []*filesystem.DirectoryEntry{ - &filesystem.DirectoryEntry{ + { Name: "dir0", InodeNumber: 1, }, - &filesystem.DirectoryEntry{ + { Name: "dir1", InodeNumber: 2, }, @@ -339,7 +339,7 @@ func testDataDirectory2() *filesystem.FileSystem { }, DirectoryInode: filesystem.DirectoryInode{ EntryList: []*filesystem.DirectoryEntry{ - &filesystem.DirectoryEntry{ + { Name: "dir2", InodeNumber: 1, }, @@ -355,7 +355,7 @@ func testDataFile0(uid uint32) *filesystem.FileSystem { }, DirectoryInode: filesystem.DirectoryInode{ EntryList: []*filesystem.DirectoryEntry{ - &filesystem.DirectoryEntry{ + { Name: "file0", InodeNumber: 1, }, @@ -371,7 +371,7 @@ func testDataFile1(uid uint32) *filesystem.FileSystem { }, DirectoryInode: filesystem.DirectoryInode{ EntryList: []*filesystem.DirectoryEntry{ - &filesystem.DirectoryEntry{ + { Name: "file1", InodeNumber: 1, }, @@ -388,11 +388,11 @@ func testDataDuplicateFiles() *filesystem.FileSystem { }, DirectoryInode: filesystem.DirectoryInode{ EntryList: []*filesystem.DirectoryEntry{ - &filesystem.DirectoryEntry{ + { Name: "file1", InodeNumber: 1, }, - &filesystem.DirectoryEntry{ + { Name: "file2", InodeNumber: 2, }, diff --git a/hypervisor/manager/vm.go b/hypervisor/manager/vm.go index f3a1c9bd..5bb5c3cd 100644 --- a/hypervisor/manager/vm.go +++ b/hypervisor/manager/vm.go @@ -146,7 +146,7 @@ func (m *Manager) allocateVm(req proto.CreateVmRequest, if req.MilliCPUs < 1 { return nil, errors.New("no CPUs specified") } - subnetIDs := map[string]struct{}{req.SubnetId: struct{}{}} + subnetIDs := map[string]struct{}{req.SubnetId: {}} for _, subnetId := range req.SecondarySubnetIDs { if subnetId == "" { return nil, @@ -982,7 +982,7 @@ func (m *Manager) importLocalVm(authInfo *srpc.AuthInformation, manager: m, dirname: path.Join(m.StateDir, "VMs", ipAddress), ipAddress: ipAddress, - ownerUsers: map[string]struct{}{authInfo.Username: struct{}{}}, + ownerUsers: map[string]struct{}{authInfo.Username: {}}, logger: prefixlogger.New(ipAddress+": ", m.Logger), metadataChannels: make(map[chan<- string]struct{}), } @@ -1814,7 +1814,6 @@ func (m *Manager) startVm(ipAddr net.IP, authInfo *srpc.AuthInformation, default: return false, errors.New("unknown state: " + vm.State.String()) } - return false, nil } func (m *Manager) stopVm(ipAddr net.IP, authInfo *srpc.AuthInformation, diff --git a/imagebuilder/builder/bootstrapImage.go b/imagebuilder/builder/bootstrapImage.go index 58265f61..c0974049 100644 --- a/imagebuilder/builder/bootstrapImage.go +++ b/imagebuilder/builder/bootstrapImage.go @@ -28,9 +28,9 @@ const ( ) var environmentToCopy = map[string]struct{}{ - "PATH": struct{}{}, - "TZ": struct{}{}, - "SHELL": struct{}{}, + "PATH": {}, + "TZ": {}, + "SHELL": {}, } var environmentToSet = map[string]string{ diff --git a/imagepublishers/amipublisher/copyBootstrapImage.go b/imagepublishers/amipublisher/copyBootstrapImage.go index c36c3790..7c5c08cb 100644 --- a/imagepublishers/amipublisher/copyBootstrapImage.go +++ b/imagepublishers/amipublisher/copyBootstrapImage.go @@ -38,8 +38,8 @@ func copyBootstrapImage(streamName string, targets awsutil.TargetList, instanceType string, sshKeyName string, logger log.Logger) error { imageSearchTags := libtags.Tags{"Name": streamName} type resultType struct { - targetResult - error error + targetResult *targetResult + error error } resultsChannel := make(chan *resultType, 1) numTargets, err := awsutil.ForEachTarget(targets, skipList, @@ -62,7 +62,7 @@ func copyBootstrapImage(streamName string, targets awsutil.TargetList, err = result.error } } else { - target := &result.targetResult + target := result.targetResult targetResults = append(targetResults, target) if target.client != nil { if stream, ok := target.status.ImageStreams[streamName]; ok { @@ -114,7 +114,7 @@ func copyBootstrapImage(streamName string, targets awsutil.TargetList, func probeTarget(awsService *ec2.EC2, streamName string, imageSearchTags libtags.Tags, unpackerName string, logger log.Logger) ( - targetResult, error) { + *targetResult, error) { var result targetResult instance, client, err := getWorkingUnpacker(awsService, unpackerName, logger) @@ -130,10 +130,10 @@ func probeTarget(awsService *ec2.EC2, streamName string, image, err := findImage(awsService, imageSearchTags) if err != nil { logger.Println(err) - return result, err + return nil, err } result.image = image - return result, nil + return &result, nil } func (target *targetResult) bootstrap(streamName string, diff --git a/lib/filesystem/untar/decode.go b/lib/filesystem/untar/decode.go index bc1d40be..fb17d2d0 100644 --- a/lib/filesystem/untar/decode.go +++ b/lib/filesystem/untar/decode.go @@ -100,7 +100,6 @@ func (decoderData *decoderData) addHeader(tarReader *tar.Reader, hasher Hasher, return errors.New(fmt.Sprintf("Unsupported file type: %v", header.Typeflag)) } - return nil } func (decoderData *decoderData) addRegularFile(tarReader *tar.Reader, diff --git a/lib/fsutil/watchFile_test.go b/lib/fsutil/watchFile_test.go index d79aeea8..a4330e9a 100644 --- a/lib/fsutil/watchFile_test.go +++ b/lib/fsutil/watchFile_test.go @@ -112,5 +112,4 @@ func watchTimeout(channel <-chan io.ReadCloser, timeout time.Duration) ( case <-time.After(timeout): return nil, errorTimeout } - panic("impossible") } diff --git a/lib/net/proxy/common.go b/lib/net/proxy/common.go index 27bd722d..9eafac40 100644 --- a/lib/net/proxy/common.go +++ b/lib/net/proxy/common.go @@ -41,5 +41,4 @@ func newDialer(proxy string) (Dialer, error) { return nil, errorUnsupportedProxy } } - return nil, nil } diff --git a/lib/net/reverseconnection/listener.go b/lib/net/reverseconnection/listener.go index 4a45182e..fe337f5f 100644 --- a/lib/net/reverseconnection/listener.go +++ b/lib/net/reverseconnection/listener.go @@ -277,7 +277,6 @@ func (l *Listener) connect(network, serverAddress string, timeout time.Duration, // Wait for other side to consume. if _, err := rawConn.Read(buffer); err != nil { return nil, errors.New("error reading sync byte: " + err.Error()) - return nil, err } logger.Println("remote has consumed, injecting to local listener") l.remember(rawConn) diff --git a/lib/netspeed/impl.go b/lib/netspeed/impl.go index bf9f9033..6d03eca6 100644 --- a/lib/netspeed/impl.go +++ b/lib/netspeed/impl.go @@ -106,7 +106,7 @@ func findInterfaceForHost(hostname string) (string, error) { func intToIP(ip uint32) net.IP { result := make(net.IP, 4) - for i, _ := range result { + for i := range result { result[i] = byte(ip >> uint(8*i)) } return result diff --git a/lib/objectserver/client/getObjects.go b/lib/objectserver/client/getObjects.go index 954dd113..d1e203bc 100644 --- a/lib/objectserver/client/getObjects.go +++ b/lib/objectserver/client/getObjects.go @@ -55,5 +55,5 @@ func (or *ObjectsReader) nextObject() (uint64, io.ReadCloser, error) { } size := or.sizes[or.nextIndex] return size, - ioutil.NopCloser(&io.LimitedReader{or.reader, int64(size)}), nil + ioutil.NopCloser(&io.LimitedReader{R: or.reader, N: int64(size)}), nil } diff --git a/sub/scanner/api.go b/sub/scanner/api.go index 536b1b38..a5b6eb20 100644 --- a/sub/scanner/api.go +++ b/sub/scanner/api.go @@ -76,7 +76,7 @@ func (fsh *FileSystemHistory) ScanCount() uint64 { return fsh.scanCount } -func (fsh FileSystemHistory) String() string { +func (fsh *FileSystemHistory) String() string { fsh.rwMutex.RLock() defer fsh.rwMutex.RUnlock() return fmt.Sprintf("GenerationCount=%d\n", fsh.generationCount)