I'm new to golang and could not find a good answer.
Problem: I have two files in the same folder that belong to the main package called main.go
and my_type.go
. The former includes main func and uses the type defined in the second file. The type is just a simple string array i.e. type myType [] string
. Now if I understand correctly, types and funcs belonging to the same package don't need imports and by convention are started with lower case letters. This said, go run/build main.go
spits out the error "undefined" for the type. The only way it works is by specifying both files or use a wild card. Is this the expected behavior? I've also started using vs.code and wonder if there's a way to configure running this properly in vs.code
Thanks in advance!
Sample error:
go build main.go
# command-line-arguments
./main.go:17:11: undefined: myType