• flame3244@lemmy.world
    link
    fedilink
    arrow-up
    27
    ·
    1 year ago

    Yes it is a hard error and Go does not compile then. You can do _ = foobar to fake variable usage. I think this is okay for testing purposes.

    • nomadjoanne@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      Ew, that’s awful. Go is not one of my programming languages but I had always held it in high esteem because Ken Thompson and Rob Pike were involved in it.

      • flame3244@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        Honestly, it does not happen often that I have a ln unused variable that I want to keep. In my mind it is the same thing when wanting to call a function that does not exists. Also my editor is highlighting error Long before I try to compile, so this is fine too for me.

    • AstridWipenaugh@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      edit-2
      1 year ago

      The underscore is used in production code too. It’s a legitimate way to tell the compiler to discard the object because you don’t intend to use the pointer/value.