../gotamer/cfg/cfg.go:24: undefined: JsonCfg
// main.gopackage mainimport ("gotamer/cfg""gotamer/e")var Cfg JsonCfgtype JsonCfg struct{Appl stringHostname stringListenAddr stringIpAddr stringDebug uint}func main() {c, ok := cfg.Get(Cfg)e.Fail(ok)}
// cfg.go
package cfgimport ("encoding/json""io/ioutil")const file = "cfg.json"
func Get(c *JsonCfg) (b []byte, ok error) {b, ok = ioutil.ReadFile(file)if ok != nil {put() // Generates a template json filereturn c, ok}ok = json.Unmarshal(b, &c)if ok != nil {println("Bad json File: ", ok)}return b, ok}
How do I use a struct that has been defined in the main application, in a module / library.I am keep getting this error:../gotamer/cfg/cfg.go:24: undefined: JsonCfg
Looks good, only thing I might suggest is not using ok for error. ok generally is used for bool, and err for error.