More linting fun

This commit is contained in:
Asim 2016-04-06 18:03:27 +01:00
parent 2f50c74f41
commit bfe20d81d0
12 changed files with 33 additions and 38 deletions

View File

@ -11,7 +11,7 @@ func TestBroker(t *testing.T) {
b := NewBroker()
if err := b.Connect(); err != nil {
t.Fatal("Unexpected connect error %v", err)
t.Fatalf("Unexpected connect error %v", err)
}
topic := "test"

View File

@ -42,7 +42,6 @@ func (j *jsonCodec) Write(m *codec.Message, b interface{}) error {
default:
return fmt.Errorf("Unrecognised message type: %v", m.Type)
}
return nil
}
func (j *jsonCodec) ReadHeader(m *codec.Message, mt codec.MessageType) error {

View File

@ -19,29 +19,29 @@ func TestErrors(t *testing.T) {
ne := New(e.Id, e.Detail, e.Code)
if e.Error() != ne.Error() {
t.Fatal("Expected %s got %s", e.Error(), ne.Error())
t.Fatalf("Expected %s got %s", e.Error(), ne.Error())
}
pe := Parse(ne.Error())
if pe == nil {
t.Fatal("Expected error got nil %v", pe)
t.Fatalf("Expected error got nil %v", pe)
}
if pe.Id != e.Id {
t.Fatal("Expected %s got %s", e.Id, pe.Id)
t.Fatalf("Expected %s got %s", e.Id, pe.Id)
}
if pe.Detail != e.Detail {
t.Fatal("Expected %s got %s", e.Detail, pe.Detail)
t.Fatalf("Expected %s got %s", e.Detail, pe.Detail)
}
if pe.Code != e.Code {
t.Fatal("Expected %s got %s", e.Code, pe.Code)
t.Fatalf("Expected %s got %s", e.Code, pe.Code)
}
if pe.Status != e.Status {
t.Fatal("Expected %s got %s", e.Status, pe.Status)
t.Fatalf("Expected %s got %s", e.Status, pe.Status)
}
}
}

View File

@ -45,7 +45,6 @@ func (e *Example) PingPong(ctx context.Context, stream example.Example_PingPongS
return err
}
}
return nil
}
func main() {

View File

@ -55,5 +55,4 @@ func (e *Example) PingPong(ctx context.Context, stream server.Streamer) error {
return err
}
}
return nil
}

View File

@ -58,7 +58,7 @@ func TestEncodingEndpoints(t *testing.T) {
// check there are two tags; old and new
if len(e) != 2 {
t.Fatal("Expected 2 encoded tags, got %v", e)
t.Fatalf("Expected 2 encoded tags, got %v", e)
}
// check old encoding
@ -72,7 +72,7 @@ func TestEncodingEndpoints(t *testing.T) {
}
if !seen {
t.Fatal("Expected %s but not found", enc)
t.Fatalf("Expected %s but not found", enc)
}
// decode
@ -133,29 +133,29 @@ func TestEncodingVersion(t *testing.T) {
d, ok := decodeVersion(e)
if !ok {
t.Fatal("Unexpected %t for %s", ok, data.encoded)
t.Fatalf("Unexpected %t for %s", ok, data.encoded)
}
if d != data.decoded {
t.Fatal("Expected %s got %s", data.decoded, d)
t.Fatalf("Expected %s got %s", data.decoded, d)
}
d, ok = decodeVersion([]string{data.encoded})
if !ok {
t.Fatal("Unexpected %t for %s", ok, data.encoded)
t.Fatalf("Unexpected %t for %s", ok, data.encoded)
}
if d != data.decoded {
t.Fatal("Expected %s got %s", data.decoded, d)
t.Fatalf("Expected %s got %s", data.decoded, d)
}
d, ok = decodeVersion([]string{data.oldEncoded})
if !ok {
t.Fatal("Unexpected %t for %s", ok, data.oldEncoded)
t.Fatalf("Unexpected %t for %s", ok, data.oldEncoded)
}
if d != data.decoded {
t.Fatal("Expected %s got %s", data.decoded, d)
t.Fatalf("Expected %s got %s", data.decoded, d)
}
}
}

View File

@ -293,7 +293,6 @@ func (s *service) call(ctx context.Context, server *server, sending *sync.Mutex,
// no error, we send the special EOS error
return lastStreamResponseError
}
return nil
}
for i := len(server.hdlrWrappers); i > 0; i-- {

View File

@ -94,12 +94,12 @@ var (
DefaultServer Server = newRpcServer()
)
// Returns config options for the default service
// DefaultOptions returns config options for the default service
func DefaultOptions() Options {
return DefaultServer.Options()
}
// Initialises the default server with options passed in
// Init initialises the default server with options passed in
func Init(opt ...Option) {
if DefaultServer == nil {
DefaultServer = newRpcServer(opt...)
@ -107,18 +107,18 @@ func Init(opt ...Option) {
DefaultServer.Init(opt...)
}
// Returns a new server with options passed in
// NewServer returns a new server with options passed in
func NewServer(opt ...Option) Server {
return newRpcServer(opt...)
}
// Creates a new subscriber interface with the given topic
// NewSubscriber creates a new subscriber interface with the given topic
// and handler using the default server
func NewSubscriber(topic string, h interface{}, opts ...SubscriberOption) Subscriber {
return DefaultServer.NewSubscriber(topic, h, opts...)
}
// Creates a new handler interface using the default server
// NewHandler creates a new handler interface using the default server
// Handlers are required to be a public object with public
// methods. Call to a service method such as Foo.Bar expects
// the type:
@ -132,29 +132,29 @@ func NewHandler(h interface{}, opts ...HandlerOption) Handler {
return DefaultServer.NewHandler(h, opts...)
}
// Registers a handler interface with the default server to
// Handle registers a handler interface with the default server to
// handle inbound requests
func Handle(h Handler) error {
return DefaultServer.Handle(h)
}
// Registers a subscriber interface with the default server
// Subscribe registers a subscriber interface with the default server
// which subscribes to specified topic with the broker
func Subscribe(s Subscriber) error {
return DefaultServer.Subscribe(s)
}
// Registers the default server with the discovery system
// Register registers the default server with the discovery system
func Register() error {
return DefaultServer.Register()
}
// Deregisters the default server from the discovery system
// Deregister deregisters the default server from the discovery system
func Deregister() error {
return DefaultServer.Deregister()
}
// Blocking run starts the default server and waits for a kill
// Run starts the default server and waits for a kill
// signal before exiting. Also registers/deregisters the server
func Run() error {
if err := Start(); err != nil {
@ -176,19 +176,20 @@ func Run() error {
return Stop()
}
// Starts the default server
// Start starts the default server
func Start() error {
config := DefaultServer.Options()
log.Printf("Starting server %s id %s", config.Name, config.Id)
return DefaultServer.Start()
}
// Stops the default server
// Stop stops the default server
func Stop() error {
log.Printf("Stopping server")
return DefaultServer.Stop()
}
// String returns name of Server implementation
func String() string {
return DefaultServer.String()
}

View File

@ -122,8 +122,7 @@ func validateSubscriber(sub Subscriber) error {
return fmt.Errorf("subscriber %v argument type not exported: %v", name, argType)
}
if typ.NumOut() != 1 {
return fmt.Errorf(
"subscriber %v.%v has wrong number of outs: %v require signature %s",
return fmt.Errorf("subscriber %v has wrong number of outs: %v require signature %s",
name, typ.NumOut(), subSig)
}
if returnType := typ.Out(0); returnType != typeOfError {

View File

@ -312,6 +312,7 @@ func (h *httpTransportListener) Close() error {
func (h *httpTransportListener) Accept(fn func(Socket)) error {
var tempDelay time.Duration
for {
c, err := h.listener.Accept()
if err != nil {
@ -348,7 +349,6 @@ func (h *httpTransportListener) Accept(fn func(Socket)) error {
fn(sock)
}()
}
return nil
}
func (h *httpTransport) Dial(addr string, opts ...DialOption) (Client, error) {
@ -436,7 +436,7 @@ func (h *httpTransport) String() string {
return "http"
}
func newHttpTransport(opts ...Option) *httpTransport {
func newHTTPTransport(opts ...Option) *httpTransport {
var options Options
for _, o := range opts {
o(&options)

View File

@ -86,7 +86,6 @@ func (m *mockListener) Accept(fn func(transport.Socket)) error {
})
}
}
return nil
}
func (m *mockTransport) Dial(addr string, opts ...transport.DialOption) (transport.Client, error) {

View File

@ -43,13 +43,13 @@ type DialOption func(*DialOptions)
type ListenOption func(*ListenOptions)
var (
DefaultTransport Transport = newHttpTransport()
DefaultTransport Transport = newHTTPTransport()
DefaultDialTimeout = time.Second * 5
)
func NewTransport(opts ...Option) Transport {
return newHttpTransport(opts...)
return newHTTPTransport(opts...)
}
func Dial(addr string, opts ...DialOption) (Client, error) {