gh-ost/vendor/github.com/siddontang/go-mysql/mysql/position.go
2016-06-16 11:15:56 +02:00

34 lines
528 B
Go

package mysql
import (
"fmt"
)
// For binlog filename + position based replication
type Position struct {
Name string
Pos uint32
}
func (p Position) Compare(o Position) int {
// First compare binlog name
if p.Name > o.Name {
return 1
} else if p.Name < o.Name {
return -1
} else {
// Same binlog file, compare position
if p.Pos > o.Pos {
return 1
} else if p.Pos < o.Pos {
return -1
} else {
return 0
}
}
}
func (p Position) String() string {
return fmt.Sprintf("(%s, %d)", p.Name, p.Pos)
}