Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package nslog
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Foundation
#import <Foundation/Foundation.h>
void Log(const char *text) {
NSString *nss = [NSString stringWithUTF8String:text];
NSLog(@"%@", nss);
import "C"
import (
type nslog struct{}
func New() io.Writer {
return new(nslog)
func (l *nslog) Write(p []byte) (n int, err error) {
msg := append(p[:], 0)
return len(p), nil
func (l *nslog) WriteString(s string) (n int, err error) {
cs := C.CString(s)
return len(s), nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment