• MJBrune@beehaw.org
    link
    fedilink
    English
    arrow-up
    27
    arrow-down
    2
    ·
    2 years ago

    A quick “find all references” will point out it’s not used and can be deleted if it accidentally gets checked in but ideally, you have systems in place to not let it get checked into the main branch in the first place.

    • Flarp@kbin.social
      link
      fedilink
      arrow-up
      28
      arrow-down
      1
      ·
      2 years ago

      Yeah that should be looked for in a CI line check, not a compilation requirement

    • aport
      link
      fedilink
      arrow-up
      13
      arrow-down
      4
      ·
      2 years ago

      You mean a system like the compiler

      • MJBrune@beehaw.org
        link
        fedilink
        arrow-up
        14
        ·
        edit-2
        2 years ago

        Or a linter. Or code reviews. Or anything else. The nice thing is that if the compiler doesn’t demand something, it can be given to the engineer as an option. The compiler should have the option to do it. The option could even be defaulted on. Afaik there is no way in Golang to disable that error (this is the line that does it: https://github.com/golang/go/blob/04fb929a5b7991ed0945d05ab8015c1721958d82/src/go/types/stmt.go#L67-L69). like --no-pedantics or such. Golang’s compiler openly refuses to give engineers more choices in what they think is the best system to handle it.

        • aport
          link
          fedilink
          arrow-up
          1
          arrow-down
          6
          ·
          2 years ago

          Who needs an option to leave unused variables around the code base? Lazybones?

          • MJBrune@beehaw.org
            link
            fedilink
            arrow-up
            5
            ·
            2 years ago

            You’ve literally never commented out a line or two but left the variable declaration while debugging?

    • anemoia_one@lemmynsfw.com
      link
      fedilink
      English
      arrow-up
      5
      ·
      edit-2
      2 years ago

      Yeah any compiler should support environments or config files. Our CI would never work with without --env “stage”