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

doc: add README for gomodcheck #374

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ If you are facing similar challenges, we welcome you to try **Reviewbot**!
- go linters
- [golangci-lint](/internal/linters/go/golangci_lint/)
- [gofmt](/internal/linters/go/gofmt/)
- [gomodcheck](/internal/linters/go/gomodcheck/)
- c/c++ linters
- [cppcheck](/internal/linters/c/cppcheck/)
- lua linters
Expand Down
1 change: 1 addition & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- go linters
- [golangci-lint](/internal/linters/go/golangci_lint/)
- [gofmt](/internal/linters/go/gofmt/)
- [gomodcheck](/internal/linters/go/gomodcheck/)
- c/c++ linters
- [cppcheck](/internal/linters/c/cppcheck/)
- lua linters
Expand Down
1 change: 1 addition & 0 deletions docs/website/docs/components/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"label": "Linters",
"position": 3,
"collapsed": false,
"link": {
"type": "generated-index",
"description": "我们来了解 Reviewbot 目前已有的功能!"
Expand Down
34 changes: 34 additions & 0 deletions docs/website/docs/components/go/gomodcheck.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: gomodcheck
sidebar_position: 3
---

`gomodcheck` 是一个专门用于检查 Go 项目中 `go.mod` 文件的 linter。它的主要目的是限制跨仓库的 local replace 使用,以确保项目依赖管理的一致性和可重现性。

比如:

```go
replace github.com/qiniu/go-sdk/v7 => ../another_repo/src/github.com/qiniu/go-sdk/v7
```

`../another_repo` 代表当前仓库的父目录下的 `another_repo` 目录. 这种用法非常的不推荐.

### 为什么要限制跨仓库的 local replace?

1. **可重现性**: 跨仓库的 local replace 使得构建过程依赖于本地文件系统结构,这可能导致不同环境下的构建结果不一致。

2. **依赖管理**: 它绕过了正常的依赖版本控制,可能引入未经版本控制的代码。

3. **协作困难**: 其他开发者或 CI/CD 系统可能无法访问本地替换的路径,导致构建失败。

4. **版本跟踪**: 使用 local replace 难以追踪依赖的具体版本,增加了项目维护的复杂性。

### 这种情况推荐怎么做?

尽可能使用正式发布的依赖版本, 即使是 private repo 也是一样的。

:::info

可以使用 go env -w GOPRIVATE 来设置私有仓库, 方便 go mod 下载依赖.

:::
6 changes: 6 additions & 0 deletions docs/website/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ const config: Config = {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
},
docs: {
sidebar: {
hideable: true,
autoCollapseCategories: true,
},
},
} satisfies Preset.ThemeConfig,
};

Expand Down
8 changes: 6 additions & 2 deletions docs/website/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ import type { SidebarsConfig } from '@docusaurus/plugin-content-docs';
*/
const sidebars: SidebarsConfig = {
// By default, Docusaurus generates a sidebar from the docs folder structure
tutorialSidebar: [{ type: 'autogenerated', dirName: '.' }],

tutorialSidebar: [
{
type: 'autogenerated',
dirName: '.',
},
],
};

export default sidebars;
1 change: 1 addition & 0 deletions internal/linters/doc/note-check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see [note-check](../../../../docs/website/docs/components/doc/note-check.md)
1 change: 1 addition & 0 deletions internal/linters/git-flow/commit-check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see [commit-check](../../../../docs/website/docs/components/git-flow/commit-check.md)
1 change: 1 addition & 0 deletions internal/linters/go/gofmt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see [gofmt](../../../../docs/website/docs/components/go/gofmt.md)
1 change: 1 addition & 0 deletions internal/linters/go/golangci_lint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see [golangci_lint](../../../../docs/website/docs/components/go/golangci_lint.md)
1 change: 1 addition & 0 deletions internal/linters/go/gomodcheck/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see [gomodcheck](../../../../docs/website/docs/components/go/gomodcheck.md)
1 change: 1 addition & 0 deletions internal/linters/go/staticcheck/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see [staticcheck](../../../../docs/website/docs/components/go/staticcheck.md)
1 change: 1 addition & 0 deletions internal/linters/java/pmdcheck/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see [pmdcheck](../../../../docs/website/docs/components/java/pmdcheck.md)
1 change: 1 addition & 0 deletions internal/linters/java/stylecheck/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see [stylecheck](../../../../docs/website/docs/components/java/stylecheck.md)
1 change: 1 addition & 0 deletions internal/linters/lua/luacheck/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see [luacheck](../../../../docs/website/docs/components/lua/luacheck.md)
1 change: 1 addition & 0 deletions internal/linters/shell/shellcheck/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
see [shellcheck](../../../../docs/website/docs/components/shell/shellcheck.md)
Loading