GoLang getcwd

is this article helpful? yes | no
GoLang replacement for PHP's getcwd [edit | history]
func Getcwd() (string, error) {
	dir, err := os.Getwd()
	return dir, err

PHP getcwd

PHP original manual for getcwd [ show | php.net ]


(PHP 4, PHP 5, PHP 7)

getcwdGets the current working directory


string getcwd ( void )

Gets the current working directory.

Return Values

Returns the current working directory on success, or FALSE on failure.

On some Unix variants, getcwd() will return FALSE if any one of the parent directories does not have the readable or search mode set, even if the current directory does. See chmod() for more information on modes and permissions.


Example #1 getcwd() example


// current directory
echo getcwd() . "\n";


// current directory
echo getcwd() . "\n";


The above example will output something similar to:


See Also