Fix Go format
This commit is contained in:
parent
14e763c65a
commit
256f79a099
32
main.go
32
main.go
|
@ -1,9 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"unsafe"
|
||||
"fmt"
|
||||
"sync"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -18,28 +18,30 @@ import "C"
|
|||
|
||||
//export callOnMeGo
|
||||
func callOnMeGo(n int) {
|
||||
printerCallback(n)
|
||||
printerCallback(n)
|
||||
}
|
||||
|
||||
type Printer func(int)
|
||||
|
||||
var printerCallback Printer
|
||||
var printerCallbackLock sync.RWMutex
|
||||
var (
|
||||
printerCallback Printer
|
||||
printerCallbackLock sync.RWMutex
|
||||
)
|
||||
|
||||
func usePrinter(p Printer) {
|
||||
printerCallbackLock.Lock()
|
||||
printerCallback = p
|
||||
C.use_printer((C.printer_t)(unsafe.Pointer(C.callOnMeGo_cgo)))
|
||||
printerCallback = nil
|
||||
printerCallbackLock.Unlock()
|
||||
printerCallbackLock.Lock()
|
||||
printerCallback = p
|
||||
C.use_printer((C.printer_t)(unsafe.Pointer(C.callOnMeGo_cgo)))
|
||||
printerCallback = nil
|
||||
printerCallbackLock.Unlock()
|
||||
}
|
||||
|
||||
var myPrinter Printer = Printer(func(n int) {
|
||||
for i := 0; i < n; i++ {
|
||||
fmt.Printf("%d\n", i)
|
||||
}
|
||||
for i := 0; i < n; i++ {
|
||||
fmt.Printf("%d\n", i)
|
||||
}
|
||||
})
|
||||
|
||||
func main() {
|
||||
usePrinter(myPrinter)
|
||||
usePrinter(myPrinter)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue