code: func Generate(schema *rdl.Schema, params *GeneratorParams) error {
  	name := strings.ToLower(string(schema.Name))
  	outdir := params.Outdir
  	if outdir == "" {
  		outdir = "."
  		name = name + "_model.go"
  	} else if strings.HasSuffix(outdir, ".go") {
  		name = filepath.Base(outdir)
  		outdir = filepath.Dir(outdir)
  	} else {
  		name = name + "_model.go"
  	}
  	err := os.MkdirAll(outdir, 0755)
  	if err != nil {
  		return err
  	}
  	filepath := outdir + "/" + name
  	out, file, _, err := genutil.OutputWriter(filepath, "", ".go")
  	if err != nil {
  		return err
  	}
  	if file != nil {
  		defer func() {
  			file.Close()
  			err := goFmt(filepath)
  			if err != nil {
  				fmt.Println("Warning: could not format go code:", err)
  			}
  		}()
  	}
  	gen := &modelGenerator{
  		registry:       rdl.NewTypeRegistry(schema),
  		schema:         schema,
  		writer:         out,
  		librdl:         params.LibRdl,
  		prefixEnums:    params.PrefixEnums,
  		precise:        params.PreciseTypes,
  		err:            nil,
  		untaggedUnions: params.UntaggedUnions,
  		ns:             params.Namespace,
  		rdl:            schema.Name == "rdl",
  	}
  	gen.emitHeader(params.Banner)
  	if gen.err == nil {
  		for _, t := range schema.Types {
  			gen.emitType(t)
  		}
  	}
  	out.Flush()
  	if gen.err == nil {
  		if params.GenerateSchema {
  			gen.err = GenerateGoSchema(params.Banner, schema, outdir, params.Namespace, params.LibRdl, params.PrefixEnums)
  		}
  	}
  	return gen.err
  }
docs: // GenerateGoModel generates the model code for the types defined in the RDL schema.