4 ms·
Good question. If package B defined the function Bar(), and package C defined the function Bar(), then if package D linked to packages B and C, which function
by GhotiFish 14y ago
Good question. If package B defined the function Bar(), and package C defined the function Bar(), then if package D linked to packages B and C, which function should it call when it asks for Bar()?
Naming collisions are a solved problem.
- pcwalton 14y agoYou don't have to import methods in Go; the compiler just finds them. They're in a per-type namespace and therefore would be vulnerable to collisions. Of course, they could change the language to allow/require you to import methods, but that would add some complexity. On the other hand, you have to import functions, so your example isn't a problem.
- mseepgood 14y agoIn Go each external function call is preceded by its package name to avoid collisions, but you don't have packages within the method namespace of a type.