I have a version.go on my root folder(MyPackage).
package MyPackage
var (
Version = "undifened"
Hash = "undifined"
)
And I have second file found on MyPackage/cmd/bootloader/bootloader.go
package main
import(
"MyPackage"
"fmt"
)
func main() {
fmt.Println(MyPackage.Version)
}
But I am gettingundeclared name: MyPackage
and "MyPackage" imported but not used as ext
on gotype and i dont know how to fix.
I tried executing this gotype bootloader.go
and get this.
bootloader.go:9:14: undeclared name: MyPackage
bootloader.go:4:2: "MyPackage" imported but not used as ext
I will appreciate for any help will come.
Edit: This is not the same with Golang Global Variable access because this will defeat the purpose of that variables, because i don't want to rewrite it on the every main.go. because I want to build the main.go with the -ldflags
to set the value on the variable.