code: func NewSocket(id int) (*Socket, error) {
  	var err error
  	// Create RAW HCI Socket.
  	fd, err := unix.Socket(unix.AF_BLUETOOTH, unix.SOCK_RAW, unix.BTPROTO_HCI)
  	if err != nil {
  		return nil, errors.Wrap(err, "can't create socket")
  	}
  
  	if id != -1 {
  		return open(fd, id)
  	}
  
  	req := devListRequest{devNum: hciMaxDevices}
  	if err = ioctl(uintptr(fd), hciGetDeviceList, uintptr(unsafe.Pointer(&req))); err != nil {
  		return nil, errors.Wrap(err, "can't get device list")
  	}
  	var msg string
  	for id := 0; id < int(req.devNum); id++ {
  		s, err := open(fd, id)
  		if err == nil {
  			return s, nil
  		}
  		msg = msg + fmt.Sprintf("(hci%d: %s)", id, err)
  	}
  	return nil, errors.Errorf("no devices available: %s", msg)
  }
docs: // NewSocket returns a HCI User Channel of specified device id.
  // If id is -1, the first available HCI device is returned.