FAQ
How about a "warn about shadowed variables" feature of a tool like vet?
+1, this has come up many times.

On Tue, Feb 19, 2013 at 10:22 PM, Michael Jones wrote:

How about a "warn about shadowed variables" feature of a tool like vet?

What else could it do?

+ look for idiomatic ways to do things (go fmt can turn s[0:k] into s[:k]
for example)
+ warn about shadowed variables/return args
+ maybe whine about using fmt.Printf with fixed strings (silly waste of
time): Printf -> Print
:

On Tue, Feb 19, 2013 at 1:11 PM, minux wrote:


On Wed, Feb 20, 2013 at 5:07 AM, Johann Höchtl wrote:
On 02/19/2013 10:03 PM, Jan Mercl wrote:

This is how block scoping must work for it to be useful. Imagine for
example code getting moved around. There's no reason for the compiler to
say anything about it.
Ok, but when you remove the block, code like this is very likely to be
erroneous:

var i int

if i != 0 {
} else {
}

Of course, Go promises to be well defined but it's still likely to make
no sense as i get's never explicitly assigned to
the behavior of your example really is well defined, and it might be the
programmer's intention,
or not, but in general (like the other thread about giving error for
const if conditions), the compiler
is impossible to know the real intent at this stage (and when they do,
maybe we don't even need to write it down).

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Michael T. Jones | Chief Technology Advocate | mtj@google.com | +1
650-335-5765

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

People

Translate

site design / logo © 2021 Grokbase