func (c *Client) Publish(ctx context.Context, topic string, msg interface{}, isJSON bool) error {
	var b []byte
	var err error
	if isJSON {
		b, err = json.Marshal(msg)
	} else {
		b, err = proto.Marshal(msg.(proto.Message))
	}
	if err != nil {
		return err
	}
	m := &Msg{Data: b}
	mw := chainPublisherMiddleware(c.Middleware...)
	return mw(c.ServiceName, func(ctx context.Context, topic string, m *Msg) error {
		return c.Provider.Publish(ctx, topic, m)
	})(ctx, topic, m)
}
Publish published on the client
package pubsub
import (
	"context"
	"encoding/json"
	"sync"
	"github.com/golang/protobuf/proto"
)