Skip to content

tarm/gounused

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

.

'gounused' finds unused assignements in your code.

The compiler checks for unused variables, but sometimes assignments are never read before getting overwriten or ignored. For example this code:

package main

import "fmt"

func main() {
     _, err := fmt.Println("Hello")
     _, err = fmt.Println(" world")
     _, err = fmt.Println(err)
}

The err variable is used so the compiler does not complain, but the first and third assignment to the err variable are never checked. 'gounused' finds that mistake as follows:

$ gounused ./testdata/
Unused assignment for 'err' ./testdata/test.go:6:5
Unused assignment for 'err' ./testdata/test.go:8:5
$ echo $?
1

Generated by godoc2md

About

Find unused variable assignments in Go code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages