Skip to content

Commit

Permalink
fix: Improve go samples formatting (#122)
Browse files Browse the repository at this point in the history
* fix: Improve go samples formatting

* ci: Generate code

* Remove extra newline

---------

Co-authored-by: Seam Bot <[email protected]>
  • Loading branch information
andrii-balitskyi and seambot authored Oct 11, 2024
1 parent cfe3ca3 commit cb26a6d
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 45 deletions.
6 changes: 3 additions & 3 deletions src/lib/code-sample/go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ export const createGoRequest = (
goPackageName,
requestStructName,
})
const goSdkRequestArgs = `context.Background()${isReqWithParams ? `, ${goPackageName}.${requestStructName}{${formattedArgs}}` : ''}`
const goSdkRequestArgs = `context.Background()${isReqWithParams ? `,\n${goPackageName}.${requestStructName}{\n${formattedArgs},\n}` : ''}`

const pathParts = request.path.split('/')

return `package main
${goSdkImports}
func main() {
client${pathParts.map((p) => pascalCase(p)).join('.')}(${goSdkRequestArgs})
client${pathParts.map((p) => pascalCase(p)).join('.')}(${isReqWithParams ? '\n' : ''}${goSdkRequestArgs},\n)
}
`.trim()
}
Expand Down Expand Up @@ -105,7 +105,7 @@ const formatGoRequestArgs = (
)
return `${pascalCase(paramKey)}: ${formattedValue}`
})
.join(', ')
.join(',\n')

const formatGoRequestArgValue = (
key: string,
Expand Down
Loading

0 comments on commit cb26a6d

Please sign in to comment.