Skip to content

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iSchluff committed Dec 15, 2021
1 parent 51d68b6 commit 423bb89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions relay/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

var (
StreamAlreadyExists = errors.New("Stream already exists")
StreamNotExisting = errors.New("Stream does not exist")
ErrStreamAlreadyExists = errors.New("stream already exists")
ErrStreamNotExisting = errors.New("stream does not exist")
)

type RelayConfig struct {
Expand Down Expand Up @@ -50,13 +50,13 @@ func (s *RelayImpl) Publish(name string) (chan<- []byte, error) {
defer s.mutex.Unlock()

if _, exists := s.channels[name]; exists {
return nil, StreamAlreadyExists
return nil, ErrStreamAlreadyExists
}

channel := NewChannel(s.config.Buffersize)
s.channels[name] = channel

ch := make(chan []byte, 0)
ch := make(chan []byte)

// Setup publisher goroutine
go func() {
Expand Down Expand Up @@ -87,7 +87,7 @@ func (s *RelayImpl) Subscribe(name string) (<-chan []byte, UnsubscribeFunc, erro
defer s.mutex.Unlock()
channel, ok := s.channels[name]
if !ok {
return nil, nil, StreamNotExisting
return nil, nil, ErrStreamNotExisting
}
ch, unsub := channel.Sub()
return ch, unsub, nil
Expand Down
8 changes: 4 additions & 4 deletions relay/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func TestRelayImpl_DoublePublish(t *testing.T) {
relay.Publish("foo")
_, err := relay.Publish("foo")

if err != StreamAlreadyExists {
t.Errorf("Publish to existing stream should return '%s', got '%s'", StreamAlreadyExists, err)
if err != ErrStreamAlreadyExists {
t.Errorf("Publish to existing stream should return '%s', got '%s'", ErrStreamAlreadyExists, err)
}
}

Expand All @@ -85,7 +85,7 @@ func TestRelayImpl_SubscribeNonExisting(t *testing.T) {
relay := NewRelay(&config)

_, _, err := relay.Subscribe("foobar")
if err != StreamNotExisting {
t.Errorf("Subscribe to non-existing stream should return '%s', got '%s'", StreamNotExisting, err)
if err != ErrStreamNotExisting {
t.Errorf("Subscribe to non-existing stream should return '%s', got '%s'", ErrStreamNotExisting, err)
}
}

0 comments on commit 423bb89

Please sign in to comment.