func (f *File) GoString() string {
	buf := &bytes.Buffer{}
	if err := f.Render(buf); err != nil {
		panic(err)
	}
	return buf.String()
}
GoString renders the File for testing. Any error will cause a panic.
package jen
import (
	"bytes"
	"fmt"
	"regexp"
	"strings"
	"unicode"
	"unicode/utf8"
)
func NewFile(packageName string) *File {
	return &File{
		Group: &Group{
			multi: true,
		},
		name:    packageName,
		imports: map[string]importdef{},
		hints:   map[string]importdef{},
	}
}
func NewFilePath(packagePath string) *File {
	return &File{
		Group: &Group{
			multi: true,
		},
		name:    guessAlias(packagePath),
		path:    packagePath,
		imports: map[string]importdef{},
		hints:   map[string]importdef{},
	}
}
func NewFilePathName(packagePath, packageName string) *File {
	return &File{
		Group: &Group{
			multi: true,
		},
		name:    packageName,
		path:    packagePath,
		imports: map[string]importdef{},
		hints:   map[string]importdef{},
	}
}
type File struct {
	*Group
	name        string
	path        string
	imports     map[string]importdef
	hints       map[string]importdef
	comments    []string
	headers     []string
	cgoPreamble []string
	PackagePrefix string
	CanonicalPath string
}
type importdef struct {
	name  string
	alias bool
}
func (f *File) HeaderComment(comment string) {
	f.headers = append(f.headers, comment)
}
func (f *File) PackageComment(comment string) {
	f.comments = append(f.comments, comment)
}
func (f *File) CgoPreamble(comment string) {
	f.cgoPreamble = append(f.cgoPreamble, comment)
}
func (f *File) Anon(paths ...string) {
	for _, p := range paths {
		f.imports[p] = importdef{name: "_", alias: true}
	}
}
func (f *File) ImportName(path, name string) {
	f.hints[path] = importdef{name: name, alias: false}
}
func (f *File) ImportNames(names map[string]string) {
	for path, name := range names {
		f.hints[path] = importdef{name: name, alias: false}
	}
}
func (f *File) ImportAlias(path, alias string) {
	f.hints[path] = importdef{name: alias, alias: true}
}
func (f *File) isLocal(path string) bool {
	return f.path == path
}
func (f *File) isValidAlias(alias string) bool {
	if alias == "." {
		return true
	}
	if IsReservedWord(alias) {
		return false
	}
	for _, v := range f.imports {
		if alias == v.name {
			return false
		}
	}
	return true
}
func (f *File) isDotImport(path string) bool {
	if id, ok := f.hints[path]; ok {
		return id.name == "." && id.alias
	}
	return false
}
func (f *File) register(path string) string {
	if f.isLocal(path) {
		return ""
	}
	def := f.imports[path]
	if def.name != "" && def.name != "_" {
		return def.name
	}
	if path == "C" {
		f.imports["C"] = importdef{name: "C", alias: false}
		return "C"
	}
	var name string
	var alias bool
	if hint := f.hints[path]; hint.name != "" {
		name = hint.name
		alias = hint.alias
	} else if standardLibraryHints[path] != "" {
		name = standardLibraryHints[path]
		alias = false
	} else {
		name = guessAlias(path)
		alias = true
	}
	unique := name
	i := 0
	for !f.isValidAlias(unique) {
		i++
		unique = fmt.Sprintf("%s%d", name, i)
	}
	if unique != name {
		alias = true
	}
	if f.PackagePrefix != "" && alias {
		unique = f.PackagePrefix + "_" + unique
	}
	f.imports[path] = importdef{name: unique, alias: alias}
	return unique
}