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
+8.2k Golang : Metaprogramming example of wrapping a function
+9.6k Javascript : Read/parse JSON data from HTTP response
+15k Golang : package is not in GOROOT during compilation
+4.8k Facebook : How to place save to Facebook button on your website
+10.1k Golang : Print how to use flag for your application example
+9.7k Golang : Sort and reverse sort a slice of floats
+12.7k Android Studio : Highlight ImageButton when pressed on example
+7.5k Golang : How to stop user from directly running an executable file?
+8.6k Golang : Another camera capture GUI application with GTK and OpenCV
+32.4k Golang : Math pow(the power of x^y) example
+9.1k Golang : Intercept and compare HTTP response code example
+24.5k Golang : Change file read or write permission example