handleService(proxyService) // does not implement 'Service' as the 'Handle' method has a pointer receiver // proxyService2 为【值对象】,存储在接口中是自动不可寻址的 // 因此无法通过 (&proxyService2).Handle 和 (&proxyService2).SetName 调用 【指针接收器的方法】 // handleService(proxyService2)
handleService(backService) // does not implement 'Service' as the 'Handle' method has a pointer receiver // 由于 backService2 是【值对象】,存储在接口中是自动不可寻址的 // 因此也就无法通过自动寻址 (&backService2).Handle() 调用 【指针接收者方法】 // 但是可以调用 【值接收者的方法】 backService2.SetName() // handleService(backService2) }
输出
1 2 3 4 5 6 7 8 9 10
test2 test2 test test test test ProxyService xxx SettingService test SettingService test BackgroundService test