1

Hi I have a program where I want to read files relative to the binary installed in the bin folder. I have looked at using:

filepath.Abs
os.Getwd()

But this only gives me the folder beneath "src" during.




Eventually I will use:

os.Open(abspath)

How do you read files during runtime?

Chris G.
  • 23,930
  • 48
  • 177
  • 302
  • 1
    What is β€œthe bin folder?” – fuz Dec 04 '14 at 17:30
  • `runtime.Caller()` is about traversing the call stack of the invoking function and hence has nothing to do with paths and folders. – kostix Dec 04 '14 at 17:51

1 Answers1

2

I had already seen the osext, but now that dyoo mentioned it - I went for it. And it works.

https://godoc.org/bitbucket.org/kardianos/osext

Thanks

Chris G.
  • 23,930
  • 48
  • 177
  • 302