gen/writers/generate.go
func GenerateClient(version string, descriptor *gen.APIDescriptor, codegen, pkg string) error {
	f, err := os.Create(codegen)
	if err != nil {
		return err
	}
	c, err := NewClientWriter()
	if err != nil {
		return err
	}
	kingpin.FatalIfError(c.WriteHeader(pkg, version, descriptor.NeedTime, descriptor.NeedJSON, f), "")
	for _, name := range descriptor.ResourceNames {
		resource := descriptor.Resources[name]
		c.WriteResourceHeader(name, f)
		kingpin.FatalIfError(c.WriteResource(resource, f), "")
	}
	c.WriteTypeSectionHeader(f)
	for _, name := range descriptor.TypeNames {
		t := descriptor.Types[name]
		c.WriteType(t, f)
	}
	f.Close()
	o, err := exec.Command("go", "fmt", codegen).CombinedOutput()
	if err != nil {
		return fmt.Errorf("Failed to format generated client code:\n%s", o)
	}
	return nil
}
func GenerateClient(version string, descriptor *gen.APIDescriptor, codegen, pkg string) error {
	f, err := os.Create(codegen)
	if err != nil {
		return err
	}
	c, err := NewClientWriter()
	if err != nil {
		return err
	}
	kingpin.FatalIfError(c.WriteHeader(pkg, version, descriptor.NeedTime, descriptor.NeedJSON, f), "")
	for _, name := range descriptor.ResourceNames {
		resource := descriptor.Resources[name]
		c.WriteResourceHeader(name, f)
		kingpin.FatalIfError(c.WriteResource(resource, f), "")
	}
	c.WriteTypeSectionHeader(f)
	for _, name := range descriptor.TypeNames {
		t := descriptor.Types[name]
		c.WriteType(t, f)
	}
	f.Close()
	o, err := exec.Command("go", "fmt", codegen).CombinedOutput()
	if err != nil {
		return fmt.Errorf("Failed to format generated client code:\n%s", o)
	}
	return nil
}
// Generate API client code, drives the code writer.