When i run this code:
package main
import "fmt"
func main() {
a := testfunc()
b := testfunc()
fmt.Println(a)
fmt.Println(b)
}
func testfunc() string{
fmt.Println("test")
return "testtii"
}
Why output is:
test
test
testtii
testtii
Instead of
test
testtii
test
testtii
>Solution :
func main() {
a := testfunc() // This will print "test", return "testii"
b := testfunc() // This will print "test", return "testii"
fmt.Println(a) // This will print "testii"
fmt.Println(b) // This will print "testii"
}