Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

So how to use gen ? #166

Open
cyg0618 opened this issue Jul 5, 2021 · 3 comments
Open

So how to use gen ? #166

cyg0618 opened this issue Jul 5, 2021 · 3 comments

Comments

@cyg0618
Copy link

cyg0618 commented Jul 5, 2021

So how to use gen ? No example for niubai. Is difficult to use this tool.
All we knew are

gen 

comman will show us the list of help list.
And gen --dao=dao doing nothing, steal return the help list page.
No tutorial for use in those Markdown files.

$ wget https://github.com/smallnest/gen/raw/master/example/sample.db
--2021-07-05 09:33:15--  https://github.com/smallnest/gen/raw/master/example/sample.db
Resolving github.com (github.com)... 13.229.188.59
Connecting to github.com (github.com)|13.229.188.59|:443... connected.
Unable to establish SSL connection.

@Darrenzzy
Copy link

same question! Ask for example

gen gorm postgres

@smallnest
Copy link
Owner

  1. You must have a postgres database
  2. You must install the gen tool: go get -u github.com/smallnest/gen
  3. Then, you can generate all codes by setting postgres dsn
$ gen --sqltype=postgres \
   	--connstr "host=%s port=%d user=%s  password=%s dbname=%s sslmode=disable" \
   	--database main  \
   	--json \
   	--gorm \
   	--guregu \
   	--rest \
   	--out ./example \
   	--module example.com/rest/example \
   	--mod \
   	--server \
   	--makefile \
   	--json-fmt=snake \
   	--generate-dao \
   	--generate-proj \
   	--overwrite

@Darrenzzy
Copy link

  1. You must have a postgres database
  2. You must install the gen tool: go get -u github.com/smallnest/gen
  3. Then, you can generate all codes by setting postgres dsn
$ gen --sqltype=postgres \
   	--connstr "host=%s port=%d user=%s  password=%s dbname=%s sslmode=disable" \
   	--database main  \
   	--json \
   	--gorm \
   	--guregu \
   	--rest \
   	--out ./example \
   	--module example.com/rest/example \
   	--mod \
   	--server \
   	--makefile \
   	--json-fmt=snake \
   	--generate-dao \
   	--generate-proj \
   	--overwrite

ok thanks ~ I solved it for your case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants