docs/1.32/prisma-client/setup/generating-the-client-GO-r3c3.mdx
import Code from "components/Markdown/Code"
export const meta = { title: 'Generating the Client (Go)', position: 20, technology: 'go', technologyOrder: 3, articleGroup: 'Generating the Client', }
The Prisma client is auto-generated using the prisma generate command of the Prisma CLI. One Prisma client connects to exactly one Prisma service.
prisma generate reads the information that's specified under the generate root property in your service's prisma.yml.
generate in prisma.ymlThe generate root property accepts a list of objects. Each object has two fields:
generator: The programming language in which the Prisma client should be generated. Here are the accepted values:
typescript-clientjavascript-clientflow-clientgo-clientoutput: The path and name of the file in which the Prisma client should be stored.As an example, consider the following prisma.yml:
datamodel: datamodel.prisma
endpoint: http://localhost:4466
secret: mysecret42
generate:
- generator: go-client
output: ./prisma-client/
Running prisma generate in the directory where that prisma.yml is located generates a Prisma client in Go and stores it in a directory called prisma-client.
The generated Prisma client is configured to target the endpoint specified in prisma.yml. It also knows the secret so that it can authenticate against your Prisma service when you're using it in your application.
prisma.ymlNote that you can also reference environment variables in prisma.yml by using the env:-prefix and enclosing them with ${}. For example, if you have an environment variable set that's called MY_SECRET:
datamodel: datamodel.prisma
endpoint: http://localhost:4466
secret: ${env:MY_SECRET}
generate:
- generator: go-client
output: ./prisma-client/
You can find more info about using environment variables here.
The Go client is generated in a single file called prisma.go which will be located in the directory specified as the output in your prisma.yml.