feat: Enhancements to OpenIM Engineering Practices with Standardizer and Tool Versioning (#2159)
* feat: add standardizer optimize makefile * feat: add standardizer optimize makefile * feat: add openim test docs * feat: add openim kafka docs * feat: add openim kafka docs * feat: add openim kafka docspull/2149/head
parent
48df76fb8b
commit
4f40022105
@ -0,0 +1,50 @@
|
||||
# https://github.com/marketplace/actions/conformity-checker-for-project
|
||||
baseConfig:
|
||||
searchDirectory: "./"
|
||||
ignoreCase: false
|
||||
|
||||
directoryNaming:
|
||||
allowHyphens: true
|
||||
allowUnderscores: false
|
||||
mustBeLowercase: true
|
||||
|
||||
fileNaming:
|
||||
allowHyphens: true
|
||||
allowUnderscores: true
|
||||
mustBeLowercase: true
|
||||
|
||||
ignoreFormats:
|
||||
- "\\.log$"
|
||||
- "\\.env$"
|
||||
- "README\\.md$"
|
||||
- "_test\\.go$"
|
||||
- "\\.md$"
|
||||
- _test\\.txt$
|
||||
- LICENSE
|
||||
- Dockerfile
|
||||
- CODEOWNERS
|
||||
- Makefile
|
||||
|
||||
ignoreDirectories:
|
||||
- "vendor"
|
||||
- ".git"
|
||||
- "deployments"
|
||||
- "node_modules"
|
||||
- "logs"
|
||||
- "CHANGELOG"
|
||||
- "components"
|
||||
- "_output"
|
||||
- "tools/openim-web"
|
||||
- "CHANGELOG"
|
||||
- "examples/Test_directory"
|
||||
- test/testdata
|
||||
|
||||
fileTypeSpecificNaming:
|
||||
".yaml":
|
||||
allowHyphens: true
|
||||
allowUnderscores: false
|
||||
mustBeLowercase: true
|
||||
".go":
|
||||
allowHyphens: false
|
||||
allowUnderscores: true
|
||||
mustBeLowercase: true
|
@ -0,0 +1,162 @@
|
||||
# OpenIM Kafka Guide
|
||||
|
||||
This document aims to provide a set of concise guidelines to help you quickly install and use Kafka through Docker Compose.
|
||||
|
||||
## Installing Kafka
|
||||
|
||||
With the Docker Compose script provided by OpenIM, you can easily install Kafka. Use the following command to start Kafka:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
After executing this command, Kafka will be installed and started. You can confirm the Kafka container is running with the following command:
|
||||
|
||||
```bash
|
||||
docker ps | grep kafka
|
||||
```
|
||||
|
||||
The output of this command, as shown below, displays the status information of the Kafka container:
|
||||
|
||||
```
|
||||
be416b5a0851 bitnami/kafka:3.5.1 "/opt/bitnami/script…" 3 days ago Up 2 days 9092/tcp, 0.0.0.0:19094->9094/tcp, :::19094->9094/tcp kafka
|
||||
```
|
||||
|
||||
### References
|
||||
|
||||
- Official Docker installation documentation: [Click here](http://events.jianshu.io/p/b60afa35303a)
|
||||
- Detailed installation guide: [Tutorial on Towards Data Science](https://towardsdatascience.com/how-to-install-apache-kafka-using-docker-the-easy-way-4ceb00817d8b)
|
||||
|
||||
## Using Kafka
|
||||
|
||||
### Entering the Kafka Container
|
||||
|
||||
To execute Kafka commands, you first need to enter the Kafka container. Use the following command:
|
||||
|
||||
```bash
|
||||
docker exec -it kafka bash
|
||||
```
|
||||
|
||||
### Kafka Command Tools
|
||||
|
||||
Inside the Kafka container, you can use various command-line tools to manage Kafka. These tools include but are not limited to:
|
||||
|
||||
- `kafka-topics.sh`: For creating, deleting, listing, or altering topics.
|
||||
- `kafka-console-producer.sh`: Allows sending messages to a specified topic from the command line.
|
||||
- `kafka-console-consumer.sh`: Allows reading messages from the command line, with the ability to specify topics.
|
||||
- `kafka-consumer-groups.sh`: For managing consumer group information.
|
||||
|
||||
### Kafka Client Tool Installation
|
||||
|
||||
For easier Kafka management, you can install Kafka client tools. If you installed Kafka through OpenIM's Docker Compose, you can install the Kafka client tools with the following command:
|
||||
|
||||
```bash
|
||||
make install.kafkactl
|
||||
```
|
||||
|
||||
### Automatic Topic Creation
|
||||
|
||||
When installing Kafka through OpenIM's Docker Compose method, OpenIM automatically creates the following topics:
|
||||
|
||||
- `latestMsgToRedis`
|
||||
- `msgToPush`
|
||||
- `offlineMsgToMongoMysql`
|
||||
|
||||
These topics are created using the `scripts/create-topic.sh` script. The script waits for Kafka to be ready before executing the commands to create topics:
|
||||
|
||||
```bash
|
||||
# Wait for Kafka to be ready
|
||||
until /opt/bitnami/kafka/bin/kafka-topics.sh --list --bootstrap-server localhost:9092; do
|
||||
echo "Waiting for Kafka to be ready..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Create topics
|
||||
/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic latestMsgToRedis
|
||||
/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic msgToPush
|
||||
/opt/bitnami/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 8 --topic offlineMsgToMongoMysql
|
||||
|
||||
echo "Topics created."
|
||||
```
|
||||
|
||||
The optimized and expanded documentation further details some basic commands for operations inside the Kafka container, as well as basic commands for managing Kafka using `kafkactl`. Here is a more detailed guide.
|
||||
|
||||
|
||||
## Basic Commands in the Kafka Container
|
||||
|
||||
### Listing Topics
|
||||
|
||||
To list all existing topics, you can use the following command:
|
||||
|
||||
```bash
|
||||
kafka-topics.sh --list --bootstrap-server localhost:9092
|
||||
```
|
||||
|
||||
### Creating a New Topic
|
||||
|
||||
When creating a new topic, you can specify the number of partitions and the replication factor. Here is the command to create a new topic:
|
||||
|
||||
```bash
|
||||
kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic your_topic_name
|
||||
```
|
||||
|
||||
### Producing Messages
|
||||
|
||||
To send messages to a specific topic, you can use the producer command. The following command prompts you to enter messages, which are sent to the specified topic with each press of the Enter key:
|
||||
|
||||
```bash
|
||||
kafka-console-producer.sh --broker-list localhost:9092 --topic your_topic_name
|
||||
```
|
||||
|
||||
### Consuming Messages
|
||||
|
||||
To read messages from a specific topic, you can use the consumer command. The following command reads new messages from the specified topic and outputs them on the console:
|
||||
|
||||
```bash
|
||||
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic your_topic_name --from-beginning
|
||||
```
|
||||
|
||||
The `
|
||||
|
||||
--from-beginning` parameter reads messages from the beginning of the topic. If this parameter is omitted, only new messages will be read.
|
||||
|
||||
|
||||
## Basic Commands Using `kafkactl`
|
||||
|
||||
`kafkactl` is a command-line tool for managing and operating Kafka clusters. It offers a more modern way to interact with Kafka.
|
||||
|
||||
### Listing Topics
|
||||
|
||||
To list all topics, you can use:
|
||||
|
||||
```bash
|
||||
kafkactl get topics
|
||||
```
|
||||
|
||||
### Creating a New Topic
|
||||
|
||||
To create a new topic with `kafkactl`, use:
|
||||
|
||||
```bash
|
||||
kafkactl create topic your_topic_name --partitions 1 --replication-factor 1
|
||||
```
|
||||
|
||||
### Producing Messages
|
||||
|
||||
To send messages to a topic, you can use:
|
||||
|
||||
```bash
|
||||
kafkactl produce your_topic_name --value "your message"
|
||||
```
|
||||
|
||||
Here, `"your message"` is the content of the message you want to send.
|
||||
|
||||
### Consuming Messages
|
||||
|
||||
To consume messages from a topic, use:
|
||||
|
||||
```bash
|
||||
kafkactl consume your_topic_name --from-beginning
|
||||
```
|
||||
|
||||
Again, the `--from-beginning` parameter will start consuming messages from the beginning of the topic. If you do not wish to start from the beginning, you can omit this parameter.
|
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 207 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
@ -0,0 +1,58 @@
|
||||
# Copyright © 2023 OpenIMSDK.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
# OpenIM Makefile Versions used
|
||||
#
|
||||
# Define the latest version for each tool to ensure consistent versioning across installations
|
||||
GOLANGCI_LINT_VERSION ?= latest
|
||||
GOIMPORTS_VERSION ?= latest
|
||||
ADDLICENSE_VERSION ?= latest
|
||||
DEEPCOPY_GEN_VERSION ?= latest
|
||||
CONVERSION_GEN_VERSION ?= latest
|
||||
GINKGO_VERSION ?= v1.16.2
|
||||
GO_GITLINT_VERSION ?= latest
|
||||
GO_JUNIT_REPORT_VERSION ?= latest
|
||||
GOTESTS_VERSION ?= latest
|
||||
SWAGGER_VERSION ?= latest
|
||||
KUBE_SCORE_VERSION ?= latest
|
||||
KUBECONFORM_VERSION ?= latest
|
||||
GSEMVER_VERSION ?= latest
|
||||
GIT_CHGLOG_VERSION ?= latest
|
||||
KO_VERSION ?= latest
|
||||
GITHUB_RELEASE_VERSION ?= latest
|
||||
COSCLI_VERSION ?= v0.19.0-beta
|
||||
MINIO_VERSION ?= latest
|
||||
DELVE_VERSION ?= latest
|
||||
AIR_VERSION ?= latest
|
||||
GOLINES_VERSION ?= latest
|
||||
GO_MOD_OUTDATED_VERSION ?= latest
|
||||
CFSSL_VERSION ?= latest
|
||||
DEPTH_VERSION ?= latest
|
||||
GO_CALLVIS_VERSION ?= latest
|
||||
MISSPELL_VERSION ?= latest
|
||||
GOTHANKS_VERSION ?= latest
|
||||
RICHGO_VERSION ?= latest
|
||||
RTS_VERSION ?= latest
|
||||
TYPECHECK_VERSION ?= latest
|
||||
COMMENT_LANG_DETECTOR_VERSION ?= latest
|
||||
STANDARDIZER_VERSION ?= latest
|
||||
GO_TESTS_VERSION ?= v1.6.0
|
||||
GO_APIDIFF_VERSION ?= v0.8.2
|
||||
KAFKACTL_VERSION ?= latest
|
||||
GOTESTSUM_VERSION ?= latest
|
||||
|
||||
WIRE_VERSION ?= latest
|
||||
# WIRE_VERSION ?= $(call get_go_version,github.com/google/wire)
|
||||
MOCKGEN_VERSION ?= $(call get_go_version,github.com/golang/mock)
|
||||
PROTOC_GEN_GO_VERSION ?= $(call get_go_version,github.com/golang/protobuf/protoc-gen-go)
|
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright © 2023 OpenIM. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This script does a fast type check of script srnetes code for all platforms.
|
||||
# Usage: `scripts/verify-standardizer.sh`.
|
||||
|
||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${OPENIM_ROOT}/scripts/lib/init.sh"
|
||||
|
||||
openim::golang::verify_go_version
|
||||
|
||||
cd "${OPENIM_ROOT}"
|
||||
ret=0
|
||||
scripts/run-in-gopath.sh \
|
||||
make tools.verify.standardizer
|
||||
${OPENIM_ROOT}/_output/tools/standardizer || ret=$?
|
||||
if [[ $ret -ne 0 ]]; then
|
||||
openim::log::error "Failed to check the directory name or file name. Your name may not meet the specification. Please check the configuration file and the directory or file name." >&2
|
||||
openim::log::error "Please see https://github.com/kubecub/standardizer for more information." >&2
|
||||
exit 1
|
||||
fi
|
@ -1,102 +0,0 @@
|
||||
# Development of a Go-Based Conformity Checker for Project File and Directory Naming Standards
|
||||
|
||||
### 1. Project Overview
|
||||
|
||||
#### Project Name
|
||||
|
||||
- `GoConformityChecker`
|
||||
|
||||
#### Functionality Description
|
||||
|
||||
- Checks if the file and subdirectory names in a specified directory adhere to specific naming conventions.
|
||||
- Supports specific file types (e.g., `.go`, `.yml`, `.yaml`, `.md`, `.sh`, etc.).
|
||||
- Allows users to specify directories to be checked and directories to be ignored.
|
||||
- More read https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/code-conventions.md
|
||||
|
||||
#### Naming Conventions
|
||||
|
||||
- Go files: Only underscores are allowed.
|
||||
- YAML, YML, and Markdown files: Only hyphens are allowed.
|
||||
- Directories: Only underscores are allowed.
|
||||
|
||||
### 2. File Structure
|
||||
|
||||
- `main.go`: Entry point of the program, handles command-line arguments.
|
||||
- `checker/checker.go`: Contains the core logic.
|
||||
- `config/config.go`: Parses and stores configuration information.
|
||||
|
||||
### 3. Core Code Design
|
||||
|
||||
#### main.go
|
||||
|
||||
- Parses command-line arguments, including the directory to be checked and directories to be ignored.
|
||||
- Calls the `checker` module for checking.
|
||||
|
||||
#### config.go
|
||||
|
||||
- Defines a configuration structure, such as directories to check and ignore.
|
||||
|
||||
#### checker.go
|
||||
|
||||
- Iterates through the specified directory.
|
||||
- Applies different naming rules based on file types and directory names.
|
||||
- Records files or directories that do not conform to the standards.
|
||||
|
||||
### 4. Pseudocode Example
|
||||
|
||||
#### main.go
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"GoConformityChecker/checker"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Parse command-line arguments
|
||||
var targetDir string
|
||||
var ignoreDirs string
|
||||
flag.StringVar(&targetDir, "target", ".", "Directory to check")
|
||||
flag.StringVar(&ignoreDirs, "ignore", "", "Directories to ignore")
|
||||
flag.Parse()
|
||||
|
||||
// Call the checker
|
||||
err := checker.CheckDirectory(targetDir, ignoreDirs)
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### checker.go
|
||||
|
||||
```go
|
||||
package checker
|
||||
|
||||
import (
|
||||
// Import necessary packages
|
||||
)
|
||||
|
||||
func CheckDirectory(targetDir, ignoreDirs string) error {
|
||||
// Iterate through the directory, applying rules to check file and directory names
|
||||
// Return any found errors or non-conformities
|
||||
return nil
|
||||
}
|
||||
```
|
||||
|
||||
### 5. Implementation Details
|
||||
|
||||
- **File and Directory Traversal**: Use Go's `path/filepath` package to traverse directories and subdirectories.
|
||||
- **Naming Rules Checking**: Apply different regex expressions for naming checks based on file extensions.
|
||||
- **Error Handling and Reporting**: Record files or directories that do not conform and report to the user.
|
||||
|
||||
### 6. Future Development and Extensions
|
||||
|
||||
- Support more file types and naming rules.
|
||||
- Provide more detailed error reports, such as showing line numbers and specific naming mistakes.
|
||||
- Add a graphical or web interface for non-command-line users.
|
||||
|
||||
The above is an overview of the entire project's design. Following this design, specific coding implementation can begin. Note that the actual implementation may need adjustments based on real-world conditions.
|
@ -1,113 +0,0 @@
|
||||
// Copyright © 2024 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package checker
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
|
||||
"github.com/openimsdk/open-im-server/tools/formitychecker/config"
|
||||
)
|
||||
|
||||
var (
|
||||
underscoreRegex = regexp.MustCompile(`^[a-zA-Z0-9_]+\.[a-zA-Z0-9]+$`)
|
||||
hyphenRegex = regexp.MustCompile(`^[a-zA-Z0-9\-]+\.[a-zA-Z0-9]+$`)
|
||||
)
|
||||
|
||||
// CheckDirectory initiates the checking process for the specified directories using configuration from config.Config.
|
||||
func CheckDirectory(cfg *config.Config) error {
|
||||
ignoreMap := make(map[string]struct{})
|
||||
for _, dir := range cfg.IgnoreDirs {
|
||||
ignoreMap[dir] = struct{}{}
|
||||
}
|
||||
|
||||
for _, targetDir := range cfg.TargetDirs {
|
||||
err := filepath.Walk(targetDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return errs.Wrap(err, fmt.Sprintf("error walking directory '%s'", targetDir))
|
||||
}
|
||||
|
||||
// Skip if the directory is in the ignore list
|
||||
dirName := filepath.Base(filepath.Dir(path))
|
||||
if _, ok := ignoreMap[dirName]; ok && info.IsDir() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
|
||||
// Check the naming convention
|
||||
if err := checkNamingConvention(path, info); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("error checking directory '%s': %w", targetDir, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// checkNamingConvention checks if the file or directory name conforms to the standard naming conventions.
|
||||
func checkNamingConvention(path string, info os.FileInfo) error {
|
||||
fileName := info.Name()
|
||||
|
||||
// Handle special cases for directories like .git
|
||||
if info.IsDir() && strings.HasPrefix(fileName, ".") {
|
||||
return nil // Skip special directories
|
||||
}
|
||||
|
||||
// Extract the main part of the name (without extension for files)
|
||||
mainName := fileName
|
||||
if !info.IsDir() {
|
||||
mainName = strings.TrimSuffix(fileName, filepath.Ext(fileName))
|
||||
}
|
||||
|
||||
// Determine the type of file and apply corresponding naming rule
|
||||
switch {
|
||||
case info.IsDir():
|
||||
if !isValidName(mainName, "_") { // Directory names must only contain underscores
|
||||
return fmt.Errorf("!!! invalid directory name: %s", path)
|
||||
}
|
||||
case strings.HasSuffix(fileName, ".go"):
|
||||
if !isValidName(mainName, "_") { // Go files must only contain underscores
|
||||
return fmt.Errorf("!!! invalid Go file name: %s", path)
|
||||
}
|
||||
case strings.HasSuffix(fileName, ".yml"), strings.HasSuffix(fileName, ".yaml"), strings.HasSuffix(fileName, ".md"):
|
||||
if !isValidName(mainName, "-") { // YML, YAML, and Markdown files must only contain hyphens
|
||||
return fmt.Errorf("!!! invalid file name: %s", path)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// isValidName checks if the file name conforms to the specified rule (underscore or hyphen).
|
||||
func isValidName(name, charType string) bool {
|
||||
switch charType {
|
||||
case "_":
|
||||
return underscoreRegex.MatchString(name)
|
||||
case "-":
|
||||
return hyphenRegex.MatchString(name)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
// Copyright © 2024 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Config holds all the configuration parameters for the checker.
|
||||
type Config struct {
|
||||
TargetDirs []string // Directories to check
|
||||
IgnoreDirs []string // Directories to ignore
|
||||
}
|
||||
|
||||
// NewConfig creates and returns a new Config instance.
|
||||
func NewConfig(targetDirs, ignoreDirs string) *Config {
|
||||
return &Config{
|
||||
TargetDirs: parseDirs(targetDirs),
|
||||
IgnoreDirs: parseDirs(ignoreDirs),
|
||||
}
|
||||
}
|
||||
|
||||
// parseDirs splits a comma-separated string into a slice of directory names.
|
||||
func parseDirs(dirs string) []string {
|
||||
if dirs == "" {
|
||||
return nil
|
||||
}
|
||||
return strings.Split(dirs, ",")
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
// Copyright © 2024 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/openimsdk/open-im-server/tools/formitychecker/checker"
|
||||
"github.com/openimsdk/open-im-server/tools/formitychecker/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultTargetDirs := "."
|
||||
defaultIgnoreDirs := "components,.git"
|
||||
|
||||
var targetDirs string
|
||||
var ignoreDirs string
|
||||
flag.StringVar(&targetDirs, "target", defaultTargetDirs, "Directories to check (default: current directory)")
|
||||
flag.StringVar(&ignoreDirs, "ignore", defaultIgnoreDirs, "Directories to ignore (default: A/, B/)")
|
||||
flag.Parse()
|
||||
|
||||
conf := config.NewConfig(targetDirs, ignoreDirs)
|
||||
|
||||
err := checker.CheckDirectory(conf)
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
module github.com/openimsdk/open-im-server/tools/formitychecker
|
||||
|
||||
go 1.19
|
Loading…
Reference in new issue