# pjx **Repository Path**: fwhezfwhez/pjx ## Basic Information - **Project Name**: pjx - **Description**: A project builder. Helps auto generate structual project dictories, which works for golang server program, - **Primary Language**: Go - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-07-20 - **Last Updated**: 2021-03-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## pjx pjx is a tool helps auto-generate server side directories and some go code.Supporting linux, windows, mac. **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* - [1. Start](#1-start) - [GOPATH](#gopath) - [GOMODULE](#gomodule) - [2. Module](#2-module) - [2.1 Directory generate](#21-directory-generate) - [2.2 Package storage and migration](#22-package-storage-and-migration) - [2.3 Config files encrypt and decrypt](#23-config-files-encrypt-and-decrypt) - [3. Commands](#3-commands) - [3.1 `new`](#31-new) - [3.2 `module`](#32-module) - [3.3 `add`](#33-add) - [3.4 `use`](#34-use) - [3.5 `merge`](#35-merge) - [3.6 `clone`](#36-clone) - [3.7 `encrypt`, `decrypt`](#37-encrypt-decrypt) - [4. Optional args](#4-optional-args) - [5. FAQ](#5-faq) - [5.1. pjx command not found?](#51-pjx-command-not-found) - [5.2. How to design module directories as wanted?](#52-how-to-design-module-directories-as-wanted) - [5.3. Permission deny?](#53-permission-deny) - [5.4. Pjx-repo for sharing?](#54-pjx-repo-for-sharing) ## 1. Start #### GOPATH way 1: - `go get -u github.com/fwhezfwhez/pjx` way 2: - `git clone https://github.com/fwhezfwhez/pjx.git` - `cd pjx` - `go install` #### GOMODULE - `git clone https://github.com/fwhezfwhez/pjx.git` - `go install` Make sure in cmd type `pjx --version`, output normal. ## 2. Module pjx now provides functional flows below: #### 2.1 Directory generate For developing golang server project, pjx can auto-generate projects. Take helloWorld project for example: `pjx new helloworld` `cd helloworld` `pjx module user`
The generated directories will look like: ```txt appName | -- module | -- config | -- dependence | -- independence | -- main.go ``` What are they? - appName: project name, for example `helloWorld` - module: all modules about service, for example `user`, `shop`. Each module has inner directories.They're documented below. - config: some config of the project. - dependence: packages or files of common util tool. These packages and files might import project's inner package. - independence: packages or files of common util tool. These pkg and files will not import any of this project.It can be no-harm add, remove, reuse-copy. - main.go: project entrance. **module** Module divides project into modules such as `user`, `shop`.Its generated directories will look like: ```txt module | -- user | | -- userPb | | -- userModel | | -- userRouter | | -- userService | | -- userTestClient | | -- userExport | | -- userControl | | -- userJob | | -- main.go | ... ``` What are they? - user: module name. - userPb: proto file and generated go file. - userModel: db model or service model. - userRouter: http, tcp router. - userControl: place to receive request body from router, also a place to handle error. - userService: http, tcp service codes.Errors from here will be return. - userTestClient: generate test as client codes. - userExport: export user module as another single server.It's a sub-node of user/main.go - userJob: cron jobs. Commands are below: - pjx new appName - pjx module moduleName **Design your own directories refers to [4.2. How to design module directories as wanted?](#42-how-to-design-module-directories-as-wanted)** `// - pjx test-client functionName [--http] [--tcp] [--grpc]` #### 2.2 Package storage and migration **Make sure configure system env `pjx_path`.This will let pjx know where to storage package locally** For storing and migrating local package, pjx provides commands below: Take helloworld for example: `pjx add helloworld` add a package named helloword in current dir into repo `pjx use helloworld` insert a package from repo to current dir **Make sure configure system env `pjx_path`.This will let pjx know where to storage package locally.If not well set, it still work and will save packages in user-home/pjx_path** `add` and `use` keyword ruled below: (value in '<>' is necessary, '[]' is optional. if `namespace`, `tag` not set, use 'global' and 'master'. ':value' means it's a value not fixed.) `pjx add