Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Jan Mercl
On Thu, Jan 10, 2019 at 6:30 AM Justin Israel 
wrote:

> On Thu, Jan 10, 2019 at 6:04 PM 김용빈  wrote:
>
>> package main
>>
>> func unused(x interface{}) {}
>>
>> func main() {
>> a := 1
>> unused(a)
>> }
>>
>
> The function isn't even required here. Assigning to underscore will
> prevent the error:
>
> func main() {
> a := 1
> _ = a
> }
>

 Both versions above have the same problem - it's possible to forgot the
bypass hack in production code.

For many years I'm using

func use(...interface{}) {}

but defined in tests, for example in all_test.go. This enables easy
disabling of the 'unused variable' error during development/debugging, but
the code does not otherwise compile until the 'use(foo, bar') hack is
removed or commented out.

-- 

-j

-- 
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.


Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Justin Israel
On Thu, Jan 10, 2019 at 6:04 PM 김용빈  wrote:

> package main
>
> func unused(x interface{}) {}
>
> func main() {
> a := 1
> unused(a)
> }
>

The function isn't even required here. Assigning to underscore will prevent
the error:

func main() {
a := 1
_ = a
}


>
> 2012년 3월 7일 수요일 오후 8시 32분 19초 UTC+9, Elazar Leibovich 님의 말:
>
>> I sometimes have a very strange error, which I can't understand its
>> source.
>>
>> One of my techniques for finding it, is isolate the problem to a very
>> small case, by commenting out pieces of the code, and noticing which pieces
>> of codes cause the problem.
>>
>> Go really helps me with it due to the short compile run cycles, but it is
>> very difficult to use this technique without leaving unused variables.
>>
>> Is there a flag that enables you to temporarily compile without this
>> warning?
>>
> --
> 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.
>

-- 
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.


[go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread 김용빈
package main

func unused(x interface{}) {}

func main() {
a := 1
unused(a)
}

2012년 3월 7일 수요일 오후 8시 32분 19초 UTC+9, Elazar Leibovich 님의 말:
>
> I sometimes have a very strange error, which I can't understand its source.
>
> One of my techniques for finding it, is isolate the problem to a very 
> small case, by commenting out pieces of the code, and noticing which pieces 
> of codes cause the problem.
>
> Go really helps me with it due to the short compile run cycles, but it is 
> very difficult to use this technique without leaving unused variables.
>
> Is there a flag that enables you to temporarily compile without this 
> warning?
>

-- 
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.


Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread robert engels
I’m pretty sure that is rose colored glasses…

It is a pain, but at the same time, the lack of dynamic code modification is 
more of a pain, coupled with no private methods in file scope (because with 
those you could decompose the larger functions without polluting the namespace).

But in many ways, the inability to test/debug “interactively” does force you 
down the road to better design - but when you are debugging someone else’s code 
that’s a whole other issue...

Test cases mitigate the problem immensely.

> On Jan 9, 2019, at 9:49 PM, Ekow  wrote:
> 
> It is a good kind of pain. 
> 
> This intentional construct forces you to only use what you need at the point 
> where you actually need it. 
> 
> YAGNI.
> 
> Regards,
> B Charles Jnr.
> 
> On Jan 9, 2019, at 8:17 PM, Rich mailto:rma...@gmail.com>> 
> wrote:
> 
>> Yes at times it's a pain, after programming for a while in Go you just get 
>> used to it, and I seldom run into an unused variable. Use Visual Studio 
>> Code, you'll get a red squiggly line and an error long before you ever try 
>> to compile the code. If you really want to keep the variable, variable=_ 
>> takes care of it. 
>> 
>> On Wednesday, January 9, 2019 at 5:01:52 PM UTC-5, Ian Lance Taylor wrote:
>> On Wed, Jan 9, 2019 at 1:46 PM > wrote: 
>> > 
>> > So, 2019 year. Still no compiler flag. Slphers :) 
>> 
>> This isn't a matter of being slow, it's an intentional decision. 
>> 
>> Ian 
>> 
>> -- 
>> 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 
>> .
> 
> 
> -- 
> 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 
> .

-- 
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.


Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Ekow
It is a good kind of pain. 

This intentional construct forces you to only use what you need at the point 
where you actually need it. 

YAGNI.

Regards,
B Charles Jnr.

> On Jan 9, 2019, at 8:17 PM, Rich  wrote:
> 
> Yes at times it's a pain, after programming for a while in Go you just get 
> used to it, and I seldom run into an unused variable. Use Visual Studio Code, 
> you'll get a red squiggly line and an error long before you ever try to 
> compile the code. If you really want to keep the variable, variable=_ takes 
> care of it. 
> 
>> On Wednesday, January 9, 2019 at 5:01:52 PM UTC-5, Ian Lance Taylor wrote:
>> On Wed, Jan 9, 2019 at 1:46 PM  wrote: 
>> > 
>> > So, 2019 year. Still no compiler flag. Slphers :) 
>> 
>> This isn't a matter of being slow, it's an intentional decision. 
>> 
>> Ian 
> 
> -- 
> 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.

-- 
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.


Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Rich
Yes at times it's a pain, after programming for a while in Go you just get 
used to it, and I seldom run into an unused variable. Use Visual Studio 
Code, you'll get a red squiggly line and an error long before you ever try 
to compile the code. If you really want to keep the variable, variable=_ 
takes care of it. 

On Wednesday, January 9, 2019 at 5:01:52 PM UTC-5, Ian Lance Taylor wrote:
>
> On Wed, Jan 9, 2019 at 1:46 PM > wrote: 
> > 
> > So, 2019 year. Still no compiler flag. Slphers :) 
>
> This isn't a matter of being slow, it's an intentional decision. 
>
> Ian 
>

-- 
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.


Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Glen Newton
I use the "if false{..." extensively as described above.

-- 
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.


Re: [go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread Ian Lance Taylor
On Wed, Jan 9, 2019 at 1:46 PM  wrote:
>
> So, 2019 year. Still no compiler flag. Slphers :)

This isn't a matter of being slow, it's an intentional decision.

Ian

-- 
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.


[go-nuts] Re: Temporarily allow unused variables

2019-01-09 Thread xenginex
So, 2019 year. Still no compiler flag. Slphers :)

среда, 7 марта 2012 г., 14:32:19 UTC+3 пользователь Elazar Leibovich 
написал:
>
> I sometimes have a very strange error, which I can't understand its source.
>
> One of my techniques for finding it, is isolate the problem to a very 
> small case, by commenting out pieces of the code, and noticing which pieces 
> of codes cause the problem.
>
> Go really helps me with it due to the short compile run cycles, but it is 
> very difficult to use this technique without leaving unused variables.
>
> Is there a flag that enables you to temporarily compile without this 
> warning?
>

-- 
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.