Golang Get Current Dir
In nodejs __dirname
will give you the name of the directory that the currently executing script resides. Similarly, in Python you can use the __file__
constant to get the directory of the current file.
To get something similar in golang you could do the following:
package main
import (
"path"
"runtime"
)
func main(){
_, filename, _, _ := runtime.Caller(1)
f, err := os.Open(path.Join(path.Dir(filename), "users.json"))
}