如何在不显式指定字段golang的情况下打印字段的解引用值

package main

import (
    "fmt"
)

type outer struct {
    in *int
}

func main() {
    i := 4
    o := outer{&i}
    fmt.Printf("%+v", o)
}

I'd like to see {in:4} at the end of this, not {in:0x......}, i.e. pretty print the data structure.

I'd like to accomplish this in a similar manner to the code posted (e.g. with a fmt shortcut similar to %+v or an analogous solution).

This is for autogenerated code from a required field of a thrift struct.

What's the best way to go about this?

When you use &i it does not dereference i. Rather it references i, which means that it copies the address of i into o. See the documentation for the Address operators.

From what I gather, you should be able to use *o to dereference the pointer; in other words, go from the address back to the original variable.

For an operand x of pointer type *T, the pointer indirection *x denotes the variable of type T pointed to by x. If x is nil, an attempt to evaluate *x will cause a run-time panic.