• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tarantool / go-tarantool / 5403553164

28 Jun 2023 04:41PM UTC coverage: 79.52% (+0.2%) from 79.335%
5403553164

push

github

oleg-jukovec
ci: enable more linters

- forbidigo
- gocritic
- lll
- reassign
- stylecheck
- unconvert

356 of 356 new or added lines in 15 files covered. (100.0%)

5296 of 6660 relevant lines covered (79.52%)

7621.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.33
/smallbuf.go
1
package tarantool
2

3
import (
4
        "errors"
5
        "io"
6
)
7

8
type smallBuf struct {
9
        b []byte
10
        p int
11
}
12

13
func (s *smallBuf) Read(d []byte) (l int, err error) {
669,236✔
14
        l = len(s.b) - s.p
669,236✔
15
        if l == 0 && len(d) > 0 {
669,236✔
16
                return 0, io.EOF
×
17
        }
×
18
        if l > len(d) {
1,335,748✔
19
                l = len(d)
666,512✔
20
        }
666,512✔
21
        copy(d, s.b[s.p:])
669,236✔
22
        s.p += l
669,236✔
23
        return l, nil
669,236✔
24
}
25

26
func (s *smallBuf) ReadByte() (b byte, err error) {
1,411,052✔
27
        if s.p == len(s.b) {
1,411,052✔
28
                return 0, io.EOF
×
29
        }
×
30
        b = s.b[s.p]
1,411,052✔
31
        s.p++
1,411,052✔
32
        return b, nil
1,411,052✔
33
}
34

35
func (s *smallBuf) UnreadByte() error {
238,207✔
36
        if s.p == 0 {
238,207✔
37
                return errors.New("could not unread")
×
38
        }
×
39
        s.p--
238,207✔
40
        return nil
238,207✔
41
}
42

43
func (s *smallBuf) Len() int {
4,967✔
44
        return len(s.b) - s.p
4,967✔
45
}
4,967✔
46

47
func (s *smallBuf) Bytes() []byte {
×
48
        if len(s.b) > s.p {
×
49
                return s.b[s.p:]
×
50
        }
×
51
        return nil
×
52
}
53

54
func (s *smallBuf) Offset() int {
2,782✔
55
        return s.p
2,782✔
56
}
2,782✔
57

58
func (s *smallBuf) Seek(offset int) error {
2,782✔
59
        if offset < 0 {
2,782✔
60
                return errors.New("too small offset")
×
61
        }
×
62
        if offset > len(s.b) {
2,782✔
63
                return errors.New("too big offset")
×
64
        }
×
65
        s.p = offset
2,782✔
66
        return nil
2,782✔
67
}
68

69
type smallWBuf struct {
70
        b   []byte
71
        sum uint
72
        n   uint
73
}
74

75
func (s *smallWBuf) Write(b []byte) (int, error) {
17,668✔
76
        s.b = append(s.b, b...)
17,668✔
77
        return len(s.b), nil
17,668✔
78
}
17,668✔
79

80
func (s *smallWBuf) WriteByte(b byte) error {
28,827✔
81
        s.b = append(s.b, b)
28,827✔
82
        return nil
28,827✔
83
}
28,827✔
84

85
func (s *smallWBuf) WriteString(ss string) (int, error) {
×
86
        s.b = append(s.b, ss...)
×
87
        return len(ss), nil
×
88
}
×
89

90
func (s smallWBuf) Len() int {
20,519✔
91
        return len(s.b)
20,519✔
92
}
20,519✔
93

94
func (s smallWBuf) Cap() int {
3,611✔
95
        return cap(s.b)
3,611✔
96
}
3,611✔
97

98
func (s *smallWBuf) Trunc(n int) {
×
99
        s.b = s.b[:n]
×
100
}
×
101

102
func (s *smallWBuf) Reset() {
14,015✔
103
        s.sum = uint(uint64(s.sum)*15/16) + uint(len(s.b))
14,015✔
104
        if s.n < 16 {
27,966✔
105
                s.n++
13,951✔
106
        }
13,951✔
107
        if cap(s.b) > 1024 && s.sum/s.n < uint(cap(s.b))/4 {
14,015✔
108
                s.b = make([]byte, 0, s.sum/s.n)
×
109
        } else {
14,015✔
110
                s.b = s.b[:0]
14,015✔
111
        }
14,015✔
112
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc