Everton Marques,

There is no ambiguity. Read the Go block, declaration, and scope rules:

https://golang.org/ref/spec
https://golang.org/ref/spec#Blocks
https://golang.org/ref/spec#Declarations_and_scope

You are shadowing fmt.

https://en.wikipedia.org/wiki/Variable_shadowing

Peter

On Wednesday, July 5, 2017 at 2:43:43 PM UTC, Everton Marques wrote:
>
> If context is not given, I can't tell if foo.Bar() is a function of 
> package foo or a method of variable foo.
> That is, dot is used both for package namespace and method call.
>
> Example:
>
> type T struct {
> }
>
> func (t T) Println(s string) {
> fmt.Println("method: " + s)
> }
>
> func main() {
> fmt.Println("hello from package function")
> fmt := T{}
> fmt.Println("hello")
> }
>
> https://play.golang.org/p/HZibMmJ8W5
>
> I wonder if such an ambiguity came into Go...
> 1) on purpose, since the dot (.) is easy on the eye and simple key stroke 
> (shift not needed) ?
> 2) by accident, since keyboards lack convenient alternate symbols ?
> 3) for other reasons ?
>
> Everton
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to