You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mysqlbinlog/get_first_previous_gtid_of_...

30 lines
638 B
Go

package binlog
import (
"io/ioutil"
"path/filepath"
"strings"
)
func GetFirstPreviousGtidOfBinlogDir(binlogDir, binlogBaseName string) (gtidDesc string, err error) {
files, err := ioutil.ReadDir(binlogDir)
if nil != err {
return "", err
}
var binlogFiles []string
for _, file := range files {
if strings.HasPrefix(file.Name(), binlogBaseName+".") && binlogFileSuffixPattern.MatchString(file.Name()) {
binlogFiles = append(binlogFiles, file.Name())
}
}
if 0 == len(binlogFiles) {
return "", nil
}
firstFile := filepath.Join(binlogDir, binlogFiles[0])
ret, err := GetPreviousGtids(firstFile)
return ret, err
}