
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
github.com/mkrautz/macdriver
Native Mac APIs for Golang!
MacDriver is a toolkit for working with Apple/Mac APIs and frameworks in Go. It currently has 2 parts:
The objc
package wraps the Objective-C runtime to dynamically interact with Objective-C objects and classes:
cls := objc.NewClass("AppDelegate", "NSObject")
cls.AddMethod("applicationDidFinishLaunching:", func(app objc.Object) {
fmt.Println("Launched!")
})
objc.RegisterClass(cls)
delegate := objc.Get("AppDelegate").Alloc().Init()
app := objc.Get("NSApplication").Get("sharedApplication")
app.Set("delegate:", delegate)
app.Send("run")
The cocoa
, webkit
, and core
packages wrap objc
with wrapper types for parts of the Apple/Mac APIs. They're being added to as needed by hand until
we can automate this process with schema data. These packages effectively let you use Apple APIs as if they were native Go libraries, letting
you write Mac applications (potentially also iOS, watchOS, etc) as Go applications:
func main() {
app := cocoa.NSApp_WithDidLaunch(func(notification objc.Object) {
config := webkit.WKWebViewConfiguration_New()
wv := webkit.WKWebView_Init(core.Rect(0, 0, 1440, 900), config)
url := core.URL("http://progrium.com")
req := core.NSURLRequest_Init(url)
wv.LoadRequest(req)
w := cocoa.NSWindow_Init(core.Rect(0, 0, 1440, 900),
cocoa.NSClosableWindowMask|
cocoa.NSTitledWindowMask,
cocoa.NSBackingStoreBuffered, false)
w.SetContentView(wv)
w.MakeKeyAndOrderFront(w)
w.Center()
})
app.SetActivationPolicy(cocoa.NSApplicationActivationPolicyRegular)
app.ActivateIgnoringOtherApps(true)
app.Run()
}
examples/largetype - A Contacts/Quicksilver-style Large Type utility in under 80 lines:
examples/pomodoro - A menu bar pomodoro timer in under 80 lines:
examples/topframe - An always-on-top webview with transparent background in 120 lines [requires Go 1.16+]:
NEW: See progrium/topframe for a more fully-featured standalone version!
Eventually we can generate most of the wrapper APIs using bridgesupport and/or doc schemas. However, the number of APIs is pretty ridiculous so there are lots of edge cases I wouldn't know how to automate yet. We can just continue to create them by hand as needed until we have enough coverage/confidence to know how we'd generate wrappers.
The original objc
and variadic
packages were written by Mikkel Krautz. The variadic
package is some assembly magic to make everything possible since libobjc relies heavily on variadic function calls, which aren't possible out of the box in Cgo.
MIT
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.