How to share constant between packages in golang?

Answer • 1 Asked • Jan 19 2020
I’ve the following code which require multiple packages in cmd package
PATH_SEP = string(os.PathSeparator)

my project structure is like following
go/src/my proj -cmd --runners --otherpackage -- package2 -- constants --….

in constants i put the code
PATH_SEP = string(os.PathSeparator) const2 etc

and in runners and package2/3 etc I use this constant.
is it OK ? otherwise I need to duplicate the code for other packages .

Write your answer...

On a mission to build Next-Gen Community Platform for Developers