I'm still struggling with how to setup my access.
I'm building a library, say
tagtool and it has a nice clean subdirectory with the files
that make up the go package, each with
package tagtool
And I have a subdirectory called "cmd" that contains a near trivial main.go
that calls the various tagtool.Mumble() func.
So far, so good.
But I've been using file/package level vars. This is clearly a bad thing.
So I'm trying to bundle all the various vars into a struct, and
I'll have my main.go call a
func AllocateData() *GlobalVars {
rval := new(GlobalVars)
//.. do other init stuff
return rval
}
This way we have the main holding the storage for what had been file/package level
vars.
Which is a good start. It works great if I capitalize all the variables.
But I really don't want to make all of the variables in the struct be part of my public API. They are all implementation details. I need to be able to initialize various variables in the GlobalVars struct from my 'main.go'
Right now, its mostly flag variables that I need. Stuff like
flag.BoolVar(&flags.Debug, "de", false, "debug on")
The main.go doesn't really care about the values once the flag package has set them from the shell arguments, it just wants the tagtool
Is there a "friend" declaration or import that lets the "package main" look into
the package tagtool?
Thanks
Pat