Skip to content

Commit a7a3988

Browse files
committed
doc: add README for gomodcheck
1 parent 0b4cde2 commit a7a3988

File tree

16 files changed

+59
-2
lines changed

16 files changed

+59
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ If you are facing similar challenges, we welcome you to try **Reviewbot**!
2727
- go linters
2828
- [golangci-lint](/internal/linters/go/golangci_lint/)
2929
- [gofmt](/internal/linters/go/gofmt/)
30+
- [gomodcheck](/internal/linters/go/gomodcheck/)
3031
- c/c++ linters
3132
- [cppcheck](/internal/linters/c/cppcheck/)
3233
- lua linters

README_zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- go linters
2828
- [golangci-lint](/internal/linters/go/golangci_lint/)
2929
- [gofmt](/internal/linters/go/gofmt/)
30+
- [gomodcheck](/internal/linters/go/gomodcheck/)
3031
- c/c++ linters
3132
- [cppcheck](/internal/linters/c/cppcheck/)
3233
- lua linters

docs/website/docs/components/_category_.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"label": "Linters",
33
"position": 3,
4+
"collapsed": false,
45
"link": {
56
"type": "generated-index",
67
"description": "我们来了解 Reviewbot 目前已有的功能!"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: gomodcheck
3+
sidebar_position: 3
4+
---
5+
6+
`gomodcheck` 是一个专门用于检查 Go 项目中 `go.mod` 文件的 linter。它的主要目的是限制跨仓库的 local replace 使用,以确保项目依赖管理的一致性和可重现性。
7+
8+
比如:
9+
10+
```go
11+
replace github.com/qiniu/go-sdk/v7 => ../another_repo/src/github.com/qiniu/go-sdk/v7
12+
```
13+
14+
`../another_repo` 代表当前仓库的父目录下的 `another_repo` 目录. 这种用法非常的不推荐.
15+
16+
### 为什么要限制跨仓库的 local replace?
17+
18+
1. **可重现性**: 跨仓库的 local replace 使得构建过程依赖于本地文件系统结构,这可能导致不同环境下的构建结果不一致。
19+
20+
2. **依赖管理**: 它绕过了正常的依赖版本控制,可能引入未经版本控制的代码。
21+
22+
3. **协作困难**: 其他开发者或 CI/CD 系统可能无法访问本地替换的路径,导致构建失败。
23+
24+
4. **版本跟踪**: 使用 local replace 难以追踪依赖的具体版本,增加了项目维护的复杂性。
25+
26+
### 这种情况推荐怎么做?
27+
28+
尽可能使用正式发布的依赖版本, 即使是 private repo 也是一样的。
29+
30+
:::info
31+
32+
可以使用 go env -w GOPRIVATE 来设置私有仓库, 方便 go mod 下载依赖.
33+
34+
:::

docs/website/docusaurus.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ const config: Config = {
8383
theme: prismThemes.github,
8484
darkTheme: prismThemes.dracula,
8585
},
86+
docs: {
87+
sidebar: {
88+
hideable: true,
89+
autoCollapseCategories: true,
90+
},
91+
},
8692
} satisfies Preset.ThemeConfig,
8793
};
8894

docs/website/sidebars.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ import type { SidebarsConfig } from '@docusaurus/plugin-content-docs';
1212
*/
1313
const sidebars: SidebarsConfig = {
1414
// By default, Docusaurus generates a sidebar from the docs folder structure
15-
tutorialSidebar: [{ type: 'autogenerated', dirName: '.' }],
16-
15+
tutorialSidebar: [
16+
{
17+
type: 'autogenerated',
18+
dirName: '.',
19+
},
20+
],
1721
};
1822

1923
export default sidebars;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
see [note-check](../../../../docs/website/docs/components/doc/note-check.md)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
see [commit-check](../../../../docs/website/docs/components/git-flow/commit-check.md)

internal/linters/go/gofmt/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
see [gofmt](../../../../docs/website/docs/components/go/gofmt.md)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
see [golangci_lint](../../../../docs/website/docs/components/go/golangci_lint.md)

0 commit comments

Comments
 (0)