Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FinClip
ligase
提交
1e6fc74d
ligase
项目概览
FinClip
/
ligase
通知
33
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ligase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1e6fc74d
编写于
10月 06, 2017
作者:
E
Erik Johnston
提交者:
GitHub
10月 06, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Code Style and some dev docs (#286)
上级
5229dbf3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
80 addition
and
4 deletion
+80
-4
CODE_STYLE.md
CODE_STYLE.md
+63
-0
CONTRIBUTING.md
CONTRIBUTING.md
+13
-0
INSTALL.md
INSTALL.md
+4
-4
未找到文件。
CODE_STYLE.md
0 → 100644
浏览文件 @
1e6fc74d
# Code Style
We follow the standard Go style using gofmt, but with a few extra
considerations.
## Linters
We use
`gometalinter`
to run a number of linters, the exact list can be found
in
[
linter.json
](
linter.json
)
. Some of these are slow and expensive to run, but
a subset can be found in
[
linter-fast.json
](
linter-fast.json
)
that run quickly
enough to be run as part of an IDE.
For rare cases where a linter is giving a spurious warning, it can be disabled
for that line or statement using a
[
comment directive
](
https://github.com/alecthomas/gometalinter#comment-directives
)
, e.g.
`// nolint: gocyclo`
. This should be used sparingly and only when its clear
that the lint warning is spurious.
## HTTP Error Handling
Unfortunately, converting errors into HTTP responses with the correct status
code and message can be done in a number of ways in golang:
1.
Having functions return
`JSONResponse`
directly, which can then either set
it to an error response or a
`200 OK`
.
2.
Have the HTTP handler try and cast error values to types that are handled
differently.
3.
Have the HTTP handler call functions whose errors can only be interpreted
one way, for example if a
`validate(...)`
call returns an error then handler
knows to respond with a
`400 Bad Request`
.
We attempt to always use option #3, as it more naturally fits with the way that
golang generally does error handling. In particular, option #1 effectively
requires reinventing a new error handling scheme just for HTTP handlers.
## Line length
We strive for a line length of roughly 80 characters, though less than 100 is
acceptable if necessary. Longer lines are fine if there is nothing of interest
after the first 80-100 characters (e.g. long string literals).
## TODOs and FIXMEs
The majority of TODOs and FIXMEs should have an associated tracking issue on
github. These can be added just before merging of the PR to master, and the
issue number should be added to the comment, e.g.
`// TODO(#324): ...`
## Visual Studio Code
If you use VSCode then the following is an example of a workspace setting that
sets up linting correctly:
```
json
{
"go.gopath"
:
"${workspaceRoot}:${workspaceRoot}/vendor"
,
"go.lintOnSave"
:
"workspace"
,
"go.lintTool"
:
"gometalinter"
,
"go.lintFlags"
:
[
"--config=linter-fast.json"
,
"--concurrency=5"
]
}
```
CONTRIBUTING.md
浏览文件 @
1e6fc74d
...
...
@@ -3,6 +3,19 @@
Everyone is welcome to contribute to Dendrite! We aim to make it as easy as
possible to get started.
Please ensure that you sign off your contributions! See
[
Sign Off
](
#sign-off
)
section below.
## Getting up and running
See
[
INSTALL.md
](
INSTALL.md
)
for instructions on setting up a running dev
instance of dendrite, and
[
CODE_STYLE.md
](
CODE_STYLE.md
)
for the code style
guide.
We use
`gb`
for managing our dependencies, so
`gb build`
and
`gb test`
is how
to build dendrite and run the unit tests respectively.
## Picking Things To Do
If you're new then feel free to pick up an issue labelled
[
easy
](
https://github.com/matrix-org/dendrite/labels/easy
)
.
...
...
INSTALL.md
浏览文件 @
1e6fc74d
...
...
@@ -5,7 +5,7 @@ Dendrite can be run in one of two configurations:
*
A cluster of individual components, dealing with different aspects of the
Matrix protocol (see
[
WIRING.md
](
./WIRING.md
)
). Components communicate with
one another via
[
Apache Kafka
](
https://kafka.apache.org
)
.
*
A monolith server, in which all components run in the same process. In this
configuration, Kafka can be replaced with an in-process implementation
called
[
naffka
](
https://github.com/matrix-org/naffka
)
.
...
...
@@ -17,7 +17,7 @@ Dendrite can be run in one of two configurations:
-
For Kafka (optional if using the monolith server):
-
Unix-based system (https://kafka.apache.org/documentation/#os)
-
JDK 1.8+ / OpenJDK 1.8+
-
Apache Kafka 0.10.2+ (see
https://github.com/matrix-org/dendrite/blob/master/travis-install-kafka.sh
for up-to-date version numbers)
-
Apache Kafka 0.10.2+ (see
[
travis-install-kafka.sh
](
travis-install-kafka.sh
)
for up-to-date version numbers)
## Setting up a development environment
...
...
@@ -34,7 +34,7 @@ go get github.com/constabulary/gb/...
gb build
```
If using Kafka, install and start it:
If using Kafka, install and start it
(c.f.
[
travis-install-kafka.sh
](
travis-install-kafka.sh
)
)
:
```
bash
MIRROR
=
http://apache.mirror.anlx.net/kafka/0.10.2.0/kafka_2.11-0.10.2.0.tgz
...
...
@@ -108,7 +108,7 @@ The following contains scripts which will run all the required processes in orde
```
/media +---------------------------+
/media +---------------------------+
+----------->+------------->| dendrite-media-api-server |
^ ^ +---------------------------+
| | :7774
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录