Documentation
¶
Overview ¶
Copyright © 2020 Marvin
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.
Copyright © 2020 Marvin ¶
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.
Copyright © 2020 Marvin ¶
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.
Index ¶
- Constants
- Variables
- func DiffStructArray(structA, structB interface{}) ([]interface{}, []interface{}, bool)
- func FilterDifferenceStringItems(originItems, excludeItems []string) []string
- func FilterIntersectionStringItems(originItems, newItems []string) []string
- func GbkToUtf8(s []byte) ([]byte, error)
- func GetStringSliceElementIndex(items []string, item string) int
- func IsContainString(items []string, item string) bool
- func IsEmptyString(str string) bool
- func IsNum(s string) bool
- func IsSubsetString(originItems, checkItems []string) (bool, []string)
- func PathExist(path string) error
- func ReSplit(text string, cut string) []string
- func ReplaceQuotesString(s string) string
- func ReplaceSpecifiedString(s string, oldStr, newStr string) string
- func SpecialLetters(bs []byte) string
- func SplitMultipleSlice(arr []interface{}, num int64) [][]interface{}
- func SplitMultipleStringSlice(arr [][]string, num int64) [][][]string
- func StrconvFloatBitSize(s string, bitSize int) (float64, error)
- func StrconvIntBitSize(s string, bitSize int) (int64, error)
- func StrconvRune(s string) (int32, error)
- func StrconvUintBitSize(s string, bitSize int) (uint64, error)
- func StringArrayToCapitalChar(strs []string) string
- func StringsBuilder(str ...string) string
- func TrimLastChar(s string) string
- func Utf8ToGbk(s []byte) ([]byte, error)
- func VersionOrdinal(version string) string
Constants ¶
const ( UpdateOperation = "UPDATE" InsertOperation = "INSERT" DeleteOperation = "DELETE" TruncateOperation = "TRUNCATE" DropOperation = "DROP" DDLOperation = "DDL" TruncateTableOperation = "TRUNCATE TABLE" DropTableOperation = "DROP TABLE" )
同步操作类型
const ( // MySQL 支持 check 约束版本 > 8.0.15 MySQLCheckConsVersion = "8.0.15" // MySQL 版本分隔符号 MySQLVersionDelimiter = "-" // MySQL 字符集 MySQLCharacterSet = "UTF8MB4" // JSON 格式化某字段 ColumnsJSON = "COLUMN" IndexJSON = "INDEX" PUConstraintJSON = "PUK" FKConstraintJSON = "FK" CKConstraintJSON = "CK" PartitionJSON = "PARTITION" // 目标数据库类型 TiDBTargetDBType = "TIDB" MySQLTargetDBType = "MYSQL" // 数据全量/实时同步 Oracle 版本要求 // 要求 oracle 11g 及以上 OracleSYNCRequireDBVersion = "11" // 允许 Oracle 表、字段 Collation // 需要 oracle 12.2g 及以上 OracleTableColumnCollationDBVersion = "12.2" // Oracle 用户、表、字段默认使用 DB 排序规则 OracleUserTableColumnDefaultCollation = "USING_NLS_COMP" // CSV 字符集判断 UTF8CharacterSetCSV = "UTF8" GBKCharacterSetCSV = "GBK" // 模式 ReverseMode = "Reverse" CheckMode = "Check" DiffMode = "Diff" // Channel BufferSize = 1024 // TiDB 数据库 TiDBClusteredIndexIntOnlyValue = "INT_ONLY" TiDBClusteredIndexONValue = "ON" TiDBClusteredIndexOFFValue = "OFF" // Reverse 模式 ReverseModeO2M = "O2M" ReverseModeM2O = "M2O" )
const ( DefaultValueSysdate = "SYSDATE" DefaultValueSysdateMap = "NOW()" )
ORACLE 默认值规则映射规则
const ( DefaultValueNow = "CURRENT_TIMESTAMP" DefaultValueNowMAP = "SYSDATE" )
MySQL 默认值规则映射规则
Variables ¶
var CurrentResetFlag = 0
用于控制当程序消费追平到当前 CURRENT 重做日志, 当值 == 0 启用 filterOracleRedoGreaterOrEqualRecordByTable 大于或者等于 当值 == 1 启用 filterOracleRedoGreaterOrEqualRecordByTable 大于,避免已被消费得日志一直被重复消费
var MySQLDBCharacterSetMap = map[string]string{
"UTF8MB4": "AL32UTF8",
"UTF8": "AL32UTF8",
"GBK": "AL32UTF8",
}
MySQL 字符集映射规则
var MySQLDBCollationMap = map[string]string{
"utf8mb4_0900_as_ci": "BINARY_CI",
"utf8mb4_general_ci": "BINARY_AI",
"utf8mb4_bin": "BINARY/BINARY_CS",
"utf8_0900_as_ci": "BINARY_CI",
"utf8_general_ci": "BINARY_AI",
"utf8_bin": "BINARY/BINARY_CS",
}
var OracleCollationMap = map[string]string{
"BINARY_CI": "utf8mb4_0900_as_ci",
"BINARY_AI": "utf8mb4_general_ci",
"BINARY_CS": "utf8mb4_bin",
"BINARY": "utf8mb4_bin",
}
MySQL 8.0 utf8mb4_0900_as_cs 区分重音、区分大小写的排序规则 utf8mb4_0900_ai_ci 不区分重音和不区分大小写的排序规则 utf8mb4_0900_as_ci 区分重音、不区分大小写的排序规则 Oracle 字段 Collation 映射
var OracleDBCSVCharacterSetMap = map[string]string{
"AL32UTF8": "UTF8",
"UTF8": "UTF8",
"ZHS16GBK": "GBK",
}
ORACLE 字符集映射规则
var OracleDBCharacterSetMap = map[string]string{
"AL32UTF8": "UTF8MB4",
"UTF8": "UTF8MB4",
"ZHS16GBK": "GBK",
}
ORACLE 字符集映射规则
var OracleIsNotSupportDataType = []string{"ENUM", "SET"}
Oracle 不支持数据类型 -> M2O
var TiDBIntegerPrimaryKeyList = []string{"TINYINT", "SMALLINT", "INT", "BIGINT", "DECIMAL"}
alter-primary-key = fase 主键整型数据类型列表
Functions ¶
func DiffStructArray ¶
func DiffStructArray(structA, structB interface{}) ([]interface{}, []interface{}, bool)
用于对比 struct 是否相等
func FilterDifferenceStringItems ¶
过滤排除元素,返回新数组
func FilterIntersectionStringItems ¶
过滤两个数组相同元素(交集),返回新数组
func GetStringSliceElementIndex ¶
获取数组元素下标
func IsSubsetString ¶
两个数组对比,判断 checkItems 是否是 originItems 子集
func ReplaceSpecifiedString ¶
替换指定字符
func SpecialLetters ¶ added in v1.0.5
如果存在特殊字符,直接在特殊字符前添加\ * 判断是否为字母: unicode.IsLetter(v) 判断是否为十进制数字: unicode.IsDigit(v) 判断是否为数字: unicode.IsNumber(v) 判断是否为空白符号: unicode.IsSpace(v) 判断师傅是特殊符号:unicode.IsSymbol(v) 判断是否为Unicode标点字符 :unicode.IsPunct(v) 判断是否为中文:unicode.Han(v)
func SplitMultipleSlice ¶ added in v1.0.4
func SplitMultipleSlice(arr []interface{}, num int64) [][]interface{}
多重数组拆分
func SplitMultipleStringSlice ¶
数组拆分
func StrconvFloatBitSize ¶ added in v1.0.4
func StrconvIntBitSize ¶ added in v1.0.4
字符转换
func StrconvRune ¶ added in v1.0.4
func StrconvUintBitSize ¶ added in v1.0.4
Types ¶
This section is empty.