Is there any way to force ignore Go errors?

1

Golang forces us to manually remove unused items in the code, for example:

for index, item := range retorno.Threads {
    fmt.Fprint(w, item.Id)
}

If you run a go run .... it will say:

  

index declared and not used

And as a result will not run application. The same applies when using import and does not use it in code, resulting in:

  

imported and not used: "(name)"

Well, I understand how to fix these types of errors, this is not the issue.

The question is many times I'm just testing something to see if it works, out of curiosity , a simple edition and that per table requires that I change other parts, for example removing a library that I ended up leaving to use.

Is there any way to ignore the error? Is there a way to automatically fix errors, such as remove unused libraries?

    
asked by anonymous 25.05.2017 / 07:30

2 answers

2

Can be avoided by using _ before declared name:

import (_ "fmt")

for _ index, item := range retorno.Threads {
    fmt.Fprint(w, item.Id)
}
    
25.05.2017 / 12:42
0

Inklevel

The compiler does not support this. In the case of imports you can use link

There is a guy who made a modified compiler to solve this qst that you want.

link

abs

    
11.06.2017 / 04:43