feat: Integrate Comprehensive E2E Testing for GoChat (#1906)

* feat: create e2e test readme

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* feat: fix markdown file

* feat: add openim make lint

* feat: add git chglog pull request

* feat: add git chglog pull request

* fix: fix openim api err code

* fix: fix openim api err code

* fix: fix openim api err code

* feat: Improve CICD

* feat: Combining GitHub and Google Workspace for Effective Project Management'

* feat: fix openim tools error code

* feat: fix openim tools error code

* feat: add openim error handle

* feat: add openim error handle

* feat: optimize tim white prom code return err

* feat: fix openim tools error code

* style: format openim server code style

* feat: add openim optimize commit code

* feat: add openim optimize commit code

* feat: add openim auto format code

* feat: add openim auto format code

* feat: add openim auto format code

* feat: add openim auto format code

* feat: add openim auto format code

* feat: format openim code

* feat: Some of the notes were translated

* feat: Some of the notes were translated

* feat: update openim server code

* feat: optimize openim reset code

* feat: optimize openim reset code

---------

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>
This commit is contained in:
Xinwei Xiong
2024-03-04 12:12:14 +08:00
committed by GitHub
parent 1ef26b29a7
commit 853ac47e42
131 changed files with 1133 additions and 881 deletions
@@ -28,20 +28,20 @@ import (
func main() {
var (
usernameV2 = "root" // v2版本mysql用户名
passwordV2 = "openIM" // v2版本mysql密码
addrV2 = "127.0.0.1:13306" // v2版本mysql地址
databaseV2 = "admin_chat" // v2版本mysql数据库名字
usernameV2 = "root" // Username for MySQL v2 version
passwordV2 = "openIM" // Password for MySQL v2 version
addrV2 = "127.0.0.1:13306" // Address for MySQL v2 version
databaseV2 = "admin_chat" // Database name for MySQL v2 version
)
var (
usernameV3 = "root" // v3版本mysql用户名
passwordV3 = "openIM123" // v3版本mysql密码
addrV3 = "127.0.0.1:13306" // v3版本mysql地址
databaseV3 = "openim_enterprise" // v3版本mysql数据库名字
usernameV3 = "root" // Username for MySQL v3 version
passwordV3 = "openIM123" // Password for MySQL v3 version
addrV3 = "127.0.0.1:13306" // Address for MySQL v3 version
databaseV3 = "openim_enterprise" // Database name for MySQL v3 version
)
var concurrency = 1 // 并发数量
var concurrency = 1 // Concurrency quantity
log.SetFlags(log.LstdFlags | log.Llongfile)
dsnV2 := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", usernameV2, passwordV2, addrV2, databaseV2)
+5 -5
View File
@@ -18,7 +18,7 @@ import (
"time"
)
// AppVersion pc端版本管理
// AppVersion manages PC client versions
type AppVersion struct {
Version string `gorm:"column:version;size:64" json:"version"`
Type int `gorm:"column:type;primary_key" json:"type"`
@@ -29,7 +29,7 @@ type AppVersion struct {
UpdateLog string `gorm:"column:update_log" json:"update_log"`
}
// Admin 后台管理员
// Admin manages backend administrators
type Admin struct {
Account string `gorm:"column:account;primary_key;type:char(64)" json:"account"`
Password string `gorm:"column:Password;type:char(64)" json:"password"`
@@ -40,19 +40,19 @@ type Admin struct {
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
}
// RegisterAddFriend 注册时默认好友
// RegisterAddFriend specifies default friends when registering
type RegisterAddFriend struct {
UserID string `gorm:"column:user_id;primary_key;type:char(64)" json:"userID"`
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
}
// RegisterAddGroup 注册时默认群组
// RegisterAddGroup specifies default groups when registering
type RegisterAddGroup struct {
GroupID string `gorm:"column:group_id;primary_key;type:char(64)" json:"userID"`
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
}
// ClientInitConfig 系统相关配置项
// ClientInitConfig contains system-related configuration items
type ClientInitConfig struct {
DiscoverPageURL string `gorm:"column:discover_page_url;size:128" json:"discoverPageURL"`
OrdinaryUserAddFriend int32 `gorm:"column:ordinary_user_add_friend; default:1" json:"ordinaryUserAddFriend"`
+8 -8
View File
@@ -18,7 +18,7 @@ import (
"time"
)
// Register 注册信息表
// Register Registration information sheet
type Register struct {
UserID string `gorm:"column:user_id;primary_key;type:char(64)" json:"userID"`
DeviceID string `gorm:"column:device_id;type:varchar(255)" json:"deviceID"`
@@ -29,7 +29,7 @@ type Register struct {
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
}
// Account 账号密码表
// Account username and password table
type Account struct {
UserID string `gorm:"column:user_id;primary_key;type:char(64)" json:"userID"`
Password string `gorm:"column:password;type:varchar(255)" json:"password"`
@@ -38,7 +38,7 @@ type Account struct {
OperatorUserID string `gorm:"column:operator_user_id;type:varchar(64)" json:"operatorUserID"`
}
// Attribute 用户属性表
// Attribute user information table
type Attribute struct {
UserID string `gorm:"column:user_id;primary_key;type:char(64)" json:"userID"`
Account string `gorm:"column:account;type:char(64)" json:"account"`
@@ -58,7 +58,7 @@ type Attribute struct {
AllowAddFriend int32 `gorm:"column:allow_add_friend;default:1" json:"allowAddFriend"`
}
// 封号表
// User friend relationship table
type ForbiddenAccount struct {
UserID string `gorm:"column:user_id;index:userID;primary_key;type:char(64)" json:"userID"`
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
@@ -66,7 +66,7 @@ type ForbiddenAccount struct {
OperatorUserID string `gorm:"column:operator_user_id;type:varchar(255)" json:"operatorUserID"`
}
// 用户登录信息表
// user login record table
type UserLoginRecord struct {
UserID string `gorm:"column:user_id;size:64" json:"userID"`
LoginTime time.Time `gorm:"column:login_time" json:"loginTime"`
@@ -75,7 +75,7 @@ type UserLoginRecord struct {
Platform string `gorm:"column:platform;type:varchar(32)" json:"platform"`
}
// 禁止ip登录 注册
// ip login registration is prohibited
type IPForbidden struct {
IP string `gorm:"column:ip;primary_key;type:char(32)" json:"ip"`
LimitRegister int32 `gorm:"column:limit_register" json:"limitRegister"`
@@ -83,14 +83,14 @@ type IPForbidden struct {
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
}
// 限制userID只能在某些ip登录
// Restrict userids to certain ip addresses
type LimitUserLoginIP struct {
UserID string `gorm:"column:user_id;primary_key;type:char(64)" json:"userID"`
IP string `gorm:"column:ip;primary_key;type:char(32)" json:"ip"`
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
}
// 邀请码被注册使用
// The invitation code is registered for use
type InvitationRegister struct {
InvitationCode string `gorm:"column:invitation_code;primary_key;type:char(32)" json:"invitationCode"`
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
+1 -1
View File
@@ -18,7 +18,7 @@ import (
"time"
)
// Admin 后台管理员.
// Admin Background administrator.
type Admin struct {
Account string `gorm:"column:account;primary_key;type:varchar(64)"`
Password string `gorm:"column:password;type:varchar(64)"`
@@ -14,7 +14,7 @@
package admin
// ClientConfig 客户端相关配置项.
// ClientConfig Client related configuration items.
type ClientConfig struct {
Key string `gorm:"column:key;primary_key;type:varchar(255)"`
Value string `gorm:"column:value;not null;type:text"`
@@ -18,7 +18,7 @@ import (
"time"
)
// ForbiddenAccount 封号表.
// ForbiddenAccount forbidden account.
type ForbiddenAccount struct {
UserID string `gorm:"column:user_id;index:userID;primary_key;type:char(64)"`
Reason string `gorm:"column:reason;type:varchar(255)" `
@@ -18,7 +18,7 @@ import (
"time"
)
// 邀请码被注册使用.
// The invitation code is registered for use.
type InvitationRegister struct {
InvitationCode string `gorm:"column:invitation_code;primary_key;type:char(32)"`
UsedByUserID string `gorm:"column:user_id;index:userID;type:char(64)"`
@@ -18,7 +18,7 @@ import (
"time"
)
// 禁止ip登录 注册.
// ip login registration is prohibited.
type IPForbidden struct {
IP string `gorm:"column:ip;primary_key;type:char(32)"`
LimitRegister bool `gorm:"column:limit_register"`
@@ -18,7 +18,7 @@ import (
"time"
)
// 限制userID只能在某些ip登录.
// Restrict userids to certain ip addresses.
type LimitUserLoginIP struct {
UserID string `gorm:"column:user_id;primary_key;type:char(64)"`
IP string `gorm:"column:ip;primary_key;type:char(32)"`
@@ -18,7 +18,7 @@ import (
"time"
)
// RegisterAddFriend 注册时默认好友.
// RegisterAddFriend Indicates the default friend when registering.
type RegisterAddFriend struct {
UserID string `gorm:"column:user_id;primary_key;type:char(64)"`
CreateTime time.Time `gorm:"column:create_time"`
@@ -18,7 +18,7 @@ import (
"time"
)
// RegisterAddGroup 注册时默认群组.
// RegisterAddGroup Indicates the default group for registration.
type RegisterAddGroup struct {
GroupID string `gorm:"column:group_id;primary_key;type:char(64)"`
CreateTime time.Time `gorm:"column:create_time"`
@@ -18,7 +18,7 @@ import (
"time"
)
// Account 账号密码表.
// Account Account password table.
type Account struct {
UserID string `gorm:"column:user_id;primary_key;type:char(64)"`
Password string `gorm:"column:password;type:varchar(32)"`
@@ -18,7 +18,7 @@ import (
"time"
)
// Attribute 用户属性表.
// Attribute Indicates the user attribute table.
type Attribute struct {
UserID string `gorm:"column:user_id;primary_key;type:char(64)"`
Account string `gorm:"column:account;type:char(64)"`
@@ -18,7 +18,7 @@ import (
"time"
)
// Register 注册信息表.
// Register Indicates the registration information.
type Register struct {
UserID string `gorm:"column:user_id;primary_key;type:char(64)"`
DeviceID string `gorm:"column:device_id;type:varchar(255)"`
@@ -18,7 +18,7 @@ import (
"time"
)
// 用户登录信息表.
// User login information table.
type UserLoginRecord struct {
UserID string `gorm:"column:user_id;size:64"`
LoginTime time.Time `gorm:"column:login_time"`
@@ -38,11 +38,20 @@ import (
func main() {
var (
topic = "ws2ms_chat" // v2版本配置文件kafka.topic.ws2ms_chat
kafkaAddr = "127.0.0.1:9092" // v2版本配置文件kafka.topic.addr
rpcAddr = "127.0.0.1:10130" // v3版本配置文件rpcPort.openImMessagePort
adminUserID = "openIM123456" // v3版本管理员userID
concurrency = 1 // 并发数量
// The Kafka topic for ws2ms_chat in version 2 configuration
topic = "ws2ms_chat"
// The Kafka address in version 2 configuration
kafkaAddr = "127.0.0.1:9092"
// The RPC address in version 3 configuration
rpcAddr = "127.0.0.1:10130"
// The administrator userID in version 3
adminUserID = "openIM123456"
// The number of concurrent processes
concurrency = 1
)
getRpcConn := func() (*grpc.ClientConn, error) {
@@ -99,7 +108,7 @@ func main() {
ch := pc.Messages()
for {
select {
case <-time.After(time.Second * 10): // 10s读取不到就关闭
case <-time.After(time.Second * 10): // 10s Shuts down when the data cannot be read
return
case message, ok := <-ch:
if !ok {
@@ -27,21 +27,37 @@ import (
)
func main() {
var (
usernameV2 = "root" // v2版本mysql用户名
passwordV2 = "openIM" // v2版本mysql密码
addrV2 = "127.0.0.1:13306" // v2版本mysql地址
databaseV2 = "openIM_v2" // v2版本mysql数据库名字
// MySQL username for version 2
usernameV2 = "root"
// MySQL password for version 2
passwordV2 = "openIM"
// MySQL address for version 2
addrV2 = "127.0.0.1:13306"
// MySQL database name for version 2
databaseV2 = "openIM_v2"
)
var (
usernameV3 = "root" // v3版本mysql用户名
passwordV3 = "openIM123" // v3版本mysql密码
addrV3 = "127.0.0.1:13306" // v3版本mysql地址
databaseV3 = "openim_v3" // v3版本mysql数据库名字
// MySQL username for version 3
usernameV3 = "root"
// MySQL password for version 3
passwordV3 = "openIM123"
// MySQL address for version 3
addrV3 = "127.0.0.1:13306"
// MySQL database name for version 3
databaseV3 = "openim_v3"
)
var concurrency = 1 // 并发数量
// The number of concurrent processes
var concurrency = 1
log.SetFlags(log.LstdFlags | log.Llongfile)
dsnV2 := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", usernameV2, passwordV2, addrV2, databaseV2)
+25 -36
View File
@@ -38,41 +38,30 @@ func (FriendModel) TableName() string {
}
type FriendModelInterface interface {
// 插入多条记录
Create(ctx context.Context, friends []*FriendModel) (err error)
// 删除ownerUserID指定的好友
Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error)
// 更新ownerUserID单个好友信息 更新零值
UpdateByMap(ctx context.Context, ownerUserID string, friendUserID string, args map[string]interface{}) (err error)
// 更新好友信息的非零值
Update(ctx context.Context, friends []*FriendModel) (err error)
// 更新好友备注(也支持零值
UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error)
// 获取单个好友信息,如没找到 返回错误
Take(ctx context.Context, ownerUserID, friendUserID string) (friend *FriendModel, err error)
// 查找好友关系,如果是双向关系,则都返回
FindUserState(ctx context.Context, userID1, userID2 string) (friends []*FriendModel, err error)
// 获取 owner指定的好友列表 如果有friendUserIDs不存在,也不返回错误
FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*FriendModel, err error)
// 获取哪些人添加了friendUserID 如果有ownerUserIDs不存在,也不返回错误
FindReversalFriends(
ctx context.Context,
friendUserID string,
ownerUserIDs []string,
) (friends []*FriendModel, err error)
// 获取ownerUserID好友列表 支持翻页
FindOwnerFriends(
ctx context.Context,
ownerUserID string,
pageNumber, showNumber int32,
) (friends []*FriendModel, total int64, err error)
// 获取哪些人添加了friendUserID 支持翻页
FindInWhoseFriends(
ctx context.Context,
friendUserID string,
pageNumber, showNumber int32,
) (friends []*FriendModel, total int64, err error)
// 获取好友UserID列表
FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error)
// Create inserts multiple friend records.
Create(ctx context.Context, friends []*FriendModel) error
// Delete removes specified friends for an owner user.
Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) error
// UpdateByMap updates a single friend's information for an owner user based on a map of arguments. Zero values are updated.
UpdateByMap(ctx context.Context, ownerUserID string, friendUserID string, args map[string]interface{}) error
// Update modifies the information of friends, excluding zero values.
Update(ctx context.Context, friends []*FriendModel) error
// UpdateRemark updates the remark for a friend, supporting zero values.
UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) error
// Take retrieves a single friend's information. Returns an error if not found.
Take(ctx context.Context, ownerUserID, friendUserID string) (*FriendModel, error)
// FindUserState finds the friendship status between two users, returning both if a mutual friendship exists.
FindUserState(ctx context.Context, userID1, userID2 string) ([]*FriendModel, error)
// FindFriends retrieves a list of friends for an owner, not returning an error for non-existent friendUserIDs.
FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) ([]*FriendModel, error)
// FindReversalFriends finds who has added the specified user as a friend, not returning an error for non-existent ownerUserIDs.
FindReversalFriends(ctx context.Context, friendUserID string, ownerUserIDs []string) ([]*FriendModel, error)
// FindOwnerFriends paginates through the friends list of an owner user.
FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) ([]*FriendModel, int64, error)
// FindInWhoseFriends paginates through users who have added the specified user as a friend.
FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) ([]*FriendModel, int64, error)
// FindFriendUserIDs retrieves a list of friend user IDs for an owner user.
FindFriendUserIDs(ctx context.Context, ownerUserID string) ([]string, error)
// NewTx creates a new transactional instance of the FriendModelInterface.
NewTx(tx any) FriendModelInterface
}
@@ -38,29 +38,33 @@ func (FriendRequestModel) TableName() string {
}
type FriendRequestModelInterface interface {
// 插入多条记录
// Insert multiple records
Create(ctx context.Context, friendRequests []*FriendRequestModel) (err error)
// 删除记录
// Delete a record
Delete(ctx context.Context, fromUserID, toUserID string) (err error)
// 更新零值
UpdateByMap(ctx context.Context, formUserID string, toUserID string, args map[string]interface{}) (err error)
// 更新多条记录 (非零值)
// Update records with zero values based on a map of changes
UpdateByMap(ctx context.Context, formUserID, toUserID string, args map[string]interface{}) (err error)
// Update multiple records (non-zero values)
Update(ctx context.Context, friendRequest *FriendRequestModel) (err error)
// 获取来指定用户的好友申请 未找到 不返回错误
// Find a friend request sent to a specific user; does not return an error if not found
Find(ctx context.Context, fromUserID, toUserID string) (friendRequest *FriendRequestModel, err error)
// Alias for Find (retrieves a friend request between two users)
Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *FriendRequestModel, err error)
// 获取toUserID收到的好友申请列表
FindToUserID(
ctx context.Context,
toUserID string,
pageNumber, showNumber int32,
) (friendRequests []*FriendRequestModel, total int64, err error)
// 获取fromUserID发出去的好友申请列表
FindFromUserID(
ctx context.Context,
fromUserID string,
pageNumber, showNumber int32,
) (friendRequests []*FriendRequestModel, total int64, err error)
// Get a list of friend requests received by `toUserID`
FindToUserID(ctx context.Context, toUserID string, pageNumber, showNumber int32) (friendRequests []*FriendRequestModel, total int64, err error)
// Get a list of friend requests sent by `fromUserID`
FindFromUserID(ctx context.Context, fromUserID string, pageNumber, showNumber int32) (friendRequests []*FriendRequestModel, total int64, err error)
// Find all friend requests between two users (both directions)
FindBothFriendRequests(ctx context.Context, fromUserID, toUserID string) (friends []*FriendRequestModel, err error)
// Create a new transaction
NewTx(tx any) FriendRequestModelInterface
}
@@ -58,9 +58,10 @@ type GroupModelInterface interface {
keyword string,
pageNumber, showNumber int32,
) (total uint32, groups []*GroupModel, err error)
// GetGroupIDsByCreatorUserID retrieves a list of group IDs created by the specified user.
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
// 获取群总数
// CountTotal retrieves the total number of groups.
CountTotal(ctx context.Context, before *time.Time) (count int64, err error)
// 获取范围内群增量
// CountRangeEverydayTotal retrieves the total number of groups created every day within the specified time range.
CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error)
}
+20 -5
View File
@@ -53,20 +53,35 @@ func (UserModel) TableName() string {
return UserModelTableName
}
// UserModelInterface defines the operations available for managing user models.
type UserModelInterface interface {
// Create inserts a new user or multiple users into the database.
Create(ctx context.Context, users []*UserModel) (err error)
// UpdateByMap updates a user's information based on a map of changes.
UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)
// Update modifies a user's information in the database.
Update(ctx context.Context, user *UserModel) (err error)
// 获取指定用户信息 不存在,也不返回错误
// Find retrieves information for a list of users by their IDs. If a user does not exist, it is simply skipped without returning an error.
Find(ctx context.Context, userIDs []string) (users []*UserModel, err error)
// 获取某个用户信息 不存在,则返回错误
// Take retrieves a specific user's information by their ID. Returns an error if the user does not exist.
Take(ctx context.Context, userID string) (user *UserModel, err error)
// 获取用户信息 不存在,不返回错误
// Page retrieves a paginated list of users and the total count of users. If no users exist, returns an empty list without an error.
Page(ctx context.Context, pageNumber, showNumber int32) (users []*UserModel, count int64, err error)
// GetAllUserID retrieves all user IDs in a paginated manner.
GetAllUserID(ctx context.Context, pageNumber, showNumber int32) (userIDs []string, err error)
// GetUserGlobalRecvMsgOpt retrieves a user's global message receiving option.
GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error)
// 获取用户总数
// CountTotal returns the total number of users before a specified time.
CountTotal(ctx context.Context, before *time.Time) (count int64, err error)
// 获取范围内用户增量
// CountRangeEverydayTotal calculates the daily increment of users within a specified time range.
CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error)
}
+2 -1
View File
@@ -21,6 +21,7 @@ import (
"regexp"
"strings"
"github.com/OpenIMSDK/tools/errs"
"github.com/openimsdk/open-im-server/tools/formitychecker/config"
)
@@ -39,7 +40,7 @@ func CheckDirectory(cfg *config.Config) error {
for _, targetDir := range cfg.TargetDirs {
err := filepath.Walk(targetDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
return errs.Wrap(err, fmt.Sprintf("error walking directory '%s'", targetDir))
}
// Skip if the directory is in the ignore list
+2 -2
View File
@@ -20,7 +20,7 @@ import (
"github.com/fatih/color"
)
// 定义一个函数以打印重要的链接信息
// Define a function to print important link information
func printLinks() {
blue := color.New(color.FgBlue).SprintFunc()
fmt.Printf("OpenIM Github: %s\n", blue("https://github.com/OpenIMSDK/Open-IM-Server"))
@@ -47,5 +47,5 @@ Keep checking for updates!
`
blue.Println(message)
printLinks() // 调用函数以打印链接信息
printLinks() // Call the function to print the link information
}
+32 -11
View File
@@ -31,17 +31,38 @@ import (
*/
func main() {
var conf pkg.Config // 后面带*的为必填项
flag.StringVar(&conf.TaskPath, "task", "take.txt", "task path") // 任务日志文件*
flag.StringVar(&conf.ProgressPath, "progress", "", "progress path") // 进度日志文件
flag.IntVar(&conf.Concurrency, "concurrency", 1, "concurrency num") // 并发数
flag.IntVar(&conf.Retry, "retry", 1, "retry num") // 重试次数
flag.StringVar(&conf.TempDir, "temp", "", "temp dir") // 临时文件夹
flag.Int64Var(&conf.CacheSize, "cache", 1024*1024*100, "cache size") // 缓存大小(超过时,下载到磁盘)
flag.Int64Var((*int64)(&conf.Timeout), "timeout", 5000, "timeout") // 请求超时时间(毫秒)
flag.StringVar(&conf.Api, "api", "http://127.0.0.1:10002", "api") // im地址*
flag.StringVar(&conf.UserID, "userID", "openIM123456", "userID") // im管理员
flag.StringVar(&conf.Secret, "secret", "openIM123", "secret") // im config secret
var conf pkg.Config // Configuration object, '*' denotes required fields
// *Required*: Path for the task log file
flag.StringVar(&conf.TaskPath, "task", "take.txt", "Path for the task log file")
// Optional: Path for the progress log file
flag.StringVar(&conf.ProgressPath, "progress", "", "Path for the progress log file")
// Number of concurrent operations
flag.IntVar(&conf.Concurrency, "concurrency", 1, "Number of concurrent operations")
// Number of retry attempts
flag.IntVar(&conf.Retry, "retry", 1, "Number of retry attempts")
// Optional: Path for the temporary directory
flag.StringVar(&conf.TempDir, "temp", "", "Path for the temporary directory")
// Cache size in bytes (downloads move to disk when exceeded)
flag.Int64Var(&conf.CacheSize, "cache", 1024*1024*100, "Cache size in bytes")
// Request timeout in milliseconds
flag.Int64Var((*int64)(&conf.Timeout), "timeout", 5000, "Request timeout in milliseconds")
// *Required*: API endpoint for the IM service
flag.StringVar(&conf.Api, "api", "http://127.0.0.1:10002", "API endpoint for the IM service")
// IM administrator's user ID
flag.StringVar(&conf.UserID, "userID", "openIM123456", "IM administrator's user ID")
// Secret for the IM configuration
flag.StringVar(&conf.Secret, "secret", "openIM123", "Secret for the IM configuration")
flag.Parse()
if !filepath.IsAbs(conf.TaskPath) {
var err error