Skip to content

Commit

Permalink
docs: modify scripts style(#7)
Browse files Browse the repository at this point in the history
Signed-off-by: AllianceTing <[email protected]>
  • Loading branch information
PolarishT committed Jul 10, 2023
1 parent dd5e1d0 commit b4ebe28
Show file tree
Hide file tree
Showing 37 changed files with 93 additions and 55 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OUT_DIR=$(REPO_ROOT)/_output

# define the default goal
#

# define shell
SHELL := /bin/bash
DIRS=$(shell ls)
GO=go
Expand Down
5 changes: 3 additions & 2 deletions cmd/api/admin_api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw"
openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/chat/internal/api"
"github.com/OpenIMSDK/chat/pkg/common/config"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/OpenIMSDK/chat/internal/api"
"github.com/OpenIMSDK/chat/pkg/common/config"

"github.com/gin-gonic/gin"
)

Expand Down
5 changes: 3 additions & 2 deletions cmd/api/chat_api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw"
openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/chat/internal/api"
"github.com/OpenIMSDK/chat/pkg/common/config"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/OpenIMSDK/chat/internal/api"
"github.com/OpenIMSDK/chat/pkg/common/config"

"github.com/gin-gonic/gin"
)

Expand Down
1 change: 1 addition & 0 deletions cmd/rpc/admin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main

import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/chat/pkg/common/chatrpcstart"

"github.com/OpenIMSDK/chat/internal/rpc/admin"
Expand Down
1 change: 1 addition & 0 deletions cmd/rpc/chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main

import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/chat/pkg/common/chatrpcstart"

"github.com/OpenIMSDK/chat/internal/rpc/chat"
Expand Down
1 change: 0 additions & 1 deletion internal/api/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
)

func NewChat(chatConn, adminConn grpc.ClientConnInterface) *ChatApi {

return &ChatApi{chatClient: chat.NewChatClient(chatConn), adminClient: admin.NewAdminClient(adminConn)}
}

Expand Down
3 changes: 2 additions & 1 deletion internal/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import (
"context"

"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/gin-gonic/gin"

"github.com/OpenIMSDK/chat/pkg/common/config"
)

func NewChatRoute(router gin.IRouter, discov discoveryregistry.SvcDiscoveryRegistry) {
Expand Down
5 changes: 4 additions & 1 deletion internal/rpc/admin/applet.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ package admin

import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"strings"
"time"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"github.com/google/uuid"
Expand Down
1 change: 1 addition & 0 deletions internal/rpc/admin/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package admin
import (
"context"
"fmt"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/chat/pkg/common/db/dbutil"
Expand Down
1 change: 1 addition & 0 deletions internal/rpc/admin/client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package admin

import (
"context"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
Expand Down
5 changes: 4 additions & 1 deletion internal/rpc/admin/invitation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ package admin

import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"math/rand"
"strings"
"time"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"

Expand Down
4 changes: 3 additions & 1 deletion internal/rpc/admin/ip_forbidden.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ package admin

import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"time"


"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

admin2 "github.com/OpenIMSDK/chat/pkg/common/db/table/admin"
"github.com/OpenIMSDK/chat/pkg/common/mctx"
"github.com/OpenIMSDK/chat/pkg/proto/admin"
Expand Down
5 changes: 4 additions & 1 deletion internal/rpc/admin/register_add_friend.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ package admin

import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"strings"
"time"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"

Expand Down
5 changes: 4 additions & 1 deletion internal/rpc/admin/register_add_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ package admin

import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"strings"
"time"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
Expand Down
1 change: 1 addition & 0 deletions internal/rpc/admin/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package admin

import (
"context"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/chat/pkg/common/config"
Expand Down
7 changes: 5 additions & 2 deletions internal/rpc/admin/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ package admin

import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/chat/pkg/common/constant"
"strings"
"time"


"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/chat/pkg/common/constant"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
Expand Down
4 changes: 3 additions & 1 deletion internal/rpc/admin/user_ip_limit_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ package admin

import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"time"


"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"

Expand Down
1 change: 1 addition & 0 deletions internal/rpc/chat/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package chat

import (
"context"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
Expand Down
1 change: 1 addition & 0 deletions internal/rpc/chat/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package chat

import (
"context"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"

"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
Expand Down
9 changes: 4 additions & 5 deletions pkg/common/chatrpcstart/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ package chatrpcstart

import (
"fmt"
"net"
"strconv"
"time"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/network"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
"github.com/OpenIMSDK/chat/pkg/common/config"
chatMw "github.com/OpenIMSDK/chat/pkg/common/mw"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"net"
"strconv"
"time"
)

func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error {
Expand Down
7 changes: 2 additions & 5 deletions pkg/common/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,16 @@ import (
"bytes"
"errors"
"fmt"
openIMConfig "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
"gopkg.in/yaml.v3"
"os"
"path/filepath"
"runtime"
"time"

)

var (
_, b, _, _ = runtime.Caller(0)
// Root folder of this project
// Root folder of this project.
Root = filepath.Join(filepath.Dir(b), "../../..")
)

Expand Down
6 changes: 4 additions & 2 deletions pkg/common/db/database/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ package database

import (
"context"
"time"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/tx"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"gorm.io/gorm"

"github.com/OpenIMSDK/chat/pkg/common/db/model/chat"
table "github.com/OpenIMSDK/chat/pkg/common/db/table/chat"
"gorm.io/gorm"
"time"
)

type ChatDatabaseInterface interface {
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/db/model/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"context"
"crypto/md5"
"encoding/hex"
"time"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/chat/pkg/common/db/table/admin"
"gorm.io/gorm"
"time"
)

func NewAdmin(db *gorm.DB) *Admin {
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/db/model/chat/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ package chat

import (
"context"
"time"

"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/chat/pkg/common/db/table/chat"
"gorm.io/gorm"
"time"
)

func NewAccount(db *gorm.DB) chat.AccountInterface {
Expand Down
1 change: 0 additions & 1 deletion pkg/common/db/model/chat/user_login_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package chat
import (
"context"


"gorm.io/gorm"

"github.com/OpenIMSDK/chat/pkg/common/db/table/chat"
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/db/model/chat/verify_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ package chat

import (
"context"
"time"

"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/chat/pkg/common/db/table/chat"
"gorm.io/gorm"
"time"
)

func NewVerifyCode(db *gorm.DB) *VerifyCode {
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/dbconn/gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ package dbconn

import (
"fmt"
"time"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/chat/pkg/common/config"
mysqlDriver "github.com/go-sql-driver/mysql"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"time"
)

func NewMysqlGormDB() (*gorm.DB, error) {
Expand Down
4 changes: 3 additions & 1 deletion pkg/common/mw/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package mw

import (
"context"

"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/chat/pkg/common/constant"
"google.golang.org/grpc"

"github.com/OpenIMSDK/chat/pkg/common/constant"
)

func AddUserType() grpc.DialOption {
Expand Down
14 changes: 7 additions & 7 deletions pkg/common/tokenverify/token_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
package tokenverify

import (
"time"

"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/chat/pkg/common/config"
"github.com/OpenIMSDK/chat/pkg/common/constant"
utils "github.com/OpenIMSDK/open_utils"
"github.com/golang-jwt/jwt/v4"
"time"
)

const (
Expand All @@ -41,10 +40,11 @@ func buildClaims(userID string, userType int32, ttl int64) claims {
UserID: userID,
UserType: userType,
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(now.Add(time.Duration(ttl*24) * time.Hour)), //Expiration time
IssuedAt: jwt.NewNumericDate(now), //Issuing time
NotBefore: jwt.NewNumericDate(before), //Begin Effective time
}}
ExpiresAt: jwt.NewNumericDate(now.Add(time.Duration(ttl*24) * time.Hour)), // Expiration time
IssuedAt: jwt.NewNumericDate(now), // Issuing time
NotBefore: jwt.NewNumericDate(before), // Begin Effective time
},
}
}

func CreateToken(UserID string, userType int32, ttl int64) (string, error) {
Expand Down
Loading

0 comments on commit b4ebe28

Please sign in to comment.