On Tuesday, October 11, 2016 at 10:42:02 PM UTC+8, Jan Mercl wrote:
>
> On Tue, Oct 11, 2016 at 4:26 PM T L <[email protected] <javascript:>>
> wrote:
>
> package main
>
> import (
> "sync/atomic"
> "unsafe"
> )
>
> type T struct {
> a *int // no ways?!
> }
>
> func (t T) A() *int {
> return
> (*int)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&t.a))))
> }
>
>
Wow, cool!
So values of type unsafe.Pointer can be converted to values of type
*unsafe.Pointer?
But I can't find the official docs mentioning this. Is it safe?
> func main() {
> i := 42
> t := &T{&i}
> p := t.A()
> println(*p)
> }
>
> (https://play.golang.org/p/zHaeGjvEUC)
> --
>
> -j
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.