如何键入转换切片类型别名

package main

import (
    "fmt"
)

type alias int
type aliases []*alias

func main() {
    a1 := alias(1)
    t := aliases{&a1}

    fmt.Println([]*int([]*alias(t)))
}

The type type aliases []*alias is essentially []*int

I want to be able to type convert aliases back to []*int

Try this, you could do that by doing right casting.

type alias int
type aliases []*alias

func main() {
    a1 := alias(1)
    t := aliases{&a1}

    orig := int(*([]*alias(t)[0]))
    fmt.Println(orig)
}

Example on http://play.golang.org/p/1WosCIUZSa

If you want to get all values (not just the first index) you have to loop and cast each element.

func main() {
    a1 := alias(1)
    t := aliases{&a1}

    orig := []*int{}

    for _, each := range t {
        temp := int(*each)
        orig = append(orig, &temp)
    }

    fmt.Printf("%#v
", orig) // []*int{(*int)(0x10434114)}
}

Example: http://play.golang.org/p/Sx4JK3kA45

You can with unsafe.Pointer, a little bit unsafe so not recommended

PointerToSliceOfPointersToInt := (*([]*int))(unsafe.Pointer(&t))

try it works https://play.golang.org/p/6AWd1W_it3