Documentation
¶
Index ¶
- func BoolToInt(b bool) uintptr
- func CString(s string) []byte
- func Free(ptr uintptr)
- func IntToBool(i uintptr) bool
- func LoadLibrary(libalpmPath string) error
- func PtrToString(ptr uintptr) string
- func PtrToStringWithLen(ptr uintptr, length int) string
- func Syscall(fn uintptr, args ...uintptr) uintptr
- func SyscallWithError(fn uintptr, args ...uintptr) (uintptr, uintptr)
- type FunctionCaller
- type FunctionRegistry
- type MockFunctionRegistry
- func (m *MockFunctionRegistry) CallFunc(name string, args ...uintptr) (uintptr, error)
- func (m *MockFunctionRegistry) GetCallCount(name string) int
- func (m *MockFunctionRegistry) GetFunc(name string) (uintptr, error)
- func (m *MockFunctionRegistry) RegisterFunc(name string, ptr uintptr)
- func (m *MockFunctionRegistry) Reset()
- func (m *MockFunctionRegistry) SetCallError(name string, err error)
- func (m *MockFunctionRegistry) SetCallResult(name string, result uintptr)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CString ¶
CString converts a Go string to a null-terminated byte slice. The caller must keep the slice alive during the C call and use &buf[0] as the pointer.
func LoadLibrary ¶
LoadLibrary loads the ALPM library. It's safe to call multiple times.
func PtrToString ¶
PtrToString converts a C string pointer to a Go string This function finds the null terminator to determine the length
func PtrToStringWithLen ¶
PtrToStringWithLen converts a C string pointer with known length to Go string
Types ¶
type FunctionCaller ¶
type FunctionCaller interface {
// GetFunc returns a function pointer by name
GetFunc(name string) (uintptr, error)
// CallFunc calls a function by name with the given arguments
CallFunc(name string, args ...uintptr) (uintptr, error)
}
FunctionCaller is an interface for calling C functions. This abstraction allows for mocking in unit tests.
type FunctionRegistry ¶
type FunctionRegistry struct {
// contains filtered or unexported fields
}
FunctionRegistry manages lazy loading of ALPM functions
func GetRegistry ¶
func GetRegistry() (*FunctionRegistry, error)
GetRegistry returns the global function registry
type MockFunctionRegistry ¶
type MockFunctionRegistry struct {
// contains filtered or unexported fields
}
MockFunctionRegistry is a mock implementation of FunctionCaller for testing.
func NewMockRegistry ¶
func NewMockRegistry() *MockFunctionRegistry
NewMockRegistry creates a new mock function registry.
func (*MockFunctionRegistry) CallFunc ¶
func (m *MockFunctionRegistry) CallFunc(name string, args ...uintptr) (uintptr, error)
CallFunc returns a mock result for the function call.
func (*MockFunctionRegistry) GetCallCount ¶
func (m *MockFunctionRegistry) GetCallCount(name string) int
GetCallCount returns how many times a function was called.
func (*MockFunctionRegistry) GetFunc ¶
func (m *MockFunctionRegistry) GetFunc(name string) (uintptr, error)
GetFunc returns a mock function pointer.
func (*MockFunctionRegistry) RegisterFunc ¶
func (m *MockFunctionRegistry) RegisterFunc(name string, ptr uintptr)
RegisterFunc registers a mock function pointer.
func (*MockFunctionRegistry) Reset ¶
func (m *MockFunctionRegistry) Reset()
Reset clears all mock data.
func (*MockFunctionRegistry) SetCallError ¶
func (m *MockFunctionRegistry) SetCallError(name string, err error)
SetCallError sets an error that CallFunc should return for a function.
func (*MockFunctionRegistry) SetCallResult ¶
func (m *MockFunctionRegistry) SetCallResult(name string, result uintptr)
SetCallResult sets the result that CallFunc should return for a function.