i have appConfig.nim
import yaml, streams
type
AppConfig* = object
api_end_point: string
binance_api_key: string
binance_secret: string
proc loadConfig*(filePath: string): AppConfig =
var config: AppConfig
let s = newFileStream(filePath)
load(s, config)
s.close()
result = config
in other nim file, I import and use the loadConfig like this:
let cfg = loadConfig("config.yaml")
echo $cfg.api_end_point
I'm getting Error: undeclared field: 'api_end_point' for type appConfig.AppConfig. I can't see a fix for it.
You need to export the fields of an object, in addition to the object itself.
type
AppConfig* = object
api_end_point*: string
binance_api_key*: string
binance_secret*: string