Skip to content

Instantly share code, notes, and snippets.

@theartofdevel
Last active July 3, 2025 20:26
Show Gist options
  • Save theartofdevel/b61543e2f2470f870ce39410f9706e5d to your computer and use it in GitHub Desktop.
Save theartofdevel/b61543e2f2470f870ce39410f9706e5d to your computer and use it in GitHub Desktop.
golang wtf
package main
import (
"encoding/json"
"fmt"
)
type Some struct {
Name string `json:"name"`
}
func main() {
var s *Some
un(s)
fmt.Println(fmt.Sprintf("%v - %T", s, s))
}
func un(payload any) {
fmt.Println(fmt.Sprintf("%v - %T", payload, payload))
body, _ := json.Marshal(Some{Name: "some123"})
err := json.Unmarshal(body, &payload)
if err != nil {
panic(err)
}
fmt.Println(fmt.Sprintf("%v - %T", payload, payload))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment