Skip to content

Commit

Permalink
fix: Go code samples (#120)
Browse files Browse the repository at this point in the history
* Fix request args construction in go samples

* Enclose the executable statement in a function

* Add package declaration before imports

* ci: Generate code

---------

Co-authored-by: Seam Bot <[email protected]>
  • Loading branch information
andrii-balitskyi and seambot authored Oct 10, 2024
1 parent 0bbdd5c commit 7d25f9f
Show file tree
Hide file tree
Showing 3 changed files with 233 additions and 68 deletions.
7 changes: 5 additions & 2 deletions src/lib/code-sample/go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ export const createGoRequest = (
goPackageName,
requestStructName,
})
const goSdkRequestArgs = `context.Background()${isReqWithParams ? `, ${goPackageName}.${requestStructName}(${formattedArgs})` : ''}`
const goSdkRequestArgs = `context.Background()${isReqWithParams ? `, ${goPackageName}.${requestStructName}{${formattedArgs}}` : ''}`

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

return `${goSdkImports}
return `package main
${goSdkImports}
func main() {
client${pathParts.map((p) => pascalCase(p)).join('.')}(${goSdkRequestArgs})
}
`.trim()
}

Expand Down
Loading

0 comments on commit 7d25f9f

Please sign in to comment.