How to send an interrupt signal

Assuming you are using something like this for capturing interrupt signal

var stopChan = make(chan os.Signal, 2)
signal.Notify(stopChan, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)

<-stopChan // wait for SIGINT

Use below from anywhere in your code to send interrupt signal to above wait part.

syscall.Kill(syscall.Getpid(), syscall.SIGINT)

Or if you are in the same package where where stopChan variable is defined. Thus making it accessible. You can do this.

stopChan <- syscall.SIGINT

Or you can define stopChan as a global variable (making the first letter in Capital letter will achieve the same), then you can send interrupt signal from a different package too.

Stopchan <- syscall.SIGINT

Get the process using FindProcess, StartProcess or some other means. Call Signal to send the interrupt:

 err := p.Signal(os.Interrupt)

This will send the signal to the target process (assuming the calling process has permission to do so) and invoke whatever signal handlers the target process may have for SIGINT.