[lxc-devel] [lxd/master] Drop unnecessary else statement

freeekanayaka on Github lxc-bot at linuxcontainers.org
Wed Apr 26 10:17:37 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 546 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170426/5933d268/attachment.bin>
-------------- next part --------------
From 1d9b18bf352234991db19b99c685b111b9d96a7a Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at gmail.com>
Date: Wed, 26 Apr 2017 12:13:17 +0200
Subject: [PATCH] Drop unnecessary else statement

This branch drops an unnecessary else statement, as highlighted by a
linting hint in my emacs setup. Essentially since the "if" part ends
up with a return, there's no need for "else".

Signed-off-by: Free Ekanayaka <free.ekanayaka at gmail.com>
---
 lxc/init.go | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/lxc/init.go b/lxc/init.go
index 85e8369..cf31812 100644
--- a/lxc/init.go
+++ b/lxc/init.go
@@ -228,21 +228,20 @@ func (c *initCmd) run(config *lxd.Config, args []string) error {
 
 	if err != nil {
 		return err
-	} else {
-		op, err := resp.MetadataAsOperation()
-		if err != nil {
-			return fmt.Errorf(i18n.G("didn't get any affected image, container or snapshot from server"))
-		}
+	}
+	op, err := resp.MetadataAsOperation()
+	if err != nil {
+		return fmt.Errorf(i18n.G("didn't get any affected image, container or snapshot from server"))
+	}
 
-		containers, ok := op.Resources["containers"]
-		if !ok || len(containers) == 0 {
-			return fmt.Errorf(i18n.G("didn't get any affected image, container or snapshot from server"))
-		}
+	containers, ok := op.Resources["containers"]
+	if !ok || len(containers) == 0 {
+		return fmt.Errorf(i18n.G("didn't get any affected image, container or snapshot from server"))
+	}
 
-		if len(containers) == 1 && name == "" {
-			fields := strings.Split(containers[0], "/")
-			fmt.Printf(i18n.G("Container name is: %s")+"\n", fields[len(fields)-1])
-		}
+	if len(containers) == 1 && name == "" {
+		fields := strings.Split(containers[0], "/")
+		fmt.Printf(i18n.G("Container name is: %s")+"\n", fields[len(fields)-1])
 	}
 
 	c.checkNetwork(d, name)


More information about the lxc-devel mailing list