MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / parseInterval

Function parseInterval

IceFireDB-SQLite/pkg/mysql/mysql/mysql_gtid.go:27–52  ·  view source on GitHub ↗

Interval is [start, stop), but the GTID string's format is [n] or [n1-n2], closed interval

(str string)

Source from the content-addressed store, hash-verified

25
26// Interval is [start, stop), but the GTID string's format is [n] or [n1-n2], closed interval
27func parseInterval(str string) (i Interval, err error) {
28 p := strings.Split(str, "-")
29 switch len(p) {
30 case 1:
31 i.Start, err = strconv.ParseInt(p[0], 10, 64)
32 i.Stop = i.Start + 1
33 case 2:
34 i.Start, err = strconv.ParseInt(p[0], 10, 64)
35 if err == nil {
36 i.Stop, err = strconv.ParseInt(p[1], 10, 64)
37 i.Stop++
38 }
39 default:
40 err = errors.Errorf("invalid interval format, must n[-n]")
41 }
42
43 if err != nil {
44 return
45 }
46
47 if i.Stop <= i.Start {
48 err = errors.Errorf("invalid interval format, must n[-n] and the end must >= start")
49 }
50
51 return
52}
53
54func (i Interval) String() string {
55 if i.Stop == i.Start+1 {

Callers 2

TestMysqlGTIDIntervalMethod · 0.70
ParseUUIDSetFunction · 0.70

Calls

no outgoing calls

Tested by 1

TestMysqlGTIDIntervalMethod · 0.56