GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - d1ss0nanz/go-xpc: Wrapper for Cocoa XPC Services written in Go

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
cocoa
cocoa
 
 
xpc
xpc
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

go-xpc

This borrows VERY VERY VERY heavily from the rpc package in http://golang.org/src/pkg/net/rpc/server.go

It relies on msgpack (github.com/ugorji/go/codec) for it's serialization.

Right now, I just threw this together from some of the other work I have been doing lately. It works, but it needs some love to be sure; bear with me.

There is a companion XPCConnection (Obj-C) (Swift doesn't have it's XPC stuff all there at the time of this writing).

Sample usage:

From Go:

package main

import (
    "fmt"
    "github.com/aventurella/go-xpc/xpc"
)

type Sample struct{}

func (s *Sample) Test(args *[]interface{}, reply *interface{}) error {
    fmt.Println("CALLED SAMPLE.TEST!!!")
    fmt.Println(args)
    return nil
}

func main() {
    sample := new(Sample)
    xpc.Register(sample)
    xpc.Start()
}

From Cocoa App (Swift):

import Cocoa

// @objc is required here.
@objc class Foo {

    func Bar(args: Array<AnyObject>){
        println("Bazzle Got Args: \(args)")
    }
}

// ... later in some func ...

func initializeXPCService(){
    connection = XPCConnection(name:"com.blitzagency.officebeats-api")
    connection.register(Foo())
    connection.resume()

    connection.call("Sample.Test", withArgs: [1,2,3]) {
        (value) -> () in
        println(value)
    }
}

you can even call back from your Go XPC Service into your app:

Building on the Go example above:

package main

import (
    "fmt"
    "github.com/aventurella/go-xpc/xpc"
)

type Sample struct{}

func (s *Sample) Test(args *[]interface{}, reply *interface{}) error {
    fmt.Println("CALLED SAMPLE.TEST!!!")
    fmt.Println(args)

    // Note that we MUST use selector style here,
    // aka: passingAnArgEndsWithAColon:
    //
    //-------------------------------------
        xpc.CallHost("Foo.Bar:", args)
    //-------------------------------------
    //

    return nil
}

func main() {
    sample := new(Sample)
    xpc.Register(sample)
    xpc.Start()
}

About

Wrapper for Cocoa XPC Services written in Go

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.