简体   繁体   中英

reflect.TypeOf is *string and returns 0xc0001ae4a8 - how to print

This is my code from retrieving results from the Go AWS client:

  fmt.Println("Success", reflect.TypeOf(result.Reservations[0].Instances[0].Architecture))
  Success *string

fmt.Println("Success", result.Reservations[0].Instances[0].Architecture)
Success 0xc0001ae4a8

I don't know why this is happening.

result.Reservations[0].Instances[0].Architecture is a pointer to a string. The type prints as *string . The value prints as hex.

If your goal is to print the value of the string, then dereference the pointer:

fmt.Println("Success", *result.Reservations[0].Instances[0].Architecture)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM