lint fixes

This commit is contained in:
onyx-and-iris 2025-03-10 15:32:10 +00:00
parent 7d93ecb1c7
commit 29e6c2e8aa
7 changed files with 19 additions and 15 deletions

View File

@ -1,3 +1,4 @@
// Package main provides the configuration loading functionality for the vbantxt application.
package main
import (

View File

@ -35,5 +35,4 @@ func TestLoadConfig_Errors(t *testing.T) {
assert.ErrorContains(t, err, tc.err)
})
}
}

View File

@ -1,3 +1,4 @@
// Package vbantxt provides utilities for handling VBAN text errors.
package vbantxt
// Error is used to define sentinel errors.

View File

@ -9,14 +9,14 @@ import (
// Option is a functional option type that allows us to configure the VbanTxt.
type Option func(*VbanTxt)
// WithRateLimit is a functional option to set the ratelimit for requests
// WithRateLimit is a functional option to set the ratelimit for requests.
func WithRateLimit(ratelimit time.Duration) Option {
return func(vt *VbanTxt) {
vt.ratelimit = ratelimit
}
}
// WithBPSOpt is a functional option to set the bps index for {VbanTxt}.packet
// WithBPSOpt is a functional option to set the bps index for {VbanTxt}.packet.
func WithBPSOpt(bps int) Option {
return func(vt *VbanTxt) {
bpsIndex := indexOf(BpsOpts, bps)
@ -28,7 +28,7 @@ func WithBPSOpt(bps int) Option {
}
}
// WithChannel is a functional option to set the channel for {VbanTxt}.packet
// WithChannel is a functional option to set the channel for {VbanTxt}.packet.
func WithChannel(channel int) Option {
return func(vt *VbanTxt) {
vt.packet.channel = channel

View File

@ -13,9 +13,12 @@ const (
headerSz = 4 + 1 + 1 + 1 + 1 + 16 + 4
)
var BpsOpts = []int{0, 110, 150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 31250,
// BpsOpts defines the available baud rate options.
var BpsOpts = []int{
0, 110, 150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 31250,
38400, 57600, 115200, 128000, 230400, 250000, 256000, 460800, 921600,
1000000, 1500000, 2000000, 3000000}
1000000, 1500000, 2000000, 3000000,
}
type packet struct {
streamname []byte
@ -39,17 +42,17 @@ func newPacket(streamname string) packet {
}
}
// sr defines the samplerate for the request
// sr defines the samplerate for the request.
func (p *packet) sr() byte {
return byte(vbanProtocolTxt + p.bpsIndex)
}
// nbc defines the channel of the request
// nbc defines the channel of the request.
func (p *packet) nbc() byte {
return byte(p.channel)
}
// header returns a fully formed packet header
// header returns a fully formed packet header.
func (p *packet) header() []byte {
p.hbuf.Reset()
p.hbuf.WriteString("VBAN")
@ -62,7 +65,7 @@ func (p *packet) header() []byte {
return p.hbuf.Bytes()
}
// bumpFrameCounter increments the frame counter by 1
// bumpFrameCounter increments the frame counter by 1.
func (p *packet) bumpFrameCounter() {
x := binary.LittleEndian.Uint32(p.framecounter)
binary.LittleEndian.PutUint32(p.framecounter, x+1)

View File

@ -7,12 +7,12 @@ import (
log "github.com/sirupsen/logrus"
)
// udpConn represents the UDP client
// udpConn represents the UDP client.
type udpConn struct {
conn *net.UDPConn
}
// newUDPConn returns a UDP client
// newUDPConn returns a UDP client.
func newUDPConn(host string, port int) (udpConn, error) {
udpAddr, err := net.ResolveUDPAddr("udp4", fmt.Sprintf("%s:%d", host, port))
if err != nil {
@ -27,7 +27,7 @@ func newUDPConn(host string, port int) (udpConn, error) {
return udpConn{conn: conn}, nil
}
// Write implements the io.WriteCloser interface
// Write implements the io.WriteCloser interface.
func (u udpConn) Write(buf []byte) (int, error) {
n, err := u.conn.Write(buf)
if err != nil {
@ -38,7 +38,7 @@ func (u udpConn) Write(buf []byte) (int, error) {
return n, nil
}
// Close implements the io.WriteCloser interface
// Close implements the io.WriteCloser interface.
func (u udpConn) Close() error {
err := u.conn.Close()
if err != nil {

View File

@ -49,7 +49,7 @@ func (vt VbanTxt) Send(cmd string) error {
return nil
}
// Close is responsible for closing the UDP Client connection
// Close is responsible for closing the UDP Client connection.
func (vt VbanTxt) Close() error {
err := vt.udpConn.Close()
if err != nil {