Skip to content

Instantly share code, notes, and snippets.

@cep21
Last active August 29, 2017 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cep21/2011bc824b275c17065cb90a8f59b819 to your computer and use it in GitHub Desktop.
Save cep21/2011bc824b275c17065cb90a8f59b819 to your computer and use it in GitHub Desktop.
Two file imports
// 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
}
// 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