Created
June 12, 2021 23:27
-
-
Save austin-millan/076f43b6a79777bf753a2d1d3b9698b0 to your computer and use it in GitHub Desktop.
Markdium-
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 A struct { | |
ValA int `json:"valA"` | |
ValB int`json:"valB"` | |
} | |
var input = A{} | |
func fetchFromMemory() (*A) { | |
return &input | |
} | |
func main() { | |
json.Unmarshal([]byte(`{"valA": 1, "valB": 1}`), fetchFromMemory()) | |
for i := 0; i < 10; i++ { | |
go json.Unmarshal([]byte(`{"valA": 99}`), fetchFromMemory()) | |
go json.Unmarshal([]byte(`{"valA": 9999999}`), fetchFromMemory()) | |
output, _ := json.Marshal(fetchFromMemory()) | |
fmt.Println(string(output)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment