Is there function and method overloading in Go like in Java/C++?
Hello everyone! I just started learning Go after Java, and I encountered an unclear situation. In Java, I'm used to being able to declare multiple methods with the same name but different parameters — this is called overloading. For example, I can write:
```java
void print(String s) { ... }
void print(int i) { ... }
void print(double d) { ... }
```
Now I'm trying to do the same in Go:
```go
package main
func print(s string) {
fmt.Println(s)
}
func print(i int) {
fmt.Println(i)
}
func main() {
print("hello")
print(42)
}
```
But the compiler gives an error: `print redeclared in this block`. I tried renaming the package, changing the order of functions — nothing helps.
I've read that Go doesn't have classical overloading, but this seems very strange.