you can use go vet -shadow
to try to find the potential bugs related to shadowing. Personally, I feel the proposal in https://github.com/golang/go/issues/377 <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fgolang%2Fgo%2Fissues%2F377&sa=D&sntz=1&usg=AFQjCNFMljXJpWaGGbpKPY9E_i1wwVX4DQ> :n, err = f() is not bad. I think shadowing has its usefulness. It can be used to mute some kinds of identifiers. For example, var x = 1 ... { type x bool ... // so from here using x as a variable is forbidden, // to avoid some causal bugs. } So at least I think it should allow a type name to shadow a value (var/const/func) name, and vice versa. In fact, I ever have a proposal, I think which is better than the above shadowing way, to use the following way to mute an identifer: { var a int type b bool ... a = _ b = _ // now we can't use a and b any more. } On Sunday, October 28, 2018 at 6:24:48 AM UTC-4, Sokolov Yura wrote: > > First, I know this will not happen. It is just a dream. > Second, I'm not original: https://github.com/golang/go/issues/377 , > https://groups.google.com/forum/#!topic/golang-dev/wg5K15tEJRQ > And this topic is just a forum for ideas. > > I'm not really against := operator, but I'm against inconsistency bound > with variable shadowing. > It is really annoying to search bugs introduced with variable shadowing, > and since Golang presents itself as > a language where bugs are harder to introduce, this looks to be an issue. > > Could Go2 be less error prone at least in this place? > > > -- 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.