这种行为有原因吗?我想知道内存级别有什么不同.编译器返回"不能取复合文字的地址",而我可以明确要求它这样做.
继续去操场去游乐场的链接
u := User{"john"}
fmt.Println(u.Name()) //implicit
//fmt.Println(User{"john"}.Name()) //Error: cannot call pointer method on composite literal, cannot take the address of composite literal
fmt.Println((&User{"jim"}).Name()) //explicit
type User struct {
name string
}
func (u *User) Name() string {
return u.name
}
Run Code Online (Sandbox Code Playgroud) Template.ParseGlob("*.html") //fetches all html files from current directory.
Template.ParseGlob("**/*.html") //Seems to only fetch at one level depth
Run Code Online (Sandbox Code Playgroud)
我不是在寻找"Walk"解决方案.只是想知道这是否可行.我不太明白这种期望的"模式".如果我可以得到关于ParseGlob使用的模式的解释,那也很棒.