“variable declared and not used” compilation error

后端 未结 6 1062
遥遥无期
遥遥无期 2021-01-12 07:04

I am learning Google\'s new language Go. I am just trying stuff out and I noticed that if you declare a variable and do not do anything with it the go compiler (8g

6条回答
  •  庸人自扰
    2021-01-12 07:47

    this can make development a bit of a pain. sometimes i run code that has variables declared but not used (but will be used).

    in these cases i simple do this:

    fmt.Printf("%v %v %v",somevar1,somevar2,somevar3)

    and there, they are "used".

    i'd like to see a flag to the go tools that lets me suppress this error while developing.

提交回复
热议问题