diff --git a/arduino/commander.go b/arduino/commander.go index be04254a..cde050b5 100644 --- a/arduino/commander.go +++ b/arduino/commander.go @@ -22,7 +22,7 @@ import ( ) // Commander of arduino package allows to call -// the arduino-cli commands in a programmatic way +// the arduino-cli commands in a programmatic way. type Commander interface { BoardList() ([]*rpc.DetectedPort, error) UploadBin(fqbn, bin, port string) error diff --git a/arduino/dir.go b/arduino/dir.go index 923c8f07..1418af21 100644 --- a/arduino/dir.go +++ b/arduino/dir.go @@ -27,7 +27,7 @@ import ( "github.com/arduino/go-win32-utils" ) -// DataDir returns the Arduino default data directory (arduino15) +// DataDir returns the Arduino default data directory (arduino15). func DataDir() (*paths.Path, error) { userHomeDir, err := os.UserHomeDir() if err != nil { diff --git a/arduino/grpc/client.go b/arduino/grpc/client.go index 58aac7fe..f8f3d115 100644 --- a/arduino/grpc/client.go +++ b/arduino/grpc/client.go @@ -43,7 +43,7 @@ type client struct { // NewClient instantiates and returns a new grpc client that allows to // programmatically call arduino-cli commands. // It exploits the grpc interface of the arduino-cli. -// It returns: the client instance, a callback to close the client and an error +// It returns: the client instance, a callback to close the client and an error. func NewClient() (arduino.Commander, func() error, error) { // Establish a connection with the gRPC server, started with the command: // arduino-cli daemon diff --git a/cli/version/version.go b/cli/version/version.go index a36ca717..7b9007fd 100644 --- a/cli/version/version.go +++ b/cli/version/version.go @@ -25,7 +25,7 @@ import ( "github.com/spf13/cobra" ) -// NewCommand created a new `version` command +// NewCommand creates a new `version` command. func NewCommand() *cobra.Command { return &cobra.Command{ Use: "version", diff --git a/command/dashboard/create.go b/command/dashboard/create.go index d92c5949..f26e350c 100644 --- a/command/dashboard/create.go +++ b/command/dashboard/create.go @@ -32,7 +32,7 @@ type CreateParams struct { Template string // Path of the template file } -// Create allows to create a new dashboard +// Create allows to create a new dashboard. func Create(params *CreateParams) (*DashboardInfo, error) { conf, err := config.Retrieve() if err != nil { diff --git a/command/device/board.go b/command/device/board.go index f0eaf527..e616a16b 100644 --- a/command/device/board.go +++ b/command/device/board.go @@ -39,7 +39,7 @@ var ( } ) -// board contains details of a physical arduino board +// board contains details of a physical arduino board. type board struct { fqbn string serial string @@ -48,7 +48,7 @@ type board struct { } // isCrypto checks if the board is a valid arduino board with a -// supported crypto-chip +// supported crypto-chip. func (b *board) isCrypto() bool { for _, f := range cryptoFQBN { if b.fqbn == f { @@ -58,7 +58,7 @@ func (b *board) isCrypto() bool { return false } -// isCrypto checks if the board is a valid LoRa arduino board +// isLora checks if the board is a valid LoRa arduino board. func (b *board) isLora() bool { for _, f := range loraFQBN { if b.fqbn == f { @@ -94,8 +94,8 @@ func boardFromPorts(ports []*rpc.DetectedPort, params *CreateParams) *board { // - if the port parameter does not match the actual port address. // - if the the detected port does not contain any board. // It returns: -// true -> to skip the port -// false -> to keep the port +// true -> to skip the port. +// false -> to keep the port. func portFilter(port *rpc.DetectedPort, params *CreateParams) bool { if len(port.Boards) == 0 { return true diff --git a/command/device/createlora.go b/command/device/createlora.go index 58e34590..78d5e37e 100644 --- a/command/device/createlora.go +++ b/command/device/createlora.go @@ -40,7 +40,7 @@ const ( serialEUIBaudrate = 9600 // dev-eui is an IEEE EUI64 address, so it must have length of 8 bytes. - // It's retrieved as hexadecimal string, thus 16 chars are expected + // It's retrieved as hexadecimal string, thus 16 chars are expected. deveuiLength = 16 ) diff --git a/command/device/provision.go b/command/device/provision.go index 0cba536f..fd167130 100644 --- a/command/device/provision.go +++ b/command/device/provision.go @@ -64,7 +64,7 @@ func downloadProvisioningFile(fqbn string) (string, error) { } // provision is responsible for running the provisioning -// procedures for boards with crypto-chip +// procedures for boards with crypto-chip. type provision struct { arduino.Commander iot.Client @@ -73,7 +73,7 @@ type provision struct { id string } -// run provisioning procedure for boards with crypto-chip +// run provisioning procedure for boards with crypto-chip. func (p provision) run() error { bin, err := downloadProvisioningFile(p.board.fqbn) if err != nil { diff --git a/command/ota/massupload.go b/command/ota/massupload.go index 85e2d539..9410d4d9 100644 --- a/command/ota/massupload.go +++ b/command/ota/massupload.go @@ -43,7 +43,7 @@ type MassUploadParams struct { FQBN string } -// Result of an ota upload on a device +// Result of an ota upload on a device. type Result struct { ID string Err error diff --git a/command/tag/create.go b/command/tag/create.go index a0970906..fe237069 100644 --- a/command/tag/create.go +++ b/command/tag/create.go @@ -33,7 +33,7 @@ type CreateTagsParams struct { } // CreateTags allows to create or overwrite tags -// on a resource of Arduino IoT Cloud +// on a resource of Arduino IoT Cloud. func CreateTags(params *CreateTagsParams) error { conf, err := config.Retrieve() if err != nil { diff --git a/command/tag/tag.go b/command/tag/tag.go index 319bb6b1..56c7d2e3 100644 --- a/command/tag/tag.go +++ b/command/tag/tag.go @@ -19,8 +19,8 @@ package tag import "fmt" -// TagsInfo transforms tags into user-readable strings -// An error is returned if a tag value is not a string +// TagsInfo transforms tags into user-readable strings. +// An error is returned if a tag value is not a string. func TagsInfo(tags map[string]interface{}) ([]string, error) { var str []string for key, value := range tags { diff --git a/command/thing/clone.go b/command/thing/clone.go index ffc0ce64..0a9f6600 100644 --- a/command/thing/clone.go +++ b/command/thing/clone.go @@ -31,7 +31,7 @@ type CloneParams struct { CloneID string // ID of thing to be cloned } -// Clone allows to create a new thing from an already existing one +// Clone allows to create a new thing from an already existing one. func Clone(params *CloneParams) (*ThingInfo, error) { conf, err := config.Retrieve() if err != nil { diff --git a/command/thing/create.go b/command/thing/create.go index a9572146..f95eb1a0 100644 --- a/command/thing/create.go +++ b/command/thing/create.go @@ -32,7 +32,7 @@ type CreateParams struct { Template string // Path of the template file } -// Create allows to create a new thing +// Create allows to create a new thing. func Create(params *CreateParams) (*ThingInfo, error) { conf, err := config.Retrieve() if err != nil { diff --git a/internal/binary/download.go b/internal/binary/download.go index 714d092e..44cc28c1 100644 --- a/internal/binary/download.go +++ b/internal/binary/download.go @@ -28,7 +28,7 @@ import ( fwuploader "github.com/arduino/arduino-fwuploader/indexes/download" ) -// Download a binary file contained in the binary index +// Download a binary file contained in the binary index. func Download(bin *IndexBin) ([]byte, error) { b, err := download(bin.URL) if err != nil { diff --git a/internal/binary/index.go b/internal/binary/index.go index ef67b795..5a08d257 100644 --- a/internal/binary/index.go +++ b/internal/binary/index.go @@ -30,24 +30,24 @@ import ( ) const ( - // URL of cloud-team binary index + // URL of cloud-team binary index. IndexGZURL = "https://cloud-downloads.arduino.cc/binaries/index.json.gz" IndexSigURL = "https://cloud-downloads.arduino.cc/binaries/index.json.sig" ) // Index contains details about all the binaries -// loaded in 'cloud-downloads' +// loaded in 'cloud-downloads'. type Index struct { Boards []IndexBoard `json:"boards"` } -// IndexBoard describes all the binaries available for a specific board +// IndexBoard describes all the binaries available for a specific board. type IndexBoard struct { Fqbn string `json:"fqbn"` Provision *IndexBin `json:"provision"` } -// IndexBin contains the details needed to retrieve a binary file from the cloud +// IndexBin contains the details needed to retrieve a binary file from the cloud. type IndexBin struct { URL string `json:"url"` Checksum string `json:"checksum"` @@ -95,7 +95,7 @@ func LoadIndex() (*Index, error) { // FindProvisionBin looks for the provisioning binary corresponding // to the passed fqbn in the index. -// Returns nil if the binary is not found +// Returns nil if the binary is not found. func (i *Index) FindProvisionBin(fqbn string) *IndexBin { for _, b := range i.Boards { if b.Fqbn == fqbn { diff --git a/internal/config/config.go b/internal/config/config.go index 00730198..1d8f212f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -26,7 +26,7 @@ import ( ) // Config contains all the configuration parameters -// known by arduino-cloud-cli +// known by arduino-cloud-cli. type Config struct { Client string `map-structure:"client"` // Client ID of the user Secret string `map-structure:"secret"` // Secret ID of the user, unique for each Client ID @@ -78,7 +78,7 @@ func searchConfigDir() (string, error) { } return "", fmt.Errorf( - "didn't find config file in the current directory, its parents or in %s.", + "didn't find config file in the current directory, its parents or in %s", arduino15.String(), ) } diff --git a/internal/config/default.go b/internal/config/default.go index b4cf24c4..ee0698a3 100644 --- a/internal/config/default.go +++ b/internal/config/default.go @@ -23,7 +23,7 @@ var ( Filename = "arduino-cloud" ) -// SetDefaults sets the default values for configuration keys +// SetDefaults sets the default values for configuration keys. func SetDefaults(settings *viper.Viper) { // Client ID settings.SetDefault("client", "xxxxxxxxxxxxxx") diff --git a/internal/serial/protocol.go b/internal/serial/protocol.go index f7b284fb..d4a95497 100644 --- a/internal/serial/protocol.go +++ b/internal/serial/protocol.go @@ -18,24 +18,24 @@ package serial var ( - // msgStart is the initial byte sequence of every packet + // msgStart is the initial byte sequence of every packet. msgStart = [2]byte{0x55, 0xAA} - // msgEnd is the final byte sequence of every packet + // msgEnd is the final byte sequence of every packet. msgEnd = [2]byte{0xAA, 0x55} ) const ( - // Position of payload field + // payloadField indicates the position of payload field. payloadField = 5 - // Position of payload length field + // payloadLenField indicates the position of payload length field. payloadLenField = 3 - // Length of payload length field + // payloadLenFieldLen indicatest the length of payload length field. payloadLenFieldLen = 2 - // Length of the signature field + // crcFieldLen indicates the length of the signature field. crcFieldLen = 2 ) -// MsgType indicates the type of the packet +// MsgType indicates the type of the packet. type MsgType byte const ( diff --git a/internal/serial/serial.go b/internal/serial/serial.go index d6c9e7d3..5d3b7dbb 100644 --- a/internal/serial/serial.go +++ b/internal/serial/serial.go @@ -147,7 +147,7 @@ func (s *Serial) receive() ([]byte, error) { return payload, nil } -// encode is internally used to create a valid provisioning packet +// encode is internally used to create a valid provisioning packet. func encode(mType MsgType, msg []byte) []byte { // Insert the preamble sequence followed by the message type packet := append(msgStart[:], byte(mType))