export async function tcgcToGoCodeModel()

in packages/typespec-go/src/tcgcadapter/adapter.ts [19:70]


export async function tcgcToGoCodeModel(context: EmitContext<GoEmitterOptions>): Promise<go.CodeModel> {
  const info = new go.Info('TODO Title');
  const options = new go.Options(headerText,
    context.options['generate-fakes'] === true,
    context.options['inject-spans'] === true,
    context.options['disallow-unknown-fields'] === true,
    context.options['generate-examples'] === true || context.options['generate-samples'] === true // generate-examples has been deprecated, for compat we still support it.
  );
  if (context.options['azcore-version']) {
    options.azcoreVersion = context.options['azcore-version'];
  }

  // @encodedName can be used in XML scenarios, it
  // is effectively the same as TypeSpec.Xml.@name.
  // however, it's filtered out by default so we need
  // to add it to the allow list of decorators
  const sdkContext = await tcgc.createSdkContext(context, '@azure-tools/typespec-go', {
    additionalDecorators: ['TypeSpec\\.@encodedName'],
    disableUsageAccessPropagationToBase: true,
  });
  context.program.reportDiagnostics(sdkContext.diagnostics);
  let codeModelType: go.CodeModelType = 'data-plane';
  if (sdkContext.arm === true) {
    codeModelType = 'azure-arm';
  }

  const codeModel = new go.CodeModel(info, codeModelType, packageNameFromOutputFolder(context.emitterOutputDir), options);
  if (context.options.module && context.options['module-version']) {
    codeModel.options.module = new go.Module(context.options.module, context.options['module-version']);
  } else if (context.options.module || context.options['module-version']) {
    throw new AdapterError('InvalidArgument', '--module and --module-version must both or neither be set', NoTarget);
  }
  if (context.options['rawjson-as-bytes']) {
    codeModel.options.rawJSONAsBytes = true;
  }
  if (context.options['slice-elements-byval']) {
    codeModel.options.sliceElementsByval = true;
  }
  codeModel.options.factoryGatherAllParams = true;
  if (context.options['factory-gather-all-params'] === false) {
    codeModel.options.factoryGatherAllParams = false;
  }
  fixStutteringTypeNames(sdkContext.sdkPackage, codeModel, context.options);

  const ta = new typeAdapter(codeModel);
  ta.adaptTypes(sdkContext);

  const ca = new clientAdapter(ta, context.options);
  ca.adaptClients(sdkContext.sdkPackage);
  codeModel.sortContent();
  return codeModel;
}