Dnia 2023-02-17, o godz. 19:18:23 
Pat Farrell <pat22...@gmail.com> napisaƂ(a):

> 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.

   then make GetSmth methods on that struct. That will be your public api.

> They are all implementation details. I need to be able to
> initialize various variables in the GlobalVars struct from my 'main.go'

If you use flags package you will have other fields exposed though.

I personally stopped use flags, due to too much chores around it.

Here is mine's substitute I prefer for simple cmd scripts: 

https://github.com/ohir/mopt


> But I've been using file/package level vars. This is clearly a bad thing.

It is perfectly OK if these are set once from the cmdline.

Hope this helps,

-- 
Wojciech S. Czarnecki
 << ^oo^ >> OHIR-RIPE

(cc due to thread age)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/20230227192857.674ad274%40xmint.

Reply via email to