Answer the question
In order to leave comments, you need to log in
Is it possible to build a project in Go with variables declared but not used?
Decided to try Go today. Porting my project from Python to Go. I noticed such a feature, if a variable is declared in the project, but it is not used, the compiler does not issue a warning, but immediately an error. Of course, the project is not going.
Example:
Going like this:
var files string = "Предположим, тут список файлов"
fmt.Println(files)
And now it's gone:var files string = "Предположим, тут список файлов"
// fmt.Println(files)
./main.go:5:2: imported and not used: "fmt"
Ошибка: процесс завершился с кодом 2.
imported and not used: "fmt"
Answer the question
In order to leave comments, you need to log in
No, you can't collect.
You can make a feint with your ears (but this is a bad form)
var _ = fmt.Println
var _ = myvar
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question