https://github.com/benzinga/go-bztcp
Benzinga TCP client library for Go.
https://github.com/benzinga/go-bztcp
Last synced: 12 months ago
JSON representation
Benzinga TCP client library for Go.
- Host: GitHub
- URL: https://github.com/benzinga/go-bztcp
- Owner: Benzinga
- Created: 2017-04-20T20:30:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-09-10T14:36:36.000Z (almost 5 years ago)
- Last Synced: 2025-05-17T13:03:23.870Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 15.6 KB
- Stars: 5
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go BzTCP
This project provides a pure-Go implementation of the Benzinga TCP protocol.
**Service Deprecated**
# Features
* Tested with Go 1.13+
* Reasonably performant.
* No external dependencies.
# Getting Started
To install the library and the example client, run the following:
```sh
go install github.com/Benzinga/go-bztcp/cmd/bztcp
```
To use the example client, use the new `bztcp` binary. By default, it will be installed to `$GOPATH/bin`. If this isn't on your `$PATH`/`%PATH%` you may need to invoke it by specifying the absolute path of the binary.
```sh
bztcp -v -user USER -key KEY
```
If all has gone well, you should begin seeing messages shortly, depending on the time of day.
This program makes use of the Go context library and thus requires Go 1.8. It would be relatively simple to backport this library to use an external implementation of context.
# Usage
The Go library exposes both high-level and low-level functionality for dealing with the Benzinga TCP protocol, but in particular you usually only need to be concerned with two functions: `Dial`, and `Conn.Stream`.
A quick example follows:
```go
package main
import (
"context"
"fmt"
"github.com/Benzinga/go-bztcp/bztcp"
)
func main() {
conn, err := bztcp.Dial("tcp-v1.benzinga.io:11337", "USER", "KEY")
if err != nil {
panic(err)
}
err = conn.Stream(context.Background(), func(stream bztcp.StreamData) {
fmt.Printf("%#v\n", stream)
})
if err != nil {
panic(err)
}
}
```