[Libguestfs] [libnbd PATCH 3/7] golang: Simplify RBool return

Eric Blake
Wed, 26 Jul 2023 17:29:46 -0000

Among other things, the 'gofmt' tool flagged our use of a single-line
if/else statement for returning an RBool value, recommending we expand
it to multiple lines.  But we don't need that much typing, when we can
just directly compute the boolean result in place.

Signed-off-by: Eric Blake <eblake at redhat.com>
---
 generator/GoLang.ml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/generator/GoLang.ml b/generator/GoLang.ml
index 82d73ed6..0aa83bdc 100644
--- a/generator/GoLang.ml
+++ b/generator/GoLang.ml
@@ -366,8 +366,7 @@ let
    | RErr ->
       pr "    return nil\n"
    | RBool ->
-      pr "    r := int (ret)\n";
-      pr "    if r != 0 { return true, nil } else { return false, nil
}\n"
+      pr "    return int (ret) != 0, nil\n"
    | RStaticString ->
       pr "    /* ret is statically allocated, do not free it. */\n";
       pr "    r := C.GoString (ret);\n";
--
2.41.0