fix cos and minio etc to typecheck

pull/1799/head
Xinwei Xiong (cubxxw) 2 years ago
parent bb65e1bfac
commit 10a37da16a

@ -5,7 +5,7 @@ go 1.19
require ( require (
firebase.google.com/go v3.13.0+incompatible firebase.google.com/go v3.13.0+incompatible
github.com/OpenIMSDK/protocol v0.0.48 github.com/OpenIMSDK/protocol v0.0.48
github.com/OpenIMSDK/tools v0.0.23 github.com/OpenIMSDK/tools v0.0.28
github.com/bwmarrin/snowflake v0.3.0 // indirect github.com/bwmarrin/snowflake v0.3.0 // indirect
github.com/dtm-labs/rockscache v0.1.1 github.com/dtm-labs/rockscache v0.1.1
github.com/gin-gonic/gin v1.9.1 github.com/gin-gonic/gin v1.9.1

@ -20,8 +20,11 @@ github.com/AndrewZuo01/protocol v0.0.0-20240112093520-fd9c53e27b94/go.mod h1:F25
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/IBM/sarama v1.41.3 h1:MWBEJ12vHC8coMjdEXFq/6ftO6DUZnQlFYcxtOJFa7c= github.com/IBM/sarama v1.41.3 h1:MWBEJ12vHC8coMjdEXFq/6ftO6DUZnQlFYcxtOJFa7c=
github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ= github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ=
github.com/OpenIMSDK/protocol v0.0.48/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
github.com/OpenIMSDK/tools v0.0.23 h1:xozfrGzhbpNPlDTap5DLVPk+JfgZ/ZyIj4Cuu3/bm9w= github.com/OpenIMSDK/tools v0.0.23 h1:xozfrGzhbpNPlDTap5DLVPk+JfgZ/ZyIj4Cuu3/bm9w=
github.com/OpenIMSDK/tools v0.0.23/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI= github.com/OpenIMSDK/tools v0.0.23/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
github.com/OpenIMSDK/tools v0.0.28 h1:UT0rN1ysCFvsxQXyuxAj2TEkHt4C/sUezy+ChKpgt2Y=
github.com/OpenIMSDK/tools v0.0.28/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=

@ -36,9 +36,9 @@ import (
) )
const ( const (
minPartSize = 1024 * 1024 * 1 // 1MB minPartSize int64 = 1024 * 1024 * 1 // 1MB
maxPartSize = 1024 * 1024 * 1024 * 5 // 5GB maxPartSize int64 = 1024 * 1024 * 1024 * 5 // 5GB
maxNumSize = 1000 maxNumSize int64 = 1000
) )
const ( const (
@ -133,7 +133,7 @@ func (c *Cos) PartSize(ctx context.Context, size int64) (int64, error) {
return 0, errors.New("size must be greater than 0") return 0, errors.New("size must be greater than 0")
} }
if size > maxPartSize*maxNumSize { if size > maxPartSize*maxNumSize {
return 0, fmt.Errorf("size must be less than %db", maxPartSize*maxNumSize) return 0, fmt.Errorf("COS size must be less than the maximum allowed limit")
} }
if size <= minPartSize*maxNumSize { if size <= minPartSize*maxNumSize {
return minPartSize, nil return minPartSize, nil

@ -45,9 +45,9 @@ const (
) )
const ( const (
minPartSize = 1024 * 1024 * 5 // 1MB minPartSize int64 = 1024 * 1024 * 5 // 1MB
maxPartSize = 1024 * 1024 * 1024 * 5 // 5GB maxPartSize int64 = 1024 * 1024 * 1024 * 5 // 5GB
maxNumSize = 10000 maxNumSize int64 = 10000
) )
const ( const (
@ -240,7 +240,7 @@ func (m *Minio) PartSize(ctx context.Context, size int64) (int64, error) {
return 0, errors.New("size must be greater than 0") return 0, errors.New("size must be greater than 0")
} }
if size > maxPartSize*maxNumSize { if size > maxPartSize*maxNumSize {
return 0, fmt.Errorf("size must be less than %db", maxPartSize*maxNumSize) return 0, fmt.Errorf("MINIO size must be less than the maximum allowed limit")
} }
if size <= minPartSize*maxNumSize { if size <= minPartSize*maxNumSize {
return minPartSize, nil return minPartSize, nil

@ -37,9 +37,9 @@ import (
) )
const ( const (
minPartSize = 1024 * 1024 * 1 // 1MB minPartSize int64 = 1024 * 1024 * 1 // 1MB
maxPartSize = 1024 * 1024 * 1024 * 5 // 5GB maxPartSize int64 = 1024 * 1024 * 1024 * 5 // 5GB
maxNumSize = 10000 maxNumSize int64 = 10000
) )
const ( const (
@ -141,7 +141,7 @@ func (o *OSS) PartSize(ctx context.Context, size int64) (int64, error) {
return 0, errors.New("size must be greater than 0") return 0, errors.New("size must be greater than 0")
} }
if size > maxPartSize*maxNumSize { if size > maxPartSize*maxNumSize {
return 0, fmt.Errorf("size must be less than %db", maxPartSize*maxNumSize) return 0, fmt.Errorf("OSS size must be less than the maximum allowed limit")
} }
if size <= minPartSize*maxNumSize { if size <= minPartSize*maxNumSize {
return minPartSize, nil return minPartSize, nil

@ -24,7 +24,7 @@ import (
type PartLimit struct { type PartLimit struct {
MinPartSize int64 `json:"minPartSize"` MinPartSize int64 `json:"minPartSize"`
MaxPartSize int64 `json:"maxPartSize"` MaxPartSize int64 `json:"maxPartSize"`
MaxNumSize int `json:"maxNumSize"` MaxNumSize int64 `json:"maxNumSize"`
} }
type InitiateMultipartUploadResult struct { type InitiateMultipartUploadResult struct {

@ -1,27 +1,50 @@
# OpenIM Typecheck # OpenIM Typecheck: Cross-Platform Source Code Type Checking for Go
OpenIM Typecheck 为所有 Go 构建平台进行跨平台源代码类型检查。 ## Introduction
## 优点 OpenIM Typecheck is a robust tool designed for cross-platform source code type checking across all Go build platforms. This utility leverages Gos built-in parsing and type-check libraries (`go/parser` and `go/types`) to deliver efficient and reliable code analysis.
- **速度**OpenIM 完整编译大约需要 3 分钟,而使用 Typecheck 只需数秒。 ## Advantages
- **资源消耗**:与需要 >40GB 的 RAM 不同Typecheck 只需 <8GB RAM
## 实现 - **Speed**: A complete compilation with OpenIM can take approximately 3 minutes. In contrast, OpenIM Typecheck achieves this in mere seconds, significantly enhancing productivity.
- **Resource Efficiency**: Unlike the typical requirement of over 40GB of RAM for standard processes, Typecheck operates effectively with less than 8GB of RAM. This reduction in resource consumption makes it highly suitable for a variety of systems, reducing overheads and facilitating smoother operations.
OpenIM Typecheck 使用 Go 内置的解析和类型检查库 (`go/parser` 和 `go/types`)。然而,这些库并不是 go 编译器所使用的。偶尔会出现不匹配的情况,但总的来说,它们是相当接近的。 ## Implementation
## 错误处理 OpenIM Typecheck employs Go's native parsing and type-checking libraries (`go/parser` and `go/types`). However, it's important to note that these libraries aren't identical to those used by the Go compiler. While occasional mismatches may occur, these libraries generally provide close approximations to the compiler's functionality, offering a reliable basis for type checking.
如果错误不会阻止构建,可以忽略。 ## Error Handling
**`go/types` 报告的错误,但 `go build` 不会** Typecheck's approach to error handling is pragmatic, focusing on practicality and build continuity.
- **真正的错误**(根据规范):
- 应尽量修复。如果无法修复或正在进行中(例如,已被外部引用的代码),则可以忽略。
- 例如:闭包中的未使用变量
- **不真实的错误**
- 应忽略并在适当的情况下向上游报告。
- 例如staging 和 generated 类型之间的类型检查不匹配
**`go build` 报告的错误,但我们不会** **Errors reported by `go/types` but not by `go build`**:
- CGo 错误,包括语法和链接器错误。 - **Actual Errors** (as per the specification):
- These should ideally be rectified. If rectification is not feasible, such as in cases of ongoing work or external dependencies in the code, these errors can be overlooked.
- Example: Unused variables within a closure.
- **False Positives**:
- These errors should be ignored and, where appropriate, reported upstream for resolution.
- Example: Type mismatches between staging and generated types.
**Errors reported by `go build` but not by us**:
- CGo-related errors, including both syntax and linker issues, are outside our scope.
## Usage
### Locally
To run Typecheck locally, simply use the following command:
```bash
make verify
```
### Continuous Integration (CI)
In CI environments, Typecheck can be integrated into the workflow as follows:
```yaml
- name: Typecheck
run: make verify
```
This streamlined process facilitates efficient error detection and resolution, ensuring a robust and reliable build pipeline.

@ -62,17 +62,14 @@ var (
// inside of staging/, but works when typechecked as part of vendor/. // inside of staging/, but works when typechecked as part of vendor/.
"staging", "staging",
"components", "components",
"logs",
// OS-specific vendor code tends to be imported by OS-specific // OS-specific vendor code tends to be imported by OS-specific
// packages. We recursively typecheck imported vendored packages for // packages. We recursively typecheck imported vendored packages for
// each OS, but don't typecheck everything for every OS. // each OS, but don't typecheck everything for every OS.
"vendor", "vendor",
"test",
"_output", "_output",
"OpenIMSKD/tools", "*/mw/rpc_server_interceptor.go",
// This is a weird one. /testdata/ is *mostly* ignored by Go,
// and this translates to kubernetes/vendor not working.
// edit/record.go doesn't compile without gopkg.in/yaml.v2
// in $GOSRC/$GOROOT (both typecheck and the shell script).
"pkg/kubectl/cmd/testdata/edit",
// Tools we use for maintaining the code base but not necessarily // Tools we use for maintaining the code base but not necessarily
// ship as part of the release // ship as part of the release
"sopenim::golang::setup_env:tools/yamlfmt/yamlfmt.go:tools", "sopenim::golang::setup_env:tools/yamlfmt/yamlfmt.go:tools",

Loading…
Cancel
Save