mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 10:52:33 +08:00
feat: add openim offline deployment docs
Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>
This commit is contained in:
parent
df45847c7e
commit
f8710fee0d
@ -25,7 +25,7 @@ assets/
|
|||||||
|
|
||||||
## Copyright Notice:
|
## Copyright Notice:
|
||||||
|
|
||||||
The OpenIM logo, including its variations and animated versions, displayed in this repository [OpenIM](https://github.com/OpenIMSDK/openim) under the `/assets/logo` and `/assets/logo-gif` directories, are protected by copyright laws.
|
The OpenIM logo, including its variations and animated versions, displayed in this repository [OpenIM](https://github.com/openimsdk/open-im-server) under the `/assets/logo` and `/assets/logo-gif` directories, are protected by copyright laws.
|
||||||
|
|
||||||
The logo design is credited to @Xx(席欣).
|
The logo design is credited to @Xx(席欣).
|
||||||
|
|
||||||
|
|||||||
@ -126,7 +126,8 @@ services:
|
|||||||
|
|
||||||
# Uncomment and configure the following services as needed
|
# Uncomment and configure the following services as needed
|
||||||
# openim-admin:
|
# openim-admin:
|
||||||
# image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-admin-front:v3.4.0
|
# # https://github.com/openimsdk/open-im-server/issues/1662
|
||||||
|
# image: ${IMAGE_REGISTRY:-ghcr.io/openimsdk}/openim-admin:${ADMIN_FRONT_VERSION:-toc-base-open-docker.35}
|
||||||
# container_name: openim-admin
|
# container_name: openim-admin
|
||||||
# restart: always
|
# restart: always
|
||||||
# ports:
|
# ports:
|
||||||
@ -141,8 +142,8 @@ services:
|
|||||||
# hostname: prometheus
|
# hostname: prometheus
|
||||||
# restart: always
|
# restart: always
|
||||||
# volumes:
|
# volumes:
|
||||||
# - ./config/prometheus.yml:/etc/prometheus/prometheus.yml
|
# - "${DATA_DIR:-./}/config/instance-down-rules.yml:/etc/prometheus/instance-down-rules.yml"
|
||||||
# - ./config/instance-down-rules.yml:/etc/prometheus/instance-down-rules.yml
|
# - "${DATA_DIR:-./}/config/prometheus.yml:/etc/prometheus/prometheus.yml"
|
||||||
# ports:
|
# ports:
|
||||||
# - "${PROMETHEUS_PORT:-19090}:9090"
|
# - "${PROMETHEUS_PORT:-19090}:9090"
|
||||||
# networks:
|
# networks:
|
||||||
@ -155,8 +156,8 @@ services:
|
|||||||
# hostname: alertmanager
|
# hostname: alertmanager
|
||||||
# restart: always
|
# restart: always
|
||||||
# volumes:
|
# volumes:
|
||||||
# - ./config/alertmanager.yml:/etc/alertmanager/alertmanager.yml
|
# - ${DATA_DIR:-./}/config/alertmanager.yml:/etc/alertmanager/alertmanager.yml
|
||||||
# - ./config/email.tmpl:/etc/alertmanager/email.tmpl
|
# - ${DATA_DIR:-./}/config/email.tmpl:/etc/alertmanager/email.tmpl
|
||||||
# ports:
|
# ports:
|
||||||
# - "${ALERT_MANAGER_PORT:-19093}:9093"
|
# - "${ALERT_MANAGER_PORT:-19093}:9093"
|
||||||
# networks:
|
# networks:
|
||||||
@ -172,7 +173,7 @@ services:
|
|||||||
# ports:
|
# ports:
|
||||||
# - "${GRAFANA_PORT:-13000}:3000"
|
# - "${GRAFANA_PORT:-13000}:3000"
|
||||||
# volumes:
|
# volumes:
|
||||||
# - ${DATA_DIR:-./}/components/grafana:/var/lib/grafana
|
# - "${DATA_DIR:-./}/components/grafana:/var/lib/grafana"
|
||||||
# networks:
|
# networks:
|
||||||
# server:
|
# server:
|
||||||
# ipv4_address: ${GRAFANA_NETWORK_ADDRESS:-172.28.0.11}
|
# ipv4_address: ${GRAFANA_NETWORK_ADDRESS:-172.28.0.11}
|
||||||
|
|||||||
@ -108,7 +108,7 @@ export CHAT_IMAGE_VERSION="main"
|
|||||||
export SERVER_IMAGE_VERSION="main"
|
export SERVER_IMAGE_VERSION="main"
|
||||||
```
|
```
|
||||||
|
|
||||||
These variables are stored within the [`environment.sh`](https://github.com/OpenIMSDK/openim-docker/blob/main/scripts/install/environment.sh) configuration:
|
These variables are stored within the [`environment.sh`](https://github.com/OpenIMSDK/open-im-server/blob/main/scripts/install/environment.sh) configuration:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
readonly CHAT_IMAGE_VERSION=${CHAT_IMAGE_VERSION:-'main'}
|
readonly CHAT_IMAGE_VERSION=${CHAT_IMAGE_VERSION:-'main'}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ It is critical that our full community is actively engaged on enhancements in th
|
|||||||
|
|
||||||
- Be aware the cherry pick script assumes you have a git remote called `upstream` that points at the openim-server github org.
|
- Be aware the cherry pick script assumes you have a git remote called `upstream` that points at the openim-server github org.
|
||||||
|
|
||||||
Please see our [recommended Git workflow](https://github.com/openimsdk/open-im-server/blob/main/docs/contributors/github-workflow.md#workflow).
|
Please see our [recommended Git workflow](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/github-workflow.md#workflow).
|
||||||
|
|
||||||
- You will need to run the cherry pick script separately for each patch release you want to cherry pick to. Cherry picks should be applied to all [active](https://github.com/openimsdk/open-im-server/releases) release branches where the fix is applicable.
|
- You will need to run the cherry pick script separately for each patch release you want to cherry pick to. Cherry picks should be applied to all [active](https://github.com/openimsdk/open-im-server/releases) release branches where the fix is applicable.
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@ description: |
|
|||||||
commit hygiene.
|
commit hygiene.
|
||||||
---
|
---
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 1. Fork in the cloud
|
## 1. Fork in the cloud
|
||||||
|
|
||||||
@ -28,10 +27,10 @@ neither `$GOPATH/src/github.com/${your github profile name}/`
|
|||||||
nor any other pattern will work.
|
nor any other pattern will work.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
export working_dir="$(go env GOPATH)/src/k8s.io"
|
export working_dir="$(go env GOPATH)/src/github.com/openimsdk"
|
||||||
```
|
```
|
||||||
|
|
||||||
If you already do Go development on github, the `k8s.io` directory
|
If you already do Go development on github, the `github.com/openimsdk` directory
|
||||||
will be a sibling to your existing `github.com` directory.
|
will be a sibling to your existing `github.com` directory.
|
||||||
|
|
||||||
Set `user` to match your github profile name:
|
Set `user` to match your github profile name:
|
||||||
|
|||||||
@ -6,25 +6,57 @@
|
|||||||
|
|
||||||
Below are the base images and their versions you'll need:
|
Below are the base images and their versions you'll need:
|
||||||
|
|
||||||
- wurstmeister/kafka
|
- [ ] bitnami/kafka:3.5.1
|
||||||
- redis:7.0.0
|
- [ ] redis:7.0.0
|
||||||
- mongo:6.0.2
|
- [ ] mongo:6.0.2
|
||||||
- mysql:5.7
|
- [ ] bitnami/zookeeper:3.8
|
||||||
- wurstmeister/zookeeper
|
- [ ] minio/minio:latest
|
||||||
- minio/minio
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> It is important to note that OpenIM removed mysql components from versions v3.5.0 (release-v3.5) and above, so mysql can be deployed without this requirement or above
|
||||||
|
|
||||||
|
**If you need to install more IM components or monitoring products:**
|
||||||
|
|
||||||
|
OpenIM:
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> If you need to install more IM components or monitoring products [images.md](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/images.md)
|
||||||
|
|
||||||
|
- [ ] ghcr.io/openimsdk/openim-web:latest
|
||||||
|
- [ ] ghcr.io/openimsdk/openim-admin:latest
|
||||||
|
- [ ] ghcr.io/openimsdk/openim-chat:latest
|
||||||
|
- [ ] ghcr.io/openimsdk/openim-server:latest
|
||||||
|
|
||||||
|
|
||||||
|
Monitoring:
|
||||||
|
|
||||||
|
- [ ] prom/prometheus:v2.48.1
|
||||||
|
- [ ] prom/alertmanager:v0.23.0
|
||||||
|
- [ ] grafana/grafana:10.2.2
|
||||||
|
- [ ] bitnami/node-exporter:1.7.0
|
||||||
|
|
||||||
|
|
||||||
Use the following commands to pull these base images:
|
Use the following commands to pull these base images:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
docker pull wurstmeister/kafka
|
docker pull bitnami/kafka:3.5.1
|
||||||
docker pull redis:7.0.0
|
docker pull redis:7.0.0
|
||||||
docker pull mongo:6.0.2
|
docker pull mongo:6.0.2
|
||||||
docker pull mysql:5.7
|
docker pull mysql:5.7
|
||||||
docker pull wurstmeister/zookeeper
|
docker pull bitnami/zookeeper:3.8
|
||||||
docker pull minio/minio
|
docker pull minio/minio:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## 2. OpenIM & Chat Images
|
If you need to install more IM components or monitoring products:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull prom/prometheus:v2.48.1
|
||||||
|
docker pull prom/alertmanager:v0.23.0
|
||||||
|
docker pull grafana/grafana:10.2.2
|
||||||
|
docker pull bitnami/node-exporter:1.7.0
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. OpenIM Images
|
||||||
|
|
||||||
**For detailed understanding of version management and storage of OpenIM and Chat**: [version.md](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/version.md)
|
**For detailed understanding of version management and storage of OpenIM and Chat**: [version.md](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/version.md)
|
||||||
|
|
||||||
@ -42,9 +74,26 @@ docker pull ghcr.io/openimsdk/openim-server:<version-name>
|
|||||||
- Execute the following command to pull the image:
|
- Execute the following command to pull the image:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker pull ghcr.io/openimsdk/openim-server:<version-name>
|
docker pull ghcr.io/openimsdk/openim-chat:<version-name>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Web Image
|
||||||
|
|
||||||
|
- Execute the following command to pull the image:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull ghcr.io/openimsdk/openim-web:<version-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Admin Image
|
||||||
|
|
||||||
|
- Execute the following command to pull the image:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker pull ghcr.io/openimsdk/openim-admin:<version-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## 3. Image Storage Selection
|
## 3. Image Storage Selection
|
||||||
|
|
||||||
**Repositories**:
|
**Repositories**:
|
||||||
@ -71,46 +120,49 @@ You can select from the following versions:
|
|||||||
1. **Pull images**: Execute the above `docker pull` commands to pull all required images locally.
|
1. **Pull images**: Execute the above `docker pull` commands to pull all required images locally.
|
||||||
2. **Save images**:
|
2. **Save images**:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
docker save -o <tar-file-name>.tar <image-name>
|
docker save -o <tar-file-name>.tar <image-name>
|
||||||
```
|
```
|
||||||
|
|
||||||
1. **Fetch code**: Clone the repository:
|
1. **Fetch code**: Clone the repository:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
git clone https://github.com/OpenIMSDK/openim-docker.git
|
git clone https://github.com/openimsdk/openim-docker.git
|
||||||
```
|
```
|
||||||
|
|
||||||
Or download the code from [Releases](https://github.com/OpenIMSDK/openim-docker/releases/).
|
Or download the code from [Releases](https://github.com/openimsdk/openim-docker/releases/).
|
||||||
|
|
||||||
|
> Because of the difference between win and linux newlines, please do not clone the repository with win and then synchronize scp to linux.
|
||||||
|
|
||||||
1. **Transfer files**: Use `scp` to transfer all images and code to the intranet server.
|
1. **Transfer files**: Use `scp` to transfer all images and code to the intranet server.
|
||||||
|
|
||||||
```
|
```bash
|
||||||
scp <tar-file-name>.tar user@remote-ip:/path/on/remote/server
|
scp <tar-file-name>.tar user@remote-ip:/path/on/remote/server
|
||||||
```
|
```
|
||||||
|
|
||||||
Or choose other transfer methods such as a hard drive.
|
Or choose other transfer methods such as a hard drive.
|
||||||
|
|
||||||
1. **Import images**: On the intranet server:
|
2. **Import images**: On the intranet server:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
docker load -i <tar-file-name>.tar
|
docker load -i <tar-file-name>.tar
|
||||||
```
|
```
|
||||||
|
|
||||||
1. **Deploy**: Navigate to the `openim-docker` repository directory and follow the README guide for deployment.
|
3. **Deploy**: Navigate to the `openim-docker` repository directory and follow the [README guide](https://github.com/openimsdk/openim-docker) for deployment.
|
||||||
2. **Deploy using Docker-compose**:
|
|
||||||
|
|
||||||
```
|
4. **Deploy using docker compose**:
|
||||||
docker-compose up -d
|
|
||||||
|
```bash
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
# Verify
|
# Verify
|
||||||
docker-compose ps
|
docker compose ps
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Note**: If you're using a version of Docker prior to 20, make sure you've installed `docker-compose`.
|
> **Note**: If you're using a version of Docker prior to 20, make sure you've installed `docker-compose`.
|
||||||
|
|
||||||
## 6. Reference Links
|
## 6. Reference Links
|
||||||
|
|
||||||
- [OpenIMSDK Issue #432](https://github.com/openimsdk/open-im-server/issues/432)
|
- [openimsdk Issue #432](https://github.com/openimsdk/open-im-server/issues/432)
|
||||||
- [Notion Link](https://nsddd.notion.site/435ee747c0bc44048da9300a2d745ad3?pvs=25)
|
- [Notion Link](https://nsddd.notion.site/435ee747c0bc44048da9300a2d745ad3?pvs=25)
|
||||||
- [OpenIMSDK Issue #474](https://github.com/openimsdk/open-im-server/issues/474)
|
- [openimsdk Issue #474](https://github.com/openimsdk/open-im-server/issues/474)
|
||||||
@ -111,32 +111,35 @@ Importing Grafana Dashboards is a straightforward process and is applicable to O
|
|||||||
|
|
||||||
To monitor OpenIM in Grafana, you need to focus on three categories of key metrics, each with its specific deployment and configuration steps:
|
To monitor OpenIM in Grafana, you need to focus on three categories of key metrics, each with its specific deployment and configuration steps:
|
||||||
|
|
||||||
1. **OpenIM Metrics (`prometheus-dashboard.yaml`)**:
|
**OpenIM Metrics (`prometheus-dashboard.yaml`)**:
|
||||||
+ **Configuration File Path**: Located at `config/prometheus-dashboard.yaml`.
|
|
||||||
+ **Enabling Monitoring**: Set the environment variable `export PROMETHEUS_ENABLE=true` to enable Prometheus monitoring.
|
|
||||||
+ **More Information**: Refer to the [OpenIM Configuration Guide](https://docs.openim.io/configurations/prometheus-integration).
|
|
||||||
2. **Node Exporter**:
|
|
||||||
+ **Container Deployment**: Deploy the `quay.io/prometheus/node-exporter` container for node monitoring.
|
|
||||||
+ **Get Dashboard**: Access the [Node Exporter Full Feature Dashboard](https://grafana.com/grafana/dashboards/1860-node-exporter-full/) and import it using YAML file download or ID import.
|
|
||||||
+ **Deployment Guide**: Refer to the [Node Exporter Deployment Documentation](https://prometheus.io/docs/guides/node-exporter/).
|
|
||||||
3. **Middleware Metrics**: Each middleware requires specific steps and configurations to enable monitoring. Here is a list of common middleware and links to their respective setup guides:
|
|
||||||
+ MySQL:
|
|
||||||
+ **Configuration**: Ensure MySQL has performance monitoring enabled.
|
|
||||||
+ **Link**: Refer to the [MySQL Monitoring Configuration Guide](https://grafana.com/docs/grafana/latest/datasources/mysql/).
|
|
||||||
+ Redis:
|
|
||||||
+ **Configuration**: Configure Redis to allow monitoring data export.
|
|
||||||
+ **Link**: Refer to the [Redis Monitoring Guide](https://grafana.com/docs/grafana/latest/datasources/redis/).
|
|
||||||
+ MongoDB:
|
|
||||||
+ **Configuration**: Set up monitoring metrics for MongoDB.
|
|
||||||
+ **Link**: Refer to the [MongoDB Monitoring Guide](https://grafana.com/grafana/plugins/grafana-mongodb-datasource/).
|
|
||||||
+ Kafka:
|
|
||||||
+ **Configuration**: Integrate Kafka with Prometheus monitoring.
|
|
||||||
+ **Link**: Refer to the [Kafka Monitoring Guide](https://grafana.com/grafana/plugins/grafana-kafka-datasource/).
|
|
||||||
+ Zookeeper:
|
|
||||||
+ **Configuration**: Ensure Zookeeper can be monitored by Prometheus.
|
|
||||||
+ **Link**: Refer to the [Zookeeper Monitoring Configuration](https://grafana.com/docs/grafana/latest/datasources/zookeeper/).
|
|
||||||
|
|
||||||
|
- **Configuration File Path**: Find this at `config/prometheus-dashboard.yaml`.
|
||||||
|
- **Enabling Monitoring**: Activate Prometheus monitoring by setting the environment variable: `export PROMETHEUS_ENABLE=true`.
|
||||||
|
- **More Information**: For detailed instructions, see the [OpenIM Configuration Guide](https://docs.openim.io/configurations/prometheus-integration).
|
||||||
|
|
||||||
|
**Node Exporter**:
|
||||||
|
|
||||||
|
- **Container Deployment**: Use the container `quay.io/prometheus/node-exporter` for effective node monitoring.
|
||||||
|
- **Access Dashboard**: Visit the [Node Exporter Full Feature Dashboard](https://grafana.com/grafana/dashboards/1860-node-exporter-full/) for dashboard integration either through YAML file download or ID.
|
||||||
|
- **Deployment Guide**: For deployment steps, consult the [Node Exporter Deployment Documentation](https://prometheus.io/docs/guides/node-exporter/).
|
||||||
|
|
||||||
|
**Middleware Metrics**: Different middlewares require unique steps and configurations for monitoring:
|
||||||
|
|
||||||
|
- MySQL:
|
||||||
|
- **Configuration**: Make sure MySQL is set up for performance monitoring.
|
||||||
|
- **Guide**: See the [MySQL Monitoring Configuration Guide](https://grafana.com/docs/grafana/latest/datasources/mysql/).
|
||||||
|
- Redis:
|
||||||
|
- **Configuration**: Adjust Redis settings to enable monitoring data export.
|
||||||
|
- **Guide**: Consult the [Redis Monitoring Guide](https://grafana.com/docs/grafana/latest/datasources/redis/).
|
||||||
|
- MongoDB:
|
||||||
|
- **Configuration**: Configure MongoDB for monitoring metrics.
|
||||||
|
- **Guide**: Visit the [MongoDB Monitoring Guide](https://grafana.com/grafana/plugins/grafana-mongodb-datasource/).
|
||||||
|
- Kafka:
|
||||||
|
- **Configuration**: Set up Kafka for Prometheus monitoring integration.
|
||||||
|
- **Guide**: Refer to the [Kafka Monitoring Guide](https://grafana.com/grafana/plugins/grafana-kafka-datasource/).
|
||||||
|
- Zookeeper:
|
||||||
|
- **Configuration**: Ensure Prometheus can monitor Zookeeper.
|
||||||
|
- **Guide**: Check out the [Zookeeper Monitoring Configuration](https://grafana.com/docs/grafana/latest/datasources/zookeeper/).
|
||||||
|
|
||||||
**Importing Steps**:
|
**Importing Steps**:
|
||||||
|
|
||||||
|
|||||||
102
tools/formitychecker/README.md
Normal file
102
tools/formitychecker/README.md
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
# 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.
|
||||||
Loading…
x
Reference in New Issue
Block a user