-3

What will be the difference between the fmt.Print("print something") and just print("print something") in Go lang.

var a int
fmt.Print("In Print ", &a, "\n ")
print("In print ", &a, "\n")

Both provide the same result.

Result :

In Print 0xcSameAddressLocation
In print 0xcSameAddressLocation 

However when I do this :

ar := []int{1, 2, 3, 4, 5, 6, 7, 8}
print("In print ", &ar, "\n")
print("In print ", ar[0], "\n")
print("In print ", ar, "\n")
fmt.Print("In fmt.Print ", &ar, "\n")
fmt.Print("In fmt.Print ", &ar[0], "\n")
fmt.Print("In fmt.Print ", ar[0], "\n")
fmt.Print("In fmt.Print ", ar, "\n")

Result:

In print 0xcAddressLocation1
In print 1
In print [8/8]0xcAddressLocation2
In fmt.Print &[1 2 3 4 5 6 7 8]
In fmt.Print 0xcAddressLocation2
In fmt.Print 1
In fmt.Print [1 2 3 4 5 6 7 8]

Can someone please how this works and what "print()" and "fmt.Print()" do in Go Language respectively.

1 Answers1

0

print() is builtin funstion and it is not guaranteed to stay in the language. See builtin.go