Fixed unchecked array access

This commit is contained in:
Cristian Maglie
2015-01-01 17:46:14 +01:00
parent 4b12c041b5
commit 9c18e832ce

View File

@@ -10,6 +10,7 @@ package serial // import "go.bug.st/serial"
import "io/ioutil" import "io/ioutil"
import "regexp" import "regexp"
import "strings"
import "syscall" import "syscall"
import "unsafe" import "unsafe"
@@ -116,7 +117,7 @@ func GetPortsList() ([]string, error) {
portName := devFolder + "/" + f.Name() portName := devFolder + "/" + f.Name()
// Check if serial port is real or is a placeholder serial port "ttySxx" // Check if serial port is real or is a placeholder serial port "ttySxx"
if f.Name()[:4] == "ttyS" { if strings.HasPrefix(f.Name(), "ttyS") {
port, err := OpenPort(portName, &Mode{}) port, err := OpenPort(portName, &Mode{})
if err != nil { if err != nil {
serr, ok := err.(*SerialPortError) serr, ok := err.(*SerialPortError)