http://play.golang.org/p/joEmjQdMaS
package main
import \"fmt\"
type SomeStruct struct {
somePointer *somePointer
}
type somePointer struct {
field
package main
import (
"fmt"
)
type SomeTest struct {
someVal string
}
func (this *SomeTest) String() string {
return this.someVal
}
func main() {
fmt.Println(&SomeTest{"You can see this now"})
}
Anything that provides the Stringer
interface will be printed with it's String() method. To implement stringer, you only need to implement String() string
. To do what you want, you'd have to implement Stringer
for SomeStruct
(in your case, dereference somePointer
and do something with that).