github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/tm2/pkg/amino/cmd/goscan/goscan.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"go/parser"
     6  	"go/token"
     7  	"os"
     8  
     9  	"github.com/davecgh/go-spew/spew"
    10  )
    11  
    12  func main() {
    13  	fset := token.NewFileSet() // positions are relative to fset
    14  
    15  	filename := os.Args[1]
    16  	bz, err := os.ReadFile(filename)
    17  	if err != nil {
    18  		panic(err)
    19  	}
    20  
    21  	// Parse src but stop after processing the imports.
    22  	f, err := parser.ParseFile(fset, "", string(bz), parser.ParseComments|parser.DeclarationErrors)
    23  	if err != nil {
    24  		fmt.Println(err)
    25  		return
    26  	}
    27  
    28  	// Print the imports from the file's AST.
    29  	spew.Dump(f)
    30  }