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
+19.7k Golang : Archive directory with tar and gzip
+18.2k Golang : Get command line arguments
+9k Golang : automatically figure out array length(size) with three dots
+19.4k Golang : How to count the number of repeated characters in a string?
+15.2k Golang : How to check if IP address is in range
+11.6k SSL : The certificate is not trusted because no issuer chain was provided
+10.6k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+12.1k Golang : convert(cast) string to integer value
+20.2k Golang : Determine if directory is empty with os.File.Readdir() function
+15.2k Golang : Accurate and reliable decimal calculations
+12.3k Golang : 2 dimensional array example