I am new to Go language and I am trying to get familiar with interfaces and their assignability.
I am trying to pass an argument from a struct
into a function
which is imported from another package
.
main.go package:
package main
import {
anotherPackage
}
type I1 interface {
anotherPackage.I2
}
type T1 struct {
*anotherPackage.S1
}
type T2 struct {
variable1 T1
}
type T3 struct {
variable2 T2
}
func handler() {
var fromI I
var input = T3{}
template := fromI.ExportedFunction(input.T3.variable1)
}
func main() {
handler()
}
anotherPackage.go package
package anotherPackage
type I2 interface {
ExportedFunction(S1)
}
type S1 struct {
Path string
File string
}
type S2 struct {}
func (s2 *S2) ExportedFunction(s1 S1) {}
I keep getting an error:
cannot use input.T3.variable1 (type T1) as type anotherPackage.S1 in argument to fromI.ExportedFunction