Skip to content

Commit

Permalink
Prepare for preview.52 release (#988)
Browse files Browse the repository at this point in the history
* Prepare for preview.52 release

* Add comment explaining else if branch, fixed indentation

* add another else if branch comment
  • Loading branch information
jhendrixMSFT authored Jul 6, 2023
1 parent e256b4d commit c39ab75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/autorest.go/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@autorest/go",
"version": "4.0.0-preview.51",
"version": "4.0.0-preview.52",
"description": "AutoRest Go Generator",
"main": "dist/exports.js",
"typings": "dist/exports.d.ts",
Expand Down
7 changes: 6 additions & 1 deletion packages/autorest.go/src/generator/fake/servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,9 @@ function createParamGroupParams(clientPkg: string, op: Operation, imports: Impor
}
content += `\t\t${localVar}[i] = ${toType}(${fromVar})\n\t}\n`;
} else if (param.language.go!.paramGroup) {
// for slices of strings that aren't in a parameter group, the call to strings.Split(...) is inlined
// into the invocation of the fake e.g. srv.FakeFunc(strings.Split...). but if it's grouped, then we
// need to create a local first which will later be copied into the param group.
imports.add('strings');
content += `\t${createLocalVariableName(param, 'Param')} := strings.Split(${paramValue}, "${getArraySeparator(param)}")\n`;
}
Expand All @@ -572,11 +575,13 @@ function createParamGroupParams(clientPkg: string, op: Operation, imports: Impor
}
content += `\t${createLocalVariableName(param, 'Param')}, err := ${from}\n`;
content += '\tif err != nil {\n\t\treturn nil, err\n\t}\n';
} else if (param.schema.type === SchemaType.ByteArray) {
} else if (param.schema.type === SchemaType.ByteArray) {
imports.add('encoding/base64');
content += `\t${createLocalVariableName(param, 'Param')}, err := base64.StdEncoding.DecodeString(${paramValue})\n`;
content += '\tif err != nil {\n\t\treturn nil, err\n\t}\n';
} else if (param.language.go!.paramGroup && (param.schema.type === SchemaType.Choice || param.schema.type === SchemaType.Constant || param.schema.type === SchemaType.Duration || param.schema.type === SchemaType.SealedChoice || param.schema.type === SchemaType.String)) {
// for params that don't require parsing, the value is inlined into the invocation of the fake.
// but if it's grouped, then we need to create a local first which will later be copied into the param group.
content += `\t${createLocalVariableName(param, 'Param')} := `;
let paramValue = getParamValueWithCast(clientPkg, param, imports);
if (!param.required) {
Expand Down

0 comments on commit c39ab75

Please sign in to comment.