从GO读取MIDI输入

I would like to listen to incoming MIDI messages using my GO program. However, I can't make it work.

I've tried using midi libraries such as https://github.com/gomidi/midi, but I couldn't get it to work. There are no examples to be found and the documentation is unclear to me.

package main

import (
    "fmt"
    "io"

    "github.com/gomidi/midi"
    . "github.com/gomidi/midi/midimessage/channel" // (Channel Messages)
    "github.com/gomidi/midi/midimessage/realtime"
    "github.com/gomidi/midi/midireader"
)

func main() {
    var input io.Reader

    rthandler := func(m realtime.Message) {
        fmt.Printf("Realtime: %s
", m)
    }

    rd := midireader.New(input, rthandler)

    var m midi.Message
    var err error

    for {
        m, err = rd.Read()

        // breaking at least with io.EOF
        if err != nil {
            break
        }

        // inspect
        fmt.Println(m)

        switch v := m.(type) {
        case NoteOn:
            fmt.Printf("NoteOn at channel %v: key: %v velocity: %v
", v.Channel(), v.Key(), v.Velocity())
        case NoteOff:
            fmt.Printf("NoteOff at channel %v: key: %v
", v.Channel(), v.Key())
        }

    }

    if err != io.EOF {
        panic("error: " + err.Error())
    }
}

My goal is to be able to read (just printing when the midi message is received) the MIDI input for further processing.

Thanks in advance