To get the current working directory using the os
package and print it using the fmt
package in Go, you can use the following code:
main.go215 chars16 lines
In this code, we first import the required packages os
and fmt
. We then use the Getwd()
function from the os
package to get the current working directory. If there is an error, we log it using the Println()
function from the fmt
package. Otherwise, we print the current working directory using Println()
.
gistlibby LogSnag