Signed-off-by: Liam Stanley <me@liamstanley.io>
Этот коммит содержится в:
Liam Stanley 2022-03-21 16:27:51 -04:00
родитель b5af8a2128
Коммит 8487a7de15
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 16DB886FBE5ABAC2
8 изменённых файлов: 5 добавлений и 44 удалений

Просмотреть файл

@ -451,7 +451,7 @@ func handleNAMES(c *Client, e Event) {
var modes, nick string
var ok bool
s := &Source{}
var s *Source
c.state.Lock()
for i := 0; i < len(parts); i++ {

2
cap.go
Просмотреть файл

@ -106,7 +106,7 @@ func parseCap(raw string) map[string]map[string]string {
if j < 0 {
out[parts[i][:val]][option] = ""
} else {
out[parts[i][:val]][option[:j]] = option[j+1 : len(option)]
out[parts[i][:val]][option[:j]] = option[j+1:]
}
}
}

Просмотреть файл

@ -120,7 +120,6 @@ func handleSASL(c *Client, e Event) {
break
}
}
return
}
func handleSASLError(c *Client, e Event) {

Просмотреть файл

@ -43,8 +43,7 @@ type ircConn struct {
lastPing time.Time
// lastPong is the last successful time that we pinged the server and
// received a successful pong back.
lastPong time.Time
pingDelay time.Duration
lastPong time.Time
}
// Dialer is an interface implementation of net.Dialer. Use this if you would
@ -477,7 +476,7 @@ func (c *Client) write(event *Event) {
func (c *ircConn) rate(chars int) time.Duration {
_time := time.Second + ((time.Duration(chars) * time.Second) / 100)
if c.writeDelay += _time - time.Now().Sub(c.lastWrite); c.writeDelay < 0 {
if c.writeDelay += _time - time.Since(c.lastWrite); c.writeDelay < 0 {
c.writeDelay = 0
}

Просмотреть файл

@ -46,8 +46,6 @@ func TestDecode(t *testing.T) {
if err == nil {
t.Fatalf("should have failed to parse decoded event. got: %#v", event)
}
return
}
func TestEncode(t *testing.T) {
@ -70,8 +68,6 @@ func TestEncode(t *testing.T) {
if want != line {
t.Fatalf("encoded line wanted: %q, got: %q", want, line)
}
return
}
func TestRate(t *testing.T) {
@ -88,8 +84,6 @@ func TestRate(t *testing.T) {
if delay := c.rate(200); delay > (3 * time.Second) {
t.Fatal("rate delay too high")
}
return
}
func genMockConn() (client *Client, clientConn net.Conn, serverConn net.Conn) {

Просмотреть файл

@ -13,7 +13,7 @@ import (
const (
eventSpace byte = ' ' // Separator.
maxLength = 510 // Maximum length is 510 (2 for line endings).
maxLength int = 510 // Maximum length is 510 (2 for line endings).
)
// cutCRFunc is used to trim CR characters from prefixes/messages.
@ -636,6 +636,4 @@ func (s *Source) writeTo(buffer *bytes.Buffer) {
buffer.WriteByte(prefixHost)
buffer.WriteString(s.Host)
}
return
}

Просмотреть файл

@ -13,32 +13,24 @@ func BenchmarkFormat(b *testing.B) {
for i := 0; i < b.N; i++ {
Fmt("{red}test{c}")
}
return
}
func BenchmarkFormatLong(b *testing.B) {
for i := 0; i < b.N; i++ {
Fmt("{red}test {blue}2 {red}3 {brown} {italic}test{c}")
}
return
}
func BenchmarkStripFormat(b *testing.B) {
for i := 0; i < b.N; i++ {
TrimFmt("{red}test{c}")
}
return
}
func BenchmarkStripFormatLong(b *testing.B) {
for i := 0; i < b.N; i++ {
TrimFmt("{red}test {blue}2 {red}3 {brown} {italic}test{c}")
}
return
}
func BenchmarkStripRaw(b *testing.B) {
@ -46,8 +38,6 @@ func BenchmarkStripRaw(b *testing.B) {
for i := 0; i < b.N; i++ {
StripRaw(text)
}
return
}
func BenchmarkStripRawLong(b *testing.B) {
@ -55,8 +45,6 @@ func BenchmarkStripRawLong(b *testing.B) {
for i := 0; i < b.N; i++ {
StripRaw(text)
}
return
}
func TestFormat(t *testing.T) {
@ -249,8 +237,6 @@ func TestToRFC1459(t *testing.T) {
t.Errorf("ToRFC1459() = %q, want %q", got, tt.want)
}
}
return
}
func BenchmarkGlob(b *testing.B) {
@ -259,31 +245,23 @@ func BenchmarkGlob(b *testing.B) {
b.Fatalf("should match")
}
}
return
}
func testGlobMatch(t *testing.T, subj, pattern string) {
if !Glob(subj, pattern) {
t.Fatalf("'%s' should match '%s'", pattern, subj)
}
return
}
func testGlobNoMatch(t *testing.T, subj, pattern string) {
if Glob(subj, pattern) {
t.Fatalf("'%s' should not match '%s'", pattern, subj)
}
return
}
func TestEmptyPattern(t *testing.T) {
testGlobMatch(t, "", "")
testGlobNoMatch(t, "test", "")
return
}
func TestEmptySubject(t *testing.T) {
@ -324,14 +302,10 @@ func TestEmptySubject(t *testing.T) {
for _, pattern := range cases {
testGlobNoMatch(t, pattern, "")
}
return
}
func TestPatternWithoutGlobs(t *testing.T) {
testGlobMatch(t, "test", "test")
return
}
func TestGlob(t *testing.T) {
@ -368,6 +342,4 @@ func TestGlob(t *testing.T) {
for _, pattern := range cases {
testGlobNoMatch(t, "this is a test", pattern)
}
return
}

Просмотреть файл

@ -458,7 +458,6 @@ func recoverHandlerPanic(client *Client, event *Event, id string, skip int) {
}
client.Config.RecoverFunc(client, err)
return
}
// HandlerError is the error returned when a panic is intentionally recovered