In Python I often use the __file__ constant to get the directory of the current file (e.g., os.path.dirname(os.path.realpath(__file__))). While writing a Go app recently, I found that there wasn’t an immediately obvious (or searchable, even with “golang”) equivalent. But in the annals of the golong-nuts mailing list I eventually found out about runtime.Caller(). This returns …
-
Elsewhere
-
Recent Posts
- Go: How to Get the Directory of the Current File
- Run Django Unit Tests in a Sublime Text 2 Build System
- Python: How to tell what class a decorated method is in at runtime
- Make Sublime Text 2 More like Vim: Wrap Code, Go To Last Edit, Jump Back, and More
- Sharp Edges: Protecting Ourselves from Digital Publishing
- iA Writer and Notational Velocity