-
-
Save cep21/2011bc824b275c17065cb90a8f59b819 to your computer and use it in GitHub Desktop.
Two file imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From package A | |
package a | |
type T int64 | |
type S struct{} | |
func (s *S) TypedFunction() T { | |
return T(0) | |
} | |
func (s *S) UntypedFunction() []byte { | |
return nil | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From package B | |
package b | |
type CanCallUntypedFunction interface { | |
UntypedFunction() []byte | |
} | |
func Compute(i interface{}) { | |
if can, ok := i.(CanCallUntypedFunction); ok { | |
can.UntypedFunction() | |
} | |
// <<<< | |
// There is no way to call i.TypedFunction without importing package a | |
// <<<< | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment