// create a new config state state := spew.ConfigState{} // inspect a complex data structure data := map[string]interface{}{ "name": "John Doe", "age": 30, "address": map[string]string{ "street": "123 Main St", "city": "Anytown", "state": "CA", }, } spew.Dump(data, state)
// create a new config state with custom options state := spew.ConfigState{ Indent: " ", // use two spaces for indentation MaxDepth: 2, // limit the output to two levels DisablePointerAddresses: true, // do not show pointer addresses } // inspect a complex data structure data := []interface{}{ "one", 2, true, map[string]string{"key": "value"}, map[int]string{1: "one", 2: "two", 3: "three"}, []string{"a", "b", "c"}, } spew.Dump(data, state)In this example, we create a new ConfigState object with custom options and use it with the Dump function to inspect a complex data structure. The Dump function prints out the structure with the customized options. By using the go-spew package, we can easily inspect and debug complex data structures in a human-friendly way during development and testing.