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
+12.3k Golang : List running EC2 instances and descriptions
+22.2k Golang : Convert seconds to minutes and remainder seconds
+13k Swift : Convert (cast) Int to String ?
+9.7k Golang : List available AWS regions
+16.4k Golang : How to implement two-factor authentication?
+6.8k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?
+6.1k PageSpeed : Clear or flush cache on web server
+18.7k Unmarshal/Load CSV record into struct in Go
+9.2k Golang : Create and shuffle deck of cards example
+4.7k Javascript : Access JSON data example
+9.5k Golang : Detect Pascal, Kebab, Screaming Snake and Camel cases
+19.1k Golang : Clearing slice