Last active
July 3, 2025 20:26
-
-
Save theartofdevel/b61543e2f2470f870ce39410f9706e5d to your computer and use it in GitHub Desktop.
golang wtf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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