Skip to content

Commit be703da

Browse files
Make golint happy
1 parent c9a9be3 commit be703da

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

class.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package slowlog
77

88
const (
9+
// MAX_EXAMPLE_BYTES defines the maximum Example.Query size.
910
MAX_EXAMPLE_BYTES = 1024 * 10
1011
)
1112

event.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
package slowlog
77

8-
// An event is a query like "SELECT col FROM t WHERE id = 1", some metrics like
8+
// An Event is a query like "SELECT col FROM t WHERE id = 1", some metrics like
99
// Query_time (slow log) or SUM_TIMER_WAIT (Performance Schema), and other
1010
// metadata like default database, timestamp, etc. Metrics and metadata are not
1111
// guaranteed to be defined--and frequently they are not--but at minimum an

parser.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
Copyright 2014-2016 Percona LLC and/or its affiliates
44
*/
55

6-
// Package slow implements a MySQL slow log parser.
6+
// Package slowlog provides functions and data structures for working with the
7+
// MySQL slow log.
78
package slowlog
89

910
import (
@@ -19,8 +20,8 @@ import (
1920
)
2021

2122
var (
23+
// ErrStarted is returned if Parser.Start is called more than once.
2224
ErrStarted = errors.New("parser is started")
23-
ErrStopped = errors.New("parser is stopped")
2425
)
2526

2627
// Options encapsulate common options for making a new LogParser.
@@ -29,7 +30,10 @@ type Options struct {
2930
FilterAdminCommand map[string]bool // admin commands to ignore
3031
}
3132

32-
// A LogParser sends events to a channel.
33+
// A Parser parses events from a slow log. The canonical Parser is FileParser
34+
// because the slow log is a file. The caller receives events on the Events
35+
// channel. This channel is closed when there are no more events. Any error
36+
// during parsing is returned by Error.
3337
type Parser interface {
3438
Start(Options) error
3539
Events() <-chan Event
@@ -47,7 +51,8 @@ var adminRe = regexp.MustCompile(`command: (.+)`)
4751
var setRe = regexp.MustCompile(`^SET (?:last_insert_id|insert_id|timestamp)`)
4852
var useRe = regexp.MustCompile(`^(?i)use `)
4953

50-
// A FileParser parses a MySQL slow log.
54+
// FileParser represents a file-based Parser. This is the canonical Parser
55+
// because the slow log is a file.
5156
type FileParser struct {
5257
file *os.File
5358
// --
@@ -68,6 +73,7 @@ type FileParser struct {
6873
var Debug = false
6974

7075
// NewFileParser returns a new FileParser that reads from the open file.
76+
// The file is not closed.
7177
func NewFileParser(file *os.File) *FileParser {
7278
p := &FileParser{
7379
file: file,
@@ -97,9 +103,9 @@ func (p *FileParser) Stop() {
97103
return
98104
}
99105

100-
// Start starts the parser. Events are sent to the unbuffered event channel.
101-
// Parsing stops on EOF, error, or call to Stop. The event channel is closed
102-
// when parsing stops. The file is not closed.
106+
// Start starts the parser. Events are sent to the unbuffered Events channel.
107+
// Parsing stops on EOF, error, or call to Stop. The Events channel is closed
108+
// when parsing stops.
103109
func (p *FileParser) Start(opt Options) error {
104110
if p.started {
105111
return ErrStarted
@@ -122,10 +128,14 @@ func (p *FileParser) Start(opt Options) error {
122128
return nil
123129
}
124130

131+
// Events returns the channel to which events from the slow log are sent.
132+
// The channel is closed when there are no more events. Events are not sent
133+
// until Start is called.
125134
func (p *FileParser) Events() <-chan Event {
126135
return p.eventChan
127136
}
128137

138+
// Error returns an error, if any, encountered while parsing the slow log.
129139
func (p *FileParser) Error() error {
130140
return p.err
131141
}

0 commit comments

Comments
 (0)