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
+22.1k Golang : Repeat a character by multiple of x factor
+7.9k Golang : How to feed or take banana with Gorilla Web Toolkit Session package
+8.3k Golang : Configure Apache and NGINX to access your Go service example
+26k Golang : Convert IP address string to long ( unsigned 32-bit integer )
+14.1k Golang : Check if a file exist or not
+15.2k Golang : How to check if IP address is in range
+9.5k Mac OSX : Get a process/daemon status information
+11.3k Golang : How to use if, eq and print properly in html template
+20k Golang : How to run your code only once with sync.Once object
+7.5k Golang : Dealing with struct's private part
+28.8k Golang : Detect (OS) Operating System
+20.6k Golang : Secure(TLS) connection between server and client