Skip to content

Instantly share code, notes, and snippets.

@nhooyr
Created August 1, 2016 01:56
Show Gist options
  • Save nhooyr/314e8b5334639280095437230957a982 to your computer and use it in GitHub Desktop.
Save nhooyr/314e8b5334639280095437230957a982 to your computer and use it in GitHub Desktop.
package main
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa
#import <Cocoa/Cocoa.h>
int writeString(const char *data) {
@autoreleasepool {
[[NSPasteboard generalPasteboard] declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil];
[[NSPasteboard generalPasteboard] setString:[NSString stringWithUTF8String: data] forType:NSPasteboardTypeString];
}
return 0;
}
*/
import "C"
import "os"
func main() {
C.writeString(C.CString(os.Args[0]))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment