68473/how-to-get-the-directory-of-the-currently-running-file
In nodejs I use __dirname . What is the equivalent of this in Golang?
_, filename, _, _ := runtime.Caller(1) f, err := os.Open(path.Join(path.Dir(filename), "data.csv"))
But is it the right way or idiomatic way to do in Golang?
Hello @kartik,
This should do it:
import ( "fmt" "log" "os" "path/filepath" ) func main() { dir, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { log.Fatal(err) } fmt.Println(dir) }
Hello @kartik, Use this: var filename = fullPath.replace(/^.*[\\\/]/, '') This ...READ MORE
Hello @kartik, Use this code: function roughSizeOfObject( object ) ...READ MORE
Hello @kartik, Managed to get the input field ...READ MORE
Hello @kartik, You would iterate inside the object ...READ MORE
Hi Unfortunately no, you have to know the ...READ MORE
Hello guys, Can Someone helps me to find ...READ MORE
Let us consider the below block: <div ng-controller="emp"> ...READ MORE
Hii, The $_SERVER["PHP_SELF"] variable can be used by ...READ MORE
You have to download the file with ...READ MORE
Hello @kartik, Yes ,you can read the value ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.