mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-10-31 16:32:12 +08:00 
			
		
		
		
	* feat: add logic to deploy images Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add logic to deploy images Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: add ubuntu Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: sync quest Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add copyright information Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add more cicd design Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * fix: fix sync Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: test file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: test file Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: build multiarch Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: build multiarch Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> * feat: add start scripts Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
		
			
				
	
	
		
			142 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			142 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // 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.
 | |
| 
 | |
| package utils
 | |
| 
 | |
| import (
 | |
| 	"encoding/json"
 | |
| 	"math/rand"
 | |
| 	"strconv"
 | |
| )
 | |
| 
 | |
| func IntToString(i int) string {
 | |
| 	return strconv.FormatInt(int64(i), 10)
 | |
| }
 | |
| 
 | |
| func StringToInt(i string) int {
 | |
| 	j, _ := strconv.Atoi(i)
 | |
| 	return j
 | |
| }
 | |
| func StringToInt64(i string) int64 {
 | |
| 	j, _ := strconv.ParseInt(i, 10, 64)
 | |
| 	return j
 | |
| }
 | |
| func StringToInt32(i string) int32 {
 | |
| 	j, _ := strconv.ParseInt(i, 10, 64)
 | |
| 	return int32(j)
 | |
| }
 | |
| func Int32ToString(i int32) string {
 | |
| 	return strconv.FormatInt(int64(i), 10)
 | |
| }
 | |
| 
 | |
| func Uint32ToString(i uint32) string {
 | |
| 	return strconv.FormatInt(int64(i), 10)
 | |
| }
 | |
| 
 | |
| // judge a string whether in the  string list
 | |
| func IsContain(target string, List []string) bool {
 | |
| 	for _, element := range List {
 | |
| 
 | |
| 		if target == element {
 | |
| 			return true
 | |
| 		}
 | |
| 	}
 | |
| 	return false
 | |
| }
 | |
| func IsContainInt32(target int32, List []int32) bool {
 | |
| 	for _, element := range List {
 | |
| 		if target == element {
 | |
| 			return true
 | |
| 		}
 | |
| 	}
 | |
| 	return false
 | |
| }
 | |
| func IsContainInt(target int, List []int) bool {
 | |
| 	for _, element := range List {
 | |
| 		if target == element {
 | |
| 			return true
 | |
| 		}
 | |
| 	}
 | |
| 	return false
 | |
| }
 | |
| func InterfaceArrayToStringArray(data []interface{}) (i []string) {
 | |
| 	for _, param := range data {
 | |
| 		i = append(i, param.(string))
 | |
| 	}
 | |
| 	return i
 | |
| }
 | |
| func StructToJsonString(param interface{}) string {
 | |
| 	dataType, _ := json.Marshal(param)
 | |
| 	dataString := string(dataType)
 | |
| 	return dataString
 | |
| }
 | |
| 
 | |
| func StructToJsonBytes(param interface{}) []byte {
 | |
| 	dataType, _ := json.Marshal(param)
 | |
| 	return dataType
 | |
| }
 | |
| 
 | |
| // The incoming parameter must be a pointer
 | |
| func JsonStringToStruct(s string, args interface{}) error {
 | |
| 	err := json.Unmarshal([]byte(s), args)
 | |
| 	return err
 | |
| }
 | |
| 
 | |
| func GetMsgID(sendID string) string {
 | |
| 	t := int64ToString(GetCurrentTimestampByNano())
 | |
| 	return Md5(t + sendID + int64ToString(rand.Int63n(GetCurrentTimestampByNano())))
 | |
| }
 | |
| 
 | |
| func int64ToString(i int64) string {
 | |
| 	return strconv.FormatInt(i, 10)
 | |
| }
 | |
| func Int64ToString(i int64) string {
 | |
| 	return strconv.FormatInt(i, 10)
 | |
| }
 | |
| 
 | |
| func RemoveDuplicateElement(idList []string) []string {
 | |
| 	result := make([]string, 0, len(idList))
 | |
| 	temp := map[string]struct{}{}
 | |
| 	for _, item := range idList {
 | |
| 		if _, ok := temp[item]; !ok {
 | |
| 			temp[item] = struct{}{}
 | |
| 			result = append(result, item)
 | |
| 		}
 | |
| 	}
 | |
| 	return result
 | |
| }
 | |
| 
 | |
| func RemoveDuplicate[T comparable](arr []T) []T {
 | |
| 	result := make([]T, 0, len(arr))
 | |
| 	temp := map[T]struct{}{}
 | |
| 	for _, item := range arr {
 | |
| 		if _, ok := temp[item]; !ok {
 | |
| 			temp[item] = struct{}{}
 | |
| 			result = append(result, item)
 | |
| 		}
 | |
| 	}
 | |
| 	return result
 | |
| }
 | |
| 
 | |
| func IsDuplicateStringSlice(arr []string) bool {
 | |
| 	t := make(map[string]struct{})
 | |
| 	for _, s := range arr {
 | |
| 		if _, ok := t[s]; ok {
 | |
| 			return true
 | |
| 		}
 | |
| 		t[s] = struct{}{}
 | |
| 	}
 | |
| 	return false
 | |
| }
 |