News for hackers. Stuff that matters.
Re:Map[string]interface{} in Go: a user's manual by akavel on Monday July 26, 2021 @04:35PM (#27965094)
There's a nice trick you can use to make your map[string]interface{} code a bit easier to write and arguably also to read (less {}s), useful especially when you need e.g. to serialize some deeply nested JSON, for one-off request:

  func doSomeRequest(...) {
      type loose map[string]interface{}
      payload, err := json.Marshal(loose{
          "fooBar": true,
          "nested": loose{
              "subfield": bazArg,
          },
      })
      // ...
  }
I should really probably write some blog listing various tricks like this I'm using, but I still can't make myself do it...
Re:Map[string]interface{} in Go: a user's manual by scruple on Monday July 26, 2021 @07:49PM (#27966958)
That is a good trick and I have a place where I can use this idea to make something more clear. You should write that blog post!