Created
June 22, 2016 07:09
-
-
Save zwh8800/3422e23caa5b5e9394622152ff8eda88 to your computer and use it in GitHub Desktop.
美丽的debug
This file contains 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 util | |
import "encoding/json" | |
func JsonStringify(obj interface{}, intent bool) string { | |
if intent { | |
data, err := json.MarshalIndent(obj, "", " ") | |
if err != nil { | |
return "" | |
} | |
return string(data) | |
} else { | |
data, err := json.Marshal(obj) | |
if err != nil { | |
return "" | |
} | |
return string(data) | |
} | |
} |
This file contains 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 | |
func main() { | |
someComplicatedVar := make(map[string][]*SomeComplicatedStruct, 0) | |
someOrmLib.Select().Into(someComplicatedVar) | |
// when debug | |
// awful: "someComplicatedVar: { "a": [0x12344321, 0x12344322] }" | |
glog.Infoln("someComplicatedVar:", someComplicatedVar) | |
/* | |
awesome: "{ "a": [{ | |
"Id": 5740, | |
"Uuid": "619cd38fa263", | |
"RestaurantId": 385758, | |
"Removed": false | |
}, { | |
"Id": 5745, | |
"Uuid": "619cd38fa233", | |
"RestaurantId": 345378, | |
"Removed": false | |
}]}" | |
*/ | |
glog.Infoln("someComplicatedVar:", util.JsonStringify(someComplicatedVar, false)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment