Table of Contents generated with DocToc
The template is used to create golang project in Nirvana. All nirvana projects must follow the conventions in the template. Calling for exceptions must be brought up in the engineering team.
The template doesn't have API docs. For web service, please include API docs here, whether it's auto-generated or hand-written. For auto-generated API docs, you can also give instructions on the build process.
The template follows project convention doc.
The template project is in alpha status.
Below we describe the conventions or tools specific to golang project.
. #
├── Gopkg.toml #
├── Makefile #
├── OWNERS #
├── README.md #
├── apis # Store apidocs (swagger json)
├── bin # Store the compiled binary
├── build # Store Dockerfile
│ └── demo-admin #
│ └── Dockerfile #
├── cmd # Store startup commands for project
│ └── demo-admin #
│ └── main.go #
├── nirvana.yaml # File to describes your project
├── pkg # Store structures and converters required by API, distinguish by version
│ ├── apis #
│ │ └── v1 #
│ │ ├── converters #
│ │ │ └── converters.go #
│ │ └── types.go #
│ ├── descriptors # Store API descriptions (routing and others), distinguish by version
│ │ └── v1 #
│ │ ├── descriptors.go #
│ │ └── message.go # Store API definition of message
│ ├── filters # Store HTTP Request filter
│ │ └── filter.go #
│ ├── handler # Store the logical processing required by APIs
│ │ └── message.go #
│ ├── middlewares # Store middlewares
│ │ └── middlewares.go #
│ ├── modifiers # Store definition modifiers
│ │ └── modifiers.go #
│ └── version # Store version information of project
│ └── version.go #
├── release #
│ └── template-admin.yaml #
├── test # Store all tests (except unit tests), e.g. integration, e2e tests.
│ └── test_make.sh #
└── vendor #
Notes
- Makefile MUST NOT change well-defined command semantics, see Makefile for details.
- Every project MUST use
dep
for vendor management and MUST checkinvendor
direcotry. cmd
andbuild
MUST have the same set of subdirectories for main targets- For example,
cmd/admin,cmd/controller
andbuild/admin,build/controller
. - Dockerfile MUST be put under
build
directory even if you have only one Dockerfile.
- For example,
- Upon checking out, you should install pre-commit hook by running
pre-commit install -t pre-push
.