Skip to content

Commit

Permalink
make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
umbynos committed Apr 9, 2024
1 parent efabea3 commit 992bb50
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
3 changes: 3 additions & 0 deletions args/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
// a commercial license, send an email to [email protected].
//

// Package args provides functionality to parse command-line arguments.
// It includes a function to parse arguments passed by the user and a variable to check if the version flag is set.
// The package also handles invalid arguments by printing an error message and exiting the program.
package args

import (
Expand Down
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// a commercial license, send an email to [email protected].
//

// Package main implements the serial discovery
package main

import (
Expand Down Expand Up @@ -48,6 +49,7 @@ type SerialDiscovery struct {
}

// Hello is the handler for the pluggable-discovery HELLO command
// revive:disable:unused-parameter
func (d *SerialDiscovery) Hello(userAgent string, protocolVersion int) error {
return nil
}
Expand All @@ -68,10 +70,10 @@ func (d *SerialDiscovery) Stop() error {

// StartSync is the handler for the pluggable-discovery START_SYNC command
func (d *SerialDiscovery) StartSync(eventCB discovery.EventCallback, errorCB discovery.ErrorCallback) error {
close, err := sync.Start(eventCB, errorCB)
done, err := sync.Start(eventCB, errorCB)
if err != nil {
return err
}
d.closeChan = close
d.closeChan = done
return nil
}
15 changes: 15 additions & 0 deletions sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
// a commercial license, send an email to [email protected].
//

// Package sync provides functions for synchronizing and processing updates
// related to serial port discovery.
//
// This package includes functions for comparing two lists of serial ports and
// sending 'add' and 'remove' events based on the differences between the lists.
// It also includes utility functions for converting port details to the discovery
// protocol format.
//
// The main function in this package is `processUpdates`, which takes in two lists
// of serial port details and an event callback function. It compares the two lists
// and sends 'add' and 'remove' events based on the differences. The `portListHas`
// function is used to check if a port is contained in a list, and the `toDiscoveryPort`
// function is used to convert port details to the discovery protocol format.
package sync

import (
Expand All @@ -23,6 +36,7 @@ import (
"go.bug.st/serial/enumerator"
)

// nolint
// processUpdates sends 'add' and 'remove' events by comparing two ports enumeration
// made at different times:
// - ports present in the new list but not in the old list are reported as 'added'
Expand All @@ -44,6 +58,7 @@ func processUpdates(old, new []*enumerator.PortDetails, eventCB discovery.EventC
}
}

// nolint
// portListHas checks if port is contained in list. The port metadata are
// compared in particular the port address, and vid/pid if the port is a usb port.
func portListHas(list []*enumerator.PortDetails, port *enumerator.PortDetails) bool {
Expand Down
5 changes: 4 additions & 1 deletion sync/sync_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ func Start(eventCB discovery.EventCallback, errorCB discovery.ErrorCallback) (ch
closeChan := make(chan bool)
go func() {
<-closeChan
syncReader.Close()
err := syncReader.Close()
if err != nil {
errorCB(fmt.Sprintf("Error closing sync reader: %s", err))
}
}()

// Run synchronous event emitter
Expand Down
6 changes: 6 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
// a commercial license, send an email to [email protected].
//

// Package version provides information about the version of the application.
// It includes the version string, commit hash, and timestamp.
// The package also defines a struct `Info` that represents the version information.
// The `newInfo` function creates a new `Info` instance with the provided application name.
// The `String` method of the `Info` struct returns a formatted string representation of the version information.
// The package also initializes the `Version` variable with a default version string if it is empty.
package version

import (
Expand Down

0 comments on commit 992bb50

Please sign in to comment.