Categorygithub.com/mattetti/cocoa
repositorypackage
0.0.0-20180803235253-82a0d65036fb
Repository: https://github.com/mattetti/cocoa.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author

# README

GoDoc

Cocoa

Pure Go reimplementation of some Cocoa specific features.

Work in progress, this code is NOT production ready. There is a hight risk that it will erase all your data and might also make your pets sick!

Alias

Cocoa has a concept of alias which work a little bit like hard links but with more flexibility. Unfortunately this feature isn't exposed outside of Cocoa and while we could use cgo to generate a aliases, a pure Go solution has its advantages. This implementation is based on many guesses and can be seen as a hack. Use at your own risks.

if err := cocoa.Alias("source/path", "destination/path"); err != nil {
    panic(err)
}

Similar to the following Swift code:

import Foundation

var originalUrl = NSURL.fileURL(withPath: "source/path")
var aliasUrl = NSURL.fileURL(withPath: "destination/path")
var bookmarkData = try? originalUrl.bookmarkData(options: NSURL.BookmarkCreationOptions.suitableForBookmarkFile,
                                                 includingResourceValuesForKeys: nil, relativeTo: nil)
// URLBookmarkCreationSuitableForBookmarkFile
try? URL.writeBookmarkData(bookmarkData!, to: aliasUrl)

Check GoDoc for more information.