Skip to content

Commit

Permalink
Reorg function order
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Sep 26, 2024
1 parent 9a1ed46 commit 52d95b8
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/lib/code-sample/go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,6 @@ const formatGoArray = (value: Json[], key: string): string => {
return `[${value.length}]${arrayType}{${formattedItems.join(', ')}}`
}

const formatGoObject = (value: Record<string, Json>, key: string): string => {
if (Object.keys(value).length === 0) {
return 'struct{}{}'
}

const formattedEntries = Object.entries(value)
.map(
([objKey, val]) =>
`${pascalCase(objKey)}: ${formatGoValue({ value: val, key: objKey })}`,
)
.join(', ')

return `api.${pascalCase(key)}{${formattedEntries}}`
}

const isPrimitiveValue = (value: Json): boolean =>
value != null && typeof value !== 'object'

Expand All @@ -164,4 +149,19 @@ const getPrimitiveTypeName = (value: Json): string => {
}
}

const formatGoObject = (value: Record<string, Json>, key: string): string => {
if (Object.keys(value).length === 0) {
return 'struct{}{}'
}

const formattedEntries = Object.entries(value)
.map(
([objKey, val]) =>
`${pascalCase(objKey)}: ${formatGoValue({ value: val, key: objKey })}`,
)
.join(', ')

return `api.${pascalCase(key)}{${formattedEntries}}`
}

export const createGoResponse = createJsonResponse

0 comments on commit 52d95b8

Please sign in to comment.