Package cgo implements CGo by modifying a loaded AST. It does this by parsing the `import "C"` statements found in the source code with libclang and generating stub function and global declarations.

There are a few advantages to modifying the AST directly instead of doing CGo as a preprocessing step, with the main advantage being that debug information is kept intact as much as possible.



This section is empty.


This section is empty.


func Process

func Process(files []*ast.File, dir string, fset *token.FileSet, cflags []string) (*ast.File, []string, []string, map[string][]byte, []error)

Process extracts `import "C"` statements from the AST, parses the comment with libclang, and modifies the AST to use this information. It returns a newly created *ast.File that should be added to the list of to-be-parsed files, the CFLAGS and LDFLAGS found in #cgo lines, and a map of file hashes of the accessed C header files. If there is one or more error, it returns these in the []error slice but still modifies the AST.


This section is empty.