Fix Go format

This commit is contained in:
Victor Timofei 2022-07-29 21:54:01 +03:00
parent 14e763c65a
commit 256f79a099
Signed by: vtimofei
GPG Key ID: B790DCEBE281403A
1 changed files with 17 additions and 15 deletions

32
main.go
View File

@ -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)
}