This is a very watered down version of what I'm trying to do but please help me with the following scenario:
PackageA.go
package A
import "B"
type TestStruct struct {
Atest string
}
func Test() {
test := TestStruct{"Hello World"}
B.Test(test)
}
PackageB.go
package B
import "fmt"
func Test(test TestStruct) {
fmt.Println(test.Atest)
}
This fails with undefined: test
when it hits Package B
Basically I'm having issues passing structs from one package to another or even passing variables that act as pointers to other structs or functions.
Any pointers would be very helpful.
Reorganize your code as:
a.go
package a
import "b"
func Test() {
test := b.TestStruct{"Hello World"}
b.Test(test)
}
b.go
package b
import "fmt"
type TestStruct struct {
Atest string
}
func Test(test TestStruct) {
fmt.Println(test.Atest)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With