Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- type Interface interface {
- }
- type A struct {
- }
- type B struct {
- }
- func id(i Interface) Interface {
- return i
- }
- func withA(a A) {
- }
- func withB(b B) {
- }
- func main() {
- a, ok := id(A{}).(A)
- if ok {
- withA(a)
- }
- b, ok := id(B{}).(B)
- if ok {
- withB(b)
- }
- c, ok := id(B{}).(A)
- if ok {
- withA(c)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement