初级会员
  • 第 15848 位会员
  • 304158
  • 2018-01-29 15:40:31
  • Offline
  • 20 21

最近分享的资源

    暂无

最近发布的项目

    暂无

最近的评论

  • 不用加./直接写程序名 ,(程序,命令)
  • func SetTempCookie(k , v string,w http.ResponseWriter){ cookie:=http.Cookie{Name: k, Value: v,Path:"/"} http.SetCookie(w,&cookie) } 解决了。原来是没有添加Path 所有只有在设置cookie控制器下实现
  • ```go package main import "fmt" type IAnimal interface { Run() } type Animal struct{} func (a *Animal) Escape(ianimal IAnimal) { ianimal.Run() } func (a *Animal) Run() { fmt.Printf("Animal Run.\n") } type Dog struct { s Animal } func (d *Dog) Run() { fmt.Printf("Dog Run.\n") } func main() { dog := &Dog{} dog.s.Escape(dog) ad:=&Animal{} ad.Escape(ad) } ``` //输出 //Dog Run. //Animal Run.
  • #6 @304158 ```go package main import ( "fmt" "reflect" ) type IAnimal interface { Run() } type Animal struct{} func (a *Animal) Escape(ianimal IAnimal) { ianimal.Run() } func (a *Animal) Run() { fmt.Printf("Animal Run.\n") } type Dog struct { Animal } func (d *Dog) Run() { fmt.Printf("Dog Run.\n") } ``` func main() { dog := &Dog{} dogv:=reflect.ValueOf(dog) dogt:=reflect.Indirect(dogv).Type() dognew:=reflect.New(dogt) dogi:=dognew.Interface().(IAnimal) dog.Escape(dogi) }
  • ```go package main import ( "fmt" "reflect" ) type IAnimal interface { Run() } type Animal struct{} func (a *Animal) Escape(ianimal IAnimal) { ianimal.Run() } func (a *Animal) Run() { fmt.Printf("Animal Run.\n") } type Dog struct { Animal } func (d *Dog) Run() { fmt.Printf("Dog Run.\n") } func main() { dog := &Dog{} dogv:=reflect.ValueOf(dog) dogt:=reflect.Indirect(dogv).Type() dognew:=reflect.New(dogt) dogi:=dognew.Interface().(IAnimal) dog.Escape(dogi) } ```