24 lines
471 B
Go
24 lines
471 B
Go
package ncurses
|
|
|
|
import (
|
|
"github.com/ebitengine/purego"
|
|
)
|
|
|
|
var libc uintptr = 0
|
|
func libcFunction[T any](name string) T {
|
|
if libc == 0 {
|
|
var err error
|
|
libc, err = purego.Dlopen(LIBC_PATH, purego.RTLD_GLOBAL | purego.RTLD_NOW)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
var tmp = new(T)
|
|
purego.RegisterLibFunc(tmp, libc, name)
|
|
return *tmp
|
|
}
|
|
|
|
type setlocaleFP func(category int, locale string)
|
|
var SetLocale = libcFunction[setlocaleFP]("setlocale")
|