https://github.com/vikpe/udphelper
UDP test helper for Go.
https://github.com/vikpe/udphelper
go testing udp
Last synced: about 1 month ago
JSON representation
UDP test helper for Go.
- Host: GitHub
- URL: https://github.com/vikpe/udphelper
- Owner: vikpe
- License: mit
- Created: 2022-05-08T17:08:57.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-04-26T07:58:37.000Z (about 3 years ago)
- Last Synced: 2026-01-14T23:20:43.810Z (6 months ago)
- Topics: go, testing, udp
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# udphelper [](https://pkg.go.dev/github.com/vikpe/udphelper) [](https://github.com/vikpe/udphelper/actions/workflows/test.yml) [](https://codecov.io/gh/vikpe/udphelper) [](https://goreportcard.com/report/github.com/vikpe/udphelper)
> UDP test helper for Go
## Usage
### Listen
Listen to given address without responding to requests.
```go
udphelper.New(":8000").Listen()
```
### Echo requests
Respond to requests with `ok:` prepended to the request packet.
```go
udphelper.New(":8000").Echo()
```
### Respond
Respond to any request with given response(s).
**Single**
```go
response := []byte("pong")
udphelper.New(":8000").Respond(response)
```
**Multiple**
```go
response1 := []byte("pong1")
response2 := []byte("pong2")
udphelper.New(":8000").Respond(response1, response2)
```