Member-only story
Real-Time Trading App: Golang, Kafka, Websockets — Setting up Kafka in Golang (PART-2)
Configuring Kafka in a Golang environment and creating a build file for the producer.
This marks Part 2 of our real-time trade app series in Golang. In this installment, we’ll dive into coding for Kafka, focusing on establishing a connection and creating a producer build file. This step is crucial for testing the API connection to Binance’s web sockets. Stay tuned for hands-on coding and insights into optimizing the integration!
Establishing a connection with the data source.
As previously noted, we’ll utilize Binance’s WebSocket API as our data source. Within your app folder, create a trades subfolder and include the following files: listener.go, publish.go, and ticker.go.

Ticker.go
- Within ticker.go, you’ll find the model for the ticker data sourced from Binance. This model serves a dual purpose, as it will be employed for both receiving and publishing the data.
package trades
type Ticker struct {
Symbol string `json:"s"`
Price string `json:"p"`
Quantity string…