• wyrmroot@programming.dev
    link
    fedilink
    arrow-up
    9
    ·
    3 months ago

    I hate seeing data encoded into magic comments, struct tags included. One of my biggest gripes with Go is that I think they should have used a different symbol to distinguish important annotations from true comments.

    • Ethan@programming.dev
      link
      fedilink
      English
      arrow-up
      3
      ·
      3 months ago

      Who uses struct tags for comments? I’ve never used or seen them used as anything except annotations as in tag:"value". And linters (go vet?) will tell you if you’re formatting them wrong.

  • rhabarba@feddit.de
    link
    fedilink
    arrow-up
    4
    arrow-down
    1
    ·
    3 months ago

    That blog is hard to read on a desktop computer in my opinion. But hey, “it looks cool”, at least…

  • Solemarc@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    3 months ago

    As far as I was aware Go didn’t have enums and this

    const()
    

    Pattern is just a weird thing people do because it behaves like an enum?

    • Ethan@programming.dev
      link
      fedilink
      English
      arrow-up
      4
      ·
      3 months ago

      You are correct, Go doesn’t have enums. The const thing is a widely accepted pattern for approximating enums.

  • Pixel@lemmy.sdf.org
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    Don’t understand why people hate them so much. They work fine for me, the go team, and many others. If you want an enum scope you can use the sub package trick. Not ideal but I don’t even need that. Iota is cool because it basically repeats any pattern, including bit flags. My biggest beef with them is the ability to assign any literal value to these custom types, but I can handle it. Plus you can wrap in a struct if you care that much. It’s just not a big deal.