Golang go/ast.MergePackageFiles() function example
package go/ast
MergePackageFiles creates a file AST by merging the ASTs of the files belonging to a package. The mode flags control merging behavior.
Golang go/ast.MergePackageFiles() function usage example
// from https://github.com/chuckpreslar/gofer/blob/master/gofer.go
func parsePackages(packages map[string]*ast.Package, dir string) {
for _, pkg := range packages {
file := ast.MergePackageFiles(pkg, ast.FilterImportDuplicates) // <-- here
if isGoferTaskFile(file) {
imprtPath := strings.TrimPrefix(strings.Replace(dir, goPath, "", 1), SourcePrefix)
templateData.Imports = append(templateData.Imports, imprt{imprtPath})
}
}
}
References :
Advertisement
Something interesting
Tutorials
+13k Swift : Convert (cast) Int to String ?
+7.8k Golang : Load DSA public key from file example
+18.4k Golang : How to get hour, minute, second from time?
+20.2k Golang : Reset or rewind io.Reader or io.Writer
+8.3k Golang : Implementing class(object-oriented programming style)
+8.3k Golang : Check if integer is power of four example
+7k Golang : Find the shortest line of text example
+7.1k Golang : Get environment variable
+6.9k Default cipher that OpenSSL used to encrypt a PEM file
+10.5k Golang : Create matrix with Gonum Matrix package example
+12.1k Golang : Sort and reverse sort a slice of runes
+6.2k Golang : Process non-XML/JSON formatted ASCII text file example