News for hackers. Stuff that matters.
Re:Fixing for Loops in Go 1.22 by badrequest on Tuesday September 19, 2023 @05:51PM (#37577335)
I write Go every day, and can count the number of times per year I have to involve an `interface{}` literal on one hand. Unless you're doing JSON wrong or working with an API that simply doesn't care about returning consistently structured data, I can't fathom why you'd be using it "all over the place."
Re:Fixing for Loops in Go 1.22 by coffeebeqn on Tuesday September 19, 2023 @06:51PM (#37578145)
Me too. We have around a dozen go services and I have maybe used or seen interface{} once or twice for a hack. Especially after generics. I think the parent comment is suffering from poor quality go code. It’s like complaining about typescript because things in your codebase don’t have types
Re:Fixing for Loops in Go 1.22 by xarope on Wednesday September 20, 2023 @01:37AM (#37580726)
Dealing with databases and data scanning into custom structs, you would be writing lots Scanner/Valuer custom functions which use interface{}

If you are the lucky ones not dealing with databases, I sort-of envy you...!

Re:Fixing for Loops in Go 1.22 by kiitos on Wednesday September 20, 2023 @08:57AM (#37583559)
Applications should basically never need to write custom Scanner/Valuer functions that deal in interface{}, if you find yourself doing that it's a red flag
Re:Fixing for Loops in Go 1.22 by badrequest on Thursday September 21, 2023 @01:59PM (#37601441)
I use sqlc and it makes this a non-issue.