update hook, Fixed #202 fatal error: concurrent map writes

This commit is contained in:
vcaesar 2019-03-15 14:00:17 -04:00
parent 9c57dfa17f
commit e71e8e9c3e
5 changed files with 12 additions and 4 deletions

2
go.mod
View File

@ -7,7 +7,7 @@ require (
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/lxn/win v0.0.0-20190226192825-50e22abd4ff9
github.com/otiai10/gosseract v2.2.1+incompatible
github.com/robotn/gohook v0.0.0-20190305192954-bbbbefb5ff85
github.com/robotn/gohook v0.0.0-20190315174547-bc414970f3d6
github.com/shirou/gopsutil v0.0.0-20190131151121-071446942108
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/vcaesar/imgo v0.0.0-20181209162409-13af122cf2fa

4
go.sum
View File

@ -14,8 +14,8 @@ github.com/lxn/win v0.0.0-20190226192825-50e22abd4ff9 h1:7noriXA0DUpF8QGGBsuGCRn
github.com/lxn/win v0.0.0-20190226192825-50e22abd4ff9/go.mod h1:jACzEp9RV7NhfPJQkiCNTteU4nkZZVlvkNpYtVOZPfE=
github.com/otiai10/gosseract v2.2.1+incompatible h1:Ry5ltVdpdp4LAa2bMjsSJH34XHVOV7XMi41HtzL8X2I=
github.com/otiai10/gosseract v2.2.1+incompatible/go.mod h1:XrzWItCzCpFRZ35n3YtVTgq5bLAhFIkascoRo8G32QE=
github.com/robotn/gohook v0.0.0-20190305192954-bbbbefb5ff85 h1:1PEPida55e7OPyWDRzJ/c2TbLpsvGjA0M6ib6aMru9w=
github.com/robotn/gohook v0.0.0-20190305192954-bbbbefb5ff85/go.mod h1:YD5RyCnUEY2xqtkkgeQVZ31UAfAnVPwUxpTE5cwSXg4=
github.com/robotn/gohook v0.0.0-20190315174547-bc414970f3d6 h1:XTKPqoPYwgasmAWhtpolldqBpnbpgH6iAtQPReXiywA=
github.com/robotn/gohook v0.0.0-20190315174547-bc414970f3d6/go.mod h1:YD5RyCnUEY2xqtkkgeQVZ31UAfAnVPwUxpTE5cwSXg4=
github.com/shirou/gopsutil v0.0.0-20190131151121-071446942108 h1:XXgDK65TPH+Qbo2sdYHldM5avclwThBXVYZHxroFkTQ=
github.com/shirou/gopsutil v0.0.0-20190131151121-071446942108/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAriGFsTZppLXDX93OM=

View File

@ -24,7 +24,9 @@ func go_send(s *C.char) {
}
if out.Keychar != CharUndefined {
lck.Lock()
raw2key[out.Rawcode] = string([]rune{out.Keychar})
lck.Unlock()
}
// todo bury this deep into the C lib so that the time is correct

View File

@ -26,6 +26,7 @@ import "C"
import (
"fmt"
"sync"
"time"
"unsafe"
)
@ -83,6 +84,8 @@ type Event struct {
var (
ev = make(chan Event, 1024)
asyncon = false
lck sync.RWMutex
)
// String return hook kind string
@ -136,6 +139,9 @@ func (e Event) String() string {
// RawcodetoKeychar rawcode to keychar
func RawcodetoKeychar(r uint16) string {
lck.RLock()
defer lck.RUnlock()
return raw2key[r]
}

2
vendor/modules.txt vendored
View File

@ -17,7 +17,7 @@ github.com/go-ole/go-ole/oleutil
github.com/lxn/win
# github.com/otiai10/gosseract v2.2.1+incompatible
github.com/otiai10/gosseract
# github.com/robotn/gohook v0.0.0-20190305192954-bbbbefb5ff85
# github.com/robotn/gohook v0.0.0-20190315174547-bc414970f3d6
github.com/robotn/gohook
# github.com/shirou/gopsutil v0.0.0-20190131151121-071446942108
github.com/shirou/gopsutil/process