Problem with return string from function


I’m a beginner with Go and have the following problem.

The following function works fine if I leave it in the main.go file:

func GetCWD() string {
	dir, _ := os.Getwd()
	return dir

As soon as I move this to another file: recover/recover.go and import this into the main.go

the print function in the main.go : fmt.Println(recover.GetCWD) will show : 0x4a00f0

instead of the string ?

I have tried to use fmt.Printf("%s", recover.GetCWD)

but probably I miss something ?


Try calling the function: recover.GetCWD().

1 Like

Like this it works :wink:

test := recover.GetCWD()
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.