mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
ent/doc: better installation instructions
Reviewed By: alexsn Differential Revision: D17950790 fbshipit-source-id: d7517768bdfcc2eff8a5d900943a61ea2359d91b
This commit is contained in:
committed by
Facebook Github Bot
parent
38b1fc9e66
commit
e75a817d63
@@ -47,7 +47,18 @@ When working with `entc` in a project, you want to make sure that the version be
|
||||
used by `entc` is **identical** to the `ent` version used by your project.
|
||||
|
||||
One of the options for achieving this is asking `go generate` to use the version
|
||||
mentioned in the `go.mod` file when running `entc`.
|
||||
mentioned in the `go.mod` file when running `entc`. If your project does not use
|
||||
[Go modules](https://github.com/golang/go/wiki/Modules#quick-start), setup one as follows:
|
||||
|
||||
```console
|
||||
go mod init <project>
|
||||
```
|
||||
|
||||
And then, re-run the following command in order to add `ent` to your `go.mod` file:
|
||||
|
||||
```console
|
||||
go get github.com/facebookincubator/ent/cmd/entc
|
||||
```
|
||||
|
||||
Add a `generate.go` file to your project under `<project>/ent`:
|
||||
|
||||
@@ -57,7 +68,8 @@ package ent
|
||||
//go:generate go run github.com/facebookincubator/ent/cmd/entc generate ./schema
|
||||
```
|
||||
|
||||
And run `go generate ./ent` from your project root directory in order to run `entc` for your project.
|
||||
Finally, you can run `go generate ./ent` from the root directory of your project
|
||||
in order to run `entc` code generation on your project schemas.
|
||||
|
||||
## Code Generation Options
|
||||
|
||||
|
||||
@@ -22,6 +22,15 @@ go get github.com/facebookincubator/ent/cmd/entc
|
||||
|
||||
After installing `entc` (the code generator for `ent`), you should have it in your `PATH`.
|
||||
|
||||
## Setup A Go Environment
|
||||
|
||||
If your project directory is outside [GOPATH](https://github.com/golang/go/wiki/GOPATH) or you are not familiar with
|
||||
GOPATH, setup a [Go module](https://github.com/golang/go/wiki/Modules#quick-start) project as follows:
|
||||
|
||||
```console
|
||||
go mod init <project>
|
||||
```
|
||||
|
||||
## Create Your First Schema
|
||||
|
||||
Go to the root directory of your project, and run:
|
||||
|
||||
Reference in New Issue
Block a user