jjzjj

AwsRegion

全部标签

pointers - 将类型别名的变量传递给需要指向基础类型的指针的函数

我将自定义类型别名(使用方法)定义为:typeAwsRegionstring然后我想将这种类型的变量传递给另一个遗留(不受我控制)函数,它接受指向字符串的指针(指向基础类型的指针):funcmain(){varregionAwsRegion="us-west-2"f(®ion)//HowtoproperlycastAwsRegiontypehere?}funcf(s*string){fmt.Println(*s)//justanexample}当然我不能这样做,错误消息指出:cannotuse®ion(type*AwsRegion)astype*stringinargume