我有下面的函數接受布爾指針。我想知道是否有任何符號允許我在結構字面量中將is
字段的值設置爲true
;基本上沒有定義一個新的標識符(i.e. var x := true ; handler{is: &x})
如何在結構體字符中將bool指針設置爲true?
package main
import "fmt"
func main() {
fmt.Println("Hello, playground")
check(handler{is: new(bool) })
}
type handler struct{
is *bool
}
func check(is handler){}
相關:http:// stackoverflow。com/questions/30716354/how-do-a-literal-int64-in-go – icza 2015-06-10 09:17:11