Skip to content

Commit bcb0408

Browse files
committed
Windows: added a check for \\.\ prefix
1 parent 5069d66 commit bcb0408

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

serial_windows.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package serial
1919

2020
import (
2121
"errors"
22+
"strings"
2223
"sync"
2324
"syscall"
2425
"time"
@@ -352,7 +353,9 @@ func createOverlappedEvent() (*windows.Overlapped, error) {
352353
}
353354

354355
func nativeOpen(portName string, mode *Mode) (*windowsPort, error) {
355-
portName = "\\\\.\\" + portName
356+
if !strings.HasPrefix(portName, `\\.\`) {
357+
portName = `\\.\` + portName
358+
}
356359
path, err := windows.UTF16PtrFromString(portName)
357360
if err != nil {
358361
return nil, err

0 commit comments

Comments
 (0)