Documentation
¶
Overview ¶
* Copyright (c) 2024 OceanBase. * * 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 ¶
- func CheckDirEmpty(path string) error
- func CheckDirExists(dir string) error
- func CheckPathExistAndValid(path string) error
- func CheckPathValid(path string) error
- func ContainsPrefix(prefix []string, s string) bool
- func ContainsString(list []string, item string) bool
- func Difference[T comparable](a, b []T) ([]T, []T)
- func IsPortFree(port int) (bool, error)
- func IsValidIp(ip string) bool
- func IsValidParamKey(key string) bool
- func IsValidPort(port string) bool
- func IsValidPortValue(p int) bool
- func Sha1(input string) string
- func ShellQuote(s string) string
- func SliceEqual(list1, list2 []string) bool
- type RotateFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckDirEmpty ¶
func CheckDirExists ¶
CheckDirExists checks if the provided filesystem path exists and is a dir. It returns an error if the path does not exist or if the path is not a dir.
func CheckPathExistAndValid ¶
CheckPathExistAndValid checks if the provided filesystem path exists and is valid. It returns an error if the path does not exist or if the path is invalid according to the CheckPathValid function's criteria.
func CheckPathValid ¶
CheckPathValid validates the specified path according to several rules. It ensures that the path:
- starts with a forward slash ("/"),
- matches a specific pattern that includes alphanumeric characters, Chinese characters, certain special characters (-_: @/.), and
- does not lead to directory traversal issues when joined with a generated parent path.
func ContainsPrefix ¶
func ContainsString ¶
func Difference ¶
func Difference[T comparable](a, b []T) ([]T, []T)
func IsPortFree ¶
func IsValidParamKey ¶
IsValidParamKey checks whether a parameter key contains only safe characters (letters, digits, and underscores).
func IsValidPort ¶
func IsValidPortValue ¶
func ShellQuote ¶
ShellQuote wraps a string in single quotes with proper escaping for safe use in shell commands. Single quotes inside the string are escaped as '\”.
func SliceEqual ¶
Types ¶
type RotateFile ¶
type RotateFile struct {
// contains filtered or unexported fields
}
func NewRotateFile ¶
func NewRotateFile(fileName string, maxSize int64, maxAge, maxBackups int) *RotateFile
NewRotateFile creates a new RotateFile. The maxSize is the maximum size in megabytes of the log file before it gets rotated. It defaults to 128 megabytes. The maxAge is the maximum number of days to retain old log files based on the timestamp encoded in their filename. If maxAge is 0, old files are not removed. It defaults to 0. The maxBackups is the maximum number of old log files to retain. If maxBackups is 0, all old log files are retained. It defaults to 0.
func (*RotateFile) Close ¶
func (rf *RotateFile) Close() error