From 16bfd2bf15d0f4fc90324d3625e081c97ec2eda1 Mon Sep 17 00:00:00 2001 From: CodeLingo Bot Date: Tue, 5 Feb 2019 05:53:02 +0000 Subject: [PATCH] Fix error formatting based on best practices from Code Review Comments Signed-off-by: CodeLingo Bot --- api.go | 2 +- daemon.go | 2 +- listeners.go | 4 ++-- nfs.go | 2 +- vm.go | 14 +++++++------- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/api.go b/api.go index 9a37048..326dbcd 100644 --- a/api.go +++ b/api.go @@ -16,7 +16,7 @@ type API struct { func extractUser(r *http.Request) (*User, error) { userHeader, ok := r.Header["X-Username"] if !ok { - return nil, fmt.Errorf("Missing X-Username header") + return nil, fmt.Errorf("missing X-Username header") } return lookupUser(userHeader[0]) diff --git a/daemon.go b/daemon.go index f13c3ba..34d28bf 100644 --- a/daemon.go +++ b/daemon.go @@ -66,7 +66,7 @@ func (d *Daemon) Shutdown() { d.Proxy.Stop() d.API.Stop() d.DNS.Stop() - d.Error <- fmt.Errorf("Shutting down privileged daemon") + d.Error <- fmt.Errorf("shutting down privileged daemon") } func (d *Daemon) Wait() []error { diff --git a/listeners.go b/listeners.go index 46c6778..7573383 100644 --- a/listeners.go +++ b/listeners.go @@ -16,7 +16,7 @@ func (l *tcpListener) Accept() (net.Conn, error) { l.SetDeadline(time.Now().Add(time.Second)) select { case <-l.done: - return nil, fmt.Errorf("Server closed") + return nil, fmt.Errorf("server closed") default: } @@ -47,7 +47,7 @@ func (s *unixListener) Accept() (net.Conn, error) { s.SetDeadline(time.Now().Add(time.Second)) select { case <-s.done: - return nil, fmt.Errorf("Server closed") + return nil, fmt.Errorf("server closed") default: } diff --git a/nfs.go b/nfs.go index 109d270..69e2dff 100644 --- a/nfs.go +++ b/nfs.go @@ -54,7 +54,7 @@ func ensureNFS(home string) error { output, err := exec.Command("nfsd", "checkexports").Output() if err != nil { - return fmt.Errorf("There was a problem updating the /etc/exports file, please resolve the issue and run 'sudo nfsd restart'\n%s", string(output)) + return fmt.Errorf("there was a problem updating the /etc/exports file, please resolve the issue and run 'sudo nfsd restart'\n%s", string(output)) } output, _ = exec.Command("nfsd", "status").Output() diff --git a/vm.go b/vm.go index 975ecb2..6a6a497 100644 --- a/vm.go +++ b/vm.go @@ -66,7 +66,7 @@ type VM struct { func (vm *VM) Start() error { if vm.Process != nil { - return fmt.Errorf("Virtual machine is already running") + return fmt.Errorf("virtual machine is already running") } vm.Process = exec.Command(vm.Bin, vm.Args...) @@ -101,7 +101,7 @@ func (vm *VM) waitForBoot() error { for { if attempts >= 30 { - return fmt.Errorf("Timed out waiting for virtual machine") + return fmt.Errorf("timed out waiting for virtual machine") } time.Sleep(time.Second) @@ -146,7 +146,7 @@ func (vm *VM) Route() error { routeIfaceMatcher := regexp.MustCompile(`(?m)^\s*interface:\s*(\w+)$`) routeIfaceMatches := routeIfaceMatcher.FindAllStringSubmatch(string(routeBytes), -1) if routeIfaceMatches == nil { - return fmt.Errorf("Unable to find interface") + return fmt.Errorf("unable to find interface") } routeIface := routeIfaceMatches[0][1] @@ -159,7 +159,7 @@ func (vm *VM) Route() error { memberMatcher := regexp.MustCompile(`(?m)^\s*member:\s*(.*) flags.*$`) memberMatches := memberMatcher.FindAllStringSubmatch(string(memberBytes), -1) if memberMatches == nil { - return fmt.Errorf("Unable to find interface members") + return fmt.Errorf("unable to find interface members") } members := strings.Split(memberMatches[0][1], " ") @@ -199,7 +199,7 @@ func (vm *VM) dockerSubnet() (string, error) { } } - return "", fmt.Errorf("Unable to find bridge network") + return "", fmt.Errorf("unable to find bridge network") } func (vm *VM) findContainer(name string) (string, error) { @@ -226,7 +226,7 @@ func (vm *VM) findContainer(name string) (string, error) { return container.NetworkSettings.IPAddress, nil } - return "", fmt.Errorf("Unable to find container") + return "", fmt.Errorf("unable to find container") } func (vm *VM) Stop() error { @@ -261,7 +261,7 @@ func (vm *VM) IP() (string, error) { attempts := 0 for { if attempts >= 15 { - value <- result{"", fmt.Errorf("Timed out waiting for IP address")} + value <- result{"", fmt.Errorf("timed out waiting for IP address")} break }