Q:

How to get the working directory using syscall in Golang?

belongs to collection: Golang syscall Package Programs

0

In the Go programming language, to get the working directory using syscall – we use the Getwd() function of the syscall package. The Getwd() function returns the working directory.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Syntax:

func Getwd() (wd string, err error)

Consider the below example demonstrating how to get the working directory using syscall in Golang?

package main

import (
	"fmt"
	"syscall"
)

func main() {
	// Using the Getwd(),
	// Getting the working directory
	wd,_ := syscall.Getwd()

	// Printing the working directory
	fmt.Println("Working directory:", wd)
}

Output

Working directory: /home

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

How to get the number of seconds since the epoch u... >>
<< How to get the parent process identification using...