Golang go/parser.Mode type example
package go/parser
A Mode value is a set of flags (or 0). They control the amount of source code parsed and other optional parser functionality.
Golang go/parser.Mode type usage example
func doDir(name string) {
notests := func(info os.FileInfo) bool {
if !info.IsDir() && strings.HasSuffix(info.Name(), ".go") &&
!strings.HasSuffix(info.Name(), "_test.go") {
return true
}
return false
}
fs := token.NewFileSet()
pkgs, err := parser.ParseDir(fs, name, notests, parser.Mode(0))
if err != nil {
errorf("%s", err)
return
}
for _, pkg := range pkgs {
doPackage(fs, pkg)
}
}
References :
https://gowalker.org/github.com/remyoudompheng/go-misc/deadcode?f=deadcode.go
Advertisement
Something interesting
Tutorials
+14k Golang : Compress and decompress file with compress/flate example
+20.3k Golang : Check if os.Stdin input data is piped or from terminal
+5.4k Golang *File points to a file or directory ?
+14k Golang : Fix cannot use buffer (type bytes.Buffer) as type io.Writer(Write method has pointer receiver) error
+12.1k Golang : Detect user location with HTML5 geo-location
+8.4k Your page has meta tags in the body instead of the head
+6.8k Get Facebook friends working in same company
+14.4k Golang : Parsing or breaking down URL
+7.4k Golang : Check to see if *File is a file or directory
+35.5k Golang : Smarter Error Handling with strings.Contains()
+30.9k error: trying to remove "yum", which is protected
+8k Findstr command the Grep equivalent for Windows