func mergeImports(env *ProcessEnv, fset *token.FileSet, f *ast.File) {
	if len(f.Decls) <= 1 {
		return
	}
	var first *ast.GenDecl
	for i := 0; i < len(f.Decls); i++ {
		decl := f.Decls[i]
		gen, ok := decl.(*ast.GenDecl)
		if !ok || gen.Tok != token.IMPORT || declImports(gen, "C") {
			continue
		}
		if first == nil {
			first = gen
			continue  
		}
		first.Lparen = first.Pos()
		for _, spec := range gen.Specs {
			spec.(*ast.ImportSpec).Path.ValuePos = first.Pos()
			first.Specs = append(first.Specs, spec)
		}
		f.Decls = append(f.Decls[:i], f.Decls[i+1:]...)
		i--
	}
}
mergeImports merges all the import declarations into the first one.
Taken from golang.org/x/tools/ast/astutil.
package imports
import (
	"go/ast"
	"go/token"
	"sort"
	"strconv"
)
func sortImports(env *ProcessEnv, fset *token.FileSet, f *ast.File) {
	for i, d := range f.Decls {
		d, ok := d.(*ast.GenDecl)
		if !ok || d.Tok != token.IMPORT {
			break
		}
		if len(d.Specs) == 0 {
			f.Decls = append(f.Decls[:i], f.Decls[i+1:]...)
		}
		if !d.Lparen.IsValid() {
			continue
		}
		i := 0
		specs := d.Specs[:0]
		for j, s := range d.Specs {
			if j > i && fset.Position(s.Pos()).Line > 1+fset.Position(d.Specs[j-1].End()).Line {
				specs = append(specs, sortSpecs(env, fset, f, d.Specs[i:j])...)
				i = j
			}
		}
		specs = append(specs, sortSpecs(env, fset, f, d.Specs[i:])...)
		d.Specs = specs
		if len(d.Specs) > 0 {
			lastSpec := d.Specs[len(d.Specs)-1]
			lastLine := fset.Position(lastSpec.Pos()).Line
			if rParenLine := fset.Position(d.Rparen).Line; rParenLine > lastLine+1 {
				fset.File(d.Rparen).MergeLine(rParenLine - 1)
			}
		}
	}
}