Yes.  You have to understand how "fmt.Print," etc., handle types with 
String() methods.  From the docs:

package fmt - 

5. If an operand implements method String() string, that method will be 
invoked to convert the object to a string, which will then be formatted as 
required by the verb (if any).

package reflect - 

func (Value) Elem 
<http://localhost:6060/src/reflect/value.go?s=25679:25706#L800>
func (v Value <http://localhost:6060/pkg/reflect/#Value>) Elem() Value 
<http://localhost:6060/pkg/reflect/#Value>

Elem returns the value that the interface v contains or that the pointer v 
points to. It panics if v's Kind is not Interface or Ptr. It returns the 
zero Value if v is nil.

func (Value) String 
<http://localhost:6060/src/reflect/value.go?s=55738:55768#L1847>

func (v Value <http://localhost:6060/pkg/reflect/#Value>) String() string 
<http://localhost:6060/pkg/builtin/#string>

String returns the string v's underlying value, as a string. String is a 
special case because of Go's String method convention. Unlike the other 
getters, it does not panic if v's Kind is not String. Instead, it returns a 
string of the form "<T value>" where T is v's type. The fmt package treats 
Values specially. It does not call their String method implicitly but 
instead prints the concrete values they hold.
On Thursday, February 25, 2021 at 11:42:32 PM UTC-7 tapi...@gmail.com wrote:

> What I mean is 
>
>     fmt.Println(v3)
>
> and
>
>     fmt.Println(v3.Elem())
>
> print the same thing. Is it an intended design?
>
> On Thursday, February 25, 2021 at 11:11:52 PM UTC-5 Kurtis Rader wrote:
>
>> On Thu, Feb 25, 2021 at 8:01 PM tapi...@gmail.com <tapi...@gmail.com> 
>> wrote:
>>
>>>
>>> https://play.golang.org/p/-GZajVGPWYv
>>>
>>
>> You need to clarify your question. I don't see any obvious problem with 
>> the output of your program. The reflect.Value.Elem() call is defined to 
>> return a reflect.Elem object. But that observation might be irrelevant 
>> since you have not clearly stated the problem. 
>>
>> -- 
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b23569b4-a0cc-48c2-a04d-3c0991c8f8d2n%40googlegroups.com.

Reply via email to