Windows Runtime API(WinRT API)は、ここ最近のWindowsに追加された新しいAPIです。このAPIはC#などから使いやすいように出来ていて、一見.NETのマネージドコードのように見えます。しかし実際の所、COMをベースしたネイティブコードAPIでした。それならば、Goから呼び出せるのではないかと考えて試した内容が本記事になります。 go-ole GoにはCOMのライブラリとして有名なgo-oleがあります。その中を覗くとwinrt.goというファイルがあり、既にWinRTに対応済みでした。そのため、このgo-oleを使えばWinRT APIを呼び出すことができます。 APIの呼び出し 下記のコードはgo-oleを使用して、WinRT APIのWindows.Data.Json.JsonObjectを呼び出すメイン処理です(ソース全体はこちら)。この処理自体は、